public function actionIndex() { // Обработка формы календаря $data = array('person' => array('fname' => '', 'lname' => '', 'sex' => 'f', 'date' => '', 'hour' => -1, 'minute' => -1, 'notime' => true, 'city' => '', 'city_id' => 0), 'event' => array('date' => '', 'hour' => -1, 'minute' => -1, 'notime' => true, 'city' => '', 'city_id' => 0)); $templateData = array('data' => $data); // Запуск калькулятора if (isset($_GET['data'])) { // Обработка данных персоны $data = $_GET['data']; $this->_processingData($data['person']); $this->_processingData($data['event']); // Калькулятор $calendar = new Calendar($data); if ($calendar->validate()) { // Запуск расчета $calendar->run(); // Вывод в шаблон $this->render('chart', array('data' => $data, 'calendar' => $calendar)); Yii::app()->end(); } else { $templateData['person_errors'] = $calendar->getErrors('person'); $templateData['event_errors'] = $calendar->getErrors('event'); } } // Вывод в шаблон $this->render('index', $templateData); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Calendar'])) { $pn = Project::model()->findByPk($_POST['Calendar']['project_id'])->project_name; $model = new Calendar(); $model->attributes = $_POST['Calendar']; $model->description = $_POST['Calendar']['description'] . " of"; if ($model->save()) { echo "sukses"; } else { print_r($model->getErrors()); } // $this->redirect(array('view','id'=>$model->id)); } // $this->render('create',array( // 'model'=>$model, // )); }
public function actionCreate() { // echo "masuk"; $transaction = Yii::app()->db->beginTransaction(); try { $model = new Project(); if (isset($_POST['Project'])) { $id = Yii::app()->user->id; $model->scenario = "user_create"; $model->attributes = $_POST['Project']; $idm = Member::model()->find("email = '{$id}'")->id; $model->start_date = date('Y-m-d'); $model->id_member = $idm; $model->status = 1; // $this->redirect(array('client/index')); if ($model->save()) { $calendar = new Calendar(); $calendar->project_id = $model->id; $calendar->start_date = $model->start_date; $calendar->due_date = $_POST['Project']['due_date']; $calendar->description = $_REQUEST['descriptionca'] . " of "; $calendar->type = "due"; if ($calendar->save()) { $transaction->commit(); echo "sukses"; } else { echo json_encode($calendar->getErrors()); } } else { echo json_encode($model->getErrors()); } } else { echo "not isset"; } } catch (Exception $e) { $transaction->rollBack(); // other actions to perform on fail (redirect, alert, etc.) } }
/** * Подтверждает список операций */ function accept_all() { $ids = explode(',', @$_POST['ids']); $accepted_array = array(); foreach ($ids as $id) { if ((int) $id > 0) { $accepted_array[] = $id; } } if (count($accepted_array) > 0) { $calendar = new Calendar(Core::getInstance()->user); if ($calendar->acceptEvents($accepted_array)) { $this->tpl->assign('result', array('text' => 'Операции успешно подтверждены')); } else { $this->tpl->assign('error', array('text' => implode(",\n", $calendar->getErrors()))); } } else { $this->tpl->assign('error', array('text' => 'Не указаны операции для подтверждения!')); } }
public function actionCalendarChange() { $action = Yii::app()->request->getParam('action', ''); $date = Yii::app()->request->getParam('date', ''); $m = Yii::app()->request->getParam('m', ''); $returnArray = array(); $status = false; $switch = false; $msg = ''; $dateObject = DateTime::createFromFormat('Y-m-d', $date); if ($dateObject) { $modelDate = new DateTime($date); switch ($action) { case 'makeUnavailable': $switch = true; $modelStatus = 1; $modelType = 3; break; case 'makeAvailable': $switch = true; $modelStatus = 0; $modelType = 3; break; case 'removeFlag': $switch = true; $modelStatus = 0; $modelType = 1; break; case 'addFlag': $switch = true; $modelStatus = 1; $modelType = 1; break; } if ($switch) { $model = Calendar::model()->find('calendar_date = "' . $modelDate->format('Y-m-d H:i:s') . '" AND calendar_type = "' . $modelType . '" AND created_by = ' . Yii::app()->user->getInfo()); if ($model == null) { $model = new Calendar(); } $model->status = $modelStatus; $model->message = $m; $model->calendar_type = $modelType; $model->calendar_date = $modelDate->format('Y-m-d H:i:s'); $model->created_by = Yii::app()->user->getInfo(); if ($model->save()) { $status = true; $msg = 'Success'; } else { $msg = $model->getErrors(); } } } $returnArray['status'] = $status; $returnArray['msg'] = $msg; header('Content-Type: application/json'); $return = json_encode($returnArray); echo $return; Yii::app()->end(); }