Browse Source

Gestion référence commande

dev
Guillaume 3 years ago
parent
commit
9c18008912
12 changed files with 94 additions and 7 deletions
  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 View File

'selectedProductsArray' => $selectedProductsArray, 'selectedProductsArray' => $selectedProductsArray,
'pointsSaleArray' => $pointsSaleArray, 'pointsSaleArray' => $pointsSaleArray,
'productsArray' => $productsArray, 'productsArray' => $productsArray,
'ordersArray' => $ordersArray
'ordersArray' => $ordersArray,
'producer' => Producer::searchOne(['id' => $idProducer])
]); ]);


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

+ 3
- 0
backend/controllers/OrderController.php View File

$productOrder->save(); $productOrder->save();
} }
} }

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


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



+ 6
- 1
backend/views/distribution/report.php View File

$strUser = ''; $strUser = '';


// username // username
$strUser = $order->getStrUser() ;
$strUser .= $order->getStrUser() ;
if(strlen($order->comment_point_sale)) if(strlen($order->comment_point_sale))
{ {
$strUser .= '<br />' . $order->user->phone . ''; $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>'; $html .= '<td>'.$strUser.'</td>';
// produits // produits

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

0 => 'Non', 0 => 'Non',
1 => 'Oui' 1 => 'Oui'
], []); ?> ], []); ?>

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



+ 1
- 1
common/mail/orderConfirm-html.php View File



<p>Bonjour <?= Html::encode($user->name); ?>,</p> <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>Récapitulatif des produits commandés :</p>
<p><?= $order->getCartSummary() ?></p> <p><?= $order->getCartSummary() ?></p>

+ 1
- 1
common/mail/orderConfirm-text.php View File



Bonjour <?= $user->name; ?>, 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 : Récapitulatif des produits commandés :
<?= $order->getCartSummary(false) ?> <?= $order->getCartSummary(false) ?>

+ 34
- 2
common/models/Order.php View File

[['id_user', 'date', 'status'], 'required', 'message' => ''], [['id_user', 'date', 'status'], 'required', 'message' => ''],
[['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], [['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'],
[['auto_payment', 'tiller_synchronization'], 'boolean'], [['auto_payment', 'tiller_synchronization'], 'boolean'],
[['status'], 'string'],
[['status', 'reference'], 'string'],
[['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] [['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe']
]; ];
} }
'status' => 'Statut', 'status' => 'Statut',
'id_invoice' => 'Facture', 'id_invoice' => 'Facture',
'id_quotation' => 'Devis', 'id_quotation' => 'Devis',
'id_delivery_note' => 'Bon de livraison'
'id_delivery_note' => 'Bon de livraison',
'reference' => 'Référence'
]; ];
} }


} }
} }


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 View File

const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR = 'calendar' ; const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_CALENDAR = 'calendar' ;
const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST = 'list' ; const BEHAVIOR_ORDER_SELECT_DISTRIBUTION_LIST = 'list' ;


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

var $secret_key_payplug; var $secret_key_payplug;


/** /**
} }
}], }],
[['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'], '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'], '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'],
'option_dashboard_date_end' => 'Date de fin', '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_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',
]; ];
} }



+ 2
- 0
common/models/Subscription.php View File

if (!$productsAdd) { if (!$productsAdd) {
$order->delete(); $order->delete();
} }

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

+ 17
- 0
console/migrations/m210317_120805_reference_order.php View File

<?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 View File

<?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 View File

} }


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





Loading…
Cancel
Save