Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.43 KB | None | 0 0
  1. /* MODEL --*/
  2.  
  3. class studentlaptop extends ActiveRecord
  4. {
  5.     public $firstName;
  6.     public $lastName;
  7.     public $jenzId;
  8.  
  9.     public function rules()
  10.     {
  11.         return [
  12.             [['firstName', 'lastName', 'jenzId'], 'safe'],
  13.             [['jenzId'], 'default'],
  14.             [['firstName'], 'validateAtLeastOne', 'skipOnEmpty' => true],
  15.         ];
  16.     }
  17.  
  18.     public function attributeLabels()
  19.     {
  20.         return [
  21.             'jenzId' => 'ID'
  22.         ];
  23.     }
  24.  
  25.     /**
  26.      * Validates that all search terms were provided.
  27.      * @param $attribute
  28.      * @param $params
  29.      */
  30.     public function validateAtLeastOne($attribute, $params)
  31.     {
  32.         if (empty($this->firstName) || empty($this->lastName) || empty($this->jenzId)) {
  33.             $this->addError('firstName', 'All search terms need to be provided.');
  34.             $this->addError('lastName');
  35.             $this->addError('jenzId');
  36.         }
  37.     }
  38.     public function findFirstnames()
  39.     {   $query = new Query();
  40.                 $query ->select('nm.id_num as JenzabarID,
  41.                 nm.first_name as [First Name],
  42.                 nm.last_name as [Last Name],
  43.                 dh.div_cde as [Current Degree],
  44.                 dh.MAJOR_1 as [Major],sm.MOST_RECNT_YR_ENR as [Recent Year Enrolled],
  45.                 sm.MOST_RECNT_TRM_ENR as [Recent Term Enrolled],sm.TRM_PT_FT_HRS as [Hours Enrolled],
  46.                 sm.TRM_PT_FT_STS as [Full or Part time],
  47.                 (Case c.candidacy_type
  48.                        When \'T\' then \'Y\'
  49.                        Else \'N\'
  50.                 End) as [Transfer Student]')
  51.                 ->from('name_master nm')
  52.                 ->leftJoin('student_master sm', 'nm.id_num=sm.id_num')
  53.                 ->leftJoin('degree_history dh', 'nm.id_num=dh.id_num')
  54.                 ->leftJoin('CANDIDACY c', 'nm.id_num=c.id_num');
  55.  
  56.             if (!empty($this->firstName)) {
  57.                     $query->where('LOWER(nm.first_name) LIKE :firstName', [':firstName' => '%' . strtolower($this->firstName) . '%']);
  58.                         }
  59.            if (!empty($this->lastName)) {
  60.                  $query->andwhere('LOWER(nm.last_name) LIKE :lastName', [':lastName' => '%' . strtolower($this->lastName) . '%']);
  61.                         }
  62.                 if (empty($this->jenzId)) {
  63.                             $query->andwhere(['nm.id_num'=> $this->jenzId]);
  64.                         }
  65.                         return $query->createCommand()->queryOne();
  66.         }
  67.  
  68. -----------------------
  69. <!-- View -->
  70.  
  71. <?php
  72. if (!empty($firstnames)) {
  73.     ?>
  74.     <div class="span12">
  75.         <h3>Student Standings</h3>
  76.  
  77.             <table width="100%">
  78.               <tr style="background:#ebebeb;">
  79.                 <th>ID Number</th>
  80.                 <th>Full Names</th>
  81.                 <th>Last Name</th>
  82.                 <th>Current Degree</th>
  83.                 <th>Major</th>
  84.                 <th>Recent Year Enrolled</th>
  85.                 <th>Recent Term Enrolled</th>
  86.                 <th>Hours Enrolled</th>
  87.                 <th>Full/Part Time</th>
  88.                 <th>Transfer Student</th>
  89.               </tr>
  90.                <tr style="border:1px solid #ccc; margin-bottom:20px;">
  91.                 <td><?= $firstnames['JenzabarID'] ?> </td>
  92.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['First Name'] ?> </td>
  93.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Last Name'] ?> </td>
  94.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Current Degree'] ?> </td>
  95.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Major'] ?> </td>
  96.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Recent Year Enrolled'] ?> </td>
  97.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Recent Term Enrolled'] ?> </td>
  98.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Hours Enrolled'] ?> </td>
  99.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Full or Part time'] ?> </td>
  100.                 <td style="border-left:1px solid #ccc;"><?= $firstnames['Transfer Student'] ?> </td>
  101.               </tr>
  102.             </table>
  103.  
  104.     </div>
  105.     <?php
  106. } else { ($firstnames !== false && empty($firstnames))
  107.     ?>
  108.     <div class="span6">
  109.         <h3>No Matching Account Found</h3>
  110.         <p>Please try your search again or call 414-277-7288 for further assistance.</p>
  111.     </div>
  112.     <?php
  113. }
  114. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement