mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el edit
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);
|
||||
|
||||
@ -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) {
|
||||
@ -153,14 +152,13 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$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()
|
||||
|
||||
@ -312,19 +310,19 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
$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['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['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);
|
||||
@ -339,16 +337,31 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$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();
|
||||
$this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions();*/
|
||||
|
||||
$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);
|
||||
// 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.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
@ -767,86 +780,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,
|
||||
$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);
|
||||
}
|
||||
$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);
|
||||
}
|
||||
@ -880,6 +903,7 @@ 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user