Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* MODEL --*/
- class studentlaptop extends ActiveRecord
- {
- public $firstName;
- public $lastName;
- public $jenzId;
- public function rules()
- {
- return [
- [['firstName', 'lastName', 'jenzId'], 'safe'],
- [['jenzId'], 'default'],
- [['firstName'], 'validateAtLeastOne', 'skipOnEmpty' => true],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'jenzId' => 'ID'
- ];
- }
- /**
- * Validates that all search terms were provided.
- * @param $attribute
- * @param $params
- */
- public function validateAtLeastOne($attribute, $params)
- {
- if (empty($this->firstName) || empty($this->lastName) || empty($this->jenzId)) {
- $this->addError('firstName', 'All search terms need to be provided.');
- $this->addError('lastName');
- $this->addError('jenzId');
- }
- }
- public function findFirstnames()
- { $query = new Query();
- $query ->select('nm.id_num as JenzabarID,
- nm.first_name as [First Name],
- nm.last_name as [Last Name],
- dh.div_cde as [Current Degree],
- dh.MAJOR_1 as [Major],sm.MOST_RECNT_YR_ENR as [Recent Year Enrolled],
- sm.MOST_RECNT_TRM_ENR as [Recent Term Enrolled],sm.TRM_PT_FT_HRS as [Hours Enrolled],
- sm.TRM_PT_FT_STS as [Full or Part time],
- (Case c.candidacy_type
- When \'T\' then \'Y\'
- Else \'N\'
- End) as [Transfer Student]')
- ->from('name_master nm')
- ->leftJoin('student_master sm', 'nm.id_num=sm.id_num')
- ->leftJoin('degree_history dh', 'nm.id_num=dh.id_num')
- ->leftJoin('CANDIDACY c', 'nm.id_num=c.id_num');
- if (!empty($this->firstName)) {
- $query->where('LOWER(nm.first_name) LIKE :firstName', [':firstName' => '%' . strtolower($this->firstName) . '%']);
- }
- if (!empty($this->lastName)) {
- $query->andwhere('LOWER(nm.last_name) LIKE :lastName', [':lastName' => '%' . strtolower($this->lastName) . '%']);
- }
- if (empty($this->jenzId)) {
- $query->andwhere(['nm.id_num'=> $this->jenzId]);
- }
- return $query->createCommand()->queryOne();
- }
- -----------------------
- <!-- View -->
- <?php
- if (!empty($firstnames)) {
- ?>
- <div class="span12">
- <h3>Student Standings</h3>
- <table width="100%">
- <tr style="background:#ebebeb;">
- <th>ID Number</th>
- <th>Full Names</th>
- <th>Last Name</th>
- <th>Current Degree</th>
- <th>Major</th>
- <th>Recent Year Enrolled</th>
- <th>Recent Term Enrolled</th>
- <th>Hours Enrolled</th>
- <th>Full/Part Time</th>
- <th>Transfer Student</th>
- </tr>
- <tr style="border:1px solid #ccc; margin-bottom:20px;">
- <td><?= $firstnames['JenzabarID'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['First Name'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Last Name'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Current Degree'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Major'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Recent Year Enrolled'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Recent Term Enrolled'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Hours Enrolled'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Full or Part time'] ?> </td>
- <td style="border-left:1px solid #ccc;"><?= $firstnames['Transfer Student'] ?> </td>
- </tr>
- </table>
- </div>
- <?php
- } else { ($firstnames !== false && empty($firstnames))
- ?>
- <div class="span6">
- <h3>No Matching Account Found</h3>
- <p>Please try your search again or call 414-277-7288 for further assistance.</p>
- </div>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement