<?php
error_reporting(0);
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	$SLCT_e = "SELECT  * FROM admin,login_details WHERE login_details.admin_id=admin.admin_id AND admin.admin_id= '$_SESSION[admin_login_id]'";	
	//echo $SLCT_e;
	$QURY_e = mysqli_query($connect,$SLCT_e);
	$FTCH_e = mysqli_fetch_object($QURY_e);
	$admin_id	=	$_SESSION['admin_login_id'];
	
	$check_acc  = check_access('53');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<title><?php echo $PROJECT_TITLE ?></title>
		<script type="text/javascript" src="js/statistics_JS.js"></script>
		<link href="css/styles.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.chosen.min.js"></script>
		<script type="text/javascript" src="js/files/bootstrap.js"></script>
		<script src="js/col_chart/highcharts.js"></script>
		<script src="js/col_chart/modules/exporting.js"></script>
		<script>
			$(document).ready(function(){
				$( ".datepicker" ).datepicker({ 
					defaultDate: +0,
					showOtherMonths:true,
					autoSize: true,
					appendText: '(dd/mm/yyyy)',
					dateFormat: 'dd/mm/yy',
					changeMonth: true,
			        changeYear: true
				});
			});
		</script>
		<style>
			.axisLabel {
			    position: absolute;
			    text-align: center;
			    font-size: 12px;
			    font-weight: bold;
			}

			.xaxisLabel {
			    bottom: -15px;
			    left: 0;
			    right: 0;
			}

			.yaxisLabel {
			    top: 155px;
			    left: -18px;
			    transform: rotate(-90deg);
			    -o-transform: rotate(-90deg);
			    -ms-transform: rotate(-90deg);
			    -moz-transform: rotate(-90deg);
			    -webkit-transform:  rotate(-90deg);
			    transform-origin: 0 0;
			    -o-transform-origin: 0 0;
			    -ms-transform-origin: 0 0;
			    -moz-transform-origin: 0 0;
			    -webkit-transform-origin: 0 0;
			    font-weight: bold;
			}
		</style>
		<script>
			function reload_page(ids)
			{
				window.location='statistics.php?chrt_yr='+ids;
			}
		</script>
		<!-- Shared on MafiaShare.net  --><!-- Shared on MafiaShare.net  -->
	</head>
	<body>
		<!-- Top line begins -->
		<?php include "header_footer/header.php"; ?>
		<!-- Top line ends -->
		<!-- Sidebar begins -->
		<?php include "menus/left_menu.php"; ?>
		<!-- Sidebar ends -->
		<!-- Content begins -->
		<div id="content">
			<?php include "menus/top_menu.php"; ?>    
    		<!-- Breadcrumbs line -->
    		<div class="breadLine">
				<?php include "menus/top_left_menu.php"; ?>
			</div>    
    		<!-- Main content -->
    		<div class="wrapper">
			<?php if($check_acc==1){?>
   				<?php
				if(isset($_GET['chrt_yr']) && $_GET['chrt_yr']!='')
				{
					$encde = $_GET['chrt_yr'];
					$chrt_yr = base64_decode(base64_decode(base64_decode(base64_decode($encde))));
					$dat_frm = date("Ym",strtotime($chrt_yr));
					$day_frm = date("m",strtotime($chrt_yr));
					$yer_frm = date("Y",strtotime($chrt_yr));
					
					$chrt_lbl = date("M Y",strtotime($chrt_yr));	
				}
				else
				{
					$chrt_lbl = date("M Y");
					$chrt_yr = date("F - Y");
					$encde = base64_encode(base64_encode(base64_encode(base64_encode($chrt_yr))));	
					$dat_frm = date("Ym",strtotime($chrt_yr));	
					$day_frm = date("m",strtotime($chrt_yr));	
					$yer_frm = date("Y",strtotime($chrt_yr));
				}
				if(isset($_GET['fdate']) && $_GET['fdate']!='' ){ $fdate = $_GET['fdate'];	}else{ $fdate = ''; }
				if(isset($_GET['todate']) && $_GET['todate']!='' ){ $todate = $_GET['todate'];	}else{ $todate = ''; }				
				if(isset($_GET['yea_r']) && $_GET['yea_r']!='' ){ $yea_r = 'checked="checked"'; $y_r = $_GET['yea_r'];}else{ $yea_r = ''; $y_r = '';}
				if(isset($_GET['mont_h']) && $_GET['mont_h']!='' ){ $mont_h = 'checked="checked"'; $m_h = $_GET['mont_h'];}else{ $mont_h = ''; $m_h = ''; }
				if(isset($_GET['da_y']) && $_GET['da_y']!='' ){ $da_y = 'checked="checked"'; $d_y = $_GET['da_y'];}else{ $da_y = ''; $d_y = ''; }

				if($admin_flagg==1)
				{
				?> 
					<div class="widget">
	        			<div class="formRow" >
							<table width="100%">
								<tr>
									<td width="9%" style="display:table-cell; vertical-align:middle;">From Date:</td>
									<td width="22%"><div class="grid6"><input type="text" name="fdate" id="fdate" value="<?php echo $fdate ?>" class="datepicker" /></div></td>
							        <td width="9%" style="display:table-cell; vertical-align:middle;">To Date:</td>
							        <td width="23%"><div class="grid6"><input type="text" name="todate" id="todate" value="<?php echo $todate ?>" class="datepicker" /></div></td>
							        <td width="10%" style="display:table-cell; vertical-align:middle;">Filter:</td>
							        <td width="8%"><input id="yea_r"  name="filter" type="checkbox" value="y" <?php echo $yea_r ?> /> <label for="yea_r">Year</label></td>
							        <td width="8%"><input id="mont_h" name="filter2" type="checkbox" value="m" <?php echo $mont_h ?> /> <label for="mont_h">Month</label></td>
							        <td width="11%"><input id="da_y" name="filter3" type="checkbox" value="d" <?php echo $da_y ?> /> <label for="da_y">Day</label></td>
					  			</tr>
							</table>
						</div>
					 	<div class="formRow">
					 		<input type="button" value="Submit" class="buttonM bBlack formSubmit" onclick="fom_validate();" style="float: right; margin-left:20px;"/>
         					<input type="button" value="Reset" class="buttonM bRed" style="float: right; margin-left:20px;" onclick="form_rest();"/>
        					<div class="clear"></div>
        				</div>
			       	</div>
			       	<?php
			       	if(isset($_GET['fdate']) && $_GET['fdate']!='' || isset($_GET['todate']) && $_GET['todate']!='')
					{ 						
					?>	
	                	<input type="hidden" value="<?php echo $_GET['fdate']; ?>" name="std" id="std" />
						<input type="hidden" value="<?php echo $_GET['todate']; ?>" name="edd" id="edd" />
						<input type="hidden" value="<?php echo $_GET['yea_r']; ?>" name="yr" id="yr" />
						<input type="hidden" value="<?php echo $_GET['mont_h']; ?>" name="mnt" id="mnt" />
						<input type="hidden" value="<?php echo $_GET['da_y']; ?>" name="dty" id="dty" />
						<input type="hidden" value="<?php echo $_GET['todate']; ?>" name="edd" id="edd" />
						<input type="hidden" value="" name="par_id" id="par_id" />
					<?php
						$billing_date = "bill_date"; 
						$collect_date = "ARD.received_date"; 
						$po_entry_dat = "PE.po_date";
						$po_finis_dat = "PF.post_dt";
						$po_deliv_dat = "PD.delivery_date";
						$dat_str_bill = ''; //THIS IS FOR QUERY STRING
						$dat_str_coll = '';	//THIS IS FOR QUERY STRING
						$dat_str_entr = ''; //THIS IS FOR QUERY STRING
						$dat_str_fnsh = '';	//THIS IS FOR QUERY STRING
						$dat_str_deli = ''; //THIS IS FOR QUERY STRING
						if($fdate!='' && $todate!='')
						{
							$dat_str_bill = " AND STR_TO_DATE(".$billing_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('".$todate."','%d/%m/%Y')";
							$dat_str_coll = " AND STR_TO_DATE(".$collect_date.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('".$todate."','%d/%m/%Y')";
							$dat_str_entr = " AND STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
							$dat_str_fnsh = " AND STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
							$dat_str_deli = " AND STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y') BETWEEN STR_TO_DATE('$fdate','%d/%m/%Y') AND STR_TO_DATE('".$todate."','%d/%m/%Y')";
							$flgg = 1;

							$frm_dt = str_replace('/', '-', $fdate);
							$to_dt = str_replace('/', '-', $todate);
						}
						else if($fdate=='' && $todate!='')
						{
							$vl = explode("/",$todate);

							if($yea_r!='' && $mont_h!='' && $da_y!='')
							{ 
								$dat_str_bill = " AND STR_TO_DATE(".$billing_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_coll = " AND STR_TO_DATE(".$collect_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')";
								$dat_str_entr = " AND STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_fnsh = " AND STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d') = STR_TO_DATE('".$todate."','%d/%m/%Y')";
								$dat_str_deli = " AND STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')";
								$flgg = 1;	

								$frm_dt = "01-".$vl[1]."-".$vl[2];
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							}
							else if($yea_r!='' && $mont_h!='' && $da_y=='')
							{
								$todat_vl = $vl[2]."-".$vl[1]."-".$vl[0]; 
							 	/*$dat_str_bill = " AND DATE_FORMAT(STR_TO_DATE(".$billing_date.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";  
								$dat_str_coll = " AND DATE_FORMAT(STR_TO_DATE(".$collect_date.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";  
								$dat_str_entr = " AND DATE_FORMAT(STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')"; 
								$dat_str_fnsh = " AND DATE_FORMAT(STR_TO_DATE(".$po_finis_dat.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";
								$dat_str_deli = " AND DATE_FORMAT(STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";*/  

								$dat_str_bill = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$billing_date.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$todate.",'%d/%m/%Y'))";  
								$dat_str_coll = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$collect_date.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$todate.",'%d/%m/%Y'))";  
								$dat_str_entr = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$todate.",'%d/%m/%Y'))";  
								$dat_str_fnsh = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$todate.",'%d/%m/%Y'))";  
								$dat_str_deli = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$todate.",'%d/%m/%Y'))";  

								$flgg = 1;	

								$frm_dt = "01-".$vl[1]."-".$vl[2];
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							}
							else if($yea_r!='' && $mont_h=='' && $da_y=='')
							{ 
								$todat_vl = ($vl[2]-1)."-12-31";
								$dat_str_bill = " AND YEAR(STR_TO_DATE(".$billing_date.",'%d-%m-%Y')) = YEAR(STR_TO_DATE('".$todate."','%d/%m/%Y'))";
								$dat_str_coll = " AND YEAR(STR_TO_DATE(".$collect_date.",'%d-%m-%Y')) = YEAR(STR_TO_DATE('".$todate."','%d/%m/%Y'))";
								$dat_str_entr = " AND YEAR(STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y')) = YEAR(STR_TO_DATE('".$todate."','%d/%m/%Y'))";
								$dat_str_fnsh = " AND YEAR(STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d')) = YEAR(STR_TO_DATE('".$todate."','%d/%m/%Y'))";
								$dat_str_deli = " AND YEAR(STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y')) = YEAR(STR_TO_DATE('".$todate."','%d/%m/%Y'))";
								$flgg = 1;

								$frm_dt = "01-01-".($vl[2]-1);
								$to_dt = "31-12-".($vl[2]-1);
							}
							else if($yea_r=='' && $mont_h=='' && $da_y=='')
							{ 
								$dat_str_bill = " AND STR_TO_DATE(".$billing_date.",'%d-%m-%Y') <= STR_TO_DATE('".$todate."','%d/%m/%Y')";
								$dat_str_coll = " AND STR_TO_DATE(".$collect_date.",'%d-%m-%Y') <= STR_TO_DATE('".$todate."','%d/%m/%Y')";
								$dat_str_entr = " AND STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y') <= STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_fnsh = " AND STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d') <= STR_TO_DATE('".$todate."','%d/%m/%Y')";
								$dat_str_deli = " AND STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y') <= STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$flgg = 0;
 
								$frm_dt = "01-04-2013";
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							} 
							else if($yea_r=='' && $mont_h!='' && $da_y=='')
							{ 
								$todat_vl = $vl[2]."-".$vl[1]."-".$vl[0];
								
								$dat_str_bill = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$billing_date.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE('".$todate."','%d/%m/%Y'))";  
								$dat_str_coll = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$collect_date.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE('".$todate."','%d/%m/%Y'))";  
								$dat_str_entr = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE('".$todate."','%d/%m/%Y'))";  
								$dat_str_fnsh = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE('".$todate."','%d/%m/%Y'))";  
								$dat_str_deli = " AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y')) = EXTRACT(YEAR_MONTH FROM STR_TO_DATE('".$todate."','%d/%m/%Y'))";

								/*$dat_str_bill = " AND DATE_FORMAT(STR_TO_DATE(".$billing_date.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";  
								$dat_str_coll = " AND DATE_FORMAT(STR_TO_DATE(".$collect_date.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";  
								$dat_str_entr = " AND DATE_FORMAT(STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";  
								$dat_str_fnsh = " AND DATE_FORMAT(STR_TO_DATE(".$po_finis_dat.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')";  
								$dat_str_deli = " AND DATE_FORMAT(STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y'),'%m-%Y') = DATE_FORMAT(STR_TO_DATE('".$todate."','%d/%m/%Y'),'%m-%Y')"; */ 
								$flgg = 1;
 
								$frm_dt = "01-".$vl[1]."-".$vl[2];
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							} 
							else if($yea_r=='' && $mont_h=='' && $da_y!='')
							{ 
								$dat_str_bill = " AND STR_TO_DATE(".$billing_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_coll = " AND STR_TO_DATE(".$collect_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 				
								$dat_str_entr = " AND STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_fnsh = " AND STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_deli = " AND STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$flgg = 1;
 
								$frm_dt = "01-".$vl[1]."-".$vl[2];
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							} 
							else if($yea_r!='' && $mont_h=='' && $da_y!='')
							{ 
								$dat_str_bill = " AND STR_TO_DATE(".$billing_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_coll = " AND STR_TO_DATE(".$collect_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 				
								$dat_str_entr = " AND STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_fnsh = " AND STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 				
								$dat_str_deli = " AND STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$flgg = 1;
								
								$frm_dt = "01-".$vl[1]."-".$vl[2];
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							} 
							else if($yea_r=='' && $mont_h!='' && $da_y!='')
							{ 
								$dat_str_bill = " AND STR_TO_DATE(".$billing_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_coll = " AND STR_TO_DATE(".$collect_date.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 				
								$dat_str_entr = " AND STR_TO_DATE(".$po_entry_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$dat_str_fnsh = " AND STR_TO_DATE(".$po_finis_dat.",'%Y-%m-%d') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 				
								$dat_str_deli = " AND STR_TO_DATE(".$po_deliv_dat.",'%d-%m-%Y') = STR_TO_DATE('".$todate."','%d/%m/%Y')"; 
								$flgg = 1;

								$frm_dt = "01-".$vl[1]."-".$vl[2];
								$to_dt = $vl[0]."-".$vl[1]."-".$vl[2];
							}
						}
						
						$i = date("Ym", strtotime($frm_dt));
						while($i <= date("Ym", strtotime($to_dt)))
						{
							$yr_mnth[] = $i;
							$v1 = str_split($i, 4);
							$mnth_nm[] = date("M Y", strtotime($v1[0]."-".$v1[1]."-01"));
						   	if(substr($i, 4, 2) == "12")
						   	{
						        $i = (date("Y", strtotime($i."01")) + 1)."01";
						   	}
						   	else
						   	{
						    	$i++;
						    }
						}
						$yrmnthArrayJSON = json_encode($yr_mnth);
						?>
						<div class="widget chartWrapper" style="overflow-x:scroll; overflow-y: hidden;">
				            <div class="whead">
				            	<h6>Orders Chart</h6>
				            	<div class="clear"></div>
				            </div>
				            <div id="container_orders" style="min-width: 310px; height: 400px; margin: 0 auto"></div> 
				        </div>
				        <div class="widget chartWrapper" style="overflow-x:scroll; overflow-y: hidden;">
				            <div class="whead">
				            	<h6>Accounts Chart</h6> 
				            	<div class="clear"></div>
				            </div>
				            <div id="container_accounts" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
				        </div>
		        <?php
		        	}
		        }
		        ?>
				
				<?php } else {  echo ACCESS_MSG;} ?>
	    		</div>
	    	<?php
	    		if(isset($_GET['fdate']) && $_GET['fdate']!='' || isset($_GET['todate']) && $_GET['todate']!='')
				{ 
		    		if($admin_flagg==1)
					{
						$rst_day = count($yr_mnth)-1;	
						// THE PO ENTRY OPERATION STARTS HERE 
			    		$ENTR_DET 		= 	'';
			    		$MSTR_PIEC_EN	= 	'0';
						$RSLT_ENTR_DI 	=	'0';
						$RSLT_ENTR_DS 	=	'0';
						$MNTH_ENTR_DIE  =	array();
						$MNTH_ENTR_DES  =   '';
						$MNTH_ENTR_KEY  =   '';
						$MNTH_ENTR_DET  =   '';
 
						$SLCT_ENTR = "SELECT GROUP_CONCAT(DISTINCT PE.party_det_id) AS par_id, GROUP_CONCAT(DISTINCT PE.po_entry_id) AS poe_id, GROUP_CONCAT(DISTINCT PE.po_no) AS poe_no, COUNT(PED.design_det_id) AS DES_CNT, EXTRACT(DAY FROM STR_TO_DATE(PE.po_date,'%d-%m-%Y')) AS DES_DAY, EXTRACT(MONTH FROM STR_TO_DATE(PE.po_date,'%d-%m-%Y')) AS DES_MONTH, EXTRACT(YEAR FROM STR_TO_DATE(PE.po_date,'%d-%m-%Y')) AS DES_YEAR, EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PE.po_date,'%d-%m-%Y')) AS DES_YEAR_MONTH FROM `po_entry` PE, po_entry_det PED WHERE PE.po_entry_id=PED.po_entry_id AND PED.cancelled='no' ".$dat_str_entr." GROUP BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PE.po_date,'%d-%m-%Y')) ORDER BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PE.po_date,'%d-%m-%Y')) ASC";
						$QURY_ENTR = mysqli_query($connect,$SLCT_ENTR);
						if(mysqli_num_rows($QURY_ENTR)>0)
						{ 
							while($FTCH_ENTR = mysqli_fetch_object($QURY_ENTR))
							{
								$party_expld = explode(",",$FTCH_ENTR->par_id);
								$poent_expld = explode(",",$FTCH_ENTR->poe_id);
								$poeno_expld = explode(",",$FTCH_ENTR->poe_no);
								foreach($poent_expld AS $key=>$value)
								{
									$SLCT_ENTR_DD 	= "SELECT CONCAT(PD.`party_code`,' - ',PD.`cmp_name`,' - ','$poeno_expld[$key]',' - ',COUNT(PED.design_det_id),' Designs - ',SUM(DD.master_pieces),' Dies<br>') AS entr_det, SUM(DD.master_pieces) AS MSTR_PIEC FROM `po_entry` PE, po_entry_det PED, party_det PD, design_det DD WHERE PE.po_entry_id=PED.po_entry_id AND PE.po_entry_id='$poent_expld[$key]' AND PED.cancelled='no' AND PE.party_det_id = PD.party_det_id AND DD.design_det_id=PED.design_det_id";
									$QURY_ENTR_DD 	= mysqli_query($connect,$SLCT_ENTR_DD);
									$FTCH_ENTR_DD 	= mysqli_fetch_object($QURY_ENTR_DD);
									$ENTR_DET  		= $ENTR_DET.$FTCH_ENTR_DD->entr_det;
									$MSTR_PIEC_EN	+= $FTCH_ENTR_DD->MSTR_PIEC;
								}
								$MNTH_ENTR_DES[$FTCH_ENTR->DES_YEAR_MONTH] = $FTCH_ENTR->DES_CNT;
								$MNTH_ENTR_DIE[$FTCH_ENTR->DES_YEAR_MONTH] = $MSTR_PIEC_EN;
								$MNTH_ENTR_KEY[] = $FTCH_ENTR->DES_YEAR_MONTH;
								$MNTH_ENTR_DET[$FTCH_ENTR->DES_YEAR_MONTH] = trim($ENTR_DET,'<br>');
								$ENTR_DET ='';
								$MSTR_PIEC_EN = '0';
							}
						}
						if(count($MNTH_ENTR_DIE)>=1 && $MNTH_ENTR_DIE!='')
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$arr_val_entr = $yr_mnth[$lop];
								if(in_array($arr_val_entr, $MNTH_ENTR_KEY))
								{
									$ENTR_DES_CNT[] 	= $MNTH_ENTR_DES[$arr_val_entr];
									$ENTR_DIE_CNT[] 	= $MNTH_ENTR_DIE[$arr_val_entr];
								}
								else
								{
									$ENTR_DES_CNT[] 	= '0';
									$ENTR_DIE_CNT[]  	= '0';
								}
							}
							$MAX_ENTR = max($MNTH_ENTR_DIE);
						}
						else
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$ENTR_DES_CNT[] 	= '0';
								$ENTR_DIE_CNT[]  	= '0';
							}
							$MAX_ENTR = 0; 
						}
						// THE PO ENTRY OPERATION ENDS HERE 
 
						// THE PO FINISH OPERATION STARTS HERE 
 
						$FNSH_DET 		= 	'';
			    		$MSTR_PIEC_FN	= 	'0';
						$RSLT_FNSH_DI 	=	'0';
						$RSLT_FNSH_DS 	=	'0';
						$MNTH_FNSH_DIE	=	array();
						$MNTH_FNSH_DES  =   '';
						$MNTH_FNSH_KEY  =   '';
						$MNTH_FNSH_DET  =   '';
 
						$SLCT_FNSH = "SELECT GROUP_CONCAT(DISTINCT PED.po_entry_id) AS poe_id, COUNT(PED.design_det_id) AS DES_CNT, EXTRACT(DAY FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d')) AS DES_DAY, EXTRACT(MONTH FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d')) AS DES_MONTH, EXTRACT(YEAR FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d')) AS DES_YEAR, EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d')) AS DES_YEAR_MONTH,  SUM(master_pieces) AS MSTR_PIEC FROM `po_finish` PF, po_entry_det PED, design_det DD, po_entry PE WHERE PE.po_entry_id=PED.po_entry_id AND PED.fin_status='yes' AND PED.cancelled='no' AND PF.po_entry_det_id=PED.po_entry_det_id AND DD.design_det_id = PED.design_det_id ".$dat_str_fnsh." GROUP BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d')) ORDER BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d')) ASC";
						$QURY_FNSH = mysqli_query($connect,$SLCT_FNSH);
						$loop=1;
						if(mysqli_num_rows($QURY_FNSH)>0)
						{
							while($FTCH_FNSH = mysqli_fetch_object($QURY_FNSH))
							{
								$poent_expld = explode(",",$FTCH_FNSH->poe_id);
								foreach($poent_expld AS $key=>$value)
								{
									//$SLCT_FNSH_DD 	= "SELECT CONCAT(PD.`party_code`,' - ',PD.`cmp_name`,' - ','$poeno_expld[$key]',' - ',COUNT(PED.design_det_id),' Designs - ',SUM(DD.master_pieces),' Dies<br>') AS fnsh_det, SUM(DD.master_pieces) AS MSTR_PIEC FROM `po_finish` PF,`po_entry` PE, po_entry_det PED, party_det PD, design_det DD WHERE PE.po_entry_id=PED.po_entry_id AND PF.po_entry_det_id=PED.po_entry_det_id AND PE.po_entry_id='$poent_expld[$key]' AND PED.cancelled='no' AND PED.fin_status='yes' AND PE.party_det_id = PD.party_det_id AND DD.design_det_id=PED.design_det_id";
									$SLCT_FNSH_DD 	= "SELECT PD.`party_code`,PD.`cmp_name`,PE.po_no FROM `po_entry` PE, party_det PD WHERE PE.po_entry_id='$poent_expld[$key]' AND PE.party_det_id = PD.party_det_id ";
									$QURY_FNSH_DD 	= mysqli_query($connect,$SLCT_FNSH_DD);
									$FTCH_FNSH_DD 	= mysqli_fetch_object($QURY_FNSH_DD);

									$SLCT_FNSH_DD2 	= "SELECT CONCAT('$FTCH_FNSH_DD->party_code',' - ','$FTCH_FNSH_DD->cmp_name',' - ','$FTCH_FNSH_DD->po_no',' - ',COUNT( PF.design_det_id ),' Designs - ',SUM( master_pieces ),' Dies<br>') AS fnsh_det, SUM( master_pieces ) AS MSTR_PIEC FROM `po_finish` PF, po_entry_det PED, design_det DD, po_entry PE WHERE PE.po_entry_id = PED.po_entry_id AND PED.fin_status='yes' AND PED.cancelled='no' PF.`po_entry_det_id` = PED.`po_entry_det_id` AND PED.po_entry_id='$poent_expld[$key]' AND DD.design_det_id = PED.design_det_id AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PF.post_dt,'%Y-%m-%d'))='$FTCH_FNSH->DES_YEAR_MONTH' ".$dat_str_fnsh." GROUP BY STR_TO_DATE(PF.post_dt,'%Y-%m-%d') ORDER BY STR_TO_DATE(PF.post_dt,'%Y-%m-%d') ASC";
									$QURY_FNSH_DD2 	= mysqli_query($connect,$SLCT_FNSH_DD2);
									$FTCH_FNSH_DD2 	= mysqli_fetch_object($QURY_FNSH_DD2);
									$FNSH_DET  		= $FNSH_DET.$FTCH_FNSH_DD2->fnsh_det; 
									$MSTR_PIEC_FN	+= $FTCH_FNSH_DD2->MSTR_PIEC;
								}
								$MNTH_FNSH_DES[$FTCH_FNSH->DES_YEAR_MONTH] = $FTCH_FNSH->DES_CNT;
								$MNTH_FNSH_DIE[$FTCH_FNSH->DES_YEAR_MONTH] = $FTCH_FNSH->MSTR_PIEC;
								$MNTH_FNSH_KEY[] = $FTCH_FNSH->DES_YEAR_MONTH;
								$MNTH_FNSH_DET[$FTCH_FNSH->DES_YEAR_MONTH] = trim($FNSH_DET,'<br>');
								$FNSH_DET ='';
								$MSTR_PIEC_FN = '0';
							}
						}
						if(count($MNTH_FNSH_DIE)>=1 && $MNTH_FNSH_DIE!='')
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$arr_val_fnsh = $yr_mnth[$lop];
								if(in_array($arr_val_fnsh, $MNTH_FNSH_KEY))
								{
									$FNSH_DES_CNT[] 	= $MNTH_FNSH_DES[$arr_val_fnsh];
									$FNSH_DIE_CNT[] 	= $MNTH_FNSH_DIE[$arr_val_fnsh];
								}
								else
								{
									$FNSH_DES_CNT[] 	= '0';
									$FNSH_DIE_CNT[]  	= '0';
								}
							}
							$MAX_FNSH = max($MNTH_FNSH_DIE); 
						}
						else
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$FNSH_DES_CNT[] 	= '0';
								$FNSH_DIE_CNT[]  	= '0';
							}
							$MAX_FNSH = 0;
						}
						// THE PO FINISH OPERATION ENDS HERE 

						// THE PO DELIVERY OPERATION STARTS HERE 

			    		$DELI_DET 		= 	'';
			    		$MSTR_PIEC_DL	= 	'0';
						$RSLT_DELI_DI 	=	'0';
						$RSLT_DELI_DS 	=	'0';
						$MNTH_DELI_DIE	=	'';
						$MNTH_DELI_DES  =   '';
						$MNTH_DELI_KEY  =   '';
						$MNTH_DEL_DET  =   '';
 
						$SLCT_DELI = "SELECT GROUP_CONCAT(DISTINCT PE.party_det_id) AS par_id, GROUP_CONCAT(DISTINCT PE.po_entry_id) AS poe_id, GROUP_CONCAT(DISTINCT PE.po_no) AS poe_no, COUNT(PDD.design_det_id) AS DES_CNT, EXTRACT(DAY FROM STR_TO_DATE(PD.delivery_date,'%d-%m-%Y')) AS DES_DAY, EXTRACT(MONTH FROM STR_TO_DATE(PD.delivery_date,'%d-%m-%Y')) AS DES_MONTH, EXTRACT(YEAR FROM STR_TO_DATE(PD.delivery_date,'%d-%m-%Y')) AS DES_YEAR, EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PD.delivery_date,'%d-%m-%Y')) AS DES_YEAR_MONTH, SUM(master_pieces) AS MSTR_PIEC FROM `po_entry` PE, `po_delivery` PD, po_delivery_det PDD, design_det DD WHERE DD.design_det_id = PDD.design_det_id AND PE.po_entry_id=PD.po_entry_id AND PD.po_delivery_id=PDD.po_delivery_id AND PDD.cancelled='no' ".$dat_str_deli." GROUP BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PD.delivery_date,'%d-%m-%Y')) ORDER BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(PD.delivery_date,'%d-%m-%Y')) ASC";
						$QURY_DELI = mysqli_query($connect,$SLCT_DELI);
						if(mysqli_num_rows($QURY_DELI)>0)
						{ 
							while($FTCH_DELI = mysqli_fetch_object($QURY_DELI))
							{
								$party_expld = explode(",",$FTCH_DELI->par_id);
								$poent_expld = explode(",",$FTCH_DELI->poe_id);
								$poeno_expld = explode(",",$FTCH_DELI->poe_no);
								foreach($party_expld AS $key=>$value)
								{
									$SLCT_DELI_DD1 	= "SELECT PD.`party_code`,PD.`cmp_name`,PE.po_no FROM `po_entry` PE, party_det PD WHERE PE.po_entry_id='$poent_expld[$key]' AND PE.party_det_id = PD.party_det_id ";
									$QURY_DELI_DD1 	= mysqli_query($connect,$SLCT_DELI_DD1);
									$FTCH_DELI_DD1 	= mysqli_fetch_object($QURY_DELI_DD1);

									$SLCT_DELI_DD 	= "SELECT CONCAT('$FTCH_FNSH_DD->party_code',' - ','$FTCH_FNSH_DD->cmp_name',' - ','$FTCH_FNSH_DD->po_no',' - ',COUNT( PDD.design_det_id ),' Designs - ',SUM( master_pieces ),' Dies<br>') AS deli_det, SUM(DD.master_pieces) AS MSTR_PIEC FROM `po_entry` PE, `po_delivery` PD, po_delivery_det PDD, design_det DD WHERE DD.design_det_id = PDD.design_det_id AND PE.po_entry_id=PD.po_entry_id AND PD.po_delivery_id=PDD.po_delivery_id AND PDD.cancelled='no' AND PE.po_entry_id='$poent_expld[$key]' AND EXTRACT(YEAR_MONTH FROM STR_TO_DATE(POD.delivery_date,'%d-%m-%Y'))='$FTCH_DELI->DES_YEAR_MONTH'";
									$QURY_DELI_DD 	= mysqli_query($connect,$SLCT_DELI_DD);
									$FTCH_DELI_DD 	= mysqli_fetch_object($QURY_DELI_DD);
									$DELI_DET = $DELI_DET.$FTCH_DELI_DD->deli_det;
									//$MSTR_PIEC_DL	+= $FTCH_DELI_DD->MSTR_PIEC;
								}
								$MSTR_PIEC_DL	+= $FTCH_DELI->MSTR_PIEC;
								$MNTH_DELI_DES[$FTCH_DELI->DES_YEAR_MONTH] = $FTCH_DELI->DES_CNT;
								$MNTH_DELI_DIE[$FTCH_DELI->DES_YEAR_MONTH] = $MSTR_PIEC_DL;
								$MNTH_DELI_KEY[] = $FTCH_DELI->DES_YEAR_MONTH;
								$MNTH_DELI_DET[$FTCH_DELI->DES_YEAR_MONTH] = trim($DELI_DET,'<br>');
								$DELI_DET ='';
								$MSTR_PIEC_DL = '0';
							}
						}
						if(count($MNTH_DELI_DIE)>=1 && $MNTH_DELI_DIE!='')
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$arr_val_deli = $yr_mnth[$lop];
								if(in_array($arr_val_deli, $MNTH_DELI_KEY))
								{
									$DELI_DES_CNT[] 	= $MNTH_DELI_DES[$arr_val_deli];
									$DELI_DIE_CNT[] 	= $MNTH_DELI_DIE[$arr_val_deli];
								}
								else
								{
									$DELI_DES_CNT[] 	= '0';
									$DELI_DIE_CNT[]  	= '0';
								}
							}
							$MAX_DELI = max($MNTH_DELI_DIE);
						}
						else
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$DELI_DES_CNT[] 	= '0';
								$DELI_DIE_CNT[]  	= '0';
							}
							$MAX_DELI = 0;
						}

			    		// THE PO DELIVERY OPERATION ENDS HERE 

			    		// THE BILLING OPERATION STARTS HERE 	    	

				    	$MNTH_BILL = '';
				    	$MNTH_BILL_KEY = '';
				    	$MNTH_BILL_DET = '';
				    	$RSLT_BILL = '';
				    	$RSLT_BILL_DI = 0;
				    	$RSLT_BILL_DET = '';
				    	$RSLT_BILL_AMT = '';
				    	$tot_day = cal_days_in_month(CAL_GREGORIAN,$day_frm,$yer_frm);
				    	$SLCT_BILL = "SELECT GROUP_CONCAT(CONCAT(`party_code`,' / ',`cmp_name`,' - ',`bill_no`,' - Rs. ',`bill_amt`) SEPARATOR '<br>') AS bill_det,SUM(bill_amt) AS bill_amt, EXTRACT(DAY FROM STR_TO_DATE(bill_date,'%d-%m-%Y')) AS bill_day, EXTRACT(MONTH FROM STR_TO_DATE(bill_date,'%d-%m-%Y')) AS bill_month, EXTRACT(YEAR FROM STR_TO_DATE(bill_date,'%d-%m-%Y')) AS bill_year, EXTRACT(YEAR_MONTH FROM STR_TO_DATE(bill_date,'%d-%m-%Y')) AS bill_year_month FROM `billing_det`,`party_det` WHERE party_det.party_det_id = `billing_det`.party_det_id ".$dat_str_bill." GROUP BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(bill_date,'%d-%m-%Y')) ORDER BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(bill_date,'%d-%m-%Y')) ASC";
						$QURY_BILL = mysqli_query($connect,$SLCT_BILL);
						if(mysqli_num_rows($QURY_BILL)>0)
						{
							while($FTCH_BILL = mysqli_fetch_object($QURY_BILL))
							{
								$MNTH_BILL[$FTCH_BILL->bill_year_month] = $FTCH_BILL->bill_amt;
								$MNTH_BILL_KEY[] = $FTCH_BILL->bill_year_month;
								$MNTH_BILL_DET[$FTCH_BILL->bill_year_month] = trim($FTCH_BILL->bill_det,'<br>');
							}
						}
						if(count($MNTH_BILL)>=1 && $MNTH_BILL!='')
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$arr_val_bill = $yr_mnth[$lop];
								if(in_array($arr_val_bill, $MNTH_BILL_KEY))
								{
									$RSLT_BILL_AMT[] = $MNTH_BILL[$arr_val_bill];
								}
								else
								{
									$RSLT_BILL_AMT[] = '0';
								}
							}
							$MAX_BILL = max($MNTH_BILL);
						}
						else
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$RSLT_BILL_AMT[] = '0';
							}
							$MAX_BILL = 0; 
						}
						// THE BILLING OPERATION ENDS HERE 

						// THE COLLECTION OPERATION STARTS HERE 

						$MNTH_COLL = '';
				    	$MNTH_COLL_KEY = '';
				    	$MNTH_COLL_DET = '';
				    	$RSLT_COLL = '';
				    	$RSLT_COLL_DI = 0;
				    	$RSLT_COLL_DET = '';
				    	$RSLT_COLL_AMT = '';
						$SLCT_COLL = "SELECT GROUP_CONCAT(CONCAT(PD.`party_code`,' / ',PD.`cmp_name` ,' - Rs. ', ARD.`received_amt`) SEPARATOR '<br>') AS coll_det, SUM(ARD.`received_amt`) AS received_amt, EXTRACT(DAY FROM STR_TO_DATE(ARD.`received_date`,'%d-%m-%Y')) AS received_day, EXTRACT(MONTH FROM STR_TO_DATE(ARD.`received_date`,'%d-%m-%Y')) AS received_month, EXTRACT(YEAR FROM STR_TO_DATE(ARD.`received_date`,'%d-%m-%Y')) AS received_year, EXTRACT(YEAR_MONTH FROM STR_TO_DATE(ARD.`received_date`,'%d-%m-%Y')) AS received_year_month FROM `ac_received_det` ARD, `ac_party_det` APD, `party_det` PD WHERE APD.`ac_party_det_id`=ARD.`ac_party_det_id` AND APD.`party_det_id`=PD.`party_det_id` ".$dat_str_coll." GROUP BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(ARD.`received_date`,'%d-%m-%Y')) ORDER BY EXTRACT(YEAR_MONTH FROM STR_TO_DATE(ARD.`received_date`,'%d-%m-%Y')) ASC";
						$QURY_COLL = mysqli_query($connect,$SLCT_COLL);
						if(mysqli_num_rows($QURY_COLL)>0)
						{			
							while($FTCH_COLL = mysqli_fetch_object($QURY_COLL))
							{
								$MNTH_COLL[$FTCH_COLL->received_year_month] = $FTCH_COLL->received_amt;
								$MNTH_COLL_KEY[] = $FTCH_COLL->received_year_month;
								$MNTH_COLL_DET[$FTCH_COLL->received_year_month] = trim($FTCH_COLL->coll_det,'<br>');
							}
						}
						if(count($MNTH_COLL)>=1 && $MNTH_COLL!='')
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$arr_val_coll = $yr_mnth[$lop];
								if(in_array($arr_val_coll, $MNTH_COLL_KEY))
								{
									$RSLT_COLL_AMT[] = $MNTH_COLL[$arr_val_coll];
								}
								else
								{
									$RSLT_COLL_AMT[] = '0';
								}
							}
							$MAX_COLL = max($MNTH_COLL);
						}
						else
						{
							for($lop=0;$lop<=$rst_day;$lop++)
							{
								$RSLT_COLL_AMT[] = '0';
							}
							$MAX_COLL = 0;
						}

						// THE COLLECTION OPERATION ENDS HERE 

						$ENTR_STR = implode(",",$ENTR_DIE_CNT);
						$FNSH_STR = implode(",",$FNSH_DIE_CNT);
						$DELI_STR = implode(",",$DELI_DIE_CNT);
						$BILL_STR = implode(",",$RSLT_BILL_AMT);
						$COLL_STR = implode(",",$RSLT_COLL_AMT);
						$MNTH_STR = "'".implode("', '",$mnth_nm)."'";
					}
				}
		    ?>
	    </div>
	    <?php 
	    if(isset($_GET['fdate']) && $_GET['fdate']!='' || isset($_GET['todate']) && $_GET['todate']!='')
		{ 
		    if($admin_flagg==1)
			{
		?>
			    <script>
					$(function () {

						 // THE PO ENTRY, PO FINISH AND PO DELIVERY CHART OPERATION STARTS HERE 
					    $('#container_orders').highcharts({
					        chart: {
					            type: 'column'
					        },
					        title: {
					            text: 'Monthly Order Status'
					        },
					        subtitle: {
					            text: '<?php echo date("d/m/Y",strtotime($frm_dt))." - ".date("d/m/Y",strtotime($to_dt)) ?>'
					        },
					        xAxis: {
					            categories: [<?php echo $MNTH_STR; ?>],
					            crosshair: true
					        },
					        yAxis: {
					            min: 0,
					            title: {
					                text: 'Die Quantity'
					            }
					        },
					        tooltip: {
					            headerFormat: '<span align="center" style="font-size:15px; text-align:center;"><b>{point.key}</b></span><table>',
					            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
					                '<td style="padding:0"><b>{point.y} Qty</b></td></tr>',
					            footerFormat: '</table>',
					            shared: true,
					            useHTML: true
					        },
					        plotOptions: {
					            column: {
					                pointPadding: 0.2,
					                borderWidth: 0
					            }
					        },
					        series: [{
					            name: 'Po Entry',
					            data: [<?php echo $ENTR_STR; ?>]

					        }, {
					            name: 'PO Finish',
					            data: [<?php echo $FNSH_STR; ?>]

					        }, {
					            name: 'PO Delivery',
					            data: [<?php echo $DELI_STR; ?>]

					        }]
					    });
					    // THE PO ENTRY, PO FINISH AND PO DELIVERY CHART OPERATION ENDS HERE 

					    // THE COLLECTION AND BILLING CHART OPERATION STARTS HERE 

					    $('#container_accounts').highcharts({
					        chart: {
					            type: 'column'
					        },
					        title: {
					            text: 'Monthly Accounts Status'
					        },
					        subtitle: {
					            text: '<?php echo date("d/m/Y",strtotime($frm_dt))." - ".date("d/m/Y",strtotime($to_dt)) ?>'
					        },
					        xAxis: {
					            categories: [<?php echo $MNTH_STR; ?>],
					            crosshair: true
					        },
					        yAxis: {
					            min: 0,
					            title: {
					                text: 'Rupees in INR'
					            }
					        },
					        tooltip: {
					            headerFormat: '<span align="center" style="font-size:15px; text-align:center;"><b>{point.key}</b></span><table>',
					            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
					                '<td style="padding:0"><b>Rs. {point.y:.1f}</b></td></tr>',
					            footerFormat: '</table>',
					            shared: true,
					            useHTML: true
					        },
					        plotOptions: {
					            column: {
					                pointPadding: 0.2,
					                borderWidth: 0
					            }
					        },
					        series: [{
					            name: 'Billing',
					            data: [<?php echo $BILL_STR; ?>]

					        }, {
					            name: 'Collection',
					            data: [<?php echo $COLL_STR; ?>]

					        }]
					    });
					    // THE COLLECTION AND BILLING CHART OPERATION ENDS HERE 
					});	
				</script>
	   	<?php
	   		}
	   	}
	   	?> 
	    <!-- Main content ends -->
		<!-- Content ends -->
	</body>
</html>
