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

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

?>

		
  					
	<script src="angular/angular.min.js"></script>  
        
 
     
     
		

   
  
 									
									<?php
//this is where you paste. Below paste it:

if (isset($_GET['rosterid'])) {
		$_SESSION['rosterid'] = stripslashes($_GET['rosterid']);
	}
	$rosterid = $_SESSION['rosterid'];


$printdate = date("d-m-Y");



		
	

				$SQL = "SELECT rostering.rosterid,
											
											rostering.id,
											guardforceclient.debtorno,
											guardforceclient.patrollocation,
											guardforceclient.sectors,
											guardforceclient.account_number,
											guardforceclient.department,
										    
											rostering.status,
											calendar_management.start_date,
											calendar_management.end_date
											
		                            FROM rostering 
									inner join guardforceclient on guardforceclient.clientid = rostering.clientid
									inner join calendar_management on calendar_management.id = rostering.id
		                            WHERE rosterid = '" . $rosterid."' 
									
									";

$result=DB_query($SQL);
	
	$myrow50=DB_fetch_array($result);

	
	$startdate= date("d-m-Y", strtotime($myrow50['start_date']));
	$enddate= date("d-m-Y", strtotime($myrow50['end_date']));
	$date = date('d-m-Y');


$SQLdepart = "SELECT departmentname
											
		                            FROM department
		                            WHERE departmentid ='" . $myrow50['department']."' ";
	$resultdepart=DB_query($SQLdepart);
	
$myrowdepart=DB_fetch_array($resultdepart);




	$SQLsectors = "SELECT name,supervisor_details_for_rosterprintheaders
											
		                            FROM sectors
		                            WHERE id ='" . $myrow50['sectors']."' ";
	$resultQ=DB_query($SQLsectors);
	
	$myrow200=DB_fetch_array($resultQ);

	$SQLdebtors = "SELECT 
											
											name
											
		                            FROM debtorsmaster
		                            WHERE debtorno ='" . $myrow50['debtorno']."' ";
	$resultR=DB_query($SQLdebtors);
	
	
	$myrow300=DB_fetch_array($resultR);
	

$sqlcom = "SELECT 
					controlroom_ph
				FROM companies
				WHERE coycode=1";

	$ErrMsg =  _('The company preferences could not be retrieved because');
	$resultcom = DB_query($sqlcom,$ErrMsg);


	$myrowcom = DB_fetch_array($resultcom);
	
$PaperSize = 'A4_Landscape';// PDFStarter.php: $Page_Width=842; $Page_Height=595; $Top_Margin=30; $Bottom_Margin=30; $Left_Margin=40; $Right_Margin=30;
include('includes/PDFStarter.php');
$pdf->addInfo('Title', _('Roster') );
$pdf->addInfo('Subject', _('Roster') );
$FontSize = 12;
	$pdf->setCellHeightRatio(0.5);
$line_height = 12;// Recoeommended: $line_height = $x * $FontSize.
	$headinggap = 6;	
		include('includes/PDFRosterheader.inc');

  $topheading = $YPos + 35;
 $SQL = "SELECT rosteringtimesheet.*,
  				
                  employeemaster.first_name,
				  employeemaster.last_name
				  
				  
				FROM rosteringtimesheet INNER JOIN employeemaster
				ON rosteringtimesheet.employeeid = employeemaster.employeeid 
				WHERE rosteringtimesheet.rosterid='" . $rosterid."'
				";

  
  			

	$AccountsResult = DB_query($SQL);

	

$num= DB_num_rows($AccountsResult);


$rowCount= 0;
	$cellcount = 0;	
	$cellcount2 = 6;
$montotalhours = 0;	
		$tuestotalhours = 0; 	$wedtotalhours = 0;		$thurstotalhours = 0;	$fritotalhours = 0; 	$sattotalhours = 0;
	 	$suntotalhours = 0; 	$mon2totalhours = 0; $totalhours = 0;$totalnormal = 0; $totaltimehalf = 0 ; $totaldouble = 0;
while ($rowCount < $num) {
	


   
	while ($myrow3=DB_fetch_array($AccountsResult)) {
		
		
		
				
				  $ListCount ++;
				

		$YPos -= $line_height;// Increment a line down for the next line item.
				
      
		if ((mb_strlen($myrow1['narrative']) >200 AND $YPos-$line_height <= 75)
			OR (mb_strlen($myrow1['narrative']) >1 AND $YPos-$line_height <= 62)
			OR $YPos-$line_height <= 50){
		/* We reached the end of the page so finsih off the page and start a newy */
			include ('includes/PDFRosterheader.inc');
		} //end if need a new page headed up

			
								//$myrow6 = DB_fetch_array($result6) ;
				
				
				//write to pdf
				
				//$total = $myrow7979['quantity'] * $myrow3['materialcost'] ;
			    
			 
			  // $grandtotal += $total;
				
				//$costprice = locale_number_format($myrow3['materialcost'],2);
				
				//$roundtotal= locale_number_format($total,2);

	
			
			$FontSize =8;// Font size for the line item.
 $employee = $myrow3['employeeid'].'-'.$myrow3['first_name'];
		$LeftOvers = $pdf->addTextWrap(20, $YPos+12-$cellcount,200,$FontSize,$employee,'left');
		
		
	
	$FontSize =7;
		
		if ($myrow3['mon_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(130, $YPos+12 - $cellcount,200,$FontSize,$myrow3['mon_absent'],'left');
		}
		
		
		if (round($myrow3['mon_total']) > 0.0){
			
			$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(130, $YPos+12 - $cellcount,200,$FontSize,$mon._(' ').$myrow3['mon_total'],'left');
		}
		
		if ($myrow3['tues_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(220, $YPos+12 - $cellcount,200,$FontSize,$myrow3['tues_absent'],'left');
		}
		if (round($myrow3['tues_total']) > 0.0){
		
		$tuestimein = date("g:i a", strtotime($myrow3['tuestime_in']));
			$tuestimeout = date("g:i a", strtotime($myrow3['tuestime_out']));
			$tues = $tuestimein.'-'.$tuestimeout;
			
			
			$LeftOvers = $pdf->addTextWrap(220, $YPos+12 - $cellcount,200,$FontSize,$tues._(' ').$myrow3['tues_total'],'left');
				
		}
		
       if ($myrow3['wed_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(300, $YPos+12 - $cellcount,200,$FontSize,$myrow3['wed_absent'],'left');
		}
		if (round($myrow3['wed_total']) > 0.0){
			$wedtimein = date("g:i a", strtotime($myrow3['wedtime_in']));
			$wedtimeout = date("g:i a", strtotime($myrow3['wedtime_out']));
			$wed = $wedtimein.'-'.$wedtimeout;
			
			
			$LeftOvers = $pdf->addTextWrap(300, $YPos+12 - $cellcount,200,$FontSize,$wed._(' ').$myrow3['wed_total'],'left');
		
		 
		}
		
if ($myrow3['thurs_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(380, $YPos+12 - $cellcount,200,$FontSize,$myrow3['thurs_absent'],'left');
		}
		if (round($myrow3['thurs_total']) > 0.0){
				$thurstimein = date("g:i a", strtotime($myrow3['thurstime_in']));
			$thurstimeout = date("g:i a", strtotime($myrow3['thurstime_out']));
			$thurs = $thurstimein.'-'.$thurstimeout;
			
			
			$LeftOvers = $pdf->addTextWrap(380, $YPos+12 - $cellcount,200,$FontSize,$thurs._(' ').$myrow3['thurs_total'],'left');
				
		   
		 
		}
		
		if ($myrow3['fri_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(460, $YPos+12 - $cellcount,200,$FontSize,$myrow3['fri_absent'],'left');
		}
	
       if (round($myrow3['fri_total']) > 0.0){
			$fritimein = date("g:i a", strtotime($myrow3['fritime_in']));
			$fritimeout = date("g:i a", strtotime($myrow3['fritime_out']));
			$fri = $fritimein.'-'.$fritimeout;
			
			$LeftOvers = $pdf->addTextWrap(460, $YPos+12 - $cellcount,200,$FontSize,$fri._(' ').$myrow3['fri_total'],'left');
				
		
		}
		
		if ($myrow3['sat_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(540, $YPos+12 - $cellcount,200,$FontSize,$myrow3['sat_absent'],'left');
		}
		
		if (round($myrow3['sat_total']) > 0.0){
			$sattimein = date("g:i a", strtotime($myrow3['sattime_in']));
			$sattimeout = date("g:i a", strtotime($myrow3['sattime_out']));
			$sat = $sattimein.'-'.$sattimeout;
			
			$LeftOvers = $pdf->addTextWrap(540, $YPos+12 - $cellcount,200,$FontSize,$sat._(' ').$myrow3['sat_total'],'left');
					
		 
		}
		
		if ($myrow3['sun_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(620, $YPos+12 - $cellcount,200,$FontSize,$myrow3['sun_absent'],'left');
		}
		
		if (round($myrow3['sun_total']) > 0.0){
			$sunttimein = date("g:i a", strtotime($myrow3['sunttime_in']));
			$sunttimeout = date("g:i a", strtotime($myrow3['sunttime_out']));
			$sunt = $sunttimein.'-'.$sunttimeout;
			
			
			$LeftOvers = $pdf->addTextWrap(620, $YPos+12 - $cellcount,200,$FontSize,$sunt._(' ').$myrow3['sun_total'],'left');
				
		 
		}

		
		if ($myrow3['mon2_absent'] !=='None' ){
			
			//$montimein = date("g:i a", strtotime($myrow3['montime_in']));
			//$montimeout = date("g:i a", strtotime($myrow3['montime_out']));
			//$mon = $montimein.'-'.$montimeout;
			$LeftOvers = $pdf->addTextWrap(700, $YPos+12 - $cellcount,200,$FontSize,$myrow3['mon2_absent'],'left');
		}
			if (round($myrow3['mon2_total']) > 0.0){
			$mon2timein = date("g:i a", strtotime($myrow3['mon2time_in']));
			$mon2timeout = date("g:i a", strtotime($myrow3['mon2time_out']));
			$mon2= $mon2timein.'-'.$mon2timeout;
			
			
			$LeftOvers = $pdf->addTextWrap(700, $YPos+12 - $cellcount,200,$FontSize,$mon2._(' ').$myrow3['mon2_total'],'left');
				
		 
		}
		
	//tallies
		
		$LeftOvers = $pdf->addTextWrap(800, $YPos+12 - $cellcount,200,$FontSize,$myrow3['total_hrs'],'left');
		
			
		
	
		
		$monday   = $myrow3['mon_total'] ;
		$montotalhours +=$monday;
		
		$tuesday   = $myrow3['tues_total'] ;
		$tuestotalhours +=$tuesday;
		
		$wednesday   = $myrow3['wed_total'] ;
		$wedtotalhours +=$wednesday;
		
		$thursday   = $myrow3['thurs_total'] ;
		$thurstotalhours +=$thursday;
		
		$friday   = $myrow3['fri_total'];
		$fritotalhours +=$friday;
		
		$satday   = $myrow3['sat_total'] ;
		$sattotalhours +=$satday;
		
		$sunday   = $myrow3['sun_total'];
		$suntotalhours +=$sunday;
		
			$monday2   = $myrow3['mon2_total'];
		$mon2totalhours +=$monday2;
		
		
		$totalhours += $myrow3['total_hrs'];
		
		$cellcount = $cellcount + 6;
		$cellcount2 = $cellcount2 + 6;
		
		
			
			
			// Prints salesorderdetails.narrative:
		$FontSize2 = $FontSize*0.8;// Font size to print salesorderdetails.narrative.
		$Width2 = $Page_Width-$Right_Margin-145;// Width to print salesorderdetails.narrative.
		$LeftOvers = trim($myrow1['narrative']);
		//**********
		$LeftOvers = str_replace('\n', ' ', $LeftOvers);// Replaces line feed character.
		$LeftOvers = str_replace('\r', '', $LeftOvers);// Delete carriage return character
		$LeftOvers = str_replace('\t', '', $LeftOvers);// Delete tabulator character
			
			while (mb_strlen($LeftOvers) > 1) {
			$YPos -= $FontSize2;
			if ($YPos < ($Bottom_Margin)) {// Begins new page.
				include ('includes/PDFRosterheader.inc');
			}
			$LeftOvers = $pdf->addTextWrap(145, $YPos, $Width2, $FontSize2, $LeftOvers);
		}
			
			if ((mb_strlen($quoteterms) >200 AND $YPos-$line_height <= 75)
			OR (mb_strlen($quoteterms) >1 AND $YPos-$line_height <= 62)
			OR $YPos-$line_height <= 50){
		/* We reached the end of the page so finish off the page and start a newy */
			include ('includes/PDFRosterheader.inc');
	} //end if need a new page headed up

				
				
				
				
		}	
	$rowCount++;
}


//total
		
		$pdf->addTextWrap(60, $Bottom_Margin+(2*$line_height),200,$FontSize,"TOTAL",'left');
         
$pdf->addTextWrap(140, $Bottom_Margin+(2*$line_height),200,$FontSize,$montotalhours,'left');
$pdf->addTextWrap(230, $Bottom_Margin+(2*$line_height),200,$FontSize,$tuestotalhours,'left');
$pdf->addTextWrap(313, $Bottom_Margin+(2*$line_height),200,$FontSize,$wedtotalhours,'left');
$pdf->addTextWrap(393, $Bottom_Margin+(2*$line_height),200,$FontSize,$thurstotalhours,'left');
$pdf->addTextWrap(472, $Bottom_Margin+(2*$line_height),200,$FontSize,$fritotalhours,'left');
$pdf->addTextWrap(546, $Bottom_Margin+(2*$line_height),200,$FontSize,$sattotalhours,'left');
$pdf->addTextWrap(630, $Bottom_Margin+(2*$line_height),200,$FontSize,$suntotalhours,'left');
$pdf->addTextWrap(710, $Bottom_Margin+(2*$line_height),200,$FontSize,$mon2totalhours,'left');
$pdf->addTextWrap(800, $Bottom_Margin+(2*$line_height),200,$FontSize,$totalhours,'left');
		/* Print a column vertical line  with enough space for the footer */
			/* draw the vertical column lines to 4 lines shy of the bottom to leave space for invoice footer info ie totals etc */
			//the first part is the horizontal path, second is from top 
//$pdf->line(143, $topheading,143,$Bottom_Margin+(3*$line_height));
$pdf->line(120, $topheading,120,$Bottom_Margin+(2*$line_height));
$pdf->line(210, $topheading,210,$Bottom_Margin+(2*$line_height));
$pdf->line(300, $topheading,300,$Bottom_Margin+(2*$line_height));
$pdf->line(382, $topheading,382,$Bottom_Margin+(2*$line_height));
$pdf->line(459, $topheading,459,$Bottom_Margin+(2*$line_height));
$pdf->line(538, $topheading,538,$Bottom_Margin+(2*$line_height));
$pdf->line(617, $topheading,617,$Bottom_Margin+(2*$line_height));
$pdf->line(705, $topheading,705,$Bottom_Margin+(2*$line_height));
//tallies columns
$pdf->line(790, $topheading,790,$Bottom_Margin+(2*$line_height));

		$FontSize = 10;
		

	$pdf->line($Page_Width-$Right_Margin-810, $Bottom_Margin+(2*$line_height),$Page_Width-$Right_Margin,$Bottom_Margin+(2*$line_height));		$pdf->line($Page_Width-$Right_Margin-810, $Bottom_Margin+(2*$line_height+20),$Page_Width-$Right_Margin,$Bottom_Margin+(2*$line_height+20));
	
	//$pdf->addTextWrap(60, $Bottom_Margin+(2*$line_height),200,$FontSize,"Supervisor Signature:",'left');
//$pdf->addTextWrap(160, $Bottom_Margin+(2*$line_height),200,$FontSize,"_________________",'left');

	//$pdf->addTextWrap(280, $Bottom_Margin+(2*$line_height),200,$FontSize,"Manager Signature:",'left');
//$pdf->addTextWrap(380, $Bottom_Margin+(2*$line_height),200,$FontSize,"_________________",'left');
	//$grand = locale_number_format($grandtotal,2);

//$pdf->addTextWrap(480, $Bottom_Margin+(2*$line_height),200,$FontSize,"Date Signed:",'left');
//$pdf->addTextWrap(550, $Bottom_Margin+(2*$line_height),200,$FontSize,"_________________",'left');
	//$grand = locale_number_format($grandtotal,2);

	$pdf->addTextWrap(60, $Bottom_Margin+(0.5*$line_height),800,8,"Supervisor _____________________          Manager ______________________       Date: ___________________",'left');
//$pdf->addTextWrap(30, $Bottom_Margin+(0.5*$line_height),800,8,"Any guard on AWOL will be taken off the roster.",'left');
			$DisplayFreight = 0;
			
			
			
	$YPos -= $line_height;
	/*rule off for total */
		//	$pdf->line($Page_Width-$Right_Margin-222, $YPos+7,$Page_Width-$Right_Margin,$YPos+7);
$YPos -= $FontSize;
	//$LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-90-655, $YPos, 655, $FontSize, _('GRAND TOTAL'), 'right');
	//$LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-90, $YPos, 90, $FontSize, _('$').$grand, 'right');
	$YPos -= $FontSize;





	// Print salesorders.comments:
	$YPos -= $FontSize*3;
	//$pdf->addText($XPos+550, $YPos+$FontSize, $FontSize, _('Supervision Signiture By:'));
    //$pdf->addText($XPos+650, $YPos+$FontSize, $FontSize, $received_by);
//$pdf->line($Page_Width-$Right_Margin-222, $YPos+$FontSize*-1,$Page_Width-$Right_Margin,$YPos+$FontSize*-1);

//
	//$pdf->addText($XPos+550, $YPos+$FontSize*-2, $FontSize, _('Authorized By:'));
   // $pdf->addText($XPos+650, $YPos+$FontSize*-2, $FontSize, $authorized_by);
//$pdf->line($Page_Width-$Right_Margin-222, $YPos+$FontSize*-3.5,$Page_Width-$Right_Margin,$YPos+$FontSize*-3.5);

	//$pdf->addText($XPos, $YPos+$FontSize-45, $FontSize, _('Comments').':');
	$Width2 = $Page_Width-$Right_Margin-120;// Width to print salesorders.comments.
$LeftOvers =	$pdf->addText($XPos, $YPos+$FontSize-55, $FontSize, $narrative);
	//$LeftOvers = trim($quoteterms);
	//**********
	$LeftOvers = str_replace('\n', ' ', $LeftOvers);// Replaces line feed character.
	$LeftOvers = str_replace('\r', '', $LeftOvers);// Delete carriage return character
	$LeftOvers = str_replace('\t', '', $LeftOvers);// Delete tabulator character
	//**********
	while(mb_strlen($LeftOvers) > 1) {
		$YPos -= $FontSize;
		if ($YPos < ($Bottom_Margin)) {// Begins new page.
				include ('includes/PDFRosterheader.inc');
		}
		$LeftOvers = $pdf->addTextWrap(40, $YPos, $Width2, $FontSize, $LeftOvers);
	}


	
	


	
	

ob_end_clean();
	 //its not an email just print the invoice to PDF
		$pdf->OutputD('Roster_' . $rosterid. '.pdf');

		
		
	
	$pdf->__destruct();
		
			

			
		
			
		
		
		
			    
		
	
//echo 'Quotation Created Successfully'. $jobno.'!';




//echo 'Quotation Created Successfully'. $jobno.'!';
echo '</div>';
echo '</div>';






			  
 	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($){

   // event must be delegated from .xcrud
	
	//check employee for a clash on existing patrol location
$(".xcrud").on("change","#internal",function(){ // !important, delegation from static container
     var internal = $("#internal").val();
	 
	
        if(internal != 0)
       {
		
		 $('#sectors').attr("disabled", true);
		
            $('#patrollocation').attr("disabled",true);
		  $('#account').attr("disabled", true);
		   
		//   $("#account").hide();
       }
	else{
		 $('#sectors').attr("disabled", false);
		
            $('#patrollocation').attr("disabled",false);
		  $('#account').attr("disabled", false)
		//$("#account").show();
	}
     
	  
   });
	
	//check employee for a clash on same employee working at different location but at same time-frame
	//monday shift one and two	
	$(".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();
		
	
	
		
	
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclash.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });

	//monday calculations
 
	



	
	
	//tuesdayshift one and two	
	$(".xcrud").on("change","#tuesout",function(){ // !important, delegation from static container
     var start_time = $("#tuesin").val();
	 var end_time = $("#tuesout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclashtues.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });
	
	//wed shift one and two	
	$(".xcrud").on("change","#wedout",function(){ // !important, delegation from static container
     var start_time = $("#wedin").val();
	 var end_time = $("#wedout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclashwed.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });
	
	
	//thursday shift one and two	
	$(".xcrud").on("change","#thursout",function(){ // !important, delegation from static container
     var start_time = $("#thursin").val();
	 var end_time = $("#thursout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclashthurs.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });
	
	//friday shift one and two	
	$(".xcrud").on("change","#friout",function(){ // !important, delegation from static container
     var start_time = $("#friin").val();
	 var end_time = $("#friout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclashfri.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });
	
	//saturday shift one and two	
	$(".xcrud").on("change","#satout",function(){ // !important, delegation from static container
     var start_time = $("#satin").val();
	 var end_time = $("#satout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclashsat.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });
	
	//sundayshift one and two	
	$(".xcrud").on("change","#sunout",function(){ // !important, delegation from static container
     var start_time = $("#sunin").val();
	 var end_time = $("#sunout").val();
	 var rosterid = $("#rosterid").val();
		 var employeeid = $("#employeeid").val();
		
		
	   $.ajax({
      url:'hrms/CheckEmployee-timeclashsun.php',
      method:"POST",
      data:{start_time:start_time,end_time:end_time,rosterid:rosterid,employeeid:employeeid},
		 
		
      success:function(data)
     {
		 	
	   var data = JSON.parse(data);
	    console.log(data);
        if(data != 0)
       {
		  
		   
       alert('CLASH!This employee is already rostered in another location/post at these selected times. Please choose another employee before proceeding. Full Details where they are rostered at :ROSTERID:'+ data);
		    
       }
      }
     })  
	  
   });
	
	

	
	
	
   }); 
	
	

	
	
		
		

	
	
</script>


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