<?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 '<div class ="nav-hrms"><ul>';
     echo '<li><a href="'.$RootPath.'/hrms.php">' . _('HRMS Portal') . '</a></li>';
     echo '<li><a href="'.$RootPath.'/employee.php">' . _('Employee Management') . '</a>';
          echo '<ul>';
                echo '<li><a href="'.$RootPath.'/addemployee.php">' . _('Create New') . '</a></li>';
                echo '<li><a href="'.$RootPath.'/searchemployee.php">' . _('Search') . '</a></li>';
            
		  echo '</ul></li>';
		  
		  echo '<li><a href="'.$RootPath.'/Rostermanagement.php">' . _('Roster Management') . '</a></li>';
		  
		  
          echo '<li><a href="'.$RootPath.'/PlannerDashboard.php">' . _('Timesheet Management') . '</a></li>';
		  
		  
		  echo '<li><a href="'.$RootPath.'/Intel-dashboard.php">' . _('Leave Management') . '</a>';
		  
		 
		  echo '<li><a href="'.$RootPath.'/FinancialDashboard.php">' . _('Deductions') . '</a></li>';
		  
		 
		  echo '<li><a href="'.$RootPath.'/ManagementDashboard.php">' . _('Payroll Processing') . '</a></li>';
		  
		     			   
			   echo '<li><a href="'.$RootPath.'/ManagementDashboard.php">' . _('Reports') . '</a></li>';
		  
		      echo '<li><a href="'.$RootPath.'/ManagementDashboard.php">' . _('Setup') . '</a></li>';
		  echo'<ul> </div>';
		  
		
  
echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/maintenance.png" title="' . _('Guardforce Client Business') .
	'" alt="" />'  . '</p>';
echo '<div class="page_help_text">' . _('Quick Check Panel') . '</div>';
	
	
      
	echo '<div class="col-sm-9">';
		
    include('xcrud/xcrud.php');
	
	
    $xcrud = Xcrud::get_instance();
    $xcrud->table('guardforceclient-west');
$xcrud->where('department =', 1);
	$xcrud->table_name('Guardforce Patrol Location &  Business Data');
	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_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);
	
$xcrud->columns('clientid,sectors,patrollocation,account_number,department,req_guards,premium_rate,monday,tuesday,wednesday,thursday,friday,saturday,sunday,monday_2');
			
    $xcrud->fields('clientid,sectors,patrollocation,account_number,department,req_guards,premium_rate,monday,tuesday,wednesday,thursday,friday,saturday,sunday,monday_2', false, 'Guardforce Patrol Location');


 
	$xcrud->relation('debtorno','debtorsmaster','debtorno','name');
$xcrud->relation('sectors','sectors','id','name');
$xcrud->relation('department','department','departmentid','departmentname','departmentid = 1');

$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');
		
   //$xcrud->change_type('clientname','select','',$name);
   
   	$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('full_name','employeeid'));
   $allocated_staffs->before_update('employeename','functionsguardforceclient.php');
	$allocated_staffs->before_update('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('full_name','employeeid'));
   $approved_staffs->before_update('employeename','functionsguardforceclient.php');
	$approved_staffs->before_update('employeename','functionsguardforceclient.php');
//		
    $approved_staffs->disabled('clientid');
$allocated_staffs->columns('employees',true);
	$allocated_staffs->fields('employees',true);

echo $xcrud->render();
	
	

echo '</div>';

include('includes/footer.inc'); 

?>

