diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 0b535831..bab916c2 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -77,8 +77,6 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ( $routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']); $routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']); $routes->get('select', 'TarifaAcabados::show_select', ["as" => "showSelectTarifaAcabado"]); - $routes->get('gettarifas', 'TarifaAcabados::getSelect2'); - $routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) { $routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']); $routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']); @@ -966,6 +964,8 @@ $routes->group( $routes->options('items', static function () { }); $routes->options('items/(:any)', static function () { }); + $routes->post("calcular", 'ImprimelibrosApi::calcular'); + // ... diff --git a/ci4/app/Controllers/API/ImprimelibrosApi.php b/ci4/app/Controllers/API/ImprimelibrosApi.php new file mode 100644 index 00000000..d95bbdf0 --- /dev/null +++ b/ci4/app/Controllers/API/ImprimelibrosApi.php @@ -0,0 +1,135 @@ +findAll(); + return $this->respond($data); + } + + + + public function calcular() + { + helper(['form']); + + // Access the entire POST data + $post_data = $this->request->getJSON(true); + + //return $this->respond(var_dump($post_data)); + + $data_tmp = array + ( + '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(); + $response = $presupuestocliente->calcular($post_data); + + $response = [ + 'status' => 200, + 'error' => null, + 'messages' => [ + 'precio' => $response['precio_u'] + ] + ]; + 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); + } +} diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 66e8d76a..d729e12a 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1586,7 +1586,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if (!is_null($new_name)) { $path = WRITEPATH . 'uploads/presupuestos/' . $new_name; move_uploaded_file($tmp_name, $path); +<<<<<<< HEAD + +======= +>>>>>>> main } } $ftp->uploadFilePresupuesto($presupuesto_id); @@ -1605,9 +1609,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController /*********************** - * + * * Funciones auxiliares - * + * **********************/ protected function borrarRelacionesPresupuesto($id) { @@ -2384,7 +2388,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value ]; +<<<<<<< HEAD + // se comprueba si $datos guardas es un array +======= // se comprueba si $datos guardas es un array +>>>>>>> main if (is_array($datos_guardas)) { if (count($datos_guardas) > 0) { array_push($servicios, $servicio_plegado_guardas); // Plegado de guardas @@ -2407,7 +2415,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController array_push($servicios, $servicio_solapas_cubierta); if (!is_null($sobreCubierta) && $sobreCubierta) // Si hay sobrecubierta, siempre con solapas array_push($servicios, $servicio_solapas_sobrecubierta); +<<<<<<< HEAD + /* TO-DO +======= /* TO-DO +>>>>>>> main if (!is_null($faja) && $faja) // Si hay faja, siempre con solapas array_push($servicios, $servicio_solapas_faja); */ @@ -2831,10 +2843,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ; 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'; } - 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'; } }