diff --git a/ajax/ajax_accountSave.php b/ajax/ajax_accountSave.php
index d440d939..d7f6502c 100644
--- a/ajax/ajax_accountSave.php
+++ b/ajax/ajax_accountSave.php
@@ -69,6 +69,7 @@ $accountGroupEditEnabled = Request::analyze('geditenabled', 0, false, 1);
$accountUserEditEnabled = Request::analyze('ueditenabled', 0, false, 1);
$accountMainGroupId = Request::analyze('mainGroupId', 0);
$accountChangesHash = Request::analyze('hash');
+$customFieldsHash = Request::analyze('hashcf');
$customFields = Request::analyze('customfield');
// Datos del Usuario
@@ -138,6 +139,18 @@ if ($actionId == ActionsInterface::ACTION_ACC_NEW
}
$Account = new Account;
+$Account->setAccountId($accountId);
+$Account->setAccountName($accountName);
+$Account->setAccountCategoryId($categoryId);
+$Account->setAccountCustomerId($customerId);
+$Account->setAccountLogin($accountLogin);
+$Account->setAccountUrl($accountUrl);
+$Account->setAccountNotes($accountNotes);
+$Account->setAccountUserEditId($currentUserId);
+$Account->setAccountUsersId($accountOtherUsers);
+$Account->setAccountUserGroupsId($accountOtherGroups);
+$Account->setAccountOtherUserEdit($accountUserEditEnabled);
+$Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
switch ($actionId) {
case ActionsInterface::ACTION_ACC_NEW:
@@ -154,20 +167,10 @@ switch ($actionId) {
}
}
- $Account->setAccountName($accountName);
- $Account->setAccountCategoryId($categoryId);
- $Account->setAccountCustomerId($customerId);
- $Account->setAccountLogin($accountLogin);
- $Account->setAccountUrl($accountUrl);
$Account->setAccountPass($accountEncPass['data']);
$Account->setAccountIV($accountEncPass['iv']);
- $Account->setAccountNotes($accountNotes);
$Account->setAccountUserId($currentUserId);
$Account->setAccountUserGroupId($accountMainGroupId);
- $Account->setAccountUsersId($accountOtherUsers);
- $Account->setAccountUserGroupsId($accountOtherGroups);
- $Account->setAccountOtherUserEdit($accountUserEditEnabled);
- $Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
// Crear cuenta
if ($Account->createAccount()) {
@@ -196,36 +199,22 @@ switch ($actionId) {
}
}
- $Account->setAccountId($accountId);
- $Account->setAccountName($accountName);
- $Account->setAccountCategoryId($categoryId);
- $Account->setAccountCustomerId($customerId);
- $Account->setAccountLogin($accountLogin);
- $Account->setAccountUrl($accountUrl);
- $Account->setAccountNotes($accountNotes);
- $Account->setAccountUserEditId($currentUserId);
- $Account->setAccountUsersId($accountOtherUsers);
- $Account->setAccountUserGroupsId($accountOtherGroups);
- $Account->setAccountOtherUserEdit($accountUserEditEnabled);
- $Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
-
// Cambiar el grupo principal si el usuario es Admin
if (Session::getUserIsAdminApp() || Session::getUserIsAdminAcc()) {
$Account->setAccountUserGroupId($accountMainGroupId);
}
// Comprobar si han habido cambios
- if ($accountChangesHash == $Account->calcChangesHash()) {
+ if ($accountChangesHash == $Account->calcChangesHash()
+ && \SP\Mgmt\CustomFieldsUtil::checkHash($customFields, $customFieldsHash)
+ ) {
Response::printJSON(_('Sin cambios'), 0);
}
// Actualizar cuenta
if ($Account->updateAccount()) {
if (is_array($customFields)) {
- foreach ($customFields as $id => $value) {
- $CustomFields = new CustomFields($id, $accountId, $value);
- $CustomFields->updateCustomField();
- }
+ \SP\Mgmt\CustomFieldsUtil::updateCustonFields($customFields, $accountId);
}
Response::printJSON(_('Cuenta actualizada'), 0);
@@ -246,10 +235,8 @@ switch ($actionId) {
Response::printJSON(_('Error al eliminar la cuenta'));
break;
case ActionsInterface::ACTION_ACC_EDIT_PASS:
- $Account->setAccountId($accountId);
$Account->setAccountPass($accountEncPass['data']);
$Account->setAccountIV($accountEncPass['iv']);
- $Account->setAccountUserEditId($currentUserId);
// Actualizar clave de cuenta
if ($Account->updateAccountPass()) {
diff --git a/ajax/ajax_appMgmtSave.php b/ajax/ajax_appMgmtSave.php
index be00c564..734266af 100644
--- a/ajax/ajax_appMgmtSave.php
+++ b/ajax/ajax_appMgmtSave.php
@@ -590,6 +590,18 @@ if ($actionId === ActionsInterface::ACTION_USR_USERS_NEW
}
Response::printJSON(_('Error al eliminar el archivo'));
+} elseif ($actionId === ActionsInterface::ACTION_MGM_ACCOUNTS_DELETE) {
+ $Account = new \SP\Account\Account();
+ $Account->setAccountId($itemId);
+
+ // Eliminar cuenta
+ if ($Account->deleteAccount()
+ && CustomFields::deleteCustomFieldForItem($itemId, ActionsInterface::ACTION_ACC_NEW)
+ ) {
+ Response::printJSON(_('Cuenta eliminada'), 0, $doActionOnClose);
+ }
+
+ Response::printJSON(_('Error al eliminar la cuenta'));
} else {
Response::printJSON(_('Acción Inválida'));
}
\ No newline at end of file
diff --git a/ajax/ajax_appMgmtSearch.php b/ajax/ajax_appMgmtSearch.php
new file mode 100644
index 00000000..dece10ff
--- /dev/null
+++ b/ajax/ajax_appMgmtSearch.php
@@ -0,0 +1,83 @@
+.
+ *
+ */
+
+use SP\Controller\ItemsMgmtSearch;
+use SP\Core\Init;
+use SP\Core\SessionUtil;
+use SP\Core\Template;
+use SP\Http\Request;
+use SP\Http\Response;
+
+define('APP_ROOT', '..');
+
+require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
+
+Request::checkReferer('POST');
+
+if (!Init::isLoggedIn()) {
+ Response::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10);
+}
+
+$sk = Request::analyze('sk', false);
+
+if (!$sk || !SessionUtil::checkSessionKey($sk)) {
+ Response::printJSON(_('CONSULTA INVÁLIDA'));
+}
+
+$actionId = Request::analyze('actionId', 0);
+$search = Request::analyze('search');
+
+$Tpl = new Template();
+$Tpl->assign('index', Request::analyze('activeTab', 0));
+
+$Controller = new ItemsMgmtSearch($Tpl);
+
+switch ($actionId) {
+ case \SP\Core\ActionsInterface::ACTION_MGM_CATEGORIES_SEARCH:
+ $Controller->getCategories($search);
+ break;
+ case \SP\Core\ActionsInterface::ACTION_MGM_CUSTOMERS_SEARCH:
+ $Controller->getCustomers($search);
+ break;
+ case \SP\Core\ActionsInterface::ACTION_MGM_CUSTOMFIELDS_SEARCH:
+ $Controller->getCustomFields($search);
+ break;
+ case \SP\Core\ActionsInterface::ACTION_MGM_FILES_SEARCH:
+ $Controller->getFiles($search);
+ break;
+ case \SP\Core\ActionsInterface::ACTION_MGM_ACCOUNTS_SEARCH:
+ $Controller->getAccounts($search);
+ break;
+ default:
+ Response::printJSON(_('Acción Inválida'));
+ break;
+}
+
+$data = array(
+ 'sk' => SessionUtil::getSessionKey(),
+ 'html' => $Controller->render()
+);
+
+Response::printJSON($data, 0);
\ No newline at end of file
diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php
index 1e8b7473..8d4e4615 100644
--- a/ajax/ajax_getContent.php
+++ b/ajax/ajax_getContent.php
@@ -146,6 +146,7 @@ switch ($actionId) {
$Controller->getCustomers();
$Controller->getCustomFields();
$Controller->getFiles();
+ $Controller->getAccounts();
break;
case ActionsInterface::ACTION_CFG:
case ActionsInterface::ACTION_CFG_GENERAL:
diff --git a/ajax/ajax_search.php b/ajax/ajax_search.php
index 9ae2d766..04057756 100644
--- a/ajax/ajax_search.php
+++ b/ajax/ajax_search.php
@@ -27,6 +27,7 @@ use SP\Controller\SearchC;
use SP\Core\Init;
use SP\Http\Request;
use SP\Core\SessionUtil;
+use SP\Http\Response;
use SP\Util\Util;
define('APP_ROOT', '..');
@@ -42,9 +43,15 @@ if (!Init::isLoggedIn()) {
$sk = \SP\Http\Request::analyze('sk', false);
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
- die('
' . _('CONSULTA INVÁLIDA') . '
');
+ Response::printJSON(_('CONSULTA INVÁLIDA'));
}
$Controller = new SearchC();
$Controller->getSearch();
-$Controller->view();
\ No newline at end of file
+
+$data = array(
+ 'sk' => SessionUtil::getSessionKey(),
+ 'html' => $Controller->render()
+);
+
+Response::printJSON($data, 0);
\ No newline at end of file
diff --git a/inc/SP/Account/AccountSearch.class.php b/inc/SP/Account/AccountSearch.class.php
index 73576e4a..694a6881 100644
--- a/inc/SP/Account/AccountSearch.class.php
+++ b/inc/SP/Account/AccountSearch.class.php
@@ -133,7 +133,7 @@ class AccountSearch
*/
public function setTxtSearch($txtSearch)
{
- $this->_txtSearch = $txtSearch;
+ $this->_txtSearch = (string) $txtSearch;
}
/**
diff --git a/inc/SP/Account/AccountUtil.class.php b/inc/SP/Account/AccountUtil.class.php
index 9fa3c359..eabdfb3b 100644
--- a/inc/SP/Account/AccountUtil.class.php
+++ b/inc/SP/Account/AccountUtil.class.php
@@ -154,4 +154,67 @@ class AccountUtil
return ($queryRes !== false) ? $queryRes->account_name : false;
}
+
+ /**
+ * Obtener los datos de todas las cuentas y el cliente
+ *
+ * @return array
+ * @throws SPException
+ */
+ public static function getAccountsCustomerData()
+ {
+ $Data = new QueryData();
+ $query = 'SELECT account_id,'
+ . 'account_name,'
+ . 'customer_name '
+ . 'FROM accounts '
+ . 'LEFT JOIN customers ON account_customerId = customer_id ';
+
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ return $queryRes;
+ }
+
+ /**
+ * Obtener los datos de todas las cuentas y el cliente mediante una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @return array|bool
+ */
+ public static function getAccountsCustomerDataSearch($search)
+ {
+ $Data = new QueryData();
+
+ $search = '%' . $search . '%';
+
+ $query = 'SELECT account_id,'
+ . 'account_name,'
+ . 'customer_name '
+ . 'FROM accounts '
+ . 'LEFT JOIN customers ON account_customerId = customer_id '
+ . 'WHERE account_name LIKE ? '
+ . 'OR customer_name LIKE ?';
+
+ $Data->setQuery($query);
+ $Data->addParam($search);
+ $Data->addParam($search);
+
+ DB::setReturnArray();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ return $queryRes;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Controller/AccountC.class.php b/inc/SP/Controller/AccountC.class.php
index 9a7ee864..763796d6 100644
--- a/inc/SP/Controller/AccountC.class.php
+++ b/inc/SP/Controller/AccountC.class.php
@@ -162,6 +162,8 @@ class AccountC extends Controller implements ActionsInterface
*/
private function setCommonData()
{
+ $this->getCustomFieldsForItem();
+
if ($this->isGotData()) {
$this->view->assign('accountIsHistory', $this->getAccount()->getAccountIsHistory());
$this->view->assign('accountOtherUsers', $this->getAccount()->getAccountUsersId());
@@ -186,7 +188,8 @@ class AccountC extends Controller implements ActionsInterface
$this->view->assign('customers', DBUtil::getValuesForSelect('customers', 'customer_id', 'customer_name'));
$this->view->assign('otherUsers', DBUtil::getValuesForSelect('usrData', 'user_id', 'user_name'));
$this->view->assign('otherGroups', DBUtil::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
- $this->getCustomFieldsForItem();
+
+
}
/**
diff --git a/inc/SP/Controller/AccountsMgmtC.class.php b/inc/SP/Controller/AccountsMgmtC.class.php
index acc96825..eef2f56d 100644
--- a/inc/SP/Controller/AccountsMgmtC.class.php
+++ b/inc/SP/Controller/AccountsMgmtC.class.php
@@ -25,11 +25,17 @@
namespace SP\Controller;
+use SP\Account\AccountUtil;
+use SP\Config\Config;
use SP\Core\ActionsInterface;
+use SP\Core\Template;
use SP\Html\DataGrid\DataGridAction;
+use SP\Html\DataGrid\DataGridActionSearch;
+use SP\Html\DataGrid\DataGridActionType;
use SP\Html\DataGrid\DataGridData;
use SP\Html\DataGrid\DataGridHeader;
use SP\Html\DataGrid\DataGridIcon;
+use SP\Html\DataGrid\DataGridPager;
use SP\Html\DataGrid\DataGridTab;
use SP\Http\Request;
use SP\Mgmt\Category;
@@ -79,9 +85,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
/**
* Constructor
*
- * @param $template \SP\Core\Template con instancia de plantilla
+ * @param $template Template con instancia de plantilla
*/
- public function __construct(\SP\Core\Template $template = null)
+ public function __construct(Template $template = null)
{
parent::__construct($template);
@@ -103,13 +109,31 @@ class AccountsMgmtC extends Controller implements ActionsInterface
}
$this->view->assign('sk', SessionUtil::getSessionKey(true));
+ $this->view->append('tabs', $this->getCategoriesGrid());
+ }
+
+ /**
+ * @param string $search
+ * @return DataGridTab
+ */
+ public function getCategoriesGrid($search = '')
+ {
+ $GridActionSearch = new DataGridActionSearch();
+ $GridActionSearch->setId(self::ACTION_MGM_CATEGORIES_SEARCH);
+ $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
+ $GridActionSearch->setName('frmSearchCustomer');
+ $GridActionSearch->setTitle(_('Buscar Categoría'));
+ $GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
+ $GridActionSearch->setOnSubmitArgs('this');
+ $GridActionSearch->setOnSubmitArgs($this->view->sk);
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_MGM_CATEGORIES_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nueva Categoría'));
+ $GridActionNew->setTitle(_('Nueva Categoría'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_MGM_CATEGORIES_NEW);
@@ -117,7 +141,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_MGM_CATEGORIES_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Categoría'));
+ $GridActionEdit->setTitle(_('Editar Categoría'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -126,9 +152,10 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_MGM_CATEGORIES_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Categoría'));
+ $GridActionDel->setTitle(_('Eliminar Categoría'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_MGM_CATEGORIES_DELETE);
@@ -142,19 +169,28 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridData->setDataRowSourceId('category_id');
$GridData->addDataRowSource('category_name');
$GridData->addDataRowSource('category_description');
- $GridData->setData(Category::getCategories());
+
+ if(empty($search)) {
+ $GridData->setData(Category::getCategories());
+ } else {
+ $GridData->setData(Category::getCategoriesSearch($search));
+ }
$Grid = new DataGridTab();
$Grid->setId('tblCategories');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionDel);
+ $Grid->setDataActions($GridActionSearch);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Categorías'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
- $this->view->append('tabs', $Grid);
+ return $Grid;
}
/**
@@ -169,13 +205,31 @@ class AccountsMgmtC extends Controller implements ActionsInterface
}
$this->view->assign('sk', SessionUtil::getSessionKey(true));
+ $this->view->append('tabs', $this->getCustomersGrid());
+ }
+
+ /**
+ * @param string $search
+ * @return DataGridTab
+ */
+ public function getCustomersGrid($search = '')
+ {
+ $GridActionSearch = new DataGridActionSearch();
+ $GridActionSearch->setId(self::ACTION_MGM_CUSTOMERS_SEARCH);
+ $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
+ $GridActionSearch->setName('frmSearchCustomer');
+ $GridActionSearch->setTitle(_('Buscar Cliente'));
+ $GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
+ $GridActionSearch->setOnSubmitArgs('this');
+ $GridActionSearch->setOnSubmitArgs($this->view->sk);
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_MGM_CUSTOMERS_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nuevo Cliente'));
+ $GridActionNew->setTitle(_('Nuevo Cliente'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_NEW);
@@ -183,7 +237,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_MGM_CUSTOMERS_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Cliente'));
+ $GridActionEdit->setTitle(_('Editar Cliente'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -192,9 +248,10 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_MGM_CUSTOMERS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Cliente'));
+ $GridActionDel->setTitle(_('Eliminar Cliente'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMERS_DELETE);
@@ -208,19 +265,28 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridData->setDataRowSourceId('customer_id');
$GridData->addDataRowSource('customer_name');
$GridData->addDataRowSource('customer_description');
- $GridData->setData(Customer::getCustomers());
+
+ if (empty($search)) {
+ $GridData->setData(Customer::getCustomers());
+ } else {
+ $GridData->setData(Customer::getCustomersSearch($search));
+ }
$Grid = new DataGridTab();
$Grid->setId('tblCustomers');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionDel);
+ $Grid->setDataActions($GridActionSearch);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Clientes'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
- $this->view->append('tabs', $Grid);
+ return $Grid;
}
/**
@@ -304,13 +370,31 @@ class AccountsMgmtC extends Controller implements ActionsInterface
}
$this->view->assign('sk', SessionUtil::getSessionKey(true));
+ $this->view->append('tabs', $this->getCustomFieldsGrid());
+ }
+
+ /**
+ * @param string $search
+ * @return DataGridTab
+ */
+ public function getCustomFieldsGrid($search = '')
+ {
+ $GridActionSearch = new DataGridActionSearch();
+ $GridActionSearch->setId(self::ACTION_MGM_CUSTOMFIELDS_SEARCH);
+ $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
+ $GridActionSearch->setName('frmSearchCustomField');
+ $GridActionSearch->setTitle(_('Buscar Campo'));
+ $GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
+ $GridActionSearch->setOnSubmitArgs('this');
+ $GridActionSearch->setOnSubmitArgs($this->view->sk);
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_MGM_CUSTOMFIELDS_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nuevo Campo'));
+ $GridActionNew->setTitle(_('Nuevo Campo'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_NEW);
@@ -318,7 +402,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_MGM_CUSTOMFIELDS_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Campo'));
+ $GridActionEdit->setTitle(_('Editar Campo'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -327,9 +413,10 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_MGM_CUSTOMFIELDS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Campo'));
+ $GridActionDel->setTitle(_('Eliminar Campo'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_MGM_CUSTOMFIELDS_DELETE);
@@ -345,19 +432,28 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridData->addDataRowSource('module');
$GridData->addDataRowSource('name');
$GridData->addDataRowSource('typeName');
- $GridData->setData(CustomFieldDef::getCustomFields());
+
+ if(empty($search)) {
+ $GridData->setData(CustomFieldDef::getCustomFields());
+ } else {
+ $GridData->setData(CustomFieldDef::getCustomFieldsSearch($search));
+ }
$Grid = new DataGridTab();
$Grid->setId('tblCustomFields');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionDel);
+ $Grid->setDataActions($GridActionSearch);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Campos Personalizados'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
- $this->view->append('tabs', $Grid);
+ return $Grid;
}
/**
@@ -405,9 +501,27 @@ class AccountsMgmtC extends Controller implements ActionsInterface
}
$this->view->assign('sk', SessionUtil::getSessionKey(true));
+ $this->view->append('tabs', $this->getFilesGrid());
+ }
+
+ /**
+ * @param string $search
+ * @return DataGridTab
+ */
+ public function getFilesGrid($search = '')
+ {
+ $GridActionSearch = new DataGridActionSearch();
+ $GridActionSearch->setId(self::ACTION_MGM_FILES_SEARCH);
+ $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
+ $GridActionSearch->setName('frmSearchFile');
+ $GridActionSearch->setTitle(_('Buscar Archivo'));
+ $GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
+ $GridActionSearch->setOnSubmitArgs('this');
+ $GridActionSearch->setOnSubmitArgs($this->view->sk);
$GridActionView = new DataGridAction();
$GridActionView->setId(self::ACTION_MGM_FILES_VIEW);
+ $GridActionView->setType(DataGridActionType::VIEW_ITEM);
$GridActionView->setName(_('Ver Archivo'));
$GridActionView->setIcon($this->_iconView);
$GridActionView->setOnClickFunction('sysPassUtil.Common.viewFile');
@@ -417,9 +531,9 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_MGM_FILES_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Archivo'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_MGM_FILES_DELETE);
@@ -439,17 +553,116 @@ class AccountsMgmtC extends Controller implements ActionsInterface
$GridData->addDataRowSource('accfile_name');
$GridData->addDataRowSource('accfile_type');
$GridData->addDataRowSource('accfile_size');
- $GridData->setData(Files::getFileList());
+
+ if (empty($search)) {
+ $GridData->setData(Files::getFileList());
+ } else {
+ $GridData->setData(Files::getFileListSearch($search));
+ }
$Grid = new DataGridTab();
$Grid->setId('tblFiles');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionView);
$Grid->setDataActions($GridActionDel);
+ $Grid->setDataActions($GridActionSearch);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Archivos'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
- $this->view->append('tabs', $Grid);
+ return $Grid;
+ }
+
+ /**
+ * Obtener los datos para la pestaña de cuentas
+ */
+ public function getAccounts()
+ {
+ $this->setAction(self::ACTION_MGM_ACCOUNTS);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->assign('sk', SessionUtil::getSessionKey(true));
+ $this->view->append('tabs', $this->getAccountsGrid());
+ }
+
+ /**
+ * @param string $search La cadena de búsqueda
+ * @return DataGridTab
+ */
+ public function getAccountsGrid($search = '')
+ {
+ $GridActionSearch = new DataGridActionSearch();
+ $GridActionSearch->setId(self::ACTION_MGM_ACCOUNTS_SEARCH);
+ $GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
+ $GridActionSearch->setName('frmSearchAccount');
+ $GridActionSearch->setTitle(_('Buscar Cuenta'));
+ $GridActionSearch->setOnSubmitFunction('sysPassUtil.Common.appMgmtSearch');
+ $GridActionSearch->setOnSubmitArgs('this');
+ $GridActionSearch->setOnSubmitArgs($this->view->sk);
+
+ $GridActionDel = new DataGridAction();
+ $GridActionDel->setId(self::ACTION_MGM_ACCOUNTS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
+ $GridActionDel->setName(_('Eliminar Cuenta'));
+ $GridActionDel->setTitle(_('Eliminar Cuenta'));
+ $GridActionDel->setIcon($this->_iconDelete);
+ $GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
+ $GridActionDel->setOnClickArgs('this');
+ $GridActionDel->setOnClickArgs(self::ACTION_MGM_ACCOUNTS_DELETE);
+ $GridActionDel->setOnClickArgs($this->view->sk);
+
+ $GridHeaders = new DataGridHeader();
+ $GridHeaders->addHeader(_('Nombre'));
+ $GridHeaders->addHeader(_('Cliente'));
+
+ $GridData = new DataGridData();
+ $GridData->setDataRowSourceId('account_id');
+ $GridData->addDataRowSource('account_name');
+ $GridData->addDataRowSource('customer_name');
+
+ if (empty($search)) {
+ $GridData->setData(AccountUtil::getAccountsCustomerData());
+ } else {
+ $GridData->setData(AccountUtil::getAccountsCustomerDataSearch($search));
+ }
+
+ $Grid = new DataGridTab();
+ $Grid->setId('tblAccounts');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
+ $Grid->setDataActions($GridActionDel);
+ $Grid->setDataActions($GridActionSearch);
+ $Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
+ $Grid->setData($GridData);
+ $Grid->setTitle(_('Gestión de Cuentas'));
+ $Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
+
+ return $Grid;
+ }
+
+ /**
+ * Devolver el paginador
+ *
+ * @param int $numRows El número de registros devueltos
+ * @param bool $filter Si está activo el filtrado
+ * @return DataGridPager
+ */
+ public function getPager($numRows, $filter = false)
+ {
+ $GridPager = new DataGridPager();
+ $GridPager->setFilterOn($filter);
+ $GridPager->setTotalRows($numRows);
+ $GridPager->setLimitStart(Request::analyze('start', 0));
+ $GridPager->setLimitCount(Request::analyze('count', Config::getValue('account_count', 15)));
+ $GridPager->setOnClickFunction('sysPassUtil.Common.searchSort');
+
+ return $GridPager;
}
}
diff --git a/inc/SP/Controller/Controller.class.php b/inc/SP/Controller/Controller.class.php
index e1c11585..c2dbddb2 100644
--- a/inc/SP/Controller/Controller.class.php
+++ b/inc/SP/Controller/Controller.class.php
@@ -104,13 +104,21 @@ abstract class Controller
}
/**
- * Renderizar los datos de la plantilla
+ * Renderizar los datos de la plantilla y mostrarlos
*/
public function view()
{
echo $this->view->render();
}
+ /**
+ * Renderizar los datos de la plantilla y devolverlos
+ */
+ public function render()
+ {
+ return $this->view->render();
+ }
+
/**
* Obtener los datos para la vista de depuración
*/
diff --git a/inc/SP/Controller/ItemsMgmtSearch.class.php b/inc/SP/Controller/ItemsMgmtSearch.class.php
new file mode 100644
index 00000000..0809e7e2
--- /dev/null
+++ b/inc/SP/Controller/ItemsMgmtSearch.class.php
@@ -0,0 +1,163 @@
+.
+ *
+ */
+
+namespace SP\Controller;
+
+use SP\Core\ActionsInterface;
+use SP\Core\SessionUtil;
+use SP\Core\Template;
+use SP\Util\Checks;
+
+/**
+ * Class ItemsMgmt para las buśquedas en los listados de elementos de gestión
+ *
+ * @package SP\Controller
+ */
+class ItemsMgmtSearch extends Controller implements ActionsInterface
+{
+ /**
+ * Constructor
+ *
+ * @param $template Template con instancia de plantilla
+ */
+ public function __construct(Template $template = null)
+ {
+ parent::__construct($template);
+
+ $this->view->assign('isDemo', Checks::demoIsEnabled());
+ $this->view->assign('sk', SessionUtil::getSessionKey());
+ $this->view->assign('queryTimeStart', microtime());
+ }
+
+ /**
+ * Obtener las cuentas de una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @throws \SP\Core\SPException
+ */
+ public function getAccounts($search)
+ {
+ $this->setAction(self::ACTION_MGM_ACCOUNTS_SEARCH);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->addTemplate('datagrid-rows');
+
+ $AccountMgmt = new AccountsMgmtC($this->view);
+
+ $this->view->assign('data', $AccountMgmt->getAccountsGrid($search));
+ $this->view->assign('actionId', self::ACTION_MGM);
+ }
+
+ /**
+ * Obtener los archivos de una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @throws \SP\Core\SPException
+ */
+ public function getFiles($search)
+ {
+ $this->setAction(self::ACTION_MGM_FILES_SEARCH);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->addTemplate('datagrid-rows');
+
+ $AccountMgmt = new AccountsMgmtC($this->view);
+
+ $this->view->assign('data', $AccountMgmt->getFilesGrid($search));
+ $this->view->assign('actionId', self::ACTION_MGM);
+ }
+
+ /**
+ * Obtener los campos personalizados de una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @throws \SP\Core\SPException
+ */
+ public function getCustomFields($search)
+ {
+ $this->setAction(self::ACTION_MGM_CUSTOMFIELDS_SEARCH);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->addTemplate('datagrid-rows');
+
+ $AccountMgmt = new AccountsMgmtC($this->view);
+
+ $this->view->assign('data', $AccountMgmt->getCustomFieldsGrid($search));
+ $this->view->assign('actionId', self::ACTION_MGM);
+ }
+
+ /**
+ * Obtener los clientes de una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @throws \SP\Core\SPException
+ */
+ public function getCustomers($search)
+ {
+ $this->setAction(self::ACTION_MGM_CUSTOMERS_SEARCH);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->addTemplate('datagrid-rows');
+
+ $AccountMgmt = new AccountsMgmtC($this->view);
+
+ $this->view->assign('data', $AccountMgmt->getCustomersGrid($search));
+ $this->view->assign('actionId', self::ACTION_MGM);
+ }
+
+ /**
+ * Obtener las categorías de una búsqueda
+ *
+ * @param string $search La cadena a buscar
+ * @throws \SP\Core\SPException
+ */
+ public function getCategories($search)
+ {
+ $this->setAction(self::ACTION_MGM_CATEGORIES_SEARCH);
+
+ if (!$this->checkAccess()) {
+ return;
+ }
+
+ $this->view->addTemplate('datagrid-rows');
+
+ $AccountMgmt = new AccountsMgmtC($this->view);
+
+ $this->view->assign('data', $AccountMgmt->getCategoriesGrid($search));
+ $this->view->assign('actionId', self::ACTION_MGM);
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Controller/SearchC.class.php b/inc/SP/Controller/SearchC.class.php
index e4a76ffe..b9426ca6 100644
--- a/inc/SP/Controller/SearchC.class.php
+++ b/inc/SP/Controller/SearchC.class.php
@@ -106,7 +106,7 @@ class SearchC extends Controller implements ActionsInterface
}
// Obtener el filtro de búsqueda desde la sesión
- $filters = \SP\Core\Session::getSearchFilters();
+ $filters = Session::getSearchFilters();
// Valores POST
$this->view->assign('searchKey', Request::analyze('skey', $filters->getSortKey()));
@@ -182,7 +182,7 @@ class SearchC extends Controller implements ActionsInterface
$limitLast = ((AccountSearch::$queryNumRows % $this->view->limitCount) == 0) ? AccountSearch::$queryNumRows - $this->view->limitCount : floor(AccountSearch::$queryNumRows / $this->view->limitCount) * $this->view->limitCount;
- $this->view->assign('pagerOnnClick', array(
+ $this->view->assign('pagerOnClick', array(
'first' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ', 0,1)',
'last' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . $limitLast . ',1)',
'prev' => 'sysPassUtil.Common.searchSort(' . $this->view->searchKey . ',' . ($this->view->limitStart - $this->view->limitCount) . ',1)',
diff --git a/inc/SP/Controller/UsersMgmtC.class.php b/inc/SP/Controller/UsersMgmtC.class.php
index 418e71b0..6aec5386 100644
--- a/inc/SP/Controller/UsersMgmtC.class.php
+++ b/inc/SP/Controller/UsersMgmtC.class.php
@@ -26,12 +26,16 @@
namespace SP\Controller;
use SP\Api\ApiTokens;
+use SP\Config\Config;
use SP\Core\ActionsInterface;
use SP\Html\DataGrid\DataGridAction;
+use SP\Html\DataGrid\DataGridActionType;
use SP\Html\DataGrid\DataGridData;
use SP\Html\DataGrid\DataGridHeader;
use SP\Html\DataGrid\DataGridIcon;
+use SP\Html\DataGrid\DataGridPager;
use SP\Html\DataGrid\DataGridTab;
+use SP\Http\Request;
use SP\Mgmt\PublicLinkUtil;
use SP\Mgmt\CustomFields;
use SP\Mgmt\User\Groups;
@@ -117,10 +121,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_USR_USERS_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nuevo Usuario'));
+ $GridActionNew->setTitle(_('Nuevo Usuario'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_USR_USERS_NEW);
@@ -128,7 +133,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionView = new DataGridAction();
$GridActionView->setId(self::ACTION_USR_USERS_VIEW);
+ $GridActionView->setType(DataGridActionType::VIEW_ITEM);
$GridActionView->setName(_('Ver Detalles de Usuario'));
+ $GridActionView->setTitle(_('Ver Detalles de Usuario'));
$GridActionView->setIcon($this->_iconView);
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionView->setOnClickArgs('this');
@@ -137,7 +144,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_USR_USERS_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Usuario'));
+ $GridActionEdit->setTitle(_('Editar Usuario'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -146,9 +155,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_USR_USERS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Usuario'));
+ $GridActionDel->setTitle(_('Eliminar Usuario'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_USR_USERS_DELETE);
@@ -156,7 +166,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionEditPass = new DataGridAction();
$GridActionEditPass->setId(self::ACTION_USR_USERS_EDITPASS);
+ $GridActionEditPass->setType(DataGridActionType::EDIT_ITEM);
$GridActionEditPass->setName(_('Cambiar Clave de Usuario'));
+ $GridActionEditPass->setTitle(_('Cambiar Clave de Usuario'));
$GridActionEditPass->setIcon(new DataGridIcon('lock_outline', 'imgs/pass.png', 'fg-orange80'));
$GridActionEditPass->setOnClickFunction('sysPassUtil.Common.usrUpdPass');
$GridActionEditPass->setOnClickArgs('this');
@@ -185,12 +197,15 @@ class UsersMgmtC extends Controller implements ActionsInterface
$Grid = new DataGridTab();
$Grid->setId('tblUsers');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionView);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionEditPass);
$Grid->setDataActions($GridActionDel);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Usuarios'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
@@ -211,10 +226,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_USR_GROUPS_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nuevo Grupo'));
+ $GridActionNew->setTitle(_('Nuevo Grupo'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_USR_GROUPS_NEW);
@@ -222,7 +238,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_USR_GROUPS_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Grupo'));
+ $GridActionEdit->setTitle(_('Editar Grupo'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -231,9 +249,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_USR_GROUPS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Grupo'));
+ $GridActionDel->setTitle(_('Eliminar Grupo'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_USR_GROUPS_DELETE);
@@ -251,10 +270,13 @@ class UsersMgmtC extends Controller implements ActionsInterface
$Grid = new DataGridTab();
$Grid->setId('tblGroups');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionDel);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Grupos'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
@@ -275,10 +297,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_USR_PROFILES_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nuevo Perfil'));
+ $GridActionNew->setTitle(_('Nuevo Perfil'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_USR_PROFILES_NEW);
@@ -286,7 +309,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionView = new DataGridAction();
$GridActionView->setId(self::ACTION_USR_PROFILES_VIEW);
+ $GridActionView->setType(DataGridActionType::VIEW_ITEM);
$GridActionView->setName(_('Ver Detalles de Perfil'));
+ $GridActionView->setTitle(_('Ver Detalles de Perfil'));
$GridActionView->setIcon($this->_iconView);
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionView->setOnClickArgs('this');
@@ -295,7 +320,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_USR_PROFILES_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Perfil'));
+ $GridActionEdit->setTitle(_('Editar Perfil'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -304,9 +331,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_USR_PROFILES_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Perfil'));
+ $GridActionDel->setTitle(_('Eliminar Perfil'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_USR_PROFILES_DELETE);
@@ -322,11 +350,14 @@ class UsersMgmtC extends Controller implements ActionsInterface
$Grid = new DataGridTab();
$Grid->setId('tblProfiles');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionView);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionDel);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Perfiles'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
@@ -441,10 +472,11 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionNew = new DataGridAction();
$GridActionNew->setId(self::ACTION_MGM_APITOKENS_NEW);
+ $GridActionNew->setType(DataGridActionType::NEW_ITEM);
$GridActionNew->setName(_('Nueva Autorización'));
+ $GridActionNew->setTitle(_('Nueva Autorización'));
$GridActionNew->setIcon($this->_iconAdd);
$GridActionNew->setSkip(true);
- $GridActionNew->setIsNew(true);
$GridActionNew->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionNew->setOnClickArgs('this');
$GridActionNew->setOnClickArgs(self::ACTION_MGM_APITOKENS_NEW);
@@ -452,7 +484,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionView = new DataGridAction();
$GridActionView->setId(self::ACTION_MGM_APITOKENS_VIEW);
+ $GridActionView->setType(DataGridActionType::VIEW_ITEM);
$GridActionView->setName(_('Ver token de Autorización'));
+ $GridActionView->setTitle(_('Ver token de Autorización'));
$GridActionView->setIcon($this->_iconView);
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionView->setOnClickArgs('this');
@@ -461,7 +495,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionEdit = new DataGridAction();
$GridActionEdit->setId(self::ACTION_MGM_APITOKENS_EDIT);
+ $GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
$GridActionEdit->setName(_('Editar Autorización'));
+ $GridActionEdit->setTitle(_('Editar Autorización'));
$GridActionEdit->setIcon($this->_iconEdit);
$GridActionEdit->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionEdit->setOnClickArgs('this');
@@ -470,9 +506,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_MGM_APITOKENS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Autorización'));
+ $GridActionDel->setTitle(_('Eliminar Autorización'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_MGM_APITOKENS_DELETE);
@@ -490,11 +527,14 @@ class UsersMgmtC extends Controller implements ActionsInterface
$Grid = new DataGridTab();
$Grid->setId('tblTokens');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionNew);
$Grid->setDataActions($GridActionView);
$Grid->setDataActions($GridActionEdit);
$Grid->setDataActions($GridActionDel);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Autorizaciones API'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
@@ -535,7 +575,9 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionView = new DataGridAction();
$GridActionView->setId(self::ACTION_MGM_PUBLICLINKS_VIEW);
+ $GridActionView->setType(DataGridActionType::VIEW_ITEM);
$GridActionView->setName(_('Ver Enlace'));
+ $GridActionView->setTitle(_('Ver Enlace'));
$GridActionView->setIcon($this->_iconView);
$GridActionView->setOnClickFunction('sysPassUtil.Common.appMgmtData');
$GridActionView->setOnClickArgs('this');
@@ -545,6 +587,7 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionRefresh = new DataGridAction();
$GridActionRefresh->setId(self::ACTION_MGM_PUBLICLINKS_REFRESH);
$GridActionRefresh->setName(_('Renovar Enlace'));
+ $GridActionRefresh->setTitle(_('Renovar Enlace'));
$GridActionRefresh->setIcon(new DataGridIcon('refresh', 'imgs/view.png', 'fg-green80'));
$GridActionRefresh->setOnClickFunction('sysPassUtil.Common.linksMgmtRefresh');
$GridActionRefresh->setOnClickArgs('this');
@@ -553,9 +596,10 @@ class UsersMgmtC extends Controller implements ActionsInterface
$GridActionDel = new DataGridAction();
$GridActionDel->setId(self::ACTION_MGM_PUBLICLINKS_DELETE);
+ $GridActionDel->setType(DataGridActionType::DELETE_ITEM);
$GridActionDel->setName(_('Eliminar Enlace'));
+ $GridActionDel->setTitle(_('Eliminar Enlace'));
$GridActionDel->setIcon($this->_iconDelete);
- $GridActionDel->setIsDelete(true);
$GridActionDel->setOnClickFunction('sysPassUtil.Common.appMgmtDelete');
$GridActionDel->setOnClickArgs('this');
$GridActionDel->setOnClickArgs(self::ACTION_MGM_PUBLICLINKS_DELETE);
@@ -581,10 +625,13 @@ class UsersMgmtC extends Controller implements ActionsInterface
$Grid = new DataGridTab();
$Grid->setId('tblLinks');
+ $Grid->setDataRowTemplate('datagrid-rows');
+ $Grid->setDataPagerTemplate('datagrid-nav-full');
$Grid->setDataActions($GridActionView);
$Grid->setDataActions($GridActionRefresh);
$Grid->setDataActions($GridActionDel);
$Grid->setHeader($GridHeaders);
+ $Grid->setPager($this->getPager($GridData->getDataCount(), !empty($search)));
$Grid->setData($GridData);
$Grid->setTitle(_('Gestión de Enlaces'));
$Grid->setTime(round(microtime() - $this->view->queryTimeStart, 5));
@@ -601,4 +648,23 @@ class UsersMgmtC extends Controller implements ActionsInterface
$this->view->assign('link', PublicLinkUtil::getLinks($this->view->itemId)[0]);
}
+
+ /**
+ * Devolver el paginador
+ *
+ * @param int $numRows El número de registros devueltos
+ * @param bool $filter Si está activo el filtrado
+ * @return DataGridPager
+ */
+ public function getPager($numRows, $filter = false)
+ {
+ $GridPager = new DataGridPager();
+ $GridPager->setFilterOn($filter);
+ $GridPager->setTotalRows($numRows);
+ $GridPager->setLimitStart(Request::analyze('start', 0));
+ $GridPager->setLimitCount(Request::analyze('count', Config::getValue('account_count', 15)));
+ $GridPager->setOnClickFunction('sysPassUtil.Common.searchSort');
+
+ return $GridPager;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Core/ActionsInterface.class.php b/inc/SP/Core/ActionsInterface.class.php
index da5088f4..1a06e667 100644
--- a/inc/SP/Core/ActionsInterface.class.php
+++ b/inc/SP/Core/ActionsInterface.class.php
@@ -59,29 +59,39 @@ interface ActionsInterface {
const ACTION_MGM_CATEGORIES_NEW = 611;
const ACTION_MGM_CATEGORIES_EDIT = 612;
const ACTION_MGM_CATEGORIES_DELETE = 613;
+ const ACTION_MGM_CATEGORIES_SEARCH = 615;
const ACTION_MGM_CUSTOMERS = 62;
const ACTION_MGM_CUSTOMERS_VIEW = 620;
const ACTION_MGM_CUSTOMERS_NEW = 621;
const ACTION_MGM_CUSTOMERS_EDIT = 622;
const ACTION_MGM_CUSTOMERS_DELETE = 623;
+ const ACTION_MGM_CUSTOMERS_SEARCH = 625;
const ACTION_MGM_APITOKENS = 63;
const ACTION_MGM_APITOKENS_NEW = 630;
const ACTION_MGM_APITOKENS_VIEW = 631;
const ACTION_MGM_APITOKENS_EDIT = 632;
const ACTION_MGM_APITOKENS_DELETE = 633;
+ const ACTION_MGM_APITOKENS_SEARCH = 635;
const ACTION_MGM_CUSTOMFIELDS = 64;
const ACTION_MGM_CUSTOMFIELDS_NEW = 640;
const ACTION_MGM_CUSTOMFIELDS_VIEW = 641;
const ACTION_MGM_CUSTOMFIELDS_EDIT = 642;
const ACTION_MGM_CUSTOMFIELDS_DELETE = 643;
+ const ACTION_MGM_CUSTOMFIELDS_SEARCH = 645;
const ACTION_MGM_PUBLICLINKS = 65;
const ACTION_MGM_PUBLICLINKS_NEW = 650;
const ACTION_MGM_PUBLICLINKS_VIEW = 651;
const ACTION_MGM_PUBLICLINKS_DELETE = 653;
const ACTION_MGM_PUBLICLINKS_REFRESH = 654;
+ const ACTION_MGM_PUBLICLINKS_SEARCH = 655;
const ACTION_MGM_FILES = 66;
const ACTION_MGM_FILES_VIEW = 661;
const ACTION_MGM_FILES_DELETE = 663;
+ const ACTION_MGM_FILES_SEARCH = 665;
+ const ACTION_MGM_ACCOUNTS = 67;
+ const ACTION_MGM_ACCOUNTS_VIEW = 671;
+ const ACTION_MGM_ACCOUNTS_DELETE = 673;
+ const ACTION_MGM_ACCOUNTS_SEARCH = 675;
const ACTION_USR = 70;
const ACTION_USR_USERS = 71;
const ACTION_USR_USERS_VIEW= 710;
diff --git a/inc/SP/Core/Template.class.php b/inc/SP/Core/Template.class.php
index d63fac3a..451dcfda 100644
--- a/inc/SP/Core/Template.class.php
+++ b/inc/SP/Core/Template.class.php
@@ -56,7 +56,9 @@ class Template
*/
public function __construct($file = null, array $vars = array())
{
- $this->addTemplate($file);
+ if (!is_null($file)) {
+ $this->addTemplate($file);
+ }
if (!empty($vars)) {
$this->setVars($vars);
@@ -71,19 +73,37 @@ class Template
*/
public function addTemplate($file)
{
- if (!is_null($file) && $this->checkTemplate($file)) {
- return true;
+ try {
+ $template = $this->checkTemplate($file);
+ $this->setTemplate($template);
+ } catch (InvalidArgumentException $e) {
+ return false;
}
- return false;
+ return true;
+ }
+
+ /**
+ * Añadir una nueva plantilla dentro de una plantilla
+ *
+ * @param string $file Con el nombre del archivo de plantilla
+ * @return bool
+ */
+ public function includeTemplate($file)
+ {
+ try {
+ $template = $this->checkTemplate($file);
+ return $template;
+ } catch (InvalidArgumentException $e) {
+ return false;
+ }
}
/**
* Comprobar si un archivo de plantilla existe y se puede leer
*
* @param string $file Con el nombre del archivo
- * @return bool
- * @throws InvalidArgumentException
+ * @return string La ruta al archivo de la plantilla
*/
private function checkTemplate($file)
{
@@ -94,8 +114,7 @@ class Template
throw new InvalidArgumentException(sprintf(_('No es posible obtener la plantilla "%s" : %s'), $file, $template));
}
- $this->setTemplate($template);
- return true;
+ return $template;
}
/**
diff --git a/inc/SP/Html/DataGrid/DataGridActionBase.class.php b/inc/SP/Html/DataGrid/DataGridActionBase.class.php
index 6ad4f581..234a6178 100644
--- a/inc/SP/Html/DataGrid/DataGridActionBase.class.php
+++ b/inc/SP/Html/DataGrid/DataGridActionBase.class.php
@@ -67,24 +67,12 @@ abstract class DataGridActionBase implements DataGridActionInterface
* @var DataGridIcon
*/
private $_icon = null;
- /**
- * Si es una acción de eliminar elementos
- *
- * @var bool
- */
- private $_isDelete = false;
/**
* Si se debe de omitir para los elementos del listado
*
* @var bool
*/
private $_isSkip = false;
- /**
- * Si es una acción para crear elementos
- *
- * @var bool
- */
- private $_isNew = false;
/**
* La columna de origen de datos que condiciona esta acción
*
@@ -97,6 +85,12 @@ abstract class DataGridActionBase implements DataGridActionInterface
* @var bool
*/
private $_isHelper;
+ /**
+ * El tipo de acción
+ *
+ * @var int
+ */
+ private $_type = 0;
/**
* @return string
@@ -208,38 +202,6 @@ abstract class DataGridActionBase implements DataGridActionInterface
return $this->_isSkip;
}
- /**
- * @param $delete bool
- */
- public function setIsDelete($delete)
- {
- $this->_isDelete = $delete;
- }
-
- /**
- * @return bool
- */
- public function isDelete()
- {
- return $this->_isDelete;
- }
-
- /**
- * @param bool $new
- */
- public function setIsNew($new)
- {
- $this->_isNew = $new;
- }
-
- /**
- * @return bool
- */
- public function isNew()
- {
- return $this->_isNew;
- }
-
/**
* @param bool $helper
*/
@@ -271,4 +233,20 @@ abstract class DataGridActionBase implements DataGridActionInterface
{
return $this->_filterRowSource;
}
+
+ /**
+ * @param int $type El tipo de acción definido en DataGridActionType
+ */
+ public function setType($type)
+ {
+ $this->_type = $type;
+ }
+
+ /**
+ * @return int El tipo de acción
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridActionInterface.class.php b/inc/SP/Html/DataGrid/DataGridActionInterface.class.php
index 23940ea9..05d94275 100644
--- a/inc/SP/Html/DataGrid/DataGridActionInterface.class.php
+++ b/inc/SP/Html/DataGrid/DataGridActionInterface.class.php
@@ -97,26 +97,6 @@ interface DataGridActionInterface
*/
public function isSkip();
- /**
- * @param $delete bool
- */
- public function setIsDelete($delete);
-
- /**
- * @return bool
- */
- public function isDelete();
-
- /**
- * @param $new bool
- */
- public function setIsNew($new);
-
- /**
- * @return bool
- */
- public function isNew();
-
/**
* @param bool $helper
*/
@@ -136,4 +116,14 @@ interface DataGridActionInterface
* @return string
*/
public function getFilterRowSource();
+
+ /**
+ * @param int $type El tipo de acción definido en DataGridActionType
+ */
+ public function setType($type);
+
+ /**
+ * @return int El tipo de acción
+ */
+ public function getType();
}
diff --git a/inc/SP/Html/DataGrid/DataGridActionSearch.class.php b/inc/SP/Html/DataGrid/DataGridActionSearch.class.php
new file mode 100644
index 00000000..6984d976
--- /dev/null
+++ b/inc/SP/Html/DataGrid/DataGridActionSearch.class.php
@@ -0,0 +1,84 @@
+.
+ *
+ */
+
+namespace SP\Html\DataGrid;
+
+/**
+ * Class DataGridActionSearch para definir una acción de búsqueda de datos
+ *
+ * @package SP\Html\DataGrid
+ */
+class DataGridActionSearch extends DataGridActionBase
+{
+ /**
+ * @var string
+ */
+ private $_onSubmitFunction = '';
+
+ /**
+ * Los argumentos de la función OnSubmit
+ *
+ * @var array
+ */
+ private $_onSubmitArgs = array();
+
+ /**
+ * DataGridActionSearch constructor.
+ */
+ public function __construct()
+ {
+ $this->setSkip(true);
+ }
+
+ /**
+ * @return string
+ */
+ public function getOnSubmit()
+ {
+ $args = array();
+
+ foreach ($this->_onSubmitArgs as $arg) {
+ $args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg;
+ }
+
+ return 'return ' . $this->_onSubmitFunction . '(' . implode(',', $args) . ');';
+ }
+
+ /**
+ * @param string $onSubmitFunction
+ */
+ public function setOnSubmitFunction($onSubmitFunction)
+ {
+ $this->_onSubmitFunction = $onSubmitFunction;
+ }
+
+ /**
+ * @param array $args
+ */
+ public function setOnSubmitArgs($args)
+ {
+ $this->_onSubmitArgs[] = $args;
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridActionType.class.php b/inc/SP/Html/DataGrid/DataGridActionType.class.php
new file mode 100644
index 00000000..569931f2
--- /dev/null
+++ b/inc/SP/Html/DataGrid/DataGridActionType.class.php
@@ -0,0 +1,40 @@
+.
+ *
+ */
+
+namespace SP\Html\DataGrid;
+
+/**
+ * Class DataGridActionType para definir los tipos de acciones
+ *
+ * @package SP\Html\DataGrid
+ */
+class DataGridActionType
+{
+ const NEW_ITEM = 1;
+ const VIEW_ITEM = 2;
+ const EDIT_ITEM = 3;
+ const DELETE_ITEM = 4;
+ const SEARCH_ITEM = 5;
+}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridBase.class.php b/inc/SP/Html/DataGrid/DataGridBase.class.php
index 005a1672..f323cf10 100644
--- a/inc/SP/Html/DataGrid/DataGridBase.class.php
+++ b/inc/SP/Html/DataGrid/DataGridBase.class.php
@@ -25,7 +25,9 @@
namespace SP\Html\DataGrid;
+use InvalidArgumentException;
use SP\Core\ActionsInterface;
+use SP\Core\Themes;
use SplObjectStorage;
/**
@@ -53,6 +55,12 @@ abstract class DataGridBase implements DataGridInterface
* @var DataGridData
*/
private $_data;
+ /**
+ * El paginador
+ *
+ * @var DataGridPagerBase
+ */
+ private $_pager;
/**
* Las acciones asociadas a los elementos de la matriz
*
@@ -65,6 +73,30 @@ abstract class DataGridBase implements DataGridInterface
* @var int
*/
private $_onCloseAction = 0;
+ /**
+ * La pantilla a utilizar para presentar la cabecera
+ *
+ * @var string
+ */
+ private $_headerTemplate;
+ /**
+ * La pantilla a utilizar para presentar las acciones
+ *
+ * @var string
+ */
+ private $_actionsTemplate;
+ /**
+ * La pantilla a utilizar para presentar el paginador
+ *
+ * @var string
+ */
+ private $_pagerTemplate;
+ /**
+ * La pantilla a utilizar para presentar los datos
+ *
+ * @var string
+ */
+ private $_rowsTemplate;
/**
* @return int
@@ -131,9 +163,9 @@ abstract class DataGridBase implements DataGridInterface
}
/**
- * @param DataGridAction $action
+ * @param DataGridActionBase $action
*/
- public function setDataActions(DataGridAction $action)
+ public function setDataActions(DataGridActionBase $action)
{
if (is_null($this->_actions)) {
$this->_actions = new SplObjectStorage();
@@ -151,10 +183,126 @@ abstract class DataGridBase implements DataGridInterface
}
/**
- * @return mixed
+ * @return $this
*/
public function getGrid()
{
- // TODO: Implement getGrid() method.
+ return $this;
}
+
+ /**
+ * Establecer la plantilla utilizada para la cabecera
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataHeaderTemplate($template)
+ {
+ $this->_headerTemplate = $this->checkTemplate($template);
+ }
+
+ /**
+ * Comprobar si existe una plantilla y devolver la ruta completa
+ *
+ * @param $template
+ * @return string
+ */
+ protected function checkTemplate($template)
+ {
+ $file = VIEW_PATH . DIRECTORY_SEPARATOR . Themes::$theme . DIRECTORY_SEPARATOR . $template . '.inc';
+
+ if (!is_readable($file)) {
+ throw new InvalidArgumentException(sprintf(_('No es posible obtener la plantilla "%s" : %s'), $template, $file));
+ }
+
+ return $file;
+ }
+
+ /**
+ * Devolver la plantilla utilizada para la cabecera
+ *
+ * @return string
+ */
+ public function getDataHeaderTemplate()
+ {
+ return $this->_headerTemplate;
+ }
+
+ /**
+ * Establecer la plantilla utilizada para las acciones
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataActionsTemplate($template)
+ {
+ $this->_actionsTemplate = $this->checkTemplate($template);
+ }
+
+ /**
+ * Devolver la plantilla utilizada para las acciones
+ *
+ * @return string
+ */
+ public function getDataActionsTemplate()
+ {
+ return $this->_actionsTemplate;
+ }
+
+ /**
+ * Establecer la plantilla utilizada para el paginador
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataPagerTemplate($template)
+ {
+ $this->_pagerTemplate = $this->checkTemplate($template);
+ }
+
+ /**
+ * Devolver la plantilla utilizada para el paginador
+ *
+ * @return string
+ */
+ public function getDataPagerTemplate()
+ {
+ return $this->_pagerTemplate;
+ }
+
+ /**
+ * @param string $template El nombre de la plantilla a utilizar
+ * @return mixed
+ * @throws InvalidArgumentException
+ */
+ public function setDataRowTemplate($template)
+ {
+ $this->_rowsTemplate = $this->checkTemplate($template);
+ }
+
+ /**
+ * @return string
+ */
+ public function getDataRowTemplate()
+ {
+ return $this->_rowsTemplate;
+ }
+
+ /**
+ * Establecer el paginador
+ *
+ * @param DataGridPagerBase $pager
+ */
+ public function setPager(DataGridPagerBase $pager)
+ {
+ $this->_pager = $pager;
+ }
+
+ /**
+ * Devolver el paginador
+ *
+ * @return DataGridPagerBase
+ */
+ public function getPager()
+ {
+ return $this->_pager;
+ }
+
}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridDataBase.class.php b/inc/SP/Html/DataGrid/DataGridDataBase.class.php
index 23f4d85e..a0cdc5d5 100644
--- a/inc/SP/Html/DataGrid/DataGridDataBase.class.php
+++ b/inc/SP/Html/DataGrid/DataGridDataBase.class.php
@@ -56,6 +56,10 @@ abstract class DataGridDataBase implements DataGridDataInterface
* @var array
*/
private $_sourcesWithIcon = array();
+ /**
+ * @var int
+ */
+ private $_dataCount = 0;
/**
* @return array
@@ -110,6 +114,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function setData(array $data)
{
+ $this->_dataCount = count($data);
$this->_data = $data;
}
@@ -121,4 +126,14 @@ abstract class DataGridDataBase implements DataGridDataInterface
{
$this->_sourcesWithIcon[] = array($source, $icon);
}
+
+ /**
+ * Devolver el número de elementos obtenidos
+ *
+ * @return int
+ */
+ public function getDataCount()
+ {
+ return $this->_dataCount;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridDataInterface.class.php b/inc/SP/Html/DataGrid/DataGridDataInterface.class.php
index e17cacc7..e604e539 100644
--- a/inc/SP/Html/DataGrid/DataGridDataInterface.class.php
+++ b/inc/SP/Html/DataGrid/DataGridDataInterface.class.php
@@ -33,44 +33,66 @@ namespace SP\Html\DataGrid;
interface DataGridDataInterface
{
/**
+ * Establecer los orígenes de datos de la consulta
+ *
* @param $source string
*/
public function addDataRowSource($source);
/**
+ * Devolver los orígenes de datos de la consulta
+ *
* @return array
*/
public function getDataRowSources();
/**
+ * Establecer el origen de datos utilizado como Id de los elementos
+ *
* @param $id string
*/
public function setDataRowSourceId($id);
/**
+ * Devolver el origen de datos utilizado como Id de los elementos
+ *
* @return string
*/
public function getDataRowSourceId();
/**
+ * Establecer los datos de la consulta
+ *
* @param $data array
*/
public function setData(array $data);
/**
+ * Devolver los datos de la consulta
+ *
* @return array
*/
public function getData();
/**
+ * Establecer los orígenes de datos que se muestran con iconos
+ *
* @param $source string
* @param $icon DatagridIcon
- * @return
*/
public function addDataRowSourceWithIcon($source, $icon);
/**
+ * Devolver los orígenes de datos que se muestran con iconos
+ *
* @return array
*/
public function getDataRowSourcesWithIcon();
+
+ /**
+ * Devolver el número de elementos obtenidos
+ *
+ * @return int
+ */
+ public function getDataCount();
}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridInterface.class.php b/inc/SP/Html/DataGrid/DataGridInterface.class.php
index 52359589..c13e0253 100644
--- a/inc/SP/Html/DataGrid/DataGridInterface.class.php
+++ b/inc/SP/Html/DataGrid/DataGridInterface.class.php
@@ -65,12 +65,12 @@ interface DataGridInterface
public function getData();
/**
- * @param DataGridAction $action
+ * @param DataGridActionBase $action
*/
- public function setDataActions(DataGridAction $action);
+ public function setDataActions(DataGridActionBase $action);
/**
- * @return DataGridAction
+ * @return DataGridActionBase
*/
public function getDataActions();
@@ -79,8 +79,78 @@ interface DataGridInterface
*/
public function getGrid();
+ /**
+ * Establecer el paginador
+ *
+ * @param DataGridPagerBase $pager
+ */
+ public function setPager(DataGridPagerBase $pager);
+
+ /**
+ * Devolver el paginador
+ *
+ * @return DataGridPagerBase
+ */
+ public function getPager();
+
/**
* @param ActionsInterface $action
*/
public function setOnCloseAction(ActionsInterface $action);
+
+ /**
+ * Establecer la plantilla utilizada para la cabecera
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataHeaderTemplate($template);
+
+ /**
+ * Devolver la plantilla utilizada para la cabecera
+ *
+ * @return string
+ */
+ public function getDataHeaderTemplate();
+
+ /**
+ * Establecer la plantilla utilizada para las acciones
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataActionsTemplate($template);
+
+ /**
+ * Devolver la plantilla utilizada para las acciones
+ *
+ * @return string
+ */
+ public function getDataActionsTemplate();
+
+ /**
+ * Establecer la plantilla utilizada para el paginador
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataPagerTemplate($template);
+
+ /**
+ * Devolver la plantilla utilizada para el paginador
+ *
+ * @return string
+ */
+ public function getDataPagerTemplate();
+
+ /**
+ * Establcer la plantilla utilizada para los datos de la consulta
+ *
+ * @param string $template El nombre de la plantilla a utilizar
+ */
+ public function setDataRowTemplate($template);
+
+ /**
+ * Devolver la plantilla utilizada para los datos de la consulta
+ *
+ * @return string
+ */
+ public function getDataRowTemplate();
}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridPager.class.php b/inc/SP/Html/DataGrid/DataGridPager.class.php
new file mode 100644
index 00000000..a9510f29
--- /dev/null
+++ b/inc/SP/Html/DataGrid/DataGridPager.class.php
@@ -0,0 +1,36 @@
+.
+ *
+ */
+
+namespace SP\Html\DataGrid;
+
+/**
+ * Class DataGridPager
+ *
+ * @package SP\Html\DataGrid
+ */
+class DataGridPager extends DataGridPagerBase
+{
+
+}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridPagerBase.class.php b/inc/SP/Html/DataGrid/DataGridPagerBase.class.php
new file mode 100644
index 00000000..62fe2db0
--- /dev/null
+++ b/inc/SP/Html/DataGrid/DataGridPagerBase.class.php
@@ -0,0 +1,263 @@
+.
+ *
+ */
+
+namespace SP\Html\DataGrid;
+
+/**
+ * Class DataGridPagerBase para implementar los métodos del paginador
+ *
+ * @package SP\Html\DataGrid
+ */
+abstract class DataGridPagerBase implements DataGridPagerInterface
+{
+ /**
+ * @var int
+ */
+ protected $_searchKey = 0;
+ /**
+ * @var int
+ */
+ protected $_limitStart = 0;
+ /**
+ * @var int
+ */
+ protected $_limitCount = 0;
+ /**
+ * @var int
+ */
+ protected $_totalRows = 0;
+ /**
+ * @var bool
+ */
+ protected $_filterOn = false;
+ /**
+ * @var string
+ */
+ protected $_onClickFunction = '';
+ /**
+ * @var array
+ */
+ protected $_onClickArgs = array();
+
+
+ /**
+ * Establecer el campo de la búsqueda
+ *
+ * @param int $searchKey
+ */
+ public function setSearchKey($searchKey)
+ {
+ $this->_searchKey = $searchKey;
+ }
+
+ /**
+ * Devolver el campo de la búsqueda
+ *
+ * @return int
+ */
+ public function getSearchKey()
+ {
+ return $this->_searchKey;
+ }
+
+ /**
+ * Establecer el registro de inicio de la página
+ *
+ * @param int $limitStart
+ */
+ public function setLimitStart($limitStart)
+ {
+ $this->_limitStart = $limitStart;
+ }
+
+ /**
+ * Devolver el registro de inicio de la página
+ *
+ * @return int
+ */
+ public function getLimitStart()
+ {
+ return $this->_limitStart;
+ }
+
+ /**
+ * Establecer el número de registros en una página
+ *
+ * @param int $limitCount
+ */
+ public function setLimitCount($limitCount)
+ {
+ $this->_limitCount = $limitCount;
+ }
+
+ /**
+ * Devolver el número de registros en una página
+ *
+ * @return mixed
+ */
+ public function getLimitCount()
+ {
+ return $this->_limitCount;
+ }
+
+ /**
+ * Devolver el número de página inicial
+ *
+ * @return int
+ */
+ public function getFirstPage()
+ {
+ return ceil(($this->_limitStart + 1) / $this->_limitCount);
+ }
+
+ /**
+ * Devolver el número de página final
+ *
+ * @return int
+ */
+ public function getLastPage()
+ {
+ return ceil($this->_totalRows / $this->_limitCount);
+ }
+
+ /**
+ * Establecer el número total de registros obtenidos
+ *
+ * @param int $totalRows
+ */
+ public function setTotalRows($totalRows)
+ {
+ $this->_totalRows = $totalRows;
+ }
+
+ /**
+ * Devolver el número total de registros obtenidos
+ *
+ * @return int
+ */
+ public function getTotalRows()
+ {
+ return $this->_totalRows;
+ }
+
+ /**
+ * Establecer si está activado el filtro
+ *
+ * @param bool $filterOn
+ */
+ public function setFilterOn($filterOn)
+ {
+ $this->_filterOn = $filterOn;
+ }
+
+ /**
+ * Devolver si está activado el filtro
+ *
+ * @return bool
+ */
+ public function getFilterOn()
+ {
+ return $this->_filterOn;
+ }
+
+ /**
+ * Establecer la función javascript para paginar
+ *
+ * @param string $function
+ */
+ public function setOnClickFunction($function)
+ {
+ $this->_onClickFunction = $function;
+ }
+
+ /**
+ * Devolver la función javascript para paginar
+ *
+ * @return string
+ */
+ public function getOnClick()
+ {
+ $args = array();
+
+ foreach ($this->_onClickArgs as $arg) {
+ $args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg;
+ }
+
+ return $this->_onClickFunction . '(' . implode(',', $args) . ')';
+ }
+
+ /**
+ * Establecer los argumentos de la función OnClick
+ *
+ * @param string $args
+ */
+ public function setOnClickArgs($args)
+ {
+ $this->_onClickArgs[] = $args;
+ }
+
+ /**
+ * Devolver la funcion para ir a la primera página
+ *
+ * @return string
+ */
+ public function getOnClickFirst()
+ {
+ return $this->_onClickFunction . '(' . $this->_searchKey .', 0, 1)';
+ }
+
+ /**
+ * Devolver la funcion para ir a la última página
+ *
+ * @return string
+ */
+ public function getOnClickLast()
+ {
+ $limitLast = (($this->_totalRows % $this->_limitCount) == 0) ? $this->_totalRows - $this->_limitCount : floor($this->_totalRows / $this->_limitCount) * $this->_limitCount;
+
+ return $this->_onClickFunction . '(' . $this->_searchKey . ',' . $limitLast . ',1)';
+ }
+
+ /**
+ * Devolver la funcion para ir a la siguiente página
+ *
+ * @return string
+ */
+ public function getOnClickNext()
+ {
+ return $this->_onClickFunction . '(' . $this->_searchKey . ',' . ($this->_limitStart + $this->_limitCount) . ',1)';
+ }
+
+ /**
+ * Devolver la funcion para ir a la página anterior
+ *
+ * @return string
+ */
+ public function getOnClickPrev()
+ {
+ return $this->_onClickFunction .'(' . $this->_searchKey . ',' . ($this->_limitStart - $this->_limitCount) . ',1)';
+ }
+
+}
\ No newline at end of file
diff --git a/inc/SP/Html/DataGrid/DataGridPagerInterface.class.php b/inc/SP/Html/DataGrid/DataGridPagerInterface.class.php
new file mode 100644
index 00000000..4a440989
--- /dev/null
+++ b/inc/SP/Html/DataGrid/DataGridPagerInterface.class.php
@@ -0,0 +1,154 @@
+.
+ *
+ */
+
+namespace SP\Html\DataGrid;
+
+/**
+ * Interface DataGridPagerInterface para la definición del paginador
+ *
+ * @package SP\Html\DataGrid
+ */
+interface DataGridPagerInterface
+{
+ /**
+ * Establecer el campo de la búsqueda
+ *
+ * @param int $searchKey
+ */
+ public function setSearchKey($searchKey);
+
+ /**
+ * Devolver el campo de la búsqueda
+ *
+ * @return int
+ */
+ public function getSearchKey();
+
+ /**
+ * Establecer el registro de inicio de la página
+ *
+ * @param int $limitStart
+ */
+ public function setLimitStart($limitStart);
+
+ /**
+ * Devolver el registro de inicio de la página
+ *
+ * @return int
+ */
+ public function getLimitStart();
+
+ /**
+ * Establecer el número de registros en una página
+ *
+ * @param int $limitCount
+ */
+ public function setLimitCount($limitCount);
+
+ /**
+ * Devolver el número de registros en una página
+ *
+ * @return mixed
+ */
+ public function getLimitCount();
+
+ /**
+ * Establecer el número total de registros obtenidos
+ *
+ * @param int $totalRows
+ */
+ public function setTotalRows($totalRows);
+
+ /**
+ * Devolver el número total de registros obtenidos
+ *
+ * @return int
+ */
+ public function getTotalRows();
+
+ /**
+ * Establecer si está activado el filtro
+ *
+ * @param bool $filterOn
+ */
+ public function setFilterOn($filterOn);
+
+ /**
+ * Devolver si está activado el filtro
+ *
+ * @return bool
+ */
+ public function getFilterOn();
+
+ /**
+ * Establecer la función javascript para paginar
+ *
+ * @param string $function
+ */
+ public function setOnClickFunction($function);
+
+ /**
+ * Devolver la función javascript para paginar
+ *
+ * @return string
+ */
+ public function getOnClick();
+
+ /**
+ * Establecer los argumentos de la función OnClick
+ *
+ * @param string $args
+ */
+ public function setOnClickArgs($args);
+
+ /**
+ * Devolver la funcion para ir a la primera página
+ *
+ * @return string
+ */
+ public function getOnClickFirst();
+
+ /**
+ * Devolver la funcion para ir a la última página
+ *
+ * @return string
+ */
+ public function getOnClickLast();
+
+ /**
+ * Devolver la funcion para ir a la siguiente página
+ *
+ * @return string
+ */
+ public function getOnClickNext();
+
+ /**
+ * Devolver la funcion para ir a la página anterior
+ *
+ * @return string
+ */
+ public function getOnClickPrev();
+
+}
\ No newline at end of file
diff --git a/inc/SP/Html/Html.class.php b/inc/SP/Html/Html.class.php
index b3def0f4..45616c27 100644
--- a/inc/SP/Html/Html.class.php
+++ b/inc/SP/Html/Html.class.php
@@ -40,8 +40,8 @@ class Html
*/
public static function sanitize(&$data)
{
- if (!$data) {
- return false;
+ if (empty($data)) {
+ return $data;
}
if (is_array($data)) {
diff --git a/inc/SP/Http/Request.class.php b/inc/SP/Http/Request.class.php
index 7f28ff84..40a12d12 100644
--- a/inc/SP/Http/Request.class.php
+++ b/inc/SP/Http/Request.class.php
@@ -36,20 +36,61 @@ use SP\Core\Init;
*/
class Request
{
+ /**
+ * Comprobar el método utilizado para enviar un formulario.
+ *
+ * @param string $method con el método utilizado.
+ */
+ public static function checkReferer($method)
+ {
+ if ($_SERVER['REQUEST_METHOD'] !== strtoupper($method)
+ || !isset($_SERVER['HTTP_REFERER'])
+ || !preg_match('#' . Init::$WEBROOT . '/.*$#', $_SERVER['HTTP_REFERER'])
+ ) {
+ Init::initError(_('No es posible acceder directamente a este archivo'));
+ exit();
+ }
+ }
+
+ /**
+ * Analizar un valor encriptado y devolverlo desencriptado
+ *
+ * @param $param
+ * @return string
+ */
+ public static function analyzeEncrypted($param)
+ {
+ $encryptedData = self::analyze($param, '', false, false, false);
+
+ if ($encryptedData === '') {
+ return '';
+ }
+
+ try {
+ // Desencriptar con la clave RSA
+ $CryptPKI = new CryptPKI();
+ $clearData = $CryptPKI->decryptRSA(base64_decode($encryptedData));
+ } catch (\Exception $e) {
+ return $encryptedData;
+ }
+
+ return $clearData;
+ }
+
/**
* Obtener los valores de variables $_GET y $_POST
* y devolverlos limpios con el tipo correcto o esperado.
*
- * @param string $param con el parámetro a consultar
- * @param mixed $default valor por defecto a devolver
- * @param bool $check comprobar si el parámetro está presente
- * @param mixed $force valor devuelto si el parámeto está definido
- * @param bool $sanitize escapar/eliminar carácteres especiales
+ * @param string $param con el parámetro a consultar
+ * @param mixed $default valor por defecto a devolver
+ * @param bool $check comprobar si el parámetro está presente
+ * @param mixed $force valor devuelto si el parámeto está definido
+ * @param bool $sanitize escapar/eliminar carácteres especiales
* @return mixed si está presente el parámeto en la petición devuelve bool. Si lo está, devuelve el valor.
*/
public static function analyze($param, $default = '', $check = false, $force = false, $sanitize = true)
{
- switch($_SERVER['REQUEST_METHOD']){
+ switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
if (!isset($_GET[$param])) {
return ($force) ? !$force : $default;
@@ -83,62 +124,33 @@ class Request
*/
private static function parse($value, $default, $sanitize)
{
- if (is_array($value)){
- foreach($value as &$data){
+ if (is_array($value)) {
+ foreach ($value as &$data) {
self::parse($data, $default, $sanitize);
}
return $value;
}
- if ((is_numeric($value) && !is_string($default)) || is_numeric($default)) {
+ if ((is_numeric($value) || is_numeric($default))
+ && !is_string($default)
+ ) {
return intval($value);
}
if (is_string($value)) {
- return ($sanitize === true) ? Html::sanitize($value) : $value;
+ return ($sanitize === true) ? Html::sanitize($value) : (string)$value;
}
}
/**
- * Comprobar el método utilizado para enviar un formulario.
+ * Comprobar si se realiza una recarga de la página
*
- * @param string $method con el método utilizado.
+ * @return bool
*/
- public static function checkReferer($method)
+ public static function checkReload()
{
- if ($_SERVER['REQUEST_METHOD'] !== strtoupper($method)
- || !isset($_SERVER['HTTP_REFERER'])
- || !preg_match('#' . Init::$WEBROOT . '/.*$#', $_SERVER['HTTP_REFERER'])
- ) {
- Init::initError(_('No es posible acceder directamente a este archivo'));
- exit();
- }
- }
-
- /**
- * Analizar un valor encriptado y devolverlo desencriptado
- *
- * @param $param
- * @return string
- */
- public static function analyzeEncrypted($param)
- {
- $encryptedData = self::analyze($param, '', false, false, false);
-
- if ($encryptedData === ''){
- return '';
- }
-
- try {
- // Desencriptar con la clave RSA
- $CryptPKI = new CryptPKI();
- $clearData = $CryptPKI->decryptRSA(base64_decode($encryptedData));
- } catch (\Exception $e) {
- return $encryptedData;
- }
-
- return $clearData;
+ return (self::getRequestHeaders('Cache-Control') == 'max-age=0');
}
/**
@@ -174,16 +186,6 @@ class Request
return $headers;
}
- /**
- * Comprobar si se realiza una recarga de la página
- *
- * @return bool
- */
- public static function checkReload()
- {
- return (self::getRequestHeaders('Cache-Control') == 'max-age=0');
- }
-
/**
* Comprobar si existen parámetros pasados por POST para enviarlos por GET
*/
diff --git a/inc/SP/Mgmt/Category.class.php b/inc/SP/Mgmt/Category.class.php
index d483cddc..99bdaa2d 100644
--- a/inc/SP/Mgmt/Category.class.php
+++ b/inc/SP/Mgmt/Category.class.php
@@ -44,85 +44,6 @@ class Category
public static $categoryDescription;
public static $categoryLastId;
- /**
- * Obtener el id de una categoría por el nombre.
- *
- * @param string $categoryName con el nombre de la categoría
- * @return bool|int si la consulta es errónea devuelve bool. Si no hay registros o se obtiene el id, devuelve int
- */
- public static function getCategoryIdByName($categoryName)
- {
- $query = 'SELECT category_id FROM categories WHERE category_name = :name LIMIT 1';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($categoryName, 'name');
-
- $queryRes = DB::getResults($Data);
-
- if ($queryRes === false || DB::$lastNumRows === 0) {
- return false;
- }
-
- return $queryRes->category_id;
- }
-
- /**
- * Crear una nueva categoría en la BBDD.
- *
- * @throws SPException
- */
- public static function addCategory()
- {
- if (self::checkDupCategory()){
- throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
- }
-
- $query = 'INSERT INTO categories SET category_name = :name ,category_description = :description';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam(self::$categoryName, 'name');
- $Data->addParam(self::$categoryDescription, 'description');
-
- if (DB::getQuery($Data) === false) {
- throw new SPException(SPException::SP_CRITICAL, _('Error al crear la categoría'));
- }
-
- self::$categoryLastId = DB::$lastId;
-
- $Log = new Log(_('Nueva Categoría'));
- $Log->addDetails(Html::strongText(_('Categoría')), self::$categoryName);
- $Log->writeLog();
-
- Email::sendEmail($Log);
- }
-
- /**
- * Comprobar si existe una categoría duplicada.
- *
- * @param int $id con el Id de la categoría a consultar
- * @return bool
- */
- public static function checkDupCategory($id = null)
- {
-
- $Data = new QueryData();
-
- if (is_null($id)) {
- $query = 'SELECT category_id FROM categories WHERE category_name = :name';
- } else {
- $query = 'SELECT category_id FROM categories WHERE category_name = :name AND category_id <> :id';
-
- $Data->addParam($id, 'id');
- }
-
- $Data->setQuery($query);
- $Data->addParam(self::$categoryName, 'name');
-
- return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
- }
-
/**
* Eliminar una categoría de la BBDD.
*
@@ -156,6 +77,48 @@ class Category
Email::sendEmail($Log);
}
+ /**
+ * Comprobar si una categoría está en uso por cuentas.
+ *
+ * @param int $id con el Id de la categoría a consultar
+ * @return bool|string
+ */
+ public static function checkCategoryInUse($id)
+ {
+ $numAccounts = self::getCategoriesInAccounts($id);
+
+ $out = '';
+
+ if ($numAccounts) {
+ $out[] = _('Cuentas') . " (" . $numAccounts . ")";
+ }
+
+ if (is_array($out)) {
+ return implode('
', $out);
+ }
+
+ return true;
+ }
+
+ /**
+ * Obtener el número de cuentas que usan una categoría.
+ *
+ * @param int $id con el Id de la categoría a consultar
+ * @return false|integer con el número total de cuentas
+ */
+ private static function getCategoriesInAccounts($id)
+ {
+ $query = 'SELECT account_id FROM accounts WHERE account_categoryId = :id';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($id, 'id');
+
+ DB::getQuery($Data);
+
+ return DB::$lastNumRows;
+ }
+
/**
* Obtiene el nombre de la categoría a partir del Id.
*
@@ -187,7 +150,7 @@ class Category
*/
public static function updateCategory($id)
{
- if (self::checkDupCategory($id)){
+ if (self::checkDupCategory($id)) {
throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
}
@@ -214,6 +177,31 @@ class Category
Email::sendEmail($Log);
}
+ /**
+ * Comprobar si existe una categoría duplicada.
+ *
+ * @param int $id con el Id de la categoría a consultar
+ * @return bool
+ */
+ public static function checkDupCategory($id = null)
+ {
+
+ $Data = new QueryData();
+
+ if (is_null($id)) {
+ $query = 'SELECT category_id FROM categories WHERE category_name = :name';
+ } else {
+ $query = 'SELECT category_id FROM categories WHERE category_name = :name AND category_id <> :id';
+
+ $Data->addParam($id, 'id');
+ }
+
+ $Data->setQuery($query);
+ $Data->addParam(self::$categoryName, 'name');
+
+ return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
+ }
+
/**
* Obtener los datos de una categoría.
*
@@ -284,56 +272,15 @@ class Category
return $queryRes;
}
- /**
- * Comprobar si una categoría está en uso por cuentas.
- *
- * @param int $id con el Id de la categoría a consultar
- * @return bool|string
- */
- public static function checkCategoryInUse($id)
- {
- $numAccounts = self::getCategoriesInAccounts($id);
-
- $out = '';
-
- if ($numAccounts) {
- $out[] = _('Cuentas') . " (" . $numAccounts . ")";
- }
-
- if (is_array($out)) {
- return implode('
', $out);
- }
-
- return true;
- }
-
- /**
- * Obtener el número de cuentas que usan una categoría.
- *
- * @param int $id con el Id de la categoría a consultar
- * @return false|integer con el número total de cuentas
- */
- private static function getCategoriesInAccounts($id)
- {
- $query = 'SELECT account_id FROM accounts WHERE account_categoryId = :id';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($id, 'id');
-
- DB::getQuery($Data);
-
- return DB::$lastNumRows;
- }
-
/**
* Crear una categoría y devolver el id si existe o de la nueva
*
- * @param $name string El nombre de la categoría
+ * @param $name string El nombre de la categoría
* @param $description string La descripción de la categoría
* @return int
*/
- public static function addCategoryReturnId($name, $description = ''){
+ public static function addCategoryReturnId($name, $description = '')
+ {
// Comprobamos si existe la categoría o la creamos
$newCategoryId = self::getCategoryIdByName($name);
@@ -344,10 +291,96 @@ class Category
try {
self::addCategory();
$newCategoryId = self::$categoryLastId;
- } catch (SPException $e){
+ } catch (SPException $e) {
}
}
return (int)$newCategoryId;
}
+
+ /**
+ * Obtener el id de una categoría por el nombre.
+ *
+ * @param string $categoryName con el nombre de la categoría
+ * @return bool|int si la consulta es errónea devuelve bool. Si no hay registros o se obtiene el id, devuelve int
+ */
+ public static function getCategoryIdByName($categoryName)
+ {
+ $query = 'SELECT category_id FROM categories WHERE category_name = :name LIMIT 1';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($categoryName, 'name');
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false || DB::$lastNumRows === 0) {
+ return false;
+ }
+
+ return $queryRes->category_id;
+ }
+
+ /**
+ * Crear una nueva categoría en la BBDD.
+ *
+ * @throws SPException
+ */
+ public static function addCategory()
+ {
+ if (self::checkDupCategory()) {
+ throw new SPException(SPException::SP_WARNING, _('Nombre de categoría duplicado'));
+ }
+
+ $query = 'INSERT INTO categories SET category_name = :name ,category_description = :description';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam(self::$categoryName, 'name');
+ $Data->addParam(self::$categoryDescription, 'description');
+
+ if (DB::getQuery($Data) === false) {
+ throw new SPException(SPException::SP_CRITICAL, _('Error al crear la categoría'));
+ }
+
+ self::$categoryLastId = DB::$lastId;
+
+ $Log = new Log(_('Nueva Categoría'));
+ $Log->addDetails(Html::strongText(_('Categoría')), self::$categoryName);
+ $Log->writeLog();
+
+ Email::sendEmail($Log);
+ }
+
+ /**
+ * Obtiene el listado de categorías mediante una búsqueda
+ *
+ * @param string $search La cadena de búsqueda
+ * @return array con el id de categoria como clave y en nombre como valor
+ */
+ public static function getCategoriesSearch($search)
+ {
+ $query = 'SELECT category_id, category_name,category_description '
+ . 'FROM categories '
+ . 'WHERE category_name LIKE ? '
+ . 'OR category_description LIKE ? '
+ . 'ORDER BY category_name';
+
+ $search = '%' . $search . '%';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($search);
+ $Data->addParam($search);
+
+ DB::setReturnArray();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ return $queryRes;
+ }
}
diff --git a/inc/SP/Mgmt/CustomFieldDef.class.php b/inc/SP/Mgmt/CustomFieldDef.class.php
index 93844831..948914dc 100644
--- a/inc/SP/Mgmt/CustomFieldDef.class.php
+++ b/inc/SP/Mgmt/CustomFieldDef.class.php
@@ -73,6 +73,107 @@ class CustomFieldDef extends CustomFieldsBase
return $queryRes && CustomFields::deleteCustomFieldForDefinition($id);
}
+ /**
+ * Devolver los datos de definiciones de campos personalizados
+ *
+ * @param string $search La cadena de búsqueda
+ * @return array|bool
+ */
+ public static function getCustomFieldsSearch($search)
+ {
+ $query = 'SELECT customfielddef_id, customfielddef_module, customfielddef_field '
+ . 'FROM customFieldsDef '
+ . ' ORDER BY customfielddef_module';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+
+ DB::setReturnArray();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ $customFields = array();
+
+ foreach ($queryRes as $customField) {
+ /**
+ * @var CustomFieldDef
+ */
+ $field = unserialize($customField->customfielddef_field);
+
+ if (get_class($field) === '__PHP_Incomplete_Class') {
+ $field = Util::castToClass('SP\Mgmt\CustomFieldDef', $field);
+ }
+
+ if (stripos($field->getName(), $search) !== false
+ || stripos(self::getFieldsTypes($field->getType(), true), $search) !== false
+ || stripos(self::getFieldsModules($customField->customfielddef_module), $search) !== false
+ ) {
+ $attribs = new \stdClass();
+ $attribs->id = $customField->customfielddef_id;
+ $attribs->module = self::getFieldsModules($customField->customfielddef_module);
+ $attribs->name = $field->getName();
+ $attribs->typeName = self::getFieldsTypes($field->getType(), true);
+ $attribs->type = $field->getType();
+
+ $customFields[] = $attribs;
+ }
+ }
+
+ return $customFields;
+ }
+
+ /**
+ * Añadir nuevo campo personalizado
+ *
+ * @return bool
+ */
+ public function addCustomField()
+ {
+ $query = 'INSERT INTO customFieldsDef SET customfielddef_module = :module, customfielddef_field = :field';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($this->_module, 'module');
+ $Data->addParam(serialize($this), 'field');
+
+ $queryRes = DB::getQuery($Data);
+
+ return $queryRes;
+ }
+
+ /**
+ * Actualizar campo personalizado
+ *
+ * @return bool
+ */
+ public function updateCustomField()
+ {
+ $curField = self::getCustomFields($this->_id, true);
+
+ $query = 'UPDATE customFieldsDef SET ' .
+ 'customfielddef_module = :module, ' .
+ 'customfielddef_field = :field ' .
+ 'WHERE customfielddef_id= :id LIMIT 1';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($this->_id, 'id');
+ $Data->addParam($this->_module, 'module');
+ $Data->addParam(serialize($this), 'field');
+
+ $queryRes = DB::getQuery($Data);
+
+ if ($queryRes && $curField->customfielddef_module !== $this->_module) {
+ $queryRes = CustomFields::updateCustomFieldModule($this->_module, $this->_id);
+ }
+
+ return $queryRes;
+ }
+
/**
* Devolver los datos de definiciones de campos personalizados
*
@@ -134,54 +235,6 @@ class CustomFieldDef extends CustomFieldsBase
return $queryRes;
}
- /**
- * Añadir nuevo campo personalizado
- *
- * @return bool
- */
- public function addCustomField()
- {
- $query = 'INSERT INTO customFieldsDef SET customfielddef_module = :module, customfielddef_field = :field';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($this->_module, 'module');
- $Data->addParam(serialize($this), 'field');
-
- $queryRes = DB::getQuery($Data);
-
- return $queryRes;
- }
-
- /**
- * Actualizar campo personalizado
- *
- * @return bool
- */
- public function updateCustomField()
- {
- $curField = self::getCustomFields($this->_id, true);
-
- $query = 'UPDATE customFieldsDef SET ' .
- 'customfielddef_module = :module, ' .
- 'customfielddef_field = :field ' .
- 'WHERE customfielddef_id= :id LIMIT 1';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($this->_id, 'id');
- $Data->addParam($this->_module, 'module');
- $Data->addParam(serialize($this), 'field');
-
- $queryRes = DB::getQuery($Data);
-
- if ($queryRes && $curField->customfielddef_module !== $this->_module) {
- $queryRes = CustomFields::updateCustomFieldModule($this->_module, $this->_id);
- }
-
- return $queryRes;
- }
-
/**
* @param int $id
*/
diff --git a/inc/SP/Mgmt/CustomFields.class.php b/inc/SP/Mgmt/CustomFields.class.php
index 9280091d..f1d8d48c 100644
--- a/inc/SP/Mgmt/CustomFields.class.php
+++ b/inc/SP/Mgmt/CustomFields.class.php
@@ -126,6 +126,8 @@ class CustomFields extends CustomFieldsBase
$customFields[] = $attribs;
}
+ $customFields['hash'] = '';
+
return $customFields;
}
@@ -170,6 +172,7 @@ class CustomFields extends CustomFieldsBase
$queryMerge = array_merge($queryRes, self::getCustomFieldsNoData($moduleId, $itemId));
$customFields = array();
+ $customFieldsHash = '';
foreach ($queryMerge as $customField) {
/**
@@ -191,9 +194,13 @@ class CustomFields extends CustomFieldsBase
$attribs->help = $field->getHelp();
$attribs->required = $field->isRequired();
+ $customFieldsHash .= $attribs->value;
+
$customFields[] = $attribs;
}
+ $customFields['hash'] = md5($customFieldsHash);
+
return $customFields;
}
@@ -488,6 +495,7 @@ class CustomFields extends CustomFieldsBase
* Eliminar los datos de un campo personalizado o los de una definición de campos
*
* @param int $itemId El Id del elemento asociado al campo
+ * @param $moduleId
* @return bool
*/
public static function deleteCustomFieldForItem($itemId, $moduleId)
diff --git a/inc/SP/Mgmt/CustomFieldsUtil.class.php b/inc/SP/Mgmt/CustomFieldsUtil.class.php
new file mode 100644
index 00000000..8f395057
--- /dev/null
+++ b/inc/SP/Mgmt/CustomFieldsUtil.class.php
@@ -0,0 +1,63 @@
+.
+ *
+ */
+
+namespace SP\Mgmt;
+
+/**
+ * Class CustomFieldsUtil utilidades para los campos personalizados
+ *
+ * @package SP\Mgmt
+ */
+class CustomFieldsUtil
+{
+ public static function updateCustonFields(array &$fields, $accountId)
+ {
+ foreach ($fields as $id => $value) {
+ $CustomFields = new CustomFields($id, $accountId, $value);
+ $CustomFields->updateCustomField();
+ }
+
+ return true;
+ }
+
+ public static function checkHash(&$fields, $srcHhash)
+ {
+ if (!is_array($fields)){
+ return true;
+ }
+
+ $hash = '';
+
+ foreach ($fields as $value) {
+ $hash .= $value;
+ }
+
+ if (!empty($hash)) {
+ return ($srcHhash == md5($hash));
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/inc/SP/Mgmt/Customer.class.php b/inc/SP/Mgmt/Customer.class.php
index 999180d9..bc6c9fb9 100644
--- a/inc/SP/Mgmt/Customer.class.php
+++ b/inc/SP/Mgmt/Customer.class.php
@@ -46,60 +46,6 @@ class Customer
public static $customerLastId;
public static $customerHash;
- /**
- * Crear un nuevo cliente en la BBDD.
- *
- * @param null $id El Id del cliente actual (solo para comprobar duplicidad)
- * @throws SPException
- */
- public static function addCustomer($id = null)
- {
- if(self::checkDupCustomer($id)){
- throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
- }
-
- $query = 'INSERT INTO customers ' .
- 'SET customer_name = :name,'.
- 'customer_description = :description,' .
- 'customer_hash = :hash';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam(self::$customerName, 'name');
- $Data->addParam(self::$customerDescription, 'description');
- $Data->addParam(self::mkCustomerHash(), 'hash');
-
- if (DB::getQuery($Data) === false) {
- throw new SPException(SPException::SP_CRITICAL, _('Error al crear el cliente'));
- }
-
- self::$customerLastId = DB::$lastId;
-
- $Log = new Log(_('Nuevo Cliente'));
- $Log->addDetails(Html::strongText(_('Cliente')), self::$customerName);
- $Log->writeLog();
-
- Email::sendEmail($Log);
- }
-
- /**
- * Crear un hash con el nombre del cliente.
- * Esta función crear un hash para detectar clientes duplicados mediante
- * la eliminación de carácteres especiales y capitalización
- *
- * @return string con el hash generado
- */
- private static function mkCustomerHash()
- {
- $charsSrc = array(
- ".", " ", "_", ", ", "-", ";",
- "'", "\"", ":", "(", ")", "|", "/");
- $newValue = strtolower(str_replace($charsSrc, '', DBUtil::escape(self::$customerName)));
- $hashValue = md5($newValue);
-
- return $hashValue;
- }
-
/**
* Actualizar un cliente en la BBDD.
*
@@ -108,7 +54,7 @@ class Customer
*/
public static function updateCustomer($id)
{
- if(self::checkDupCustomer($id)){
+ if (self::checkDupCustomer($id)) {
throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
}
@@ -138,6 +84,49 @@ class Customer
Email::sendEmail($Log);
}
+ /**
+ * Comprobar si existe un cliente duplicado comprobando el hash.
+ *
+ * @param int $id opcional con el Id del cliente
+ * @return bool
+ */
+ public static function checkDupCustomer($id = null)
+ {
+ $Data = new QueryData();
+ $Data->addParam($id, 'id');
+
+ if (is_null($id)) {
+ $query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash';
+ } else {
+ $query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash AND customer_id <> :id';
+
+ $Data->addParam($id, 'id');
+ }
+
+ $Data->setQuery($query);
+ $Data->addParam(self::mkCustomerHash(), 'hash');
+
+ return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
+ }
+
+ /**
+ * Crear un hash con el nombre del cliente.
+ * Esta función crear un hash para detectar clientes duplicados mediante
+ * la eliminación de carácteres especiales y capitalización
+ *
+ * @return string con el hash generado
+ */
+ private static function mkCustomerHash()
+ {
+ $charsSrc = array(
+ ".", " ", "_", ", ", "-", ";",
+ "'", "\"", ":", "(", ")", "|", "/");
+ $newValue = strtolower(str_replace($charsSrc, '', DBUtil::escape(self::$customerName)));
+ $hashValue = md5($newValue);
+
+ return $hashValue;
+ }
+
/**
* Obtener el Nombre de un cliente por su Id.
*
@@ -195,50 +184,35 @@ class Customer
}
/**
- * Comprobar si existe un cliente duplicado comprobando el hash.
+ * Comprobar si un cliente está en uso.
+ * Esta función comprueba si un cliente está en uso por cuentas.
*
- * @param int $id opcional con el Id del cliente
- * @return bool
+ * @param int $id con el Id del cliente a consultar
+ * @return int Con el número de cuentas
*/
- public static function checkDupCustomer($id = null)
+ public static function checkCustomerInUse($id)
{
- $Data = new QueryData();
- $Data->addParam($id, 'id');
-
- if (is_null($id)) {
- $query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash';
- } else {
- $query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash AND customer_id <> :id';
-
- $Data->addParam($id, 'id');
- }
-
- $Data->setQuery($query);
- $Data->addParam(self::mkCustomerHash(), 'hash');
-
- return (DB::getQuery($Data) === false || DB::$lastNumRows >= 1);
+ $count['accounts'] = self::getCustomerInAccounts($id);
+ return $count;
}
/**
- * Obtener el Id de un cliente por su nombre
+ * Obtener el número de cuentas que usan un cliente.
*
- * @return false|int Con el Id del cliente
+ * @param int $id con el Id del cliente a consultar
+ * @return int con el número total de cuentas
*/
- public static function getCustomerByName()
+ private static function getCustomerInAccounts($id)
{
- $query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash LIMIT 1';
+ $query = 'SELECT account_id FROM accounts WHERE account_customerId = :id';
$Data = new QueryData();
$Data->setQuery($query);
- $Data->addParam(self::mkCustomerHash(), 'hash');
+ $Data->addParam($id, 'id');
- $queryRes = DB::getResults($Data);
+ DB::getQuery($Data);
- if ($queryRes === false) {
- return false;
- }
-
- return $queryRes->customer_id;
+ return DB::$lastNumRows;
}
/**
@@ -311,45 +285,15 @@ class Customer
return $queryRes;
}
- /**
- * Comprobar si un cliente está en uso.
- * Esta función comprueba si un cliente está en uso por cuentas.
- *
- * @param int $id con el Id del cliente a consultar
- * @return int Con el número de cuentas
- */
- public static function checkCustomerInUse($id)
- {
- $count['accounts'] = self::getCustomerInAccounts($id);
- return $count;
- }
-
- /**
- * Obtener el número de cuentas que usan un cliente.
- *
- * @param int $id con el Id del cliente a consultar
- * @return int con el número total de cuentas
- */
- private static function getCustomerInAccounts($id)
- {
- $query = 'SELECT account_id FROM accounts WHERE account_customerId = :id';
-
- $Data = new QueryData();
- $Data->setQuery($query);
- $Data->addParam($id, 'id');
-
- DB::getQuery($Data);
-
- return DB::$lastNumRows;
- }
-
/**
* Añadir un cliente
+ *
* @param $name
* @param $description
* @return int
*/
- public static function addCustomerReturnId($name, $description = ''){
+ public static function addCustomerReturnId($name, $description = '')
+ {
$customerId = 0;
self::$customerName = $name;
@@ -359,11 +303,101 @@ class Customer
self::addCustomer();
$customerId = self::$customerLastId;
} catch (SPException $e) {
- if ($e->getType() === SPException::SP_WARNING){
+ if ($e->getType() === SPException::SP_WARNING) {
$customerId = self::getCustomerByName();
}
}
return (int)$customerId;
}
+
+ /**
+ * Crear un nuevo cliente en la BBDD.
+ *
+ * @param null $id El Id del cliente actual (solo para comprobar duplicidad)
+ * @throws SPException
+ */
+ public static function addCustomer($id = null)
+ {
+ if (self::checkDupCustomer($id)) {
+ throw new SPException(SPException::SP_WARNING, _('Cliente duplicado'));
+ }
+
+ $query = 'INSERT INTO customers ' .
+ 'SET customer_name = :name,' .
+ 'customer_description = :description,' .
+ 'customer_hash = :hash';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam(self::$customerName, 'name');
+ $Data->addParam(self::$customerDescription, 'description');
+ $Data->addParam(self::mkCustomerHash(), 'hash');
+
+ if (DB::getQuery($Data) === false) {
+ throw new SPException(SPException::SP_CRITICAL, _('Error al crear el cliente'));
+ }
+
+ self::$customerLastId = DB::$lastId;
+
+ $Log = new Log(_('Nuevo Cliente'));
+ $Log->addDetails(Html::strongText(_('Cliente')), self::$customerName);
+ $Log->writeLog();
+
+ Email::sendEmail($Log);
+ }
+
+ /**
+ * Obtener el Id de un cliente por su nombre
+ *
+ * @return false|int Con el Id del cliente
+ */
+ public static function getCustomerByName()
+ {
+ $query = 'SELECT customer_id FROM customers WHERE customer_hash = :hash LIMIT 1';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam(self::mkCustomerHash(), 'hash');
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return false;
+ }
+
+ return $queryRes->customer_id;
+ }
+
+ /**
+ * Obtener el listado de clientes mediante una búsqueda
+ *
+ * @param string $search La cadena de búsqueda
+ * @return array con el id de cliente como clave y el nombre como valor
+ */
+ public static function getCustomersSearch($search)
+ {
+ $query = 'SELECT customer_id, customer_name, customer_description '
+ . 'FROM customers '
+ . 'WHERE customer_name LIKE ? '
+ . 'OR customer_description LIKE ? '
+ . 'ORDER BY customer_name';
+
+ $search = '%' . $search . '%';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($search);
+ $Data->addParam($search);
+
+ DB::setReturnArray();
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ return $queryRes;
+ }
}
diff --git a/inc/SP/Mgmt/Files.class.php b/inc/SP/Mgmt/Files.class.php
index bb9057aa..77170c5f 100644
--- a/inc/SP/Mgmt/Files.class.php
+++ b/inc/SP/Mgmt/Files.class.php
@@ -287,4 +287,47 @@ class Files
return $queryRes;
}
+
+ /**
+ * Obtener el listado de archivos
+ *
+ * @param string $search La cadena de búsqueda
+ * @return array|false Con los archivos de las cuentas.
+ */
+ public static function getFileListSearch($search)
+ {
+ $query = 'SELECT accfile_id,'
+ . 'accfile_name,'
+ . 'CONCAT(ROUND(accfile_size/1000, 2), " KB") AS accfile_size,'
+ . 'accfile_thumb,'
+ . 'accfile_type,'
+ . 'account_name,'
+ . 'customer_name '
+ . 'FROM accFiles '
+ . 'JOIN accounts ON account_id = accfile_accountId '
+ . 'JOIN customers ON customer_id = account_customerId '
+ . 'WHERE accfile_name LIKE ? '
+ . 'OR accfile_type LIKE ? '
+ . 'OR account_name LIKE ? '
+ . 'OR customer_name LIKE ?';
+
+ DB::setReturnArray();
+
+ $search = '%' . $search . '%';
+
+ $Data = new QueryData();
+ $Data->setQuery($query);
+ $Data->addParam($search);
+ $Data->addParam($search);
+ $Data->addParam($search);
+ $Data->addParam($search);
+
+ $queryRes = DB::getResults($Data);
+
+ if ($queryRes === false) {
+ return array();
+ }
+
+ return $queryRes;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Storage/QueryData.class.php b/inc/SP/Storage/QueryData.class.php
index 4873a18f..1b67b580 100644
--- a/inc/SP/Storage/QueryData.class.php
+++ b/inc/SP/Storage/QueryData.class.php
@@ -47,7 +47,11 @@ class QueryData
*/
public function addParam($value, $name = null)
{
- $this->_data[$name] = $value;
+ if (!is_null($name)) {
+ $this->_data[$name] = $value;
+ } else {
+ $this->_data[] = $value;
+ }
}
/**
diff --git a/inc/themes/material-blue/account.inc b/inc/themes/material-blue/account.inc
index d357d658..9e469f52 100644
--- a/inc/themes/material-blue/account.inc
+++ b/inc/themes/material-blue/account.inc
@@ -1,204 +1,228 @@
-
+
-
+
-