Пример #1
0
 /**
  * Logout the current user and redirect to returnLogoutUrl.
  */
 public function actionLogout()
 {
     //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
     ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '2', NULL, NULL, NULL, NULL, NULL);
     Yii::app()->user->logout();
     $this->redirect(Yii::app()->controller->module->returnLogoutUrl);
 }
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     if ($_GET['find']) {
         if ($_GET['activity_type'] != NULL and $_GET['start_date'] == NULL and $_GET['end_date'] == NULL) {
             $type = $_GET['activity_type'];
             $criteria->condition = 'activity_type LIKE :type';
             $criteria->params[':type'] = $type;
         } elseif ($_GET['activity_type'] == NULL and $_GET['start_date'] != NULL and $_GET['end_date'] != NULL) {
             $start_date = date('Y-m-d', strtotime($_GET['start_date']));
             $end_date = date('Y-m-d', strtotime($_GET['end_date']));
             if ($start_date == $end_date) {
                 $criteria->condition = 'DATE(activity_time) LIKE :date';
                 $criteria->params[':date'] = $start_date;
             } else {
                 $criteria->condition = 'DATE(activity_time) BETWEEN :start_date AND :end_date';
                 $criteria->params[':start_date'] = $start_date;
                 $criteria->params[':end_date'] = $end_date;
             }
         } elseif ($_GET['activity_type'] == NULL and $_GET['start_date'] != NULL and $_GET['end_date'] == NULL) {
             $start_date = date('Y-m-d', strtotime($_GET['start_date']));
             $criteria->condition = 'DATE(activity_time) >= :date';
             $criteria->params[':date'] = $start_date;
         } elseif ($_GET['activity_type'] == NULL and $_GET['start_date'] == NULL and $_GET['end_date'] != NULL) {
             $end_date = date('Y-m-d', strtotime($_GET['end_date']));
             $criteria->condition = 'DATE(activity_time) <= :date';
             $criteria->params[':date'] = $end_date;
         } elseif ($_GET['activity_type'] != NULL and $_GET['start_date'] != NULL and $_GET['end_date'] != NULL) {
             $type = $_GET['activity_type'];
             $start_date = date('Y-m-d', strtotime($_GET['start_date']));
             $end_date = date('Y-m-d', strtotime($_GET['end_date']));
             $criteria->condition = 'activity_type LIKE :type';
             $criteria->params[':type'] = $type;
             if ($start_date == $end_date) {
                 $criteria->condition = $criteria->condition . ' AND DATE(activity_time) LIKE :date';
                 $criteria->params[':date'] = $start_date;
             } else {
                 $criteria->condition = $criteria->condition . ' AND DATE(activity_time) BETWEEN :start_date AND :end_date';
                 $criteria->params[':start_date'] = $start_date;
                 $criteria->params[':end_date'] = $end_date;
             }
         }
     }
     $total = ActivityFeed::model()->count($criteria);
     // Count feeds
     $pages = new CPagination($total);
     $pages->setPageSize(Yii::app()->params['listPerPage']);
     $pages->applyLimit($criteria);
     $feeds = ActivityFeed::model()->findAll($criteria);
     // Get feeds
     /*echo $pages->getCurrentPage().'-'.$pages->getPageCount().'---'.count($feeds).'....';
     		echo $total;exit;*/
     $this->render('index', array('feeds' => $feeds, 'type' => $type, 'start_date' => $_GET['start_date'], 'end_date' => $_GET['end_date'], 'pages' => $pages, 'criteria' => $criteria));
 }
Пример #3
0
 public function saveFeed($initiator_id, $activity_type, $goal_id, $goal_name, $field_name, $initial_field_value, $new_field_value)
 {
     $model = new ActivityFeed();
     $model->initiator_id = $initiator_id;
     $model->activity_type = $activity_type;
     $model->goal_id = $goal_id;
     $model->goal_name = $goal_name;
     $model->field_name = $field_name;
     $model->initial_field_value = $initial_field_value;
     $model->new_field_value = $new_field_value;
     $settings = UserSettings::model()->findByAttributes(array('user_id' => 1));
     if ($settings != NULL) {
         $timezone = Timezone::model()->findByAttributes(array('id' => $settings->timezone));
         date_default_timezone_set($timezone->timezone);
     }
     $model->activity_time = date('Y-m-d H:i:s');
     $model->save();
 }
Пример #4
0
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     if (Yii::app()->user->isGuest) {
         $model = new UserLogin();
         // collect user input data
         if (isset($_POST['UserLogin'])) {
             $model->attributes = $_POST['UserLogin'];
             // validate user input and redirect to previous page if valid
             if ($model->validate()) {
                 $this->lastViset();
                 //Yii::import('application.controllers.ActivityFeedController');
                 //SmsSettings::model()->sendSms($to,$from,$message); To call an action written on a controller
                 //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
                 ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '1', NULL, NULL, NULL, NULL, NULL);
                 $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
                 // check for single role
                 foreach ($roles as $role) {
                     if (sizeof($roles) == 1 and $role->name == 'Company') {
                         $this->redirect(array('/students'));
                     }
                 }
                 if (sizeof($roles) == 1 and $role->name == 'Trainee') {
                     $this->redirect(array('/students'));
                 }
                 if (sizeof($roles) == 1 and $role->name == 'Employee') {
                     $this->redirect(array('/students'));
                 }
                 if (Yii::app()->user->checkAccess('admin')) {
                     if (Yii::app()->user->returnUrl == '/index.php') {
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         $this->redirect(Yii::app()->user->returnUrl);
                     }
                 } else {
                     $this->redirect(array('/students'));
                 }
             }
         }
         // display the login form
         $this->render('/user/login', array('model' => $model));
     } else {
         $this->redirect(Yii::app()->controller->module->returnUrl);
     }
 }
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         $model = ExamScores::model()->findByAttributes(array('id' => $id));
         $student = Students::model()->findByAttributes(array('id' => $model->student_id));
         $student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name);
         $exam = Exams::model()->findByAttributes(array('id' => $model->exam_id));
         $subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id));
         $examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id));
         $batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id));
         $exam_name = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')';
         $goal_name = $student_name . ' for the exam ' . $exam_name;
         // we only allow deletion via POST request
         $this->loadModel($id)->delete();
         //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
         ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '22', $model->id, $goal_name, NULL, NULL, NULL);
         // we only allow deletion via POST request
         //$this->loadModel($id)->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
 public function actionAjax_delete()
 {
     $id = $_POST['id'];
     $deleted = $this->loadModel($id);
     $deleted_batch_id = $deleted->batch_id;
     // Saving the id of the batch that is going to be deleted.
     if ($deleted->delete()) {
         //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
         ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '13', $deleted_batch_id, ucfirst($deleted->name), NULL, NULL, NULL);
         // For SMS
         $sms_settings = SmsSettings::model()->findAll();
         $to = '';
         if ($sms_settings[0]->is_enabled == '1' and $sms_settings[5]->is_enabled == '1') {
             // Checking if SMS is enabled.
             $students = Students::model()->findAll("batch_id=:x", array(':x' => $deleted_batch_id));
             //Selecting students of the batch
             foreach ($students as $student) {
                 if ($student->phone1) {
                     // Checking if phone number is provided
                     $to = $student->phone1;
                 } elseif ($student->phone2) {
                     $to = $student->phone2;
                 }
                 if ($to != '') {
                     // Sending SMS to each student
                     $college = Configurations::model()->findByPk(1);
                     $from = $college->config_value;
                     $message = $deleted->name . ' is cancelled';
                     SmsSettings::model()->sendSms($to, $from, $message);
                 }
             }
         }
         // End For SMS
         // Delete Exam and exam score
         $exam = Exams::model()->findAllByAttributes(array('exam_group_id' => $id));
         //print_r($exam);
         foreach ($exam as $exam1) {
             $examscore = ExamScores::model()->findAllByAttributes(array('exam_id' => $exam1->id));
             foreach ($examscore as $examscore1) {
                 $examscore1->delete();
             }
             $exam1->delete();
         }
         // End Delete Exam and exam score
         echo json_encode(array('success' => true));
         exit;
     } else {
         echo json_encode(array('success' => false));
         exit;
     }
 }
 public function actionDeleteLeave()
 {
     $flag = true;
     $model = StudentAttentance::model()->findByAttributes(array('id' => $_REQUEST['id']));
     $attendance = StudentAttentance::model()->DeleteAllByAttributes(array('id' => $_REQUEST['id']));
     $student = Students::model()->findByAttributes(array('id' => $model->student_id));
     $settings = UserSettings::model()->findByAttributes(array('user_id' => 1));
     if ($settings != NULL) {
         $date = date($settings->displaydate, strtotime($model->date));
     }
     //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
     ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '10', $model->student_id, ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name), $date, NULL, NULL);
     if ($flag) {
         Yii::app()->clientScript->scriptMap['jquery.js'] = false;
         $this->renderPartial('update', array('model' => $model, 'day' => $_GET['day'], 'month' => $_GET['month'], 'year' => $_GET['year'], 'emp_id' => $_GET['emp_id']), false, true);
     }
 }
Пример #8
0
 public function actionUpdate($id)
 {
     $model = ExamScores::model()->findByAttributes(array('id' => $id));
     $old_model = $model->attributes;
     // For activity feed
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ExamScores'])) {
         $model->attributes = $_POST['ExamScores'];
         $exam = Exams::model()->findByAttributes(array('id' => $_REQUEST['exam_id']));
         if ($model->marks < $exam->minimum_marks) {
             $model->is_failed = 1;
         } else {
             $model->is_failed = '';
         }
         if ($model->save()) {
             // Saving to activity feed
             $results = array_diff_assoc($model->attributes, $old_model);
             // To get the fields that are modified.
             foreach ($results as $key => $value) {
                 if ($key != 'updated_at') {
                     $student = Students::model()->findByAttributes(array('id' => $model->student_id));
                     $student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name);
                     $subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id));
                     $examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id));
                     $batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id));
                     $exam_name = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')';
                     $goal_name = $student_name . ' for the exam ' . $exam_name;
                     if ($key == 'is_failed') {
                         if ($value == 1) {
                             $value = 'Fail';
                         } else {
                             $value = 'Pass';
                         }
                         if ($old_model[$key] == 1) {
                             $old_model[$key] = 'Fail';
                         } else {
                             $old_model[$key] = 'Pass';
                         }
                     }
                     //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
                     ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '21', $model->id, $goal_name, $model->getAttributeLabel($key), $old_model[$key], $value);
                 }
             }
             //END saving to activity feed
             if ($_REQUEST['allexam'] == 1) {
                 $url = 'default/allexam';
             } else {
                 $url = 'default/classexam';
             }
             $this->redirect(array($url, 'bid' => $_REQUEST['bid'], 'exam_group_id' => $_REQUEST['exam_group_id'], 'r_flag' => $_REQUEST['r_flag'], 'exam_id' => $_REQUEST['exam_id']));
         }
     }
     $this->render('examination/examination', array('model' => $model));
 }
Пример #9
0
 function handler_rss($page, $user = null, $hash = null)
 {
     $feed = new ActivityFeed();
     return $feed->run($page, $user, $hash);
 }
Пример #10
0
 public function actionDeletes()
 {
     $model = Employees::model()->findByAttributes(array('id' => $_REQUEST['id']));
     $model->saveAttributes(array('is_deleted' => '1'));
     //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
     ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '25', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->middle_name) . ' ' . ucfirst($model->last_name), NULL, NULL, NULL);
     echo $val;
 }
 public function actionDeletes()
 {
     $model = Students::model()->findByAttributes(array('id' => $_REQUEST['sid']));
     $model->saveAttributes(array('is_deleted' => '1'));
     //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
     ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '7', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->middle_name) . ' ' . ucfirst($model->last_name), NULL, NULL, NULL);
     if ($model->uid and $model->uid != NULL and $model->uid != 0) {
         $user = User::model()->findByPk($model->uid);
         if ($user) {
             $profile = Profile::model()->findByPk($user->id);
             if ($profile) {
                 $profile->delete();
             }
             $user->delete();
         }
     }
     $guardian = Guardians::model()->findByAttributes(array('ward_id' => $_REQUEST['sid']));
     if ($guardian->uid and $guardian->uid != NULL and $guardian->uid != 0) {
         $parent_user = User::model()->findByPk($guardian->uid);
         if ($parent_user) {
             $profile = Profile::model()->findByPk($parent_user->id);
             if ($profile) {
                 $profile->delete();
             }
             $parent_user->delete();
         }
     }
     $examscores = ExamScores::model()->DeleteAllByAttributes(array('student_id' => $_REQUEST['sid']));
     $transactions = FinanceTransaction::model()->deleteAll('collection_id=:x', array(':x' => $_REQUEST['sid']));
     $this->redirect(array('/courses/batches/batchstudents', 'id' => $_REQUEST['id']));
 }
Пример #12
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         $model = Guardians::model()->findByAttributes(array('id' => $id));
         // we only allow deletion via POST request
         $this->loadModel($id)->delete();
         //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
         ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '16', $model->id, ucfirst($model->first_name) . ' ' . ucfirst($model->last_name), $model->getAttributeLabel($key), $old_model[$key], $value);
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }