Przeglądaj źródła

Gestion référence commande

dev
Guillaume 3 lat temu
rodzic
commit
9c18008912
12 zmienionych plików z 94 dodań i 7 usunięć
  1. +2
    -1
      backend/controllers/DistributionController.php
  2. +3
    -0
      backend/controllers/OrderController.php
  3. +6
    -1
      backend/views/distribution/report.php
  4. +6
    -0
      backend/views/producer/update.php
  5. +1
    -1
      common/mail/orderConfirm-html.php
  6. +1
    -1
      common/mail/orderConfirm-text.php
  7. +34
    -2
      common/models/Order.php
  8. +5
    -1
      common/models/Producer.php
  9. +2
    -0
      common/models/Subscription.php
  10. +17
    -0
      console/migrations/m210317_120805_reference_order.php
  11. +16
    -0
      console/migrations/m210317_122616_option_order_reference_type.php
  12. +1
    -0
      producer/controllers/OrderController.php

+ 2
- 1
backend/controllers/DistributionController.php Wyświetl plik

@@ -516,7 +516,8 @@ class DistributionController extends BackendController
'selectedProductsArray' => $selectedProductsArray,
'pointsSaleArray' => $pointsSaleArray,
'productsArray' => $productsArray,
'ordersArray' => $ordersArray
'ordersArray' => $ordersArray,
'producer' => Producer::searchOne(['id' => $idProducer])
]);

$dateStr = date('d/m/Y', strtotime($date));

+ 3
- 0
backend/controllers/OrderController.php Wyświetl plik

@@ -149,6 +149,8 @@ class OrderController extends BackendController
$productOrder->save();
}
}

$order->initReference() ;
}
}
}
@@ -881,6 +883,7 @@ class OrderController extends BackendController
}

if($order) {
$order->initReference() ;
$order->setTillerSynchronization() ;
}


+ 6
- 1
backend/views/distribution/report.php Wyświetl plik

@@ -73,7 +73,7 @@ foreach ($pointsSaleArray as $pointSale) {
$strUser = '';

// username
$strUser = $order->getStrUser() ;
$strUser .= $order->getStrUser() ;
if(strlen($order->comment_point_sale))
{
@@ -85,6 +85,11 @@ foreach ($pointsSaleArray as $pointSale) {
$strUser .= '<br />' . $order->user->phone . '';
}

// référence
if($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY && $order->reference && strlen($order->reference) > 0) {
$strUser .= '<br />'.$order->reference ;
}

$html .= '<td>'.$strUser.'</td>';
// produits

+ 6
- 0
backend/views/producer/update.php Wyświetl plik

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

<?= $form->field($model, 'option_order_reference_type')
->dropDownList([
Producer::ORDER_REFERENCE_TYPE_NONE => '--',
Producer::ORDER_REFERENCE_TYPE_YEARLY => 'Annuelle',
], []) ; ?>
</div>
</div>


+ 1
- 1
common/mail/orderConfirm-html.php Wyświetl plik

@@ -44,7 +44,7 @@ $producer = GlobalParam::getCurrentProducer() ;

<p>Bonjour <?= Html::encode($user->name); ?>,</p>

<p>Votre commande d'une valeur de <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p>
<p>Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? 'N°'.$order->reference : '' ?> d'une valeur de <strong><?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?></strong> a bien été prise en compte.</p>

<p>Récapitulatif des produits commandés :</p>
<p><?= $order->getCartSummary() ?></p>

+ 1
- 1
common/mail/orderConfirm-text.php Wyświetl plik

@@ -44,7 +44,7 @@ $producer = GlobalParam::getCurrentProducer() ;

Bonjour <?= $user->name; ?>,

Votre commande d'une valeur de <?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte.
Votre commande <?= ($order->reference && strlen($order->reference) > 0) ? '<strong>N°'.$order->reference.'</strong>' : '' ?> d'une valeur de <?= $order->getAmountWithTax(Order::AMOUNT_TOTAL, true); ?> a bien été prise en compte.

Récapitulatif des produits commandés :
<?= $order->getCartSummary(false) ?>

+ 34
- 2
common/models/Order.php Wyświetl plik

@@ -103,7 +103,7 @@ class Order extends ActiveRecordCommon
[['id_user', 'date', 'status'], 'required', 'message' => ''],
[['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'],
[['auto_payment', 'tiller_synchronization'], 'boolean'],
[['status'], 'string'],
[['status', 'reference'], 'string'],
[['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe']
];
}
@@ -124,7 +124,8 @@ class Order extends ActiveRecordCommon
'status' => 'Statut',
'id_invoice' => 'Facture',
'id_quotation' => 'Devis',
'id_delivery_note' => 'Bon de livraison'
'id_delivery_note' => 'Bon de livraison',
'reference' => 'Référence'
];
}

@@ -964,4 +965,35 @@ class Order extends ActiveRecordCommon
}
}

public function initReference()
{
$producer = GlobalParam::getCurrentProducer() ;

if($producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY)
{
$lastOrder = Order::find()->innerJoinWith('distribution', true)
->where(['>=', 'distribution.date', date('Y').'-01-01'])
->andWhere([
'distribution.id_producer' => $producer->id
])
->andWhere(['not', ['order.reference' => null]])
->orderBy('order.id DESC')
->one() ;

if($lastOrder && $lastOrder->reference && strlen($lastOrder->reference) > 0) {
$pattern = '#A([0-9]+)C([0-9]+)#';
preg_match($pattern, $lastOrder->reference, $matches, PREG_OFFSET_CAPTURE);
$sizeNumReference = strlen($matches[2][0]);
$numReference = ((int)$matches[2][0]) + 1;
$numReference = str_pad($numReference, $sizeNumReference, '0', STR_PAD_LEFT);

$this->reference = 'A'.$matches[1][0].'C'.$numReference ;
}
else {
$this->reference = 'A'.date('y').'C0001' ;
}

$this->save() ;
}
}
}

+ 5
- 1
common/models/Producer.php Wyświetl plik

@@ -92,6 +92,9 @@ class Producer extends ActiveRecordCommon
const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR = 'calendar' ;
const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST = 'list' ;

const ORDER_REFERENCE_TYPE_NONE = '' ;
const ORDER_REFERENCE_TYPE_YEARLY = 'yearly' ;

var $secret_key_payplug;

/**
@@ -133,7 +136,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'],
'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'],
[['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'],
@@ -223,6 +226,7 @@ class Producer extends ActiveRecordCommon
'option_dashboard_date_end' => 'Date de fin',
'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',
];
}


+ 2
- 0
common/models/Subscription.php Wyświetl plik

@@ -261,6 +261,8 @@ class Subscription extends ActiveRecordCommon
if (!$productsAdd) {
$order->delete();
}

$order->initReference() ;
}
}
}

+ 17
- 0
console/migrations/m210317_120805_reference_order.php Wyświetl plik

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

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

class m210317_120805_reference_order extends Migration
{
public function safeUp()
{
$this->addColumn('order', 'reference', Schema::TYPE_STRING) ;
}

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

+ 16
- 0
console/migrations/m210317_122616_option_order_reference_type.php Wyświetl plik

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

use yii\db\Migration;

class m210317_122616_option_order_reference_type extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'option_order_reference_type', Schema::TYPE_STRING);
}

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

+ 1
- 0
producer/controllers/OrderController.php Wyświetl plik

@@ -459,6 +459,7 @@ class OrderController extends ProducerBaseController
}

$order->setTillerSynchronization() ;
$order->initReference() ;
}



Ładowanie…
Anuluj
Zapisz