public function actionBeritaacara_reject($id)
 {
     $request = AttendancePresencesRequest::model()->findByPk($id);
     $request->rejected_by = 'admin';
     $request->status = 'rejected';
     $request->save();
     $this->render('beritaacara_view', array('model' => $request));
 }
Ejemplo n.º 2
0
								<th width="10%"><?php 
echo at('Type');
?>
</th>
								<?php 
if (getUser()->role == 'admin') {
    ?>
<th width="10%"></th><?php 
}
?>
								
							</tr>
						</thead>
						<tbody>
						<?php 
$attendances = AttendancePresencesRequest::model()->findAllByAttributes(array('status' => 'saved'));
foreach ($attendances as $attendance) {
    $show = 0;
    if ($attendance->created_by == 'rm') {
        $show = 1;
    }
    if ($attendance->created_by == 'kadept') {
        $show = 1;
    }
    if ($attendance->approved_by == 'rm') {
        $show = 1;
    }
    if ($attendance->approved_by == 'kadept') {
        $show = 1;
    }
    $url = Yii::app()->createUrl('attendances/beritaacara_view&id=' . $attendance->id);
 public function actionBeritaacara()
 {
     $model = new AttendancePresencesRequest();
     $locations = CHtml::listData(MastersLocation::model()->findAll(), 'id', 'name');
     $request = 0;
     if (isset($_GET['id'])) {
         $attendance = $this->loadModel($_GET['id']);
         $attendances = AttendancePresencesRecap::model()->findAllByAttributes(array('employee_id' => $attendance->employee_id, 'date' => $attendance->date));
         $request = AttendancePresencesRequest::model()->findByAttributes(array('employee_id' => $attendance->employee_id));
         if (count($request) != 0) {
             if ($request->status == 'draft') {
                 $model = $request;
             } else {
                 $this->redirect(array('beritaacara_view', 'id' => $request->id));
             }
         }
         $locations = array();
         foreach ($attendances as $value) {
             $locations[$value->location_id] = $value->location->name;
         }
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['AttendancePresencesRequest'])) {
         if (isset($_POST['yt0']) or isset($_POST['yt1']) or isset($_POST['yt2'])) {
             $model->attributes = $_POST['AttendancePresencesRequest'];
             if (isset($_POST['yt1'])) {
                 $model->status = 'saved';
             }
             if (isset($_POST['yt0']) and $_POST['yt0'] == 'Save') {
                 $model->status = 'saved';
             }
             $model->attendance_id = $_POST['attendance_id'];
             $break_out = '00:00:00';
             $break_in = '00:00:00';
             if (isset($_POST['AttendancePresencesRequest']['break_out'])) {
                 $break_out = $_POST['AttendancePresencesRequest']['break_out'];
                 $break_in = $_POST['AttendancePresencesRequest']['break_in'];
             }
             $check_in = $_POST['AttendancePresencesRequest']['check_in'];
             $check_out = $_POST['AttendancePresencesRequest']['check_out'];
             $date = $_POST['AttendancePresencesRequest']['date'];
             $model->check_in = $date . ' ' . $check_in;
             $model->check_out = $date . ' ' . $check_out;
             $model->break_out = $date . ' ' . $break_out;
             $model->break_in = $date . ' ' . $break_in;
             $model->created_by = getUser()->role;
             if ($model->save()) {
                 $this->redirect(array('beritaacara_view', 'id' => $model->id));
             } else {
                 print_r($model->errors);
             }
         } else {
             $attendance = AttendancePresencesRecap::model()->findByAttributes(array('employee_id' => $_POST['AttendancePresencesRequest']['employee_id'], 'date' => $_POST['AttendancePresencesRequest']['date'], 'location_id' => $_POST['AttendancePresencesRequest']['location_id']));
         }
     }
     if (isset($attendance)) {
         if (count($request) == 0) {
             $model->attributes = $attendance->attributes;
         }
         if (isset($_GET['request'])) {
             $model = AttendancePresencesRequest::model()->findByPk($_GET['request']);
         }
         $model->check_in = substr($model->check_in, 10);
         $model->break_out = substr($model->break_out, 10);
         $model->break_in = substr($model->break_in, 10);
         $model->check_out = substr($model->check_out, 10);
         if ($model->check_in == null) {
             $model->check_in = '00:00:00';
         }
         if ($model->break_out == null) {
             $model->break_out = '00:00:00';
         }
         if ($model->break_in == null) {
             $model->break_in = '00:00:00';
         }
         if ($model->check_out == null) {
             $model->check_out = '00:00:00';
         }
     }
     $attendance_id = 0;
     if (isset($_GET['id'])) {
         $attendance_id = $_GET['id'];
     }
     $this->render('beritaacara', array('model' => $model, 'locations' => $locations, 'attendance_id' => $attendance_id));
 }