Exemplo n.º 1
0
 /**
  * Generates UNIX timestamp from YYYY-MM-DD formatted dates
  *
  * Value returned is always GMT
  *
  * @static
  * @param string $date
  * @return integer
  */
 function getTimestamp($date)
 {
     BURAK_Gantt::validateDate($date);
     list($y, $m, $d) = sscanf($date, "%4d-%2d-%2d");
     return gmmktime(0, 0, 0, $m, $d, $y);
 }
Exemplo n.º 2
0
 function get_gantt_chart($id, $cur_tab_id, $rel_tab_id, $actions = false)
 {
     require_once "BURAK_Gantt.class.php";
     $headers = array();
     $headers[0] = getTranslatedString('LBL_PROGRESS_CHART');
     $entries = array();
     global $adb, $tmp_dir, $default_charset;
     $record = $id;
     $g = new BURAK_Gantt();
     // set grid type
     $g->setGrid(1);
     // set Gantt colors
     $g->setColor("group", "000000");
     $g->setColor("progress", "660000");
     $related_projecttasks = $adb->pquery("SELECT pt.* FROM vtiger_projecttask AS pt \n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity AS crment ON pt.projecttaskid=crment.crmid \n\t\t\t\t\t\t\t\t\t\t\t\tWHERE projectid=? AND crment.deleted=0 AND pt.startdate IS NOT NULL AND pt.enddate IS NOT NULL", array($record)) or die("Please install the ProjectMilestone and ProjectTasks modules first.");
     while ($rec_related_projecttasks = $adb->fetchByAssoc($related_projecttasks)) {
         if ($rec_related_projecttasks['projecttaskprogress'] == "--none--") {
             $percentage = 0;
         } else {
             $percentage = str_replace("%", "", $rec_related_projecttasks['projecttaskprogress']);
         }
         $rec_related_projecttasks['projecttaskname'] = iconv($default_charset, "ISO-8859-2//TRANSLIT", $rec_related_projecttasks['projecttaskname']);
         $g->addTask($rec_related_projecttasks['projecttaskid'], $rec_related_projecttasks['startdate'], $rec_related_projecttasks['enddate'], $percentage, $rec_related_projecttasks['projecttaskname']);
     }
     $related_projectmilestones = $adb->pquery("SELECT pm.* FROM vtiger_projectmilestone AS pm \n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity AS crment on pm.projectmilestoneid=crment.crmid \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE projectid=? and crment.deleted=0", array($record)) or die("Please install the ProjectMilestone and ProjectTasks modules first.");
     while ($rec_related_projectmilestones = $adb->fetchByAssoc($related_projectmilestones)) {
         $rec_related_projectmilestones['projectmilestonename'] = iconv($default_charset, "ISO-8859-2//TRANSLIT", $rec_related_projectmilestones['projectmilestonename']);
         $g->addMilestone($rec_related_projectmilestones['projectmilestoneid'], $rec_related_projectmilestones['projectmilestonedate'], $rec_related_projectmilestones['projectmilestonename']);
     }
     $g->outputGantt($tmp_dir . "diagram_" . $record . ".jpg", "100");
     $origin = $tmp_dir . "diagram_" . $record . ".jpg";
     $destination = $tmp_dir . "pic_diagram_" . $record . ".jpg";
     $imagesize = getimagesize($origin);
     $actualWidth = $imagesize[0];
     $actualHeight = $imagesize[1];
     $size = 1000;
     if ($actualWidth > $size) {
         $width = $size;
         $height = $actualHeight * $size / $actualWidth;
         copy($origin, $destination);
         $id_origin = imagecreatefromjpeg($destination);
         $id_destination = imagecreate($width, $height);
         imagecopyresized($id_destination, $id_origin, 0, 0, 0, 0, $width, $height, $actualWidth, $actualHeight);
         imagejpeg($id_destination, $destination);
         imagedestroy($id_origin);
         imagedestroy($id_destination);
         $image = $destination;
     } else {
         $image = $origin;
     }
     $fullGanttChartImageUrl = $tmp_dir . "diagram_" . $record . ".jpg";
     $thumbGanttChartImageUrl = $image;
     $entries[0] = array("<a href='{$fullGanttChartImageUrl}' border='0' target='_blank'><img src='{$thumbGanttChartImageUrl}' border='0'></a>");
     return array('header' => $headers, 'entries' => $entries);
 }