Merge branch 'mod/tarifas_envio' into 'main'

Mod/tarifas envio

See merge request jjimenez/safekat!60
This commit is contained in:
2023-09-05 19:03:22 +00:00
14 changed files with 179 additions and 106 deletions

9
.idea/deployment.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="Always" serverName="SK-IMN" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false">
<component name="PublishConfigData" autoUpload="Always" serverName="SK-JJO" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false">
<option name="confirmBeforeUploading" value="false" />
<serverData>
<paths name="SK-IMN">
@ -10,6 +10,13 @@
</mappings>
</serverdata>
</paths>
<paths name="SK-JJO">
<serverdata>
<mappings>
<mapping deploy="/" local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="SK-MAIN">
<serverdata>
<mappings>

7
.idea/webServers.xml generated
View File

@ -16,6 +16,13 @@
</advancedOptions>
</fileTransfer>
</webServer>
<webServer id="36de594c-5db8-413e-b1a1-cd035ebed2f1" name="SK-JJO" url="http://sk-jjo.imnavajas.es">
<fileTransfer host="sk-jjo.imnavajas.es" port="21">
<advancedOptions>
<advancedOptions dataProtectionLevel="Private" passiveMode="true" shareSSLContext="true" />
</advancedOptions>
</fileTransfer>
</webServer>
</option>
<groups>
<group>

View File

@ -253,7 +253,7 @@ class Tarifasenviosprecios extends \App\Controllers\GoBaseResourceController {
->validator('Validate::numeric', array(
'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.decimal'))
),
Field::inst('zona_envio_id'),
Field::inst('tarifa_envio_id'),
Field::inst('proveedor_id'),
Field::inst('user_created_id'),
Field::inst('created_at'),
@ -272,7 +272,7 @@ class Tarifasenviosprecios extends \App\Controllers\GoBaseResourceController {
$process_data['peso_max'] = $data['data'][$pkey]['peso_max'];
$process_data['proveedor_id'] = $data['data'][$pkey]['proveedor_id'];
$process_data['tipo_envio'] = $data['data'][$pkey]['tipo_envio'];
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['zona_envio_id']);
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_envio_id']);
// No se pueden duplicar valores al crear o al editar
if (!empty($response)) {
return $response;
@ -333,14 +333,14 @@ class Tarifasenviosprecios extends \App\Controllers\GoBaseResourceController {
$order = TarifaEnvioPrecioModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$zona_envio_id = $reqData['zona_envio_id'] ?? -1;
$tarifa_envio_id = $reqData['tarifa_envio_id'] ?? -1;
$resourceData = $this->model->getResource($search, $zona_envio_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$resourceData = $this->model->getResource($search, $tarifa_envio_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource()->countAllResults(),
$this->model->getResource($search, $zona_envio_id)->countAllResults()
$this->model->getResource($search, $tarifa_envio_id)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
@ -427,7 +427,6 @@ class Tarifasenviosprecios extends \App\Controllers\GoBaseResourceController {
protected function getTipoEnvioOptions() {
$tipoEnvioOptions = [
'' => lang('Basic.global.pleaseSelect'),
'a domicilio' => 'a domicilio',
'cajas' => 'cajas',
'palets' => 'palets',
];

View File

@ -14,6 +14,7 @@ class TarifaEnvioPrecioEntity extends \CodeIgniter\Entity\Entity
"peso_max" => null,
"precio" => null,
"precio_adicional" => 0,
"margen" => 0,
"user_created_id" => 0,
"user_updated_id" => 0,
"is_deleted" => 0,
@ -27,6 +28,7 @@ class TarifaEnvioPrecioEntity extends \CodeIgniter\Entity\Entity
"peso_max" => "float",
"precio" => "float",
"precio_adicional" => "float",
"margen" => "float",
"user_created_id" => "int",
"user_updated_id" => "int",
"is_deleted" => "int",

View File

@ -8,6 +8,7 @@ class TarifaEnvioZonaEntity extends \CodeIgniter\Entity\Entity
protected $attributes = [
"id" => null,
"tarifa_envio_id" => null,
"nombre" => "",
"cp_inicial" => null,
"cp_final" => null,
"importe_fijo" => 0,

View File

@ -15,6 +15,7 @@ return [
'pesoMin' => 'Min Weight',
'precio' => 'Price',
'precioAdicional' => 'Additional Price',
'margen' => 'Margin',
'proveedorId' => 'Provider',
'tarifaEnvioId' => 'Shipping Rate',
'tarifaEnvioPrecio' => 'Weight and Cost',
@ -52,6 +53,12 @@ return [
],
'margen' => [
'decimal' => 'The field must contain a decimal number.',
'required' => 'The field is required.',
],
'tipo_envio' => [
'in_list' => 'The field must be one of the are included in the list.',
'required' => 'The field is required.',

View File

@ -3,6 +3,7 @@
return [
'nombre' => 'Name',
'cpFinal' => 'Final Postcode',
'cpInicial' => 'Initial Postcode',
'createdAt' => 'Created At',
@ -20,6 +21,12 @@ return [
'userCreatedId' => 'User Created ID',
'userUpdatedId' => 'User Updated ID',
'validation' => [
'nombre' => [
'max_length' => 'The field cannot exceed 50 characters in length.',
'required' => 'The field is required.',
],
'cp_final' => [
'max_length' => 'The field cannot exceed 10 characters in length.',
'required' => 'The field is required.',

View File

@ -3,7 +3,6 @@
return [
'aDomicilio' => 'A domicilio',
'cajas' => 'Cajas',
'createdAt' => 'Created At',
'deletedAt' => 'Deleted At',
@ -15,6 +14,7 @@ return [
'pesoMin' => 'Peso Min',
'precio' => 'Precio peso mín.',
'precioAdicional' => 'Precio Kg Adicional',
'margen' => 'Margen',
'proveedorId' => 'Proveedor',
'tarifaEnvioId' => 'Tarifa Envío',
'tarifaEnvioPrecio' => 'Peso y Precio',
@ -52,6 +52,12 @@ return [
],
'margen' => [
'decimal' => 'El campo debe contener un número decimal.',
'required' => 'El campo es obligatorio.',
],
'tipo_envio' => [
'in_list' => 'El campo debe ser uno de la lista.',
'required' => 'El campo es obligatorio.',

View File

@ -3,6 +3,7 @@
return [
'nombre' => 'Nombre',
'cpFinal' => 'CP Final',
'cpInicial' => 'CP Inicial',
'createdAt' => 'Created At',
@ -20,6 +21,12 @@ return [
'userCreatedId' => 'User Created ID',
'userUpdatedId' => 'User Updated ID',
'validation' => [
'nombre' => [
'max_length' => 'El campo no puede exceder 50 caracteres en longitud.',
'required' => 'El campo es obligatorio.',
],
'cp_final' => [
'max_length' => 'El campo no puede exceder 10 caracteres en longitud.',
'required' => 'El campo es obligatorio.',

View File

@ -18,7 +18,8 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
2 => "t1.peso_min",
3 => "t1.peso_max",
4 => "t1.precio",
5 => "t1.precio_adicional"
5 => "t1.precio_adicional",
5 => "t1.margen"
];
protected $allowedFields = [
@ -29,6 +30,7 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
"peso_max",
"precio",
"precio_adicional",
"margen",
"deleted_at",
"is_deleted",
];
@ -60,9 +62,13 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
"label" => "TarifasEnviosPrecios.precioAdicional",
"rules" => "required|decimal",
],
"margen" => [
"label" => "TarifasEnviosPrecios.margen",
"rules" => "required|decimal",
],
"tipo_envio" => [
"label" => "TarifasEnviosPrecios.tipoEnvio",
"rules" => "required|in_list[a domicilio,cajas,palets]",
"rules" => "required|in_list[cajas,palets]",
],
];
@ -83,6 +89,10 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
"decimal" => "TarifasEnviosPrecios.validation.precio_adicional.decimal",
"required" => "TarifasEnviosPrecios.validation.precio_adicional.required",
],
"margen" => [
"decimal" => "TarifasEnviosPrecios.margen.margen.decimal",
"required" => "TarifasEnviosPrecios.margen.margen.required",
],
"tipo_envio" => [
"in_list" => "TarifasEnviosPrecios.validation.tipo_envio.in_list",
"required" => "TarifasEnviosPrecios.validation.tipo_envio.required",
@ -116,17 +126,17 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource(string $search = "", $zona_envio_id = -1)
public function getResource(string $search = "", $tarifa_envio_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tipo_envio AS tipo_envio, t1.peso_min AS peso_min, t1.peso_max AS peso_max, t1.precio AS precio,
t1.precio_adicional AS precio_adicional, t2.id AS tarifa_envio, t3.id AS proveedor_id, t3.nombre AS proveedor"
t1.precio_adicional AS precio_adicional, t1.margen AS margen, t2.id AS tarifa_envio, t3.id AS proveedor_id, t3.nombre AS proveedor"
);
$builder->join("tarifas_envios_zonas t2", "t1.zona_envio_id = t2.id", "left");
$builder->join("tarifas_envios_zonas t2", "t1.tarifa_envio_id = t2.id", "left");
$builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left");
$builder->where("t1.zona_envio_id", $zona_envio_id);
$builder->where("t1.tarifa_envio_id", $tarifa_envio_id);
//JJO
$builder->where("t1.is_deleted", 0);
@ -140,12 +150,14 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
->orLike("t1.peso_max", $search)
->orLike("t1.precio", $search)
->orLike("t1.precio_adicional", $search)
->orLike("t1.margen", $search)
->orLike("t3.nombre", $search)
->orLike("t1.tipo_envio", $search)
->orLike("t1.peso_min", $search)
->orLike("t1.peso_max", $search)
->orLike("t1.precio", $search)
->orLike("t1.precio_adicional", $search)
->orLike("t1.margen", $search)
->orLike("t3.nombre", $search)
->groupEnd();
}
@ -163,7 +175,7 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
->table($this->table)
->select("id, proveedor_id, tipo_envio, peso_min, peso_max")
->where("is_deleted", 0)
->where("zona_envio_id", $zona_id)
->where("tarifa_envio_id", $zona_id)
->get()->getResultObject();
@ -190,7 +202,7 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
->table($this->table)
->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'),
'is_deleted' => $delete_flag])
->where('zona_envio_id',$zona_id)
->where('tarifa_envio_id',$zona_id)
->update();
return $builder;

View File

@ -13,12 +13,13 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
protected $useAutoIncrement = true;
const SORTABLE = [
0 => "t1.cp_inicial",
1 => "t1.cp_final",
2 => "t1.importe_fijo",
0 => "t1.nombre",
1 => "t1.cp_inicial",
2 => "t1.cp_final",
3 => "t1.importe_fijo",
];
protected $allowedFields = ["tarifa_envio_id", "cp_inicial", "cp_final", "importe_fijo", "is_deleted", "deleted_at"];
protected $allowedFields = ["tarifa_envio_id", "nombre", "cp_inicial", "cp_final", "importe_fijo", "is_deleted", "deleted_at"];
protected $returnType = "App\Entities\Tarifas\TarifaEnvioZonaEntity";
protected $useTimestamps = true;
@ -31,6 +32,11 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
public static $labelField = "tarifa_envio_id";
protected $validationRules = [
"nombre" => [
"label" => "TarifasEnviosZonas.nombre",
"rules" => "trim|required|max_length[50]",
],
"cp_final" => [
"label" => "TarifasEnviosZonas.cpFinal",
"rules" => "trim|required|max_length[10]",
@ -46,6 +52,10 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
];
protected $validationMessages = [
"nombre" => [
"max_length" => "TarifasEnviosZonas.validation.nombre.max_length",
"required" => "TarifasEnviosZonas.validation.nombre.required",
],
"cp_final" => [
"max_length" => "TarifasEnviosZonas.validation.cp_final.max_length",
"required" => "TarifasEnviosZonas.validation.cp_final.required",
@ -93,7 +103,7 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id as id, t1.cp_inicial AS cp_inicial, t1.cp_final AS cp_final, t1.importe_fijo AS importe_fijo, t2.id AS tarifa_envio"
"t1.id as id, t1.nombre AS nombre, t1.cp_inicial AS cp_inicial, t1.cp_final AS cp_final, t1.importe_fijo AS importe_fijo, t2.id AS tarifa_envio"
);
$builder->join("lg_tarifas_envios t2", "t1.tarifa_envio_id = t2.id", "left");
$builder->where("t1.tarifa_envio_id", $tarifa_envio_id);
@ -105,9 +115,11 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
? $builder
: $builder
->groupStart()
->like("t1.cp_inicial", $search)
->like("t1.nombre", $search)
->orLike("t1.cp_inicial", $search)
->orLike("t1.cp_final", $search)
->orLike("t1.importe_fijo", $search)
->orLike("t1.nombre", $search)
->orLike("t1.cp_inicial", $search)
->orLike("t1.cp_final", $search)
->orLike("t1.importe_fijo", $search)

View File

@ -1,8 +1,16 @@
<div class="row">
<div class="col-md-12 col-lg-12 px-4">
<div class="mb-3">
<label for="nombre" class="form-label">
<?=lang('TarifasEnvios.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaEnvioEntity->nombre) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="paisId" class="form-label">
<?=lang('TarifasEnvios.paisId') ?>
<?=lang('TarifasEnvios.paisId') ?>*
</label>
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('TarifasEnvios.paisId')]) ?></option>
@ -15,13 +23,6 @@
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="nombre" class="form-label">
<?=lang('TarifasEnvios.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaEnvioEntity->nombre) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->

View File

@ -1,7 +1,9 @@
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
@ -9,24 +11,22 @@
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="tarifaEnvioForm" method="post" action="<?= $formAction ?>">
<form id="tarifaEnvioForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/tarifas/envios/_tarifaEnvioFormItems") ?>
</div><!-- /.card-body -->
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("tarifaEnvioList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div><!-- /.card-footer -->
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/tarifas/envios/_tarifaEnvioFormItems") ?>
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("tarifaEnvioList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div>
</form>
</div><!-- //.card -->
</div><!-- //.card -->
</div><!--//.col -->
<?php if(str_contains($formAction, 'edit')): ?>
@ -45,6 +45,7 @@
<table id="tableOfZonas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('TarifasEnviosZonas.nombre') ?></th>
<th><?= lang('TarifasEnviosZonas.cpInicial') ?></th>
<th><?= lang('TarifasEnviosZonas.cpFinal') ?></th>
<th><?= lang('TarifasEnviosZonas.importeFijo') ?></th>
@ -71,7 +72,7 @@
<div id="accordionTip2" class="accordion-collapse collapse show" data-bs-parent="#accordionPrecios">
<div class="accordion-body">
<div id="newButton" class="mb-4 float-end"></div>
<table id="tableOfPrecios" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
@ -81,6 +82,7 @@
<th><?= lang('TarifasEnviosPrecios.pesoMax') ?></th>
<th><?= lang('TarifasEnviosPrecios.precio') ?></th>
<th><?= lang('TarifasEnviosPrecios.precioAdicional') ?></th>
<th><?= lang('TarifasEnviosPrecios.margen') ?></th>
<th style="min-width:100px"></th>
</tr>
</thead>
@ -138,9 +140,7 @@
}
});
var selected_zona_id = -1;
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
@ -174,6 +174,8 @@
table : "#tableOfZonas",
idSrc: 'id',
fields: [ {
name: "nombre"
}, {
name: "cp_inicial"
}, {
name: "cp_final"
@ -224,14 +226,20 @@
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
order: [[ 0, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
paging: true,
select: true,
paging: true,
info: false,
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>',
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifasEnvioZonas') ?>',
data: {
@ -242,6 +250,7 @@
async: true,
}),
columns: [
{ 'data': 'nombre' },
{ 'data': 'cp_inicial' },
{ 'data': 'cp_final' },
{ 'data': 'importe_fijo' },
@ -256,7 +265,7 @@
searchable: false,
targets: [lastColNr]
},
{"orderData": [ 0, 1 ], "targets": 0 },
{"orderData": [ 0], "targets": 0 },
],
language: {
@ -309,22 +318,6 @@
});
}
theTable.on( 'select', function ( e, dt, type, indexes ) {
if ( type === 'row' ) {
selected_zona_id = parseInt(theTable.rows( indexes ).data().pluck( 'id' )[0]);
theTable2.clearPipeline();
theTable2.draw();
}
} );
theTable.on( 'deselect', function ( e, dt, type, indexes ) {
if ( theTable.rows( '.selected' ).count() == 0 ) {
selected_zona_id = -1;
theTable2.clearPipeline();
theTable2.draw();
}
} );
<?= $this->endSection() ?>
@ -357,9 +350,12 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
}, {
name: "precio"
}, {
name: "precio_adicional"
name: "precio_adicional",
def: 0
}, {
"name": "zona_envio_id",
name: "margen"
}, {
"name": "tarifa_envio_id",
"type": "hidden"
}, {
"name": "deleted_at",
@ -377,11 +373,11 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
editor2.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['zona_envio_id'] = selected_zona_id;
d.data[0]['tarifa_envio_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['zona_envio_id'] = selected_zona_id;
d.data[v]['tarifa_envio_id'] = id;
}
}
});
@ -390,7 +386,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
editor2.dependent('proveedor_id', function (val, data, callback, e ) {
var supplier = suppliersList.find(o => o.value === val);
values = [{label:'<?= lang('TarifasEnviosPrecios.aDomicilio') ?>', value: "a domicilio"}];
values = [];
if(supplier.options != null)
{
@ -424,17 +420,18 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25, 50, 100],
order: [[ 0, "asc" ], [ 1, "asc" ]],
order: [ 0, "asc" ],
pageLength: 25,
lengthChange: true,
searching: false,
searching: true,
paging: true,
info: false,
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>',
dom: 'Brtip',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifasEnvioPrecios') ?>',
data: function ( d ) {
d.zona_envio_id = selected_zona_id;
d.tarifa_envio_id = id;
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
@ -448,9 +445,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
},
},
{ 'data': 'tipo_envio', "render": function ( data, type, row, meta ) {
if(data=='a domicilio')
return '<?= lang('TarifasEnviosPrecios.aDomicilio') ?>';
else if (data=='cajas')
if (data=='cajas')
return '<?= lang('TarifasEnviosPrecios.cajas') ?>';
else if (data=='palets')
return '<?= lang('TarifasEnviosPrecios.palets') ?>';
@ -460,6 +455,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
{ 'data': 'peso_max' },
{ 'data': 'precio' },
{ 'data': 'precio_adicional' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
@ -475,35 +471,43 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
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: editor2,
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_zona_id == -1){
popErrorAlert("<?= lang('TarifasEnviosPrecios.validation.error_seleccion_zonas') ?>");
}
else{
formOptions= {
buttons: [ 'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}],
initComplete: function () {
new $.fn.dataTable.Buttons(theTable2, {
name: 'btn_new',
buttons: [{
className: 'btn btn-primary float-end',
extend: "createInline",
editor: editor2,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
};
editor2.inlineCreate(config.position, formOptions);
}
},
} ],
}
}]
});
var $newbtncontainer = $("<div style='float: right;'></div>");
$("#tableOfPrecios_wrapper").prepend($newbtncontainer);
theTable2.buttons('btn_new', null)
.container()
.appendTo($newbtncontainer);
}
} );
// Activate an inline edit on click of a table cell
$('#tableOfPrecios').on( 'click', 'tbody span.edit', function (e) {
editor2.inline(

View File

@ -12,4 +12,5 @@ table.dataTable > tbody > tr.selected > * {
table.dataTable.table-hover > tbody > tr.selected:hover > * {
box-shadow: inset 0 0 0 9999px rgba(13, 110, 253, 0.65);
}
}