public function actionEditProcess() { try { $post = StringHelper::filterArrayString($_POST); $result = Documentary::model()->edit($_POST); if ($result == 1) { Yii::app()->user->setFlash('success', 'Cập nhật dữ liệu thành công !'); $this->redirect(Yii::app()->createUrl('documentary/edit', array('id' => $post['id']))); } else { if ($result == 2) { Yii::app()->user->setFlash('error', 'Cập nhật dữ liệu thất bại !'); $this->redirect(Yii::app()->createUrl('documentary/edit', array('id' => $post['id']))); } else { Yii::app()->user->setFlash('error', 'Không tồn tại tài liệu !'); $this->redirect(Yii::app()->createUrl('documentary/edit', array('id' => $post['id']))); } } } catch (Exception $ex) { var_dump($ex->getMessage()); } }
public function actionPrintArea() { $documentary = Documentary::model()->searchByCondition($_GET, null, 2); $wanted_abroad = WantedAbroad::model()->searchByCondition($_GET, null, 2); $letters = Letters::model()->searchByCondition($_GET, null, 2); $cases = Cases::model()->searchByCondition($_GET, null, 2); $cases_abroad = CasesAbroadOther::model()->searchByCondition($_GET, null, 2); $opinion = Opinion::model()->searchByCondition($_GET, null, 2); $documentary_recieve = DocumentaryRecieve::model()->searchByCondition($_GET, null, 2); $documentary_abroad = DocumentaryAbroad::model()->searchByCondition($_GET, null, 2); $guide = Guide::model()->searchByCondition($_GET, null, 2); $result = array('documentary' => $documentary, 'wanted_abroad' => $wanted_abroad, 'letters' => $letters, 'cases' => $cases, 'cases_abroad' => $cases_abroad, 'opinion' => $opinion, 'documentary_recieve' => $documentary_recieve, 'documentary_abroad' => $documentary_abroad, 'guide' => $guide); $this->render('printArea', $result); }
public function searchByCondition($attr, $cnt = NULL, $pagination = 1) { $criteria = new CDbCriteria(); if (!empty($attr['date_start']) && !empty($attr['date_end'])) { // $date_start = strtotime($attr['date_start']); // $date_end = strtotime($attr['date_end']); // $criteria->addBetweenCondition('date_prosecution', $date_start, $date_end); } if (!empty($attr['obj_name'])) { $obj_name = $attr['obj_name']; $criteria->addSearchCondition('obj_name', $obj_name); } if (!empty($attr['nation'])) { $nation = $attr['nation']; $criteria->addSearchCondition('country', $nation); } if (!empty($attr['assignee'])) { $assignee = $attr['assignee']; $criteria->addSearchCondition('did_by', $assignee); } if (!empty($attr['keyword'])) { $keyword = $attr['keyword']; $criteria->addSearchCondition('shortcut', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('number', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('abstract', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('country', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('did_by', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('obj_name', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('number_doc_finish', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('number_doc_send', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('signed_user', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('reciever', $keyword, true, "OR", "LIKE"); } $count = Documentary::model()->count($criteria); if (!empty($cnt)) { return $count; } if ($pagination != 1) { $result = Documentary::model()->findAll($criteria); return $result; } $pages = new CPagination($count); // results per page $pages->pageSize = Yii::app()->params['limit']; $pages->applyLimit($criteria); $result = Documentary::model()->findAll($criteria); return array('models' => $result, 'pages' => $pages); }