Browse Source

[backend] Ajout référence produit + affichage dans l'export PDF

refactoring
Guillaume 3 years ago
parent
commit
6dd12c6bb9
6 changed files with 43 additions and 5 deletions
  1. +3
    -3
      backend/views/distribution/report.php
  2. +6
    -0
      backend/views/producer/update.php
  3. +1
    -0
      backend/views/product/_form.php
  4. +2
    -1
      common/models/Producer.php
  5. +12
    -1
      common/models/Product.php
  6. +19
    -0
      console/migrations/m210318_095733_add_product_reference.php

+ 3
- 3
backend/views/distribution/report.php View File

foreach ($order->productOrder as $productOrder) { foreach ($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) { if($product->id == $productOrder->id_product) {
$unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($productOrder->unit, 'wording_short', true) ; $unit = (Product::strUnit($productOrder->unit, 'wording_short', true) == 'p.') ? '' : ' '.Product::strUnit($productOrder->unit, 'wording_short', true) ;
$strProducts .= $product->name . ' (' .$productOrder->quantity .$unit.')<br />';
$strProducts .= $product->getNameExport() . ' (' .$productOrder->quantity .$unit.')<br />';
$add = true; $add = true;
} }
} }
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); $quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) { if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ; $theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$strProducts .= $product->name . ' (' .$quantity .$theUnit.')<br />';
$strProducts .= $product->getNameExport() . ' (' .$quantity .$theUnit.')<br />';
} }
} }


$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit); $quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) { if ($quantity) {
$theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ; $theUnit = (Product::strUnit($unit, 'wording_short', true) == 'p.') ? '' : '&nbsp;'.Product::strUnit($unit, 'wording_short', true) ;
$html .= $product->name . ' (' .$quantity .$theUnit.')<br />';
$html .= $product->getNameExport() . ' (' .$quantity .$theUnit.')<br />';
} }
} }



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

Producer::ORDER_REFERENCE_TYPE_NONE => '--', Producer::ORDER_REFERENCE_TYPE_NONE => '--',
Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle', Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle',
], []) ; ?> ], []) ; ?>

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



+ 1
- 0
backend/views/product/_form.php View File

<div class="col-md-8"> <div class="col-md-8">
<?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?> <?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'id_product_category')->dropDownList(ProductCategory::populateDropdownList()); ?> <?= $form->field($model, 'id_product_category')->dropDownList(ProductCategory::populateDropdownList()); ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?> <?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> <?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?>

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

}], }],
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', [['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', 'option_order_reference_type'], 'string'], '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', 'option_order_reference_type'], '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', 'option_csv_export_all_products', 'option_csv_export_by_piece'], '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', 'option_csv_export_by_piece', 'option_export_display_product_reference'], '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], [['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', 'credit_limit_reminder', 'credit_limit'], 'double'],
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'], ['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)', 'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)',
'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', 'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)',
'option_order_reference_type' => 'Type de référence', 'option_order_reference_type' => 'Type de référence',
'option_export_display_product_reference' => 'Afficher la référence des produits au moment de l\'export',
]; ];
} }



+ 12
- 1
common/models/Product.php View File

[['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'unavailable', 'apply_distributions'], 'boolean'], [['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'unavailable', 'apply_distributions'], 'boolean'],
[['price', 'weight', 'step', 'quantity_max', 'quantity_max_monday', 'quantity_max_tuesday', 'quantity_max_wednesday', 'quantity_max_thursday', 'quantity_max_friday', 'quantity_max_saturday', 'quantity_max_sunday'], 'number'], [['price', 'weight', 'step', 'quantity_max', 'quantity_max_monday', 'quantity_max_tuesday', 'quantity_max_wednesday', 'quantity_max_thursday', 'quantity_max_friday', 'quantity_max_saturday', 'quantity_max_sunday'], 'number'],
[['photo'], 'file'], [['photo'], 'file'],
[['name', 'description', 'photo', 'unit'], 'string', 'max' => 255],
[['name', 'reference', 'description', 'photo', 'unit'], 'string', 'max' => 255],
[['recipe'], 'string', 'max' => 1000], [['recipe'], 'string', 'max' => 1000],
['step', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { ['step', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) {
if ($model->unit != 'piece') { if ($model->unit != 'piece') {
return [ return [
'id' => 'ID', 'id' => 'ID',
'name' => 'Nom', 'name' => 'Nom',
'reference' => 'Référence',
'description' => 'Description', 'description' => 'Description',
'active' => 'Actif', 'active' => 'Actif',
'photo' => 'Photo', 'photo' => 'Photo',
} }
} }


public function getNameExport()
{
$producer = GlobalParam::getCurrentProducer() ;
if($producer->option_export_display_product_reference && $this->reference && strlen($this->reference) > 0) {
return $this->reference ;
}

return $this->name ;
}



} }

+ 19
- 0
console/migrations/m210318_095733_add_product_reference.php View File

<?php

use yii\db\Migration;
use yii\db\Schema;

class m210318_095733_add_product_reference extends Migration
{
public function safeUp()
{
$this->addColumn('product', 'reference', Schema::TYPE_STRING . ' DEFAULT NULL') ;
$this->addColumn('producer', 'option_export_display_product_reference', Schema::TYPE_BOOLEAN.' DEFAULT 0') ;
}

public function safeDown()
{
$this->dropColumn('product', 'reference') ;
$this->dropColumn('producer', 'option_export_display_product_reference') ;
}
}

Loading…
Cancel
Save