Browse Source

[backend] Ajout option permettant d'exporter tous les produits lors de l'export CSV

refactoring
Guillaume 4 years ago
parent
commit
91e7d47811
5 changed files with 42 additions and 6 deletions
  1. +6
    -2
      backend/controllers/DistributionController.php
  2. +6
    -0
      backend/views/producer/update.php
  3. +10
    -3
      common/models/Order.php
  4. +2
    -1
      common/models/Producer.php
  5. +18
    -0
      console/migrations/m201218_071628_add_option_export_csv.php

+ 6
- 2
backend/controllers/DistributionController.php View File

@@ -532,6 +532,8 @@ class DistributionController extends BackendController
} elseif ($type == 'csv') {
$datas = [];

$optionCsvExportAllProducts = Producer::getConfig('option_csv_export_all_products') ;

// produits en colonne
$productsNameArray = [''];
$productsIndexArray = [];
@@ -545,7 +547,7 @@ class DistributionController extends BackendController
$productsHasQuantity[$product->id] += $quantity;
}
}
if ($productsHasQuantity[$product->id] > 0) {
if ($productsHasQuantity[$product->id] > 0 || $optionCsvExportAllProducts) {
$productsNameArray[] = $product->name . ' (' . Product::strUnit($product->unit, 'wording_short', true) . ')';
$productsIndexArray[$product->id] = $cpt++;
}
@@ -771,7 +773,9 @@ class DistributionController extends BackendController
for ($i = 0; $i <= $cptMax; $i++) {
if (isset($orderLine[$i]) && $orderLine[$i]) {
$line[] = $orderLine[$i];
$cptTotal += $orderLine[$i];
if(is_numeric($orderLine[$i])) {
$cptTotal += $orderLine[$i];
}
} else {
$line[] = '';
}

+ 6
- 0
backend/views/producer/update.php View File

@@ -260,6 +260,12 @@ $this->addBreadcrumb($this->getTitle()) ;
0 => 'Non',
1 => 'Oui'
], []); ?>

<?= $form->field($model, 'option_csv_export_all_products')
->dropDownList([
0 => 'Non',
1 => 'Oui'
], []); ?>
</div>
</div>


+ 10
- 3
common/models/Order.php View File

@@ -637,10 +637,17 @@ class Order extends ActiveRecordCommon
public function getStrUser()
{
if (isset($this->user)) {
return Html::encode($this->user->lastname . ' ' . $this->user->name);
} elseif (strlen($this->username)) {
if(isset($this->user->name_legal_person) && strlen($this->user->name_legal_person)) {
return Html::encode($this->user->name_legal_person);
}
else {
return Html::encode($this->user->lastname . ' ' . $this->user->name);
}
}
elseif (strlen($this->username)) {
return Html::encode($this->username);
} else {
}
else {
return 'Client introuvable';
}
}

+ 2
- 1
common/models/Producer.php View File

@@ -134,7 +134,7 @@ class Producer extends ActiveRecordCommon
}],
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status',
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address', 'behavior_home_point_sale_day_list', 'behavior_order_select_distribution', 'option_payment_info'], 'string'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer'], 'boolean'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note', 'document_display_prices_delivery_note', 'option_email_confirm', 'option_email_confirm_producer', 'option_csv_export_all_products'], 'boolean'],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255],
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'],
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
@@ -221,6 +221,7 @@ class Producer extends ActiveRecordCommon
'option_dashboard_number_distributions' => 'Nombre de distributions affichées sur le tableau de board',
'option_dashboard_date_start' => 'Date de début',
'option_dashboard_date_end' => 'Date de fin',
'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)',
];
}


+ 18
- 0
console/migrations/m201218_071628_add_option_export_csv.php View File

@@ -0,0 +1,18 @@
<?php

use yii\db\Migration;

class m201218_071628_add_option_export_csv extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'option_csv_export_all_products', Schema::TYPE_BOOLEAN.' DEFAULT 0');
}

public function safeDown()
{
$this->dropColumn('producer', 'option_csv_export_all_products');

return false;
}
}

Loading…
Cancel
Save