imposiciones

This commit is contained in:
amazuecos
2025-04-20 19:26:07 +02:00
parent 52a4e7d37b
commit c3d38e29a4
34 changed files with 1676 additions and 496 deletions

View File

@ -146,17 +146,25 @@ $routes->group('tipologiaslibros', ['namespace' => 'App\Controllers\Configuracio
$routes->group('imposiciones', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->group('imposiciones', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'Imposiciones::index', ['as' => 'imposicionList']); $routes->get('', 'Imposiciones::index', ['as' => 'imposicionList']);
$routes->get('add', 'Imposiciones::add', ['as' => 'newImposicion']); $routes->get('add', 'Imposiciones::add', ['as' => 'newImposicion']);
$routes->post('add', 'Imposiciones::add', ['as' => 'createImposicion']); $routes->get('add/esquema', 'Imposiciones::add_esquema', ['as' => 'newImposicionEsquema']);
$routes->get('find/(:num)', 'Imposiciones::find_imposicion/$1', ['as' => 'findImposicion']);
$routes->get('esquema/find/(:num)', 'Imposiciones::find_imposicion_esquema/$1', ['as' => 'findImposicionEsquema']);
$routes->post('create', 'Imposiciones::create', ['as' => 'ajaxCreateImposicion']); $routes->post('create', 'Imposiciones::create', ['as' => 'ajaxCreateImposicion']);
$routes->put('(:num)/update', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']); $routes->post('esquema/create', 'Imposiciones::create_imposicion_esquema', ['as' => 'ajaxCreateImposicionEsquema']);
$routes->post('(:num)/edit', 'Imposiciones::edit/$1', ['as' => 'updateImposicion']); $routes->post('(:num)', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']);
$routes->post('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']); $routes->post('esquema/(:num)', 'Imposiciones::update_imposicion_esquema/$1', ['as' => 'ajaxUpdateImposicionEsquema']);
$routes->delete('(:num)', 'Imposiciones::delete/$1', ['as' => 'deleteImposicion']);
$routes->delete('esquema/(:num)', 'Imposiciones::delete_imposicion_esquema/$1', ['as' => 'deleteImposicionEsquema']);
$routes->get('edit/(:num)', 'Imposiciones::edit/$1', ['as' => 'updateImposicionForm']);
$routes->get('esquema/edit/(:num)', 'Imposiciones::edit_imposicion_esquema/$1', ['as' => 'updateImposicionEsquemaForm']);
$routes->get('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']);
$routes->get('esquema/datatable', 'Imposiciones::datatable_imposicion_esquema', ['as' => 'dataTableOfEsquemaImposiciones']);
$routes->post('allmenuitems', 'Imposiciones::allItemsSelect', ['as' => 'select2ItemsOfImposiciones']); $routes->post('allmenuitems', 'Imposiciones::allItemsSelect', ['as' => 'select2ItemsOfImposiciones']);
$routes->post('menuitems', 'Imposiciones::menuItems', ['as' => 'menuItemsOfImposiciones']); $routes->post('menuitems', 'Imposiciones::menuItems', ['as' => 'menuItemsOfImposiciones']);
$routes->get('select', 'Imposiciones::selectImposicion', ['as' => 'selectImposicion']); $routes->get('select', 'Imposiciones::selectImposicion', ['as' => 'selectImposicion']);
$routes->get('esquema/select', 'Imposiciones::selectImposicionEsquema', ['as' => 'selectImposicionEsquema']);
}); });
$routes->resource('imposiciones', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Imposiciones', 'except' => 'show,new,create,update']);
$routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('add', 'Papelimpresiontipologias::add', ['as' => 'newPapelImpresionTipologia']); $routes->get('add', 'Papelimpresiontipologias::add', ['as' => 'newPapelImpresionTipologia']);

View File

@ -2,37 +2,41 @@
namespace App\Controllers\Configuracion; namespace App\Controllers\Configuracion;
use App\Controllers\BaseController;
use App\Controllers\BaseResourceController; use App\Controllers\BaseResourceController;
use App\Models\Collection; use App\Models\Collection;
use App\Entities\Configuracion\Imposicion; use App\Entities\Configuracion\Imposicion;
use App\Models\Configuracion\ImposicionEsquemaModel;
use App\Models\Configuracion\ImposicionModel; use App\Models\Configuracion\ImposicionModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
class Imposiciones extends \App\Controllers\BaseResourceController class Imposiciones extends BaseController
{ {
protected $modelName = ImposicionModel::class; protected $modelName = ImposicionModel::class;
protected $format = 'json'; protected ImposicionModel $model;
protected ImposicionEsquemaModel $imposicionEsquemaModel;
protected static $singularObjectName = 'Imposicion';
protected static $singularObjectNameCc = 'imposicion';
protected static $pluralObjectName = 'Imposiciones';
protected static $pluralObjectNameCc = 'imposiciones';
protected static $controllerSlug = 'imposiciones'; protected static $controllerSlug = 'imposiciones';
protected $format = 'json';
protected static $viewPath = 'themes/vuexy/form/configuracion/imposiciones/'; protected static $viewPath = 'themes/vuexy/form/configuracion/imposiciones/';
protected $indexRoute = 'imposicionList'; protected $indexRoute = 'imposicionList';
protected array $viewData = [];
protected Validation $validation;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{ {
$this->viewData['pageTitle'] = lang('Imposiciones.moduleTitle'); $this->viewData['pageTitle'] = lang('Imposiciones.moduleTitle');
$this->viewData['usingSweetAlert'] = true; $this->viewData['usingSweetAlert'] = true;
$this->model = model($this->modelName);
$this->validation = service("validation");
$this->imposicionEsquemaModel = model(ImposicionEsquemaModel::class);
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
} }
@ -47,7 +51,10 @@ class Imposiciones extends \App\Controllers\BaseResourceController
'usingServerSideDataTable' => true, 'usingServerSideDataTable' => true,
]; ];
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => true],
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewImposicionList', $viewData); return view(static::$viewPath . 'viewImposicionList', $viewData);
@ -56,234 +63,147 @@ class Imposiciones extends \App\Controllers\BaseResourceController
public function add() public function add()
{ {
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => true],
];
return view(static::$viewPath . 'viewImposicionNewForm', $this->viewData);
}
if ($this->request->getPost()) : public function add_esquema()
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif;
if ($noException && $successfulResult) :
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['imposicion'] = isset($sanitizedData) ? new Imposicion($sanitizedData) : new Imposicion();
$this->viewData['orientacionList'] = $this->getOrientacionOptions();
$this->viewData['formAction'] = route_to('createImposicion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null)
{ {
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => true],
];
$this->viewData["imposicion_esquema"] = null;
if ($requestedId == null) : return view(static::$viewPath . 'viewImposicionEsquemaForm', $this->viewData);
return $this->redirect2listView(); }
endif; public function edit($imposicion_id = null)
$id = filter_var($requestedId, FILTER_SANITIZE_URL); {
$imposicion = $this->model->find($id); if ($imposicion_id) {
$this->viewData["imposicion"] = $this->model->find($imposicion_id);
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => false],
['title' => $this->viewData["imposicion"]->full_name, 'route' => route_to("updateImposicionForm", $imposicion_id), 'active' => true],
if ($imposicion == false) : ];
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Imposiciones.imposicion')), $id]); }
return $this->redirect2listView('sweet-error', $message); return view(static::$viewPath . 'viewImposicionForm', $this->viewData);
endif; }
public function edit_imposicion_esquema($imposicion_esquema_id = null)
{
if ($imposicion_esquema_id) {
$this->viewData["imposicion_esquema"] = $this->imposicionEsquemaModel->find($imposicion_esquema_id);
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => false],
['title' => $this->viewData["imposicion_esquema"]->name, 'route' => route_to("updateImposicionEsquemaForm", $imposicion_esquema_id), 'active' => true],
];
}
if ($this->request->getPost()) : return view(static::$viewPath . 'viewImposicionEsquemaForm', $this->viewData);
}
$nullIfEmpty = true; // !(phpversion() >= '8.1'); public function update($imposicion_id = null)
{
$postData = $this->request->getPost(); if ($imposicion_id) {
$bodyData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $status = $this->model->update($imposicion_id, $bodyData);
if ($status) {
$imposicionEntity = $this->model->find($imposicion_id);
$noException = true; } else {
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->model->errors(), "status" => true])->setStatusCode(400);
}
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status, "data" => $imposicionEntity]);
if ($this->canValidate()) : } else {
try { return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "message" => "", "status" => false])->setStatusCode(400);
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); }
} catch (\Exception $e) { }
$noException = false; public function update_imposicion_esquema($imposicion_esquema_id = null)
$this->dealWithException($e); {
} if ($imposicion_esquema_id) {
else: $bodyData = $this->request->getPost();
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Imposiciones.imposicion'))]); $status = $this->imposicionEsquemaModel->update($imposicion_esquema_id, $bodyData);
$this->session->setFlashdata('formErrors', $this->model->errors()); if ($status) {
$imposicionEsquemaEntity = $this->imposicionEsquemaModel->find($imposicion_esquema_id);
endif; } else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->imposicionEsquemaModel->errors(), "status" => true])->setStatusCode(400);
$imposicion->fill($sanitizedData); }
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status, "data" => $imposicionEsquemaEntity]);
$thenRedirect = false; } else {
endif; return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "message" => "", "status" => false])->setStatusCode(400);
if ($noException && $successfulResult) : }
$id = $imposicion->id ?? $id; }
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; public function delete($imposicion_id = null)
{
if ($thenRedirect) : $status = $this->model->delete($imposicion_id);
if (!empty($this->indexRoute)) : return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true]);
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); }
else: public function delete_imposicion_esquema($imposicion_esquema_id = null)
return $this->redirect2listView('sweet-success', $message); {
endif; $status = $this->imposicionEsquemaModel->delete($imposicion_esquema_id);
else: return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $status]);
$this->session->setFlashData('sweet-success', $message); }
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['imposicion'] = $imposicion;
$this->viewData['orientacionList'] = $this->getOrientacionOptions();
$this->viewData['formAction'] = route_to('updateImposicion', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() public function datatable()
{ {
if ($this->request->isAJAX()) { $q = $this->model->queryDatatable();
$reqData = $this->request->getPost(); return DataTable::of($q)
if (!isset($reqData['draw']) || !isset($reqData['columns'])) { ->add(
$errstr = 'No data available in response to this specific request.'; 'action',
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); fn($q) => "<div class='btn-group btn-group-md gap-2 w-100 d-flex justify-space-between'>". ImposicionModel::datatable_buttons($q->id)."</div>"
return $response; )
} ->toJson(true);
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = ImposicionModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
$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);
}
} }
public function datatable_imposicion_esquema()
public function allItemsSelect()
{ {
if ($this->request->isAJAX()) { $q = $this->imposicionEsquemaModel->queryDatatable();
$onlyActiveOnes = true; return DataTable::of($q)
$reqVal = $this->request->getPost('val') ?? 'id'; ->add(
$menu = $this->model->getAllForMenu($reqVal . ', ancho', 'ancho', $onlyActiveOnes, false); 'action',
$nonItem = new \stdClass; fn($q) => "<div class='btn-group btn-group-md gap-2'>". ImposicionEsquemaModel::datatable_buttons($q->id)."</div>"
$nonItem->id = ''; )
$nonItem->ancho = '- ' . lang('Basic.global.None') . ' -'; ->toJson(true);
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
$reqText = goSanitize($this->request->getPost('text'))[0];
$onlyActiveOnes = false;
$columns2select = [$reqId ?? 'id', $reqText ?? 'ancho'];
$onlyActiveOnes = false;
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
} }
protected function getOrientacionOptions()
{
$orientacionOptions = [
'' => lang('Basic.global.pleaseSelect'),
'H' => 'H',
'V' => 'V',
];
return $orientacionOptions;
}
public function selectImposicion() public function selectImposicion()
{ {
$data = $this->model->querySelect($this->request->getGet('q')); $data = $this->model->querySelect($this->request->getGet('q'));
return $this->response->setJSON($data); return $this->response->setJSON($data);
} }
public function selectImposicionEsquema()
{
$data = $this->imposicionEsquemaModel->querySelect($this->request->getGet('q'));
return $this->response->setJSON($data);
}
public function find_imposicion(int $imposicion_id)
{
$imposicionEntity = $this->model->find($imposicion_id)->withImposicionEsquema();
return $this->response->setJSON($imposicionEntity);
}
public function find_imposicion_esquema(int $imposicion_esquema_id)
{
$imposicionEsquemaEntity = $this->imposicionEsquemaModel->find($imposicion_esquema_id);
return $this->response->setJSON($imposicionEsquemaEntity);
}
public function create()
{
$bodyData = $this->request->getPost();
$createdId = $this->model->insert($bodyData);
if ($createdId) {
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true]);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->model->errors(), "status" => true])->setStatusCode(400);
}
}
public function create_imposicion_esquema()
{
$bodyData = $this->request->getPost();
$createdId = $this->imposicionEsquemaModel->insert($bodyData);
if ($createdId) {
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true]);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->imposicionEsquemaModel->errors(), "status" => true])->setStatusCode(400);
}
}
} }

View File

@ -0,0 +1,79 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class AddTableImposicionEsquemas extends Migration
{
protected array $COLUMNS = [
"id" => [
"type" => "INT",
"unsigned" => true,
"auto_increment" => true
],
"name" => [
"type" => "VARCHAR",
"constraint" => 255,
],
"rows" => [
"type" => "INT",
"unsigned" => true,
"default" => 0,
],
"columns" => [
"type" => "INT",
"unsigned" => true,
"default" => 0,
],
"orientacion" => [
"type" => "ENUM",
"constraint" => ["H","V"],
"default" => "H",
],
"rotativa" => [
"type" => "BOOLEAN",
"default" => false,
],
"cosido" => [
"type" => "BOOLEAN",
"default" => false,
],
"svg_schema" => [
"type" => "LONGTEXT",
"null" => true
],
];
public function up()
{
$this->forge->addField($this->COLUMNS);
$currenttime = new RawSql("CURRENT_TIMESTAMP");
$this->forge->addField([
"created_at" => [
"type" => "TIMESTAMP",
"default" => $currenttime,
],
"updated_at" => [
"type" => "TIMESTAMP",
"null" => true,
],
"deleted_at" => [
"type" => "TIMESTAMP",
"null" => true,
],
]);
$this->forge->addPrimaryKey("id");
$this->forge->createTable("imposicion_esquemas");
}
public function down()
{
$this->forge->dropTable("imposicion_esquemas",true);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class AddFkEsquemaImposiciones extends Migration
{
public function up()
{
$this->forge->addColumn("lg_imposiciones", [
"imposicion_esquema_id" => [
"type" => "INT",
"unsigned" => true,
]
]);
$this->forge->addForeignKey(["imposicion_esquema_id"],"imposicion_esquemas",["id"]);
$this->forge->processIndexes("lg_imposiciones");
}
public function down()
{
$this->forge->dropForeignKey("lg_imposiciones","lg_imposiciones_imposicion_esquema_id_foreign");
$this->forge->dropColumn("lg_imposiciones","imposicion_esquema_id");
}
}

View File

@ -1,6 +1,8 @@
<?php <?php
namespace App\Entities\Configuracion; namespace App\Entities\Configuracion;
use App\Models\Configuracion\ImposicionEsquemaModel;
use CodeIgniter\Entity; use CodeIgniter\Entity;
class Imposicion extends \CodeIgniter\Entity\Entity class Imposicion extends \CodeIgniter\Entity\Entity
@ -13,19 +15,36 @@ class Imposicion extends \CodeIgniter\Entity\Entity
"orientacion" => null, "orientacion" => null,
"maquina" => null, "maquina" => null,
"etiqueta" => null, "etiqueta" => null,
"imposicion_esquema_id" => null
]; ];
protected $casts = [ protected $casts = [
"ancho" => "int", "ancho" => "int",
"alto" => "int", "alto" => "int",
"unidades" => "?int", "unidades" => "?int",
"imposicion_esquema_id" => "?int"
]; ];
public function getFullName() : string public function getFullName(): string
{ {
$ancho_x_alto = $this->attributes["ancho"] ."x". $this->attributes["alto"]; $ancho_x_alto = $this->attributes["ancho"] . "x" . $this->attributes["alto"];
$unidades = $this->attributes["unidades"] ?? ""; $unidades = $this->attributes["unidades"] ?? "";
$orientacion = $this->attributes["orientacion"] ?? ""; $orientacion = $this->attributes["orientacion"] ?? "";
return implode("_",[$ancho_x_alto,$unidades,$orientacion]); return implode("_", [$ancho_x_alto, $unidades, $orientacion]);
}
public function withImposicionEsquema(): self
{
$this->attributes["imposicion_esquema"] = $this->imposicion_esquema();
return $this;
}
public function imposicion_esquema(): ?ImposicionEsquemaEntity
{
$esquema = null;
if ($this->attributes["imposicion_esquema_id"]) {
$m = model(ImposicionEsquemaModel::class);
$esquema = $m->find($this->attributes["imposicion_esquema_id"]);
}
return $esquema;
} }
} }

View File

@ -0,0 +1,26 @@
<?php
namespace App\Entities\Configuracion;
use CodeIgniter\Entity\Entity;
class ImposicionEsquemaEntity extends Entity
{
protected $attributes = [
"name" => null,
"rows" => null,
"columns" => null,
"orientacion"=> null,
"rotativa"=> null,
"cosido"=> null,
"svg_schema"=> null
];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [
"name" => "string",
"rows" => "integer",
"columns" => "integer",
"rotativa"=> "boolean",
"cosido"=> "boolean",
];
}

View File

@ -0,0 +1,7 @@
<?php
return [
];

View File

@ -1,4 +1,47 @@
<?php <?php
// override core en language system validation or define your own en language validation message return [
return []; 'alpha' => 'The {field} field may only contain alphabetical characters.',
'alpha_dash' => 'The {field} field may only contain alphanumeric characters, underscores, and dashes.',
'alpha_numeric' => 'The {field} field may only contain alphanumeric characters.',
'alpha_numeric_punct' => 'The {field} field may only contain alphanumeric characters, spaces, and punctuation: ~!#$%&*-_+=|:.',
'alpha_numeric_space' => 'The {field} field may only contain alphanumeric characters and spaces.',
'alpha_space' => 'The {field} field may only contain alphabetical characters and spaces.',
'decimal' => 'The {field} field must contain a decimal number.',
'differs' => 'The {field} field must differ from the {param} field.',
'exact_length' => 'The {field} field must be exactly {param} characters in length.',
'field_exists' => 'The {field} field must exist.',
'greater_than' => 'The {field} field must be greater than {param}.',
'greater_than_equal_to' => 'The {field} field must be greater than or equal to {param}.',
'hex' => 'The {field} field may only contain hexadecimal characters.',
'if_exist' => 'The {field} field will be validated only if it exists.',
'in_list' => 'The {field} field must be one of: {param}.',
'integer' => 'The {field} field must contain an integer.',
'is_natural' => 'The {field} field must only contain natural numbers.',
'is_natural_no_zero' => 'The {field} field must only contain natural numbers greater than zero.',
'is_not_unique' => 'The {field} field value already exists in the database.',
'is_unique' => 'The {field} field value must be unique.',
'less_than' => 'The {field} field must be less than {param}.',
'less_than_equal_to' => 'The {field} field must be less than or equal to {param}.',
'matches' => 'The {field} field does not match the {param} field.',
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
'min_length' => 'The {field} field must be at least {param} characters in length.',
'not_in_list' => 'The {field} field must not be one of: {param}.',
'numeric' => 'The {field} field must contain only numeric characters.',
'permit_empty' => 'The {field} field may be empty.',
'regex_match' => 'The {field} field format is invalid.',
'required' => 'The {field} field is required.',
'required_with' => 'The {field} field is required when {param} is present.',
'required_without' => 'The {field} field is required when {param} is absent.',
'string' => 'The {field} field must be a string.',
'timezone' => 'The {field} field must be a valid timezone.',
'valid_base64' => 'The {field} field must contain a valid Base64 string.',
'valid_cc_number' => 'The {field} must be a valid credit card number for the specified provider.',
'valid_date' => 'The {field} field must contain a valid date in the format {param}.',
'valid_email' => 'The {field} field must contain a valid email address.',
'valid_emails' => 'All values in the {field} field must be valid email addresses.',
'valid_ip' => 'The {field} field must contain a valid {param} IP address.',
'valid_json' => 'The {field} field must contain a valid JSON string.',
'valid_url' => 'The {field} field must contain a valid URL.',
'valid_url_strict' => 'The {field} field must contain a valid URL using one of these schemas: {param}.',
];

View File

@ -0,0 +1,38 @@
<?php
return [
"imposicionList" => "Lista imposiciones",
"id" => "id",
"ancho" => "Ancho",
"alto" => "Alto",
"unidades" => "Unidades",
"orientacion" => "Orientación",
"maquina" => "Máquina",
"etiqueta" => "Etiqueta",
"imposicion" => "Imposición",
"btnNewImposicion" => "Nueva imposición",
"btnNewImposicionEsquema" => "Nuevo esquema",
"H" => "Horizontal",
"V" => "Vertical",
"imposicion_esquemas" => "Esquemas",
"imposicion_esquema" => "Esquema",
"imposicion_esquema_drawing" => "Esquema imposicion dibujo",
"imposicion_esquema_link" => "Imposicion esquema link",
"validation" => [
"alto" => [
"required" => "Este campo es obligatorio",
],
"ancho" => [
"required" => "Este campo es obligatorio",
]
],
"esquema" => [
"name" => "Nombre",
"rows" => "Filas",
"columns" => "Columnas",
"rotativa" => "Rotativa",
"cosido" => "Cosido/Grapado"
]
];

View File

@ -1,4 +1,47 @@
<?php <?php
// override core en language system validation or define your own en language validation message return [
return []; 'alpha' => 'El campo {field} solo puede contener caracteres alfabéticos.',
'alpha_dash' => 'El campo {field} solo puede contener caracteres alfanuméricos, guiones y guiones bajos.',
'alpha_numeric' => 'El campo {field} solo puede contener caracteres alfanuméricos.',
'alpha_numeric_punct' => 'El campo {field} solo puede contener caracteres alfanuméricos, espacios y los siguientes signos de puntuación: ~!#$%&*-_+=|:.',
'alpha_numeric_space' => 'El campo {field} solo puede contener caracteres alfanuméricos y espacios.',
'alpha_space' => 'El campo {field} solo puede contener caracteres alfabéticos y espacios.',
'decimal' => 'El campo {field} debe contener un número decimal.',
'differs' => 'El campo {field} debe ser diferente al campo {param}.',
'exact_length' => 'El campo {field} debe tener exactamente {param} caracteres.',
'field_exists' => 'El campo {field} debe existir.',
'greater_than' => 'El campo {field} debe ser mayor que {param}.',
'greater_than_equal_to' => 'El campo {field} debe ser mayor o igual que {param}.',
'hex' => 'El campo {field} solo puede contener caracteres hexadecimales.',
'if_exist' => 'El campo {field} se validará solo si existe.',
'in_list' => 'El campo {field} debe ser uno de los siguientes: {param}.',
'integer' => 'El campo {field} debe contener un número entero.',
'is_natural' => 'El campo {field} solo puede contener números naturales.',
'is_natural_no_zero' => 'El campo {field} solo puede contener números naturales mayores que cero.',
'is_not_unique' => 'El valor del campo {field} ya existe en la base de datos.',
'is_unique' => 'El valor del campo {field} debe ser único.',
'less_than' => 'El campo {field} debe ser menor que {param}.',
'less_than_equal_to' => 'El campo {field} debe ser menor o igual que {param}.',
'matches' => 'El campo {field} no coincide con el campo {param}.',
'max_length' => 'El campo {field} no puede superar los {param} caracteres.',
'min_length' => 'El campo {field} debe tener al menos {param} caracteres.',
'not_in_list' => 'El campo {field} no debe ser uno de los siguientes: {param}.',
'numeric' => 'El campo {field} solo puede contener caracteres numéricos.',
'permit_empty' => 'El campo {field} puede estar vacío.',
'regex_match' => 'El campo {field} no tiene el formato correcto.',
'required' => 'El campo {field} es obligatorio.',
'required_with' => 'El campo {field} es obligatorio cuando {param} está presente.',
'required_without' => 'El campo {field} es obligatorio cuando {param} no está presente.',
'string' => 'El campo {field} debe ser una cadena de texto.',
'timezone' => 'El campo {field} debe contener una zona horaria válida.',
'valid_base64' => 'El campo {field} debe contener una cadena Base64 válida.',
'valid_cc_number' => 'El campo {field} debe contener un número de tarjeta de crédito válido para el proveedor especificado.',
'valid_date' => 'El campo {field} debe contener una fecha válida con el formato {param}.',
'valid_email' => 'El campo {field} debe contener una dirección de correo electrónico válida.',
'valid_emails' => 'Todos los valores del campo {field} deben ser direcciones de correo electrónico válidas.',
'valid_ip' => 'El campo {field} debe contener una dirección IP válida del tipo {param}.',
'valid_json' => 'El campo {field} debe contener una cadena JSON válida.',
'valid_url' => 'El campo {field} debe contener una URL válida.',
'valid_url_strict' => 'El campo {field} debe contener una URL válida con el esquema: {param}.',
];

View File

@ -0,0 +1,123 @@
<?php
namespace App\Models\Configuracion;
use App\Entities\Configuracion\ImposicionEsquemaEntity;
use CodeIgniter\Model;
class ImposicionEsquemaModel extends Model
{
protected $table = 'imposicion_esquemas';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = ImposicionEsquemaEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
protected $allowedFields = [
"name",
"rows",
"columns",
"orientacion",
"rotativa",
"cosido",
"svg_schema"
];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $castHandlers = [];
// Dates
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [
"name" => [
"label" => "Imposiciones.esquema.name",
"rules" => "required|alpha_numeric_punct",
],
"rows" => [
"label" => "Imposiciones.esquema.rows",
"rules" => "required|integer"
],
"columns" => [
"label" => "Imposiciones.esquema.columns",
"rules" => "required|integer"
],
"orientacion" => [
"label" => "Imposiciones.esquema.orientacion",
"rules" => "required|in_list[V,H]"
],
];
protected $validationMessages = [
"name" => [
"required" => "Validation.required",
],
"rows" => [
"required" => "Validation.required",
"integer" => "Validation.integer",
],
"columns" => [
"required" => "Validation.required",
"integer" => "Validation.integer",
],
"orientacion" => [
"required" => "Validation.required",
"in_list" => "Validation.in_liust",
],
];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function querySelect(?string $q)
{
$query = $this->builder()->select([
"id",
"name",
"svg_schema as description"
]);
if ($q) {
$query->orLike("name", $q);
}
return $query
->orderBy('id', 'ASC')
->get()->getResultArray();
}
public function queryDatatable()
{
return $this->builder()
->select([
"id",
"name",
"svg_schema"
])->where('deleted_at', null);
}
public static function datatable_buttons(int $id)
{
$btn = "";
if (auth()->user()->inGroup("admin")) {
$btn .= "<a type='button' href='/imposiciones/esquema/edit/{$id}' data-id='{$id}'><i class='ti ti-eye ti-sm'></i></a>";
$btn .= "<a type='button'><i class='ti ti-trash ti-sm imposicion-esquema-delete' data-id='{$id}'></i></a>";
}
return $btn;
}
}

View File

@ -2,7 +2,10 @@
namespace App\Models\Configuracion; namespace App\Models\Configuracion;
class ImposicionModel extends \App\Models\BaseModel use App\Entities\Configuracion\Imposicion;
use App\Models\BaseModel;
class ImposicionModel extends BaseModel
{ {
protected $table = "lg_imposiciones"; protected $table = "lg_imposiciones";
@ -23,8 +26,8 @@ class ImposicionModel extends \App\Models\BaseModel
7 => "t1.etiqueta", 7 => "t1.etiqueta",
]; ];
protected $allowedFields = ["ancho", "alto", "unidades", "orientacion", "maquina", "etiqueta"]; protected $allowedFields = ["ancho", "alto", "unidades", "orientacion", "maquina", "etiqueta","imposicion_esquema_id"];
protected $returnType = "App\Entities\Configuracion\Imposicion"; protected $returnType = Imposicion::class;
public static $labelField = "ancho"; public static $labelField = "ancho";
@ -53,6 +56,10 @@ class ImposicionModel extends \App\Models\BaseModel
"label" => "Imposiciones.unidades", "label" => "Imposiciones.unidades",
"rules" => "integer|permit_empty", "rules" => "integer|permit_empty",
], ],
"imposicion_esquema_id" => [
"label" => "Imposiciones.imposicion_esquema",
"rules" => "integer|permit_empty",
],
]; ];
protected $validationMessages = [ protected $validationMessages = [
@ -76,6 +83,9 @@ class ImposicionModel extends \App\Models\BaseModel
"unidades" => [ "unidades" => [
"integer" => "Imposiciones.validation.unidades.integer", "integer" => "Imposiciones.validation.unidades.integer",
], ],
"imposicion_esquema_id" => [
"integer" => "Imposiciones.validation.unidades.integer",
],
]; ];
/** /**
@ -129,4 +139,26 @@ class ImposicionModel extends \App\Models\BaseModel
->orderBy('id', 'ASC') ->orderBy('id', 'ASC')
->get()->getResultArray(); ->get()->getResultArray();
} }
public function queryDatatable()
{
return $this->builder()
->select([
"id",
"ancho",
"alto",
"unidades",
"maquina",
"orientacion",
"etiqueta"
])->where('deleted_at', null);
}
public static function datatable_buttons(int $id)
{
$btn = "";
if(auth()->user()->inGroup("admin")){
$btn.="<a type='button' href='/imposiciones/edit/{$id}' data-id='{$id}'><i class='ti ti-eye ti-sm'></i></a>";
$btn.="<a type='button'><i class='ti ti-trash ti-sm imposicion-delete' data-id='{$id}'></i></a>";
}
return $btn;
}
} }

View File

@ -0,0 +1,20 @@
<!-- Modal -->
<div class="modal fade" id="modalNewImposicion" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalTitleNew"><?= lang('Imposiciones.btnNewImposicion') ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form class="mb-3 section-block" id="form-imposicion" method="post">
<div class="modal-body">
<?= view("themes/vuexy/form/configuracion/imposiciones/_imposicionFormItems") ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-label-secondary" data-bs-dismiss="modal"><?= lang('App.global_come_back') ?></button>
<button type="button" id="btnSubmitNewImposicion" class="btn btn-primary float-end"><?= lang("Basic.global.Save") ?></button>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,12 @@
<table id="imposicion-esquema-table" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Imposiciones.id') ?></th>
<th><?= lang('Imposiciones.esquema.name') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>

View File

@ -0,0 +1,64 @@
<div class="row">
<div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="unidades" class="form-label">
<?= lang('Imposiciones.esquema.name') ?>
</label>
<input type="text" name="name" maxlength="255" class="form-control" data-input>
</div><!--//.mb-3 -->
<div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="orientacion" class="form-label">
<?= lang('Imposiciones.orientacion') ?>
</label>
<select id="esquema-orientacion" class="form-control" name="orientacion" data-input>
<option value="H" default><?= lang("Imposiciones.H") ?></option>
<option value="V"><?= lang("Imposiciones.V") ?></option>
</select>
</div>
<div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="esquema-rows"class="form-label">
<?= lang('Imposiciones.esquema.rows') ?>
</label>
<input type="number" id="esquema-rows" name="rows" max="5" value="1" class="form-control" data-input>
</div><!--//.mb-3 -->
<div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="esquema-columns" class="form-label">
<?= lang('Imposiciones.esquema.columns') ?>
</label>
<input type="number" id="esquema-columns" name="columns" max="5" class="form-control" value="1" data-input>
</div><!--//.mb-3 -->
<div class="col-lg-2 col-md-2 col-xs-12 mb-3">
<div class="d-flex flex-column gap-2">
<label class="switch switch-md">
<input type="checkbox" class="switch-input" id="esquema-rotativa" name="rotativa" data-input/>
<span class="switch-toggle-slider">
<span class="switch-on">
<i class="ti ti-check"></i>
</span>
<span class="switch-off">
<i class="ti ti-x"></i>
</span>
</span>
<span class="switch-label">Rotativa</span>
</label>
<label class="switch switch-md">
<input type="checkbox" class="switch-input" id="esquema-cosido" name="cosido" data-input/>
<span class="switch-toggle-slider">
<span class="switch-on">
<i class="ti ti-check"></i>
</span>
<span class="switch-off">
<i class="ti ti-x"></i>
</span>
</span>
<span class="switch-label">Cosido/Grapado</span>
</label>
</div>
</div><!--//.mb-3 -->
<div class="col-md-12 mt-3">
<div class="d-flex justify-content-center w-100 h-100 text-center">
<div id="imposicion-esquema-drawing" class="px-2 py-2"></div>
</div>
</div><!--//.mb-3 -->
</div><!-- //.row -->

View File

@ -1,64 +1,64 @@
<div class="row"> <div class="row">
<div class="col-md-12 col-lg-6 px-4"> <div class="col-lg-6 col-md-6 col-xs-12 mb-3">
<div class="mb-3"> <label for="ancho" class="form-label">
<label for="ancho" class="form-label"> <?= lang('Imposiciones.ancho') ?>
<?=lang('Imposiciones.ancho') ?>* </label>
</label> <input type="number" name="ancho" maxLength="11" class="form-control" data-input>
<input type="number" id="ancho" name="ancho" required maxLength="11" class="form-control" value="<?=old('ancho', $imposicion->ancho) ?>"> </div><!--//.mb-3 -->
</div><!--//.mb-3 -->
<div class="mb-3"> <div class="col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="alto" class="form-label"> <label for="alto" class="form-label">
<?=lang('Imposiciones.alto') ?>* <?= lang('Imposiciones.alto') ?>
</label> </label>
<input type="number" id="alto" name="alto" required maxLength="11" class="form-control" value="<?=old('alto', $imposicion->alto) ?>"> <input type="number" name="alto" maxLength="11" class="form-control" data-input>
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
<div class="mb-3"> <div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="unidades" class="form-label"> <label for="unidades" class="form-label">
<?=lang('Imposiciones.unidades') ?> <?= lang('Imposiciones.unidades') ?>
</label> </label>
<input type="number" id="unidades" name="unidades" maxLength="11" class="form-control" value="<?=old('unidades', $imposicion->unidades) ?>"> <input type="number" id="unidades" name="unidades" maxLength="11" class="form-control" data-input>
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
<div class="col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="unidades" class="form-label">
<?= lang('Imposiciones.etiqueta') ?>
</label>
<input type="text" name="etiqueta" maxLength="11" class="form-control" data-input>
</div><!--//.mb-3 -->
<div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="unidades" class="form-label">
<?= lang('Imposiciones.maquina') ?>
</label>
<input type="text" name="maquina" maxLength="11" class="form-control" data-input>
</div><!--//.mb-3 -->
<div class="mb-3"> <div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
<label for="orientacion" class="form-label"> <label for="unidades" class="form-label">
<?=lang('Imposiciones.orientacion') ?> <?= lang('Imposiciones.orientacion') ?>
</label> </label>
<select name="orientacion" class="form-control" data-input>
<div class="form-check"> <option value="H" default><?= lang("Imposiciones.H") ?></option>
<label for="h" class="form-check-label"> <option value="V"><?= lang("Imposiciones.V") ?></option>
<input type="radio" id="h" name="orientacion" value="H" class="form-check-input" <?= $imposicion->orientacion == 'H' ? 'checked' : '' ?>> </select>
<?= lang('Imposiciones.H') ?> </div>
</label> <div class=" col-lg-6 col-md-6 col-xs-12 mb-3">
</div><!--//.form-check --> <label for="unidades" class="form-label">
<?= lang('Imposiciones.imposicion_esquema') ?>
</label>
<div class="form-check"> <select name="imposicion_esquema_id" class="form-control" id="imposicion-esquema-select" data-input>
<label for="v" class="form-check-label"> </select>
<input type="radio" id="v" name="orientacion" value="V" class="form-check-input" <?= $imposicion->orientacion == 'V' ? 'checked' : '' ?>> </div>
<?= lang('Imposiciones.V') ?> <div class="col-lg-6 col-md-6 col-xs-12 mb-3 section-block-esquema">
</label> <div class="d-flex flex-row justify-content-between">
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="maquina" class="form-label">
<?=lang('Imposiciones.maquina') ?>
</label>
<input type="text" id="maquina" name="maquina" maxLength="100" class="form-control" value="<?=old('maquina', $imposicion->maquina) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="etiqueta" class="form-label">
<?=lang('Imposiciones.etiqueta') ?>
</label>
<input type="text" id="etiqueta" name="etiqueta" maxLength="100" class="form-control" value="<?=old('etiqueta', $imposicion->etiqueta) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<label for="imposicion-esquema-render" class="form-label">
<?= lang('Imposiciones.imposicion_esquema_drawing') ?>
</label>
<a href="" target="_blank" class="btn btn-primary btn-sm imposicion-esquema-link" disabled><?= lang("Imposiciones.imposicion_esquema_link") ?></a>
</div>
<div id="imposicion-esquema-render">
<svg width="100%" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
</svg>
</div>
</div>
</div><!-- //.row --> </div><!-- //.row -->

View File

@ -0,0 +1,41 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12 mb-3">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= lang('Imposiciones.imposicion') ?></h3>
</div><!--//.card-header -->
<form class="mb-3 section-block" id="form-imposicion-esquema" method="post" data-id="<?= $imposicion_esquema?->id ?>">
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= view("themes/vuexy/form/configuracion/imposiciones/_imposicionEsquemaFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer mb-3 py-2">
<div class="col-md-12">
<?= anchor(route_to("imposicionList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<button type="button" id="btnSubmitUpdateImposicionEsquema" class="btn btn-primary float-end"><?= lang("Basic.global.Save") ?></button>
</div>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.css") ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/notiflix/notiflix.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/notiflix/notiflix.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/imposiciones/edit_esquema.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -1,26 +1,40 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?> <?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?> <?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?=$this->extend('themes/vuexy/main/defaultlayout') ?> <?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?> <?= $this->section("content") ?>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12 mb-3">
<div class="card card-info"> <div class="card card-info">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3> <h3 class="card-title"><?= lang('Imposiciones.imposicion') ?></h3>
</div><!--//.card-header --> </div><!--//.card-header -->
<form id="imposicionForm" method="post" action="<?= $formAction ?>"> <form class="mb-3 section-block" id="form-imposicion" method="post" data-id="<?= $imposicion->id ?>">
<?= csrf_field() ?> <div class="card-body">
<div class="card-body"> <?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?> <?= view("themes/vuexy/form/configuracion/imposiciones/_imposicionFormItems") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> </div><!-- /.card-body -->
<?= view("themes/vuexy/form/configuracion/imposiciones/_imposicionFormItems") ?> <div class="card-footer mb-3 py-2">
</div><!-- /.card-body --> <div class="col-md-12">
<div class="card-footer"> <?= anchor(route_to("imposicionList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<?= anchor(route_to("imposicionList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?> <button type="button" id="btnSubmitUpdateImposicion" class="btn btn-primary float-end"><?= lang("Basic.global.Save") ?></button>
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>"> </div>
</div><!-- /.card-footer --> </div>
</form> </form>
</div><!-- //.card --> </div><!-- //.card -->
</div><!--//.col --> </div><!--//.col -->
</div><!--//.row --> </div><!--//.row -->
<?= $this->endSection() ?> <?= $this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.css") ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/notiflix/notiflix.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/notiflix/notiflix.js") ?>"></script>
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/imposiciones/edit.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -1,168 +1,83 @@
<?=$this->include('themes/_commonPartialsBs/datatables') ?> <?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?> <?= $this->include('themes/_commonPartialsBs/sweetalert') ?>
<?=$this->extend('themes/vuexy/main/defaultlayout') ?> <?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?> <?= $this->section('content'); ?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="nav-tabs-shadow nav-align-top">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<button type="button" class="nav-link active" role="tab" id="navs-top-align-imposicion-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-imposicion-table"><?= lang("Imposiciones.imposicionList") ?></button>
</li>
<li class="nav-item">
<button type="button" class="nav-link" role="tab" id="navs-top-align-esquema-tab" data-bs-toggle="tab" data-bs-target="#navs-top-align-esquema-table"><?= lang("Imposiciones.imposicion_esquemas") ?></button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="navs-top-align-imposicion-table">
<div class="col-md-12 d-flex justify-content-end">
<?= anchor(route_to('newImposicion'), lang('Imposiciones.btnNewImposicion'), ['class' => 'btn btn-primary float-end', "id" => "btnNewImposicion"]); ?>
</div>
<div class="col-md-12">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfImposiciones" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Imposiciones.id') ?></th>
<th><?= lang('Imposiciones.ancho') ?></th>
<th><?= lang('Imposiciones.alto') ?></th>
<th><?= lang('Imposiciones.unidades') ?></th>
<th><?= lang('Imposiciones.orientacion') ?></th>
<th><?= lang('Imposiciones.maquina') ?></th>
<th><?= lang('Imposiciones.etiqueta') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
<div class="card card-info"> </tbody>
<div class="card-header"> </table>
<h3 class="card-title"><?=lang('Imposiciones.imposicionList') ?></h3>
<?=anchor(route_to('newImposicion'), lang('Basic.global.addNew').' '.lang('Imposiciones.imposicion'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfImposiciones" class="table table-striped table-hover" style="width: 100%;"> </div>
<thead> </div>
<tr> <div class="tab-pane fade show" id="navs-top-align-esquema-table">
<?php // <th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> ?> <div class="col-md-12 d-flex justify-content-end">
<th><?=lang('Imposiciones.id')?></th> <?= anchor(route_to('newImposicionEsquema'), lang('Imposiciones.btnNewImposicionEsquema'), ['class' => 'btn btn-primary float-end', "id" => "btnNewImposicionEsquema"]); ?>
<th><?= lang('Imposiciones.ancho') ?></th> </div>
<th><?= lang('Imposiciones.alto') ?></th> <div class="col-md-12">
<th><?= lang('Imposiciones.unidades') ?></th> <?= view("/themes/vuexy/components/tables/imposicion_esquema_table.php") ?>
<th><?= lang('Imposiciones.orientacion') ?></th> </div>
<th><?= lang('Imposiciones.maquina') ?></th> </div>
<th><?= lang('Imposiciones.etiqueta') ?></th> </div>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> </div><!--//.col -->
</tr> </div><!--//.row -->
</thead>
<tbody>
</tbody> <?= $this->endSection() ?>
</table>
</div><!--//.card-body -->
<div class="card-footer">
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
</div><!--//.row -->
<?=$this->endSection() ?>
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfImposiciones').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<button class="btn btn-sm btn-warning btn-edit me-1" data-id="${data.id}"><?= lang('Basic.global.edit') ?></button>
<button class="btn btn-sm btn-danger btn-delete ms-1" data-id="${data.id}"><?= lang('Basic.global.Delete') ?></button>
</div>
</td>`;
};
theTable = $('#tableOfImposiciones').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfImposiciones') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns : [
//{ 'data': actionBtns },
{ 'data': 'id' },
{ 'data': 'ancho' },
{ 'data': 'alto' },
{ 'data': 'unidades' },
{ 'data': 'orientacion' },
{ 'data': 'maquina' },
{ 'data': 'etiqueta' },
{ 'data': actionBtns }
]
});
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `<?= route_to('imposicionList') ?>/${$(this).attr('data-id')}/edit`;
});
$(document).on('click', '.btn-delete', function(e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Imposiciones.imposicion'))]) ?>',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
cancelButtonColor: '#d33'
})
.then((result) => {
const dataId = $(this).data('id');
const row = $(this).closest('tr');
if (result.value) {
$.ajax({
url: `<?= route_to('imposicionList') ?>/${dataId}`,
method: 'DELETE',
}).done((data, textStatus, jqXHR) => {
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
Toast.fire({
icon: 'error',
title: jqXHR.responseJSON.messages.error,
});
})
}
});
});
<?=$this->endSection() ?>
<?=$this->section('css') ?> <?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.css") ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/notiflix/notiflix.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>"> <link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?=$this->endSection() ?> <?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?> <?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
<?=$this->endSection() ?> <script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/imposiciones/view.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -0,0 +1,40 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12 mb-3">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= lang('Imposiciones.imposicion') ?></h3>
</div><!--//.card-header -->
<form class="mb-3 section-block" id="form-imposicion" method="post">
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= view("themes/vuexy/form/configuracion/imposiciones/_imposicionFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer mb-3 py-2">
<div class="col-md-12">
<?= anchor(route_to("imposicionList"), lang("App.global_come_back"), ["class" => "btn btn-secondary float-start"]) ?>
<button type="button" id="btnSubmitNewImposicion" class="btn btn-primary float-end"><?= lang("Basic.global.Save") ?></button>
</div>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.css") ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/notiflix/notiflix.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/notiflix/notiflix.js") ?>"></script>
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/imposiciones/new.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -70,6 +70,13 @@ if (
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->inGroup('admin')) { ?>
<li class="menu-item">
<a href="<?= route_to("imposicionList") ?>" class="menu-link">
<?= lang("App.menu_imposiciones") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('usuarios.menu')) { ?> <?php if (auth()->user()->can('usuarios.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= route_to('userList') ?>" class="menu-link"> <a href="<?= route_to('userList') ?>" class="menu-link">

View File

@ -33,7 +33,7 @@ $settings = $session->get('settings');
<body> <body>
<div class="col-md-12 pdf-wrapper" data-id="<?= $ot->id."_"."_".$presupuesto->id."_".$presupuesto->titulo ?>"> <div class="col-md-12 pdf-wrapper" data-id="<?= $ot->id . "_" . "_" . $presupuesto->id . "_" . $presupuesto->titulo ?>">
<div class="row"> <div class="row">
<div class="col-12 d-flex justify-content-between align-items-center"> <div class="col-12 d-flex justify-content-between align-items-center">
<h5><?= $presupuesto->titulo ?></h5> <h5><?= $presupuesto->titulo ?></h5>
@ -180,32 +180,10 @@ $settings = $session->get('settings');
</table> </table>
</div> </div>
<div class="col-4"> <div class="col-4">
<div class="col-12 mb-2"> <div class="col-12 d-flex justify-content-center" style="width: 100%">
<div class="esquema-imposicion-wrapper"> <?php if ($imposicion->imposicion_esquema()): ?>
<div class="esquema"> <?= $imposicion->imposicion_esquema()->svg_schema ?>
<div class="pagina-imposicion-outer-start"> <?php endif; ?>
<div class="pagina-imposicion-inner">
A
</div>
</div>
<div class="pagina-imposicion-outer">
<div class="pagina-imposicion-inner">
A
</div>
</div>
<div class="pagina-imposicion-outer">
<div class="pagina-imposicion-inner">
A
</div>
</div>
<div class="pagina-imposicion-outer-end">
<div class="pagina-imposicion-inner">
A
</div>
</div>
</div>
</div>
</div> </div>
<div class="col-12"> <div class="col-12">
<div class="imposicion"> <div class="imposicion">

View File

@ -0,0 +1,66 @@
class ImposicionDatatable {
constructor(domItem) {
this.item = domItem
this.datatableColumns = [
{ data: 'id', searchable: true, sortable: true },
{ data: 'ancho', searchable: true, sortable: true },
{ data: 'alto', searchable: true, sortable: true },
{ data: 'unidades', searchable: true, sortable: true },
{ data: 'orientacion', searchable: true, sortable: true },
{ data: 'maquina', searchable: true, sortable: true },
{ data: 'etiqueta', searchable: true, sortable: true },
{ data: 'action', searchable: true, sortable: true },
]
this.datatableEsquemaColumns = [
{ data: 'name', searchable: true, sortable: true },
{ data: 'action', searchable: true, sortable: true },
]
}
init() {
this.datatable = this.item.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
columnDefs: [
{ className: 'dt-center', targets: '_all' },
],
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/imposiciones/datatable',
});
}
initEsquema() {
this.datatableEsquema = this.item.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
columnDefs: [
{ className: 'dt-center', targets: '_all' },
],
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableEsquemaColumns,
ajax: '/imposiciones/esquema/datatable',
});
}
}
export default ImposicionDatatable;

View File

@ -0,0 +1,35 @@
class ImposicionEsquemaDatatable {
constructor(domItem) {
this.item = domItem
this.datatableColumns = [
{ data: 'id', searchable: false, sortable: true },
{ data: 'name', searchable: true, sortable: true },
{ data: 'action', searchable: true, sortable: true },
]
}
init() {
this.datatable = this.item.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/imposiciones/esquema/datatable',
});
}
}
export default ImposicionEsquemaDatatable;

View File

@ -0,0 +1,179 @@
import Ajax from '../ajax.js'
import ImposicionEsquemaDrawing from '../imposicionEsquemaDrawing.js';
class ImposicionEsquemaForm {
constructor(domItem) {
this.item = domItem
this.drawing = new ImposicionEsquemaDrawing($("#imposicion-esquema-drawing"))
this.modelId = this.item.data("id");
this.btnSubmitUpdateImposicion = this.item.find("#btnSubmitUpdateImposicionEsquema")
this.btnSubmitNewImposicion = this.item.find("#btnSubmitNewImposicionEsquema")
this.initialData = {
"name": null,
"rows": null,
"columns": null,
"rotativa": null,
"orientacion": null,
"cosido": null,
"svg_schema": null,
}
this.formData = this.initialData
}
load(status = false) {
if (status) {
Notiflix.Block.circle('.section-block');
} else {
Notiflix.Block.remove('.section-block');
}
}
init() {
this.item.on("change", "#esquema-rows", (event) => {
let rows = $(event.currentTarget).val()
this.drawing.setRows(rows)
})
this.item.on("change", "#esquema-rotativa", (event) => {
let rotativa = $(event.currentTarget).prop("checked")
this.drawing.setRotativa(rotativa)
})
this.item.on("change", "#esquema-cosido", (event) => {
let cosido = $(event.currentTarget).prop("checked")
this.drawing.setCosido(cosido)
})
this.item.on("change", "#esquema-orientacion", (event) => {
let orientation = $(event.currentTarget).val()
this.drawing.setOrientation(orientation)
})
this.item.on("change", "#esquema-columns", (event) => {
let columns = $(event.currentTarget).val()
this.drawing.setColumns(columns)
})
if (this.modelId) {
this.btnSubmitUpdateImposicion.on("click", this.handleUpdate.bind(this))
this.handleGetData()
} else {
this.initNew()
}
}
initNew() {
this.btnSubmitUpdateImposicion.on("click", this.handleNew.bind(this))
}
handleGetData() {
this.load(true)
let ajax = new Ajax(`/imposiciones/esquema/find/${this.modelId}`, null, null, this.handleGetDataSuccess.bind(this), this.handleGetDataError.bind(this))
if (this.modelId) {
ajax.get()
} else {
this.load(false)
}
}
getFormData() {
let data = {}
this.item.serializeArray().forEach((e) => {
let input = this.item.find(`input[name=${e.name}]`)
if (input) {
if (input.attr("type") != "checkbox") {
data[e.name] = e.value
}
}
}
)
this.formData = data
this.formData["svg_schema"] = this.drawing.getSVG()
this.formData["rotativa"] = this.drawing.rotativa == true ? 1 : 0;
this.formData["cosido"] = this.drawing.cosido == true ? 1 : 0;
return this.formData
}
setFormData(data) {
this.drawing.rows = data.rows
this.drawing.columns = data.columns
this.drawing.rotativa = data.rotativa
this.drawing.cosido = data.cosido
this.drawing.drawSchema()
Object.entries(data).forEach(([key, value], index) => {
let input = this.item.find(`input[name=${key}]`)
if (input) {
if (input.attr("type") == "checkbox") {
this.item.find(`input[name=${key}]`).prop("checked", value)
} else {
this.item.find(`input[name=${key}]`).val(value)
}
}
this.item.find(`select[name=${key}]`).val(value)
})
}
disable() {
Object.entries(this.initialData).forEach(([key, value], index) => {
this.item.find(`input[name=${key}]`).prop("disabled", "disabled")
this.item.find(`select[name=${key}]`).prop("disabled", "disabled")
})
}
handleGetDataSuccess(response) {
this.setFormData(response)
this.load(false)
}
handleGetDataError() { }
handleNew() {
this.load(true)
let ajax = new Ajax(`/imposiciones/esquema/create`, this.getFormData(), null, this.postSuccessNew.bind(this), this.postErrorNew.bind(this))
ajax.post()
}
handleUpdate() {
this.load(true)
let ajax = new Ajax(`/imposiciones/esquema/${this.modelId}`, this.getFormData(), null, this.postSuccess.bind(this), this.postError.bind(this))
ajax.post()
}
handleDelete(id) {
let ajax = new Ajax(`/imposiciones/esquema/${id}`, null, null, this.deleteSuccess.bind(this), this.deleteError.bind(this))
ajax.delete()
}
deleteSuccess(response) {
popSuccessAlert(response.message)
}
deleteError(error) {
popErrorAlert(error.responseJSON.message)
}
postSuccess(response) {
this.load(false)
this.setFormData(response.data)
popSuccessAlert(response.message)
}
postError(error) {
this.load(false)
popErrorAlert(error.responseJSON.message)
this.validationErrors(error.responseJSON.errors)
}
postSuccessNew(response) {
this.load(false)
this.disable()
this.item.find(".invalid-feedback").remove()
this.btnSubmitNewImposicion.addClass("d-none")
popSuccessAlert(response.message)
}
postErrorNew(error) {
this.load(false)
this.validationErrors(error.responseJSON.errors)
popErrorAlert(error.responseJSON.message)
}
validationErrors(errors) {
this.item.find(".invalid-feedback").remove()
Object.entries(errors).forEach(([key, value], index) => {
let el = this.item.find(`input[name=${key}]`)
this.addError(el, value)
})
}
addError(el, error) {
el.addClass("is-invalid")
el.parent().append(`<div class="invalid-feedback">${error}</div>`)
}
}
export default ImposicionEsquemaForm;

View File

@ -0,0 +1,195 @@
import Ajax from '../ajax.js'
import ClassSelect from '../select2.js'
class ImposicionForm {
constructor(domItem) {
this.item = domItem
this.modelId = this.item.data("id");
this.btnSubmitUpdateImposicion = this.item.find("#btnSubmitUpdateImposicion")
this.btnSubmitNewImposicion = this.item.find("#btnSubmitNewImposicion")
this.selectImposicionEsquemaItem = this.item.find("#imposicion-esquema-select")
this.renderSchemaDiv = this.item.find("#imposicion-esquema-render");
this.schemaLink = this.item.find(".imposicion-esquema-link")
this.selectImposicionEsquema = new ClassSelect(this.selectImposicionEsquemaItem, '/imposiciones/esquema/select', 'Seleccione un esquema', true)
this.imposicionEsquemaData = {}
this.initialData = {
"ancho": null,
"alto": null,
"unidades": null,
"etiqueta": null,
"maquina": null,
"orientacion": null
}
this.formData = this.initialData
}
initSelectImposicionEsquema() {
this.selectImposicionEsquema.init()
this.selectImposicionEsquema.onChange(this.handleGetImposicionEsquema.bind(this))
}
resize() {
let w = this.renderSchemaDiv.width()
let h = this.renderSchemaDiv.height()
let svgX = this.renderSchemaDiv.find("svg").width()
this.renderSchemaDiv.find("svg").attr("width", w)
this.renderSchemaDiv.find("svg").attr("height", h)
this.renderSchemaDiv.find("svg").attr('viewBox', `0 0 ${svgX} ${h + 100}`);
}
load(status = false) {
if (status) {
Notiflix.Block.circle('.section-block');
} else {
Notiflix.Block.remove('.section-block');
}
}
loadSchema(status = false) {
if (status) {
Notiflix.Block.circle('.section-block-esquema');
} else {
Notiflix.Block.remove('.section-block-esquema');
}
}
init() {
this.btnSubmitUpdateImposicion.on("click", this.handleUpdate.bind(this))
this.handleGetData()
this.initSelectImposicionEsquema()
this.schemaLink.attr("disabled", "disabled")
$(window).on("resize", this.resize.bind(this))
}
initNew() {
this.btnSubmitNewImposicion.on("click", this.handleNew.bind(this))
this.initSelectImposicionEsquema()
this.schemaLink.attr("disabled", "disabled")
$(window).on("resize", this.resize.bind(this))
}
handleGetImposicionEsquema() {
this.loadSchema(true)
let imposicion_esquema_id = this.selectImposicionEsquema.getVal()
let ajax = new Ajax(`/imposiciones/esquema/find/${imposicion_esquema_id}`, null, null, this.handleGetImposicionEsquemaSuccess.bind(this), this.handleGetDataError.bind(this))
if (imposicion_esquema_id) {
ajax.get()
} else {
this.loadSchema(false)
this.renderSchemaDiv.find("svg").empty()
}
}
handleGetImposicionEsquemaSuccess(response) {
this.renderSchemaDiv.empty()
this.imposicionEsquemaData = response
this.renderSchemaDiv.append(response.svg_schema)
let svgX = this.renderSchemaDiv.width()
let svgY = this.renderSchemaDiv.height()
this.schemaLink.removeAttr("disabled")
this.schemaLink.attr("href", `/imposiciones/esquema/edit/${response.id}`)
this.renderSchemaDiv.find("svg").attr('viewBox', `0 0 ${svgX} ${svgY}`);
this.resize()
this.loadSchema(false)
}
handleGetImposicionEsquemaError(error) {
this.loadSchema(false)
}
handleGetData() {
this.load(true)
let ajax = new Ajax(`/imposiciones/find/${this.modelId}`, null, null, this.handleGetDataSuccess.bind(this), this.handleGetDataError.bind(this))
ajax.get()
}
getFormData() {
let data = {}
this.item.serializeArray().forEach((e) => {
data[e.name] = e.value
}
)
this.formData = data
return this.formData
}
setFormData(data) {
Object.entries(data).forEach(([key, value], index) => {
this.item.find(`input[name=${key}]`).val(value)
this.item.find(`select[name=${key}]`).val(value)
if (key == "imposicion_esquema" && value) {
this.selectImposicionEsquema.setOption(value.id, value.name)
this.schemaLink.removeAttr("disabled")
this.schemaLink.attr("href", `/imposiciones/esquema/edit/${value.id}`)
}
})
}
disable() {
Object.entries(this.initialData).forEach(([key, value], index) => {
this.item.find(`input[name=${key}]`).prop("disabled", "disabled")
this.item.find(`select[name=${key}]`).prop("disabled", "disabled")
})
}
handleGetDataSuccess(response) {
this.setFormData(response)
this.load(false)
}
handleGetDataError() { }
handleNew() {
this.load(true)
let ajax = new Ajax(`/imposiciones/create`, this.getFormData(), null, this.postSuccessNew.bind(this), this.postErrorNew.bind(this))
ajax.post()
}
handleUpdate() {
this.load(true)
let ajax = new Ajax(`/imposiciones/${this.modelId}`, this.getFormData(), null, this.postSuccess.bind(this), this.postError.bind(this))
ajax.post()
}
handleDelete(id) {
let ajax = new Ajax(`/imposiciones/${id}`, null, null, this.deleteSuccess.bind(this), this.deleteError.bind(this))
ajax.delete()
}
deleteSuccess(response) {
popSuccessAlert(response.message)
}
deleteError(error) {
popErrorAlert(error.responseJSON.message)
}
postSuccess(response) {
this.load(false)
this.setFormData(response.data)
popSuccessAlert(response.message)
}
postError(error) {
this.load(false)
popErrorAlert(error.responseJSON.message)
this.validationErrors(error.responseJSON.errors)
}
postSuccessNew(response) {
this.load(false)
this.disable()
this.item.find(".invalid-feedback").remove()
this.btnSubmitNewImposicion.addClass("d-none")
popSuccessAlert(response.message)
}
postErrorNew(error) {
this.load(false)
this.validationErrors(error.responseJSON.errors)
popErrorAlert(error.responseJSON.message)
}
validationErrors(errors) {
this.item.find(".invalid-feedback").remove()
Object.entries(errors).forEach(([key, value], index) => {
let el = this.item.find(`input[name=${key}]`)
this.addError(el, value)
})
}
addError(el, error) {
el.addClass("is-invalid")
el.parent().append(`<div class="invalid-feedback">${error}</div>`)
}
}
export default ImposicionForm;

View File

@ -0,0 +1,164 @@
class ImposicionEsquemaDrawing {
constructor(domItem) {
this.item = domItem;
this.params = { fitted: true }
this.rectangleDimensions = {
width: 50,
height: 100,
}
this.rectangleCosidoDimensions = {
width: 50*2,
height: 100,
}
this.offsetX = this.rectangleDimensions.width + 20
this.offsetY = this.rectangleDimensions.height + 20
this.offsetCosidoX = this.rectangleCosidoDimensions.width + 20
this.offsetCosidoY = this.rectangleCosidoDimensions.height + 20
this.dw = new Two(this.params).appendTo(this.item[0])
this.rows = 1
this.columns = 1
this.rotativa = false
this.cosido = false
this.drawingShapes = []
this.textShapes = []
this.vectorShapes = []
this.orientation = "H"
this.drawSchema()
}
setMatrix(rows, columns) {
this.rows = rows
this.columns = columns
}
setOrientation(orientation) {
this.orientation = orientation
this.drawSchema()
}
setRotativa(rotativa) {
this.rotativa = rotativa
this.drawSchema()
}
setCosido(rotativa) {
this.cosido = rotativa
this.drawSchema()
}
setRows(rows) {
this.rows = rows
this.drawSchema()
}
setColumns(columns) {
this.columns = columns
this.drawSchema()
}
init() {
}
cutPaperForm() {
this.textShapes.forEach((element, index) => {
element.scale = new Two.Vector(1, -1)
})
}
mirror(element) {
if (this.rotativa == false) {
element.scale = new Two.Vector(1, -1)
}
}
remove() {
this.drawingShapes.forEach(element => {
element.remove()
});
this.textShapes.forEach(element => {
element.remove()
});
this.vectorShapes.forEach(element => {
element.remove()
});
}
drawRows(y = 0) {
for (let index = 0; index < this.columns; index++) {
let rectangle = this.dw.makeRectangle(this.rectangleDimensions.width / 2 + this.offsetX * index, this.rectangleDimensions.height / 2 + y, this.rectangleDimensions.width, this.rectangleDimensions.height)
let text = this.dw.makeText("A", this.rectangleDimensions.width / 2 + this.offsetX * index, this.rectangleDimensions.height / 2 + y)
if ((index + 1) % 2) {
this.mirror(text)
}
this.textShapes.push(text)
this.drawingShapes.push(rectangle)
}
}
drawRowsCosido(y = 0) {
for (let index = 0; index < this.columns; index++) {
let rectangle = this.dw.makeRectangle(this.rectangleCosidoDimensions.width/2 + this.offsetCosidoX * index , this.rectangleCosidoDimensions.height /2 + y, this.rectangleCosidoDimensions.width, this.rectangleCosidoDimensions.height)
let textA = this.dw.makeText("N", this.rectangleCosidoDimensions.width/4 + this.offsetCosidoX * index, this.rectangleCosidoDimensions.height /2 + y)
let textB = this.dw.makeText("1", this.rectangleCosidoDimensions.width*3/4 + this.offsetCosidoX * index, this.rectangleCosidoDimensions.height /2 + y)
let line = this.dw.makeLine(rectangle.position.x,y,rectangle.position.x,this.rectangleCosidoDimensions.height + y)
this.textShapes.push(textA)
this.textShapes.push(textB)
this.drawingShapes.push(rectangle)
this.drawingShapes.push(line)
}
}
drawOrientation() {
let vector;
if (this.orientation == "H") {
vector = this.dw.makeArrow(0, (this.offsetY) * this.rows, (this.offsetX) * (this.columns), (this.offsetY) * this.rows)
this.dw.renderer.setSize((this.offsetX) * this.columns, (this.offsetY) * this.rows)
let width = (this.offsetX) * this.columns * 1.1
let height = (this.offsetY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
} else {
vector = this.dw.makeArrow((this.offsetX) * this.columns, 0, (this.offsetX) * this.columns, (this.offsetY) * this.rows)
this.dw.renderer.setSize((this.offsetX) * this.columns, (this.offsetY) * this.rows)
let width = (this.offsetX) * this.columns * 1.1
let height = (this.offsetY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
}
vector.linewidth = "3px"
this.vectorShapes.push(vector)
}
drawOrientationCosido() {
let vector;
if (this.orientation == "H") {
vector = this.dw.makeArrow(-this.rectangleDimensions.width/2, (this.offsetCosidoY) * this.rows, (this.offsetCosidoX) * (this.columns), (this.offsetCosidoY) * this.rows)
this.dw.renderer.setSize((this.offsetCosidoX) * this.columns, (this.offsetCosidoY) * this.rows)
let width = (this.offsetCosidoX) * this.columns*1.1
let height = (this.offsetCosidoY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
} else {
vector = this.dw.makeArrow((this.offsetCosidoX) * this.columns, 0, (this.offsetCosidoX) * this.columns, (this.offsetCosidoY) * this.rows)
this.dw.renderer.setSize((this.offsetCosidoX) * this.columns, (this.offsetCosidoY) * this.rows)
let width = (this.offsetX) * this.columns * 1.1
let height = (this.offsetY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
}
vector.linewidth = "3px"
this.vectorShapes.push(vector)
}
drawSchema() {
this.remove();
for (let index = 0; index < this.rows; index++) {
if(this.cosido){
this.drawRowsCosido(this.offsetY * index)
}else{
this.drawRows(this.offsetY * index)
}
}
if(this.cosido){
this.drawOrientationCosido()
}else{
this.drawOrientation()
}
this.dw.update()
}
getSVG() {
return this.dw.renderer.domElement.outerHTML
}
}
export default ImposicionEsquemaDrawing

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion")
let imposicion = new Imposicion()
imposicion.edit()
})

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion Esquema")
let imposicion = new Imposicion()
imposicion.init_imposicion_esquema_form()
})

View File

@ -0,0 +1,56 @@
import { alertConfirmationDelete } from "../../../components/alerts/sweetAlert.js"
import ImposicionDatatable from "../../../components/datatables/ImposicionDatatable.js"
import ImposicionEsquemaDatatable from "../../../components/datatables/ImposicionEsquemaDatatable.js"
import ImposicionEsquemaForm from "../../../components/forms/ImposicionEsquemaForm.js"
import ImposicionForm from "../../../components/forms/ImposicionForm.js"
class Imposicion {
constructor() {
this.itemTable = $("#tableOfImposiciones")
this.itemEsquemaTable = $("#imposicion-esquema-table")
this.itemForm = $("#form-imposicion")
this.itemEsquemaForm = $("#form-imposicion-esquema")
this.imposicionDatatable = new ImposicionDatatable(this.itemTable)
this.imposicionEsquemaDatatable = new ImposicionEsquemaDatatable(this.itemEsquemaTable)
}
view() {
this.imposicionDatatable.init()
this.imposicionEsquemaDatatable.init()
this.itemTable.on("click", ".imposicion-delete", this.deleteRow.bind(this))
this.itemEsquemaTable.on("click", ".imposicion-esquema-delete", this.deleteEsquemaRow.bind(this))
}
edit() {
this.imposicionForm = new ImposicionForm(this.itemForm)
this.imposicionForm.init()
}
new() {
this.imposicionForm.initNew()
}
init_imposicion_esquema_form() {
this.imposicionEsquemaForm = new ImposicionEsquemaForm(this.itemEsquemaForm)
this.imposicionEsquemaForm.init()
}
deleteRow(event) {
let modelId = $(event.currentTarget).data("id")
alertConfirmationDelete().then((result) => {
if (result.isConfirmed) {
this.imposicionForm.handleDelete(modelId)
this.imposicionDatatable.datatable.ajax.reload()
}
})
}
deleteEsquemaRow(event) {
let modelId = $(event.currentTarget).data("id")
alertConfirmationDelete().then((result) => {
if (result.isConfirmed) {
this.imposicionEsquemaForm.handleDelete(modelId)
this.imposicionEsquemaDatatable.datatableEsquema.ajax.reload()
}
})
}
}
export default Imposicion

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion")
let imposicion = new Imposicion()
imposicion.new()
})

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion")
let imposicion = new Imposicion()
imposicion.view()
})

View File

@ -6,6 +6,6 @@ $(() => {
html2canvas: { scale: 4 }, html2canvas: { scale: 4 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
}; };
let elementToPdf = $('body')[0] let elementToPdf = $('body')[0]
html2pdf().set(opt).from(elementToPdf).save() html2pdf().set(opt).from(elementToPdf).save()
}) })

View File

@ -43,10 +43,7 @@ body{
} }
.esquema{ .esquema{
display: flex;
justify-content:center;
width: 100%;
justify-items: center;
} }
.pagina-imposicion-outer-start{ .pagina-imposicion-outer-start{
@ -89,10 +86,7 @@ body{
} }
.esquema-imposicion-wrapper{ .esquema-imposicion-wrapper{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
} }
.imposicion{ .imposicion{
display: flex; display: flex;