<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	
	$get_party_id = base64_decode(base64_decode(base64_decode($_GET['party_id'])));
	
	$SLCT_FIND_party_Addrs = "SELECT * FROM party_det WHERE party_det_id = '$get_party_id'";
	$QURY_FIND_party_Addrs = mysqli_query($connect,$SLCT_FIND_party_Addrs);
	$FTCH_FIND_party_Addrs = mysqli_fetch_object($QURY_FIND_party_Addrs);
	
	$party_STATE 	= $FTCH_FIND_party_Addrs->com_master_state_id;
	$party_CNTRY 	= $FTCH_FIND_party_Addrs->com_master_country_id;
	$cour_charges 	= $FTCH_FIND_party_Addrs->cour_charges;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://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/billing_add_JS.js"></script>
		<script type="text/javascript" src="js/cnt_chkbox_JS.js"></script>
		<script type="text/javascript" src="js/toword.js"></script><!--var words = toWords(num);-->
		<link href="css/styles.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="css/fonts/rupyaINR.min.css">		
		<!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
		<script src="css/fonts/rupyaINR.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="js/plugins/forms/ui.spinner.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.mousewheel.js"></script> 
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
		<script type="text/javascript" src="js/plugins/charts/excanvas.min.js"></script>
		<script type="text/javascript" src="js/plugins/charts/jquery.flot.js"></script>
		<script type="text/javascript" src="js/plugins/charts/jquery.flot.orderBars.js"></script>
		<script type="text/javascript" src="js/plugins/charts/jquery.flot.pie.js"></script>
		<script type="text/javascript" src="js/plugins/charts/jquery.flot.resize.js"></script>
		<script type="text/javascript" src="js/plugins/charts/jquery.sparkline.min.js"></script>
		<script type="text/javascript" src="js/plugins/tables/jquery.dataTables1.js"></script>
		<script type="text/javascript" src="js/plugins/tables/jquery.sortable.js"></script>
		<script type="text/javascript" src="js/plugins/tables/jquery.resizable.js"></script>
		<script type="text/javascript" src="js/plugins/forms/autogrowtextarea.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.uniform.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.inputlimiter.min.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.tagsinput.min.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.maskedinput.min.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.autotab.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.chosen.min.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.dualListBox.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.cleditor.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.ibutton.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.validationEngine-en.js"></script>
		<script type="text/javascript" src="js/plugins/forms/jquery.validationEngine.js"></script>
		<script type="text/javascript" src="js/plugins/uploader/plupload.js"></script>
		<script type="text/javascript" src="js/plugins/uploader/plupload.html4.js"></script>
		<script type="text/javascript" src="js/plugins/uploader/plupload.html5.js"></script>
		<script type="text/javascript" src="js/plugins/uploader/jquery.plupload.queue.js"></script>
		<script type="text/javascript" src="js/plugins/wizards/jquery.form.wizard.js"></script>
		<script type="text/javascript" src="js/plugins/wizards/jquery.validate.js"></script>
		<script type="text/javascript" src="js/plugins/wizards/jquery.form.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.collapsible.min.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.breadcrumbs.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.tipsy.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.progress.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.timeentry.min.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.colorpicker.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.jgrowl.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.fancybox.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.fileTree.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.sourcerer.js"></script>
		<script type="text/javascript" src="js/plugins/others/jquery.fullcalendar.js"></script>
		<script type="text/javascript" src="js/plugins/others/jquery.elfinder.js"></script>
		<script type="text/javascript" src="js/plugins/ui/jquery.easytabs.min.js"></script>
		<script type="text/javascript" src="js/files/bootstrap.js"></script>
		<script type="text/javascript" src="js/files/functions.js"></script>
		<script type="text/javascript" src="js/charts/chart.js"></script>
		<script type="text/javascript" src="js/charts/hBar_side.js"></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">
        		<div class="bc">
            		<ul id="breadcrumbs" class="breadcrumbs">
                		<li><a href="home.php">Dashboard</a></li>
                		<li><a href="javascript:">Billing</a></li>                    
            		</ul>
        		</div>
				<?php include "menus/top_left_menu.php"; ?>   
    		</div>    
			<!-- Main content -->
			<div class="wrapper">
				<ul class="middleNavR">
					<!--<li><a href="#" title="Add an article" class="tipN"><img src="images/icons/middlenav/create.png" alt="" /></a></li>
					<li><a href="#" title="Upload files" class="tipN"><img src="images/icons/middlenav/upload.png" alt="" /></a></li>-->  
					<!--<li><a href="design_add.php" title="Add Design" class="tipN"><img src="images/icons/middlenav/add.png" alt="" /></a></li>-->
					<!--<li><a href="#" title="Messages" class="tipN"><img src="images/icons/middlenav/dialogs.png" alt="" /></a><strong>8</strong></li>-->
					<li><a href="billing_list.php" title="List Bills" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
				</ul>            
  				<?php		
					if(isset($_GET['biltype_id']))
					{
						$biltype_id = $_GET['biltype_id'];
					}
					else
					{
						$biltype_id = '';
					}					
					if(isset($_GET['party_id']))
					{
						$party_url = $_GET['party_id'];
					}
					else
					{
						$party_url = '';
					}
					if(isset($_GET['po_id']))
					{
						$po_id = $_GET['po_id'];
						$po_ar = explode(',',$po_id);
						$i=0;
						foreach($po_ar as $a) //this is for unset the empty index value
						{
							if( !empty($a) AND $a != '')
							{
								$po_ar_tmp = explode('-',$a);
								$pp_ids[$i] = $po_ar_tmp[0];
								$po_dl_ids[$i] = $po_ar_tmp[1];
								$i++;
							}
						}						
					}
					else
					{
						$pp_ids = '';
						$po_dl_ids = '';
					}
					$SLCT_bl_ck = "SELECT bill_no FROM billing_det ORDER BY billing_det_id DESC";
					$QURY_bl_ck = mysqli_query($connect,$SLCT_bl_ck);
					$FTCH_bl_ck = mysqli_fetch_object($QURY_bl_ck);
					$bilno 		= explode("/",$FTCH_bl_ck->bill_no);		
					if(date("m")<4)
					{
//						$auto_bill = "SA/".(date("y")-1)."-".date("y")."/".str_pad(($bilno[2]+1),4,'0',STR_PAD_LEFT);
						$auto_bill = "GST/".(date("y")-1)."-".date("y")."/".str_pad(($bilno[2]+1),4,'0',STR_PAD_LEFT);
					}	
					else if(date("m")>3)
					{
//						$auto_bill = "SA/".date("y")."-".(date("y")+1)."/".str_pad(($bilno[2]+1),4,'0',STR_PAD_LEFT);
						$auto_bill = "GST/".date("y")."-".(date("y")+1)."/".str_pad(($bilno[2]+1),4,'0',STR_PAD_LEFT);
					}	
					$bill_yr_id='';		 
					$max_id = '';
					$bll_aut_no = '';
					if($biltype_id == 1)
					{
						$cur_yr = '';
						$to_yr = '';						
						$mnth = date("n",strtotime($cur_date));
						$yr = date("y",strtotime($cur_date));
													
						$SLCT_bl_ck = "SELECT * FROM billing_det ORDER BY billing_det_id ASC";
						$QURY_bl_ck = mysqli_query($connect,$SLCT_bl_ck);
						if(mysqli_num_rows($QURY_bl_ck)> 0)
						{
							$FTCH_bl_ck = mysqli_fetch_object($QURY_bl_ck);								
							if($mnth < 4)
							{
								$cur_yr = $yr - 1;
								$to_yr =  $yr;	
															
								$SLCT_bil_yr = "SELECT * FROM `billing_yr` WHERE `frm_yr` = '$cur_yr' AND `to_yr` = '$to_yr' AND statu_s = 'active'";
								$QURY_bil_yr = mysqli_query($connect,$SLCT_bil_yr);
								$FTCH_bil_yr = mysqli_fetch_object($QURY_bil_yr);
								$bill_yr_id = $FTCH_bil_yr->bill_yr_no;
								
								$SLCT_sk = "SELECT COUNT(billing_det_id) as max_ids FROM billing_det WHERE bill_yr_no = '$bill_yr_id' AND bill_type = 'Non Tax' ORDER BY billing_det_id ASC";
								$QURY_sk = mysqli_query($connect,$SLCT_sk);  
								$FTCH_sk = mysqli_fetch_object($QURY_sk); 
								$max_id = $FTCH_sk->max_ids + 1;					
							}
							else if($mnth >= 4)
							{
								$cur_yr = $yr;
								$to_yr =  $yr + 1;
								
								$SLCT_bil_yr = "SELECT * FROM `billing_yr` WHERE `frm_yr` = '$cur_yr' AND `to_yr` = '$to_yr' AND statu_s = 'active'";
								$QURY_bil_yr = mysqli_query($connect,$SLCT_bil_yr);
								$FTCH_bil_yr = mysqli_fetch_object($QURY_bil_yr);
								$bill_yr_id = $FTCH_bil_yr->bill_yr_no;
								
								$SLCT_sk = "SELECT COUNT(billing_det_id) as max_ids FROM billing_det WHERE bill_yr_no = '$bill_yr_id' AND bill_type = 'Non Tax' ORDER BY billing_det_id ASC";
								$QURY_sk = mysqli_query($connect,$SLCT_sk);  
								$FTCH_sk = mysqli_fetch_object($QURY_sk);
								if($FTCH_sk->max_ids > 0){ $max_id = $FTCH_sk->max_ids + 1; }else{ $max_id = 1; }
							}				
						}
						else
						{
							if($mnth < 4)
							{
								$cur_yr = $yr - 1;
								$to_yr =  $yr;												
							}
							else if($mnth >= 4)
							{
								$cur_yr = $yr;
								$to_yr =  $yr + 1;
							}
							$max_id = 1;
							$bill_yr_id = 1;
						}
						//$bll_aut_no = "SA/".$cur_yr."-".$to_yr."/"."%04d".$max_id;
					}			 
				?>
				<!-- Chart --><!-- 6 + 6 -->
				<form id="validate" name="checklist" class="main" method="post" action="bl/billing_BL.php" onsubmit="checkTheBox();"><!--bl/billing_BL.php-->
					<fieldset>
						<div class="fluid">
							<div class="widget">
								<input type="hidden" name="bill_yr_no" id="bill_yr_no" value="<?php echo $bill_yr_id; ?>" />
								<div class="formRow">
									<div class="grid3"><label>Bill Type :</label> </div>
										<div class="grid9" style="margin-left:-50px;">
											<?php
												if($biltype_id==''){ $chumma1 = 'checked="checked"'; }else{ $chumma1 = ''; } 
												if($biltype_id=="1"){ $chumma1 = 'checked="checked"'; }else{ $chumma1 = ''; } 
												if($biltype_id=="2"){ $chumma2 = 'checked="checked"'; }else{ $chumma2 = 'checked="checked"'; } 
											?>
											<input type="radio" name="biltype" onclick="hid_bils(1)"  id="biltype1" value="1" <?php echo $chumma1; ?>  /><label for="radio1"  class="mr20">Non Tax</label>
											<input type="radio" name="biltype" onclick="hid_bils(2)" id="biltype2" value="2"  <?php echo $chumma2; ?>/><label for="radio1"  class="mr20">Tax</label>
											<input type="hidden" name="cnt_typ" id="cnt_typ" value="3" />
										</div>
										<div class="clear"></div>
									</div>
									<div class="formRow">
							            <div class="grid2"><label>Party Code:<span class="req">*</span></label></div>
							            <div class="grid4 searchDrop">
							                <select data-placeholder="Choose Party Code..." class="select" name="co_cod" id="co_cod" onchange="reload_po_lst()" style="width:350px;" tabindex="2">
							                    <option value=""></option>
							                    <?php
							                    $SLCT_E = "SELECT  * FROM party_det ORDER BY party_det_id ASC"; //HERE THE 1 IS REPRESENTS CAD DESIGNER ID 
							                    $QURY_E = mysqli_query($connect,$SLCT_E);
							                    while($FTCH_E = mysqli_fetch_object($QURY_E))
							                    {
													$SLCT_ppo = "SELECT * FROM po_entry,po_entry_det WHERE po_entry.party_det_id = '$FTCH_E->party_det_id' AND po_entry_det.po_entry_id = po_entry.po_entry_id AND po_entry_det.del_status = 'yes' AND po_entry_det.bill_status = 'no' AND po_entry_det.cancelled='no' ";
													$QURY_ppo = mysqli_query($connect,$SLCT_ppo);
													if(mysqli_num_rows($QURY_ppo) > 0)
													{
														$party_id= base64_encode(base64_encode(base64_encode($FTCH_E->party_det_id)));
							                    ?>
							                    		<option <?php if($party_url == $party_id){ ?> selected="selected" <?php } ?> value="<?php echo $party_id ?>"><?php echo $FTCH_E->party_code." / ".$FTCH_E->cmp_name ; ?></option>
							                    <?php
													}
							                    }
							                    ?>							                        
							                </select>
							            </div>
							            <div class="clear"></div>
							        </div>                        
							        <?php		
									if(isset($_GET['party_id']))
									{
										$party_url = $_GET['party_id'];
										$pa_id	=	base64_decode(base64_decode(base64_decode($_GET['party_id'])));                  
									?>
    	
										<div class="widget"> <!--style="width:600px; margin-left:150px;"-->
											<div class="whead"><span class="titleIcon check"><input type="checkbox" id="titleCheck" name="titleCheck" onclick="hid_bils_1(<?php echo $biltype_id; ?>)"/></span><h6>PO List</h6><h6 style="float:right;"><!--<input type="text" id="cnt_chk" name="cnt_chk" value="" readonly="readonly" style="width:50px; font-size:12px; text-align:center;" />--></h6><div class="clear"></div></div>
											<div style="max-height:700px; overflow-y:auto;">
												<table cellpadding="0" cellspacing="0" width="100%" class="tDefault checkAll check" id="checkAll">
													<thead>
														<tr>
															<td width="20"><img src="images/elements/other/tableArrows.png" alt="" /></td>
															<td width="45">S.No<span class="sorting" style="display: block;"></span></td>
															<td width="118">Delivery Date</td>
															<td width="66">PO No</td>
															<td width="144">Company Name</td>
															<td width="111">Company Code</td>
															<td width="98">Order Date</td>           
															<td width="83">No of Die</td>
															<td width="134">No of Finished</td>
															<td width="99">No of Delivered</td>
															<!--<td width="78">Image</td>-->
										            	</tr>
										            </thead>
										            <tbody>
										            <?php
														$SLCT = "SELECT * FROM po_delivery,po_entry WHERE po_delivery.po_entry_id = po_entry.po_entry_id AND po_entry.party_det_id='$pa_id' ORDER BY po_delivery.po_delivery_id ASC";
														$QURY = mysqli_query($connect,$SLCT);
														$loop=1;
														$i=0;
														if(mysqli_num_rows($QURY)>0)
														{			
															while($FTCH = mysqli_fetch_object($QURY))
															{															
																$po_id	=	base64_encode(base64_encode(base64_encode($FTCH->po_entry_id)));				
																
																$SLCT_t = "SELECT IFNULL(SUM(master_pieces),'0') AS tot_pic, COUNT(po_entry_det_id) AS tot_cnt FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry_id = '$FTCH->po_entry_id' AND bill_status = 'no' AND cancelled='no'";
																$QURY_t = mysqli_query($connect,$SLCT_t);
																$FTCH_t = mysqli_fetch_object($QURY_t);
																
																$SLCT_d = "SELECT IFNULL(SUM(master_pieces),'0') AS tot_pic, COUNT(po_entry_det_id) AS fin_cnt FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND fin_status = 'yes' AND po_entry_id = '$FTCH->po_entry_id' AND bill_status = 'no' AND cancelled='no'";
																$QURY_d = mysqli_query($connect,$SLCT_d);
																$FTCH_d = mysqli_fetch_object($QURY_d);
																
																$SLCT_dd1 = "SELECT IFNULL(SUM(master_pieces),'0') AS tot_pic, COUNT(po_delivery_det.design_det_id) AS del_cnt FROM po_entry_det,po_delivery_det,design_det WHERE design_det.design_det_id=po_delivery_det.design_det_id AND po_entry_det.design_det_id = po_delivery_det.design_det_id AND po_delivery_det.cancelled = 'no' AND po_delivery_det.po_delivery_id = '$FTCH->po_delivery_id' AND po_entry_det.bill_status = 'no' AND po_entry_det.po_entry_id = '$FTCH->po_entry_id' AND po_entry_det.cancelled = 'no'";
																$QURY_dd1 = mysqli_query($connect,$SLCT_dd1);
																$FTCH_dd1 = mysqli_fetch_object($QURY_dd1);
																
																$SLCT_tp = "SELECT * FROM party_det WHERE party_det_id = '$FTCH->party_det_id'";
																$QURY_tp = mysqli_query($connect,$SLCT_tp);
																$FTCH_tp = mysqli_fetch_object($QURY_tp);
																if($FTCH_dd1->del_cnt > 0)
																{	
																	$chked_vr ="";																		
																	for($i=0;$i<=sizeof($pp_ids)-1;$i++)
																	{
																		if(isset($pp_ids[$i]))
																		{
																			if($po_dl_ids[$i] == $FTCH->po_delivery_id)
																			{
																				$chked_vr = 'checked="checked"';						
																			}																				
																		}
																	}
																	if($loop%2 != "0")
																		$bg = "gradeX";
																	else
																		$bg = "class='gradeC'";
													?>
       
																	<tr <?php echo $bg ?>>
																		<td align="center" style="display:table-cell;vertical-align:middle;"><input type="checkbox" name="category[]" onclick="hid_bils_1(<?php echo $biltype_id; ?>)" id="category<?php echo $loop ?>" value="<?php echo $FTCH->po_entry_id."-".$FTCH->po_delivery_id; ?>" <?php echo $chked_vr ?>/></td>
																		<td align="center"><?php echo $loop ?></td>
																		<td align="center"><?php echo $FTCH->delivery_date; ?></td>
																		<td align="center"><?php echo $FTCH->po_no; ?></td>
																		<td align="center"><?php echo $FTCH_tp->cmp_name; ?></td>
																		<td align="center"><?php echo $FTCH_tp->party_code; ?></td>
																		<td align="center"><?php echo $FTCH->po_date; ?></td>           
																		<td align="center"><?php echo $FTCH_t->tot_cnt; ?><br><span title="No of Master Pieces for Order Designs">(<?php echo $FTCH_t->tot_pic; ?>)</span></td>
																		<td align="center"><?php echo $FTCH_d->fin_cnt; ?><br><span title="No of Master Pieces for Finished Designs">(<?php echo $FTCH_d->tot_pic; ?>)</span></td>
																		<td align="center"><?php echo $FTCH_dd1->del_cnt; ?><br><span title="No of Master Pieces for Delivery Designs">(<?php echo $FTCH_dd1->tot_pic; ?>)</span></td>            
																	</tr>
        
													<?php
																	$loop ++;
																}
															}
														}
														else
														{
													?>
															<tr>
																<td align="center" style="display:table-cell;vertical-align:middle;">&nbsp;</td>
																<td align="center">&nbsp;</td>
																<td align="center">&nbsp;</td>
																<td colspan="6" align="center"><font color="#FF0000"><b>Sorry No Po for this Party</b></font> </td>
																<td align="center">&nbsp;</td>
																<td align="center">&nbsp;</td>
															</tr>
													<?php 
														} 
													?>
													</tbody>
												</table> 
											</div>											    
											<div class="formRow">
												<input type="button" value="Load" class="buttonM bBlack formSubmit" id="load" onclick="reload_page()" style="float: right; margin-left:20px;"/>
												<input type="button" value="Clear" class="buttonM bRed" style="float: right; margin-left:20px;" onclick="clr_fm()"/>
												<div class="clear"></div>
											</div>
											<div class="clear"></div>
										</div>										
									<?php 
									} 
									
									/* Non Tax Bill part Starts*/
									
									if(isset($_GET['po_id']) && $_GET['po_id']!="" && $biltype_id == 1)
									{
										$pa_id	=	base64_decode(base64_decode(base64_decode($_GET['party_id'])));
									
										$SLCT_p = "SELECT  * FROM party_det WHERE statu_s = 'active' AND party_det_id='$pa_id'";
										$QURY_p = mysqli_query($connect,$SLCT_p);
										$FTCH_p = mysqli_fetch_object($QURY_p);
									?>
										<div class="widget" id="non_tx_bill">            
											<div style="max-height:100%; overflow-y:auto;">
												<table cellpadding="0" cellspacing="0" width="100%" class="tDefault checkAll check" id="checkAll">
													<tr>
														<td height="51" colspan="6"><div align="center"><h1>INVOICE</h1></div></td>
													</tr>
													<tr>
														<td colspan="6"><h6 style="margin-left:10px;">To</h5></td>
													</tr>
													<tr>
														<td colspan="6" ><div align="center"><h4><?php echo $FTCH_p->cmp_name ?></h4></div></td>
													</tr>
													<tr>
														<td colspan="6"><div align="center"><b><?php echo $FTCH_p->com_addr ?></b></div></td>
													</tr>
													<tr>
														<td width="195"><div align="center" style="width:150px;"><h6><?php printf("DN/".$cur_yr."-".$to_yr."/"."%04d",$max_id); ?></h6></div><input type="hidden" value="<?php printf("DN/".$cur_yr."-".$to_yr."/"."%04d",$max_id); ?>" name="bil_no" id="bil_no"  style="width:100px;"/></td>
														<td><div align="center"><input type="text" value="" name="bill_dt" id="bill_dt" class="datepicker" /></div></td>
														<td colspan="3"><div align="center"><h6>Payment Terms :  100% against delivery </h6></div></td>
													</tr>
													<tr>            
														<td width="195"><div align="center">S.No</div></td>
														<td width="285"><div align="center">Description</div></td>
														<td width="100"><div align="center"><p>No Of Design's</p><p>(Qty)</p></div></td>
														<td width="100"><div align="center"><p>No Of Diee</p></div></td>
														<td width="131"><div align="center"><p>Per Unit Price</p><p>(Rs)</p></div></td>
														<td width="136"><div align="center"><p>Amount</p><p>(Rs)</p></div></td>            
           											</tr>
										            <?php
														$pa_id	=	base64_decode(base64_decode(base64_decode($_GET['party_id'])));
														$des_cnt = 0;
														$cat_ids = array();						
														$cat_ids_tot = array();			
														$mas_tot = array();					
														$cat_ids_unit_prc= array();	
														$po_ent_id = array();	
														$po_del_id = array();					
														$SLCT_tp = "SELECT * FROM master_cat WHERE statu_s = 'active' ORDER BY master_cat_id ASC";
														$QURY_tp = mysqli_query($connect,$SLCT_tp);
														$l=1;
														$lp=1;
														while($FTCH_tp = mysqli_fetch_object($QURY_tp)) //selecting the categories in each po
														{														
															for($i=0;$i<=sizeof($pp_ids)-1;$i++) //this is for calculating every po
															{
																if($pp_ids[$i]!="")
																{
																	$SLCT_p = "SELECT IFNULL(SUM(master_pieces),'0') AS tot_pic, COUNT(po_delivery_det.design_det_id) AS dscnt FROM po_delivery_det,po_entry_det,design_det WHERE design_det.design_det_id=po_delivery_det.design_det_id AND po_delivery_det.po_delivery_id = '$po_dl_ids[$i]' AND po_delivery_det.cancelled = 'no' AND po_entry_det.design_det_id = po_delivery_det.design_det_id AND  po_entry_det.master_cat_id = '$FTCH_tp->master_cat_id' AND po_entry_det.del_status ='yes' AND po_entry_det.bill_status='no' AND po_entry_det.po_entry_id = '$pp_ids[$i]'";
																	$QURY_p = mysqli_query($connect,$SLCT_p);
																	$FTCH_p = mysqli_fetch_object($QURY_p);
																	
																	$SLCT_pr = "SELECT cost_val FROM po_delivery,po_delivery_det WHERE po_delivery.po_entry_id = '$pp_ids[$i]' AND po_delivery_det.po_delivery_id = po_delivery.po_delivery_id AND po_delivery_det.master_cat_id = '$FTCH_tp->master_cat_id' Limit 1";
																	$QURY_pr = mysqli_query($connect,$SLCT_pr);
																	$FTCH_pr = mysqli_fetch_array($QURY_pr);																
																
																	if($i==0)//this is for when po is single
																	{
																		$des_cnt = $FTCH_p->dscnt;											
																		$cat_ids[$l] = $FTCH_tp->master_cat_id;		
																		$cat_ids_tot[$l] = $des_cnt;				
																		$mas_tot[$l] = $FTCH_p->tot_pic;
																		$cat_ids_unit_prc[$l] = $FTCH_pr['cost_val'];
																		if($des_cnt > 0)
																		{
																			$cat_ids1[$lp] = $FTCH_tp->master_cat_id;						
																			$cat_ids_tot1[$lp] = $des_cnt;
																			$mas_tot1[$l] = $FTCH_p->tot_pic;
																			$cat_ids_unit_prc1[$lp] = $FTCH_pr['cost_val'];
																			$po_ent_id[$lp] = $pp_ids[$i];
																			$po_del_id[$lp] = $po_dl_ids[$i];
																			$lp ++;
																		}
																	}
																	else if($i >0) //this is for when po is multiple
																	{
																		if($cat_ids_unit_prc[$l] != $FTCH_pr['cost_val']) //checking category amnt
																		{
																			$l++;
																			$des_cnt = $FTCH_p->dscnt;											
																			$cat_ids[$l] = $FTCH_tp->master_cat_id;						
																			$cat_ids_tot[$l] = $des_cnt;
																			$mas_tot[$l] = $FTCH_p->tot_pic;
																			$cat_ids_unit_prc[$l] = $FTCH_pr['cost_val'];
																			if($des_cnt > 0)
																			{
																				$cat_ids1[$lp] = $FTCH_tp->master_cat_id;						
																				$cat_ids_tot1[$lp] = $des_cnt;
																				$mas_tot1[$l] = $FTCH_p->tot_pic;
																				$cat_ids_unit_prc1[$lp] = $FTCH_pr['cost_val'];
																				$po_ent_id[$lp] = $pp_ids[$i];
																				$po_del_id[$lp] = $po_dl_ids[$i];
																				$lp ++;
																			}																			
																		}
																		else
																		{
																			$des_cnt = $FTCH_p->dscnt;											
																			$cat_ids_tot[$l] = $cat_ids_tot[$l] + $des_cnt;
																			$mas_tot[$l] = $mas_tot[$l] + $FTCH_p->tot_pic;
																			if($des_cnt > 0)
																			{
																				$cat_ids1[$lp] = $FTCH_tp->master_cat_id;						
																				$cat_ids_tot1[$lp] = $des_cnt;
																				$mas_tot1[$l] = $FTCH_p->tot_pic;
																				$cat_ids_unit_prc1[$lp] = $FTCH_pr['cost_val'];
																				$po_ent_id[$lp] = $pp_ids[$i];
																				$po_del_id[$lp] = $po_dl_ids[$i];
																				$lp ++;
																			}																			
																		}//cost								
																	}//multiple po															
																}//po is exits of not																		
															}//for loop end
															$l++;																							
														}//while loop end
														$loop_cnt = $l-1;	
														$tot_bill_amt =0;						
														$ll=1;
														for($l=1;$l<=$loop_cnt;$l++)
														{
															if($cat_ids_tot[$l] >0)
															{				
																$SLCT = "SELECT * FROM master_cat WHERE statu_s = 'active' AND master_cat_id = '$cat_ids[$l]' ORDER BY master_cat_id ASC";
																$QURY = mysqli_query($connect,$SLCT);			
																$FTCH = mysqli_fetch_object($QURY);				
																
																$tot_unit_pr = $cat_ids_tot[$l] * $cat_ids_unit_prc[$l];
																$tot_bill_amt =$tot_bill_amt + $tot_unit_pr;
																
																	if($loop%2 != "0")
																		$bg = "gradeX";
																	else
																		$bg = "class='gradeC'";
													?>
					
																<tr <?php echo $bg ?>>														
																	<td align="center"><?php echo $ll ?></td>
																	<td align="left"><?php echo $FTCH->master_cat_name." - ".$FTCH->cat_expantion; ?></td>					
																	<td align="center"><?php echo $cat_ids_tot[$l]; ?></td>
																	<td align="center"><?php echo $mas_tot[$l]; ?></td>
																	<td align="center"><?php echo number_format($cat_ids_unit_prc[$l],2) ?></td>
																	<td align="center"><?php echo number_format($tot_unit_pr,2); ?></td>
																</tr>
					
													<?php
																$ll++;			
															}
														}
											 		?>			  
													<tr>
														<td width="173" align="center"></td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<b>Courier Amount</b>
															<input type="hidden" value="1" id="cour_amnt_val" name="cour_amnt_val" />
														</td>																
														<td colspan="2" align="center" style="text-transform:capitalize">
															<b>Courier Weight</b>
															<input type="text" value="" id="cour_wgt" name="cour_wgt" onkeyup="cour_wet_cal()" style="width:50px;"/>
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<b>Amt/Kg</b>
															<input type="text" value="" id="cour_amt_for_1" name="cour_amt_for_1" onkeyup="cour_wet_cal()" style="width:50px;"/>
														</td>
														<td align="center"><input type="text" value="" id="cour_amt" name="cour_amt" readonly/></td>
													</tr>
													<tr>
														<td width="195" align="center"><h6>RUPEES :</h6></td>
														<td colspan="3" align="center" style="text-transform:capitalize"><h6><span id="num_word_tx"><?php echo  convert_number_to_words($tot_bill_amt); ?> Only</span></h6></td>
														<td align="center"><h6>Billing Amount</h6></td>
														<td align="center"><h6><span id="tot_bl_amt_tx"><?php echo number_format($tot_bill_amt,2); ?></span></h6>
															<input type="hidden" value="<?php echo $tot_bill_amt; ?>" id="to_bil_amt" name="to_bil_amt"/>
															<input type="hidden" value="<?php echo $tot_bill_amt; ?>" id="to_bil_amt_st" name="to_bil_amt_st"/>
															<input type="hidden" value="<?php echo $tot_bill_amt; ?>" id="to_bil_amt_tx" name="to_bil_amt_tx"/>
														</td>
													</tr>
													<tr>
														<td width="195">&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
													</tr>
													<tr>
														<td width="195"><div align="center" style="width:150px;"></div></td>
														<td><div align="center"><b>Advance Received on</b></div></td>
														<td colspan="3" align="center"><input type="text" value="" name="advn_dt" id="advn_dt" class="datepicker" /></td>
														<td align="center"><input type="text" value="" name="advn_amt" id="advn_amt" onkeyup="tot_bill(this.value)" autocomplete="off" style="width:100px;"/></td>
													</tr>
													<tr>
														<td width="195">&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
														<td>&nbsp;</td>
													</tr>
													<tr>
														<td width="195" align="center"></td>
														<td colspan="3" align="center" style="text-transform:capitalize"></td>
														<td align="center"><h6>Pending Amount</h6></td>
														<td align="center"><h6><span id="tot_bil_span"><?php echo number_format($tot_bill_amt,2); ?></span></h6></td>
													</tr>
        										</table> 
            								</div>
            							</div>
								<?php
										$lp=1;
										foreach($po_ent_id as $ct)
										{				
											$SLCT = "SELECT * FROM master_cat WHERE statu_s = 'active' AND master_cat_id = '$cat_ids1[$lp]' ORDER BY master_cat_id ASC";
											$QURY = mysqli_query($connect,$SLCT);			
											$FTCH = mysqli_fetch_object($QURY);				
											
											$tot_unit_pr = $cat_ids_tot1[$lp] * $cat_ids_unit_prc1[$lp];
											$tot_bill_amt =$tot_bill_amt + $tot_unit_pr;
								?>
											<input name="po_del_id[<?php echo $lp ?>]" id="po_del_id<?php echo $lp ?>" type="hidden" value="<?php echo $po_del_id[$lp]; ?>" />		
											<input name="po_ids_s[<?php echo $lp ?>]" id="po_ids_s<?php echo $lp ?>" type="hidden" value="<?php echo $ct; ?>" />
											<input name="cat_id[<?php echo $lp ?>]" id="cat_id<?php echo $lp ?>" type="hidden" value="<?php echo $cat_ids1[$lp]; ?>" />
											<input name="cat_name[<?php echo $lp ?>]" id="cat_name<?php echo $lp ?>" type="hidden" value="<?php echo $FTCH->master_cat_name; ?>" />
											<input name="nofdes[<?php echo $lp ?>]" id="nofdes<?php echo $lp ?>" type="hidden" value="<?php echo $cat_ids_tot1[$lp]; ?>" />
											<input name="unitpr[<?php echo $lp ?>]" id="unitpr<?php echo $lp ?>" type="hidden" value="<?php echo $cat_ids_unit_prc1[$lp]; ?>" />
											<input name="tot_pr[<?php echo $lp ?>]" id="tot_pr<?php echo $lp ?>" type="hidden" value="<?php echo $tot_unit_pr; ?>" />
								<?php
											$lp++;
										}
									}
									
									/* Non Tax Bill parts End */
									
									/* Tax Bill part Starts */
									
									if(isset($_GET['po_id']) && $_GET['po_id']!="" && $biltype_id == 2)
									{
										$pa_id	=	base64_decode(base64_decode(base64_decode($_GET['party_id'])));
		
										$SLCT_p = "SELECT  * FROM party_det WHERE statu_s = 'active' AND party_det_id='$pa_id'";
										$QURY_p = mysqli_query($connect,$SLCT_p);
										$FTCH_p = mysqli_fetch_object($QURY_p);
								?>
										<div class="widget" id="tx_bill">            
											<div style="max-height:100%; overflow-y:auto;">
												<table cellpadding="0" cellspacing="0" width="100%" class="tDefault checkAll check" id="checkAll">
													<!--<tr>
														<td height="51" colspan="6"><div align="center"><h1>INVOICE</h1></div></td>
													</tr>
													<tr>
														<td colspan="2" style="padding-left:10px;"><h5>To</h5></td>
														<td colspan="4">&nbsp;</td>
													</tr>
													<tr>
														<td colspan="2" ><div align="center"><h4><?php echo $FTCH_p->cmp_name ?></h4></div></td>
														<td colspan="4" ><div align="center"><h2><font style="font-family: PaqueteSSK; font-size:26px;">Thahaayaa</font> <font style="font-size:13px; font-family: Logan;">Crea-Dons. . .  </font></h2></div></td>
													</tr>
													<tr>
														<td colspan="2"><div align="center"><b><?php echo str_replace(',',',<br/>',$FTCH_p->com_addr); ?></b></div></td>
														<td colspan="4"><div align="center"><h5><p>(Cad\Cam solutions & master models)<br/>243A, Subramaniapuram, Thirumoothi Layout <br/> R.S.Puram Coimbatore-641002.</p></h5></div></td>
													</tr>
													<tr>			
														<td align="left"><div align="center" style="width:200px;">
														  <input type="text" value="<?php echo $auto_bill; ?>" name="bil_no2" id="bil_no2"  style="width:150px;"/>
														</div></td>
														<td align="left"><div align="center" style="width:200px;"><input type="text" value="" name="bill_dt" id="bill_dt" class="datepicker" /></div></td>
														<td colspan="4"><div align="center"><h6>Payment Terms :  100% against delivery </h6></div></td>
													</tr>
													<tr>			
														<td width="173" align="center"></td>
														<td></td>
														<td colspan="2"><div align="center">TIN : 33222164671 - 27/04/11</div></td>
														<td colspan="2"><div align="center">CST : 1036607 - 27/04/11</div></td>
													</tr>
													<tr>			
														<td colspan="2" align="left"><b>Tin No Of <?php echo $FTCH_p->cmp_name ?></b></td>
														<td colspan="2"><div align="center">TIN : <?php echo $FTCH_p->tin_no ?> - <?php echo str_replace("-", "/", $FTCH_p->tin_date); ?></div></td>
														<td colspan="2"><div align="center">CST : <?php echo $FTCH_p->cst_no; ?> - <?php echo str_replace("-", "/", $FTCH_p->tin_date); ?></div></td>
													</tr>-->
													<tr>
												        <td colspan="6">
											            	<div align="center">
											            		<h2 style="margin-top:10px;"><font style="font-family: PaqueteSSK; font-size:40px;">Thahaayaa</font> <font style="font-size:20px; font-family: Logan;">Crea-Dons. . .  </font></h2> 
											          		</div>                
											          		<div align="center" style="margin-top:-8px;font-weight: bold"><p>243A, Subramaniyapuram, Thirumoothi Layout, R.S.Puram, Coimbatore-641002. Ph: 0422 - 4351080</p></div>											          	</td>
											        </tr>
											        <tr height ="2">
												        <td colspan="6">
												        	<h3 align="center" style="margin-top: 5px;margin-bottom: 5px;">Tax Invoice</h3>												      	</td>
											        </tr>
											        <tr>
												        <td colspan="6" align="center">
													  	<table cellpadding="0" cellspacing="0"  width="100%"  >
											 				<tr height="20">
											            		<td width="25%"><div align="left" style="padding-left: 05px">Invoice No</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" value="<?php echo $auto_bill; ?>" name="bil_no" id="bil_no"  style="width:150px;"/></div></td>
											            		<!--<td width="25%"><div align="left">VAT No</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;33222164671</div></td>-->
																<td width="25%"><div align="left">GSTIN No</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;33AAEFT6762G1Z3</div></td>
														     </tr>
														     <tr height="20">
											            		<td width="25%"><div align="left" style="padding-left: 05px">Invoice Date</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" value="" name="bill_dt" id="bill_dt" class="datepicker" onchange="quot_no_gen()" /></div></td>
											            		<!--<td width="25%"><div align="left">CST No</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;1036607</div></td>-->
																<td width="25%"><div align="left">Import/Export Code</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;3215026198</div></td>
														     </tr>
														     <!--<tr height="20">
											            		<td colspan="2">&nbsp;</td>
											            		<td width="25%"><div align="left">Date</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;24/04/2011</div></td>
														     </tr>
														     <tr height="20">
											            		<td colspan="2">&nbsp;</td>
											            		<td width="25%"><div align="left">Import/Export Code</div></td>
											            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;3215026198</div></td>
														     </tr>-->
														 </table>												      	</td>
											        </tr>
											        <tr>
											        	<td colspan="6" align="center">
													  		<table cellpadding="0" cellspacing="0"  width="100%">
													  			<tr>
														          	<td rowspan="6" colspan="2" valign="top" style="padding-left:20px;">To
															          	<div align="center"><strong style="font-size: 20px; "><?php echo $FTCH_p->cmp_name ?></strong></div>                
															          	<div align="center"><?php echo nl2br($FTCH_p->com_addr); ?></div>															        															</td>
<?php /*?>															        <td width="25%"><div align="left">Party Code</div></td>
															        <td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->party_code; ?></div></td><?php */?>
																	<td width="25%"><div align="left">Contact Person</div></td>
															        <td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->con_pers_1; ?></div></td>	
														        </tr>
														        <tr height="20">
											            		  	<td width="25%"><div align="left" style="padding-left: 11px">Contact No</div></td>
												            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->con_no_1; ?></div></td>
												            	</tr>
												            	<tr height="20">
											            		  <td width="25%"><div align="left" style="padding-left: 11px">Landline No</div></td>
												            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->con_ln_no_1; ?></div></td>
												            	</tr>
												            	<tr height="20">
											            		  <td width="25%"><div align="left" style="padding-left: 11px">Email-ID</div></td>
												            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->email_id_1; ?></div></td>
												            	</tr>
<?php /*?>												            	<tr height="20">
											            		  <td width="25%"><div align="left" style="padding-left: 11px">Email-ID</div></td>
												            		<td width="25%"><div align="left" >:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->email_id_1; ?></div></td>
												            	</tr><?php */?>
<?php /*?>												        <tr height="20">
												            		<td width="25%"><div align="left" style="padding-left: 11px">Tin No</div></td>
												            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->tin_no; ?></div></td>
												            	</tr><?php */?>
																<tr height="20">
											            		  <td width="25%"><div align="left" style="padding-left: 11px">GSTIN No</div></td>
												            		<td width="25%"><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $FTCH_p->gstin; ?></div></td>
												            	</tr>
														 	</table>														</td>
												  	</tr>
									            	
											        <tr>
												        <td height="7" colspan="6">
												        	<div align="center">
												        		<h3 style="margin-top: 5px;margin-bottom: 5px;">Particulars of Taxable Goods</h3>
												      		</div>												      	</td>
											        </tr>
													<tr>			
														<td width="173"><div align="center">S.No</div></td>
														<td width="169"><div align="center">Description</div></td>
														<td width="243"><div align="center"><p>No of Design (Qty)</p></div></td>
														<td width="243"><div align="center"><p>No of Dies</p></div></td>
														<td width="152"><div align="center"><p>Cost Per Design <br><span class="rupyaINR">Rs</span></p></div></td>
														<td width="196"><div align="center"><p>Total Value <br><span class="rupyaINR">Rs</span></p></div></td>
													</tr>
										            <?php
														$pa_id	=	base64_decode(base64_decode(base64_decode($_GET['party_id'])));
														$des_cnt = 0;
														$cat_ids = array();						
														$cat_ids_tot = array();	
														$mas_tot = array();						
														$cat_ids_unit_prc= array();	
														$po_ent_id = array();	
														$po_del_id = array();					
														$SLCT_tp = "SELECT * FROM master_cat WHERE statu_s = 'active' ORDER BY master_cat_id ASC";
														$QURY_tp = mysqli_query($connect,$SLCT_tp);
														$l=1;
														$lp=1;
														while($FTCH_tp = mysqli_fetch_object($QURY_tp)) //selecting the categories in each po
														{															
															for($i=0;$i<=sizeof($pp_ids)-1;$i++) //this is for calculating every po
															{
																if($pp_ids[$i]!="")
																{	
																	$SLCT_p = "SELECT IFNULL(SUM(master_pieces),'0') AS tot_pic,COUNT(po_delivery_det.design_det_id) AS dscnt FROM po_delivery_det,po_entry_det,design_det WHERE design_det.design_det_id=po_delivery_det.design_det_id AND po_delivery_det.po_delivery_id = '$po_dl_ids[$i]' AND po_delivery_det.cancelled = 'no' AND po_entry_det.design_det_id = po_delivery_det.design_det_id AND  po_entry_det.master_cat_id = '$FTCH_tp->master_cat_id' AND po_entry_det.del_status ='yes' AND po_entry_det.bill_status='no' AND po_entry_det.po_entry_id = '$pp_ids[$i]'";
																	$QURY_p = mysqli_query($connect,$SLCT_p);
																	$FTCH_p = mysqli_fetch_object($QURY_p);

																	$SLCT_pr = "SELECT cost_val FROM po_delivery,po_delivery_det WHERE po_delivery.po_entry_id = '$pp_ids[$i]' AND po_delivery_det.po_delivery_id = po_delivery.po_delivery_id AND po_delivery_det.master_cat_id = '$FTCH_tp->master_cat_id' Limit 1";
																	$QURY_pr = mysqli_query($connect,$SLCT_pr);
																	$FTCH_pr = mysqli_fetch_array($QURY_pr);					

																	if($i==0)//this is for when po is single
																	{
																		$des_cnt = $FTCH_p->dscnt;											
																		$cat_ids[$l] = $FTCH_tp->master_cat_id;						
																		$cat_ids_tot[$l] = $des_cnt;
																		$mas_tot[$l] = $FTCH_p->tot_pic;
																		$cat_ids_unit_prc[$l] = $FTCH_pr['cost_val'];
																		if($des_cnt > 0)
																		{
																			$cat_ids1[$lp] = $FTCH_tp->master_cat_id;						
																			$cat_ids_tot1[$lp] = $des_cnt;
																			$mas_tot1[$l] = $FTCH_p->tot_pic;
																			$cat_ids_unit_prc1[$lp] = $FTCH_pr['cost_val'];
																			$po_ent_id[$lp] = $pp_ids[$i];
																			$po_del_id[$lp] = $po_dl_ids[$i];
																			$lp ++;
																		}
																	}
																	else if($i >0) //this is for when po is multiple
																	{
																		if($cat_ids_unit_prc[$l] != $FTCH_pr['cost_val']) //checking category amnt
																		{
																			$l++;
																			$des_cnt = $FTCH_p->dscnt;											
																			$cat_ids[$l] = $FTCH_tp->master_cat_id;						
																			$cat_ids_tot[$l] = $des_cnt;
																			$mas_tot[$l] = $FTCH_p->tot_pic;
																			$cat_ids_unit_prc[$l] = $FTCH_pr['cost_val'];
																			if($des_cnt > 0)
																			{
																				$cat_ids1[$lp] = $FTCH_tp->master_cat_id;						
																				$cat_ids_tot1[$lp] = $des_cnt;
																				$mas_tot1[$l] = $FTCH_p->tot_pic;
																				$cat_ids_unit_prc1[$lp] = $FTCH_pr['cost_val'];
																				$po_ent_id[$lp] = $pp_ids[$i];
																				$po_del_id[$lp] = $po_dl_ids[$i];
																				$lp ++;
																			}																			
																		}
																		else
																		{
																			$des_cnt = $FTCH_p->dscnt;											
																			$cat_ids_tot[$l] = $cat_ids_tot[$l] + $des_cnt;
																			$mas_tot[$l] = $mas_tot[$l] + $FTCH_p->tot_pic;
																			if($des_cnt > 0)
																			{
																				$cat_ids1[$lp] = $FTCH_tp->master_cat_id;						
																				$cat_ids_tot1[$lp] = $des_cnt;
																				$mas_tot1[$l] = $FTCH_p->tot_pic;
																				$cat_ids_unit_prc1[$lp] = $FTCH_pr['cost_val'];
																				$po_ent_id[$lp] = $pp_ids[$i];
																				$po_del_id[$lp] = $po_dl_ids[$i];
																				$lp ++;
																			}																			
																		}//cost								
																	}//multiple po																
																}//po is exits of not																			
															}//for loop end
															$l++;																								
														}//while loop end
														
														$loop_cnt = $l-1;															
														$tot_bill_amt =0;						
														$ll=1;
														for($l=1;$l<=$loop_cnt;$l++)
														{
															if($cat_ids_tot[$l] >0)
															{				
																$SLCT = "SELECT * FROM master_cat WHERE statu_s = 'active' AND master_cat_id = '$cat_ids[$l]' ORDER BY master_cat_id ASC";
																$QURY = mysqli_query($connect,$SLCT);			
																$FTCH = mysqli_fetch_object($QURY);	
																$tot_unit_pr = $cat_ids_tot[$l] * $cat_ids_unit_prc[$l];
																$tot_bill_amt =$tot_bill_amt + $tot_unit_pr;
															
																if($loop%2 != "0")
																	$bg = "gradeX";
																else
																	$bg = "class='gradeC'";
													?>
					
																<tr <?php echo $bg ?>>																
																	<td align="center"><?php echo $ll ?></td>
																	<td align="left"><?php echo $FTCH->master_cat_name." - ".$FTCH->cat_expantion; ?> </td>																
																	<td align="center"><?php echo $cat_ids_tot[$l]; ?></td>
																	<td align="center"><?php echo $mas_tot[$l]; ?></td>
																	<td align="center"><?php echo number_format($cat_ids_unit_prc[$l],2) ?></td>
																	<td ><div align="right" style="padding-right: 5px"><?php echo number_format($tot_unit_pr,2); ?></div></td>
																</tr>
													<?php
																$ll++;			
															}
														 }
			 										?>
			 										<tr>
											              <td align="center">&nbsp;</td>
											              <td align="center"><b>Total</b></td>
											              <td align="center" style="padding-right: 5px"><b><?php echo array_sum($cat_ids_tot); ?></b></td>
											              <td align="center" style="padding-right: 5px"><b><?php echo array_sum($mas_tot); ?></b></td>
											              <td>&nbsp;</td>
											              <td>&nbsp;</td>
										            </tr>
										            <tr>
												       
									            		<td align="center">&nbsp;</td>
									            		<td align="center">&nbsp;</td>
									            		<td align="center">&nbsp;</td>
									            		<td align="center">&nbsp;</td>
									            		<td align="center"><div align="right">Net Sales Amount</div></td>
									            		<td>
									            			<div align="right" style="padding-right: 5px"><?php echo number_format($tot_bill_amt,2); ?></div>
									            			<input type="hidden" value="<?php echo $tot_bill_amt ?>" id="bil_amt" name="bil_amt"/>
															<input type="hidden" value="<?php echo $tot_bill_amt ?>" id="bl_amt_wo_cur" name="bl_amt_wo_cur"/>
															<input type="hidden" value="" id="fin_tax_amt" name="fin_tax_amt"/>									            		</td>
												    </tr>
											<?php if($cour_charges == "yes" || $cour_charges == "") {?>
													<tr>
														<td colspan="3" align="center" style="text-transform:capitalize">
															<b>Courier</b>
															<input type="hidden" value="2" id="cour_amnt_val" name="cour_amnt_val" />
															<input type="hidden" value="<?php echo $party_CNTRY; ?>" id="party_CNTRY" name="party_CNTRY" />
															<input type="hidden" value="<?php echo $party_STATE; ?>" id="party_STATE" name="party_STATE" />														
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Weight</b></span>
															<span style="width:50%"><input type="text" value="" id="cour_wgt" name="cour_wgt" <?php if($party_CNTRY != 1) { ?> onkeyup="abroad_cour_wet_cal()" <?php } else if($party_CNTRY == 1) { ?> onkeyup="cour_wet_cal()" <?php } ?> style="width:50px;"/></span></td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Amt / Kg</b></span>
															<span style="width:50%"><input type="text" value="" id="cour_amt_for_1" name="cour_amt_for_1" <?php if($party_CNTRY != 1) { ?> onkeyup="abroad_cour_wet_cal()" <?php } else if($party_CNTRY == 1) { ?> onkeyup="cour_wet_cal()" <?php } ?> style="width:50px;"/></span>														</td>
														<td align="right"><input type="text" value="" id="cour_amt" name="cour_amt" readonly="" style="text-align: right; padding-right: 5px;" /></td>
													</tr>
											<?php } else if($cour_charges == "no") {?>
													<tr>
														<td colspan="3" align="center" style="text-transform:capitalize">
															<b>Courier</b>
															<input type="hidden" value="2" id="cour_amnt_val" name="cour_amnt_val" />														
															<input type="hidden" value="<?php echo $party_CNTRY; ?>" id="party_CNTRY" name="party_CNTRY" />
															<input type="hidden" value="<?php echo $party_STATE; ?>" id="party_STATE" name="party_STATE" />														
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Weight</b></span>
															<span style="width:50%"><input type="text" value="0" id="cour_wgt" name="cour_wgt" onkeyup="cour_wet_cal()" style="width:50px;"/></span></td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Amt / Kg</b></span>
															<span style="width:50%"><input type="text" value="0" id="cour_amt_for_1" name="cour_amt_for_1" onkeyup="cour_wet_cal()" style="width:50px;" readonly=""/></span></td>
														<td align="right"><input type="text" value="0" id="cour_amt" name="cour_amt" readonly="" style="text-align: right; padding-right: 5px;"/></td>
													</tr>											
											<?php }?>											

												    <tr height="25">
									            		<td rowspan="2" colspan="6"><div align="center" style="padding-left: 05px"><b>If There is any Changes in Invoice Details Please intimate us within two working days.</b></div></td>
									            	</tr>
									            	<tr height="25">
									            		<td rowspan="2" colspan="6"><div align="center" style="padding-left: 05px">&nbsp;</td>
									            	</tr>
													
													<?php if($party_CNTRY == 1 && $party_STATE != 32){
													
													$SLCT_GST_DETAILS = mysqli_query($connect,"SELECT * FROM master_tax WHERE tax_desc = 'Outerstate Tax' AND stat_us = 'active'");
													$FTCH_GST_DETAILS = mysqli_fetch_object($SLCT_GST_DETAILS);
													
													?>
													
									            	<tr>
														<td colspan="4"><div align="center"><b><?php echo $FTCH_GST_DETAILS->tax_lable; ?> - <?php echo $FTCH_GST_DETAILS->tax_percent; ?>%</b></div></td>
													  <td align="center"><input type="text" value="<?php echo $FTCH_GST_DETAILS->tax_percent; ?>" name="tax_p" id="tax_p" style="width:50px;" readonly=""/> %
													    <input type="hidden" name="gst_tax_lable" id="gst_tax_lable" value="<?php echo $FTCH_GST_DETAILS->tax_lable; ?>" />														</td>
														<td align="right"><b><span id="igst_cor_net_tot"><?php echo $gst_tax_amt = ($tot_bill_amt / 100) * $FTCH_GST_DETAILS->tax_percent; ?>.00</span></b></td>
													</tr><input type="hidden" name="fin_tax_amt" id="fin_tax_amt" value="<?php echo $gst_tax_amt; ?>" />
													
													<?php } else if($party_CNTRY != 1) { 

													$SLCT_GST_DETAILS = mysqli_query($connect,"SELECT * FROM master_tax WHERE tax_desc = 'Foreign Tax' AND stat_us = 'active'");
													$FTCH_GST_DETAILS = mysqli_fetch_object($SLCT_GST_DETAILS);
													
													?>
													
									            	<tr>
														<td colspan="4"><div align="center"><b><?php echo $FTCH_GST_DETAILS->tax_lable; ?> - <?php echo $FTCH_GST_DETAILS->tax_percent; ?>%</b></div></td>
													  <td align="center"><input type="text" value="<?php echo $FTCH_GST_DETAILS->tax_percent; ?>" name="tax_p" id="tax_p" style="width:50px;" readonly=""/> %
													    <input type="hidden" name="gst_tax_lable" id="gst_tax_lable" value="<?php echo $FTCH_GST_DETAILS->tax_lable; ?>" />														</td>
														<td align="right"><b><span id="igst_cor_net_tot"><?php echo $gst_tax_amt = ($tot_bill_amt / 100) * $FTCH_GST_DETAILS->tax_percent; ?>.00</span></b></td>
													</tr><input type="hidden" name="fin_tax_amt" id="fin_tax_amt" value="<?php echo $gst_tax_amt; ?>" />
													
													
													<?php } else if($party_CNTRY == 1 && $party_STATE == 32) { 
													
													$SLCT_GST_DETAILS 	= mysqli_query($connect,"SELECT * FROM master_tax WHERE tax_desc = 'Interstate Tax' AND stat_us = 'active'");
													$FTCH_GST_DETAILS 	= mysqli_fetch_object($SLCT_GST_DETAILS);
													
													$gst_tax_lable 		= explode(",", $FTCH_GST_DETAILS->tax_lable);
													$sgst_tax_lable		= $gst_tax_lable[0];
													$cgst_tax_lable		= $gst_tax_lable[1];
													
													$gst_tax_percent	= explode(",", $FTCH_GST_DETAILS->tax_percent);
													$sgst_tax_percent	= $gst_tax_percent[0];
													$cgst_tax_percent	= $gst_tax_percent[1];													
													
													?>
													
									            	<tr>
														<td colspan="4"><div align="center"><b><?php echo $sgst_tax_lable; ?> - <?php echo $sgst_tax_percent; ?>%</b></div></td>
														<td align="center"><input type="text" value="<?php echo $sgst_tax_percent; ?>" name="disp_tax_p" id="disp_tax_p" style="width:50px;" readonly=""/> %
														
														<input type="hidden" value="<?php echo $sgst_tax_percent; ?>, <?php echo $cgst_tax_percent; ?>" name="tax_p" id="tax_p"/>
														
														<input type="hidden" name="gst_tax_lable" id="gst_tax_lable" value="<?php echo $sgst_tax_lable; ?>, <?php echo $cgst_tax_lable; ?>" />														</td>
														<td align="right"><b><span id="sgst_cor_net_tot"><?php echo $gst_tax_amt = ($tot_bill_amt / 100) * $sgst_tax_percent; ?>.00</span></b></td>
													</tr>
													
													<tr>
														<td colspan="4"><div align="center"><b><?php echo $cgst_tax_lable; ?> - <?php echo $cgst_tax_percent; ?>%</b></div></td>
														<td align="center"><input type="text" value="<?php echo $cgst_tax_percent; ?>" name="disp_tax_p" id="disp_tax_p" style="width:50px;" readonly=""/> %
														
														<!--<input type="hidden" value="<?php echo $cgst_tax_percent; ?>" name="tax_p" id="tax_p"/>
														
														<input type="hidden" name="gst_tax_lable" id="gst_tax_lable" value="<?php echo $cgst_tax_lable; ?>" />-->														</td>
														<td align="right"><b><span id="cgst_cor_net_tot"><?php echo $gst_tax_amt = ($tot_bill_amt / 100) * $cgst_tax_percent; ?>.00</span></b></td>
													</tr><input type="hidden" name="netamt_cour_tax_amt" id="netamt_cour_tax_amt" value="<?php echo $gst_tax_amt; ?>" />
													
													<?php } ?>
													
													<!--<tr>
														<td colspan="3" align="center" style="text-transform:capitalize">
															<b>Courier</b>
															<input type="hidden" value="2" id="cour_amnt_val" name="cour_amnt_val" />
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Weight</b></span>
															<span style="width:50%"><input type="text" value="" id="cour_wgt" name="cour_wgt" onkeyup="cour_wet_cal()" style="width:50px;"/></span>
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Amt / Kg</b></span>
															<span style="width:50%"><input type="text" value="" id="cour_amt_for_1" name="cour_amt_for_1" onkeyup="cour_wet_cal()" style="width:50px;"/></span>              
														</td>
														<td align="right"><input type="text" value="" id="cour_amt" name="cour_amt" readonly="" style="text-align: right; padding-right: 5px;" /></td>
													</tr>-->
													<tr>
														<td colspan="4" align="center">&nbsp;</td>
														<td align="center" style="text-transform:capitalize"><b><!--Roundoff--></b></td>
														<td align="right"><span id="rnd_amt"></span><input type="hidden" value="" id="round_amt" name="round_amt"/></td>
													</tr>
													
											<?php if($party_CNTRY == 1 && $party_STATE == 32){ ?>		
													<tr>
														<td colspan="2" align="center"><h6>RUPEES :</h6></td>
														<td colspan="2" align="center" style="text-transform:capitalize"><h6><span id="num_word_ntx"><?php echo  convert_number_to_words($tot_bill_amt  + ($gst_tax_amt * 2)); ?> Only</span></h6></td>
														<td align="center"><h6>Total Billing Amount</h6></td>
														<td align="right"><h6><span id="tot_bl_amt"><?php echo number_format($tot_bill_amt + ($gst_tax_amt * 2), 2) ?></span></h6>
															<input type="text" value="<?php echo number_format($tot_bill_amt, 2); ?>" id="to_bil_amt" name="to_bil_amt"/>
															<input type="text" value="<?php echo $tot_bill_amt ?>" id="to_bil_amt_ntx" name="to_bil_amt_ntx"/>														</td>
													</tr>											        
											<?php } else if($party_CNTRY == 1 && $party_STATE != 32){ ?>
													<tr>
														<td colspan="2" align="center"><h6>RUPEES :</h6></td>
														<td colspan="2" align="center" style="text-transform:capitalize"><h6><span id="num_word_ntx"><?php echo  convert_number_to_words($tot_bill_amt  + ($gst_tax_amt)); ?> Only</span></h6></td>
														<td align="center"><h6>Total Billing Amount</h6></td>
														<td align="right"><h6><span id="tot_bl_amt"><?php echo number_format($tot_bill_amt + ($gst_tax_amt), 2) ?></span></h6>
															<input type="text" value="<?php echo $tot_bill_amt; ?>" id="to_bil_amt" name="to_bil_amt"/>
															<input type="text" value="<?php echo $tot_bill_amt ?>" id="to_bil_amt_ntx" name="to_bil_amt_ntx"/>														</td>
													</tr>											        
											<?php } else { ?>
													<tr>
														<td colspan="2" align="center"><h6>RUPEES :</h6></td>
														<td colspan="2" align="center" style="text-transform:capitalize"><h6><span id="num_word_ntx"><?php echo  convert_number_to_words($tot_bill_amt  + ($gst_tax_amt)); ?> Only</span></h6></td>
														<td align="center"><h6>Total Billing Amount</h6></td>
														<td align="right"><h6><span id="tot_bl_amt"><?php echo number_format($tot_bill_amt + ($gst_tax_amt), 2) ?></span></h6>
															<input type="text" value="<?php echo $tot_bill_amt; ?>" id="to_bil_amt" name="to_bil_amt"/>
															<input type="text" value="<?php echo $tot_bill_amt ?>" id="to_bil_amt_ntx" name="to_bil_amt_ntx"/>														</td>
													</tr>											        
											<?php } ?>
													<tr height="25">
									            		<td colspan="3"><div align="center" style=""><b>Thahaayaa Bank Details</b></div></td>
									            		<td colspan="3"><div align="center" style=""><b>Terms & Conditions</b></div></td>
									            	</tr>
									 				<tr height="25">
									            		<td colspan="2"><div align="left" style="padding-left: 05px">Name</div></td>
									            		<td><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;Thahaayaa Creadons</div></td>
									            		<td colspan="3"><div align="left" style=""><b>1. </b>Payment with in 10 Days from the date of billing.</div></td>
												    </tr>
												    <tr height="25">
									            		<td colspan="2"><div align="left" style="padding-left: 05px">Bank Name</div></td>
									            		<td><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;Union Bank of India</div></td>
									            		<td colspan="3"><div align="left" style=""><b>2. </b>Subject To coimbatore Jurisdiction.</div></td>
												    </tr>
												    <tr height="25">
									            		<td colspan="2"><div align="left" style="padding-left: 05px">A/c No</div></td>
									            		<td><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;548901010050617</div></td>
									            		<td colspan="3"><div align="left" style="">&nbsp;</div></td>
												    </tr>
												    <tr height="25">
									            		<td colspan="2"><div align="left" style="padding-left: 05px">Branch</div></td>
									            		<td><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;R.S.Puram</div></td>
									            		<td colspan="3"><div align="left" style="">&nbsp;</div></td>
												    </tr>
												    <tr height="25">
									            		<td colspan="2"><div align="left" style="padding-left: 05px">IFSC Code</div></td>
									            		<td><div align="left">:&nbsp;&nbsp;&nbsp;&nbsp;UBIN0550264</div></td>
									            		<td colspan="3"><div align="left" style="">&nbsp;</div></td>
												    </tr>
											        <tr>
												        <td height="28" colspan="3">
												        	<div align="center" style="padding-left:10px;padding-right:10px ">
												        		<p align="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Certified that the particulars given above are true and correct and the amount indicated represents the pricce actually charged and that there is no flow of additional consideration,directly or indirectly, from the buyer</p>
												      		</div>												      	</td>
												      	<td height="28">
												        	<div align="center" style="padding-left:10px;padding-right:10px ">												      		</div>												      	</td>
												      	<td height="28" colspan="2">
												        	<div align="center">
												        		<p>For M/s <font style="font-family: PaqueteSSK; font-size:22px;font-weight:bold ">Thahaayaa</font> <font style="font-size:12px; font-family: Logan;">Crea-Dons. . .  </font></p> 
												      		</div>
												      		<div align="center" height="20">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;												      		</div>
												      		<div align="center">
												        		<p>Authorised Signature</p> 
												      		</div>												      	</td>
											        </tr>
											        <tr>
												        <td height="7" colspan="6">
												        	<div align="center">
												        		<p style=" font-size:12px; margin-top: 5px;margin-bottom: 5px;"><b>Sales : </b>sales@thahaayaa.com / 9894347273 || <b>Accounts : </b>accounts@thahaayaa.com / 9843214151 || <b>Internal Management : </b>info@thahaayaa.com / 9843018906</p>
												      		</div>												      	</td>
											        </tr>
													<!--<tr>
														<td width="173" align="center"></td>
														<td colspan="4" align="center" style="text-transform:capitalize"><b>Net Sales</b></td>
														<td align="center"><b><?php echo number_format($tot_bill_amt,2); ?></b>
															<input type="hidden" value="<?php echo $tot_bill_amt ?>" id="bil_amt" name="bil_amt"/>
															<input type="hidden" value="<?php echo $tot_bill_amt ?>" id="bl_amt_wo_cur" name="bl_amt_wo_cur"/>
															<input type="hidden" value="" id="fin_tax_amt" name="fin_tax_amt"/>
														</td>
													</tr>
													<tr>
														<td width="173"><div align="center" style="width:150px;"></div></td>
														<td align="center">&nbsp;</td>
														<td><div align="center"><b>VAT / CST </b></div></td>
														<td align="center"><input type="text" value="" name="tax_p" id="tax_p" onkeyup="bil_tx(this.value)" autocomplete="off" style="width:50px;"/> %</td>
														<td align="center">&nbsp;</td>
														<td align="center"><b><span id="tax_cl">0.00</span></b></td>
													</tr>
													<tr>
														<td width="173" align="center"></td>
														<td align="center">&nbsp;</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<b>Courier</b>
															<input type="hidden" value="2" id="cour_amnt_val" name="cour_amnt_val" />
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Weight</b></span>
															<span style="width:50%"><input type="text" value="" id="cour_wgt" name="cour_wgt" onkeyup="cour_wet_cal()" style="width:50px;"/></span>
														</td>
														<td colspan="1" align="center" style="text-transform:capitalize">
															<span style="width:50%"><b>Amt / Kg</b></span>
															<span style="width:50%"><input type="text" value="" id="cour_amt_for_1" name="cour_amt_for_1" onkeyup="cour_wet_cal()" style="width:50px;"/></span>              
														</td>
														<td align="center"><input type="text" value="" id="cour_amt" name="cour_amt" readonly="" /></td>
													</tr>
													<tr>
														<td width="173" align="center"></td>
														<td align="center">&nbsp;</td>
														<td colspan="3" align="center" style="text-transform:capitalize"><b>Roundoff</b></td>
														<td align="center"><span id="rnd_amt"></span><input type="text" value="" id="round_amt" name="round_amt"/></td>
													</tr>
													<tr>
														<td width="173" align="center"><h6>RUPEES :</h6></td>
														<td colspan="3" align="center" style="text-transform:capitalize"><h6><span id="num_word_ntx"><?php echo  convert_number_to_words($tot_bill_amt); ?> Only</span></h6></td>
														<td align="center"><h6>Total Billing Amount</h6></td>
														<td align="center"><h6><span id="tot_bl_amt"><?php echo number_format($tot_bill_amt,2) ?></span></h6>
															<input type="hidden" value="<?php echo $tot_bill_amt; ?>" id="to_bil_amt" name="to_bil_amt"/>
															<input type="hidden" value="<?php echo $tot_bill_amt ?>" id="to_bil_amt_ntx" name="to_bil_amt_ntx"/>
														</td>
													</tr>
													<tr>
														<td colspan="3"><div align="center"><b>Terms &amp; Condition's</b></div></td>
														<td rowspan="3">&nbsp;</td>
														<td colspan="2" rowspan="2"><div align="center"><h3><font style="font-weight:300; font-size:14px;">For &nbsp;&nbsp;&nbsp;</font><font style="font-family: PaqueteSSK; font-size:20px;">Thahaayaa</font></font> <font style="font-size:11px; font-family: Logan;">Crea-Dons. . .  </font></h3> </div></td>
													</tr>
													<tr>
														<td colspan="3">
															<ul style="list-style:circle; margin-left:5px;">
																<li>• A/c Payee Cheque/Drafts Should be made payable to“Thahaayaa <br/>Crea-dons.” and are subject to realization</li>
																<li>• If any modification in billing inform within 3 working days.</li>
																<li>• Subject To coimbatore Jurisdiction</li>
															</ul>				
														</td>
													</tr>
													<tr>
														<td colspan="4">&nbsp;</td>
														<td colspan="2"><div align="center"><h5>Partner</h5></div></td>
													</tr>
													<tr>
														<td colspan="6"><div align="center" style="font-size:14px">Customer Copy / File Copy / Extra Copy</div></td>
													</tr>
													<tr>
														<td height="46" colspan="6"><div align="center" style="font-size:14px">Computer Generated Bill </div></td>
													</tr>-->
												</table> 
							  </div>
										</div>
								<?php 
										$lp=1;
										foreach($po_ent_id as $ct)
										{				
											$SLCT = "SELECT * FROM master_cat WHERE statu_s = 'active' AND master_cat_id = '$cat_ids1[$lp]' ORDER BY master_cat_id ASC";
											$QURY = mysqli_query($connect,$SLCT);			
											$FTCH = mysqli_fetch_object($QURY);				
											
											$tot_unit_pr = $cat_ids_tot1[$lp] * $cat_ids_unit_prc1[$lp];
											$tot_bill_amt =$tot_bill_amt + $tot_unit_pr;
								?>
											<input name="po_del_id[<?php echo $lp ?>]" id="po_del_id<?php echo $lp ?>" type="hidden" value="<?php echo $po_del_id[$lp]; ?>" />											
											<input name="po_ids_s[<?php echo $lp ?>]" id="po_ids_s<?php echo $lp ?>" type="hidden" value="<?php echo $ct; ?>" />
											<input name="cat_id[<?php echo $lp ?>]" id="cat_id<?php echo $lp ?>" type="hidden" value="<?php echo $cat_ids1[$lp]; ?>" />
											<input name="cat_name[<?php echo $lp ?>]" id="cat_name<?php echo $lp ?>" type="hidden" value="<?php echo $FTCH->master_cat_name; ?>" />
											<input name="nofdes[<?php echo $lp ?>]" id="nofdes<?php echo $lp ?>" type="hidden" value="<?php echo $cat_ids_tot1[$lp]; ?>" />
											<input name="unitpr[<?php echo $lp ?>]" id="unitpr<?php echo $lp ?>" type="hidden" value="<?php echo $cat_ids_unit_prc1[$lp]; ?>" />
											<input name="tot_pr[<?php echo $lp ?>]" id="tot_pr<?php echo $lp ?>" type="hidden" value="<?php echo $tot_unit_pr; ?>" />
								<?php
											$lp++;
										}
									}
									if(isset($_GET['biltype_id']))
									{ 
								?>
								        <div class="fluid" id="but_area">
											<div class="widget">
										        <input type="hidden" value="<?php echo $loop_cnt; ?>" id="loop_cnt" name="loop_cnt"/>
									            <input type="hidden" value="<?php echo $biltype_id ?>" id="bill_typ_id" name="bill_typ_id"/> 
									           	<div class="formRow">
									           		<input type="button" value="Generate Bill" class="buttonM bBlack formSubmit" onclick="checkTheBox(<?php echo $biltype_id ?>);" 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 class="clear"></div>
								            </div>
								        </div>
					       		<?php 
					       			} 
					       		?> 
					       </div>
					   	</div>
					</fieldset>
				</form>        
				<div class="fluid"><!-- Media table --></div>
			</div>
			<!-- Main content ends -->
		</div>
		<!-- Content ends -->
		<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
	</body>
</html>
