mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'feat/importador_rama'
Main See merge request jjimenez/safekat!743
This commit is contained in:
@ -522,6 +522,9 @@ $routes->group('albaranes', ['namespace' => 'App\Controllers\Albaranes'], functi
|
|||||||
$routes->post('updateAlbaranLinea', 'Albaran::updateAlbaranLinea');
|
$routes->post('updateAlbaranLinea', 'Albaran::updateAlbaranLinea');
|
||||||
$routes->post('addIvaAlbaran', 'Albaran::addLineasIva');
|
$routes->post('addIvaAlbaran', 'Albaran::addLineasIva');
|
||||||
$routes->post('nuevaLineaAlbaran', 'Albaran::addBlankLineaAlbaran');
|
$routes->post('nuevaLineaAlbaran', 'Albaran::addBlankLineaAlbaran');
|
||||||
|
$routes->get('datatable', 'Albaran::datatable', ['as' => 'dataTableOfAlbaranes']);
|
||||||
|
$routes->get('getAlbaran', 'Albaran::getAlbaran');
|
||||||
|
$routes->get('edit/(:num)', 'Albaran::editAlbaran/$1', ['as' => 'editarAlbaran']);
|
||||||
});
|
});
|
||||||
$routes->resource('albaranes', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Albaran', 'except' => 'show,new,create,update']);
|
$routes->resource('albaranes', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Albaran', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
@ -820,6 +823,9 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
|||||||
$routes->get('selectForNewEnvio', 'LogisticaController::findForNewEnvio');
|
$routes->get('selectForNewEnvio', 'LogisticaController::findForNewEnvio');
|
||||||
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
||||||
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
|
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
|
||||||
|
|
||||||
|
$routes->get('listAlbaranes', 'LogisticaController::listAlbaranes', ['as' => 'albaranesList']);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -47,6 +47,18 @@ class Albaran extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function editAlbaran($albaran_id){
|
||||||
|
|
||||||
|
$albaran = $this->model->find($albaran_id);
|
||||||
|
if ($albaran == false) {
|
||||||
|
return redirect()->to(base_url('albaranesList'));
|
||||||
|
}
|
||||||
|
$this->viewData['boxTitle'] = lang('Albaran.editAlbaran') . ' ' . $albaran->numero_albaran;
|
||||||
|
$this->viewData['albaranId'] = $albaran_id;
|
||||||
|
|
||||||
|
return view('themes/vuexy/form/logistica/albaranes/viewAlbaranesEdit', $this->viewData);
|
||||||
|
}
|
||||||
|
|
||||||
public function addLinea($albaran_id)
|
public function addLinea($albaran_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -305,6 +317,23 @@ class Albaran extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAlbaran()
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$id = $this->request->getGet('id');
|
||||||
|
$albaran = $this->model->getAlbaranData($id);
|
||||||
|
$data = [
|
||||||
|
'success' => true,
|
||||||
|
'data' => $albaran,
|
||||||
|
];
|
||||||
|
return $this->respond($data);
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function generateAlbaran()
|
public function generateAlbaran()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -324,6 +353,32 @@ class Albaran extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datatable(){
|
||||||
|
|
||||||
|
$pedidosFilter = $this->request->getGet('pedidosFilter');
|
||||||
|
$q = $this->model->getDatatableQuery();
|
||||||
|
|
||||||
|
if($pedidosFilter != null && !empty($pedidosFilter)) {
|
||||||
|
$q->groupStart();
|
||||||
|
$q->like('t4.id', $pedidosFilter);
|
||||||
|
$q->groupEnd();
|
||||||
|
}
|
||||||
|
$result = DataTable::of($q)
|
||||||
|
->add(
|
||||||
|
"action",
|
||||||
|
callback: function ($q) {
|
||||||
|
return '
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="' . $q->id . '"></i></a>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result->toJson(returnAsObject: true);
|
||||||
|
}
|
||||||
|
|
||||||
public function datatablesLineasAlbaran()
|
public function datatablesLineasAlbaran()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,17 @@ class LogisticaController extends BaseController
|
|||||||
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
|
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function listAlbaranes(){
|
||||||
|
$viewData = [
|
||||||
|
'currentModule' => static::$controllerSlug,
|
||||||
|
'boxTitle' => lang('Albaran.albaranes'),
|
||||||
|
'usingServerSideDataTable' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||||
|
|
||||||
|
return view(static::$viewPath . '/albaranes/viewAlbaranesList', $viewData);
|
||||||
|
}
|
||||||
|
|
||||||
public function findForNewEnvio()
|
public function findForNewEnvio()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
|
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||||
|
use CodeIgniter\Database\Migration;
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
|
use CodeIgniter\I18n\Time;
|
||||||
|
|
||||||
|
class AddClickColumnOrdenTrabajoTarea extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
|
protected array $COLUMNS = [
|
||||||
|
"click_init" => [
|
||||||
|
"type" => "INT",
|
||||||
|
"unsigned" => true,
|
||||||
|
"default" => 0,
|
||||||
|
"comment" => "Click iniciales de una tarea de impresion"
|
||||||
|
],
|
||||||
|
"click_end" => [
|
||||||
|
"type" => "INT",
|
||||||
|
"unsigned" => true,
|
||||||
|
"default" => 0,
|
||||||
|
"comment" => "Click finales de una tarea de impresion"
|
||||||
|
],
|
||||||
|
];
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->forge->addColumn('orden_trabajo_tareas', $this->COLUMNS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->forge->dropColumn('orden_trabajo_tareas', array_keys($this->COLUMNS));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
'fechaCreacion' => 'Fecha de creación',
|
'fechaCreacion' => 'Fecha de creación',
|
||||||
"fechaAlbaran" => 'Fecha de albarán',
|
"fechaAlbaran" => 'Fecha de albarán',
|
||||||
'numEnvio' => 'Número de envío',
|
'numEnvio' => 'Número de envío',
|
||||||
'cliente' => 'Cliente',
|
'cliente' => 'Cliente',
|
||||||
'albaran' => 'Albarán',
|
'albaran' => 'Albarán',
|
||||||
|
'numAlbaran' => 'Número de albarán',
|
||||||
|
'numPedidos' => 'Número de Pedidos',
|
||||||
|
'unidadesTotal' => 'Unidades Totales',
|
||||||
|
'albaranes' => 'Albaranes',
|
||||||
'att' => 'Att',
|
'att' => 'Att',
|
||||||
'direccion' => 'Dirección',
|
'direccion' => 'Dirección',
|
||||||
'cajas' => 'Cajas',
|
'cajas' => 'Cajas',
|
||||||
|
'acciones' => 'Acciones',
|
||||||
|
|
||||||
'unidades' => 'Unidades',
|
'unidades' => 'Unidades',
|
||||||
'titulo' => 'Título',
|
'titulo' => 'Título',
|
||||||
@ -28,4 +34,6 @@ return [
|
|||||||
|
|
||||||
'iva4' => 'IVA 4%',
|
'iva4' => 'IVA 4%',
|
||||||
'iva21' => 'IVA 21%',
|
'iva21' => 'IVA 21%',
|
||||||
|
|
||||||
|
'editAlbaran' => 'Editar albarán',
|
||||||
];
|
];
|
||||||
@ -173,6 +173,37 @@ class AlbaranModel extends \App\Models\BaseModel
|
|||||||
return $albaran_data;
|
return $albaran_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getAlbaranData($albaran_id=null){
|
||||||
|
if (!$albaran_id) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$albaran_data = $this->db->table('albaranes t1')
|
||||||
|
->select("
|
||||||
|
t1.id,
|
||||||
|
t1.att_albaran AS att,
|
||||||
|
t1.direccion_albaran AS direccion,
|
||||||
|
t1.envio_id,
|
||||||
|
t1.numero_albaran AS numero_albaran,
|
||||||
|
DATE_FORMAT(t1.created_at, '%d/%m/%Y') AS fecha_creacion,
|
||||||
|
DATE_FORMAT(t1.fecha_albaran, '%d/%m/%Y') AS fecha_albaran,
|
||||||
|
t1.mostrar_precios AS mostrar_precios,
|
||||||
|
t2.nombre AS cliente,
|
||||||
|
t1.cajas AS cajas
|
||||||
|
")
|
||||||
|
->join('clientes t2', 't1.cliente_id = t2.id', 'left')
|
||||||
|
->where('t1.id', $albaran_id)
|
||||||
|
->where('t1.deleted_at IS NULL')
|
||||||
|
->get()
|
||||||
|
->getResultObject();
|
||||||
|
if (count($albaran_data) == 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $albaran_data[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get resource data for creating PDFs.
|
* Get resource data for creating PDFs.
|
||||||
*
|
*
|
||||||
@ -203,4 +234,25 @@ class AlbaranModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDatatableQuery()
|
||||||
|
{
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.id, t1.numero_albaran as numero_albaran, t1.envio_id as envio_id, GROUP_CONCAT(DISTINCT t4.id) AS pedidos,
|
||||||
|
t5.nombre as cliente, t1.att_albaran as att, t1.direccion_albaran as direccion, SUM(t2.cantidad) as unidades_total,
|
||||||
|
t1.cajas as cajas"
|
||||||
|
)
|
||||||
|
->join("albaranes_lineas t2", "t1.id = t2.albaran_id", "left")
|
||||||
|
->join("pedidos_linea t3", "t2.pedido_linea_id = t3.id", "left")
|
||||||
|
->join("pedidos t4", "t3.pedido_id = t4.id", "left")
|
||||||
|
->join("clientes t5", "t1.cliente_id = t5.id", "left");
|
||||||
|
|
||||||
|
$builder->where("t1.deleted_at IS NULL");
|
||||||
|
$builder->where("t2.deleted_at IS NULL");
|
||||||
|
$builder->groupBy("t1.id");
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||||
|
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||||
|
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||||
|
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||||
|
|
||||||
|
<?= $this->section('content'); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4><?= $boxTitle ?></h4>
|
||||||
|
</div>
|
||||||
|
<div id="albaranContainer" class="card-body">
|
||||||
|
|
||||||
|
<input type="hidden" id="id" value="<?= $albaranId ?>">
|
||||||
|
|
||||||
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?= $this->section('css') ?>
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
|
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||||
|
<script type="module" src="<?= site_url("assets/js/safekat/pages/albaranes/edit.js") ?>"></script>
|
||||||
|
<?= $this->endSection() ?>
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||||
|
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||||
|
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||||
|
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||||
|
|
||||||
|
<?= $this->section('content'); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4><?= $boxTitle ?></h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||||
|
|
||||||
|
<table id="tableOfAlbaranes" class="table table-striped table-hover w-100">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?= lang('Albaran.id') ?></th>
|
||||||
|
<th><?= lang('Albaran.numAlbaran') ?></th>
|
||||||
|
<th><?= lang('Albaran.numEnvio') ?></th>
|
||||||
|
<th><?= lang('Albaran.numPedidos') ?></th>
|
||||||
|
<th><?= lang('Albaran.cliente') ?></th>
|
||||||
|
<th><?= lang('Albaran.att') ?></th>
|
||||||
|
<th><?= lang('Albaran.direccion') ?></th>
|
||||||
|
<th><?= lang('Albaran.unidadesTotal') ?></th>
|
||||||
|
<th><?= lang('Albaran.cajas') ?></th>
|
||||||
|
<th><?= lang('Albaran.acciones') ?? 'Acciones' ?></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><input type="text" class="form-control albaran-filter" name="id"></th>
|
||||||
|
<th><input type="text" class="form-control albaran-filter" name="numero_albaran"></th>
|
||||||
|
<th><input type="text" class="form-control albaran-filter" name="envio_id"></th>
|
||||||
|
<th><input type="text" class="form-control albaran-filter-pedidos" name="pedidos"></th>
|
||||||
|
<th><input type="text" class="form-control albaran-filter" name="cliente"></th>
|
||||||
|
<th><input type="text" class="form-control albaran-filter" name="att"></th>
|
||||||
|
<th><input type="text" class="form-control albaran-filter" name="direccion"></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?= $this->section('css') ?>
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
|
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||||
|
<script type="module" src="<?= site_url("assets/js/safekat/pages/albaranes/list.js") ?>"></script>
|
||||||
|
<?= $this->endSection() ?>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<img src="<?= site_url("assets/img/logistica/impresionEtiquetas.jpg") ?>" alt="Etiquetas de títulos">
|
<img src="<?= site_url("assets/img/logistica/impresionEtiquetas.jpg") ?>" alt="Etiquetas de títulos">
|
||||||
<div><span><?= lang("Logistica.etiquetasTitulos"); ?></span></div>
|
<div><span><?= lang("Logistica.etiquetasTitulos"); ?></span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item" onclick="location.href='<?= route_to('albaranesList') ?>'">
|
||||||
<img src="<?= site_url("assets/img/logistica/albaranes.png") ?>" alt="Albaranes">
|
<img src="<?= site_url("assets/img/logistica/albaranes.png") ?>" alt="Albaranes">
|
||||||
<div><span><?= lang("Logistica.albaranes"); ?></span></div>
|
<div><span><?= lang("Logistica.albaranes"); ?></span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import DatePicker from "./datepicker.js";
|
import DatePicker from "./datepicker.js";
|
||||||
class AlbaranComponent {
|
class AlbaranComponent {
|
||||||
|
|
||||||
constructor(item) {
|
constructor(item, url_after_delete = '') {
|
||||||
|
|
||||||
|
this.url_after_delete = url_after_delete;
|
||||||
|
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.numero = item.numero_albaran;
|
this.numero = item.numero_albaran;
|
||||||
this.cliente = item.cliente;
|
this.cliente = item.cliente;
|
||||||
this.att = item.att;
|
this.att = item.att;
|
||||||
this.direccion = item.direccion;
|
this.direccion = item.direccion;
|
||||||
this.envio_id = item.envio_id;
|
this.envio_id = item.envio_id != null ? item.envio_id : '';
|
||||||
this.fecha = null;
|
this.fecha = null;
|
||||||
if(this.item.fecha_albaran != null){
|
if(this.item.fecha_albaran != null){
|
||||||
const [dia, mes, anio] = item.fecha_albaran.split('/');
|
const [dia, mes, anio] = item.fecha_albaran.split('/');
|
||||||
@ -461,6 +464,9 @@ class AlbaranComponent {
|
|||||||
if (response.success) {
|
if (response.success) {
|
||||||
// quitar del dom el albarán
|
// quitar del dom el albarán
|
||||||
$(`#accordioAlbaran${albaranId}`).remove();
|
$(`#accordioAlbaran${albaranId}`).remove();
|
||||||
|
if(this.url_after_delete != ''){
|
||||||
|
window.location.href = this.url_after_delete;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
|
|||||||
43
httpdocs/assets/js/safekat/pages/albaranes/edit.js
Normal file
43
httpdocs/assets/js/safekat/pages/albaranes/edit.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import Ajax from '../../components/ajax.js';
|
||||||
|
import AlbaranComponent from '../../components/albaranComponent.js';
|
||||||
|
|
||||||
|
$(() => {
|
||||||
|
|
||||||
|
const dropdown = document.querySelector(".dropdown-language");
|
||||||
|
const activeItem = dropdown.querySelector(".dropdown-menu .dropdown-item");
|
||||||
|
let locale = 'es';
|
||||||
|
if (activeItem) {
|
||||||
|
locale = activeItem.getAttribute("data-language");
|
||||||
|
}
|
||||||
|
|
||||||
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Albaran'] }, {},
|
||||||
|
function (translations) {
|
||||||
|
window.language = JSON.parse(translations);
|
||||||
|
new Ajax(
|
||||||
|
'/albaranes/getAlbaran',
|
||||||
|
{
|
||||||
|
id: $('#id').val()
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
function (data, headers, success, error, type) {
|
||||||
|
if (success) {
|
||||||
|
const albaran = new AlbaranComponent(data.data, '/logistica/listAlbaranes');
|
||||||
|
albaran.mount('#albaranContainer');
|
||||||
|
$('.accordion-button').trigger('click');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
popErrorAlert(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (data, headers, success, error, type) {
|
||||||
|
popErrorAlert(error);
|
||||||
|
}
|
||||||
|
).get();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log("Error getting translations:", error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
160
httpdocs/assets/js/safekat/pages/albaranes/list.js
Normal file
160
httpdocs/assets/js/safekat/pages/albaranes/list.js
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
import Ajax from "../../components/ajax.js";
|
||||||
|
|
||||||
|
$(() => {
|
||||||
|
|
||||||
|
let pedidosFilter = '';
|
||||||
|
|
||||||
|
const dropdown = document.querySelector(".dropdown-language");
|
||||||
|
const activeItem = dropdown.querySelector(".dropdown-menu .dropdown-item");
|
||||||
|
let locale = 'es';
|
||||||
|
if (activeItem) {
|
||||||
|
locale = activeItem.getAttribute("data-language");
|
||||||
|
}
|
||||||
|
|
||||||
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Albaran'] }, {},
|
||||||
|
function (translations) {
|
||||||
|
window.language = JSON.parse(translations);
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log("Error getting translations:", error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
|
||||||
|
|
||||||
|
$('#btnAddEnvio').on('click', () => {
|
||||||
|
const pedido_id = selectPedidos.getVal();
|
||||||
|
const direccionSeleccionada = selectDirecciones.getText();
|
||||||
|
$.post('/albaranes/datatable', {
|
||||||
|
pedido_id: pedido_id,
|
||||||
|
direccion: direccionSeleccionada
|
||||||
|
}, function (response) {
|
||||||
|
if (response.status) {
|
||||||
|
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
|
||||||
|
selectDirecciones.empty();
|
||||||
|
selectPedidos.empty();
|
||||||
|
$('.select-direcciones').addClass('d-none');
|
||||||
|
$('.add-envio').addClass('d-none');
|
||||||
|
} else {
|
||||||
|
popErrorAlert(response.message);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr, status, error) {
|
||||||
|
popErrorAlert(error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const tableAlbaranes = $('#tableOfAlbaranes').DataTable({
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
autoWidth: true,
|
||||||
|
responsive: true,
|
||||||
|
scrollX: true,
|
||||||
|
orderCellsTop: true,
|
||||||
|
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||||
|
pageLength: 50,
|
||||||
|
"dom": 'lBrtip',
|
||||||
|
"ajax": {
|
||||||
|
"url": "/albaranes/datatable",
|
||||||
|
"data": function (d) {
|
||||||
|
d.pedidosFilter = pedidosFilter;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"columns": [
|
||||||
|
{ "data": "id" },
|
||||||
|
{ "data": "numero_albaran" },
|
||||||
|
{ "data": "envio_id" },
|
||||||
|
{ "data": "pedidos" },
|
||||||
|
{ "data": "cliente" },
|
||||||
|
{ "data": "att" },
|
||||||
|
{ "data": "direccion" },
|
||||||
|
{ "data": "unidades_total" },
|
||||||
|
{ "data": "cajas" },
|
||||||
|
{ "data": "action" }
|
||||||
|
|
||||||
|
],
|
||||||
|
"language": {
|
||||||
|
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||||
|
},
|
||||||
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
targets: [9]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"order": [[0, "desc"]],
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-delete', function (e) {
|
||||||
|
const data = {
|
||||||
|
albaranId: $(this).attr('data-id')
|
||||||
|
};
|
||||||
|
const url = '/albaranes/borrarAlbaran';
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: window.language.Albaran.borrarAlbaran,
|
||||||
|
text: window.language.Albaran.borrarAlbaranConfirm,
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
cancelButtonColor: '#d33',
|
||||||
|
confirmButtonText: window.language.Albaran.borrar,
|
||||||
|
cancelButtonText: window.language.Albaran.cancelar,
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
cancelButton: 'btn btn-outline-secondary'
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
}).then((result) => {
|
||||||
|
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: (response) => {
|
||||||
|
if (response.success) {
|
||||||
|
tableAlbaranes.draw();
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'No se ha podido borrar el albarán',
|
||||||
|
icon: 'error',
|
||||||
|
showCancelButton: false,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: 'Ok',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (xhr, status, error) => {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-edit', function (e) {
|
||||||
|
window.location.href = '/albaranes/edit/' + $(this).attr('data-id');
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("keyup", ".albaran-filter", (event) => {
|
||||||
|
let columnName = $(event.currentTarget).attr("name");
|
||||||
|
let columnIndex = $('#tableOfAlbaranes').DataTable().columns().eq(0).filter(function (index) {
|
||||||
|
return $('#tableOfAlbaranes').DataTable().column(index).dataSrc() === columnName;
|
||||||
|
})[0];
|
||||||
|
$('#tableOfAlbaranes').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on("keyup", ".albaran-filter-pedidos", (event) => {
|
||||||
|
pedidosFilter = $(event.currentTarget).val();
|
||||||
|
$('#tableOfAlbaranes').DataTable().ajax.reload();
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user