mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Cambios en la API con imprimelibros
This commit is contained in:
@ -19,45 +19,17 @@ class ImprimelibrosApi extends ResourceController
|
|||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null)
|
|
||||||
{
|
|
||||||
$model = new ItemModel();
|
|
||||||
$data = $model->find(['id' => $id]);
|
|
||||||
if (!$data)
|
|
||||||
return $this->failNotFound('No Data Found');
|
|
||||||
return $this->respond($data[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
helper(['form']);
|
|
||||||
$rules = [
|
|
||||||
'title' => 'required',
|
|
||||||
'price' => 'required'
|
|
||||||
];
|
|
||||||
$data = [
|
|
||||||
'title' => $this->request->getVar('title'),
|
|
||||||
'price' => $this->request->getVar('price')
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!$this->validate($rules))
|
|
||||||
return $this->fail($this->validator->getErrors());
|
|
||||||
$model = new ItemModel();
|
|
||||||
$model->save($data);
|
|
||||||
$response = [
|
|
||||||
'status' => 201,
|
|
||||||
'error' => null,
|
|
||||||
'messages' => [
|
|
||||||
'success' => 'Data Inserted'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
return $this->respondCreated($response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function calcular()
|
public function calcular()
|
||||||
{
|
{
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
|
|
||||||
|
// Access the entire POST data
|
||||||
|
$post_data = $this->request->getJSON(true);
|
||||||
|
|
||||||
|
//return $this->respond(var_dump($post_data));
|
||||||
|
|
||||||
$data_tmp = array
|
$data_tmp = array
|
||||||
(
|
(
|
||||||
'clienteId' => 1870,
|
'clienteId' => 1870,
|
||||||
@ -131,16 +103,16 @@ class ImprimelibrosApi extends ResourceController
|
|||||||
$client = \Config\Services::curlrequest();
|
$client = \Config\Services::curlrequest();
|
||||||
|
|
||||||
$presupuestocliente = new Presupuestocliente();
|
$presupuestocliente = new Presupuestocliente();
|
||||||
$response = $presupuestocliente->calcular($data_tmp);
|
$response = $presupuestocliente->calcular($post_data);
|
||||||
|
|
||||||
/*$response = [
|
$response = [
|
||||||
'status' => 200,
|
'status' => 200,
|
||||||
'error' => null,
|
'error' => null,
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'success' => 'Data updated'
|
'precio' => $response['precio_u']
|
||||||
]
|
]
|
||||||
];*/
|
];
|
||||||
return $this->respond($response['precio_u']);
|
return $this->respond($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id = null)
|
public function delete($id = null)
|
||||||
|
|||||||
@ -588,7 +588,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
else{
|
else{
|
||||||
return $return_data;
|
return $return_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if($this->request){
|
if($this->request){
|
||||||
if($this->request->isAJAX())
|
if($this->request->isAJAX())
|
||||||
@ -1376,9 +1376,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
/***********************
|
/***********************
|
||||||
*
|
*
|
||||||
* Funciones auxiliares
|
* Funciones auxiliares
|
||||||
*
|
*
|
||||||
**********************/
|
**********************/
|
||||||
protected function borrarRelacionesPresupuesto($id)
|
protected function borrarRelacionesPresupuesto($id)
|
||||||
{
|
{
|
||||||
@ -2116,7 +2116,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
*/
|
*/
|
||||||
$serviciosAutomaticos = [];
|
$serviciosAutomaticos = [];
|
||||||
$servicios = [];
|
$servicios = [];
|
||||||
// se comprueba si $datos guardas es un array
|
// se comprueba si $datos guardas es un array
|
||||||
if (is_array($datos_guardas)) {
|
if (is_array($datos_guardas)) {
|
||||||
if (count($datos_guardas) > 0) {
|
if (count($datos_guardas) > 0) {
|
||||||
array_push($servicios, 62); // Plegado de guardas
|
array_push($servicios, 62); // Plegado de guardas
|
||||||
@ -2488,10 +2488,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
;
|
;
|
||||||
foreach ($data as $linea) {
|
foreach ($data as $linea) {
|
||||||
|
|
||||||
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
|
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"
|
||||||
$calidad = 'premium';
|
$calidad = 'premium';
|
||||||
}
|
}
|
||||||
if (strpos($linea->tipo, "color") !== false) { // $linea->tipo contains the substring "color"
|
if (strpos($linea->tipo, "color") !== false) { // $linea->tipo contains the substring "color"
|
||||||
$color = 'color';
|
$color = 'color';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user