<?php

/*******************************************/
/**	Fichier de migration de la base MYSQL **/
/*******************************************/

require_once(__DIR__.DIRECTORY_SEPARATOR.'common.php');
global $myUser;
try{
if(!$myUser->superadmin) throw new Exception('Merci de vous identifier en super admin');





// [ MODIFICATIONS DU 18/03/2019 12:07 par JNARBONI] 
$comment = "Création de la table activedirectory_group";
$query  = "CREATE TABLE `activedirectory_group` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`rank` varchar(225) DEFAULT NULL,
	`firm` int(11) DEFAULT NULL,
	`created` int(11) DEFAULT NULL,
	`updated` int(11) DEFAULT NULL,
	`updater` varchar(225) DEFAULT NULL,
	`creator` varchar(225) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
execute($comment,$query);



$comment = "Création de la table dashboard_dashboard";
$query  = "CREATE TABLE `dashboard_dashboard` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`user` varchar(225) DEFAULT NULL,
	`label` varchar(225) DEFAULT NULL,
	`icon` varchar(225) DEFAULT NULL,
	`default` tinyint(1) NOT NULL DEFAULT '0',
	`created` int(11) DEFAULT NULL,
	`updated` int(11) DEFAULT NULL,
	`updater` varchar(225) DEFAULT NULL,
	`creator` varchar(225) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
execute($comment,$query);



$comment = "Création de la table dashboard_dashboard_widget";
$query  = "CREATE TABLE `dashboard_dashboard_widget` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`model` varchar(225) DEFAULT NULL,
	`position` int(11) DEFAULT NULL,
	`minified` tinyint(1) NOT NULL DEFAULT '0',
	`dashboard` int(11) DEFAULT NULL,
	`created` int(11) DEFAULT NULL,
	`updated` int(11) DEFAULT NULL,
	`updater` varchar(225) DEFAULT NULL,
	`creator` varchar(225) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
execute($comment,$query);



$comment = "Ajout de la colonne mail (varchar(225)) sur la table firm";
$query  = "ALTER TABLE `firm` ADD COLUMN `mail` varchar(225) NOT NULL;";
execute($comment,$query);



$comment = "Ajout de la colonne assign (varchar(225)) sur la table issue_report";
$query  = "ALTER TABLE `issue_report` ADD COLUMN `assign` varchar(225) DEFAULT NULL;";
execute($comment,$query);



$comment = "Ajout de la colonne state (varchar(225)) sur la table issue_report";
$query  = "ALTER TABLE `issue_report` ADD COLUMN `state` varchar(225) DEFAULT NULL;";
execute($comment,$query);



$comment = "Ajout de la colonne passwordTime (varchar(225)) sur la table user";
$query  = "ALTER TABLE `user` ADD COLUMN `passwordTime` varchar(225) DEFAULT NULL;";
execute($comment,$query);

//--INSTRUCTIONS


function execute($comment,$sql){
	echo $comment.'<br/>';
	User::staticQuery($sql);
	echo '</hr>';
}

}catch(Exception $e){ ?>
	<div style="text-align: center;margin:auto;width:500px;">
		Erreur : <?php echo $e->getMessage(); ?>
	</div>
<?php } ?>
