Promociones para cada subdivicion
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user