mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/presupuestos3' into 'dev/formas_libro'
# Conflicts: # ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php
This commit is contained in:
@ -312,11 +312,16 @@ class Cliente extends \App\Controllers\GoBaseResourceController
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
try{
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
}
|
||||
catch(Exception $e){
|
||||
$menu = [];
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
@ -255,18 +255,28 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon
|
||||
|
||||
/**
|
||||
* Convenience method to validate form submission
|
||||
* JJO: Se le añade las reglas y los mensajes custom
|
||||
* @return bool
|
||||
*/
|
||||
protected function canValidate()
|
||||
protected function canValidate($customValidationRules = null, $customValidationMessages = null)
|
||||
{
|
||||
|
||||
$validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null;
|
||||
|
||||
if($customValidationRules == null){
|
||||
$validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null;
|
||||
}
|
||||
else{
|
||||
$validationRules = $customValidationRules;
|
||||
}
|
||||
if ($validationRules == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
|
||||
if($customValidationMessages == null){
|
||||
$validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;;
|
||||
}
|
||||
else{
|
||||
$validationErrorMessages = $customValidationMessages;
|
||||
}
|
||||
|
||||
if ($validationErrorMessages != null) {
|
||||
$valid = $this->validate($validationRules, $validationErrorMessages);
|
||||
|
||||
@ -14,7 +14,7 @@ use App\Services\PresupuestoService;
|
||||
use App\Models\Configuracion\PapelImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
@ -96,10 +96,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // 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()) :
|
||||
if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -117,6 +116,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$lp_model->createForPresupuesto($id);
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
@ -138,217 +140,150 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
$this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo'));
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
|
||||
$this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro();
|
||||
$this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ();
|
||||
$this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor();
|
||||
$this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ();
|
||||
$this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta();
|
||||
$this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta();
|
||||
|
||||
// Tarifas
|
||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
||||
|
||||
$this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO
|
||||
|
||||
$this->viewData['formAction'] = route_to('createCosidotapablanda');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
/* TEST JS LOADER */
|
||||
//$this->viewData['global_js_variables'] = array('jsVarTest' => "'Hola Jaime'");
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$presupuestoEntity = $this->model->find($id);
|
||||
|
||||
if ($presupuestoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
if ($this->request->getPost('recoger_en_taller') == null) {
|
||||
$sanitizedData['recoger_en_taller'] = false;
|
||||
}
|
||||
if ($this->request->getPost('ferro') == null) {
|
||||
$sanitizedData['ferro'] = false;
|
||||
}
|
||||
if ($this->request->getPost('ferro_digital') == null) {
|
||||
$sanitizedData['ferro_digital'] = false;
|
||||
}
|
||||
if ($this->request->getPost('marcapaginas') == null) {
|
||||
$sanitizedData['marcapaginas'] = false;
|
||||
}
|
||||
if ($this->request->getPost('papel_formato_personalizado') == null) {
|
||||
$sanitizedData['papel_formato_personalizado'] = false;
|
||||
}
|
||||
if ($this->request->getPost('solapas') == null) {
|
||||
$sanitizedData['solapas'] = false;
|
||||
}
|
||||
if ($this->request->getPost('cosido') == null) {
|
||||
$sanitizedData['cosido'] = false;
|
||||
}
|
||||
if ($this->request->getPost('cubiertas') == null) {
|
||||
$sanitizedData['cubiertas'] = false;
|
||||
}
|
||||
if ($this->request->getPost('imagenes_bn_interior') == null) {
|
||||
$sanitizedData['imagenes_bn_interior'] = false;
|
||||
}
|
||||
if ($this->request->getPost('en_produccion') == null) {
|
||||
$sanitizedData['en_produccion'] = false;
|
||||
}
|
||||
if ($this->request->getPost('en_espera') == null) {
|
||||
$sanitizedData['en_espera'] = false;
|
||||
}
|
||||
if ($this->request->getPost('modo_comparador') == null) {
|
||||
$sanitizedData['modo_comparador'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_negro_hq') == null) {
|
||||
$sanitizedData['paginas_negro_hq'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_negro_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_negro_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_negro_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_negro_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_color_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_color_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_color_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_color_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_portada_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_portada_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_portada_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_portada_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_cubierta_papel_impresion_id') == null) {
|
||||
$sanitizedData['paginas_cubierta_papel_impresion_id'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_cubierta_check_papel_total') == null) {
|
||||
$sanitizedData['paginas_cubierta_check_papel_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('paginas_cubierta_check_impresion_total') == null) {
|
||||
$sanitizedData['paginas_cubierta_check_impresion_total'] = false;
|
||||
}
|
||||
if ($this->request->getPost('isDig') == null) {
|
||||
$sanitizedData['isDig'] = false;
|
||||
}
|
||||
if ($this->request->getPost('envios_recoge_cliente') == null) {
|
||||
$sanitizedData['envios_recoge_cliente'] = false;
|
||||
}
|
||||
if ($this->request->getPost('fecha_entrega_real_aviso') == null) {
|
||||
$sanitizedData['fecha_entrega_real_aviso'] = false;
|
||||
}
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$presupuestoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
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));
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$presupuestoEntity = $this->model->find($id);
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
if ($presupuestoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$postData['updated_at'] = gmdate('Y-m-d H:m:s', time());
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else :
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else :
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$presupuestoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
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)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else :
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'mensaje' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
}
|
||||
|
||||
endif;
|
||||
else :
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'mensaje' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
}
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
$this->viewData['formaPagoList'] = $this->getFormaPagoListItems();
|
||||
$this->viewData['tiposImpresionList'] = $this->getTiposImpresionListItems($presupuestoEntity->tipo_impresion_id ?? null);
|
||||
$this->viewData['tipologiasLibroList'] = $this->getTipologiasLibroListItems($presupuestoEntity->tipologia_id ?? null);
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
$this->viewData['ubicacionLibroList'] = $this->getUbicacionLibroListItems($presupuestoEntity->ubicacion_id ?? null);
|
||||
$this->viewData['presupuestoEstadoList'] = $this->getPresupuestoEstadoListItems($presupuestoEntity->estado_id ?? null);
|
||||
$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
|
||||
$this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($presupuestoEntity->paginas_negro_papel_id ?? null);
|
||||
$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($presupuestoEntity->paginas_negro_papel_impresion_id ?? null);
|
||||
$this->viewData['maquinaList'] = $this->getMaquinaListItems($presupuestoEntity->paginas_negro_maquina_id ?? null);
|
||||
$this->viewData['maquinasTarifasImpresionList'] = $this->getMaquinasTarifasImpresionListItems($presupuestoEntity->paginas_negro_tarifa_impresion_id ?? null);
|
||||
$this->viewData['papelGenericoList2'] = $this->getPapelGenericoListItems2($presupuestoEntity->paginas_color_papel_id ?? null);
|
||||
$this->viewData['papelImpresionList2'] = $this->getPapelImpresionListItems2($presupuestoEntity->paginas_color_papel_impresion_id ?? null);
|
||||
$this->viewData['maquinaList2'] = $this->getMaquinaListItems2($presupuestoEntity->paginas_color_maquina_id ?? null);
|
||||
$this->viewData['maquinasTarifasImpresionList2'] = $this->getMaquinasTarifasImpresionListItems2($presupuestoEntity->paginas_color_tarifa_impresion_id ?? null);
|
||||
$this->viewData['papelGenericoList3'] = $this->getPapelGenericoListItems3($presupuestoEntity->paginas_portada_papel_id ?? null);
|
||||
$this->viewData['papelImpresionList3'] = $this->getPapelImpresionListItems3($presupuestoEntity->paginas_portada_papel_impresion_id ?? null);
|
||||
$this->viewData['maquinaList3'] = $this->getMaquinaListItems3($presupuestoEntity->paginas_portada_maquina_id ?? null);
|
||||
$this->viewData['maquinasTarifasImpresionList3'] = $this->getMaquinasTarifasImpresionListItems3($presupuestoEntity->paginas_portada_tarifa_impresion_id ?? null);
|
||||
$this->viewData['papelGenericoList4'] = $this->getPapelGenericoListItems4($presupuestoEntity->paginas_cubierta_papel_id ?? null);
|
||||
$this->viewData['papelImpresionList4'] = $this->getPapelImpresionListItems4($presupuestoEntity->paginas_cubierta_papel_impresion_id ?? null);
|
||||
$this->viewData['maquinaList4'] = $this->getMaquinaListItems4($presupuestoEntity->paginas_cubierta_maquina_id ?? null);
|
||||
$this->viewData['maquinasTarifasImpresionList4'] = $this->getMaquinasTarifasImpresionListItems4($presupuestoEntity->paginas_cubierta_tarifa_impresion_id ?? null);
|
||||
$this->viewData['userList'] = $this->getUserListItems($presupuestoEntity->total_confirmado_user_id ?? null);
|
||||
$this->viewData['userList2'] = $this->getUserListItems2($presupuestoEntity->aprobado_user_id ?? null);
|
||||
$this->viewData['userList3'] = $this->getUserListItems3($presupuestoEntity->pedido_espera_user_id ?? null);
|
||||
$this->viewData['paginasCubiertaList'] = $this->getPaginasCubiertaOptions();
|
||||
$this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions();
|
||||
|
||||
if(!is_null($presupuestoEntity->comparador_json_data))
|
||||
$this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data);
|
||||
else
|
||||
$this->viewData['comp_data'] = "";
|
||||
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||
$this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo'));
|
||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||
$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
|
||||
$this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro();
|
||||
$this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ();
|
||||
$this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor();
|
||||
$this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ();
|
||||
$this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta();
|
||||
$this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta();
|
||||
$this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro();
|
||||
$this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor();
|
||||
|
||||
$this->viewData['formAction'] = route_to('updatePresupuesto', $id);
|
||||
// Lineas Presupuesto
|
||||
$this->viewData['lineasPresupuesto'] = $this->getLineasPresupuestoActivas($id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
// Tarifas
|
||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
||||
|
||||
$this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
@ -440,6 +375,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
];
|
||||
|
||||
$gramaje = $reqData['gramaje'] ?? 0;
|
||||
|
||||
|
||||
|
||||
if ($type=='interior') {
|
||||
|
||||
@ -461,7 +398,21 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
'color' => intval($reqData['paginas_color']) ?? 0,
|
||||
);
|
||||
|
||||
$resourceData = $this->getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas);
|
||||
$datosTipolog = $reqData['negro'] ?? null;
|
||||
if(!is_null($datosTipolog)){
|
||||
$datosTipolog = [];
|
||||
$data = (object)array(
|
||||
'negro' => intval($reqData['negro']) ?? 0,
|
||||
'cyan' => intval($reqData['cyan']) ?? 0,
|
||||
'magenta' => intval($reqData['magenta']) ?? 0,
|
||||
'amarillo' => intval($reqData['amarillo']) ?? 0,
|
||||
'gota_negro' => intval($reqData['gota_negro']) ?? 0,
|
||||
'gota_color' => intval($reqData['gota_color']) ?? 0,
|
||||
);
|
||||
array_push($datosTipolog, $data);
|
||||
}
|
||||
|
||||
$resourceData = $this->getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $datosTipolog);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -502,6 +453,50 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function datatable_2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$tipo = $reqData['tipo'] ?? '';
|
||||
|
||||
if($tipo=='lineasPresupuesto'){
|
||||
|
||||
$datos = $reqData['datos'] ?? null;
|
||||
$presupuesto_id = $reqData['presupuesto_id'] ?? -1;
|
||||
|
||||
/*foreach($datos as $key=>$linea){
|
||||
$datos[$key]['papel_id'] = $datos[$key]['papel_id'] ?? -1;
|
||||
}*/
|
||||
|
||||
|
||||
if($datos != null){
|
||||
$this->updateLineasPresupuestoActivas($presupuesto_id, $datos);
|
||||
}
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getCompIntData($uso, $datosPedido, $papel_generico, $gramaje, $isColor, $isHq)
|
||||
{
|
||||
$tipo = $isColor? ($isHq?'colorhq':'color'): ($isHq?'negrohq':'negro');
|
||||
@ -509,14 +504,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
if( $uso == 'cubierta' ){
|
||||
$opciones_papel = array(
|
||||
'cubierta' => 1,
|
||||
'color' => 1,
|
||||
//'color' => 1,
|
||||
'rotativa' => 0,
|
||||
);
|
||||
}
|
||||
else if ( $uso == 'sobrecubierta' ){
|
||||
$opciones_papel = array(
|
||||
'sobrecubierta' => 1,
|
||||
'color' => 1,
|
||||
//'color' => 1,
|
||||
'rotativa' => 0,
|
||||
);
|
||||
}
|
||||
@ -551,6 +546,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto(
|
||||
is_rotativa: 0,
|
||||
tarifa_tipo: $tipo,
|
||||
uso_tarifa: $uso,
|
||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||
papel_impresion_id: $papel->id,
|
||||
);
|
||||
@ -559,11 +555,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
foreach ($maquinas as $maquina) {
|
||||
|
||||
$tarifamodel = new MaquinasTarifasImpresionModel();
|
||||
$tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo);
|
||||
[$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo);
|
||||
if(!is_float($tarifa)){
|
||||
continue;
|
||||
}
|
||||
$linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa);
|
||||
if(array_key_exists('error', $linea))
|
||||
continue;
|
||||
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
|
||||
$linea['fields']['maquina'] = $maquina->maquina;
|
||||
$linea['fields']['maquina_id'] = $maquina->maquina_id;
|
||||
$linea['fields']['maquina_velocidad'] = $maquina->velocidad;
|
||||
@ -584,7 +583,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
return $lineas;
|
||||
}
|
||||
|
||||
public function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas)
|
||||
public function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $datosTipolog = null)
|
||||
{
|
||||
|
||||
$uso = 'interior';
|
||||
@ -628,10 +627,20 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
foreach ($papeles as $papel) {
|
||||
|
||||
$papelImpresionTipologiaModel = new \App\Models\Configuracion\PapelImpresionTipologiaModel();
|
||||
$datosTipologias = $papelImpresionTipologiaModel
|
||||
->findTipologiasForPapelImpresion($papel->id, $parametrosRotativa->colorPages>0?'color':'negro')
|
||||
->get()->getResultObject();
|
||||
if(is_null($datosTipolog)){
|
||||
$datosTipologias = $papelImpresionTipologiaModel
|
||||
->findTipologiasForPapelImpresion($papel->id, $parametrosRotativa->colorPages>0?'color':'negro')
|
||||
->get()->getResultObject();
|
||||
|
||||
|
||||
if(count($datosTipologias)==0){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$datosTipologias = $datosTipolog;
|
||||
}
|
||||
|
||||
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
||||
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
||||
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
|
||||
@ -644,6 +653,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto(
|
||||
is_rotativa: 1,
|
||||
tarifa_tipo: $tipo,
|
||||
uso_tarifa: $uso,
|
||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||
papel_impresion_id: $papel->id,
|
||||
);
|
||||
@ -656,7 +666,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$parametrosRotativa->a_favor_fibra = $i;
|
||||
|
||||
$tarifamodel = new MaquinasTarifasImpresionModel();
|
||||
$tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo);
|
||||
[$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo);
|
||||
if(!is_float($tarifa)){
|
||||
continue;
|
||||
}
|
||||
@ -665,6 +675,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
|
||||
|
||||
$precio_pliego_impresion = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas);
|
||||
|
||||
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
|
||||
|
||||
$linea['fields']['precios_pliegos'] = $precio_pliego_impresion;
|
||||
|
||||
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $precio_pliego_impresion;
|
||||
@ -678,6 +691,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$linea['fields']['papel_impresion'] = $papel->nombre;
|
||||
$linea['fields']['papel_impresion_id'] = $papel->id;
|
||||
$linea['fields']['paginas'] = $datosPedido->paginas;
|
||||
$linea['fields']['paginas_color'] = $paginas->color;
|
||||
$linea['fields']['gramaje'] = $gramaje;
|
||||
$linea['fields']['papel_generico_id'] = $papel_generico['id'];
|
||||
$linea['fields']['papel_generico'] = $papel_generico['nombre'];
|
||||
@ -686,6 +700,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$linea['fields']['num_formas_horizontales'] = floor($linea['fields']['factor_anchura']);
|
||||
$linea['fields']['num_formas_verticales'] = floor($linea['fields']['factor_altura']);
|
||||
|
||||
$linea['fields']['datosTipologias'] = $datosTipologias[0];
|
||||
|
||||
// impresion
|
||||
$linea['fields']['precio_click'] = $tarifa;
|
||||
$linea['fields']['precio_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click'];
|
||||
@ -734,85 +750,96 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
try{
|
||||
|
||||
$tipo = $reqData['tipo'] ?? null;
|
||||
$uso = $reqData['uso'] ?? null;
|
||||
$datos = $reqData['datos'] ?? null;
|
||||
//$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$tipo = $reqData['tipo'] ?? null;
|
||||
$uso = $reqData['uso'] ?? null;
|
||||
$datos = $reqData['datos'] ?? null;
|
||||
//$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($tipo == 'gramaje') {
|
||||
// En este caso contiene el nombre del papel generico
|
||||
$model = new PapelGenericoModel();
|
||||
$menu = $model->getGramajeComparador($datos, $uso );
|
||||
if ($tipo == 'gramaje') {
|
||||
// En este caso contiene el nombre del papel generico
|
||||
$model = new PapelGenericoModel();
|
||||
$menu = $model->getGramajeComparador($datos, $uso );
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
elseif ($tipo == 'gramajeLineasPresupuesto') {
|
||||
$tipoLinea = $reqData['tipoLinea'] ?? null;
|
||||
// En este caso contiene el id del papel generico
|
||||
$model = new PapelGenericoModel();
|
||||
$menu = $model->getGramajeLineasPresupuesto($datos, $tipoLinea, $uso );
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
elseif ($tipo == 'gramajeLineasPresupuesto') {
|
||||
$tipoLinea = $reqData['tipoLinea'] ?? null;
|
||||
// En este caso contiene el id del papel generico
|
||||
$model = new PapelGenericoModel();
|
||||
$menu = $model->getGramajeLineasPresupuesto($datos, $tipoLinea, $uso );
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
elseif ($tipo == 'papelImpresion') {
|
||||
$gramaje = $reqData['gramaje'] ?? null;
|
||||
$tipoLinea = $reqData['tipoLinea'] ?? null;
|
||||
// En este caso contiene el nombre del papel generico
|
||||
// Uso: negro, negrohq, color, colorhq, rot_bn, rot_color,
|
||||
$model = new PapelImpresionModel();
|
||||
$menu = $model->getPapelesImpresionForMenu($datos, $gramaje, $tipoLinea, $uso );
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
elseif ($tipo == 'papelImpresion') {
|
||||
$gramaje = $reqData['gramaje'] ?? null;
|
||||
$tipoLinea = $reqData['tipoLinea'] ?? null;
|
||||
// En este caso contiene el nombre del papel generico
|
||||
// Uso: negro, negrohq, color, colorhq, rot_bn, rot_color,
|
||||
$model = new PapelImpresionModel();
|
||||
$menu = $model->getPapelesImpresionForMenu($datos, $gramaje, $tipoLinea, $uso );
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
|
||||
elseif ($tipo == 'maquina') {
|
||||
$is_rotativa = $reqData['is_rotativa'] ?? null;
|
||||
$papel_impresion = $reqData['papel_impresion'] ?? null;
|
||||
$tipo_linea = $reqData['tipoLinea'] ?? null;
|
||||
$ancho = $reqData['ancho'] ?? null;
|
||||
$alto = $reqData['alto'] ?? null;
|
||||
// Datos contiene la tirada
|
||||
// uso: negro, negrohq, color, colorhq,
|
||||
$model = new MaquinaModel();
|
||||
$maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $datos, $papel_impresion );
|
||||
$menu = [];
|
||||
foreach ($maquinas as $maquina){
|
||||
|
||||
$formas = PresupuestoService::getNumFormasPlana($tipo_linea, $maquina, floatval($ancho), floatval($alto), true);
|
||||
|
||||
if($formas['num_formas'] != 'n/a'){
|
||||
array_push($menu, $maquina);
|
||||
}
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
elseif ($tipo == 'maquina') {
|
||||
$is_rotativa = $reqData['is_rotativa'] ?? null;
|
||||
$papel_impresion = $reqData['papel_impresion'] ?? null;
|
||||
$tipo_linea = $reqData['tipoLinea'] ?? null;
|
||||
$ancho = $reqData['ancho'] ?? null;
|
||||
$alto = $reqData['alto'] ?? null;
|
||||
// Datos contiene la tirada
|
||||
// uso: negro, negrohq, color, colorhq,
|
||||
$uso_tarifa = $reqData['uso_tarifa'] ?? 'interior';
|
||||
$model = new MaquinaModel();
|
||||
$maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $uso_tarifa ,$datos, $papel_impresion );
|
||||
$menu = [];
|
||||
foreach ($maquinas as $maquina){
|
||||
|
||||
$formas = PresupuestoService::getNumFormasPlana($tipo_linea, $maquina, floatval($ancho), floatval($alto), true);
|
||||
|
||||
if($formas['num_formas'] != 'n/a'){
|
||||
array_push($menu, $maquina);
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
$data = [
|
||||
'tipo' => $tipo,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$data = [
|
||||
'tipo' => $tipo,
|
||||
'error' => $e,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
|
||||
return $this->respond($data);
|
||||
finally{
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
@ -846,10 +873,34 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
$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'))])]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getPapelGenericoRotativaNegro()
|
||||
{
|
||||
$model = model('App\Models\Configuracion\PapelGenericoModel');
|
||||
$data = $model->getPapelForComparador('negro', false, false, true);
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getPapelGenericoRotativaColor()
|
||||
{
|
||||
$model = model('App\Models\Configuracion\PapelGenericoModel');
|
||||
$data = $model->getPapelForComparador('color', false, false, true);
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getPapelGenericoNegro()
|
||||
{
|
||||
$model = model('App\Models\Configuracion\PapelGenericoModel');
|
||||
@ -960,7 +1011,26 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getLineasPresupuestoActivas($presupuesto_id)
|
||||
{
|
||||
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$data = $model->getLineasPresupuesto($presupuesto_id);
|
||||
|
||||
$papel_imp_model = model('App\Models\Configuracion\PapelImpresionModel');
|
||||
$maquina_model = model('App\Models\Configuracion\MaquinaModel');
|
||||
|
||||
foreach($data as $linea){
|
||||
$linea->papel_impresion_nombre = $papel_imp_model->getNombre($linea->papel_impresion_id)[0]->text;
|
||||
$linea->maquina_nombre = $maquina_model->getNombre($linea->maquina_id)[0]->text;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function updateLineasPresupuestoActivas($presupuesto_id, $datos)
|
||||
{
|
||||
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
return $model->updateLineasPresupuesto($presupuesto_id, $datos);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -17,7 +17,34 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->testLineasIntPlana();
|
||||
$this->getLP();
|
||||
}
|
||||
|
||||
public function timeToSeconds(){
|
||||
$time = '99:59:59';
|
||||
|
||||
$time_parts = explode(":", $time);
|
||||
$seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600;
|
||||
echo "Time in seconds: " . $seconds;
|
||||
}
|
||||
|
||||
public function getLP(){
|
||||
$lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$data = $lp_model->getLineasPresupuesto(8);
|
||||
$papel_imp_model = model('App\Models\Configuracion\PapelImpresionModel');
|
||||
$maquina_model = model('App\Models\Configuracion\MaquinaModel');
|
||||
foreach($data as $linea){
|
||||
$linea->papel_impresion_id = $papel_imp_model->getValue_Nombre($linea->papel_impresion_id)[0];
|
||||
$linea->maquina_id = $maquina_model->getValue_Nombre($linea->maquina_id)[0];
|
||||
var_dump($linea->papel_impresion_id);
|
||||
var_dump($linea->maquina_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createLP(){
|
||||
$lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$lp_model->createForPresupuesto(8);
|
||||
}
|
||||
|
||||
public function getPapelesHQ(){
|
||||
|
||||
Reference in New Issue
Block a user