mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado. mejorado update de resumenes. quitado bug rotativa color (siempre tarifa negro)
This commit is contained in:
@ -21,8 +21,6 @@ use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
||||
use App\Services\PresupuestoService;
|
||||
use App\Models\Configuracion\PapelImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
use App\Models\Clientes\ClientePreciosModel;
|
||||
use Exception;
|
||||
|
||||
class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
@ -531,8 +529,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
} else if ($type == 'interior_rot') {
|
||||
|
||||
$paginas = (object)array(
|
||||
'negro' => intval($reqData['paginas_negro']) ?? 0,
|
||||
'color' => intval($reqData['paginas_color']) ?? 0,
|
||||
'negro' => intval($reqData['paginas_negro'] ?? 0),
|
||||
'color' => intval($reqData['paginas_color'] ?? 0),
|
||||
);
|
||||
|
||||
$datosTipolog = $reqData['negro'] ?? null;
|
||||
@ -768,7 +766,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$tipo = 'color';
|
||||
$opciones_papel['color'] = 1;
|
||||
}
|
||||
if ($paginas->negro > 0) {
|
||||
else {
|
||||
$opciones_papel['bn'] = 1;
|
||||
$tipo = 'negro';
|
||||
}
|
||||
@ -819,93 +817,22 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
// Se recorren las máquinas y se calcula el coste de linea por cada una
|
||||
foreach ($maquinas as $maquina) {
|
||||
|
||||
$tarifamodel = new MaquinasTarifasImpresionModel();
|
||||
[$tarifaId, $tarifa, $tarifa_margen] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo) ? 'color' : $tipo);
|
||||
if (!is_float($tarifa)) {
|
||||
$data['uso'] = $uso;
|
||||
$data['tipo'] = $tipo;
|
||||
$data['datosPedido'] = $datosPedido;
|
||||
$data['cliente_id'] = $cliente_id;
|
||||
$data['papel'] = $papel;
|
||||
$data['maquina'] = $maquina;
|
||||
$data['papel_generico'] = $papel_generico;
|
||||
$data['parametrosRotativa'] = $parametrosRotativa;
|
||||
$data['paginas'] = $paginas;
|
||||
$data['gramaje'] = $gramaje;
|
||||
|
||||
$linea = PresupuestoService::getLineaPresupuestoRotativa($data);
|
||||
|
||||
if(empty($linea))
|
||||
continue;
|
||||
}
|
||||
|
||||
// precio del pliego de impresion
|
||||
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
|
||||
|
||||
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas);
|
||||
|
||||
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
|
||||
|
||||
$linea['fields']['precios_pliegos'] = $precio_pliego_impresion + $margen_pliego_impresion;
|
||||
|
||||
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
||||
// Precio papel pedido
|
||||
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
||||
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);;
|
||||
|
||||
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
||||
$linea['fields']['maquina'] = $maquina->maquina;
|
||||
$linea['fields']['maquina_id'] = $maquina->maquina_id;
|
||||
$linea['fields']['maquina_velocidad'] = $maquina->velocidad;
|
||||
$linea['fields']['tipo_maquina'] = 'inkjet';
|
||||
$linea['fields']['papel_impresion'] = $papel->nombre;
|
||||
$linea['fields']['papel_impresion_id'] = $papel->id;
|
||||
$linea['fields']['paginas'] = $datosPedido->paginas;
|
||||
$linea['fields']['paginas_color'] = $paginas->color;
|
||||
$linea['fields']['gramaje'] = $gramaje;
|
||||
$linea['fields']['papel_generico_id'] = $papel_generico['id'];
|
||||
$linea['fields']['papel_generico'] = $papel_generico['nombre'];
|
||||
|
||||
$linea['fields']['posicion_formas'] = $parametrosRotativa->a_favor_fibra ? 'h' : 'v';
|
||||
$linea['fields']['num_formas_horizontales'] = floor($linea['fields']['factor_anchura']);
|
||||
$linea['fields']['num_formas_verticales'] = floor($linea['fields']['factor_altura']);
|
||||
|
||||
|
||||
|
||||
$linea['fields']['datosTipologias'] = $datosTipologias[0];
|
||||
|
||||
// impresion
|
||||
$linea['fields']['precio_click'] = $tarifa * (1 + $tarifa_margen / 100.0);
|
||||
$linea['fields']['precio_click_margen'] = $tarifa * ($tarifa_margen / 100.0);
|
||||
$linea['fields']['precio_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click'];
|
||||
$linea['fields']['margen_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click_margen'];
|
||||
|
||||
$linea['fields']['tiempo_maquina'] = PresupuestoService::getTiempoMaquina(
|
||||
$linea['fields']['precio_click_pedido'],
|
||||
$linea['fields']['precio_click'],
|
||||
$maquina->velocidad
|
||||
);
|
||||
|
||||
|
||||
$clientePreciosModel = new ClientePreciosModel();
|
||||
$config = (object)[
|
||||
"tipo" => $uso,
|
||||
"tipo_maquina" => 'inkjet',
|
||||
"tipo_impresion" => $tipo
|
||||
];
|
||||
$tiempo = PresupuestoService::getHorasMaquina(
|
||||
$linea['fields']['precio_click_pedido'],
|
||||
$linea['fields']['precio_click'],
|
||||
$maquina->velocidad
|
||||
);
|
||||
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
||||
|
||||
if (is_null($precio_hora)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$linea['fields']['precio_hora'] = $precio_hora * (1 + $margen_precio_hora / 100.0);
|
||||
$linea['fields']['precio_hora_margen'] = $precio_hora * ($margen_precio_hora / 100.0);
|
||||
$linea['fields']['horas_maquina'] = $tiempo;
|
||||
$linea['fields']['precio_impresion_horas'] = $linea['fields']['precio_hora'] * $tiempo;
|
||||
$linea['fields']['margen_impresion_horas'] = $linea['fields']['precio_hora_margen'] * $tiempo;
|
||||
|
||||
// total linea rotativa
|
||||
//$linea['fields']['total_impresion'] = $linea['fields']['precio_pedido'] + $linea['fields']['precio_click_pedido'] + $linea['fields']['precio_tinta'] +
|
||||
// $linea['fields']['total_corte'];
|
||||
$linea['fields']['total_impresion'] =
|
||||
floatval($linea['fields']['precio_pedido']) + // papel
|
||||
floatval($linea['fields']['precio_click_pedido']) + // precio clicks del pedido
|
||||
floatval($linea['fields']['precio_impresion_horas']) + // horas de maquina
|
||||
floatval($linea['fields']['precio_tinta']) + // tinta
|
||||
floatval($linea['fields']['total_corte']); // corte
|
||||
|
||||
|
||||
array_push($lineas, $linea);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,13 +137,31 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
||||
$papel_generico['nombre'] = $pg->nombre;
|
||||
|
||||
$maquina->maquina_id = $maquina->id;
|
||||
unset($maquina->id);
|
||||
|
||||
switch ($linea['row_id']) {
|
||||
case 'lp_rot_bn':
|
||||
case 'lp_rot_color':
|
||||
$uso = 'rotativa';
|
||||
$uso = 'interior';
|
||||
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
|
||||
$paginas_negro = isset($linea['numPagColor']) ? intval($datosPedido->paginas) - intval($linea['numPagColor']) : 0;
|
||||
$paginas_color = $linea['numPagColor'] ?? 0;
|
||||
$paginas = (object)array(
|
||||
'negro' => $paginas_negro,
|
||||
'color' => $paginas_color,
|
||||
);
|
||||
$parametrosRotativa = (object)array(
|
||||
'a_favor_fibra' => $datosPedido->a_favor_fibra,
|
||||
'bnPages' => $paginas->negro,
|
||||
'colorPages' => $paginas->color,
|
||||
'rotativa_gota_negro' => 0,
|
||||
'rotativa_gota_color' => 0,
|
||||
);
|
||||
$parametrosRotativa->rotativa_gota_negro = intval($linea['gotaNegro']?? 0);
|
||||
$parametrosRotativa->rotativa_gota_color = intval($linea['gotaColor']?? 0);
|
||||
$parametrosRotativa->rotativa_negro = intval($linea['cobNegro'] ?? 0);
|
||||
$parametrosRotativa->rotativa_cyan = intval($linea['cobCyan'] ?? 0);
|
||||
$parametrosRotativa->rotativa_magenta = intval($linea['cobMagenta']?? 0);
|
||||
$parametrosRotativa->rotativa_amarillo = intval($linea['cobAmarillo']?? 0);
|
||||
break;
|
||||
case 'lp_cubierta':
|
||||
$uso = 'cubierta';
|
||||
@ -168,42 +186,51 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
||||
$tipo = 'colorhq';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$opciones_papel = PresupuestoService::get_opciones_papel($uso, $isColor);
|
||||
if (strpos($linea['row_id'], 'lp_rot') !== 0) {
|
||||
// The string does not start with the prefix
|
||||
$opciones_papel = PresupuestoService::get_opciones_papel($uso, $isColor);
|
||||
}
|
||||
|
||||
$datosTipolog = $linea['gotaNegro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
'negro' => intval($linea['cobNegro']) ?? 0,
|
||||
'cyan' => intval($linea['cobCyan']) ?? 0,
|
||||
'magenta' => intval($linea['cobMagenta']) ?? 0,
|
||||
'amarillo' => intval($linea['cobAmarillo']) ?? 0,
|
||||
'cg' => intval($linea['cobCG']) ?? 0,
|
||||
'gota_negro' => intval($linea['gotaNegro']) ?? 0,
|
||||
'gota_color' => intval($linea['gotaColor']) ?? 0,
|
||||
$data_temp = (object)array(
|
||||
'negro' => intval($linea['cobNegro'] ?? 0),
|
||||
'cyan' => intval($linea['cobCyan'] ?? 0),
|
||||
'magenta' => intval($linea['cobMagenta']?? 0),
|
||||
'amarillo' => intval($linea['cobAmarillo']?? 0),
|
||||
'cg' => intval($linea['cobCG'] ?? 0),
|
||||
'gota_negro' => intval($linea['gotaNegro']?? 0),
|
||||
'gota_color' => intval($linea['gotaColor']?? 0),
|
||||
);
|
||||
array_push($datosTipolog, $data);
|
||||
array_push($datosTipolog, $data_temp);
|
||||
}
|
||||
|
||||
$data['uso'] = $uso;
|
||||
$data['tipo'] = $tipo;
|
||||
$data['datosPedido'] = $datosPedido;
|
||||
$data['cliente_id'] = $cliente_id;
|
||||
$data['papel'] = $papel;
|
||||
$data['opciones_papel'] = $opciones_papel;
|
||||
$data['maquina'] = $maquina;
|
||||
$data['papel_generico'] = $papel_generico;
|
||||
$data['isColor'] = $isColor;
|
||||
$data['a_favor_fibra'] = $linea['aFavorFibra'] ?? null;
|
||||
$data['datosTipolog'] = $datosTipolog;
|
||||
$data['gramaje'] = $linea['gramaje'] ?? 0;
|
||||
$datosLinea = array();
|
||||
|
||||
$datosLinea['uso'] = $uso;
|
||||
$datosLinea['tipo'] = $tipo;
|
||||
$datosLinea['datosPedido'] = $datosPedido;
|
||||
$datosLinea['cliente_id'] = $cliente_id;
|
||||
$datosLinea['papel'] = $papel;
|
||||
if(isset($isColor))
|
||||
$datosLinea['isColor'] = $isColor;
|
||||
if(isset($opciones_papel))
|
||||
$datosLinea['opciones_papel'] = $opciones_papel;
|
||||
if(isset($parametrosRotativa))
|
||||
$datosLinea['parametrosRotativa'] = $parametrosRotativa;
|
||||
if(isset($paginas))
|
||||
$datosLinea['paginas'] = $paginas;
|
||||
$datosLinea['maquina'] = $maquina;
|
||||
$datosLinea['papel_generico'] = $papel_generico;
|
||||
$datosLinea['a_favor_fibra'] = $linea['aFavorFibra'] ?? null;
|
||||
$datosLinea['datosTipolog'] = $datosTipolog;
|
||||
$datosLinea['gramaje'] = $linea['gramaje'] ?? 0;
|
||||
|
||||
if ($linea['row_id'] != 'lp_rot_bn' && $linea['row_id'] != 'lp_rot_color') {
|
||||
$linea_coste = PresupuestoService::getLineaPresupuestoPlana($data);
|
||||
$linea_coste = PresupuestoService::getLineaPresupuestoPlana($datosLinea);
|
||||
} else {
|
||||
$linea_coste = [0];
|
||||
$linea_coste = PresupuestoService::getLineaPresupuestoRotativa($datosLinea);
|
||||
}
|
||||
|
||||
if (empty($linea))
|
||||
@ -217,17 +244,24 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
||||
$linea_coste['fields']['precio_click_pedido'] = 0;
|
||||
if ($linea_coste['fields']['tipo_maquina'] == 'inkjet') {
|
||||
$linea_coste['fields']['precio_tinta'] = 0;
|
||||
$linea_coste['fields']['totalCorte'] = 0;
|
||||
if (strpos($linea['row_id'], 'lp_rot') === 0) {
|
||||
$linea_coste['fields']['total_corte'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
$linea_coste['total_coste'] = $linea_coste['fields']['precio_pedido'] +
|
||||
$linea_coste['fields']['precio_impresion_horas'] +
|
||||
$linea_coste['fields']['precio_click_pedido'];
|
||||
if ($linea_coste['fields']['tipo_maquina'] == 'inkjet') {
|
||||
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['precio_tinta'] +
|
||||
$linea_coste['fields']['totalCorte'];
|
||||
$linea_coste['fields']['precio_tinta'];
|
||||
if (strpos($linea['row_id'], 'lp_rot') === 0) {
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['total_corte'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$linea_coste['total_margen'] = $linea_coste['fields']['margen_papel_pedido'] +
|
||||
$linea_coste['fields']['margen_impresion_horas'] +
|
||||
|
||||
@ -4,6 +4,8 @@ namespace App\Services;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
use App\Models\Clientes\ClientePreciosModel;
|
||||
|
||||
|
||||
|
||||
@ -174,28 +176,137 @@ class PresupuestoService extends BaseService
|
||||
|
||||
return $linea;
|
||||
}
|
||||
/**
|
||||
* @param mixed $uso
|
||||
* contiene algun parametro de la lista ['interior,'cubierta','sobrecubierta']
|
||||
* @param mixed $tipo
|
||||
* contiene algun parametro de la lista ['negro','color','negrohq','bicolor','colorhq']
|
||||
* @param mixed $datosPedido
|
||||
* objeto con la siguiente extructura:
|
||||
* -> paginas: numero de paginas por libro
|
||||
* -> tirada: numero de unidades a imprimir
|
||||
* -> merma: unidades que se añaden a la tirada
|
||||
*
|
||||
* @param mixed $maquina
|
||||
* objeto con la siguiente estructura:
|
||||
* -> id: el id de la maquina
|
||||
* -> nombre: nombre de la maquina
|
||||
* -> ancho_impresion: valor maximo del ancho para imprimir
|
||||
* -> alto_impresion: valor maximo del alto para imprimir
|
||||
* @param mixed $papel_impresion
|
||||
* @param mixed $tarifa
|
||||
*
|
||||
* @return [type]
|
||||
*/
|
||||
|
||||
|
||||
public static function getLineaPresupuestoRotativa($data)
|
||||
{
|
||||
|
||||
$uso = $data['uso'];
|
||||
$tipo = $data['tipo'];
|
||||
$datosPedido = $data['datosPedido'];
|
||||
$cliente_id = $data['cliente_id'];
|
||||
$papel = $data['papel'];
|
||||
$maquina = $data['maquina'];
|
||||
$papel_generico = $data['papel_generico'];
|
||||
$parametrosRotativa = $data['parametrosRotativa'];
|
||||
$gramaje = $data['gramaje'];
|
||||
$paginas = $data['paginas'];
|
||||
|
||||
$tarifamodel = new MaquinasTarifasImpresionModel();
|
||||
|
||||
$resultado_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo) ? 'color' : $tipo);
|
||||
if($resultado_tarifa == null){
|
||||
$info = [
|
||||
'maquina_id' => $maquina->maquina_id,
|
||||
'uso' => $uso,
|
||||
'tipo' => is_array($tipo) ? 'color' : $tipo
|
||||
];
|
||||
log_message("error","No se ha encontrado tarifa para la maquina {maquina_id} y el uso {uso} y el tipo {tipo}", $info);
|
||||
return [];
|
||||
}
|
||||
else{
|
||||
$tarifaId = $resultado_tarifa[0];
|
||||
$tarifa = $resultado_tarifa[1];
|
||||
$tarifa_margen = $resultado_tarifa[2];
|
||||
}
|
||||
|
||||
if (!is_float($tarifa)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// precio del pliego de impresion
|
||||
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
|
||||
|
||||
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas);
|
||||
|
||||
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
|
||||
|
||||
$linea['fields']['precios_pliegos'] = $precio_pliego_impresion + $margen_pliego_impresion;
|
||||
|
||||
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
||||
// Precio papel pedido
|
||||
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
||||
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);;
|
||||
|
||||
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
||||
$linea['fields']['maquina'] = $maquina->maquina;
|
||||
$linea['fields']['maquina_id'] = $maquina->maquina_id;
|
||||
$linea['fields']['maquina_velocidad'] = $maquina->velocidad;
|
||||
$linea['fields']['tipo_maquina'] = 'inkjet';
|
||||
$linea['fields']['papel_impresion'] = $papel->nombre;
|
||||
$linea['fields']['papel_impresion_id'] = $papel->id;
|
||||
$linea['fields']['paginas'] = $datosPedido->paginas;
|
||||
$linea['fields']['paginas_color'] = $paginas->color;
|
||||
$linea['fields']['gramaje'] = $gramaje;
|
||||
$linea['fields']['papel_generico_id'] = $papel_generico['id'];
|
||||
$linea['fields']['papel_generico'] = $papel_generico['nombre'];
|
||||
|
||||
$linea['fields']['posicion_formas'] = $parametrosRotativa->a_favor_fibra ? 'h' : 'v';
|
||||
$linea['fields']['num_formas_horizontales'] = floor($linea['fields']['factor_anchura']);
|
||||
$linea['fields']['num_formas_verticales'] = floor($linea['fields']['factor_altura']);
|
||||
|
||||
|
||||
|
||||
$linea['fields']['datosTipologias'] = //$datosTipologias[0];
|
||||
(Object)array(
|
||||
'gota_negro' => $parametrosRotativa->rotativa_gota_negro,
|
||||
'gota_color' => $parametrosRotativa->rotativa_gota_color,
|
||||
'negro' => $parametrosRotativa->rotativa_negro,
|
||||
'cyan' => $parametrosRotativa->rotativa_cyan,
|
||||
'magenta' => $parametrosRotativa->rotativa_magenta,
|
||||
'amarillo' => $parametrosRotativa->rotativa_amarillo
|
||||
);
|
||||
|
||||
// impresion
|
||||
$linea['fields']['precio_click'] = $tarifa * (1 + $tarifa_margen / 100.0);
|
||||
$linea['fields']['precio_click_margen'] = $tarifa * ($tarifa_margen / 100.0);
|
||||
$linea['fields']['precio_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click'];
|
||||
$linea['fields']['margen_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click_margen'];
|
||||
|
||||
$linea['fields']['tiempo_maquina'] = PresupuestoService::getTiempoMaquina(
|
||||
$linea['fields']['precio_click_pedido'],
|
||||
$linea['fields']['precio_click'],
|
||||
$maquina->velocidad
|
||||
);
|
||||
|
||||
|
||||
$clientePreciosModel = new ClientePreciosModel();
|
||||
$config = (object)[
|
||||
"tipo" => $uso,
|
||||
"tipo_maquina" => 'inkjet',
|
||||
"tipo_impresion" => $tipo
|
||||
];
|
||||
$tiempo = PresupuestoService::getHorasMaquina(
|
||||
$linea['fields']['precio_click_pedido'],
|
||||
$linea['fields']['precio_click'],
|
||||
$maquina->velocidad
|
||||
);
|
||||
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
||||
|
||||
if (is_null($precio_hora)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$linea['fields']['precio_hora'] = $precio_hora * (1 + $margen_precio_hora / 100.0);
|
||||
$linea['fields']['precio_hora_margen'] = $precio_hora * ($margen_precio_hora / 100.0);
|
||||
$linea['fields']['horas_maquina'] = $tiempo;
|
||||
$linea['fields']['precio_impresion_horas'] = $linea['fields']['precio_hora'] * $tiempo;
|
||||
$linea['fields']['margen_impresion_horas'] = $linea['fields']['precio_hora_margen'] * $tiempo;
|
||||
|
||||
// total linea rotativa
|
||||
//$linea['fields']['total_impresion'] = $linea['fields']['precio_pedido'] + $linea['fields']['precio_click_pedido'] + $linea['fields']['precio_tinta'] +
|
||||
// $linea['fields']['total_corte'];
|
||||
$linea['fields']['total_impresion'] =
|
||||
floatval($linea['fields']['precio_pedido']) + // papel
|
||||
floatval($linea['fields']['precio_click_pedido']) + // precio clicks del pedido
|
||||
floatval($linea['fields']['precio_impresion_horas']) + // horas de maquina
|
||||
floatval($linea['fields']['precio_tinta']) + // tinta
|
||||
floatval($linea['fields']['total_corte']); // corte
|
||||
|
||||
return $linea;
|
||||
}
|
||||
|
||||
|
||||
public static function getCostesLinea($uso, $datosPedido, $maquina, $papel_impresion, $opciones_papel, $tarifa, $tarifa_margen, $forzar_a_favor_fibra = false)
|
||||
{
|
||||
$response['fields'] = [];
|
||||
@ -432,7 +543,10 @@ class PresupuestoService extends BaseService
|
||||
$data = [];
|
||||
|
||||
$data['pulgada'] = 1 / 1000000000000.0;
|
||||
$data['resolucion'] = 600;
|
||||
if($maquina->maquina_id == 91 || $maquina->maquina_id == 99 || $maquina->maquina_id == 114 || $maquina->maquina_id == 98)
|
||||
$data['resolucion'] = 1200;
|
||||
else
|
||||
$data['resolucion'] = 600;
|
||||
$data['superficie'] = round((($datosPedido->ancho / 2.54) / 10) * (($datosPedido->alto / 2.54) / 10), 2);
|
||||
|
||||
$data['num_gotas_negro'] = round($data['superficie'] * $data['resolucion'] * $data['resolucion'] * ($parametros->rotativa_negro / 100.0), 0);
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<div id='alert-envios'></div>
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestoDireccionesForm") ?>
|
||||
<div id='rowTable' class='row'>
|
||||
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2" style="width: 95%;">
|
||||
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="lp-header">Tarifa_id</th>
|
||||
@ -86,7 +86,7 @@ const lastColNr_direcciones = $('#tableOfDireccionesEnvio').find("tr:first th").
|
||||
const actionBtns_direcciones = function(data) {
|
||||
return `
|
||||
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${data.id}"></i></a></span>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm delete-add-row mx-2"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
|
||||
`;
|
||||
};
|
||||
|
||||
@ -117,8 +117,7 @@ function updateTablaEnvios(){
|
||||
|
||||
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
|
||||
datos_tarifa.peso = peso_envio;
|
||||
console.log(datos_tarifa.precio)
|
||||
|
||||
|
||||
tableEnvios.row(rowIdx)
|
||||
.data({
|
||||
'tarifa_id': datos_tarifa.id,
|
||||
@ -141,9 +140,7 @@ function updateTablaEnvios(){
|
||||
})
|
||||
.draw();
|
||||
|
||||
checkInsertar()
|
||||
updateTotales(false, false, true)
|
||||
|
||||
checkInsertar()
|
||||
}
|
||||
else{
|
||||
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
||||
@ -157,7 +154,6 @@ $(document).on('click', '.delete-add-row', function(e) {
|
||||
.remove()
|
||||
.draw();
|
||||
checkInsertar()
|
||||
updateTotales(false, false, true)
|
||||
})
|
||||
|
||||
$(document).on('click', '.btn-edit-add', function(e) {
|
||||
@ -279,6 +275,7 @@ var tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
|
||||
} );
|
||||
|
||||
|
||||
|
||||
function checkInsertar(){
|
||||
cantidad_total = 0
|
||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
@ -382,7 +379,9 @@ function load_datos_envios(){
|
||||
})
|
||||
.draw();
|
||||
checkInsertar()
|
||||
|
||||
});
|
||||
$('#tableOfDireccionesEnvio').bind('draw.dt', update_tiradas_alternativas);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -259,8 +259,8 @@ async function get_servPreimpresion_tiradasAlternativas(){
|
||||
const values = await response.json();
|
||||
yeniden(values[window.csrf_token]);
|
||||
values.lines.forEach((line) => {
|
||||
serviciosPreimpresion.coste += parseFloat(line[0].total);
|
||||
serviciosPreimpresion.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||
serviciosPreimpresion.coste += parseFloat(line[0].precio);
|
||||
serviciosPreimpresion.margen += parseFloat(line[0].precio)*parseFloat(line[0].margen)/100.0;
|
||||
});
|
||||
return serviciosPreimpresion;
|
||||
}
|
||||
@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<div id="serv-acabado-error">
|
||||
</div>
|
||||
<table id="tableOfServiciosAcabado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<table id="tableOfServiciosAcabado" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Presupuestos.id') ?></th>
|
||||
@ -99,7 +99,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||
<button id="insertar_serv_acabado" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||
<button id="insertar_serv_acabado" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -111,7 +111,7 @@
|
||||
</div>
|
||||
<div id="serv-preimpresion-error">
|
||||
</div>
|
||||
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover" style="width: 100%;">
|
||||
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Presupuestos.id') ?></th>
|
||||
@ -136,7 +136,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||
<button id="insertar_serv_preimpresion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||
<button id="insertar_serv_preimpresion" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -148,7 +148,7 @@
|
||||
<div id="serv-enc-error">
|
||||
</div>
|
||||
|
||||
<table id="tableOfServiciosEncuadernacion" class="table dt-responsive dataTable" style="width: 100%;">
|
||||
<table id="tableOfServiciosEncuadernacion" class="table dt-responsive dataTable tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Presupuestos.id') ?></th>
|
||||
@ -176,7 +176,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||
<button id="insertar_serv_enc" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||
<button id="insertar_serv_enc" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -188,7 +188,7 @@
|
||||
</div>
|
||||
<div id="serv-manipulado-error">
|
||||
</div>
|
||||
<table id="tableOfServiciosManipulado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<table id="tableOfServiciosManipulado" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Presupuestos.id') ?></th>
|
||||
@ -214,7 +214,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||
<button id="insertar_serv_manipulado" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||
<button id="insertar_serv_manipulado" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -521,9 +521,6 @@
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
"drawCallback": function(settings ) {
|
||||
updateTotales(false, true, false)
|
||||
}
|
||||
});
|
||||
|
||||
function init_servicio_acabado(){
|
||||
@ -612,7 +609,7 @@
|
||||
'<span id="precio_unidad_acabado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
|
||||
'<input class="update-totales" id="precio_total_acabado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||
'<span style="display: none;" class="update-totales" id="acabado_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'" data-text="' + nombre +'"></i></a>'
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2 tiradas-alternativas" data-id="' + row.tarifa_id +'" data-text="' + nombre +'"></i></a>'
|
||||
]).draw(false)
|
||||
});
|
||||
|
||||
@ -730,10 +727,7 @@
|
||||
select: false,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
"drawCallback": function(settings ) {
|
||||
updateTotales(false, true, false)
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -803,6 +797,7 @@
|
||||
});
|
||||
$('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', proveedor_enc_event)
|
||||
});
|
||||
|
||||
check_serv_enc_error()
|
||||
|
||||
}
|
||||
@ -1006,9 +1001,6 @@
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
"drawCallback": function(settings ) {
|
||||
updateTotales(false, true, false)
|
||||
}
|
||||
});
|
||||
|
||||
function init_servicio_manipulado(){
|
||||
@ -1163,9 +1155,6 @@
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
"drawCallback": function(settings ) {
|
||||
updateTotales(false, true, false)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<div id="divAlarmasLineasPresupuesto"></div>
|
||||
<!----------------------------------------------------------------------------->
|
||||
|
||||
<table id="tableLineasPresupuesto" class="comparator-table table dt-responsive dataTable" style="width: 100%;">
|
||||
<table id="tableLineasPresupuesto" class="comparator-table table dt-responsive dataTable tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10px"></th>
|
||||
@ -685,7 +685,7 @@ $(document).on('click', '.btn-delete-lp', function(e) {
|
||||
tableLineasPresupuesto.row( row )
|
||||
.remove()
|
||||
.draw();
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
if(data.row_id == 'lp_guardas')
|
||||
@ -1244,7 +1244,7 @@ $('#btn_addLinea').on("click", function (e) {
|
||||
// de los checkboxes que esten seleccionados
|
||||
function update_total_linea(e){
|
||||
|
||||
updateTotales(true, false, false)
|
||||
|
||||
}
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -1548,7 +1548,7 @@ function fill_lp_bn(row, fromComparator=false){
|
||||
$('#lp_bn_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -1877,7 +1877,7 @@ function fill_lp_color(row, fromComparator=false){
|
||||
$('#lp_color_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -2203,7 +2203,7 @@ function fill_lp_bnhq(row, fromComparator=false){
|
||||
$('#lp_bnhq_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -2532,7 +2532,7 @@ function fill_lp_colorhq(row, fromComparator=false){
|
||||
$('#lp_colorhq_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -2871,7 +2871,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
|
||||
$('#lp_rot_bn_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -3214,7 +3214,7 @@ function fill_lp_rot_color(row, fromComparador=false){
|
||||
$('#lp_rot_color_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -3491,7 +3491,7 @@ function fill_lp_cubierta(row, fromComparador=false){
|
||||
check_update_sobrecubierta()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
}
|
||||
@ -3754,7 +3754,7 @@ function fill_lp_sobrecubierta(row, fromComparador=false){
|
||||
$('#lp_sobrecubierta_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
}
|
||||
@ -3949,7 +3949,7 @@ function fill_lp_guardas(row, fromComparador=false){
|
||||
$('#lp_guardas_checkPapel').change()
|
||||
|
||||
calcular_mermas()
|
||||
updateTotales(true, false, false)
|
||||
|
||||
updateTablaEnvios()
|
||||
|
||||
// Si existe cubierta, hay que actualizar con el valor del lomo
|
||||
@ -4402,7 +4402,7 @@ function updateLineasPresupuesto(){
|
||||
checkComparadorInt(false, false, false, true)
|
||||
}
|
||||
else if(this.id.endsWith('lp_rot_color')){
|
||||
checkComparadorInt(false,true, false, true);
|
||||
checkComparadorInt(true,false, false, true);
|
||||
}
|
||||
else if(this.id.endsWith('_cubierta')){
|
||||
checkComparadorCubierta(true)
|
||||
|
||||
@ -250,10 +250,8 @@ $('#saveDireccionEnvio').on('click', function(){
|
||||
})
|
||||
}
|
||||
checkInsertar()
|
||||
updateTotales(false, false, true)
|
||||
$('#addressForm').modal("hide");
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
||||
|
||||
@ -83,6 +83,17 @@
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
|
||||
$('.update-resumen-presupuesto').each(function() {
|
||||
if ($(this).is('table')) {
|
||||
if($(this).attr('id') == 'tableLineasPresupuesto')
|
||||
$(this).bind('draw.dt',{updateLP:true, updateServicios:false, updateEnvio:false}, updateTotales);
|
||||
else if ($(this).attr('id') == 'tableOfServiciosAcabado' || $(this).attr('id') == 'tableOfServiciosPreimpresion' ||
|
||||
$(this).attr('id') == 'tableOfServiciosEncuadernacion' || $(this).attr('id') == 'tableOfServiciosManipulado')
|
||||
$(this).bind('draw.dt',{updateLP:false, updateServicios:true, updateEnvio:false}, updateTotales);
|
||||
else if ($(this).attr('id') == 'tableOfDireccionesEnvio')
|
||||
$(this).bind('draw.dt',{updateLP:false, updateServicios:false, updateEnvio:true}, updateTotales);
|
||||
}
|
||||
});
|
||||
|
||||
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
|
||||
var totalPapel = 0
|
||||
|
||||
@ -22,14 +22,49 @@ var tableTiradas;
|
||||
initTableTiradas();
|
||||
fill_tiradas_alternativas();
|
||||
|
||||
$('.tiradas-alternativas').each(function() {
|
||||
if ($(this).is('input')) {
|
||||
$(this).bind('change', update_tiradas_alternativas);
|
||||
} else if ($(this).is('button')) {
|
||||
$(this).bind('click', update_tiradas_alternativas);
|
||||
} else if ($(this).is('table')) {
|
||||
$(this).bind('draw.dt', update_tiradas_alternativas);
|
||||
}
|
||||
else{
|
||||
// para los botones de borrar
|
||||
$(this).bind('click', update_tiradas_alternativas);
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
||||
function update_tiradas_alternativas(){
|
||||
// se obtiene la primera columna de la tabla de tiradas
|
||||
const data = tableTiradas.rows().data().toArray();
|
||||
// se borra la tabla de tiradas
|
||||
tableTiradas.clear().draw();
|
||||
const tiradas = data.map(row => row.tirada);
|
||||
// por cada tirada, se añade una fila a la tabla de tiradas
|
||||
tiradas.forEach(tirada => {
|
||||
add_tirada_alternativa(tirada);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Evento de añadir una tirada alternativa
|
||||
$('#add_tirada_alt').on('click', function () {
|
||||
|
||||
// se comprueba que la tirada no existe ya en la tabla
|
||||
const tirada_alt = parseInt($('#tirada_alt').val());
|
||||
add_tirada_alternativa(tirada_alt);
|
||||
});
|
||||
|
||||
|
||||
// Funcion para añadir una tirada alternativa
|
||||
function add_tirada_alternativa(tirada_alt) {
|
||||
|
||||
// se comprueba que la tirada no existe ya en la tabla
|
||||
const exists = tableTiradas.rows().data().toArray().some(row => row.tirada == tirada_alt);
|
||||
const isPOD = parseInt($('#tirada').val())<= parseInt($('#POD').val());
|
||||
|
||||
@ -40,8 +75,8 @@ $('#add_tirada_alt').on('click', function () {
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
let datos = {
|
||||
tirada: $('#tirada_alt').val(),
|
||||
merma: get_merma_tirada_alternativa($('#tirada_alt').val()),
|
||||
tirada: tirada_alt,
|
||||
merma: get_merma_tirada_alternativa(tirada_alt),
|
||||
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
||||
json_tiradas: generate_json_tiradas(),
|
||||
ancho: dimension.ancho,
|
||||
@ -75,7 +110,6 @@ $('#add_tirada_alt').on('click', function () {
|
||||
if(data.lineas.length >0){
|
||||
// Se cogen los valores de la linea con los datos correspondientes
|
||||
$.each(data.lineas, function(key, value) {
|
||||
|
||||
coste_total += value.total_coste;
|
||||
margen_total += value.total_margen;
|
||||
});
|
||||
@ -148,9 +182,10 @@ $('#add_tirada_alt').on('click', function () {
|
||||
}
|
||||
$('#alert-tiradas_alt').html(htmlString);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Función para obtener el lomo exterior
|
||||
function getLomoExterior(){
|
||||
let lomoTotal = 0
|
||||
|
||||
Reference in New Issue
Block a user