<?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('clientlocationroster');
	
	
	
	//second level table configurations
	 //$rostering_timesheet = $xcrud->nested_table('rostering_timesheet','rosterid','rosteringtimesheet','rosterid'); 
	 
	 //$xcrud->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
	  
	
	$xcrud->relation('employeeid','employeemaster','employeeid','full_name');
	$xcrud->relation('mon_shift','shifts','shiftid','shiftname');
	$xcrud->relation('tues_shift','shifts','shiftid','shiftname');
	$xcrud->relation('wed_shift','shifts','shiftid','shiftname');
	$xcrud->relation('thurs_shift','shifts','shiftid','shiftname');
	$xcrud->relation('fri_shift','shifts','shiftid','shiftname');
	$xcrud->relation('sat_shift','shifts','shiftid','shiftname');
	$xcrud->relation('sun_shift','shifts','shiftid','shiftname');
	 //$rostering_timesheet->change_type('mon_shift','select','3pm-7pm','3pm-7pm,9am-12pm');
	 
 
	
	
     //$rostering_timesheet->relation('mon_hrs','shifts','shiftid','hours','','','','','','shiftid','mon_shift');
	 
	 
	 //$rostering_timesheet->before_insert('gridcolor');
	//$rostering_timesheet->before_update('gridcolor');
	
	
	
	
	$xcrud->label('employeeid','Employees');
	
	$xcrud->column_name('mon_hrs,tues_hrs,wed_hrs,thurs_hrs,fri_hrs,sat_hrs,sun_hrs','');
	//$rostering_timesheet->column_width('employeeid','150px'); 
//$rostering_timesheet->column_width('mon_hrs,tues_hrs,wed_hrs,thurs_hrs,fri_hrs,sat_hrs,sun_hrs','5px');
	//$rostering_timesheet->column_width('mon_shift,tues_shift,wed_shift,thurs_shift,fri_shift,sat_shift,sun_shift','85px');
	//$rostering_timesheet->column_width('total_hrs','15px');
	
	$xcrud->validation_required(array('period' => 1,'start_date','end_date','clientid','location'));
	
	//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('mon_shift','=','{mon_shift}',$mon_color);
	//$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
$xcrud->before_list('highlightcell');




$xcrud->before_insert('calculate_totalhoursperweek');
$xcrud->before_update('calculate_totalhoursperweek');

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

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

	//$xcrud->table_name('Employee Schedulling');
	
	//calculate total  hours per per each day
	
   $xcrud->sum('mon_hrs,tues_hrs,wed_hrs,thurs_hrs,fri_hrs,sat_hrs,sun_hrs,total_hrs');
   
   
   
	
	
	$xcrud->duplicate_button();
	$xcrud->disabled('mon_hrs,tues_hrs,wed_hrs,thurs_hrs,fri_hrs,sat_hrs,sun_hrs,total_hrs,modified_by');
	//$rostering_timesheet->disabled('m_hrs');
	
	$xcrud->highlight('total_hrs','=',48,'#99FF66');
	$xcrud->highlight('total_hrs','>',48,'#ffe6f2');
	$xcrud->highlight('total_hrs','<',48,'#e6fff2');
	$xcrud->highlight_row('total_hrs','<',48,'white');
	


	//$rostering_timesheet->highlight('mon_shift','=','{mon_shift}','{mon_color}');
	
	//1st level main table
	
	$xcrud->relation('clientid','guardforceclient','clientid','clientname');
	
  $xcrud->relation('location','guardforceclient','clientid','patrollocation','','','',' ','','clientid','clientid');
 	
	$xcrud->table_name('Employee Rostering based on client Locations','Employee scheduling','icon-leaf');
	
			
    $xcrud->change_type('status','select','pending','pending,approved');
	
	$approvedby=stripslashes($_SESSION['UsersRealName']);
	
	//$xcrud->columns('approved_by',true);
     
	//$xcrud->fields('approved_by',true);
	
	//$xcrud->validation_required(array('period' => 1,'start_date','end_date','client','patrol_location'));
	$xcrud->duplicate_button();
	
	//	$rostering_timesheet->benchmark(true);
	
	//validate max hours for employees
	
$xcrud->after_insert('after');
$xcrud->after_update('after');
	
	
	
	
	echo $xcrud->render();
	

	

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

include('includes/footer.inc'); 

?>

