diff --git a/ci4/app/Language/en/Pedidos.php b/ci4/app/Language/en/Pedidos.php
index d0d4f8bd..3a7518f3 100644
--- a/ci4/app/Language/en/Pedidos.php
+++ b/ci4/app/Language/en/Pedidos.php
@@ -58,8 +58,15 @@ return [
],
'albaranes' => 'Delivery Notes',
+ 'albaran' => 'Delivery Note',
'generarAlbaranes' => 'Generate delivery notes',
'borrarAlbaranes' => 'Delete delivery notes',
+ 'att' => "Att",
+ 'direccion' => 'Address',
+ 'borrarAlbaran' => 'Delete delivery note',
+ 'imprimirAlbaran' => 'Print',
+ 'nuevaLinea' => 'New line',
+ 'addIva' => "Add VAT",
'facturas' => 'Invoices',
diff --git a/ci4/app/Language/es/Pedidos.php b/ci4/app/Language/es/Pedidos.php
index f8f9d409..c37f9dc4 100644
--- a/ci4/app/Language/es/Pedidos.php
+++ b/ci4/app/Language/es/Pedidos.php
@@ -57,8 +57,15 @@ return [
],
'albaranes' => 'Albaranes',
+ 'albaran' => 'Albarán',
'generarAlbaranes' => 'Generar albaranes',
'borrarAlbaranes' => 'Borrar albaranes',
+ 'att' => "Att",
+ 'direccion' => 'Direccion',
+ 'borrarAlbaran' => 'Borrar albarán',
+ 'imprimirAlbaran' => 'Imprimir',
+ 'nuevaLinea' => 'Nueva línea',
+ 'addIva' => "Añadir IVA",
'facturas' => 'Facturas',
diff --git a/ci4/app/Models/Pedidos/AlbaranLineaModel.php b/ci4/app/Models/Pedidos/AlbaranLineaModel.php
index e7d7a757..a384fb22 100644
--- a/ci4/app/Models/Pedidos/AlbaranLineaModel.php
+++ b/ci4/app/Models/Pedidos/AlbaranLineaModel.php
@@ -26,9 +26,5 @@ class AlbaranLineaModel extends \App\Models\BaseModel
'precio_unidad',
'total',
];
-
- protected $useTimestamps = true;
- protected $createdField = 'created_at';
- protected $updatedField = 'updated_at';
}
\ No newline at end of file
diff --git a/ci4/app/Models/Pedidos/AlbaranModel.php b/ci4/app/Models/Pedidos/AlbaranModel.php
index 7fd30c73..87923a9b 100644
--- a/ci4/app/Models/Pedidos/AlbaranModel.php
+++ b/ci4/app/Models/Pedidos/AlbaranModel.php
@@ -45,6 +45,8 @@ class AlbaranModel extends \App\Models\BaseModel
$presupuestos = $model_presupuesto->find($presupuestos_id);
+ $return_data = [];
+
foreach ($presupuestos as $presupuesto) {
$envios = $model_presupuesto_direcciones->where('presupuesto_id', $presupuesto->id)->findAll();
@@ -54,7 +56,7 @@ class AlbaranModel extends \App\Models\BaseModel
$precio_unidad = $presupuesto->total_aceptado/$presupuesto->tirada;
$albaran_linea = [];
- $albaran_linea = array(
+ $albaran_linea = [
'titulo' => $presupuesto->titulo,
'isbn' => $presupuesto->isbn,
'ref_cliente' => $presupuesto->ref_cliente,
@@ -63,17 +65,17 @@ class AlbaranModel extends \App\Models\BaseModel
'ejemplares_por_caja' => $envio->cantidad,
'precio_unidad' => $precio_unidad,
'total' => $precio_unidad * $envio->cantidad
- );
+ ];
$serie = $model_series->find(11);
- $numero_albaran = str_replace($serie->next, 'number', $serie->formato);
- $numero_albaran = str_replace(date("Y"), 'year', $numero_albaran);
+ $numero_albaran = str_replace('{number}', $serie->next, $serie->formato);
+ $numero_albaran = str_replace( '{year}', date("Y"), $numero_albaran);
$serie->next = $serie->next + 1;
$model_series->save($serie);
- $albaran = array(
+ $albaran = [
'pedido_id' => $pedido_id,
'presupuesto_id' => $presupuesto->id,
'presupuesto_direccion_id' => $envio->id,
@@ -84,20 +86,22 @@ class AlbaranModel extends \App\Models\BaseModel
'total' => $albaran_linea['total'],
'direccion_albaran' => $envio->direccion,
'att_albaran' => $envio->att,
- 'created_at' => date("Y-m-d H:i:s"),
- 'updated_at' => date("Y-m-d H:i:s"),
'user_created_id' => $user_id,
- 'user_updated_id' => $user_id
- );
+ 'user_updated_id' => $user_id,
+ 'fecha_albaran' => date('d/m/Y'),
+ ];
$id_albaran = $this->insert($albaran);
$model_albaran_linea = model('App\Models\Pedidos\AlbaranLineaModel');
- $model_albaran_linea->insert($albaran_linea);
+ $albaran['id'] = $id_albaran;
+ $albaran_linea['albaran_id'] = $id_albaran;
+ $id_albaran_linea =$model_albaran_linea->insert($albaran_linea);
+ $albaran_linea['id'] = $id_albaran_linea;
- return $id_albaran;
+ array_push($return_data, ["albaran"=>$albaran, "albaran_linea" =>$albaran_linea]);
}
}
- return 0;
+ return $return_data;
}
}
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/_albaranesItems.php b/ci4/app/Views/themes/vuexy/form/pedidos/_albaranesItems.php
index 01fcd952..a8fba5ed 100644
--- a/ci4/app/Views/themes/vuexy/form/pedidos/_albaranesItems.php
+++ b/ci4/app/Views/themes/vuexy/form/pedidos/_albaranesItems.php
@@ -8,10 +8,10 @@
-
+
-
+
= lang('Pedidos.generarAlbaranes') ?>
@@ -45,10 +45,376 @@ $('#generar_albaranes').on('click', function(){
= csrf_token() ?? "token" ?>: = csrf_token() ?>v,
},
success: function(response){
- console.log(response);
+
+ if(response.data.length > 0){
+ Object.values(response.data).forEach(function(item){
+ generarAlbaran(item);
+ });
+ }
}
});
})
+const deleteLineaBtns = function(data) {
+ return `
+
+
+ | `;
+};
+
+function generarAlbaran(item){
+
+ // Crear los elementos necesarios
+ const accordion = $('
', {
+ class: 'accordion accordion-bordered mt-3',
+ id: 'albaran' + item.albaran_linea.id
+ });
+
+ const card = $('
', {
+ class: 'card accordion-item active'
+ });
+
+ const header = $('
', {
+ class: 'accordion-header',
+ id: 'headingAlbaran' + item.albaran_linea.id
+ });
+
+ const button = $('