use common\models\ProductDistribution ; | use common\models\ProductDistribution ; | ||||
use common\models\User ; | use common\models\User ; | ||||
use common\models\Producer ; | |||||
use DateTime; | use DateTime; | ||||
class OrderController extends ProducerBaseController | class OrderController extends ProducerBaseController | ||||
$format = 'Y-m-d' ; | $format = 'Y-m-d' ; | ||||
$dateObject = DateTime::createFromFormat($format, $date); | $dateObject = DateTime::createFromFormat($format, $date); | ||||
// Distributions | |||||
$distributionsArray = Distribution::searchAll([ | $distributionsArray = Distribution::searchAll([ | ||||
'active' => 1 | 'active' => 1 | ||||
], [ | ], [ | ||||
]) ; | ]) ; | ||||
$json['distributions'] = $distributionsArray ; | $json['distributions'] = $distributionsArray ; | ||||
// Producteur | |||||
$json['producer'] = Producer::searchOne([ | |||||
'id' => $this->getProducer()->id | |||||
]) ; | |||||
if($dateObject && $dateObject->format($format) === $date) { | if($dateObject && $dateObject->format($format) === $date) { | ||||
// distribution | // distribution | ||||
$distribution = Distribution::initDistribution($date) ; | $distribution = Distribution::initDistribution($date) ; |
?> | ?> | ||||
<div id="app-order-order"> | <div id="app-order-order"> | ||||
<div class="col-md-9"> | |||||
<div :class="(producer.order_infos.length) ? 'col-md-9' : 'col-md-12'"> | |||||
<div id="steps"> | <div id="steps"> | ||||
<ul> | <ul> | ||||
<li id="step-date" :class="'col-md-3 '+((step == 'date') ? 'active' : '')"> | <li id="step-date" :class="'col-md-3 '+((step == 'date') ? 'active' : '')"> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td colspan="3"></td> | <td colspan="3"></td> | ||||
<td>{{ priceTotal() }}</td> | |||||
<td class="price-total">{{ priceTotal() }}</td> | |||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div id="summary" class="col-md-3" v-if="date"> | |||||
<div id="infos" class="col-md-3" v-if="producer.order_infos.length"> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
Résumé | |||||
Informations | |||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<span class="glyphicon glyphicon-time"></span> {{ dateFormat }} | |||||
{{ producer.order_infos }} | |||||
<!--<span class="glyphicon glyphicon-time"></span> {{ dateFormat }} | |||||
<div v-if="pointSaleActive"> | <div v-if="pointSaleActive"> | ||||
<span class="glyphicon glyphicon-map-marker"></span> | <span class="glyphicon glyphicon-map-marker"></span> | ||||
{{ pointSaleActive.name }} | {{ pointSaleActive.name }} | ||||
<div class="products" v-if="products.length && oneProductOrdered()"> | <div class="products" v-if="products.length && oneProductOrdered()"> | ||||
<span class="glyphicon glyphicon-euro"></span> | <span class="glyphicon glyphicon-euro"></span> | ||||
{{ priceTotal() }} | {{ priceTotal() }} | ||||
</div> | |||||
</div>--> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> |
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 72, ../sass/order/_order.scss */ | /* line 72, ../sass/order/_order.scss */ | ||||
.order-order #app-order-order #summary .glyphicon { | |||||
margin-right: 11px; | |||||
} | |||||
/* line 76, ../sass/order/_order.scss */ | |||||
.order-order #app-order-order #summary .products ul { | |||||
padding-left: 30px; | |||||
position: relative; | |||||
top: -19px; | |||||
.order-order #app-order-order #infos .panel-body { | |||||
padding-top: 0px; | |||||
white-space: pre-line; | |||||
} | } | ||||
/** | /** |
el: '#app-order-order', | el: '#app-order-order', | ||||
data: { | data: { | ||||
step: 'date', | step: 'date', | ||||
producer: null, | |||||
date: null, | date: null, | ||||
dateFormat: null, | dateFormat: null, | ||||
pointsSale: [], | pointsSale: [], | ||||
}, | }, | ||||
formatPrice: function(price) { | formatPrice: function(price) { | ||||
var isNumberRegExp = new RegExp(/^[-+]?[0-9]+(\.[0-9]+)*$/); | var isNumberRegExp = new RegExp(/^[-+]?[0-9]+(\.[0-9]+)*$/); | ||||
if(isNumberRegExp.test(price)) { | |||||
if(isNumberRegExp.test(price) && price > 0) { | |||||
return Number(price).toFixed(2).replace('.',',')+' €' ; | return Number(price).toFixed(2).replace('.',',')+' €' ; | ||||
} | } | ||||
return '' ; | |||||
return '--' ; | |||||
}, | }, | ||||
getPointSale: function(idPointSale) { | getPointSale: function(idPointSale) { | ||||
for(var key in this.pointsSale) { | for(var key in this.pointsSale) { | ||||
init: function() { | init: function() { | ||||
axios.get("ajax-infos",{params: {date : this.getDate()}}) | axios.get("ajax-infos",{params: {date : this.getDate()}}) | ||||
.then(response => { | .then(response => { | ||||
this.producer = response.data.producer ; | |||||
this.calendar.attrs = [] ; | this.calendar.attrs = [] ; | ||||
var distributions = response.data.distributions ; | var distributions = response.data.distributions ; | ||||
if(distributions.length) { | if(distributions.length) { | ||||
price += this.products[key].quantity_form * this.products[key].price ; | price += this.products[key].quantity_form * this.products[key].price ; | ||||
} | } | ||||
} | } | ||||
return this.formatPrice(price) ; | return this.formatPrice(price) ; | ||||
} | } | ||||
} | } |
} | } | ||||
} | } | ||||
#summary { | |||||
.glyphicon { | |||||
margin-right: 11px ; | |||||
} | |||||
.products { | |||||
ul { | |||||
padding-left: 30px ; | |||||
position: relative ; | |||||
top: -19px ; | |||||
} | |||||
#infos { | |||||
.panel-body { | |||||
padding-top: 0px ; | |||||
white-space: pre-line ; | |||||
} | } | ||||
} | } | ||||
} | } |