mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en direcciones!
This commit is contained in:
@ -69,23 +69,26 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$tirada = $postData->tirada ?? 0;
|
||||
$POD = $postData->POD ?? 0;
|
||||
$postData = $this->request->getPost();
|
||||
$datos_tarifas = $postData['datos'] ?? [];
|
||||
$tirada = $postData['tirada'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
$result = [];
|
||||
|
||||
if (count($tarifas) > 0) {
|
||||
foreach ($tarifas as $tarifa) {
|
||||
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
array_push($result, $values);
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$proveedor = $tarifa['proveedor_id'] == '' ? -1 : $tarifa['proveedor_id'];
|
||||
$values = $this->model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $proveedor, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
'lineas' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
@ -510,6 +510,13 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
$data['servicios'] = $this->getLineasServicios($presupuesto)[1];
|
||||
|
||||
if (intval($presupuesto->envios_recoge_cliente) == 1) {
|
||||
$data['direcciones']['entrega_taller'] = 1;
|
||||
} else {
|
||||
$data['direcciones']['entrega_taller'] = 0;
|
||||
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@ -1422,4 +1429,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
return PresupuestoService::checkLineasEnvios($direccionesEnvio);
|
||||
}
|
||||
|
||||
protected function obtenerDireccionesEnvio($id, $cliente_id)
|
||||
{
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$model_direcciones = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$direcciones = $model
|
||||
->join('lg_proveedores', 'presupuesto_direcciones.proveedor_id = lg_proveedores.id')
|
||||
->join('lg_paises', 'presupuesto_direcciones.pais_id = lg_paises.id')
|
||||
->select('presupuesto_direcciones.*, lg_proveedores.nombre AS proveedor, lg_paises.nombre AS pais')
|
||||
->where('presupuesto_id', $id)->findAll();
|
||||
|
||||
return $direcciones;
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,6 +345,53 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$lomo += floatval($linea['mano']);
|
||||
}
|
||||
}
|
||||
|
||||
//Guardas
|
||||
$guardas = $reqData['guardas'] ?? [];
|
||||
if ($guardas != "false" && $guardas != null) {
|
||||
$datos_guardas = [
|
||||
'papel' => $modelPapelGenerico->getIdFromCode($guardas['papel']),
|
||||
'gramaje' => intval($guardas['gramaje']),
|
||||
'caras' => intval($guardas['caras']),
|
||||
];
|
||||
} else
|
||||
$datos_guardas = false;
|
||||
$guardas = [];
|
||||
$peso_guardas = 0.0;
|
||||
$coste_guardas = 0.0;
|
||||
if ($datos_guardas != 0) {
|
||||
if (count($datos_guardas) != 0 && $datos_guardas) {
|
||||
|
||||
$guardas = $datos_guardas;
|
||||
$input_data['papel_generico'] = $datos_guardas['papel'] ?? 0;
|
||||
$input_data['gramaje'] = $datos_guardas['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 8;
|
||||
$input_data['paginas_color'] = 8;
|
||||
$input_data['datosPedido']->paginas_impresion = $datos_guardas['caras'] ?? 0;
|
||||
$input_data['datosPedido']->solapas_ancho = 0;
|
||||
$input_data['datosPedido']->solapas = 0;
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'guardas';
|
||||
|
||||
// Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico
|
||||
// y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral
|
||||
// o wire-o tapa dura, las guardas se imprimen como hojas sueltas
|
||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||
$input_data['datosPedido']->isCosido = true;
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$input_data['datosPedido']->isCosido = false;
|
||||
}
|
||||
|
||||
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||
|
||||
foreach ($guardas as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$lomo += floatval($linea['mano']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$lomo = round($lomo, 2);
|
||||
$errors = [
|
||||
'status' => 0,
|
||||
@ -659,7 +706,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($interior == null) {
|
||||
return $this->failServerError('Error al calcular el interior');
|
||||
}
|
||||
$anchoTotal = $interior[0]['mano'];
|
||||
|
||||
$anchoTotal = 0;
|
||||
if(count($interior) == 2) {
|
||||
|
||||
if(count($interior[0]) > 0)
|
||||
$anchoTotal += $interior[0]['mano'];
|
||||
if(count($interior[1]) > 0)
|
||||
$anchoTotal += $interior[1]['mano'];
|
||||
}
|
||||
else{
|
||||
if(count($interior) > 0)
|
||||
$anchoTotal += $interior['mano'];
|
||||
}
|
||||
|
||||
|
||||
// le añadimos 2*ancho libro
|
||||
$anchoTotal += 2 * $datosPedido->ancho;
|
||||
// le añadimos los dobleces de las solapas
|
||||
|
||||
@ -69,30 +69,30 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$tirada = $postData->tirada ?? 0;
|
||||
$paginas = $postData->paginas ?? 0;
|
||||
$POD = $postData->POD ?? 0;
|
||||
$ancho = $postData->ancho ?? 0;
|
||||
$alto = $postData->alto ?? 0;
|
||||
$postData = $this->request->getPost();
|
||||
$datos_tarifas = $postData['datos'] ?? [];
|
||||
$tirada = $postData['tirada'] ?? 0;
|
||||
$paginas = $postData['paginas'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
$ancho = $postData['ancho'] ?? 0;
|
||||
$alto = $postData['alto'] ?? 0;
|
||||
$result = [];
|
||||
|
||||
if (count($tarifas) > 0) {
|
||||
foreach ($tarifas as $tarifa) {
|
||||
if ($tarifaModel->isTarifaPorHoras($tarifa)) {
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa, $paginas, $tirada, -1, $POD);
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
if ($tarifaModel->isTarifaPorHoras($tarifa['tarifa_id'])) {
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa['tarifa_id'], $paginas, $tirada, -1, $POD);
|
||||
} else {
|
||||
$values = $this->model->getPrecioTarifa($tarifa, $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||
$values = $this->model->getPrecioTarifa($tarifa['tarifa_id'], $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||
}
|
||||
array_push($result, $values);
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
'lineas' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
@ -63,6 +63,27 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServicioSolapas(){
|
||||
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas')->value;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$data = [
|
||||
'service' => $servicio,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($requestedId = null)
|
||||
{
|
||||
|
||||
@ -70,23 +91,23 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$tirada = $postData->tirada ?? 0;
|
||||
$POD = $postData->POD ?? 0;
|
||||
$postData = $this->request->getPost();
|
||||
$tarifas = $postData['datos'] ?? [];
|
||||
$tirada = $postData['tirada'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
$result = [];
|
||||
|
||||
if(count($tarifas)>0){
|
||||
foreach ($tarifas as $tarifa){
|
||||
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
array_push($result, $values);
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
'lineas' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user