<?php
/* $Id: index.php 6941 2014-10-26 23:18:08Z daintree $*/
error_reporting(E_ALL & ~E_NOTICE);
$PageSecurity=0;

include('includes/session.inc');
$Title=_('ERP Home');
include('includes/newheader.php');

?>

		

		

   
  
 									
									<?php
			include('xcrud/xcrud.php');
	
	
    $xcrud = Xcrud::get_instance();
    $xcrud->table('guardforceclient');
	$xcrud->table_name('Client Patrol Location & General Admin - Enter your respective location and start!');

 $xcrud->default_tab('Patrol Location Profile');
	Xcrud_config::$editor_url = dirname($_SERVER["SCRIPT_NAME"]).'/editors/ckeditor/ckeditor.js'; 
    //$xcrud->change_type('contract','select','1 year', '1 year,2 years,3 years,4 Years, 5 Years');
	//$xcrud->change_type('agreementfile', 'file', '', array('not_rename'=>true));

	$xcrud->column_name('debtorno','Customer');
	$xcrud->label('debtorno','Customer');
	$xcrud->column_name('patrollocation','Patrol Location/Post');
	$xcrud->label('patrollocation','Patrol Location/Post');
	//$xcrud->column_width('client_code','150px');
	//$xcrud->column_width('remarks','200px');
	//hiding fullnameclient data as this is field is used behind the scene and used in rostering and timesheet
	
	//$xcrud->columns('customername',true);
	//$xcrud->fields('customername',true);


$userid = $_SESSION['UserID'];


	$xcrud->relation('portforlio_manager','employeemaster','employeeid',array('first_name','last_name'));
$xcrud->relation('supervisor','employeemaster','employeeid',array('first_name','last_name'));
$xcrud->relation('debtorno','debtorsmaster','debtorno','name');
$xcrud->relation('sectors','sectors','id','name');
$xcrud->change_type('location_type','select','8 hr contract','8 hr contract,9 hr contract');
//$xcrud->fields_inline('location_type');
$xcrud->relation('department','department','departmentid','departmentname','departmentid = 1 OR departmentid = 2 OR departmentid = 3 OR departmentid = 4 OR departmentid = 5');

$xcrud->order_by('clientid','desc');
$xcrud->show_primary_ai_column(true);
 $xcrud->column_pattern('clientid', '<a href="#" class="xcrud-action" data-task="edit" data-primary="{clientid}">{value}</a>');
	//$xcrud->relation('sectors','sectors','id','name');

	//meaning of debtorno in below is that we need to get account number based on which debtor is selected above. The second last option takens into consideration customer name and select those customers by checking which option the user choice for client in above. This is the last option.
	
	//$xcrud->relation('account_number','debtoraccount','account_number','account_number','','','','','','debtorno','debtorno');
	
		//$xcrud->disabled('department,account_number,sectors');
		
	$timenow = date('Y-m-d H:i:s');
$log = "Entered by: ".$userid." Date : ".$timenow;
$xcrud->pass_default('log',$log);
$xcrud->pass_var('log',$log );
	//$xcrud->before_update('update_log');
	$xcrud->disabled('log');
   //$xcrud->change_type('clientname','select','',$name);
   //$xcrud->default_tab(‘Order info’);
   	$xcrud->before_update('customername','functionsguardforceclient.php');
	$xcrud->before_update('customername','functionsguardforceclient.php');
//		
		//$xcrud->order_by('clientid','desc');


//second level table configurations
	$allocated_staffs = $xcrud->nested_table('allocated staffs','clientid','allocated_guards','clientid'); 

    $allocated_staffs->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid'));
   //$allocated_staffs->before_update('employeename','functionsguardforceclient.php');
	//$allocated_staffs->before_insert('employeename','functionsguardforceclient.php');
//		
    $allocated_staffs->disabled('clientid');
$allocated_staffs->columns('employees',true);
	$allocated_staffs->fields('employees',true);

//second level second table configurations
	$approved_staffs = $xcrud->nested_table('approved_staffs','clientid','approved_guards','clientid'); 

    $approved_staffs->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid'));
   //$approved_staffs->before_update('employeename','functionsguardforceclient.php');
	//$approved_staffs->before_insert('employeename','functionsguardforceclient.php');
//		
    $approved_staffs->disabled('clientid');
$allocated_staffs->columns('employees',true);
	$allocated_staffs->fields('employees',true);
//$xcrud->change_type('portforlio_manager','select','Select Manager','Select Manager, Tito Elo, Timoci Vosailagi');

$xcrud->default_tab('Patrol Location Profile');
//$xcrud->button('ReportRoster-Employee.php?id={id}', 'Employee Report','glyphicon glyphicon-download-alt','payslipemail');
$rostering = $xcrud->nested_table('Rostering','clientid','rostering','clientid');
$rostering->relation('id','calendar_management','id',array('id','end_date'),'', 'id desc');
$rostering->label('id','WeekEnding:');

//$rostering->labels('id','Calendar ID');
$rostering->change_type('status','select','pending','pending,approved,locked');

$rostering->button('PDFPrintRoster-GFS.php?rosterid={rosterid}', 'Print Roster PDF','glyphicon glyphicon-download-alt','approve');
$rostering->button('PrintRosterExcel-GFS.php?rosterid={rosterid}', 'Print Roster Excel','glyphicon glyphicon-export','payslipemail');

	$timenow = date('Y-m-d H:i:s');
$log = "Entered by: ".$userid." Date : ".$timenow;
$rostering->pass_default('log',$log);
$rostering->pass_var('log',$log );
$rostering->before_update('update_logroster');
$rostering->column_width('id','400px'); 

if ($userid =='sala'){
	
	$xcrud->where('department=',2);
	
	
	$xcrud->where('sectors =','');
	$xcrud->pass_default('department','2');
    $xcrud->pass_var('department','2');
$xcrud->unset_remove();
	$rostering->unset_remove();
}
if ($userid=='ronald'){
	
//	$xcrud->disabled('jobno,job_type');
	
$xcrud->where('department=','2'); 
//	$xcrud->relation('department','department','departmentid','departmentname','department.departmentid = 4 OR  department.departmentid = 1');
	//$rostering_timesheet->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid'));
	
	$xcrud->unset_remove();
	$rostering->unset_remove();
}

if ($userid=='ilimo'){
	
//	$xcrud->disabled('jobno,job_type');
	
$xcrud->where('department=','1'); 
//	$xcrud->relation('department','department','departmentid','departmentname','department.departmentid = 4 OR  department.departmentid = 1');

	
}

if ($userid =='jokaveti'||$userid=='roster1'||$userid=='roster2'||$userid=='roster3'){
	
//	$xcrud->disabled('jobno,job_type');
	
$xcrud->where('department=','1'); 
//	$xcrud->relation('department','department','departmentid','departmentname','department.departmentid = 4 OR  department.departmentid = 1');
	//$rostering_timesheet->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid'));
	$xcrud->unset_remove();
	$rostering->unset_remove();
	
}
if ($userid =='liti'|| $userid=='maca'  ){
	
	$xcrud->where('department=',2);
	
	
	$xcrud->where('sectors =','24');
	$xcrud->pass_default('department','2');
    $xcrud->pass_var('department','2');
	
	
$xcrud->unset_remove();
	$rostering->unset_remove();
}



if ($userid =='vani' ||$userid =='roneelp'||$userid =='saula' ){
	
	$xcrud->where('departmentid', array('2','7','10','14','16','19','23','29'));

	
	
$xcrud->unset_remove();
	$rostering->unset_remove();
}


if ($userid =='nisha'){
	
	$xcrud->where('department=',7);
	
	 $xcrud->unset_edit();
	$rostering->unset_remove();
}
if ($userid =='lusi' ){
	
	$xcrud->where('department', array('9','10'));
	$rostering->unset_remove();
	//$xcrud->unset_edit();
}

if ($userid =='rowen' || $userid =='rramlu'){
	
	$xcrud->where('department', array('8','21'));
	$xcrud->unset_edit();
	$rostering->unset_remove();
}
if ($userid =='tarusila' || $userid =='seni'){
	
	$xcrud->where('department=',2);
	$xcrud->unset_remove();
	
	$xcrud->where('sectors =','23');
	$xcrud->pass_default('department','2');
    $xcrud->pass_var('department','2');
$rostering->unset_remove();
}

$rostering->disabled('log,lock');
$rostering_timesheet = $rostering->nested_table('Rostering Timesheet','rosterid','rosteringtimesheet','rosterid'); 


	//$rostering_timesheet->relation('employeeid','poolguards','employeeid',array('first_name','last_name','employeeid'),array('rostered' => '0'));
$rostering_timesheet->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid'));

//$rostering_timesheet->unset_remove();

	
	$rostering_timesheet->change_type('mon_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('tues_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('wed_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('thurs_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('fri_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('sat_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('sun_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$rostering_timesheet->change_type('mon2_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');

$rostering_timesheet->highlight('mon_absent','=','None','white');
$rostering_timesheet->highlight('mon_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('mon_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('mon_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('mon_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('mon_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('mon_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('mon_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('mon_absent','=','Paid Public Holiday','#FFDAB9');

$rostering_timesheet->highlight('tues_absent','=','None','white');
$rostering_timesheet->highlight('tues_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('tues_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('tues_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('tues_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('tues_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('tues_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('tues_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('tues_absent','=','Paid Public Holiday','#FFDAB9');




$rostering_timesheet->highlight('wed_absent','=','None','white');
$rostering_timesheet->highlight('wed_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('wed_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('wed_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('wed_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('wed_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('wed_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('wed_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('wed_absent','=','Paid Public Holiday','#FFDAB9');


$rostering_timesheet->highlight('thurs_absent','=','None','white');
$rostering_timesheet->highlight('thurs_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('thurs_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('thurs_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('thurs_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('thurs_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('thurs_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('thurs_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('thurs_absent','=','Paid Public Holiday','#FFDAB9');



$rostering_timesheet->highlight('fri_absent','=','None','white');
$rostering_timesheet->highlight('fri_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('fri_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('fri_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('fri_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('fri_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('fri_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('fri_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('fri_absent','=','Paid Public Holiday','#FFDAB9');



$rostering_timesheet->highlight('sat_absent','=','None','white');
$rostering_timesheet->highlight('sat_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('sat_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('sat_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('sat_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('sat_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('sat_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('sat_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('sat_absent','=','Paid Public Holiday','#FFDAB9');

$rostering_timesheet->highlight('sun_absent','=','None','white');
$rostering_timesheet->highlight('sun_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('sun_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('sun_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('sun_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('sun_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('sun_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('sun_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('sun_absent','=','Paid Public Holiday','#FFDAB9');

$rostering_timesheet->highlight('mon2_absent','=','None','white');
$rostering_timesheet->highlight('mon2_absent','=','Dayoff','#FFC0CB');
$rostering_timesheet->highlight('mon2_absent','=','AWOL','#F08080');
$rostering_timesheet->highlight('mon2_absent','=','SickLeave','#CCFFFF');
$rostering_timesheet->highlight('mon2_absent','=','BereavementLeave','#BCC6CC');
$rostering_timesheet->highlight('mon2_absent','=','AnnualLeave','#DAEE01');
$rostering_timesheet->highlight('mon2_absent','=','MaternityLeave','#FFDAB9');
$rostering_timesheet->highlight('mon2_absent','=','Public Holiday','#FFDAB9');
$rostering_timesheet->highlight('mon2_absent','=','Paid Public Holiday','#FFDAB9');



	$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->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('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('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('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('mon_hrs','=','{mon_hrs}',$mon_color);
	
	
//$rostering_timesheet->before_insert('gridcolor');
//$rostering_timesheet->before_update('gridcolor');
	
	
	//calculate total employee hours per week
//$rostering_timesheet->before_list('highlightcell');




$rostering_timesheet->before_insert('calculate_totalhoursperweek');
$rostering_timesheet->before_update('calculate_totalhoursperweek');
//$rostering_timesheet->after_insert('check_guards');
//$rostering_timesheet->after_update('check_guards');
//$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->sum('mon_total,tues_total,wed_total,thurs_total,fri_total,sat_total,sun_total,mon2_total,total_hrs');
   
   
   
	$rostering_timesheet->table_name('Employee scheduling');
	
	$rostering_timesheet->duplicate_button();
	$rostering_timesheet->disabled('mon_total,tues_total,wed_total,thurs_total,fri_total,sat_total,sun_total,mon2_total,total_hrs,log');
	//$rostering_timesheet->disabled('m_hrs');
	

	

$rostering_timesheet->show_primary_ai_column(false);
$rostering_timesheet->load_view('list','rosteringlist.php');
$rostering_timesheet->load_view('edit','rosteringedit.php');
$rostering_timesheet->load_view('create','rosteringedit.php');
$rostering_timesheet->load_view('view','rosteringedit.php');


$rostering_timesheet->relation('employeeid','employeemaster','employeeid',array('employeeid','first_name','last_name'));
$rostering_timesheet->set_attr('employeeid',array('id'=>'employeeid'));
$rostering_timesheet->set_attr('rosterid',array('id'=>'rosterid'));
$rostering_timesheet->set_attr('calendar_id',array('id'=>'calendarid'));
//mon
$rostering_timesheet->set_attr('montime_in',array('id'=>'monin'));
$rostering_timesheet->set_attr('montime_out',array('id'=>'monout'));

$rostering_timesheet->set_attr('mon_total',array('id'=>'montotal'));
//tues
$rostering_timesheet->set_attr('tuestime_in',array('id'=>'tuesin'));
$rostering_timesheet->set_attr('tuestime_out',array('id'=>'tuesout'));
$rostering_timesheet->set_attr('tues_total',array('id'=>'tuestotal'));
//wed
$rostering_timesheet->set_attr('wedtime_in',array('id'=>'wedin'));
$rostering_timesheet->set_attr('wedtime_out',array('id'=>'wedout'));

$rostering_timesheet->set_attr('wed_total',array('id'=>'wedtotal'));
//thurs
$rostering_timesheet->set_attr('thurstime_in',array('id'=>'thursin'));
$rostering_timesheet->set_attr('thurstime_out',array('id'=>'thursout'));

$rostering_timesheet->set_attr('thurs_total',array('id'=>'thurstotal'));

//fri
$rostering_timesheet->set_attr('fritime_in',array('id'=>'friin'));
$rostering_timesheet->set_attr('fritime_out',array('id'=>'friout'));


$rostering_timesheet->set_attr('fri_total',array('id'=>'fritotal'));
// 
//sat
$rostering_timesheet->set_attr('sattime_in',array('id'=>'satin'));
$rostering_timesheet->set_attr('sattime_out',array('id'=>'satout'));

$rostering_timesheet->set_attr('sat_total',array('id'=>'sattotal'));

//sun
$rostering_timesheet->set_attr('sunttime_in',array('id'=>'sunin'));
$rostering_timesheet->set_attr('sunttime_out',array('id'=>'sunout'));

$rostering_timesheet->set_attr('sun_total',array('id'=>'suntotal'));
//mon2
$rostering_timesheet->set_attr('mon2ttime_in',array('id'=>'mon2in'));
$rostering_timesheet->set_attr('mon2time_out',array('id'=>'mon2out'));

$rostering_timesheet->set_attr('mon2_total',array('id'=>'mon2total'));

$rostering_timesheet->column_class('employeeid,wed_total,tues_total','align-center font-bold ');
$rostering_timesheet->column_pattern('employeeid', '<a href="#" class="xcrud-action" data-task="edit" data-primary="{rstimeid}">{value}</a>');



//timesheet

	  
$timesheet= $xcrud->nested_table('timesheet','clientid','timesheetsuva','clientid'); 


$timesheetdetails = $timesheet->nested_table('rostering_timesheet','timesuvaid','timesheetsuvadetails','timesuvaid'); 
	
	//$rostering_timesheet->highlight('mon_shift','=','{mon_shift}','{mon_color}');

	//1st level main table
$timesheet->relation('department','department','departmentid','departmentname');
	
	$timesheet->table_name('Timesheet by Location ','Employee Timesheet Scheduling','icon-leaf');
	$timesheet->relation('id','calendar_management','id',array('id','end_date'),'', 'id desc');
$timesheet->label('id','WeekEnding:');

//$rostering->labels('id','Calendar ID');
$timesheet->change_type('status','select','pending','pending,approved,locked');


$timesheet->button('PDFPrintTimesheet-GFS.php?rosterid={timesuvaid}', 'Print Timesheet PDF','glyphicon glyphicon-download-alt','approve');
$timesheet->button('PrintTimesheetExcel-GFS.php?rosterid={timesuvaid}', 'Print Timesheet Excel','glyphicon glyphicon-export','payslipemail');

	$timenow = date('Y-m-d H:i:s');
$log = "Entered by: ".$userid." Date : ".$timenow;
$timesheet->pass_default('log',$log);
$timesheet->pass_var('log',$log );
$timesheet->before_update('update_logtimesheet');
$timesheet->column_width('id','400px'); 
//$timesheet->unset_add();

   

	//$approvedby=stripslashes($_SESSION['UsersRealName']);
	//$timesheetdetails->columns('approved_by',true);
     
	//$timesheetdetails->fields('approved_by',true);
	
	//$timesheetdetails->validation_required(array('period' => 1,'start_date','end_date','cl'));
	//$timesheetdetails->duplicate_button();
		$timesheetdetails->unset_print();
        $timesheetdetails->unset_csv();
	$timesheetdetails->benchmark(true);
	 
	
//$timesheetdetails->after_insert('after');
//$timesheetdetails->after_update('after');
	
	$timesheet->highlight('total_hrs','=',48,'#99FF66');
	$timesheet->highlight('total_hrs','>',48,'#ffe6f2');
	$timesheet->highlight('total_hrs','<',48,'#e6fff2');
	$timesheet->highlight_row('total_hrs','<',48,'white');
	
	$timesheet->disabled('log,lock');
	//$timesheet->before_insert('displaydepartment','functionsguardforceclient.php');
	//$timesheet->before_update('displaydepartment','functionsguardforceclient.php');
    $timesheet->show_primary_ai_column(true);
    $timesheet->column_pattern('timesuvaid', '<a href="#" class="xcrud-action" data-task="view" data-primary="{timesuvaid}">{value}</a>');
	//$timesheet->load_view('create','timesheet.php'); 
   //$timesheet->load_view('edit','timesheet.php');
//$timesheet->load_view('view','timesheet.php');

$timesheet->set_attr('id',array('id'=>'id'));

$timesheet->set_attr('status',array('id'=>'status'));



//$timesheet->set_attr('locked',array('id'=>'lock'));
	  $timesheetdetails->show_primary_ai_column(false);
$timesheetdetails->load_view('list','timesheetlist.php');
$timesheetdetails->load_view('edit','timesheetsuvadetailedit.php');
$timesheetdetails->load_view('create','timesheetsuvadetailedit.php');
$timesheetdetails->load_view('view','timesheetsuvadetailedit.php');
$timesheet->unset_print();
$timesheet->unset_csv();
    $timesheet->duplicate_button();
//$timesheet->before_insert('poolguardcreation');
//$timesheet->before_update('poolguardcreation');

//
$userid = $_SESSION['UserID'];

$timesheet->pass_var('last_modified_by',$userid );

$timenow = date('Y-m-d H:i:s');
$timesheet->order_by('timesuvaid','desc');
	$timesheet->pass_var('lastupdate',$timenow);
$timesheet->column_class('sectors','align-center font-bold ');


$timesheetdetails->set_attr('employeeid',array('id'=>'employeeid'));
$timesheetdetails->set_attr('timesuvaid',array('id'=>'rosterid'));
$timesheetdetails->set_attr('calendar_id',array('id'=>'calendarid'));
//mon
$timesheetdetails->set_attr('montime_in',array('id'=>'monin'));
$timesheetdetails->set_attr('montime_out',array('id'=>'monout'));

$timesheetdetails->set_attr('mon_total',array('id'=>'montotal'));
//tues
$timesheetdetails->set_attr('tuestime_in',array('id'=>'tuesin'));
$timesheetdetails->set_attr('tuestime_out',array('id'=>'tuesout'));
$timesheetdetails->set_attr('tues_total',array('id'=>'tuestotal'));
//wed
$timesheetdetails->set_attr('wedtime_in',array('id'=>'wedin'));
$timesheetdetails->set_attr('wedtime_out',array('id'=>'wedout'));

$timesheetdetails->set_attr('wed_total',array('id'=>'wedtotal'));
//thurs
$timesheetdetails->set_attr('thurstime_in',array('id'=>'thursin'));
$timesheetdetails->set_attr('thurstime_out',array('id'=>'thursout'));

$timesheetdetails->set_attr('thurs_total',array('id'=>'thurstotal'));

//fri
$timesheetdetails->set_attr('fritime_in',array('id'=>'friin'));
$timesheetdetails->set_attr('fritime_out',array('id'=>'friout'));


$timesheetdetails->set_attr('fri_total',array('id'=>'fritotal'));
// 
//sat
$timesheetdetails->set_attr('sattime_in',array('id'=>'satin'));
$timesheetdetails->set_attr('sattime_out',array('id'=>'satout'));

$timesheetdetails->set_attr('sat_total',array('id'=>'sattotal'));

//sun
$timesheetdetails->set_attr('sunttime_in',array('id'=>'sunin'));
$timesheetdetails->set_attr('sunttime_out',array('id'=>'sunout'));

$timesheetdetails->set_attr('sun_total',array('id'=>'suntotal'));


//mon2
//mon
$timesheetdetails->set_attr('mon2time_in',array('id'=>'mon2in'));
$timesheetdetails->set_attr('mon2time_out',array('id'=>'mon2out'));

$timesheetdetails->set_attr('mon2_total',array('id'=>'mon2total'));

//$timesheetdetails->set_attr('calendar_id',array('id'=>'calendarid'));
$timesheetdetails->set_attr('locked',array('id'=>'locked'));


$timesheetdetails->column_class('employeeid,wed_total,tues_total','align-center font-bold ');
$timesheetdetails->column_pattern('employeeid', '<a href="#" class="xcrud-action" data-task="edit" data-primary="{id}">{value}</a>');


	//$timesheetdetails->relation('employeeid','poolguards','employeeid',array('first_name','last_name','employeeid'),array('rostered' => '0'));
//$timesheetdetails->relation('employeeid','employeemaster','employeeid',array('first_name','last_name','employeeid'));
$timesheetdetails->relation('employeeid','employeemaster','employeeid',array('employeeid','first_name','last_name'));

 
	
	
     //$timesheetdetails->relation('mon_hrs','shifts','shiftid','hours','','','','','','shiftid','mon_shift');
	 
	 
	 //$timesheetdetails->before_insert('gridcolor');
	//$timesheetdetails->before_update('gridcolor');
	
	//$timesheetdetails->pass_var('montime_in', 'NOW()');
    //$timesheetdetails->no_quotes('montime_in');
	
	 
	$timesheetdetails->label('employeeid','Employees');
	$timesheetdetails->label('debtorno','Customer');
	$timesheetdetails->column_name('debtorno','Customer');
	$timesheetdetails->column_name('total_hrs','Total');
	//$timesheetdetails->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','');
		$timesheetdetails->column_width('debtorno','120px'); 
		$timesheetdetails->column_width('location','150px'); 
	$timesheetdetails->column_width('employeeid','500px'); 
//$timesheetdetails->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');
	//$timesheetdetails->column_width('mon_shift,tues_shift,wed_shift,thurs_shift,fri_shift,sat_shift,sun_shift,mon_shift_2','95px');
	//$timesheetdetails->column_width('total_hrs','20px');
	//$timesheetdetails->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);
	//$timesheetdetails->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
	
	$timesheetdetails->highlight('montime_in','>=','00:00:00','white');
	
	$timesheetdetails->highlight('montime_in','>=','07:00:00','#00d8ff');

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

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

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

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

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


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

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

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

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

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

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


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

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

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

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

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

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

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

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

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


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

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

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

	

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

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

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

	


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

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

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


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

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

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

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

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

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


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

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

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

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

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

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





	//$timesheetdetails->highlight('mon_hrs','=','{mon_hrs}',$mon_color);
	
	
//$timesheetdetails->before_insert('gridcolor');
//$timesheetdetails->before_update('gridcolor');
	
	
	//calculate total employee hours per week
//$timesheetdetails->before_list('highlightcell');

	
	$timesheetdetails->change_type('mon_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('tues_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('wed_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('thurs_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('fri_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('sat_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('sun_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');
$timesheetdetails->change_type('mon2_absent','select','None','None,Dayoff,AWOL,Public Holiday,Paid Public Holiday,SickLeave,BereavementLeave,AnnualLeave,MaternityLeave');

$timesheetdetails->highlight('mon_absent','=','None','white');
$timesheetdetails->highlight('mon_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('mon_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('mon_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('mon_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('mon_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('mon_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('mon_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('mon_absent','=','Paid Public Holiday','#FFDAB9');

$timesheetdetails->highlight('tues_absent','=','None','white');
$timesheetdetails->highlight('tues_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('tues_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('tues_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('tues_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('tues_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('tues_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('tues_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('tues_absent','=','Paid Public Holiday','#FFDAB9');




$timesheetdetails->highlight('wed_absent','=','None','white');
$timesheetdetails->highlight('wed_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('wed_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('wed_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('wed_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('wed_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('wed_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('wed_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('wed_absent','=','Paid Public Holiday','#FFDAB9');


$timesheetdetails->highlight('thurs_absent','=','None','white');
$timesheetdetails->highlight('thurs_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('thurs_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('thurs_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('thurs_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('thurs_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('thurs_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('thurs_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('thurs_absent','=','Paid Public Holiday','#FFDAB9');



$timesheetdetails->highlight('fri_absent','=','None','white');
$timesheetdetails->highlight('fri_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('fri_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('fri_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('fri_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('fri_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('fri_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('fri_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('fri_absent','=','Paid Public Holiday','#FFDAB9');



$timesheetdetails->highlight('sat_absent','=','None','white');
$timesheetdetails->highlight('sat_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('sat_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('sat_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('sat_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('sat_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('sat_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('sat_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('sat_absent','=','Paid Public Holiday','#FFDAB9');

$timesheetdetails->highlight('sun_absent','=','None','white');
$timesheetdetails->highlight('sun_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('sun_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('sun_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('sun_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('sun_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('sun_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('sun_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('sun_absent','=','Paid Public Holiday','#FFDAB9');

$timesheetdetails->highlight('mon2_absent','=','None','white');
$timesheetdetails->highlight('mon2_absent','=','Dayoff','#FFC0CB');
$timesheetdetails->highlight('mon2_absent','=','AWOL','#F08080');
$timesheetdetails->highlight('mon2_absent','=','SickLeave','#CCFFFF');
$timesheetdetails->highlight('mon2_absent','=','BereavementLeave','#BCC6CC');
$timesheetdetails->highlight('mon2_absent','=','AnnualLeave','#DAEE01');
$timesheetdetails->highlight('mon2_absent','=','MaternityLeave','#FFDAB9');
$timesheetdetails->highlight('mon2_absent','=','Public Holiday','#FFDAB9');
$timesheetdetails->highlight('mon2_absent','=','Paid Public Holiday','#FFDAB9');


$timesheetdetails->before_insert('calculate_totalhoursperweek','functionstimesheetsuva.php');
$timesheetdetails->before_update('calculate_totalhoursperweek','functionstimesheetsuva.php');



//$timesheetdetails->after_insert('check_guards');
//$timesheetdetails->after_update('check_guards');
//$timesheetdetails->field_callback('total_hrs','validate_maxhours');

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

	//$timesheetdetails->table_name('Employee Schedulling');
	
	//calculate total  hours per per each day
	
   $timesheetdetails->sum('mon_total,tues_total,wed_total,thurs_total,fri_total,sat_total,sun_total,mon2_total,total_hrs');
   
   //$timesheetdetails->columns('mon_gap,tues_gap,wed_gap,thurs_gap,fri_gap,sat_gap,sun_gap',true);
   
	$timesheetdetails->table_name('Employee scheduling');
	
	$timesheetdetails->duplicate_button();

	







	
echo $xcrud->render();	
  
 	echo '</div >';
	?>
						

		
					</div>
				</div>
			</div>
					
					

						<!--end:: Widgets/Stats-->

						<!--Begin::Section-->
						

		<!-- end::Quick Sidebar -->

		<!-- begin::Scroll Top -->
		<div id="m_scroll_top" class="m-scroll-top">
			<i class="la la-arrow-up"></i>
		</div>

		<!-- end::Scroll Top -->

		<!-- begin::Quick Nav -->
		

		<!-- begin::Quick Nav -->
<script src="includes/vendors/owl.carousel/dist/owl.carousel.js" type="text/javascript"></script>

		<!--end::Page Scripts -->
	</body>

	<!-- end::Body -->
</html>
 
      
<?php



/*The module link codes are hard coded in a switch statement below to determine the options to show for each tab */
include('includes/MainMenuLinksArray.php');

if (isset($SupplierLogin) AND $SupplierLogin==1){
	echo '<table class="table_index">
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=1">' . _('View or Amend outstanding offers') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=2">' . _('Create a new offer') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=3">' . _('View any open tenders without an offer') . '</a></p>
			</td>
			</tr>
		</table>';
	include('includes/footer.inc');
	exit;
} elseif (isset($CustomerLogin) AND $CustomerLogin==1){
	echo '<table class="table_index">
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/CustomerInquiry.php?CustomerID=' . $_SESSION['CustomerID'] . '">' . _('Account Status') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SelectOrderItems.php?NewOrder=Yes">' . _('Place An Order') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SelectCompletedOrder.php?SelectedCustomer=' . $_SESSION['CustomerID'] . '">' . _('Order Status') . '</a></p>
			</td>
			</tr>
		</table>';

	include('includes/footer.inc');
	exit;
}

if (isset($_GET['Application'])){ /*This is sent by this page (to itself) when the user clicks on a tab */
	$_SESSION['Module'] = $_GET['Application'];
}








//include('includes/footer.inc');

function GetRptLinks($GroupID) {
/*
This function retrieves the reports given a certain group id as defined in /reports/admin/defaults.php
in the acssociative array $ReportGroups[]. It will fetch the reports belonging solely to the group
specified to create a list of links for insertion into a table to choose a report. Two table sections will
be generated, one for standard reports and the other for custom reports.
*/
	global $db, $RootPath, $ReportList;
	require_once('reportwriter/languages/en_US/reports.php');
	require_once('reportwriter/admin/defaults.php');
	$GroupID=$ReportList[$GroupID];
	$Title= array(_('Custom Reports'), _('Standard Reports and Forms'));

	$sql= "SELECT id,
				reporttype,
				defaultreport,
				groupname,
				reportname
			FROM reports
			ORDER BY groupname,
					reportname";
	$Result=DB_query($sql,'','',false,true);
	$ReportList = '';
	while ($Temp = DB_fetch_array($Result)) $ReportList[] = $Temp;

	$RptLinks = '';
	for ($Def=1; $Def>=0; $Def--) {
        $RptLinks .= '<li class="menu_group_headers">';
        $RptLinks .= '<b>' .  $Title[$Def] . '</b>';
        $RptLinks .= '</li>';
		$NoEntries = true;
		if ($ReportList) { // then there are reports to show, show by grouping
			foreach ($ReportList as $Report) {
				if ($Report['groupname']==$GroupID AND $Report['defaultreport']==$Def) {
                    $RptLinks .= '<li class="menu_group_item">';
					$RptLinks .= '<p>&bull; <a href="' . $RootPath . '/reportwriter/ReportMaker.php?action=go&amp;reportid=' . $Report['id'] . '">' . _($Report['reportname']) . '</a></p>';
					$RptLinks .= '</li>';
					$NoEntries = false;
				}
			}
			// now fetch the form groups that are a part of this group (List after reports)
			$NoForms = true;
			foreach ($ReportList as $Report) {
				$Group=explode(':',$Report['groupname']); // break into main group and form group array
				if ($NoForms AND $Group[0]==$GroupID AND $Report['reporttype']=='frm' AND $Report['defaultreport']==$Def) {
                    $RptLinks .= '<li class="menu_group_item">';
					$RptLinks .= '<img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/folders.gif" width="16" height="13" alt="" />&nbsp;';
					$RptLinks .= '<p>&bull; <a href="' . $RootPath . '/reportwriter/FormMaker.php?id=' . $Report['groupname'] . '"></p>';
					$RptLinks .= $FormGroups[$Report['groupname']] . '</a>';
					$RptLinks .= '</li>';
					$NoForms = false;
					$NoEntries = false;
				}
			}
		}
		if ($NoEntries) $RptLinks .= '<li class="menu_group_item">' . _('There are no reports to show!') . '</li>';
	}
	return $RptLinks;
}
	
?>
<!-- Modal HTML embedded directly into document -->
<div id="ex1" class="modal">
  <p>Thanks for clicking. That felt good.</p>
  <a href="#" rel="modal:close">Close</a>
</div>


<!-- Modal -->
 <div class="modal fade" id="getCodeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog modal-lg">
      <div class="modal-content">
       <div class="modal-header">
         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
         <h4 class="modal-title" id="myModalLabel"> API CODE </h4>
       </div>
       <div class="modal-body" id="getCode" style="overflow-x: scroll;">
       
          
          
       </div>
    </div>
   </div>
 </div>
<script>
jQuery(document).ready(function($){


	$(".xcrud").on("change","#monout",function(){ // !important, delegation from static container
     var start_time = $("#monin").val();
	 var end_time = $("#monout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
	var fromDate = parseInt(new Date(start_time).getTime()/1000); 
    var toDate = parseInt(new Date(end_time).getTime()/1000);
    var timeDiff = (toDate - fromDate)/3600;  // will give difference in hrs
	
		$("#mon_total").val(timeDiff);
	
	  
	  
   });

	//monday calculations
 
	
	

	
	
	
   }); 
	
	

	
	
		
		

	
	
</script>


<script type="text/javascript">
jQuery(document).on("ready xcrudafterrequest",function(){
    
});
</script>