Skip to content
Merged
4 changes: 2 additions & 2 deletions Controller/EditNotaProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public function getPageData(): array
protected function loadData($viewName, $view)
{
switch ($viewName) {
case $this->getMainViewName():
case $this->mainTabName():
parent::loadData($viewName, $view);
if (false === $view->model->getProject()->userCanSee($this->user)) {
$this->setTemplate('Error/AccessDenied');
}

if (empty($view->model->idtarea)) {
$this->views[$viewName]->disableColumn('task');
$this->tab($viewName)->disableColumn('task');
}
break;
}
Expand Down
66 changes: 33 additions & 33 deletions Controller/EditProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function addCommonSalesPurchases(string $viewName, string $modelName):
$this->listView($viewName)->disableColumn('project');

// añadimos botón para enlazar documentos
$this->addButton($viewName, [
$this->tab($viewName)->addButton([
'type' => 'modal',
'action' => 'link-up-' . $modelName,
'icon' => 'fa-solid fa-link',
Expand Down Expand Up @@ -217,7 +217,7 @@ protected function createViews()

// disable company column if there is only one company
if ($this->empresa->count() < 2) {
$this->views[$this->getMainViewName()]->disableColumn('company');
$this->tab($this->mainTabName())->disableColumn('company');
}

$this->createViewsTasks();
Expand Down Expand Up @@ -436,7 +436,7 @@ protected function createViewsNotes(string $viewName = 'ListNotaProyecto'): void
->addSearchFields(['descripcion']);

$status = $this->codeModel->all('tareas', 'idtarea', 'nombre');
$this->views[$viewName]->addFilterSelect('idtarea', 'task', 'idtarea', $status);
$this->listView($viewName)->addFilterSelect('idtarea', 'task', 'idtarea', $status);
}

protected function createViewsServices(string $viewName = 'ListServicioAT'): void
Expand All @@ -453,22 +453,22 @@ protected function createViewsServices(string $viewName = 'ListServicioAT'): voi
->addSearchFields(['descripcion', 'idservicio', 'material', 'observaciones', 'solucion']);

// filters
$this->views[$viewName]->addFilterPeriod('fecha', 'date', 'fecha')
$this->listView($viewName)->addFilterPeriod('fecha', 'date', 'fecha')
->addFilterAutocomplete('codcliente', 'customer', 'codcliente', 'clientes', 'codcliente', 'nombre');

$priority = $this->codeModel->all('serviciosat_prioridades', 'id', 'nombre');
$this->views[$viewName]->addFilterSelect('idprioridad', 'priority', 'idprioridad', $priority);
$this->listView($viewName)->addFilterSelect('idprioridad', 'priority', 'idprioridad', $priority);

$status = $this->codeModel->all('serviciosat_estados', 'id', 'nombre');
$this->views[$viewName]->addFilterSelect('idestado', 'status', 'idestado', $status);
$this->listView($viewName)->addFilterSelect('idestado', 'status', 'idestado', $status);

$users = $this->codeModel->all('users', 'nick', 'nick');
$this->views[$viewName]->addFilterSelect('nick', 'user', 'nick', $users);
$this->listView($viewName)->addFilterSelect('nick', 'user', 'nick', $users);

$agents = $this->codeModel->all('agentes', 'codagente', 'nombre');
$this->views[$viewName]->addFilterSelect('codagente', 'agent', 'codagente', $agents);
$this->listView($viewName)->addFilterSelect('codagente', 'agent', 'codagente', $agents);

$this->views[$viewName]->addFilterNumber('netogt', 'net', 'neto', '>=')
$this->listView($viewName)->addFilterNumber('netogt', 'net', 'neto', '>=')
->addFilterNumber('netolt', 'net', 'neto', '<=');

// asignamos colores
Expand All @@ -478,7 +478,7 @@ protected function createViewsServices(string $viewName = 'ListServicioAT'): voi
continue;
}

$this->views[$viewName]->getRow('status')->options[] = [
$this->listView($viewName)->getRow('status')->options[] = [
'tag' => 'option',
'children' => [],
'color' => $estado->color,
Expand Down Expand Up @@ -507,21 +507,21 @@ protected function createViewsStock(string $viewName = 'ListStockProyecto'): voi
->addOrderBy(['pterecibir'], 'pending-reception');

// filters
$this->views[$viewName]->addFilterNumber('cantidad', 'quantity', 'cantidad')
$this->listView($viewName)->addFilterNumber('cantidad', 'quantity', 'cantidad')
->addFilterNumber('reservada', 'reserved', 'reservada')
->addFilterNumber('pterecibir', 'pending-reception', 'pterecibir')
->addFilterNumber('disponible', 'available', 'disponible');

// disable column
$this->views[$viewName]->disableColumn('project');
$this->listView($viewName)->disableColumn('project');

// disable buttons
$this->setSettings($viewName, 'btnDelete', false);
$this->setSettings($viewName, 'btnNew', false);
$this->setSettings($viewName, 'checkBoxes', false);

if ($this->user->admin) {
$this->addButton($viewName, [
$this->tab($viewName)->addButton([
'action' => 'rebuild-stock',
'color' => 'warning',
'confirm' => true,
Expand All @@ -542,32 +542,32 @@ protected function createViewsTasks(string $viewName = 'ListTareaProyecto'): voi
->addSearchFields(['descripcion', 'nombre']);

// filters
$this->views[$viewName]->addFilterPeriod('fecha', 'start-date', 'fecha');
$this->views[$viewName]->addFilterPeriod('fechafin', 'end-date', 'fechafin');
$this->listView($viewName)->addFilterPeriod('fecha', 'start-date', 'fecha');
$this->listView($viewName)->addFilterPeriod('fechafin', 'end-date', 'fechafin');

$status = $this->codeModel->all('tareas_fases', 'idfase', 'nombre');
$this->views[$viewName]->addFilterSelect('idfase', 'phase', 'idfase', $status);
$this->listView($viewName)->addFilterSelect('idfase', 'phase', 'idfase', $status);

// filtro por usuario asignado
$users = $this->codeModel->all('users', 'nick', 'nick');
if (count($users) > 1) {
$this->views[$viewName]->addFilterSelect('nick', 'user', 'nick', $users);
$this->listView($viewName)->addFilterSelect('nick', 'user', 'nick', $users);
}

// disable columns
$this->views[$viewName]->disableColumn('project');
$this->views[$viewName]->disableColumn('company');
$this->listView($viewName)->disableColumn('project');
$this->listView($viewName)->disableColumn('company');

$this->addButton($viewName, [
$this->tab($viewName)->addButton([
'type' => 'modal',
'action' => 'import-task',
'icon' => 'fa-solid fa-file-import',
'label' => 'import'
]);

$this->addButton($viewName, [
$this->tab($viewName)->addButton([
'type' => 'link',
'action' => 'KanbanProyectos?idproyecto=' . $this->request->get('code', ''),
'action' => 'KanbanProyectos?idproyecto=' . $this->request->queryOrInput('code', ''),
'icon' => 'fa-brands fa-trello',
'label' => 'kanban',
'color' => 'info',
Expand All @@ -579,7 +579,7 @@ protected function createViewsUsers(string $viewName = 'EditUserProyecto'): void
$this->addEditListView($viewName, 'UserProyecto', 'users', 'fa-solid fa-users');

// disable column
$this->views[$viewName]->disableColumn('project');
$this->tab($viewName)->disableColumn('project');
}

/**
Expand Down Expand Up @@ -694,13 +694,13 @@ protected function importTaskAction(): bool

// cargamos el proyecto actual
$origProject = new Proyecto();
if (false === $origProject->load($this->request->get('code', ''))) {
if (false === $origProject->load($this->request->queryOrInput('code', ''))) {
return true;
}

// obtenemos el ID del proyecto a copiar
$copyProject = new Proyecto();
if (false === $copyProject->load($this->request->get('idproyecto', '')) ||
if (false === $copyProject->load($this->request->queryOrInput('idproyecto', '')) ||
$origProject->idproyecto === $copyProject->idproyecto) {
return true;
}
Expand Down Expand Up @@ -757,7 +757,7 @@ protected function linkUpAction(string $modelName): bool
$modelTable = $model->tableName();
$modelKey = $model->primaryColumn();
$code = $this->request->request->get('linkupcode', '');
$idproyecto = $this->request->get('code', '');
$idproyecto = $this->request->queryOrInput('code', '');

$sql = "UPDATE $modelTable SET idproyecto = " . $this->dataBase->var2str($idproyecto)
. " WHERE " . $this->dataBase->escapeColumn($modelKey) . " = " . $this->dataBase->var2str($code) . ';';
Expand All @@ -779,8 +779,8 @@ protected function linkUpAction(string $modelName): bool
*/
protected function loadData($viewName, $view)
{
$mainViewName = $this->getMainViewName();
$idproyecto = $this->getViewModelValue($mainViewName, 'idproyecto');
$mainViewName = $this->mainTabName();
$idproyecto = $this->tabModelValue($mainViewName, 'idproyecto');

switch ($viewName) {
case $mainViewName:
Expand All @@ -799,7 +799,7 @@ protected function loadData($viewName, $view)
break;

case 'docfiles':
$this->loadDataDocFiles($view, $this->getModelClassName(), $this->getModel()->primaryColumnValue());
$this->loadDataDocFiles($view, $this->getModelClassName(), $this->getModel()->id());
break;

case 'EditUserProyecto':
Expand All @@ -825,13 +825,13 @@ protected function loadData($viewName, $view)

// añadimos el botón de nuevo documento, no para asientos
if ($viewName !== 'ListAsiento') {
$codcliente = $this->getViewModelValue($mainViewName, 'codcliente');
$codcliente = $this->tabModelValue($mainViewName, 'codcliente');
$url = $view->model->url('edit') . '?idproyecto=' . $idproyecto;
if (false === empty($codcliente)
&& in_array($view->model->modelClassName(), ['PresupuestoCliente', 'PedidoCliente', 'AlbaranCliente', 'FacturaCliente'])) {
$url .= '&codcliente=' . $codcliente;
}
$this->addButton($viewName, [
$this->tab($viewName)->addButton([
'type' => 'link',
'action' => $url,
'color' => 'success',
Expand All @@ -841,7 +841,7 @@ protected function loadData($viewName, $view)

// si hay documentos añadimos el botón de desvincular
if ($view->count > 0) {
$this->addButton($viewName, [
$this->tab($viewName)->addButton([
'type' => 'action',
'action' => 'unlink-up-' . $view->model->modelClassName(),
'color' => 'warning',
Expand Down Expand Up @@ -889,7 +889,7 @@ protected function unlinkUpAction(string $modelName): bool

// obtenemos el proyecto
$project = $this->getModel();
if (false === $project->load($this->request->get('code', ''))) {
if (false === $project->load($this->request->queryOrInput('code', ''))) {
return true;
}

Expand Down
16 changes: 8 additions & 8 deletions Controller/EditTareaProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ protected function createViews()
$this->createViewsNotes();
$this->createViewDocFiles();

$idproyecto = $this->request->get('code', '')
$idproyecto = $this->request->queryOrInput('code', '')
? $this->getModel()->idproyecto
: $this->request->get('idproyecto', '');
: $this->request->queryOrInput('idproyecto', '');

$this->addButton($this->getMainViewName(), [
$this->tab($this->mainTabName())->addButton([
'type' => 'link',
'action' => 'KanbanProyectos?idproyecto=' . $idproyecto,
'icon' => 'fa-brands fa-trello',
Expand Down Expand Up @@ -127,15 +127,15 @@ protected function execPreviousAction($action)
*/
protected function loadData($viewName, $view)
{
$mainViewName = $this->getMainViewName();
$mainViewName = $this->mainTabName();
switch ($viewName) {
case $mainViewName:
parent::loadData($viewName, $view);
if (false === $view->model->getProject()->userCanSee($this->user)) {
$this->setTemplate('Error/AccessDenied');
} elseif (false === $view->model->getProject()->editable) {
$this->disableTaskColumns($view);
$this->views['EditTareaProyecto']->disableColumn('code');
$this->tab('EditTareaProyecto')->disableColumn('code');
}

// Si el modelo no existe, desactivamos la pestaña de archivos
Expand All @@ -146,15 +146,15 @@ protected function loadData($viewName, $view)
break;

case 'EditNotaProyecto':
$where = [Where::eq('idtarea', $this->getViewModelValue($mainViewName, 'idtarea'))];
$where = [Where::eq('idtarea', $this->tabModelValue($mainViewName, 'idtarea'))];
$view->loadData('', $where, ['fecha' => 'DESC']);
if (false === $view->model->exists()) {
$view->model->idproyecto = $this->getViewModelValue($mainViewName, 'idproyecto');
$view->model->idproyecto = $this->tabModelValue($mainViewName, 'idproyecto');
}
break;

case 'docfiles':
$this->loadDataDocFiles($view, $this->getModelClassName(), $this->getViewModelValue($mainViewName, 'idtarea'));
$this->loadDataDocFiles($view, $this->getModelClassName(), $this->tabModelValue($mainViewName, 'idtarea'));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/ListProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function setProjectColors(string $viewName): void
continue;
}

$this->views[$viewName]->getRow('status')->options[] = [
$this->listView($viewName)->getRow('status')->options[] = [
'tag' => 'option',
'children' => [],
'color' => $estado->color,
Expand Down
2 changes: 1 addition & 1 deletion Extension/Controller/EditCliente.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function loadData(): Closure
{
return function ($viewName, $view) {
if ($viewName === 'ListProyecto') {
$codcliente = $this->getViewModelValue($this->getMainViewName(), 'codcliente');
$codcliente = $this->tabModelValue($this->mainTabName(), 'codcliente');
$where = [Where::eq('codcliente', $codcliente)];
$view->loadData('', $where);
}
Expand Down
2 changes: 1 addition & 1 deletion Extension/Controller/EditProducto.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function loadData(): Closure
{
return function ($viewName, $view) {
if ($viewName === 'ListStockProyecto') {
$idproducto = $this->getViewModelValue($this->getMainViewName(), 'idproducto');
$idproducto = $this->tabModelValue($this->mainTabName(), 'idproducto');
$where = [Where::eq('idproducto', $idproducto)];
$view->loadData('', $where);
}
Expand Down
12 changes: 6 additions & 6 deletions Extension/Controller/NewServicioAT.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class NewServicioAT
public function load(): Closure
{
return function () {
if (empty($this->request->get('idproyecto')) || !empty($this->codcliente)) {
if (empty($this->request->queryOrInput('idproyecto')) || !empty($this->codcliente)) {
return;
}

// buscamos el proyecto
$project = new Proyecto();
$id = $this->request->get('idproyecto');
if (false === $project->loadFromCode($id)) {
$id = $this->request->queryOrInput('idproyecto');
if (false === $project->load($id)) {
Tools::log()->warning('project-not-found', [
'project' => $id
]);
Expand All @@ -50,14 +50,14 @@ public function load(): Closure
public function saveNewService(): Closure
{
return function ($service) {
if (empty($this->request->get('idproyecto'))) {
if (empty($this->request->queryOrInput('idproyecto'))) {
return;
}

// buscamos el proyecto
$project = new Proyecto();
$id = $this->request->get('idproyecto');
if (false === $project->loadFromCode($id)) {
$id = $this->request->queryOrInput('idproyecto');
if (false === $project->load($id)) {
Tools::log()->warning('project-not-found', [
'project' => $id
]);
Expand Down
2 changes: 1 addition & 1 deletion Extension/Traits/ProjectControllerSalesPurchases.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function execPreviousAction(): Closure
return function ($action) {
if ($action === 'autocomplete-project') {
$this->setTemplate(false);
$query = (string)$this->request->get('term', '');
$query = (string)$this->request->queryOrInput('term', '');
$this->response->setContent(json_encode($this->autocompleteProjectAction($query)));
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions Model/EstadoProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ class EstadoProyecto extends ModelClass
{
use ModelTrait;

/** Color de fondo asociado al estado. @var string */
/** @var string Color de fondo asociado al estado. */
public $color;

/** Indica si los proyectos con este estado se pueden editar. @var bool */
/** @var bool Indica si los proyectos con este estado se pueden editar. */
public $editable;

/** Identificador del estado. @var integer */
/** @var integer Identificador del estado. */
public $idestado;

/** Nombre del estado. @var string */
/** @var string Nombre del estado. */
public $nombre;

/** Indica si es el estado predeterminado para nuevos proyectos. @var bool */
/** @var bool Indica si es el estado predeterminado para nuevos proyectos. */
public $predeterminado;

public function clear(): void
Expand Down
Loading