public function loadReadNotice() { $res = array(); $list = StudentNotification::model()->findAll(array('limit'=>10, 'order'=>'student_notification_id desc','condition'=>'student_notification_to = :to AND student_notification_alert_after_date <= :afterdate AND student_notification_alert_before_date >= :beforedate', 'params'=> array(':to' => Yii::app()->user->getState('stud_id'), ':afterdate'=>date('Y-m-d'),':beforedate'=>date('Y-m-d')))); $menu = null; foreach($list as $notice) { $usertype=User::model()->findByPk($notice->student_notification_from)->user_type; $menu .= ($notice->student_notification_read == 1) ? '<div class="notify-data">' : '<div class="notify-data unread">'; if($usertype=="employee") { $tran=EmployeeTransaction::model()->findByAttributes(array('employee_transaction_user_id'=>$notice->student_notification_from)); $emp_model = EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id'=>$tran->employee_transaction_id)); $photo=EmployeePhotos::model()->findByPk($tran['employee_transaction_emp_photos_id']); $menu .= '<span class="userimage">'; if(file_exists(Yii::app()->baseUrl.'/college_data/emp_images/'.$photo->employee_photos_path)) $user_image = Yii::app()->baseUrl.'/college_data/emp_images/'.$photo->employee_photos_path; else $user_image = Yii::app()->baseUrl.'/college_data/emp_images/no-images'; $menu .= CHtml::image($user_image,"",array("width"=>"50px","height"=>"50px")); $menu .='</span><span class="username">'; $menu .= ucfirst(strtolower($emp_model->employee_first_name)).' '.ucfirst(strtolower($emp_model->employee_last_name)).'</span>'; } else { $user=User::model()->findByPk($notice->student_notification_from); $org=$user->user_organization_id; $name=$user->user_organization_email_id; $menu .= '<span class="userimage">'; $user_image = Yii::app()->baseUrl.'/college_data/emp_images/no-images'; $menu .= CHtml::image($user_image,'No Image',array('width'=>'50px','height'=>'50px')); $menu .='</span><span class="username">'; $menu .=ucfirst(strtolower(strstr($name,'@',true))); $menu .='</span>'; } $menu .='<div class="notificationlink">'; $menu .='<a href='.Yii::app()->request->baseUrl.'/notification/studentNotification/Read?id='.$notice->student_notification_id.'>'; $menu .=$notice->student_notification_title.'</a></div></div>'; } if(!empty($list)) $menu .='<span class="view-more-notice">'.CHtml::link('View More..','../notification/studentNotification/index').'</span>'; return $menu; }
public function actionAjaxRequest() { $res = array(); $list = StudentNotification::model()->findAll(array('condition'=>'student_notification_to = :to AND student_notification_alert_after_date <= :afterdate AND student_notification_alert_before_date >= :beforedate AND student_notification_read = :read', 'params'=> array(':to' => Yii::app()->user->getState('stud_id'), ':afterdate'=>date('Y-m-d'),':beforedate'=>date('Y-m-d'), ':read' => 0))); $res['count'] = count($list); $menu = null; foreach($list as $notice) { $menu .= '<div class="comment_ui">'; $menu .='<a href='.Yii::app()->request->baseUrl.'/notification/studentNotification/Read?id='.$notice->student_notification_id.'>'; $menu .='<div style="position: relative;cursor:pointer;">'; $menu .=$notice->student_notification_title.'</div></a></div>'; } $res['details'] = $menu; echo json_encode($res); }
public function actionDashboard() { if (!Yii::app()->user->isGuest) { if (Yii::app()->user->getState('parent_id')) { $this->redirect(array('parents/parent/studentprofile?id=' . Yii::app()->user->getState('stud_id'))); } if (Yii::app()->user->getState('emp_id')) { $read = array(); $unread = array(); $read = EmployeeNotification::loadReadNotice(); $count = count($read) + count($unread); $pages = new CPagination($count); $pages->pageSize = 10; $this->render('newdashboard', array('read' => $read, 'pages' => $pages)); } else { if (Yii::app()->user->getState('stud_id')) { $read = array(); $unread = array(); $read = StudentNotification::loadReadNotice(); $count = count($read) + count($unread); $pages = new CPagination($count); $pages->pageSize = 10; $this->render('newdashboard', array('read' => $read, 'pages' => $pages)); } else { $this->render('newdashboard'); } } } else { $this->redirect(array('login')); } }
?> <?php foreach ($notifiche as $notifica) { if ($notifica->isNotReaded()) { if ($notifica->employee_notification_type == "Leave") { $count1++; $lnotifications[$notifica->id] = $notifica->title; } else { $count++; $notifications[$notifica->id] = $notifica->title; } } } } if (Yii::app()->user->getState('stud_id')) { $notifiche = StudentNotification::model()->getAllNotifications(); ?> <?php $notifications = array(); ?> <?php $count = 0; ?> <?php foreach ($notifiche as $notifica) { ?> <?php if ($notifica->isNotReaded()) { ?> <?php $count++;