registerJs($js, View::POS_READY);
$js = <<< JS
$('#order-phone, #order-phone2').mask('+38(000)000-00-00', {
placeholder: '+38(___)___-__-__'
});
JS;
$this->registerJs($js, View::POS_READY);
$js = <<< JS
$(document).on('change', '#sms-template-selector', function(event) {
var text = $('#select2-sms-template-selector-container').attr('title');
var val = $('option:contains(' + text + ')').attr('value');
$('#sms-text-area').val(val);
});
$(document).on('click', '#send-sms-action', function(event) {
console.log('click');
var content = $('#sms-text-area').val()
var phone = $('input#order-phone').val();
$.ajax({
url: "/admin/ecommerce/order/send-sms",
method: "POST",
data: {
phone: phone,
content: content
},
success: function(data) {
console.log(data);
var newButton = document.createElement('button');
newButton.classList.add('btn', 'btn-default');
newButton.innerText = 'Отправлено';
var current = document.getElementById("send-sms-action");
var parentDiv = current.parentNode;
parentDiv.replaceChild(newButton, current);
}
});
});
JS;
$this->registerJs($js, View::POS_READY);
?>
$dataProvider,
'layout' => '{items}{pager}',
'columns' => [
'id',
'sku',
'product_name',
'productVariant.product.brand.lang.title',
'productVariant.lang.title',
'price',
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'count',
'editableOptions' => [
'header' => \Yii::t('app', 'Количество'),
'inputType' => kartik\editable\Editable::INPUT_SPIN,
'options' => [
'pluginOptions' => [
'min' => 0,
'max' => 5000,
],
],
'pluginEvents' => [
'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }',
],
],
'format' => [
'decimal',
0,
],
'pageSummary' => false,
],
'sum_cost',
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'booking',
'editableOptions' => [
'header' => \Yii::t('app', 'Бронь'),
'inputType' => kartik\editable\Editable::INPUT_TEXT,
'options' => [
'pluginOptions' => [
'min' => 0,
'max' => 20,
],
],
],
'format' => [
'text',
],
'pageSummary' => false,
],
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'status',
'editableOptions' => [
'header' => \Yii::t('app', 'Статус'),
'inputType' => kartik\editable\Editable::INPUT_TEXT,
'options' => [
'pluginOptions' => [
'min' => 0,
'max' => 20,
],
],
],
'format' => [
'text',
],
'pageSummary' => false,
],
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'return',
'editableOptions' => [
'header' => \Yii::t('app', 'Возврат'),
'inputType' => kartik\editable\Editable::INPUT_CHECKBOX,
'options' => [],
],
'format' => [
'boolean',
],
'pageSummary' => false,
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{delete}',
],
],
'responsive' => true,
'hover' => true,
'pjax' => true,
'pjaxSettings' => [
'options' => [
'scrollTo' => 'false',
'id' => 'order-products-grid',
],
],
]
);
?>
yii\helpers\Url::to([ 'add' ]),
'id' => 'add-product-form',
]
);
$newOrderProduct = new OrderProduct();
?>
field($newOrderProduct, 'id')
->widget(
Select2::className(),
[
'options' => [ 'placeholder' => 'Search for a product ...' ],
'pluginOptions' => [
'allowClear' => true,
'disabled' => $model->isNewRecord ? true : false,
'minimumInputLength' => 3,
'language' => [
'errorLoading' => new JsExpression(
"function () { return 'Waiting for results...'; }"
),
],
'ajax' => [
'url' => \yii\helpers\Url::to([ 'find-product' ]),
'dataType' => 'json',
'data' => new JsExpression(
'function(params) { return {q:params.term}; }'
),
],
'escapeMarkup' => new JsExpression(
'function (markup) { return markup; }'
),
'templateResult' => new JsExpression(
'function(data) { return data.sku; }'
),
'templateSelection' => new JsExpression(
'function (data) { return data.sku; }'
),
],
]
);
?>
field(
$newOrderProduct,
'count'
)
->input(
'number',
[
'disabled' => $model->isNewRecord ? true : false,
]
); ?>
$model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary',
]
) ?>
field($newOrderProduct, 'order_id')
->hiddenInput(
[
'value' => $model->id,
]
)
->label(false) ?>
'sms-template-selector',
'name' => 'select-sms-template',
'data' => ArrayHelper::map(
SmsTemplate::find()
->asArray()
->all(),
'text',
'title'
),
'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ],
'pluginOptions' => [
'allowClear' => true,
],
]
);
?>
3,
'id' => 'sms-text-area',
'class' => 'form-control',
]
);
?>
isNewRecord) {
echo Html::button(
\Yii::t('app', 'Отправить'),
[
'class' => 'btn btn-warning disabled',
]
);
} else {
echo Html::button(
\Yii::t('app', 'Отправить'),
[
'class' => 'btn btn-warning',
'id' => 'send-sms-action',
]
);
}
?>