{ | { | ||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
if ($document->send()) { | if ($document->send()) { | ||||
$document->is_sent = true; | |||||
$document->save(); | |||||
Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('send', $document)); | Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('send', $document)); | ||||
} else { | } else { | ||||
Yii::$app->getSession()->setFlash('danger', $this->getFlashMessage('send', $document)); | Yii::$app->getSession()->setFlash('danger', $this->getFlashMessage('send', $document)); |
return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | ||||
} | } | ||||
], | ], | ||||
[ | |||||
'attribute' => 'is_sent', | |||||
'header' => 'Envoyé', | |||||
'format' => 'raw', | |||||
'value' => function($model) { | |||||
if($model->is_sent) { | |||||
return '<span class="label label-success">Oui</span>'; | |||||
} | |||||
else { | |||||
return '<span class="label label-danger">Non</span>'; | |||||
} | |||||
} | |||||
], | |||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'template' => '{validate} {update} {delete} {send} {download} {export-csv-evoliz}', | 'template' => '{validate} {update} {delete} {send} {download} {export-csv-evoliz}', |
[['date'], 'safe'], | [['date'], 'safe'], | ||||
[['comment', 'address', 'tax_calculation_method'], 'string'], | [['comment', 'address', 'tax_calculation_method'], 'string'], | ||||
[['id_user', 'id_producer'], 'integer'], | [['id_user', 'id_producer'], 'integer'], | ||||
['is_sent', 'boolean'], | |||||
[['name', 'reference', 'status'], 'string', 'max' => 255], | [['name', 'reference', 'status'], 'string', 'max' => 255], | ||||
[['deliveryNotes'], 'safe'] | [['deliveryNotes'], 'safe'] | ||||
]; | ]; | ||||
'address' => 'Adresse', | 'address' => 'Adresse', | ||||
'id_producer' => 'Producteur', | 'id_producer' => 'Producteur', | ||||
'status' => 'Statut', | 'status' => 'Statut', | ||||
'tax_calculation_method' => 'Méthode de calcul de la TVA' | |||||
'tax_calculation_method' => 'Méthode de calcul de la TVA', | |||||
'is_sent' => 'Envoyé' | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m221010_124540_document_is_sent | |||||
*/ | |||||
class m221010_124540_document_is_sent extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('quotation', 'is_sent', Schema::TYPE_BOOLEAN); | |||||
$this->addColumn('delivery_note', 'is_sent', Schema::TYPE_BOOLEAN); | |||||
$this->addColumn('invoice', 'is_sent', Schema::TYPE_BOOLEAN); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('quotation', 'is_sent'); | |||||
$this->dropColumn('delivery_note', 'is_sent'); | |||||
$this->dropColumn('invoice', 'is_sent'); | |||||
} | |||||
} |