mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'mod/presupuesto_admin' of https://git.imnavajas.es/jjimenez/safekat into mod/presupuesto_admin
This commit is contained in:
@ -356,7 +356,10 @@ class Maquinas extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function select(){
|
||||
$r = $this->model->getSelectQuery($this->request->getGet("q"));
|
||||
return $this->response->setJSON($r);
|
||||
}
|
||||
protected function getMaquinaListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
|
||||
|
||||
89
ci4/app/Controllers/Configuracion/ServicioCliente.php
Normal file
89
ci4/app/Controllers/Configuracion/ServicioCliente.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Configuracion\ServicioClienteModel;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class ServicioCliente extends BaseController
|
||||
{
|
||||
|
||||
protected ServicioClienteModel $servicioClienteModel;
|
||||
protected $format = 'json';
|
||||
protected array $viewData = [];
|
||||
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/servicios_cliente/';
|
||||
protected static $controllerSlug = "servicios";
|
||||
protected $indexRoute = 'viewServicioCliente';
|
||||
protected $editRoute = 'ServicioClienteEdit';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->servicioClienteModel = model(ServicioClienteModel::class);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => true]
|
||||
];
|
||||
return view(static::$viewPath . $this->indexRoute, $this->viewData);
|
||||
}
|
||||
public function viewForm(int $servicio_cliente_id)
|
||||
{
|
||||
$servicioCliente = $this->servicioClienteModel->find($servicio_cliente_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => false],
|
||||
['title' => $servicioCliente->nombre, 'route' => site_url('configuracion/servicios/edit/' . $servicio_cliente_id), 'active' => true]
|
||||
];
|
||||
$this->viewData["model"] = $servicioCliente;
|
||||
|
||||
return view(static::$viewPath . 'ServicioClienteEdit', $this->viewData);
|
||||
}
|
||||
public function show(int $id)
|
||||
{
|
||||
$data = $this->servicioClienteModel->find($id)->withAllTarifas();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function update_servicio_cliente(int $id)
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$status = $this->servicioClienteModel->update($id, [
|
||||
"nombre" => $data["nombre"],
|
||||
"code" => $data["code"]
|
||||
]);
|
||||
if (isset($data["tarifa_manipulado_id"])) {
|
||||
$this->servicioClienteModel->upsertTarifaManipulado($id, $data["tarifa_manipulado_id"]);
|
||||
}else if(isset($data["tarifa_acabado_id"])) {
|
||||
|
||||
$this->servicioClienteModel->upsertTarifaAcabado($id, $data["tarifa_acabado_id"]);
|
||||
}else{
|
||||
$this->servicioClienteModel->detachTarifas($id);
|
||||
}
|
||||
|
||||
return $this->response->setJSON(["message" => lang("App.global_success"), "status" => $status]);
|
||||
}
|
||||
public function store()
|
||||
{
|
||||
// $this->servicioClienteModel->update($id,[$this->request->getPost()]);
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
public function datatable()
|
||||
{
|
||||
$query = $this->servicioClienteModel->getQueryDatatable()->orderBy("created_at", "DESC");
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ use App\Entities\Pedidos\PedidoEntity;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
use App\Services\PedidoXMLService;
|
||||
use App\Services\ProductionService;
|
||||
|
||||
class Pedido extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -388,5 +389,20 @@ class Pedido extends \App\Controllers\BaseResourceController
|
||||
// $xml_service = new PedidoXMLService($this->model);
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function to_produccion($pedido_id)
|
||||
{
|
||||
$serviceProduction = service('production');
|
||||
$pedido = $this->model->find($pedido_id);
|
||||
$serviceProduction->setPedido($pedido);
|
||||
if($pedido->orden_trabajo()){
|
||||
return $this->response->setJSON(["data"=>$pedido->orden_trabajo(),"message" => "Ya existe una orden de trabajo para este pedido"]);
|
||||
|
||||
}else{
|
||||
$r = $serviceProduction->createOrdenTrabajo();
|
||||
return $this->response->setJSON(["data"=>$r,"message" => "Orden trabajo creada correctamente"]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,50 +1,268 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Produccion;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoUser;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use App\Services\ProductionService;
|
||||
use CodeIgniter\Files\File;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\I18n\Time;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
use Config\LogoImpresion;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Ordentrabajo extends BaseController
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
{
|
||||
protected $format = 'json';
|
||||
protected array $viewData = [];
|
||||
protected ProductionService $produccionService;
|
||||
protected OrdenTrabajoModel $otModel;
|
||||
protected OrdenTrabajoUser $otUserModel;
|
||||
protected OrdenTrabajoTarea $otTarea;
|
||||
protected UserModel $userModel;
|
||||
protected Validation $validation;
|
||||
protected static $viewPath = 'themes/vuexy/form/produccion/';
|
||||
protected static $controllerSlug = "orden-trabajo";
|
||||
protected $indexRoute = 'viewOrdenTrabajoList';
|
||||
protected $indexRoutePlanning = 'ot/viewPlanningRotativa';
|
||||
protected $editRoute = 'viewOrdenTrabajoEdit';
|
||||
|
||||
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->otModel = model(OrdenTrabajoModel::class);
|
||||
$this->userModel = model(UserModel::class);
|
||||
$this->produccionService = new ProductionService();
|
||||
$this->otTarea = model(OrdenTrabajoTarea::class);
|
||||
$this->validation = service("validation");
|
||||
helper("time");
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo 'Orden trabajo';
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Produccion.ot"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("Produccion.ots"), 'route' => site_url('produccion/ordentrabajo'), 'active' => true]
|
||||
];
|
||||
return view(static::$viewPath . $this->indexRoute, $this->viewData);
|
||||
}
|
||||
public function index_planning_rotativa()
|
||||
{
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Produccion.ots"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("Produccion.ots"), 'route' => site_url('produccion/ordentrabajo/planning/rotativa'), 'active' => true]
|
||||
];
|
||||
return view(static::$viewPath . $this->indexRoutePlanning, $this->viewData);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
|
||||
public function get_orden_trabajo_summary($orden_trabajo_id)
|
||||
{
|
||||
$summary = $this->produccionService->init($orden_trabajo_id)->getSummary();
|
||||
return $this->response->setJSON($summary);
|
||||
}
|
||||
public function add() {}
|
||||
|
||||
/**========================================================================
|
||||
* UPDATES
|
||||
*========================================================================**/
|
||||
public function update_orden_trabajo()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo");
|
||||
if ($validated) {
|
||||
$r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajo($bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function update_orden_trabajo_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea");
|
||||
if ($validated) {
|
||||
$r = $this->produccionService->updateOrdenTrabajoTarea($bodyData["orden_trabajo_tarea_id"], $bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function update_orden_trabajo_date()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo_date");
|
||||
if ($validated) {
|
||||
$r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoDate($bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r["status"], "user" => $r["user"], "data" => $bodyData]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($orden_trabajo_id)
|
||||
{
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Produccion.ot"), 'route' => site_url('produccion/ordentrabajo'), 'active' => false],
|
||||
['title' => $this->otModel->find($orden_trabajo_id)->pedido()->presupuesto()->titulo, 'route' => site_url('produccion/ordentrabajo/edit/' . $orden_trabajo_id), 'active' => true]
|
||||
];
|
||||
$this->viewData["modelId"] = $orden_trabajo_id;
|
||||
$this->produccionService->init($orden_trabajo_id);
|
||||
$this->viewData["presupuesto"] = $this->produccionService->getPresupuesto();
|
||||
$this->viewData["cliente"] = $this->produccionService->getCliente();
|
||||
$this->viewData["ot"] = $this->produccionService->getOrdenTrabajo();
|
||||
return view(static::$viewPath . $this->editRoute, $this->viewData);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado","F");
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_pendientes()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado",["I","PM"]);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_ferro_pendiente()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at",null);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_ferro_ok()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL",NULL,FALSE);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)))
|
||||
->edit(
|
||||
"fecha_encuadernado_at",
|
||||
fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y")
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function papel_gramaje_datatable()
|
||||
{
|
||||
|
||||
$q = $this->produccionService->papelGramajeDatatableQuery();
|
||||
return DataTable::of($q)
|
||||
->edit("tiempoReal", fn($q) => float_seconds_to_hhmm_string($q->tiempoReal * 3600))
|
||||
->toJson(true);
|
||||
}
|
||||
|
||||
public function add()
|
||||
public function reset_tareas(int $orden_trabajo_id)
|
||||
{
|
||||
|
||||
$r = $this->produccionService->init($orden_trabajo_id)->resetAllTareas();
|
||||
return $this->response->setJSON(["message" => "Tareas reseteadas", "status" => $r]);
|
||||
}
|
||||
|
||||
public function edit()
|
||||
public function delete_tarea(int $orden_trabajo_tarea_id)
|
||||
{
|
||||
|
||||
$r = $this->otTarea->delete($orden_trabajo_tarea_id);
|
||||
return $this->response->setJSON(["message" => "Tarea eliminada", "states" => $r]);
|
||||
}
|
||||
|
||||
public function cien()
|
||||
public function tareas_datatable(int $orden_trabajo_id)
|
||||
{
|
||||
echo 'Orden trabajo 100%';
|
||||
$q = $this->produccionService->init($orden_trabajo_id)->taskDatatableQuery($orden_trabajo_id);
|
||||
// return $this->response->setJSON($q->get()->getResultArray());
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q)
|
||||
->edit("orden", fn($q) => ["id" => $q->id, "orden" => $q->orden])
|
||||
->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmm_string($q->tiempo_estimado))
|
||||
->edit("tiempo_real", fn($q) => float_seconds_to_hhmm_string($q->tiempo_real))
|
||||
->edit("maquina_tarea", fn($q) => ["id" => $q->id, "maquina_id" => $q->maquina_tarea, "maquina_name" => $q->maquina_nombre])
|
||||
->toJson(true);
|
||||
}
|
||||
|
||||
public function finalizado()
|
||||
public function get_pdf($orden_trabajo_id)
|
||||
{
|
||||
echo 'Orden trabajo finalizado';
|
||||
return $this->produccionService->init($orden_trabajo_id)->getPdf();
|
||||
}
|
||||
|
||||
public function pendiente()
|
||||
public function upload_orden_trabajo_portada()
|
||||
{
|
||||
echo 'Orden trabajo pendiente';
|
||||
try {
|
||||
//code...
|
||||
$file = $this->request->getFile("portada_file");
|
||||
$bodyData = $this->request->getPost();
|
||||
$id = $bodyData["orden_trabajo_id"];
|
||||
$r = null;
|
||||
$fullpath = null;
|
||||
if ($file->isValid() && !$file->hasMoved()) {
|
||||
$fullpath = $file->store('ordenes_trabajo_portadas');
|
||||
$r = $this->otModel->update($id, ["portada_path" => $fullpath]);
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Portada subida", "data" => $r]);
|
||||
} catch (\Throwable $th) {
|
||||
if ($fullpath) {
|
||||
delete_files($fullpath);
|
||||
}
|
||||
return $this->response->setJSON(["message" => "Portada error", "error" => $th->getMessage()])->setStatusCode($th->getCode());
|
||||
}
|
||||
}
|
||||
public function get_portada_img($orden_trabajo_id)
|
||||
{
|
||||
$ot = $this->otModel->find($orden_trabajo_id);
|
||||
if ($ot->portada_path) {
|
||||
$filePath = WRITEPATH . 'uploads/' . $ot->portada_path;
|
||||
$mimeType = mime_content_type($filePath);
|
||||
return $this->response
|
||||
->setHeader('Content-Type', $mimeType)
|
||||
->setHeader('Content-Length', filesize($filePath))
|
||||
->setBody(file_get_contents($filePath));
|
||||
} else {
|
||||
return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function planning_rotativa_datatable()
|
||||
{
|
||||
$q = $this->produccionService->planningRotativaQueryDatatable();
|
||||
return DataTable::of($q)
|
||||
->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "")
|
||||
->add("action", fn($q) => $q)
|
||||
->toJson(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Tarifas\Acabados;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas\Acabados;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
@ -22,7 +24,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
protected static $controllerSlug = 'tarifasacabado';
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/tarifas/acabado/';
|
||||
protected static $viewPath = 'themes/vuexy/form/tarifas/acabado/';
|
||||
|
||||
protected $indexRoute = 'tarifaAcabadoList';
|
||||
|
||||
@ -133,7 +135,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['proveedores'] = $this->getProveedores();
|
||||
$this->viewData['proveedores'] = $this->getProveedores();
|
||||
|
||||
$this->viewData['tarifaacabadoEntity'] = isset($sanitizedData) ? new TarifaAcabadoEntity($sanitizedData) : new TarifaAcabadoEntity();
|
||||
$this->viewData['formAction'] = route_to('tarifaAcabadoAdd');
|
||||
@ -169,7 +171,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
|
||||
if ($this->request->getPost('mostrar_en_presupuesto') == null) {
|
||||
$sanitizedData['mostrar_en_presupuesto'] = false;
|
||||
}
|
||||
@ -181,7 +183,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
if ($this->request->getPost('acabado_sobrecubierta') == null) {
|
||||
$sanitizedData['acabado_sobrecubierta'] = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
@ -207,7 +209,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaacabadoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) .'.';
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
@ -312,12 +314,26 @@ class TarifaAcabados extends BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
private function getProveedores(){
|
||||
private function getProveedores()
|
||||
{
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
$tipoId = $provTipoModel->getTipoId("Acabados");
|
||||
return $provModel->getProvList($tipoId);
|
||||
}
|
||||
|
||||
public function show_select()
|
||||
{
|
||||
$query = $this->model->builder()
|
||||
->select(
|
||||
["id", "nombre as name", "code as description"]
|
||||
)
|
||||
->where("deleted_at",null);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
}
|
||||
|
||||
205
ci4/app/Controllers/Tarifas/Maquinas/TarifaMaquinas.php
Normal file
205
ci4/app/Controllers/Tarifas/Maquinas/TarifaMaquinas.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas\Maquinas;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Configuracion\MaquinaTareaModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaAcabadoMaquinaModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaManipuladoMaquinaModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaEncuadernacionMaquinaModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaPreimpresionMaquinaModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaExtraMaquinaModel;
|
||||
|
||||
use App\Services\TarifaMaquinaService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
class TarifaMaquinas extends BaseController
|
||||
{
|
||||
protected $format = 'json';
|
||||
protected array $viewData = [];
|
||||
protected MaquinaModel $maquinaModel;
|
||||
protected MaquinaTareaModel $maquinaTareaModel;
|
||||
protected TarifaMaquinaService $tarifaMaquinaService;
|
||||
protected Validation $validation;
|
||||
protected static $controllerSlug = "tarifa-maquinas";
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->maquinaModel = model(MaquinaModel::class);
|
||||
$this->maquinaTareaModel = model(MaquinaTareaModel::class);
|
||||
$this->tarifaMaquinaService = service("tarifa_maquina");
|
||||
$this->validation = service("validation");
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
/**========================================================================
|
||||
* CREATE
|
||||
*========================================================================**/
|
||||
|
||||
public function add_tarifa_acabado_maquina_with_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "tarifa_maquina_acabado");
|
||||
if ($validated) {
|
||||
$r = $this->tarifaMaquinaService->attachAcabadoToMaquina(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]);
|
||||
} else {
|
||||
return $this->response->setJSON($this->validation->getErrors())->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function add_tarifa_manipulado_maquina_with_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "tarifa_maquina_manipulado");
|
||||
if ($validated) {
|
||||
$r = $this->tarifaMaquinaService->attachManipuladoToMaquina(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function add_tarifa_preimpresion_maquina_with_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "tarifa_maquina_preimpresion");
|
||||
if ($validated) {
|
||||
|
||||
$r = $this->tarifaMaquinaService->attachPreimpresionToMaquina(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function add_tarifa_encuadernacion_maquina_with_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "tarifa_maquina_encuadernacion");
|
||||
if ($validated) {
|
||||
|
||||
$r = $this->tarifaMaquinaService->attachEncuadernacionToMaquina(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function add_tarifa_extra_maquina_with_tarea()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "tarifa_maquina_encuadernacion");
|
||||
if ($validated) {
|
||||
$r = $this->tarifaMaquinaService->attachExtraToMaquina(...$bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
/**========================================================================
|
||||
* DELETES
|
||||
*========================================================================**/
|
||||
public function delete_tarifa_acabado_maquina_with_tarea($tarifa_acabado_maquina_id)
|
||||
{
|
||||
$m = model(TarifaAcabadoMaquinaModel::class);
|
||||
$r = $m->delete($tarifa_acabado_maquina_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]);
|
||||
|
||||
}
|
||||
public function delete_tarifa_manipulado_maquina_with_tarea($tarifa_manipulado_maquina_id)
|
||||
{
|
||||
$m = model(TarifaManipuladoMaquinaModel::class);
|
||||
$r = $m->delete($tarifa_manipulado_maquina_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]);
|
||||
|
||||
}
|
||||
public function delete_tarifa_encuadernacion_maquina_with_tarea($tarifa_encuadernacion_maquina_id)
|
||||
{
|
||||
$m = model(TarifaEncuadernacionMaquinaModel::class);
|
||||
$r = $m->delete($tarifa_encuadernacion_maquina_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]);
|
||||
|
||||
}
|
||||
public function delete_tarifa_preimpresion_maquina_with_tarea($tarifa_preimpresion_maquina_id)
|
||||
{
|
||||
$m = model(TarifaPreimpresionMaquinaModel::class);
|
||||
$r = $m->delete($tarifa_preimpresion_maquina_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]);
|
||||
|
||||
}
|
||||
public function delete_tarifa_extra_maquina_with_tarea($tarifa_extra_maquina_id)
|
||||
{
|
||||
$m = model(TarifaExtraMaquinaModel::class);
|
||||
$r = $m->delete($tarifa_extra_maquina_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]);
|
||||
|
||||
}
|
||||
|
||||
/**========================================================================
|
||||
* SELECTS
|
||||
*========================================================================**/
|
||||
public function get_select_maquina_acabado()
|
||||
{
|
||||
$r = $this->maquinaModel->getSelectQuery(q: $this->request->getGet("q"), type: 'acabado');
|
||||
return $this->response->setJSON($r);
|
||||
}
|
||||
public function get_select_maquina_impresion()
|
||||
{
|
||||
$r = $this->maquinaModel->getSelectQuery(q: $this->request->getGet("q"), type: 'impresion');
|
||||
return $this->response->setJSON($r);
|
||||
}
|
||||
public function get_select_maquina_manipulado()
|
||||
{
|
||||
$r = $this->maquinaModel->getSelectQuery(q: $this->request->getGet("q"), type: 'manipulado');
|
||||
return $this->response->setJSON($r);
|
||||
}
|
||||
public function get_select_maquina_tareas()
|
||||
{
|
||||
$r = $this->maquinaTareaModel->getSelectQuery(q: $this->request->getGet("q"));
|
||||
return $this->response->setJSON($r);
|
||||
}
|
||||
/**========================================================================
|
||||
* DATATABLES
|
||||
*========================================================================**/
|
||||
public function get_datatable_tarifa_acabado_maquina(int $tarifa_acabado_id)
|
||||
{
|
||||
$m = model(TarifaAcabadoMaquinaModel::class);
|
||||
$q = $m->queryDatatable($tarifa_acabado_id);
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function get_datatable_tarifa_manipulado_maquina(int $tarifa_manipulado_id)
|
||||
{
|
||||
$m = model(TarifaManipuladoMaquinaModel::class);
|
||||
$q = $m->queryDatatable($tarifa_manipulado_id);
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function get_datatable_tarifa_preimpresion_maquina(int $tarifa_preimpresion_id)
|
||||
{
|
||||
$m = model(TarifaPreimpresionMaquinaModel::class);
|
||||
$q = $m->queryDatatable($tarifa_preimpresion_id);
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function get_datatable_tarifa_encuadernacion_maquina(int $tarifa_encuadernacion_id)
|
||||
{
|
||||
$m = model(TarifaEncuadernacionMaquinaModel::class);
|
||||
$q = $m->queryDatatable($tarifa_encuadernacion_id);
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function get_datatable_tarifa_extra_maquina(int $tarifa_extra_id)
|
||||
{
|
||||
$m = model(TarifaExtraMaquinaModel::class);
|
||||
$q = $m->queryDatatable($tarifa_extra_id);
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -130,7 +132,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity();
|
||||
|
||||
$this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add');//route_to('createTarifaManipulado');
|
||||
$this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add'); //route_to('createTarifaManipulado');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
@ -153,7 +155,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -293,5 +295,19 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
public function show_select()
|
||||
{
|
||||
$query = $this->model->builder()
|
||||
->select(
|
||||
["id", "nombre as name", "code as description"]
|
||||
)
|
||||
->where("deleted_at", null);
|
||||
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user