Beispiel #1
0
 /**
  * Calculates the the date for each of the days between start- and enddate.
  * @param string $strstart Startdate in the format yyyymmdd
  * @param string $strend Enddate in the format yyyymmdd
  * @return array Array containing arrays like "date"=>date
  */
 function daysBetween($strstart, $strend)
 {
     // Initialize the weekdata array
     $daydata = array();
     // First fill the weeks and start/end dates..
     $startstamp = dateUtil::str2stamp($strstart);
     $endstamp = dateUtil::str2stamp($strend);
     // Calculate the number of days between the selected start and end date
     $nrofdays = dateUtil::date_diff($strstart, $strend);
     // Loop through the days, starting at the day selected as "from"
     for ($i = 0; $i <= $nrofdays; $i++) {
         // Calculate the current day depending on the startdate and iterator
         $curstamp = $startstamp + ONEDAY * $i;
         $key = date("Ymd", $curstamp);
         $daydata[$key]["date"] = $key;
     }
     // Return the array containing the dayid, and date for each day within the given from and to dates
     return $daydata;
 }
Beispiel #2
0
include_once "achievotools.inc";
atksession();
atksecure();
global $g_securityManager;
if ($g_securityManager->allowed("project.project", "any_project")) {
    $coordinator = $_REQUEST["coordinator"];
} else {
    $user = getUser();
    $coordinator = $user["id"];
}
function dashDate($undasheddate)
{
    return substr($undasheddate, 0, 4) . "-" . substr($undasheddate, 4, 2) . "-" . substr($undasheddate, 6, 2);
}
$from = dashDate(dateUtil::startOfWeek($_REQUEST["from"]));
$to = dashDate(dateUtil::endOfWeek($_REQUEST["to"]));
$plannedbooked = $_REQUEST["plannedbooked"];
if ($plannedbooked != "planned" && $plannedbooked != "booked") {
    $plannedbooked = "planned";
}
// safeguard
$db =& atkGetDb();
$projects = $db->getrows("SELECT\n                              project.id,\n                              project.name,\n                              MIN(phase.startdate) as startdate,\n                              MAX(phase.enddate) as enddate,\n                              SUM(phase.current_planning) as planned\n                            FROM\n                              project,\n                              phase\n                            WHERE\n                              phase.status='active'\n                              AND project.status='active'\n                              AND phase.projectid = project.id\n                              AND (phase.enddate IS NULL OR phase.enddate>='{$from}')\n                              AND (phase.startdate <= '{$to}')\n                              " . ($coordinator != "" ? "AND project.coordinator={$coordinator}" : "") . "\n                            GROUP BY\n                              project.id,\n                              project.name");
//make an gant array, this array contains important information about the phases
$gant = array();
for ($i = 0; $i < count($projects); $i++) {
    $gant[$projects[$i]['id']] = $projects[$i];
    $gant[$projects[$i]['id']]['booked'] = getBooked($projects[$i]['id']);
}
function getBooked($projectid)
{