trabajando en obtener el gramaje. las funcion calcular mermas hay que colocarla en mejor sitio

This commit is contained in:
jaimejimenezortega
2024-04-18 20:40:22 +02:00
parent dff0399237
commit 4e3120703e
11 changed files with 23750 additions and 90 deletions

View File

@ -149,13 +149,18 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController
$presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity();
$presupuestoEntity->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$presupuestoEntity->clienteId = $clienteId;
$datosPresupuesto = (object)array();
$datosPresupuesto->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true);
$datosPresupuesto->papelFormatoList = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
$datosPresupuesto->papelInteriorNegro = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negro', false, false);
$datosPresupuesto->papelInteriorNegroHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negrohq', false, false);
$datosPresupuesto->papelInteriorColor = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('color', false, false);
$datosPresupuesto->papelInteriorColorHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false);
$this->viewData['formAction'] = route_to('crearPresupuestoCliente');
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
@ -468,6 +473,39 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController
return $response;
}
public function getGramaje(){
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
try {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$tirada = $reqData['tirada'] ?? 0;
$merma = $reqData['merma'] ?? 0;
$papel = $reqData['papel'] ?? "";
$uso = $reqData['uso'] ?? "";
$model = new PapelGenericoModel();
$menu = $model->getGramajeComparador($papel, $uso, intval($tirada + $merma));
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
} catch (Exception $e) {
$data = [
'error' => $e,
$csrfTokenName => $newTokenHash
];
} finally {
return $this->respond($data);
}
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable()
{