示例#1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return RepairWork the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = RepairWork::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#2
0
 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
 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);
         }
     }
 }