/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { try { $model = $this->loadModel($id); $model->scenario = "update"; $cmsFormater = new CmsFormatter(); $model->posted = $cmsFormater->formatDatePickerInput($model->posted); if (isset($_POST['ProOpportunity'])) { $model->attributes = $_POST['ProOpportunity']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess)); } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException("Exception " . print_r($e, true)); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { try { $model = $this->loadModel($id); if (!Listing::CanUpdateCompanyListing($model)) { $this->redirect(array('index')); } $model->scenario = 'UpdateListingCompany'; $cmsFormater = new CmsFormatter(); $model->dnc_expiry_date = $cmsFormater->formatDatePickerInput($model->dnc_expiry_date); if (isset($_POST['Listing'])) { $model->attributes = $_POST['Listing']; $model->validate(); if (!$model->hasErrors()) { Listing::SaveCompanyListing($model); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess)); } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException("Exception " . print_r($e, true)); } }
public function actionUpdateDefectStatus($id) { try { $model = ProReportDefect::model()->findByPk($id); if (is_null($model)) { throw new Exception('id not valid'); } $model->scenario = 'UpdateDefectStatus'; $this->layout = 'ajax'; $cmsFormater = new CmsFormatter(); $model->approved_date = $cmsFormater->formatDatePickerInput($model->approved_date); if (isset($_POST['ProReportDefect'])) { $attUpdate = array('status'); $model->attributes = $_POST['ProReportDefect']; if ($model->status == CmsFormatter::COMPLETE_REPORT) { $model->approved_by_complete = Yii::app()->user->id; $model->scenario = 'UpdateDefectStatusComplete'; $attUpdate[] = 'approved_by_complete'; $attUpdate[] = 'approved_date'; $attUpdate[] = 'remark'; } elseif ($model->status == CmsFormatter::PROGESS_REPORT) { $model->approved_by_progess = Yii::app()->user->id; $attUpdate[] = 'approved_by_progess'; } $model->validate(); if (!$model->hasErrors()) { $model->update($attUpdate); die('<script type="text/javascript">parent.$.fn.colorbox.close(); parent.$.fn.yiiGridView.update("pro-defect-grid");</script>'); } } $this->render('UpdateDefectStatus', array('model' => $model, 'actions' => $this->listActionsCanAccess)); } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException("Exception " . print_r($e, true)); } }
if (!isset($_GET['term']) || !Yii::app()->request->isAjaxRequest) { throw new CHttpException(404, "Invalid request"); } $criteria = new CDbCriteria(); // $criteria->addNotInCondition(" t.role_id", array(ROLE_ADMIN, ROLE_MANAGER)); $criteria->addInCondition(" t.role_id", array(ROLE_AGENT)); $criteria->addSearchCondition('CONCAT(t.first_name, t.last_name)', $_GET['term'], true); // true ==> LIKE '%...%' if (isset($_GET['id'])) { $criteria->addNotInCondition(" t.id", array($_GET['id'])); } $criteria->limit = 30; $models = Users::model()->findAll($criteria); $returnVal = array(); $cmsFormat = new CmsFormatter(); foreach ($models as $model) { $label = $cmsFormat->formatFullNameRegisteredUsers($model); $returnVal[] = array('label' => $label, 'value' => $label, 'id' => $model->id, 'row_class_id' => "row_class_id{$model->id}", 'full_name' => $label, 'nric_passportno_roc' => $model->nric_passportno_roc, 'address' => $model->address, 'postal_code' => $model->postal_code, 'commission_schema_id' => isset($model->rCommissionSchema) ? $model->rCommissionSchema->percent : 0); } echo CJSON::encode($returnVal); Yii::app()->end(); } /**
public function actionUpdateVoucher($id) { $model = MyFormat::loadModelByClass($id, 'FiPaymentVoucher'); $cmsFormater = new CmsFormatter(); if ($model) { if (!FiPaymentVoucher::CanUpdate($model)) { $this->redirect(array('index')); } $model->scenario = 'update_voucher'; $dataTmp = ''; if (isset($_POST['FiPaymentVoucher'])) { $model->attributes = $_POST['FiPaymentVoucher']; if ($model->validate()) { $statusTmp = MyFormat::loadModelByClass($id, 'FiPaymentVoucher'); if ($statusTmp->status != STATUS_ACTIVE && $model->status == STATUS_ACTIVE && empty($model->date_paid)) { $model->date_paid = date('Y-m-d'); } if ($model->save()) { //save detail FiPaymentVoucherDetail::saveDetailWithVoucherID($model->id, $_POST['FiPaymentVoucherDetail']); } $this->redirect(Yii::app()->createAbsoluteUrl('admin/fiInvoice/viewvoucher', array('id' => $id))); } } else { $model->created_date = date('d-m-Y', strtotime($model->created_date)); // $model->date_paid = ($model->date_paid !='' && $model->date_paid !='0000-00-00') ? date('d-m-Y',strtotime($model->date_paid)) : date('d-m-Y'); $model->date_paid = $cmsFormater->formatDatePickerInput($model->date_paid); $dataTmp = FiPaymentVoucherDetail::getDataWithWithVoucherID($id); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } $this->render('payment_voucher', array('actions' => $this->listActionsCanAccess, 'model' => $model, 'dataTmp' => $dataTmp)); }