コード例 #1
0
 public function actionEdit($id)
 {
     /** @var $model Note */
     $model = Note::model()->findByPk($id, array('with' => 'changes'));
     $this->layout = '//layouts/new/popup';
     if (isset($_POST['delete']) || isset($_POST['restore'])) {
         $model->not_status = isset($_POST['delete']) ? 'Deleted' : 'Active';
         if ($model->save()) {
             if (isset($_POST['delete'])) {
                 Yii::app()->user->setFlash('note-deleted', 'Note is deleted!');
             } else {
                 Yii::app()->user->setFlash('note-restored', 'Note is restored!');
             }
             Yii::app()->user->setFlash('note-callback', isset($_GET['callback']) ? $_GET['callback'] : "");
             $this->redirect(array('Edit', 'id' => $id, 'callback' => isset($_GET['callback']) ? $_GET['callback'] : "", 'close' => isset($_POST['close']) ? true : false));
         }
     } elseif (isset($_POST['Note'])) {
         $model->attributes = $_POST['Note'];
         if ($model->save()) {
             Yii::app()->user->setFlash('note-updated', 'Saved!');
             Yii::app()->user->setFlash('note-callback', isset($_GET['callback']) ? $_GET['callback'] : "");
             $this->redirect(array('Edit', 'id' => $id, 'callback' => isset($_GET['callback']) ? $_GET['callback'] : "", 'close' => isset($_POST['close']) ? true : false));
         }
     }
     if (Yii::app()->user->hasFlash('note-callback')) {
         $callback = Yii::app()->user->getFlash('note-callback');
         $callback = new PopupCallback($callback);
         $callback->run(array($model->not_id), isset($_GET['close']) && $_GET['close']);
     }
     $this->render('edit', ['model' => $model]);
 }
コード例 #2
0
 public function edit(Branch $model)
 {
     if (isset($_POST['Branch']) && $_POST['Branch']) {
         $model->attributes = $_POST['Branch'];
         if ($model->save()) {
             $params = ['id' => $model->bra_id];
             $params['close'] = false;
             if (isset($_POST['close'])) {
                 $params['close'] = true;
             }
             if (isset($_GET['callback']) && $_GET['callback']) {
                 Yii::app()->user->setFlash('branch-callback', true);
                 $params['callback'] = $_GET['callback'];
             }
             Yii::app()->user->setFlash('branch-update-success', 'Branch info updated');
             $this->redirect($this->createUrl('Update', $params));
         }
     }
     if (Yii::app()->user->getFlash('branch-callback')) {
         $callback = new PopupCallback($_GET['callback']);
         $callback->run([$model->bra_id], isset($_GET['close']) && $_GET['close']);
     } elseif (isset($_GET['close']) && $_GET['close']) {
         echo '<script>window.close();</script>';
     }
     $this->render('edit', array('model' => $model));
 }
コード例 #3
0
 private function edit(Offer $model)
 {
     if (isset($_POST['restore'])) {
         if ($model->restore()) {
             Yii::app()->user->setFlash('offer-restored', 'Offer is restored!');
         }
     }
     if (isset($_POST['delete'])) {
         $model->deactivate();
     }
     if ($model->off_status == Offer::STATUS_DELETED) {
         // status becomes read-only. until restored
         unset($_POST['Offer']['off_status']);
     }
     if (isset($_POST['Offer']) && $_POST['Offer']) {
         $model->attributes = $_POST['Offer'];
         if (isset($_POST['client']) && $_POST['client']) {
             $model->setClients($_POST['client']);
         }
         if ($model->save()) {
             if ($_POST['clientStatus']) {
                 foreach ($model->clients as $client) {
                     $client->cli_salestatus = $_POST['clientStatus'];
                     $client->save();
                 }
             }
             Yii::app()->user->setFlash('offer-success', 'Offer is saved!');
             $this->redirect(['update', 'id' => $model->off_id, 'popup' => $this->popupMode, 'callback' => isset($_GET['callback']) ? $_GET['callback'] : ""]);
         }
     }
     if (isset($_GET['callback']) && $_GET['callback']) {
         $callback = new PopupCallback($_GET['callback']);
         $callback->run([], isset($_POST['close']));
     } else {
         if (isset($_POST['close'])) {
             echo '<script type="text/javascript">window.close()</script>';
             Yii::app()->end();
         }
     }
     $this->render('edit', array('model' => $model));
 }