|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
$pointSale = PointSale::findOne($order->id_point_sale); |
|
|
$pointSale = PointSale::findOne($order->id_point_sale); |
|
|
$distribution = Distribution::findOne($order->id_distribution); |
|
|
$distribution = Distribution::findOne($order->id_distribution); |
|
|
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); |
|
|
|
|
|
|
|
|
|
|
|
if ($order->id_user && $this->producerRepository->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' => $order->id_user, |
|
|
|
|
|
'id_producer' => $distribution->id_producer |
|
|
|
|
|
]); |
|
|
|
|
|
if ($userProducer) { |
|
|
|
|
|
return $userProducer->credit_active; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($pointSale) { |
|
|
|
|
|
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale); |
|
|
|
|
|
|
|
|
|
|
|
if ($order->id_user && $this->producerRepository->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' => $order->id_user, |
|
|
|
|
|
'id_producer' => $distribution->id_producer |
|
|
|
|
|
]); |
|
|
|
|
|
if ($userProducer) { |
|
|
|
|
|
return $userProducer->credit_active; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |