mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en cubierta
This commit is contained in:
@ -580,7 +580,8 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos
|
||||
$routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']);
|
||||
|
||||
$routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1');
|
||||
$routes->post('comparadorplana', 'Presupuestoadmin::obtenerComparadorPlana');
|
||||
$routes->post('comparadorinterior', 'Presupuestoadmin::obtenerComparadorInterior');
|
||||
$routes->post('comparadorexteriores', 'Presupuestoadmin::obtenerComparadorExteriores');
|
||||
$routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico');
|
||||
$routes->get('papelgramaje', 'Presupuestoadmin::getGramaje');
|
||||
});
|
||||
|
||||
@ -82,9 +82,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -104,36 +104,36 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) :
|
||||
if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)):
|
||||
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', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
||||
$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);
|
||||
return redirect()->to(site_url('presupuestoadmin/edit/' . $id))->with('sweet-success', $message);
|
||||
else :
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
@ -167,20 +167,20 @@ class Presupuestoadmin 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);
|
||||
$presupuestoEntity = $this->model->find($id);
|
||||
|
||||
if ($presupuestoEntity == false) :
|
||||
if ($presupuestoEntity == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -252,16 +252,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$successfulResult = false;
|
||||
} else {
|
||||
|
||||
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('Presupuestos.presupuesto'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
@ -273,16 +273,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
endif;
|
||||
}
|
||||
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $presupuestoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.';
|
||||
// $message .= anchor("admin/presupuestos/{$id}/edit", lang('Basic.global.continueEditing') . '?');
|
||||
//$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
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:
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -296,14 +296,14 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
endif;
|
||||
else :
|
||||
else:
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
if($presupuestoEntity->estado_id==1 && $presupuestoEntity->confirmar==1){
|
||||
if ($presupuestoEntity->estado_id == 1 && $presupuestoEntity->confirmar == 1) {
|
||||
$this->model->confirmarPresupuesto($id);
|
||||
PresupuestoService::crearPedido($id);
|
||||
}
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
@ -345,7 +345,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
// Lineas Presupuesto
|
||||
[$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->getLineasPresupuesto($presupuestoEntity);
|
||||
$this->viewData['presupuestoEntity']->cambios_lineas=$cambios_lineas;
|
||||
$this->viewData['presupuestoEntity']->cambios_lineas = $cambios_lineas;
|
||||
|
||||
// Servicios
|
||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||
@ -353,10 +353,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
||||
$this->viewData['serviciosExtra'] = $this->getServiciosExtra();
|
||||
|
||||
|
||||
[$cambios_en_servicios, $servicios] = $this->getLineasServicios($presupuestoEntity);
|
||||
$this->viewData['presupuestoEntity']->cambios_servicios=$cambios_en_servicios;
|
||||
|
||||
$this->viewData['presupuestoEntity']->cambios_servicios = $cambios_en_servicios;
|
||||
|
||||
$this->viewData['serviciosEncuadernacionList'] = $servicios->serviciosEncuadernacion;
|
||||
$this->viewData['serviciosAcabadosList'] = $servicios->serviciosAcabado;
|
||||
$this->viewData['serviciosManipuladoList'] = $servicios->serviciosManipulado;
|
||||
@ -365,8 +365,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
// Direciones presupuesto
|
||||
[$cambios_en_direcciones, $this->viewData['direccionesList']] = $this->getLineasDirecciones($presupuestoEntity);
|
||||
$this->viewData['presupuestoEntity']->cambios_direcciones=$cambios_en_direcciones;
|
||||
|
||||
$this->viewData['presupuestoEntity']->cambios_direcciones = $cambios_en_direcciones;
|
||||
|
||||
$this->viewData['POD'] = $this->getPOD();
|
||||
|
||||
$this->viewData['serviciosAutomaticos'] = [
|
||||
@ -386,7 +386,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
||||
if($presupuestoEntity->is_duplicado){
|
||||
if ($presupuestoEntity->is_duplicado) {
|
||||
$this->model->removeIsDuplicado($presupuestoEntity->id);
|
||||
}
|
||||
|
||||
@ -406,22 +406,23 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
public function delete($id = null)
|
||||
{
|
||||
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
|
||||
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc) . '.' . static::$singularObjectNameCc));
|
||||
} else {
|
||||
$objName = lang('Basic.global.record');
|
||||
}
|
||||
|
||||
if (!$this->soft_delete){
|
||||
|
||||
if (!$this->soft_delete) {
|
||||
|
||||
if (!$this->model->delete($id)) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$rawResult = $this->model->where('id',$id)
|
||||
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag])
|
||||
$rawResult = $this->model->where('id', $id)
|
||||
->set([
|
||||
'deleted_at' => $datetime->format('Y-m-d H:i:s'),
|
||||
'is_deleted' => $this->delete_flag
|
||||
])
|
||||
->update();
|
||||
if (!$rawResult) {
|
||||
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
|
||||
@ -463,7 +464,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function cargar($id){
|
||||
public function cargar($id)
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$modelPapelFormato = new PapelFormatoModel();
|
||||
@ -474,12 +476,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$presupuesto = $this->model->find($id);
|
||||
$data = [];
|
||||
if ($presupuesto) {
|
||||
|
||||
|
||||
$data['lc'] = $presupuesto->lomo_cubierta;
|
||||
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
||||
$data['tipo_impresion'] = $presupuesto->tipo_impresion_id;
|
||||
$data['cosido'] = $presupuesto->cosido;
|
||||
|
||||
|
||||
$data['datosGenerales']['id'] = $presupuesto->id;
|
||||
$data['datosGenerales']['state'] = intval($presupuesto->estado_id);
|
||||
$data['datosGenerales']['updated_at'] = date('d/m/Y', strtotime($presupuesto->updated_at));
|
||||
@ -495,7 +497,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$data['datosGenerales']['cliente']['nombre'] = $modelCliente->getNombre($presupuesto->cliente_id);
|
||||
$data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente;
|
||||
|
||||
|
||||
|
||||
$data['datosLibro']['papelFormatoId'] = $presupuesto->papel_formato_id;
|
||||
$data['datosLibro']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id);
|
||||
$data['datosLibro']['papelFormatoPersonalizado'] = $presupuesto->papel_formato_personalizado;
|
||||
@ -536,7 +538,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$item['papel_nombre'] = $modelPapelGenerico->getNombre($item['papel_id'])['nombre'];
|
||||
}
|
||||
$data['comparador']['posPagColor'] = $presupuesto->comp_pos_paginas_color;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -609,9 +611,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
public function obtenerComparadorPlana(){
|
||||
public function obtenerComparadorInterior()
|
||||
{
|
||||
|
||||
if($this->request->isAJAX()){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$cliente_id = $this->request->getPost('cliente_id');
|
||||
$datosPedido = $this->request->getPost('datosPedido');
|
||||
@ -623,9 +626,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$tipo_impresion_id = $this->request->getPost('tipo_impresion_id');
|
||||
$uso = $this->request->getPost('uso');
|
||||
|
||||
$tipo_maquina = $this->request->getPost('tipo_maquina');
|
||||
|
||||
$data = array(
|
||||
'cliente_id' => $cliente_id,
|
||||
'datosPedido' => (object)$datosPedido,
|
||||
'datosPedido' => (object) $datosPedido,
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'papelInteriorDiferente' => true,
|
||||
@ -636,15 +641,94 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
'uso' => $uso
|
||||
);
|
||||
|
||||
$data = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data, true);
|
||||
if ($tipo_maquina == 'rotativa') {
|
||||
$data['papelInteriorDiferente'] = false;
|
||||
$lineas = PresupuestoClienteService::obtenerPresupuestoClienteInteriorRotativa($data, true);
|
||||
} else
|
||||
$lineas = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data, true);
|
||||
return $this->respond(
|
||||
[
|
||||
'status' => 1,
|
||||
'data' => $data
|
||||
'data' => $lineas
|
||||
]
|
||||
);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
else{
|
||||
}
|
||||
|
||||
public function obtenerComparadorExteriores()
|
||||
{
|
||||
|
||||
$resultado = [];
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$cubierta = $this->request->getPost('cubierta') ?? false;
|
||||
$sobrecubierta = $this->request->getPost('sobrecubierta') ?? false;
|
||||
|
||||
// cubierta y sobrecubierta siempre colorhq
|
||||
$isColor = true;
|
||||
$isHq = true;
|
||||
|
||||
if ($cubierta) {
|
||||
|
||||
$cliente_id = $cubierta['cliente_id'];
|
||||
$datosPedido = $cubierta['datosPedido'];
|
||||
$papel_generico = $cubierta['papel_generico'];
|
||||
$gramaje = $cubierta['gramaje'];
|
||||
$paginas_color = $this->request->getPost('paginas_color') ?? 0;
|
||||
$tipo_impresion_id = $this->request->getPost('tipo_impresion_id');
|
||||
$uso = $this->request->getPost('uso');
|
||||
$lomoRedondo = $cubierta['lomoRedondo'] ?? false;
|
||||
|
||||
$data = array(
|
||||
'cliente_id' => $cliente_id,
|
||||
'datosPedido' => (object) $datosPedido,
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'paginas_color' => $paginas_color,
|
||||
'isColor' => $isColor,
|
||||
'isHq' => $isHq,
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'uso' => $uso,
|
||||
'lomoRedondo' => $lomoRedondo
|
||||
);
|
||||
$lineas = PresupuestoClienteService::obtenerCubierta($data, true);
|
||||
$resultado['cubierta'] = $lineas;
|
||||
}
|
||||
|
||||
if ($sobrecubierta) {
|
||||
|
||||
$cliente_id = $sobrecubierta['cliente_id'];
|
||||
$datosPedido = $sobrecubierta['datosPedido'];
|
||||
$papel_generico = $sobrecubierta['papel_generico'];
|
||||
$gramaje = $sobrecubierta['gramaje'];
|
||||
$paginas_color = $this->request->getPost('paginas_color') ?? 0;
|
||||
$tipo_impresion_id = $this->request->getPost('tipo_impresion_id');
|
||||
$uso = $this->request->getPost('uso');
|
||||
|
||||
$data = array(
|
||||
'cliente_id' => $cliente_id,
|
||||
'datosPedido' => (object) $datosPedido,
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'paginas_color' => $paginas_color,
|
||||
'isColor' => $isColor,
|
||||
'isHq' => $isHq,
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'uso' => $uso
|
||||
);
|
||||
$lineas = PresupuestoClienteService::obtenerSobrecubierta($data, true);
|
||||
$resultado['sobrecubierta'] = $lineas;
|
||||
}
|
||||
|
||||
return $this->respond(
|
||||
[
|
||||
'status' => 1,
|
||||
'data' => $resultado
|
||||
]
|
||||
);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
@ -687,41 +771,41 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
$resourceData = $this->model->getResource($searchValues, $tipo_impresion_id)->orderBy($order1, $dir1)->orderBy($order2, $dir2)
|
||||
->orderBy($order3, $dir3)->limit($length, $start)->get()->getResultObject();
|
||||
foreach ($resourceData as $item) :
|
||||
if (isset($item->comentarios_pdf) && strlen($item->comentarios_pdf) > 100) :
|
||||
foreach ($resourceData as $item):
|
||||
if (isset($item->comentarios_pdf) && strlen($item->comentarios_pdf) > 100):
|
||||
$item->comentarios_pdf = character_limiter($item->comentarios_pdf, 100);
|
||||
endif;
|
||||
if (isset($item->causa_cancelacion) && strlen($item->causa_cancelacion) > 100) :
|
||||
if (isset($item->causa_cancelacion) && strlen($item->causa_cancelacion) > 100):
|
||||
$item->causa_cancelacion = character_limiter($item->causa_cancelacion, 100);
|
||||
endif;
|
||||
if (isset($item->comentarios_cliente) && strlen($item->comentarios_cliente) > 100) :
|
||||
if (isset($item->comentarios_cliente) && strlen($item->comentarios_cliente) > 100):
|
||||
$item->comentarios_cliente = character_limiter($item->comentarios_cliente, 100);
|
||||
endif;
|
||||
if (isset($item->comentarios_safekat) && strlen($item->comentarios_safekat) > 100) :
|
||||
if (isset($item->comentarios_safekat) && strlen($item->comentarios_safekat) > 100):
|
||||
$item->comentarios_safekat = character_limiter($item->comentarios_safekat, 100);
|
||||
endif;
|
||||
if (isset($item->comentarios_tarifa) && strlen($item->comentarios_tarifa) > 100) :
|
||||
if (isset($item->comentarios_tarifa) && strlen($item->comentarios_tarifa) > 100):
|
||||
$item->comentarios_tarifa = character_limiter($item->comentarios_tarifa, 100);
|
||||
endif;
|
||||
if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) :
|
||||
if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100):
|
||||
$item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100);
|
||||
endif;
|
||||
if (isset($item->tirada_alternativa_json_data) && strlen($item->tirada_alternativa_json_data) > 100) :
|
||||
if (isset($item->tirada_alternativa_json_data) && strlen($item->tirada_alternativa_json_data) > 100):
|
||||
$item->tirada_alternativa_json_data = character_limiter($item->tirada_alternativa_json_data, 100);
|
||||
endif;
|
||||
if (isset($item->titulo) && strlen($item->titulo) > 100) :
|
||||
if (isset($item->titulo) && strlen($item->titulo) > 100):
|
||||
$item->titulo = character_limiter($item->titulo, 100);
|
||||
endif;
|
||||
if (isset($item->paginas_color_posicion) && strlen($item->paginas_color_posicion) > 100) :
|
||||
if (isset($item->paginas_color_posicion) && strlen($item->paginas_color_posicion) > 100):
|
||||
$item->paginas_color_posicion = character_limiter($item->paginas_color_posicion, 100);
|
||||
endif;
|
||||
if (isset($item->aprobado_json_data) && strlen($item->aprobado_json_data) > 100) :
|
||||
if (isset($item->aprobado_json_data) && strlen($item->aprobado_json_data) > 100):
|
||||
$item->aprobado_json_data = character_limiter($item->aprobado_json_data, 100);
|
||||
endif;
|
||||
if (isset($item->comparador_json_data) && strlen($item->comparador_json_data) > 100) :
|
||||
if (isset($item->comparador_json_data) && strlen($item->comparador_json_data) > 100):
|
||||
$item->comparador_json_data = character_limiter($item->comparador_json_data, 100);
|
||||
endif;
|
||||
if (isset($item->ws_externo_json_data) && strlen($item->ws_externo_json_data) > 100) :
|
||||
if (isset($item->ws_externo_json_data) && strlen($item->ws_externo_json_data) > 100):
|
||||
$item->ws_externo_json_data = character_limiter($item->ws_externo_json_data, 100);
|
||||
endif;
|
||||
endforeach;
|
||||
@ -731,7 +815,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$isColor = $reqData['color'] ?? false;
|
||||
$isHq = $reqData['hq'] ?? false;
|
||||
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => intval($reqData['paginas']) ?? 0,
|
||||
'tirada' => intval($reqData['tirada']) ?? 0,
|
||||
'merma' => intval($reqData['merma']) ?? 0,
|
||||
@ -757,7 +841,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$datosTipolog = $reqData['negro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
$data = (object) array(
|
||||
'negro' => floatval($reqData['negro']) ?? 0,
|
||||
'cyan' => floatval($reqData['cyan']) ?? 0,
|
||||
'magenta' => floatval($reqData['magenta']) ?? 0,
|
||||
@ -801,7 +885,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
} else if ($type == 'interior_rot') {
|
||||
|
||||
$paginas = (object)array(
|
||||
$paginas = (object) array(
|
||||
'negro' => intval($reqData['paginas_negro'] ?? 0),
|
||||
'color' => intval($reqData['paginas_color'] ?? 0),
|
||||
);
|
||||
@ -809,7 +893,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$datosTipolog = $reqData['negro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
$data = (object) array(
|
||||
'negro' => floatval($reqData['negro']) ?? 0,
|
||||
'cyan' => floatval($reqData['cyan']) ?? 0,
|
||||
'magenta' => floatval($reqData['magenta']) ?? 0,
|
||||
@ -828,7 +912,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
'cliente_id' => $cliente_id,
|
||||
'datosTipolog' => $datosTipolog
|
||||
];
|
||||
|
||||
|
||||
$resourceData = PresupuestoService::obtenerComparadorRotativa($input_data);
|
||||
|
||||
} else if ($type == 'cubierta' || $type == 'sobrecubierta') {
|
||||
@ -844,10 +928,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'isColor' => 1, // Cubierta y sobrecubierta siempre color HQ
|
||||
'isHq' => 1,
|
||||
'isHq' => 1,
|
||||
'cliente_id' => $cliente_id,
|
||||
);
|
||||
|
||||
|
||||
$resourceData = PresupuestoService::obtenerComparadorPlana($input_data);
|
||||
}
|
||||
|
||||
@ -900,25 +984,22 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
else if ($tipo == 'duplicar'){
|
||||
} else if ($tipo == 'duplicar') {
|
||||
$presupuesto_id = $reqData['presupuesto_id'] ?? -1;
|
||||
$result = $this->duplicarPresupuesto($presupuesto_id);
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
if($result['success']){
|
||||
if ($result['success']) {
|
||||
$data = [
|
||||
'id' => $result['id'],
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$data = [
|
||||
'error' => $result['message'],
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
}
|
||||
@ -942,7 +1023,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
switch ($tipo_impresion_id) {
|
||||
|
||||
// Fresado tapa dura
|
||||
// Fresado tapa dura
|
||||
case 1:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleFresadoTD');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -950,7 +1031,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_fresasdo_tapa_dura");
|
||||
break;
|
||||
|
||||
// Fresado tapa blanda
|
||||
// Fresado tapa blanda
|
||||
case 2:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleFresadoTB');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -958,7 +1039,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_fresasdo_tapa_blanda");
|
||||
break;
|
||||
|
||||
// Cosido tapa dura
|
||||
// Cosido tapa dura
|
||||
case 3:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleCosidoTD');
|
||||
$viewData['isCosido'] = 1;
|
||||
@ -966,7 +1047,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_cosido_tapa_dura");
|
||||
break;
|
||||
|
||||
// Cosido tapa blanda
|
||||
// Cosido tapa blanda
|
||||
case 4:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleCosidoTB');
|
||||
$viewData['isCosido'] = 1;
|
||||
@ -974,7 +1055,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_cosido_tapa_blanda");
|
||||
break;
|
||||
|
||||
// Espiral tapa dura
|
||||
// Espiral tapa dura
|
||||
case 5:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleEspiralTD');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -982,7 +1063,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_espiral_tapa_dura");
|
||||
break;
|
||||
|
||||
// Espiral tapa blanda
|
||||
// Espiral tapa blanda
|
||||
case 6:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleEspiralTB');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -990,7 +1071,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_espiral_tapa_blanda");
|
||||
break;
|
||||
|
||||
// Wire-o tapa dura
|
||||
// Wire-o tapa dura
|
||||
case 7:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleWireoTD');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -998,7 +1079,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_wireo_tapa_dura");
|
||||
break;
|
||||
|
||||
// Wire-o tapa blanda
|
||||
// Wire-o tapa blanda
|
||||
case 8:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleWireoTB');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -1006,7 +1087,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$breadcrumbTitle = lang("App.menu_libros_wireo_tapa_blanda");
|
||||
break;
|
||||
|
||||
// Grapado
|
||||
// Grapado
|
||||
case 21:
|
||||
$viewData['pageTitle'] = lang('Presupuestos.moduleTitleGrapado');
|
||||
$viewData['isCosido'] = 0;
|
||||
@ -1026,7 +1107,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
|
||||
return $viewData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Duplica un presupuesto dado por su ID.
|
||||
@ -1041,67 +1122,68 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
* Si ocurre una excepción, la clave 'success' será false y una clave 'message' contendrá el mensaje de la excepción.
|
||||
* @throws \Exception Si ocurre un error durante la operación.
|
||||
*/
|
||||
private function duplicarPresupuesto($id){
|
||||
private function duplicarPresupuesto($id)
|
||||
{
|
||||
|
||||
try{
|
||||
|
||||
$presupuesto = $this->model->find($id);
|
||||
$presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado');
|
||||
$presupuesto->is_duplicado = 1;
|
||||
$presupuesto->estado_id = 1;
|
||||
$new_id = $this->model->insert($presupuesto);
|
||||
|
||||
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) {
|
||||
$acabado->presupuesto_id = $new_id;
|
||||
$presupuestoAcabadosModel->insert($acabado);
|
||||
}
|
||||
|
||||
$presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) {
|
||||
$encuadernacion->presupuesto_id = $new_id;
|
||||
$presupuestoEncuadernacionesModel->insert($encuadernacion);
|
||||
}
|
||||
|
||||
$presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
|
||||
foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) {
|
||||
$manipulado->presupuesto_id = $new_id;
|
||||
$presupuestoManipuladosModel->insert($manipulado);
|
||||
}
|
||||
|
||||
$presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel');
|
||||
foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) {
|
||||
$preimpresion->presupuesto_id = $new_id;
|
||||
$presupuestoPreimpresionesModel->insert($preimpresion);
|
||||
}
|
||||
try {
|
||||
|
||||
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
|
||||
$servicioExtra->presupuesto_id = $new_id;
|
||||
$presupuestoServiciosExtraModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
|
||||
$direccion->presupuesto_id = $new_id;
|
||||
$presupuestoDireccionesModel->insert($direccion);
|
||||
}
|
||||
|
||||
$presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'id' => $new_id
|
||||
];
|
||||
|
||||
}catch(\Exception $e){
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
$presupuesto = $this->model->find($id);
|
||||
$presupuesto->titulo = $presupuesto->titulo . ' - ' . lang('Presupuestos.duplicado');
|
||||
$presupuesto->is_duplicado = 1;
|
||||
$presupuesto->estado_id = 1;
|
||||
$new_id = $this->model->insert($presupuesto);
|
||||
|
||||
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) {
|
||||
$acabado->presupuesto_id = $new_id;
|
||||
$presupuestoAcabadosModel->insert($acabado);
|
||||
}
|
||||
|
||||
$presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) {
|
||||
$encuadernacion->presupuesto_id = $new_id;
|
||||
$presupuestoEncuadernacionesModel->insert($encuadernacion);
|
||||
}
|
||||
|
||||
$presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
|
||||
foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) {
|
||||
$manipulado->presupuesto_id = $new_id;
|
||||
$presupuestoManipuladosModel->insert($manipulado);
|
||||
}
|
||||
|
||||
$presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel');
|
||||
foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) {
|
||||
$preimpresion->presupuesto_id = $new_id;
|
||||
$presupuestoPreimpresionesModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
|
||||
$servicioExtra->presupuesto_id = $new_id;
|
||||
$presupuestoServiciosExtraModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
|
||||
$direccion->presupuesto_id = $new_id;
|
||||
$presupuestoDireccionesModel->insert($direccion);
|
||||
}
|
||||
|
||||
$presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'id' => $new_id
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
@ -1223,11 +1305,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
protected function getClienteListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];
|
||||
if (!empty($selId)) :
|
||||
if (!empty($selId)):
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
|
||||
$selOption = $clienteModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
if (!empty($selOption)):
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
@ -1257,7 +1339,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
$model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel');
|
||||
$data = $model->getServiciosAcabadoCubierta();
|
||||
array_unshift($data, (object)['id' => '', 'label' => lang('Basic.global.None')]);
|
||||
array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -1265,38 +1347,39 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
$model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel');
|
||||
$data = $model->getServiciosAcabadoSobrecubierta();
|
||||
array_unshift($data, (object)['id' => '', 'label' => lang('Basic.global.None')]);
|
||||
array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getPapelGenerico(){
|
||||
public function getPapelGenerico()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$POD_value = $this->getPOD();
|
||||
$tirada = $this->request->getGet("tirada");
|
||||
$isPOD = intval($tirada)<=intval($POD_value);
|
||||
$isPOD = intval($tirada) <= intval($POD_value);
|
||||
|
||||
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
|
||||
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
|
||||
|
||||
$tipo = $this->request->getGet("tipo");
|
||||
|
||||
|
||||
$uso = $this->request->getGet("uso") ?? 'interior';
|
||||
$cubierta = false;
|
||||
if($uso=='cubierta'){
|
||||
if ($uso == 'cubierta') {
|
||||
$cubierta = true;
|
||||
}
|
||||
$sobrecubierta = false;
|
||||
if($uso=='sobrecubierta'){
|
||||
if ($uso == 'sobrecubierta') {
|
||||
$sobrecubierta = true;
|
||||
}
|
||||
$guardas = false;
|
||||
if($uso=='guardas'){
|
||||
if ($uso == 'guardas') {
|
||||
$guardas = true;
|
||||
}
|
||||
$rotativa = false;
|
||||
if($uso=='rotativa'){
|
||||
if ($uso == 'rotativa') {
|
||||
$rotativa = true;
|
||||
}
|
||||
|
||||
@ -1314,35 +1397,36 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getGramaje(){
|
||||
public function getGramaje()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$papel_generico_id = $this->request->getGet("papel_generico");
|
||||
|
||||
$POD_value = $this->getPOD();
|
||||
$tirada = $this->request->getGet("tirada");
|
||||
$isPOD = intval($tirada)<=intval($POD_value);
|
||||
$isPOD = intval($tirada) <= intval($POD_value);
|
||||
|
||||
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
|
||||
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
|
||||
|
||||
$tipo = $this->request->getGet("tipo");
|
||||
|
||||
|
||||
$uso = $this->request->getGet("uso") ?? 'interior';
|
||||
$cubierta = false;
|
||||
if($uso=='cubierta'){
|
||||
if ($uso == 'cubierta') {
|
||||
$cubierta = true;
|
||||
}
|
||||
$sobrecubierta = false;
|
||||
if($uso=='sobrecubierta'){
|
||||
if ($uso == 'sobrecubierta') {
|
||||
$sobrecubierta = true;
|
||||
}
|
||||
$guardas = false;
|
||||
if($uso=='guardas'){
|
||||
if ($uso == 'guardas') {
|
||||
$guardas = true;
|
||||
}
|
||||
$rotativa = false;
|
||||
if($uso=='rotativa'){
|
||||
if ($uso == 'rotativa') {
|
||||
$rotativa = true;
|
||||
}
|
||||
|
||||
@ -1361,13 +1445,13 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected function getServiciosPreimpresion()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifapreimpresionModel');
|
||||
$data = $model->getServiciosPreimpresionSelector();
|
||||
array_unshift($data, (object)array(
|
||||
array_unshift($data, (object) array(
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioPreimpresion'))])
|
||||
));
|
||||
@ -1378,7 +1462,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaextraModel');
|
||||
$data = $model->getServiciosExtraSelector();
|
||||
array_unshift($data, (object)array(
|
||||
array_unshift($data, (object) array(
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioExtra'))])
|
||||
));
|
||||
@ -1397,7 +1481,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel');
|
||||
$data = $papelFormatoModel->getElementsForMenu();
|
||||
array_shift($data);
|
||||
array_unshift($data, (object)['id' => '', 'tamanio' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papelFormatoId'))])]);
|
||||
array_unshift($data, (object) ['id' => '', 'tamanio' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papelFormatoId'))])]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -1412,7 +1496,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaManipuladoModel');
|
||||
$data = $model->getServiciosManipuladoSelector();
|
||||
array_unshift($data, (object)array(
|
||||
array_unshift($data, (object) array(
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioManipulado'))])
|
||||
));
|
||||
@ -1425,25 +1509,27 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
return $model->getPOD();
|
||||
}
|
||||
|
||||
protected function getLineasPresupuesto($presupuestoEntity){
|
||||
protected function getLineasPresupuesto($presupuestoEntity)
|
||||
{
|
||||
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
|
||||
|
||||
|
||||
$input_data = [];
|
||||
$input_data['presupuesto'] = $presupuestoEntity;
|
||||
|
||||
|
||||
return PresupuestoService::checkLineasPresupuesto($input_data, $lineas);
|
||||
}
|
||||
|
||||
protected function getLineasServicios($presupuestoEntity){
|
||||
|
||||
$serviciosPresupuesto = (object)array();
|
||||
protected function getLineasServicios($presupuestoEntity)
|
||||
{
|
||||
|
||||
$serviciosPresupuesto = (object) array();
|
||||
|
||||
$serviciosPresupuesto->serviciosAcabado = (new PresupuestoAcabadosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
$serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
|
||||
|
||||
$input_data = [];
|
||||
$input_data['presupuesto_id'] = $presupuestoEntity->id;
|
||||
$input_data['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id;
|
||||
@ -1451,19 +1537,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$input_data['POD'] = $this->getPOD();
|
||||
$input_data['paginas'] = $presupuestoEntity->paginas;
|
||||
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
||||
|
||||
if($presupuestoEntity->papel_formato_personalizado){
|
||||
$input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ;
|
||||
$input_data['alto'] = $presupuestoEntity->papel_formato_alto ;
|
||||
}
|
||||
else{
|
||||
|
||||
if ($presupuestoEntity->papel_formato_personalizado) {
|
||||
$input_data['ancho'] = $presupuestoEntity->papel_formato_ancho;
|
||||
$input_data['alto'] = $presupuestoEntity->papel_formato_alto;
|
||||
} else {
|
||||
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
||||
$papel = $model->find($presupuestoEntity->papel_formato_id);
|
||||
if($papel){
|
||||
if ($papel) {
|
||||
$input_data['ancho'] = $papel->ancho;
|
||||
$input_data['alto'] = $papel->alto;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$input_data['ancho'] = 0;
|
||||
$input_data['alto'] = 0;
|
||||
}
|
||||
@ -1472,11 +1556,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
return PresupuestoService::checkLineasServicios($input_data, $serviciosPresupuesto);
|
||||
}
|
||||
|
||||
protected function getLineasDirecciones($presupuestoEntity){
|
||||
protected function getLineasDirecciones($presupuestoEntity)
|
||||
{
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$direccionesEnvio = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll();
|
||||
|
||||
|
||||
return PresupuestoService::checkLineasEnvios($direccionesEnvio);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
public static function obtenerCubierta($data)
|
||||
public static function obtenerCubierta($data, $return_raw=false)
|
||||
{
|
||||
|
||||
$uso = $data['uso'];
|
||||
@ -76,7 +76,6 @@ class PresupuestoClienteService extends BaseService
|
||||
$isColor = $data['isColor'];
|
||||
$isHq = $data['isHq'];
|
||||
$cliente_id = $data['cliente_id'];
|
||||
$paginas_color = $data['paginas_color'];
|
||||
$lomoRedondo = $data['lomoRedondo'];
|
||||
|
||||
$lineas_cubierta = [];
|
||||
@ -102,6 +101,14 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
if (count($lineas_cubierta) > 0) {
|
||||
|
||||
if($return_raw){
|
||||
$lineas_cubierta = array_values(array_unique($lineas_cubierta, SORT_REGULAR));
|
||||
|
||||
return[
|
||||
'cubierta' => $lineas_cubierta
|
||||
];
|
||||
}
|
||||
|
||||
usort(
|
||||
$lineas_cubierta,
|
||||
function ($a, $b) {
|
||||
@ -119,7 +126,7 @@ class PresupuestoClienteService extends BaseService
|
||||
return $lineas_cubierta;
|
||||
}
|
||||
|
||||
public static function obtenerSobrecubierta($data)
|
||||
public static function obtenerSobrecubierta($data, $return_raw=false)
|
||||
{
|
||||
|
||||
$uso = $data['uso'];
|
||||
@ -154,6 +161,14 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
if (count($lineas_sobrecubierta) > 0) {
|
||||
|
||||
if($return_raw){
|
||||
$lineas_sobrecubierta = array_values(array_unique($lineas_sobrecubierta, SORT_REGULAR));
|
||||
|
||||
return[
|
||||
'cubierta' => $lineas_sobrecubierta
|
||||
];
|
||||
}
|
||||
|
||||
usort(
|
||||
$lineas_sobrecubierta,
|
||||
function ($a, $b) {
|
||||
@ -247,22 +262,25 @@ class PresupuestoClienteService extends BaseService
|
||||
$uso = $data['uso'];
|
||||
$tipo_impresion_id = $data['tipo_impresion_id'];
|
||||
$datosPedido = $data['datosPedido'];
|
||||
$paginas_color = $data['paginas_color'];
|
||||
if ($data['papelInteriorDiferente'] == false)
|
||||
$papel_generico = $data['papel_generico'];
|
||||
else {
|
||||
$papel_generico = $data['papel_generico']['negro'];
|
||||
$papel_generico_color = $data['papel_generico']['color'];
|
||||
if($paginas_color>0)
|
||||
$papel_generico_color = $data['papel_generico']['color'];
|
||||
}
|
||||
if ($data['papelInteriorDiferente'] == false)
|
||||
$gramaje = $data['gramaje'];
|
||||
else {
|
||||
$gramaje = $data['gramaje']['negro'];
|
||||
$gramaje_color = $data['gramaje']['color'];
|
||||
if($paginas_color>0)
|
||||
$gramaje_color = $data['gramaje']['color'];
|
||||
}
|
||||
$isColor = $data['isColor'];
|
||||
$isHq = $data['isHq'];
|
||||
$cliente_id = $data['cliente_id'];
|
||||
$paginas_color = $data['paginas_color'];
|
||||
|
||||
|
||||
$paginas_negro = $datosPedido->paginas - $paginas_color;
|
||||
|
||||
@ -293,6 +311,14 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
if (count($linea_negro_plana) > 0) {
|
||||
|
||||
/*if($return_raw){
|
||||
$linea_negro_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
|
||||
|
||||
return[
|
||||
'negro' => $linea_negro_plana
|
||||
];
|
||||
}*/
|
||||
|
||||
usort(
|
||||
$linea_negro_plana,
|
||||
function ($a, $b) {
|
||||
@ -335,6 +361,14 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
if (count($linea_color_plana) > 0) {
|
||||
|
||||
/*if($return_raw){
|
||||
$linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
|
||||
|
||||
return[
|
||||
'color' => $linea_color_plana
|
||||
];
|
||||
}*/
|
||||
|
||||
usort(
|
||||
$linea_color_plana,
|
||||
function ($a, $b) {
|
||||
@ -349,8 +383,7 @@ class PresupuestoClienteService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación
|
||||
// más económica con la misma máquna
|
||||
|
||||
if($return_raw){
|
||||
$linea_negro_plana = array_values(array_unique($linea_negro_plana, SORT_REGULAR));
|
||||
$linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
|
||||
@ -360,6 +393,8 @@ class PresupuestoClienteService extends BaseService
|
||||
'color' => $linea_color_plana
|
||||
];
|
||||
}
|
||||
// Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación
|
||||
// más económica con la misma máquna
|
||||
if (
|
||||
$paginas_negro > 0 && $paginas_color > 0 && $data['papelInteriorDiferente'] == 0 &&
|
||||
count($linea_negro_plana) > 0 && count($linea_color_plana) > 0
|
||||
@ -500,7 +535,7 @@ class PresupuestoClienteService extends BaseService
|
||||
* - isHq: si es alta calidad
|
||||
* - paginas_color: número de páginas a color
|
||||
*/
|
||||
private static function obtenerPresupuestoClienteInteriorRotativa($data)
|
||||
public static function obtenerPresupuestoClienteInteriorRotativa($data, $return_raw = false)
|
||||
{
|
||||
$datosPedido = $data['datosPedido'];
|
||||
$papel_generico = $data['papel_generico'];
|
||||
@ -539,6 +574,14 @@ class PresupuestoClienteService extends BaseService
|
||||
|
||||
if (count($linea_rotativa) > 0) {
|
||||
|
||||
if($return_raw){
|
||||
$linea_rotativa = array_values(array_unique($linea_rotativa, SORT_REGULAR));
|
||||
|
||||
return[
|
||||
'rotativa' => $linea_rotativa,
|
||||
];
|
||||
}
|
||||
|
||||
usort(
|
||||
$linea_rotativa,
|
||||
function ($a, $b) {
|
||||
|
||||
@ -1,18 +1,3 @@
|
||||
/*******************************
|
||||
* Eventos asociados a elementos HTML
|
||||
*******************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#compPosPaginasColor').on("keyup", function () {
|
||||
computarPaginasColor(this.value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -23,163 +8,6 @@ $('#compPosPaginasColor').on("keyup", function () {
|
||||
*******************************/
|
||||
|
||||
|
||||
function getRowFromLineaRot(linea) {
|
||||
|
||||
$precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
||||
|
||||
return {
|
||||
'tipo': 'rotativa',
|
||||
'paginas': linea.fields.paginas,
|
||||
'papel': linea.fields.papel_generico,
|
||||
'gramaje': linea.fields.gramaje,
|
||||
'marca': linea.fields.papel_impresion,
|
||||
'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no',
|
||||
'maquina': linea.fields.maquina,
|
||||
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
|
||||
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
|
||||
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
|
||||
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
|
||||
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
|
||||
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
|
||||
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
|
||||
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
|
||||
'precioImpresion': $precio_impresion,
|
||||
'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6),
|
||||
'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6),
|
||||
'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2),
|
||||
'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2),
|
||||
'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2),
|
||||
'maquinaId': linea.fields.maquina_id,
|
||||
'maquinaVelocidad': linea.fields.maquina_velocidad,
|
||||
'tiempoMaquina': linea.fields.tiempo_maquina,
|
||||
'papelGenericoId': linea.fields.papel_generico_id,
|
||||
'papelImpresionId': linea.fields.papel_impresion_id,
|
||||
'paginasColor': linea.fields.paginas_color,
|
||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function clearIntLineas(is_color) {
|
||||
//$("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect();
|
||||
var tabla = $('#tableCompIntPlana').DataTable();
|
||||
tabla
|
||||
.rows(function (idx, data, node) {
|
||||
return data['tipo'].includes(is_color ? 'color' : 'bn');
|
||||
})
|
||||
.remove()
|
||||
.draw();
|
||||
//$('#tableCompIntPlana').DataTable().clear().draw();
|
||||
$('#insertarPlanaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
|
||||
function clearCubierta() {
|
||||
|
||||
var tabla = $('#tableCompCubierta').DataTable();
|
||||
tabla
|
||||
.rows(function (idx, data, node) {
|
||||
return data['tipo'] === 'cubierta';
|
||||
})
|
||||
.remove()
|
||||
.draw();
|
||||
if(tabla.rows().count()==0)
|
||||
$('#insertarCubiertaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
function clearSobrecubierta() {
|
||||
|
||||
|
||||
var tabla = $('#tableCompCubierta').DataTable();
|
||||
tabla
|
||||
.rows(function (idx, data, node) {
|
||||
return data['tipo'] === 'sobrecubierta';
|
||||
})
|
||||
.remove()
|
||||
.draw();
|
||||
if(tabla.rows().count()==0)
|
||||
$('#insertarCubiertaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
function clearGuardas() {
|
||||
|
||||
$('#tableCompGuardas').DataTable().clear().draw();
|
||||
$('#insertarGuardasBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
function clearIntRot() {
|
||||
|
||||
$('#errorComRot').html('');
|
||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
||||
$('#insertarRotativaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function selectIntRotLineas() {
|
||||
|
||||
$("#tableCompIntRotativa").DataTable().rows('.selected').deselect();
|
||||
|
||||
let value_total = 0.00;
|
||||
|
||||
if ($("#tableCompIntRotativa").DataTable().rows().count() > 0) {
|
||||
|
||||
$("#tableCompIntRotativa").DataTable().row(0).nodes().to$().toggleClass('selected');
|
||||
value_total = parseFloat($("#tableCompIntRotativa").DataTable().rows(0).data()[0]['total'])
|
||||
};
|
||||
|
||||
|
||||
$('#total_comp_rot').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function selectCubiertaLineas() {
|
||||
|
||||
$("#tableCompCubierta").DataTable().rows('.selected').deselect();
|
||||
|
||||
cubierta_selected = false;
|
||||
sobrecubierta_selected = false;
|
||||
|
||||
if ($("#tableCompCubierta").DataTable().rows().count() > 0) {
|
||||
|
||||
$("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') {
|
||||
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
cubierta_selected = true;
|
||||
}
|
||||
if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') {
|
||||
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
sobrecubierta_selected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var table = $("#tableCompCubierta").DataTable();
|
||||
var rows = table.rows('.selected').indexes();
|
||||
var data = table.rows(rows).data();
|
||||
|
||||
var value_total = 0.00;
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
|
||||
value_total += parseFloat(data[i]['total'])
|
||||
}
|
||||
|
||||
|
||||
$('#total_comp_cubierta').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function selectGuardasLineas() {
|
||||
|
||||
@ -197,140 +25,12 @@ function selectGuardasLineas() {
|
||||
$('#total_comp_guardas').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function getIDsComparador(is_color, is_hq) {
|
||||
|
||||
if (!is_color) {
|
||||
if (is_hq) {
|
||||
var papel = '#compPapelNegrohq';
|
||||
var gramaje = '#compGramajeNegrohq';
|
||||
var paginas = '#compPaginasNegrohq';
|
||||
}
|
||||
else {
|
||||
var papel = '#compPapelNegro';
|
||||
var gramaje = '#compGramajeNegro';
|
||||
var paginas = '#compPaginasNegro';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_hq) {
|
||||
var papel = '#compPapelColorhq';
|
||||
var gramaje = '#compGramajeColorhq';
|
||||
var paginas = '#compPaginasColorhq';
|
||||
}
|
||||
else {
|
||||
var papel = '#compPapelColor';
|
||||
var gramaje = '#compGramajeColor';
|
||||
var paginas = '#compPaginasColor';
|
||||
}
|
||||
}
|
||||
return {
|
||||
papel: papel,
|
||||
gramaje: gramaje,
|
||||
paginas: paginas,
|
||||
}
|
||||
}
|
||||
|
||||
function getDimensionLibro() {
|
||||
var ancho = 0;
|
||||
var alto = 0;
|
||||
|
||||
// TO-DO
|
||||
if (!document.getElementById('papelFormatoPersonalizado').checked) {
|
||||
ancho = 170//parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]);
|
||||
alto = 240//parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]);
|
||||
|
||||
}
|
||||
|
||||
else if (document.getElementById('papelFormatoPersonalizado').checked) {
|
||||
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
|
||||
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
|
||||
}
|
||||
return {
|
||||
ancho: ancho,
|
||||
alto: alto
|
||||
}
|
||||
}
|
||||
|
||||
function checkInputsForRotativa() {
|
||||
|
||||
// Si es color, el gramaje y el papel tiene que ser el mismo
|
||||
try {
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
if ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ($('#tipoImpresion').select2('data')[0].id == 'negro') {
|
||||
if ($('#compPapelNegro').select2('data')[0].id.length > 0 &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function fillIntPlana(data, is_color, is_hq) {
|
||||
let sorted = data.lineas.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompIntPlana').DataTable().row
|
||||
.add(getRowFromLineaInt(is_color ? (is_hq ? 'colorhq' : 'color') : (is_hq ? 'bnhq' : 'bn'), linea))
|
||||
.draw()
|
||||
})
|
||||
}
|
||||
|
||||
function fillIntRot(data) {
|
||||
let sorted = data.lineas.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined") {
|
||||
$('#tableCompIntRotativa').DataTable().row
|
||||
.add(getRowFromLineaRot(linea))
|
||||
.draw()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function fillCubierta(data) {
|
||||
|
||||
let sorted = data.lineas.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompCubierta').DataTable().row
|
||||
.add(getRowFromLineaInt('cubierta', linea))
|
||||
.draw()
|
||||
})
|
||||
}
|
||||
|
||||
function fillSobrecubierta(data) {
|
||||
|
||||
let sorted = data.lineas.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompCubierta').DataTable().row
|
||||
.add(getRowFromLineaInt('sobrecubierta', linea))
|
||||
.draw()
|
||||
})
|
||||
}
|
||||
|
||||
function fillGuardas(data) {
|
||||
|
||||
@ -345,130 +45,5 @@ function fillGuardas(data) {
|
||||
})
|
||||
}
|
||||
|
||||
function clearCompTable() {
|
||||
|
||||
$('#insertarPlanaBtn').addClass('d-none')
|
||||
$('#insertarRotativaBtn').addClass('d-none')
|
||||
$('#total_comp_plana').html('0.00')
|
||||
$('#total_comp_rot').html('0.00')
|
||||
}
|
||||
|
||||
function generateCompJSON() {
|
||||
|
||||
data = {}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
bn_obj = {
|
||||
"bn": {
|
||||
'paginas': $('#compPaginasNegro').val(),
|
||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bn_obj = {}
|
||||
}
|
||||
$.extend(data, bn_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
bnhq_obj = {
|
||||
"bnhq": {
|
||||
'paginas': $('#compPaginasNegrohq').val(),
|
||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bnhq_obj = {}
|
||||
}
|
||||
$.extend(data, bnhq_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
color_obj = {
|
||||
"color": {
|
||||
'paginas': $('#compPaginasColor').val(),
|
||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
color_obj = {}
|
||||
}
|
||||
$.extend(data, color_obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
colorhq_obj = {
|
||||
"colorhq": {
|
||||
'paginas': $('#compPaginasColorhq').val(),
|
||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
colorhq_obj = {}
|
||||
}
|
||||
$.extend(data, colorhq_obj);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
cubierta_obj = {
|
||||
"cubierta": {
|
||||
'paginas': $('#compCarasCubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
cubierta_obj = {}
|
||||
}
|
||||
$.extend(data, cubierta_obj);
|
||||
|
||||
try {
|
||||
sobrecubierta_obj = {
|
||||
"sobrecubierta": {
|
||||
'imprimir': $('#compSobrecubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
sobrecubierta_obj = {}
|
||||
}
|
||||
$.extend(data, sobrecubierta_obj);
|
||||
|
||||
if($('#compCarasGuardas').length>0){
|
||||
try {
|
||||
guardas_obj = {
|
||||
"guardas": {
|
||||
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
|
||||
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
guardas_obj = {}
|
||||
}
|
||||
$.extend(data, guardas_obj);
|
||||
|
||||
}
|
||||
|
||||
data_str = JSON.stringify(data)
|
||||
$('#comparador_json_data').val(data_str)
|
||||
}
|
||||
|
||||
|
||||
@ -164,6 +164,7 @@ class Comparador {
|
||||
this.btnInsertarCubierta = $('#insertarCubiertaBtn');
|
||||
|
||||
this.cargando = false;
|
||||
this.comparadorPlanaRunning = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -179,18 +180,19 @@ class Comparador {
|
||||
|
||||
initSelect2() {
|
||||
|
||||
this.paginasCubierta.select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
|
||||
if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 ||
|
||||
$('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) {
|
||||
$('#compCarasCubierta').select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
|
||||
$('#compPapelGuardas').select2({
|
||||
this.papelGuardas.select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compCarasGuardas').select2({
|
||||
this.carasGuardas.select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
@ -206,6 +208,11 @@ class Comparador {
|
||||
this.papelCubierta.init();
|
||||
this.gramajeCubierta.init();
|
||||
if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) {
|
||||
|
||||
this.sobrecubierta.select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
this.papelSobrecubierta.init();
|
||||
this.gramajeSobrecubierta.init();
|
||||
this.papelSobrecubierta.onChange(() => this.gramajeSobrecubierta.setVal(0))
|
||||
@ -268,6 +275,12 @@ class Comparador {
|
||||
$('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
|
||||
$('.comp_cubierta_items').on('change', this.obtenerComparadorExteriores.bind(this));
|
||||
if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) {
|
||||
$('.comp_sobrecubierta_items').on('change', this.obtenerComparadorExteriores.bind(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#changePaginasComparador(element) {
|
||||
@ -343,6 +356,7 @@ class Comparador {
|
||||
|
||||
this.cargando = false;
|
||||
this.paginasNegro.trigger('change');
|
||||
this.paginasCubierta.trigger('change');
|
||||
}
|
||||
|
||||
|
||||
@ -580,6 +594,14 @@ class Comparador {
|
||||
|
||||
updateOpcionesComparador() {
|
||||
|
||||
$('.comp_negro_items').off('change');
|
||||
$('.comp_negrohq_items').off('change');
|
||||
$('.comp_color_items').off('change');
|
||||
$('.comp_colorhq_items').off('change');
|
||||
|
||||
this.tableCompIntPlana.clear().draw();
|
||||
this.tableCompIntRotativa.clear().draw();
|
||||
|
||||
const selValue = this.tipo_impresion.val();
|
||||
const elements_negro = $('.comp-negro-selected');
|
||||
const elements_negrohq = $('.comp-negrohq-selected');
|
||||
@ -597,6 +619,11 @@ class Comparador {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
else {
|
||||
Array.from(elements_colorhq).forEach(element => {
|
||||
$(element).addClass('d-none');
|
||||
});
|
||||
}
|
||||
Array.from(elements_negrohq).forEach(element => {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
@ -613,11 +640,21 @@ class Comparador {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
else {
|
||||
Array.from(elements_color).forEach(element => {
|
||||
$(element).addClass('d-none');
|
||||
});
|
||||
}
|
||||
Array.from(elements_negro).forEach(element => {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
|
||||
$('.comp_negro_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
|
||||
if (selValue.includes('color')) {
|
||||
$('.pos-paginas-color').removeClass('d-none');
|
||||
}
|
||||
@ -714,6 +751,7 @@ class Comparador {
|
||||
let papel_generico = {};
|
||||
let gramaje = {};
|
||||
let paginasColor = 0;
|
||||
let paginas = parseInt($('#paginas').val());
|
||||
|
||||
if (!$('#papelFormatoPersonalizado').prop('checked')) {
|
||||
const selectedFormat = $('#papelFormatoId').select2('data')[0].text;
|
||||
@ -780,27 +818,63 @@ class Comparador {
|
||||
};
|
||||
|
||||
if (this.tipo_impresion.val().includes('color')) {
|
||||
|
||||
if (this.tipo_impresion.val().includes('hq')) {
|
||||
papel_generico.color = { id: this.papelColorhq.getVal(), nombre: this.papelColorhq.getText() };
|
||||
gramaje.color = this.gramajeColorhq.getVal();
|
||||
paginasColor = this.paginasColorhq.val();
|
||||
}
|
||||
papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() };
|
||||
gramaje.negro = this.gramajeNegrohq.getVal();
|
||||
}
|
||||
else {
|
||||
if (this.tipo_impresion.val().includes('hq')) {
|
||||
else {
|
||||
papel_generico.color = { id: this.papelColor.getVal(), nombre: this.papelColor.getText() };
|
||||
gramaje.color = this.gramajeColor.getVal();
|
||||
paginasColor = this.paginasColor.val();
|
||||
}
|
||||
|
||||
}
|
||||
if (this.tipo_impresion.val().includes('hq')) {
|
||||
papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() };
|
||||
gramaje.negro = this.gramajeNegrohq.getVal();
|
||||
}
|
||||
else {
|
||||
papel_generico.negro = { id: this.papelNegro.getVal(), nombre: this.papelNegro.getText() };
|
||||
gramaje.negro = this.gramajeNegro.getVal();
|
||||
}
|
||||
|
||||
}
|
||||
else if (uso = 'cubierta') {
|
||||
if (this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
|
||||
|
||||
papel_generico = { id: this.papelCubierta.getVal(), nombre: this.papelCubierta.getText() };
|
||||
gramaje = this.gramajeCubierta.getVal();
|
||||
paginas = this.paginasCubierta.select2('data')[0].id
|
||||
}
|
||||
|
||||
else if (uso = 'sobrecubierta') {
|
||||
if (this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
|
||||
papel_generico = { id: this.papelSobrecubierta.getVal(), nombre: this.papelSobrecubierta.getText() };
|
||||
gramaje = this.gramajeSobrecubierta.getVal();
|
||||
paginas = 4;
|
||||
|
||||
}
|
||||
|
||||
const datosPedido = {
|
||||
paginas: $('#paginas').val(),
|
||||
paginas: paginas,
|
||||
tirada: $('#tirada').val(),
|
||||
merma: $('#merma').val(),
|
||||
ancho: ancho,
|
||||
@ -826,6 +900,10 @@ class Comparador {
|
||||
isHq: this.tipo_impresion.val().includes('hq'),
|
||||
paginas_color: paginasColor
|
||||
}
|
||||
// TO-DO
|
||||
if(uso == 'cubierta'){
|
||||
datos.lomoRedondo = false;
|
||||
}
|
||||
|
||||
|
||||
return { error: false, data: datos };
|
||||
@ -837,9 +915,10 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando || this.comparadorPlanaRunning) {
|
||||
return
|
||||
}
|
||||
this.comparadorPlanaRunning = true;
|
||||
|
||||
if (event.currentTarget.id.includes('Paginas')) {
|
||||
this.#changePaginasComparador(event.currentTarget.id);
|
||||
@ -848,113 +927,249 @@ class Comparador {
|
||||
this.tableCompIntPlana.clear().draw();
|
||||
this.tableCompIntRotativa.clear().draw();
|
||||
this.btnInsertarPlana.addClass('d-none');
|
||||
this.btnInsertarRotativa.addClass('d-none');
|
||||
$('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa);
|
||||
$('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana);
|
||||
|
||||
const datosComp = this.getDataForComp('interior');
|
||||
if (datosComp.error) {
|
||||
this.comparadorPlanaRunning = false;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
const isHq = this.tipo_impresion.val().includes('hq');
|
||||
const isColor = this.tipo_impresion.val().includes('color');
|
||||
|
||||
datosComp.data['tipo_maquina'] = 'plana';
|
||||
datosComp.data[this.csrf_token] = this.csrf_hash;
|
||||
new Ajax('/presupuestoadmin/comparadorplana',
|
||||
new Ajax('/presupuestoadmin/comparadorinterior',
|
||||
datosComp.data,
|
||||
{},
|
||||
(response) => {
|
||||
if (response.data.negro.length > 0) {
|
||||
const isHq = response.data.negro[0].fields.tipo_linea.includes('hq');
|
||||
let sorted = response.data.negro.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompIntPlana').DataTable().row
|
||||
.add(self.getRowFromLineaInt(isHq ? 'bnhq' : 'bn', linea))
|
||||
self.tableCompIntPlana.row
|
||||
.add(self.getRowFromLinea(isHq ? 'bnhq' : 'bn', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
if (response.data.color.length > 0) {
|
||||
const isHq = response.data.color[0].fields.tipo_linea.includes('hq');
|
||||
let sorted = response.data.color.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompIntPlana').DataTable().row
|
||||
.add(self.getRowFromLineaInt(isHq ? 'colorhq' : 'color', linea))
|
||||
self.tableCompIntPlana.row
|
||||
.add(self.getRowFromLinea(isHq ? 'colorhq' : 'color', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
this.selectIntLineas();
|
||||
|
||||
self.selectLineas('plana');
|
||||
if ($('#tableCompIntPlana').DataTable().rows().count() > 0) {
|
||||
$('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana + ' (' + self.tableCompIntPlana.rows().count() + ')');
|
||||
$('#insertarPlanaBtn').removeClass('d-none');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana);
|
||||
$('#insertarPlanaBtn').addClass('d-none');
|
||||
}
|
||||
|
||||
// Rotativa
|
||||
if (!isHq) {
|
||||
if (!isColor || (isColor && datosComp.data.papel_generico.negro.id == datosComp.data.papel_generico.color.id &&
|
||||
datosComp.data.gramaje.negro == datosComp.data.gramaje.color)) {
|
||||
|
||||
datosComp.data['tipo_maquina'] = 'rotativa';
|
||||
datosComp.data.papel_generico.id = datosComp.data.papel_generico.negro.id;
|
||||
datosComp.data.papel_generico.nombre = datosComp.data.papel_generico.negro.nombre;
|
||||
datosComp.data.gramaje = datosComp.data.gramaje.negro;
|
||||
new Ajax('/presupuestoadmin/comparadorinterior',
|
||||
datosComp.data,
|
||||
{},
|
||||
(response) => {
|
||||
if (response.data.rotativa.length > 0) {
|
||||
let sorted = response.data.rotativa.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompIntRotativa.row
|
||||
.add(self.getRowFromLineaRot(linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
self.selectLineas('rotativa');
|
||||
if (self.tableCompIntRotativa.rows().count() > 0) {
|
||||
self.btnInsertarRotativa.removeClass('d-none');
|
||||
$('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa + ' (' + self.tableCompIntRotativa.rows().count() + ')');
|
||||
}
|
||||
else {
|
||||
$('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa);
|
||||
}
|
||||
|
||||
self.comparadorPlanaRunning = false;
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
).post();
|
||||
}
|
||||
else {
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
).post();
|
||||
}
|
||||
/*
|
||||
elementos = getIDsComparador(is_color, is_hq)
|
||||
|
||||
|
||||
if ($('' + elementos.papel).select2('data').length > 0 &&
|
||||
$('' + elementos.gramaje).select2('data').length > 0 &&
|
||||
parseInt($('' + elementos.paginas).val()) >= 0 &&
|
||||
checkDatosPedidoForComp()) {
|
||||
|
||||
|
||||
getLineasIntPlana(is_color, is_hq, actualizarLineaPlana).then((result) => {
|
||||
// Para rotativa, si es color el papel y el gramaje tiene que ser igual
|
||||
if (!is_color) {
|
||||
getLineasIntRot(is_hq, actualizarLineaRot);
|
||||
}
|
||||
else {
|
||||
if (!is_hq) {
|
||||
if ($('#compPapelNegro').select2('data').length > 0 && $('#compPapelColor').select2('data').length > 0 &&
|
||||
$('#compGramajeNegro').select2('data').length > 0 && $('#compGramajeColor').select2('data').length > 0) {
|
||||
if (($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) {
|
||||
getLineasIntRot(is_hq, actualizarLineaRot);
|
||||
}
|
||||
else {
|
||||
$('#errorComRot').html('<?= lang("Presupuestos.errores.errorRotColor") ?>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
this.comparadorPlanaRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
obtenerComparadorExteriores(event, actualizarLineaPlana = false, actualizarLineaRot = false) {
|
||||
|
||||
try {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
return
|
||||
}
|
||||
|
||||
this.tableCompCubierta.clear().draw();
|
||||
this.btnInsertarCubierta.addClass('d-none');
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta);
|
||||
|
||||
let datosComp = {};
|
||||
datosComp.cubierta = this.getDataForComp('cubierta');
|
||||
if (datosComp.cubierta.error) {
|
||||
return;
|
||||
}
|
||||
if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) {
|
||||
if (this.sobrecubierta.select2('data')[0].id == 1) {
|
||||
datosComp.sobrecubierta = this.getDataForComp('sobrecubierta');
|
||||
if (datosComp.sobrecubierta.error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
datosComp.sobrecubierta = {};
|
||||
}
|
||||
}
|
||||
else{
|
||||
datosComp.sobrecubierta = {};
|
||||
}
|
||||
datosComp.cubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
if(Object.keys(datosComp.sobrecubierta).length > 0){
|
||||
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
}
|
||||
new Ajax('/presupuestoadmin/comparadorexteriores',
|
||||
{
|
||||
cubierta: datosComp.cubierta.data,
|
||||
sobrecubierta: datosComp.sobrecubierta.data
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
if (response.data.cubierta.length > 0) {
|
||||
let sorted = response.data.cubierta.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompCubierta.row
|
||||
add(self.getRowFromLinea('cubierta', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
if (response.data.sobrecubierta) {
|
||||
let sorted = response.data.sobrecubierta.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompCubierta.row
|
||||
.add(self.getRowFromLinea('sobrecubierta', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
|
||||
self.selectLineas('cubierta');
|
||||
if (self.tableCompCubierta.rows().count() > 0) {
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta +
|
||||
(' (' + self.tableCompCubierta.rows().count() + ')'));
|
||||
self.btnInsertarCubierta.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta);
|
||||
self.btnInsertarCubierta.addClass('d-none');
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
).post();
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
selectIntLineas() {
|
||||
var negro_selected = false;
|
||||
var color_selected = false;
|
||||
$("#tableCompIntPlana").DataTable().rows('.selected').deselect();
|
||||
$("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) {
|
||||
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
negro_selected = true;
|
||||
}
|
||||
if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) {
|
||||
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
color_selected = true;
|
||||
|
||||
selectLineas(tabla) {
|
||||
|
||||
let table = this.tableCompIntPlana;
|
||||
let select1 = false;
|
||||
let select2 = false;
|
||||
let tipo1 = 'bn';
|
||||
let tipo2 = 'color';
|
||||
let total_label = '#total_comp_plana'
|
||||
switch (tabla) {
|
||||
case 'cubierta':
|
||||
table = this.tableCompCubierta;
|
||||
tipo1 = 'lp_cubierta';
|
||||
tipo2 = 'lp_sobrecubierta';
|
||||
total_label = '#total_comp_cubierta';
|
||||
break;
|
||||
|
||||
case 'rotativa':
|
||||
table = this.tableCompIntRotativa;
|
||||
tipo1 = 'rotativa';
|
||||
total_label = '#total_comp_rot';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
table.rows('.selected').deselect();
|
||||
table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (!select1 && table.cell(rowIdx, 0).data().includes(tipo1)) {
|
||||
table.row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
select1 = true;
|
||||
}
|
||||
if (tabla == 'plana' || tabla == 'cubierta')
|
||||
if (!select2 && table.cell(rowIdx, 0).data().includes(tipo2)) {
|
||||
table.row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
select2 = true;
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#tableCompIntPlana").DataTable();
|
||||
var rows = table.rows('.selected').indexes();
|
||||
var data = table.rows(rows).data();
|
||||
|
||||
@ -965,10 +1180,10 @@ class Comparador {
|
||||
value_total += parseFloat(data[i]['total'])
|
||||
}
|
||||
|
||||
$('#total_comp_plana').html(value_total.toFixed(2));
|
||||
$(total_label).html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
getRowFromLineaInt(tipo, linea) {
|
||||
getRowFromLinea(tipo, linea) {
|
||||
|
||||
const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
||||
@ -1002,25 +1217,165 @@ class Comparador {
|
||||
data['paginas_impresion'] = linea.fields.paginas_impresion;
|
||||
return data;
|
||||
}
|
||||
|
||||
getRowFromLineaRot(linea) {
|
||||
|
||||
const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
||||
|
||||
return {
|
||||
'tipo': 'rotativa',
|
||||
'paginas': linea.fields.paginas,
|
||||
'papel': linea.fields.papel_generico,
|
||||
'gramaje': linea.fields.gramaje,
|
||||
'marca': linea.fields.papel_impresion,
|
||||
'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no',
|
||||
'maquina': linea.fields.maquina,
|
||||
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
|
||||
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
|
||||
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
|
||||
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
|
||||
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
|
||||
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
|
||||
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
|
||||
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
|
||||
'precioImpresion': precio_impresion,
|
||||
'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6),
|
||||
'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6),
|
||||
'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2),
|
||||
'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2),
|
||||
'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2),
|
||||
'maquinaId': linea.fields.maquina_id,
|
||||
'maquinaVelocidad': linea.fields.maquina_velocidad,
|
||||
'tiempoMaquina': linea.fields.tiempo_maquina,
|
||||
'papelGenericoId': linea.fields.papel_generico_id,
|
||||
'papelImpresionId': linea.fields.papel_impresion_id,
|
||||
'paginasColor': linea.fields.paginas_color,
|
||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
||||
}
|
||||
}
|
||||
|
||||
generateCompJSON() {
|
||||
|
||||
data = {}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
bn_obj = {
|
||||
"bn": {
|
||||
'paginas': $('#compPaginasNegro').val(),
|
||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bn_obj = {}
|
||||
}
|
||||
$.extend(data, bn_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
bnhq_obj = {
|
||||
"bnhq": {
|
||||
'paginas': $('#compPaginasNegrohq').val(),
|
||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bnhq_obj = {}
|
||||
}
|
||||
$.extend(data, bnhq_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
color_obj = {
|
||||
"color": {
|
||||
'paginas': $('#compPaginasColor').val(),
|
||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
color_obj = {}
|
||||
}
|
||||
$.extend(data, color_obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
colorhq_obj = {
|
||||
"colorhq": {
|
||||
'paginas': $('#compPaginasColorhq').val(),
|
||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
colorhq_obj = {}
|
||||
}
|
||||
$.extend(data, colorhq_obj);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
cubierta_obj = {
|
||||
"cubierta": {
|
||||
'paginas': $('#compCarasCubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
cubierta_obj = {}
|
||||
}
|
||||
$.extend(data, cubierta_obj);
|
||||
|
||||
try {
|
||||
sobrecubierta_obj = {
|
||||
"sobrecubierta": {
|
||||
'imprimir': $('#compSobrecubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
sobrecubierta_obj = {}
|
||||
}
|
||||
$.extend(data, sobrecubierta_obj);
|
||||
|
||||
if ($('#compCarasGuardas').length > 0) {
|
||||
try {
|
||||
guardas_obj = {
|
||||
"guardas": {
|
||||
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
|
||||
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
guardas_obj = {}
|
||||
}
|
||||
$.extend(data, guardas_obj);
|
||||
|
||||
}
|
||||
|
||||
data_str = JSON.stringify(data)
|
||||
$('#comparador_json_data').val(data_str)
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
$('#compSobrecubierta').on('change', function(){
|
||||
if ($('#compSobrecubierta').val()==1){
|
||||
value = false
|
||||
}
|
||||
else{
|
||||
value = 'disabled'
|
||||
$('#compPapelSobrecubierta').val(0)
|
||||
$('#compGramajeSobrecubierta').val('')
|
||||
$('#compGramajeSobrecubierta').select2("destroy")
|
||||
$('#compGramajeSobrecubierta').select2({allowClear: false, minimumResultsForSearch: Infinity})
|
||||
|
||||
}
|
||||
$('#compPapelSobrecubierta').prop('disabled', value);
|
||||
$('#compGramajeSobrecubierta').prop('disabled', value);
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user