@@ -320,6 +320,10 @@ class DocumentController extends BackendController | |||
{ | |||
$document = $this->findModel($id); | |||
if ($document->send()) { | |||
$document->is_sent = true; | |||
$document->save(); | |||
Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('send', $document)); | |||
} else { | |||
Yii::$app->getSession()->setFlash('danger', $this->getFlashMessage('send', $document)); |
@@ -99,6 +99,19 @@ $this->addButton(['label' => 'Nouvelle facture <span class="glyphicon glyphicon- | |||
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', | |||
'template' => '{validate} {update} {delete} {send} {download} {export-csv-evoliz}', |
@@ -67,6 +67,7 @@ class Document extends ActiveRecordCommon | |||
[['date'], 'safe'], | |||
[['comment', 'address', 'tax_calculation_method'], 'string'], | |||
[['id_user', 'id_producer'], 'integer'], | |||
['is_sent', 'boolean'], | |||
[['name', 'reference', 'status'], 'string', 'max' => 255], | |||
[['deliveryNotes'], 'safe'] | |||
]; | |||
@@ -87,7 +88,8 @@ class Document extends ActiveRecordCommon | |||
'address' => 'Adresse', | |||
'id_producer' => 'Producteur', | |||
'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é' | |||
]; | |||
} | |||
@@ -0,0 +1,30 @@ | |||
<?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'); | |||
} | |||
} |