Esempio n. 1
0
 public function actionStationTypeDataExport()
 {
     /** @var ScheduleReport $form */
     /** @var ScheduleReportDestination[] $forms_d] */
     if (Yii::app()->request->isPostRequest) {
     }
     TimezoneWork::set('UTC');
     if (isset($_REQUEST['ex_schedule_id']) and (int) $_REQUEST['ex_schedule_id'] and isset($_REQUEST['active'])) {
         $scheduleTypeReportForm = ScheduleTypeReport::model()->findByPk(intval($_REQUEST['ex_schedule_id']));
         $scheduleTypeReportForm->setAttribute('active', $_REQUEST['active']);
         $scheduleTypeReportForm->save();
     }
     $scheduleTypeReportForm = new ScheduleTypeReport();
     if (isset($_REQUEST['ex_delete_id'])) {
         $scheduleTypeReportForm = ScheduleTypeReport::model()->findByPk(intval($_REQUEST['ex_delete_id']));
         if ($scheduleTypeReportForm && $scheduleTypeReportForm->delete()) {
             It::memStatus('schedule_deleted');
             $this->redirect($this->createUrl('site/StationTypeDataExport'));
         }
     }
     //		if (isset($_REQUEST['resend_schedule_id'])) {
     //            $form = ScheduleTypeReport::model()->findByPk(intval($_REQUEST['resend_schedule_id']));
     //        }
     if (isset($_REQUEST['ex_schedule_id']) and (int) $_REQUEST['ex_schedule_id'] and !isset($_REQUEST['active'])) {
         $scheduleTypeReportForm = ScheduleTypeReport::model()->findByPk(intval($_REQUEST['ex_schedule_id']));
     }
     if (isset($scheduleTypeReportForm)) {
         $scheduleTypeReportDestination = ScheduleTypeReportDestination::model()->findAllByAttributes(array('ex_schedule_id' => $scheduleTypeReportForm->ex_schedule_id));
     } else {
         $scheduleTypeReportDestination = array();
     }
     $valid = true;
     if (Yii::app()->request->isPostRequest && isset($_POST['ScheduleTypeReport'])) {
         $scheduleTypeReportForm->attributes = $_POST['ScheduleTypeReport'];
         $valid = $valid & $scheduleTypeReportForm->validate();
         if (isset($_POST['ScheduleTypeReportDestination'])) {
             foreach ($_POST['ScheduleTypeReportDestination'] as $key => $value) {
                 if ($value['ex_schedule_destination_id']) {
                     $scheduleTypeReportDestination[$key] = ScheduleTypeReportDestination::model()->findByPk($value['ex_schedule_destination_id']);
                 } else {
                     $scheduleTypeReportDestination[$key] = new ScheduleTypeReportDestination();
                 }
                 $scheduleTypeReportDestination[$key]->attributes = $value;
                 $valid = $valid & $scheduleTypeReportDestination[$key]->validate();
             }
         }
         if ($valid) {
             // $scheduleTypeReportForm->scenario='admin';
             $scheduleTypeReportForm->save(false);
             foreach ($scheduleTypeReportDestination as $key => $value) {
                 $scheduleTypeReportDestination[$key]->ex_schedule_id = $scheduleTypeReportForm->ex_schedule_id;
                 $scheduleTypeReportDestination[$key]->save();
             }
             //                foreach ($forms_s as $key => $value) {
             //                    $forms_s[$key]->schedule_id = $form->schedule_id;
             //                    $forms_s[$key]->save();
             //                }
             It::memStatus($scheduleTypeReportForm->isNewRecord ? 'schedule_added' : 'schedule_updated');
             $this->redirect($this->createUrl('site/StationTypeDataExport'));
         }
     }
     $str = new ScheduleTypeReport();
     $scheduleTypeReportProcessed = new ScheduleTypeReportProcessed();
     $scheduleTypesReports = $str->getList(10);
     $this->render('schedule_type_report', array('forms_d' => $scheduleTypeReportDestination, 'scheduleTypeReportForm' => $scheduleTypeReportForm, 'scheduleTypesReports' => $scheduleTypesReports, 'scheduleTypeReportProcessed' => $scheduleTypeReportProcessed));
 }
 public static function getList($ex_schedule_id)
 {
     return ScheduleTypeReportDestination::model()->findAllByAttributes(array('ex_schedule_id' => $ex_schedule_id));
 }
Esempio n. 3
0
 public function actionDeleteScheduleTypeDestination()
 {
     $ex_schedule_id = isset($_REQUEST['sid']) ? intval($_REQUEST['sid']) : null;
     $destination_id = isset($_REQUEST['did']) ? intval($_REQUEST['did']) : null;
     $return = array('ok' => 0);
     if ($ex_schedule_id && $destination_id) {
         $res = ScheduleTypeReportDestination::model()->deleteAllByAttributes(array('ex_schedule_id' => $ex_schedule_id, 'ex_schedule_destination_id' => $destination_id));
         if ($res) {
             $return['ok'] = 1;
         }
     }
     print json_encode($return);
     CApplication::end();
 }