{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||||
$rotatingModule = $this->getRotatingModule(); | |||||
$unitModule = $this->getUnitModule(); | $unitModule = $this->getUnitModule(); | ||||
$productModule = $this->getProductModule(); | |||||
$productsQuery = Product::find() | $productsQuery = Product::find() | ||||
->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | ->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | ||||
} | } | ||||
} | } | ||||
// Produits tournants | |||||
$rotatingsArrayReturn = []; | |||||
$rotatingsArray = $rotatingModule->getRepository()->findRotatings(); | |||||
foreach($rotatingsArray as $rotating) { | |||||
$rotatingsArrayReturn[] = array_merge($rotating->getAttributes(), [ | |||||
'quantity' => '' | |||||
]); | |||||
} | |||||
return [ | return [ | ||||
'products' => $productsArray | |||||
'products' => $productsArray, | |||||
'rotatings' => $rotatingsArrayReturn | |||||
]; | ]; | ||||
} | } | ||||
} | } |
termes. | termes. | ||||
*/ | */ | ||||
use domain\Feature\Feature\Feature; | |||||
use domain\Subscription\Subscription\Subscription; | use domain\Subscription\Subscription\Subscription; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$pointSaleModule = $this->getPointSaleModule(); | $pointSaleModule = $this->getPointSaleModule(); | ||||
$featureChecker = $this->getFeatureModule()->getChecker(); | |||||
?> | ?> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<?php if($featureChecker->isEnabled(Feature::ALIAS_ROTATING_PRODUCT)): ?> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title"> | |||||
<i class="fa fa-clone"></i> | |||||
Produits tournants | |||||
</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<div class="rotatings"> | |||||
<table class="table table-bordered table-condensed table-hover" id="rotatings"> | |||||
<tr v-for="rotating in rotatings"> | |||||
<td> | |||||
{{ rotating.name }} | |||||
</td> | |||||
<td> | |||||
<div class="input-group"> | |||||
<span class="input-group-btn"> | |||||
<button class="btn btn-default" type="button" @click="changeQuantityRotating(rotating, false)"><span class="glyphicon glyphicon-minus"></span></button> | |||||
</span> | |||||
<input v-model="rotating.quantity" :name="'SubscriptionForm[rotatings][rotating_'+rotating.id+']'" class="form-control input-quantity" /> | |||||
<div class="input-group-addon"> | |||||
<span>p.</span> | |||||
</div> | |||||
<span class="input-group-btn"> | |||||
<button class="btn btn-default" type="button" @click="changeQuantityRotating(rotating, true)"><span class="glyphicon glyphicon-plus"></span></button> | |||||
</span> | |||||
</div> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<?php endif; ?> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
<h3 class="panel-title"> | <h3 class="panel-title"> |
data: { | data: { | ||||
showLoading: false, | showLoading: false, | ||||
loading: true, | loading: true, | ||||
products: [] | |||||
products: [], | |||||
rotatings: [] | |||||
}, | }, | ||||
mounted: function () { | mounted: function () { | ||||
axios.get("ajax-infos", {params: {idSubscription: $('#subscriptionform-id').val()}}) | axios.get("ajax-infos", {params: {idSubscription: $('#subscriptionform-id').val()}}) | ||||
.then(function (response) { | .then(function (response) { | ||||
app.products = response.data.products; | app.products = response.data.products; | ||||
app.rotatings = response.data.rotatings; | |||||
app.showLoading = false; | app.showLoading = false; | ||||
}); | }); | ||||
}, | }, | ||||
if (quantity + step >= 0) { | if (quantity + step >= 0) { | ||||
product.quantity = quantity + step; | product.quantity = quantity + step; | ||||
} | } | ||||
if (!product.quantity) product.quantity = ''; | |||||
if (!product.quantity) { | |||||
product.quantity = ''; | |||||
} | |||||
}, | |||||
changeQuantityRotating: function(rotating, increase) { | |||||
var step = 1; | |||||
var quantity = rotating.quantity ? parseFloat(rotating.quantity) : 0; | |||||
if (!increase) { | |||||
step = -step; | |||||
} | |||||
if (quantity + step >= 0) { | |||||
rotating.quantity = quantity + step; | |||||
} | |||||
if (!rotating.quantity) { | |||||
rotating.quantity = ''; | |||||
} | |||||
} | } | ||||
} | } | ||||
}); | }); |
public $sunday; | public $sunday; | ||||
public $week_frequency; | public $week_frequency; | ||||
public $products; | public $products; | ||||
public $rotatings; | |||||
public $auto_payment; | public $auto_payment; | ||||
public $comment ; | public $comment ; | ||||
[['date_begin', 'date_end'], 'date', 'format' => 'php:d/m/Y'], | [['date_begin', 'date_end'], 'date', 'format' => 'php:d/m/Y'], | ||||
[['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], 'boolean'], | [['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], 'boolean'], | ||||
[['id_point_sale', 'id_producer', 'date_begin'], 'required', 'message' => 'Champs obligatoire'], | [['id_point_sale', 'id_producer', 'date_begin'], 'required', 'message' => 'Champs obligatoire'], | ||||
[['products', 'id_user', 'username','comment'], 'safe'], | |||||
[['products', 'rotatings', 'id_user', 'username','comment'], 'safe'], | |||||
['id_user', function ($attribute, $params) { | ['id_user', function ($attribute, $params) { | ||||
if (!$this->id_user && !strlen($this->username)) { | if (!$this->id_user && !strlen($this->username)) { | ||||
$this->addError($attribute, 'Vous devez sélectionner ou saisir un utilisateur.'); | $this->addError($attribute, 'Vous devez sélectionner ou saisir un utilisateur.'); |