Bladeren bron

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

dev
Guillaume Bourgeois 5 jaren geleden
bovenliggende
commit
4956a18eba
7 gewijzigde bestanden met toevoegingen van 109 en 73 verwijderingen
  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 Bestand weergeven

@@ -376,6 +376,30 @@ class Producer extends ActiveRecordCommon
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 Bestand weergeven

@@ -63,9 +63,21 @@ class OrderController extends ProducerBaseController
];
}
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) ;
}

/**
@@ -384,19 +396,17 @@ class OrderController extends ProducerBaseController
$productsArray[] = $product;
}
}
$producer = $this->getProducer() ;

// date
$errorDate = false;
if (isset($order->id_distribution)) {
// date de commande
$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;
}
}
@@ -615,18 +625,7 @@ class OrderController extends ProducerBaseController
] ;
// 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([
'active' => 1

+ 2
- 2
producer/views/order/history.php Bestand weergeven

@@ -102,7 +102,7 @@ GridView::widget([
if($c->date_delete) {
$html .= '<span class="label label-danger">Annulée</span><br />' ;
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 {
@@ -114,7 +114,7 @@ GridView::widget([
}
elseif($c->getState() == Order::STATE_OPEN) {
$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">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>

+ 3
- 0
producer/views/order/order.php Bestand weergeven

@@ -43,6 +43,9 @@ $this->setTitle('Commander') ;
?>

<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 class="alert alert-success">
<span class="glyphicon glyphicon-ok glyphicon-big"></span>

+ 53
- 49
producer/web/css/screen.css Bestand weergeven

@@ -1179,34 +1179,38 @@ termes.
display: block;
}
/* 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 {
transition: all .2s ease;
}
/* line 15, ../sass/order/_order.scss */
/* line 19, ../sass/order/_order.scss */
.order-order #app-order-order .slide-leave-active {
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 {
transform: translateX(10px);
opacity: 0;
}
/* line 24, ../sass/order/_order.scss */
/* line 28, ../sass/order/_order.scss */
.order-order #app-order-order #steps {
margin-bottom: 20px;
}
/* line 26, ../sass/order/_order.scss */
/* line 30, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul {
margin-top: 30px;
}
/* line 28, ../sass/order/_order.scss */
/* line 32, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li {
text-align: center;
padding-right: 8px;
padding-left: 8px;
position: relative;
}
/* line 34, ../sass/order/_order.scss */
/* line 38, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .info-step {
position: absolute;
top: -30px;
@@ -1214,26 +1218,26 @@ termes.
width: 100%;
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 {
float: right;
color: gray;
position: relative;
top: 10px;
}
/* line 50, ../sass/order/_order.scss */
/* line 54, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li#step-date {
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 {
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 {
display: none;
}
/* line 63, ../sass/order/_order.scss */
/* line 67, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn {
color: #333;
text-transform: uppercase;
@@ -1247,180 +1251,180 @@ termes.
border: 0px none;
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 {
position: relative;
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 {
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 {
content: "";
position: absolute;
top: -1px;
}
/* line 89, ../sass/order/_order.scss */
/* line 93, ../sass/order/_order.scss */
.order-order #app-order-order #steps ul li .btn::after {
right: -34px;
border: 17px solid transparent;
border-left: 17px solid #e0e0e0;
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 {
left: 0px;
border: 17px solid transparent;
border-left: 17px solid white;
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 {
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 {
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 #distribution-date-color {
width: 13px;
height: 13px;
display: inline-block;
}
/* line 132, ../sass/order/_order.scss */
/* line 136, ../sass/order/_order.scss */
.order-order #app-order-order #legend #order-date-color {
background-color: #018548;
}
/* line 135, ../sass/order/_order.scss */
/* line 139, ../sass/order/_order.scss */
.order-order #app-order-order #legend #distribution-date-color {
background-color: #00A65A;
}
/* line 140, ../sass/order/_order.scss */
/* line 144, ../sass/order/_order.scss */
.order-order #app-order-order #calendar {
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] {
font-size: 2rem;
}
/* line 145, ../sass/order/_order.scss */
/* line 149, ../sass/order/_order.scss */
.order-order #app-order-order #calendar .c-day-background {
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 {
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 {
font-size: 1.3rem;
}
/* line 160, ../sass/order/_order.scss */
/* line 164, ../sass/order/_order.scss */
.order-order #app-order-order .block-actions {
text-align: right;
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 {
text-transform: uppercase;
font-family: "myriadpro-regular";
color: black;
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 {
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 {
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 {
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 {
text-transform: uppercase;
font-family: "myriadpro-regular";
color: black;
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 {
font-size: 14px;
color: #333;
}
/* line 201, ../sass/order/_order.scss */
/* line 205, ../sass/order/_order.scss */
.order-order #app-order-order table#products td.name .recipe {
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 {
width: 100px;
text-align: center;
}
/* line 209, ../sass/order/_order.scss */
/* line 213, ../sass/order/_order.scss */
.order-order #app-order-order table#products .td-quantity {
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 {
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 {
font-size: 23px;
}
/* line 224, ../sass/order/_order.scss */
/* line 228, ../sass/order/_order.scss */
.order-order #app-order-order #content-step-payment .credit {
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 {
margin-left: 20px;
color: gray;
}
/* line 234, ../sass/order/_order.scss */
/* line 238, ../sass/order/_order.scss */
.order-order #app-order-order #infos {
margin-top: 30px;
}
/* line 236, ../sass/order/_order.scss */
/* line 240, ../sass/order/_order.scss */
.order-order #app-order-order #infos .panel-body {
padding-top: 0px;
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 {
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 {
background-color: #0097BC;
padding: 55px 30px;
}
/* line 256, ../sass/order/_order.scss */
/* line 260, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert {
padding: 0px;
}
/* line 258, ../sass/order/_order.scss */
/* line 262, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert .glyphicon-big {
font-size: 90px;
color: white;
padding: 30px;
float: left;
}
/* line 265, ../sass/order/_order.scss */
/* line 269, ../sass/order/_order.scss */
.order-order #app-order-order #order-success .alert div.content {
color: #333;
padding: 20px;
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 {
font-family: "myriadpro-light";
text-transform: uppercase;
@@ -1433,7 +1437,7 @@ termes.
padding-left: 0px;
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 {
color: gray;
}

+ 4
- 2
producer/web/js/vuejs/order-order.js Bestand weergeven

@@ -56,12 +56,14 @@ var app = new Vue({
},
},
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)+ '/'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '/'
+ this.date.getFullYear() ;
this.changeStep('point-sale') ;
}
this.init() ;
this.loadingInit = false ;
},

+ 4
- 0
producer/web/sass/order/_order.scss Bestand weergeven

@@ -8,6 +8,10 @@
display: block ;
}
#order-distribution-date {
display: none ;
}
.slide-enter-active {
transition: all .2s ease;
}

Laden…
Annuleren
Opslaan