->setParameter('year', $year); | ->setParameter('year', $year); | ||||
} | } | ||||
public function filterByDistributions(array $distributions): self | |||||
public function filterByDistributions(array $distributionArray): self | |||||
{ | { | ||||
return $this | return $this | ||||
->andWhere('.distribution IN(:distributions)') | |||||
->setParameter('distributions', $distributions); | |||||
->andWhere('.distribution IN (:distributions)') | |||||
->setParameter('distributions', $distributionArray); | |||||
} | } | ||||
public function filterByProducts(array $products): self | public function filterByProducts(array $products): self |
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->orderBy('id', 'DESC'); | |||||
//$query->orderBy('id', 'DESC'); | |||||
return $query; | return $query; | ||||
} | } | ||||
$query->filterByDistribution($params['distribution']); | $query->filterByDistribution($params['distribution']); | ||||
} | } | ||||
if (isset($params['distributions'])) { | |||||
$query->filterByDistributions($params['distributions']); | |||||
} | |||||
if (isset($params['isCart'])) { | if (isset($params['isCart'])) { | ||||
$query->filterByStatus(OrderStatusModel::$statusAliasAsCart); | $query->filterByStatus(OrderStatusModel::$statusAliasAsCart); | ||||
} | } | ||||
if (isset($params['excludeComplementaryOrderShops']) || isset($params['mergeComplementaryOrderShops'])) { | if (isset($params['excludeComplementaryOrderShops']) || isset($params['mergeComplementaryOrderShops'])) { | ||||
$query->filterIsNullMainOrderShop(); | $query->filterIsNullMainOrderShop(); | ||||
} | } | ||||
if (isset($params['joinProductFamily'])) { | if (isset($params['joinProductFamily'])) { | ||||
$query->joinProductFamily(true); | $query->joinProductFamily(true); | ||||
} | } | ||||
if (isset($params['groupBy'])) { | if (isset($params['groupBy'])) { | ||||
$query->groupBy($params['groupBy']); | $query->groupBy($params['groupBy']); | ||||
} | } | ||||
return $query; | return $query; | ||||
} | } | ||||
if($quantity) { | if($quantity) { | ||||
return ($quantityProduct / $unit->getCoefficient()) * $quantity; | return ($quantityProduct / $unit->getCoefficient()) * $quantity; | ||||
}else{ | }else{ | ||||
$quantity = 0; | |||||
return 0; | |||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
public function isDone(OrderShopInterface $orderShop): bool | |||||
{ | |||||
if ($orderShop->getOrderStatus() && $orderShop->getOrderStatus()->getAlias() == OrderStatusModel::ALIAS_DONE ) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
// getProductQuantityMaxAddCart | // getProductQuantityMaxAddCart | ||||
public function getProductQuantityMaxAddCart(OrderShopInterface $orderShop, ProductInterface $product) | public function getProductQuantityMaxAddCart(OrderShopInterface $orderShop, ProductInterface $product) | ||||
{ | { |