@@ -38,20 +38,20 @@ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
use common\logic\PointSale\PointSale\PointSaleSearch; | |||
use common\logic\PointSale\UserPointSale\UserPointSale; | |||
use Yii; | |||
use yii\filters\AccessControl; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use yii\helpers\Html; | |||
/** | |||
* PointVenteController implements the CRUD actions for PointVente model. | |||
*/ | |||
class PointSaleController extends BackendController | |||
{ | |||
public function behaviors() | |||
{ | |||
return [ | |||
@@ -77,8 +77,6 @@ class PointSaleController extends BackendController | |||
/** | |||
* Liste les points de vente. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionIndex() | |||
{ | |||
@@ -98,28 +96,32 @@ class PointSaleController extends BackendController | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$model = new PointSale(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSale = $pointSaleManager->instanciatePointSale(); | |||
if ($pointSale->load(\Yii::$app->request->post()) && $pointSale->save()) { | |||
$pointSaleManager->updatePointSalePointProduction($pointSale); | |||
$pointSaleManager->processRestrictedAccess($pointSale); | |||
$distributionManager->addPointSaleIncomingDistributions($pointSale); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
$model->processPointProduction(); | |||
$model->processRestrictedAccess(); | |||
DistributionModel::linkPointSaleIncomingDistributions($model); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('create', array_merge($this->initForm(), [ | |||
'model' => $model, | |||
'model' => $pointSale, | |||
])); | |||
} | |||
} | |||
/** | |||
* Modifie un point de vente. | |||
* | |||
* @param integer $id | |||
* @return mixed | |||
*/ | |||
public function actionUpdate($id) | |||
public function actionUpdate(int $id) | |||
{ | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$model = PointSale::find() | |||
->with('userPointSale') | |||
->where(['id' => $id]) | |||
@@ -131,10 +133,13 @@ class PointSaleController extends BackendController | |||
} | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
$model->processPointProduction(); | |||
$model->processRestrictedAccess(); | |||
DistributionModel::linkPointSaleIncomingDistributions($model); | |||
$pointSaleManager->updatePointSalePointProduction($model); | |||
$pointSaleManager->processRestrictedAccess($model); | |||
$distributionManager->addPointSaleIncomingDistributions($model); | |||
$this->setFlash('success', 'Point de vente modifié.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('update', array_merge($this->initForm($id), [ | |||
@@ -145,13 +150,12 @@ class PointSaleController extends BackendController | |||
/** | |||
* Initialise le formulaire de création/modification. | |||
* | |||
* @param integer $id | |||
* @return mixed | |||
*/ | |||
public function initForm($id = 0) | |||
public function initForm(int $id = 0) | |||
{ | |||
$users = User::findBy() | |||
$userManager = $this->getUserManager(); | |||
$users = $userManager->queryUsersBy() | |||
->leftJoin('user_point_sale', 'user_point_sale.id_user = user.id AND user_point_sale.id_point_sale = :id_point_sale', [':id_point_sale' => $id]) | |||
->orderBy('user_point_sale.id_point_sale DESC, lastname ASC, name ASC') | |||
->all(); | |||
@@ -163,12 +167,12 @@ class PointSaleController extends BackendController | |||
/** | |||
* Supprime un point de vente et redirige vers la liste des points de vente. | |||
* | |||
* @param integer $id | |||
* @return mixed | |||
*/ | |||
public function actionDelete($id, $confirm = false) | |||
public function actionDelete(int $id, $confirm = false) | |||
{ | |||
$orderManager = $this->getOrderManager(); | |||
$distributionManager = $this->getDistributionManager(); | |||
$pointSale = $this->findModel($id); | |||
if ($confirm) { | |||
@@ -179,9 +183,9 @@ class PointSaleController extends BackendController | |||
UserPointSale::deleteAll(['id_point_sale' => $id]); | |||
// Suppression du lien PointSaleDistribution pour toutes les distributions à venir | |||
$incomingDistributions = DistributionModel::getIncoming(); | |||
$incomingDistributions = $distributionManager->findDistributionsIncoming(); | |||
foreach ($incomingDistributions as $distribution) { | |||
PointSaleDistributionModel::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | |||
PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | |||
} | |||
// Suppression de toutes les commandes à venir de ce point de vente | |||
@@ -197,7 +201,7 @@ class PointSaleController extends BackendController | |||
if ($ordersArray) { | |||
foreach ($ordersArray as $order) { | |||
$order->delete(true); | |||
$orderManager->deleteOrder($order, true); | |||
} | |||
} | |||
@@ -212,17 +216,19 @@ class PointSaleController extends BackendController | |||
/** | |||
* Définit un point de vente par défaut. | |||
* | |||
* @param integer $id | |||
*/ | |||
public function actionDefault($id) | |||
public function actionDefault(int $id) | |||
{ | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$pointSale = $this->findModel($id); | |||
if ($pointSale) { | |||
PointSale::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => GlobalParam::getCurrentProducerId()]); | |||
if (!$pointSale->default) { | |||
$pointSale->default = 1; | |||
$pointSale->save(); | |||
$pointSaleManager->saveUpdate($pointSale); | |||
$this->setFlash('success', 'Point de vente <strong>' . Html::encode($pointSale->name) . '</strong> défini par défaut.'); | |||
} else { | |||
$this->setFlash('success', 'Aucun point de vente défini par défaut'); | |||
@@ -234,12 +240,8 @@ class PointSaleController extends BackendController | |||
/** | |||
* Recherche un point de vente en fonction de son ID. | |||
* | |||
* @param integer $id | |||
* @return PointVente | |||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | |||
*/ | |||
protected function findModel($id) | |||
protected function findModel(int $id) | |||
{ | |||
if (($model = PointSale::findOne($id)) !== null) { | |||
return $model; | |||
@@ -247,5 +249,4 @@ class PointSaleController extends BackendController | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
} | |||
} | |||
} |
@@ -38,9 +38,10 @@ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\Product\Product\Product; | |||
use Yii; | |||
use common\models\ User; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use yii\filters\AccessControl; | |||
@@ -51,7 +52,6 @@ use yii\data\ActiveDataProvider; | |||
*/ | |||
class ProducerAdminController extends BackendController | |||
{ | |||
public function behaviors() | |||
{ | |||
return [ | |||
@@ -83,6 +83,8 @@ class ProducerAdminController extends BackendController | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$dataProviderProducer = new ActiveDataProvider([ | |||
'query' => Producer::find() | |||
->with('userProducer', 'user') | |||
@@ -92,11 +94,10 @@ class ProducerAdminController extends BackendController | |||
], | |||
]); | |||
$producersArray = Producer::find()->where('active = 1')->all(); | |||
$producersArray = $producerManager->findProducersActive(); | |||
$sumPrices = 0; | |||
foreach ($producersArray as $producer) { | |||
$sumPrices += $producer->getAmountBilledLastMonth(); | |||
$sumPrices += $producerManager->getAmountBilledLastMonth($producer); | |||
} | |||
return $this->render('index', [ | |||
@@ -107,48 +108,49 @@ class ProducerAdminController extends BackendController | |||
/** | |||
* Crée un producteur. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$model = new Producer(); | |||
$producerManager = $this->getProducerManager(); | |||
$producer = $producerManager->instanciateProducer(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
if ($producer->load(\Yii::$app->request->post()) && $producerManager->saveCreate($producer)) { | |||
$this->setFlash('success', 'Producteur créé.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('create', [ | |||
'model' => $model, | |||
'model' => $producer, | |||
]); | |||
} | |||
} | |||
/** | |||
* Modification d'un producteur. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionUpdate($id) | |||
public function actionUpdate(int $id) | |||
{ | |||
$model = $this->findModel($id); | |||
$producerManager = $this->getProducerManager(); | |||
$producer = $this->findModel($id); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
if ($producer->load(\Yii::$app->request->post()) && $producerManager->saveCreate($producer)) { | |||
$this->setFlash('success', 'Producteur modifié.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('update', [ | |||
'model' => $model, | |||
'model' => $producer, | |||
]); | |||
} | |||
} | |||
public function actionUserTransfer($fromProducerId, $toProducerId, $withOrders = 1) | |||
{ | |||
$producerManager = $this->getProducerManager(); | |||
$userManager = $this->getUserManager(); | |||
$fromProducerId = (int)$fromProducerId; | |||
$toProducerId = (int)$toProducerId; | |||
$count = 0; | |||
$usersArray = User::findBy(['id_producer' => $fromProducerId])->all(); | |||
$usersArray = $userManager->queryUsersBy(['id_producer' => $fromProducerId])->all(); | |||
foreach ($usersArray as $user) { | |||
$idUser = $user['user_id']; | |||
@@ -162,7 +164,10 @@ class ProducerAdminController extends BackendController | |||
} | |||
if (($withOrders && $countOrders) || !$withOrders) { | |||
Producer::addUser($idUser, $toProducerId); | |||
$producerManager->addUser( | |||
$userManager->findOneUserById($idUser), | |||
$producerManager->findOneProducerById($toProducerId) | |||
); | |||
$count++; | |||
} | |||
} | |||
@@ -176,68 +181,8 @@ class ProducerAdminController extends BackendController | |||
return $this->redirect(['producer-admin/index']); | |||
} | |||
/** | |||
* Génère la facture mensuelle d'un producteur. | |||
* | |||
* @param integer $idProducer | |||
*/ | |||
public function actionBill($idProducer) | |||
{ | |||
$producer = Producer::findOne($idProducer); | |||
if ($producer) { | |||
$period = date('Y-m', strtotime('-1 month')); | |||
$last_invoice = Invoice::getLastInvoice(); | |||
if (!$last_invoice) { | |||
$reference = 'BAP000001'; | |||
} else { | |||
$reference = str_replace('BAP', '', $last_invoice->reference); | |||
$reference++; | |||
$reference = 'BAP' . $reference; | |||
} | |||
$invoice = new Invoice; | |||
$invoice->id_producer = $idProducer; | |||
$invoice->date = date('Y-m-d H:i:s'); | |||
$invoice->reference = $reference; | |||
$invoice->turnover = $producer->getTurnover($period); | |||
$invoice->amount_ht = $producer->getFreePrice(); | |||
$invoice->wording = 'Facture ' . date('m/Y', strtotime('-1 month')); | |||
$invoice->text = 'Utilisation de la plateforme <strong>distrib</strong> pour le mois : ' . date('m/Y', strtotime('-1 month')) . '<br />' | |||
. 'Chiffre d\'affaire réalisé sur la plateforme : <strong>' . number_format($facture->ca, 2) . ' €</strong> commissionné à <strong>1%</strong>.'; | |||
$invoice->paid = 0; | |||
$invoice->period = $period; | |||
$invoice->save(); | |||
} | |||
$this->redirect(['producer-admin/index']); | |||
} | |||
/** | |||
* Liste les factures des producteurs. | |||
* | |||
* @return mxied | |||
*/ | |||
public function actionBilling() | |||
{ | |||
$dataProviderInvoice = new ActiveDataProvider([ | |||
'query' => Invoice::find() | |||
->with('producer') | |||
->orderBy('reference DESC'), | |||
'pagination' => [ | |||
'pageSize' => 1000, | |||
], | |||
]); | |||
return $this->render('billing', [ | |||
'dataProviderInvoice' => $dataProviderInvoice, | |||
]); | |||
} | |||
public function actionProducerInstallTaxUpdatePrices($idProducer) | |||
{ | |||
// product | |||
$productsArray = Product::searchAll([ | |||
'id_producer' => $idProducer | |||
]); | |||
@@ -266,13 +211,9 @@ class ProducerAdminController extends BackendController | |||
} | |||
/** | |||
* Recherche un établissement. | |||
* | |||
* @param integer $id | |||
* @return Etablissement | |||
* @throws NotFoundHttpException | |||
* Recherche un producteur. | |||
*/ | |||
protected function findModel($id) | |||
protected function findModel(int $id) | |||
{ | |||
if (($model = Producer::findOne($id)) !== null) { | |||
return $model; |
@@ -39,6 +39,8 @@ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\Producer\ProducerPriceRange\ProducerPriceRange; | |||
use Yii; | |||
use yii\data\ActiveDataProvider; | |||
use yii\web\NotFoundHttpException; | |||
@@ -79,8 +81,6 @@ class ProducerController extends BackendController | |||
/** | |||
* Modifie un producteur. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionUpdate() | |||
{ | |||
@@ -150,20 +150,9 @@ class ProducerController extends BackendController | |||
/** | |||
* Affiche le formulaire permettant au producteur de définir le montant | |||
* de son abonnement. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionBilling() | |||
{ | |||
$datasInvoices = new ActiveDataProvider([ | |||
'query' => Invoice::find() | |||
->where(['id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->orderBy('reference DESC'), | |||
'pagination' => [ | |||
'pageSize' => 1000, | |||
], | |||
]); | |||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | |||
if ($producer->load(\Yii::$app->request->post())) { | |||
@@ -184,7 +173,6 @@ class ProducerController extends BackendController | |||
return $this->render('billing', [ | |||
'dataProviderPrices' => $dataProviderPrices, | |||
'datasInvoices' => $datasInvoices, | |||
'producer' => $producer, | |||
'alertFreePrice' => (isset($alertFreeprice)) ? true : false | |||
]); | |||
@@ -192,12 +180,8 @@ class ProducerController extends BackendController | |||
/** | |||
* Recherche un établissement via son ID. | |||
* | |||
* @param integer $id | |||
* @return Etablissement | |||
* @throws NotFoundHttpException | |||
*/ | |||
protected function findModel($id) | |||
protected function findModel(int $id) | |||
{ | |||
if (($model = Producer::findOne($id)) !== null) { | |||
return $model; | |||
@@ -208,8 +192,9 @@ class ProducerController extends BackendController | |||
public function actionUpdateOpendistribVersion() | |||
{ | |||
$producer = GlobalParam::getCurrentProducer(); | |||
$producer->updateOpendistribVersion(); | |||
$producerManager = $this->getProducerManager(); | |||
$producerManager->updateOpendistribVersion(GlobalParam::getCurrentProducer()); | |||
return $this->redirect(\Yii::$app->request->referrer); | |||
} | |||
} |
@@ -38,6 +38,7 @@ | |||
namespace backend\controllers; | |||
use common\logic\Producer\ProducerPriceRange\ProducerPriceRange; | |||
use Yii; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
@@ -45,11 +46,10 @@ use yii\filters\AccessControl; | |||
use yii\data\ActiveDataProvider; | |||
/** | |||
* TaxRateAdminController implements the CRUD actions for TaxRate model. | |||
* ProducerPriceRangeAdminController implements the CRUD actions for ProducerPriceRange model. | |||
*/ | |||
class ProducerPriceRangeAdminController extends BackendController | |||
{ | |||
public function behaviors() | |||
{ | |||
return [ | |||
@@ -75,8 +75,6 @@ class ProducerPriceRangeAdminController extends BackendController | |||
/** | |||
* Liste les tranches de prix. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionIndex() | |||
{ | |||
@@ -91,69 +89,62 @@ class ProducerPriceRangeAdminController extends BackendController | |||
/** | |||
* Crée une tranche de prix. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$model = new ProducerPriceRange(); | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerPriceRange = $producerPriceRangeManager->instanciateProducerPriceRange(); | |||
if ($producerPriceRange->load(\Yii::$app->request->post()) | |||
&& $producerPriceRangeManager->saveCreate($producerPriceRange)) { | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
$this->setFlash('success', 'Tranche de prix créée.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('create', [ | |||
'model' => $model, | |||
'model' => $producerPriceRange, | |||
]); | |||
} | |||
} | |||
/** | |||
* Édition d'une tranche de prix. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionUpdate($id) | |||
public function actionUpdate(int $id) | |||
{ | |||
$model = $this->findModel($id); | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerPriceRange = $this->findModel($id); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
if ($producerPriceRange->load(\Yii::$app->request->post()) && $producerPriceRangeManager->saveUpdate($producerPriceRange)) { | |||
$this->setFlash('success', 'Tranche de prix éditée.'); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('update', [ | |||
'model' => $model, | |||
'model' => $producerPriceRange, | |||
]); | |||
} | |||
} | |||
/** | |||
* Supprime une tranche de prix. | |||
* | |||
* @param integer $id | |||
*/ | |||
public function actionDelete($id) | |||
public function actionDelete(int $id) | |||
{ | |||
$producerPriceRange = ProducerPriceRange::searchOne([ | |||
'id' => $id | |||
]); | |||
$producerPriceRange->delete(); | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
$producerPriceRange = $this->findModel($id); | |||
$producerPriceRangeManager->delete($producerPriceRange); | |||
$this->setFlash('success', 'Tranche de prix supprimée.'); | |||
return $this->redirect(['producer-price-range-admin/index']); | |||
} | |||
/** | |||
* Finds the Developpement model based on its primary key value. | |||
* If the model is not found, a 404 HTTP exception will be thrown. | |||
* @param integer $id | |||
* @return ProducerPriceRange the loaded model | |||
* @throws NotFoundHttpException if the model cannot be found | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = ProducerPriceRange::findOne($id)) !== null) { | |||
return $model; | |||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||
if (($producerPriceRange = $producerPriceRangeManager->findOneProducerPriceRangeById($id)) !== null) { | |||
return $producerPriceRange; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
} |
@@ -39,6 +39,8 @@ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Product\Product\Product; | |||
use common\logic\Product\ProductCategory\ProductCategorySearch; | |||
use Yii; | |||
use yii\filters\AccessControl; | |||
use yii\web\NotFoundHttpException; | |||
@@ -46,7 +48,7 @@ use yii\filters\VerbFilter; | |||
use yii\helpers\Html; | |||
/** | |||
* PointVenteController implements the CRUD actions for PointVente model. | |||
* ProductCategoryController implements the CRUD actions for ProductCategory model. | |||
*/ | |||
class ProductCategoryController extends BackendController | |||
{ | |||
@@ -74,9 +76,7 @@ class ProductCategoryController extends BackendController | |||
} | |||
/** | |||
* Liste les points de vente. | |||
* | |||
* @return mixed | |||
* Liste les catégories. | |||
*/ | |||
public function actionIndex() | |||
{ | |||
@@ -91,57 +91,53 @@ class ProductCategoryController extends BackendController | |||
/** | |||
* Crée une catégorie. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionCreate() | |||
{ | |||
$model = new ProductCategory(); | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$productCategory = $productCategoryManager->instanciateProductCategory(); | |||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||
$productCategory->id_producer = GlobalParam::getCurrentProducerId(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
if ($productCategory->load(\Yii::$app->request->post()) && $productCategoryManager->saveCreate($productCategory)) { | |||
$this->setFlash('success', "Catégorie ajoutée."); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('create', [ | |||
'model' => $model, | |||
'model' => $productCategory, | |||
]); | |||
} | |||
} | |||
/** | |||
* Modifie une catégorie. | |||
* | |||
* @param integer $id | |||
* @return mixed | |||
*/ | |||
public function actionUpdate($id) | |||
public function actionUpdate(int $id) | |||
{ | |||
$model = $this->findModel($id); | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$productCategory = $this->findModel($id); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
if ($productCategory->load(\Yii::$app->request->post()) && $productCategoryManager->saveUpdate($productCategory)) { | |||
$this->setFlash('success', "Catégorie modifiée."); | |||
return $this->redirect(['index']); | |||
} else { | |||
return $this->render('update', [ | |||
'model' => $model, | |||
'model' => $productCategory, | |||
]); | |||
} | |||
} | |||
/** | |||
* Supprime une catégorie | |||
* | |||
* @param integer $id | |||
* @return mixed | |||
* Supprime une catégorie. | |||
*/ | |||
public function actionDelete($id) | |||
{ | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$productCategory = $this->findModel($id); | |||
$productCategory->delete(); | |||
$productCategoryManager->delete($productCategory); | |||
Product::updateAll(['id_product_category' => null], ['id_product_category' => $id]); | |||
$this->setFlash('success', 'Catégorie <strong>' . Html::encode($productCategory->name) . '</strong> supprimée.'); | |||
return $this->redirect(['index']); | |||
@@ -149,8 +145,6 @@ class ProductCategoryController extends BackendController | |||
/** | |||
* Modifie l'ordre des catégories. | |||
* | |||
* @param array $array | |||
*/ | |||
public function actionPosition() | |||
{ | |||
@@ -166,15 +160,12 @@ class ProductCategoryController extends BackendController | |||
/** | |||
* Recherche une catégorie en fonction de son ID. | |||
* | |||
* @param integer $id | |||
* @return ProductCategory | |||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = ProductCategory::findOne($id)) !== null) { | |||
return $model; | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
if (($productCategory = $productCategoryManager->findOneProductCategoryById($id)) !== null) { | |||
return $productCategory; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
} |
@@ -39,22 +39,10 @@ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use common\models\ProductDistribution; | |||
use common\models\ProductPrice; | |||
use common\models\ProductPriceSearch; | |||
use common\models\ProductSearch; | |||
use common\models\ UserSearch; | |||
use Yii; | |||
use yii\filters\AccessControl; | |||
use common\models\Product; | |||
use common\models\Distribution; | |||
use common\models\ User; | |||
use common\logic\UserProducer\ UserProducer; | |||
use yii\data\ActiveDataProvider; | |||
use yii\web\Controller; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use yii\web\UploadedFile; | |||
use common\helpers\Upload; | |||
/** |
@@ -22,6 +22,13 @@ class ProducerPriceRangeRepository extends BaseService implements RepositoryInte | |||
]; | |||
} | |||
public function findOneProducerPriceRangeById(int $id) | |||
{ | |||
return ProducerPriceRange::searchOne([ | |||
'id' => $id | |||
]); | |||
} | |||
public function queryProducerPriceRanges() | |||
{ | |||
return ProducerPriceRange::find()->orderBy('range_begin ASC'); |
@@ -18,6 +18,11 @@ class ProductCategoryRepository extends BaseService implements RepositoryInterfa | |||
]; | |||
} | |||
public function findOneProductCategoryById(int $id) | |||
{ | |||
return ProductCategory::searchOne(['id' => $id]); | |||
} | |||
public function findProductCategories() | |||
{ | |||
return ProductCategory::searchAll([], ['orderby' => 'product_category.position ASC']); |