mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'bugfix/papel_impresion_1' into 'main'
Realizadas todas la modificaciones solicitadas por @jm See merge request jjimenez/safekat!44
This commit is contained in:
@ -119,17 +119,15 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
$order = MaquinasPapelesImpresionModel::SORTABLE_2[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$papel_id = $reqData['papel_id'] ?? -1;
|
||||
$ancho = $reqData['ancho'] ?? -1;
|
||||
$alto = $reqData['alto'] ?? -1;
|
||||
$papel_id = $reqData['papel_id'] ?? -1;
|
||||
$isRotativa = $reqData['isRotativa'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource_maquinas($search, $papel_id, $isRotativa, $ancho, $alto)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$resourceData = $this->model->getResource_maquinas($search, $papel_id, $isRotativa)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource_maquinas()->countAllResults(),
|
||||
$this->model->getResource_maquinas($search, $papel_id, $isRotativa, $ancho, $alto)->countAllResults()
|
||||
$this->model->getResource_maquinas($search, $papel_id, $isRotativa)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
@ -415,12 +415,12 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
$ma_model = new MaquinaModel();
|
||||
$ma_pa_model = new MaquinasPapelesImpresionModel();
|
||||
|
||||
$active_values = $ma_pa_model->getInitSelectedMachines($id, $data['rotativa'], $data['ancho'], $data['alto'])->get()->getResult('array');
|
||||
$active_values = $ma_pa_model->getInitSelectedMachines($id, $data['rotativa'])->get()->getResult('array');
|
||||
|
||||
$ma_pa_model->deleteForPapelImpresion($id);
|
||||
|
||||
// Se obtienen las máquinas que cumplen las condiciones
|
||||
$rows = $ma_model->getIdMaquinasForPapelImpresion($id, $data['rotativa'], $data['ancho'], $data['alto'])->get()->getResult('array');
|
||||
$rows = $ma_model->getIdMaquinasForPapelImpresion($id, $data['rotativa'])->get()->getResult('array');
|
||||
$ma_pa_model->insertRows($rows);
|
||||
|
||||
// Se actualizan los activos que había en caso de que los hubiera
|
||||
|
||||
@ -25,8 +25,9 @@ return [
|
||||
'papelImpresionList' => 'Print Paper List',
|
||||
'papelesImpresion' => 'Print papers',
|
||||
'papelesimpresion' => 'Print papers',
|
||||
'pesoPorPliego' => 'Weight per sheet',
|
||||
'pesoPorPliego' => 'Weight per sheet (grams)',
|
||||
'precioPliego' => 'Sheet price',
|
||||
'precioMetro' => 'Meter price',
|
||||
'precioTonelada' => 'Ton price',
|
||||
'referencia' => 'Reference',
|
||||
'rotativa' => 'Rotary',
|
||||
|
||||
@ -25,8 +25,9 @@ return [
|
||||
'papelImpresionList' => 'Lista Papel Impresión',
|
||||
'papelesImpresion' => 'Papeles Impresión',
|
||||
'papelesimpresion' => 'Papeles Impresión',
|
||||
'pesoPorPliego' => 'Peso Por Pliego',
|
||||
'pesoPorPliego' => 'Peso Por Pliego (gramos)',
|
||||
'precioPliego' => 'Precio Pliego',
|
||||
'precioMetro' => 'Precio Metro',
|
||||
'precioTonelada' => 'Precio Tonelada',
|
||||
'referencia' => 'Referencia',
|
||||
'rotativa' => 'Rotativa',
|
||||
|
||||
@ -252,16 +252,14 @@ class MaquinaModel extends \App\Models\GoBaseModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa, $ancho, $alto){
|
||||
public function getIdMaquinasForPapelImpresion($papel_impresion_id, $rotativa){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"'".$papel_impresion_id."'". " as papel_impresion_id, t1.id AS maquina_id, '0' as active"
|
||||
);
|
||||
$builder->where("t1.is_rotativa", $rotativa);
|
||||
$builder->where("t1.ancho >", $ancho);
|
||||
$builder->where("t1.alto >", $alto);
|
||||
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource_maquinas(string $search = "", $papel_id = -1, $isRotativa = -1, $ancho =-1, $alto = -1)
|
||||
public function getResource_maquinas(string $search = "", $papel_id = -1, $isRotativa = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -126,8 +126,6 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
||||
$builder->where("t1.papel_impresion_id", $papel_id);
|
||||
$builder->where("t2.is_deleted", 0);
|
||||
$builder->where("t2.is_rotativa", $isRotativa);
|
||||
$builder->where("t2.ancho >", $ancho);
|
||||
$builder->where("t2.alto >", $alto);
|
||||
$builder->where("t3.is_deleted", 0);
|
||||
$builder->where("t3.isActivo", 1);
|
||||
|
||||
@ -192,7 +190,7 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
||||
|
||||
|
||||
// Funcion para obtener todas las máquinas seleccionadas para un papel
|
||||
public function getInitSelectedMachines($papel_impresion_id= -1, $isRotativa, $ancho, $alto)
|
||||
public function getInitSelectedMachines($papel_impresion_id= -1, $isRotativa)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -207,8 +205,6 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
||||
|
||||
// Se aplican las condiciones que tienen que cumplir
|
||||
$builder->where("t2.is_rotativa", $isRotativa);
|
||||
$builder->where("t2.ancho >", $ancho);
|
||||
$builder->where("t2.alto >", $alto);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="alto" class="form-label">
|
||||
<label id="labelAlto" for="alto" class="form-label">
|
||||
<?= lang('PapelImpresion.alto') ?>*
|
||||
</label>
|
||||
<input type="number" id="alto" name="alto" required maxLength="8" step="0.01" class="form-control" value="<?= old('alto', $papelImpresion->alto) ?>">
|
||||
@ -139,10 +139,10 @@
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioPliego" class="form-label">
|
||||
<label id="labelPrecioPliego" for="precioPliego" class="form-label">
|
||||
<?= lang('PapelImpresion.precioPliego') ?>
|
||||
</label>
|
||||
<input readonly style="background-color:#d6d6d6; id="precioPliego" name="precio_pliego" required maxLength="31" class="form-control" value="<?= old('precio_pliego', $papelImpresion->precio_pliego) ?>">
|
||||
<input readonly style="background-color:#d6d6d6;" id="precioPliego" name="precio_pliego" required maxLength="31" class="form-control" value="<?= old('precio_pliego', $papelImpresion->precio_pliego) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
|
||||
@ -124,6 +124,38 @@
|
||||
id = -1;
|
||||
}
|
||||
|
||||
|
||||
$(document).on('click', '#rotativa', function(e) {
|
||||
updateForRotativa();
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
updateForRotativa();
|
||||
});
|
||||
|
||||
function updateForRotativa(){
|
||||
let label = document.getElementById('labelAlto');
|
||||
let field = document.getElementById('alto');
|
||||
let labelPrecio = document.getElementById('labelPrecioPliego');
|
||||
if($("#rotativa").is(":checked")) {
|
||||
labelPrecio.innerHTML = '<?= lang('PapelImpresion.precioMetro') ?>';
|
||||
label.innerHTML = '<?= lang('PapelImpresion.alto') ?>';
|
||||
field.readOnly = true;
|
||||
field.style.backgroundColor = "#d6d6d6";
|
||||
field.value = '0';
|
||||
updateValue();
|
||||
}
|
||||
else{
|
||||
labelPrecio.innerHTML = '<?= lang('PapelImpresion.precioPliego') ?>';
|
||||
label.innerHTML = '<?= lang('PapelImpresion.alto') ?>*';
|
||||
field.readOnly = false;
|
||||
field.style.backgroundColor = "white";
|
||||
updateValue();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const lastColNr = $('#tableOfPapelimpresiontipologias').find("tr:first th").length - 1;
|
||||
const actionBtns = function(data) {
|
||||
return `
|
||||
@ -465,7 +497,9 @@
|
||||
});
|
||||
|
||||
$("#alto").on('input', function () {
|
||||
updateValue();
|
||||
if(!$('#rotativa').is(':checked')){
|
||||
updateValue();
|
||||
}
|
||||
});
|
||||
|
||||
$("#gramaje").on('input', function () {
|
||||
@ -477,12 +511,18 @@
|
||||
});
|
||||
|
||||
function updateValue() {
|
||||
let value = parseFloat($("#gramaje").val()) * parseFloat($("#ancho").val())*parseFloat($("#alto").val())/1E6;
|
||||
let value;
|
||||
if($("#rotativa").is(":checked")) {
|
||||
value = parseFloat($("#gramaje").val()) * parseFloat($("#ancho").val())*1000/1E6;
|
||||
}
|
||||
else{
|
||||
value = parseFloat($("#gramaje").val()) * parseFloat($("#ancho").val())*parseFloat($("#alto").val())/1E6;
|
||||
}
|
||||
value = value.toFixed(2);
|
||||
$('#pesoPorPliego').val(value);
|
||||
let value2 = parseFloat($("#precioTonelada").val()) *value/1E6;
|
||||
value2 = value2.toFixed(6);
|
||||
$('#preciopliego').val(value2);
|
||||
$('#precioPliego').val(value2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user