Sfoglia il codice sorgente

Adaptations producer/order

refactoring
parent
commit
869ed9a647
18 ha cambiato i file con 672 aggiunte e 672 eliminazioni
  1. +1
    -1
      backend/controllers/CronController.php
  2. +329
    -370
      backend/controllers/OrderController.php
  3. +6
    -1
      common/components/ActiveRecordCommon.php
  4. +10
    -10
      common/models/CreditHistory.php
  5. +34
    -34
      common/models/Order.php
  6. +28
    -15
      common/models/PointSale.php
  7. +1
    -1
      common/models/PointSaleDistribution.php
  8. +7
    -2
      common/models/ProductDistribution.php
  9. +16
    -1
      common/models/ProductOrder.php
  10. +4
    -4
      common/models/Subscription.php
  11. +1
    -1
      console/migrations/m181220_080234_translate_database.php
  12. +1
    -1
      frontend/views/layouts/main.php
  13. +31
    -26
      producer/controllers/OrderController.php
  14. +10
    -10
      producer/views/order/_form.php
  15. +2
    -1
      producer/views/order/history.php
  16. +55
    -50
      producer/web/css/screen.css
  17. +130
    -142
      producer/web/js/lechatdesnoisettes.js
  18. +6
    -2
      producer/web/sass/order/_form.scss

+ 1
- 1
backend/controllers/CronController.php Vedi File

@@ -247,7 +247,7 @@ class CronController extends BackendController
if($order->payment_auto && Producer::getConfig('credit', $order->distribution->id_producer)) {
if ($order->getAmount(Order::AMOUNT_REMAINING) > 0) {
$order->creditHistory(
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
$order->getAmount(Order::AMOUNT_REMAINING),
$order->distribution->id_producer,

+ 329
- 370
backend/controllers/OrderController.php
File diff soppresso perché troppo grande
Vedi File


+ 6
- 1
common/components/ActiveRecordCommon.php Vedi File

@@ -73,7 +73,12 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
if (isset($options['attribute_id_producer']) && strlen($options['attribute_id_producer'])
&& !isset($params[$options['attribute_id_producer']]) && !Yii::$app->user->isGuest)
{
$params[$options['attribute_id_producer']] = Producer::getId();
if(Yii::$app->controller->module->id == 'app-producer') {
$params[$options['attribute_id_producer']] = Yii::$app->controller->getProducer()->id ;
}
else {
$params[$options['attribute_id_producer']] = Producer::getId() ;
}
}
if(!isset($options['type_search'])) {

+ 10
- 10
common/models/CreditHistory.php Vedi File

@@ -85,7 +85,7 @@ class CreditHistory extends ActiveRecordCommon
public function rules()
{
return [
[['montant'], 'required'],
[['amount'], 'required'],
[['id_user', 'id_user_action', 'id_order', 'id_producer'], 'integer'],
[['date'], 'safe'],
[['amount'], 'double'],
@@ -205,7 +205,7 @@ class CreditHistory extends ActiveRecordCommon
{
return in_array($this->type, [
self::TYPE_DEBIT,
self::TYPE_PAIEMENT,
self::TYPE_PAYMENT,
]) ;
}
@@ -218,8 +218,8 @@ class CreditHistory extends ActiveRecordCommon
{
return in_array($this->type, [
self::TYPE_CREDIT,
self::TYPE_CREDIT_INITIAL,
self::TYPE_REMBOURSEMENT
self::TYPE_INITIAL_CREDIT,
self::TYPE_REFUND
]) ;
}
@@ -249,25 +249,25 @@ class CreditHistory extends ActiveRecordCommon
{
$str = '' ;
if($this->type == self::TYPE_CREDIT_INITIAL) {
if($this->type == self::TYPE_INITIAL_CREDIT) {
$str = 'Crédit initial' ;
}
elseif($this->type == self::TYPE_CREDIT) {
$str = 'Crédit' ;
}
elseif($this->type == self::TYPE_PAIEMENT) {
elseif($this->type == self::TYPE_PAYMENT) {
$str = 'Paiement' ;
}
elseif($this->type == self::TYPE_REMBOURSEMENT) {
elseif($this->type == self::TYPE_REFUND) {
$str = 'Remboursement' ;
}
elseif($this->type == self::TYPE_DEBIT) {
$str = 'Débit' ;
}
if($this->type == self::TYPE_PAIEMENT || $this->type == self::TYPE_REMBOURSEMENT) {
if(isset($this->commande)) {
$str .= '<br />Commande : '.date('d/m/Y',strtotime($this->commande->production->date)) ;
if($this->type == self::TYPE_PAYMENT || $this->type == self::TYPE_REFUND) {
if(isset($this->order)) {
$str .= '<br />Commande : '.date('d/m/Y',strtotime($this->order->distribution->date)) ;
}
else {
$str .= '<br />Commande supprimée' ;

+ 34
- 34
common/models/Order.php Vedi File

@@ -51,7 +51,7 @@ use common\components\ActiveRecordCommon ;
* @property string $date
* @property string $date_update
* @property integer $id_point_sale
* @property integer $id_production
* @property integer $id_distribution
* @property boolean $auto_payment
*/
class Order extends ActiveRecordCommon
@@ -91,8 +91,8 @@ class Order extends ActiveRecordCommon
public function rules()
{
return [
[['id_user', 'date', 'id_point_sale', 'id_production'], 'required', 'message' => ''],
[['id_user', 'id_point_sale', 'id_production'], 'integer'],
[['id_user', 'date', 'id_point_sale', 'id_distribution'], 'required', 'message' => ''],
[['id_user', 'id_point_sale', 'id_distribution'], 'integer'],
[['auto_payment'], 'boolean'],
[['date', 'date_update', 'comment', 'comment_point_sale'], 'safe']
];
@@ -109,7 +109,7 @@ class Order extends ActiveRecordCommon
'date' => 'Date',
'date_update' => 'Date de modification',
'id_point_sale' => 'Point de vente',
'id_production' => 'Date de production',
'id_distribution' => 'Date de distribution',
];
}

@@ -128,16 +128,16 @@ class Order extends ActiveRecordCommon
->with('product');
}

public function getProduction()
public function getDistribution()
{
return $this->hasOne(Production::className(), ['id' => 'id_production'])
return $this->hasOne(Distribution::className(), ['id' => 'id_distribution'])
->with('producer');
}

public function getPointSale()
{
return $this->hasOne(PointSale::className(), ['id' => 'id_point_sale'])
->with('pointSaleUser');
->with('userPointSale');
}

public function getCreditHistory()
@@ -153,9 +153,9 @@ class Order extends ActiveRecordCommon
public static function defaultOptionsSearch() {
return [
'with' => ['productOrder', 'creditHistory', 'pointSale'],
'join_with' => ['production', 'user', 'user.userProducer'],
'join_with' => ['distribution', 'user', 'user.userProducer'],
'orderby' => 'order.date ASC',
'attribute_id_producer' => 'production.id_producer'
'attribute_id_producer' => 'distribution.id_producer'
] ;
}
@@ -177,15 +177,15 @@ class Order extends ActiveRecordCommon
*/
public function initAmount() {
if (isset($this->productOrder)) {
foreach ($this->productOrder as $p) {
if ($p->sale_mode == Product::SALE_MODE_UNIT) {
$this->amount += $p->price * $p->quantity ;
if(isset($p->product)) {
$this->weight += ($p->quantity * $p->product->weight) / 1000 ;
foreach ($this->productOrder as $productOrder) {
if ($productOrder->sale_mode == Product::SALE_MODE_UNIT) {
$this->amount += $productOrder->price * $productOrder->quantity ;
if(isset($productOrder->product)) {
$this->weight += ($productOrder->quantity * $productOrder->product->weight) / 1000 ;
}
}
elseif ($p->sale_mode == Product::SALE_MODE_WEIGHT) {
$this->amount += $p->price * $p->quantity / 1000;
elseif ($productOrder->sale_mode == Product::SALE_MODE_WEIGHT) {
$this->amount += $productOrder->price * $productOrder->quantity / 1000;
}
}
}
@@ -264,8 +264,8 @@ class Order extends ActiveRecordCommon
$jsonOrder = [
'products' => [],
'amount' => $order->amount,
'str_amount' => $order->getAmount(self::TYPE_AMOUNT_TOTAL, true),
'paid_amount' => $order->getPaidAmount(self::TYPE_AMOUNT_PAID),
'str_amount' => $order->getAmount(self::AMOUNT_TOTAL, true),
'paid_amount' => $order->getPaidAmount(self::AMOUNT_PAID),
'comment' => $order->comment,
];

@@ -308,17 +308,17 @@ class Order extends ActiveRecordCommon
public function getPaymentStatus()
{
// payé
if ($this->getAmount() - $this->getAmount(self::TYPE_AMOUNT_PAID) < 0.01 &&
$this->getAmount() - $this->getAmount(self::TYPE_AMOUNT_PAID) >= 0)
if ($this->getAmount() - $this->getAmount(self::AMOUNT_PAID) < 0.01 &&
$this->getAmount() - $this->getAmount(self::AMOUNT_PAID) >= 0)
{
return self::PAYMENT_PAID ;
}
// à rembourser
elseif ($this->getAmount() - $this->getAmount(self::TYPE_AMOUNT_PAID) <= -0.01) {
elseif ($this->getAmount() - $this->getAmount(self::AMOUNT_PAID) <= -0.01) {
return self::PAYMENT_SURPLUS ;
}
// reste à payer
elseif ($this->getAmount() - $this->getAmount(self::TYPE_AMOUNT_PAID) >= 0.01) {
elseif ($this->getAmount() - $this->getAmount(self::AMOUNT_PAID) >= 0.01) {
return self::PAYMENT_UNPAID ;
}
}
@@ -354,19 +354,19 @@ class Order extends ActiveRecordCommon
*
* @return string
*/
public function getSalePointSummary()
public function getPointSaleSummary()
{
$html = '';

if (isset($this->salePoint)) {
if (isset($this->pointSale)) {
$html .= '<span class="name-point-sale">' .
Html::encode($this->salePoint->name) .
Html::encode($this->pointSale->name) .
'</span>' .
'<br /><span class="locality">'
. Html::encode($this->salePoint->locality)
. Html::encode($this->pointSale->locality)
. '</span>';
if (strlen($this->sale_point_comment)) {
if (strlen($this->comment_point_sale)) {
$html .= '<div class="comment"><span>'
. Html::encode($this->comment_point_sale)
. '</span></div>';
@@ -387,7 +387,7 @@ class Order extends ActiveRecordCommon
{
$html = '';

$html .= $this->getAmount(self::TYPE_AMOUNT_TOTAL, true) . '<br />';
$html .= $this->getAmount(self::AMOUNT_TOTAL, true) . '<br />';

if ($this->paid_amount) {
if ($this->getPaymentStatus() == Order::PAYMENT_PAID) {
@@ -431,21 +431,21 @@ class Order extends ActiveRecordCommon
{
$orderDelay = Producer::getConfig(
'order_delay',
$this->production->id_producer
$this->distribution->id_producer
);
$orderDeadline = Producer::getConfig(
'order_deadline',
$this->production->id_producer
$this->distribution->id_producer
);

$orderDate = strtotime($this->production->date);
$orderDate = strtotime($this->distribution->date);
$today = strtotime(date('Y-m-d'));
$todayHour = date('G');

$nbDays = (int) (($dateOrder - $today) / (24 * 60 * 60));
$nbDays = (int) (($orderDate - $today) / (24 * 60 * 60));

if ($nb_days <= 0) {
if ($nbDays <= 0) {
return self::STATE_DELIVERED;
}
elseif ($nbDays >= $orderDelay &&
@@ -565,7 +565,7 @@ class Order extends ActiveRecordCommon
foreach ($orders as $c) {
if(is_null($c->date_delete)) {
foreach ($c->productOrder as $po) {
if ($po->id_product == $id_product) {
if ($po->id_product == $idProduct) {
$quantity += $po->quantity ;
}
}

+ 28
- 15
common/models/PointSale.php Vedi File

@@ -40,8 +40,9 @@ namespace common\models;

use Yii;
use yii\helpers\Html;
use common\models\PointSaleUser;
use common\models\ProductionPointSale;
use common\models\UserPointSale;
use common\models\PointSaleDistribution ;
use common\components\ActiveRecordCommon ;

/**
* This is the model class for table "point_vente".
@@ -51,7 +52,7 @@ use common\models\ProductionPointSale;
* @property string $address
* @property integer $id_producer
*/
class PointSale extends \yii\db\ActiveRecord
class PointSale extends ActiveRecordCommon
{
var $orders = [];
var $revenues = 0;
@@ -141,7 +142,19 @@ class PointSale extends \yii\db\ActiveRecord
);
}

/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function defaultOptionsSearch() {
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => 'point_sale.id_producer'
] ;
}
/**
* Initialise les commandes liées au point de vente.
@@ -207,19 +220,19 @@ class PointSale extends \yii\db\ActiveRecord
*/
public function processRestrictedAccess()
{
PointSaleUser::deleteAll(['id_point_sale' => $this->id]);
UserPointSale::deleteAll(['id_point_sale' => $this->id]);

if (is_array($this->users) && count($this->users)) {
foreach ($this->users as $key => $val) {
$user = User::findOne($val);
if ($user) {
$pointSaleUser = new PointSaleUser;
$pointSaleUser->id_user = $val;
$pointSaleUser->id_point_sale = $this->id;
$userPointSale = new UserPointSale;
$userPointSale->id_user = $val;
$userPointSale->id_point_sale = $this->id;
if (isset($this->users_comment[$val]) && strlen($this->users_comment[$val])) {
$point_sale_user->comment = $this->users_comment[$val];
$userPointSale->comment = $this->users_comment[$val];
}
$point_sale_user->save();
$userPointSale->save();
}
}
}
@@ -232,10 +245,10 @@ class PointSale extends \yii\db\ActiveRecord
*/
public function getComment()
{
if (isset($this->pointSaleUser)) {
foreach ($this->pointSaleUser as $pointSaleUser) {
if ($pointSaleUser->id_user == Yii::$app->user->identity->id) {
return $pointSaleUser->comment;
if (isset($this->userPointSale)) {
foreach ($this->userPointSale as $userPointSale) {
if ($userPointSale->id_user == User::getCurrentId()) {
return $userPointSale->comment;
}
}
}
@@ -310,7 +323,7 @@ class PointSale extends \yii\db\ActiveRecord
$field = 'infos_'.$day ;
if(strlen($this->$field)) {
$str = nl2br(Html::encode($this->$champs)) ;
$str = nl2br(Html::encode($this->$field)) ;
$str = preg_replace('/\[select_previous_day\](.*?)\[\/select_previous_day\]/', '<a href="javascript:void(0);" class="select-previous-day">$1</a>' , $str) ;
}
return $str ;

+ 1
- 1
common/models/PointSaleDistribution.php Vedi File

@@ -107,7 +107,7 @@ class PointSaleDistribution extends ActiveRecordCommon
*/
public static function defaultOptionsSearch() {
return [
'with' => ['production', 'pointVente'],
'with' => ['distribution', 'pointSale'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''

+ 7
- 2
common/models/ProductDistribution.php Vedi File

@@ -79,6 +79,11 @@ class ProductDistribution extends ActiveRecordCommon
{
return $this->hasOne(Product::className(), ['id' => 'id_product']);
}
public function getDistribution()
{
return $this->hasOne(Distribution::className(), ['id' => 'id_distribution']);
}

/**
* @inheritdoc
@@ -101,7 +106,7 @@ class ProductDistribution extends ActiveRecordCommon
*/
public static function defaultOptionsSearch() {
return [
'with' => ['produit','distribution'],
'with' => ['product','distribution'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
@@ -128,7 +133,7 @@ class ProductDistribution extends ActiveRecordCommon
if (isset($productDistribution->product)) {
$arrayProductsDistribution[$productDistribution->id_product] = [
'active' => (int) $productDistribution->active,
'epuise' => (int) $productDistribution->product->unavailable,
'unavailable' => (int) $productDistribution->product->unavailable,
'quantity_max' => $productDistribution->quantity_max,
'quantity_order' => Order::getProductQuantity($productDistribution->id_product, $orders),
'quantity_remaining' => $productDistribution->quantity_max - Order::getProductQuantity($productDistribution->id_product, $orders)

+ 16
- 1
common/models/ProductOrder.php Vedi File

@@ -39,6 +39,7 @@ termes.
namespace common\models;

use Yii;
use common\components\ActiveRecordCommon ;

/**
* This is the model class for table "product_order".
@@ -48,7 +49,7 @@ use Yii;
* @property integer $id_product
* @property double $quantity
*/
class ProductOrder extends \yii\db\ActiveRecord
class ProductOrder extends ActiveRecordCommon
{

/**
@@ -92,5 +93,19 @@ class ProductOrder extends \yii\db\ActiveRecord
'quantity' => 'Quantité',
];
}
/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function defaultOptionsSearch() {
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
] ;
}

}

+ 4
- 4
common/models/Subscription.php Vedi File

@@ -42,7 +42,7 @@ use Yii;
use common\components\ActiveRecordCommon ;
use common\models\Producer;
use common\models\PointSale;
use common\models\PointSaleUser;
use common\models\UserPointSale;
use common\models\Order;
use common\models\ProductOrder;

@@ -189,13 +189,13 @@ class Subscription extends ActiveRecordCommon
$order->id_production = $production->id;
$order->auto_payment = $this->auto_payment ;
$pointSaleUser = PointSaleUser::searchOne([
$userPointSale = UserPointSale::searchOne([
'id_point_sale' => $this->id_point_sale,
'id_user' => $this->id_user
]) ;

if ($pointSaleUser && strlen($pointSaleUser->comment)) {
$order->comment_point_sale = $pointSaleUser->comment;
if ($userPointSale && strlen($userPointSale->comment)) {
$order->comment_point_sale = $userPointSale->comment;
}

$order->save();

+ 1
- 1
console/migrations/m181220_080234_translate_database.php Vedi File

@@ -141,7 +141,7 @@ class m181220_080234_translate_database extends Migration
$this->renameColumn('product', 'recette', 'recipe') ;
$this->renameColumn('product', 'lundi', 'monday') ;
$this->renameColumn('product', 'mardi', 'tuesday') ;
$this->renameColumn('product', 'mercredi', 'w<ednesday') ;
$this->renameColumn('product', 'mercredi', 'wednesday') ;
$this->renameColumn('product', 'jeudi', 'thursday') ;
$this->renameColumn('product', 'vendredi', 'friday') ;
$this->renameColumn('product', 'samedi', 'saterday') ;

+ 1
- 1
frontend/views/layouts/main.php Vedi File

@@ -168,7 +168,7 @@ $isHome = (Yii::$app->controller->id == 'site' && Yii::$app->controller->action-
<?php if(count($producersArray)): ?>
<h2>Mes producteurs</h2>
<?php foreach($producersArray as $producer): ?>
<div class="col-md-<?php if(count($producers) == 1): ?>6<?php elseif(count($producersArray) == 2): ?>6<?php else: ?>3<?php endif; ?>">
<div class="col-md-<?php if(count($producersArray) == 1): ?>6<?php elseif(count($producersArray) == 2): ?>6<?php else: ?>3<?php endif; ?>">
<div class="producer" style="background-image:url('<?= Yii::$app->urlManagerProducer->getHostInfo().'/'.Yii::$app->urlManagerProducer->baseUrl ; ?>/uploads/<?= $producer->photo ?>');">
<a class="btn btn-primary" href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index','slug_producer' => $producer->slug]); ?>"><?= Html::encode($producer->name); ?></a>
</div>

+ 31
- 26
producer/controllers/OrderController.php Vedi File

@@ -67,13 +67,15 @@ class OrderController extends ProducerBaseController
*/
public function actionInfosDistribution($idDistribution)
{
$distribution = Distribution::searchOne($idDistribution);
$distribution = Distribution::searchOne([
'id' => $idDistribution
]);

if ($distribution) {
$arr = [];

$productsArray = ProductDistribution::searchByDistribution($distribution->id) ;
$data['products'] = $productsArray;

$pointSaleArray = PointSale::find()
@@ -85,13 +87,13 @@ class OrderController extends ProducerBaseController
])
->all();

$data['pointsSale'] = [];
$data['points_sale'] = [];
foreach ($pointSaleArray as $pointSale) {
if (isset($pointSale->pointSaleDistribution) &&
isset($pointSale->pointSaleDistribution[0])) {
$data['points_vente'][$pointSale->id] = $pointSale->pointSaleDistribution[0]->delivery;
$data['points_sale'][$pointSale->id] = $pointSale->pointSaleDistribution[0]->delivery;
} else {
$data['points_vente'][$pointSale->id] = false;
$data['points_sale'][$pointSale->id] = false;
}
}

@@ -120,7 +122,7 @@ class OrderController extends ProducerBaseController
$pointsSaleArray = PointSale::find()
->with('userPointSale')
->where(['id_producer' => $idProducer])
->andWhere('restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND point_sale_user.id_user = :id_user) > 0)')
->andWhere('restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0)')
->params([':id_user' => User::getCurrentId()])
->all();

@@ -270,7 +272,6 @@ class OrderController extends ProducerBaseController
*/
public function actionCreate()
{

$idProducer = $this->getProducer()->id ;
$order = new Order;

@@ -282,7 +283,11 @@ class OrderController extends ProducerBaseController

if ($order->load($posts)) {

$order = Order::find()->where('id_distribution = ' . $posts['Order']['id_distribution'])->andWhere('id_user = ' . User::getCurrentId())->one();
$order = Order::find()
->where('id_distribution = ' . $posts['Order']['id_distribution'])
->andWhere('id_user = ' . User::getCurrentId())
->one();
if (!$order) {
$order = new Order;
$order->load(Yii::$app->request->post());
@@ -290,8 +295,8 @@ class OrderController extends ProducerBaseController
$order->date = date('Y-m-d H:i:s');
$order->type = Order::ORIGIN_USER;
}
$this->processForm($Order);
$this->processForm($order);
}

return $this->render('create', array_merge($this->initForm($order), [
@@ -308,7 +313,7 @@ class OrderController extends ProducerBaseController
*/
public function actionUpdate($id)
{
$order = sOrder::searchOne([
$order = Order::searchOne([
'id' => $id
]) ;

@@ -323,7 +328,7 @@ class OrderController extends ProducerBaseController
$this->processForm($order);
}

return $this->render('update', array_merge($this->processForm($order), [
return $this->render('update', array_merge($this->initForm($order), [
'model' => $order,
'orderNotfound' => !$order,
]));
@@ -357,7 +362,7 @@ class OrderController extends ProducerBaseController

foreach ($posts['Product'] as $key => $quantity) {
$key = (int) str_replace('product_', '', $key);
$product = Produit::find()->where(['id' => $key])->one();
$product = Product::find()->where(['id' => $key])->one();
$totalQuantity += $quantity;
if ($product && $quantity) {
$productsArray[] = $product;
@@ -393,7 +398,7 @@ class OrderController extends ProducerBaseController
$errorPointSale = true;
}

$pointSale = PointSale::findOne($posts['Commande']['id_point_vente']);
$pointSale = PointSale::findOne($posts['Order']['id_point_sale']);

if ($pointSale) {
if (strlen($pointSale->code) && !$pointSale->validateCode($posts['code_point_sale_' . $pointSale->id])) {
@@ -433,7 +438,6 @@ class OrderController extends ProducerBaseController
// sauvegarde des produits
foreach ($productsArray as $product) {
if (isset($availableProducts[$product->id])) {

$productOrder = new ProductOrder();
$productOrder->id_order = $order->id;
$productOrder->id_product = $product->id;
@@ -441,22 +445,23 @@ class OrderController extends ProducerBaseController
$productOrder->price = $product->price;

$quantity = (int) $posts['Product']['product_' . $product->id];
if ($produits_dispos[$product->id]['quantity_max'] && $quantity > $availableProducts[$product->id]['quantity_remaining']) {
$quantity = $availableProducts[$p->id]['quantity_remaining'];
if ($availableProducts[$product->id]['quantity_max'] && $quantity > $availableProducts[$product->id]['quantity_remaining']) {
$quantity = $availableProducts[$product->id]['quantity_remaining'];
}
$productOrder->quantity = $quantity;

$productOrder->sale_mode = Product::SALE_MODE_UNIT ;
$productOrder->save();
}
}

// credit
$credit = isset($posts['credit']) && $posts['credit'];
$order = Order::searchOne([
'id' => $order->id
]) ;
if ($credit && ($pointSale->credit || $order->getAmount(Order::AMOUNT_PAID))) {
$order = Order::searchOne([
'id' => $order->id
]) ;
$amountPaid = $order->getAmount(Order::AMOUNT_PAID);

// à payer
@@ -469,7 +474,7 @@ class OrderController extends ProducerBaseController
}

if ($amountRemaining > 0) {
$order->creditHistory(
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
$amountRemaining,
$distribution->id_producer,
@@ -481,7 +486,7 @@ class OrderController extends ProducerBaseController
// surplus à rembourser
elseif ($order->getPaymentStatus() == Order::PAYMENT_SURPLUS) {
$amountSurplus = $order->getAmount(Order::AMOUNT_SURPLUS) ;
$order->creditHistory(
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$amountSurplus,
$distribution->id_producer,
@@ -532,8 +537,8 @@ class OrderController extends ProducerBaseController
if ($order && User::getCurrentId() == $order->id_user) {
// remboursement
if ($order->getAmount(Order::AMOUNT_PAID)) {
$order->creditHistory(
CreditHistory::PAYMENT_REFUND,
$order->saveCreditHistory(
CreditHistory::TYPE_REFUND,
$order->getAmount(Order::AMOUNT_PAID),
$order->distribution->id_producer,
User::getCurrentId(),
@@ -557,7 +562,7 @@ class OrderController extends ProducerBaseController
* @param string $code
* @return boolean
*/
public function actionvalidateCodePointSale($idPointSale, $code)
public function actionValidateCodePointSale($idPointSale, $code)
{
$pointSale = PointSale::findOne($idPointSale);
if ($pointSale) {

+ 10
- 10
producer/views/order/_form.php Vedi File

@@ -56,7 +56,7 @@ use yii\widgets\ActiveForm;
<?php if($idProducer && count($distributionDaysArray) > 1): ?>
<div id="step-choice-date" class="col-md-6">
<div id="step-date" class="col-md-6">
<?= $form->field($model, 'id_distribution')->label('')->hiddenInput(); ?>

<?php if (isset($model->id)): ?>
@@ -75,15 +75,15 @@ use yii\widgets\ActiveForm;
<div id="dates" style="display:none;">
<?php
foreach ($distributionDaysArray as $idDistribution => $day) {
if ($j != '--') {
echo '<div><span class="date">' . $day . '</span><span class="id_production">' . $idDistribution. '</span></div>';
if ($day != '--') {
echo '<div><span class="date">' . $day . '</span><span class="id_distribution">' . $idDistribution. '</span></div>';
}
}
?>
</div>

<div class="clr"></div>
<div id="in-progress-orders" style="display:none;">
<div id="orders-in-progress" style="display:none;">
<?php foreach ($ordersArray as $order): ?>
<?php echo '<div class="order" data-iddistribution="' . $order->id_distribution. '" data-id="' . $order->id . '" data-href="' . Yii::$app->urlManager->createUrl(['order/update', 'id' => $order->id, 'id_producer' => $order->distribution->id_producer]) . '"></div>'; ?>
<?php endforeach; ?>
@@ -112,7 +112,7 @@ use yii\widgets\ActiveForm;

<input type="hidden" id="livraison" value="<?php if (!is_null($distribution) && $distribution->delivery): ?>1<?php else: ?>0<?php endif; ?>" />

<ul id="points-sale" class="blocs">
<ul id="points-sale" class="blocks">
<?php
foreach ($pointsSaleArray as $pointSale) {
@@ -124,7 +124,7 @@ use yii\widgets\ActiveForm;
{
if($userPointSale->id_user == User::getCurrentId() && strlen($userPointSale->comment))
{
$comment = '<div class="commentaire"><span>'.Html::encode($userPointSale->comment).'</span></div>' ;
$comment = '<div class="comment"><span>'.Html::encode($userPointSale->comment).'</span></div>' ;
}
}
}
@@ -144,7 +144,7 @@ use yii\widgets\ActiveForm;
}
}
echo '<li class="bloc point-vente point-vente-' . $pointSale->id . '" data-code="'.$dataCode.'" data-credit="'.(int) $pointSale->credit.'"><div class="contenu">' .
echo '<li class="block point-sale point-sale-' . $pointSale->id . '" data-code="'.$dataCode.'" data-credit="'.(int) $pointSale->credit.'"><div class="contenu">' .
'<span style="display:none;" class="id">' . $pointSale->id . '</span>' .
'<div class="name">' .$htmlCode. Html::encode($pointSale->name) . '</div>' .
'<div class="address">à ' . Html::encode($pointSale->locality) . '</div>' .
@@ -161,7 +161,7 @@ use yii\widgets\ActiveForm;
<div id="step-infos-point-sale">
<?php
foreach ($pointsSaleArray as $pointSale) {
echo '<div class="alert alert-warning infos-pv infos-pv-'.$pointSale->id.'"><h4>Infos : <span>'.Html::encode($pointSale->name).'</span></h4>' .
echo '<div class="alert alert-warning infos-point-sale infos-point-sale-'.$pointSale->id.'"><h4>Infos : <span>'.Html::encode($pointSale->name).'</span></h4>' .
'<div class="jour jour-1">' . $pointSale->getStrInfos('monday') . '</div>' .
'<div class="jour jour-2">' . $pointSale->getStrInfos('tuesday') . '</div>' .
'<div class="jour jour-3">' . $pointSale->getStrInfos('wednesday') . '</div>' .
@@ -188,7 +188,7 @@ use yii\widgets\ActiveForm;

<div id="">
<div class="alert alert-warning unavailable">Produit indisponible pour ce point de vente</div>
<table class="table table-bordered" id="table-produits">
<table class="table table-bordered" id="table-products">
<thead>
<tr>
<th class="th-photo">Photo</th>
@@ -233,7 +233,7 @@ use yii\widgets\ActiveForm;
endif; ?></span> <?php echo Html::encode(strtolower($product->name)); ?>(s)
</div>
<div class="epuise">Épuisé</div>
<div class="unavailable">Épuisé</div>
</td>
<td class="total"><strong></strong></td>
</tr>

+ 2
- 1
producer/views/order/history.php Vedi File

@@ -37,6 +37,7 @@ termes.
*/

use yii\bootstrap\ActiveForm;
use common\models\Order ;

$this->setTitle('Historique de mes commandes') ;

@@ -96,7 +97,7 @@ GridView::widget([
'label' => 'Statut',
'format' => 'raw',
'value' => function($c) {
if($c->getState() == Order::STATE_DELIVERY) {
if($c->getState() == Order::STATE_DELIVERED) {
return 'Livrée' ;
}
elseif($c->getState() == Order::STATE_PREPARATION) {

+ 55
- 50
producer/web/css/screen.css Vedi File

@@ -793,14 +793,14 @@ termes.
padding: 3px 10px;
}
/* line 200, ../sass/order/_form.scss */
.order-create #main #content .order-form .infos-point-sale,
.order-update #main #content .order-form .infos-point-sale {
.order-create #main #content .order-form .infos-points-sale,
.order-update #main #content .order-form .infos-points-sale {
display: none;
margin-top: 15px;
}
/* line 204, ../sass/order/_form.scss */
.order-create #main #content .order-form .infos-point-sale h4,
.order-update #main #content .order-form .infos-point-sale h4 {
.order-create #main #content .order-form .infos-points-sale h4,
.order-update #main #content .order-form .infos-points-sale h4 {
margin-top: 0px;
padding-top: 0px;
text-align: left;
@@ -809,14 +809,14 @@ termes.
font-family: "myriadpro-semibold";
}
/* line 212, ../sass/order/_form.scss */
.order-create #main #content .order-form .infos-point-sale h4 span,
.order-update #main #content .order-form .infos-point-sale h4 span {
.order-create #main #content .order-form .infos-points-sale h4 span,
.order-update #main #content .order-form .infos-points-sale h4 span {
font-family: "myriadpro-regular";
text-transform: none;
}
/* line 218, ../sass/order/_form.scss */
.order-create #main #content .order-form .infos-point-sale a,
.order-update #main #content .order-form .infos-point-sale a {
.order-create #main #content .order-form .infos-points-sale a,
.order-update #main #content .order-form .infos-points-sale a {
text-decoration: underline;
}
/* line 223, ../sass/order/_form.scss */
@@ -825,29 +825,34 @@ termes.
margin-top: 15px;
}
/* line 226, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .alert.unavailable,
.order-update #main #content .order-form #products .alert.unavailable {
display: none;
}
/* line 230, ../sass/order/_form.scss */
.order-create #main #content .order-form #products #label-products,
.order-update #main #content .order-form #products #label-products {
display: block;
margin-bottom: 5px;
}
/* line 231, ../sass/order/_form.scss */
/* line 235, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table,
.order-update #main #content .order-form #products .table {
margin-top: 7px;
}
/* line 234, ../sass/order/_form.scss */
/* line 238, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .photo,
.order-update #main #content .order-form #products .table .photo {
padding: 0px;
width: 120px;
}
/* line 239, ../sass/order/_form.scss */
/* line 243, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .th-photo, .order-create #main #content .order-form #products .table .td-photo,
.order-update #main #content .order-form #products .table .th-photo,
.order-update #main #content .order-form #products .table .td-photo {
width: 120px;
}
/* line 243, ../sass/order/_form.scss */
/* line 247, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .name,
.order-update #main #content .order-form #products .table .name {
font-family: "comfortaalight";
@@ -855,27 +860,27 @@ termes.
text-transform: uppercase;
font-size: 18px;
}
/* line 250, ../sass/order/_form.scss */
/* line 254, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .description,
.order-update #main #content .order-form #products .table .description {
font-style: italic;
}
/* line 254, ../sass/order/_form.scss */
/* line 258, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .recipe,
.order-update #main #content .order-form #products .table .recipe {
font-size: 12px;
}
/* line 258, ../sass/order/_form.scss */
/* line 262, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .input-group,
.order-update #main #content .order-form #products .table .input-group {
width: 133px;
}
/* line 260, ../sass/order/_form.scss */
/* line 264, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .input-group .quantity,
.order-update #main #content .order-form #products .table .input-group .quantity {
text-align: center;
}
/* line 265, ../sass/order/_form.scss */
/* line 269, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .column-quantity, .order-create #main #content .order-form #products .table .price-unit, .order-create #main #content .order-form #products .table .total,
.order-update #main #content .order-form #products .table .column-quantity,
.order-update #main #content .order-form #products .table .price-unit,
@@ -883,16 +888,16 @@ termes.
width: 150px;
text-align: center;
}
/* line 270, ../sass/order/_form.scss */
/* line 274, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table td#total-order, .order-create #main #content .order-form #products .table td#total-order-vrac, .order-create #main #content .order-form #products .table td.total,
.order-update #main #content .order-form #products .table td#total-order,
.order-update #main #content .order-form #products .table td#total-order-vrac,
.order-update #main #content .order-form #products .table td.total {
text-align: center;
}
/* line 274, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .epuise,
.order-update #main #content .order-form #products .table .epuise {
/* line 278, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .unavailable,
.order-update #main #content .order-form #products .table .unavailable {
display: none;
text-transform: uppercase;
color: #B32815;
@@ -900,42 +905,42 @@ termes.
font-size: 16px;
text-align: center;
}
/* line 283, ../sass/order/_form.scss */
/* line 287, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .quantity-remaining,
.order-update #main #content .order-form #products .table .quantity-remaining {
font-size: 12px;
margin-top: 8px;
}
/* line 287, ../sass/order/_form.scss */
/* line 291, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table .quantity-remaining .nb,
.order-update #main #content .order-form #products .table .quantity-remaining .nb {
font-weight: bold;
}
/* line 292, ../sass/order/_form.scss */
/* line 296, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table td.product, .order-create #main #content .order-form #products .table th.product,
.order-update #main #content .order-form #products .table td.product,
.order-update #main #content .order-form #products .table th.product {
width: 70%;
}
/* line 296, ../sass/order/_form.scss */
/* line 300, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table td.price-unit, .order-create #main #content .order-form #products .table th.price-unit,
.order-update #main #content .order-form #products .table td.price-unit,
.order-update #main #content .order-form #products .table th.price-unit {
width: 10%;
}
/* line 300, ../sass/order/_form.scss */
/* line 304, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table td.column-quantity, .order-create #main #content .order-form #products .table th.column-quantity,
.order-update #main #content .order-form #products .table td.column-quantity,
.order-update #main #content .order-form #products .table th.column-quantity {
width: 10%;
}
/* line 304, ../sass/order/_form.scss */
/* line 308, ../sass/order/_form.scss */
.order-create #main #content .order-form #products .table td.total, .order-create #main #content .order-form #products .table th.total,
.order-update #main #content .order-form #products .table td.total,
.order-update #main #content .order-form #products .table th.total {
width: 10%;
}
/* line 310, ../sass/order/_form.scss */
/* line 314, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed,
.order-update #main #content .order-form #bar-fixed {
display: none;
@@ -955,14 +960,14 @@ termes.
background-color: #F8F1DD;
text-align: center;
}
/* line 326, ../sass/order/_form.scss */
/* line 330, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed .container,
.order-update #main #content .order-form #bar-fixed .container {
min-height: auto;
background: none;
border: 0px none;
}
/* line 332, ../sass/order/_form.scss */
/* line 336, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed.not-fixed,
.order-update #main #content .order-form #bar-fixed.not-fixed {
position: relative;
@@ -975,18 +980,18 @@ termes.
border: solid 1px #e0e0e0;
padding-right: 20px;
}
/* line 339, ../sass/order/_form.scss */
/* line 343, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed.not-fixed .container,
.order-update #main #content .order-form #bar-fixed.not-fixed .container {
width: auto;
}
/* line 345, ../sass/order/_form.scss */
/* line 349, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed.no-credit #bloc-valider-commande,
.order-update #main #content .order-form #bar-fixed.no-credit #bloc-valider-commande {
margin-top: 0px;
float: right;
}
/* line 351, ../sass/order/_form.scss */
/* line 355, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #total-order-bottom,
.order-update #main #content .order-form #bar-fixed #total-order-bottom {
background-color: white;
@@ -996,29 +1001,29 @@ termes.
padding: 5px 25px;
border: solid 1px #e0e0e0;
}
/* line 358, ../sass/order/_form.scss */
/* line 362, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed .btn-comment,
.order-update #main #content .order-form #bar-fixed .btn-comment {
float: left;
}
/* line 366, ../sass/order/_form.scss */
/* line 370, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed .btn-comment,
.order-update #main #content .order-form #bar-fixed .btn-comment {
margin-right: 10px;
}
/* line 370, ../sass/order/_form.scss */
/* line 374, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #block-confirm-order,
.order-update #main #content .order-form #bar-fixed #block-confirm-order {
text-align: right;
margin-top: 20px;
}
/* line 374, ../sass/order/_form.scss */
/* line 378, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #block-confirm-order button,
.order-update #main #content .order-form #bar-fixed #block-confirm-order button {
width: 340px;
margin-right: 10px;
}
/* line 380, ../sass/order/_form.scss */
/* line 384, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit,
.order-update #main #content .order-form #bar-fixed #checkbox-credit {
float: right;
@@ -1035,18 +1040,18 @@ termes.
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 1px rgba(0, 0, 0, 0.075);
}
/* line 391, ../sass/order/_form.scss */
/* line 395, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit.payment-impossible,
.order-update #main #content .order-form #bar-fixed #checkbox-credit.payment-impossible {
background-color: #e0e0e0;
}
/* line 395, ../sass/order/_form.scss */
/* line 399, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit .info,
.order-update #main #content .order-form #bar-fixed #checkbox-credit .info {
color: gray;
font-weight: normal;
}
/* line 400, ../sass/order/_form.scss */
/* line 404, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit .the-credit,
.order-update #main #content .order-form #bar-fixed #checkbox-credit .the-credit {
background-color: #BB8757;
@@ -1056,36 +1061,36 @@ termes.
-webkit-border-radius: 5px;
border-radius: 5px;
}
/* line 407, ../sass/order/_form.scss */
/* line 411, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit .amount-paid,
.order-update #main #content .order-form #bar-fixed #checkbox-credit .amount-paid {
color: #BB8757;
}
/* line 411, ../sass/order/_form.scss */
/* line 415, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit #info-credit-empty,
.order-update #main #content .order-form #bar-fixed #checkbox-credit #info-credit-empty {
font-size: 12px;
}
/* line 415, ../sass/order/_form.scss */
/* line 419, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #checkbox-credit #credit-disabled,
.order-update #main #content .order-form #bar-fixed #checkbox-credit #credit-disabled {
display: none;
font-size: 12px;
}
/* line 421, ../sass/order/_form.scss */
/* line 425, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed .btn-back, .order-create #main #content .order-form #bar-fixed .cancel-order,
.order-update #main #content .order-form #bar-fixed .btn-back,
.order-update #main #content .order-form #bar-fixed .cancel-order {
float: left;
margin-right: 5px;
}
/* line 426, ../sass/order/_form.scss */
/* line 430, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed .cancel-order,
.order-update #main #content .order-form #bar-fixed .cancel-order {
color: #b92c28;
background-color: white;
}
/* line 431, ../sass/order/_form.scss */
/* line 435, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed #total-order-bottom,
.order-update #main #content .order-form #bar-fixed #total-order-bottom {
display: none;
@@ -1093,12 +1098,12 @@ termes.
font-family: "comfortaalight";
font-size: 24px;
}
/* line 438, ../sass/order/_form.scss */
/* line 442, ../sass/order/_form.scss */
.order-create #main #content .order-form #bar-fixed .field-order-comment,
.order-update #main #content .order-form #bar-fixed .field-order-comment {
display: none;
}
/* line 446, ../sass/order/_form.scss */
/* line 450, ../sass/order/_form.scss */
.order-create .ui-datepicker .ui-widget-header,
.order-update .ui-datepicker .ui-widget-header {
background: none;
@@ -1107,7 +1112,7 @@ termes.
color: black;
font-weight: normal;
}
/* line 454, ../sass/order/_form.scss */
/* line 458, ../sass/order/_form.scss */
.order-create .ui-datepicker .ui-datepicker-current-day a,
.order-create .ui-datepicker a.ui-state-hover,
.order-update .ui-datepicker .ui-datepicker-current-day a,

+ 130
- 142
producer/web/js/lechatdesnoisettes.js Vedi File

@@ -76,9 +76,6 @@ termes.


$(document).ready(function() {
//chat_scroll() ;
chat_tabs_gamme_saison() ;
//chat_slideshow() ;
$('[data-toggle="tooltip"]').tooltip() ;
chat_systeme_commande() ;
chat_profil_user() ;
@@ -103,21 +100,21 @@ function chat_profil_user() {

function chat_event_click_point_vente(id, force) {
if($('.point-vente-'+id).data('code') == 1) {
if($('.point-sale-'+id).data('code') == 1) {
$('#modal-code #id-point-vente').val(id) ;
$('#modal-code #id-point-sale').val(id) ;
$('#modal-code').modal('show') ;
}
else {
$('#commande-id_point_vente').val(id) ;
$('#order-id_point_sale').val(id) ;
$('#points-vente .point-vente').removeClass('selected') ;
$('.point-vente-'+id).addClass('selected') ;
$('.point-vente-'+id).hide().fadeIn('fast') ;
$('#points-sale .point-sale').removeClass('selected') ;
$('.point-sale-'+id).addClass('selected') ;
$('.point-sale-'+id).hide().fadeIn('fast') ;

var pain = parseInt($('.point-vente-'+id).data('pain')) ;
var vrac = parseInt($('.point-vente-'+id).data('vrac')) ;
var pain = parseInt($('.point-sale-'+id).data('pain')) ;
var vrac = parseInt($('.point-sale-'+id).data('vrac')) ;

if(pain) {
$('#pain .table').show() ;
@@ -137,25 +134,25 @@ function chat_event_click_point_vente(id, force) {
$('#vrac .indisponible').show() ;
}

$('#produits, .valider-commande, .btn-commentaire, #bar-fixed').fadeIn() ;
$('#products, #step-infos-point-sale, .confirm-order, .btn-comment, #bar-fixed').fadeIn() ;

// credit pain
chat_systeme_commande_credit_pain_event(chat_systeme_commande_maj_table_prix()) ;

// scroll
if(!force) {
boulange_scroll('step-infos-pv') ;
boulange_scroll('step-infos-point-sale') ;
}

// infos point de vente
$('.infos-pv').hide() ;
$('.infos-pv-'+id).fadeIn() ;
$('.infos-point-sale').hide() ;
$('.infos-point-sale-'+id).fadeIn() ;
}
}

function chat_init_horaire_point_vente(date) {
$('.infos-pv .jour').hide() ;
var selector_jour = '.infos-pv .jour-'+date.getDay() ;
$('.infos-point-sale .jour').hide() ;
var selector_jour = '.infos-point-sale .jour-'+date.getDay() ;
$(selector_jour).show() ;
$('.select-previous-day').unbind('click').click(function() {
@@ -173,40 +170,41 @@ function chat_base_url(with_slug) {

function chat_systeme_commande() {
if($('.commande-form').size()) {
if($('.order-form').size()) {
// scroll initial
if($('.boulangerie.selected').size())
if($('.producer.selected').size())
{
boulange_scroll('step-choix-date') ;
boulange_scroll('step-date') ;
}
// affichage des différentes parties du formulaire
if(!$('#commande-id_production').val()) {
$('#depots, #points-vente, #produits, .valider-commande, #info-horaire-retrait-commande, .btn-commentaire, #bar-fixed').hide() ;
if(!$('#order-id_distribution').val()) {
$('#block-points-sale, #step-infos-point-sale, #points-sale, #products, .confirm-order, .btn-comment, #bar-fixed').hide() ;
}
else if(!$('#commande-id_point_vente').val()) {
$('#produits, .valider-commande, .btn-commentaire, #bar-fixed').hide() ;
$('#products, .confirm-order, .btn-comment, #bar-fixed, #has-order-in-progress').hide() ;
}
// points de vente
if($('#commande-id_point_vente').val())
chat_event_click_point_vente($('#commande-id_point_vente').val(), true) ;
if($('#order-id_point_sale').val()) {
chat_event_click_point_vente($('#order-id_point_sale').val(), true) ;
}
$('#modal-code form').submit(function() {
var id_pv = $('#modal-code #id-point-vente').val() ;
var id_pv = $('#modal-code #id-point-sale').val() ;
var code = $('#modal-code #code').val() ;
$.get(chat_base_url(true)+'commande/verif-code-point-vente',{
id_point_vente: id_pv,
$.get(chat_base_url(true)+'order/validate-code-point-sale',{
idPointSale: id_pv,
code: code
}, function(ok) {
if(ok) {
$('.point-vente-'+id_pv).data('code',0) ;
$('.point-vente-'+id_pv+' .glyphicon').remove() ;
$('input[name="code_point_vente_'+id_pv+'"]').val(code) ;
$('.point-sale-'+id_pv).data('code',0) ;
$('.point-sale-'+id_pv+' .glyphicon').remove() ;
$('input[name="code_point_sale_'+id_pv+'"]').val(code) ;
$('#modal-code').modal('hide') ;
chat_event_click_point_vente($('#modal-code #id-point-vente').val()) ;
chat_event_click_point_vente($('#modal-code #id-point-sale').val()) ;
}
else {
$('#modal-code .field-code').addClass('has-error') ;
@@ -216,7 +214,7 @@ function chat_systeme_commande() {
return false ;
}) ;
$('#points-vente .point-vente').click(function() {
$('#points-sale .point-sale').click(function() {
var id = parseInt($(this).find('.id').html()) ;
chat_event_click_point_vente(id) ;
}) ;
@@ -229,7 +227,7 @@ function chat_systeme_commande() {
//var var_datepicker = $.datepicker ;
$('#datepicker-production').datepicker({
$('#datepicker-distribution').datepicker({
beforeShowDay: function(date){
var string = $.datepicker.formatDate('dd/mm/yy', date);
@@ -246,12 +244,12 @@ function chat_systeme_commande() {
},
onSelect: function(selectedDate) {
$('.infos-pv').hide() ;
$('.infos-points-sale').hide() ;
// on remet tout les prix à zéro
chat_systeme_commande_reset_table_prix() ;
$('#has-commande-en-cours').hide() ;
$('#has-order-in-progress').hide() ;
var tab_date = selectedDate.split('/') ;
var date = new Date(tab_date[2],tab_date[1]-1,tab_date[0]) ;
@@ -260,21 +258,21 @@ function chat_systeme_commande() {
var id_production = 0 ;
$('#dates div .date').each(function() {
if($(this).html() == selectedDate) {
id_production = $(this).parent().find('.id_production').html() ;
id_production = $(this).parent().find('.id_distribution').html() ;
}
});
$('#commande-id_production').val(id_production) ;
$('#order-id_distribution').val(id_production) ;
// verif si le gars a une commande en cours pour cette production
var has_commande_en_cours = false ;
$('#commandes-en-cours .commande').each(function() {
if($(this).data('idproduction') == id_production) {
$('#orders-in-progress .order').each(function() {
if($(this).data('iddistribution') == id_production) {
//alert('bada') ;
$('#has-commande-en-cours a').attr('href',$(this).data('href')) ;
$('#has-commande-en-cours').show() ;
$('#has-order-in-progress a').attr('href',$(this).data('href')) ;
$('#has-order-in-progress').show() ;
has_commande_en_cours = true ;
$('#depots, #points-vente, #produits, #info-horaire-retrait-commande').hide() ;
$('#block-points-sale, #step-infos-point-sale, #points-sale, #products, #bar-fixed').hide() ;
}
}) ;
@@ -282,28 +280,28 @@ function chat_systeme_commande() {
chat_systeme_commande_produits_dispos(tab_date[2]+'-'+tab_date[1]+'-'+tab_date[0], date) ;
$('#produits, .valider-commande, .btn-commentaire, #bar-fixed').hide() ;
$('#products, .confirm-order, .btn-comment, #bar-fixed').hide() ;
// déselection points de vente
$('#points-vente .point-vente').removeClass('selected') ;
$('#commande-id_point_vente').val('') ;
$('#points-sale .point-sale').removeClass('selected') ;
$('#order-id_point_sale').val('') ;
// affichage points de vente
$('#depots, #points-vente, #info-horaire-retrait-commande').fadeIn() ;
$('#block-points-sale, #points-sale, #order-infos').fadeIn() ;
// scroll
boulange_scroll('step-choix-depot') ;
boulange_scroll('step-point-sale') ;
}
}
}) ;
if($('#commande-id_production').val()) {
$("#dates .id_production").each(function() {
if($(this).html() == $('#commande-id_production').val()) {
if($('#order-id_distribution').val()) {
$("#dates .id_distribution").each(function() {
if($(this).html() == $('#order-id_distribution').val()) {
var tab_date = $(this).parent().find('.date').html().split('/') ;
var date = new Date(tab_date[2],tab_date[1]-1,tab_date[0]);
$('#datepicker-production').datepicker('setDate',date) ;
$('#datepicker-distribution').datepicker('setDate',date) ;
chat_systeme_commande_produits_dispos(tab_date[2]+'-'+tab_date[1]+'-'+tab_date[0], date) ;
chat_init_horaire_point_vente(date) ;
}
@@ -312,14 +310,14 @@ function chat_systeme_commande() {
// tableau produits
$('.commande-form .move-quantity').click(function() {
$('.order-form .move-quantity').click(function() {
var vrac = ($(this).parent().parent().parent().parent().parent().parent().parent().attr('id') == 'vrac') ;
if(vrac) {
var quantite = parseInt($(this).parent().parent().find('input.quantity').val()) ;
if($(this).hasClass('moins') && quantite != 0)
if($(this).hasClass('minus') && quantite != 0)
quantite -= 500 ;
if($(this).hasClass('plus'))
quantite += 500 ;
@@ -336,11 +334,11 @@ function chat_systeme_commande() {
}) ;
var quantite = parseInt($(this).parent().parent().find('input.quantity').val()) ;
var quantite_restante = parseInt($(this).parent().parent().parent().find('.quantite-restante .nb').html()) ;
var quantite_max = $(this).parent().parent().parent().parent().data('quantite-max') ;
var quantite_restante = parseInt($(this).parent().parent().parent().find('.quantity-remaining .nb').html()) ;
var quantite_max = $(this).parent().parent().parent().parent().data('quantity-max') ;
var no_limit = $(this).parent().parent().parent().parent().data('no-limit') ;
if($(this).hasClass('moins') && quantite != 0) {
if($(this).hasClass('minus') && quantite != 0) {
quantite -- ;
quantite_restante ++ ;
}
@@ -352,19 +350,19 @@ function chat_systeme_commande() {
}
}
$(this).parent().parent().parent().find('.quantite-restante .nb').html(quantite_restante) ;
$(this).parent().parent().parent().find('.quantity-remaining .nb').html(quantite_restante) ;
if(quantite_restante <= 5 && quantite_restante > 0) {
$(this).parent().parent().parent().find('.quantite-restante').fadeIn() ;
$(this).parent().parent().parent().find('.quantity-remaining').fadeIn() ;
}
else {
$(this).parent().parent().parent().find('.quantite-restante').hide() ;
$(this).parent().parent().parent().find('.quantity-remaining').hide() ;
}
if(quantite_restante == 0 && !no_limit) {
$(this).parent().parent().parent().find('.epuise').fadeIn() ;
$(this).parent().parent().parent().find('.unavailable').fadeIn() ;
}
else {
$(this).parent().parent().parent().find('.epuise').hide() ;
$(this).parent().parent().parent().find('.unavailable').hide() ;
}

$(this).parent().parent().find('input.quantity').val(quantite) ;
@@ -379,12 +377,12 @@ function chat_systeme_commande() {
}
// commentaire commande
$('.commande-form .btn-commentaire').click(function() {
if($('.field-commande-commentaire').css('display') == 'none') {
$('.field-commande-commentaire').slideDown() ;
$('.order-form .btn-comment').click(function() {
if($('.field-order-comment').css('display') == 'none') {
$('.field-order-comment').slideDown() ;
}
else {
$('.field-commande-commentaire').slideUp() ;
$('.field-order-comment').slideUp() ;
}
return false ;
}) ;
@@ -393,9 +391,9 @@ function chat_systeme_commande() {
if($('#bar-fixed').size()) {
$(window).scroll(function (event) {
var scroll = $(window).scrollTop() + $(window).height();
var pos_bottom_produits = $('#table-produits').offset().top + $('#table-produits').height() + 100 ;
var pos_bottom_produits = $('#table-products').offset().top + $('#table-products').height() + 100 ;
if($(window).height() < 1000) {
if($(window).height() < 700) {
if(!$('#bar-fixed').hasClass('not-fixed')) {
$('#bar-fixed').addClass('not-fixed') ;
}
@@ -410,71 +408,68 @@ function chat_systeme_commande() {
$('#bar-fixed').removeClass('not-fixed') ;
}
}
});
}
}

function chat_systeme_commande_produits_dispos(str_date, date) {
// produits dispos à la vente à cette date
$.get(chat_base_url(true)+'commande/infos-production',{
id_production: $('#commande-id_production').val()
$.get(chat_base_url(true)+'order/infos-distribution',{
idDistribution: $('#order-id_distribution').val()
}, function(data) {
if(data.produits_dispos) {
$.each(data.produits_dispos, function( id_produit, produit ) {
if(data.products) {
$.each(data.products, function( id_produit, produit ) {
if(produit.actif) $('.produit-'+id_produit).show() ;
else $('.produit-'+id_produit).hide() ;
if(produit.active) $('.product-'+id_produit).show() ;
else $('.product-'+id_produit).hide() ;
var quantite_restante = produit.quantite_max - produit.quantite_commandee ;
var quantite_restante = produit.quantity_max - produit.quantity_order ;
var no_limit = 0 ;
if(!produit.quantite_max)
if(!produit.quantity_max)
no_limit = 1 ;
$('.produit-'+id_produit).attr('data-no-limit',no_limit) ;
$('.produit-'+id_produit).attr('data-quantite-max',produit.quantite_max) ;
$('.produit-'+id_produit+' .quantite-restante .nb').html(quantite_restante) ;
$('.product-'+id_produit).attr('data-no-limit',no_limit) ;
$('.product-'+id_produit).attr('data-quantity-max',produit.quantity_max) ;
$('.product-'+id_produit+' .quantity-remaining .nb').html(quantite_restante) ;
if(produit.quantite_max && (!quantite_restante || quantite_restante < 0 || produit.epuise)) {
$('.produit-'+id_produit+' .epuise').show() ;
if(produit.quantity_max && (!quantite_restante || quantite_restante < 0 || produit.unavailable)) {
$('.product-'+id_produit+' .unavailable').show() ;
if(!$('#id-commande').val() && $('.produit-'+id_produit+' .quantity').val() == 0)
if(!$('#id-order').val() && $('.product-'+id_produit+' .quantity').val() == 0)
{
$('.produit-'+id_produit+' .quantite-restante').hide() ;
$('.produit-'+id_produit+' .input-group').hide() ;
$('.product-'+id_produit+' .quantity-remaining').hide() ;
$('.product-'+id_produit+' .input-group').hide() ;
}
}
else {
$('.produit-'+id_produit+' .epuise').hide() ;
$('.produit-'+id_produit+' .input-group').show() ;
$('.produit-'+id_produit+' .quantite-restante .nb').html(quantite_restante) ;
$('.product-'+id_produit+' .unavailable').hide() ;
$('.product-'+id_produit+' .input-group').show() ;
$('.product-'+id_produit+' .quantity-remaining .nb').html(quantite_restante) ;
}
if($('.produit-'+id_produit+' .quantite-restante').size()) {
if(parseInt($('.produit-'+id_produit+' .quantite-restante .nb').html()) > 5 ||
parseInt($('.produit-'+id_produit+' .quantite-restante .nb').html()) <= 0) {
$('.produit-'+id_produit+' .quantite-restante').hide() ;
if($('.product-'+id_produit+' .quantity-remaining').size()) {
if(parseInt($('.product-'+id_produit+' .quantity-remaining .nb').html()) > 5 ||
parseInt($('.product-'+id_produit+' .quantity-remaining .nb').html()) <= 0) {
$('.product-'+id_produit+' .quantity-remaining').hide() ;
}
else {
$('.produit-'+id_produit+' .quantite-restante').show() ;
$('.product-'+id_produit+' .quantity-remaining').show() ;
}
}
});
}
$('#points-vente .point-vente').hide() ;
$('#points-sale .point-sale').hide() ;
// init affichage points de vente
$.each(data.points_vente, function(key, livraison) {
console.log(key+' | '+livraison) ;
$.each(data.points_sale, function(key, livraison) {
if(livraison) {
$('.point-vente-'+key).fadeIn() ;
$('.point-sale-'+key).fadeIn() ;
}
else {
$('.point-vente-'+key).hide() ;
$('.point-sale-'+key).hide() ;
}
}) ;
@@ -484,7 +479,7 @@ function chat_systeme_commande_produits_dispos(str_date, date) {
}

function chat_systeme_commande_reset_table_prix() {
$('#table-produits tr .colonne-quantite .quantity').each(function() {
$('#table-products tr .column-quantity .quantity').each(function() {
$(this).val(0) ;
}) ;
chat_systeme_commande_maj_table_prix() ;
@@ -494,9 +489,9 @@ function chat_systeme_commande_maj_table_prix() {
// produits pain
var prix = 0 ;
$('.commande-form #table-produits tbody tr').each(function() {
$('.order-form #table-products tbody tr').each(function() {
var quantite = parseInt($(this).find('.quantity').val()) ;
var prix_produit = parseFloat($(this).find('.prix').html()) ;
var prix_produit = parseFloat($(this).find('.price').html()) ;
var prix_total_produit = quantite * prix_produit ;
if(prix_total_produit)
@@ -508,14 +503,14 @@ function chat_systeme_commande_maj_table_prix() {
prix += prix_total_produit ;
}) ;
$('#total-commande strong').html(formate_prix(prix)+' €') ;
$('#total-order strong').html(formate_prix(prix)+' €') ;
var prix_global = prix ;
// produits vrac
var prix = 0 ;
$('.commande-form #table-produits-vrac tbody tr').each(function() {
$('.order-form #table-products-vrac tbody tr').each(function() {
var quantite = parseInt($(this).find('.quantity').val()) ;
var prix_produit = parseFloat($(this).find('.prix').html()) ;
var prix_produit = parseFloat($(this).find('.price').html()) ;
var prix_total_produit = quantite/1000 * prix_produit ;
if(prix_total_produit)
@@ -527,17 +522,17 @@ function chat_systeme_commande_maj_table_prix() {
prix += prix_total_produit ;
}) ;
$('#total-commande-vrac strong').html(formate_prix(prix)+' €') ;
$('#total-order-vrac strong').html(formate_prix(prix)+' €') ;
prix_global += prix ;
$('#total-commande-bottom span').html(formate_prix(prix_global)) ;
$('#total-order-bottom span').html(formate_prix(prix_global)) ;
if(prix_global)
$('#total-commande-bottom').fadeIn() ;
$('#total-order-bottom').fadeIn() ;
else
$('#total-commande-bottom').hide() ;
$('#total-order-bottom').hide() ;
// maj credit pain
chat_systeme_commande_credit_pain_event(prix_global) ;
@@ -546,7 +541,7 @@ function chat_systeme_commande_maj_table_prix() {
}

function chat_systeme_commande_credit_pain() {
$('input[name=credit_pain]').change(function() {
$('input[name=credit]').change(function() {
var prix_global = chat_systeme_commande_maj_table_prix() ;
chat_systeme_commande_credit_pain_event(prix_global) ;
}) ;
@@ -554,42 +549,42 @@ function chat_systeme_commande_credit_pain() {

function chat_systeme_commande_credit_pain_event(prix_global) {
var html = '' ;
var use_credit_pain = $('input[name=credit_pain]').prop('checked') ;
var use_credit_pain = $('input[name=credit]').prop('checked') ;

var credit_pain = parseFloat($('#montant-credit-pain').val()) ;
var credit_pain = parseFloat($('#montant-credit').val()) ;
var credit_pain_dispo = credit_pain ;
var montant_paye = 0
if($('#montant-paye').size() && $('#montant-paye').val())
montant_paye = parseFloat($('#montant-paye').val()) ;
if($('#amount-paid').size() && $('#amount-paid').val())
montant_paye = parseFloat($('#amount-paid').val()) ;
if($('#id-commande').size() && $('#id-commande').val()) {
if($('#id-order').size() && $('#id-order').val()) {
credit_pain_dispo = credit_pain + montant_paye ;
}
var credit_pain_active = $('.point-vente.selected').data('credit-pain') ;
var credit_pain_active = $('.point-sale.selected').data('credit') ;
if(credit_pain_active || montant_paye) {
$('#checkbox-credit-pain #info-credit-vide').show() ;
$('#checkbox-credit-pain label').show() ;
$('#checkbox-credit-pain #credit-pain-disabled').hide() ;
$('#checkbox-credit #info-credit-empty').show() ;
$('#checkbox-credit label').show() ;
$('#checkbox-credit #credit-disabled').hide() ;
if(prix_global > credit_pain_dispo) {
var reste_payer = prix_global - credit_pain_dispo ;
if(use_credit_pain) {
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
html += '<span class="amount-paid">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+credit_pain+' €</strong> seront débités<br />' ;
html += 'Restera <strong>'+reste_payer+' €</strong> à payer à la boulangerie' ;
$('#checkbox-credit-pain .info').html(html) ;
$('#checkbox-credit .info').html(html) ;
}
else {
$('#checkbox-credit-pain .info').html('') ;
$('#checkbox-credit .info').html('') ;
}
}
else {

$('#checkbox-credit-pain').removeClass('paiement-impossible') ;
$('input[name=credit_pain]').removeAttr('disabled') ;
$('#checkbox-credit').removeClass('payment-impossible') ;
$('input[name=credit]').removeAttr('disabled') ;
if(use_credit_pain) {
var html = '' ;
// à payer
@@ -597,37 +592,37 @@ function chat_systeme_commande_credit_pain_event(prix_global) {
{
montant = prix_global - montant_paye ;
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
html += '<span class="amount-paid">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+montant+' €</strong> seront débités' ;
$('#checkbox-credit-pain .info').html(html) ;
$('#checkbox-credit .info').html(html) ;
}
// remboursé
else if(prix_global < montant_paye) {
montant = montant_paye - prix_global ;
if(montant_paye) {
html += '<span class="montant-paye">'+montant_paye+' € déjà payé</span><br />' ;
html += '<span class="amount-paid">'+montant_paye+' € déjà payé</span><br />' ;
}
html += '<strong>'+montant+' €</strong> seront remboursés' ;
$('#checkbox-credit-pain .info').html(html) ;
$('#checkbox-credit .info').html(html) ;

}
else {
if(montant_paye > 0)
$('#checkbox-credit-pain .info').html('<span class="montant-paye">'+montant_paye+' € déjà payé</span>') ;
$('#checkbox-credit .info').html('<span class="amount-paid">'+montant_paye+' € déjà payé</span>') ;
else
$('#checkbox-credit-pain .info').html('') ;
$('#checkbox-credit .info').html('') ;
}
}
else {
$('#checkbox-credit-pain .info').html('')
$('#checkbox-credit .info').html('')
}
}
}
else {
$('#checkbox-credit-pain #info-credit-vide').hide() ;
$('#checkbox-credit-pain label').hide() ;
$('#checkbox-credit-pain #credit-pain-disabled').show() ;
$('#checkbox-credit #info-credit-empty').hide() ;
$('#checkbox-credit label').hide() ;
$('#checkbox-credit #credit-disabled').show() ;
}
}

@@ -684,10 +679,3 @@ function chat_event_scroll() {
}) ;
}

function chat_tabs_gamme_saison() {
$('#tab-gamme-saison a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
}


+ 6
- 2
producer/web/sass/order/_form.scss Vedi File

@@ -197,7 +197,7 @@ termes.
}
}
.infos-point-sale {
.infos-points-sale {
display: none;
margin-top: 15px ;
@@ -223,6 +223,10 @@ termes.
#products {
margin-top: 15px ;

.alert.unavailable {
display: none ;
}
#label-products {
display: block ;
margin-bottom: 5px ;
@@ -271,7 +275,7 @@ termes.
text-align: center ;
}

.epuise {
.unavailable {
display: none ;
text-transform: uppercase ;
color: #B32815 ;

Loading…
Annulla
Salva