Browse Source

Merge branch 'dev'

master
Guillaume Bourgeois 5 years ago
parent
commit
4b61e51103
12 changed files with 153 additions and 88 deletions
  1. +2
    -14
      backend/controllers/OrderController.php
  2. +5
    -0
      backend/controllers/ProductController.php
  3. +6
    -0
      backend/views/producer/update.php
  4. +23
    -23
      backend/views/site/index.php
  5. +15
    -0
      backend/views/subscription/index.php
  6. +27
    -0
      common/models/Order.php
  7. +6
    -2
      common/models/Producer.php
  8. +1
    -1
      common/models/ProductSearch.php
  9. +16
    -0
      console/migrations/m190522_091006_option_comportement_annulation_commande.php
  10. +5
    -14
      producer/controllers/OrderController.php
  11. +39
    -33
      producer/web/css/screen.css
  12. +8
    -1
      producer/web/sass/_responsive.scss

+ 2
- 14
backend/controllers/OrderController.php View File

use common\models\User ; use common\models\User ;
use common\models\ProductDistribution ; use common\models\ProductDistribution ;
use common\models\Distribution ; use common\models\Distribution ;
use common\models\Producer ;


class OrderController extends BackendController class OrderController extends BackendController
{ {
// delete // delete
if ($order) { if ($order) {
// remboursement si l'utilisateur a payé pour cette commande
$amountPaid = $order->getAmount(Order::AMOUNT_PAID);
if ($amountPaid > 0.01) {
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$amountPaid,
Producer::getId(),
$order->id_user,
User::getCurrentId()
);
}

$order->delete();
ProductOrder::deleteAll(['id_order' => $idOrder]);
$order->delete() ;
} }


return ['success'] ; return ['success'] ;

+ 5
- 0
backend/controllers/ProductController.php View File



if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
$lastProductOrder = Product::find()->orderBy('order DESC')->one() ;
if($lastProductOrder) {
$model->order = $lastProductOrder->order ++ ;
}
Upload::uploadFile($model, 'photo'); Upload::uploadFile($model, 'photo');
$model->save(); $model->save();



+ 6
- 0
backend/views/producer/update.php View File

0 => 'Non', 0 => 'Non',
1 => 'Oui', 1 => 'Oui',
], []) ; ?> ], []) ; ?>
<?= $form->field($model, 'option_behavior_cancel_order')
->dropDownList([
Producer::BEHAVIOR_DELETE_ORDER_DELETE => 'Suppression de la commande',
Producer::BEHAVIOR_DELETE_ORDER_STATUS => 'Passage de la commande en statut "supprimé"',
], []) ; ?>
</div> </div>
</div> </div>



+ 23
- 23
backend/views/site/index.php View File

</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if(count($distributionsArray)): ?>
<div id="distributions"> <div id="distributions">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
</div> </div>
<div class="panel-body"> <div class="panel-body">
<!-- distributions --> <!-- distributions -->
<?php if(count($distributionsArray)): ?>
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
</span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span> </span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['distribution/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?><?= Html::a('<span class="fa fa-download"></span>', ['distribution/report', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?><?php endif; ?>
</div>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['distribution/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?><?= Html::a('<span class="fa fa-download"></span>', ['distribution/report', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?><?php endif; ?>
</div> </div>
</div> </div>
</div> </div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div> </div>
</div> </div>
</div> </div>
<?php endif; ?>
<div class="clr"></div> <div class="clr"></div>

+ 15
- 0
backend/views/subscription/index.php View File

$this->addBreadcrumb($this->getTitle()) ; $this->addBreadcrumb($this->getTitle()) ;
$this->addButton(['label' => 'Nouvel abonnement <span class="glyphicon glyphicon-plus"></span>', 'url' => 'subscription/create', 'class' => 'btn btn-primary']) ; $this->addButton(['label' => 'Nouvel abonnement <span class="glyphicon glyphicon-plus"></span>', 'url' => 'subscription/create', 'class' => 'btn btn-primary']) ;


$subscriptionsArray = Subscription::searchAll() ;
$hasUnitsNotMatch = false ;
foreach($subscriptionsArray as $subscription) {
if($subscription->hasUnitsNotMatch()) {
$hasUnitsNotMatch = true ;
}
}

?> ?>
<div class="subscription-index"> <div class="subscription-index">

<?php if($hasUnitsNotMatch) : ?>
<div class="alert alert-warning">
<span class="glyphicon glyphicon-warning-sign"></span> Attention, des unités ne correspondent pas entre vos produits et vos abonnements.<br />
Veuillez modifier vos abonnements et ajuster les unités / quantités pour régler le problème.
</div>
<?php endif; ?>
<?= GridView::widget([ <?= GridView::widget([
'filterModel' => $searchModel, 'filterModel' => $searchModel,

+ 27
- 0
common/models/Order.php View File

} }
} }
public function delete() {
// remboursement si l'utilisateur a payé pour cette commande
$amountPaid = $this->getAmount(Order::AMOUNT_PAID);
if ($amountPaid > 0.01) {
$this->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$amountPaid,
Producer::getId(),
$this->id_user,
User::getCurrentId()
);
}

// delete
if(Producer::getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE ||
(Producer::getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($this->date_delete)) ) {
ProductOrder::deleteAll(['id_order' => $this->id]);
return parent::delete() ;
}
// status 'delete'
elseif(Producer::getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) {
$this->date_delete = date('Y-m-d H:i:s');
return $this->save() ;
}
}
/** /**
* Retourne le montant de la commande (total, payé, restant, ou en surplus). * Retourne le montant de la commande (total, payé, restant, ou en surplus).
* *

+ 6
- 2
common/models/Producer.php View File

self::CREDIT_FUNCTIONING_USER => 'Basée sur l\'utilisateur', self::CREDIT_FUNCTIONING_USER => 'Basée sur l\'utilisateur',
]; ];
const BEHAVIOR_DELETE_ORDER_DELETE = 'delete' ;
const BEHAVIOR_DELETE_ORDER_STATUS = 'status' ;
var $secret_key_payplug ; var $secret_key_payplug ;
/** /**
$this->addError($attribute, 'Ce code est déjà utilisé par un autre producteur.'); $this->addError($attribute, 'Ce code est déjà utilisé par un autre producteur.');
} }
}], }],
[['description','mentions','gcs','order_infos','slug','secret_key_payplug','background_color_logo'], 'string'],
[['description','mentions','gcs','order_infos','slug','secret_key_payplug','background_color_logo','option_behavior_cancel_order'], 'string'],
[['negative_balance', 'credit', 'active','online_payment','user_manage_subscription', 'option_allow_user_gift','use_credit_checked_default'], 'boolean'], [['negative_balance', 'credit', 'active','online_payment','user_manage_subscription', 'option_allow_user_gift','use_credit_checked_default'], 'boolean'],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning'], 'string', 'max' => 255],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code','type','credit_functioning','option_behavior_cancel_order'], 'string', 'max' => 255],
[['free_price', 'credit_limit_reminder','credit_limit'], 'double'], [['free_price', 'credit_limit_reminder','credit_limit'], 'double'],
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'], ['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
]; ];
'credit_limit' => 'Crédit limite', 'credit_limit' => 'Crédit limite',
'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser mon crédit" lors de la commande de l\'utilisateur', 'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser mon crédit" lors de la commande de l\'utilisateur',
'background_color_logo' => 'Couleur de fond du logo', 'background_color_logo' => 'Couleur de fond du logo',
'option_behavior_cancel_order' => 'Comportement lors de la suppression d\'une commande',
]; ];
} }



+ 1
- 1
common/models/ProductSearch.php View File

'query' => $query, 'query' => $query,
'sort' => ['attributes' => ['order', 'photo', 'name', 'description','active']], 'sort' => ['attributes' => ['order', 'photo', 'name', 'description','active']],
'pagination' => [ 'pagination' => [
'pageSize' => 20,
'pageSize' => 1000,
], ],
]); ]);

+ 16
- 0
console/migrations/m190522_091006_option_comportement_annulation_commande.php View File

<?php

use yii\db\Migration;
use yii\db\mysql\Schema;
use common\models\Producer ;

class m190522_091006_option_comportement_annulation_commande extends Migration {

public function up() {
$this->addColumn('producer', 'option_behavior_cancel_order', Schema::TYPE_STRING.' DEFAULT \''.Producer::BEHAVIOR_DELETE_ORDER_STATUS.'\'') ;
}

public function down() {
$this->dropColumn('producer', 'option_behavior_cancel_order') ;
}
}

+ 5
- 14
producer/controllers/OrderController.php View File

} }


if ($order && User::getCurrentId() == $order->id_user) { if ($order && User::getCurrentId() == $order->id_user) {
// remboursement
if ($order->getAmount(Order::AMOUNT_PAID)) {
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$order->getAmount(Order::AMOUNT_PAID),
$order->distribution->id_producer,
User::getCurrentId(),
User::getCurrentId()
);
}
// delete
$order->date_delete = date('Y-m-d H:i:s');
$order->save() ;
$order->delete() ;
Yii::$app->session->setFlash('success','Votre commande a bien été annulée.') ; Yii::$app->session->setFlash('success','Votre commande a bien été annulée.') ;
} }
$indexProduct = 0 ; $indexProduct = 0 ;
foreach($productsArray as &$product) { foreach($productsArray as &$product) {
if(!isset($theProduct['productDistribution'][0])) {
$theProduct['productDistribution'][0] = $distribution->linkProduct($product) ;
}
$coefficient_unit = Product::$unitsArray[$product['unit']]['coefficient'] ; $coefficient_unit = Product::$unitsArray[$product['unit']]['coefficient'] ;
if(is_null($product['photo'])) { if(is_null($product['photo'])) {

+ 39
- 33
producer/web/css/screen.css View File

pris connaissance de la licence CeCILL, et que vous en avez accepté les pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes. termes.
*/ */
@media screen and (max-width: 768px) {
@media screen and (min-width: 768px) and (max-width: 992px) {
/* line 39, ../sass/_responsive.scss */ /* line 39, ../sass/_responsive.scss */
#left .fixed {
position: relative;
}
}
@media screen and (max-width: 768px) {
/* line 47, ../sass/_responsive.scss */
#header-bap { #header-bap {
display: block; display: block;
position: relative; position: relative;
width: 100%; width: 100%;
padding: 0px; padding: 0px;
} }
/* line 48, ../sass/_responsive.scss */
/* line 56, ../sass/_responsive.scss */
#header-bap #logo { #header-bap #logo {
margin-left: 10px; margin-left: 10px;
} }


/* line 54, ../sass/_responsive.scss */
/* line 62, ../sass/_responsive.scss */
#left .fixed { #left .fixed {
position: relative; position: relative;
} }


/* line 62, ../sass/_responsive.scss */
/* line 69, ../sass/_responsive.scss */
#main #img-big { #main #img-big {
display: none; display: none;
} }
/* line 68, ../sass/_responsive.scss */
/* line 75, ../sass/_responsive.scss */
#main nav#main-nav ul li { #main nav#main-nav ul li {
display: block; display: block;
float: none; float: none;
} }
/* line 72, ../sass/_responsive.scss */
/* line 79, ../sass/_responsive.scss */
#main nav#main-nav ul li.active a { #main nav#main-nav ul li.active a {
border-bottom: solid 1px white; border-bottom: solid 1px white;
background-color: #FF7F00; background-color: #FF7F00;
color: white; color: white;
} }
/* line 77, ../sass/_responsive.scss */
/* line 84, ../sass/_responsive.scss */
#main nav#main-nav ul li.active a:hover { #main nav#main-nav ul li.active a:hover {
background-color: #FF7F00; background-color: #FF7F00;
color: white; color: white;
} }
/* line 83, ../sass/_responsive.scss */
/* line 90, ../sass/_responsive.scss */
#main nav#main-nav ul li a { #main nav#main-nav ul li a {
display: block; display: block;
border-bottom: solid 1px #e0e0e0; border-bottom: solid 1px #e0e0e0;
} }
/* line 87, ../sass/_responsive.scss */
/* line 94, ../sass/_responsive.scss */
#main nav#main-nav ul li a:hover { #main nav#main-nav ul li a:hover {
background-color: white; background-color: white;
color: #FF7F00; color: #FF7F00;
} }
/* line 94, ../sass/_responsive.scss */
/* line 101, ../sass/_responsive.scss */
#main nav#main-nav ul li#btn-administration { #main nav#main-nav ul li#btn-administration {
float: none; float: none;
} }
/* line 96, ../sass/_responsive.scss */
/* line 103, ../sass/_responsive.scss */
#main nav#main-nav ul li#btn-administration a:hover { #main nav#main-nav ul li#btn-administration a:hover {
background-color: white; background-color: white;
color: #FF7F00; color: #FF7F00;
} }
/* line 104, ../sass/_responsive.scss */
/* line 111, ../sass/_responsive.scss */
#main h2#page-title { #main h2#page-title {
text-align: center; text-align: center;
} }
/* line 110, ../sass/_responsive.scss */
/* line 117, ../sass/_responsive.scss */
#main #products td { #main #products td {
padding: 3px; padding: 3px;
} }
/* line 114, ../sass/_responsive.scss */
/* line 121, ../sass/_responsive.scss */
#main #products .td-photo, #main #products .th-photo { #main #products .td-photo, #main #products .th-photo {
display: none; display: none;
} }
/* line 118, ../sass/_responsive.scss */
/* line 125, ../sass/_responsive.scss */
#main #products .product { #main #products .product {
font-size: 12px; font-size: 12px;
} }
/* line 120, ../sass/_responsive.scss */
/* line 127, ../sass/_responsive.scss */
#main #products .product .nom { #main #products .product .nom {
font-size: 15px; font-size: 15px;
} }
/* line 127, ../sass/_responsive.scss */
/* line 134, ../sass/_responsive.scss */
#main #bar-fixed { #main #bar-fixed {
position: relative; position: relative;
} }
/* line 129, ../sass/_responsive.scss */
/* line 136, ../sass/_responsive.scss */
#main #bar-fixed .btn-comment { #main #bar-fixed .btn-comment {
float: none; float: none;
display: block; display: block;
margin-top: 15px; margin-top: 15px;
} }


/* line 139, ../sass/_responsive.scss */
/* line 146, ../sass/_responsive.scss */
.order-create #main #content .order-form #products .table .input-group, .order-create #main #content .order-form #products .table .input-group,
.order-update #main #content .order-form #products .table .input-group { .order-update #main #content .order-form #products .table .input-group {
width: 60px; width: 60px;
} }
/* line 143, ../sass/_responsive.scss */
/* line 150, ../sass/_responsive.scss */
.order-create #main #content .order-form #products .table .input-group .form-control, .order-create #main #content .order-form #products .table .input-group .form-control,
.order-update #main #content .order-form #products .table .input-group .form-control { .order-update #main #content .order-form #products .table .input-group .form-control {
width: 20px; width: 20px;
padding: 3px; padding: 3px;
} }


/* line 149, ../sass/_responsive.scss */
/* line 156, ../sass/_responsive.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit, .order-create #main #content .order-form #bar-fixed #checkbox-credit,
.order-update #main #content .order-form #bar-fixed #checkbox-credit { .order-update #main #content .order-form #bar-fixed #checkbox-credit {
width: 100%; width: 100%;
margin: 0px; margin: 0px;
padding: 5px 0px; padding: 5px 0px;
} }
/* line 155, ../sass/_responsive.scss */
/* line 162, ../sass/_responsive.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit .the-credit, .order-create #main #content .order-form #bar-fixed #checkbox-credit .the-credit,
.order-update #main #content .order-form #bar-fixed #checkbox-credit .the-credit { .order-update #main #content .order-form #bar-fixed #checkbox-credit .the-credit {
word-break: break-all; word-break: break-all;
} }


/* line 160, ../sass/_responsive.scss */
/* line 167, ../sass/_responsive.scss */
.order-create #main #content .order-form #bar-fixed #block-confirm-order button, .order-create #main #content .order-form #bar-fixed #block-confirm-order button,
.order-update #main #content .order-form #bar-fixed #block-confirm-order button { .order-update #main #content .order-form #bar-fixed #block-confirm-order button {
width: 100%; width: 100%;
} }


/* line 168, ../sass/_responsive.scss */
/* line 175, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul { .order-order #app-order-order #steps ul {
height: auto; height: auto;
} }
/* line 170, ../sass/_responsive.scss */
/* line 177, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul li { .order-order #app-order-order #steps ul li {
padding-left: 0px; padding-left: 0px;
padding-right: 0px; padding-right: 0px;
} }
/* line 174, ../sass/_responsive.scss */
/* line 181, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul li .info-step { .order-order #app-order-order #steps ul li .info-step {
display: none; display: none;
} }
/* line 178, ../sass/_responsive.scss */
/* line 185, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul li .btn::after, .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::before {
display: none; display: none;
} }
/* line 189, ../sass/_responsive.scss */
/* line 196, ../sass/_responsive.scss */
.order-order #app-order-order table#products td.name .recipe { .order-order #app-order-order table#products td.name .recipe {
display: none; display: none;
} }
/* line 195, ../sass/_responsive.scss */
/* line 202, ../sass/_responsive.scss */
.order-order #app-order-order table#products td.td-quantity .input-group-btn { .order-order #app-order-order table#products td.td-quantity .input-group-btn {
width: 100%; width: 100%;
display: block; display: block;
} }
/* line 199, ../sass/_responsive.scss */
/* line 206, ../sass/_responsive.scss */
.order-order #app-order-order table#products td.td-quantity .input-group-btn button { .order-order #app-order-order table#products td.td-quantity .input-group-btn button {
width: 100%; width: 100%;
display: block; display: block;
} }
/* line 209, ../sass/_responsive.scss */
/* line 216, ../sass/_responsive.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;
text-align: center; text-align: center;
margin-bottom: 20px; margin-bottom: 20px;
} }
/* line 218, ../sass/_responsive.scss */
/* line 225, ../sass/_responsive.scss */
.order-order #app-order-order #order-success .alert div.content { .order-order #app-order-order #order-success .alert div.content {
margin-left: 0px; margin-left: 0px;
text-align: center; text-align: center;
} }


/* line 229, ../sass/_responsive.scss */
/* line 236, ../sass/_responsive.scss */
#footer .content { #footer .content {
text-align: center; text-align: center;
} }

+ 8
- 1
producer/web/sass/_responsive.scss View File

termes. termes.
*/ */


@media screen and (min-width: 768px) and (max-width: 992px) {
#left {
.fixed {
position: relative ;
}
}
}

@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
#header-bap { #header-bap {
} }
} }
#main { #main {
#img-big { #img-big {

Loading…
Cancel
Save