|
Hello I have seen that some of us, in addition to having tasks in a certain order requires a graphic representation and that there are doubts in the example / tutorial that is offered for the JSGantt Javascript function.
I have expanded and published the example to see if it can help any of you. Create GANTT.
<?php
global $conn;
$keyMaster=$data['project_id'];
$trunk1="<link rel=\"stylesheet\" type=\"text/css\" href=\"jsgantt/jsgantt.css\" />
<script language=\"javascript\" src=\"jsgantt/jsgantt.js\"></script>
<div style=\"position:relative\" class=\"gantt\" id=\"GanttChartDIV\"></div>
<script>
var g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'week');
if (g.getDivId() != null) {
g.setCaptionType('Complete'); // Set to Show Caption (None,Caption,Resource,Duration,Complete)
g.setQuarterColWidth(36);
g.setDateTaskDisplayFormat('day dd month yyyy'); // Shown in tool tip box
g.setDayMajorDateDisplayFormat('mon yyyy - Week ww') // Set format to display dates in the \"Major\" header of the \"Day\" view
g.setWeekMinorDateDisplayFormat('dd mon') // Set format to display dates in the \"Minor\" header of the \"Week\" view
g.setShowTaskInfoLink(1); // Show link in tool tip (0/1)
g.setShowEndWeekDate(0); // Show/Hide the date for the last day of the week in header for daily view (1/0)
g.setUseSingleCell(10000); // Set the threshold at which we will only use one cell per table row (0 disables). Helps with rendering performance for large charts.
g.setFormatArr('Day', 'Week', 'Month', 'Quarter'); // Even with setUseSingleCell using Hour format on such a large chart can cause issues in some browsers
// Language
g.addLang('es',{'january': 'Enero',
'february': 'Febrero',
'march': 'Marzo',
'april': 'Abril',
'maylong': 'Mayo',
'june': 'Junio',
'july': 'Julio',
'august': 'Agosto',
'september': 'Septiembre',
'october':'Octubre',
'november':'Noviembre',
'december':'Diciembre',
'jan':'Ene',
'feb':'Feb',
'mar':'Mar',
'apr':'Abr',
'may':'May',
'jun':'Jun',
'jul':'Jul',
'aug':'Ago',
'sep':'Sep',
'oct':'Oct',
'nov':'Nov',
'dec':'Dic',
'sunday':'Domingo',
'monday':'Lunes',
'tuesday':'Martes',
'wednesday':'Miércoles',
'thursday':'Jueves',
'friday':'Viernes',
'saturday':'Sábado',
'sun':' Dom',
'mon':' Lun',
'tue':' Mar',
'wed':' Mie',
'thu':' Jue',
'fri':' Vie',
'sat':' Sab',
'resource':'Recurso',
'duration':'Duración',
'comp':'% Completado',
'completion':'Terminado',
'startdate':'Inicio',
'enddate':'Fin',
'moreinfo':'+información',
'notes':'Notas',
'format':'Formato',
'hour':'Hora',
'day':'Dia',
'week':'Semana',
'month':'Mes',
'quarter':'Trimestre',
'hours':'Horas',
'days':'Días',
'weeks':'Semanas',
'months':'Meses',
'quarters':'Trimestres',
'hr':'Hr',
'dy':'D',
'wk':'Sem',
'mth':'Mes',
'qtr':'Trim',
'hrs':'Hrs',
'dys':'Dias',
'wks':'Sems',
'mths':'Meses',
'qtrs':'Trims'});
g.setLang('es');
// Parameters (pID, pName, pStart, pEnd, pStyle, pLink (unused) pMile, pRes,
";
$trunk2='';
// Read Task the Project
$sql="SELECT O.task_level, O.task_master,O.task_orden,t.task_id,t.task_name,
if (t.task_parent=t.task_id,0 ,t.task_parent) task_parent,
t.task_milestone,
t.task_project,t.task_owner,
DATE_FORMAT(t.task_start_date,'%Y-%m-%d') task_start_date,
t.task_duration,t.task_duration_type,t.task_hours_worked,
DATE_FORMAT(t.task_end_date,'%Y-%m-%d') task_end_date,
t.task_status,t.task_priority,t.task_percent_complete,t.task_description,t.task_target_budget,
t.task_related_url,t.task_creator,t.task_order,t.task_client_publish,t.task_dynamic,t.task_access,t.task_notify,
t.task_departments,t.task_contacts,t.task_custom,t.task_type,t.task_updator,t.task_created,t.task_updated,t.task_dep_reset_dates,
t.task_represents_project,t.task_allow_other_user_tasklogs
FROM tasks AS t
INNER JOIN task_order AS O ON t.task_id = O.task_id and t.task_project = $keyMaster
ORDER BY O.task_orden";
$resql = db_query($sql,$conn);
while ($row = db_fetch_array($resql)) {
$task_id = $row['task_id'];
$task_name = $row['task_name'];
$task_start_date = $row['task_start_date'];
$task_end_date = $row['task_end_date'];
$task_color = 'gtaskblue';
if ($row['task_master'] == 1){
$task_color = 'ggroupblack';
}
$task_link = $row['task_related_url'];
$task_mile = $row['task_milestone'];
$task_resource = '';
$task_completion= $row['task_percent_complete'];
$task_group = $row['task_master'];
$task_parent = $row['task_parent'];
$task_open = '1';
$task_depende = '';
$task_caption = '';
$trunk2.="g.AddTaskItem(new JSGantt.TaskItem(
$task_id,'$task_name','$task_start_date','$task_end_date','$task_color','$task_link',$task_mile, '$task_resource',$task_completion,$task_group,$task_parent,$task_open,'$task_depende','$task_caption','',g));";;
}
$trunk3="
g.Draw();
g.DrawDependencies();
}
else
{
alert(\"not defined\");
}
</script>";
$value=$trunk1.$trunk2.$trunk3;
?>
It is published in BLOG For any questions, please, communicate it to me through [email="fernandohumanes@gmail.com"]email[/email]. Regards,
fernando
|