mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/api_il_2' into 'main'
Dev/api il 2 See merge request jjimenez/safekat!563
This commit is contained in:
@ -970,7 +970,7 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
|
|||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$routes->post('auth/jwt', '\App\Controllers\Sistema\AuthAPIController::jwtLogin');
|
$routes->post('auth/jwt', '\App\Controllers\Sistema\AuthAPIController::jwtLogin');
|
||||||
|
|
||||||
$routes->group(
|
$routes->group(
|
||||||
'api',
|
'api',
|
||||||
[
|
[
|
||||||
@ -984,13 +984,8 @@ $routes->group(
|
|||||||
'filter' => 'cors'
|
'filter' => 'cors'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$routes->options('items', static function () { });
|
|
||||||
$routes->options('items/(:any)', static function () { });
|
|
||||||
|
|
||||||
$routes->post("calcular", 'ImprimelibrosApi::calcular');
|
$routes->post("calcular", 'ImprimelibrosApi::calcular');
|
||||||
|
$routes->post("guardar", 'ImprimelibrosApi::guardar');
|
||||||
|
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -25,111 +25,74 @@ class ImprimelibrosApi extends ResourceController
|
|||||||
{
|
{
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
|
|
||||||
|
$jsonData = json_decode($this->request->getBody(), true);
|
||||||
|
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
return $this->respond(
|
||||||
|
[
|
||||||
|
'status' => 400,
|
||||||
|
'error' => 'Invalid JSON format'
|
||||||
|
],
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Access the entire POST data
|
||||||
|
$post_data = $jsonData;
|
||||||
|
|
||||||
|
//return $this->respond(var_dump($post_data));
|
||||||
|
|
||||||
|
// Instancia de presupuesto cliente
|
||||||
|
$presupuestocliente = new Presupuestocliente();
|
||||||
|
$response = $presupuestocliente->calcular($post_data);
|
||||||
|
|
||||||
|
if (isset($response['tiradas'])) {
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'status' => 200,
|
||||||
|
'error' => null,
|
||||||
|
'data' => [
|
||||||
|
'tiradas' => $response['tiradas'],
|
||||||
|
'precios' => $response['precio_u']
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$response = [
|
||||||
|
'status' => 400,
|
||||||
|
'error' => $response
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
return $this->respond($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function guardar()
|
||||||
|
{
|
||||||
|
helper(['form']);
|
||||||
|
|
||||||
// Access the entire POST data
|
// Access the entire POST data
|
||||||
$post_data = $this->request->getJSON(true);
|
$post_data = $this->request->getJSON(true);
|
||||||
|
|
||||||
//return $this->respond(var_dump($post_data));
|
//return $this->respond(var_dump($post_data));
|
||||||
|
|
||||||
$data_tmp = array
|
// Instancia de presupuesto cliente
|
||||||
(
|
|
||||||
'clienteId' => 1870,
|
|
||||||
'tamanio' => array
|
|
||||||
(
|
|
||||||
'ancho' => 170,
|
|
||||||
'alto' => 240
|
|
||||||
),
|
|
||||||
'tirada' => array
|
|
||||||
(
|
|
||||||
'0' => 50,
|
|
||||||
'1' => 100,
|
|
||||||
|
|
||||||
),
|
|
||||||
'paginas' => 320,
|
|
||||||
'paginasColor' => 0,
|
|
||||||
'pagColorConsecutivas' => 0,
|
|
||||||
'papelInteriorDiferente' => 0,
|
|
||||||
'paginasCuadernillo' => 32,
|
|
||||||
'tipo' => 'cosido',
|
|
||||||
'isColor' => 0,
|
|
||||||
'isHq' => 0,
|
|
||||||
'interior' => array
|
|
||||||
(
|
|
||||||
'papelInterior' => 3,
|
|
||||||
'gramajeInterior' => 80
|
|
||||||
),
|
|
||||||
'guardas' => array
|
|
||||||
(
|
|
||||||
'papel' => 'OFF1',
|
|
||||||
'gramaje' => 170,
|
|
||||||
'caras' => 8
|
|
||||||
),
|
|
||||||
'posPaginasColor' => null,
|
|
||||||
'prototipo' => 0,
|
|
||||||
'ferro' => 0,
|
|
||||||
'ferroDigital' => 0,
|
|
||||||
'marcapaginas' => 0,
|
|
||||||
'retractilado' => 0,
|
|
||||||
'retractilado5' => 0,
|
|
||||||
'eb' => 10.5,
|
|
||||||
'cubierta' => array
|
|
||||||
(
|
|
||||||
'tipoCubierta' => 'tapaDura',
|
|
||||||
'papelCubierta' => 2,
|
|
||||||
'gramajeCubierta' => 170,
|
|
||||||
'cabezada' => 'WHI',
|
|
||||||
'acabado' => 1,
|
|
||||||
'carasImpresion' => 2,
|
|
||||||
'lomoRedondo' => 0,
|
|
||||||
'solapas' => 0,
|
|
||||||
),
|
|
||||||
'sobrecubierta' => false,
|
|
||||||
'faja' => false,
|
|
||||||
'excluirRotativa' => 0,
|
|
||||||
'ivaReducido' => 1,
|
|
||||||
'servicios' => array
|
|
||||||
(
|
|
||||||
'prototipo' => 0,
|
|
||||||
'ferro' => 0,
|
|
||||||
'ferroDigital' => 0,
|
|
||||||
'marcapaginas' => 0,
|
|
||||||
'retractilado' => 0,
|
|
||||||
'retractilado5' => 0
|
|
||||||
),
|
|
||||||
'entrega_taller' => 1,
|
|
||||||
'id' => 334
|
|
||||||
);
|
|
||||||
|
|
||||||
// Crear el cliente HTTP
|
|
||||||
$client = \Config\Services::curlrequest();
|
|
||||||
|
|
||||||
$presupuestocliente = new Presupuestocliente();
|
$presupuestocliente = new Presupuestocliente();
|
||||||
$response = $presupuestocliente->calcular($post_data);
|
$response = $presupuestocliente->guardar($post_data);
|
||||||
|
|
||||||
|
return $this->respond($response);
|
||||||
|
|
||||||
$response = [
|
$response = [
|
||||||
'status' => 200,
|
'status' => 200,
|
||||||
'error' => null,
|
'error' => null,
|
||||||
'messages' => [
|
'data' => [
|
||||||
'precio' => $response['precio_u']
|
'tiradas' => $response['tiradas'],
|
||||||
|
'precios' => $response['precio_u']
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
return $this->respond($response);
|
return $this->respond($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id = null)
|
|
||||||
{
|
|
||||||
$model = new ItemModel();
|
|
||||||
$find = $model->find(['id' => $id]);
|
|
||||||
if (!$find)
|
|
||||||
return $this->failNotFound('No Data Found');
|
|
||||||
$model->delete($id);
|
|
||||||
|
|
||||||
$response = [
|
|
||||||
'status' => 200,
|
|
||||||
'error' => null,
|
|
||||||
'messages' => [
|
|
||||||
'success' => 'Data deleted'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
return $this->respond($response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -450,12 +450,12 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
'comparador_json_data' => $this->generateJson($data),
|
'comparador_json_data' => $this->generateJson($data),
|
||||||
|
|
||||||
'faja_color' => is_array($data['faja']) ? 1 : 0,
|
'faja_color' => is_array($data['faja']) ? 1 : 0,
|
||||||
'solapas_ancho_faja_color' => is_array($data['faja']) ? $data['faja']['solapas'] : 60,
|
'solapas_ancho_faja_color' => is_array($data['faja']) && $data['faja'] !== [] ? $data['faja']['solapas'] : 60,
|
||||||
'alto_faja_color' => is_array($data['faja']) ? $data['faja']['alto'] : 50,
|
'alto_faja_color' => is_array($data['faja']) && $data['faja'] !== [] ? $data['faja']['alto'] : 50,
|
||||||
|
|
||||||
'acabado_cubierta_id' => $data['cubierta']['acabado'],
|
'acabado_cubierta_id' => $data['cubierta']['acabado'],
|
||||||
'acabado_sobrecubierta_id' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['acabado'],
|
'acabado_sobrecubierta_id' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['acabado'],
|
||||||
'acabado_faja_id' => is_array($data['faja']) ? $data['faja']['acabado'] : 0,
|
'acabado_faja_id' => is_array($data['faja']) && $data['faja'] !== [] ? $data['faja']['acabado'] : 0,
|
||||||
|
|
||||||
'comp_tipo_impresion' => $data['isHq'] ? ($data['isColor'] ? 'colorhq' : 'negrohq') : ($data['isColor'] ? 'color' : 'negro'),
|
'comp_tipo_impresion' => $data['isHq'] ? ($data['isColor'] ? 'colorhq' : 'negrohq') : ($data['isColor'] ? 'color' : 'negro'),
|
||||||
|
|
||||||
@ -582,7 +582,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- Faja --
|
// -- Faja --
|
||||||
if ($data['faja'] != 0) {
|
if ($data['faja'] != 0 && $data['faja'] !== []) {
|
||||||
$values['faja'] = array(
|
$values['faja'] = array(
|
||||||
'papel_id' => intval($data['faja']['papel']),
|
'papel_id' => intval($data['faja']['papel']),
|
||||||
'gramaje' => intval($data['faja']['gramaje']),
|
'gramaje' => intval($data['faja']['gramaje']),
|
||||||
|
|||||||
Reference in New Issue
Block a user