コード例 #1
0
 public function actionCreate()
 {
     $model = new Repair();
     $file = new FileOther('required');
     $model->personnel_id = Yii::app()->user->id;
     $model->create_at = date('Y-m-d H:i:s');
     $model->update_at = date('Y-m-d H:i:s');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Repair']) && isset($_POST['FileOther'])) {
         $model->attributes = $_POST['Repair'];
         $file->attributes = $_POST['FileOther'];
         $file->file = CUploadedFile::getInstance($file, 'file');
         if ($file->file != null) {
             $filename = time() . '.' . $file->file->getExtensionName();
             $file->file->saveAs(Yii::app()->params['pathUpload'] . $filename);
             $model->file = $filename;
         }
         $model->validate();
         $file->validate();
         if ($model->getErrors() == null && $file->getErrors() == null) {
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->repair_id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'file' => $file));
 }
コード例 #2
0
ファイル: RepairController.php プロジェクト: rodespsan/LMEC
 public function actionUpdateAjax($id)
 {
     $modelRepair = Repair::model()->find('order_id=:order_id', array(':order_id' => $id));
     if (empty($modelRepair)) {
         $modelRepair = new Repair();
         $modelRepair->order_id = $id;
     }
     if (isset($_POST['RepairWork'])) {
         $modelRepairWork = RepairWork::model()->find('repair_id=:repair_id AND work_id=:work_id', array(':repair_id' => $modelRepair->id, ':work_id' => $_POST['RepairWork']['work_id']));
         if (empty($modelRepairWork)) {
             $modelRepairWork = new RepairWork();
             $modelRepairWork->repair_id = $modelRepair->id;
             $modelRepairWork->user_id = Yii::app()->user->id;
             $modelRepairWork->date_hour = date('Y-m-d H:i:s');
             $modelRepairWork->work_id = $_POST['RepairWork']['work_id'];
             $modelRepairWork->validate();
             $modelRepairWork->save(false);
         }
     }
     if (isset($_POST['Repair'])) {
         $modelRepair->attributes = $_POST['Repair'];
         $modelRepair->save();
         if ($modelRepair->finished == 1) {
             $this->redirect(array('view', 'id' => $modelRepair->id));
         }
     }
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: rodespsan/LMEC
 public function actionCreateAccesoryOrder()
 {
     $modelRepair = Repair::model()->find('order_id=:order_id', array(':order_id' => $id));
     if (empty($modelRepair)) {
         $modelRepair = new Repair();
         $modelRepair->order_id = $id;
         $modelRepair->description = $_POST['Repair']['description'];
         $modelRepair->finished = $_POST['Repair']['finished'];
         $modelRepair->save();
     }
     if (isset($_POST['RepairWork'])) {
         $modelRepairWork = RepairWork::model()->find('repair_id=:repair_id AND work_id=:work_id', array(':repair_id' => $modelRepair->id, ':work_id' => $_POST['RepairWork']['work_id']));
         if (empty($modelRepairWork)) {
             $modelRepairWork = new RepairWork();
             $modelRepairWork->repair_id = $modelRepair->id;
             $modelRepairWork->user_id = Yii::app()->user->id;
             $modelRepairWork->date_hour = date('Y-m-d H:i:s');
             $modelRepairWork->work_id = $_POST['RepairWork']['work_id'];
             $modelRepairWork->validate();
             $modelRepairWork->save(false);
         }
     }
 }
コード例 #4
0
 public function postAddRepairHistory()
 {
     $property = Properties::find(Input::get('properties_id'));
     if (!$property) {
         App::abort(404);
     }
     $validator = Validator::make(Input::all(), ['transaction' => 'required|in:REPLACEMENT,ADDITION', 'details' => 'required|max:50', 'effectdate' => 'required|date_format:Y-m-d', 'cost' => 'required|numeric']);
     if ($validator->fails()) {
         return Redirect::route('add-repair-history', $property->id)->withErrors($validator)->withInput();
     }
     $repair = new Repair();
     $repair->transaction = Input::get('transaction');
     $repair->details = Input::get('details');
     $repair->effectdate = Input::get('effectdate');
     $repair->cost = Input::get('cost');
     $repair->property()->associate($property);
     $repair->save();
     return Redirect::route('repair-history', $property->id)->with('alert', 'success|Repair history entry created successfully.');
 }