echo ">"; if ($startdate > 0) { echo ldate($CONFIG['dateformat_date'], $startdate); } echo "</td>"; echo "<td"; if ($duedate > 0 and $duedate <= $now and $task->completion < 100) { echo " class='urgent'"; } echo ">"; if ($duedate > 0) { echo ldate($CONFIG['dateformat_date'], $duedate); } echo "</td>"; } else { $billing = make_incident_billing_array($incidentid); echo "<td>" . format_date_friendly($startdate) . "</td>"; if ($enddate == '0') { echo "<td><script type='text/javascript'>\n//<![CDATA[\n"; echo "var act = new Activity();"; echo "act.id = {$task->id};"; echo "act.start = {$startdate}; "; echo "addActivity(act);"; echo "\n//]]>\n</script>"; echo "{$strNotCompleted}</td>"; $duration = $now - $startdate; //echo "<td id='duration{$task->id}'><em><div id='duration{$task->id}'>".format_seconds($duration)."</div></em></td>"; echo "<td id='duration{$task->id}'>" . format_seconds($duration) . "</td>"; } else { $duration = $enddate - $startdate; $a = $duration % $billing[-1]['customerperiod'];
/** * Function to make an array with the number of units at each billable multiplier, broken down by engineer * @author Paul Heaney * @param int $incidentid The inicident to create the billing breakdown for * @return array. Array of the billing for this incident broken down by enegineer * */ function get_incident_billable_breakdown_array($incidentid) { $billable = make_incident_billing_array($incidentid, FALSE); //echo "<pre>"; //print_r($billable); //echo "</pre>"; if (!empty($billable)) { foreach ($billable as $engineer) { if (is_array($engineer) and empty($engineer['refunds'])) { $engineerName = $engineer['owner']; foreach ($engineer['customerperiods'] as $period) { // $period is the start time $day = date('D', $period); $hour = date('H', $period); $dayNumber = date('d', $period); $month = date('n', $period); $year = date('Y', $period); // echo "DAY {$day} HOUR {$hour}"; $dayofweek = strtolower($day); if (is_day_bank_holiday($dayNumber, $month, $year)) { $dayofweek = "holiday"; } $multiplier = get_billable_multiplier($dayofweek, $hour, 1); //FIXME make this not hard coded $billing[$engineerName]['owner'] = $engineerName; $billing[$engineerName][$multiplier]['multiplier'] = $multiplier; if (empty($billing[$engineerName][$multiplier]['count'])) { $billing[$engineerName][$multiplier]['count'] = 0; } $billing[$engineerName][$multiplier]['count']++; } } } if (!empty($billable[-1]['refunds'])) { $billing['refunds'] = $billable[-1]['refunds']; } } return $billing; }
$sql = "SELECT i.* FROM `{$GLOBALS['dbIncidents']}` AS i, `{$GLOBALS['dbContacts']}` AS c WHERE c.id = i.contact AND c.siteid = {$objsite->site} "; if ($startdate != 0) { $sql .= "AND closed >= {$startdate} "; } if ($enddate != 0) { $sql .= "AND closed <= {$enddate} "; } $result = mysql_query($sql); if (mysql_error()) { trigger_error(mysql_error(), E_USER_WARNING); return FALSE; } $units = 0; if (mysql_num_rows($result) > 0) { while ($obj = mysql_fetch_object($result)) { $a = make_incident_billing_array($obj->id); if ($a[-1]['totalcustomerperiods'] > 0) { $str .= "<tr><td>{$obj->id}</td><td>{$obj->title}</td><td>{$a[-1]['totalcustomerperiods']}</td></tr>"; $used = true; } } } if ($used) { if ($output == 'html') { $datadisplayed = true; echo "<table align='center'>"; echo "<tr><th colspan='3'>" . site_name($objsite->site) . "</th></tr>"; echo "<tr><th>{$strIncidentID}</th><th>{$strTitle}</th><th>{$strBillingCustomerPeriod}</th></tr>"; echo $str; echo "</table>"; }