diff --git a/inc/SP/Controller/ItemShowController.class.php b/inc/SP/Controller/ItemShowController.class.php
index 6a83567f..7e697983 100644
--- a/inc/SP/Controller/ItemShowController.class.php
+++ b/inc/SP/Controller/ItemShowController.class.php
@@ -512,7 +512,9 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite
if (!$Acl->isShowViewPass()) {
throw new ItemException(__('No tiene permisos para acceder a esta cuenta', false));
- } elseif (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) {
+ }
+
+ if (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) {
throw new ItemException(__('Clave maestra actualizada', false) . '
' . __('Reinicie la sesión para cambiarla', false));
}
diff --git a/inc/SP/Core/Upgrade/Upgrade.class.php b/inc/SP/Core/Upgrade/Upgrade.class.php
index 5a233d7c..48b11f32 100644
--- a/inc/SP/Core/Upgrade/Upgrade.class.php
+++ b/inc/SP/Core/Upgrade/Upgrade.class.php
@@ -56,7 +56,7 @@ class Upgrade
/**
* @var array Versiones actualizables
*/
- private static $dbUpgrade = ['110', '112.1', '112.2', '112.3', '112.13', '112.19', '112.20', '120.01', '120.02', '130.16011001', '130.16100601', '200.17011302', '200.17011701', '210.17022601', '213.17031402'];
+ private static $dbUpgrade = ['110', '112.1', '112.2', '112.3', '112.13', '112.19', '112.20', '120.01', '120.02', '130.16011001', '130.16100601', '200.17011302', '200.17011701', '210.17022601', '213.17031402', '220.17040501'];
private static $cfgUpgrade = ['112.4', '130.16020501', '200.17011202'];
private static $auxUpgrade = ['120.01', '120.02', '200.17010901', '200.17011202'];
private static $appUpgrade = ['210.17022601'];
diff --git a/inc/SP/DataModel/CustomerData.class.php b/inc/SP/DataModel/CustomerData.class.php
index 0f6a484b..6312bdb1 100644
--- a/inc/SP/DataModel/CustomerData.class.php
+++ b/inc/SP/DataModel/CustomerData.class.php
@@ -49,6 +49,10 @@ class CustomerData extends DataModelBase implements DataModelInterface
* @var string
*/
public $customer_hash = '';
+ /**
+ * @var int
+ */
+ public $customer_isGlobal = 0;
/**
* CustomerData constructor.
@@ -135,4 +139,20 @@ class CustomerData extends DataModelBase implements DataModelInterface
{
return $this->customer_name;
}
+
+ /**
+ * @return int
+ */
+ public function getCustomerIsGlobal()
+ {
+ return (int)$this->customer_isGlobal;
+ }
+
+ /**
+ * @param int $customer_isGlobal
+ */
+ public function setCustomerIsGlobal($customer_isGlobal)
+ {
+ $this->customer_isGlobal = (bool)$customer_isGlobal;
+ }
}
\ No newline at end of file
diff --git a/inc/SP/Forms/CustomerForm.class.php b/inc/SP/Forms/CustomerForm.class.php
index e469d343..8c2669e4 100644
--- a/inc/SP/Forms/CustomerForm.class.php
+++ b/inc/SP/Forms/CustomerForm.class.php
@@ -72,6 +72,7 @@ class CustomerForm extends FormBase implements FormInterface
$this->CustomerData->setCustomerId($this->itemId);
$this->CustomerData->setCustomerName(Request::analyze('name'));
$this->CustomerData->setCustomerDescription(Request::analyze('description'));
+ $this->CustomerData->setCustomerIsGlobal(Request::analyze('isglobal', 0, false, 1));
}
/**
diff --git a/inc/SP/Mgmt/Customers/Customer.class.php b/inc/SP/Mgmt/Customers/Customer.class.php
index 9b394496..53e7ef01 100644
--- a/inc/SP/Mgmt/Customers/Customer.class.php
+++ b/inc/SP/Mgmt/Customers/Customer.class.php
@@ -59,12 +59,14 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
'INSERT INTO customers
SET customer_name = ?,
customer_description = ?,
+ customer_isGlobal = ?,
customer_hash = ?';
$Data = new QueryData();
$Data->setQuery($query);
$Data->addParam($this->itemData->getCustomerName());
$Data->addParam($this->itemData->getCustomerDescription());
+ $Data->addParam($this->itemData->getCustomerIsGlobal());
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
$Data->setOnErrorMessage(__('Error al crear el cliente', false));
@@ -159,7 +161,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
public function getById($id)
{
$query = /** @lang SQL */
- 'SELECT customer_id, customer_name, customer_description FROM customers WHERE customer_id = ? LIMIT 1';
+ 'SELECT customer_id, customer_name, customer_description, customer_isGlobal FROM customers WHERE customer_id = ? LIMIT 1';
$Data = new QueryData();
$Data->setMapClassName($this->getDataModel());
@@ -183,6 +185,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
'UPDATE customers
SET customer_name = ?,
customer_description = ?,
+ customer_isGlobal = ?,
customer_hash = ?
WHERE customer_id = ? LIMIT 1';
@@ -190,6 +193,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
$Data->setQuery($query);
$Data->addParam($this->itemData->getCustomerName());
$Data->addParam($this->itemData->getCustomerDescription());
+ $Data->addParam($this->itemData->getCustomerIsGlobal());
$Data->addParam($this->makeItemHash($this->itemData->getCustomerName()));
$Data->addParam($this->itemData->getCustomerId());
$Data->setOnErrorMessage(__('Error al actualizar el cliente', false));
@@ -225,7 +229,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
public function getAll()
{
$query = /** @lang SQL */
- 'SELECT customer_id, customer_name, customer_description FROM customers ORDER BY customer_name';
+ 'SELECT customer_id, customer_name, customer_description, customer_isGlobal FROM customers ORDER BY customer_name';
$Data = new QueryData();
$Data->setMapClassName($this->getDataModel());
@@ -250,7 +254,8 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
'SELECT customer_id as id, customer_name as name
FROM accounts
RIGHT JOIN customers ON customer_id = account_customerId
- WHERE account_customerId IS NULL
+ WHERE account_customerId IS NULL
+ OR customer_isGlobal = 1
OR (' . implode(' AND ', $queryWhere) . ')
GROUP BY customer_id
ORDER BY customer_name';
@@ -273,7 +278,7 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
}
$query = /** @lang SQL */
- 'SELECT customer_id, customer_name, customer_description FROM customers WHERE customer_id IN (' . $this->getParamsFromArray($ids) . ')';
+ 'SELECT customer_id, customer_name, customer_description, customer_isGlobal FROM customers WHERE customer_id IN (' . $this->getParamsFromArray($ids) . ')';
$Data = new QueryData();
$Data->setMapClassName($this->getDataModel());
diff --git a/inc/sql/22017040501.sql b/inc/sql/22017040501.sql
new file mode 100644
index 00000000..6b9b240f
--- /dev/null
+++ b/inc/sql/22017040501.sql
@@ -0,0 +1 @@
+ALTER TABLE `customers` ADD `customer_isGlobal` BIT(1) DEFAULT b'0' NULL;
\ No newline at end of file
diff --git a/inc/sql/dbstructure.sql b/inc/sql/dbstructure.sql
index e17617c7..32b92592 100644
--- a/inc/sql/dbstructure.sql
+++ b/inc/sql/dbstructure.sql
@@ -17,6 +17,7 @@ CREATE TABLE `customers` (
`customer_name` varchar(100) NOT NULL,
`customer_hash` varbinary(40) NOT NULL,
`customer_description` varchar(255) DEFAULT NULL,
+ `customer_isGlobal` bit DEFAULT b'0',
PRIMARY KEY (`customer_id`),
KEY `IDX_name` (`customer_name`,`customer_hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -29,7 +30,7 @@ CREATE TABLE `categories` (
`category_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`category_name` varchar(50) NOT NULL,
`category_hash` varbinary(40) NOT NULL,
- `category_description` varchar(255) DEFAULT NULL,
+ `category_description` varchar(255) DEFAULT NULL
PRIMARY KEY (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/inc/themes/material-blue/views/itemshow/customers.inc b/inc/themes/material-blue/views/itemshow/customers.inc
index 90e2a944..32924f77 100644
--- a/inc/themes/material-blue/views/itemshow/customers.inc
+++ b/inc/themes/material-blue/views/itemshow/customers.inc
@@ -41,6 +41,29 @@
+
+ +
++ +
+