Fixed a problem with predefined expenses missing on mobile pages.
[timetracker.git] / dbinstall.php
index 9a2078e..6dc831a 100755 (executable)
@@ -61,7 +61,7 @@ if ($request->isGet()) {
     // spit white space before output in some situations such as in PDF reports.
     $file = fopen(APP_DIR.'/WEB-INF/config.php', 'r');
     $line = fgets($file);
-    if (strcmp('<?php'.PHP_EOL, $line) !== 0) {
+    if (strcmp("<?php\n", $line) !== 0 && strcmp("<?php\r\n", $line) !== 0) {
       echo('<font color="red">Error: WEB-INF/config.php file does not start with PHP opening tag.</font><br>');
     }
     fclose($file);
@@ -709,11 +709,29 @@ if ($_POST) {
     setChange("ALTER TABLE `tt_log` ADD `paid` tinyint(4) NULL default '0' AFTER `billable`");
   }
 
-  if ($_POST["convert11400to11600"]) {
+  if ($_POST["convert11400to11730"]) {
     setChange("ALTER TABLE `tt_teams` DROP `address`");
     setChange("ALTER TABLE `tt_fav_reports` ADD `report_spec` text default NULL AFTER `user_id`");
     setChange("ALTER TABLE `tt_fav_reports` ADD `paid_status` tinyint(4) default NULL AFTER `invoice`");
     setChange("ALTER TABLE `tt_fav_reports` ADD `show_paid` tinyint(4) NOT NULL DEFAULT '0' AFTER `show_invoice`");
+    setChange("ALTER TABLE `tt_expense_items` ADD `paid` tinyint(4) NULL default '0' AFTER `invoice_id`");
+    setChange("ALTER TABLE `tt_monthly_quotas` MODIFY `quota` decimal(5,2) NOT NULL");
+    setChange("ALTER TABLE `tt_teams` MODIFY `workday_hours` decimal(5,2) DEFAULT '8.00'");
+    setChange("ALTER TABLE `tt_teams` ADD `config` text default NULL AFTER `custom_logo`");
+    setChange("ALTER TABLE `tt_monthly_quotas` ADD `minutes` int(11) DEFAULT NULL");
+    setChange("ALTER TABLE `tt_teams` ADD `workday_minutes` smallint(4) DEFAULT '480' AFTER `workday_hours`");
+    setChange("UPDATE `tt_teams` SET `workday_minutes` = 60 * `workday_hours`");
+    setChange("ALTER TABLE `tt_teams` DROP `workday_hours`");
+    setChange("UPDATE `tt_monthly_quotas` SET `minutes` = 60 * `quota`");
+    setChange("ALTER TABLE `tt_monthly_quotas` DROP `quota`");
+    setChange("ALTER TABLE `tt_teams` DROP `uncompleted_indicators`");
+    setChange("ALTER TABLE `tt_users` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+    setChange("ALTER TABLE `tt_teams` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+    setChange("ALTER TABLE `tt_log` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+    setChange("ALTER TABLE `tt_tmp_refs` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+    setChange("CREATE TABLE `tt_roles` (`id` int(11) NOT NULL auto_increment, `team_id` int(11) NOT NULL, `name` varchar(80) default NULL, `rank` int(11) default 0, `rights` text default NULL, `status` tinyint(4) default 1, PRIMARY KEY  (`id`))");
+    setChange("create unique index role_idx on tt_roles(team_id, rank, status)");
+    setChange("ALTER TABLE `tt_roles` ADD `description` varchar(255) default NULL AFTER `name`");
   }
 
   if ($_POST["cleanup"]) {
@@ -746,6 +764,7 @@ if ($_POST) {
     setChange("OPTIMIZE TABLE tt_tmp_refs");
     setChange("OPTIMIZE TABLE tt_user_project_binds");
     setChange("OPTIMIZE TABLE tt_users");
+    setChange("OPTIMIZE TABLE tt_roles");
   }
 
   print "done.<br>\n";
@@ -758,7 +777,7 @@ if ($_POST) {
 <h2>DB Install</h2>
 <table width="80%" border="1" cellpadding="10" cellspacing="0">
   <tr>
-    <td width="80%"><b>Create database structure (v1.16.0)</b>
+    <td width="80%"><b>Create database structure (v1.17.30)</b>
     <br>(applies only to new installations, do not execute when updating)</br></td><td><input type="submit" name="crstructure" value="Create"></td>
   </tr>
 </table>
@@ -794,8 +813,8 @@ if ($_POST) {
     <td><input type="submit" name="convert1600to11400" value="Update"><br></td>
   </tr>
   <tr valign="top">
-    <td>Update database structure (v1.14 to v1.16)</td>
-    <td><input type="submit" name="convert11400to11600" value="Update"><br></td>
+    <td>Update database structure (v1.14 to v1.17.30)</td>
+    <td><input type="submit" name="convert11400to11730" value="Update"><br></td>
   </tr>
 </table>