mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Trabajando
This commit is contained in:
@ -378,13 +378,15 @@ $routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Ta
|
|||||||
});
|
});
|
||||||
$routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']);
|
$routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|
||||||
$routes->group('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
$routes->group('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||||
$routes->post('datatable', 'Tarifaencuadernaciontiradas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionTiradas']);
|
$routes->post('datatable', 'Tarifaencuadernaciontiradas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionTiradas']);
|
||||||
$routes->post('datatable_editor', 'Tarifaencuadernaciontiradas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionTiradas']);
|
$routes->post('datatable_editor', 'Tarifaencuadernaciontiradas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionTiradas']);
|
||||||
$routes->post('menuitems', 'Tarifaencuadernaciontiradas::menuItems', ['as' => 'menuItemsOfTarifaencuadernaciontiradas']);
|
$routes->post('menuitems', 'Tarifaencuadernaciontiradas::menuItems', ['as' => 'menuItemsOfTarifaencuadernaciontiradas']);
|
||||||
});
|
});
|
||||||
$routes->resource('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernaciontiradas', 'except' => 'show,new,create,update']);
|
$routes->resource('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernaciontiradas', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|
||||||
$routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], function ($routes) {
|
$routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], function ($routes) {
|
||||||
$routes->get('', 'Proveedores::index', ['as' => 'proveedorList']);
|
$routes->get('', 'Proveedores::index', ['as' => 'proveedorList']);
|
||||||
$routes->get('add', 'Proveedores::add', ['as' => 'newProveedor']);
|
$routes->get('add', 'Proveedores::add', ['as' => 'newProveedor']);
|
||||||
|
|||||||
@ -27,6 +27,26 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl
|
|||||||
{
|
{
|
||||||
protected static $controllerSlug = 'tarifaencuadernaciontiradas';
|
protected static $controllerSlug = 'tarifaencuadernaciontiradas';
|
||||||
|
|
||||||
|
protected $modelName = TarifaEncuadernacionTiradaModel::class;
|
||||||
|
protected $format = 'json';
|
||||||
|
|
||||||
|
protected static $singularObjectName = 'Tarifa Encuadernacion Tirada';
|
||||||
|
protected static $singularObjectNameCc = 'tarifaEncuadernacionTirada';
|
||||||
|
protected static $pluralObjectName = 'Tarifa Encuadernacion Tiradas';
|
||||||
|
protected static $pluralObjectNameCc = 'tarifaEncuadernacionTiradas';
|
||||||
|
|
||||||
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
// Se indica que este controlador trabaja con soft_delete
|
||||||
|
$this->soft_delete = true;
|
||||||
|
// Se indica el flag para los ficheros borrados
|
||||||
|
$this->delete_flag = 1;
|
||||||
|
|
||||||
|
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
|
||||||
|
|
||||||
|
parent::initController($request, $response, $logger);
|
||||||
|
}
|
||||||
|
|
||||||
public function datatable_editor()
|
public function datatable_editor()
|
||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
@ -50,14 +70,11 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl
|
|||||||
->validator('Validate::notEmpty', array(
|
->validator('Validate::notEmpty', array(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required'))
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required'))
|
||||||
),
|
),
|
||||||
Field::inst('proveedor')
|
Field::inst('proveedor_id')
|
||||||
->options( Options::inst()
|
->validator('Validate::notEmpty', array(
|
||||||
->table( 'lg_proveedores' )
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required'))
|
||||||
->value( 'id' )
|
),
|
||||||
->label( 'nombre' )
|
|
||||||
),
|
|
||||||
Field::inst('tarifa_encuadernacion_id'),
|
Field::inst('tarifa_encuadernacion_id'),
|
||||||
Field::inst('proveedor_id'),
|
|
||||||
Field::inst('user_created_id'),
|
Field::inst('user_created_id'),
|
||||||
Field::inst('created_at'),
|
Field::inst('created_at'),
|
||||||
Field::inst('user_updated_id'),
|
Field::inst('user_updated_id'),
|
||||||
@ -161,9 +178,10 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl
|
|||||||
|
|
||||||
$tipoId = $provTipoModel->getTipoId("Encuadernacion");
|
$tipoId = $provTipoModel->getTipoId("Encuadernacion");
|
||||||
$provList = $provModel->getProvList($tipoId);
|
$provList = $provModel->getProvList($tipoId);
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'data' => $provList,
|
'data' => $provList,
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
|
|||||||
@ -8,6 +8,9 @@ use App\Models\Collection;
|
|||||||
use App\Entities\Tarifas\TarifaEncuadernacionEntity;
|
use App\Entities\Tarifas\TarifaEncuadernacionEntity;
|
||||||
|
|
||||||
use App\Models\Tarifas\TarifaEncuadernacionModel;
|
use App\Models\Tarifas\TarifaEncuadernacionModel;
|
||||||
|
use App\Models\Compras\ProveedorModel;
|
||||||
|
use App\Models\Compras\ProveedorTipoModel;
|
||||||
|
|
||||||
|
|
||||||
class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
|
class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
|
||||||
{
|
{
|
||||||
@ -210,6 +213,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
|
|||||||
|
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||||
|
|
||||||
|
//JJO
|
||||||
|
$this->viewData['proveedores'] = $this->getProveedores();
|
||||||
|
|
||||||
return $this->displayForm(__METHOD__, $id);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
} // end function edit(...)
|
} // end function edit(...)
|
||||||
@ -293,4 +298,11 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getProveedores(){
|
||||||
|
$provTipoModel = new ProveedorTipoModel();
|
||||||
|
$provModel = new ProveedorModel();
|
||||||
|
|
||||||
|
$tipoId = $provTipoModel->getTipoId("Encuadernacion");
|
||||||
|
return $provModel->getProvList($tipoId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ return [
|
|||||||
'paginasMin' => 'Min Pages',
|
'paginasMin' => 'Min Pages',
|
||||||
'margen' => 'Margin',
|
'margen' => 'Margin',
|
||||||
'validation' => [
|
'validation' => [
|
||||||
|
'error_seleccion_tiradas' => 'A line from the Printings table must be selected before creating a new record.',
|
||||||
'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.',
|
'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.',
|
||||||
'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages',
|
'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages',
|
||||||
'precio_max' => [
|
'precio_max' => [
|
||||||
|
|||||||
@ -13,6 +13,7 @@ return [
|
|||||||
'paginasMin' => 'Páginas Min',
|
'paginasMin' => 'Páginas Min',
|
||||||
'margen' => 'Margen',
|
'margen' => 'Margen',
|
||||||
'validation' => [
|
'validation' => [
|
||||||
|
'error_seleccion_tiradas' => 'Debe seleccionar una línea de la tabla tiradas antes de crear un registro nuevo.',
|
||||||
'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.',
|
'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.',
|
||||||
'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max',
|
'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max',
|
||||||
'precio_max' => [
|
'precio_max' => [
|
||||||
|
|||||||
@ -205,9 +205,9 @@ class ProveedorModel extends \App\Models\GoBaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS proveedor_id, t1.nombre AS proveedor")
|
"t1.id AS value, t1.nombre AS label")
|
||||||
->where("tipo_id", $tipoId);
|
->where("tipo_id", $tipoId);
|
||||||
|
|
||||||
return $builder->getResult('array');
|
return $builder->get()->getResultObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,6 +81,10 @@ class ProveedorTipoModel extends \App\Models\GoBaseModel
|
|||||||
->select("t1.id AS id")
|
->select("t1.id AS id")
|
||||||
->where("t1.nombre", $tipo);
|
->where("t1.nombre", $tipo);
|
||||||
|
|
||||||
return $builder->get()->getResultObject();
|
$rows = $builder->get()->getResultObject();
|
||||||
|
if(sizeof($rows)>0)
|
||||||
|
return intval($rows[0]->id);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,7 @@ if (session()->has('error')) {
|
|||||||
|
|
||||||
<?= $this->section('additionalInlineJs') ?>
|
<?= $this->section('additionalInlineJs') ?>
|
||||||
|
|
||||||
function popAlert(message, alertType){
|
function popAlert(message, alertClass, alertIcon){
|
||||||
var alertClass = "alert-" + alertType;
|
|
||||||
var alertIcon = alertType == "success" ? "ti-check" : "ti-" + alertType;
|
|
||||||
var htmlString = `
|
var htmlString = `
|
||||||
<div class="alert ${alertClass} d-flex align-items-baseline" role="alert">
|
<div class="alert ${alertClass} d-flex align-items-baseline" role="alert">
|
||||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||||
@ -45,15 +43,15 @@ function popAlert(message, alertType){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function popSuccessAlert(successMsg){
|
function popSuccessAlert(successMsg){
|
||||||
popAlert(successMsg, "success");
|
popAlert(successMsg, "alert-success", "ti-check");
|
||||||
}
|
}
|
||||||
|
|
||||||
function popWarningAlert(warningMsg){
|
function popWarningAlert(warningMsg){
|
||||||
popAlert(warningMsg, "warning");
|
popAlert(warningMsg, "alert-warning", "ti-bell");
|
||||||
}
|
}
|
||||||
|
|
||||||
function popErrorAlert(errorMsg){
|
function popErrorAlert(errorMsg){
|
||||||
popAlert(errorMsg, "error");
|
popAlert(errorMsg, "alert-danger", "ti-ban");
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php if (isset($successMessage) && $successMessage){ ?>
|
<?php if (isset($successMessage) && $successMessage){ ?>
|
||||||
|
|||||||
@ -78,7 +78,7 @@
|
|||||||
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
||||||
<th></th>
|
<th style="min-width:100px"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -117,6 +117,10 @@
|
|||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-delete', function(e) {
|
||||||
|
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||||
|
});
|
||||||
|
|
||||||
var selected_tirada_id = -1;
|
var selected_tirada_id = -1;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -166,11 +170,11 @@
|
|||||||
|
|
||||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||||
if ( type === 'create'){
|
if ( type === 'create'){
|
||||||
d.data[0]['tirada_encuadernacion_id'] = id;
|
d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id;
|
||||||
}
|
}
|
||||||
else if(type === 'edit' ) {
|
else if(type === 'edit' ) {
|
||||||
for (v in d.data){
|
for (v in d.data){
|
||||||
d.data[v]['tirada_encuadernacion_id'] = id;
|
d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -188,6 +192,7 @@
|
|||||||
theTable.draw();
|
theTable.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( {
|
var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( {
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
processing: true,
|
processing: true,
|
||||||
@ -203,8 +208,8 @@
|
|||||||
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||||
ajax : $.fn.dataTable.pipeline( {
|
ajax : $.fn.dataTable.pipeline( {
|
||||||
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineas') ?>',
|
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineas') ?>',
|
||||||
data: {
|
data: function ( d ) {
|
||||||
tirada_id: selected_tirada_id,
|
d.tirada_id = selected_tirada_id;
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||||
@ -240,7 +245,21 @@
|
|||||||
formOptions: {
|
formOptions: {
|
||||||
submitTrigger: -1,
|
submitTrigger: -1,
|
||||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
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>'
|
||||||
|
|
||||||
|
};
|
||||||
|
editor.inlineCreate(config.position, formOptions);
|
||||||
|
}
|
||||||
|
},
|
||||||
} ]
|
} ]
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -261,34 +280,29 @@
|
|||||||
|
|
||||||
|
|
||||||
// Delete row
|
// Delete row
|
||||||
$(document).on('click', '.btn-delete', function(e) {
|
$(document).on('click', '.btn-remove', function(e) {
|
||||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
const dataId = $(this).attr('data-id');
|
||||||
});
|
const row = $(this).closest('tr');
|
||||||
|
if ($.isNumeric(dataId)) {
|
||||||
$(document).on('click', '.btn-remove', function(e) {
|
/*$.ajax({
|
||||||
const dataId = $(this).attr('data-id');
|
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
|
||||||
const row = $(this).closest('tr');
|
method: 'GET',
|
||||||
if ($.isNumeric(dataId)) {
|
}).done((data, textStatus, jqXHR) => {
|
||||||
/*$.ajax({
|
$('#confirm2delete').modal('toggle');
|
||||||
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
|
theTable.clearPipeline();
|
||||||
method: 'GET',
|
theTable.row($(row)).invalidate().draw();
|
||||||
}).done((data, textStatus, jqXHR) => {
|
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||||
$('#confirm2delete').modal('toggle');
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
theTable.clearPipeline();
|
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||||
theTable.row($(row)).invalidate().draw();
|
})*/
|
||||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
/*editor
|
||||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
.create( false )
|
||||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
.edit( this.parentNode, false)
|
||||||
})*/
|
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||||
console.log(this.parentNode);
|
.set( 'is_deleted', 1 )
|
||||||
/*editor
|
.submit();*/
|
||||||
.create( false )
|
}
|
||||||
.edit( this.parentNode, false)
|
});
|
||||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
|
||||||
.set( 'is_deleted', 1 )
|
|
||||||
.submit();*/
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) {
|
$('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) {
|
||||||
@ -326,8 +340,11 @@
|
|||||||
<!------------------------------------------->
|
<!------------------------------------------->
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
|
||||||
|
// Definicion de la ultima columna de la tabla
|
||||||
const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1;
|
const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1;
|
||||||
|
|
||||||
|
|
||||||
|
// Datatables Editor
|
||||||
var editor2 = new $.fn.dataTable.Editor( {
|
var editor2 = new $.fn.dataTable.Editor( {
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "<?= route_to('editorOfTarifaEncuadernacionTiradas') ?>",
|
url: "<?= route_to('editorOfTarifaEncuadernacionTiradas') ?>",
|
||||||
@ -338,7 +355,7 @@
|
|||||||
table : "#tableOfTarifaencuadernaciontiradas",
|
table : "#tableOfTarifaencuadernaciontiradas",
|
||||||
idSrc: 'id',
|
idSrc: 'id',
|
||||||
fields: [ {
|
fields: [ {
|
||||||
name: "proveedor",
|
name: "proveedor_id",
|
||||||
"type": "select"
|
"type": "select"
|
||||||
}, {
|
}, {
|
||||||
name: "tirada_min"
|
name: "tirada_min"
|
||||||
@ -348,7 +365,7 @@
|
|||||||
"name": "tarifa_encuadernacion_id",
|
"name": "tarifa_encuadernacion_id",
|
||||||
"type": "hidden"
|
"type": "hidden"
|
||||||
},{
|
},{
|
||||||
name: "proveedor_id",
|
name: "proveedor",
|
||||||
"type": "hidden"
|
"type": "hidden"
|
||||||
}, {
|
}, {
|
||||||
"name": "deleted_at",
|
"name": "deleted_at",
|
||||||
@ -361,6 +378,11 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
// Generación de la lista de proveedores (id, nombre) para encuadernación
|
||||||
|
const suppliersList = <?php echo json_encode($proveedores); ?>;
|
||||||
|
editor2.field( 'proveedor_id' ).update( suppliersList );
|
||||||
|
|
||||||
|
|
||||||
editor2.on( 'preSubmit', function ( e, d, type ) {
|
editor2.on( 'preSubmit', function ( e, d, type ) {
|
||||||
if ( type === 'create'){
|
if ( type === 'create'){
|
||||||
d.data[0]['tarifa_encuadernacion_id'] = id;
|
d.data[0]['tarifa_encuadernacion_id'] = id;
|
||||||
@ -381,11 +403,12 @@
|
|||||||
|
|
||||||
editor2.on( 'submitSuccess', function ( e, json, data, action ) {
|
editor2.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||||
|
|
||||||
theTable.clearPipeline();
|
theTable2.clearPipeline();
|
||||||
theTable.draw();
|
theTable2.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Tabla de tiradas
|
||||||
var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( {
|
var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( {
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
processing: true,
|
processing: true,
|
||||||
@ -410,7 +433,12 @@
|
|||||||
async: true,
|
async: true,
|
||||||
}),
|
}),
|
||||||
columns: [
|
columns: [
|
||||||
{ 'data': 'proveedor' },
|
{ 'data': 'proveedor_id',
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
var value = suppliersList.find(element => element.value === data);
|
||||||
|
return value['label'];
|
||||||
|
},
|
||||||
|
},
|
||||||
{ 'data': 'tirada_min' },
|
{ 'data': 'tirada_min' },
|
||||||
{ 'data': 'tirada_max' },
|
{ 'data': 'tirada_max' },
|
||||||
{
|
{
|
||||||
@ -441,6 +469,25 @@
|
|||||||
} ]
|
} ]
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
// Obtener la id de la fila seleccionada o ponerla a -1 cuando no haya ninguna seleccionada
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
theTable2.on( 'deselect', function ( e, dt, type, indexes ) {
|
||||||
|
if ( theTable2.rows( '.selected' ).count() == 0 ) {
|
||||||
|
selected_tirada_id = -1;
|
||||||
|
theTable.clearPipeline();
|
||||||
|
theTable.draw();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
// Activate an inline edit on click of a table cell
|
// Activate an inline edit on click of a table cell
|
||||||
$('#tableOfTarifaencuadernaciontiradas').on( 'click', 'tbody span.edit', function (e) {
|
$('#tableOfTarifaencuadernaciontiradas').on( 'click', 'tbody span.edit', function (e) {
|
||||||
@ -458,36 +505,24 @@
|
|||||||
|
|
||||||
|
|
||||||
// Delete row
|
// Delete row
|
||||||
|
$(document).on('click', '.btn-remove', function(e) {
|
||||||
|
const dataId = $(this).attr('data-id');
|
||||||
|
const row = $(this).closest('tr');
|
||||||
|
if ($.isNumeric(dataId)) {
|
||||||
|
$.ajax({
|
||||||
|
url: `/tarifas/tarifaencuadernaciontiradas/delete/${dataId}`,
|
||||||
|
method: 'GET',
|
||||||
|
}).done((data, textStatus, jqXHR) => {
|
||||||
|
$('#confirm2delete').modal('toggle');
|
||||||
|
theTable2.clearPipeline();
|
||||||
|
theTable2.row($(row)).invalidate().draw();
|
||||||
|
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||||
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
|
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
$('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) {
|
|
||||||
|
|
||||||
Swal.fire({
|
|
||||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
|
|
||||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: '#3085d6',
|
|
||||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
|
||||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
|
||||||
cancelButtonColor: '#d33'
|
|
||||||
})
|
|
||||||
.then((result) => {
|
|
||||||
const dataId = $(this).data('id');
|
|
||||||
const row = $(this).closest('tr');
|
|
||||||
if (result.value) {
|
|
||||||
editor
|
|
||||||
.create( false )
|
|
||||||
.edit( this.parentNode, false)
|
|
||||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
|
||||||
.set( 'is_deleted', 1 )
|
|
||||||
.submit();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});*/
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user