diff --git a/apps/maarch_entreprise/admin/priorities/class_priorities_Abstract.php b/apps/maarch_entreprise/admin/priorities/class_priorities_Abstract.php index d7d71027c5d13d0f2e4ca618ffca2a30940f56d6..e9e911f47fd40128eec0c608ed3d4f779f481d4c 100755 --- a/apps/maarch_entreprise/admin/priorities/class_priorities_Abstract.php +++ b/apps/maarch_entreprise/admin/priorities/class_priorities_Abstract.php @@ -77,6 +77,7 @@ abstract class PrioritiesAbstract extends Database protected function updateSession() { $_SESSION['mail_priorities'] = []; + $_SESSION['mail_priorities_id'] = []; $_SESSION['mail_priorities_attribute'] = []; $_SESSION['mail_priorities_wdays'] = []; $_SESSION['mail_priorities_color'] = []; @@ -86,6 +87,7 @@ abstract class PrioritiesAbstract extends Database $i = 0; foreach ($priorities as $priority) { $_SESSION['mail_priorities'][$i] = $priority['label']; + $_SESSION['mail_priorities_id'][$i] = $priority['id']; $_SESSION['mail_priorities_attribute'][$i] = ($priority['delays'] == null ? 'false' : $priority['delays']); $_SESSION['mail_priorities_wdays'][$i] = ($priority['working_days'] ? 'true' : 'false'); $_SESSION['mail_priorities_color'][$i] = $priority['color']; diff --git a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php index 7177d2ecdb7c212dee536a75857ce77cd7c917f1..9aee01393f9f3b58bb294b505f093eb10fda9e66 100755 --- a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php +++ b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php @@ -555,6 +555,7 @@ abstract class business_app_tools_Abstract extends Database } $_SESSION['mail_priorities'] = []; + $_SESSION['mail_priorities_id'] = []; $_SESSION['mail_priorities_attribute'] = []; $_SESSION['mail_priorities_wdays'] = []; $_SESSION['mail_priorities_color'] = []; @@ -564,6 +565,7 @@ abstract class business_app_tools_Abstract extends Database $i = 0; foreach ($priorities as $priority) { $_SESSION['mail_priorities'][$i] = $priority['label']; + $_SESSION['mail_priorities_id'][$i] = $priority['id']; $_SESSION['mail_priorities_attribute'][$i] = ($priority['delays'] == null ? 'false' : $priority['delays']); $_SESSION['mail_priorities_wdays'][$i] = ($priority['working_days'] ? 'true' : 'false'); $_SESSION['mail_priorities_color'][$i] = $priority['color']; diff --git a/migration/18.04/migrate.sh b/migration/18.04/migrate.sh new file mode 100644 index 0000000000000000000000000000000000000000..02da4b77b9596464d7e2a21306bc531f8b85a65a --- /dev/null +++ b/migration/18.04/migrate.sh @@ -0,0 +1,3 @@ +#!/bin/sh +php ./migratePriorities.php + diff --git a/migration/18.04/migratePriorities.php b/migration/18.04/migratePriorities.php new file mode 100644 index 0000000000000000000000000000000000000000..a42f30b1cc7c3398d4fd12402940422c789aad67 --- /dev/null +++ b/migration/18.04/migratePriorities.php @@ -0,0 +1,56 @@ +<?php + +require '../../vendor/autoload.php'; + +chdir('../..'); + +$customId = \SrcCore\models\CoreConfigModel::getCustomId(); + +if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/entreprise.xml")) { + $path = "custom/{$customId}/apps/maarch_entreprise/xml/entreprise.xml"; +} else { + $path = 'apps/maarch_entreprise/xml/entreprise.xml'; +} + +$priorities = []; +if (file_exists($path)) { + $loadedXml = simplexml_load_file($path); + if ($loadedXml) { + $i = 0; + foreach ($loadedXml->priorities->priority as $value) { + if (isset($loadedXml->priorities->default_priority) && $loadedXml->priorities->default_priority == $i) { + $priorities[] = [ + 'id' => $i, + 'label' => (string)$value, + 'color' => (string)$value['color'], + 'working_days' => (string)$value['working_days'], + 'delays' => (string)$value['with_delay'] == 'false' ? null : (int)$value['with_delay'], + 'default_priority' => 'true' + ]; + } else { + $priorities[] = [ + 'id' => $i, + 'label' => (string)$value, + 'color' => (string)$value['color'], + 'working_days' => (string)$value['working_days'], + 'delays' => (string)$value['with_delay'] == 'false' ? null : (int)$value['with_delay'], + 'default_priority' => 'false' + ]; + } + ++$i; + } + } +} + +foreach ($priorities as $priority) { + if ($priority['default_priority'] == 'true') { + \Priority\models\PriorityModel::resetDefaultPriority(); + } + $id = \Priority\models\PriorityModel::create($priority); + + \Resource\models\ResModel::update([ + 'set' => ['priority' => $id], + 'where' => ['priority = ?'], + 'data' => [$priority['id']] + ]); +} diff --git a/sql/data_fr.sql b/sql/data_fr.sql index 0aacb7a0492ce1d92f1f67319abe380edabaf2e1..5018f0506743f90b87721db9f0409c2fa0b432d2 100755 --- a/sql/data_fr.sql +++ b/sql/data_fr.sql @@ -1695,6 +1695,12 @@ INSERT INTO templates (template_label, template_comment, template_content, templ ------------ Select setval('templates_seq', (select max(template_id)+1 from templates), false); +/* PRIORITIES */ +TRUNCATE TABLE priorities; +INSERT INTO priorities (id, label, color, working_days, delays, default_priority) VALUES ('prio11111', 'Normal', '#009dc5', TRUE, null, TRUE); +INSERT INTO priorities (id, label, color, working_days, delays, default_priority) VALUES ('prio22222', 'Urgent', '#ffa500', TRUE, 8, FALSE); +INSERT INTO priorities (id, label, color, working_days, delays, default_priority) VALUES ('prio33333', 'Très urgent', '#ff0000', TRUE, 4, FALSE); + ------------ --NOTIFICATIONS ------------ diff --git a/sql/develop.sql b/sql/develop.sql index 2e8ab7fde32682ff7407d472d8efa6228140e252..1e8addec11d1ee5a94872b1a5611a50ac7dc301e 100755 --- a/sql/develop.sql +++ b/sql/develop.sql @@ -134,6 +134,10 @@ ALTER TABLE entities ADD COLUMN archival_agency character varying(255) DEFAULT ' /*PERFS ON VIEW*/ DROP VIEW IF EXISTS res_view_letterbox; + +/* Alter table here because view depends on it*/ +ALTER TABLE res_letterbox ALTER COLUMN priority TYPE character varying(16); + CREATE OR REPLACE VIEW res_view_letterbox AS SELECT r.tablename, r.is_multi_docservers, diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index d296577a56db9446ba35854c29d05418b43b9c37..064f2486b415a118d59bdc60d06faf9c422dac22 100644 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -107,7 +107,7 @@ class UserController $user['entities'] = UserModel::getEntitiesById(['userId' => $user['user_id']]); $user['allEntities'] = EntityModel::getAvailableEntitiesForAdministratorByUserId(['userId' => $user['user_id'], 'administratorUserId' => $GLOBALS['userId']]); $user['baskets'] = BasketModel::getBasketsByUserId(['userId' => $user['user_id'], 'unneededBasketId' => ['IndexingBasket']]); - $user['history'] = HistoryModel::getByUserId(['userId' => $user['user_id']]); + $user['history'] = HistoryModel::getByUserId(['userId' => $user['user_id'], 'select' => ['event_type', 'event_date', 'info', 'remote_ip']]); return $response->withJson($user); }