소스 검색

Pouvoir activer / désactiver une semaine de distribution

dev
부모
커밋
bc6301d2e2
5개의 변경된 파일195개의 추가작업 그리고 56개의 파일을 삭제
  1. +129
    -9
      backend/controllers/DistributionController.php
  2. +8
    -12
      backend/views/distribution/index.php
  3. +38
    -34
      backend/web/css/screen.css
  4. +14
    -1
      backend/web/js/vuejs/distribution-index.js
  5. +6
    -0
      backend/web/sass/distribution/_index.scss

+ 129
- 9
backend/controllers/DistributionController.php 파일 보기

@@ -212,6 +212,39 @@ class DistributionController extends BackendController
$usersArray = User::findBy()->all() ;
$json['users'] = $usersArray ;
// une production de la semaine activée ou non
$oneDistributionWeekActive = false ;
$week = sprintf('%02d',date('W',strtotime($date)));
$start = strtotime(date('Y',strtotime($date)).'W'.$week);
$dateMonday = date('Y-m-d',strtotime('Monday',$start)) ;
$dateTuesday = date('Y-m-d',strtotime('Tuesday',$start)) ;
$dateWednesday = date('Y-m-d',strtotime('Wednesday',$start)) ;
$dateThursday = date('Y-m-d',strtotime('Thursday',$start)) ;
$dateFriday = date('Y-m-d',strtotime('Friday',$start)) ;
$dateSaturday = date('Y-m-d',strtotime('Saturday',$start)) ;
$dateSunday = date('Y-m-d',strtotime('Sunday',$start)) ;

$weekDistribution = Distribution::find()
->andWhere([
'id_producer' => Producer::getId(),
'active' => 1,
])
->andWhere(['or',
['date' => $dateMonday],
['date' => $dateTuesday],
['date' => $dateWednesday],
['date' => $dateThursday],
['date' => $dateFriday],
['date' => $dateSaturday],
['date' => $dateSunday],
])
->one();
if($weekDistribution) {
$oneDistributionWeekActive = true ;
}
$json['one_distribution_week_active'] = $oneDistributionWeekActive ;
}
return $json ;
@@ -349,20 +382,107 @@ class DistributionController extends BackendController
return ['success'] ;
}
public function actionAjaxProcessActiveDistribution($idDistribution, $active)
/**
* Active/désactive un jour de distribution.
*
* @param integer $idDistribution
* @param string $date
* @param boolean $active
* @return array
*/
public function actionAjaxProcessActiveDistribution($idDistribution = 0, $date = '', $active)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$distribution = Distribution::searchOne([
'id' => $idDistribution
]) ;
$distribution->active = (int) $active ;
$distribution->save() ;
if ($active) {
// ajout des abonnements
Subscription::addAll($distribution->date);
if($idDistribution) {
$distribution = Distribution::searchOne([
'id' => $idDistribution
]) ;
}
$format = 'Y-m-d' ;
$dateObject = DateTime::createFromFormat($format, $date);
if($dateObject && $dateObject->format($format) === $date) {
$distribution = Distribution::initDistribution($date) ;
}
if($distribution) {
$distribution->active = (int) $active ;
$distribution->save() ;

if ($active) {
// ajout des abonnements
Subscription::addAll($distribution->date);
}
return ['success'] ;
}
return ['error'] ;
}
/**
* Change l'état d'une semaine de production (activé, désactivé).
*
* @param string $date
* @param integer $active
*/
public function actionAjaxProcessActiveWeekDistribution($date, $active)
{
$week = sprintf('%02d',date('W',strtotime($date)));
$start = strtotime(date('Y',strtotime($date)).'W'.$week);
$dateMonday = date('Y-m-d',strtotime('Monday',$start)) ;
$dateTuesday = date('Y-m-d',strtotime('Tuesday',$start)) ;
$dateWednesday = date('Y-m-d',strtotime('Wednesday',$start)) ;
$dateThursday = date('Y-m-d',strtotime('Thursday',$start)) ;
$dateFriday = date('Y-m-d',strtotime('Friday',$start)) ;
$dateSaturday = date('Y-m-d',strtotime('Saturday',$start)) ;
$dateSunday = date('Y-m-d',strtotime('Sunday',$start)) ;
$pointsSaleArray = PointSale::searchAll() ;
$activeMonday = false ;
$activeTuesday = false ;
$activeWednesday = false ;
$activeThursday = false ;
$activeFriday = false ;
$activeSaturday = false ;
$activeSunday = false ;
foreach($pointsSaleArray as $pointSale) {
if($pointSale->delivery_monday) $activeMonday = true ;
if($pointSale->delivery_tuesday) $activeTuesday = true ;
if($pointSale->delivery_wednesday) $activeWednesday = true ;
if($pointSale->delivery_thursday) $activeThursday = true ;
if($pointSale->delivery_friday) $activeFriday = true ;
if($pointSale->delivery_saturday) $activeSaturday = true ;
if($pointSale->delivery_sunday) $activeSunday = true ;
}
if($activeMonday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateMonday, $active) ;
}
if($activeTuesday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateTuesday, $active) ;
}
if($activeWednesday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateWednesday, $active) ;
}
if($activeThursday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateThursday, $active) ;
}
if($activeFriday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateFriday, $active) ;
}
if($activeSaturday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateSaturday, $active) ;
}
if($activeSunday || !$active) {
$this->actionAjaxProcessActiveDistribution(0, $dateSunday, $active) ;
}

return ['success'] ;
}
}

+ 8
- 12
backend/views/distribution/index.php 파일 보기

@@ -70,21 +70,16 @@ $this->setPageTitle('Distributions') ;
<div v-if="date">
<div id="infos-top">
<div class="col-md-12">
<div class="info-box" v-if="distribution.active">
<span class="info-box-icon bg-green"><i class="fa fa-check"></i></span>
<div class="info-box" id="info-box-distribution">
<span :class="'info-box-icon '+(distribution.active ? 'bg-green' : 'bg-red')"><i :class="'fa '+(distribution.active ? 'fa-check' : 'fa-remove')"></i></span>
<div class="info-box-content">
<span class="info-box-text">
<h4>Distribution du <strong>{{ dateFormat }}</strong></h4>
<a @click="activeDistribution" data-active="0" class="btn btn-default">Désactiver</a>
</span>
</div>
</div>
<div class="info-box" v-else>
<span class="info-box-icon bg-red"><i class="fa fa-remove"></i></span>
<div class="info-box-content">
<span class="info-box-text">
<h4>Distribution du <strong>{{ dateFormat }}</strong></h4>
<a @click="activeDistribution" data-active="1" class="btn btn-default">Activer</a>
<a @click="activeWeekDistribution" data-active="0" class="btn btn-default btn-active-week" v-if="oneDistributionWeekActive">Désactiver cette semaine</a>
<a @click="activeWeekDistribution" data-active="1" class="btn btn-default btn-active-week" v-else>Activer cette semaine</a>
<a @click="activeDistribution" data-active="0" class="btn btn-default" v-if="distribution.active">Désactiver ce jour</a>
<a @click="activeDistribution" data-active="1" class="btn btn-default" v-else>Activer ce jour</a>
</span>
</div>
</div>
@@ -483,3 +478,4 @@ $this->setPageTitle('Distributions') ;
</div>
</transition>
</script>


+ 38
- 34
backend/web/css/screen.css 파일 보기

@@ -1720,56 +1720,60 @@ termes.
.distribution-index #infos-top .info-box .info-box-content .info-box-number {
font-size: 14px;
}
/* line 137, ../sass/distribution/_index.scss */
/* line 133, ../sass/distribution/_index.scss */
.distribution-index #infos-top #info-box-distribution .btn-active-week {
float: right;
}
/* line 143, ../sass/distribution/_index.scss */
.distribution-index #modal-products table.table thead tr td {
font-weight: bold;
}
/* line 142, ../sass/distribution/_index.scss */
/* line 148, ../sass/distribution/_index.scss */
.distribution-index #modal-products table.table td.quantity-ordered,
.distribution-index #modal-products table.table td.quantity-max {
text-align: center;
}
/* line 147, ../sass/distribution/_index.scss */
/* line 153, ../sass/distribution/_index.scss */
.distribution-index #modal-products table.table td.quantity-ordered {
width: 50px;
}
/* line 150, ../sass/distribution/_index.scss */
/* line 156, ../sass/distribution/_index.scss */
.distribution-index #modal-products table.table td.quantity-max {
width: 70px;
}
/* line 153, ../sass/distribution/_index.scss */
/* line 159, ../sass/distribution/_index.scss */
.distribution-index #modal-products table.table td.quantity-max input {
text-align: center;
}
/* line 161, ../sass/distribution/_index.scss */
/* line 167, ../sass/distribution/_index.scss */
.distribution-index #orders #btn-add-order {
float: right;
}
/* line 165, ../sass/distribution/_index.scss */
/* line 171, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale {
margin-bottom: 10px;
}
/* line 168, ../sass/distribution/_index.scss */
/* line 174, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale {
margin: 0px;
padding: 0px;
list-style-type: none;
}
/* line 173, ../sass/distribution/_index.scss */
/* line 179, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li {
float: left;
margin-right: 10px;
margin-bottom: 10px;
}
/* line 178, ../sass/distribution/_index.scss */
/* line 184, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li a {
position: relative;
}
/* line 182, ../sass/distribution/_index.scss */
/* line 188, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li a.btn-primary .glyphicon {
display: block;
}
/* line 187, ../sass/distribution/_index.scss */
/* line 193, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li a .glyphicon {
display: none;
position: absolute;
@@ -1780,7 +1784,7 @@ termes.
color: #BB8757;
position: absolute;
}
/* line 198, ../sass/distribution/_index.scss */
/* line 204, ../sass/distribution/_index.scss */
.distribution-index #orders #wrapper-nav-points-sale ul#nav-points-sale li a .label {
background-color: white;
border: solid 1px #e0e0e0;
@@ -1788,57 +1792,57 @@ termes.
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* line 211, ../sass/distribution/_index.scss */
/* line 217, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions {
text-align: right;
width: 200px;
}
/* line 215, ../sass/distribution/_index.scss */
/* line 221, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .modal-form-order,
.distribution-index #orders table td.column-actions .modal-payment {
text-align: left;
}
/* line 222, ../sass/distribution/_index.scss */
/* line 228, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view ul {
list-style-type: none;
margin-left: 0px;
padding-left: 15px;
}
/* line 238, ../sass/distribution/_index.scss */
/* line 244, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered td {
background-color: #e9e9e9;
}
/* line 242, ../sass/distribution/_index.scss */
/* line 248, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered input {
font-size: 16px;
font-weight: bold;
}
/* line 248, ../sass/distribution/_index.scss */
/* line 254, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity {
width: 150px;
}
/* line 251, ../sass/distribution/_index.scss */
/* line 257, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center;
color: gray;
}
/* line 257, ../sass/distribution/_index.scss */
/* line 263, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right;
}
/* line 265, ../sass/distribution/_index.scss */
/* line 271, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 267, ../sass/distribution/_index.scss */
/* line 273, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 271, ../sass/distribution/_index.scss */
/* line 277, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}
/* line 277, ../sass/distribution/_index.scss */
/* line 283, ../sass/distribution/_index.scss */
.distribution-index .modal-mask {
position: fixed;
z-index: 9998;
@@ -1850,12 +1854,12 @@ termes.
display: table;
transition: opacity .3s ease;
}
/* line 289, ../sass/distribution/_index.scss */
/* line 295, ../sass/distribution/_index.scss */
.distribution-index .modal-wrapper {
display: table-cell;
vertical-align: middle;
}
/* line 294, ../sass/distribution/_index.scss */
/* line 300, ../sass/distribution/_index.scss */
.distribution-index .modal-container {
width: 70%;
margin: 0px auto;
@@ -1866,37 +1870,37 @@ termes.
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
}
/* line 305, ../sass/distribution/_index.scss */
/* line 311, ../sass/distribution/_index.scss */
.distribution-index .modal-header {
padding-bottom: 0px;
}
/* line 307, ../sass/distribution/_index.scss */
/* line 313, ../sass/distribution/_index.scss */
.distribution-index .modal-header h3 {
margin-top: 0;
color: #333;
text-transform: uppercase;
margin-bottom: 0px;
}
/* line 315, ../sass/distribution/_index.scss */
/* line 321, ../sass/distribution/_index.scss */
.distribution-index .modal-body {
margin: 20px 0;
max-height: 300px;
height: 300px;
overflow-y: scroll;
}
/* line 322, ../sass/distribution/_index.scss */
/* line 328, ../sass/distribution/_index.scss */
.distribution-index .modal-default-button {
float: right;
}
/* line 335, ../sass/distribution/_index.scss */
/* line 341, ../sass/distribution/_index.scss */
.distribution-index .modal-enter {
opacity: 0;
}
/* line 339, ../sass/distribution/_index.scss */
/* line 345, ../sass/distribution/_index.scss */
.distribution-index .modal-leave-active {
opacity: 0;
}
/* line 343, ../sass/distribution/_index.scss */
/* line 349, ../sass/distribution/_index.scss */
.distribution-index .modal-enter .modal-container,
.distribution-index .modal-leave-active .modal-container {
-webkit-transform: scale(1.1);

+ 14
- 1
backend/web/js/vuejs/distribution-index.js 파일 보기

@@ -9,6 +9,7 @@ var app = new Vue({
distribution: {
active: false,
},
oneDistributionWeekActive: false,
products: [],
countActiveProducts: 0,
pointsSale: [],
@@ -78,7 +79,6 @@ var app = new Vue({
},
mounted: function() {
if($('#distribution-date').size()) {
this.date = new Date($('#distribution-date').html()) ;
this.dateFormat = ('0' + this.date.getDate()).slice(-2)+ '/'
@@ -112,6 +112,8 @@ var app = new Vue({
this.products = response.data.products ;
this.initCountActiveProducts() ;
this.oneDistributionWeekActive = response.data.one_distribution_week_active ;
if(response.data.orders) {
this.orders = response.data.orders ;
@@ -256,6 +258,17 @@ var app = new Vue({
this.init() ;
}) ;
},
activeWeekDistribution: function(event) {
axios.get("ajax-process-active-week-distribution",{params: {
date: this.date.getFullYear() + '-'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '-'
+ ('0' + this.date.getDate()).slice(-2),
active: event.currentTarget.getAttribute('data-active')
}})
.then(response => {
this.init() ;
}) ;
},
pointSaleClick: function(event) {
this.setIdActivePointSale(event.currentTarget.getAttribute('data-id-point-sale')) ;
},

+ 6
- 0
backend/web/sass/distribution/_index.scss 파일 보기

@@ -128,6 +128,12 @@ termes.
}
}
}
#info-box-distribution {
.btn-active-week {
float: right ;
}
}
}
#modal-products {

Loading…
취소
저장