<?php foreach($product as $productOrder): ?> | <?php foreach($product as $productOrder): ?> | ||||
<tr> | <tr> | ||||
<td class="align-left"><?= Html::encode($productOrder->product->name) ?></td> | <td class="align-left"><?= Html::encode($productOrder->product->name) ?></td> | ||||
<td class="align-center"><?= Price::format($productOrder->product->getPrice()) ?></td> | |||||
<td class="align-center"><?= Price::format($productOrder->getPrice()) ?></td> | |||||
<td class="align-center"><?= $productOrder->quantity ?></td> | <td class="align-center"><?= $productOrder->quantity ?></td> | ||||
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | <td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | ||||
<td class="align-center"><?= $productOrder->product->taxRate->value * 100 ?> %</td> | <td class="align-center"><?= $productOrder->product->taxRate->value * 100 ?> %</td> | ||||
<td class="align-center"><?= Price::format($productOrder->product->getPrice() * $productOrder->quantity) ?></td> | |||||
<td class="align-center"><?= Price::format($productOrder->getPrice() * $productOrder->quantity) ?></td> | |||||
</tr> | </tr> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> |
], | ], | ||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'template' => '{update} {delete} {download}', | |||||
'template' => '{update} {delete} {send} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | 'buttons' => [ | ||||
'send' => function($url, $model) { | |||||
return (!$model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Envoyer'), 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'download' => function($url, $model) { | 'download' => function($url, $model) { | ||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | ||||
'title' => Yii::t('app', 'Télécharger'), 'class' => 'btn btn-default' | 'title' => Yii::t('app', 'Télécharger'), 'class' => 'btn btn-default' |
namespace common\models; | namespace common\models; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\helpers\Price; | |||||
use Yii; | use Yii; | ||||
use common\components\ActiveRecordCommon; | use common\components\ActiveRecordCommon; | ||||
return $this->hasOne(Product::className(), ['id' => 'id_product']); | return $this->hasOne(Product::className(), ['id' => 'id_product']); | ||||
} | } | ||||
public function getTaxRate() | |||||
{ | |||||
return $this->hasOne(TaxRate::className(), ['id' => 'id_tax_rate']); | |||||
} | |||||
/** | /** | ||||
* @inheritdoc | * @inheritdoc | ||||
*/ | */ | ||||
parent::afterFind(); | parent::afterFind(); | ||||
} | } | ||||
public function getTaxRate() | |||||
public function getPrice() | |||||
{ | { | ||||
return $this->hasOne(TaxRate::className(), ['id' => 'id_tax_rate']); | |||||
return $this->price ; | |||||
} | } | ||||
/** | |||||
* Retourne le prix du produit avec taxe | |||||
*/ | |||||
public function getPriceWithTax() | |||||
{ | |||||
return Price::getPriceWithTax($this->price, $this->taxRate->value); | |||||
} | |||||
} | } |