Browse Source

Gestion de l'id en paramètre pour l'update

refactoring
Guillaume Bourgeois 6 years ago
parent
commit
4956a18eba
7 changed files with 109 additions and 73 deletions
  1. +24
    -0
      common/models/Producer.php
  2. +19
    -20
      producer/controllers/OrderController.php
  3. +2
    -2
      producer/views/order/history.php
  4. +3
    -0
      producer/views/order/order.php
  5. +53
    -49
      producer/web/css/screen.css
  6. +4
    -2
      producer/web/js/vuejs/order-order.js
  7. +4
    -0
      producer/web/sass/order/_order.scss

+ 24
- 0
common/models/Producer.php View File

return false ; return false ;
} }
/**
* Retourne la date la plus proche où il est possible de commander.
* Attention, cette méthode ne garantit pas qu'une distribution a été initialisée
* à cette date.
*
* @return string
*/
public function getEarliestDateOrder()
{
$deadline = 20;
$earliestDateOrder = date('Y-m-d');
if($this->order_deadline) {
$deadline = $this->order_deadline;
}
if (date('H') >= $deadline) {
$earliestDateOrder = date('Y-m-d', strtotime(date('Y-m-d')) + ($this->order_delay) * (24 * 60 * 60));
} else {
$earliestDateOrder = date('Y-m-d', strtotime(date('Y-m-d')) + ($this->order_delay - 1) * (24 * 60 * 60));
}
return $earliestDateOrder ;
}


} }

+ 19
- 20
producer/controllers/OrderController.php View File

]; ];
} }
public function actionOrder()
public function actionOrder($id = 0)
{ {
return $this->render('order') ;
$params = [] ;
if($id) {
$order = Order::searchOne([
'id' => $id
]) ;
if($order) {
if($order->getState() == Order::STATE_OPEN) {
$params['order'] = $order ;
}
}
}
return $this->render('order', $params) ;
} }


/** /**
$productsArray[] = $product; $productsArray[] = $product;
} }
} }
$producer = $this->getProducer() ;


// date // date
$errorDate = false; $errorDate = false;
if (isset($order->id_distribution)) { if (isset($order->id_distribution)) {
// date de commande // date de commande
$distribution = Distribution::find()->where(['id' => $order->id_distribution])->one(); $distribution = Distribution::find()->where(['id' => $order->id_distribution])->one();
if (date('H') >= 20) {
$date = date('Y-m-d', strtotime(date('Y-m-d')) + 60 * 60 * 24);
} else {
$date = date('Y-m-d');
}
$date = $this->getProducer()->getEarliestDateOrder() ;


if ($distribution->date < $date) {
if($order->getState() != Order::STATE_OPEN) {
$errorDate = true; $errorDate = true;
} }
} }
] ; ] ;
// Distributions // 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));
}
}
$dateMini = $producer->getEarliestDateOrder() ;
$distributionsArray = Distribution::searchAll([ $distributionsArray = Distribution::searchAll([
'active' => 1 'active' => 1

+ 2
- 2
producer/views/order/history.php View File

if($c->date_delete) { if($c->date_delete) {
$html .= '<span class="label label-danger">Annulée</span><br />' ; $html .= '<span class="label label-danger">Annulée</span><br />' ;
if($c->getState() == Order::STATE_OPEN) { if($c->getState() == Order::STATE_OPEN) {
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/update','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>' ;
$html .= '<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>' ;
} }
} }
else { else {
} }
elseif($c->getState() == Order::STATE_OPEN) { elseif($c->getState() == Order::STATE_OPEN) {
$html .= '<div class="btn-group"> $html .= '<div class="btn-group">
<a href="'.Yii::$app->urlManager->createUrl(['order/update','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<a href="'.Yii::$app->urlManager->createUrl(['order/order','id'=>$c->id]).'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span> <span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span> <span class="sr-only">Toggle Dropdown</span>

+ 3
- 0
producer/views/order/order.php View File

?> ?>


<div id="app-order-order" :class="{'loaded': !loadingInit}"> <div id="app-order-order" :class="{'loaded': !loadingInit}">
<?php if(isset($order)): ?>
<span id="order-distribution-date"><?= $order->distribution->date; ?></span>
<?php endif; ?>
<div v-if="orderSuccess" id="order-success"> <div v-if="orderSuccess" id="order-success">
<div class="alert alert-success"> <div class="alert alert-success">
<span class="glyphicon glyphicon-ok glyphicon-big"></span> <span class="glyphicon glyphicon-ok glyphicon-big"></span>

+ 53
- 49
producer/web/css/screen.css View File

display: block; display: block;
} }
/* line 11, ../sass/order/_order.scss */ /* line 11, ../sass/order/_order.scss */
.order-order #app-order-order #order-distribution-date {
display: none;
}
/* line 15, ../sass/order/_order.scss */
.order-order #app-order-order .slide-enter-active { .order-order #app-order-order .slide-enter-active {
transition: all .2s ease; transition: all .2s ease;
} }
/* line 15, ../sass/order/_order.scss */
/* line 19, ../sass/order/_order.scss */
.order-order #app-order-order .slide-leave-active { .order-order #app-order-order .slide-leave-active {
transition: all 0s ease; transition: all 0s ease;
} }
/* line 19, ../sass/order/_order.scss */
/* line 23, ../sass/order/_order.scss */
.order-order #app-order-order .slide-enter, .order-order #app-order-order .slide-leave-to { .order-order #app-order-order .slide-enter, .order-order #app-order-order .slide-leave-to {
transform: translateX(10px); transform: translateX(10px);
opacity: 0; opacity: 0;
} }
/* line 24, ../sass/order/_order.scss */
/* line 28, ../sass/order/_order.scss */
.order-order #app-order-order #steps { .order-order #app-order-order #steps {
margin-bottom: 20px; margin-bottom: 20px;
} }
/* line 26, ../sass/order/_order.scss */
/* line 30, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul { .order-order #app-order-order #steps ul {
margin-top: 30px; margin-top: 30px;
} }
/* line 28, ../sass/order/_order.scss */
/* line 32, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li { .order-order #app-order-order #steps ul li {
text-align: center; text-align: center;
padding-right: 8px; padding-right: 8px;
padding-left: 8px; padding-left: 8px;
position: relative; position: relative;
} }
/* line 34, ../sass/order/_order.scss */
/* line 38, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .info-step { .order-order #app-order-order #steps ul li .info-step {
position: absolute; position: absolute;
top: -30px; top: -30px;
width: 100%; width: 100%;
text-transform: normal; text-transform: normal;
} }
/* line 42, ../sass/order/_order.scss */
/* line 46, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .glyphicon-chevron-right, .order-order #app-order-order #steps ul li.active .glyphicon-chevron-right { .order-order #app-order-order #steps ul li .glyphicon-chevron-right, .order-order #app-order-order #steps ul li.active .glyphicon-chevron-right {
float: right; float: right;
color: gray; color: gray;
position: relative; position: relative;
top: 10px; top: 10px;
} }
/* line 50, ../sass/order/_order.scss */
/* line 54, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li#step-date { .order-order #app-order-order #steps ul li#step-date {
padding-left: 0px; padding-left: 0px;
} }
/* line 54, ../sass/order/_order.scss */
/* line 58, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li#step-payment { .order-order #app-order-order #steps ul li#step-payment {
padding-right: 0px; padding-right: 0px;
} }
/* line 58, ../sass/order/_order.scss */
/* line 62, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li#step-payment .btn::after, .order-order #app-order-order #steps ul li#step-date .btn::before { .order-order #app-order-order #steps ul li#step-payment .btn::after, .order-order #app-order-order #steps ul li#step-date .btn::before {
display: none; display: none;
} }
/* line 63, ../sass/order/_order.scss */
/* line 67, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn { .order-order #app-order-order #steps ul li .btn {
color: #333; color: #333;
text-transform: uppercase; text-transform: uppercase;
border: 0px none; border: 0px none;
text-transform: uppercase; text-transform: uppercase;
} }
/* line 74, ../sass/order/_order.scss */
/* line 78, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn .button-content { .order-order #app-order-order #steps ul li .btn .button-content {
position: relative; position: relative;
left: 8px; left: 8px;
} }
/* line 79, ../sass/order/_order.scss */
/* line 83, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn.btn-primary { .order-order #app-order-order #steps ul li .btn.btn-primary {
background-color: #BB8757; background-color: #BB8757;
} }
/* line 83, ../sass/order/_order.scss */
/* line 87, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn::after, .order-order #app-order-order #steps ul li .btn::before { .order-order #app-order-order #steps ul li .btn::after, .order-order #app-order-order #steps ul li .btn::before {
content: ""; content: "";
position: absolute; position: absolute;
top: -1px; top: -1px;
} }
/* line 89, ../sass/order/_order.scss */
/* line 93, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn::after { .order-order #app-order-order #steps ul li .btn::after {
right: -34px; right: -34px;
border: 17px solid transparent; border: 17px solid transparent;
border-left: 17px solid #e0e0e0; border-left: 17px solid #e0e0e0;
background-color: transparent; background-color: transparent;
} }
/* line 96, ../sass/order/_order.scss */
/* line 100, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn::before { .order-order #app-order-order #steps ul li .btn::before {
left: 0px; left: 0px;
border: 17px solid transparent; border: 17px solid transparent;
border-left: 17px solid white; border-left: 17px solid white;
background-color: transparent; background-color: transparent;
} }
/* line 103, ../sass/order/_order.scss */
/* line 107, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn.btn-primary::after { .order-order #app-order-order #steps ul li .btn.btn-primary::after {
border-left: 17px solid #BB8757; border-left: 17px solid #BB8757;
} }
/* line 117, ../sass/order/_order.scss */
/* line 121, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn-primary { .order-order #app-order-order #steps ul li .btn-primary {
color: white; color: white;
} }
/* line 125, ../sass/order/_order.scss */
/* line 129, ../sass/order/_order.scss */
.order-order #app-order-order #legend #order-date-color, .order-order #app-order-order #legend #order-date-color,
.order-order #app-order-order #legend #distribution-date-color { .order-order #app-order-order #legend #distribution-date-color {
width: 13px; width: 13px;
height: 13px; height: 13px;
display: inline-block; display: inline-block;
} }
/* line 132, ../sass/order/_order.scss */
/* line 136, ../sass/order/_order.scss */
.order-order #app-order-order #legend #order-date-color { .order-order #app-order-order #legend #order-date-color {
background-color: #018548; background-color: #018548;
} }
/* line 135, ../sass/order/_order.scss */
/* line 139, ../sass/order/_order.scss */
.order-order #app-order-order #legend #distribution-date-color { .order-order #app-order-order #legend #distribution-date-color {
background-color: #00A65A; background-color: #00A65A;
} }
/* line 140, ../sass/order/_order.scss */
/* line 144, ../sass/order/_order.scss */
.order-order #app-order-order #calendar { .order-order #app-order-order #calendar {
margin-bottom: 15px; margin-bottom: 15px;
} }
/* line 142, ../sass/order/_order.scss */
/* line 146, ../sass/order/_order.scss */
.order-order #app-order-order #calendar .c-header .c-title-layout .c-title-popover .c-title-anchor .c-title[data-v-2083cb72] { .order-order #app-order-order #calendar .c-header .c-title-layout .c-title-popover .c-title-anchor .c-title[data-v-2083cb72] {
font-size: 2rem; font-size: 2rem;
} }
/* line 145, ../sass/order/_order.scss */
/* line 149, ../sass/order/_order.scss */
.order-order #app-order-order #calendar .c-day-background { .order-order #app-order-order #calendar .c-day-background {
padding: 20px; padding: 20px;
} }
/* line 150, ../sass/order/_order.scss */
/* line 154, ../sass/order/_order.scss */
.order-order #app-order-order #calendar .c-day:hover .c-day-background { .order-order #app-order-order #calendar .c-day:hover .c-day-background {
background-color: #F39C12 !important; background-color: #F39C12 !important;
} }
/* line 155, ../sass/order/_order.scss */
/* line 159, ../sass/order/_order.scss */
.order-order #app-order-order #calendar .c-day-popover-content { .order-order #app-order-order #calendar .c-day-popover-content {
font-size: 1.3rem; font-size: 1.3rem;
} }
/* line 160, ../sass/order/_order.scss */
/* line 164, ../sass/order/_order.scss */
.order-order #app-order-order .block-actions { .order-order #app-order-order .block-actions {
text-align: right; text-align: right;
margin-top: 20px; margin-top: 20px;
} }
/* line 167, ../sass/order/_order.scss */
/* line 171, ../sass/order/_order.scss */
.order-order #app-order-order table#points-sale td.name .the-name { .order-order #app-order-order table#points-sale td.name .the-name {
text-transform: uppercase; text-transform: uppercase;
font-family: "myriadpro-regular"; font-family: "myriadpro-regular";
color: black; color: black;
font-size: 16px; font-size: 16px;
} }
/* line 175, ../sass/order/_order.scss */
/* line 179, ../sass/order/_order.scss */
.order-order #app-order-order table#points-sale td.actions { .order-order #app-order-order table#points-sale td.actions {
width: 150px; width: 150px;
} }
/* line 177, ../sass/order/_order.scss */
/* line 181, ../sass/order/_order.scss */
.order-order #app-order-order table#points-sale td.actions button { .order-order #app-order-order table#points-sale td.actions button {
width: 100%; width: 100%;
} }
/* line 183, ../sass/order/_order.scss */
/* line 187, ../sass/order/_order.scss */
.order-order #app-order-order table#points-sale tr.selected td { .order-order #app-order-order table#points-sale tr.selected td {
background-color: #F8F1DD; background-color: #F8F1DD;
} }
/* line 191, ../sass/order/_order.scss */
/* line 195, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .name { .order-order #app-order-order table#products td.name .name {
text-transform: uppercase; text-transform: uppercase;
font-family: "myriadpro-regular"; font-family: "myriadpro-regular";
color: black; color: black;
font-size: 16px; font-size: 16px;
} }
/* line 197, ../sass/order/_order.scss */
/* line 201, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .other { .order-order #app-order-order table#products td.name .other {
font-size: 14px; font-size: 14px;
color: #333; color: #333;
} }
/* line 201, ../sass/order/_order.scss */
/* line 205, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .recipe { .order-order #app-order-order table#products td.name .recipe {
color: gray; color: gray;
} }
/* line 205, ../sass/order/_order.scss */
/* line 209, ../sass/order/_order.scss */
.order-order #app-order-order table#products .price-unit, .order-order #app-order-order table#products .price-total { .order-order #app-order-order table#products .price-unit, .order-order #app-order-order table#products .price-total {
width: 100px; width: 100px;
text-align: center; text-align: center;
} }
/* line 209, ../sass/order/_order.scss */
/* line 213, ../sass/order/_order.scss */
.order-order #app-order-order table#products .td-quantity { .order-order #app-order-order table#products .td-quantity {
width: 150px; width: 150px;
} }
/* line 211, ../sass/order/_order.scss */
/* line 215, ../sass/order/_order.scss */
.order-order #app-order-order table#products .td-quantity input.quantity { .order-order #app-order-order table#products .td-quantity input.quantity {
text-align: center; text-align: center;
} }
/* line 217, ../sass/order/_order.scss */
/* line 221, ../sass/order/_order.scss */
.order-order #app-order-order table#products tr.total .price-total { .order-order #app-order-order table#products tr.total .price-total {
font-size: 23px; font-size: 23px;
} }
/* line 224, ../sass/order/_order.scss */
/* line 228, ../sass/order/_order.scss */
.order-order #app-order-order #content-step-payment .credit { .order-order #app-order-order #content-step-payment .credit {
margin-top: 20px; margin-top: 20px;
} }
/* line 227, ../sass/order/_order.scss */
/* line 231, ../sass/order/_order.scss */
.order-order #app-order-order #content-step-payment .credit .info { .order-order #app-order-order #content-step-payment .credit .info {
margin-left: 20px; margin-left: 20px;
color: gray; color: gray;
} }
/* line 234, ../sass/order/_order.scss */
/* line 238, ../sass/order/_order.scss */
.order-order #app-order-order #infos { .order-order #app-order-order #infos {
margin-top: 30px; margin-top: 30px;
} }
/* line 236, ../sass/order/_order.scss */
/* line 240, ../sass/order/_order.scss */
.order-order #app-order-order #infos .panel-body { .order-order #app-order-order #infos .panel-body {
padding-top: 0px; padding-top: 0px;
white-space: pre-line; white-space: pre-line;
} }
/* line 244, ../sass/order/_order.scss */
/* line 248, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert.alert-success .glyphicon-big { .order-order #app-order-order #order-success .alert.alert-success .glyphicon-big {
background-color: #00A65A; background-color: #00A65A;
} }
/* line 250, ../sass/order/_order.scss */
/* line 254, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert.alert-info .glyphicon-big { .order-order #app-order-order #order-success .alert.alert-info .glyphicon-big {
background-color: #0097BC; background-color: #0097BC;
padding: 55px 30px; padding: 55px 30px;
} }
/* line 256, ../sass/order/_order.scss */
/* line 260, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert { .order-order #app-order-order #order-success .alert {
padding: 0px; padding: 0px;
} }
/* line 258, ../sass/order/_order.scss */
/* line 262, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert .glyphicon-big { .order-order #app-order-order #order-success .alert .glyphicon-big {
font-size: 90px; font-size: 90px;
color: white; color: white;
padding: 30px; padding: 30px;
float: left; float: left;
} }
/* line 265, ../sass/order/_order.scss */
/* line 269, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content { .order-order #app-order-order #order-success .alert div.content {
color: #333; color: #333;
padding: 20px; padding: 20px;
margin-left: 151px; margin-left: 151px;
} }
/* line 270, ../sass/order/_order.scss */
/* line 274, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content h3 { .order-order #app-order-order #order-success .alert div.content h3 {
font-family: "myriadpro-light"; font-family: "myriadpro-light";
text-transform: uppercase; text-transform: uppercase;
padding-left: 0px; padding-left: 0px;
line-height: 35px; line-height: 35px;
} }
/* line 283, ../sass/order/_order.scss */
/* line 287, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content .locality { .order-order #app-order-order #order-success .alert div.content .locality {
color: gray; color: gray;
} }

+ 4
- 2
producer/web/js/vuejs/order-order.js View File

}, },
}, },
mounted: function() { mounted: function() {
if($('#distribution-date').size()) {
this.date = new Date($('#distribution-date').html()) ;
if($('#order-distribution-date').size()) {
this.date = new Date($('#order-distribution-date').html()) ;
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/' this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/' + ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ; + this.date.getFullYear() ;
this.changeStep('point-sale') ;
} }
this.init() ; this.init() ;
this.loadingInit = false ; this.loadingInit = false ;
}, },

+ 4
- 0
producer/web/sass/order/_order.scss View File

display: block ; display: block ;
} }
#order-distribution-date {
display: none ;
}
.slide-enter-active { .slide-enter-active {
transition: all .2s ease; transition: all .2s ease;
} }

Loading…
Cancel
Save