Ejemplo n.º 1
0
 public function actionIndex()
 {
     $searchModel = new PaymentSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $paymentTypes = ArrayHelper::map(PaymentType::find()->all(), 'id', 'name');
     return $this->render('index', ['searchModel' => $searchModel, 'paymentTypes' => $paymentTypes, 'dataProvider' => $dataProvider]);
 }
Ejemplo n.º 2
0
 public function run()
 {
     $shippingTypesList = ShippingType::find()->orderBy('order DESC')->all();
     $shippingTypes = ['' => yii::t('order', 'Choose shipping type')];
     foreach ($shippingTypesList as $sht) {
         if ($sht->cost > 0) {
             $currency = yii::$app->getModule('order')->currency;
             $name = "{$sht->name} ({$sht->cost}{$currency})";
         } else {
             $name = $sht->name;
         }
         $shippingTypes[$sht->id] = $name;
     }
     $paymentTypes = ['' => yii::t('order', 'Choose payment type')];
     $paymentTypesList = PaymentType::find()->orderBy('order DESC')->all();
     foreach ($paymentTypesList as $pt) {
         $paymentTypes[$pt->id] = $pt->name;
     }
     $fieldFind = Field::find()->orderBy('order DESC');
     $fieldValueModel = new FieldValue();
     $orderModel = new Order();
     if (empty($orderModel->shipping_type_id) && ($orderShippingType = yii::$app->session->get('orderShippingType'))) {
         if ($orderShippingType > 0) {
             $orderModel->shipping_type_id = (int) $orderShippingType;
         }
     }
     $this->getView()->registerJs("pistol88.order.updateShippingType = '" . Url::toRoute(['/order/tools/update-shipping-type']) . "';");
     return $this->render($this->view, ['orderModel' => $orderModel, 'fieldFind' => $fieldFind, 'paymentTypes' => $paymentTypes, 'elements' => $this->elements, 'shippingTypes' => $shippingTypes, 'shippingTypesList' => $shippingTypesList, 'fieldValueModel' => $fieldValueModel]);
 }
Ejemplo n.º 3
0
 public function run()
 {
     $paymentTypes = ArrayHelper::map(PaymentType::find()->orderBy('order DESC')->all(), 'id', 'name');
     $orderModel = yii::$app->orderModel;
     $model = new $orderModel();
     $this->getView()->registerJs("pistol88.createorder.updateCartUrl = '" . Url::toRoute(['tools/cart-info']) . "';");
     return $this->render($this->view, ['model' => $orderModel, 'paymentTypes' => $paymentTypes, 'useAjax' => $this->useAjax, 'nextStep' => $this->nextStep, 'staffer' => $this->staffer]);
 }
Ejemplo n.º 4
0
 public function search($params)
 {
     $query = PaymentType::find()->orderBy('order DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', 'widget', $this->widget]);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 public function actionView($id)
 {
     $this->layout = '@vendor/pistol88/yii2-order/views/layouts/mini';
     $model = $this->findModel($id);
     if ($model->status == $this->module->defaultStatus) {
         $model->status = $this->module->operatorOpenStatus;
         $model->seller_user_id = yii::$app->user->id;
         $model->save(false);
     }
     $searchModel = new ElementSearch();
     $params = yii::$app->request->queryParams;
     if (!is_array($params)) {
         $params = [];
     }
     $params['ElementSearch']['order_id'] = $model->id;
     $dataProvider = $searchModel->search($params);
     $paymentTypes = ArrayHelper::map(PaymentType::find()->all(), 'id', 'name');
     $shippingTypes = ArrayHelper::map(ShippingType::find()->all(), 'id', 'name');
     $fieldFind = Field::find();
     return $this->render('view', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'shippingTypes' => $shippingTypes, 'fieldFind' => $fieldFind, 'paymentTypes' => $paymentTypes, 'model' => $model]);
 }
Ejemplo n.º 6
0
 public function run()
 {
     if ($this->types) {
         $paymentTypes = ArrayHelper::map(PaymentType::find()->where(['id' => $this->types])->all(), 'id', 'name');
     } else {
         $paymentTypes = ArrayHelper::map(PaymentType::find()->all(), 'id', 'name');
     }
     $report = [];
     $hasReport = false;
     foreach ($paymentTypes as $pid => $pname) {
         $query = Order::find()->where('date >= :dateStart AND date <= :dateStop', [':dateStart' => $this->dateStart, ':dateStop' => $this->dateStop]);
         $sum = $query->andWhere(['payment_type_id' => $pid])->distinct()->sum('cost');
         $report[$pname] = $sum;
         if ($sum) {
             $hasReport = true;
         }
     }
     if (!$hasReport) {
         return '';
     }
     return $this->render('report-payment-types', ['report' => $report, 'dateStart' => $this->dateStart, 'dateStop' => $this->dateStop]);
 }
Ejemplo n.º 7
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use pistol88\order\models\PaymentType;
use pistol88\order\models\ShippingType;
use pistol88\cart\widgets\ElementsList;
use pistol88\cart\widgets\CartInformer;
use pistol88\order\widgets\BuyByCode;
use pistol88\order\widgets\ChooseClient;
use pistol88\order\models\FieldValue;
$paymentTypes = ArrayHelper::map(PaymentType::find()->orderBy('order DESC')->all(), 'id', 'name');
$shippingTypes = ArrayHelper::map(ShippingType::find()->orderBy('order DESC')->all(), 'id', 'name');
pistol88\order\assets\CreateOrderAsset::register($this);
$this->registerJs("pistol88.createorder.updateCartUrl = '" . Url::toRoute(['tools/cart-info']) . "';");
$this->title = Yii::t('order', 'Create order');
$this->params['breadcrumbs'][] = ['label' => Yii::t('order', 'Orders'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="order-create">

<div class="order-form">
    <div class="row">
        <?php 
$form = ActiveForm::begin(['id' => 'orderForm']);
?>
        <div class="col-lg-6">
            <div class=" panel panel-default">
                <div class="panel-heading"><h3>Заказ</h3></div>
Ejemplo n.º 8
0
 public function actionOrder($order_id = false)
 {
     $customServiceModel = new CustomService();
     if ($customServiceModel->load(Yii::$app->request->post()) && $customServiceModel->save()) {
         yii::$app->cart->put($customServiceModel);
         if (yii::$app->request->post('ajax')) {
             die(json_encode(['result' => 'success']));
         } else {
             \Yii::$app->session->setFlash('customServiceBuy', 'В корзине!');
         }
     }
     if ($type = yii::$app->request->get('service-order-type')) {
         if (!in_array($type, ['net', 'table'])) {
             return $this->redirect('404');
         }
         yii::$app->response->cookies->add(new \yii\web\Cookie(['name' => 'service-order-type', 'value' => $type]));
     } else {
         $type = yii::$app->request->cookies->get('service-order-type');
         if (!$type) {
             $type = 'net';
         }
     }
     $organization = false;
     $organizations = [];
     if (yii::$app->has('organization')) {
         $organization = yii::$app->organization->get();
         $organizations = yii::$app->organization->getList();
     }
     if ($organization) {
         $services = Service::find()->where('(calculator = "" OR calculator IS NULL) AND organization_id = :org_id', [':org_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
         $categories = Category::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
         $complexes = Complex::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
     } else {
         $services = Service::find()->orderBy('sort DESC, id ASC')->all();
         $categories = Category::find()->where('parent_id IS NULL OR parent_id = 0')->orderBy('sort DESC, id ASC')->all();
         $complexes = Complex::find()->orderBy('sort DESC, id ASC')->all();
     }
     $calculateServiceModel = Service::find()->where('calculator != ""')->all();
     $priceModel = new Price();
     $orderModel = new Order();
     $paymentTypes = ArrayHelper::map(PaymentType::find()->orderBy('order DESC')->all(), 'id', 'name');
     $shippingTypes = ArrayHelper::map(ShippingType::find()->orderBy('order DESC')->all(), 'id', 'name');
     $prices = [];
     foreach ($priceModel::find()->all() as $price) {
         $prices[$price->service_type][$price->category_id][$price->service_id] = $price;
     }
     $this->getView()->registerJs('pistol88.service.propertyListUrl = "' . Url::toRoute(['/service/property/get-ajax-list']) . '";');
     $this->getView()->registerJs('pistol88.service.searchClientByIdentUrl = "' . Url::toRoute(['/service/property/get-client-by-property']) . '";');
     if ($order_id) {
         $order = Order::findOne($order_id);
     } else {
         $order = false;
     }
     return $this->render('order', ['order' => $order, 'organization' => $organization, 'organizations' => $organizations, 'type' => $type, 'customServiceModel' => $customServiceModel, 'calculateServiceModel' => $calculateServiceModel, 'prices' => $prices, 'services' => $services, 'complexes' => $complexes, 'categories' => $categories, 'orderModel' => $orderModel, 'priceModel' => $priceModel, 'paymentTypes' => $paymentTypes, 'shippingTypes' => $shippingTypes]);
 }
Ejemplo n.º 9
0
 public function actionPrint($id)
 {
     $this->layout = 'print';
     $this->enableCsrfValidation = false;
     $model = $this->findModel($id);
     $searchModel = new ElementSearch();
     $params = yii::$app->request->queryParams;
     if (empty($params['ElementSearch'])) {
         $params = ['ElementSearch' => ['order_id' => $model->id]];
     }
     $dataProvider = $searchModel->search($params);
     $paymentTypes = ArrayHelper::map(PaymentType::find()->all(), 'id', 'name');
     $shippingTypes = ArrayHelper::map(ShippingType::find()->all(), 'id', 'name');
     $fieldFind = Field::find();
     return $this->render('print', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'shippingTypes' => $shippingTypes, 'fieldFind' => $fieldFind, 'paymentTypes' => $paymentTypes, 'module' => $this->module, 'model' => $model]);
 }