cargando papeles y gramaje en el comparador

This commit is contained in:
Jaime Jimenez
2023-09-20 21:45:22 +02:00
parent ba176c04c2
commit 96a2c7f985
12 changed files with 516 additions and 280 deletions

View File

@ -7,7 +7,7 @@ use App\Controllers\GoBaseResourceController;
use App\Models\Collection;
use App\Entities\Presupuestos\PresupuestoEntity;
use App\Models\Configuracion\PapelGenericoModel;
use App\Models\Presupuestos\PresupuestoModel;
class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
@ -135,6 +135,13 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$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();
/*
@ -356,6 +363,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$this->viewData['paginasCubiertaList'] = $this->getPaginasCubiertaOptions();
$this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions();
$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['formAction'] = route_to('updatePresupuesto', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3');
@ -455,17 +470,23 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
public function menuItems()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$tipo = $reqData['tipo'] ?? null;
$datos = $reqData['datos'] ?? null;
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
$reqText = goSanitize($this->request->getPost('text'))[0];
$onlyActiveOnes = false;
$columns2select = [$reqId ?? 'id', $reqText ?? 'titulo'];
$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);
if ($tipo == 'gramaje'){
// En este caso contiene el nombre del papel generico
$model = new PapelGenericoModel();
$menu = $model->getGramajeComparador($datos, $searchStr);
$nonItem = new \stdClass;
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -511,6 +532,54 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
return $data;
}
protected function getPapelGenericoNegro()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('negro', false, false);
array_unshift($data, lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]));
return $data;
}
protected function getPapelGenericoNegroHQ()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('negrohq', false, false);
array_unshift($data, lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]));
return $data;
}
protected function getPapelGenericoColor()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('color', false, false);
array_unshift($data, lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]));
return $data;
}
protected function getPapelGenericoColorHQ()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('colorhq', false, false);
array_unshift($data, lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]));
return $data;
}
protected function getPapelGenericoCubierta()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('color', true, false);
array_unshift($data, lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]));
return $data;
}
protected function getPapelGenericoSobreCubierta()
{
$model = model('App\Models\Configuracion\PapelGenericoModel');
$data = $model->getPapelForComparador('color', false, true);
array_unshift($data, lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]));
return $data;
}
/*

View File

@ -2,7 +2,7 @@
namespace App\Controllers;
use App\Services\PresupuestoService;
use App\Models\Configuracion\PapelGenericoModel;
class Test extends BaseController
{
@ -15,8 +15,10 @@ class Test extends BaseController
public function index()
{
$text = PresupuestoService::example();
echo $text;
$model = new PapelGenericoModel();
echo '<pre>';
var_dump($model->getGramajeComparador('CARTULINA GRÁFICA ESTUCADA 1/C'));
echo '</pre>';
}
}