Пример #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 SparePartsOrder the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SparePartsOrder::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #2
0
 /**
  * Remove spareParts from an order and delete the model SparePartsOrder associated
  * with the spare_parts_id.
  * If removing is successful, the browser will be redirected to the same page.
  */
 public function actionRemove($spare_parts_id, $order_id)
 {
     $modelSparePartsOrder = SparePartsOrder::model()->findByPk($spare_parts_id);
     $modelSparePartsOrder->delete();
     $model = $this->loadModel($spare_parts_id);
     $model->assigned = 0;
     $model->save();
     // if AJAX request (triggered by activation via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('check', 'id' => $order_id));
     }
 }