Skip to content
Snippets Groups Projects
Verified Commit f1bd181b authored by Damien's avatar Damien
Browse files

[MIGRATION] #130 Priority migration

parent e28ff274
No related branches found
No related tags found
No related merge requests found
...@@ -77,6 +77,7 @@ abstract class PrioritiesAbstract extends Database ...@@ -77,6 +77,7 @@ abstract class PrioritiesAbstract extends Database
protected function updateSession() { protected function updateSession() {
$_SESSION['mail_priorities'] = []; $_SESSION['mail_priorities'] = [];
$_SESSION['mail_priorities_id'] = [];
$_SESSION['mail_priorities_attribute'] = []; $_SESSION['mail_priorities_attribute'] = [];
$_SESSION['mail_priorities_wdays'] = []; $_SESSION['mail_priorities_wdays'] = [];
$_SESSION['mail_priorities_color'] = []; $_SESSION['mail_priorities_color'] = [];
...@@ -86,6 +87,7 @@ abstract class PrioritiesAbstract extends Database ...@@ -86,6 +87,7 @@ abstract class PrioritiesAbstract extends Database
$i = 0; $i = 0;
foreach ($priorities as $priority) { foreach ($priorities as $priority) {
$_SESSION['mail_priorities'][$i] = $priority['label']; $_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_attribute'][$i] = ($priority['delays'] == null ? 'false' : $priority['delays']);
$_SESSION['mail_priorities_wdays'][$i] = ($priority['working_days'] ? 'true' : 'false'); $_SESSION['mail_priorities_wdays'][$i] = ($priority['working_days'] ? 'true' : 'false');
$_SESSION['mail_priorities_color'][$i] = $priority['color']; $_SESSION['mail_priorities_color'][$i] = $priority['color'];
......
...@@ -555,6 +555,7 @@ abstract class business_app_tools_Abstract extends Database ...@@ -555,6 +555,7 @@ abstract class business_app_tools_Abstract extends Database
} }
$_SESSION['mail_priorities'] = []; $_SESSION['mail_priorities'] = [];
$_SESSION['mail_priorities_id'] = [];
$_SESSION['mail_priorities_attribute'] = []; $_SESSION['mail_priorities_attribute'] = [];
$_SESSION['mail_priorities_wdays'] = []; $_SESSION['mail_priorities_wdays'] = [];
$_SESSION['mail_priorities_color'] = []; $_SESSION['mail_priorities_color'] = [];
...@@ -564,6 +565,7 @@ abstract class business_app_tools_Abstract extends Database ...@@ -564,6 +565,7 @@ abstract class business_app_tools_Abstract extends Database
$i = 0; $i = 0;
foreach ($priorities as $priority) { foreach ($priorities as $priority) {
$_SESSION['mail_priorities'][$i] = $priority['label']; $_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_attribute'][$i] = ($priority['delays'] == null ? 'false' : $priority['delays']);
$_SESSION['mail_priorities_wdays'][$i] = ($priority['working_days'] ? 'true' : 'false'); $_SESSION['mail_priorities_wdays'][$i] = ($priority['working_days'] ? 'true' : 'false');
$_SESSION['mail_priorities_color'][$i] = $priority['color']; $_SESSION['mail_priorities_color'][$i] = $priority['color'];
......
#!/bin/sh
php ./migratePriorities.php
<?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']]
]);
}
...@@ -1695,6 +1695,12 @@ INSERT INTO templates (template_label, template_comment, template_content, templ ...@@ -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); 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 --NOTIFICATIONS
------------ ------------
......
...@@ -134,6 +134,10 @@ ALTER TABLE entities ADD COLUMN archival_agency character varying(255) DEFAULT ' ...@@ -134,6 +134,10 @@ ALTER TABLE entities ADD COLUMN archival_agency character varying(255) DEFAULT '
/*PERFS ON VIEW*/ /*PERFS ON VIEW*/
DROP VIEW IF EXISTS res_view_letterbox; 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 CREATE OR REPLACE VIEW res_view_letterbox AS
SELECT r.tablename, SELECT r.tablename,
r.is_multi_docservers, r.is_multi_docservers,
......
...@@ -107,7 +107,7 @@ class UserController ...@@ -107,7 +107,7 @@ class UserController
$user['entities'] = UserModel::getEntitiesById(['userId' => $user['user_id']]); $user['entities'] = UserModel::getEntitiesById(['userId' => $user['user_id']]);
$user['allEntities'] = EntityModel::getAvailableEntitiesForAdministratorByUserId(['userId' => $user['user_id'], 'administratorUserId' => $GLOBALS['userId']]); $user['allEntities'] = EntityModel::getAvailableEntitiesForAdministratorByUserId(['userId' => $user['user_id'], 'administratorUserId' => $GLOBALS['userId']]);
$user['baskets'] = BasketModel::getBasketsByUserId(['userId' => $user['user_id'], 'unneededBasketId' => ['IndexingBasket']]); $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); return $response->withJson($user);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment