añadidas tarifas encuadernacion por horas para los cosidos

This commit is contained in:
Jaime Jiménez Ortega
2023-11-30 23:19:45 +01:00
parent f1eb8f6808
commit 67e12c8eff
24 changed files with 1369 additions and 131 deletions

View File

@ -22,39 +22,50 @@
<input type="text" id="importe_fijo" name="importe_fijo" class="form-control" value="<?=old('importe_fijo', $tarifaEncuadernacionEntity->importe_fijo) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="mostrar_en_presupuesto" class="form-check-label">
<input type="checkbox" id="mostrar_en_presupuesto" name="mostrar_en_presupuesto" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->mostrar_en_presupuesto == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.mostrar_en_presupuesto') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="tipo_encuadernacion" class="form-check-label">
<input type="checkbox" id="tipo_encuadernacion" name="tipo_encuadernacion" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->tipo_encuadernacion == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.tipo_encuadernacion') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="servicio_encuadernacion" class="form-check-label">
<input type="checkbox" id="servicio_encuadernacion" name="servicio_encuadernacion" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->servicio_encuadernacion == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.servicio_encuadernacion') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->
</div><!-- //.row -->
<div class="row">
<div class="col-md-12 col-lg-4 px-4">
<div class="mb-3">
<div class="form-check">
<label for="mostrar_en_presupuesto" class="form-check-label">
<input type="checkbox" id="mostrar_en_presupuesto" name="mostrar_en_presupuesto" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->mostrar_en_presupuesto == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.mostrar_en_presupuesto') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!-- //.col -->
<div class="col-md-12 col-lg-4 px-4">
<div class="mb-3">
<div class="form-check">
<label for="tipo_encuadernacion" class="form-check-label">
<input type="checkbox" id="tipo_encuadernacion" name="tipo_encuadernacion" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->tipo_encuadernacion == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.tipo_encuadernacion') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="servicio_encuadernacion" class="form-check-label">
<input type="checkbox" id="servicio_encuadernacion" name="servicio_encuadernacion" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->servicio_encuadernacion == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.servicio_encuadernacion') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!-- //.col -->
<div class="col-md-12 col-lg-4 px-4">
<div class="mb-3">
<div class="form-check">
<label for="por_horas" class="form-check-label">
<input type="checkbox" id="por_horas" name="por_horas" value="1" class="form-check-input" <?= $tarifaEncuadernacionEntity->por_horas == true ? 'checked' : ''; ?>>
<?= lang('Tarifaencuadernacion.por_horas') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!-- //.col -->
</div><!-- //.row -->

View File

@ -60,7 +60,7 @@
</div>
</div> <!-- //.accordion -->
<div class="accordion mt-3" id="accordionEncuadernacionLineas" style="visibility:visible" >
<div class="accordion mt-3" id="accordionEncuadernacionLineas" style="visibility:<?php ?>visible" >
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
@ -92,6 +92,37 @@
</div>
</div>
</div> <!-- //.accordion -->
<div class="accordion mt-3" id="accordionEncuadernacionLineasHoras" style="visibility:hidden" >
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
<h3><?= lang("TarifaEncuadernacionLineas.moduleTitle") ?></h3>
</button>
</h2>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionEncuadernacionLineas">
<div class="accordion-body">
<table id="tableOfTarifaencuadernacionlineasHoras" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>ID</th>
<th><?= lang('TarifaEncuadernacionLineas.tiempoMin') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.tiempoMax') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.precioHora') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
<th style="min-width:100px"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?php endif; ?>
</div><!--//.row -->
@ -146,17 +177,274 @@
if($(this).attr('table').includes('tiradas')){
remove_tiradas(dataId, row);
}
else if ($(this).attr('table').includes('lineas')){
else if ($(this).attr('table').includes('lineasHoras')){
remove_lineas_horas(dataId, row);
}
else{
remove_lineas(dataId, row);
}
}
});
function check_por_horas(){
if($('#por_horas').is(':checked')){
$('#accordionEncuadernacionLineasHoras').css("visibility", "visible");
$('#accordionEncuadernacionLineas').css("visibility", "collapse");
}
else{
$('#accordionEncuadernacionLineasHoras').css("visibility", "collapse");
$('#accordionEncuadernacionLineas').css("visibility", "visible");
}
}
check_por_horas()
$("#por_horas").change(function() {
asyncConfirmDialog('<?= lang('Tarifaencuadernacion.sureToChange') ?>',
'<?= lang('Tarifaencuadernacion.sureToChangePorHorasText') ?>', yesCallback, noCallback);
});
function yesCallback() {
check_por_horas()
if($('#por_horas').is(':checked')){
theTable.clearPipeline();
theTable.draw();
$.ajax({
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineas') ?>',
data: {
cleandatatable: 1,
tarifa_encuadernacion_id: id,
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
success:function(response){
token=JSON.parse(response).<?= csrf_token() ?>;
yeniden(token);
theTable3.clearPipeline();
theTable3.draw();
theTable.clearPipeline();
theTable.draw();
}
});
}else{
theTable3.clearPipeline();
theTable3.draw();
$.ajax({
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineasHoras') ?>',
data: {
cleandatatable: 1,
tarifa_encuadernacion_id: id,
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
success:function(response){
token=JSON.parse(response).<?= csrf_token() ?>;
yeniden(token);
theTable3.clearPipeline();
theTable3.draw();
theTable.clearPipeline();
theTable.draw();
}
});
}
}
function noCallback() {
// Toggle behaviour
$('#por_horas').prop("checked", !$('#por_horas').prop("checked"));
}
<?php endif; ?>
<?= $this->endSection() ?>
<?php if(str_contains($formAction, 'edit')): ?>
<!------------------------------------------->
<!-- Código JS para tableOfTarifaencuadernacionlineashoras -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
const lastColNr3 = $('#tableOfTarifaencuadernacionlineasHoras').find("tr:first th").length - 1;
var editor3 = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfTarifaEncuadernacionLineasHoras') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfTarifaencuadernacionlineasHoras",
idSrc: 'id',
fields: [
{name: "id",
"type": "readonly"},
{
name: "tiempo_min"
}, {
name: "tiempo_max"
}, {
name: "precio_hora"
}, {
name: "margen"
}, {
"name": "tirada_encuadernacion_id",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
]
} );
editor3.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id;
}
}
});
editor3.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
editor3.on( 'submitSuccess', function ( e, json, data, action ) {
theTable3.clearPipeline();
theTable3.draw();
});
var theTable3 = $('#tableOfTarifaencuadernacionlineasHoras').DataTable( {
draw:3,
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineasHoras') ?>',
data: function ( d ) {
d.tirada_id = selected_tirada_id;
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'id' },
{ 'data': 'tiempo_min' },
{ 'data': 'tiempo_max' },
{ 'data': 'precio_hora' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr3]
},
{"orderData": [ 0, 1 ], "targets": 0 },
],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
buttons: [ {
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor3,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
},
action: function ( e, dt, node, config ) {
if(selected_tirada_id == -1){
popErrorAlert("<?= lang('TarifaEncuadernacionLineas.validation.error_seleccion_tiradas') ?>");
}
else{
formOptions= {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
};
editor3.inlineCreate(config.position, formOptions);
}
},
} ]
} );
// Activate an inline edit on click of a table cell
$('#tableOfTarifaencuadernacionlineasHoras').on( 'click', 'tbody span.edit', function (e) {
editor3.inline(
theTable3.cells(this.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
// Delete row
function remove_lineas_horas(dataId, row){
$.ajax({
url: `/tarifas/tarifaencuadernacionlineashoras/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable3.clearPipeline();
theTable3.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
});
}
<?= $this->endSection() ?>
<!------------------------------------------->
<!-- Código JS para tableOfTarifaencuadernacionlineas -->
<!------------------------------------------->
@ -233,7 +521,8 @@
var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( {
serverSide: true,
draw:2,
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
@ -485,17 +774,30 @@
var selected_tirada_id = -1;
theTable2.on( 'select', function ( e, dt, type, indexes ) {
if ( type === 'row' ) {
selected_tirada_id = parseInt(theTable2.rows( indexes ).data().pluck( 'id' )[0]);
theTable.clearPipeline();
theTable.draw();
if($('#por_horas').is(':checked')){
theTable3.clearPipeline();
theTable3.draw();
}
else{
theTable.clearPipeline();
theTable.draw();
}
}
} );
theTable2.on( 'deselect', function ( e, dt, type, indexes ) {
if ( theTable2.rows( '.selected' ).count() == 0 ) {
selected_tirada_id = -1;
theTable.clearPipeline();
theTable.draw();
if($('#por_horas').is(':checked')){
theTable3.clearPipeline();
theTable3.draw();
}
else{
theTable.clearPipeline();
theTable.draw();
}
}
} );