Merge branch 'add/print_labels_maquinista' into 'main'

terminado

See merge request jjimenez/safekat!775
This commit is contained in:
2025-05-05 11:14:14 +00:00
6 changed files with 220 additions and 13 deletions

View File

@ -11,6 +11,8 @@ use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use App\Models\OrdenTrabajo\OrdenTrabajoUser;
use App\Models\Presupuestos\PresupuestoModel;
use App\Models\Usuarios\UserModel;
use App\Services\EtiquetasTitulosService;
use App\Services\ImpresoraEtiquetaService;
use App\Services\ProductionService;
use CodeIgniter\Files\File;
use CodeIgniter\HTTP\RequestInterface;
@ -22,6 +24,7 @@ use Exception;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
class Ordentrabajo extends BaseController
{
protected $format = 'json';
@ -627,10 +630,19 @@ class Ordentrabajo extends BaseController
public function maquinista_maquina_tarea_view(int $orden_trabajo_tarea_id)
{
$modelImpresoras = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
$impresoras = $modelImpresoras->select('id, name')
->where('deleted_at', null)
->where('tipo', 1)
->orderBy('name', 'asc')
->findAll();
$impresoras = array_map(fn($impresora) => $impresora->toArray(), $impresoras);
$otTareaEntity = $this->otTarea->find($orden_trabajo_tarea_id);
$this->viewData['ot_tarea'] = $otTareaEntity;
$this->viewData['ot'] = $otTareaEntity->orden_trabajo();
$this->viewData['presupuesto'] = $this->viewData['ot']->presupuesto();
$this->viewData['impresoras'] = $impresoras;
$this->viewData['breadcrumb'] = [
['title' => lang("Produccion.maquinista.maquinas"), 'route' => route_to("viewProduccionMaquinistaMaquinas"), 'active' => false],
['title' => $otTareaEntity->maquina_actual()->nombre, 'route' => route_to("viewProduccionMaquinaTareasList", $otTareaEntity?->maquina_actual()?->id), 'active' => true],
@ -919,4 +931,36 @@ class Ordentrabajo extends BaseController
return $this->response->setJSON($responseData);
}
public function printPackagingLabels(){
$ot_id = $this->request->getPost('ot_id') ?? null;
$unidades_caja = $this->request->getPost('unidades_caja') ?? null;
$impresora_id = $this->request->getPost('impresora_id') ?? null;
if ($ot_id == null || $impresora_id == null) {
return [
'status' => false,
'message' => lang('Logistica.errors.errorMissingData')
];
}
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
$impresora = $modelImpresora->select('id, name, ip, port, user, pass')
->where('deleted_at', null)
->where('id', $impresora_id)
->orderBy('name', 'asc')
->first();
if ($impresora == null) {
return $this->response->setJSON([
'status' => false,
'message' => 'Impresora no válida'
]);
}
$printerService = new ImpresoraEtiquetaService();
$result = $printerService->generateEtiquetasEmbalaje($ot_id, $unidades_caja, $impresora);
return $this->response->setJSON($result);
}
}