Example #1
0
 public function cacheCreateFilter($models)
 {
     $array = array('stext');
     $r = $this->checkCacheSearchFields($array);
     if ($r === false) {
         false;
     }
     $returnArray = array();
     $systems = PSystem::model()->cache()->findAllInArray();
     foreach ($models as $k => $model) {
         $bool = true;
         if ($this->searchFields['stext']) {
             $string = $model['gateway_id'] . $model['alias'];
             $pos = strpos($string, $this->searchFields['stext']);
             if ($pos === false) {
                 $bool = false;
             }
         }
         if ($bool) {
             $model['system_name'] = isset($systems[$model['system_code']]['system_name']) ? $systems[$model['system_code']]['system_name'] : '';
             $returnArray[] = $model;
         }
     }
     return $returnArray;
 }
Example #2
0
 public function updateAction()
 {
     $model = new Gateway();
     $this->performAjaxValidation($model);
     // Uncomment the following line if AJAX validation is needed
     if (isset($_POST['model']) && $_POST['model'] == 'Gateway') {
         if (isset($_POST['ajax'])) {
             $model->fillFromArray($_POST, FALSE);
             $model->user_id_updated = $this->user->user_id;
             $model->updated = 'NOW():sql';
             $model->model_uset_id = $this->user->user_id;
             if ($model->save()) {
                 Message::echoJsonSuccess(__('gateway_updated'));
             } else {
                 Message::echoJsonError(__('gateway_no_updated'));
             }
             die;
         }
         $model->save();
         $this->redirect();
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->cache()->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $currencies = Currency::model()->cache()->findAllInArray();
     $methods = Method::model()->cache()->findAllInArray();
     $systems = PSystem::model()->cache()->findAllInArray();
     $gateways = Gateway::model()->cache()->findAllInArray();
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     $models = AFActiveDataProvider::models('GatewayLimit', $this->params, $pagination);
     $limits = $models->getLimitsByGatewayId($id);
     Assets::js('jquery.form');
     $this->addToPageTitle('Update Gateway');
     $this->render('update', array('model' => $model, 'currencies' => $currencies, 'limits' => $limits, 'methods' => $methods, 'systems' => $systems, 'gateways' => $gateways));
 }