@@ -98,6 +98,14 @@ class PointSaleRepository extends AbstractRepository | |||
->find(); | |||
} | |||
public function findPointSalesByUserAccess(User $user) | |||
{ | |||
return $this->createDefaultQuery() | |||
->filterIsOnline() | |||
->filterByUserAccess($user) | |||
->find(); | |||
} | |||
public function queryPointSalesPublic(Producer $producer) | |||
{ | |||
return $this->createDefaultQuery() |
@@ -6,6 +6,7 @@ use common\logic\AbstractRepositoryQuery; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\PointSale\PointSale\Service\PointSaleDefinition; | |||
use common\logic\StatusInterface; | |||
use common\logic\User\User\Model\User; | |||
use yii\db\ActiveQuery; | |||
class PointSaleRepositoryQuery extends AbstractRepositoryQuery | |||
@@ -44,4 +45,12 @@ class PointSaleRepositoryQuery extends AbstractRepositoryQuery | |||
return $this; | |||
} | |||
public function filterByUserAccess(User $user): self | |||
{ | |||
$this->andWhere('status = 1 AND (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))'); | |||
$this->addParams([':id_user' => $user->id]); | |||
return $this; | |||
} | |||
} |
@@ -245,7 +245,7 @@ class SubscriptionController extends ProducerBaseController | |||
$params = []; | |||
$productModule = $this->getProductModule(); | |||
$subscriptionModule = $this->getSubscriptionModule(); | |||
$user = GlobalParam::getCurrentUser(); | |||
$user = $this->getUserCurrent(); | |||
$userProducer = $this->getUserProducerModule()->findOneUserProducer($this->getUserCurrent()); | |||
$pointSale = null; | |||
@@ -304,7 +304,7 @@ class SubscriptionController extends ProducerBaseController | |||
$params['products'] = $productsArray; | |||
$pointsSaleArray = $this->getPointSaleModule()->findPointSales(); | |||
$pointsSaleArray = $this->getPointSaleModule()->findPointSalesByUserAccess($user); | |||
foreach ($pointsSaleArray as &$pointSale) { | |||
$pointSale = array_merge($pointSale->getAttributes(), [ | |||
'userPointSale' => ($pointSale->userPointSale ? $pointSale->userPointSale[0] : '') |