|
@@ -29,6 +29,9 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
// Firma powiąz. / adres / opis-temat
|
|
// Firma powiąz. / adres / opis-temat
|
|
|
// Lokalizacja
|
|
// Lokalizacja
|
|
|
|
|
|
|
|
|
|
+ 'PROJECT__ID' => [ '@type' => "xsd:int" ],
|
|
|
|
|
+ 'PROJECT__L_APPOITMENT_USER' => [ '@type' => "xsd:string" ],
|
|
|
|
|
+
|
|
|
// 'idZasob' => [ '@type' => 'xsd:integer' ],
|
|
// 'idZasob' => [ '@type' => 'xsd:integer' ],
|
|
|
// 'idDatabase' => [ '@type' => 'xsd:integer' ],
|
|
// 'idDatabase' => [ '@type' => 'xsd:integer' ],
|
|
|
// '_rootTableName' => [ '@type' => 'xsd:string' ],
|
|
// '_rootTableName' => [ '@type' => 'xsd:string' ],
|
|
@@ -50,7 +53,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
];
|
|
];
|
|
|
// public $_rootTableName = 'CRM_LISTA_ZASOBOW';
|
|
// public $_rootTableName = 'CRM_LISTA_ZASOBOW';
|
|
|
public $_rootTableName = '_PRZYPOMNIJ_ITEMS';
|
|
public $_rootTableName = '_PRZYPOMNIJ_ITEMS';
|
|
|
- static function _createTable() {
|
|
|
|
|
|
|
+ static function _createItemsTable() {
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
|
CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_ITEMS` (
|
|
CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_ITEMS` (
|
|
|
`L_APPOITMENT_USER` varchar(255) NOT NULL default '',
|
|
`L_APPOITMENT_USER` varchar(255) NOT NULL default '',
|
|
@@ -64,8 +67,11 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
`featureDesc` varchar(255) NOT NULL default '',
|
|
`featureDesc` varchar(255) NOT NULL default '',
|
|
|
`L_APPOITMENT_DATE` dateTime DEFAULT NULL,
|
|
`L_APPOITMENT_DATE` dateTime DEFAULT NULL,
|
|
|
`L_APPOITMENT_INFO` varchar(255) NOT NULL default '',
|
|
`L_APPOITMENT_INFO` varchar(255) NOT NULL default '',
|
|
|
|
|
+ `PROJECT__ID` int(11) NOT NULL DEFAULT 0,
|
|
|
|
|
+ `PROJECT__L_APPOITMENT_USER` varchar(255) NOT NULL default '',
|
|
|
|
|
|
|
|
PRIMARY KEY (`feature_id`),
|
|
PRIMARY KEY (`feature_id`),
|
|
|
|
|
+ KEY `namespace` (`namespace`),
|
|
|
KEY `L_APPOITMENT_USER` (`L_APPOITMENT_USER`),
|
|
KEY `L_APPOITMENT_USER` (`L_APPOITMENT_USER`),
|
|
|
KEY `A_ADM_COMPANY` (`A_ADM_COMPANY`),
|
|
KEY `A_ADM_COMPANY` (`A_ADM_COMPANY`),
|
|
|
KEY `A_CLASSIFIED` (`A_CLASSIFIED`)
|
|
KEY `A_CLASSIFIED` (`A_CLASSIFIED`)
|
|
@@ -107,6 +113,8 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
$confKeyLastUpdateDate = 'Schema_PrzypomnijStorageAcl::lastUpdateDate';
|
|
$confKeyLastUpdateDate = 'Schema_PrzypomnijStorageAcl::lastUpdateDate';
|
|
|
$lastUpdateDate = DB::getPDO()->fetchValue(" select CONF_VAL from CRM_CONFIG where CONF_KEY = :conf_key ", [ ':conf_key' => $confKeyLastUpdateDate ]);
|
|
$lastUpdateDate = DB::getPDO()->fetchValue(" select CONF_VAL from CRM_CONFIG where CONF_KEY = :conf_key ", [ ':conf_key' => $confKeyLastUpdateDate ]);
|
|
|
$tablesList = [];
|
|
$tablesList = [];
|
|
|
|
|
+ $tablesList[] = '_PRZYPOMNIJ_ITEMS'; // to check if tables exists
|
|
|
|
|
+ $tablesList[] = '_PRZYPOMNIJ_PROJECT_TREE'; // to check if tables exists
|
|
|
$tablesList[] = 'IN7_MK_BAZA_DYSTRYBUCJI';
|
|
$tablesList[] = 'IN7_MK_BAZA_DYSTRYBUCJI';
|
|
|
$tablesList[] = 'IN7_DZIENNIK_KORESP';
|
|
$tablesList[] = 'IN7_DZIENNIK_KORESP';
|
|
|
$tablesList[] = 'CRM_PROCES';
|
|
$tablesList[] = 'CRM_PROCES';
|
|
@@ -117,28 +125,47 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
// $tablesList[] = 'QUALITY_NOTICES';
|
|
// $tablesList[] = 'QUALITY_NOTICES';
|
|
|
// $tablesList[] = 'BADANIA_W_TERENIE';
|
|
// $tablesList[] = 'BADANIA_W_TERENIE';
|
|
|
$sqlTableList = implode(", ", array_map(function ($table) { return "'{$table}'"; }, $tablesList));
|
|
$sqlTableList = implode(", ", array_map(function ($table) { return "'{$table}'"; }, $tablesList));
|
|
|
- $tablesUpdateDates = DB::getPDO()->fetchAll("
|
|
|
|
|
- select TABLE_NAME, UPDATE_TIME
|
|
|
|
|
- , IF( UPDATE_TIME > :last_update_date, 1, 0 ) as TO_UPDATE
|
|
|
|
|
- , 1 as DBG__TO_UPDATE
|
|
|
|
|
|
|
+ $tablesUpdateDates = DB::getPDO()->fetchValuesListByKey("
|
|
|
|
|
+ select IF( UPDATE_TIME > :last_update_date, 1, 0 ) as TO_UPDATE
|
|
|
|
|
+ , TABLE_NAME
|
|
|
|
|
+ , UPDATE_TIME
|
|
|
from information_schema.tables
|
|
from information_schema.tables
|
|
|
where TABLE_SCHEMA = :db_name
|
|
where TABLE_SCHEMA = :db_name
|
|
|
and TABLE_NAME in({$sqlTableList})
|
|
and TABLE_NAME in({$sqlTableList})
|
|
|
- ", [
|
|
|
|
|
|
|
+ ", $key = 'TABLE_NAME', [
|
|
|
':db_name' => DB::getPDO()->getDatabaseName(),
|
|
':db_name' => DB::getPDO()->getDatabaseName(),
|
|
|
':last_update_date' => $lastUpdateDate,
|
|
':last_update_date' => $lastUpdateDate,
|
|
|
]);
|
|
]);
|
|
|
- DBG::log($tablesUpdateDates, 'array', "\$tablesUpdateDates");
|
|
|
|
|
-
|
|
|
|
|
- $tablesToUpdate = array_map(function ($tableStatus) {
|
|
|
|
|
- return $tableStatus['TABLE_NAME'];
|
|
|
|
|
- }, array_filter($tablesUpdateDates, function ($tableStatus) { return ($tableStatus['TO_UPDATE']); }));
|
|
|
|
|
-
|
|
|
|
|
- DBG::log($tablesToUpdate, 'array', "\$tablesToUpdate");
|
|
|
|
|
|
|
+ DBG::log($tablesUpdateDates, 'array', "DBG::Przypomnij: \$tablesUpdateDates 1");
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_ITEMS', $tablesUpdateDates)) {
|
|
|
|
|
+ self::_createItemsTable();
|
|
|
|
|
+ $tablesUpdateDates = array_map(function ($value) { return 1; }, $tablesUpdateDates);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_PROJECT_TREE', $tablesUpdateDates)
|
|
|
|
|
+ || $tablesUpdateDates['IN7_MK_BAZA_DYSTRYBUCJI']
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_PROJECT_TREE', $tablesUpdateDates)) {
|
|
|
|
|
+ self::_createProjectsTreeTable();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (self::_isProjectsOwnerChanged()) {
|
|
|
|
|
+ self::_updateProjectsTree();
|
|
|
|
|
+ }
|
|
|
|
|
+ // $tablesUpdateDates = array_map(function ($value) { return 1; }, $tablesUpdateDates); // moved to mass update
|
|
|
|
|
+ }
|
|
|
|
|
+ DBG::log($tablesUpdateDates, 'array', "DBG::Przypomnij: \$tablesUpdateDates 2");
|
|
|
|
|
|
|
|
- self::_createTable();
|
|
|
|
|
|
|
+ $tablesToUpdate = array_keys(
|
|
|
|
|
+ array_filter($tablesUpdateDates, function ($value) { return $value; })
|
|
|
|
|
+ );
|
|
|
|
|
+ DBG::log($tablesToUpdate, 'array', "DBG::Przypomnij: \$tablesToUpdate");
|
|
|
foreach ($tablesToUpdate as $tableName) self::_updateForTable($tableName);
|
|
foreach ($tablesToUpdate as $tableName) self::_updateForTable($tableName);
|
|
|
|
|
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_PROJECT_TREE', $tablesUpdateDates)
|
|
|
|
|
+ || $tablesUpdateDates['IN7_MK_BAZA_DYSTRYBUCJI']
|
|
|
|
|
+ ) {
|
|
|
|
|
+ self::_updateLAppUserByProjectsTree();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
DB::getPDO()->insertOrUpdate('CRM_CONFIG', [
|
|
DB::getPDO()->insertOrUpdate('CRM_CONFIG', [
|
|
|
'CONF_KEY' => $confKeyLastUpdateDate,
|
|
'CONF_KEY' => $confKeyLastUpdateDate,
|
|
|
'@insert' => [
|
|
'@insert' => [
|
|
@@ -176,7 +203,8 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
':namespace' => $namespace,
|
|
':namespace' => $namespace,
|
|
|
':table_name' => $tableName,
|
|
':table_name' => $tableName,
|
|
|
]);
|
|
]);
|
|
|
- } else if ('CRM_PROCES' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ('CRM_PROCES' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
|
insert into `_PRZYPOMNIJ_ITEMS` (
|
|
insert into `_PRZYPOMNIJ_ITEMS` (
|
|
@@ -200,7 +228,8 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
':namespace' => $namespace,
|
|
':namespace' => $namespace,
|
|
|
':table_name' => $tableName,
|
|
':table_name' => $tableName,
|
|
|
]);
|
|
]);
|
|
|
- } else if ('IN7_DZIENNIK_KORESP' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ('IN7_DZIENNIK_KORESP' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
|
insert into `_PRZYPOMNIJ_ITEMS` (
|
|
insert into `_PRZYPOMNIJ_ITEMS` (
|
|
@@ -208,6 +237,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
, `A_STATUS`, `featureType`, `featureDesc`
|
|
, `A_STATUS`, `featureType`, `featureDesc`
|
|
|
, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`
|
|
, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`
|
|
|
, `L_APPOITMENT_DATE`, `L_APPOITMENT_INFO`
|
|
, `L_APPOITMENT_DATE`, `L_APPOITMENT_INFO`
|
|
|
|
|
+ , `PROJECT__ID`
|
|
|
)
|
|
)
|
|
|
select concat( :table_name , '.', t.ID) as `feature_id`, :namespace as `namespace`, t.ID as `primaryKey`
|
|
select concat( :table_name , '.', t.ID) as `feature_id`, :namespace as `namespace`, t.ID as `primaryKey`
|
|
|
, t.`A_STATUS`
|
|
, t.`A_STATUS`
|
|
@@ -215,13 +245,15 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
, concat('<strong>', t.`K_OD_KOGO`, '</strong><br><em>', t.`OD_KOGO_ADRES`, '</em><br>', t.`K_ZAWARTOS`) as `featureDesc`
|
|
, concat('<strong>', t.`K_OD_KOGO`, '</strong><br><em>', t.`OD_KOGO_ADRES`, '</em><br>', t.`K_ZAWARTOS`) as `featureDesc`
|
|
|
, t.`L_APPOITMENT_USER`, t.`A_ADM_COMPANY`, t.`A_CLASSIFIED`
|
|
, t.`L_APPOITMENT_USER`, t.`A_ADM_COMPANY`, t.`A_CLASSIFIED`
|
|
|
, t.`L_APPOITMENT_DATE`, t.`L_APPOITMENT_INFO`
|
|
, t.`L_APPOITMENT_DATE`, t.`L_APPOITMENT_INFO`
|
|
|
|
|
+ , t.`ID_PROJECT` as PROJECT__ID
|
|
|
from `IN7_DZIENNIK_KORESP` as t
|
|
from `IN7_DZIENNIK_KORESP` as t
|
|
|
where t.`A_STATUS` not in ('OFF_HARD', 'DELETED')
|
|
where t.`A_STATUS` not in ('OFF_HARD', 'DELETED')
|
|
|
", [
|
|
", [
|
|
|
':namespace' => $namespace,
|
|
':namespace' => $namespace,
|
|
|
':table_name' => $tableName,
|
|
':table_name' => $tableName,
|
|
|
]);
|
|
]);
|
|
|
- } else if ('IN7_MK_BAZA_DYSTRYBUCJI' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ('IN7_MK_BAZA_DYSTRYBUCJI' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
// TODO: 'M_DIST_DESC' => htmlspecialchars($row['M_DIST_DESC']), // TODO: fix bug in html a href inside M_DIST_DES
|
|
// TODO: 'M_DIST_DESC' => htmlspecialchars($row['M_DIST_DESC']), // TODO: fix bug in html a href inside M_DIST_DES
|
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
@@ -230,6 +262,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
, `A_STATUS`, `featureType`, `featureDesc`
|
|
, `A_STATUS`, `featureType`, `featureDesc`
|
|
|
, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`
|
|
, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`
|
|
|
, `L_APPOITMENT_DATE`, `L_APPOITMENT_INFO`
|
|
, `L_APPOITMENT_DATE`, `L_APPOITMENT_INFO`
|
|
|
|
|
+ , `PROJECT__ID`
|
|
|
)
|
|
)
|
|
|
select concat( :table_name , '.', t.ID) as `feature_id`, :namespace as `namespace`, t.ID as `primaryKey`
|
|
select concat( :table_name , '.', t.ID) as `feature_id`, :namespace as `namespace`, t.ID as `primaryKey`
|
|
|
, t.`A_STATUS`
|
|
, t.`A_STATUS`
|
|
@@ -237,13 +270,15 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
, t.`M_DIST_DESC` as `featureDesc`
|
|
, t.`M_DIST_DESC` as `featureDesc`
|
|
|
, t.`L_APPOITMENT_USER`, t.`A_ADM_COMPANY`, t.`A_CLASSIFIED`
|
|
, t.`L_APPOITMENT_USER`, t.`A_ADM_COMPANY`, t.`A_CLASSIFIED`
|
|
|
, t.`L_APPOITMENT_DATE`, t.`L_APPOITMENT_INFO`
|
|
, t.`L_APPOITMENT_DATE`, t.`L_APPOITMENT_INFO`
|
|
|
|
|
+ , t.`P_ID` as PROJECT__ID
|
|
|
from `IN7_MK_BAZA_DYSTRYBUCJI` as t
|
|
from `IN7_MK_BAZA_DYSTRYBUCJI` as t
|
|
|
where t.`A_STATUS` not in ('OFF_HARD', 'DELETED')
|
|
where t.`A_STATUS` not in ('OFF_HARD', 'DELETED')
|
|
|
", [
|
|
", [
|
|
|
':namespace' => $namespace,
|
|
':namespace' => $namespace,
|
|
|
':table_name' => $tableName,
|
|
':table_name' => $tableName,
|
|
|
]);
|
|
]);
|
|
|
- } else if ('PROBLEMS' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ('PROBLEMS' === $tableName) { // TODO: getUpdateConfigForTable($tableName);
|
|
|
// TODO: 'A_PROBLEM_DESC' => htmlspecialchars($row['A_PROBLEM_DESC']),
|
|
// TODO: 'A_PROBLEM_DESC' => htmlspecialchars($row['A_PROBLEM_DESC']),
|
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
DB::getPDO()->execSql(" DELETE from `_PRZYPOMNIJ_ITEMS` where `namespace` = :namespace ", [ ':namespace' => $namespace ]);
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
@@ -252,6 +287,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
, `A_STATUS`, `featureType`, `featureDesc`
|
|
, `A_STATUS`, `featureType`, `featureDesc`
|
|
|
, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`
|
|
, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`
|
|
|
, `L_APPOITMENT_DATE`, `L_APPOITMENT_INFO`
|
|
, `L_APPOITMENT_DATE`, `L_APPOITMENT_INFO`
|
|
|
|
|
+ , `PROJECT__ID`
|
|
|
)
|
|
)
|
|
|
select concat( :table_name , '.', t.ID) as `feature_id`, :namespace as `namespace`, t.ID as `primaryKey`
|
|
select concat( :table_name , '.', t.ID) as `feature_id`, :namespace as `namespace`, t.ID as `primaryKey`
|
|
|
, t.`A_STATUS`
|
|
, t.`A_STATUS`
|
|
@@ -259,6 +295,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
, t.`A_PROBLEM_DESC` as `featureDesc`
|
|
, t.`A_PROBLEM_DESC` as `featureDesc`
|
|
|
, t.`L_APPOITMENT_USER`, t.`A_ADM_COMPANY`, t.`A_CLASSIFIED`
|
|
, t.`L_APPOITMENT_USER`, t.`A_ADM_COMPANY`, t.`A_CLASSIFIED`
|
|
|
, t.`L_APPOITMENT_DATE`, t.`L_APPOITMENT_INFO`
|
|
, t.`L_APPOITMENT_DATE`, t.`L_APPOITMENT_INFO`
|
|
|
|
|
+ , t.`ID_PROJECT` as PROJECT__ID
|
|
|
from `PROBLEMS` as t
|
|
from `PROBLEMS` as t
|
|
|
where t.`A_STATUS` not in ('OFF_HARD', 'DELETED')
|
|
where t.`A_STATUS` not in ('OFF_HARD', 'DELETED')
|
|
|
and t.`L_APPOITMENT_DATE` != ''
|
|
and t.`L_APPOITMENT_DATE` != ''
|
|
@@ -267,11 +304,108 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
':namespace' => $namespace,
|
|
':namespace' => $namespace,
|
|
|
':table_name' => $tableName,
|
|
':table_name' => $tableName,
|
|
|
]);
|
|
]);
|
|
|
- } else {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ('_PRZYPOMNIJ_ITEMS' === $tableName) {}
|
|
|
|
|
+ else if ('_PRZYPOMNIJ_PROJECT_TREE' === $tableName) {}
|
|
|
|
|
+ else {
|
|
|
throw new Exception("TODO: (default_objects/Przypomnij)::_updateForTable({$tableName})");
|
|
throw new Exception("TODO: (default_objects/Przypomnij)::_updateForTable({$tableName})");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static function _createProjectsTreeTable() {
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_PROJECT_TREE` (
|
|
|
|
|
+ `ID_PROJECT` int(11) NOT NULL,
|
|
|
|
|
+ `P_ID` int(11) NOT NULL DEFAULT 0,
|
|
|
|
|
+ `L_APPOITMENT_USER` varchar(40) NOT NULL DEFAULT '',
|
|
|
|
|
+ `_l_app_user` varchar(40) NOT NULL DEFAULT '',
|
|
|
|
|
+ UNIQUE KEY `ID_PROJECT` (`ID_PROJECT`),
|
|
|
|
|
+ KEY `P_ID` (`P_ID`)
|
|
|
|
|
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+ static function _isProjectsOwnerChanged() {
|
|
|
|
|
+ return ( DB::getPDO()->fetchValue("
|
|
|
|
|
+ select count(1) as total
|
|
|
|
|
+ -- p.ID as p__ID, p.L_APPOITMENT_USER as p__L_APPOITMENT_USER, t.*
|
|
|
|
|
+ from IN7_MK_BAZA_DYSTRYBUCJI p
|
|
|
|
|
+ left join _PRZYPOMNIJ_PROJECT_TREE t on ( t.ID_PROJECT = p.ID )
|
|
|
|
|
+ where (
|
|
|
|
|
+ t.L_APPOITMENT_USER is null
|
|
|
|
|
+ or p.L_APPOITMENT_USER != t.L_APPOITMENT_USER
|
|
|
|
|
+ )
|
|
|
|
|
+ ") > 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ static function _updateProjectsTree() {
|
|
|
|
|
+ DB::getPDO()->execSql(" truncate table `_PRZYPOMNIJ_PROJECT_TREE` ");
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ insert into `_PRZYPOMNIJ_PROJECT_TREE` (`ID_PROJECT`,`P_ID`,`_l_app_user`,`L_APPOITMENT_USER`)
|
|
|
|
|
+ select `ID`,`P_ID`,`L_APPOITMENT_USER`,`L_APPOITMENT_USER`
|
|
|
|
|
+ from `IN7_MK_BAZA_DYSTRYBUCJI`
|
|
|
|
|
+ where 1=1
|
|
|
|
|
+ ");
|
|
|
|
|
+
|
|
|
|
|
+ // test recurse update l_app
|
|
|
|
|
+ $sql = "
|
|
|
|
|
+ select c._l_app_user
|
|
|
|
|
+ , p.L_APPOITMENT_USER
|
|
|
|
|
+ , p1.L_APPOITMENT_USER
|
|
|
|
|
+ , p2.L_APPOITMENT_USER
|
|
|
|
|
+ , p3.L_APPOITMENT_USER
|
|
|
|
|
+ , p4.L_APPOITMENT_USER
|
|
|
|
|
+ , p5.L_APPOITMENT_USER
|
|
|
|
|
+ , p.ID
|
|
|
|
|
+ , p1.ID
|
|
|
|
|
+ , p2.ID
|
|
|
|
|
+ , p3.ID
|
|
|
|
|
+ , p4.ID
|
|
|
|
|
+ , p5.ID
|
|
|
|
|
+ from `_PRZYPOMNIJ_PROJECT_TREE` as c
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p on (p.ID=c.ID_PROJECT)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p1 on (p1.ID=p.P_ID)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p2 on (p2.ID=p1.P_ID)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p3 on (p3.ID=p2.P_ID)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p4 on (p4.ID=p3.P_ID)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p5 on (p5.ID=p4.P_ID)
|
|
|
|
|
+ where c.`_l_app_user`=''
|
|
|
|
|
+ ";
|
|
|
|
|
+
|
|
|
|
|
+ // for i to recurse limit
|
|
|
|
|
+ $sql = "
|
|
|
|
|
+ update `_PRZYPOMNIJ_PROJECT_TREE` as c
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p on (p.ID=c.ID_PROJECT)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p1 on (p1.ID=p.P_ID)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p2 on (p2.ID=p1.P_ID)
|
|
|
|
|
+ left join `IN7_MK_BAZA_DYSTRYBUCJI` as p3 on (p3.ID=p2.P_ID)
|
|
|
|
|
+ -- left join `IN7_MK_BAZA_DYSTRYBUCJI` as p4 on (p4.ID=p3.P_ID)
|
|
|
|
|
+ -- left join `IN7_MK_BAZA_DYSTRYBUCJI` as p5 on (p5.ID=p4.P_ID)
|
|
|
|
|
+ set
|
|
|
|
|
+ c.`_l_app_user`=IF(p.`L_APPOITMENT_USER`!='', p.`L_APPOITMENT_USER`
|
|
|
|
|
+ , IF(p1.`L_APPOITMENT_USER`!='', p1.`L_APPOITMENT_USER`
|
|
|
|
|
+ , IF(p2.`L_APPOITMENT_USER`!='', p2.`L_APPOITMENT_USER`
|
|
|
|
|
+ , IF(p3.`L_APPOITMENT_USER`!='', p3.`L_APPOITMENT_USER`
|
|
|
|
|
+ -- , IF(p4.`L_APPOITMENT_USER`!='', p4.`L_APPOITMENT_USER`
|
|
|
|
|
+ -- , IF(p5.`L_APPOITMENT_USER`!='', p5.`L_APPOITMENT_USER`
|
|
|
|
|
+ , ''
|
|
|
|
|
+ -- )
|
|
|
|
|
+ -- )
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ where c.`_l_app_user`=''
|
|
|
|
|
+ ";
|
|
|
|
|
+ DB::getPDO()->execSql($sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ static function _updateLAppUserByProjectsTree() {
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ update `_PRZYPOMNIJ_ITEMS` as i
|
|
|
|
|
+ join `_PRZYPOMNIJ_PROJECT_TREE` as t on ( t.ID_PROJECT = i.PROJECT__ID )
|
|
|
|
|
+ set i.PROJECT__L_APPOITMENT_USER = t._l_app_user
|
|
|
|
|
+ where i.PROJECT__ID > 0
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// function getTotal($params = []) {
|
|
// function getTotal($params = []) {
|
|
|
// self::updateCacheIfNeeded();
|
|
// self::updateCacheIfNeeded();
|
|
|
// $sqlWhere = $this->_parseWhere($params);
|
|
// $sqlWhere = $this->_parseWhere($params);
|