public function actionIndex() | public function actionIndex() | ||||
{ | { | ||||
$searchModel = new OrderSearch(); | $searchModel = new OrderSearch(); | ||||
$dataProvider = $searchModel->search(array_merge(\Yii::$app->request->queryParams)); | |||||
$dataProvider = $searchModel->search([ | |||||
'order_by' => 'IF(ISNULL(date_update), `order`.`date`, `order`.`date_update`) DESC' | |||||
]); | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'searchModel' => $searchModel, | 'searchModel' => $searchModel, |
'url' => ['order-admin/index'], | 'url' => ['order-admin/index'], | ||||
'visible' => $isUserCurrentGrantedAsAdministrator, | 'visible' => $isUserCurrentGrantedAsAdministrator, | ||||
], | ], | ||||
[ | |||||
'label' => 'Fonctionnalités', | |||||
'icon' => 'flag', | |||||
'url' => ['/feature-admin/index'], | |||||
'visible' => $isUserCurrentGrantedAsAdministrator | |||||
], | |||||
[ | [ | ||||
'label' => 'Statistiques', | 'label' => 'Statistiques', | ||||
'icon' => 'line-chart', | 'icon' => 'line-chart', | ||||
'visible' => $isUserCurrentGrantedAsAdministrator, | 'visible' => $isUserCurrentGrantedAsAdministrator, | ||||
'items' => [ | 'items' => [ | ||||
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)], | ['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/setting-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator && $featureChecker->isEnabled(Feature::ALIAS_SETTINGS)], | ||||
['label' => 'Fonctionnalités', 'icon' => 'flag', 'url' => ['/feature-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | |||||
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | ['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | ||||
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | ['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator], | ||||
], | ], |
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Origine', | |||||
'label' => 'Utilisateur', | |||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($order) use ($orderModule) { | 'value' => function ($order) use ($orderModule) { | ||||
return $orderModule->getSolver()->getLabelOrigin($order, true);; | |||||
return $orderModule->getSolver()->getOrderUsername($order) | |||||
.'<br />'.$orderModule->getSolver()->getLabelOrigin($order, true); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
<?= $form->field($model, 'slug') ?> | <?= $form->field($model, 'slug') ?> | ||||
<?= $form->field($model, 'name') ?> | <?= $form->field($model, 'name') ?> | ||||
<?= $form->field($model, 'type')->textInput(['placeholder' => 'Boulangerie, brasserie, ferme ...']); ?> | <?= $form->field($model, 'type')->textInput(['placeholder' => 'Boulangerie, brasserie, ferme ...']); ?> | ||||
<?= $form->field($model, 'address')->textarea(['rows' => 4]) ?> | |||||
<?= $form->field($model, 'postcode') ?> | <?= $form->field($model, 'postcode') ?> | ||||
<?= $form->field($model, 'city') ?> | <?= $form->field($model, 'city') ?> | ||||
<?= $form->field($model, 'contact_email') ?> | <?= $form->field($model, 'contact_email') ?> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="col-md-6"> | <div class="col-md-6"> | ||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title"> | |||||
<i class="fa fa-copy"></i> | |||||
Données à copier | |||||
</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<ul class="list-group list-group-unbordered"> | |||||
<li class="list-group-item"> | |||||
<strong>Email</strong> | |||||
<span class="pull-right"> | |||||
<a class="btn btn-xs btn-default" href="mailto:<?= $model->contact_email ?>"> | |||||
<span class="glyphicon glyphicon-send"></span> | |||||
</a> | |||||
<a class="btn btn-xs btn-default clipboard-paste" data-clipboard-paste="<?= $model->contact_email ?>"> | |||||
<span class="glyphicon glyphicon-copy"></span> | |||||
</a> | |||||
</span> | |||||
</li> | |||||
<li class="list-group-item"> | |||||
<strong>Url courte boutique</strong> | |||||
<span class="pull-right"> | |||||
<a class="btn btn-xs btn-default clipboard-paste" data-clipboard-paste="<?= $model->getShortShopUrl() ?>"> | |||||
<span class="glyphicon glyphicon-copy"></span> | |||||
</a> | |||||
</span> | |||||
</li> | |||||
<li class="list-group-item"> | |||||
<strong>Url connexion / inscription</strong> | |||||
<span class="pull-right"> | |||||
<a class="btn btn-xs btn-default clipboard-paste" data-clipboard-paste="<?= $model->getLoginSignupUrl() ?>"> | |||||
<span class="glyphicon glyphicon-copy"></span> | |||||
</a> | |||||
</span> | |||||
</li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
<h3 class="panel-title"> | <h3 class="panel-title"> |
opendistrib_dashboard_admin_statistics(); | opendistrib_dashboard_admin_statistics(); | ||||
opendistrib_tinymce_responsive(); | opendistrib_tinymce_responsive(); | ||||
opendistrib_sponsorship(); | opendistrib_sponsorship(); | ||||
opendistrib_clipboard_paste(); | |||||
}); | }); | ||||
return 'litre(s)'; | return 'litre(s)'; | ||||
} | } | ||||
} | } | ||||
function opendistrib_clipboard_paste() { | |||||
$('.clipboard-paste').click(function() { | |||||
navigator.clipboard.writeText($(this).attr('data-clipboard-paste')); | |||||
appAlerts.alert('success', 'Copié dans le presse-papier'); | |||||
return false; | |||||
}); | |||||
} | |||||
function opendistrib_sponsorship() { | function opendistrib_sponsorship() { | ||||
$('#sponsorship-link-copy').click(function() { | $('#sponsorship-link-copy').click(function() { | ||||
navigator.clipboard.writeText($(this).attr('href')); | navigator.clipboard.writeText($(this).attr('href')); |
{ | { | ||||
public function search($params) | public function search($params) | ||||
{ | { | ||||
$orderRepository = OrderRepository::getInstance(); | |||||
$optionsSearch = $orderRepository->getDefaultOptionsSearch() ; | |||||
$paramsSearch = []; | $paramsSearch = []; | ||||
if(isset($params['id_user'])) { | if(isset($params['id_user'])) { | ||||
$paramsSearch['id_user'] = $params['id_user']; | $paramsSearch['id_user'] = $params['id_user']; | ||||
$query = Order::searchQuery($paramsSearch, [ | $query = Order::searchQuery($paramsSearch, [ | ||||
'ignore_id_producer' => true, | 'ignore_id_producer' => true, | ||||
'orderby' => 'distribution.date DESC' | |||||
'orderby' => isset($params['order_by']) ? $params['order_by'] : 'distribution.date DESC' | |||||
]); | ]); | ||||
$dataProvider = new ActiveDataProvider([ | $dataProvider = new ActiveDataProvider([ |
return false; | return false; | ||||
} | } | ||||
public function getShortShopUrl(): string | |||||
{ | |||||
return 'https://'.$this->slug.'.souke.fr'; | |||||
} | |||||
public function getLoginSignupUrl(): string | |||||
{ | |||||
return \Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer', 'id' => $this->id]); | |||||
} | |||||
} | } | ||||
'option_delivery' => $producer->option_delivery, | 'option_delivery' => $producer->option_delivery, | ||||
'online_payment' => $producer->online_payment, | 'online_payment' => $producer->online_payment, | ||||
'option_online_payment_type' => $producer->online_payment, | 'option_online_payment_type' => $producer->online_payment, | ||||
'has_specific_delays' => $this->getProducerModule()->getSolver()->hasSpecificDelays($producer) | |||||
'has_specific_delays' => $this->getProducerModule()->getSolver()->hasSpecificDelays($producer), | |||||
'feature_product_accessory_enabled' => $this->getFeatureModule()->getChecker()->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY), | |||||
]; | ]; | ||||
} | } | ||||
<span v-if="product.weight">({{ product.weight }} g)</span> | <span v-if="product.weight">({{ product.weight }} g)</span> | ||||
</span> | </span> | ||||
<div> | <div> | ||||
<span v-if="product.quantity_max != null && (product.quantity_remaining <= 0 || product.quantity_remaining * product.coefficient_unit < product.step)" | |||||
<span v-if="product.quantity_max != null && (product.quantity_remaining <= 0 || product.quantity_remaining * product.coefficient_unit < product.step || product.quantity_form >= product.quantity_max * product.coefficient_unit)" | |||||
class="badge bg-danger">Épuisé</span> | class="badge bg-danger">Épuisé</span> | ||||
</div> | </div> | ||||
<div class="description" v-if="product.description.length"> | <div class="description" v-if="product.description.length"> |
app.products = response.products; | app.products = response.products; | ||||
app.loadingProducts = false; | app.loadingProducts = false; | ||||
}, 'json'); | }, 'json'); | ||||
}.bind(this, app), 300); | |||||
}.bind(this, app), 500); | |||||
return; | return; | ||||
} | } | ||||
) { | ) { | ||||
var theQuantity = parseFloat(this.products[product.index].quantity_form) + parseFloat(quantity); | var theQuantity = parseFloat(this.products[product.index].quantity_form) + parseFloat(quantity); | ||||
this.products[product.index].quantity_form = parseFloat(theQuantity.toFixed(2)) ; | this.products[product.index].quantity_form = parseFloat(theQuantity.toFixed(2)) ; | ||||
this.init('first', true); | |||||
if(this.producer.feature_product_accessory_enabled) { | |||||
this.init('first', true); | |||||
} | |||||
} | } | ||||
}, | }, | ||||
oneProductOrdered: function() { | oneProductOrdered: function() { |