Bläddra i källkod

Merge branch 'dev'

master
Guillaume Bourgeois 5 år sedan
förälder
incheckning
4b61e51103
12 ändrade filer med 153 tillägg och 88 borttagningar
  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 Visa fil

@@ -44,6 +44,7 @@ use common\models\Product ;
use common\models\User ;
use common\models\ProductDistribution ;
use common\models\Distribution ;
use common\models\Producer ;

class OrderController extends BackendController
{
@@ -760,20 +761,7 @@ class OrderController extends BackendController
// delete
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'] ;

+ 5
- 0
backend/controllers/ProductController.php Visa fil

@@ -112,6 +112,11 @@ class ProductController extends BackendController

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');
$model->save();


+ 6
- 0
backend/views/producer/update.php Visa fil

@@ -149,6 +149,12 @@ $this->addBreadcrumb($this->getTitle()) ;
0 => 'Non',
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>


+ 23
- 23
backend/views/site/index.php Visa fil

@@ -91,6 +91,7 @@ $this->title = 'Tableau de bord';
</div>
<?php endif; ?>
<?php if(count($distributionsArray)): ?>
<div id="distributions">
<div class="panel panel-default">
<div class="panel-heading">
@@ -100,36 +101,35 @@ $this->title = 'Tableau de bord';
</div>
<div class="panel-body">
<!-- 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>
<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>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<div class="clr"></div>

+ 15
- 0
backend/views/subscription/index.php Visa fil

@@ -45,8 +45,23 @@ $this->setTitle('Abonnements') ;
$this->addBreadcrumb($this->getTitle()) ;
$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">

<?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([
'filterModel' => $searchModel,

+ 27
- 0
common/models/Order.php Visa fil

@@ -224,6 +224,33 @@ class Order extends ActiveRecordCommon
}
}
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).
*

+ 6
- 2
common/models/Producer.php Visa fil

@@ -83,6 +83,9 @@ class Producer extends ActiveRecordCommon
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 ;
/**
@@ -110,9 +113,9 @@ class Producer extends ActiveRecordCommon
$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'],
[['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', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
];
@@ -153,6 +156,7 @@ class Producer extends ActiveRecordCommon
'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',
'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 Visa fil

@@ -69,7 +69,7 @@ class ProductSearch extends Product
'query' => $query,
'sort' => ['attributes' => ['order', 'photo', 'name', 'description','active']],
'pagination' => [
'pageSize' => 20,
'pageSize' => 1000,
],
]);

+ 16
- 0
console/migrations/m190522_091006_option_comportement_annulation_commande.php Visa fil

@@ -0,0 +1,16 @@
<?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 Visa fil

@@ -425,20 +425,7 @@ class OrderController extends ProducerBaseController
}

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.') ;
}
@@ -609,6 +596,10 @@ class OrderController extends ProducerBaseController
$indexProduct = 0 ;
foreach($productsArray as &$product) {
if(!isset($theProduct['productDistribution'][0])) {
$theProduct['productDistribution'][0] = $distribution->linkProduct($product) ;
}
$coefficient_unit = Product::$unitsArray[$product['unit']]['coefficient'] ;
if(is_null($product['photo'])) {

+ 39
- 33
producer/web/css/screen.css Visa fil

@@ -1769,8 +1769,14 @@ Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/
@media screen and (max-width: 768px) {
@media screen and (min-width: 768px) and (max-width: 992px) {
/* line 39, ../sass/_responsive.scss */
#left .fixed {
position: relative;
}
}
@media screen and (max-width: 768px) {
/* line 47, ../sass/_responsive.scss */
#header-bap {
display: block;
position: relative;
@@ -1780,80 +1786,80 @@ termes.
width: 100%;
padding: 0px;
}
/* line 48, ../sass/_responsive.scss */
/* line 56, ../sass/_responsive.scss */
#header-bap #logo {
margin-left: 10px;
}

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

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

/* line 139, ../sass/_responsive.scss */
/* line 146, ../sass/_responsive.scss */
.order-create #main #content .order-form #products .table .input-group,
.order-update #main #content .order-form #products .table .input-group {
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-update #main #content .order-form #products .table .input-group .form-control {
width: 20px;
padding: 3px;
}

/* line 149, ../sass/_responsive.scss */
/* line 156, ../sass/_responsive.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit,
.order-update #main #content .order-form #bar-fixed #checkbox-credit {
width: 100%;
margin: 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-update #main #content .order-form #bar-fixed #checkbox-credit .the-credit {
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-update #main #content .order-form #bar-fixed #block-confirm-order button {
width: 100%;
}

/* line 168, ../sass/_responsive.scss */
/* line 175, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul {
height: auto;
}
/* line 170, ../sass/_responsive.scss */
/* line 177, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul li {
padding-left: 0px;
padding-right: 0px;
}
/* line 174, ../sass/_responsive.scss */
/* line 181, ../sass/_responsive.scss */
.order-order #app-order-order #steps ul li .info-step {
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::before {
display: none;
}
/* line 189, ../sass/_responsive.scss */
/* line 196, ../sass/_responsive.scss */
.order-order #app-order-order table#products td.name .recipe {
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 {
width: 100%;
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 {
width: 100%;
display: block;
}
/* line 209, ../sass/_responsive.scss */
/* line 216, ../sass/_responsive.scss */
.order-order #app-order-order #order-success .alert .glyphicon-big {
font-size: 90px;
color: white;
@@ -1935,13 +1941,13 @@ termes.
text-align: center;
margin-bottom: 20px;
}
/* line 218, ../sass/_responsive.scss */
/* line 225, ../sass/_responsive.scss */
.order-order #app-order-order #order-success .alert div.content {
margin-left: 0px;
text-align: center;
}

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

+ 8
- 1
producer/web/sass/_responsive.scss Visa fil

@@ -34,6 +34,14 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

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

@media screen and (max-width: 768px) {
#header-bap {
@@ -56,7 +64,6 @@ termes.
}
}
#main {
#img-big {

Laddar…
Avbryt
Spara