mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
commit para mergear antes de ramas nuevas
This commit is contained in:
@ -661,6 +661,7 @@ $routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], funct
|
||||
$routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']);
|
||||
$routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']);
|
||||
$routes->get('deleteLinea/(:any)', 'FacturasLineas::deleteLinea/$1', ['as' => 'deleteLineaFactura']);
|
||||
$routes->post('editorLineas', 'FacturasLineas::datatable_editor', ['as' => 'editorOfLineasFacturas']);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -4,7 +4,9 @@ namespace App\Controllers\Facturacion;
|
||||
|
||||
use App\Models\Facturas\FacturaLineaModel;
|
||||
use App\Models\Collection;
|
||||
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
|
||||
class FacturasLineas extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -74,4 +76,117 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
|
||||
$response = $this->respondDeleted(['id' => $factura_linea_id, 'msg' => $message]);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
public function datatable_editor() {
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst( $db, 'cliente_plantilla_precios_lineas' )
|
||||
->fields(
|
||||
Field::inst( 'plantilla_id' ),
|
||||
Field::inst( 'tipo' ),
|
||||
Field::inst( 'tipo_maquina' ),
|
||||
Field::inst( 'tipo_impresion' ),
|
||||
Field::inst( 'user_updated_id' ),
|
||||
Field::inst( 'updated_at' ),
|
||||
Field::inst( 'tiempo_min' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'tiempo_max' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'precio_hora' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'margen' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
)
|
||||
->validator(function ($editor, $action, $data) {
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
|
||||
foreach ($data['data'] as $pkey => $values) {
|
||||
// Si no se quiere borrar...
|
||||
if ($data['data'][$pkey]['is_deleted'] != 1) {
|
||||
$process_data['tiempo_min'] = $data['data'][$pkey]['tiempo_min'];
|
||||
$process_data['tiempo_max'] = $data['data'][$pkey]['tiempo_max'];
|
||||
$process_data['tipo'] = $data['data'][$pkey]['tipo'];
|
||||
$process_data['tipo_maquina'] = $data['data'][$pkey]['tipo_maquina'];
|
||||
$process_data['tipo_impresion'] = $data['data'][$pkey]['tipo_impresion'];
|
||||
|
||||
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['plantilla_id']);
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if (!empty($response)) {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
->on('preCreate', function ($editor, &$values) {
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue($session->id_user);
|
||||
$editor
|
||||
->field('updated_at')
|
||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||
})
|
||||
->on('preEdit', function ($editor, &$values) {
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue($session->id_user);
|
||||
$editor
|
||||
->field('updated_at')
|
||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||
})
|
||||
->debug(true)
|
||||
->process($_POST)
|
||||
->data();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||
$this->viewData['clienteId'] = $clienteId;
|
||||
$this->viewData['clienteId'] = $presupuestoEntity->cliente_id; // En el caso del edit, se mantiene el clienteId del presupuesto
|
||||
|
||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
||||
@ -1449,9 +1449,18 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
// Servicios
|
||||
if ($datos_guardas > 0) {
|
||||
array_push($servicios, 62); // Plegado de guardas
|
||||
// se comprueba si $datos guardas es un array
|
||||
if(is_array($datos_guardas)){
|
||||
if(count($datos_guardas) > 0){
|
||||
array_push($servicios, 62); // Plegado de guardas
|
||||
}
|
||||
}
|
||||
else{
|
||||
if ($datos_guardas > 0) {
|
||||
array_push($servicios, 62); // Plegado de guardas
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
'retractilado' => 3,
|
||||
'retractilado5' => 5,
|
||||
|
||||
@ -210,6 +210,8 @@ return [
|
||||
'confirmar' => 'Confirmar presupuesto',
|
||||
'confirmado' => 'Presupuesto confirmado',
|
||||
|
||||
'totalAceptado' => 'Total aceptado',
|
||||
|
||||
// Preview
|
||||
'preview' => 'Previsualización de configuraciones',
|
||||
'preview-conf-bn' => 'Configuración Blanco y Negro',
|
||||
|
||||
@ -39,9 +39,11 @@ class FacturaLineaModel extends \App\Models\BaseModel {
|
||||
"t1.id AS id, t1.factura_id AS factura_id,
|
||||
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
|
||||
t1.descripcion AS concepto, t1.cantidad as unidades, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
|
||||
t1.base AS subtotal, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id"
|
||||
t1.base AS subtotal, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id,
|
||||
t3.total_aceptado AS total_aceptado"
|
||||
)
|
||||
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
|
||||
->join("presupuestos t3", "t3.id = t2.presupuesto_id", "left")
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
],
|
||||
"titulo" => [
|
||||
"label" => "Presupuestos.titulo",
|
||||
"rules" => "trim|required|max_length[30]",
|
||||
"rules" => "trim|required|max_length[300]",
|
||||
],
|
||||
"inc_rei" => [
|
||||
"label" => "Presupuestos.incRei",
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>id</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
@ -86,7 +87,7 @@ const actionBtns = function(data) {
|
||||
<div class="row mb-2">
|
||||
<div class="btn-group btn-group-sm"><span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||
</div>
|
||||
</div>
|
||||
</td>`;
|
||||
@ -97,7 +98,7 @@ const actionBtns = function(data) {
|
||||
<div class="row mb-2">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -107,7 +108,7 @@ const actionBtns = function(data) {
|
||||
}
|
||||
};
|
||||
|
||||
var editor = new $.fn.dataTable.Editor( {
|
||||
var editor_lineas = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfLineasFacturas') ?>",
|
||||
headers: {
|
||||
@ -121,28 +122,14 @@ var editor = new $.fn.dataTable.Editor( {
|
||||
name: "unidades",
|
||||
|
||||
}, {
|
||||
name: "concepto",
|
||||
type: "textarea"
|
||||
name: "concepto"
|
||||
}, {
|
||||
name: "precio_unidad",
|
||||
|
||||
}, {
|
||||
name: "iva",
|
||||
|
||||
}, {
|
||||
"name": "factura_id",
|
||||
"type": "hidden"
|
||||
}, {
|
||||
"name": "pedido_linea_impresion_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "pedido_maquetacion_id",
|
||||
"type": "hidden"
|
||||
},
|
||||
}
|
||||
]
|
||||
} );
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
editor_lineas.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['factura_id'] = <?= $facturaEntity->id ?>;
|
||||
}
|
||||
@ -154,12 +141,12 @@ editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
});
|
||||
|
||||
|
||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
editor_lineas.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
editor_lineas.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
tableLineas.clearPipeline();
|
||||
tableLineas.draw();
|
||||
@ -168,7 +155,7 @@ editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfLineasFactura').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor.inline(
|
||||
editor_lineas.inline(
|
||||
tableLineas.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
@ -189,11 +176,41 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
||||
scrollX: true,
|
||||
columns: [
|
||||
{data: null, render: actionBtns},
|
||||
{data: "id"},
|
||||
{data: "pedido_linea_impresion_id"},
|
||||
{data: "pedido_maquetacion_id"},
|
||||
{data: "pedido_id"},
|
||||
{data: "unidades"},
|
||||
{data: "concepto"},
|
||||
{
|
||||
data: "concepto",
|
||||
render: function (data, type, row, meta) {
|
||||
|
||||
// se convierten a float data.total_aceptado y subtotal
|
||||
var total_aceptado = parseFloat(row.total_aceptado);
|
||||
var subtotal = parseFloat(row.subtotal);
|
||||
|
||||
var error_text = '';
|
||||
if(total_aceptado != subtotal){
|
||||
error_text = 'El total del pedido ('+ total_aceptado + '€) no coincide con la línea ('+ subtotal + '€)';
|
||||
}
|
||||
|
||||
return `
|
||||
<div>
|
||||
${data}
|
||||
</div>
|
||||
|
||||
<div class="mt-5">
|
||||
|
||||
<span style="color: red;" id="error-${meta.row}">${error_text}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<label for="input-${meta.row}">Total aceptado</label>
|
||||
<input readonly type="text" id="input-${meta.row}" value="${row.total_aceptado}">
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
},
|
||||
{data: "precio_unidad"},
|
||||
{data: "iva"},
|
||||
{data: "subtotal"},
|
||||
@ -219,7 +236,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
||||
},
|
||||
{
|
||||
visible: false,
|
||||
targets: [1, 2, 3, 9, 10]
|
||||
targets: [1, 2, 3, 4, 10, 11]
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 mb-3" <?= $clienteId != 0 ?' style="display:none;"':''?>>
|
||||
<div class="col-sm-6 mb-3" <?= $clienteId != 0 && !(auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) ?' style="display:none;"':''?>>
|
||||
<label for="clienteId" class="form-label">
|
||||
<?= lang('Presupuestos.clienteId') ?>*
|
||||
</label>
|
||||
|
||||
@ -97,7 +97,7 @@
|
||||
$total = $presupuestoEntity->total_aceptado;
|
||||
$iva = $presupuestoEntity->iva_reducido?1.04:1.21;
|
||||
$total *= $iva;
|
||||
$total_unidad = $total / $presupuestoEntity->tirada;
|
||||
$total_unidad = $presupuestoEntity->total_precio_unidad * $iva;;
|
||||
echo '<h4 id="resumenTotalIVA" class="mb-1">Total: ' . round($total, 2) . '€</h4>';
|
||||
echo '<h6 id="resumenPrecioU" class="mb-0">' . round($total_unidad, 4) . '€/ud</h6>'
|
||||
?>
|
||||
|
||||
@ -606,7 +606,7 @@ async function calcularPresupuesto() {
|
||||
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isColor = true;
|
||||
let isHq = false;
|
||||
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
if($('#colorNegroHqDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
|
||||
isHq = true;
|
||||
|
||||
if(!comprobarTiradasPOD()){
|
||||
|
||||
@ -76,6 +76,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($presupuestoEntity->estado_id == 2): ?>
|
||||
<div class="row mt-5">
|
||||
<div class="mb-1">
|
||||
<label for="paginas" class="form-label">
|
||||
<?= lang('Presupuestos.totalAceptado') ?>
|
||||
</label>
|
||||
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="<?= old('paginas', $presupuestoEntity->total_aceptado) ?>" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
|
||||
</div><!--//.mb-3 -->
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div> <!-- //.accordion-body -->
|
||||
</div> <!-- //.accordion-collapse -->
|
||||
|
||||
@ -177,8 +177,8 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
|
||||
margenEnvios = parseFloat($('#margenEnvios').attr('val'))
|
||||
}
|
||||
|
||||
var totalCostes = totalPapel + totalImpresion + totalServicios + totalEnvios
|
||||
var totalMargenes = margenPapel + margenImpresion + margenServicios + margenEnvios
|
||||
var totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
|
||||
var totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
|
||||
$('#totalCostes').text((addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
|
||||
$('#totalMargenes').text((addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
|
||||
$('#totalCostes').attr('val',(totalCostes).toFixed(2) + '€')
|
||||
@ -251,11 +251,13 @@ function getValuesResumenForm(){
|
||||
formResumen += '&total_presupuesto=' + $('#totalDespuesDecuento').attr('val');
|
||||
formResumen += '&total_precio_unidad=' + $('#precioUnidadPresupuesto').attr('val');
|
||||
|
||||
formResumen += '&total_factor=' + $('#total_factor').text();
|
||||
formResumen += '&total_factor_ponderado=' + $('#total_factor_ponderado').text();
|
||||
// replace , for . in the values
|
||||
formResumen += '&total_factor=' + $('#factor').text().replace(/,/g, '.');
|
||||
formResumen += '&total_factor_ponderado=' + $('#factor_ponderado').text().replace(/,/g, '.');
|
||||
|
||||
if($('#confirmar_presupuesto').prop('checked')){
|
||||
formResumen += '&confirmar=1';
|
||||
formResumen += '&confirmar=1';
|
||||
formResumen += '&total_aceptado=' + $('#totalDespuesDecuento').attr('val');
|
||||
}
|
||||
|
||||
return formResumen
|
||||
|
||||
Reference in New Issue
Block a user