<?php

/* $Id: SelectCustomer.php 7133 2015-02-07 03:23:51Z daintree $*/

include('includes/session.inc');
$Title = _('HRMS');
include('includes/header.inc');


include('includes/SQL_CommonFunctions.inc');
echo '<link href="' . $RootPath . '/css/evergreen2'.'/default.css" rel="stylesheet" type="text/css" media="screen"/>';


//echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/maintenance.png"> </p>';
      
	echo '<div class="col-sm-9">';
		
    include('xcrud/xcrud.php');
    $xcrud = Xcrud::get_instance();
	$xcrud->table('aflrostering');
	
	$xcrud->order_by('aflrosterid','desc');
	
//second level table configurations
	$rostering_timesheet = $xcrud->nested_table('rostering_timesheet','aflrosterid','aflrosteringtimesheet','aflrosterid'); 
	
	 //$rostering_timesheet->columns('employeeid,mon_shift,mon_hrs,tues_shift,tues_hrs,wed_shift,wed_hrs,thurs_shift,thurs_hrs,fri_shift,fri_hrs,sat_shift,sat_hrs,sun_shift,sun_hrs,total_hrs');
	 
   //$rostering_timesheet->fields('employeeid,mon_shift,mon_hrs,tues_shift,tues_hrs,wed_shift,wed_hrs,thurs_shift,thurs_hrs,fri_shift,fri_hrs,sat_shift,sat_hrs,sun_shift,sun_hrs,total_hrs');
	
	  //employee id and name
	  
	


	$rostering_timesheet->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid','certifications'),array('department' => 'GF Aviation West'));

	
	$rostering_timesheet->sum('mon_total,tues_total,wed_total,thurs_total,fri_total,sat_total,sun_total,mon2_total,total_hrs,normal_hours,time_half_hours,double_hours');
	$rostering_timesheet->disabled('rosterid,mon_hrs,mon_hrs2,mon_total,tues_hrs,tues_hrs2,tues_total,wed_hrs,wed_hrs2,wed_total,thurs_hrs,thurs_hrs2,thurs_total,fri_hrs,fri_hrs2,fri_total,sat_hrs,sat_hrs2,sat_total,sun_hrs,sun_hrs2,sun_total,mon_hrs_2,mon_hrs_2_2,mon2_total,total_hrs,normal_hours,time_half_hours,double_hours,mon_date,tues_date,wed_date,thurs_date,fri_date,sat_date,sun_date,mon2_date');
	//$rostering_timesheet->disabled('m_hrs');
	

	$rostering_timesheet->label('employeeid','Employees');
	$rostering_timesheet->label('debtorno','Customer');
	$rostering_timesheet->column_name('debtorno','Customer');
	$rostering_timesheet->column_name('total_hrs','Total');
	$rostering_timesheet->column_name('mon_hrs,tues_hrs,wed_hrs,thurs_hrs,fri_hrs,sat_hrs,sun_hrs,mon_hrs_2,mon_hrs2,tues_hrs2,wed_hrs2,thurs_hrs2,fri_hrs2,sat_hrs2,sun_hrs2,mon_hrs_2_2','');
		$rostering_timesheet->column_width('debtorno','120px'); 
		$rostering_timesheet->column_width('location','150px'); 
	$rostering_timesheet->column_width('employeeid','500px'); 
//$rostering_timesheet->column_width('mon_hrs,tues_hrs,wed_hrs,thurs_hrs,fri_hrs,sat_hrs,sun_hrs,mon_hrs_2,mon_hrs2,tues_hrs2,wed_hrs2,thurs_hrs2,fri_hrs2,sat_hrs2,sun_hrs2,mon_hrs_2_2','5px');
	//$rostering_timesheet->column_width('mon_shift,tues_shift,wed_shift,thurs_shift,fri_shift,sat_shift,sun_shift,mon_shift_2','95px');
	//$rostering_timesheet->column_width('total_hrs','20px');
	//$rostering_timesheet->fields('mon_hrs,mon_total,tues_hrs,tues_total,wed_hrs,wed_total,thurs_hrs,thurs_total,fri_hrs,fri_total,sat_hrs,sat_total,sun_hrs,sun_total,mon_hrs_2,mon2_total,mon_hrs2,tues_hrs2,wed_hrs2,thurs_hrs2,fri_hrs2,sat_hrs2,sun_hrs2,mon_hrs_2_2', true);
	//$rostering_timesheet->validation_required('employeeid');
	
	//check whether total hours doesnt exceel employees max hours allowed to work. checking with employeemaster database.

	
	//grid coloring based on shift table
	
	$rostering_timesheet->highlight('montime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('montime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('montime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('montime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('montime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('montime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('montime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('montime_in1','>=','15:00:00','#FFFF33');


		$rostering_timesheet->highlight('tuestime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('tuestime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('tuestime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('tuestime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('tuestime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('tuestime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('tuestime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('tuestime_in1','>=','15:00:00','#FFFF33');


	$rostering_timesheet->highlight('wedtime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('wedtime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('wedtime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('wedtime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('wedtime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('wedtime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('wedtime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('wedtime_in1','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('thurstime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('thurstime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('thurstime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('thurstime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('thurstime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('thurstime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('thurstime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('thurstime_in1','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('fritime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('fritime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('fritime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('fritime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('fritime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('fritime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('fritime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('fritime_in1','>=','15:00:00','#FFFF33');
	$rostering_timesheet->highlight('sattime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('sattime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('sattime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('sattime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('sattime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('sattime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('sattime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('sattime_in1','>=','15:00:00','#FFFF33');


	$rostering_timesheet->highlight('sunttime_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('sunttime_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('sunttime_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('sunttime_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('suntime_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('suntime_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('suntime_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('suntime_in1','>=','15:00:00','#FFFF33');


	$rostering_timesheet->highlight('mon2time_in','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('mon2time_in','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('mon2time_in','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('mon2time_in','>=','15:00:00','#FFFF33');

	$rostering_timesheet->highlight('mon2time_in1','>=','00:00:00','white');
	
	$rostering_timesheet->highlight('mon2time_in1','>=','07:00:00','#00d8ff');

$rostering_timesheet->highlight('mon2time_in1','>=','12:00:00','#28B463');

$rostering_timesheet->highlight('mon2time_in1','>=','15:00:00','#FFFF33');



$rostering_timesheet->before_insert('calculate_totalhoursperweek','functionsairportrostering.php');
$rostering_timesheet->before_update('calculate_totalhoursperweek','functionsairportrostering.php');

//$rostering_timesheet->field_callback('total_hrs','validate_maxhours');

//$rostering_timesheet->before_insert('validate_maxhours');
//$rostering_timesheet->before_update('validate_maxhours');

	//$rostering_timesheet->table_name('Employee Schedulling');
	
	//calculate total  hours per per each day
	
   
   
	$rostering_timesheet->table_name('Employee scheduling');
	

	
	
		$rostering_timesheet->unset_print();
        $rostering_timesheet->unset_csv();


	//$rostering_timesheet->highlight('mon_shift','=','{mon_shift}','{mon_color}');
	
	//1st level main table
	


	
	$xcrud->relation('client','debtorsmaster','debtorno','name',array('airport' => 1));
	
  $xcrud->relation('patrol_location','aflpatrollocations','aflid','guard_location',array('department' => 5),'','','','','debtorno','client');       
 	// $xcrud->relation('account_number','aflpatrollocations','aflid','account_number','','','','','','aflid','patrol_location');
	$xcrud->table_name('Nadi Airports Operations Rostering Management','Employee scheduling','icon-leaf');
	//$xcrud->disabled('department');
			

$xcrud->change_type('roster_group','select','None','None,Alpha,Bravo,Charlie,Delta,All Airport Staffs');
    $xcrud->change_type('status','select','pending','pending,approved,Locked');
    
	

	
	$rostering_timesheet->benchmark(true);
	
	//validate max hours for employees
	
//$rostering_timesheet->after_insert('after');
//$rostering_timesheet->after_update('after');
	
	//$xcrud->highlight('total_hrs','=',48,'#99FF66');
	//$rostering_timesheetcrud->highlight('total_hrs','>',48,'#F77F8A');
	//$xcrud->highlight('total_hrs','<',48,'#e6fff2');
	//$rostering_timesheet->highlight_row('total_hrs','=',48,'yellow');
	
	$xcrud->disabled('last_modified_by,lastupdate');
    //$xcrud->before_insert('displaydepartment','functionsairportrostering.php');
	//$xcrud->before_update('displaydepartment','functionsairportrostering.php');
	
    $xcrud->show_primary_ai_column(true);
    $xcrud->column_pattern('aflrosterid', '<a href="#" class="xcrud-action" data-task="edit" data-primary="{aflrosterid}">{value}</a>');
	//$xcrud->load_view('create','rostering.php'); 
    //$xcrud->load_view('edit','rostering.php');
	//$xcrud->load_view('view','rostering.php');

	$xcrud->unset_print();
$xcrud->unset_csv();
 $rostering_timesheet->load_view('list','rosteringaviationwestlist.php');
$rostering_timesheet->load_view('edit','rosteringaviationwestedit.php');
$rostering_timesheet->load_view('create','rosteringaviationwestedit.php');
$rostering_timesheet->load_view('view','rosteringaviationwestedit.php');
$userid = $_SESSION['UserID'];
	$xcrud->pass_var('last_modified_by',$userid );
$rostering_timesheet->duplicate_button();

$timenow = date('Y-m-d H:i:s');

	$xcrud->pass_var('lastupdate',$timenow);
	echo $xcrud->render();
	

	

echo '</div>';
echo '</div>';

include('includes/footer.inc'); 

?>

