@@ -418,6 +418,8 @@ class DocumentController extends BackendController | |||
$userManager = $this->getUserManager(); | |||
$documentManager = $this->getDocumentManager(); | |||
$orderManager = $this->getOrderManager(); | |||
$producerManager = $this->getProducerManager(); | |||
$producerCurrent = $this->getProducerCurrent(); | |||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||
@@ -460,8 +462,13 @@ class DocumentController extends BackendController | |||
$json['delivery_note_create_array'] = $this->initDeliveryNoteArray('create', $deliveryNotesCreateArray); | |||
$json['delivery_note_update_array'] = $this->initDeliveryNoteArray('update', $deliveryNotesUpdateArray); | |||
$json['orders_create_array'] = $this->initOrdersArray($orderManager->findOrdersByUserNotInvoiced($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderManager->findOrdersByUserAndInvoice($user, $document)) : []; | |||
$json['orders_create_array'] = []; | |||
$json['orders_update_array'] = []; | |||
if(!$producerManager->getConfig('option_invoice_only_based_on_delivery_notes')) { | |||
$json['orders_create_array'] = $this->initOrdersArray($orderManager->findOrdersByUserNotInvoiced($user)); | |||
$json['orders_update_array'] = $document ? $this->initOrdersArray($orderManager->findOrdersByUserAndInvoice($user, $document)) : []; | |||
} | |||
} | |||
if ($classDocument == 'DeliveryNote') { |
@@ -458,6 +458,10 @@ $this->addBreadcrumb($this->getTitle()); | |||
<?= $form->field($model, 'document_invoice_first_reference'); ?> | |||
<?= $form->field($model, 'document_delivery_note_prefix'); ?> | |||
<?= $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, 'document_display_orders_invoice')->dropDownList([ | |||
0 => 'Non', | |||
1 => 'Oui' |
@@ -268,7 +268,8 @@ class Producer extends ActiveRecordCommon | |||
'option_export_evoliz', | |||
'option_display_message_new_opendistrib_version', | |||
'option_billing_permanent_transfer', | |||
'option_export_display_column_delivery_note' | |||
'option_export_display_column_delivery_note', | |||
'option_invoice_only_based_on_delivery_notes' | |||
], | |||
'boolean' | |||
], | |||
@@ -435,6 +436,7 @@ class Producer extends ActiveRecordCommon | |||
'dolibarr_product_id' => 'Dolibarr : id produit', | |||
'option_export_display_column_delivery_note' => "Récapitulatif PDF : afficher une colonne bon de livraison", | |||
'option_weeks_distributions_activated_in_advance' => "Semaines de distributions à activer à l'avance", | |||
'option_invoice_only_based_on_delivery_notes' => 'Facturer uniquement sur la base des bons de livraison' | |||
]; | |||
} | |||
@@ -0,0 +1,26 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\Schema; | |||
/** | |||
* Class m231004_083707_add_column_producer_option_invoice_only_based_on_delivery_notes | |||
*/ | |||
class m231004_083707_add_column_producer_option_invoice_only_based_on_delivery_notes extends Migration | |||
{ | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeUp() | |||
{ | |||
$this->addColumn('producer', 'option_invoice_only_based_on_delivery_notes', Schema::TYPE_BOOLEAN); | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeDown() | |||
{ | |||
$this->dropColumn('producer', 'option_invoice_only_based_on_delivery_notes'); | |||
} | |||
} |