|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
use common\logic\PointSale\PointSale\Model\PointSale; |
|
|
use common\logic\PointSale\PointSale\Model\PointSale; |
|
|
|
|
|
use common\logic\Producer\Producer\Wrapper\ProducerManager; |
|
|
use common\logic\Product\Product\Model\Product; |
|
|
use common\logic\Product\Product\Model\Product; |
|
|
|
|
|
use common\logic\Product\Product\Wrapper\ProductManager; |
|
|
use yii\helpers\Html; |
|
|
use yii\helpers\Html; |
|
|
use yii\grid\GridView; |
|
|
use yii\grid\GridView; |
|
|
use common\helpers\GlobalParam; |
|
|
use common\helpers\GlobalParam; |
|
|
use yii\helpers\ArrayHelper; |
|
|
use yii\helpers\ArrayHelper; |
|
|
|
|
|
|
|
|
$producerManager = $this->getProducerManager(); |
|
|
|
|
|
|
|
|
$producerManager = ProducerManager::getInstance(); |
|
|
|
|
|
$productManager = ProductManager::getInstance(); |
|
|
|
|
|
|
|
|
$this->setTitle('Abonnements') ; |
|
|
$this->setTitle('Abonnements') ; |
|
|
$this->addButton(['label' => '<span class="glyphicon glyphicon-plus"></span> Ajouter', 'url' => 'subscription/form', 'class' => 'btn btn-primary']) ; |
|
|
$this->addButton(['label' => '<span class="glyphicon glyphicon-plus"></span> Ajouter', 'url' => 'subscription/form', 'class' => 'btn btn-primary']) ; |
|
|
|
|
|
|
|
|
'attribute' => 'product_name', |
|
|
'attribute' => 'product_name', |
|
|
'label' => 'Produits', |
|
|
'label' => 'Produits', |
|
|
'format' => 'raw', |
|
|
'format' => 'raw', |
|
|
'value' => function($model) { |
|
|
|
|
|
|
|
|
'value' => function($model) use ($productManager) { |
|
|
$html = '' ; |
|
|
$html = '' ; |
|
|
foreach($model->productSubscription as $productSubscription) |
|
|
foreach($model->productSubscription as $productSubscription) |
|
|
{ |
|
|
{ |
|
|
if(isset($productSubscription->product)) { |
|
|
|
|
|
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']) . ' '. Product::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; |
|
|
|
|
|
|
|
|
if(isset($productSubscription->product) && $productSubscription->product) { |
|
|
|
|
|
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']) . ' '. $productManager->strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
$html .= 'Produit non défini<br />' ; |
|
|
$html .= 'Produit non défini<br />' ; |
|
|
|
|
|
|
|
|
'format' => 'raw', |
|
|
'format' => 'raw', |
|
|
'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'), |
|
|
'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'), |
|
|
'value' => function($model) { |
|
|
'value' => function($model) { |
|
|
return Html::encode($model->pointSale->name) ; |
|
|
|
|
|
|
|
|
if($model->pointSale) { |
|
|
|
|
|
return Html::encode($model->pointSale->name) ; |
|
|
|
|
|
} |
|
|
|
|
|
return ''; |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
[ |
|
|
[ |