Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Controller/EditProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use FacturaScripts\Core\DataSrc\Series;
use FacturaScripts\Core\Lib\ExtendedController\EditController;
use FacturaScripts\Core\Lib\ExtendedController\EditView;
use FacturaScripts\Core\Lib\ExtendedController\DocFilesTrait;
use FacturaScripts\Core\Lib\InvoiceOperation;
use FacturaScripts\Core\Tools;
use FacturaScripts\Dinamic\Lib\ProjectStockManager;
Expand All @@ -46,6 +47,8 @@
*/
class EditProyecto extends EditController
{
use DocFilesTrait;

public function getModelClassName(): string
{
return 'Proyecto';
Expand Down Expand Up @@ -161,6 +164,7 @@ protected function createViews()
$this->createViewsNotes();
$this->createViewsStock();
$this->createViewsServices();

// Purchases (supplier) views - add only if user has permissions (mirror EditProveedor)
if ($this->user->can('EditPresupuestoProveedor')) {
$this->createViewPurchases('PresupuestoProveedor', 'supplier-estimations');
Expand Down Expand Up @@ -190,6 +194,8 @@ protected function createViews()
if ($this->user->can('EditReciboCliente')) {
$this->createReceiptView('ListReciboCliente', 'ReciboCliente');
}

$this->createViewDocFiles();
$this->createViewsUsers();
}

Expand Down Expand Up @@ -516,6 +522,21 @@ protected function execPreviousAction($action)
$parts = explode('-', $action);
return $this->unlinkUpAction(end($parts));

case 'add-file':
return $this->addFileAction();

case 'delete-file':
return $this->deleteFileAction();

case 'edit-file':
return $this->editFileAction();

case 'unlink-file':
return $this->unlinkFileAction();

case 'sort-files':
return $this->sortFilesAction();

default:
return parent::execPreviousAction($action);
}
Expand Down Expand Up @@ -640,6 +661,7 @@ protected function loadData($viewName, $view)
case 'ListStockProyecto':
case 'ListTareaProyecto':
case 'ListServicioAT':
case 'docfiles':
$where = [new DataBaseWhere('idproyecto', $idproyecto)];
$view->loadData('', $where);
break;
Expand Down
46 changes: 46 additions & 0 deletions Controller/EditTareaProyecto.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
use FacturaScripts\Core\Lib\ExtendedController\EditController;
use FacturaScripts\Core\Lib\ExtendedController\EditView;
use FacturaScripts\Core\Lib\ExtendedController\DocFilesTrait;
use FacturaScripts\Core\Tools;


Expand All @@ -33,6 +34,13 @@
*/
class EditTareaProyecto extends EditController
{
use DocFilesTrait;

public function __construct(string $className = '', string $uri = '')
{
parent::__construct($className, $uri);
}

public function getModelClassName(): string
{
return 'TareaProyecto';
Expand Down Expand Up @@ -91,6 +99,34 @@ protected function disableTaskColumns(&$view): void
}
}

/**
* @param string $action
*
* @return bool
*/
protected function execPreviousAction($action)
{
switch ($action) {
case 'add-file':
return $this->addFileAction();

case 'delete-file':
return $this->deleteFileAction();

case 'edit-file':
return $this->editFileAction();

case 'unlink-file':
return $this->unlinkFileAction();

case 'sort-files':
return $this->sortFilesAction();

default:
return parent::execPreviousAction($action);
}
}

/**
* @param string $viewName
* @param EditView $view
Expand All @@ -107,6 +143,12 @@ protected function loadData($viewName, $view)
$this->disableTaskColumns($view);
$this->views['EditTareaProyecto']->disableColumn('code');
}

// If it is a new task (no model exists yet) keep the files tab active so user can add files
if (false === $view->model->exists()) {
$this->setSettings('docfiles', 'active', true);
}

break;

case 'EditNotaProyecto':
Expand All @@ -116,6 +158,10 @@ protected function loadData($viewName, $view)
$view->model->idproyecto = $this->getViewModelValue($mainViewName, 'idproyecto');
}
break;

case 'docfiles':
$this->loadDataDocFiles($view, $this->getModelClassName(), $this->getViewModelValue($mainViewName, 'idtarea'));
break;
}
}
}
Loading