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']); $request = AttendancePresencesRequest::model()->findByAttributes(array('attendance_id' => $_GET['id'])); if (isset($attendance)) { $attendances = AttendancePresencesRecap::model()->findAllByAttributes(array('employee_id' => $attendance->employee_id, 'date' => $attendance->date)); } else { $attendances = AttendancePresencesRecap::model()->findAllByAttributes(array('employee_id' => $request->employee_id, 'date' => $request->date)); } if (count($request) != 0) { if ($request->status == 'draft' and $request->created_by = 'rm') { $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)); }
echo CHtml::activeTextField($model, 'date', array('class' => 'validate[required] form-control datepicker', 'data-date-format' => 'yyyy-mm-dd')); ?> </div> <?php echo CHtml::error($model, 'date'); ?> </div> </div> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'location_id', array('class' => $label_class)); ?> <div class="col-md-6 col-xs-12"> <?php echo CHtml::activeDropDownList($model, 'location_id', CHtml::listData(MastersLocation::model()->findAll(), 'id', 'name'), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'data-live-search' => 'true', 'class' => 'validate[required] form-control select')); ?> <?php echo CHtml::error($model, 'location_id'); ?> </div> </div> </div> <?php echo CHtml::hiddenField('action', '', array('id' => 'action')); ?> <div class="panel-footer"> <?php