/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new AttendancePresencesRecap();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['AttendancePresencesRecap'])) {
         $model->attributes = $_POST['AttendancePresencesRecap'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 public function afterSave()
 {
     $recap = AttendancePresencesRecap::model()->findByAttributes(array('date' => $this->date, 'employee_id' => $this->employee_id));
     if (!isset($recap)) {
         $recap_new = new AttendancePresencesRecap();
         $recap_new->employee_id = $this->employee_id;
         $recap_new->shift_id = $this->shift_id;
         $recap_new->date = $this->date;
         $recap_new->location_id = $this->location_id;
         $recap_new->type = 'CI';
         if ($this->type == 'CI') {
             $recap_new->check_in = $this->presence_date;
         }
         if ($this->type == 'BO') {
             $recap_new->break_out = $this->presence_date;
         }
         if ($this->type == 'BI') {
             $recap_new->break_in = $this->presence_date;
         }
         if ($this->type == 'CO') {
             $recap_new->check_out = $this->presence_date;
         }
         $recap_new->save();
     } else {
         if ($this->type == 'CI') {
             $recap->check_in = $this->presence_date;
         }
         if ($this->type == 'BO') {
             $recap->break_out = $this->presence_date;
         }
         if ($this->type == 'BI') {
             $recap->break_in = $this->presence_date;
         }
         if ($this->type == 'CO') {
             $recap->check_out = $this->presence_date;
         }
         $recap->save();
     }
 }
 public function actionBeritaacara_approve($id)
 {
     $request = AttendancePresencesRequest::model()->findByPk($id);
     $request->approved_by = 'admin';
     $request->status = 'approved';
     $recap = AttendancePresencesRecap::model()->findByAttributes(array('employee_id' => $request->employee_id, 'date' => $request->date, 'location_id' => $request->location_id));
     if (count($recap) != 0) {
         $recap->check_in = $request->check_in;
         $recap->check_out = $request->check_out;
         $recap->break_out = $request->break_out;
         $recap->break_in = $request->break_in;
         $recap->save();
     } else {
         $recap = new AttendancePresencesRecap();
         $recap->employee_id = $request->employee_id;
         $recap->shift_id = $request->shift_id;
         $recap->date = $request->date;
         $recap->type = $request->type;
         $recap->check_in = $request->check_in;
         $recap->check_out = $request->check_out;
         $recap->break_out = $request->break_out;
         $recap->break_in = $request->break_in;
         $recap->location_id = $request->location_id;
         $recap->type = 'CI';
         $recap->save();
     }
     $request->save();
     $this->render('beritaacara_view', array('model' => $request));
 }
 public function afterSave()
 {
     if ($this->status == 'approved') {
         $recap = new AttendancePresencesRecap();
         $recap->employee_id = $this->employee_id;
         $recap->shift_id = $this->shift_id;
         $recap->date = $this->date;
         $recap->location_id = $this->location_id;
         $recap->type = 'OFF';
         if (!$recap->save()) {
             print_r($recap->errors);
             die;
         }
         $this->sendMail('template_attendance_off_approve');
     } elseif ($this->status == 'saved') {
         $this->sendMail('template_attendance_off_request');
     } elseif ($this->status == 'rejected') {
         $this->sendMail('template_attendance_off_reject');
     }
 }
Ejemplo n.º 5
0
 public function savePresence()
 {
     $long_date = strtotime($this->end_date) - strtotime($this->start_date);
     $count_day = $long_date / 86400;
     for ($i = 0; $i <= $count_day; $i++) {
         $date = strtotime($this->start_date) + 86400 * $i;
         $presence = new AttendancePresencesRecap();
         $presence->employee_id = $this->employee_id;
         $presence->date = date('Y-m-d', $date) . "<br>";
         if ($this->type == 'Normal') {
             $presence->type = 'P';
             $presence->permit = date('Y-m-d');
         } elseif ($this->type == 'Sick') {
             if ($this->doctor_note == 1) {
                 $presence->type = 'S';
                 $presence->sick = date('Y-m-d');
             } elseif ($this->doctor_note == 0) {
                 $presence->type = 'SN';
                 $presence->sickwithoutmail = date('Y-m-d');
             }
         }
         $presence->save();
     }
 }