mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadidos entidades y modelos. Hecha lista de todos
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user