diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php
index 34182efa..060fe82e 100755
--- a/ci4/app/Config/Routes.php
+++ b/ci4/app/Config/Routes.php
@@ -588,6 +588,18 @@ $routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controller
$routes->post('datatable_2', 'Presupuestotiradasalternativas::datatable_2', ['as' => 'getTiradaData']);
});
+$routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
+ $routes->get('list', 'Pedido::todos', ['as' => 'listaPresupuestos']);
+ $routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPresupuestosActivos']);
+ $routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']);
+ $routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']);
+ $routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']);
+ $routes->get('add', 'Pedido::add', ['as' => 'nuevoPedido']);
+ $routes->post('add', 'Pedido::add', ['as' => 'crearPedido']);
+ $routes->post('edit/(:num)', 'Pedido::edit/$1', ['as' => 'editarPedido']);
+});
+$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
+
$routes->group(
diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php
index af9c7953..7a32875e 100755
--- a/ci4/app/Controllers/Pedidos/Pedido.php
+++ b/ci4/app/Controllers/Pedidos/Pedido.php
@@ -2,18 +2,48 @@
namespace App\Controllers\Pedidos;
use App\Controllers\BaseController;
+use App\Entities\Pedidos\PedidoEntity;
+use App\Models\Collection;
+use App\Models\Pedidos\PedidoModel;
-class Pedido extends BaseController
+class Pedido extends \App\Controllers\BaseResourceController
{
- function __construct()
- {
-
+ protected $modelName = PedidoModel::class;
+ protected $format = 'json';
+
+ protected static $singularObjectNameCc = 'pedido';
+ protected static $singularObjectName = 'Pedido';
+ protected static $pluralObjectName = 'Pedidos';
+ protected static $controllerSlug = 'pedido';
+
+ protected static $viewPath = 'themes/vuexy/form/pedidos/';
+
+ protected $indexRoute = 'pedidoList';
+
+
+ public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
+ {
+ $this->viewData['pageTitle'] = lang('Tarifaextra.moduleTitle');
+ // Se indica que este controlador trabaja con soft_delete
+
+ // Breadcrumbs
+ $this->viewData['breadcrumb'] = [
+ ['title' => lang("App.menu_pedidos"), 'route' => "javascript:void(0);", 'active' => false],
+ ];
+
+ parent::initController($request, $response, $logger);
+
}
public function index()
{
- echo 'Pedidos';
+
+ $this->viewData['usingClientSideDataTable'] = true;
+
+ $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifaextra.tarifaextra')]);
+ parent::index();
+
}
public function activos()
@@ -31,25 +61,55 @@ class Pedido extends BaseController
echo 'Pedidos Cancelados';
}
- public function manuales()
+ public function todos()
{
- echo 'Pedidos Manuales';
+
+ $viewData = [
+ 'currentModule' => static::$controllerSlug,
+ 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
+ 'presupuestoEntity' => new PedidoEntity(),
+ 'usingServerSideDataTable' => true,
+ 'pageTitle' => lang('Pedidos.Pedidos'),
+ 'estadoPedidos' => 'todos',
+ ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
+ ];
+
+ return view(static::$viewPath . 'viewPedidosList', $viewData);
+
}
-// public function delete_files()
-// {
-//
-// }
-//
-// public function pedidos_maquetacion()
-// {
-//
-// }
-//
-// public function pedidos_prestashop()
-// {
-//
-// }
+ public function edit($id=null){
+ echo "Edit";
+ }
+
+ public function datatable(){
+
+ if ($this->request->isAJAX()) {
+
+ $reqData = $this->request->getPost();
+ if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
+ $errstr = 'No data available in response to this specific request.';
+ $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
+ return $response;
+ }
+ $start = $reqData['start'] ?? 0;
+ $length = $reqData['length'] ?? 5;
+ $search = $reqData['search']['value'];
+ $requestedOrder = $reqData['order']['0']['column'] ?? 0;
+ $order = PedidoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
+ $dir = $reqData['order']['0']['dir'] ?? 'asc';
+
+ $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
+
+ return $this->respond(Collection::datatable(
+ $resourceData,
+ $this->model->getResource()->countAllResults(),
+ $this->model->getResource($search)->countAllResults()
+ ));
+ } else {
+ return $this->failUnauthorized('Invalid request', 403);
+ }
+ }
}
\ No newline at end of file
diff --git a/ci4/app/Entities/Pedidos/PedidoEntity.php b/ci4/app/Entities/Pedidos/PedidoEntity.php
new file mode 100644
index 00000000..a847c03b
--- /dev/null
+++ b/ci4/app/Entities/Pedidos/PedidoEntity.php
@@ -0,0 +1,30 @@
+ null,
+ "total_precio" => null,
+ "total_tirada" => null,
+ "estado" => null,
+ "user_created_id" => null,
+ "user_updated_id" => null,
+ "user_validated_id" => null,
+ "fecha_entrega_real" => null,
+ "fecha_impresion" => null,
+ "fecha_encuadernado" => null,
+ "fecha_entrega_externo" => null,
+ "created_at" => null,
+ "updated_at" => null,
+ "validated_at" => null,
+ ];
+
+
+ protected $casts = [
+ "total_precio" => "float",
+ "total_tirada" => "float",
+ ];
+}
diff --git a/ci4/app/Entities/Pedidos/PedidoLineaEntity.php b/ci4/app/Entities/Pedidos/PedidoLineaEntity.php
new file mode 100644
index 00000000..38efab3f
--- /dev/null
+++ b/ci4/app/Entities/Pedidos/PedidoLineaEntity.php
@@ -0,0 +1,25 @@
+ null,
+ "pedido_id" => null,
+ "presupuesto_id" => null,
+ "ubicacion_id" => null,
+ "user_created_id" => null,
+ "user_updated_id" => null,
+ "created_at" => null,
+ "updated_at" => null,
+ ];
+
+
+ protected $casts = [
+ "pedido_id" => "int",
+ "presupuesto_id" => "int",
+ "ubicacion_id" => "int",
+ ];
+}
diff --git a/ci4/app/Language/en/App.php b/ci4/app/Language/en/App.php
index f3648c44..8a54743e 100755
--- a/ci4/app/Language/en/App.php
+++ b/ci4/app/Language/en/App.php
@@ -731,7 +731,7 @@ return [
"menu_pedidos_activos" => "Actives",
"menu_pedidos_finalizados" => "Finished",
"menu_pedidos_cancelados" => "Cancelled",
- "menu_pedidos_manuales" => "Manual",
+ "menu_pedidos_todos" => "All",
"menu_presupuestos" => "Budgets",
"menu_presupuesto" => "Books",
diff --git a/ci4/app/Language/en/Pedidos.php b/ci4/app/Language/en/Pedidos.php
new file mode 100644
index 00000000..c5f68504
--- /dev/null
+++ b/ci4/app/Language/en/Pedidos.php
@@ -0,0 +1,27 @@
+ 'Number',
+ 'fecha' => 'Date',
+ 'fecha_entrega' => 'Delivery Date',
+ 'cliente' => 'Client',
+ 'comercial' => 'Commercial',
+ 'titulo' => 'Title',
+ 'ubicacion' => 'Location',
+ 'inc_rei' => 'Inc/Rei', // This seems to be a specific term, left as is
+ 'num_paginas' => 'Number of Pages',
+ 'tiradas' => 'Print Runs',
+ 'total_presupuesto' => 'Total Budget',
+ 'estado' => 'Status',
+
+ 'moduleTitle' => 'Orders',
+ 'pedido' => 'Order',
+ 'pedidos' => 'Orders',
+ 'pedidosList' => 'Orders List',
+
+ 'validation' => [
+
+ ],
+];
\ No newline at end of file
diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php
index 653da4cf..f41817f4 100755
--- a/ci4/app/Language/es/App.php
+++ b/ci4/app/Language/es/App.php
@@ -737,7 +737,7 @@ return [
"menu_pedidos_activos" => "Activos",
"menu_pedidos_finalizados" => "Finalizados",
"menu_pedidos_cancelados" => "Cancelados",
- "menu_pedidos_manuales" => "Manuales",
+ "menu_pedidos_todos" => "Todos",
"menu_presupuestos" => "Presupuestos",
"menu_presupuesto" => "Libros",
diff --git a/ci4/app/Language/es/Pedidos.php b/ci4/app/Language/es/Pedidos.php
new file mode 100644
index 00000000..386fd67c
--- /dev/null
+++ b/ci4/app/Language/es/Pedidos.php
@@ -0,0 +1,28 @@
+ 'Número',
+ 'fecha' => 'Fecha',
+ 'fecha_entrega' => 'Fecha
Entrega',
+ 'cliente' => 'Cliente',
+ 'comercial' => 'Comercial',
+ 'titulo' => 'Título',
+ 'ubicacion' => 'Ubicación',
+ 'inc_rei' => 'Inc/Rei',
+ 'num_paginas' => 'Nº Páginas',
+ 'tiradas' => 'Tiradas',
+ 'total_presupuesto' => 'Total',
+ 'estado' => 'Estado',
+
+ 'moduleTitle' => 'Pedidos',
+ 'pedido' => 'Pedido',
+ 'pedidos' => 'Pedidos',
+ 'pedidosList' => 'Lista de Pedidos',
+
+ 'validation' => [
+
+ ],
+
+
+];
\ No newline at end of file
diff --git a/ci4/app/Models/Pedidos/PedidoLineaModel.php b/ci4/app/Models/Pedidos/PedidoLineaModel.php
new file mode 100644
index 00000000..f61c2fc0
--- /dev/null
+++ b/ci4/app/Models/Pedidos/PedidoLineaModel.php
@@ -0,0 +1,42 @@
+ "t1.id",
+ 1 => "t1.estado",
+ 2 => "t1.total_precio",
+ 3 => "t1.total_tirada",
+ ];
+
+ protected $allowedFields = [
+ "pedido_id",
+ "presupuesto_id",
+ "ubicacion_id",
+ "user_created_id",
+ "user_updated_id",
+ "created_at",
+ "updated_at",
+ ];
+ protected $returnType = "App\Entities\Pedidos\PedidoLineaEntity";
+
+ protected $useTimestamps = true;
+ protected $useSoftDeletes = false;
+
+ protected $createdField = "created_at";
+ protected $updatedField = "updated_at";
+
+ public static $labelField = "id";
+
+}
\ No newline at end of file
diff --git a/ci4/app/Models/Pedidos/PedidoModel.php b/ci4/app/Models/Pedidos/PedidoModel.php
new file mode 100644
index 00000000..fc43d402
--- /dev/null
+++ b/ci4/app/Models/Pedidos/PedidoModel.php
@@ -0,0 +1,82 @@
+ "t1.id",
+ 1 => "t1.updated_at",
+ 2 => "t1.fecha_entrega_real",
+ 3 => "t4.nombre",
+ 4 => "t5.first_name",
+ 5 => "t3.titulo",
+ 6 => "t6.ubicacion",
+ 7 => "t3.inc_rei",
+ 8 => "t3.paginas",
+ 9 => "t3.tirada",
+ 10 => "t3.total_aceptado",
+ 11 => "t1.estado"
+ ];
+
+ protected $allowedFields = [
+ "total_precio",
+ "total_tirada",
+ "estado",
+ "user_created_id",
+ "user_updated_id",
+ "user_validated_id",
+ "fecha_entrega_real",
+ "fecha_impresion",
+ "fecha_encuadernado",
+ "fecha_entrega_externo",
+ "created_at",
+ "updated_at",
+ "validated_at",
+ ];
+ protected $returnType = "App\Entities\Pedidos\PedidoEntity";
+
+ protected $useTimestamps = true;
+ protected $useSoftDeletes = false;
+
+ protected $createdField = "created_at";
+ protected $updatedField = "updated_at";
+
+ public static $labelField = "id";
+
+ public function getResource(string $search = "", $tarifa_envio_id = -1)
+ {
+ $builder = $this->db
+ ->table($this->table . " t1")
+ ->select(
+ "t1.id AS id, t1.updated_at AS fecha, t1.fecha_entrega_real AS fecha_entrega,
+ t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial,
+ t3.titulo AS titulo, t6.nombre AS ubicacion, t3.inc_rei AS inc_rei,
+ t3.paginas AS paginas, t3.tirada AS tirada, t3.total_aceptado AS total_presupuesto,
+ t1.estado AS estado"
+ );
+
+ $builder->join("pedidos_linea t2", "t1.id = t2.pedido_id", "left");
+ $builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
+ $builder->join("clientes t4", "t4.id = t3.cliente_id", "left");
+ $builder->join("users t5", "t5.id = t4.comercial_id", "left");
+ $builder->join("ubicaciones t6", "t6.id = t2.ubicacion_id", "left");
+
+ return empty($search)
+ ? $builder
+ : $builder
+ ->groupStart()
+ ->like("t1.id", $search)
+ ->orLike("t1.id", $search)
+ ->groupEnd();
+ }
+}
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php
new file mode 100644
index 00000000..6a45dc7e
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php
@@ -0,0 +1,147 @@
+=$this->include('themes/_commonPartialsBs/datatables') ?>
+= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
+=$this->extend('themes/vuexy/main/defaultlayout') ?>
+=$this->section('content'); ?>
+
| = lang('Pedidos.id') ?> | += lang('Pedidos.fecha') ?> | += lang('Pedidos.fecha_entrega') ?> | += lang('Pedidos.cliente') ?> | += lang('Pedidos.comercial') ?> | += lang('Pedidos.titulo') ?> | += lang('Pedidos.ubicacion') ?> | += lang('Pedidos.inc_rei') ?> | += lang('Pedidos.num_paginas') ?> | += lang('Pedidos.tiradas') ?> | += lang('Pedidos.total_presupuesto') ?> | += lang('Pedidos.estado') ?> | += lang('Basic.global.Action') ?> | +
|---|