/**
  * 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);
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['ProUploadDocument'])) {
             $model->attributes = $_POST['ProUploadDocument'];
             $new_file = CUploadedFile::getInstance($model, 'file_name');
             if ($model->validate()) {
                 if (!$model->getErrors()) {
                     if ($model->save()) {
                         if (!is_null($new_file)) {
                             $path = ProUploadDocument::$folderUpload . "/" . $model->user_id . "/";
                             ProUploadDocument::deleteOldFile($model, 'file_name', $path);
                             $model->file_name = $new_file;
                             $model->file_name = ProUploadDocument::saveFile($model, 'file_name', ProUploadDocument::$folderUpload, $model->order_no);
                             $model->update(array('file_name'));
                         }
                         $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));
     }
 }