- $decimal_mark = $fields['decimal_mark'];
- if ($decimal_mark !== null) {
- $decimal_mark_f = ', decimal_mark';
- $decimal_mark_v = ', ' . $mdb2->quote($decimal_mark);
- } else {
- $decimal_mark_f = '';
- $decimal_mark_v = '';
- }
-
- $date_format = $fields['date_format'];
- if ($date_format !== null) {
- $date_format_f = ', date_format';
- $date_format_v = ', ' . $mdb2->quote($date_format);
- } elseif (defined('DATE_FORMAT_DEFAULT')) {
- $date_format_f = ', date_format';
- $date_format_v = ', ' . $mdb2->quote(DATE_FORMAT_DEFAULT);
- } else {
- $date_format_f = '';
- $date_format_v = '';
- }
-
- $time_format = $fields['time_format'];
- if ($time_format !== null) {
- $time_format_f = ', time_format';
- $time_format_v = ', ' . $mdb2->quote($time_format);
- } elseif (defined('TIME_FORMAT_DEFAULT')) {
- $time_format_f = ', time_format';
- $time_format_v = ', ' . $mdb2->quote(TIME_FORMAT_DEFAULT);
- } else {
- $time_format_f = '';
- $time_format_v = '';
- }
-
- $week_start = $fields['week_start'];
- if ($week_start !== null) {
- $week_start_f = ', week_start';
- $week_start_v = ', ' . (int)$week_start;
- } elseif (defined('WEEK_START_DEFAULT')) {
- $week_start_f = ', week_start';
- $week_start_v = ', ' . (int)WEEK_START_DEFAULT;
- } else {
- $week_start_f = '';
- $week_start_v = '';
- }
-
- $plugins = $fields['plugins'];
- if ($plugins !== null) {
- $plugins_f = ', plugins';
- $plugins_v = ', ' . $mdb2->quote($plugins);
- } else {
- $plugins_f = '';
- $plugins_v = '';
- }
-
- $tracking_mode = $fields['tracking_mode'];
- if ($tracking_mode !== null) {
- $tracking_mode_f = ', tracking_mode';
- $tracking_mode_v = ', ' . (int)$tracking_mode;
- } else {
- $tracking_mode_f = '';
- $tracking_mode_v = '';
- }
-
- $record_type = $fields['record_type'];
- if ($record_type !== null) {
- $record_type_f = ', record_type';
- $record_type_v = ', ' . (int)$record_type;
- } else {
- $record_type_f = '';
- $record_type_v = '';
- }
-
- $uncompleted_indicators = $fields['uncompleted_entries'];
- if ($uncompleted_indicators !== null) {
- $uncompleted_indicators_f = ', uncompleted_indicators';
- $uncompleted_indicators_v = ', ' . (int)$uncompleted_indicators;
- } else {
- $uncompleted_indicators_f = '';
- $uncompleted_indicators_v = '';
- }
-
- $workday_hours = $fields['workday_hours'];
- if ($workday_hours !== null) {
- $workday_hours_f = ', workday_hours';
- $workday_hours_v = ', ' . (int)$workday_hours;
- } else {
- $workday_hours_f = '';
- $workday_hours_v = '';
- }
-
- $sql = "insert into tt_teams (name, address, currency $lockspec_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $record_type_f $uncompleted_indicators_f $workday_hours_f)
- values(".$mdb2->quote(trim($fields['name'])).
- ", ".$mdb2->quote(trim($fields['address'])).
- ", ".$mdb2->quote(trim($fields['currency']))." $lockspec_v, ".$mdb2->quote($lang).
- "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $record_type_v $uncompleted_indicators_v $workday_hours_v)";
+ if ($fields['date_format'] || defined('DATE_FORMAT_DEFAULT')) {
+ $date_format = $fields['date_format'] ? $fields['date_format'] : DATE_FORMAT_DEFAULT;
+ $columns .= ', date_format';
+ $values .= ', '.$mdb2->quote($date_format);
+ }
+
+ if ($fields['time_format'] || defined('TIME_FORMAT_DEFAULT')) {
+ $time_format = $fields['time_format'] ? $fields['time_format'] : TIME_FORMAT_DEFAULT;
+ $columns .= ', time_format';
+ $values .= ', '.$mdb2->quote($time_format);
+ }
+
+ if ($fields['week_start'] || defined('WEEK_START_DEFAULT')) {
+ $week_start = $fields['week_start'] ? $fields['week_start'] : WEEK_START_DEFAULT;
+ $columns .= ', week_start';
+ $values .= ', '.(int)$week_start;
+ }
+
+ if ($fields['tracking_mode']) {
+ $columns .= ', tracking_mode';
+ $values .= ', '.(int)$fields['tracking_mode'];
+ }
+
+ if ($fields['project_required']) {
+ $columns .= ', project_required';
+ $values .= ', '.(int)$fields['project_required'];
+ }
+
+ if ($fields['task_required']) {
+ $columns .= ', task_required';
+ $values .= ', '.(int)$fields['task_required'];
+ }
+
+ if ($fields['record_type']) {
+ $columns .= ', record_type';
+ $values .= ', '.(int)$fields['record_type'];
+ }
+
+ if ($fields['bcc_email']) {
+ $columns .= ', bcc_email';
+ $values .= ', '.$mdb2->quote($fields['bcc_email']);
+ }
+
+ if ($fields['plugins']) {
+ $columns .= ', plugins';
+ $values .= ', '.$mdb2->quote($fields['plugins']);
+ }
+
+ if ($fields['lock_spec']) {
+ $columns .= ', lock_spec';
+ $values .= ', '.$mdb2->quote($fields['lock_spec']);
+ }
+
+ if ($fields['workday_minutes']) {
+ $columns .= ', workday_minutes';
+ $values .= ', '.(int)$fields['workday_minutes'];
+ }
+
+ if ($fields['config']) {
+ $columns .= ', config';
+ $values .= ', '.$mdb2->quote($fields['config']);
+ }
+
+ $sql = "insert into tt_teams ($columns) values($values)";