/**
  * 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 = ProReportDefect::model()->findByPk($id);
         if (is_null($model)) {
             throw new Exception('id not valid');
         }
         $model->scenario = 'update';
         //            $model->created_date =  MyFormat::InvoiceDateDbDateToShowDate($model->created_date);
         $oldImage = $model->photo;
         $this->layout = 'ajax';
         if (isset($_POST['ProReportDefect'])) {
             $model->attributes = $_POST['ProReportDefect'];
             $model->photo = CUploadedFile::getInstance($model, 'photo');
             if ($model->save()) {
                 if (!is_null($model->photo)) {
                     ProReportDefect::save_photo($model);
                 } else {
                     $model->photo = $oldImage;
                     $model->update(array('photo'));
                 }
                 die('<script type="text/javascript">parent.$.fn.colorbox.close(); parent.$.fn.yiiGridView.update("pro-defect-grid");</script>');
             }
         }
         $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));
     }
 }
示例#2
0
                     }
                 }
             }
         }
         $this->render('member/upload', array('model' => $model));
     } catch (Exception $exc) {
         throw new CHttpException(404, $exc->getMessage());
     }
 }
 /**
  * <Jason>
  * <To added a report into gridview in tenancy details page>
  */
 public function actionAddReport()
 {
     try {
         $aRoleRestrict = array(ROLE_LANDLORD);
         if (in_array(Yii::app()->user->role_id, $aRoleRestrict)) {
             die;
         }
         $model = new ProReportDefect('create');
         if (isset($_POST['ProReportDefect'])) {
             $model->attributes = $_POST['ProReportDefect'];
             $model->transaction_id = $_GET['transaction_id'];
             $model->created_date = date('Y-m-d H:i:s');
             $model->photo = CUploadedFile::getInstance($model, 'photo');
             $model->status = 0;
             $model->user_id = Yii::app()->user->id;
             if ($model->validate()) {
                 if (!$model->getErrors()) {
                     if ($model->save()) {
                         ProReportDefect::save_photo($model);