Commit b660aa0b by semenov

1

parent 459d6a6e
......@@ -34,6 +34,12 @@ return [
],
[
"label" => "Статусы заказов",
"url" => ["shop/admin-shop-order-status"],
"img" => ['\skeeks\modules\cms\shop\assets\Asset', 'icons/shop.png']
],
[
"label" => "Заказы",
"url" => ["shop/admin-shop-order"],
"img" => ['\skeeks\modules\cms\shop\assets\Asset', 'icons/shop.png']
......
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 02.04.2015
*/
namespace skeeks\modules\cms\shop\controllers;
use skeeks\cms\modules\admin\controllers\AdminModelEditorSmartController;
use skeeks\modules\cms\shop\models\ShopDelivery;
use skeeks\modules\cms\shop\models\ShopOrder;
use skeeks\modules\cms\shop\models\ShopOrderStatus;
use skeeks\modules\cms\shop\models\ShopPaySystem;
use skeeks\modules\cms\shop\models\ShopPersonType;
/**
* Class AdminShopPaySystemController
* @package skeeks\modules\cms\shop\controllers
*/
class AdminShopOrderStatusController extends AdminModelEditorSmartController
{
public function init()
{
$this->_label = "Статусы заказов";
$this->_modelShowAttribute = "name";
$this->_modelClassName = ShopOrderStatus::className();
$this->modelValidate = true;
$this->enableScenarios = true;
parent::init();
}
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ use skeeks\modules\cms\form\models\Form;
use skeeks\modules\cms\form\models\FormField;
use skeeks\modules\cms\form\models\FormSendMessage;
use skeeks\modules\cms\shop\models\ShopOrder;
use skeeks\modules\cms\shop\models\ShopPaySystem;
use skeeks\modules\cms\shop\models\ShopPersonType;
use yii\base\Exception;
use yii\base\UserException;
......@@ -85,6 +86,13 @@ class BackendController extends Controller
throw new UserException('Не указан плательщик');
}
$shopPaySystemId = (int) \Yii::$app->request->post('shopPaySystemId');
$shopPaySystem = ShopPaySystem::findOne($shopPaySystemId);
if (!$shopPaySystem)
{
throw new UserException('Не указана система оплаты');
}
if (!$model->email)
{
throw new UserException('Не указан email.');
......@@ -108,7 +116,7 @@ class BackendController extends Controller
//Проверим может что то можно заполнить в профиле пользователя.
if ($user)
{
foreach ($model->attributes as $code => $value)
foreach ($model->attributeValues() as $code => $value)
{
if ($user->hasAttribute($code))
{
......@@ -119,9 +127,12 @@ class BackendController extends Controller
$user->save(false);
} else
{
throw new UserException("Не удалось зарегистрировать пользователя");
throw new UserException("Не удалось зарегистрировать пользователя, возможно пользователь с указанным email адресом уже зарегистрирован.");
}
//Авторизация пользователя
\Yii::$app->user->login($user, 0);
} else
{
$user = \Yii::$app->cms->getAuthUser();
......@@ -136,6 +147,8 @@ class BackendController extends Controller
'price' => $cost->getAmount() / $currency->getSubUnit(),
'currency' => (string) $currency,
'user_id' => $user->id,
'pay_system_id' => $shopPaySystem->id,
'data' => $model->attributeLabelsValues(),
]);
if (!$shopOrder->save())
......
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 01.04.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150401_100559_create_table__shop_order_status extends Migration
{
public function safeUp()
{
$tableExist = $this->db->getTableSchema("{{%shop_order_status}}", true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable("{{%shop_order_status}}", [
'id' => Schema::TYPE_PK,
'created_by' => Schema::TYPE_INTEGER . ' NULL',
'updated_by' => Schema::TYPE_INTEGER . ' NULL',
'created_at' => Schema::TYPE_INTEGER . ' NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NULL',
'code' => 'char(1) NOT NULL',
'name' => Schema::TYPE_STRING . '(255) NOT NULL',
'description' => Schema::TYPE_TEXT . ' NULL',
'priority' => Schema::TYPE_INTEGER . ' NOT NULL DEFAULT 0',
'color' => Schema::TYPE_STRING . '(32) NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(name);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(priority);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD INDEX(color);");
$this->execute("ALTER TABLE {{%shop_order_status}} ADD UNIQUE(code);");
$this->execute("ALTER TABLE {{%shop_order_status}} COMMENT = 'Статусы заказов';");
$this->addForeignKey(
'shop_order_status_created_by', "{{%shop_order_status}}",
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'shop_order_status_updated_by', "{{%shop_order_status}}",
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
}
public function safeDown()
{
$this->dropForeignKey("shop_order_status_updated_by", "{{%shop_order_status}}");
$this->dropForeignKey("shop_order_status_updated_by", "{{%shop_order_status}}");
$this->dropTable("{{%shop_order_status}}");
}
}
......@@ -41,13 +41,15 @@ class m150401_110600_create_table__shop_order extends Migration
'canceled_at' => Schema::TYPE_INTEGER . ' NULL',
'reason_canceled' => Schema::TYPE_STRING . '(255) NULL',
'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 0',
'status_code' => 'char(1) NOT NULL DEFAULT "N"',
'status_at' => Schema::TYPE_INTEGER . ' NULL',
'price' => Schema::TYPE_DECIMAL . '(18,2)',
'currency' => Schema::TYPE_STRING. '(3) DEFAULT "RUB"',
'price_delivery' => Schema::TYPE_DECIMAL . '(18,2) NULL',
'allow_delivery' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0',
'allow_delivery_at' => Schema::TYPE_INTEGER . ' NULL',
'discount_value' => Schema::TYPE_DECIMAL . '(18,2) NULL',
'user_id' => Schema::TYPE_INTEGER . ' NOT NULL',
......@@ -65,10 +67,16 @@ class m150401_110600_create_table__shop_order extends Migration
'ps_sum' => Schema::TYPE_DECIMAL . '(18,2) NULL',
'ps_currency' => Schema::TYPE_STRING. '(3) NULL',
'ps_respose_at' => Schema::TYPE_INTEGER. ' NULL',
'data' => Schema::TYPE_TEXT. ' NULL',
'comments' => Schema::TYPE_TEXT. ' NULL',
'tax_value' => Schema::TYPE_DECIMAL . '(18,2) NULL',
'locked_by' => Schema::TYPE_INTEGER . ' NULL',
'locked_at' => Schema::TYPE_INTEGER . ' NULL',
'reserved' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0',
], $tableOptions);
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(updated_by);");
......@@ -80,7 +88,8 @@ class m150401_110600_create_table__shop_order extends Migration
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(person_type_id);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(payed);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(payed_at);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(status);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(status_code);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(status_at);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(canceled);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(canceled_at);");
......@@ -91,6 +100,7 @@ class m150401_110600_create_table__shop_order extends Migration
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(price_delivery);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(allow_delivery);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(allow_delivery_at);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(discount_value);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(user_id);");
......@@ -111,6 +121,11 @@ class m150401_110600_create_table__shop_order extends Migration
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(tax_value);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(locked_by);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(locked_at);");
$this->execute("ALTER TABLE {{%shop_order}} ADD INDEX(reserved);");
$this->execute("ALTER TABLE {{%shop_order}} COMMENT = 'Заказы';");
$this->addForeignKey(
......@@ -132,6 +147,17 @@ class m150401_110600_create_table__shop_order extends Migration
'shop_order__user_id', "{{%shop_order}}",
'user_id', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'shop_order__status_code', "{{%shop_order}}",
'status_code', '{{%shop_order_status}}', 'code', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'shop_order__locked_by', "{{%shop_order}}",
'locked_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function safeDown()
......@@ -140,6 +166,8 @@ class m150401_110600_create_table__shop_order extends Migration
$this->dropForeignKey("shop_order_updated_by", "{{%shop_order}}");
$this->dropForeignKey("shop_order_person_type_id", "{{%shop_order}}");
$this->dropForeignKey("shop_order__user_id", "{{%shop_order}}");
$this->dropForeignKey("shop_order__status_code", "{{%shop_order}}");
$this->dropForeignKey("shop_order__locked_by", "{{%shop_order}}");
$this->dropTable("{{%shop_order}}");
}
......
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 01.04.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150401_113818_append_data extends Migration
{
public function up()
{
$status = new \skeeks\modules\cms\shop\models\ShopOrderStatus();
$status->name = 'Выполнен';
$status->description = 'Заказ доставлен и оплачен';
$status->priority = '200';
$status->code = 'F';
$status->save();
$status = new \skeeks\modules\cms\shop\models\ShopOrderStatus();
$status->name = 'Принят';
$status->description = 'Заказ принят, но пока не обрабатывается (например, заказ только что создан или ожидается оплата заказа)';
$status->priority = '200';
$status->code = 'N';
$status->save();
$paySystem = new \skeeks\modules\cms\shop\models\ShopPaySystem();
$paySystem->name = 'Наличная оплата';
$paySystem->currency = 'RUB';
$paySystem->active = 1;
$paySystem->save();
$paySystem = new \skeeks\modules\cms\shop\models\ShopPaySystem();
$paySystem->name = 'Безналичная оплата';
$paySystem->currency = 'RUB';
$paySystem->active = 0;
$paySystem->save();
$personType = new \skeeks\modules\cms\shop\models\ShopPersonType();
$personType->name = 'Физическое лицо';
$personType->active = 1;
$personType->save();
$personType = new \skeeks\modules\cms\shop\models\ShopPersonType();
$personType->name = 'Юридическое лицо';
$personType->active = 0;
$personType->save();
}
public function down()
{}
}
......@@ -6,6 +6,7 @@
* @date 02.04.2015
*/
namespace skeeks\modules\cms\shop\models;
use skeeks\cms\models\behaviors\Serialize;
use skeeks\cms\models\User;
use skeeks\cms\helpers\UrlHelper;
use skeeks\cms\models\behaviors\HasStatus;
......@@ -14,6 +15,7 @@ use skeeks\cms\models\Core;
use skeeks\modules\cms\money\Currency;
use skeeks\modules\cms\money\Money;
use \Yii;
use yii\db\BaseActiveRecord;
use yii\helpers\ArrayHelper;
/**
......@@ -30,11 +32,13 @@ use yii\helpers\ArrayHelper;
* @property integer $canceled
* @property integer $canceled_at
* @property string $reason_canceled
* @property integer $status
* @property string $status_code
* @property integer $status_at
* @property string $price
* @property string $currency
* @property string $price_delivery
* @property integer $allow_delivery
* @property integer $allow_delivery_at
* @property string $discount_value
* @property integer $user_id
* @property integer $pay_system_id
......@@ -48,14 +52,20 @@ use yii\helpers\ArrayHelper;
* @property string $ps_sum
* @property string $ps_currency
* @property integer $ps_respose_at
* @property string $data
* @property string $comments
* @property string $tax_value
* @property integer $locked_by
* @property integer $locked_at
* @property integer $reserved
*
* @property ShopBasket[] $shopBaskets
* @property User $user
* @property User $lockedBy
* @property User $createdBy
* @property ShopPersonType $personType
* @property CmsUser $updatedBy
* @property User $updatedBy
* @property ShopOrderStatus $statusCode
* @property User $user
*/
class ShopOrder extends Core
{
......@@ -76,6 +86,11 @@ class ShopOrder extends Core
HasStatusBoolean::className() =>
[
'class' => HasStatusBoolean::className(),
],
Serialize::className() =>
[
'class' => Serialize::className(),
'fields' => ['data']
]
]);
}
......@@ -101,7 +116,7 @@ class ShopOrder extends Core
'price' => Yii::t('app', 'Price'),
'currency' => Yii::t('app', 'Currency'),
'price_delivery' => Yii::t('app', 'Price Delivery'),
'allow_delivery' => Yii::t('app', 'Allow Delivery'),
'allow_delivery' => Yii::t('app', 'Доставка разрешена?'),
'discount_value' => Yii::t('app', 'Discount Value'),
'user_id' => Yii::t('app', 'User ID'),
'pay_system_id' => Yii::t('app', 'Pay System ID'),
......@@ -117,6 +132,9 @@ class ShopOrder extends Core
'ps_respose_at' => Yii::t('app', 'Ps Respose At'),
'comments' => Yii::t('app', 'Comments'),
'tax_value' => Yii::t('app', 'Tax Value'),
'status_code' => Yii::t('app', 'Статус'),
'data' => Yii::t('app', 'Данные заказа'),
'reason_canceled' => Yii::t('app', 'Причина отмены'),
]);
}
......@@ -135,21 +153,79 @@ class ShopOrder extends Core
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->on(BaseActiveRecord::EVENT_BEFORE_INSERT, [$this, "checkSave"]);
$this->on(BaseActiveRecord::EVENT_BEFORE_UPDATE, [$this, "checkSave"]);
}
public function checkSave()
{
if ($this->getOldAttribute('status_code') != $this->getAttribute('status_code'))
{
$this->status_at = \Yii::$app->formatter->asTimestamp(time());
}
if ($this->getOldAttribute('payed') != $this->getAttribute('payed'))
{
$this->payed_at = \Yii::$app->formatter->asTimestamp(time());
}
if ($this->getOldAttribute('canceled') != $this->getAttribute('canceled'))
{
$this->canceled_at = \Yii::$app->formatter->asTimestamp(time());
}
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
[['created_by', 'updated_by', 'created_at', 'updated_at', 'person_type_id', 'payed', 'payed_at', 'canceled', 'canceled_at', 'status', 'allow_delivery', 'user_id', 'pay_system_id', 'delivery_id', 'ps_respose_at'], 'integer'],
[['created_by', 'updated_by', 'created_at', 'updated_at', 'person_type_id', 'payed', 'payed_at', 'canceled', 'canceled_at', 'status_at', 'allow_delivery', 'allow_delivery_at', 'user_id', 'pay_system_id', 'delivery_id', 'ps_respose_at', 'locked_by', 'locked_at', 'reserved'], 'integer'],
[['price', 'price_delivery', 'discount_value', 'ps_sum', 'tax_value'], 'number'],
[['user_id'], 'required'],
[['data'], 'safe'],
[['canceled'], 'validateCanceled'],
[['comments'], 'string'],
[['reason_canceled', 'user_description', 'additional_info', 'ps_status_description', 'ps_status_message'], 'string', 'max' => 255],
[['status_code', 'ps_status'], 'string', 'max' => 1],
[['currency', 'ps_currency'], 'string', 'max' => 3],
[['ps_status'], 'string', 'max' => 1],
[['ps_status_code'], 'string', 'max' => 5]
[['ps_status_code'], 'string', 'max' => 5],
['status_at', 'default', 'value' => function(ShopOrder $model, $attribute)
{
if (!$model->$attribute)
{
return \Yii::$app->formatter->asTimestamp(time());
}
}],
]);
}
/**
* Правильная валидация видео ссылки.
*
* @param $attribute
*/
public function validateCanceled($attribute)
{
if ($this->$attribute == 1)
{
if (!$this->reason_canceled)
{
$this->addError($attribute, "Укажите причину отмены");
}
}
}
/**
* @return \yii\db\ActiveQuery
*/
public function getShopBaskets()
......@@ -168,6 +244,14 @@ class ShopOrder extends Core
/**
* @return \yii\db\ActiveQuery
*/
public function getLockedBy()
{
return $this->hasOne(CmsUser::className(), ['id' => 'locked_by']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCreatedBy()
{
return $this->hasOne(User::className(), ['id' => 'created_by']);
......@@ -184,11 +268,26 @@ class ShopOrder extends Core
/**
* @return \yii\db\ActiveQuery
*/
public function getPaySystem()
{
return $this->hasOne(ShopPaySystem::className(), ['id' => 'pay_system_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUpdatedBy()
{
return $this->hasOne(User::className(), ['id' => 'updated_by']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getStatusCode()
{
return $this->hasOne(ShopOrderStatus::className(), ['code' => 'status_code']);
}
......
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 21.04.2015
*/
namespace skeeks\modules\cms\shop\models;
use skeeks\cms\models\Core;
use skeeks\cms\models\User;
use skeeks\modules\cms\shop\models\ShopOrder;
use Yii;
use yii\base\UserException;
use yii\db\BaseActiveRecord;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "{{%shop_order_status}}".
*
* @property integer $id
* @property integer $created_by
* @property integer $updated_by
* @property integer $created_at
* @property integer $updated_at
* @property string $code
* @property string $name
* @property string $description
* @property integer $priority
* @property string $color
*
* @property ShopOrder[] $shopOrders
* @property User $updatedBy
* @property User $createdBy
*/
class ShopOrderStatus extends Core
{
const STATUS_CODE_START = "N";
const STATUS_CODE_END = "F";
static public $protectedStatuses =
[
self::STATUS_CODE_START, self::STATUS_CODE_END
];
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->on(BaseActiveRecord::EVENT_BEFORE_DELETE, [$this, "checkDelete"]);
}
public function checkDelete()
{
if ($this->isProtected())
{
throw new UserException('Нельзя удалять этот статус');
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%shop_order_status}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), []);
}
/**
* Нельзя удалять и редактировать статус?
* @return bool
*/
public function isProtected()
{
if (in_array($this->code, (array) static::$protectedStatuses))
{
return true;
}
return false;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
'id' => Yii::t('app', 'ID'),
'created_by' => Yii::t('app', 'Created By'),
'updated_by' => Yii::t('app', 'Updated By'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
'code' => Yii::t('app', 'Код'),
'name' => Yii::t('app', 'Name'),
'description' => Yii::t('app', 'Описание'),
'priority' => Yii::t('app', 'Priority'),
'color' => Yii::t('app', 'Color'),
]);
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios[self::SCENARIO_DEFAULT];
$scenarios['create'] = $scenarios[self::SCENARIO_DEFAULT];
$scenarios['update'] = $scenarios[self::SCENARIO_DEFAULT];
return $scenarios;
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority'], 'integer'],
[['code', 'name'], 'required'],
[['description'], 'string'],
[['code'], 'string', 'max' => 1],
[['name'], 'string', 'max' => 255],
[['color'], 'string', 'max' => 32],
[['code'], 'unique'],
[['code'], 'validateCode']
]);
}
public function validateCode($attribute)
{
if(!preg_match('/^[A-Z]{1}$/', $this->$attribute))
{
$this->addError($attribute, 'Используйте только заглавные буквы латинского алфавита.');
}
}
/**
* @return \yii\db\ActiveQuery
*/
public function getShopOrders()
{
return $this->hasMany(ShopOrder::className(), ['status_code' => 'code']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUpdatedBy()
{
return $this->hasOne(CmsUser::className(), ['id' => 'updated_by']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCreatedBy()
{
return $this->hasOne(CmsUser::className(), ['id' => 'created_by']);
}
}
\ No newline at end of file
......@@ -138,12 +138,13 @@ class ShopPersonType extends Core
$model->setAttributes(\Yii::$app->cms->getAuthUser()->toArray(), true);
}
return \Yii::$app->getModule('shop')->renderFile('cart-form.php', [
return \Yii::$app->view->render('@skeeks/modules/cms/shop/views/cart-form', [
'shopPersonType' => $this,
'module' => $moduleForm,
'modelForm' => $formModel,
'fields' => $formModel->fields(),
'model' => $model
'shopPaySystems' => $this->fetchPaySystems(),
'module' => $moduleForm,
'modelForm' => $formModel,
'fields' => $formModel->fields(),
'model' => $model
]);
} catch (\Exception $e)
......@@ -153,4 +154,13 @@ class ShopPersonType extends Core
return 'Ошибка рендеринга формы: ' . $e->getMessage();
}
}
/**
* TODO: добавить выборку платежных систем которые подходят для текущего плательщика.
* @return ShopPaySystem[]
*/
public function fetchPaySystems()
{
return ShopPaySystem::find()->where(['active' => 1])->all();
}
}
\ No newline at end of file
<?php
use yii\helpers\Html;
use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm;
/* @var $this yii\web\View */
/* @var $model \skeeks\modules\cms\shop\models\ShopOrderStatus */
?>
<?php $form = ActiveForm::begin(); ?>
<?= $form->fieldSet('Основное'); ?>
<? if ($model->isProtected()) : ?>
<div class="alert-danger alert fade in">
Этот статус является базовым, нельзя менять его код
</div>
<?= $form->field($model, 'code')->textInput([
'maxlength' => 255,
'disabled' => 'disabled',
]) ?>
<? else: ?>
<?= $form->field($model, 'code')->textInput([
'maxlength' => 255,
]) ?>
<? endif; ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->fieldSetEnd(); ?>
<?= $form->buttonsCreateOrUpdate($model); ?>
<?php ActiveForm::end(); ?>
\ No newline at end of file
<?php
/**
* index
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 30.10.2014
* @since 1.0.0
*/
use skeeks\cms\modules\admin\widgets\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\Game */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'class' => \skeeks\cms\modules\admin\grid\ActionColumn::className(),
'controller' => $controller
],
[
'attribute' => 'code',
//'filter' => \yii\helpers\Html::input(),
],
'name',
'description',
],
]); ?>
......@@ -9,24 +9,49 @@
/* @var $model \skeeks\modules\cms\shop\models\ShopOrder */
/* @var $this \yii\web\View */
use yii\helpers\Html;
use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm;
?>
<?php $form = ActiveForm::begin(); ?>
<?= $form->fieldSet('Карточка заказа'); ?>
<table class="table table-striped table-bordered">
<tr>
<th colspan="2">Заказ №<?= $model->id; ?> от <?= \Yii::$app->formatter->asDatetime($model->created_at); ?> (<?= \Yii::$app->formatter->asRelativeTime($model->created_at); ?>)</th>
</tr>
<tr>
<td width="40%">Текущий статус заказа:</td>
<td width="40%">Заказ №:</td>
<td><?= $model->id; ?></td>
</tr>
<tr>
<td width="40%">Создан:</td>
<td><?= \Yii::$app->formatter->asDatetime($model->created_at); ?> <small>(<?= \Yii::$app->formatter->asRelativeTime($model->created_at); ?>)</small></td>
</tr>
<tr>
<td width="40%">Текущий статус заказа:</td>
<td><?= $model->statusCode->name; ?> <br /><small><?= \Yii::$app->formatter->asDatetime($model->status_at); ?> (<?= \Yii::$app->formatter->asRelativeTime($model->status_at); ?>)</small></td>
</tr>
<tr>
<td>Сумма заказа:</td>
<td><?= \Yii::$app->money->intlFormatter()->format($model->price()); ?></td>
</tr>
<tr>
<td>Отменен:</td>
<td></td>
<td>
<? if($model->canceled) : ?>
Да
<br />
<small><?= \Yii::$app->formatter->asDatetime($model->canceled_at); ?> (<?= \Yii::$app->formatter->asRelativeTime($model->canceled_at); ?>)</small>
<br />
<p><b>Прчина:</b> <?= $model->reason_canceled; ?></p>
<? else: ?>
Нет
<? endif; ?>
</td>
</tr>
</table>
......@@ -56,18 +81,33 @@
<td width="40%">Тип плательщика:</td>
<td><?= $model->personType->name; ?></td>
</tr>
<? if ($model->data) : ?>
<? foreach ($model->data as $key => $value) : ?>
<tr>
<td width="40%"><?= $key; ?>:</td>
<td><?= $value; ?></td>
</tr>
<? endforeach; ?>
<? endif; ?>
</table>
<table class="table table-striped table-bordered">
<tr>
<th colspan="2">Оплата и доставка</th>
</tr>
<tr>
<td width="40%">Платежная система:</td>
<td><?= $model->pay_system_id; ?></td>
<td><?= $model->paySystem->name; ?></td>
</tr>
<tr>
<td>Оплачен:</td>
<td><?= $model->user->username; ?></td>
<td>
<? if($model->payed) : ?>
Да <br /><small><?= \Yii::$app->formatter->asDatetime($model->payed_at); ?> (<?= \Yii::$app->formatter->asRelativeTime($model->payed_at); ?>)</small>
<? else: ?>
Нет
<? endif; ?>
</td>
</tr>
</table>
......@@ -77,7 +117,7 @@
</tr>
<tr>
<td width="40%">Служба доставки:</td>
<td>Не установлена</td>
<td>Не используется</td>
</tr>
</table>
......@@ -173,4 +213,99 @@ HTML;
</div>
</td>
</tr>
</table>
\ No newline at end of file
</table>
<?= $form->fieldSetEnd(); ?>
<?= $form->fieldSet('Управление'); ?>
<?= $form->field($model, 'status_code')->widget(
\skeeks\widget\chosen\Chosen::className(),
[
'allowDeselect' => false,
'items' => \yii\helpers\ArrayHelper::map(
\skeeks\modules\cms\shop\models\ShopOrderStatus::find()->all(),
'code',
'name'
)
]
) ?>
<?= $form->field($model, 'payed')->radioList(
\Yii::$app->formatter->booleanFormat
) ?>
<?= $form->field($model, 'allow_delivery')->radioList(
\Yii::$app->formatter->booleanFormat
) ?>
<?= $form->field($model, 'canceled')->widget(
\skeeks\widget\chosen\Chosen::className(),
[
'allowDeselect' => false,
'items' => \Yii::$app->formatter->booleanFormat
]
) ?>
<div class="" id="rejected-text-wrapper" style="display: none;">
<?= $form->field($model, 'reason_canceled')->textarea(['rows' => 3]); ?>
</div>
<?
$rejected = 1;
$this->registerJs(<<<JS
(function(sx, $, _)
{
sx.classes.ProjectConferenceStatus = sx.classes.Component.extend({
_init: function()
{
},
_onDomReady: function()
{
var self = this;
$("#shoporder-canceled").on('change', function()
{
self.update();
});
self.update();
},
_onWindowReady: function()
{},
update: function()
{
var self = this;
if ($("#shoporder-canceled").val() == self.get('rejected'))
{
$("#rejected-text-wrapper").show();
} else
{
$("#rejected-text-wrapper").hide();
}
}
});
new sx.classes.ProjectConferenceStatus({
'rejected' : {$rejected}
});
})(sx, sx.$, sx._);
JS
);?>
<?= $form->fieldSetEnd(); ?>
<?= $form->buttonsCreateOrUpdate($model); ?>
<?php ActiveForm::end(); ?>
......@@ -91,5 +91,16 @@ $dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
'class' => \skeeks\cms\grid\BooleanColumn::className(),
'attribute' => 'canceled',
],
[
'class' => \yii\grid\DataColumn::className(),
'value' => function(\skeeks\modules\cms\shop\models\ShopOrder $model)
{
return $model->statusCode->name;
},
'attribute' => 'status_code',
'label' => 'Статус',
'filter' => \yii\helpers\ArrayHelper::map(\skeeks\modules\cms\shop\models\ShopOrderStatus::find()->all(), 'code', 'name')
],
],
]); ?>
......@@ -21,6 +21,9 @@ use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm;
) ?>
<?= $form->fieldSetEnd(); ?>
<?= $form->fieldSet('Типы плательщиков'); ?>
<?= $form->fieldSetEnd(); ?>
<?= $form->buttonsCreateOrUpdate($model); ?>
<?php ActiveForm::end(); ?>
\ No newline at end of file
......@@ -33,9 +33,9 @@ use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm;
]);
?>
<?= $form->fieldSetEnd(); ?>
<?= $form->fieldSet('Платежные системы'); ?>
<?= $form->fieldSetEnd(); ?>
<!--
<?/*= $form->fieldSet('Платежные системы'); */?>
--><?/*= $form->fieldSetEnd(); */?>
<?= $form->buttonsCreateOrUpdate($model); ?>
<?php ActiveForm::end(); ?>
\ No newline at end of file
......@@ -8,6 +8,7 @@
* @var $formField \skeeks\modules\cms\form\models\FormField
* @var $model \skeeks\modules\cms\form\models\FormValidateModel
* @var $shopPersonType \skeeks\modules\cms\shop\models\ShopPersonType
* @var $shopPaySystems \skeeks\modules\cms\shop\models\ShopPaySystem[]
*/
use skeeks\modules\cms\form\widgets\ActiveForm;
?>
......@@ -17,7 +18,25 @@ use skeeks\modules\cms\form\widgets\ActiveForm;
]);
?>
<?= \yii\helpers\Html::hiddenInput('shopPersonType', $shopPersonType->id); ?>
<? if ($shopPaySystems) : ?>
<? if (count($shopPaySystems) == 1) : ?>
<? $shopPaySystem = $shopPaySystems[0]; ?>
<?= \yii\helpers\Html::hiddenInput('shopPaySystemId', $shopPaySystem->id); ?>
<? else : ?>
<div class="form-group field-formvalidatemodel-name">
<label class="control-label">Система оплаты: </label>
<?= \skeeks\widget\chosen\Chosen::widget([
'allowDeselect' => false,
'name' => 'shopPaySystemId',
'items' => \yii\helpers\ArrayHelper::map($shopPaySystems, 'id', 'name')
])?>
</div>
<? endif; ?>
<? endif;?>
<? if ($fields) : ?>
<? foreach ($fields as $formField) : ?>
......@@ -25,4 +44,6 @@ use skeeks\modules\cms\form\widgets\ActiveForm;
<? endforeach; ?>
<? endif; ?>
<?php ActiveForm::end(); ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment