mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into refactor/sk-21
This commit is contained in:
@ -72,6 +72,7 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function (
|
||||
$routes->group('acabados', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) {
|
||||
|
||||
$routes->get('', 'TarifaAcabados::index', ['as' => 'tarifaAcabadoList']);
|
||||
$routes->get('gettarifas', 'TarifaAcabados::getSelect2');
|
||||
$routes->match(['get', 'post'], 'add', 'TarifaAcabados::add', ['as' => 'tarifaAcabadoAdd']);
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'TarifaAcabados::edit/$1', ['as' => 'tarifaAcabadoEdit']);
|
||||
$routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
|
||||
@ -275,7 +276,7 @@ $routes->group('papelesimpresion', ['namespace' => 'App\Controllers\Configuracio
|
||||
$routes->post('datatable', 'Papelesimpresion::datatable', ['as' => 'dataTableOfPapelesImpresion']);
|
||||
$routes->post('allmenuitems', 'Papelesimpresion::allItemsSelect', ['as' => 'select2ItemsOfPapelesImpresion']);
|
||||
$routes->post('menuitems', 'Papelesimpresion::menuItems', ['as' => 'menuItemsOfPapelesImpresion']);
|
||||
$routes->post('duplicate/(:num)','Papelesimpresion::duplicate/$1',['as' => 'duplicatePapelImpresion']);
|
||||
$routes->post('duplicate/(:num)', 'Papelesimpresion::duplicate/$1', ['as' => 'duplicatePapelImpresion']);
|
||||
});
|
||||
$routes->resource('papelesimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesimpresion', 'except' => 'show,new,create,update']);
|
||||
|
||||
@ -308,7 +309,7 @@ $routes->group('maquinas', ['namespace' => 'App\Controllers\Configuracion'], fun
|
||||
$routes->post('datatable', 'Maquinas::datatable', ['as' => 'dataTableOfMaquinas']);
|
||||
$routes->post('allmenuitems', 'Maquinas::allItemsSelect', ['as' => 'select2ItemsOfMaquinas']);
|
||||
$routes->post('menuitems', 'Maquinas::menuItems', ['as' => 'menuItemsOfMaquinas']);
|
||||
$routes->post('duplicate/(:num)', 'Maquinas::duplicate/$1',['as' => 'duplicateMaquina']);
|
||||
$routes->post('duplicate/(:num)', 'Maquinas::duplicate/$1', ['as' => 'duplicateMaquina']);
|
||||
|
||||
$routes->get('select', 'Maquinas::select', ['as' => 'selectMaquinas']);
|
||||
});
|
||||
|
||||
@ -72,9 +72,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -84,36 +84,36 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else :
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
@ -133,20 +133,20 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$papelGenerico = $this->model->find($id);
|
||||
|
||||
if ($papelGenerico == false) :
|
||||
if ($papelGenerico == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -159,24 +159,24 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->getPost('show_in_client_special') == null) {
|
||||
$sanitizedData['show_in_client_special'] = false;
|
||||
}
|
||||
|
||||
if($sanitizedData['show_in_client_special']){
|
||||
|
||||
if ($sanitizedData['show_in_client_special']) {
|
||||
$sanitizedData['show_in_client'] = true;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
@ -186,17 +186,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $papelGenerico->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.';
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else :
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
@ -210,7 +210,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelGenerico.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
$this->viewData['usingServerSideDataTable'] = true;
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
@ -297,15 +297,14 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
public function getPapelCliente()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
|
||||
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
|
||||
$POD = null;
|
||||
if($tirada != null){
|
||||
if ($tirada != null) {
|
||||
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
if(intval($tirada) <= intval($POD_value)){
|
||||
if (intval($tirada) <= intval($POD_value)) {
|
||||
$POD = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$POD = false;
|
||||
}
|
||||
}
|
||||
@ -313,17 +312,38 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
$selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null;
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
|
||||
|
||||
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
|
||||
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
$lomo = floatval($this->request->getGet('lomo') ?? 0);
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
|
||||
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
|
||||
$forSelect2 = intval($this->request->getGet('forSelect2') ?? 0);
|
||||
|
||||
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
|
||||
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
|
||||
if ($forSelect2) {
|
||||
$menu = array_map(function ($item) {
|
||||
if (isset($item->id)) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'name' => $item->nombre
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'id' => $item->gramaje,
|
||||
'name' => $item->gramaje
|
||||
];
|
||||
}
|
||||
}, $menu);
|
||||
|
||||
return $this->respond($menu);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
@ -340,23 +360,23 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function selectPapelEspecial()
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
|
||||
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
|
||||
$POD = null;
|
||||
if($tirada != null){
|
||||
if ($tirada != null) {
|
||||
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
if(intval($tirada) <= intval($POD_value)){
|
||||
if (intval($tirada) <= intval($POD_value)) {
|
||||
$POD = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$POD = false;
|
||||
}
|
||||
}
|
||||
$tipo = goSanitize($this->request->getGet('tipo'))[0];
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
|
||||
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
|
||||
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
@ -364,9 +384,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
|
||||
$tapa_dura = $this->request->getGet('tapa_dura') ?? 0;
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
$items = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
$items = array_map(function ($item) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
|
||||
@ -97,6 +97,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $proveedor, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
$values[0]->faja = $tarifa['faja'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,6 +495,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
} else {
|
||||
$data['datosLibro']['acabadoSobrecubierta']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
||||
}
|
||||
$data['datosLibro']['acabadoFaja']['id'] = $presupuesto->acabado_faja_id;
|
||||
if ($presupuesto->acabado_faja_id == 0) {
|
||||
$data['datosLibro']['acabadoFaja']['text'] = "Ninguno";
|
||||
} else {
|
||||
$data['datosLibro']['acabadoFaja']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
|
||||
}
|
||||
$data['datosLibro']['prototipo'] = $presupuesto->prototipo;
|
||||
$data['datosLibro']['ferro'] = $presupuesto->ferro;
|
||||
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
|
||||
@ -1110,7 +1116,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$tirada);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_papel_generico.nombre", $this->request->getGet("q"))
|
||||
->orLike("t1.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
@ -1174,7 +1180,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$tirada);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_papel_impresion.gramaje", $this->request->getGet("q"))
|
||||
->orLike("t2.gramaje", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
@ -540,6 +540,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $sobrecubierta,
|
||||
'datos_guardas' => $datos_guardas,
|
||||
'faja' => $faja,
|
||||
|
||||
'servicios' => $reqData['servicios'] ?? [],
|
||||
);
|
||||
@ -694,7 +695,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
|
||||
$excluirRotativa = intval($excluirRotativa);
|
||||
|
||||
$tipo = $reqData['tipo'] ??'cosido';
|
||||
$tipo = $reqData['tipo'] ?? 'cosido';
|
||||
$tipoCubierta = 'blanda'; // solapas sólo tapa blanda y sobre cubierta
|
||||
|
||||
$isColor = intval($reqData['isColor']) ?? 0;
|
||||
@ -1054,6 +1055,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $sobrecubierta,
|
||||
'datos_guardas' => $datos_guardas,
|
||||
'faja' => $faja,
|
||||
|
||||
'servicios' => $reqData['servicios'] ?? [],
|
||||
);
|
||||
@ -1241,6 +1243,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$resultado_presupuesto['info']['merma'] = $this->calcular_merma($selected_tirada, $POD);
|
||||
|
||||
$datos_presupuesto['faja'] = $faja;
|
||||
|
||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||
$id,
|
||||
$selected_tirada,
|
||||
@ -1267,6 +1271,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['cubierta']);
|
||||
if (count($resultado_presupuesto['values']['sobrecubierta']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['sobrecubierta']);
|
||||
if (count($resultado_presupuesto['values']['faja']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['faja']);
|
||||
if (count($resultado_presupuesto['values']['guardas']) > 0)
|
||||
$this->guardarLineaPresupuesto($id, $resultado_presupuesto['values']['guardas']);
|
||||
|
||||
@ -1293,6 +1299,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (is_array($faja) && intval($faja['acabado']) > 0) {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$servicio = $model->getPrecioTarifa(intval($faja['acabado']), intval($selected_tirada), -1, $POD);
|
||||
|
||||
if (count($servicio) > 0) {
|
||||
if ($servicio[0]->total > 0) {
|
||||
$this->guardarServicio($id, $servicio[0], 'acabado', false, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($resultado_presupuesto['values']['serviciosDefecto']['encuadernacion'] as $servicio) {
|
||||
$this->guardarServicio($id, $servicio, 'encuadernacion');
|
||||
@ -1475,6 +1492,21 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data['sobrecubierta']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
||||
}
|
||||
|
||||
if (array_key_exists('faja', $datos_papel)) {
|
||||
$data['faja']['papel'] = $datos_papel['faja'];
|
||||
$data['faja']['alto'] = $presupuesto->alto_faja_color;
|
||||
$data['faja']['solapas'] = 1;
|
||||
$data['faja']['solapas_ancho'] = $presupuesto->solapas_ancho_faja_color;
|
||||
$data['faja']['acabado']['id'] = $presupuesto->acabado_sobrecubierta_id;
|
||||
if ($presupuesto->acabado_faja_id == 0) {
|
||||
$data['faja']['acabado']['text'] = "Ninguno";
|
||||
} else {
|
||||
$data['faja']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_faja_id)->nombre;
|
||||
}
|
||||
} else {
|
||||
$data['faja'] = [];
|
||||
}
|
||||
|
||||
$data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : [];
|
||||
|
||||
$modelLinea = new PresupuestoLineaModel();
|
||||
@ -1586,11 +1618,6 @@ 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);
|
||||
@ -1684,7 +1711,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
protected function guardarServicio($presupuestoId, $servicio, $tipo, $cubierta = false, $sobrecubierta = false)
|
||||
protected function guardarServicio($presupuestoId, $servicio, $tipo, $cubierta = false, $sobrecubierta = false, $faja = false)
|
||||
{
|
||||
|
||||
if ($tipo == 'encuadernacion') {
|
||||
@ -1695,8 +1722,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'tarifa_encuadernado_id' => $servicio->tarifa_id,
|
||||
'proveedor_id' => $servicio->proveedor_id,
|
||||
'tiempo' => $servicio->tiempo,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'precio_total' => round($servicio->total, 2),
|
||||
'precio_unidad' => round($servicio->precio_unidad, 2),
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
|
||||
@ -1712,7 +1739,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_extra_id' => $servicio->tarifa_id,
|
||||
'precio' => $servicio->precio,
|
||||
'precio' => round($servicio->precio, 2),
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
@ -1728,6 +1755,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'proveedor_id' => $servicio->proveedor_id,
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $sobrecubierta,
|
||||
'faja' => $faja,
|
||||
];
|
||||
$model->insert($data);
|
||||
} else if ($tipo == 'manipulado') {
|
||||
@ -1736,8 +1764,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data = [
|
||||
'presupuesto_id' => $presupuestoId,
|
||||
'tarifa_manipulado_id' => $servicio->tarifa_id,
|
||||
'precio_total' => $servicio->total,
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'precio_total' => round($servicio->total, 2),
|
||||
'precio_unidad' => round($servicio->precio_unidad, 2),
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
$model->insert($data);
|
||||
@ -1764,7 +1792,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$margen = 0;
|
||||
|
||||
|
||||
$peso_envio = round(floatval(floatval($peso) * floatval($unidades) / 1000.0)); // peso libro * unidades y se pasa a kilogramos
|
||||
$peso_envio = round(floatval(floatval($peso) * floatval($unidades) / 1000.0), 3); // peso libro * unidades y se pasa a kilogramos
|
||||
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($pais_id, $cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas');
|
||||
for ($i = 0; $i < count($tarifas_envio); $i++) {
|
||||
if ($peso_envio > $tarifas_envio[$i]->peso_max || floatval($tarifas_envio[$i]->precio_max) == 0) {
|
||||
@ -1840,6 +1868,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
// Sobrecubierta
|
||||
$sobreCubierta = $datos_entrada["sobrecubierta"] ?? null;
|
||||
|
||||
// Faja
|
||||
$faja = $datos_entrada["faja"] ?? null;
|
||||
|
||||
// Guardas
|
||||
$datos_guardas = $datos_entrada['datos_guardas'] ?? [];
|
||||
|
||||
@ -1930,7 +1961,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$peso_interior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$costeInterior += round(floatval($linea['total_impresion']), 2);
|
||||
$peso_interior += floatval($linea['peso']);
|
||||
$lomo += floatval($linea['mano']);
|
||||
$info['lomo_interior'] += floatval($linea['mano']);
|
||||
@ -1990,7 +2021,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$costeInterior += round(floatval($linea['total_impresion']), 2);
|
||||
$peso_interior += floatval($linea['peso']);
|
||||
$lomo += floatval($linea['mano']);
|
||||
if ($extra_info) {
|
||||
@ -2042,7 +2073,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$coste_cubierta = 0.0;
|
||||
$peso_cubierta = 0.0;
|
||||
if (count($cubierta) > 0) {
|
||||
$coste_cubierta += floatval($cubierta['total_impresion']);
|
||||
$coste_cubierta += round(floatval($cubierta['total_impresion']), 2);
|
||||
$peso_cubierta += floatval($cubierta['peso']);
|
||||
$lomo += floatval($cubierta['mano']);
|
||||
if ($extra_info) {
|
||||
@ -2099,7 +2130,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||
$coste_servicios += round(floatval($acabadoCubierta[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($acabadoCubierta[0]->total), 2);
|
||||
$base = round(floatval($acabadoCubierta[0]->total / (1 + $acabadoCubierta[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($acabadoCubierta[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2126,7 +2163,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$linea_sobrecubierta = PresupuestoClienteService::obtenerSobrecubierta($input_data);
|
||||
|
||||
if (count($linea_sobrecubierta) > 0) {
|
||||
$coste_sobrecubierta += floatval($linea_sobrecubierta['total_impresion']);
|
||||
$coste_sobrecubierta += round(floatval($linea_sobrecubierta['total_impresion']), 2);
|
||||
$peso_sobrecubierta += floatval($linea_sobrecubierta['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
@ -2184,7 +2221,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($acabadoSobrecubierta[0]->total);
|
||||
$coste_servicios += round(floatval($acabadoSobrecubierta[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($acabadoSobrecubierta[0]->total), 2);
|
||||
$base = round(floatval($acabadoSobrecubierta[0]->total / (1 + $acabadoSobrecubierta[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($acabadoSobrecubierta[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2220,7 +2263,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$guardas = PresupuestoClienteService::obtenerGuardas($input_data);
|
||||
|
||||
if (count($guardas) > 0) {
|
||||
$coste_guardas += floatval($guardas['total_impresion']);
|
||||
$coste_guardas += round(floatval($guardas['total_impresion']), 2);
|
||||
$peso_guardas += floatval($guardas['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
@ -2251,6 +2294,98 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$coste_faja = 0.0;
|
||||
$peso_faja = 0.0;
|
||||
$linea_faja = [];
|
||||
$acabadoFaja = [];
|
||||
if (!is_null($faja) && $faja && $faja != false) {
|
||||
|
||||
$input_data['papel_generico']['id'] = $faja['papel'] ?? 0;
|
||||
$input_data['gramaje'] = $faja['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 4;
|
||||
$input_data['datosPedido']->alto = floatval($faja['alto'] ?? 0);
|
||||
$input_data['paginas_color'] = 4;
|
||||
$input_data['datosPedido']->solapas_ancho = intval($faja['solapas'] ?? 0);
|
||||
$input_data['datosPedido']->solapas = 1;
|
||||
$input_data['datosPedido']->lomo = $this->calcular_lomo([$cubierta], $input_data['datosPedido']->lomo);
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'faja';
|
||||
|
||||
$linea_faja = PresupuestoClienteService::obtenerSobrecubierta($input_data);
|
||||
|
||||
if (count($linea_faja) > 0) {
|
||||
$linea_faja['tipo_linea'] = 'lp_faja';
|
||||
$coste_faja += round(floatval($linea_faja['total_impresion']), 2);
|
||||
$peso_faja += floatval($linea_faja['peso']);
|
||||
if ($extra_info) {
|
||||
|
||||
$this->calcular_coste_linea(
|
||||
$linea_faja,
|
||||
$totalPapel,
|
||||
$margenPapel,
|
||||
$sumForFactor,
|
||||
$totalImpresion,
|
||||
$margenImpresion
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($coste_faja <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener la faja',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
// Acabado faja
|
||||
if (intval($faja['acabado']) != 0) {
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$acabadoFaja = $model->getPrecioTarifa(intval($faja['acabado']), $datosPedido->tirada, -1, $POD);
|
||||
|
||||
if (count($acabadoFaja) > 0) {
|
||||
|
||||
if ($acabadoFaja[0]->total <= 0) {
|
||||
|
||||
$input_data['tarifas_acabado_faja'] = intval($faja['acabado']);
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener acabados de faja',
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += round(floatval($acabadoFaja[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($acabadoFaja[0]->total), 2);
|
||||
$base = round(floatval($acabadoFaja[0]->total / (1 + $acabadoFaja[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($acabadoFaja[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($extra_info) {
|
||||
$totalPapel -= $margenPapel;
|
||||
$totalImpresion -= $margenImpresion;
|
||||
@ -2293,10 +2428,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
$costeServiciosDefecto += round(floatval($servicio->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($servicio->total);
|
||||
$margenServicios += floatval($servicio->total) * floatval($servicio->margen) / 100.0;
|
||||
$totalServicios += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada), 2)*$datosPedido->tirada;
|
||||
$margenServicios += round(floatval($servicio->total -$base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2328,10 +2465,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
$costeServiciosDefecto += round(floatval($servicio->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($servicio->total);
|
||||
$margenServicios += floatval($servicio->total) * floatval($servicio->margen) / 100.0;
|
||||
$totalServicios += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada), 2)*$datosPedido->tirada;
|
||||
$margenServicios += round(floatval($servicio->total -$base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2388,11 +2527,7 @@ 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
|
||||
@ -2411,18 +2546,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($servicios, $servicio_prototipo);
|
||||
if ($datos_entrada['servicios']['ferro']) // extra
|
||||
array_push($servicios, $servicio_ferro);
|
||||
if ($input_data['datosPedido']->solapas_ancho > 0)
|
||||
if ($solapasCubierta > 0)
|
||||
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
|
||||
if (!is_null($faja) && $faja && $faja != false) // Si hay faja, siempre con solapas
|
||||
array_push($servicios, $servicio_solapas_faja);
|
||||
*/
|
||||
|
||||
|
||||
foreach ($servicios as $servicio) {
|
||||
|
||||
@ -2452,10 +2582,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
} else if ($servicio->nombre == "ferro" || $servicio->nombre == "prototipo") {
|
||||
// Extra
|
||||
@ -2482,13 +2614,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->precio);
|
||||
$coste_servicios += round(floatval($resultado[0]->precio), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->precio);
|
||||
$margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->precio), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
else if ($servicio->nombre == 'solapas_cubierta' || $servicio->nombre == 'solapas_sobrecubierta' || $servicio->nombre == 'solapas_faja'){
|
||||
} else if ($servicio->nombre == 'solapas_cubierta' || $servicio->nombre == 'solapas_sobrecubierta' || $servicio->nombre == 'solapas_faja') {
|
||||
// Servicios manipulado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
'tarifa_id' => intval($servicio->id),
|
||||
@ -2515,10 +2648,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2551,10 +2686,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2586,22 +2723,68 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += floatval($resultado[0]->total);
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += floatval($resultado[0]->total);
|
||||
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
// TO-DO Faja
|
||||
if (is_array($faja) && ($faja['solapas'] > 0 && intval($linea_faja['dimension_desarrollo']['ancho']) > 630)) {
|
||||
|
||||
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4));
|
||||
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2));
|
||||
// Servicios manipulado
|
||||
$resultado = PresupuestoCLienteService::getServiciosManipulado([
|
||||
'tarifa_id' => intval($servicio_solapas_grandes_faja->id),
|
||||
'tirada' => $datosPedido->tirada,
|
||||
'POD' => $POD,
|
||||
]);
|
||||
|
||||
if ($resultado[0]->total <= 0) {
|
||||
|
||||
$errorModel = new ErrorPresupuesto();
|
||||
$errorModel->insertError(
|
||||
$datos_entrada['id'],
|
||||
auth()->user()->id,
|
||||
'No se puede obtener servicio de manupulado ' . ((string) $servicio->nombre),
|
||||
$input_data
|
||||
);
|
||||
$return_data = [
|
||||
'errors' => (object) ([
|
||||
'status' => 1
|
||||
]),
|
||||
];
|
||||
return $return_data;
|
||||
} else {
|
||||
array_push($serviciosAutomaticos, $resultado[0]);
|
||||
}
|
||||
|
||||
$coste_servicios += round(floatval($resultado[0]->total), 2);
|
||||
if ($extra_info) {
|
||||
$totalServicios += round(floatval($resultado[0]->total), 2);
|
||||
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
|
||||
}
|
||||
}
|
||||
|
||||
$total_por_tirada = $costeInterior +
|
||||
$coste_cubierta +
|
||||
$coste_sobrecubierta +
|
||||
$coste_guardas +
|
||||
$coste_faja +
|
||||
$costeServiciosDefecto + $coste_servicios;
|
||||
array_push(
|
||||
$precio_u,
|
||||
round(($total_por_tirada) / $tirada[$t], 4)
|
||||
);
|
||||
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas + $peso_faja, 2));
|
||||
|
||||
if ($extra_info) {
|
||||
$totalServicios -= $margenServicios;
|
||||
if (($margenServicios + $totalServicios) > 0) {
|
||||
$porcentajeMargenServicios = $margenServicios / ($margenServicios + $totalServicios) * 100;
|
||||
$porcentajeMargenServicios = $margenServicios / ($totalServicios) * 100;
|
||||
} else {
|
||||
$porcentajeMargenServicios = 0;
|
||||
}
|
||||
@ -2638,6 +2821,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$return_data['values']['cubierta'] = $cubierta;
|
||||
$return_data['values']['sobrecubierta'] = $linea_sobrecubierta;
|
||||
$return_data['values']['guardas'] = $guardas;
|
||||
$return_data['values']['faja'] = $linea_faja;
|
||||
$return_data['values']['serviciosDefecto']['encuadernacion'] = $servDefectoEnc;
|
||||
$return_data['values']['serviciosDefecto']['manipulado'] = $servDefectoMan;
|
||||
$return_data['values']['servicios_automaticos'] = $serviciosAutomaticos;
|
||||
@ -2676,25 +2860,25 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
if (count($linea) == 0)
|
||||
return;
|
||||
$totalPapel += $linea['precio_pedido'];
|
||||
$margenPapel += $linea['margen_papel_pedido'];
|
||||
$sumForFactor += $linea['precio_pedido'];
|
||||
$sumForFactor -= $linea['precio_pedido'];
|
||||
$totalPapel += round($linea['precio_pedido'], 2);
|
||||
$margenPapel += round($linea['margen_papel_pedido'], 2);
|
||||
$sumForFactor += round($linea['precio_pedido'], 2);
|
||||
$sumForFactor -= round($linea['precio_pedido'], 2);
|
||||
|
||||
$totalImpresion += $linea['precio_impresion_horas'];
|
||||
$totalImpresion += $linea['precio_click_pedido'];
|
||||
$sumForFactor += $linea['precio_click_pedido'];
|
||||
$totalImpresion += round($linea['precio_impresion_horas'], 2);
|
||||
$totalImpresion += round($linea['precio_click_pedido'], 2);
|
||||
$sumForFactor += round($linea['precio_click_pedido'], 2);
|
||||
|
||||
if ($linea['tipo_maquina'] == 'inkjet') {
|
||||
$totalImpresion += $linea['precio_tinta'];
|
||||
$totalImpresion += round($linea['precio_tinta'], 2);
|
||||
if (array_key_exists('total_corte', $linea)) {
|
||||
$totalImpresion += $linea['total_corte'];
|
||||
$sumForFactor += $linea['total_corte'];
|
||||
$totalImpresion += round($linea['total_corte'], 2);
|
||||
$sumForFactor += round($linea['total_corte'], 2);
|
||||
}
|
||||
}
|
||||
$margenImpresion += $linea['margen_impresion_horas'];
|
||||
$margenImpresion += $linea['margen_click_pedido'];
|
||||
$sumForFactor -= $linea['margen_click_pedido'];
|
||||
$margenImpresion += round($linea['margen_impresion_horas'], 2);
|
||||
$margenImpresion += round($linea['margen_click_pedido'], 2);
|
||||
$sumForFactor -= round($linea['margen_click_pedido'], 2);
|
||||
}
|
||||
|
||||
protected function calcular_lomo($lineas, $lomo_inicial)
|
||||
@ -2980,6 +3164,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$return_data['sobrecubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['sobrecubierta']['gramaje'] = $linea->gramaje;
|
||||
$return_data['sobrecubierta']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_faja') {
|
||||
$return_data['faja']['papel'] = $modelPapelGenerico->getNombre($linea->papel_id)['nombre'];
|
||||
$return_data['faja']['papel_id'] = $linea->papel_id;
|
||||
$return_data['faja']['gramaje'] = $linea->gramaje;
|
||||
$return_data['faja']['paginas'] = $linea->paginas;
|
||||
} else if ($linea->tipo == 'lp_guardas') {
|
||||
$return_data['guardas']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
|
||||
$return_data['guardas']['gramaje'] = $linea->gramaje;
|
||||
|
||||
@ -115,7 +115,20 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
$tarifa_id = 0;
|
||||
if(is_array($tarifa)){
|
||||
//check if $tarifa['tarifa_manipulado_id'] exists
|
||||
if(array_key_exists('tarifa_manipulado_id', $tarifa)){
|
||||
$tarifa_id = $tarifa['tarifa_manipulado_id'];
|
||||
}
|
||||
else if(array_key_exists('tarifa_id', $tarifa)){
|
||||
$tarifa_id = $tarifa['tarifa_id'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$tarifa_id = $tarifa;
|
||||
}
|
||||
$values = $model->getPrecioTarifa($tarifa_id, $tirada, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
|
||||
@ -86,6 +86,21 @@ class Presupuestopreimpresiones extends \App\Controllers\BaseResourceController
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServiciosPreimpresion($datos_tarifas)
|
||||
{
|
||||
$result = [];
|
||||
$model = model('App\Models\Presupuestos\Presupuestopreimpresiones');
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa);
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -86,6 +86,20 @@ class Presupuestoserviciosextra extends \App\Controllers\BaseResourceController
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServiciosExtra($datos_tarifas)
|
||||
{
|
||||
$result = [];
|
||||
$model = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa);
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -88,10 +88,17 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$json_data_acabados = $reqData['json_acabados'] ?? null;
|
||||
$json_data_encuadernacion = $reqData['json_encuadernaciones'] ?? null;
|
||||
$json_data_manipulado = $reqData['json_manipulado'] ?? null;
|
||||
$json_data_preimpresion = $reqData['json_preimpresion'] ?? null;
|
||||
$json_data_extra = $reqData['json_extra'] ?? null;
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
|
||||
$faja_alto = $reqData['faja_alto'] ?? 0;
|
||||
$solapas_faja = $reqData['solapas_faja'] ?? 0;
|
||||
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
|
||||
$values = [];
|
||||
|
||||
if ($json_data) {
|
||||
@ -120,14 +127,29 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
} else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
$datosPedido->isCosido = false;
|
||||
}
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta' || $linea['row_id'] == 'lp_cubierta') {
|
||||
$datosPedido->solapas =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta'] : $reqData['solapas_sobrecubierta'];
|
||||
$datosPedido->solapas_ancho =
|
||||
$linea['row_id'] == 'lp_cubierta' ? $reqData['solapas_cubierta_ancho'] : $reqData['solapas_sobrecubierta_ancho'];
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta' || $linea['row_id'] == 'lp_cubierta' || $linea['row_id'] == 'lp_faja') {
|
||||
$datosPedido->solapas = $reqData['solapas_cubierta'];
|
||||
if ($linea['row_id'] == 'lp_faja') {
|
||||
$datosPedido->solapas = 1;
|
||||
$datosPedido->alto = $faja_alto;
|
||||
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta') {
|
||||
$datosPedido->solapas = $reqData['solapas_sobrecubierta'];
|
||||
}
|
||||
$datosPedido->solapas_ancho = $reqData['solapas_cubierta_ancho'];
|
||||
if ($linea['row_id'] == 'lp_faja') {
|
||||
$datosPedido->solapas_ancho = $solapas_faja;
|
||||
} else if ($linea['row_id'] == 'lp_sobrecubierta') {
|
||||
$datosPedido->solapas_ancho = $reqData['solapas_sobrecubierta_ancho'];
|
||||
}
|
||||
$datosPedido->lomo = $reqData['lomo'];
|
||||
|
||||
$type = $linea['row_id'] == 'lp_cubierta' ? 'cubierta' : 'sobrecubierta';
|
||||
$type = 'lp_cubierta';
|
||||
if ($linea['row_id'] == 'lp_sobrecubierta') {
|
||||
$type = 'lp_sobrecubierta';
|
||||
} else if ($linea['row_id'] == 'lp_faja') {
|
||||
$type = 'lp_faja';
|
||||
}
|
||||
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($type, $tipo_impresion_id, $datosPedido);
|
||||
@ -174,6 +196,9 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
case 'lp_sobrecubierta':
|
||||
$uso = 'sobrecubierta';
|
||||
break;
|
||||
case 'lp_faja':
|
||||
$uso = 'faja';
|
||||
break;
|
||||
case 'lp_guardas':
|
||||
$uso = 'guardas';
|
||||
break;
|
||||
@ -185,7 +210,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
break;
|
||||
}
|
||||
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'guardas') {
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja' || $uso == 'guardas') {
|
||||
$isColor = true;
|
||||
$isHq = true;
|
||||
$tipo = 'colorhq';
|
||||
@ -288,10 +313,10 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$result = $acabados->getServiciosAcabados($json_data_acabados, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,10 +331,10 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$result = $encuadernacion->getServiciosEncuadernacion($json_data_encuadernacion, $reqData['tirada'], $reqData['paginas'], $reqData['ancho'], $reqData['alto'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,10 +348,44 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$result = $manipulados->getServiciosManipulado($json_data_manipulado, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($json_data_preimpresion){
|
||||
$json_data_preimpresion = json_decode($json_data_preimpresion, true);
|
||||
if (count($json_data_preimpresion) > 0) {
|
||||
$preimpresion = new Presupuestopreimpresiones();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $preimpresion->getServiciosPreimpresion($json_data_preimpresion);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($json_data_extra){
|
||||
$json_data_extra = json_decode($json_data_extra, true);
|
||||
if (count($json_data_extra) > 0) {
|
||||
$extra = new Presupuestoserviciosextra();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $extra->getServiciosExtra($json_data_extra, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$servicios->coste += round(floatval($servicio->total), 2);
|
||||
$base = round(floatval($servicio->total / (1 + $servicio->margen / 100.0)), 2);
|
||||
$base = round(floatval($base / $datosPedido->tirada) , 2)* $datosPedido->tirada;
|
||||
$servicios->margen += round(floatval($servicio->total - $base), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,8 +398,8 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$peso_libro = floatval($reqData['peso_libro']);
|
||||
// el primer envio con la tirada base
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro/1000.0, "cajas");
|
||||
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro/1000.0);
|
||||
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro / 1000.0, "cajas");
|
||||
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro / 1000.0);
|
||||
$coste_envio += $resultado->coste;
|
||||
$margen_envio += $resultado->margen;
|
||||
|
||||
@ -348,7 +407,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$json_envios = json_decode($json_envios, true);
|
||||
if (count($json_envios) > 0) {
|
||||
//la primera linea es el envio base
|
||||
for($i = 1; $i < count($json_envios); $i++) {
|
||||
for ($i = 1; $i < count($json_envios); $i++) {
|
||||
|
||||
$porcentaje = ($json_envios[$i]['cantidad']) / $tirada_base * 100.0;
|
||||
$cantidad = floor($reqData['tirada'] * $porcentaje / 100.0);
|
||||
@ -401,7 +460,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$m = (($envio->precio_max - $envio->precio_min) / ($envio->peso_max - $envio->peso_min));
|
||||
$b = $envio->precio_max - $m * $envio->peso_max;
|
||||
$coste_envio = number_format($m * $peso_envio + $b, 2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$margen_envio += $coste_envio * $envio->margen / 100.0;
|
||||
|
||||
@ -26,13 +26,13 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$model = model("\App\Models\Clientes\ClientePreciosModel");
|
||||
/*$model = model("\App\Models\Clientes\ClientePreciosModel");
|
||||
$model->debug_all_clientes_to_defecto();
|
||||
echo '<pre>';
|
||||
echo 'OK';
|
||||
echo '</pre>';
|
||||
echo '</pre>';*/
|
||||
|
||||
//xdebug_info();
|
||||
xdebug_info();
|
||||
|
||||
|
||||
|
||||
|
||||
@ -15,10 +15,13 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
"tarifa_acabado_id" => null,
|
||||
"proveedor_id" => null,
|
||||
"precio_unidad" => null,
|
||||
"importe_minimo" => null,
|
||||
"importe_fijo" => null,
|
||||
"precio_total" => null,
|
||||
"margen" => null,
|
||||
"cubierta" => null,
|
||||
"sobrecubierta" => null,
|
||||
"faja" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
@ -27,10 +30,12 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
"tarifa_acabado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"precio_unidad" => "float",
|
||||
"precio_total" => "float",
|
||||
"importe_minimo" => "float",
|
||||
"importe_fijo" => "float",
|
||||
"margen" => "float",
|
||||
"cubierta" => "int",
|
||||
"sobrecubierta" => "int",
|
||||
"faja" => "int",
|
||||
];
|
||||
|
||||
public function maquinas() : array
|
||||
|
||||
@ -104,6 +104,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
'excluir_rotativa' => null,
|
||||
"acabado_cubierta_id" => null,
|
||||
"acabado_sobrecubierta_id" => null,
|
||||
"acabado_faja_id" => null,
|
||||
"is_duplicado" => false,
|
||||
'paginas_color_consecutivas' => null,
|
||||
'papel_interior_diferente' => null,
|
||||
@ -176,6 +177,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
'excluir_rotativa' => "?boolean",
|
||||
"acabado_cubierta_id" => "int",
|
||||
"acabado_sobrecubierta_id" => "int",
|
||||
"acabado_faja_id" => "int",
|
||||
"is_duplicado" => "boolean",
|
||||
'paginas_color_consecutivas' => "boolean",
|
||||
'papel_interior_diferente' => "boolean",
|
||||
|
||||
@ -71,6 +71,7 @@ return [
|
||||
'acabadosExteriores' => 'Acabados exteriores',
|
||||
'acabadoCubierta' => 'Acabado Cubierta',
|
||||
'acabadoSobrecubierta' => 'Acabado Sobrecubierta',
|
||||
'acabadoFaja' => 'Acabado Faja',
|
||||
'cosido' => 'Cosido',
|
||||
'ferro' => 'Ferro',
|
||||
'ferroDigital' => 'Ferro Digital',
|
||||
@ -125,6 +126,7 @@ return [
|
||||
'faja' => 'Faja',
|
||||
'altoFaja' => 'Alto faja',
|
||||
'papelFaja' => 'Papel faja',
|
||||
'gramajeFaja' => 'Gramaje faja',
|
||||
'tamanioSolapasFaja' => 'Tamaño solapas faja',
|
||||
'plastificadoFaja' => 'Plastificado faja',
|
||||
'estucadoMate170gr' => 'Estucado mate 170 gr',
|
||||
@ -263,7 +265,7 @@ return [
|
||||
'formatoLibro' => "Formato libro",
|
||||
'selectCliente' => "Seleccione cliente",
|
||||
'selectPapel' => "Seleccione papel",
|
||||
|
||||
'selectGramaje' => "Seleccione gramaje",
|
||||
|
||||
// Preview
|
||||
'preview' => 'Previsualización de configuraciones',
|
||||
@ -370,6 +372,7 @@ return [
|
||||
'opcion_solapas' => 'Seleccione la opción para las solapas',
|
||||
'paginas_multiplo_4' => 'El número de páginas para <b>cosido</b> o <b>grapado</b> debe ser múltiplo de 4',
|
||||
'paginas_pares' => 'El número de páginas debe ser par',
|
||||
'extras_cubierta' => 'Rellene todos los campos',
|
||||
],
|
||||
|
||||
'errores' => [
|
||||
|
||||
@ -129,16 +129,16 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->groupEnd();
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
@ -413,6 +413,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
public function getPapelCliente(
|
||||
$tipo,
|
||||
$is_cubierta = false,
|
||||
$is_sobrecubierta = false,
|
||||
$selected_papel_id = null,
|
||||
$tapa_dura = null,
|
||||
$papel_especial = false,
|
||||
@ -517,6 +518,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
if ($tapa_dura == true) {
|
||||
$builder->where("t2.use_for_tapa_dura", 1);
|
||||
}
|
||||
} else if ($is_sobrecubierta == true) {
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
$builder->where("t5.uso", 'sobrecubierta');
|
||||
} else {
|
||||
$builder->where("t2.interior", 1);
|
||||
$builder->where("t5.uso", 'interior');
|
||||
|
||||
@ -22,7 +22,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
3 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "margen", "cubierta", "sobrecubierta"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "proveedor_id", "nombre", "precio_total", "importe_fijo", "importe_minimo", "precio_unidad", "margen", "cubierta", "sobrecubierta", "faja"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoAcabadosEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -48,55 +48,58 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
];
|
||||
|
||||
|
||||
public function getProveedoresForSelector($tarifa_acabado_id, $tirada){
|
||||
public function getProveedoresForSelector($tarifa_acabado_id, $tirada)
|
||||
{
|
||||
|
||||
$proveedores = [];
|
||||
$modelTarifa = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel');
|
||||
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada);
|
||||
|
||||
if (count($tarifa_value)>0) {
|
||||
foreach($tarifa_value as $tarifa)
|
||||
array_push($proveedores,
|
||||
(object)[
|
||||
'id'=> $tarifa->proveedor_id,
|
||||
'text'=> $tarifa->proveedor_nombre,
|
||||
]);
|
||||
|
||||
if (count($tarifa_value) > 0) {
|
||||
foreach ($tarifa_value as $tarifa)
|
||||
array_push(
|
||||
$proveedores,
|
||||
(object) [
|
||||
'id' => $tarifa->proveedor_id,
|
||||
'text' => $tarifa->proveedor_nombre,
|
||||
]
|
||||
);
|
||||
}
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
public function getPrecioTarifa($tarifa_acabado_id, $tirada, $proveedor_id, $POD){
|
||||
public function getPrecioTarifa($tarifa_acabado_id, $tirada, $proveedor_id, $POD)
|
||||
{
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel');
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada, $proveedor_id);
|
||||
if (count($tarifa_value)>0) {
|
||||
|
||||
if (count($tarifa_value) > 0) {
|
||||
|
||||
$ret_array = [];
|
||||
foreach ($tarifa_value as $tarifa) {
|
||||
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD<$tirada?false:true);
|
||||
array_push($ret_array, (object)[
|
||||
'tarifa_id'=> $tarifa->tarifa_acabado_id,
|
||||
'tarifa_nombre'=> $tarifa->tarifa_acabado_nombre,
|
||||
'nombre'=> $tarifa->tarifa_acabado_nombre,
|
||||
'precio_unidad'=> round($result_data[0], 2),
|
||||
'total'=> round($result_data[1], 2),
|
||||
'precio_total'=> round($result_data[1], 2),
|
||||
'margen'=> $result_data[2],
|
||||
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD < $tirada ? false : true);
|
||||
array_push($ret_array, (object) [
|
||||
'tarifa_id' => $tarifa->tarifa_acabado_id,
|
||||
'tarifa_nombre' => $tarifa->tarifa_acabado_nombre,
|
||||
'nombre' => $tarifa->tarifa_acabado_nombre,
|
||||
'precio_unidad' => round($result_data[0], 2),
|
||||
'total' => round($result_data[1], 2),
|
||||
'precio_total' => round($result_data[1], 2),
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa->proveedor_id,
|
||||
]);
|
||||
}
|
||||
usort($ret_array, function($a, $b) {
|
||||
usort($ret_array, function ($a, $b) {
|
||||
return $a->precio_total <=> $b->precio_total;
|
||||
});
|
||||
return $ret_array;
|
||||
}
|
||||
else{
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_acabado_id,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||
'nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||
} else {
|
||||
$ret_array[] = (object) [
|
||||
'tarifa_id' => $tarifa_acabado_id,
|
||||
'tarifa_nombre' => $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||
'nombre' => $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||
'precio_unidad' => 0,
|
||||
'total' => 0,
|
||||
'precio_total' => 0,
|
||||
@ -104,13 +107,14 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
'proveedor' => '',
|
||||
'proveedor_id' => 0,
|
||||
];
|
||||
return $ret_array;
|
||||
return $ret_array;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public function deleteAllServicios($presupuesto_id){
|
||||
|
||||
public function deleteAllServicios($presupuesto_id)
|
||||
{
|
||||
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
@ -118,24 +122,28 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas){
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
->table($this->table . " t1");
|
||||
$builder->select("*");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$results = $builder->get()->getResultObject();
|
||||
|
||||
$ids_for_delete = [];
|
||||
foreach($results as $result){
|
||||
$found = false;
|
||||
foreach($tarifas as $tarifa){
|
||||
if($tarifa->tarifa_id == $result->tarifa_acabado_id &&
|
||||
$tarifa->cubierta == $result->cubierta &&
|
||||
$tarifa->sobrecubierta == $result->sobrecubierta)
|
||||
foreach ($results as $result) {
|
||||
$found = false;
|
||||
foreach ($tarifas as $tarifa) {
|
||||
if (
|
||||
$tarifa->tarifa_id == $result->tarifa_acabado_id &&
|
||||
$tarifa->cubierta == $result->cubierta &&
|
||||
$tarifa->sobrecubierta == $result->sobrecubierta &&
|
||||
$tarifa->faja == $result->faja
|
||||
)
|
||||
$found = true;
|
||||
}
|
||||
if(!$found){
|
||||
if (!$found) {
|
||||
array_push($ids_for_delete, $result->id);
|
||||
}
|
||||
}
|
||||
@ -143,27 +151,29 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
foreach($ids_for_delete as $id){
|
||||
foreach ($ids_for_delete as $id) {
|
||||
$builder->orWhere('id', $id);
|
||||
}
|
||||
$builder->delete();
|
||||
}
|
||||
|
||||
public function updateTarifas($presupuesto_id, $tarifas){
|
||||
public function updateTarifas($presupuesto_id, $tarifas)
|
||||
{
|
||||
|
||||
foreach($tarifas as $tarifa){
|
||||
|
||||
$proveedor = $tarifa->proveedor_id=='undefined'?'NULL':$tarifa->proveedor_id;
|
||||
foreach ($tarifas as $tarifa) {
|
||||
|
||||
$proveedor = $tarifa->proveedor_id == 'undefined' ? 'NULL' : $tarifa->proveedor_id;
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->select("id");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_acabado_id', $tarifa->tarifa_id);
|
||||
$builder->where('cubierta', $tarifa->cubierta);
|
||||
$builder->where('sobrecubierta', $tarifa->sobrecubierta);
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_acabado_id', $tarifa->tarifa_id);
|
||||
$builder->where('cubierta', $tarifa->cubierta);
|
||||
$builder->where('sobrecubierta', $tarifa->sobrecubierta);
|
||||
$builder->where('faja', $tarifa->faja);
|
||||
$result = $builder->get()->getResultObject();
|
||||
if(count($result)>0){
|
||||
if (count($result) > 0) {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
@ -174,11 +184,11 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->set('margen', $tarifa->margen)
|
||||
->set('cubierta', $tarifa->cubierta)
|
||||
->set('sobrecubierta', $tarifa->sobrecubierta)
|
||||
->set('faja', $tarifa->faja)
|
||||
->update();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
@ -189,6 +199,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->set('margen', $tarifa->margen)
|
||||
->set('cubierta', $tarifa->cubierta)
|
||||
->set('sobrecubierta', $tarifa->sobrecubierta)
|
||||
->set('faja', $tarifa->faja)
|
||||
->insert();
|
||||
}
|
||||
}
|
||||
@ -208,6 +219,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.tarifa_acabado_id AS tarifa_id, t1.precio_unidad AS precio_unidad,
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta,
|
||||
t1.faja AS faja,
|
||||
t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,"
|
||||
);
|
||||
|
||||
@ -285,27 +297,28 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
private function calcularTarifa($tarifa, $tirada, $is_POD=false){
|
||||
private function calcularTarifa($tarifa, $tirada, $is_POD = false)
|
||||
{
|
||||
|
||||
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max))/($tarifa->tirada_max - $tarifa->tirada_min) * ($tirada - $tarifa->tirada_min);
|
||||
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max)) / ($tarifa->tirada_max - $tarifa->tirada_min) * ($tirada - $tarifa->tirada_min);
|
||||
if ($tirada > $tarifa->tirada_max)
|
||||
$precio_unidad = $tarifa->precio_max;
|
||||
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
|
||||
|
||||
$precio_unidad = $precio_unidad * (1 + floatval($tarifa->margen) / 100.0);
|
||||
|
||||
if (!$is_POD) {
|
||||
$precio_unidad += floatval($tarifa->tarifa_importe_fijo)/floatval($tirada);
|
||||
}
|
||||
|
||||
$total = $precio_unidad * $tirada;
|
||||
$margen = floatval($tarifa->margen);
|
||||
|
||||
if($tarifa->tarifa_precio_min > $total){
|
||||
$total = $total-($total * $margen/100.0);
|
||||
if ($tarifa->tarifa_precio_min > $total) {
|
||||
$total = $total - ($total * $margen / 100.0);
|
||||
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0);
|
||||
$total = floatval($tarifa->tarifa_precio_min);
|
||||
$precio_unidad = round(floatval($total / $tirada), 2);
|
||||
}
|
||||
|
||||
if (!$is_POD){
|
||||
$total += floatval($tarifa->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
return [$precio_unidad, $total, $margen];
|
||||
}
|
||||
|
||||
|
||||
@ -48,63 +48,65 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
|
||||
|
||||
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $paginas, $ancho, $alto, $POD, $paginasCuadernillo = 32){
|
||||
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $paginas, $ancho, $alto, $POD, $paginasCuadernillo = 32)
|
||||
{
|
||||
|
||||
$model = model('App\Models\Presupuestos\TipoPresupuestoServiciosDefectoModel');
|
||||
$tarifas_procesar = $model->get_tarifas($tipo_presupuesto, $solapas, "encuadernacion");
|
||||
|
||||
$tarifas_procesar = $model->get_tarifas($tipo_presupuesto, $solapas, "encuadernacion");
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
$tarifas = [];
|
||||
|
||||
foreach($tarifas_procesar as $tarifa){
|
||||
foreach ($tarifas_procesar as $tarifa) {
|
||||
|
||||
if($modelTarifa->isTarifaPorHoras($tarifa['tarifa_id'])){
|
||||
if ($modelTarifa->isTarifaPorHoras($tarifa['tarifa_id'])) {
|
||||
|
||||
if($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14){ // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
if ($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14) { // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginasCuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa['tarifa_id'], $tiempo, $tirada);
|
||||
if (count($tarifa_value)>0) {
|
||||
if (count($tarifa_value) > 0) {
|
||||
|
||||
$result_array = [];
|
||||
foreach($tarifa_value as $tarifa_proveedor){
|
||||
$precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0);
|
||||
if ($tirada>=$POD){
|
||||
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
|
||||
}
|
||||
foreach ($tarifa_value as $tarifa_proveedor) {
|
||||
$precio_total = floatval(1.0 * $tarifa_proveedor->precio_hora * $tiempo) * (1 + $tarifa_value[0]->margen / 100.0);
|
||||
if ($tirada >= $POD) {
|
||||
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
$result_data[0] = round(floatval($precio_total / $tirada), 2); // Precio/unidad
|
||||
$result_data[1] = round($result_data[0] * $tirada, 2);
|
||||
$result_data[2] = $tarifa_proveedor->margen; // margen
|
||||
|
||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||
|
||||
$datos = [
|
||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'tarifa_id' => $tarifa['tarifa_id'],
|
||||
'tarifa_nombre' => $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'nombre' => $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad' => $result_data[0],
|
||||
'tiempo' => $tiempo,
|
||||
'total'=> $result_data[1],
|
||||
'precio_total'=> $result_data[1],
|
||||
'total' => $result_data[1],
|
||||
'precio_total' => $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||
];
|
||||
|
||||
if($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14){
|
||||
if ($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14) {
|
||||
$datos['paginas_por_cuadernillo'] = $paginasCuadernillo;
|
||||
}
|
||||
|
||||
array_push($result_array,
|
||||
(object)$datos);
|
||||
array_push(
|
||||
$result_array,
|
||||
(object) $datos
|
||||
);
|
||||
}
|
||||
|
||||
usort($result_array, function($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
usort($result_array, function ($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->total < $b->total) ? -1 : 1;
|
||||
@ -113,66 +115,67 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
array_push($tarifas, $result_array[0]);
|
||||
|
||||
|
||||
} else {
|
||||
array_push(
|
||||
$tarifas,
|
||||
(object) [
|
||||
'tarifa_id' => $tarifa['tarifa_id'],
|
||||
'tarifa_nombre' => $tarifa['tarifa_nombre'],
|
||||
'nombre' => $tarifa['tarifa_nombre'],
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad' => 0,
|
||||
'tiempo' => null,
|
||||
'total' => 0,
|
||||
'precio_total' => 0,
|
||||
'margen' => 0,
|
||||
]
|
||||
);
|
||||
}
|
||||
else{
|
||||
array_push($tarifas,
|
||||
(object)[
|
||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
||||
'nombre'=> $tarifa['tarifa_nombre'],
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'tiempo' => null,
|
||||
'total'=> 0,
|
||||
'precio_total'=> 0,
|
||||
'margen' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa['tarifa_id'], $paginas, $tirada, $ancho, $alto);
|
||||
if (count($tarifa_value)>0) {
|
||||
if (count($tarifa_value) > 0) {
|
||||
|
||||
$result_array = [];
|
||||
foreach($tarifa_value as $tarifa_proveedor){
|
||||
$result_data = $this->calcularTarifa($tarifa_proveedor, $paginas, $tirada, $POD<$tirada?false:true);
|
||||
array_push($result_array, (object)[
|
||||
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
foreach ($tarifa_value as $tarifa_proveedor) {
|
||||
$result_data = $this->calcularTarifa($tarifa_proveedor, $paginas, $tirada, $POD < $tirada ? false : true);
|
||||
array_push($result_array, (object) [
|
||||
'tarifa_id' => $tarifa_proveedor->tarifa_enc_id,
|
||||
'tarifa_nombre' => $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'nombre' => $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad' => $result_data[0],
|
||||
'tiempo' => null,
|
||||
'total'=> $result_data[1],
|
||||
'precio_total'=> $result_data[1],
|
||||
'margen'=> $result_data[2],
|
||||
'total' => $result_data[1],
|
||||
'precio_total' => $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||
]);
|
||||
}
|
||||
|
||||
usort($result_array, function($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
usort($result_array, function ($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->total < $b->total) ? -1 : 1;
|
||||
});
|
||||
|
||||
array_push($tarifas, $result_array[0]);
|
||||
}
|
||||
else{
|
||||
array_push($tarifas,
|
||||
(object)[
|
||||
'tarifa_id'=> $tarifa['tarifa_id'] ,
|
||||
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
||||
'nombre'=> $tarifa['tarifa_nombre'],
|
||||
} else {
|
||||
array_push(
|
||||
$tarifas,
|
||||
(object) [
|
||||
'tarifa_id' => $tarifa['tarifa_id'],
|
||||
'tarifa_nombre' => $tarifa['tarifa_nombre'],
|
||||
'nombre' => $tarifa['tarifa_nombre'],
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'precio_unidad' => 0,
|
||||
'tiempo' => null,
|
||||
'total'=> 0,
|
||||
'precio_total'=> 0,
|
||||
'total' => 0,
|
||||
'precio_total' => 0,
|
||||
'margen' => 0,
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,202 +184,211 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function getProveedoresForSelector($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $paginasCuadernillo = 32){
|
||||
public function getProveedoresForSelector($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $paginasCuadernillo = 32)
|
||||
{
|
||||
|
||||
$proveedores = [];
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
|
||||
if($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||
|
||||
if ($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)) {
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginasCuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto);
|
||||
}
|
||||
if (count($tarifa_value)>0) {
|
||||
foreach($tarifa_value as $tarifa)
|
||||
array_push($proveedores,
|
||||
(object)[
|
||||
'id'=> $tarifa->proveedor_id,
|
||||
'text'=> $tarifa->proveedor_nombre,
|
||||
]);
|
||||
if (count($tarifa_value) > 0) {
|
||||
foreach ($tarifa_value as $tarifa)
|
||||
array_push(
|
||||
$proveedores,
|
||||
(object) [
|
||||
'id' => $tarifa->proveedor_id,
|
||||
'text' => $tarifa->proveedor_nombre,
|
||||
]
|
||||
);
|
||||
}
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
public function getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD){
|
||||
public function getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD)
|
||||
{
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
if($proveedor_id != -1){
|
||||
if ($proveedor_id != -1) {
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto);
|
||||
}
|
||||
if (count($tarifa_value)>0) {
|
||||
if (count($tarifa_value) > 0) {
|
||||
|
||||
$ret_array = [];
|
||||
foreach($tarifa_value as $tarifa){
|
||||
foreach ($tarifa_value as $tarifa) {
|
||||
|
||||
$result_data = $this->calcularTarifa($tarifa, $paginas, $tirada, $POD<$tirada?false:true);
|
||||
array_push($ret_array, (object)[
|
||||
'tarifa_id'=> $tarifa->tarifa_enc_id,
|
||||
'tarifa_nombre'=> $tarifa->tarifa_enc_nombre,
|
||||
'nombre'=> $tarifa->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
$result_data = $this->calcularTarifa($tarifa, $paginas, $tirada, $POD < $tirada ? false : true);
|
||||
array_push($ret_array, (object) [
|
||||
'tarifa_id' => $tarifa->tarifa_enc_id,
|
||||
'tarifa_nombre' => $tarifa->tarifa_enc_nombre,
|
||||
'nombre' => $tarifa->tarifa_enc_nombre,
|
||||
'precio_unidad' => $result_data[0],
|
||||
'tiempo' => null,
|
||||
'total'=> $result_data[1],
|
||||
'precio_total'=> $result_data[1],
|
||||
'margen'=> $result_data[2],
|
||||
'total' => $result_data[1],
|
||||
'precio_total' => $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa->proveedor_id,
|
||||
]);
|
||||
}
|
||||
|
||||
usort($ret_array, function($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
|
||||
usort($ret_array, function ($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->total < $b->total) ? -1 : 1;
|
||||
});
|
||||
return $ret_array;
|
||||
}
|
||||
else{
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_encuadernacion_id,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
} else {
|
||||
$ret_array[] = (object) [
|
||||
'tarifa_id' => $tarifa_encuadernacion_id,
|
||||
'tarifa_nombre' => $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'nombre' => $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'precio_unidad' => 0,
|
||||
'tiempo' => null,
|
||||
'total'=> 0,
|
||||
'precio_total'=> 0,
|
||||
'margen'=> 0,
|
||||
'total' => 0,
|
||||
'precio_total' => 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
return $ret_array;
|
||||
return $ret_array;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo = 32){
|
||||
|
||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo = 32)
|
||||
{
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
|
||||
if($tarifa_encuadernacion_id == 2 || $tarifa_encuadernacion_id == 14){ // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
|
||||
if ($tarifa_encuadernacion_id == 2 || $tarifa_encuadernacion_id == 14) { // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginas_cuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada, $proveedor_id);
|
||||
if (count($tarifa_value)>0) {
|
||||
|
||||
if (count($tarifa_value) > 0) {
|
||||
|
||||
$ret_array = [];
|
||||
foreach($tarifa_value as $tarifa_proveedor){
|
||||
$precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0);
|
||||
if ($tirada>=$POD){
|
||||
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
|
||||
foreach ($tarifa_value as $tarifa_proveedor) {
|
||||
$precio_total = floatval(1.0 * $tarifa_proveedor->precio_hora * $tiempo) * (1 + $tarifa_value[0]->margen / 100.0);
|
||||
if ($tirada >= $POD) {
|
||||
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
|
||||
$tarifa_precio_min = floatval($tarifa_proveedor->tarifa_precio_min);
|
||||
|
||||
if($tarifa_precio_min > $precio_total){
|
||||
$total = $total-($total * $margen/100.0);
|
||||
$margen = round(100.0 * (floatval($$tarifa_precio_min) - $total) / floatval($$tarifa_precio_min), 0);
|
||||
$total = floatval($$tarifa_precio_min);
|
||||
if ($tarifa_precio_min > $precio_total) {
|
||||
$precio_total = $precio_total - ($precio_total * $margen / 100.0);
|
||||
$margen = round(100.0 * (floatval($tarifa_precio_min) - $precio_total) / floatval($tarifa_precio_min), 0);
|
||||
$precio_total = floatval($tarifa_precio_min);
|
||||
}
|
||||
|
||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||
$precio_total = round($precio_total, 2);
|
||||
|
||||
|
||||
array_push($ret_array,
|
||||
(object)[
|
||||
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'tiempo' => $tiempo,
|
||||
'paginas_por_cuadernillo' => $paginas_cuadernillo,
|
||||
'precio_total'=> $result_data[1],
|
||||
'total'=> $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||
]);
|
||||
$result_data[0] = round(floatval($precio_total / $tirada), 2); // Precio/unidad
|
||||
$result_data[1] = round($result_data[0] * $tirada, 2);
|
||||
$result_data[2] = $tarifa_proveedor->margen; // margen
|
||||
|
||||
|
||||
array_push(
|
||||
$ret_array,
|
||||
(object) [
|
||||
'tarifa_id' => $tarifa_proveedor->tarifa_enc_id,
|
||||
'tarifa_nombre' => $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'nombre' => $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad' => $result_data[0],
|
||||
'tiempo' => $tiempo,
|
||||
'paginas_por_cuadernillo' => $paginas_cuadernillo,
|
||||
'precio_total' => $result_data[1],
|
||||
'total' => $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
usort($ret_array, function($a, $b) {
|
||||
usort($ret_array, function ($a, $b) {
|
||||
|
||||
if ($a->total == $b->total) {
|
||||
if ($a->total == $b->total) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->total < $b->total) ? -1 : 1;
|
||||
});
|
||||
|
||||
return $ret_array;
|
||||
}
|
||||
else{
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_encuadernacion_id,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
} else {
|
||||
$ret_array[] = (object) [
|
||||
'tarifa_id' => $tarifa_encuadernacion_id,
|
||||
'tarifa_nombre' => $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'nombre' => $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'precio_unidad' => 0,
|
||||
'tiempo' => null,
|
||||
'paginas_por_cuadernillo' => null,
|
||||
'total'=> 0,
|
||||
'precio_total'=> 0,
|
||||
'total' => 0,
|
||||
'precio_total' => 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
return $ret_array;
|
||||
return $ret_array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function calcularTarifa($tarifa, $paginas, $ejemplares, $is_POD=false){
|
||||
private function calcularTarifa($tarifa, $paginas, $ejemplares, $is_POD = false)
|
||||
{
|
||||
|
||||
$precio_unidad = floatval($tarifa->precio_max) - (floatval($tarifa->precio_max) - floatval($tarifa->precio_min))/($tarifa->paginas_max - $tarifa->paginas_min) * ($paginas - $tarifa->paginas_min);
|
||||
$precio_unidad = floatval($tarifa->precio_max) - (floatval($tarifa->precio_max) - floatval($tarifa->precio_min)) / ($tarifa->paginas_max - $tarifa->paginas_min) * ($paginas - $tarifa->paginas_min);
|
||||
if ($paginas > $tarifa->paginas_max)
|
||||
$precio_unidad = $tarifa->precio_max;
|
||||
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
|
||||
|
||||
$precio_unidad = $precio_unidad * (1 + floatval($tarifa->margen) / 100.0);
|
||||
|
||||
if (!$is_POD) {
|
||||
$precio_unidad += floatval($tarifa->tarifa_importe_fijo) / floatval($ejemplares);
|
||||
}
|
||||
|
||||
$precio_unidad = round($precio_unidad, 2);
|
||||
|
||||
$total = $precio_unidad * $ejemplares;
|
||||
$margen = floatval($tarifa->margen);
|
||||
$tarifa_precio_min = floatval($tarifa->tarifa_precio_min);
|
||||
|
||||
if($tarifa_precio_min > $total){
|
||||
$total = $total-($total * $margen/100.0);
|
||||
if ($tarifa_precio_min > $total) {
|
||||
$total = $total - ($total * $margen / 100.0);
|
||||
$margen = round(100.0 * (floatval($tarifa_precio_min) - $total) / floatval($tarifa_precio_min), 0);
|
||||
$total = floatval($tarifa_precio_min);
|
||||
$precio_unidad = round(floatval($total / $ejemplares), 2);
|
||||
}
|
||||
|
||||
if (!$is_POD){
|
||||
$total += floatval($tarifa->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
return [$precio_unidad, $total, $margen];
|
||||
}
|
||||
|
||||
|
||||
public function getIdFromTarifa($tarifa_id){
|
||||
|
||||
public function getIdFromTarifa($tarifa_id)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id"
|
||||
);
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id"
|
||||
);
|
||||
$builder->where('t1.tarifa_encuadernado_id', $tarifa_id);
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function deleteAllServicios($presupuesto_id){
|
||||
public function deleteAllServicios($presupuesto_id)
|
||||
{
|
||||
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
@ -384,30 +396,32 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
foreach($tarifas_id as $id){
|
||||
foreach ($tarifas_id as $id) {
|
||||
$builder->where('tarifa_encuadernado_id !=', $id);
|
||||
}
|
||||
$builder->delete();
|
||||
}
|
||||
|
||||
public function updateTarifas($presupuesto_id, $tarifas){
|
||||
public function updateTarifas($presupuesto_id, $tarifas)
|
||||
{
|
||||
|
||||
foreach($tarifas as $tarifa){
|
||||
|
||||
$proveedor = $tarifa->proveedor_id=='undefined'?'NULL':$tarifa->proveedor_id;
|
||||
foreach ($tarifas as $tarifa) {
|
||||
|
||||
$proveedor = $tarifa->proveedor_id == 'undefined' ? 'NULL' : $tarifa->proveedor_id;
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->select("id");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_encuadernado_id', $tarifa->tarifa_id);
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_encuadernado_id', $tarifa->tarifa_id);
|
||||
$result = $builder->get()->getResultObject();
|
||||
$paginas_cuadernillo = $tarifa->paginas_por_cuadernillo??null;
|
||||
if(count($result)>0){
|
||||
$paginas_cuadernillo = $tarifa->paginas_por_cuadernillo ?? null;
|
||||
if (count($result) > 0) {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
@ -419,10 +433,9 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
->set('margen', $tarifa->margen)
|
||||
->set('paginas_por_cuadernillo', $paginas_cuadernillo)
|
||||
->update();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
@ -461,21 +474,23 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
private function calcularTiempo($maquina_id, $paginas, $tirada){
|
||||
private function calcularTiempo($maquina_id, $paginas, $tirada)
|
||||
{
|
||||
|
||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
||||
$cuadernillos_libro = $paginas/4;
|
||||
$cuadernillos_pedido = $cuadernillos_libro*$tirada;
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id);
|
||||
return round($cuadernillos_pedido/($velocidad*60.0), 2);
|
||||
$cuadernillos_libro = $paginas / 4;
|
||||
$cuadernillos_pedido = $cuadernillos_libro * $tirada;
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id);
|
||||
return round($cuadernillos_pedido / ($velocidad * 60.0), 2);
|
||||
}
|
||||
|
||||
private function calcularTiempoCosido($maquina_id, $paginas, $tirada, $cuadernillos_por_pagina = 32){
|
||||
|
||||
private function calcularTiempoCosido($maquina_id, $paginas, $tirada, $cuadernillos_por_pagina = 32)
|
||||
{
|
||||
|
||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id); // cuadernillos por minuto
|
||||
$cuadernillos_libro = ceil($paginas/intval($cuadernillos_por_pagina));
|
||||
$cuadernillos_pedido = $cuadernillos_libro*$tirada;
|
||||
return round($cuadernillos_pedido/($velocidad*60.0), 2); // tiempo en segundos
|
||||
$cuadernillos_libro = ceil($paginas / intval($cuadernillos_por_pagina));
|
||||
$cuadernillos_pedido = $cuadernillos_libro * $tirada;
|
||||
return round($cuadernillos_pedido / ($velocidad * 60.0), 2); // tiempo en segundos
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,69 +45,82 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
||||
];
|
||||
|
||||
|
||||
public function getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD){
|
||||
public function getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD)
|
||||
{
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaManipuladoModel');
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoManipulado($tarifa_manipulado_id, $tirada);
|
||||
if (count($tarifa_value)>0) {
|
||||
if (count($tarifa_value) > 0) {
|
||||
$ret_array = [];
|
||||
foreach($tarifa_value as $tarifa){
|
||||
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD<$tirada?false:true);
|
||||
array_push($ret_array, (object)[
|
||||
'tarifa_id'=> $tarifa->tarifa_manipulado_id,
|
||||
'tarifa_nombre'=> $tarifa->tarifa_manipulado_nombre,
|
||||
'nombre'=> $tarifa->tarifa_manipulado_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'precio_total'=> $result_data[1],
|
||||
foreach ($tarifa_value as $tarifa) {
|
||||
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD < $tirada ? false : true);
|
||||
array_push($ret_array, (object) [
|
||||
'tarifa_id' => $tarifa->tarifa_manipulado_id,
|
||||
'tarifa_nombre' => $tarifa->tarifa_manipulado_nombre,
|
||||
'nombre' => $tarifa->tarifa_manipulado_nombre,
|
||||
'precio_unidad' => $result_data[0],
|
||||
'total' => $result_data[1],
|
||||
'precio_total' => $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
]);
|
||||
}
|
||||
|
||||
usort($ret_array, function($a, $b) {
|
||||
usort($ret_array, function ($a, $b) {
|
||||
return $a->precio_total <=> $b->precio_total;
|
||||
});
|
||||
|
||||
|
||||
return $ret_array;
|
||||
} else {
|
||||
if (is_array($tarifa_manipulado_id)) {
|
||||
$ret_array[] = (object) [
|
||||
'tarifa_id' => $tarifa_manipulado_id['id'],
|
||||
'tarifa_nombre' => $tarifa_manipulado_id['nombre'],
|
||||
'nombre' => $tarifa_manipulado_id['nombre'],
|
||||
'precio_unidad' => 0,
|
||||
'total' => 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
} else {
|
||||
$ret_array[] = (object) [
|
||||
'tarifa_id' => $tarifa_manipulado_id,
|
||||
'tarifa_nombre' => $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
||||
'nombre' => $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
||||
'precio_unidad' => 0,
|
||||
'total' => 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
else{
|
||||
$ret_array[] = (object)[
|
||||
'tarifa_id'=> $tarifa_manipulado_id,
|
||||
'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
||||
'nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
|
||||
'precio_unidad' => 0,
|
||||
'total'=> 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
return $ret_array;
|
||||
}
|
||||
}
|
||||
|
||||
private function calcularTarifa($tarifa, $tirada, $is_POD=false){
|
||||
private function calcularTarifa($tarifa, $tirada, $is_POD = false)
|
||||
{
|
||||
|
||||
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max))/($tarifa->tirada_max - $tarifa->tirada_min) * ($tirada - $tarifa->tirada_min);
|
||||
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max)) / ($tarifa->tirada_max - $tarifa->tirada_min) * ($tirada - $tarifa->tirada_min);
|
||||
if ($tirada > $tarifa->tirada_max)
|
||||
$precio_unidad = $tarifa->precio_max;
|
||||
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
|
||||
|
||||
$precio_unidad = $precio_unidad * (1 + floatval($tarifa->margen) / 100.0);
|
||||
|
||||
if (!$is_POD) {
|
||||
$precio_unidad += floatval($tarifa->tarifa_importe_fijo)/floatval($tirada);
|
||||
}
|
||||
|
||||
$total = $precio_unidad * $tirada;
|
||||
$margen = floatval($tarifa->margen);
|
||||
|
||||
if($tarifa->tarifa_precio_min > $total){
|
||||
$total = $total-($total * $margen/100.0);
|
||||
if ($tarifa->tarifa_precio_min > $total) {
|
||||
$total = $total - ($total * $margen / 100.0);
|
||||
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0);
|
||||
$total = floatval($tarifa->tarifa_precio_min);
|
||||
$precio_unidad = round(floatval($total / $tirada), 2);
|
||||
}
|
||||
|
||||
if (!$is_POD){
|
||||
$total += floatval($tarifa->tarifa_importe_fijo);
|
||||
}
|
||||
|
||||
return [$precio_unidad, $total, $margen];
|
||||
}
|
||||
|
||||
public function deleteAllServicios($presupuesto_id){
|
||||
public function deleteAllServicios($presupuesto_id)
|
||||
{
|
||||
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
@ -115,28 +128,30 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){
|
||||
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
foreach($tarifas_id as $id){
|
||||
foreach ($tarifas_id as $id) {
|
||||
$builder->where('tarifa_manipulado_id !=', $id);
|
||||
}
|
||||
$builder->delete();
|
||||
}
|
||||
|
||||
public function updateTarifas($presupuesto_id, $tarifas){
|
||||
public function updateTarifas($presupuesto_id, $tarifas)
|
||||
{
|
||||
|
||||
foreach ($tarifas as $tarifa) {
|
||||
|
||||
foreach($tarifas as $tarifa){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1");
|
||||
$builder->select("id");
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_manipulado_id', $tarifa->tarifa_id);
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_manipulado_id', $tarifa->tarifa_id);
|
||||
$result = $builder->get()->getResultObject();
|
||||
if(count($result)>0){
|
||||
if (count($result) > 0) {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('presupuesto_id', $presupuesto_id)
|
||||
@ -145,10 +160,9 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
->update();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->set('presupuesto_id', $presupuesto_id)
|
||||
@ -162,43 +176,45 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $POD){
|
||||
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $POD)
|
||||
{
|
||||
|
||||
$model = model('App\Models\Presupuestos\TipoPresupuestoServiciosDefectoModel');
|
||||
$tarifas_procesar = $model->get_tarifas($tipo_presupuesto, $solapas, "manipulado");
|
||||
|
||||
$tarifas_procesar = $model->get_tarifas($tipo_presupuesto, $solapas, "manipulado");
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaManipuladoModel');
|
||||
$tarifas = [];
|
||||
|
||||
|
||||
foreach($tarifas_procesar as $tarifa){
|
||||
foreach ($tarifas_procesar as $tarifa) {
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoManipulado($tarifa['tarifa_id'], $tirada);
|
||||
if (count($tarifa_value)>0) {
|
||||
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
|
||||
array_push($tarifas, (object)[
|
||||
'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id,
|
||||
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
|
||||
'nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'total'=> $result_data[1],
|
||||
'precio_total'=> $result_data[1],
|
||||
'margen'=> $result_data[2],
|
||||
if (count($tarifa_value) > 0) {
|
||||
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD < $tirada ? false : true);
|
||||
array_push($tarifas, (object) [
|
||||
'tarifa_id' => $tarifa_value[0]->tarifa_manipulado_id,
|
||||
'tarifa_nombre' => $tarifa_value[0]->tarifa_manipulado_nombre,
|
||||
'nombre' => $tarifa_value[0]->tarifa_manipulado_nombre,
|
||||
'precio_unidad' => $result_data[0],
|
||||
'total' => $result_data[1],
|
||||
'precio_total' => $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
]);
|
||||
}
|
||||
else{
|
||||
array_push($tarifas,
|
||||
(object)[
|
||||
'tarifa_id'=> $tarifa['tarifa_id'] ,
|
||||
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
|
||||
'nombre'=> $tarifa['tarifa_nombre'],
|
||||
} else {
|
||||
array_push(
|
||||
$tarifas,
|
||||
(object) [
|
||||
'tarifa_id' => $tarifa['tarifa_id'],
|
||||
'tarifa_nombre' => $tarifa['tarifa_nombre'],
|
||||
'nombre' => $tarifa['tarifa_nombre'],
|
||||
'precio_unidad' => 0,
|
||||
'total'=> 0,
|
||||
'precio_total'=> 0,
|
||||
'total' => 0,
|
||||
'precio_total' => 0,
|
||||
'margen' => 0,
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $tarifas;
|
||||
|
||||
@ -129,6 +129,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
"barniz_cubierta_id",
|
||||
"estampado_cubierta_id",
|
||||
"acabado_sobrecubierta_id",
|
||||
"acabado_faja_id",
|
||||
"is_duplicado",
|
||||
'paginas_color_consecutivas',
|
||||
'papel_interior_diferente',
|
||||
@ -410,8 +411,6 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'pais_id' => 1,
|
||||
'retractilado' => $data['retractilado'] ? 1 : 0,
|
||||
'retractilado5' => $data['retractilado5'] ? 1 : 0,
|
||||
'guardas' => in_array(62, $data['servicios']) ? 1 : 0,
|
||||
'faja_color' => in_array(16, $data['servicios']) ? 1 : 0,
|
||||
'ferro' => $data['ferro'] ? 1 : 0,
|
||||
'ferro_digital' => $data['ferro_digital'] ? 1 : 0,
|
||||
'marcapaginas' => $data['marcapaginas'] ? 1 : 0,
|
||||
@ -450,8 +449,13 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
|
||||
'comparador_json_data' => $this->generateJson($data),
|
||||
|
||||
'faja_color' => is_array($data['faja']) ? 1 : 0,
|
||||
'solapas_ancho_faja_color' => is_array($data['faja']) ? $data['faja']['solapas'] : 60,
|
||||
'alto_faja_color' => is_array($data['faja']) ? $data['faja']['alto'] : 50,
|
||||
|
||||
'acabado_cubierta_id' => $data['cubierta']['acabado'],
|
||||
'acabado_sobrecubierta_id' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['acabado'],
|
||||
'acabado_faja_id' => is_array($data['faja']) ? $data['faja']['acabado'] : 0,
|
||||
|
||||
'comp_tipo_impresion' => $data['isHq'] ? ($data['isColor'] ? 'colorhq' : 'negrohq') : ($data['isColor'] ? 'color' : 'negro'),
|
||||
|
||||
@ -571,11 +575,20 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
// -- GUARDAS --
|
||||
if ($data['datos_guardas'] != 0) {
|
||||
$values['guardas'] = array(
|
||||
'papel_id' => intval($data['datos_guardas']['papel']),
|
||||
'papel_id' => intval($data['datos_guardas']['papel']['id']),
|
||||
'gramaje' => intval($data['datos_guardas']['gramaje']),
|
||||
'paginas' => intval($data['datos_guardas']['caras']),
|
||||
);
|
||||
}
|
||||
|
||||
// -- Faja --
|
||||
if ($data['faja'] != 0) {
|
||||
$values['faja'] = array(
|
||||
'papel_id' => intval($data['faja']['papel']),
|
||||
'gramaje' => intval($data['faja']['gramaje']),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
$json = json_encode($values);
|
||||
return $json;
|
||||
|
||||
@ -112,8 +112,9 @@ class TarifaManipuladoModel extends \App\Models\BaseModel
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getTarifaPresupuestoManipulado($tarifa_id, $tirada){
|
||||
|
||||
public function getTarifaPresupuestoManipulado($tarifa_id, $tirada)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
@ -125,15 +126,22 @@ class TarifaManipuladoModel extends \App\Models\BaseModel
|
||||
->where("t1.is_deleted", 0)
|
||||
//->where("t1.mostrar_en_presupuesto", 1)
|
||||
->where("t2.is_deleted", 0);
|
||||
|
||||
$builder->where('t1.id =', $tarifa_id);
|
||||
|
||||
// check if tarifa_id is an array
|
||||
if (is_array($tarifa_id)) {
|
||||
// check if tarifa_id['id'] exists
|
||||
$builder->where('t1.id', array_key_exists('id', $tarifa_id)? $tarifa_id['id']:$tarifa_id['tarifa_id']);
|
||||
} else {
|
||||
$builder->where('t1.id', $tarifa_id);
|
||||
}
|
||||
|
||||
$builder->where('t2.tirada_min <=', $tirada);
|
||||
$builder->where('t2.tirada_max >=', $tirada);
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getNombreTarifaManipulado($id=-1)
|
||||
public function getNombreTarifaManipulado($id = -1)
|
||||
{
|
||||
/*
|
||||
Todos los servicios de encuadernacion activas que se pueden usar en presupuestos
|
||||
@ -142,9 +150,13 @@ class TarifaManipuladoModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.id", $id)
|
||||
->where("t1.is_deleted", 0);
|
||||
);
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
if (is_array($id)) {
|
||||
$builder->where("t1.id", $id['id']);
|
||||
} else
|
||||
$builder->where("t1.id", $id);
|
||||
|
||||
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ class PresupuestoService extends BaseService
|
||||
}
|
||||
|
||||
$uso_tarifa = $uso;
|
||||
if($uso == 'guardas')
|
||||
if ($uso == 'guardas')
|
||||
$uso_tarifa = 'interior';
|
||||
else if ($uso == 'faja')
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
@ -142,6 +142,7 @@ class PresupuestoService extends BaseService
|
||||
$linea['fields']['precio_click'],
|
||||
$maquina->velocidad
|
||||
);
|
||||
$tiempo = round($tiempo, 2);
|
||||
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
||||
|
||||
|
||||
@ -240,7 +241,7 @@ class PresupuestoService extends BaseService
|
||||
return [];
|
||||
}
|
||||
|
||||
$paginas_pedido = (intval($datosPedido->tirada) + intval($datosPedido->merma))*intval($datosPedido->paginas);
|
||||
$paginas_pedido = (intval($datosPedido->tirada) + intval($datosPedido->merma)) * intval($datosPedido->paginas);
|
||||
|
||||
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $paginas_pedido);
|
||||
|
||||
@ -251,8 +252,7 @@ class PresupuestoService extends BaseService
|
||||
$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']['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;
|
||||
@ -274,7 +274,7 @@ class PresupuestoService extends BaseService
|
||||
|
||||
|
||||
$linea['fields']['datosTipologias'] = //$datosTipologias[0];
|
||||
(Object) array(
|
||||
(object) array(
|
||||
'gota_negro' => $parametrosRotativa->rotativa_gota_negro,
|
||||
'gota_color' => $parametrosRotativa->rotativa_gota_color,
|
||||
'negro' => $parametrosRotativa->rotativa_negro,
|
||||
@ -374,7 +374,7 @@ class PresupuestoService extends BaseService
|
||||
if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0 || $uso == 'faja') {
|
||||
// precio papel
|
||||
$pliegos_libro = ($datosPedido->paginas / 2.0) / $response['fields']['num_formas']['value'];
|
||||
if($uso != 'faja')
|
||||
if ($uso != 'faja')
|
||||
$pliegos_libro = ceil($pliegos_libro);
|
||||
if ($uso != 'faja' && $pliegos_libro < 1) // faja pueden entrar más de una forma
|
||||
$pliegos_libro = 1;
|
||||
@ -529,8 +529,8 @@ class PresupuestoService extends BaseService
|
||||
|
||||
$data['alto_click'] = $maquina->alto_click;
|
||||
|
||||
$direccion_fibra = ($parametrosRotativa->a_favor_fibra === "false" || $parametrosRotativa->a_favor_fibra === 0 ||
|
||||
$parametrosRotativa->a_favor_fibra === "0" || $parametrosRotativa->a_favor_fibra === false)? 0 : 1;
|
||||
$direccion_fibra = ($parametrosRotativa->a_favor_fibra === "false" || $parametrosRotativa->a_favor_fibra === 0 ||
|
||||
$parametrosRotativa->a_favor_fibra === "0" || $parametrosRotativa->a_favor_fibra === false) ? 0 : 1;
|
||||
|
||||
$formas = PresupuestoService::getNumFormasRot(
|
||||
$maquina,
|
||||
@ -613,9 +613,9 @@ class PresupuestoService extends BaseService
|
||||
// precio tinta
|
||||
$data['precio_tinta'] = round(
|
||||
round(($data['peso_gotas_negro_pedido'] / 1000.0) * $maquina->precio_tinta_negro, 2) +
|
||||
round(($data['peso_gotas_cyan_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_magenta_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_amarillo_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2),
|
||||
round(($data['peso_gotas_cyan_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_magenta_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_amarillo_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2),
|
||||
2
|
||||
);
|
||||
|
||||
@ -730,7 +730,12 @@ class PresupuestoService extends BaseService
|
||||
// No es cubierta ni sobrecubierta
|
||||
else {
|
||||
// horizontales
|
||||
$h1_temp = floor(floatval($maquina->ancho_impresion) / $anchoForCalculo);
|
||||
if ($uso == 'faja') {
|
||||
$h1_temp = 1;
|
||||
} else {
|
||||
|
||||
$h1_temp = floor(floatval($maquina->ancho_impresion) / $anchoForCalculo);
|
||||
}
|
||||
$h2_temp = floor(floatval($maquina->ancho_impresion) / $altoForCalculo);
|
||||
}
|
||||
|
||||
@ -885,11 +890,18 @@ class PresupuestoService extends BaseService
|
||||
$ancho_total += 6;
|
||||
}
|
||||
}
|
||||
else if ($uso == 'faja' || $uso == 'sobrecubierta') {
|
||||
if ($datosPedido->solapas) {
|
||||
// 7 es el vuelo de la tapa dura sobre el interior
|
||||
$ancho_total += (floatval($datosPedido->solapas_ancho) * 2) + (2 * self::SANGRE_FORMAS) + 2*7;
|
||||
}
|
||||
}
|
||||
|
||||
// si es sobrecubierta
|
||||
// Se añaden 5mm de sangre por cada lado + 2 * 7mm de vuelo portada y contraportada -> total 52
|
||||
else
|
||||
$ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS) + 7;
|
||||
else{
|
||||
$ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS);
|
||||
}
|
||||
}
|
||||
// Wire-o y espiral (tapa blanda y tapa dura)
|
||||
else if (
|
||||
@ -947,9 +959,11 @@ class PresupuestoService extends BaseService
|
||||
if ($uso == "cubierta")
|
||||
$alto_total += (2 * 3.5 + 2 * $sangre_cubierta);
|
||||
// si es sobrecubierta
|
||||
// Se añaden 5mm de sangre por cada lado + 7mm de vuelo
|
||||
else
|
||||
// Se añaden 5mm de sangre por cada lado
|
||||
else if ($uso == 'sobrecubierta')
|
||||
$alto_total += (7 + 2 * self::SANGRE_FORMAS);
|
||||
else if ($uso == 'faja')
|
||||
$alto_total += (2 * self::SANGRE_FORMAS);
|
||||
}
|
||||
// Tapa dura (espiral y wire-0)
|
||||
else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
|
||||
@ -976,7 +990,7 @@ class PresupuestoService extends BaseService
|
||||
//'color' => 1,
|
||||
'rotativa' => 0,
|
||||
);
|
||||
} else if ($uso == 'sobrecubierta') {
|
||||
} else if ($uso == 'sobrecubierta' || $uso == 'faja') {
|
||||
$opciones_papel = array(
|
||||
'sobrecubierta' => 1,
|
||||
//'color' => 1,
|
||||
@ -1008,7 +1022,6 @@ class PresupuestoService extends BaseService
|
||||
{
|
||||
$presupuesto = (new PresupuestoModel())->find($presupuesto_id);
|
||||
$lineas = (new LineaPresupuestoModel())->where('presupuesto_id', $presupuesto_id)->findAll();
|
||||
|
||||
}
|
||||
|
||||
public static function checkLineasPresupuesto($input_data, $array_lineas)
|
||||
@ -1149,7 +1162,6 @@ class PresupuestoService extends BaseService
|
||||
}
|
||||
|
||||
$comp_data = PresupuestoService::obtenerComparadorPlana($datos);
|
||||
|
||||
}
|
||||
|
||||
// se ordena $comp_data usando el campo ['fields]['total_impresion']
|
||||
@ -1175,7 +1187,6 @@ class PresupuestoService extends BaseService
|
||||
array_push($lineas, $linea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1409,7 +1420,6 @@ class PresupuestoService extends BaseService
|
||||
$servicio_temp = $servicio;
|
||||
$servicio_temp->tarifa_id = $servicio_temp->tarifa_acabado_id;
|
||||
$model->updateTarifas($input_data['presupuesto_id'], array($servicio_temp));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1443,7 +1453,6 @@ class PresupuestoService extends BaseService
|
||||
$servicio_temp = $servicio;
|
||||
$servicio_temp->tarifa_id = $servicio_temp->tarifa_manipulado_id;
|
||||
$model->updateTarifas($input_data['presupuesto_id'], array($servicio_temp));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1487,7 +1496,6 @@ class PresupuestoService extends BaseService
|
||||
$input_data['POD']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
// En caso de que el presupuesto no sea duplicado, recalcular la tarifa
|
||||
// con el mismo proveedor
|
||||
@ -1600,9 +1608,7 @@ class PresupuestoService extends BaseService
|
||||
$presupuestoDirecciones = new PresupuestoDireccionesModel();
|
||||
$presupuestoDirecciones->updateLineaEnvio($envio);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1768,7 +1774,7 @@ class PresupuestoService extends BaseService
|
||||
|
||||
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
|
||||
|
||||
$uso_papel = $uso == 'faja' ? 'sobrecubierta': $uso;
|
||||
$uso_papel = $uso == 'faja' ? 'sobrecubierta' : $uso;
|
||||
$opciones_papel = PresupuestoService::get_opciones_papel($uso_papel, $isColor);
|
||||
|
||||
// Se obtienen los papeles disponibles
|
||||
@ -1797,8 +1803,8 @@ class PresupuestoService extends BaseService
|
||||
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') {
|
||||
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso_papel, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso_papel, $tipo_impresion_id, $datosPedido);
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso, $tipo_impresion_id, $datosPedido);
|
||||
}
|
||||
|
||||
$data['uso'] = $uso;
|
||||
@ -1830,7 +1836,7 @@ class PresupuestoService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta') {
|
||||
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') {
|
||||
|
||||
$linea['fields']['dimension_desarrollo']['ancho'] = $datosPedido->anchoExteriores;
|
||||
$linea['fields']['dimension_desarrollo']['alto'] = $datosPedido->altoExteriores;
|
||||
|
||||
@ -27,4 +27,4 @@
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@ -333,7 +333,7 @@
|
||||
lengthChange: false,
|
||||
searching: false,
|
||||
info: false,
|
||||
dom: "lftp",
|
||||
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
|
||||
|
||||
stateSave: true,
|
||||
@ -561,7 +561,7 @@
|
||||
lengthChange: false,
|
||||
searching: false,
|
||||
info: false,
|
||||
dom: "lftp",
|
||||
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
|
||||
|
||||
stateSave: true,
|
||||
|
||||
@ -114,7 +114,7 @@
|
||||
<?= lang('Presupuestos.solapasAnchoCubierta') ?>*
|
||||
</label>
|
||||
<input type="number" id="solapas_ancho" name="solapas_ancho" placeholder="0"
|
||||
maxLength="8" step="1" class="form-control solapas_cubierta" value="">
|
||||
maxLength="8" step="1" min=60 class="form-control solapas_cubierta" value="60">
|
||||
<div class="form-text">
|
||||
Entre 60 y 120 mm
|
||||
</div>
|
||||
@ -242,6 +242,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-lg-6 px-4 d-none acabado-faja">
|
||||
<div class="row">
|
||||
<div class="mb-1">
|
||||
<label id="label_acabado_faja_id" for="acabado_faja_id" class="form-label">
|
||||
<?= lang('Presupuestos.acabadoFaja') ?>*
|
||||
</label>
|
||||
<select id="acabado_faja_id" name="acabado_faja_id" tabindex="3"
|
||||
class="form-control select2bs2" style="width: 100%;">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!----------------------------------------------------------------------------->
|
||||
|
||||
@ -96,6 +96,7 @@
|
||||
<th><?= lang('Tarifaacabado.margen') ?></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -172,8 +172,9 @@
|
||||
<div class="row justify-content-center">
|
||||
|
||||
<div class="col-sm-6">
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoCubierta" name="acabado_cubierta">
|
||||
<option value="0"> <?=lang('Presupuestos.acabadoNinguno') ?> </option>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoCubierta"
|
||||
name="acabado_cubierta">
|
||||
<option value="0"> <?= lang('Presupuestos.acabadoNinguno') ?> </option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -187,58 +188,54 @@
|
||||
<h3 class="mb-1 fw-bold"> Extras </h3>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="row col-sm-12 mb-3 justify-content-center align-items-top">
|
||||
|
||||
|
||||
|
||||
<div class="row col-sm-2 mb-3 d-flex flex-column align-items-center sobrecubierta-items">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addSobrecubierta"
|
||||
name="add_sobrecubierta" value="1">
|
||||
<label class="form-check-label"
|
||||
for="addSobrecubierta"><?= lang('Presupuestos.sobrecubierta') ?></label>
|
||||
</div>
|
||||
<div id="divExtras" name="div_extras" class="row col-sm-12 mb-3 justify-content-center align-items-top">
|
||||
|
||||
<div class="row col-sm-2 mb-3 d-flex flex-column align-items-center sobrecubierta-items">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addSobrecubierta"
|
||||
name="add_sobrecubierta" value="1">
|
||||
<label class="form-check-label" for="addSobrecubierta"><?= lang('Presupuestos.sobrecubierta') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="papelSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.papelSobrecubierta') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="papelSobrecubierta"
|
||||
name="papel_sobrecubierta">
|
||||
<option value="EST2_170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
|
||||
<option value="EST2_200"><?= lang('Presupuestos.estucadoMate200gr') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="papelSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.papelSobrecubierta') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="papelSobrecubierta"
|
||||
name="papel_sobrecubierta">
|
||||
<option value="EST2_170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
|
||||
<option value="EST2_200"><?= lang('Presupuestos.estucadoMate200gr') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="solapasSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.tamanioSolapasSobrecubierta') ?>
|
||||
</label>
|
||||
<input id="solapasSobrecubierta" name="solapas_sobrecubierta" type="number"
|
||||
class="calcular-presupuesto form-control text-center num-input" min="60" max="120" step="1"
|
||||
value="60">
|
||||
<div id="textoLimitesSolapasSobrecubierta" class="form-text">
|
||||
Entre 60 y 120 mm
|
||||
</div>
|
||||
<div class="col-sm-3 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="solapasSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.tamanioSolapasSobrecubierta') ?>
|
||||
</label>
|
||||
<input id="solapasSobrecubierta" name="solapas_sobrecubierta" type="number"
|
||||
class="calcular-presupuesto form-control text-center num-input" min="60" max="120" step="1" value="60">
|
||||
<div id="textoLimitesSolapasSobrecubierta" class="form-text">
|
||||
Entre 60 y 120 mm
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="plastificadoSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.acabado') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoSobrecubierta"
|
||||
name="acabado_sobrecubierta">
|
||||
<option value="0"> <?=lang('Presupuestos.acabadoNinguno') ?> </option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-4 config-sobrecubierta d-none sobrecubierta-items">
|
||||
<label for="plastificadoSobrecubierta" class="form-label">
|
||||
<?= lang('Presupuestos.acabado') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoSobrecubierta"
|
||||
name="acabado_sobrecubierta">
|
||||
<option value="0"> <?= lang('Presupuestos.acabadoNinguno') ?> </option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row col-sm-12 mb-0 justify-content-center d-none">
|
||||
<div class="row col-sm-12 mb-0 justify-content-center">
|
||||
|
||||
<div class="row justify-content-center">
|
||||
|
||||
<div class="row col-sm-2 mb-3 d-flex flex-column align-items-center">
|
||||
<div class="col-sm-2 mb-3 d-flex flex-column align-items-center">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="calcular-presupuesto form-check-input" type="checkbox" id="addFaja" name="add_faja"
|
||||
value="1">
|
||||
@ -246,26 +243,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row col-sm-3 config-faja d-none">
|
||||
<div class="">
|
||||
<label for="papelFaja" class="form-label">
|
||||
<?= lang('Presupuestos.papelFaja') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="papelFaja" name="papel_faja">
|
||||
</select>
|
||||
</div>
|
||||
<div class="">
|
||||
<label for="papelFaja" class="form-label">
|
||||
<?= lang('Presupuestos.gramajeFaja') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="gramajeFaja" name="gramaje_faja">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-2 config-faja d-none">
|
||||
<label for="altoFaja" class="form-label">
|
||||
<?= lang('Presupuestos.altoFaja') ?>
|
||||
</label>
|
||||
<input id="altoFaja" name="alto_faja" type="number"
|
||||
class="calcular-presupuesto form-control text-center num-input" min="60" step="1" value="60">
|
||||
class="calcular-presupuesto form-control text-center num-input" min="50" step="1" value="60">
|
||||
<div class="form-text">
|
||||
Mayor 60 mm
|
||||
Entre 50 mm y 120 mm
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-faja d-none">
|
||||
<label for="barniz" class="form-label">
|
||||
<?= lang('Presupuestos.papelFaja') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="papelFaja" name="papel_sobrecubierta">
|
||||
<option value="EST2_170"><?= lang('Presupuestos.estucadoMate170gr') ?></option>
|
||||
<option value="EST2_200"><?= lang('Presupuestos.estucadoMate200gr') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 config-faja d-none">
|
||||
<label for="solapasFaja" class="form-label">
|
||||
@ -274,21 +280,18 @@
|
||||
<input id="solapasFaja" name="solapas_faja" type="number"
|
||||
class="calcular-presupuesto form-control text-center num-input" min="60" max="120" step="1"
|
||||
value="60">
|
||||
<div class="form-text">
|
||||
<div id="textoLimitesSolapasFaja" class="form-text">
|
||||
Entre 60 y 120 mm
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 config-faja d-none">
|
||||
<label for="plastificadoFaja" class="form-label">
|
||||
<label for="acabadoFaja" class="form-label">
|
||||
<?= lang('Presupuestos.plastificadoFaja') ?>
|
||||
</label>
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="plastificadoFaja"
|
||||
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoFaja"
|
||||
name="plastificado_faja">
|
||||
<option value="NONE"> - </option>
|
||||
<option value="BRIL"><?= lang('Presupuestos.brillo') ?></option>
|
||||
<option value="MATE"><?= lang('Presupuestos.mate') ?></option>
|
||||
<option value="ANTI"><?= lang('Presupuestos.antirrayado') ?></option>
|
||||
<option value="0"> <?= lang('Presupuestos.acabadoNinguno') ?> </option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@ -29,39 +29,38 @@
|
||||
|
||||
<?php if ($formAction == route_to('tarifaAcabadoAdd')): ?>
|
||||
<div class="accordion mt-3" id="accordionAcabadoLineas" style="visibility:hidden">
|
||||
<?php else: ?>
|
||||
<?php else: ?>
|
||||
<div class="accordion mt-3" id="accordionAcabadoLineas" style="visibility:visible">
|
||||
<?php endif; ?>
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
|
||||
<h3><?= lang("TarifaAcabadoLineas.moduleTitle") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<?php endif; ?>
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
|
||||
<h3><?= lang("TarifaAcabadoLineas.moduleTitle") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionAcabadoLineas">
|
||||
<div class="accordion-body">
|
||||
<table id="tableOfTarifaacabadolineas" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('TarifaAcabadoLineas.proveedor') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.margen') ?></th>
|
||||
<th class="noFilter"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionAcabadoLineas">
|
||||
<div class="accordion-body">
|
||||
<table id="tableOfTarifaacabadolineas" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('TarifaAcabadoLineas.proveedor') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.margen') ?></th>
|
||||
<th class="noFilter"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
<?php if (str_contains($formAction, 'edit')): ?>
|
||||
|
||||
<?php if ($tarifaacabadoEntity->id): ?>
|
||||
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingTwo">
|
||||
@ -76,7 +75,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</div><!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -32,14 +32,14 @@
|
||||
<?php if (str_contains($formAction, 'edit')): ?>
|
||||
<div class="accordion mt-3" id="accordionEncuadernacionTiradas" style="visibility:visible">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip2" aria-expanded="false" aria-controls="accordionTip2">
|
||||
<h2 class="accordion-header" id="headingZero">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip0" aria-expanded="false" aria-controls="accordionTip0">
|
||||
<h3><?= lang("TarifaEncuadernacionTiradas.moduleTitle") ?></h3>
|
||||
</button>
|
||||
|
||||
</h2>
|
||||
|
||||
<div id="accordionTip2" class="accordion-collapse collapse show" data-bs-parent="#accordionEncuadernacionTiradas">
|
||||
<div id="accordionTip0" class="accordion-collapse collapse show" data-bs-parent="#accordionEncuadernacionTiradas">
|
||||
<div class="accordion-body">
|
||||
|
||||
<table id="tableOfTarifaencuadernaciontiradas" class="table table-striped table-hover" style="width: 100%;">
|
||||
@ -60,7 +60,7 @@
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
|
||||
<div class="accordion mt-3" id="accordionEncuadernacionLineas" style="visibility:<?php ?>visible">
|
||||
<div class="accordion mt-3" id="accordionEncuadernacionLineas" style="visibility:visible">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
|
||||
@ -93,28 +93,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
|
||||
|
||||
<div class="accordion mt-3 d-none" id="accordionEncuadernacionLineasHoras" style="visibility:visible">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingTwo">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
|
||||
<h3>Tarifa máquinas</h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
|
||||
<div class="accordion-body">
|
||||
<?= view("themes/vuexy/components/forms/tarifa_maquinas", ["id" => "tarifa_maquina_component", "tarifaId" => $tarifaEncuadernacionEntity->id]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
<div class="accordion mt-3" id="accordionEncuadernacionLineasHoras" style="visibility:hidden">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
|
||||
<h2 class="accordion-header" id="headingThree">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip3" aria-expanded="false" aria-controls="accordionTip3">
|
||||
<h3><?= lang("TarifaEncuadernacionLineas.moduleTitle") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionEncuadernacionLineas">
|
||||
<div id="accordionTip3" class="accordion-collapse collapse show" data-bs-parent="#accordionEncuadernacionLineasHoras">
|
||||
<div class="accordion-body">
|
||||
|
||||
<table id="tableOfTarifaencuadernacionlineasHoras" class="table table-striped table-hover" style="width: 100%;">
|
||||
@ -136,6 +123,21 @@
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingTwo">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
|
||||
<h3>Tarifa máquinas</h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
|
||||
<div class="accordion-body">
|
||||
<?= view("themes/vuexy/components/forms/tarifa_maquinas", ["id" => "tarifa_maquina_component", "tarifaId" => $tarifaEncuadernacionEntity->id]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
|
||||
|
||||
|
||||
|
||||
@ -207,12 +209,12 @@ id = -1;
|
||||
|
||||
function check_por_horas(){
|
||||
if($('#por_horas').is(':checked')){
|
||||
$('#accordionEncuadernacionLineasHoras').css("visibility", "visible");
|
||||
$('#accordionEncuadernacionLineas').css("visibility", "collapse");
|
||||
$('#accordionEncuadernacionLineasHoras').removeClass("d-none");
|
||||
$('#accordionEncuadernacionLineas').addClass("d-none");
|
||||
}
|
||||
else{
|
||||
$('#accordionEncuadernacionLineasHoras').css("visibility", "collapse");
|
||||
$('#accordionEncuadernacionLineas').css("visibility", "visible");
|
||||
$('#accordionEncuadernacionLineasHoras').addClass("d-none");
|
||||
$('#accordionEncuadernacionLineas').removeClass("d-none");
|
||||
}
|
||||
}
|
||||
check_por_horas()
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
<?php if ($formAction != site_url('tarifas/tarifasmanipulado/add')): ?>
|
||||
<?php if ($tarifaManipuladoEntity?->id): ?>
|
||||
|
||||
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
|
||||
<div class="card accordion-item active">
|
||||
|
||||
@ -108,7 +108,7 @@ class previewFormas {
|
||||
anchoMaquina: parseFloat(rowData.maquina_ancho),
|
||||
altoImpresion: parseFloat(rowData.maquina_impresion_alto),
|
||||
anchoImpresion: parseFloat(rowData.maquina_impresion_ancho),
|
||||
altoLibro: lpName=='faja'? parseFloat(rowData.alto_faja).toFixed(0):this.alto(),
|
||||
altoLibro: lpName=='faja'? parseFloat(parseFloat(rowData.alto_faja).toFixed(0)):parseFloat(this.alto()),
|
||||
anchoLibro: this.ancho(),
|
||||
offsetSolapa: 0
|
||||
};
|
||||
@ -116,7 +116,7 @@ class previewFormas {
|
||||
//console.log(pvObj);
|
||||
|
||||
// Printing shape definition
|
||||
this.pvObj.anchoForma = parseInt(_isCosido) ? 2 * this.pvObj.anchoLibro : this.pvObj.anchoLibro;
|
||||
this.pvObj.anchoForma = parseInt(_isCosido) ? parseInt(2 * this.pvObj.anchoLibro) : parseInt(this.pvObj.anchoLibro);
|
||||
this.pvObj.altoForma = this.pvObj.altoLibro;
|
||||
|
||||
|
||||
@ -204,9 +204,8 @@ class previewFormas {
|
||||
let anchoSolapaFaja = $('#faja').is(':checked') ? parseFloat($('#faja_solapas_ancho').val()) : parseFloat(0); // mm
|
||||
if (_isTapaDura) {
|
||||
let anchoPliegue = parseFloat(7); // mm
|
||||
let altoPliegue = parseFloat(7); // mm
|
||||
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaFaja + this.pvObj.offsetSolapa)) + (2 * sangreFaja) + this.pvObj.lomoLibroSobrecubierta);
|
||||
this.pvObj.altoForma += altoPliegue + parseFloat(2 * sangreFaja);
|
||||
this.pvObj.altoForma += parseFloat(2 * sangreFaja);
|
||||
} else {
|
||||
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaFaja + this.pvObj.offsetSolapa)) + (2 * sangreFaja) + this.pvObj.lomoLibroSobrecubierta);
|
||||
this.pvObj.altoForma = parseFloat(this.pvObj.altoForma) + parseFloat(2 * sangreFaja);
|
||||
|
||||
@ -29,14 +29,18 @@ class PresupuestoAdminEdit {
|
||||
|
||||
this.tipoTapa = $('.card-title').text().toLowerCase().includes('dura') ? 'dura' : 'blanda';
|
||||
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'),
|
||||
() => { return this.cargandoPresupuesto },
|
||||
{
|
||||
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
calcularSolapas: this.calcularSolapas.bind(this)
|
||||
calcularSolapas: this.calcularSolapas.bind(this),
|
||||
});
|
||||
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'),
|
||||
() => { return this.cargandoPresupuesto },
|
||||
{
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
});
|
||||
@ -56,8 +60,6 @@ class PresupuestoAdminEdit {
|
||||
this.guardar = $('#saveForm');
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
|
||||
this.configUploadDropzone = {
|
||||
domElement: '#dropzone-presupuesto-admin-files',
|
||||
@ -134,6 +136,10 @@ class PresupuestoAdminEdit {
|
||||
|
||||
$('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta);
|
||||
$('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta);
|
||||
if ($(this.configUploadDropzone.domElement).length > 0) {
|
||||
this.fileUploadDropzone.init()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -207,7 +213,7 @@ class PresupuestoAdminEdit {
|
||||
}
|
||||
if (this.datosLibro.tamanioPersonalizado.prop('checked')) {
|
||||
datos.papel_formato_ancho = this.datosLibro.anchoPersonalizado.val(),
|
||||
datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val()
|
||||
datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val()
|
||||
}
|
||||
datos.selectedTirada = this.datosLibro.tirada.val();
|
||||
datos.acabado_cubierta_id = this.datosLibro.acabadoCubierta.getVal();
|
||||
@ -245,7 +251,7 @@ class PresupuestoAdminEdit {
|
||||
datos.solapas_sobrecubierta = this.datosLibro.solapasSobrecubierta.is(':checked') ? 1 : 0;
|
||||
datos.solapas_ancho_sobrecubierta = this.datosLibro.anchoSolapasSobrecubierta.val();
|
||||
|
||||
datos.faja_color = this.datosLibro.faja.prop('checked') ? 1: 0;
|
||||
datos.faja_color = this.datosLibro.faja.prop('checked') ? 1 : 0;
|
||||
datos.solapas_ancho_faja_color = this.datosLibro.fajaSolapasAncho.val();
|
||||
datos.alto_faja_color = this.datosLibro.fajaAlto.val();
|
||||
|
||||
@ -297,6 +303,9 @@ class PresupuestoAdminEdit {
|
||||
};
|
||||
|
||||
if (self.cargandoPresupuesto == false) {
|
||||
|
||||
self.comparador.updateComparador();
|
||||
|
||||
// Ejecutar los pasos de forma secuencial si están habilitados
|
||||
if (update_lineas) {
|
||||
$(document).trigger('update-lineas-presupuesto');
|
||||
@ -330,6 +339,8 @@ class PresupuestoAdminEdit {
|
||||
|
||||
const self = this;
|
||||
this.cargandoPresupuesto = true;
|
||||
self.comparador.cargando = true;
|
||||
self.datosLibro.cargando = true;
|
||||
|
||||
$('#loader').modal('show');
|
||||
let id = window.location.href.split("/").pop()
|
||||
@ -347,11 +358,10 @@ class PresupuestoAdminEdit {
|
||||
self.POD.val(response.data.POD);
|
||||
|
||||
self.calcularPresupuesto = false;
|
||||
self.comparador.cargando = true;
|
||||
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
self.datosLibro.cargarDatos(response.data.datosLibro);
|
||||
|
||||
|
||||
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
|
||||
|
||||
self.servicios.cargar(response.data.servicios);
|
||||
@ -376,6 +386,10 @@ class PresupuestoAdminEdit {
|
||||
|
||||
self.calcularPresupuesto = true;
|
||||
self.cargandoPresupuesto = false;
|
||||
self.datosLibro.cargando = false;
|
||||
self.comparador.cargando = false;
|
||||
|
||||
self.comparador.updateComparador();
|
||||
}
|
||||
|
||||
|
||||
@ -400,6 +414,8 @@ class PresupuestoAdminEdit {
|
||||
$('#loader').modal('hide');
|
||||
this.calcularPresupuesto = true;
|
||||
self.cargandoPresupuesto = false;
|
||||
self.datosLibro.cargando = false;
|
||||
self.comparador.cargando = false;
|
||||
}
|
||||
).get();
|
||||
}
|
||||
@ -424,7 +440,7 @@ class PresupuestoAdminEdit {
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2">` +
|
||||
window.Presupuestos.errores.paginasLP +
|
||||
window.language.Presupuestos.errores.paginasLP +
|
||||
`</h5>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
@ -4,10 +4,12 @@ import Ajax from '../../../components/ajax.js';
|
||||
|
||||
class Comparador {
|
||||
|
||||
constructor(domItem, functions = {}) {
|
||||
constructor(domItem, cargando, functions = {}) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
this.cargando = cargando;
|
||||
|
||||
this.getDimensionLibro = functions.getDimensionLibro;
|
||||
|
||||
this.tipo_impresion_id = parseInt($('#tipo_impresion_id').val());
|
||||
@ -267,8 +269,10 @@ class Comparador {
|
||||
this.btnInsertarCubierta = $('#insertarCubiertaBtn');
|
||||
this.btnInsertarFaja = $('#insertarFajaBtn');
|
||||
|
||||
this.cargando = false;
|
||||
this.comparadorPlanaRunning = false;
|
||||
this.comparadorExterioresRunning = false;
|
||||
this.comparadorGuardasRunning = false;
|
||||
this.comparadorFajaRunning = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -339,7 +343,9 @@ class Comparador {
|
||||
});
|
||||
this.papelSobrecubierta.init();
|
||||
this.gramajeSobrecubierta.init();
|
||||
this.papelSobrecubierta.onChange(() => self.gramajeSobrecubierta.empty());
|
||||
this.papelSobrecubierta.item.on('select2:select', function() {
|
||||
self.gramajeSobrecubierta.empty()
|
||||
});
|
||||
this.sobrecubierta.on('change', () => {
|
||||
if (this.sobrecubierta.select2('data')[0].id == 1) {
|
||||
if ($('#solapas_sobrecubierta').prop('checked') == false) {
|
||||
@ -370,8 +376,6 @@ class Comparador {
|
||||
}
|
||||
$('#faja').prop('checked', true);
|
||||
$('.faja-div').removeClass('d-none');
|
||||
$('#faja_solapas_ancho').val(60);
|
||||
$('#faja_alto').val(50);
|
||||
$('#compPapelFaja').prop('disabled', false);
|
||||
$('#compGramajeFaja').prop('disabled', false);
|
||||
}
|
||||
@ -387,14 +391,30 @@ class Comparador {
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
|
||||
this.papelGuardas.init();
|
||||
this.gramajeGuardas.init();
|
||||
this.papelGuardas.onChange(() => self.gramajeGuardas.empty());
|
||||
this.papelGuardas.item.on('select2:select', function() {
|
||||
self.gramajeGuardas.empty()
|
||||
});
|
||||
}
|
||||
|
||||
this.papelNegro.onChange(() => self.gramajeNegro.empty());
|
||||
this.papelNegrohq.onChange(() => self.gramajeNegrohq.empty());
|
||||
this.papelColor.onChange(() => self.gramajeColor.empty());
|
||||
this.papelColorhq.onChange(() => self.gramajeColorhq.empty());
|
||||
this.papelCubierta.onChange(() => self.gramajeCubierta.empty());
|
||||
this.papelNegro.item.on('select2:select', function() {
|
||||
self.gramajeNegro.empty()
|
||||
});
|
||||
this.papelNegrohq.item.on('select2:select', function() {
|
||||
self.gramajeNegrohq.empty()
|
||||
});
|
||||
this.papelColor.item.on('select2:select', function(){
|
||||
self.gramajeColor.empty()
|
||||
});
|
||||
this.papelColorhq.item.on('select2:select', function() {
|
||||
self.gramajeColorhq.empty()
|
||||
});
|
||||
this.papelCubierta.item.on('select2:select', function() {
|
||||
self.gramajeCubierta.empty()
|
||||
});
|
||||
|
||||
this.papelFaja.item.on('select2:select', function() {
|
||||
self.gramajeFaja.empty()
|
||||
});
|
||||
|
||||
|
||||
this.tipo_impresion.select2({
|
||||
@ -475,8 +495,6 @@ class Comparador {
|
||||
|
||||
cargarDatos(datos) {
|
||||
|
||||
this.cargando = true;
|
||||
|
||||
this.tipo_impresion.val(datos.tipo_impresion).trigger('change');
|
||||
this.updateOpcionesComparador();
|
||||
|
||||
@ -546,9 +564,10 @@ class Comparador {
|
||||
this.#computarPaginasColor(datos.posPagColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.cargando = false;
|
||||
|
||||
updateComparador(){
|
||||
|
||||
if (this.paginasColor.val() > 0) {
|
||||
this.paginasColor.trigger('change');
|
||||
}
|
||||
@ -567,7 +586,6 @@ class Comparador {
|
||||
this.carasGuardas.trigger('change');
|
||||
}
|
||||
this.faja.trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1011,6 +1029,9 @@ class Comparador {
|
||||
|
||||
getDataForComp(uso = 'interior') {
|
||||
|
||||
if(this.cargando)
|
||||
return { error: true, data: {} };
|
||||
|
||||
let ancho = 0;
|
||||
let alto = 0;
|
||||
let papel_generico = {};
|
||||
@ -1071,7 +1092,7 @@ class Comparador {
|
||||
for (let element of papeles) {
|
||||
if (element.getVal() == 0 || element.getVal() == null) {
|
||||
const tipo = element.item.attr('id').split('Papel')[1];
|
||||
if ($('#compPaginas' + tipo).val() > 0) {
|
||||
if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1081,7 +1102,7 @@ class Comparador {
|
||||
|
||||
if (element.getVal() == 0 || element.getVal() == null) {
|
||||
const tipo = element.item.attr('id').split('Gramaje')[1];
|
||||
if ($('#compPaginas' + tipo).val() > 0) {
|
||||
if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1113,11 +1134,11 @@ class Comparador {
|
||||
|
||||
}
|
||||
else if (uso == 'cubierta') {
|
||||
if (this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) {
|
||||
if ((this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) {
|
||||
if ((this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1129,11 +1150,11 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'sobrecubierta') {
|
||||
if (this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) {
|
||||
if ((this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) {
|
||||
if ((this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1145,11 +1166,11 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'faja') {
|
||||
if (this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) {
|
||||
if ((this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) && this.faja.getVal()>0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) {
|
||||
if ((this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) && this.faja.getVal()>0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1162,11 +1183,12 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'guardas') {
|
||||
if (this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) {
|
||||
|
||||
if ((this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeGuardas.getVal() == 0 || this.gramajeGuardas.getVal() == null) {
|
||||
if ((this.gramajeGuardas.getVal() == 0 || this.gramajeGuardas.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1408,7 +1430,7 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando && this.comparadorExterioresRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1439,6 +1461,7 @@ class Comparador {
|
||||
if (Object.keys(datosComp.sobrecubierta).length > 0) {
|
||||
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
}
|
||||
this.comparadorExterioresRunning = true;
|
||||
new Ajax('/presupuestoadmin/comparadorexteriores',
|
||||
{
|
||||
cubierta: datosComp.cubierta.data,
|
||||
@ -1481,14 +1504,17 @@ class Comparador {
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta);
|
||||
self.btnInsertarCubierta.addClass('d-none');
|
||||
}
|
||||
self.comparadorExterioresRunning = false;
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorExterioresRunning = false;
|
||||
}
|
||||
).post();
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.log(e);
|
||||
self.comparadorExterioresRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1499,7 +1525,7 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando && this.comparadorFajaRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1509,10 +1535,13 @@ class Comparador {
|
||||
|
||||
let datosComp = {};
|
||||
datosComp.sobrecubierta = this.getDataForComp('faja');
|
||||
if(datosComp.sobrecubierta.error){
|
||||
return;
|
||||
}
|
||||
datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas
|
||||
|
||||
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
|
||||
this.comparadorFajaRunning = true;
|
||||
new Ajax('/presupuestoadmin/comparadorexteriores',
|
||||
{
|
||||
sobrecubierta: datosComp.sobrecubierta.data
|
||||
@ -1542,15 +1571,18 @@ class Comparador {
|
||||
$('#title_faja').html(window.language.Presupuestos.faja);
|
||||
self.btnInsertarFaja.addClass('d-none');
|
||||
}
|
||||
self.comparadorFajaRunning = false;
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorFajaRunning = false;
|
||||
}
|
||||
).post();
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.log(e);
|
||||
self.comparadorFajaRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1560,7 +1592,7 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando && this.comparadorGuardasRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1575,7 +1607,7 @@ class Comparador {
|
||||
}
|
||||
|
||||
datosComp.data[this.csrf_token] = this.csrf_hash;
|
||||
|
||||
this.comparadorGuardasRunning = true;
|
||||
new Ajax('/presupuestoadmin/comparadorguardas',
|
||||
datosComp.data,
|
||||
{},
|
||||
@ -1603,14 +1635,17 @@ class Comparador {
|
||||
$('#title_guardas').html(window.language.Presupuestos.Guardas);
|
||||
self.btnInsertarGuardas.addClass('d-none');
|
||||
}
|
||||
self.comparadorGuardasRunning = false;
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorGuardasRunning = false;
|
||||
}
|
||||
).post();
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.log(e);
|
||||
self.comparadorGuardasRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { getToken } from '../../../common/common.js';
|
||||
|
||||
class DatosLibro {
|
||||
|
||||
constructor(domItem, functions = {}) {
|
||||
constructor(domItem, cargando, functions = {}) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
@ -48,6 +48,15 @@ class DatosLibro {
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
this.acabadoFaja = new ClassSelect($("#acabado_faja_id"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
this.retractilado = this.domItem.find('#retractilado');
|
||||
this.retractilado5 = this.domItem.find('#retractilado5');
|
||||
@ -61,6 +70,8 @@ class DatosLibro {
|
||||
this.fajaSolapasAncho = this.domItem.find('#faja_solapas_ancho');
|
||||
this.div_faja = this.domItem.find('.faja-div');
|
||||
|
||||
this.cargando = cargando;
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -70,13 +81,43 @@ class DatosLibro {
|
||||
this.tamanio.init();
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadoSobrecubierta.init();
|
||||
this.acabadoFaja.init();
|
||||
|
||||
this.acabadoCubierta.item.on('select2:select', function () {
|
||||
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if(self.acabadoCubierta.getVal() == 0){
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoCubierta');
|
||||
}
|
||||
else{
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
||||
}
|
||||
});
|
||||
this.acabadoSobrecubierta.item.on('select2:select', function () {
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if(self.acabadoCubierta.getVal() == 0){
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoSobrecubierta');
|
||||
}
|
||||
else{
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
||||
}
|
||||
});
|
||||
this.acabadoFaja.item.on('select2:select', function () {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if(self.acabadoFaja.getVal() == 0){
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoFaja');
|
||||
}
|
||||
else{
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoFaja');
|
||||
}
|
||||
});
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
@ -98,6 +139,7 @@ class DatosLibro {
|
||||
|
||||
this.anchoSolapasCubierta.on('change', this.changeAnchoSolapasCubierta.bind(this));
|
||||
this.anchoSolapasSobrecubierta.on('change', this.changeAnchoSolapasSobrecubierta.bind(this));
|
||||
this.fajaSolapasAncho.on('change', this.changeAnchoSolapasFaja.bind(this));
|
||||
|
||||
this.paginas.on('change', this.changePaginas.bind(this));
|
||||
this.tirada.on('change', this.changeTirada.bind(this));
|
||||
@ -116,15 +158,33 @@ class DatosLibro {
|
||||
if (this.faja.prop('checked')) {
|
||||
this.div_faja.removeClass('d-none');
|
||||
$('#compFaja').val(1).trigger('change');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_faja');
|
||||
$('.acabado-faja').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
this.div_faja.addClass('d-none');
|
||||
$('#compFaja').val(0).trigger('change');
|
||||
$('.acabado-faja').addClass('d-none');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoFaja');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_faja');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_faja');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
checkMinMaxInput(event) {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
const el = event.target;
|
||||
if (el.value != "") {
|
||||
if (parseInt(el.value) < parseInt(el.min)) {
|
||||
@ -142,6 +202,9 @@ class DatosLibro {
|
||||
|
||||
changeFerro() {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.ferro.prop('checked')) {
|
||||
$(document).trigger('add-servicio-lineas', 'ferro');
|
||||
}
|
||||
@ -152,6 +215,9 @@ class DatosLibro {
|
||||
|
||||
changePrototipo() {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.prototipo.prop('checked')) {
|
||||
$(document).trigger('add-servicio-lineas', 'prototipo');
|
||||
}
|
||||
@ -163,6 +229,9 @@ class DatosLibro {
|
||||
|
||||
checkRetractilado(event) {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
switch (event.currentTarget.id) {
|
||||
case 'retractilado':
|
||||
if ($('#' + event.currentTarget.id).prop('checked')) {
|
||||
@ -254,10 +323,14 @@ class DatosLibro {
|
||||
setTimeout(() => {
|
||||
if (this.solapasCubierta.prop('checked')) {
|
||||
$('#div_solapas_ancho').removeClass('d-none');
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_cubierta');
|
||||
}
|
||||
else {
|
||||
$('#div_solapas_ancho').addClass('d-none');
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_cubierta');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
|
||||
}
|
||||
@ -269,15 +342,19 @@ class DatosLibro {
|
||||
|
||||
changeAnchoSolapasCubierta() {
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compCarasCubierta').trigger('change');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.checkSolapasGrandes('cubierta')) {
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta');
|
||||
}
|
||||
else {
|
||||
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
|
||||
}
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compCarasCubierta').trigger('change');
|
||||
}
|
||||
|
||||
|
||||
@ -285,30 +362,58 @@ class DatosLibro {
|
||||
|
||||
if (this.solapasSobrecubierta.prop('checked')) {
|
||||
this.divSolapasSobrecubierta.removeClass('d-none');
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_sobrecubierta');
|
||||
}
|
||||
else {
|
||||
this.divSolapasSobrecubierta.addClass('d-none');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_sobrecubierta');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
if ($('#compSobrecubierta').length) {
|
||||
$('#compSobrecubierta').val(0).trigger('change');
|
||||
}
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_sobrecubierta');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeAnchoSolapasSobrecubierta() {
|
||||
|
||||
|
||||
// para que se actualice el comparador
|
||||
if($('#compGramajeSobrecubierta').select2('data').length > 0)
|
||||
$('#compGramajeSobrecubierta').trigger('change');
|
||||
|
||||
if (this.checkSolapasGrandes('cubierta')) {
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.checkSolapasGrandes('sobrecubierta')) {
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
}
|
||||
else {
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeAnchoSolapasFaja() {
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compSobrecubierta').trigger('change');
|
||||
if($('#compGramajeFaja').select2('data').length > 0){
|
||||
$('#compGramajeFaja').trigger('change');
|
||||
}
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.checkSolapasGrandes('faja')) {
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_faja');
|
||||
}
|
||||
else {
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_faja');
|
||||
}
|
||||
}
|
||||
|
||||
checkSolapasGrandes(elemento) {
|
||||
@ -317,12 +422,16 @@ class DatosLibro {
|
||||
let ancho_solapas = 0.0;
|
||||
let lomo = 0.0;
|
||||
if (elemento == 'cubierta') {
|
||||
ancho_solapas = 2 * parseFloat($('solapas_ancho').val());
|
||||
lomo = parseFloat($('lomo_cubierta').val());
|
||||
ancho_solapas = 2 * parseFloat($('#solapas_ancho').val());
|
||||
lomo = parseFloat($('#lomo_cubierta').val());
|
||||
}
|
||||
else if (elemento == 'sobrecubierta') {
|
||||
ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val());
|
||||
lomo = parseFloat($('lomo_sobrecubierta').val());
|
||||
ancho_solapas = 2 * parseFloat($('#solapas_ancho_sobrecubierta').val());
|
||||
lomo = parseFloat($('#lomo_sobrecubierta').val());
|
||||
}
|
||||
else if (elemento == 'faja') {
|
||||
ancho_solapas = 2 * parseFloat($('#faja_solapas_ancho').val());
|
||||
lomo = parseFloat($('#lomo_sobrecubierta').val());
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@ -515,6 +624,7 @@ class DatosLibro {
|
||||
this.div_faja.removeClass('d-none');
|
||||
this.fajaAlto.val(datos.fajaColorAlto).trigger('change');
|
||||
this.fajaSolapasAncho.val(datos.fajaColorSolapasAncho).trigger('change');
|
||||
$('.acabado-faja').removeClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
@ -530,6 +640,8 @@ class DatosLibro {
|
||||
this.acabadoSobrecubierta.setOption(datos.acabadoSobrecubierta.id, datos.acabadoSobrecubierta.text);
|
||||
}
|
||||
|
||||
this.acabadoFaja.setOption(datos.acabadoFaja.id, datos.acabadoFaja.text);
|
||||
|
||||
this.retractilado.prop('checked', datos.retractilado);
|
||||
this.retractilado5.prop('checked', datos.retractilado5);
|
||||
this.prototipo.prop('checked', datos.prototipo);
|
||||
|
||||
@ -1796,7 +1796,7 @@ class LineasPresupuesto {
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
alto: () => {return tipoLinea == 'lp_faja' ? $('faja_alto').val() : this.getDimensionLibro().alto},
|
||||
solapas: () => uso == 'cubierta' ? $('#solapas').prop('checked') : $('#solapas_sobrecubierta').prop('checked'),
|
||||
solapas_ancho: () => uso == 'cubierta' ? $('#solapas_ancho').val() : $('#solapas_ancho_sobrecubierta').val(),
|
||||
tirada: () => $('#tirada').val(),
|
||||
|
||||
@ -79,6 +79,8 @@ class Resumen {
|
||||
|
||||
async updateTotales(event, data = {}) {
|
||||
|
||||
const self = this;
|
||||
|
||||
let updateLP = data.updateLP || true;
|
||||
let updateServicios = data.updateServicios || true;
|
||||
let updateEnvio = data.updateEnvio || true;
|
||||
@ -89,8 +91,8 @@ class Resumen {
|
||||
let totalImpresionforMargen = 0;
|
||||
let margenImpresion = 0;
|
||||
|
||||
let totalServicios = 0;
|
||||
let margenServicios = 0;
|
||||
let totalServicios = parseFloat(0);
|
||||
let margenServicios = parseFloat(0);
|
||||
|
||||
let totalEnvios = 0;
|
||||
let margenEnvios = 0;
|
||||
@ -116,28 +118,25 @@ class Resumen {
|
||||
|
||||
}
|
||||
if (rowData.check_impresion_total) {
|
||||
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||
|
||||
if (rowData.maquinaTipo == 'inkjet') {
|
||||
totalImpresion += parseFloat(rowData.totalTinta)
|
||||
totalImpresion += parseFloat(rowData.totalCorte)
|
||||
|
||||
totalImpresion += parseFloat(rowData.totalCorte)?? 0;
|
||||
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
||||
}
|
||||
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
|
||||
|
||||
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
if (!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))) {
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||
if (!isNaN(parseFloat($('#' + rowData.row_id + '_totalTinta').val()))) {
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -177,53 +176,56 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
|
||||
totalServicios += total_servicio
|
||||
margenServicios = total_servicio - coste_servicio;
|
||||
margenServicios += total_servicio - coste_servicio;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
|
||||
totalServicios += total_servicio
|
||||
margenServicios = total_servicio - coste_servicio;
|
||||
margenServicios += total_servicio - coste_servicio;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
@ -346,6 +348,10 @@ class Resumen {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
roundToTwoDecimals(num) {
|
||||
return parseFloat(num.toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
export default Resumen;
|
||||
@ -105,10 +105,13 @@ class Servicios {
|
||||
addServicio(event, servicio) {
|
||||
|
||||
if (servicio == 'acabadoCubierta') {
|
||||
this.serviciosAcabado.updateAcabadosExteriores(1, 0);
|
||||
this.serviciosAcabado.updateAcabadosExteriores(1, 0, 0);
|
||||
}
|
||||
else if (servicio == 'acabadoSobrecubierta') {
|
||||
this.serviciosAcabado.updateAcabadosExteriores(0, 1);
|
||||
this.serviciosAcabado.updateAcabadosExteriores(0, 1, 0);
|
||||
}
|
||||
else if (servicio == 'acabadoFaja') {
|
||||
this.serviciosAcabado.updateAcabadosExteriores(0, 0, 1);
|
||||
}
|
||||
else if (servicio == 'ferro'){
|
||||
const id = $('#ferro').attr('service-id');
|
||||
@ -144,6 +147,10 @@ class Servicios {
|
||||
const id = $('#serv_solapas_sobrecubierta').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
else if (servicio == 'solapas_faja'){
|
||||
const id = $('#solapas_faja').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_cubierta'){
|
||||
const id = $('#solapas_grandes_cubierta').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
@ -152,6 +159,10 @@ class Servicios {
|
||||
const id = $('#solapas_grandes_sobrecubierta').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_faja'){
|
||||
const id = $('#solapas_grandes_faja').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
}
|
||||
|
||||
removeServicio(event, servicio) {
|
||||
@ -226,6 +237,16 @@ class Servicios {
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'solapas_faja'){
|
||||
const id = $('#solapas_faja').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
let data = this.data();
|
||||
if (data && data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_cubierta'){
|
||||
const id = $('#solapas_grandes_cubierta').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
@ -246,6 +267,43 @@ class Servicios {
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_faja'){
|
||||
const id = $('#solapas_grandes_faja').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data && data.tarifa_id == id) {
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'acabadoCubierta') {
|
||||
for (let i = 0; i < this.serviciosAcabado.table.rows().count(); i++) {
|
||||
let data = this.serviciosAcabado.table.row(i).data();
|
||||
if (data.cubierta == 1) {
|
||||
this.serviciosAcabado.table.row(i).remove();
|
||||
}
|
||||
};
|
||||
this.serviciosAcabado.table.draw();
|
||||
}
|
||||
else if (servicio == 'acabadoSobrecubierta') {
|
||||
for (let i = 0; i < this.serviciosAcabado.table.rows().count(); i++) {
|
||||
let data = this.serviciosAcabado.table.row(i).data();
|
||||
if (data.sobrecubierta == 1) {
|
||||
this.serviciosAcabado.table.row(i).remove();
|
||||
}
|
||||
};
|
||||
this.serviciosAcabado.table.draw();
|
||||
}
|
||||
else if (servicio == 'acabadoFaja') {
|
||||
for (let i = 0; i < this.serviciosAcabado.table.rows().count(); i++) {
|
||||
let data = this.serviciosAcabado.table.row(i).data();
|
||||
if (data.faja == 1) {
|
||||
this.serviciosAcabado.table.row(i).remove();
|
||||
}
|
||||
};
|
||||
this.serviciosAcabado.table.draw();
|
||||
}
|
||||
}
|
||||
|
||||
async updateServicios() {
|
||||
@ -296,6 +354,9 @@ class ServiciosAcabado {
|
||||
else if (row.sobrecubierta == 1) {
|
||||
return row.nombre + ' (' + window.language.Presupuestos.sobrecubierta + ')';
|
||||
}
|
||||
else if (row.faja == 1) {
|
||||
return row.nombre + ' (' + window.language.Presupuestos.faja + ')';
|
||||
}
|
||||
else {
|
||||
return row.nombre;
|
||||
}
|
||||
@ -330,6 +391,7 @@ class ServiciosAcabado {
|
||||
{ data: 'margen' },
|
||||
{ data: 'cubierta', visible: false },
|
||||
{ data: 'sobrecubierta', visible: false },
|
||||
{ data: 'faja', visible: false },
|
||||
{
|
||||
data: function (row) {
|
||||
return `
|
||||
@ -414,10 +476,11 @@ class ServiciosAcabado {
|
||||
const proveedor_ids = this.table.rows().data().toArray().map(row => row.proveedor_id);
|
||||
const cubiertas = this.table.rows().data().toArray().map(row => row.cubierta);
|
||||
const sobrecubiertas = this.table.rows().data().toArray().map(row => row.sobrecubierta);
|
||||
const fajas = this.table.rows().data().toArray().map(row => row.fajas);
|
||||
// emparejar los tarifa_ids con los proveedor_ids
|
||||
let tarifa_data = [];
|
||||
for (let i = 0; i < tarifa_ids.length; i++) {
|
||||
tarifa_data.push({ tarifa_id: tarifa_ids[i], proveedor_id: proveedor_ids[i], cubierta: cubiertas[i], sobrecubierta: sobrecubiertas[i] });
|
||||
tarifa_data.push({ tarifa_id: tarifa_ids[i], proveedor_id: proveedor_ids[i], cubierta: cubiertas[i], sobrecubierta: sobrecubiertas[i], faja: fajas[i] });
|
||||
}
|
||||
|
||||
let tirada = 0;
|
||||
@ -444,25 +507,33 @@ class ServiciosAcabado {
|
||||
|
||||
}
|
||||
|
||||
updateAcabadosExteriores(cubierta, sobrecubierta) {
|
||||
updateAcabadosExteriores(cubierta, sobrecubierta, faja) {
|
||||
|
||||
this.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.cubierta == cubierta && data.sobrecubierta == sobrecubierta) {
|
||||
if (data && (data.cubierta == cubierta && data.sobrecubierta == sobrecubierta && data.faja == faja)) {
|
||||
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
|
||||
let tarifa_id = 0;
|
||||
let uso = 'cubierta';
|
||||
if (cubierta == 1) {
|
||||
tarifa_id = $('#acabado_cubierta_id').val();
|
||||
}
|
||||
else if (sobrecubierta == 1) {
|
||||
tarifa_id = $('#acabado_sobrecubierta_id').val();
|
||||
uso = 'sobrecubierta';
|
||||
}
|
||||
else if (faja == 1) {
|
||||
tarifa_id = $('#acabado_faja_id').val();
|
||||
uso = 'faja';
|
||||
}
|
||||
|
||||
this.getPresupuestoAcabado(tarifa_id, cubierta == 1 ? 'cubierta' : 'sobrecubierta', null);
|
||||
|
||||
|
||||
this.getPresupuestoAcabado(tarifa_id, uso, null);
|
||||
}
|
||||
|
||||
getPresupuestoAcabado(tarifa_id = -1, uso = null, updateSelect = null) {
|
||||
@ -491,12 +562,16 @@ class ServiciosAcabado {
|
||||
if (response.values) {
|
||||
response.values[0].cubierta = 0;
|
||||
response.values[0].sobrecubierta = 0;
|
||||
response.values[0].faja = 0;
|
||||
if (uso == 'cubierta') {
|
||||
response.values[0].cubierta = 1;
|
||||
}
|
||||
else if (uso == 'sobrecubierta') {
|
||||
response.values[0].sobrecubierta = 1;
|
||||
}
|
||||
else if (uso == 'faja') {
|
||||
response.values[0].faja = 1;
|
||||
}
|
||||
if (updateSelect != null) {
|
||||
|
||||
self.table.row(updateSelect.closest('tr')).data(response.values[0]).draw();
|
||||
|
||||
@ -96,8 +96,9 @@ class TiradasAlernativas {
|
||||
|
||||
self.table.row(row).remove().draw();
|
||||
|
||||
$(document).trigger('update-envios', { tirada_inicial: $('#tirada').val(), tirada: data.tirada });
|
||||
$('#tirada').val(data.tirada).trigger('change');
|
||||
|
||||
$(document).trigger('update-envios', { tirada_inicial: $('#tirada').val(), tirada: data.tirada });
|
||||
});
|
||||
|
||||
$(document).on('update-tiradas-alternativas', async function () {
|
||||
@ -181,6 +182,8 @@ class TiradasAlernativas {
|
||||
json_acabados: this.generate_json_servicios('acabados'),
|
||||
json_encuadernaciones: this.generate_json_servicios('encuadernaciones'),
|
||||
json_manipulado: this.generate_json_servicios('manipulado'),
|
||||
json_presimpresion: this.generate_json_servicios('presimpresion'),
|
||||
json_extra: this.generate_json_servicios('extra'),
|
||||
json_envios: envios,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
@ -190,6 +193,8 @@ class TiradasAlernativas {
|
||||
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked') ? 1 : 0,
|
||||
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0,
|
||||
lomo: $('#lomo_cubierta').val(),
|
||||
faja_alto: $('#faja_alto').val(),
|
||||
solapas_faja: $('#faja_solapas_ancho').val(),
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
|
||||
@ -92,6 +92,7 @@ class DatosGenerales {
|
||||
|
||||
// Eventos
|
||||
this.checkFormatoPersonalizado.bind('change', this.#handleFormatoLibro.bind(this));
|
||||
this.formatoLibro.item.on('change', this.#handleFormatoLibro.bind(this));
|
||||
this.tiposLibro.on('click', this.#handleTipolibro.bind(this));
|
||||
this.domItem.find('.input-paginas').on('change', this.#handlePaginas.bind(this));
|
||||
this.anchoPersonalizado.on('blur', this.#handleCheckFormatoPersonalizado.bind(this));
|
||||
@ -674,6 +675,8 @@ class DatosGenerales {
|
||||
this.formValidation.revalidateField('papel_formato_ancho');
|
||||
this.formValidation.revalidateField('papel_formato_alto');
|
||||
}
|
||||
const alto = this.getDimensionLibro().alto;
|
||||
$('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + alto + ' mm');
|
||||
}
|
||||
|
||||
#checkValue(event){
|
||||
|
||||
@ -33,12 +33,12 @@ class DisenioCubierta {
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho},
|
||||
alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto},
|
||||
solapas: () => {return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val()},
|
||||
lomo: () => {return $('#lc').val()},
|
||||
tapa_dura: () => {return this.tapaBlanda.hasClass("selected") ? 0 : 1},
|
||||
tirada: () => {return this.presupuestoCliente.datosGenerales.getTiradas()[0]},
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
|
||||
solapas: () => { return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val() },
|
||||
lomo: () => { return $('#lc').val() },
|
||||
tapa_dura: () => { return this.tapaBlanda.hasClass("selected") ? 0 : 1 },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
}
|
||||
);
|
||||
|
||||
@ -77,11 +77,47 @@ class DisenioCubierta {
|
||||
|
||||
this.configuracionFaja = this.domItem.find(".config-faja");
|
||||
this.faja = this.domItem.find("#addFaja");
|
||||
this.papelFaja = new ClassSelect($("#papelFaja"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
sobrecubierta: 1,
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return $('#altoFaja').val() },
|
||||
solapas: () => { return $('#solapasFaja').val() },
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
}
|
||||
);
|
||||
this.gramajeFaja = new ClassSelect($("#gramajeFaja"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectGramaje"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
papel: () => { return this.papelFaja.getVal() },
|
||||
sobrecubierta: 1,
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return $('#altoFaja').val() },
|
||||
solapas: () => { return $('#solapasFaja').val() },
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
this.solapasSobrecubierta = this.domItem.find("#solapasSobrecubierta");
|
||||
this.textoSolapasSobrecubierta = this.domItem.find("#textoLimitesSolapasSobrecubierta");
|
||||
|
||||
this.solapasFaja = this.domItem.find("#solapasFaja");
|
||||
this.altoFaja = this.domItem.find("#altoFaja");
|
||||
this.textoSolapasFaja = this.domItem.find("#textoLimitesSolapasFaja");
|
||||
|
||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
||||
this.cosido = $(this.domItem.find("#cosido")[0]);
|
||||
@ -117,6 +153,16 @@ class DisenioCubierta {
|
||||
}
|
||||
);
|
||||
|
||||
this.acabadoFaja = new ClassSelect($("#acabadoFaja"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
this.initValidation();
|
||||
|
||||
// Creamos un nuevo observador que detecta cambios en los atributos
|
||||
@ -153,6 +199,10 @@ class DisenioCubierta {
|
||||
this.papelEspecial.init();
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadoSobrecubierta.init();
|
||||
this.acabadoFaja.init();
|
||||
|
||||
this.papelFaja.init();
|
||||
this.gramajeFaja.init();
|
||||
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
@ -171,10 +221,12 @@ class DisenioCubierta {
|
||||
}
|
||||
);
|
||||
this.faja.on('change', () => {
|
||||
this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none")
|
||||
}
|
||||
);
|
||||
this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none");
|
||||
const div = $('#divExtras'); // Selecciona el div
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
});
|
||||
|
||||
this.papelFaja.item.on('change', () => { this.gramajeFaja.empty(); });
|
||||
|
||||
// Observadores
|
||||
this.observer.observe(this.tapaBlanda[0], { attributes: true });
|
||||
@ -185,7 +237,7 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta) {
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta, datosFaja) {
|
||||
|
||||
this.papelCubierta = datosCubierta.papel.id;
|
||||
this.gramaje = datosCubierta.gramaje;
|
||||
@ -234,6 +286,15 @@ class DisenioCubierta {
|
||||
this.acabadoSobrecubierta.setOption(datosSobrecubierta.acabado.id, datosSobrecubierta.acabado.text);
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(datosFaja) === '[object Object]') {
|
||||
this.faja.trigger('click');
|
||||
this.papelFaja.setOption(datosFaja.papel.papel_id, datosFaja.papel.papel);
|
||||
this.gramajeFaja.setOption(datosFaja.papel.gramaje, datosFaja.papel.gramaje);
|
||||
this.solapasFaja.val(datosFaja.solapas_ancho);
|
||||
this.altoFaja.val(datosFaja.alto);
|
||||
this.acabadoFaja.setOption(datosFaja.acabado.id, datosFaja.acabado.text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -371,6 +432,36 @@ class DisenioCubierta {
|
||||
}
|
||||
}
|
||||
},
|
||||
div_extras: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
|
||||
const div = $('#divExtras'); // Selecciona el div
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
|
||||
if($("#addFaja").prop("checked") == false)
|
||||
return true;
|
||||
const papelFaja = $('#papelFaja').select2('data').length > 0;
|
||||
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
|
||||
if (papelFaja && gramajeFaja) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].extras_cubierta}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
@ -388,6 +479,8 @@ class DisenioCubierta {
|
||||
case 'div_gramaje_cubierta':
|
||||
case 'div_papel_especial_cubierta':
|
||||
return '.col-sm-10';
|
||||
case 'div_extras':
|
||||
return '.col-sm-12';
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
}
|
||||
@ -638,16 +731,15 @@ class DisenioCubierta {
|
||||
|
||||
try {
|
||||
if (!this.faja.is(":checked")) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
let faja = {};
|
||||
faja.alto = this.domItem.find("#altoFaja").val();
|
||||
let papel = this.domItem.find("#papelFaja").children("option:selected").val();
|
||||
faja.papel = papel.split('_')[0];
|
||||
faja.gramaje = papel.split('_')[1];
|
||||
faja.papel = this.papelFaja.getVal();
|
||||
faja.gramaje = this.gramajeFaja.getVal();
|
||||
faja.solapas = this.domItem.find("#solapasFaja").val();
|
||||
faja.plastificado = this.domItem.find("#plastificadoFaja").children("option:selected").val();
|
||||
faja.acabado = this.acabadoFaja.getVal();
|
||||
return faja;
|
||||
}
|
||||
|
||||
|
||||
@ -178,6 +178,7 @@ class PresupuestoCliente {
|
||||
this.disenioCubierta.solapasSobrecubierta.attr('max', response);
|
||||
this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm");
|
||||
this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm");
|
||||
this.disenioCubierta.textoSolapasFaja.text("Entre 60 y " + response + " mm");
|
||||
},
|
||||
() => { }
|
||||
).post();
|
||||
@ -810,7 +811,7 @@ class PresupuestoCliente {
|
||||
console.log("Error al cargar diseño interior: " + e);
|
||||
}
|
||||
try {
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta, response.data.faja);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("Error al cargar diseño cubierta: " + e);
|
||||
|
||||
Reference in New Issue
Block a user