Ejemplo n.º 1
0
 /**
  * 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)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Clients'])) {
         $model->attributes = $_POST['Clients'];
         if ($model->save()) {
             $cid = $model->id;
             foreach ($_FILES['afiles']['tmp_name'] as $key => $tmp_name) {
                 $afilesdesc = $_POST['afilesdesc'][$key];
                 $file_name = $_FILES['afiles']['name'][$key];
                 $file_tmp = $_FILES['afiles']['tmp_name'][$key];
                 if (!empty($file_name)) {
                     $nx = explode(".", $file_name);
                     $pname = $nx[0] . rand(1000, 999999999) . "." . pathinfo($file_name, PATHINFO_EXTENSION);
                     $file = Yii::app()->basePath . '/../uploads/images/' . $pname;
                     move_uploaded_file($file_tmp, $file);
                     $ca = new ClientAssessments();
                     $ca->client_id = $cid;
                     $ca->url = $pname;
                     $ca->description = $afilesdesc;
                     $ca->save();
                 }
             }
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ClientAssessments();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ClientAssessments'])) {
         $model->attributes = $_POST['ClientAssessments'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }