ソースを参照

[Backend] Distributions > édition/création commande : bouton unique "Créer" ou "Modifier" #931

feature/souke
Guillaume Bourgeois 1年前
コミット
fb1256046a
5個のファイルの変更32行の追加26行の削除
  1. +3
    -3
      backend/controllers/OrderController.php
  2. +2
    -2
      backend/views/distribution/index.php
  3. +1
    -2
      backend/web/js/vuejs/distribution-index.js
  4. +25
    -0
      common/models/Order.php
  5. +1
    -19
      common/models/Subscription.php

+ 3
- 3
backend/controllers/OrderController.php ファイルの表示

@@ -814,7 +814,7 @@ class OrderController extends BackendController
* @param string $processCredit
*/
public function actionAjaxCreate(
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment, $processCredit = 0)
$date, $idPointSale, $idUser, $username, $meanPayment = '', $products, $comment)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

@@ -894,7 +894,7 @@ class OrderController extends BackendController
}

$order = Order::searchOne(['id' => $order->id]);
if ($order && $processCredit) {
if ($order && $order->isCreditAutoPayment()) {
$order->processCredit();
}

@@ -1024,7 +1024,7 @@ class OrderController extends BackendController
$order->save();

$order = Order::searchOne(['id' => $order->id]);
if ($order && $processCredit) {
if($order && $order->isCreditAutoPayment()) {
// Si changement d'user : on rembourse l'ancien user
$amountPaid = $order->getAmount(Order::AMOUNT_PAID);
if($oldIdUser != $idUser && $amountPaid > 0) {

+ 2
- 2
backend/views/distribution/index.php ファイルの表示

@@ -684,8 +684,8 @@ $this->setPageTitle('Distributions') ;
</div>
<div slot="footer">
<div class="actions-form">
<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id && order.id_user > 0" data-process-credit="1">Créer et payer</button>
<button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id && order.id_user > 0" data-process-credit="1">Modifier et payer</button>
<!--<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id && order.id_user > 0" data-process-credit="1">Créer et payer</button>
<button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id && order.id_user > 0" data-process-credit="1">Modifier et payer</button>-->

<button class="modal-default-button btn btn-primary" @click="submitFormUpdate" v-if="order.id">Modifier</button>
<button class="modal-default-button btn btn-primary" @click="submitFormCreate" v-if="!order.id">Créer</button>

+ 1
- 2
backend/web/js/vuejs/distribution-index.js ファイルの表示

@@ -830,8 +830,7 @@ Vue.component('order-form',{
username: this.order.username,
meanPayment: this.order.mean_payment,
products: app.getProductOrderArrayRequest(),
comment: this.order.comment,
processCredit: processCredit
comment: this.order.comment
}})
.then(function(response) {
app.order.id_point_sale = 0 ;

+ 25
- 0
common/models/Order.php ファイルの表示

@@ -1099,4 +1099,29 @@ class Order extends ActiveRecordCommon
|| ($this->quotation && $this->quotation->isStatusValid())
|| ($this->invoice && $this->invoice->isStatusValid());
}

public function isCreditAutoPayment()
{
$pointSale = PointSale::findOne($this->id_point_sale);
$distribution = Distribution::findOne($this->id_distribution);
$creditFunctioning = $pointSale->getCreditFunctioning();

if ($this->id_user && Producer::getConfig('credit') && $pointSale->credit) {
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
return 0;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
return 1;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) {
$userProducer = UserProducer::searchOne([
'id_user' => $this->id_user,
'id_producer' => $distribution->id_producer
]);
if ($userProducer) {
return $userProducer->credit_active;
}
}
}

return 0;
}
}

+ 1
- 19
common/models/Subscription.php ファイルの表示

@@ -217,26 +217,9 @@ class Subscription extends ActiveRecordCommon
$pointSale = PointSale::findOne($this->id_point_sale);

if ($pointSale) {
$creditFunctioning = $pointSale->getCreditFunctioning();

$order->auto_payment = 0;
if($this->auto_payment == self::AUTO_PAYMENT_DEDUCTED) {
if ($order->id_user && Producer::getConfig('credit') && $pointSale->credit) {
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
$order->auto_payment = 0;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
$order->auto_payment = 1;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) {
$user = User::findOne($order->id_user);
$userProducer = UserProducer::searchOne([
'id_user' => $order->id_user,
'id_producer' => $distribution->id_producer
]);
if ($userProducer) {
$order->auto_payment = $userProducer->credit_active;
}
}
}
$order->auto_payment = $order->isCreditAutoPayment();
}
elseif($this->auto_payment == self::AUTO_PAYMENT_YES) {
$order->auto_payment = 1;
@@ -245,7 +228,6 @@ class Subscription extends ActiveRecordCommon
$order->auto_payment = 0;
}


$order->tiller_synchronization = $order->auto_payment;

$userPointSale = UserPointSale::searchOne([

読み込み中…
キャンセル
保存