
<?php
$today = date("Y-m-d");



$table_name = $_SESSION['db_prefix']."_mworks_jobs";
$job_query = "SELECT job_card_no, del_date, end_date, cust_id  FROM $table_name WHERE compiled = 'yes' AND completed IS NULL ";
$job_result = mySQL_query($job_query);
$job_num = mysql_num_rows($job_result);

$data = array();

$i=0;
while ($i<$job_num) {
$job_card_no = mysql_result($job_result, $i, "job_card_no");
$start_date = mysql_result($job_result, $i, "del_date");
$end_date = mysql_result($job_result, $i, "end_date");
$chart_end_date = strtotime(date("Y-m-d", strtotime($end_date)) . " +1 day");
$chart_end_date = date("Y-m-d", $chart_end_date);
if ($end_date=='') {
	  $end_date = $start_date;
}

$table_name = $_SESSION['db_prefix']."_compiled_jobs";
$project_query = "SELECT project FROM $table_name WHERE job_card_no = '".$job_card_no."'  ";
$project_result = mySQL_query($project_query);
$project = mysql_result($project_result, 0, "project");


$cust_id = mysql_result($job_result, $i, "cust_id");
$table_name2 = $_SESSION['db_prefix']."_customer";
$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
$customer_result = mySQL_query($customer_query);
$customer_num = mysql_num_rows($customer_result);	
$a1 = mysql_result($customer_result, 0, "account_type");
if ($a1=="corporate") { 
		$cust_name = mysql_result($customer_result, 0, "comp_name"); 
} 
else {
		$cust_name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
}



$color_code = 'FFF';



$labelTT = "'<font color=black><table border=0><tr><td width=75 >Job card no:</td><td width=175>".$job_card_no."</td></tr><tr><td width=75 >Project:</td><td width=175>".$project."</td></tr><tr><td width=75 >Customer:</td><td width=175>".$cust_name."</td></tr><tr><td width=75 >Start date:</td><td width=175>".date("d-m-Y", strtotime($start_date))."</td></tr><tr><td width=75 >End date:</td><td width=175>".date("d-m-Y", strtotime($end_date))."</td></tr></table></font>'";

$label = '<a href="edit_planner.php?job_card_no='.$job_card_no.'" onMouseover="ddrivetip('.$labelTT.', 250)"; onMouseout="hideddrivetip()">'.$job_card_no.' '.$project.'</a> ';

$data[] = array(
  'label' => $label ,
  'start' => $start_date , 
  'end'   => $chart_end_date,
  'class' => $color_code
);

$i++;
}


?>