mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
faltan las fechas
This commit is contained in:
@ -628,6 +628,9 @@ $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function (
|
||||
$routes->post('add', 'Pedido::add', ['as' => 'crearPedido']);
|
||||
$routes->get('edit/(:any)', 'Pedido::edit/$1', ['as' => 'editarPedido']);
|
||||
$routes->post('getlineas', 'Pedido::getLineas', ['as' => 'tablaLineasPedido']);
|
||||
$routes->post('cambiarestado', 'Pedido::cambiarEstado', ['as' => 'cambiarEstadoPedido']);
|
||||
$routes->post('update/(:any)', 'Pedido::update/$1', ['as' => 'actualizarPedido']);
|
||||
|
||||
});
|
||||
$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
|
||||
|
||||
@ -635,6 +638,12 @@ $routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'control
|
||||
$routes->group('albaranes', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
|
||||
$routes->post('add', 'Albaran::add', ['as' => 'crearAlbaranesPedido']);
|
||||
$routes->post('update/(:any)', 'Albaran::update/$1', ['as' => 'actualizarAlbaran']);
|
||||
$routes->post('updateLinea/(:any)', 'Albaran::updateLinea/$1', ['as' => 'actualizarLineaAlbaran']);
|
||||
$routes->post('deletelinea', 'Albaran::borrarlinea', ['as' => 'borrarAlbaranLinea']);
|
||||
$routes->get('delete/(:any)', 'Albaran::delete/$1', ['as' => 'borrarAlbaran']);
|
||||
$routes->get('getalbaranes/(:any)', 'Albaran::getAlbaranes/$1', ['as' => 'getAlbaranes']);
|
||||
$routes->get('nuevalinea/(:any)', 'Albaran::addLinea/$1', ['as' => 'addAlbaranLinea']);
|
||||
$routes->post('nuevalinea/(:any)', 'Albaran::addLinea/$1', ['as' => 'addIVA']);
|
||||
});
|
||||
$routes->resource('albaranes', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Albaran', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Pedidos;
|
||||
use App\Entities\Pedidos\AlbaranEntity;
|
||||
use App\Models\Pedidos\AlbaranModel;
|
||||
|
||||
|
||||
@ -26,9 +27,103 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
|
||||
public function delete($id = null)
|
||||
{
|
||||
return [];
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$model_linea->where('albaran_id', $id)->delete();
|
||||
|
||||
$this->model->where('id', $id)->delete();
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function addLinea($albaran_id){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
// si es un post, es el iva
|
||||
if($this->request->getPost()){
|
||||
$reqData = $this->request->getPost();
|
||||
$albaran_id = $reqData['albaran_id'] ?? 0;
|
||||
|
||||
$albaran = $this->model->find($albaran_id);
|
||||
if($albaran == false){
|
||||
$data = [
|
||||
'error' => 'Albaran no encontrado',
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
$presupuesto_model = model('App\Models\Presupuestos\PresupuestoModel');
|
||||
$presupuesto = $presupuesto_model->find($albaran->presupuesto_id);
|
||||
if($presupuesto == false){
|
||||
$data = [
|
||||
'error' => 'Presupuesto no encontrado',
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
$iva_reducido = $presupuesto->iva_reducido;
|
||||
$lineas = $model_linea->where('albaran_id', $albaran_id)->findAll();
|
||||
$total = 0;
|
||||
foreach($lineas as $linea){
|
||||
$total += $linea->total;
|
||||
}
|
||||
$iva = $iva_reducido? $total * 4.0 / 100: $total * 21.0 / 100;
|
||||
$data_linea= [
|
||||
'albaran_id' => $albaran_id,
|
||||
'titulo' => $iva_reducido?lang('Pedidos.iva4'):lang('Pedidos.iva21'),
|
||||
'cantidad' => 1,
|
||||
'precio_unidad' => round($iva,2),
|
||||
'total' => round($iva,2),
|
||||
'user_created_id' => auth()->user()->id,
|
||||
'user_updated_id' => auth()->user()->id
|
||||
];
|
||||
$id_linea = $model_linea->insert($data_linea);
|
||||
$linea = $model_linea->find($id_linea);
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'data' => $linea,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
$linea = [
|
||||
'albaran_id' => $albaran_id,
|
||||
'user_created_id' => auth()->user()->id,
|
||||
'user_updated_id' => auth()->user()->id
|
||||
];
|
||||
$id_linea = $model_linea->insert($linea);
|
||||
$data = $model_linea->find($id_linea);
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
'data' => $data,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
@ -64,14 +159,22 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
return $this->redirect2listView();
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$albaranEntity = $this->model->find($id);
|
||||
|
||||
if ($albaranEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
@ -128,5 +231,158 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateLinea($id = null){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$albaranEntity = $model_linea->find($id);
|
||||
|
||||
if ($albaranEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $model_linea->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
|
||||
$this->session->setFlashdata('formErrors', $model_linea->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$albaranEntity->fill($sanitizedData);
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $albaranEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function borrarLinea(){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$id = $reqData['id'] ?? 0;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$albaranLineaEntity = $model_linea->find($id);
|
||||
|
||||
if ($albaranLineaEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
$successfulResult = $model_linea->skipValidation(true)->update($id, ['deleted_at' => date('Y-m-d H:i:s')]);
|
||||
|
||||
if ($successfulResult) :
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
else:
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
endif;
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAlbaranes($pedido_id = null){
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$returnData = [];
|
||||
$albaranes = $this->model->asArray()->where('pedido_id', $pedido_id)->findAll();
|
||||
|
||||
foreach($albaranes as $albaran){
|
||||
$albaran['fecha_albaran'] = $albaran['updated_at'];
|
||||
array_push($returnData,
|
||||
[
|
||||
'albaran' => $albaran,
|
||||
'lineas' => $model_linea->asArray()->where('albaran_id', $albaran['id'])->findAll()]
|
||||
);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'data' => $returnData,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +80,99 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
|
||||
}
|
||||
|
||||
public function cambiarEstado(){
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$id = $this->request->getPost('id');
|
||||
$estado = $this->request->getPost('estado');
|
||||
|
||||
$this->model->where('id', $id)->set(['estado' => $estado])->update();
|
||||
return $this->respond(['status' => 'success', 'message' => lang('Basic.global.success')]);
|
||||
}else{
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function update($id = null){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($id == null) :
|
||||
$data = [
|
||||
'error' => 2,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
$id = filter_var($id, FILTER_SANITIZE_URL);
|
||||
$pedidoEntity = $this->model->find($id);
|
||||
|
||||
if ($pedidoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.pedido')), $id]);
|
||||
$data = [
|
||||
'error' => $message,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
endif;
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$pedidoEntity->fill($sanitizedData);
|
||||
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $pedidoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$data = [
|
||||
'error' => 0,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$data = [
|
||||
'error' => 1,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id=null){
|
||||
|
||||
if ($id == null) :
|
||||
|
||||
@ -16,6 +16,11 @@ class AlbaranLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
'ejemplares_por_caja' => null,
|
||||
'precio_unidad' => null,
|
||||
'total' => null,
|
||||
'user_created_id' => null,
|
||||
'user_updated_id' => null,
|
||||
'created_at' => null,
|
||||
'updated_at' => null,
|
||||
'deleted_at' => null,
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@ -29,5 +34,7 @@ class AlbaranLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
'ejemplares_por_caja' => '?integer',
|
||||
'precio_unidad' => 'float',
|
||||
'total' => 'float',
|
||||
'user_created_id' => 'integer',
|
||||
'user_updated_id' => 'integer',
|
||||
];
|
||||
}
|
||||
@ -45,6 +45,9 @@ return [
|
||||
'pedidos' => 'Orders',
|
||||
'pedidosList' => 'Orders List',
|
||||
|
||||
'cancelar' => 'Cancel',
|
||||
'finalizar' => 'Finish',
|
||||
|
||||
'unaCara' => '1 side',
|
||||
'dosCaras' => '2 sides',
|
||||
|
||||
@ -68,6 +71,8 @@ return [
|
||||
'nuevaLinea' => 'New line',
|
||||
'addIva' => "Add VAT",
|
||||
'mostrarPrecios' => 'Show prices',
|
||||
'iva4' => "4,00 % VAT",
|
||||
'iva21' => "21,00 % VAT",
|
||||
|
||||
'facturas' => 'Invoices',
|
||||
|
||||
|
||||
@ -44,6 +44,9 @@ return [
|
||||
'pedidos' => 'Pedidos',
|
||||
'pedidosList' => 'Lista de Pedidos',
|
||||
|
||||
'cancelar' => 'Cancelar',
|
||||
'finalizar' => 'Finalizar',
|
||||
|
||||
'unaCara' => '1 cara',
|
||||
'dosCaras' => '2 caras',
|
||||
|
||||
@ -67,6 +70,9 @@ return [
|
||||
'nuevaLinea' => 'Nueva línea',
|
||||
'addIva' => "Añadir IVA",
|
||||
'mostrarPrecios' => 'Mostrar precios',
|
||||
'iva4' => "4,00 % IVA",
|
||||
'iva21' => "21,00 % IVA",
|
||||
|
||||
|
||||
'facturas' => 'Facturas',
|
||||
|
||||
|
||||
@ -25,6 +25,17 @@ class AlbaranLineaModel extends \App\Models\BaseModel
|
||||
'ejemplares_por_caja',
|
||||
'precio_unidad',
|
||||
'total',
|
||||
'user_created_id',
|
||||
'user_updated_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
}
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models\Pedidos;
|
||||
|
||||
|
||||
|
||||
class AlbaranModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "albaranes";
|
||||
@ -33,9 +35,11 @@ class AlbaranModel extends \App\Models\BaseModel
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public function generarAlbaranes($pedido_id, $presupuestos_id, $user_id){
|
||||
|
||||
@ -64,7 +68,9 @@ class AlbaranModel extends \App\Models\BaseModel
|
||||
'cajas' => 1,
|
||||
'ejemplares_por_caja' => $envio->cantidad,
|
||||
'precio_unidad' => $precio_unidad,
|
||||
'total' => $precio_unidad * $envio->cantidad
|
||||
'total' => $precio_unidad * $envio->cantidad,
|
||||
'user_created_id' => $user_id,
|
||||
'user_updated_id' => $user_id,
|
||||
];
|
||||
|
||||
|
||||
@ -98,7 +104,7 @@ class AlbaranModel extends \App\Models\BaseModel
|
||||
$id_albaran_linea =$model_albaran_linea->insert($albaran_linea);
|
||||
$albaran_linea['id'] = $id_albaran_linea;
|
||||
|
||||
array_push($return_data, ["albaran"=>$albaran, "albaran_linea" =>$albaran_linea]);
|
||||
array_push($return_data, ["albaran"=>$albaran, "lineas" =>[$albaran_linea]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ const deleteLineaBtns = function(data) {
|
||||
return `
|
||||
<td class="text-right py-0 align-middle">
|
||||
<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-trash ti-sm btn-delete-linea mx-2" data-id="${data.id}"></i></a>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
@ -68,8 +68,9 @@ function generarAlbaran(item){
|
||||
|
||||
// Crear los elementos necesarios
|
||||
const accordion = $('<div>', {
|
||||
class: 'accordion accordion-bordered mt-3',
|
||||
id: 'albaran' + item.albaran_linea.id
|
||||
class: 'accordion accordion-bordered mt-3 accordion-albaran',
|
||||
id: 'accordioAlbaran' + item.albaran.id,
|
||||
albaran: item.albaran.id
|
||||
});
|
||||
|
||||
const card = $('<div>', {
|
||||
@ -78,16 +79,17 @@ function generarAlbaran(item){
|
||||
|
||||
const header = $('<h2>', {
|
||||
class: 'accordion-header',
|
||||
id: 'headingAlbaran' + item.albaran_linea.id
|
||||
id: 'headingAlbaran' + item.albaran.id
|
||||
});
|
||||
|
||||
const button = $('<button>', {
|
||||
type: 'button',
|
||||
class: 'accordion-button',
|
||||
class: 'accordion-button collapsed',
|
||||
'data-bs-toggle': 'collapse',
|
||||
'data-bs-target': '#accordionAlbaranesTip' + item.albaran_linea.id,
|
||||
'data-bs-target': '#accordionAlbaranTip' + item.albaran.id,
|
||||
'aria-expanded': 'false',
|
||||
'aria-controls': 'accordionAlbaranesTip' + item.albaran_linea.id,
|
||||
'aria-controls': 'accordionAlbaranTip' + item.albaran.id,
|
||||
'albaran': item.albaran.id,
|
||||
}).css({
|
||||
'background-color': '#F0F8FF'
|
||||
});
|
||||
@ -95,9 +97,9 @@ function generarAlbaran(item){
|
||||
const h3 = $('<h5>').html(item.albaran.numero_albaran);
|
||||
|
||||
const collapseDiv = $('<div>', {
|
||||
id: 'accordionAlbaranTip' + item.albaran_linea.id,
|
||||
class: 'accordion-collapse collapse show',
|
||||
'data-bs-parent': '#accordioAlbaran' + item.albaran_linea.id
|
||||
id: 'accordionAlbaranTip' + item.albaran.id,
|
||||
class: 'accordion-collapse collapse',
|
||||
'data-bs-parent': '#accordioAlbaran' + item.albaran.id
|
||||
});
|
||||
|
||||
const body = $('<div>', {
|
||||
@ -147,7 +149,7 @@ function generarAlbaran(item){
|
||||
<label><?= lang('Pedidos.att') ?>:</label>
|
||||
</div>
|
||||
<div class="col-11">
|
||||
<input id="att_${item.albaran.id}" class="cambios-albaran form-control" albaran_id=${item.albaran.id} value=${item.albaran.att_albaran} class="form-control"></input>
|
||||
<input id="att_${item.albaran.id}" class="cambios-albaran form-control" albaran_id=${item.albaran.id} value="${item.albaran.att_albaran}" class="form-control"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 d-flex justify-content-between mb-3">
|
||||
@ -155,7 +157,7 @@ function generarAlbaran(item){
|
||||
<label><?= lang('Pedidos.direccion') ?>:</label>
|
||||
</div>
|
||||
<div class="col-11">
|
||||
<input id="direccion_${item.albaran.id}" albaran_id=${item.albaran.id} value=${item.albaran.direccion_albaran} class="cambios-albaran form-control"></input>
|
||||
<input id="direccion_${item.albaran.id}" albaran_id=${item.albaran.id} value="${item.albaran.direccion_albaran}" class="cambios-albaran form-control"></input>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@ -182,7 +184,7 @@ function generarAlbaran(item){
|
||||
$('<tbody>'),
|
||||
$('<tfoot>').append(
|
||||
$('<tr>').append(
|
||||
$('<th>', { colspan: '5', style: 'text-align:right' }).text('')
|
||||
$('<th>', { colspan: '9', style: 'text-align:right' }).text('')
|
||||
)
|
||||
),
|
||||
);
|
||||
@ -200,20 +202,20 @@ function generarAlbaran(item){
|
||||
</div>
|
||||
</div>
|
||||
<div id="bonotes_albaran_${item.albaran.id}" class="col-10 d-flex flex-row-reverse gap-2">
|
||||
<div id="borrar_albaran_${item.albaran.id}" class="btn mt-3 button-albaran btn-label-danger waves-effect waves-light ml-2">
|
||||
<div id="borrar_albaran_${item.albaran.id}" class="borrar-albaran btn mt-3 button-albaran btn-label-danger waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.borrarAlbaran') ?></span>
|
||||
<i class="ti ti-trash ti-xs"></i>
|
||||
</div>
|
||||
|
||||
<div id="borrar_albaran_${item.albaran.id}" class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<div id="imprimir_albaran_${item.albaran.id}" class="imprimir-albaran btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.imprimirAlbaran') ?></span>
|
||||
<i class="ti ti-printer ti-xs"></i>
|
||||
</div>
|
||||
<div id="nueva_linea_albaran_${item.albaran.id}" class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<div id="nueva_linea_albaran_${item.albaran.id}" class="nueva-linea-albaran btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.nuevaLinea') ?></span>
|
||||
<i class="ti ti-plus ti-xs"></i>
|
||||
</div>
|
||||
<div id="add_iva_albaran_${item.albaran.id}" class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<div id="add_iva_albaran_${item.albaran.id}" class="add-iva-albaran btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.addIva') ?></span>
|
||||
<i class="ti ti-plus ti-xs"></i>
|
||||
</div>
|
||||
@ -260,12 +262,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'unidades_' + item.albaran_linea.id,
|
||||
name: 'unidades_' + item.albaran_linea.id,
|
||||
id: 'cantidad_' + row.id,
|
||||
name: 'cantidad_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller',
|
||||
@ -279,12 +282,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'titulo_' + item.albaran_linea.id,
|
||||
name: 'titulo_' + item.albaran_linea.id,
|
||||
id: 'titulo_' + row.id,
|
||||
name: 'titulo_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller',
|
||||
@ -298,12 +302,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'isbn_' + item.albaran_linea.id,
|
||||
name: 'isbn_' + item.albaran_linea.id,
|
||||
id: 'isbn_' + row.id,
|
||||
name: 'isbn_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller'
|
||||
@ -316,12 +321,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'ref_cliente_' + item.albaran_linea.id,
|
||||
name: 'ref_cliente_' + item.albaran_linea.id,
|
||||
id: 'ref_cliente_' + row.id,
|
||||
name: 'ref_cliente_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller'
|
||||
@ -334,12 +340,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'cajas_' + item.albaran_linea.id,
|
||||
name: 'cajas_' + item.albaran_linea.id,
|
||||
id: 'cajas_' + row.id,
|
||||
name: 'cajas_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller',
|
||||
@ -353,12 +360,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'ejemplares_por_caja_' + item.albaran_linea.id,
|
||||
name: 'ejemplares_por_caja_' + item.albaran_linea.id,
|
||||
id: 'ejemplares_por_caja_' + row.id,
|
||||
name: 'ejemplares_por_caja_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller',
|
||||
@ -373,12 +381,13 @@ function generarAlbaran(item){
|
||||
|
||||
value = parseFloat(data).toFixed(4);
|
||||
var input = $('<input>', {
|
||||
id: 'precio_unidad_' + item.albaran_linea.id,
|
||||
name: 'precio_unidad_' + item.albaran_linea.id,
|
||||
id: 'precio_unidad_' + row.id,
|
||||
name: 'precio_unidad_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: value
|
||||
value: value,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller',
|
||||
@ -392,12 +401,13 @@ function generarAlbaran(item){
|
||||
render: function ( data, type, row, meta ) {
|
||||
|
||||
var input = $('<input>', {
|
||||
id: 'total_' + item.albaran_linea.id,
|
||||
name: 'total_' + item.albaran_linea.id,
|
||||
id: 'total_' + row.id,
|
||||
name: 'total_' + row.id,
|
||||
class: 'lp-cell lp-input albaran_linea',
|
||||
albaran: item.albaran.numero_albaran,
|
||||
type: 'text',
|
||||
value: data
|
||||
value: data,
|
||||
linea: row.id
|
||||
}).css({
|
||||
'text-align': 'center',
|
||||
'font-size': 'smaller',
|
||||
@ -423,16 +433,58 @@ function generarAlbaran(item){
|
||||
this.api().column(numColumns - 2).visible(true);
|
||||
}
|
||||
|
||||
},
|
||||
footerCallback: function (row, data, start, end, display) {
|
||||
|
||||
/*
|
||||
let api = this.api();
|
||||
var numColumns = api.columns().count();
|
||||
|
||||
if(item.albaran.mostrar_precios == 1){
|
||||
|
||||
// Remove the formatting to get integer data for summation
|
||||
let intVal = function (i) {
|
||||
return typeof i === 'string'
|
||||
? i.replace(/[\$,]/g, '') * 1
|
||||
: typeof i === 'number'
|
||||
? i
|
||||
: 0;
|
||||
};
|
||||
|
||||
// Total over all pages
|
||||
total = api
|
||||
.column(9)
|
||||
.data()
|
||||
.reduce((a, b) => intVal(a) + intVal(b), 0);
|
||||
|
||||
// Update footer
|
||||
api.column(numColumns-1).footer().innerHTML =
|
||||
'Total: ' + total.toFixed(2);
|
||||
}
|
||||
else{
|
||||
api.column(numColumns-1).footer().innerHTML = '';
|
||||
}
|
||||
*/
|
||||
},
|
||||
});
|
||||
|
||||
// Añadir la nueva fila a la tabla
|
||||
datatableAlbaran.row.add(item.albaran_linea).draw();
|
||||
|
||||
|
||||
if(Array.isArray(item.lineas)) {
|
||||
item.lineas.forEach(function(linea) {
|
||||
datatableAlbaran.row.add(linea).draw();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('click', '.accordion-button', function(){
|
||||
|
||||
var albaran_id = $(this).attr('albaran');
|
||||
var table = $('#tablaAlbaran' + albaran_id).DataTable();
|
||||
table.columns.adjust();
|
||||
});
|
||||
|
||||
$(document).on('change', '.cambios-albaran', function(){
|
||||
|
||||
var elementId = $(this).attr('id');
|
||||
|
||||
data = {
|
||||
@ -492,6 +544,166 @@ $(document).on('change', '.mostrar-precios', function(){
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete-linea', function(){
|
||||
var elementId = $(this).attr('id');
|
||||
var domTable = $(this).closest('table');
|
||||
var table = domTable.DataTable();
|
||||
const row = $(this).closest('tr');
|
||||
var url = '<?= route_to('borrarAlbaranLinea') ?>';
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $(this).attr('data-id'),
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
},
|
||||
success: function(response){
|
||||
|
||||
if('error' in response){
|
||||
if(response.error == 0){
|
||||
table.row($(row)).remove().draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('change', '.albaran_linea', function(){
|
||||
|
||||
var elementId = $(this).attr('id');
|
||||
|
||||
data = {
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
};
|
||||
data[elementId.split('_').slice(0, -1).join('_')] = $(this).val();
|
||||
|
||||
var linea_id = $(this).attr('linea');
|
||||
var url = '<?= route_to('actualizarLineaAlbaran', ':id') ?>';
|
||||
url = url.replace(':id', linea_id );
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response){
|
||||
|
||||
if('error' in response){
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).on('click', '#borrar_albaranes', function(){
|
||||
|
||||
// seleccionan todos los accordion dentro del body del accordion accordioAlbaranes
|
||||
$('.accordion-albaran').each(function() {
|
||||
// Aquí puedes trabajar con cada acordeón interno encontrado
|
||||
var albaran_id = $(this).attr('albaran');
|
||||
var url = '<?= route_to('borrarAlbaran', ':id') ?>';
|
||||
url = url.replace(':id', albaran_id );
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
success: function(response){
|
||||
if(response){
|
||||
if('error' in response){
|
||||
if(response.error == 0){
|
||||
$('#accordioAlbaran' + albaran_id).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.borrar-albaran', function(){
|
||||
|
||||
var albaran_id = $(this).attr('id').split('_').slice(-1)[0];
|
||||
var url = '<?= route_to('borrarAlbaran', ':id') ?>';
|
||||
url = url.replace(':id', albaran_id );
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
success: function(response){
|
||||
if(response){
|
||||
if('error' in response){
|
||||
if(response.error == 0){
|
||||
$('#accordioAlbaran' + albaran_id).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.nueva-linea-albaran', function(){
|
||||
|
||||
var albaran_id = $(this).attr('id').split('_').slice(-1)[0];
|
||||
var url = '<?= route_to('addAlbaranLinea', ':id') ?>';
|
||||
url = url.replace(':id', albaran_id );
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
success: function(response){
|
||||
if(response){
|
||||
if('error' in response){
|
||||
if(response.error == 0){
|
||||
var table = $('#tablaAlbaran' + albaran_id).DataTable();
|
||||
table.row.add(response.data).draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.add-iva-albaran', function(){
|
||||
|
||||
var albaran_id = $(this).attr('id').split('_').slice(-1)[0];
|
||||
var url = '<?= route_to('addIVA', ':id') ?>';
|
||||
url = url.replace(':id', albaran_id );
|
||||
data = {
|
||||
albaran_id: albaran_id,
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
};
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response){
|
||||
if(response){
|
||||
if('error' in response){
|
||||
if(response.error == 0){
|
||||
var table = $('#tablaAlbaran' + albaran_id).DataTable();
|
||||
table.row.add(response.data).draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.imprimir-albaran', function(){
|
||||
|
||||
var albaran_id = $(this).attr('id').split('_').slice(-1)[0];
|
||||
|
||||
//NACHO AQUI
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '<?= route_to('getAlbaranes', $pedidoEntity->id) ?>',
|
||||
type: 'GET',
|
||||
success: function(response){
|
||||
|
||||
if(response.data.length > 0){
|
||||
Object.values(response.data).forEach(function(item){
|
||||
generarAlbaran(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
<?=$this->endSection() ?>
|
||||
@ -104,7 +104,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-3 px-4">
|
||||
<div class="mb-1">
|
||||
<label for="fecha_entrega_real" class="form-label">
|
||||
<label for="fecha_entrega_real" class="fecha-pedido form-label">
|
||||
<?= lang('Pedidos.fecha_entrega_real') ?>
|
||||
</label>
|
||||
<input type="text" value="" id="fecha_entrega_real" name="fecha_entrega_real" tabindex="1" maxLength="11" class="form-control" value="<?= old('fecha_entrega_real', $pedidoEntity->fecha_entrega_real) ?>" >
|
||||
@ -115,7 +115,7 @@
|
||||
<label for="fecha_impresion" class="form-label">
|
||||
<?= lang('Pedidos.fecha_impresion') ?>
|
||||
</label>
|
||||
<input type="text" id="fecha_impresion" name="fecha_impresion" tabindex="1" maxLength="11" class="form-control" value="<?= old('fecha_impresion', $pedidoEntity->fecha_impresion) ?>" >
|
||||
<input type="text" id="fecha_impresion" name="fecha_impresion" tabindex="1" maxLength="11" class="fecha-pedido form-control" value="<?= old('fecha_impresion', $pedidoEntity->fecha_impresion) ?>" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-3 px-4">
|
||||
@ -123,7 +123,7 @@
|
||||
<label for="fecha_encuadernado" class="form-label">
|
||||
<?= lang('Pedidos.fecha_encuadernado') ?>
|
||||
</label>
|
||||
<input type="text" id="fecha_encuadernado" name="fecha_encuadernado" tabindex="1" maxLength="11" class="form-control" value="<?= old('fecha_encuadernado', $pedidoEntity->fecha_encuadernado) ?>" >
|
||||
<input type="text" id="fecha_encuadernado" name="fecha_encuadernado" tabindex="1" maxLength="11" class="fecha-pedido form-control" value="<?= old('fecha_encuadernado', $pedidoEntity->fecha_encuadernado) ?>" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-3 px-4">
|
||||
@ -131,7 +131,7 @@
|
||||
<label for="fecha_entrega_externo" class="form-label">
|
||||
<?= lang('Pedidos.fecha_entrega_externo') ?>
|
||||
</label>
|
||||
<input type="text" id="fecha_entrega_externo" name="fecha_entrega_externo" tabindex="1" maxLength="11" class="form-control" value="<?= old('fecha_entrega_externo', $pedidoEntity->fecha_entrega_externo) ?>" >
|
||||
<input type="text" id="fecha_entrega_externo" name="fecha_entrega_externo" tabindex="1" maxLength="11" class="fecha-pedido form-control" value="<?= old('fecha_entrega_externo', $pedidoEntity->fecha_entrega_externo) ?>" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -139,6 +139,20 @@
|
||||
</div> <!--//accordionFechasTip-->
|
||||
</div> <!--//card-->
|
||||
</div>
|
||||
|
||||
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
|
||||
<div class="col-12 d-flex flex-row-reverse mt-4 gap-2">
|
||||
<div id="pedido_finalizado" class="buton-estado btn mt-3 btn-success waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.finalizar') ?></span>
|
||||
<i class="ti ti-hourglass-empty ti-xs"></i>
|
||||
</div>
|
||||
<div id="pedido_cancelado" class="buton-estado btn mt-3 btn-danger waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.cancelar') ?></span>
|
||||
<i class="ti ti-circle-x ti-xs"></i>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -160,6 +174,9 @@ $("#fecha_entrega_real").flatpickr({
|
||||
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
},
|
||||
},
|
||||
onChange: function(selectedDates, instance) {
|
||||
updateDate('fecha_entrega_real', selectedDates);
|
||||
}
|
||||
});
|
||||
|
||||
$("#fecha_impresion").flatpickr({
|
||||
@ -175,6 +192,9 @@ $("#fecha_impresion").flatpickr({
|
||||
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
},
|
||||
},
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
updateDate('fecha_impresion', dateStr);
|
||||
}
|
||||
});
|
||||
|
||||
$("#fecha_encuadernado").flatpickr({
|
||||
@ -190,6 +210,9 @@ $("#fecha_encuadernado").flatpickr({
|
||||
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
},
|
||||
},
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
updateDate('fecha_encuadernado', dateStr);
|
||||
}
|
||||
});
|
||||
|
||||
$("#fecha_entrega_externo").flatpickr({
|
||||
@ -205,6 +228,62 @@ $("#fecha_entrega_externo").flatpickr({
|
||||
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
},
|
||||
},
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
updateDate('fecha_entrega_externo', dateStr);
|
||||
}
|
||||
});
|
||||
|
||||
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
|
||||
$('.buton-estado').on('click', function() {
|
||||
var id = <?=$pedidoEntity->id ?>;
|
||||
var estado = $(this).attr('id').split('_')[1];
|
||||
var url = '<?= route_to('cambiarEstadoPedido') ?>';
|
||||
var data = {
|
||||
id: id,
|
||||
estado: estado
|
||||
};
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
try{
|
||||
if (response.status=="success") {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
function updateDate(elementId, dateStr) {
|
||||
var id = <?=$pedidoEntity->id ?>;
|
||||
|
||||
data = {
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
};
|
||||
data[elementId] = dateStr;
|
||||
|
||||
var url = '<?= route_to('actualizarPedido', ':id') ?>';
|
||||
url = url.replace(':id', id );
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response){
|
||||
|
||||
if('error' in response){
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
Reference in New Issue
Block a user