// Note that billable property is not part of the label. Instead, we intend to
// identify such records with a different color in week view.
static function makeRecordLabel($record) {
- // TODO: debug this function.
global $user;
// Start with client.
if ($user->isPluginEnabled('cl'))
$label = $record['client'];
// Add project.
- $project = $record['project'] ? $record['project'] : '';
- if (!empty($label)) $label .= ' - ';
- $label .= $project;
+ if (!empty($label) && !empty($record['project'])) $label .= ' - ';
+ $label .= $record['project'];
// Add task.
- $task = $record['task'] ? $record['task'] : '';
- if (!empty($label)) $label .= ' - ';
- $label .= $task;
+ if (!empty($label) && !empty($record['task'])) $label .= ' - ';
+ $label .= $record['task'];
// Add custom field 1.
if ($user->isPluginEnabled('cf')) {
- if ($record['cf_1_value']) {
- if (!empty($label)) $label .= ' - ';
- $label .= $record['cf_1_value'];
- }
+ if (!empty($label) && !empty($record['cf_1_value'])) $label .= ' - ';
+ $label .= $record['cf_1_value'];
}
return $label;
static function getDayHeadersForWeek($start_date) {
$dayHeaders = array();
$objDate = new DateAndTime(DB_DATEFORMAT, $start_date);
- $dayHeaders['day_header_0'] = (string)$objDate->getDate(); // It returns an int on first call. Why?
+ $dayHeaders['day_header_0'] = (string) $objDate->getDate(); // It returns an int on first call.
+ if (strlen($dayHeaders['day_header_0']) == 1) // Which is an implementation detail of DateAndTime class.
+ $dayHeaders['day_header_0'] = '0'.$dayHeaders['day_header_0']; // Add a 0 for single digit day.
$objDate->incDay();
- $dayHeaders['day_header_1'] = $objDate->getDate();
+ $dayHeaders['day_header_1'] = $objDate->getDate(); // After incDay it returns a string with leading 0, when necessary.
$objDate->incDay();
$dayHeaders['day_header_2'] = $objDate->getDate();
$objDate->incDay();