class views_job_summary
{
public $id;
public $style;
public $style_table_width;
public $style_left;
public $results;
public $pages;
public function __construct($context)
{
$this->id = $context['id'];
$this->style = $context['style'];
}
public function set()
{
global $database;
$total = common_schedules::get_labour_variance_reports_count();
$this->pages = new paginator('schedules_production_jobs');
$this->pages ->items_total = $total;
$this->pages ->mid_range = 9;
$this->pages ->paginate();
$results = common_schedules::get_labour_variance_reports($this->pages ->limit);
$this->results =& $results;
return $this;
}
function showPagination(){
echo $this->pages->display_pages();
//echo "Page ".$this->pages->current_page." of ". $this->pages->num_pages;
return $this;
}
public function production_job_summary()
{
?>
Job # |
Job Name |
Site Location |
Labour |
Overall Labour |
Materials |
status |
Date Created |
//bug::bug_array('',$this->results);
if(is_array($this->results))
{
foreach($this->results as $key => $val)
{
$job_details = common_jobs::get_details($key);
$company_name = $job_details['job_name'];
$date_created = $job_details['date_created'];
$site_address_nice = $job_details['site_address_nice'];
$status = $job_details['status_nice'];
$quote_id = common_quotes::get_quote_id($key);
$completed_labour = common_schedules::get_completed_job($key,$quote_id);
$material_variance = common_schedules::get_total_material_variance($quote_id);
$material_total_quantity = $material_variance[0];
$material_total_actual = $material_variance[1];
$mat_var = $material_total_quantity - $material_total_actual;
$budget_labour = common_quotes_productiontime::get_labour_budget($quote_id);
$percentage_mat = (!empty($material_total_quantity)) ? $material_total_actual/$material_total_quantity *100 : 0;
$percentage_overall = $percentage_mat * .5 + $percentage_labour * .5;
//$job_number = common_jobs::get_job_number($quote_id);
$negative_material_flag=0;
$mat_variance_per_item=common_schedules::get_total_material_variance_per_item($quote_id);
if(is_array($mat_variance_per_item))
{
foreach($mat_variance_per_item as $matkey=>$matval)
{
//echo $matval.'
';
if($matval < 0)
{
$negative_material_flag++;
}
}
}
$actual_labour_total=common_job_trackings::get_total_time_per_job_overall( $key);
//get departments from quotes_production_time table
$dept_array = common_quotes_productiontime::get_department_array($quote_id);
$negative_labour_flag=0;
$labour_per_dept = common_schedules::get_indiv_labour_variance($quote_id,$key,$dept_array);
if(is_array($labour_per_dept))
{
foreach($labour_per_dept as $lb => $lbval)
{
//echo $lbval.'
';
if($lbval < 0)
{
$negative_labour_flag++;
}
$actual_sum_labour += $lbval;
}
}
$overall_variance = $budget_labour - $actual_labour_total;
$percentage_labour = (!empty($budget_labour)) ? ($actual_labour_total / $budget_labour) * 100 : 0;
//$overall = $mat_var + $val;
$overll = $val;
if($completed_labour > 0 )
{
if($val == 0 )
{
$labour_rating ='green-rate';
}
elseif($val < 0)
{
$labour_rating ='red-rate';
}
elseif($negative_labour_flag > 0)
{
$labour_rating = 'red-rate';
}
else
{
$labour_rating = 'blue-rate';
}
if($mat_var == 0 )
{
$material_rating ='green-rate';
}
elseif($mat_var < 0)
{
$material_rating ='red-rate';
}
elseif($negative_material_flag > 0)
{
$material_rating ='red-rate';
}
else
{
$material_rating = 'blue-rate';
}
if($overall == 0 )
{
$overall_rating ='green-rate';
}
elseif($overall < 0)
{
$overall_rating ='red-rate';
}
else
{
$overall_rating = 'blue-rate';
}
}
else
{
if(!$negative_labour_flag)
{
if($val < 0 )
{
$labour_rating ='red-rate';
}
else
{
if($percentage_labour > 80)
{
$labour_rating = 'orange-rate';
}
else
{
$labour_rating = 'green-rate';
}
}
}
else
{
$labour_rating ='red-rate';
}
if($mat_var < 0 )
{
$material_rating ='red-rate';
}
else
{
if($percentage_mat > 80)
{
$material_rating = 'orange-rate';
}
else
{
$material_rating = 'green-rate';
}
}
if($overall_variance == 0 )
{
$overall_rating ='green-rate';
}
elseif($overall_variance < 0)
{
$overall_rating ='red-rate';
}
else
{
if($percentage_labour > 80)
{
$overall_rating = 'orange-rate';
}
else
{
$overall_rating = 'green-rate';
}
}
}
?>
|
|
|
|
|
|
|
|
$actual_sum_labour =0;
}
?>
} ?>
return $this;
}
public function notes()
{
extract($this->results);
if(!empty($notes))
{
?>
Notes