Promociones para cada subdivicion
This commit is contained in:
@ -163,10 +163,10 @@ class Contracts
|
||||
try {
|
||||
$unit = $unitRepository->fetchById($unit_id);
|
||||
$contractService->getById($contract_id);
|
||||
$promotion = $promotionRepository->fetchByContractAndUnit($contract_id, $unit->id);
|
||||
$promotions = $promotionRepository->fetchByContractAndUnit($contract_id, $unit->id);
|
||||
$output['unidades'] []= [
|
||||
'id' => $unit->id,
|
||||
'promotion' => $promotion
|
||||
'promotions' => $promotions
|
||||
];
|
||||
} catch (ServiceAction\Read | Implement\Exception\EmptyResult) {}
|
||||
}
|
||||
|
@ -127,14 +127,14 @@ class Promotions
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($input['operator']) > 0 and $input['operator'][0] !== '') {
|
||||
$contract_ids = array_filter($input['operator'], function($operator_id) { return $operator_id !== ''; });
|
||||
$total += count($contract_ids);
|
||||
foreach ($contract_ids as $contract_id) {
|
||||
if (count($input['broker']) > 0 and $input['broker'][0] !== '') {
|
||||
$broker_ruts = array_filter($input['broker'], function($broker_rut) { return $broker_rut !== ''; });
|
||||
$total += count($broker_ruts);
|
||||
foreach ($broker_ruts as $broker_rut) {
|
||||
try {
|
||||
$promotionService->addContract($promotion_id, $contract_id);
|
||||
$promotionService->addBroker($promotion_id, $broker_rut);
|
||||
$output['connections'] []= [
|
||||
'operator_id' => $contract_id,
|
||||
'broker_rut' => $broker_rut,
|
||||
'success' => true,
|
||||
];
|
||||
$output['partial'] = true;
|
||||
@ -205,11 +205,79 @@ class Promotions
|
||||
$output = [
|
||||
'promotion_id' => $promotion_id,
|
||||
'project_id' => $project_id,
|
||||
'connection' => null,
|
||||
'success' => false,
|
||||
];
|
||||
try {
|
||||
$output['connection'] = $promotionService->removeProject($promotion_id, $project_id);
|
||||
$promotionService->removeProject($promotion_id, $project_id);
|
||||
$output['success'] = true;
|
||||
} catch (ServiceAction\Delete $exception) {
|
||||
return $this->withError($response, $exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function removeBroker(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Promotion $promotionService,
|
||||
int $promotion_id, string $broker_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'promotion_id' => $promotion_id,
|
||||
'broker_rut' => $broker_rut,
|
||||
'success' => false,
|
||||
];
|
||||
try {
|
||||
$promotionService->removeBroker($promotion_id, $broker_rut);
|
||||
$output['success'] = true;
|
||||
} catch (ServiceAction\Delete $exception) {
|
||||
return $this->withError($response, $exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function removeUnitType(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Promotion $promotionService,
|
||||
int $promotion_id, int $project_id, int $unit_type_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'promotion_id' => $promotion_id,
|
||||
'project_id' => $project_id,
|
||||
'unit_type_id' => $unit_type_id,
|
||||
'success' => false,
|
||||
];
|
||||
try {
|
||||
$promotionService->removeUnitType($promotion_id, $project_id, $unit_type_id);
|
||||
$output['success'] = true;
|
||||
} catch (ServiceAction\Delete $exception) {
|
||||
return $this->withError($response, $exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function removeUnitLine(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Promotion $promotionService,
|
||||
int $promotion_id, int $unit_line_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'promotion_id' => $promotion_id,
|
||||
'unit_line_id' => $unit_line_id,
|
||||
'success' => false,
|
||||
];
|
||||
try {
|
||||
$promotionService->removeUnitLine($promotion_id, $unit_line_id);
|
||||
$output['success'] = true;
|
||||
} catch (ServiceAction\Delete $exception) {
|
||||
return $this->withError($response, $exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function removeUnit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Promotion $promotionService,
|
||||
int $promotion_id, int $unit_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'promotion_id' => $promotion_id,
|
||||
'unit_id' => $unit_id,
|
||||
'success' => false,
|
||||
];
|
||||
try {
|
||||
$promotionService->removeUnit($promotion_id, $unit_id);
|
||||
$output['success'] = true;
|
||||
} catch (ServiceAction\Delete $exception) {
|
||||
return $this->withError($response, $exception);
|
||||
|
@ -19,7 +19,7 @@ class Promotions extends Ideal\Controller
|
||||
}
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta\Promotion $promotionService, Service\Proyecto $proyectoService,
|
||||
Service\Proyecto\Broker $brokerService, Service\Proyecto\Broker\Contract $contractService,
|
||||
Service\Proyecto\Broker $brokerService,
|
||||
int $promotion_id): ResponseInterface
|
||||
{
|
||||
$promotion = null;
|
||||
@ -27,9 +27,8 @@ class Promotions extends Ideal\Controller
|
||||
$promotion = $promotionService->getById($promotion_id);
|
||||
} catch (ServiceAction\Read) {}
|
||||
$projects = $proyectoService->getVendibles('descripcion');
|
||||
$contracts = $contractService->getAll();
|
||||
$brokers = $brokerService->getAll('name');
|
||||
return $view->render($response, 'ventas.promotions.show', ['promotion' => $promotion,
|
||||
'projects' => $projects, 'contracts' => $contracts, 'brokers' => $brokers]);
|
||||
'projects' => $projects, 'brokers' => $brokers]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user