소스 검색

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

refactoring
Guillaume 3 년 전
부모
커밋
6dd12c6bb9
6개의 변경된 파일43개의 추가작업 그리고 5개의 파일을 삭제
  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 파일 보기

@@ -99,7 +99,7 @@ foreach ($pointsSaleArray as $pointSale) {
foreach ($order->productOrder as $productOrder) {
if($product->id == $productOrder->id_product) {
$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;
}
}
@@ -157,7 +157,7 @@ foreach ($pointsSaleArray as $pointSale) {
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$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 />';
}
}

@@ -206,7 +206,7 @@ foreach ($pointsSaleArray as $pointSale)
$quantity = Order::getProductQuantity($product->id, $pointSale->orders, false, $unit);
if ($quantity) {
$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 파일 보기

@@ -277,6 +277,12 @@ $this->addBreadcrumb($this->getTitle()) ;
Producer::ORDER_REFERENCE_TYPE_NONE => '--',
Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle',
], []) ; ?>

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


+ 1
- 0
backend/views/product/_form.php 파일 보기

@@ -21,6 +21,7 @@ use common\helpers\GlobalParam;
<div class="col-md-8">
<?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?>
<?= $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, 'description')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?>

+ 2
- 1
common/models/Producer.php 파일 보기

@@ -137,7 +137,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', '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],
[['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'],
@@ -227,6 +227,7 @@ class Producer extends ActiveRecordCommon
'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_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 파일 보기

@@ -123,7 +123,7 @@ class Product extends ActiveRecordCommon
[['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'],
[['photo'], 'file'],
[['name', 'description', 'photo', 'unit'], 'string', 'max' => 255],
[['name', 'reference', 'description', 'photo', 'unit'], 'string', 'max' => 255],
[['recipe'], 'string', 'max' => 1000],
['step', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) {
if ($model->unit != 'piece') {
@@ -143,6 +143,7 @@ class Product extends ActiveRecordCommon
return [
'id' => 'ID',
'name' => 'Nom',
'reference' => 'Référence',
'description' => 'Description',
'active' => 'Actif',
'photo' => 'Photo',
@@ -438,5 +439,15 @@ class Product extends ActiveRecordCommon
}
}

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 파일 보기

@@ -0,0 +1,19 @@
<?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…
취소
저장