コード例 #1
0
 /**
  * Manages all models.
  */
 public function admin()
 {
     $model = new Boxes('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Boxes'])) {
         $model->attributes = $_GET['Boxes'];
     }
     $this->_renderWrappedTemplate('homepagesettings', 'admin', array('model' => $model));
 }
コード例 #2
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, $boxId = null, $quantity = null)
 {
     $model = $this->loadModel($id);
     $Boxes = new Boxes('search');
     $Boxes->unsetAttributes();
     // clear any default values
     if (isset($_GET['Boxes'])) {
         $Boxes->attributes = $_GET['Boxes'];
     }
     if ($quantity) {
         $model->quantity = $quantity;
     }
     if ($boxId) {
         $items = new CActiveDataProvider('BoxItem', array('criteria' => array('condition' => 'box_id=' . (int) $boxId)));
         $SelectedBox = Box::model()->findByPk($boxId);
         $model->box_id = $boxId;
     } else {
         $items = new CActiveDataProvider('BoxItem', array('criteria' => array('condition' => 'box_id=' . $model->box_id)));
         $SelectedBox = $model->Box;
     }
     if (isset($_POST['UserBox'])) {
         $model->attributes = $_POST['UserBox'];
         $model->delivery_cost = $model->total_delivery_price;
         if ($model->save()) {
             $this->redirect(array('admin', 'id' => $model->user_box_id));
         }
     }
     $this->render('update', array('model' => $model, 'Boxes' => $Boxes, 'items' => $items, 'SelectedBox' => $SelectedBox));
 }