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">
|
||||
|
||||
Reference in New Issue
Block a user