Cosmetic formatting fixes
authorNik Okuntseff <support@anuko.com>
Sun, 20 Mar 2016 16:17:45 +0000 (09:17 -0700)
committerNik Okuntseff <support@anuko.com>
Sun, 20 Mar 2016 16:17:45 +0000 (09:17 -0700)
16 files changed:
admin_team_add.php
admin_team_delete.php
admin_team_edit.php
cf_custom_field_add.php
cf_custom_field_delete.php
cf_custom_field_edit.php
cf_custom_fields.php
cf_dropdown_option_add.php
cf_dropdown_option_delete.php
cf_dropdown_option_edit.php
charts.php
client_add.php
client_delete.php
client_edit.php
cron.php
dbinstall.php

index 15d7a32..258f6ca 100644 (file)
@@ -46,7 +46,7 @@ if ($request->getMethod() == 'POST') {
   }
   $cl_manager_email = trim($request->getParameter('manager_email'));
 }
-  
+
 $form = new Form('teamForm');
 $form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'team_name','value'=>$cl_team_name));
 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
@@ -68,23 +68,23 @@ if ($request->getMethod() == 'POST') {
     if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
     if ($cl_password1 !== $cl_password2)
       $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
-  }    
+  }
   if (!ttValidEmail($cl_manager_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
-    
+
   if ($errors->isEmpty()) {
     if (!ttUserHelper::getUserByLogin($cl_manager_login)) {
       // Create a new team.
       if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$');
       $team_id = ttTeamHelper::insert(array('name'=>$cl_team_name,'currency'=>CURRENCY_DEFAULT));
       if ($team_id) {
-      // Team created, now create a team manager.
+        // Team created, now create a team manager.
         $user_id = ttUserHelper::insert(array(
-         'team_id' => $team_id,
-         'role' => ROLE_MANAGER,
+          'team_id' => $team_id,
+          'role' => ROLE_MANAGER,
           'name' => $cl_manager_name,
           'login' => $cl_manager_login,
           'password' => $cl_password1,
-         'email' => $cl_manager_email));
+          'email' => $cl_manager_email));
       }
       if ($team_id && $user_id) {
         header('Location: admin_teams.php');
index 2ef0983..b53c5e9 100644 (file)
@@ -59,7 +59,7 @@ if ($request->getMethod() == 'POST') {
     exit();
   }
 }
-       
+
 $smarty->assign('team_to_delete', $team_name);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('title', $i18n->getKey('title.delete_team'));
index 7f2f536..fa67f7a 100644 (file)
@@ -39,7 +39,7 @@ if (!ttAccessCheck(right_administer_site)) {
 
 $team_id = $request->getParameter('id');
 $team_details = ttTeamHelper::getTeamDetails($team_id);        
-  
+
 if ($request->getMethod() == 'POST') {
   $cl_team_name = trim($request->getParameter('team_name'));
   $cl_manager_name = trim($request->getParameter('manager_name'));
@@ -58,7 +58,7 @@ if ($request->getMethod() == 'POST') {
   }
   $cl_manager_email = $team_details['manager_email'];
 }
-  
+
 $form = new Form('teamForm');
 $form->addInput(array('type'=>'text','maxlength'=>'80','name'=>'team_name','value'=>$cl_team_name));
 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_name','value'=>$cl_manager_name));
@@ -83,13 +83,13 @@ if ($request->getMethod() == 'POST') {
       if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
       if ($cl_password1 !== $cl_password2)
         $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
-    }  
+    }
     if (!ttValidEmail($cl_manager_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
-      
+
     // New login must be unique.
     if ($cl_manager_login != $team_details['manager_login'])
       if (ttUserHelper::getUserByLogin($cl_manager_login)) $errors->add($i18n->getKey('error.user_exists'));
-        
+
     if ($errors->isEmpty()) {
       $update_result = ttTeamHelper::update($team_id, array('name'=>$cl_team_name));
       if ($update_result) {
index fc35cf1..3af6c3a 100644 (file)
@@ -43,7 +43,7 @@ if ($request->getMethod() == 'POST') {
   if (!$cl_required)
     $cl_required = 0;
 }
-       
+
 $form = new Form('fieldForm');
 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>''));
 $form->addInput(array('type'=>'combobox','name'=>'type',
index 4e17cd0..78cd380 100644 (file)
@@ -66,7 +66,7 @@ if ($request->getMethod() == 'POST') {
     $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
   }
 }
-       
+
 $smarty->assign('field', $field['label']);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('onload', 'onLoad="document.fieldDeleteForm.btn_cancel.focus()"');
index 1f84659..3d92d94 100644 (file)
@@ -48,10 +48,9 @@ if ($errors->isEmpty()) {
   $form->addInput(array('type'=>'checkbox','name'=>'required','data'=>1,'value'=>$field['required']));
   $form->addInput(array('type'=>'combobox','name'=>'type','value'=>$field['type'],
     'data'=>array(CustomFields::TYPE_TEXT=>$i18n->getKey('label.type_text'),
-                  CustomFields::TYPE_DROPDOWN=>$i18n->getKey('label.type_dropdown'))
-  ));
-  $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));   
-}    
+                  CustomFields::TYPE_DROPDOWN=>$i18n->getKey('label.type_dropdown'))));
+  $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
+}
 
 if ($request->getMethod() == 'POST') {
   $cl_name = trim($request->getParameter('name'));
@@ -59,7 +58,7 @@ if ($request->getMethod() == 'POST') {
   $cl_required = $request->getParameter('required');
   if (!$cl_required)
     $cl_required = 0;
-  
+
   // Validate user input.
   if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
 
index a44f30c..17a04af 100644 (file)
@@ -46,7 +46,7 @@ if ($request->getMethod() == 'POST') {
   }
 } else {
   $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
-       
+
   $fields = CustomFields::getFields();
   // At this time only one custom field is supported. Disable the Add button if we already have one or more custom fields.
   if (count($fields) > 0)
index 5dd2c57..26ede87 100644 (file)
@@ -40,20 +40,20 @@ $cl_field_id = $request->getParameter('field_id');
 $field = CustomFields::getField($cl_field_id);
 if (false === $field)
   $errors->add($i18n->getKey('error.db'));
-    
+
 $form = new Form('optionAddForm');
 if ($errors->isEmpty()) {
   $form->addInput(array('type'=>'hidden','name'=>'field_id','value'=>$cl_field_id));
   $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>''));
   $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
 }
-  
+
 if ($request->getMethod() == 'POST') {
   $cl_option_name = trim($request->getParameter('name'));
-  
+
   // Validate user input.
   if (!ttValidString($cl_option_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
-         
+
   if ($errors->isEmpty()) {
     $res = CustomFields::insertOption($cl_field_id, $cl_option_name);
     if ($res) {
index 404896f..c53f16e 100644 (file)
@@ -58,7 +58,7 @@ if ($request->getMethod() == 'POST') {
     exit();
   }
 } else {
-  $option = CustomFields::getOptionName($cl_id);       
+  $option = CustomFields::getOptionName($cl_id);
   if (false === $option)
     $errors->add($i18n->getKey('error.db'));
 
@@ -68,7 +68,7 @@ if ($request->getMethod() == 'POST') {
     $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
   }
 }
-       
+
 $smarty->assign('option', $option);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('onload', 'onLoad="document.optionDeleteForm.btn_cancel.focus()"');
index eff95b1..b46a3a5 100644 (file)
@@ -46,11 +46,11 @@ if ($errors->isEmpty()) {
   $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>$cl_name));
   $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
   $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
-}      
+}
 
 if ($request->getMethod() == 'POST') {
   $cl_name = trim($request->getParameter('name'));
-  
+
   // Validate user input.
   if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.thing_name'));
 
index 31ac49f..a7d0887 100644 (file)
@@ -84,7 +84,7 @@ $_SESSION['chart_type'] = $cl_type;
 // Who do we draw charts for?
 $on_behalf_id = $request->getParameter('onBehalfUser', (isset($_SESSION['behalf_id'])? $_SESSION['behalf_id'] : $user->id));
 
-if ($request->getMethod( )== 'POST') {    
+if ($request->getMethod( )== 'POST') {
   // If chart interval changed - save it.
   $cl_interval = $request->getParameter('interval');
   if ($cl_interval) {
@@ -94,24 +94,24 @@ if ($request->getMethod( )== 'POST') {
     $sc = new ttSysConfig($user->id);
     $sc->setValue(SYSC_CHART_INTERVAL, $cl_interval);
   }
-  // If chart type changed - save it.  
+  // If chart type changed - save it.
   $cl_type = $request->getParameter('type');
   if ($cl_type) {
     // Save in the session
     $_SESSION['chart_type'] = $cl_type;
     // and permanently.
     $sc = new ttSysConfig($user->id);
-    $sc->setValue(SYSC_CHART_TYPE, $cl_type);  
+    $sc->setValue(SYSC_CHART_TYPE, $cl_type);
   }
   // If user has changed - set behalf_id accordingly in the session.
   if ($request->getParameter('onBehalfUser')) {
     if($user->canManageTeam()) {
       unset($_SESSION['behalf_id']);
       unset($_SESSION['behalf_name']);
-       
+
       if($on_behalf_id != $user->id) {
         $_SESSION['behalf_id'] = $on_behalf_id;
-       $_SESSION['behalf_name'] = ttUserHelper::getUserName($on_behalf_id);                    
+        $_SESSION['behalf_name'] = ttUserHelper::getUserName($on_behalf_id);
       }
       header('Location: charts.php');
       exit();
@@ -164,7 +164,7 @@ if ($chart_selector) {
     $types[CHART_TASKS] = $i18n->getKey('dropdown.tasks');
   if (in_array('cl', explode(',', $user->plugins)))
     $types[CHART_CLIENTS] = $i18n->getKey('dropdown.clients');
-       
+
   // Add chart type dropdown.
   $chart_form->addInput(array('type' => 'combobox',
     'onchange' => 'if(this.form) this.form.submit();',
@@ -179,7 +179,7 @@ $chart_form->addInput(array('type'=>'calendar','name'=>'date','value'=>$cl_date)
 
 // Get data for our chart.
 $totals = ttChartHelper::getTotals($on_behalf_id, $cl_type, $cl_date, $cl_interval);
-$smarty->assign('totals', $totals);   
+$smarty->assign('totals', $totals);
 
 // Prepare chart for drawing.
 /*
@@ -188,7 +188,7 @@ $smarty->assign('totals', $totals);
  * auto-calculated percentage markers around it. We print labels (to the side of the picture) ourselves,
  * using the same colors libchart is using. For labels printout, the $totals array (which is used for picture points)
  * is also passed to charts.tpl Smarty template.
- * 
+ *
  * To make all of the above possible with only one database call to obtain $totals we have to print the chart image
  * to a file here (see code below). Once the image is available as a .png file, the charts.tpl can render it.
  *
index da9b90e..b718705 100644 (file)
@@ -57,7 +57,7 @@ $form->addInput(array('type'=>'floatfield','name'=>'tax','size'=>'10','format'=>
 if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
   $form->addInput(array('type'=>'checkboxgroup','name'=>'projects','data'=>$projects,'layout'=>'H','datakeys'=>array('id','name'),'value'=>$cl_projects));
 $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.add')));
-       
+
 if ($request->getMethod() == 'POST') {
   // Validate user input.
   if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.client_name'));
@@ -76,12 +76,12 @@ if ($request->getMethod() == 'POST') {
         header('Location: clients.php');
         exit();
       } else
-        $errors->add($i18n->getKey('error.db'));       
+        $errors->add($i18n->getKey('error.db'));
      } else
        $errors->add($i18n->getKey('error.client_exists'));
   }
 } // post
-       
+
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('onload', 'onLoad="document.clientForm.name.focus()"');
 $smarty->assign('title', $i18n->getKey('title.add_client'));
index aea24d3..8d3f65e 100644 (file)
@@ -40,7 +40,7 @@ $id = (int)$request->getParameter('id');
 $client = ttClientHelper::getClient($id);
 
 $client_to_delete = $client['name'];
-       
+
 $form = new Form('clientDeleteForm');
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$id));
 $form->addInput(array('type'=>'combobox','name'=>'delete_client_entries',
index 373263c..c24a427 100644 (file)
@@ -91,7 +91,7 @@ if ($request->getMethod() == 'POST') {
           header('Location: clients.php');
           exit();
         } else
-          $errors->add($i18n->getKey('error.db'));     
+          $errors->add($i18n->getKey('error.db'));
       } else
         $errors->add($i18n->getKey('error.client_exists'));
     }
index 81ef898..345ddd3 100644 (file)
--- a/cron.php
+++ b/cron.php
@@ -55,11 +55,11 @@ if (is_a($res, 'PEAR_Error'))
 
 while ($val = $res->fetchRow()) {
   // We have jobs to execute in user language.
-  
+
   // Get favorite report details.
   $report = ttFavReportHelper::getReport($val['report_id']);
   if (!$report) continue;
-  
+
   // Recycle global $user and $i18n objects, as user settings and language are specific for each report.
   $user = new ttUser(null, $report['user_id']);
   $i18n->load($user->lang);
@@ -69,7 +69,7 @@ while ($val = $res->fetchRow()) {
     echo "Report ".$val['report_id']. " sent to ".$val['email']."<br>";
   else
     echo "Error while emailing report...<br>";
-    
+
   // Calculate next execution time.
   $next = tdCron::getNextOccurrence($val['cron_spec'], $now); 
 
index 48bfa74..b6ddb1e 100644 (file)
@@ -45,7 +45,7 @@ function setChange($sql) {
 
 if ($_POST) {
   print "Processing...<br>\n";
-  
+
   if ($_POST["crstructure"]) {
     $sqlQuery = join("\n", file("mysql.sql"));
     $sqlQuery = str_replace("TYPE=MyISAM","",$sqlQuery);
@@ -59,7 +59,7 @@ if ($_POST) {
       }
     }
   }
-  
+
   if ($_POST["convert5to7"]) {
     setChange("alter table `activity_log` CHANGE al_comment al_comment BLOB");
     setChange("CREATE TABLE `sysconfig` (`sysc_id` int(11) unsigned NOT NULL auto_increment,`sysc_name` varchar(32) NOT NULL default '',`sysc_value` varchar(70) default NULL, PRIMARY KEY  (`sysc_id`), UNIQUE KEY `sysc_id` (`sysc_id`), UNIQUE KEY `sysc_name` (`sysc_name`))");
@@ -99,40 +99,39 @@ if ($_POST) {
     }
     // Iterate through projects.
     while ($val = $res->fetchRow()) {
-       $project_id = $val['p_id'];
-       
-        // Get activity binds for project (old way).
-        // $sql = "select ab_id_a from activity_bind where ab_id_p = $project_id";
-        $sql = "select ab_id_a, a_id, a_name from activity_bind
-          inner join activities on (ab_id_a = a_id)
-          where ab_id_p = $project_id
-          order by a_name";
-        
-        $result = $mdb2->query($sql);
-        if (is_a($result, 'PEAR_Error')) {
-          die($result->getMessage());
-        }
-        $activity_arr = array();
-        while ($value = $result->fetchRow()) {
-          $activity_arr[] = $value['ab_id_a']; 
-        }
-        $a_comma_separated = implode(",", $activity_arr); // This is a comma-separated list of associated activity ids.
-             
-        // Re-bind the project to activities (new way).
-        $sql = "update projects set p_activities = ".$mdb2->quote($a_comma_separated)." where p_id = $project_id";
-        $affected = $mdb2->exec($sql);
-        if (is_a($affected, 'PEAR_Error')) {
-          die($affected->getMessage());
-        }
+      $project_id = $val['p_id'];
+
+      // Get activity binds for project (old way).
+      // $sql = "select ab_id_a from activity_bind where ab_id_p = $project_id";
+      $sql = "select ab_id_a, a_id, a_name from activity_bind
+        inner join activities on (ab_id_a = a_id)
+        where ab_id_p = $project_id order by a_name";
+
+      $result = $mdb2->query($sql);
+      if (is_a($result, 'PEAR_Error')) {
+        die($result->getMessage());
+      }
+      $activity_arr = array();
+      while ($value = $result->fetchRow()) {
+        $activity_arr[] = $value['ab_id_a'];
+      }
+      $a_comma_separated = implode(",", $activity_arr); // This is a comma-separated list of associated activity ids.
+
+      // Re-bind the project to activities (new way).
+      $sql = "update projects set p_activities = ".$mdb2->quote($a_comma_separated)." where p_id = $project_id";
+      $affected = $mdb2->exec($sql);
+      if (is_a($affected, 'PEAR_Error')) {
+        die($affected->getMessage());
+      }
     }
   }
-  
+
   if ($_POST["convert133to1340"]) {
     setChange("ALTER TABLE companies ADD COLUMN c_show_pie smallint(2) DEFAULT 1");
     setChange("ALTER TABLE companies ADD COLUMN c_pie_mode smallint(2) DEFAULT 1");
     setChange("ALTER TABLE companies ADD COLUMN c_lang varchar(20) default NULL");
   }
-  
+
   // The update_companies function sets up c_show_pie, c_pie_mode, and c_lang
   // fields in the companies table from the corresponding manager fields. 
   if ($_POST["update_companies"]) {
@@ -150,22 +149,22 @@ if ($_POST) {
       $show_pie = $val['u_show_pie'];
       $pie_mode = $val['u_pie_mode'];
       $lang = $val['u_lang'];
-      
+
       $sql = "update companies set
         c_show_pie = $show_pie, c_pie_mode = $pie_mode, c_lang = ".$mdb2->quote($lang).
         " where c_id = $company_id";
-      
+
       $result = $mdb2->query($sql);
       if (is_a($result, 'PEAR_Error')) {
         die($result->getMessage());
       }
     }
   }
-    
+
   if ($_POST["convert1340to1485"]) {
     setChange("ALTER TABLE users DROP u_show_pie");
     setChange("ALTER TABLE users DROP u_pie_mode");
-    setChange("ALTER TABLE users DROP u_lang");  
+    setChange("ALTER TABLE users DROP u_lang");
     setChange("ALTER TABLE `users` modify u_login varchar(100) NOT NULL");
     setChange("ALTER TABLE `users` modify u_active smallint(6) default '1'");
     setChange("drop index u_login_idx on users");
@@ -188,7 +187,7 @@ if ($_POST) {
     setChange("RENAME TABLE teams TO att_teams");
     setChange("ALTER TABLE att_teams CHANGE c_id id int(11) NOT NULL auto_increment");
     setChange("RENAME TABLE users TO att_users");
-    setChange("update att_users set u_company_id = 0 where u_company_id is NULL");    
+    setChange("update att_users set u_company_id = 0 where u_company_id is NULL");
     setChange("ALTER TABLE att_users CHANGE u_company_id team_id int(11) NOT NULL");
     setChange("RENAME TABLE att_teams TO tt_teams");
     setChange("RENAME TABLE att_users TO tt_users");
@@ -247,7 +246,7 @@ if ($_POST) {
     setChange("ALTER TABLE tt_users CHANGE u_id id int(11) NOT NULL auto_increment");
     setChange("ALTER TABLE tt_users CHANGE u_timestamp timestamp timestamp NOT NULL");
     setChange("ALTER TABLE tt_users CHANGE u_login login varchar(50) NOT NULL");
-    setChange("drop index u_login_idx on tt_users");  
+    setChange("drop index u_login_idx on tt_users");
     setChange("create unique index login_idx on tt_users(login, u_active)");
     setChange("ALTER TABLE tt_users CHANGE u_password password varchar(50) default NULL");
     setChange("ALTER TABLE tt_users CHANGE u_name name varchar(100) default NULL");
@@ -263,14 +262,14 @@ if ($_POST) {
     setChange("ALTER TABLE user_bind CHANGE ub_checked status tinyint(4) default '1'");
     setChange("ALTER TABLE activities ADD COLUMN team_id int(11) NOT NULL");
     setChange("ALTER TABLE clients ADD COLUMN team_id int(11) NOT NULL");
-    setChange("ALTER TABLE projects ADD COLUMN team_id int(11) NOT NULL");                     
+    setChange("ALTER TABLE projects ADD COLUMN team_id int(11) NOT NULL");
   }
-  
+
   // The update_to_team_id function sets team_id field projects, activities, and clients tables.
   if ($_POST["update_to_team_id"]) {
     $mdb2 = getConnection();
-    
-    // Update projects.   
+
+    // Update projects.
     $sql = "select p_id, p_manager_id from projects where team_id = 0 limit 1000";
     $res = $mdb2->query($sql);
     if (is_a($res, 'PEAR_Error')) {
@@ -281,7 +280,7 @@ if ($_POST) {
     while ($val = $res->fetchRow()) {
       $project_id = $val['p_id'];
       $manager_id = $val['p_manager_id'];
-      
+
       $sql = "select team_id from tt_users where id = $manager_id";
       $res2 = $mdb2->query($sql);
       if (is_a($res2, 'PEAR_Error')) {
@@ -289,7 +288,7 @@ if ($_POST) {
       }
       $val2 = $res2->fetchRow();
       $team_id = $val2['team_id'];
-      
+
       if ($team_id) {
         $sql = "update projects set team_id = $team_id where p_id = $project_id";
         $affected = $mdb2->exec($sql);
@@ -300,8 +299,8 @@ if ($_POST) {
       }
     }
     print "Updated $projects_updated projects...<br>\n";
-    
-    // Update tasks.   
+
+    // Update tasks.
     $sql = "select a_id, a_manager_id from activities where team_id = 0 limit 1000";
     $res = $mdb2->query($sql);
     if (is_a($res, 'PEAR_Error')) {
@@ -312,7 +311,7 @@ if ($_POST) {
     while ($val = $res->fetchRow()) {
       $task_id = $val['a_id'];
       $manager_id = $val['a_manager_id'];
-      
+
       $sql = "select team_id from tt_users where id = $manager_id";
       $res2 = $mdb2->query($sql);
       if (is_a($res2, 'PEAR_Error')) {
@@ -320,19 +319,19 @@ if ($_POST) {
       }
       $val2 = $res2->fetchRow();
       $team_id = $val2['team_id'];
-      
+
       if ($team_id) {
         $sql = "update activities set team_id = $team_id where a_id = $task_id";
         $affected = $mdb2->exec($sql);
         if (is_a($affected, 'PEAR_Error')) {
           die($affected->getMessage());
         }
-        $tasks_updated += $affected;   
+        $tasks_updated += $affected;
       }
     }
     print "Updated $tasks_updated tasks...<br>\n";
-    
-    // Update clients.   
+
+    // Update clients.
     $sql = "select clnt_id, clnt_id_um from clients where team_id = 0 limit 1000";
     $res = $mdb2->query($sql);
     if (is_a($res, 'PEAR_Error')) {
@@ -343,7 +342,7 @@ if ($_POST) {
     while ($val = $res->fetchRow()) {
       $client_id = $val['clnt_id'];
       $manager_id = $val['clnt_id_um'];
-      
+
       $sql = "select team_id from tt_users where id = $manager_id";
       $res2 = $mdb2->query($sql);
       if (is_a($res2, 'PEAR_Error')) {
@@ -351,28 +350,28 @@ if ($_POST) {
       }
       $val2 = $res2->fetchRow();
       $team_id = $val2['team_id'];
-      
+
       if ($team_id) {
         $sql = "update clients set team_id = $team_id where clnt_id = $client_id";
         $affected = $mdb2->exec($sql);
         if (is_a($affected, 'PEAR_Error')) {
           die($affected->getMessage());
         }
-        $clients_updated += $affected; 
+        $clients_updated += $affected;
       }
     }
     print "Updated $clients_updated clients...<br>\n";
   }
-    
+
   if ($_POST["convert1485to1579"]) {
     setChange("ALTER TABLE tt_fav_reports MODIFY id int(11) NOT NULL auto_increment");
     setChange("RENAME TABLE clients TO tt_clients");
     setChange("ALTER TABLE tt_clients CHANGE clnt_id id int(11) NOT NULL AUTO_INCREMENT");
     setChange("ALTER TABLE tt_clients CHANGE clnt_status status tinyint(4) default '1'");
-    setChange("ALTER TABLE tt_clients DROP clnt_id_um");       
+    setChange("ALTER TABLE tt_clients DROP clnt_id_um");
     setChange("ALTER TABLE tt_clients CHANGE clnt_name name varchar(80) NOT NULL");
     setChange("drop index clnt_name_idx on tt_clients");
-    setChange("drop index client_name_idx on tt_clients");   
+    setChange("drop index client_name_idx on tt_clients");
     setChange("create unique index client_name_idx on tt_clients(team_id, name, status)");
     setChange("ALTER TABLE tt_teams ADD COLUMN `timestamp` timestamp NOT NULL");
     setChange("ALTER TABLE tt_clients CHANGE clnt_addr_cust address varchar(255) default NULL");
@@ -459,7 +458,7 @@ if ($_POST) {
     setChange("ALTER TABLE tt_invoices drop client_name");
     setChange("ALTER TABLE tt_invoices drop client_addr");
     setChange("ALTER TABLE tt_invoices drop comment");
-    setChange("ALTER TABLE tt_invoices drop tax");    
+    setChange("ALTER TABLE tt_invoices drop tax");
     setChange("ALTER TABLE tt_invoices ADD COLUMN name varchar(80) NOT NULL");
     setChange("ALTER TABLE tt_invoices ADD COLUMN client_id int(11) NOT NULL");
     setChange("ALTER TABLE tt_invoices ADD COLUMN start_date date NOT NULL");
@@ -470,7 +469,7 @@ if ($_POST) {
     setChange("create index client_idx on tt_log(client_id)");
     setChange("create index invoice_idx on tt_log(invoice_id)");
   }
-  
+
   if ($_POST["convert1579to1600"]) {
     setChange("ALTER TABLE tt_invoices ADD COLUMN date date NOT NULL");
     setChange("ALTER TABLE tt_teams ADD COLUMN custom_logo tinyint(4) default '0'");
@@ -487,7 +486,7 @@ if ($_POST) {
     setChange("ALTER TABLE tt_invoices DROP start_date");
     setChange("ALTER TABLE tt_invoices DROP end_date");
   }
-  
+
   if ($_POST["convert1600to1900"]) {
     setChange("DROP TABLE IF EXISTS tt_invoice_headers");
     setChange("ALTER TABLE tt_fav_reports ADD COLUMN `client_id` int(11) default NULL");
@@ -517,8 +516,8 @@ if ($_POST) {
     setChange("ALTER TABLE tt_invoices ADD COLUMN status tinyint(4) default '1'");
     setChange("DROP INDEX name_idx on tt_invoices");
     setChange("create unique index name_idx on tt_invoices(team_id, name, status)");
-  }    
-   
+  }
+
   // The update_clients function updates projects field in tt_clients table.
   if ($_POST["update_clients"]) {
     $mdb2 = getConnection();
@@ -527,37 +526,37 @@ if ($_POST) {
     if (is_a($res, 'PEAR_Error')) {
       die($res->getMessage());
     }
-    
+
     $clients_updated = 0;
     // Iterate through clients.
     while ($val = $res->fetchRow()) {
       $client_id = $val['id'];
-      
+
       // Get projects binds for client.
       $sql = "select cpb.project_id from tt_client_project_binds cpb
         left join tt_projects p on (p.id = cpb.project_id)
         where cpb.client_id = $client_id order by p.name";
-      
+
       $result = $mdb2->query($sql);
       if (is_a($result, 'PEAR_Error'))
         die($result->getMessage());
-      
+
       $project_arr = array();
       while ($value = $result->fetchRow()) {
         $project_arr[] = $value['project_id']; 
       }
       $comma_separated = implode(',', $project_arr); // This is a comma-separated list of associated project ids.
-      
+
       // Update the projects field.
       $sql = "update tt_clients set projects = ".$mdb2->quote($comma_separated)." where id = $client_id";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         die($affected->getMessage());
-      $clients_updated += $affected;   
+      $clients_updated += $affected;
     }
     print "Updated $clients_updated clients...<br>\n";
   }
-  
+
   // The update_custom_fields function updates option_id field field in tt_custom_field_log table.
   if ($_POST['update_custom_fields']) {
     $mdb2 = getConnection();
@@ -565,7 +564,7 @@ if ($_POST) {
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error'))
       die($affected->getMessage());
-    
+
     print "Updated $affected custom fields...<br>\n";
   }
 
@@ -576,19 +575,19 @@ if ($_POST) {
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error'))
       die($affected->getMessage());
-    
+
     print "Updated $affected teams...<br>\n";
   }
 
   if ($_POST["cleanup"]) {
-     
+
     $mdb2 = getConnection();
     $inactive_teams = ttTeamHelper::getInactiveTeams();
-    
+
     $count = count($inactive_teams);
     print "$count inactive teams found...<br>\n";
     for ($i = 0; $i < $count; $i++) {
-      print "  deleting team ".$inactive_teams[$i]."<br>\n";           
+      print "  deleting team ".$inactive_teams[$i]."<br>\n";
       $res = ttTeamHelper::delete($inactive_teams[$i]);
     }
 
@@ -596,21 +595,21 @@ if ($_POST) {
     setChange("OPTIMIZE TABLE tt_clients");
     setChange("OPTIMIZE TABLE tt_config");
     setChange("OPTIMIZE TABLE tt_custom_field_log");
-    setChange("OPTIMIZE TABLE tt_custom_field_options");   
+    setChange("OPTIMIZE TABLE tt_custom_field_options");
     setChange("OPTIMIZE TABLE tt_custom_fields"); 
     setChange("OPTIMIZE TABLE tt_expense_items");
     setChange("OPTIMIZE TABLE tt_fav_reports");
-    setChange("OPTIMIZE TABLE tt_invoices");    
+    setChange("OPTIMIZE TABLE tt_invoices");
     setChange("OPTIMIZE TABLE tt_log");
     setChange("OPTIMIZE TABLE tt_project_task_binds");
-    setChange("OPTIMIZE TABLE tt_projects");            
+    setChange("OPTIMIZE TABLE tt_projects");
     setChange("OPTIMIZE TABLE tt_tasks");
     setChange("OPTIMIZE TABLE tt_teams");
     setChange("OPTIMIZE TABLE tt_tmp_refs");
-    setChange("OPTIMIZE TABLE tt_user_project_binds");    
+    setChange("OPTIMIZE TABLE tt_user_project_binds");
     setChange("OPTIMIZE TABLE tt_users");
   }
-  
+
   print "done.<br>\n";
 }
 ?>