/**
  * Before save event
  */
 public function beforeSave()
 {
     if ($this->position == '') {
         $max = StorePaymentMethod::model()->orderByPositionDesc()->find();
         if ($max) {
             $this->position = (int) $max->position + 1;
         } else {
             $this->position = 0;
         }
     }
     return parent::beforeSave();
 }
 /**
  * Delete method
  * @param array $id
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = StorePaymentMethod::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $m) {
                 $m->delete();
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
 public function actionProcess()
 {
     if (Yii::app()->request->getParam('Shp_pmId')) {
         $_GET['payment_id'] = $_GET['Shp_pmId'];
     }
     $payment_id = (int) Yii::app()->request->getParam('payment_id');
     $model = StorePaymentMethod::model()->findByPk($payment_id);
     if (!$model) {
         throw new CHttpException(404, 'Ошибка');
     }
     $system = $model->getPaymentSystemClass();
     if ($system instanceof BasePaymentSystem) {
         $response = $system->processPaymentRequest($model);
         if ($response instanceof Order) {
             $this->redirect($this->createUrl('/cart/cart/view', array('key' => $response->key)));
         } else {
             throw new CHttpException(404, Yii::t('OrdersModule.core', 'Возникла ошибка при обработке запроса. <br> {err}', array('{err}' => $response)));
         }
     }
 }
 /**
  * Validate payment method exists
  * @param $attr
  * @return mixed
  */
 public function validatePaymentMethods($attr)
 {
     if (!is_array($this->{$attr})) {
         return;
     }
     foreach ($this->{$attr} as $id) {
         if (StorePaymentMethod::model()->countByAttributes(array('id' => $id)) == 0) {
             $this->addError($attr, Yii::t('StoreModule.core', 'Ошибка проверки способка оплаты.'));
         }
     }
 }
Exemple #5
0
<?php

/**
 * Delivery method sform
 */
return array('id' => 'deliveryUpdateForm', 'elements' => array('tab1' => array('type' => 'form', 'title' => '', 'elements' => array('name' => array('type' => 'text'), 'active' => array('type' => 'dropdownlist', 'items' => array(1 => Yii::t('StoreModule.admin', 'Да'), 0 => Yii::t('StoreModule.admin', 'Нет'))), 'price' => array('type' => 'text'), 'free_from' => array('type' => 'text'), 'description' => array('type' => 'SRichTextarea'), 'position' => array('type' => 'text', 'hint' => Yii::t('StoreModule.admin', 'Оставьте пустым для установки максимального значения')), 'payment_methods' => array('type' => 'checkboxlist', 'items' => CHtml::listData(StorePaymentMethod::model()->findAll(), 'id', 'name'))))));