Ver código fonte

Modification de commande.

Gestion des quantités de produit.
Page de confirmation de commande / récapitulatif
dev
Guillaume Bourgeois 5 anos atrás
pai
commit
1974500e19
6 arquivos alterados com 211 adições e 48 exclusões
  1. +53
    -19
      producer/controllers/OrderController.php
  2. +4
    -4
      producer/views/layouts/main.php
  3. +30
    -7
      producer/views/order/order.php
  4. +57
    -11
      producer/web/css/screen.css
  5. +14
    -7
      producer/web/js/vuejs/order-order.js
  6. +53
    -0
      producer/web/sass/order/_order.scss

+ 53
- 19
producer/controllers/OrderController.php Ver arquivo

@@ -140,7 +140,9 @@ class OrderController extends ProducerBaseController
$deadline = 20;
$date = date('Y-m-d');
if (isset($producer)) {
$deadline = $producer->order_deadline;
if($producer->order_deadline) {
$deadline = $producer->order_deadline;
}
if (date('H') >= $deadline) {
$date = date('Y-m-d', strtotime(date('Y-m-d')) + ($producer->order_delay) * (24 * 60 * 60));
} else {
@@ -279,12 +281,11 @@ class OrderController extends ProducerBaseController
*
* @return mixed
*/
public function actionAjaxCreate()
public function actionAjaxProcess()
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$order = new Order ;
$idProducer = $this->getProducer()->id ;
$order = new Order;

$posts = Yii::$app->request->post();
@@ -604,12 +605,33 @@ class OrderController extends ProducerBaseController
$format = 'Y-m-d' ;
$dateObject = DateTime::createFromFormat($format, $date);
// Producteur
$producer = Producer::searchOne([
'id' => $this->getProducer()->id
]) ;
$json['producer'] = [
'order_infos' => $producer->order_infos
] ;
// Distributions
$deadline = 20;
$dateMini = date('Y-m-d');
if (isset($producer)) {
if($producer->order_deadline) {
$deadline = $producer->order_deadline;
}
if (date('H') >= $deadline) {
$dateMini = date('Y-m-d', strtotime(date('Y-m-d')) + ($producer->order_delay) * (24 * 60 * 60));
} else {
$dateMini = date('Y-m-d', strtotime(date('Y-m-d')) + ($producer->order_delay - 1) * (24 * 60 * 60));
}
}
$distributionsArray = Distribution::searchAll([
'active' => 1
], [
'conditions' => ['date > :date_today'],
'params' => [':date_today' => date('Y-m-d')],
'conditions' => ['date > :date'],
'params' => [':date' => $dateMini],
]) ;
$json['distributions'] = $distributionsArray ;
@@ -618,10 +640,10 @@ class OrderController extends ProducerBaseController
'id_user' => User::getCurrentId()
], [
'conditions' => [
'distribution.date >= :date'
'distribution.date > :date'
],
'params' => [
':date' => date('Y-m-d')
':date' => $dateMini
]
]);
foreach($ordersUserArray as &$order) {
@@ -633,14 +655,6 @@ class OrderController extends ProducerBaseController
}
$json['orders'] = $ordersUserArray;
// Producteur
$producer = Producer::searchOne([
'id' => $this->getProducer()->id
]) ;
$json['producer'] = [
'order_infos' => $producer->order_infos
] ;
// User
$userProducer = UserProducer::searchOne([
'id_producer' => $producer->id,
@@ -649,8 +663,18 @@ class OrderController extends ProducerBaseController
$json['credit'] = $userProducer->credit ;
if($dateObject && $dateObject->format($format) === $date) {
// Commande de l'utilisateur
$orderUser = Order::searchOne([
'distribution.date' => $date,
'id_user' => User::getCurrentId(),
]);
if($orderUser) {
$json['order'] = $orderUser->getAttributes() ;
}
// distribution
$distribution = Distribution::initDistribution($date) ;
$json['distribution'] = $distribution ;
@@ -670,7 +694,6 @@ class OrderController extends ProducerBaseController

foreach($pointsSaleArray as &$pointSale) {
$pointSale = array_merge($pointSale->getAttributes(),[
'code_form' => '',
'pointSaleDistribution' => [
'id_distribution' => $pointSale->pointSaleDistribution[0]->id_distribution,
'id_point_sale' => $pointSale->pointSaleDistribution[0]->id_point_sale,
@@ -701,11 +724,22 @@ class OrderController extends ProducerBaseController
$indexProduct = 0 ;
foreach($productsArray as &$product) {
$quantityOrder = Order::getProductQuantity($product['id'], $ordersArray) ;
$product['quantity_ordered'] = $quantityOrder ;
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder ;
if($orderUser) {
$quantityOrderUser = Order::getProductQuantity($product['id'], [$orderUser]) ;
$product['quantity_ordered'] = $quantityOrder ;
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder + $quantityOrderUser ;
$product['quantity_form'] = $quantityOrderUser ;
}
else {
$product['quantity_form'] = 0 ;
}
if($product['quantity_remaining'] < 0) $product['quantity_remaining'] = 0 ;
$product['quantity_form'] = 0 ;
$product['index'] = $indexProduct ++ ;
}

+ 4
- 4
producer/views/layouts/main.php Ver arquivo

@@ -155,15 +155,15 @@ $producer = $this->context->getProducer() ;
],
[
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
'url' => Yii::$app->urlManager->createUrl(['order/create']),
'url' => Yii::$app->urlManager->createUrl(['order/order']),
'visible' => !Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'order/create' || $this->getControllerAction() == 'order/update',
'active' => $this->getControllerAction() == 'order/order',
],
[
'label' => '<span class="glyphicon glyphicon-plus"></span> Commander',
'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer','id' => $this->context->getProducer()->id,'return_url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/create','slug_producer' => $this->context->getProducer()->slug])]),
'url' => Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/producer','id' => $this->context->getProducer()->id,'return_url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['order/order','slug_producer' => $this->context->getProducer()->slug])]),
'visible' => Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'order/create' || $this->getControllerAction() == 'order/update',
'active' => $this->getControllerAction() == 'order/order',
],
[
'label' => '<span class="glyphicon glyphicon-folder-open"></span> Historique',

+ 30
- 7
producer/views/order/order.php Ver arquivo

@@ -43,8 +43,31 @@ $this->setTitle('Commander') ;
?>

<div id="app-order-order" :class="{'loaded': !loadingInit}">
<div v-if="orderSuccess" class="alert alert-success" id="order-success">
<span class="glyphicon glyphicon-ok"></span> Votre commande a bien été prise en compte.
<div v-if="orderSuccess" id="order-success">
<div class="alert alert-success">
<span class="glyphicon glyphicon-ok glyphicon-big"></span>
<div class="content">
<h3>Votre commande a bien été prise en compte</h3>
<a href="<?= Yii::$app->urlManagerProducer->createUrl(['order/history']) ?>" class="btn btn-default">
<span class="glyphicon glyphicon-chevron-right"></span>
Voir toutes mes commandes
</a>
</div>
<div class="clr"></div>
</div>
<div class="alert alert-info">
<span class="glyphicon glyphicon-list-alt glyphicon-big"></span>
<div class="content">
<h3>Récapitulatif de votre commande</h3>
<ul>
<li><span class="glyphicon glyphicon-time"></span> {{ dateFormat }}</li>
<li><span class="glyphicon glyphicon-map-marker"></span> {{ pointSaleActive.name }} <span class="locality" v-if="pointSaleActive.locality.length > 0">à {{ pointSaleActive.locality }}</span></li>
<li><span class="glyphicon glyphicon-th-list"></span> {{ countProductOrdered() }} produits</li>
<li><span class="glyphicon glyphicon-chevron-right"></span> {{ priceTotal() }}</li>
</ul>
</div>
<div class="clr"></div>
</div>
</div>
<div v-else>
<div :class="(producer != null && producer.order_infos.length) ? 'col-md-9' : 'col-md-12'">
@@ -120,7 +143,7 @@ $this->setTitle('Commander') ;
</tr>
</thead>
<tbody>
<tr v-for="pointSale in pointsSale" v-if="pointSale && pointSale.pointSaleDistribution.delivery">
<tr v-for="pointSale in pointsSale" v-if="pointSale && pointSale.pointSaleDistribution.delivery" :class="(pointSaleActive && pointSale.id == pointSaleActive.id) ? 'selected' : ''">
<td class="name">
<span class="the-name">{{ pointSale.name }}</span>
<div class="comment" v-if="pointSale.userPointSale">
@@ -170,7 +193,7 @@ $this->setTitle('Commander') ;
<span class="description">{{ product.description }}</span>
<span v-if="product.weight">({{ product.weight }}g)</span>
</span>
<span v-if="product.quantity_remaining - product.quantity_form == 0 && product.quantity_max > 0" class="label label-danger">
<span v-if="product.quantity_form == product.quantity_remaining && product.quantity_max > 0" class="label label-danger">
Épuisé
</span>
<div class="recipe" v-if="product.recipe.length">{{ product.recipe }}</div>
@@ -181,11 +204,11 @@ $this->setTitle('Commander') ;
<td class="td-quantity">
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default btn-moins" type="button" @click="productQuantityClick(product, -1)"><span class="glyphicon glyphicon-minus"></span></button>
<button class="btn btn-default btn-moins" type="button" @click="productQuantityClick(product, -1)" :disabled="product.quantity_form == 0"><span class="glyphicon glyphicon-minus"></span></button>
</span>
<input type="text" v-model="product.quantity_form" class="form-control quantity" />
<input type="text" v-model="product.quantity_form" class="form-control quantity" readonly="readonly" />
<span class="input-group-btn">
<button class="btn btn-default btn-plus" type="button" @click="productQuantityClick(product, 1)"><span class="glyphicon glyphicon-plus"></span></button>
<button class="btn btn-default btn-plus" type="button" @click="productQuantityClick(product, 1)" :disabled="product.quantity_form == product.quantity_remaining && product.quantity_max > 0"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</td>

+ 57
- 11
producer/web/css/screen.css Ver arquivo

@@ -1340,57 +1340,103 @@ termes.
.order-order #app-order-order table#points-sale td.actions button {
width: 100%;
}
/* line 186, ../sass/order/_order.scss */
/* line 184, ../sass/order/_order.scss */
.order-order #app-order-order table#points-sale tr.selected td {
background-color: #F8F1DD;
}
/* line 192, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .name {
text-transform: uppercase;
font-family: "myriadpro-regular";
color: black;
font-size: 16px;
}
/* line 192, ../sass/order/_order.scss */
/* line 198, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .other {
font-size: 14px;
color: #333;
}
/* line 196, ../sass/order/_order.scss */
/* line 202, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .recipe {
color: gray;
}
/* line 200, ../sass/order/_order.scss */
/* line 206, ../sass/order/_order.scss */
.order-order #app-order-order table#products .price-unit, .order-order #app-order-order table#products .price-total {
width: 100px;
text-align: center;
}
/* line 204, ../sass/order/_order.scss */
/* line 210, ../sass/order/_order.scss */
.order-order #app-order-order table#products .td-quantity {
width: 150px;
}
/* line 206, ../sass/order/_order.scss */
/* line 212, ../sass/order/_order.scss */
.order-order #app-order-order table#products .td-quantity input.quantity {
text-align: center;
}
/* line 212, ../sass/order/_order.scss */
/* line 218, ../sass/order/_order.scss */
.order-order #app-order-order table#products tr.total .price-total {
font-size: 23px;
}
/* line 219, ../sass/order/_order.scss */
/* line 225, ../sass/order/_order.scss */
.order-order #app-order-order #content-step-payment .credit {
margin-top: 20px;
}
/* line 222, ../sass/order/_order.scss */
/* line 228, ../sass/order/_order.scss */
.order-order #app-order-order #content-step-payment .credit .info {
margin-left: 20px;
color: gray;
}
/* line 229, ../sass/order/_order.scss */
/* line 235, ../sass/order/_order.scss */
.order-order #app-order-order #infos {
margin-top: 30px;
}
/* line 231, ../sass/order/_order.scss */
/* line 237, ../sass/order/_order.scss */
.order-order #app-order-order #infos .panel-body {
padding-top: 0px;
white-space: pre-line;
}
/* line 245, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert.alert-success .glyphicon-big {
background-color: #00A65A;
}
/* line 251, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert.alert-info .glyphicon-big {
background-color: #0097BC;
padding: 50px 30px;
}
/* line 257, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert {
padding: 0px;
}
/* line 259, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert .glyphicon-big {
font-size: 90px;
color: white;
padding: 30px;
float: left;
}
/* line 266, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content {
color: #333;
padding: 20px;
margin-left: 151px;
}
/* line 271, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content h3 {
font-family: "myriadpro-light";
text-transform: uppercase;
font-size: 30px;
color: #333;
margin-bottom: 20px;
margin-top: 0px;
margin-left: 0px;
text-align: left;
padding-left: 0px;
}
/* line 283, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content .locality {
color: gray;
}

/**
Copyright La boîte à pain (2018)

+ 14
- 7
producer/web/js/vuejs/order-order.js Ver arquivo

@@ -139,14 +139,13 @@ var app = new Vue({
this.distribution = response.data.distribution ;
}
if(response.data.points_sale) {
this.pointsSale = [] ;
for(var key in response.data.points_sale) {
this.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key] ;
this.pointsSaleCodes[response.data.points_sale[key].id] = '' ;
Vue.set(this.pointsSaleCodes, response.data.points_sale[key].id, '');
}
}
@@ -154,8 +153,15 @@ var app = new Vue({
this.products = response.data.products ;
}
if(response.data.order) {
this.pointSaleActive = this.getPointSale(response.data.order.id_point_sale) ;
}
else {
this.pointSaleActive = null ;
}
this.loading = false ;
});
});
},
changeStep: function(step) {
var oldStep = this.step ;
@@ -213,9 +219,10 @@ var app = new Vue({
},
productQuantityClick: function(product, quantity) {
if( this.products[product.index].quantity_form + quantity >= 0 &&
( !this.products[product.index].quantity_remaining ||
this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_remaining
)) {
(this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_remaining ||
!this.products[product.index].quantity_max)
) {
this.products[product.index].quantity_form += quantity ;
}
},
@@ -255,7 +262,7 @@ var app = new Vue({
}
}
axios.post('ajax-create', {
axios.post('ajax-process', {
Order: {
id_distribution : this.distribution.id,
id_point_sale: this.pointSaleActive.id,

+ 53
- 0
producer/web/sass/order/_order.scss Ver arquivo

@@ -179,6 +179,12 @@
width: 100% ;
}
}
tr.selected {
td {
background-color: $color2 ;
}
}
}
table#products {
@@ -233,6 +239,53 @@
white-space: pre-line ;
}
}
#order-success {
.alert.alert-success {
.glyphicon-big {
background-color: #00A65A ;
}
}
.alert.alert-info {
.glyphicon-big {
background-color: #0097BC ;
padding: 50px 30px ;
}
}
.alert {
padding: 0px ;
.glyphicon-big {
font-size: 90px ;
color: white ;
padding: 30px ;
float: left ;
}

div.content {
color: #333 ;
padding: 20px ;
margin-left: 151px ;
h3 {
font-family: 'myriadpro-light' ;
text-transform: uppercase ;
font-size: 30px ;
color: #333 ;
margin-bottom: 20px ;
margin-top: 0px ;
margin-left: 0px ;
text-align: left ;
padding-left: 0px ;
}
.locality {
color: gray ;
}
}
}
}
}

Carregando…
Cancelar
Salvar