Преглед изворни кода

Adaptations producer/subscription

refactoring
Guillaume Bourgeois пре 6 година
родитељ
комит
731edb9e1c
5 измењених фајлова са 29 додато и 14 уклоњено
  1. +5
    -5
      backend/controllers/SubscriptionController.php
  2. +2
    -2
      backend/views/subscription/_form.php
  3. +1
    -1
      backend/web/js/lechatdesnoisettes.js
  4. +19
    -4
      common/models/ProductSubscription.php
  5. +2
    -2
      common/models/SubscriptionForm.php

+ 5
- 5
backend/controllers/SubscriptionController.php Прегледај датотеку

@@ -104,7 +104,7 @@ class SubscriptionController extends BackendController
{
$dataProvider = new ActiveDataProvider([
'query' => Subscription::find()
->with(['user', 'etablissement', 'pointVente', 'commandeAutoProduit'])
->with(['user', 'producer', 'pointSale', 'productSubscription'])
->joinWith(['user'])
->where(['subscription.id_producer' => Producer::getId()])
->orderBy('subscription.id_point_sale ASC, CASE `subscription`.`username` WHEN "" THEN `user`.`name` ELSE `subscription`.`username` END ASC'),
@@ -130,7 +130,7 @@ class SubscriptionController extends BackendController
$model->id_producer = Producer::getId();

// produits
$products = Product::searchAll() ;
$productsArray = Product::searchAll() ;
if ($model->load(Yii::$app->request->post()) && $model->validate()
&& $model->save())
@@ -140,7 +140,7 @@ class SubscriptionController extends BackendController

return $this->render('create', [
'model' => $model,
'products' => $products
'productsArray' => $productsArray
]);
}

@@ -191,7 +191,7 @@ class SubscriptionController extends BackendController
}

// produits
$products = Product::searchAll() ;
$productsArray = Product::searchAll() ;

if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if (!strlen($model->date_end)) {
@@ -204,7 +204,7 @@ class SubscriptionController extends BackendController

return $this->render('update', [
'model' => $model,
'products' => $products
'productsArray' => $productsArray
]);
}


+ 2
- 2
backend/views/subscription/_form.php Прегледај датотеку

@@ -97,11 +97,11 @@ use common\models\PointSale ;
<td>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default btn-minus" type="button"><span class="glyphicon glyphicon-minus"></span></button>
<button class="btn btn-default btn-moins" type="button"><span class="glyphicon glyphicon-minus"></span></button>
</span>
<?= Html::input('text', 'SubscriptionForm[products][product_'.$p->id.']', (isset($model->products['product_'.$p->id])) ? $model->products['product_'.$p->id] : '', ['class' => 'form-control quantity']) ?>
<span class="input-group-btn">
<button class="btn btn-default btn-more" type="button"><span class="glyphicon glyphicon-plus"></span></button>
<button class="btn btn-default btn-plus" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</td>

+ 1
- 1
backend/web/js/lechatdesnoisettes.js Прегледај датотеку

@@ -201,7 +201,7 @@ function chat_select_etablissement() {
function chat_commandeauto() {
// dates
$('#commandeautoform-date_debut, #commandeautoform-date_fin').datepicker() ;
$('#subscriptionform-date_begin, #subscriptionform-date_end').datepicker() ;
}


+ 19
- 4
common/models/ProductSubscription.php Прегледај датотеку

@@ -40,16 +40,17 @@ namespace common\models;

use Yii;
use common\models\Product;
use common\components\ActiveRecordCommon ;

/**
* This is the model class for table "commande_auto_produit".
*
* @property integer $id
* @property integer $id_commande_auto
* @property integer $id_produit
* @property double $quantite
* @property integer $id_subscription
* @property integer $id_product
* @property double $quantity
*/
class ProductSubscription extends \yii\db\ActiveRecord
class ProductSubscription extends ActiveRecordCommon
{

/**
@@ -93,5 +94,19 @@ class ProductSubscription extends \yii\db\ActiveRecord
{
return $this->hasOne(Product::className(), ['id' => 'id_product']);
}
/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function defaultOptionsSearch() {
return [
'with' => ['product'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
] ;
}

}

+ 2
- 2
common/models/SubscriptionForm.php Прегледај датотеку

@@ -156,10 +156,10 @@ class SubscriptionForm extends Model

foreach ($this->products as $nameInput => $quantity) {
if ($quantity) {
$idProduct = str_replace('produit_', '', $nameInput);
$idProduct = str_replace('product_', '', $nameInput);
$subscriptionProduct = new ProductSubscription;
$subscriptionProduct->id_subscription = $subscription->id;
$subscriptionProduct->id_product = $id_product;
$subscriptionProduct->id_product = $idProduct;
$subscriptionProduct->quantity = $quantity;
$subscriptionProduct->save();
}

Loading…
Откажи
Сачувај