$documentModule = $this->getDocumentModule(); | $documentModule = $this->getDocumentModule(); | ||||
$orderModule = $this->getOrderModule(); | $orderModule = $this->getOrderModule(); | ||||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && $producerModule->getConfig('document_display_prices_delivery_note')); | |||||
$isDocumentDeliveryNote = $documentModule->getSolver()->isDocumentDeliveryNote($document); | |||||
$displayPrices = !$isDocumentDeliveryNote || ($isDocumentDeliveryNote && $producerModule->getConfig('document_display_prices_delivery_note')); | |||||
$displayProductDescription = $producerModule->getConfig('document_display_product_description'); | $displayProductDescription = $producerModule->getConfig('document_display_product_description'); | ||||
$documentPriceDecimals = (int) $producerModule->getConfig('option_document_price_decimals'); | $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price_decimals'); | ||||
?> | ?> | ||||
<div class="callout callout-info"> | |||||
<span class="glyphicon glyphicon-info-sign"></span> Les factures et les réglements sont saisis en début de mois. | |||||
</div> | |||||
<?php if($invoicesArray && count($invoicesArray)): ?> | <?php if($invoicesArray && count($invoicesArray)): ?> | ||||
<div class="callout callout-info"> | |||||
<span class="glyphicon glyphicon-info-sign"></span> Les factures et les réglements sont saisis en début de mois. | |||||
</div> | |||||
<table class="table table-striped table-bordered"> | <table class="table table-striped table-bordered"> | ||||
<thead> | <thead> | ||||
<tr> | <tr> | ||||
</tbody> | </tbody> | ||||
</table> | </table> | ||||
<?php else: ?> | <?php else: ?> | ||||
<div class="alert alert-info"> | |||||
<div class="callout callout-info"> | |||||
<span class="glyphicon glyphicon-info-sign"></span> Vous n'avez encore aucune facture. | <span class="glyphicon glyphicon-info-sign"></span> Vous n'avez encore aucune facture. | ||||
</div> | </div> | ||||
<?php endif; ?> | <?php endif; ?> |
<?= $form->field($model, 'document_invoice_first_reference'); ?> | <?= $form->field($model, 'document_invoice_first_reference'); ?> | ||||
<?= $form->field($model, 'document_delivery_note_prefix')->hint($hintKeywordsPrefix);; ?> | <?= $form->field($model, 'document_delivery_note_prefix')->hint($hintKeywordsPrefix);; ?> | ||||
<?= $form->field($model, 'document_delivery_note_first_reference'); ?> | <?= $form->field($model, 'document_delivery_note_first_reference'); ?> | ||||
<?= $form->field($model, 'option_invoice_only_based_on_delivery_notes')->dropDownList([ | |||||
0 => 'Non', | |||||
1 => 'Oui' | |||||
]); ?> | |||||
<?= $form->field($model, 'delivery_note_automatic_validation')->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_invoice_only_based_on_delivery_notes')->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_document_width_logo') | <?= $form->field($model, 'option_document_width_logo') | ||||
->dropDownList(Dropdown::numberChoices(50, 250, true, 'px', 50)); ?> | ->dropDownList(Dropdown::numberChoices(50, 250, true, 'px', 50)); ?> | ||||
<?= $form->field($model, 'document_display_orders_invoice')->dropDownList(Dropdown::noYesChoices()); ?> | <?= $form->field($model, 'document_display_orders_invoice')->dropDownList(Dropdown::noYesChoices()); ?> |
], | ], | ||||
DeliveryNote::class => [ | DeliveryNote::class => [ | ||||
// Order : assignation du bon de livraison aux commandes | // Order : assignation du bon de livraison aux commandes | ||||
common\logic\Order\Order\Event\DeliveryNoteObserver::class | |||||
common\logic\Order\Order\Event\DeliveryNoteObserver::class, | |||||
// DeliveryNote : validation automatique des bons de livraison | |||||
common\logic\Document\DeliveryNote\Event\DeliveryNoteObserver::class | |||||
], | ], | ||||
Ticket::class => [ | Ticket::class => [ | ||||
// User : envoi email nouveau ticket à l'administrateur | // User : envoi email nouveau ticket à l'administrateur |
<?php | |||||
namespace common\logic\Document\DeliveryNote\Event; | |||||
use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent; | |||||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||||
use common\logic\Document\Document\Module\DocumentModule; | |||||
use common\logic\Order\Order\Module\OrderModule; | |||||
use common\logic\Producer\Producer\Module\ProducerModule; | |||||
use justcoded\yii2\eventlistener\observers\Observer; | |||||
class DeliveryNoteObserver extends Observer | |||||
{ | |||||
public function events() | |||||
{ | |||||
return [ | |||||
DeliveryNote::EVENT_CREATE => 'onDeliveryNoteCreate' | |||||
]; | |||||
} | |||||
public function onDeliveryNoteCreate(DeliveryNoteCreateEvent $event) | |||||
{ | |||||
$producerModule = ProducerModule::getInstance(); | |||||
$documentModule = DocumentModule::getInstance(); | |||||
if($producerModule->getSolver()->getConfig('delivery_note_automatic_validation')) { | |||||
$documentModule->getManager()->validateDocument($event->deliveryNote); | |||||
} | |||||
} | |||||
} |
use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent; | use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent; | ||||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | use common\logic\Document\DeliveryNote\Model\DeliveryNote; | ||||
use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository; | use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository; | ||||
use common\logic\Document\Document\Model\Document; | |||||
use common\logic\Document\Document\Service\DocumentBuilder; | use common\logic\Document\Document\Service\DocumentBuilder; | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Order\Order\Service\OrderSolver; | use common\logic\Order\Order\Service\OrderSolver; | ||||
{ | { | ||||
$deliveryNote = new DeliveryNote(); | $deliveryNote = new DeliveryNote(); | ||||
$deliveryNote->status = Document::STATUS_DRAFT; | |||||
$this->initDocumentProducer($deliveryNote); | $this->initDocumentProducer($deliveryNote); | ||||
$this->initTaxCalculationMethod($deliveryNote); | $this->initTaxCalculationMethod($deliveryNote); | ||||
if ($status == Document::STATUS_VALID) { | if ($status == Document::STATUS_VALID) { | ||||
$this->documentReferenceGenerator->generateReference($document); | $this->documentReferenceGenerator->generateReference($document); | ||||
$this->generatePdf($document, Pdf::DEST_FILE); | |||||
} | } | ||||
$this->documentBuilder->update($document); | $this->documentBuilder->update($document); |
'option_export_display_column_delivery_note', | 'option_export_display_column_delivery_note', | ||||
'option_invoice_only_based_on_delivery_notes', | 'option_invoice_only_based_on_delivery_notes', | ||||
'option_document_display_price_unit_reference', | 'option_document_display_price_unit_reference', | ||||
'option_check_by_default_prevent_user_credit' | |||||
'option_check_by_default_prevent_user_credit', | |||||
'delivery_note_automatic_validation' | |||||
], | ], | ||||
'boolean' | 'boolean' | ||||
], | ], | ||||
'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | 'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | ||||
'id_user_group_default' => "Groupe utilisateur par défaut attribué à l'inscription", | 'id_user_group_default' => "Groupe utilisateur par défaut attribué à l'inscription", | ||||
'option_check_by_default_prevent_user_credit' => "Par défaut, prévenir l'utilisateur quand on crédite son compte", | 'option_check_by_default_prevent_user_credit' => "Par défaut, prévenir l'utilisateur quand on crédite son compte", | ||||
'delivery_note_automatic_validation' => 'Validation automatique des bons de livraison' | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m231130_082147_add_column_producer_delivery_note_automatic_validation | |||||
*/ | |||||
class m231130_082147_add_column_producer_delivery_note_automatic_validation extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'delivery_note_automatic_validation', Schema::TYPE_BOOLEAN); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'delivery_note_automatic_validation'); | |||||
} | |||||
} |