This commit is contained in:
amazuecos
2024-12-16 09:19:08 +01:00
parent 422ade0030
commit 43f2daea59
13 changed files with 351 additions and 109 deletions

View File

@ -3,6 +3,7 @@
namespace App\Controllers\Produccion;
use App\Controllers\BaseController;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Services\ProductionService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Hermawan\DataTables\DataTable;
@ -12,7 +13,7 @@ class Ordentrabajo extends BaseController
{
protected $format = 'json';
protected array $viewData = [];
protected ProductionService $produccionService;
protected OrdenTrabajoModel $otModel;
protected static $viewPath = 'themes/vuexy/form/produccion/';
protected static $controllerSlug = "orden-trabajo";
@ -22,6 +23,7 @@ class Ordentrabajo extends BaseController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->otModel = model(OrdenTrabajoModel::class);
$this->produccionService = new ProductionService();
parent::initController($request, $response, $logger);
}
@ -29,8 +31,8 @@ class Ordentrabajo extends BaseController
{
// Breadcrumbs
$this->viewData['breadcrumb'] = [
['title' => lang("App.orden_trabajo"), 'route' => "javascript:void(0);", 'active' => false],
['title' => "Table", 'route' => site_url('produccion/ordentrabajo'), 'active' => true]
['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);
}
@ -40,6 +42,10 @@ class Ordentrabajo extends BaseController
}
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()
{
@ -49,9 +55,14 @@ class Ordentrabajo extends BaseController
{
// Breadcrumbs
$this->viewData['breadcrumb'] = [
['title' => lang("App.orden_trabajo"), 'route' => "javascript:void(0);", 'active' => false],
['title' => "Table", 'route' => site_url('produccion/ordentrabajo'), 'active' => true]
['title' => lang("Produccion.ot"), 'route' => "javascript:void(0);", '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);
}