<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	$pg_id = $_GET['pg_id'];
	$page_id = base64_decode(base64_decode(base64_decode(base64_decode($pg_id))));
	$pag_id = $pg_id;
?>
<!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>

<link href="css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></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="https://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.dataTables.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>
<script type="text/javascript">
function foc(ids)
{
	document.getElementById(ids).style.border="2px solid #0099FF";
	
}

function stnon(ids)
{
	document.getElementById(ids).style.border="thin solid #CCCCCC";
}
</script>
<!-- Shared on MafiaShare.net  --><!-- Shared on MafiaShare.net  --></head>

<body onload="document.getElementById('searchlink').focus();">

<!-- 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="#">Dashboard</a></li>
                <li><a href="javascript:">Pending List</a></li>
            </ul>
        </div>
	<?php include "menus/top_left_menu.php"; ?>            
        
    </div>
    
    <!-- Main content -->
    <div class="wrapper">
    
       <?php /*?> <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="acc_add.php" title="Add Accounts" 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="#" title="Check statistics" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>-->
    	</ul>      <?php */?>      
    
    	<!-- Chart --><!-- 6 + 6 -->

    	<div class="widget"> <!--style="width:600px; margin-left:150px;"-->
        <div class="whead"><h6><?php if($page_id == 1){ echo "Order Finishing Pending List"; } else if($page_id == 2){ echo "Order Delivery Pending List";  } else if($page_id == 3){ echo "Stock Pending List";  }else if($page_id == 4){ echo "Bill Pending List";  } ?></h6><div class="clear"></div></div>
        <div id="dyn" class="hiddenpars">
        	<a href="javascript:0" id="searchlink" onfocus="foc(this.id)" onblur="stnon(this.id)" class="tOptions" title="Options"><img src="images/icons/options.png" alt="" /></a>
            <table cellpadding="0" cellspacing="0" border="0" class="dTable" id="dynamic">
            <thead>
            <tr>
			<?php
			if($page_id != 3)
			{
			?>
            	<th width="26">S.No<span class="sorting" style="display: block;"></span></th>
            <?php
				if($admin_flagg==1)
				{
			?>	
					<th width="68">Party Code</th>
					<th width="211">Party Name</th>
			<?php
					if($page_id != 4)
					{
			?>
					<th width="90">Po No</th>
					<th width="90">Po Qty.</th>
					<th width="90">Fin Qty.</th>
			<?php
						if($page_id == 2)
						{
			?>
						<th width="90">Del Qty.</th>
			<?php
						}
					}
			?>
					<th width="90">Pending Qty.</th>
					<th width="90">Cost</th>
            <?php
				}
				else if($admin_flagg==2)
				{
			?>
					<th width="68">Party Code</th>
					<th width="90">Po No</th>
					<th width="90">Pending Qty.</th>
			<?php
				}
			}
			else
			{
			?>
				<th width="26">S.No<span class="sorting" style="display: block;"></span></th>
				<th width="68">Design No</th>
				<th width="20">Design Qty</th>
				<th width="68">No of Moulds</th>				
				<th width="20">Status</th>
				<th width="90">Image</th>
			<?php
			}
			?>
            </tr>
            </thead>
            <tbody>
            <?php
			$loop = 1;
			if($page_id==1) // THIS IS FOR FINISHED PENDING VIEW 
			{	
				$SLCT = "SELECT *,COUNT(`po_entry_id`) AS cont,IFNULL(SUM(master_pieces),'0') AS tot_pic FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry_det.fin_status ='no' AND po_entry_det.cancelled='no' GROUP BY po_entry_id ASC";
				$QURY = mysqli_query($connect,$SLCT);
				while($FTCH = mysqli_fetch_object($QURY))
				{
					$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_det.cancelled = 'no' AND po_entry_id = '$FTCH->po_entry_id'";
					//echo $SLCT_t;
					$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 po_entry_det.cancelled = 'no' AND po_entry_det.fin_status = 'yes' AND po_entry_id = '$FTCH->po_entry_id'";
					$QURY_d = mysqli_query($connect,$SLCT_d);
					$FTCH_d = mysqli_fetch_object($QURY_d);
					
					$fin_pen_amt = 0;
					$SLCT3 = "SELECT * FROM po_entry_det WHERE fin_status ='no' AND cancelled='no' AND po_entry_id='$FTCH->po_entry_id' ORDER BY po_entry_det_id ASC";
					$QURY3 = mysqli_query($connect,$SLCT3);
					while($FTCH3 = mysqli_fetch_object($QURY3))
					{				
						$SLCT_E = "SELECT * FROM po_entry,party_det WHERE party_det.party_det_id = po_entry.party_det_id AND po_entry.po_entry_id = '$FTCH3->po_entry_id'"; 
						//echo $SLCT_E."<br/>";
						$QURY_E = mysqli_query($connect,$SLCT_E);
						$FTCH_E = mysqli_fetch_object($QURY_E);
						
						$SLCT_E1 = "SELECT * FROM party_cost_det WHERE party_det_id = '$FTCH_E->party_det_id' AND master_cat_id = '$FTCH3->master_cat_id' AND updated = 'no'"; 
						$QURY_E1 = mysqli_query($connect,$SLCT_E1);
						if(mysqli_num_rows($QURY_E1)>0)
						{
							$FTCH_E1 = mysqli_fetch_object($QURY_E1);							
							$fin_pen_amt = $fin_pen_amt +$FTCH_E1->cost_val;
						}
						else
						{
							$fin_pen_amt = $fin_pen_amt + 0;
						}
					}
									
					$SLCT_E = "SELECT * FROM po_entry,party_det WHERE party_det.party_det_id = po_entry.party_det_id AND po_entry.po_entry_id = '$FTCH->po_entry_id'"; 
					//echo $SLCT_E."<br/>";
					$QURY_E = mysqli_query($connect,$SLCT_E);
					$FTCH_E = mysqli_fetch_object($QURY_E);
					
					$po_id = base64_encode(base64_encode(base64_encode(base64_encode($FTCH->po_entry_id))));
					
					if($loop%2 != "0")
						$bg = "gradeX";
					else
						$bg = "class='gradeC'";
			?>
           
					<tr <?php echo $bg ?>>
					<td align="center"><?php echo $loop ?></td>
                    <?php
					if($admin_flagg==1)
					{
					?>
					<td align="center"><?php echo $FTCH_E->party_code; ?></td>
					<td align="center"><?php echo $FTCH_E->cmp_name; ?></td>
					<td align="center"><?php echo $FTCH_E->po_no; ?></td>
					<td align="center"><?php echo $FTCH_t->tot_cnt; ?><br><span title="No of Master Pieces for PO 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 Finish Designs">(<?php echo $FTCH_d->tot_pic; ?>)</span></td>
					<td align="center"><a id="viewlink2<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="pending_list_view.php?code_no=<?php echo $pag_id ?>&po_id=<?php echo $po_id ?>" class="an_own"><?php echo $FTCH->cont; ?></a><br><span title="No of Master Pieces for Pending Designs">(<?php echo $FTCH->tot_pic; ?>)</span></td>
            		<td align="right"><?php echo number_format($fin_pen_amt,2);$fin_pen_amt=0; ?></td>
                    <?php
					}
					else if($admin_flagg==2)
					{
					?>
                    <td align="center"><?php echo $FTCH_E->party_code; ?></td>
					<td align="center"><?php echo $FTCH_E->po_no; ?></td>
					<td align="center"><a id="viewlink2<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="pending_list_view.php?code_no=<?php echo $pag_id ?>&po_id=<?php echo $po_id ?>" class="an_own"><?php echo $FTCH->cont; ?></a></td>
            		<?php
					}
					?>
                </tr>            
            <?php
					$loop ++;
				}
			}
			else if($page_id==2) // THIS IS FOR DELIVERED PENDING VIEW 
			{
				$SLCT = "SELECT *,COUNT(`po_entry_id`) AS cont,IFNULL(SUM(master_pieces),'0') AS tot_pic FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry_det.fin_status ='yes' AND po_entry_det.del_status= 'no' AND po_entry_det.cancelled='no' GROUP BY po_entry_id ASC";
				$QURY = mysqli_query($connect,$SLCT);
				while($FTCH = mysqli_fetch_object($QURY))
				{		
					$SLCT_t = "SELECT COUNT(po_entry_det_id) AS tot_cnt,IFNULL(SUM(master_pieces),'0') AS tot_pic FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry_det.cancelled = 'no' AND po_entry_id = '$FTCH->po_entry_id'";
					//echo $SLCT_t;
					$QURY_t = mysqli_query($connect,$SLCT_t);
					$FTCH_t = mysqli_fetch_object($QURY_t);
					
					$SLCT_d = "SELECT  COUNT(po_entry_det_id) AS fin_cnt,IFNULL(SUM(master_pieces),'0') AS tot_pic FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry_det.cancelled = 'no' AND po_entry_det.fin_status = 'yes' AND po_entry_id = '$FTCH->po_entry_id'";
					$QURY_d = mysqli_query($connect,$SLCT_d);
					$FTCH_d = mysqli_fetch_object($QURY_d);
					
					$SLCT_d2 = "SELECT  COUNT(po_entry_det_id) AS del_cnt,IFNULL(SUM(master_pieces),'0') AS tot_pic FROM po_entry_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry_det.cancelled = 'no' AND po_entry_det.del_status = 'yes' AND po_entry_id = '$FTCH->po_entry_id'";
					$QURY_d2 = mysqli_query($connect,$SLCT_d2);
					$FTCH_d2 = mysqli_fetch_object($QURY_d2);
					
					$del_pen_amt = 0;
					$SLCT4 = "SELECT * FROM po_entry_det WHERE fin_status ='yes' AND del_status= 'no' AND cancelled='no' AND po_entry_id = '$FTCH->po_entry_id' ORDER BY po_entry_det_id ASC";
					$QURY4 = mysqli_query($connect,$SLCT4);
					while($FTCH4 = mysqli_fetch_object($QURY4))
					{				
						$SLCT_E = "SELECT * FROM po_entry,party_det WHERE party_det.party_det_id = po_entry.party_det_id AND po_entry.po_entry_id = '$FTCH4->po_entry_id'"; 
						$QURY_E = mysqli_query($connect,$SLCT_E);
						$FTCH_E = mysqli_fetch_object($QURY_E);
						
						$SLCT_E1 = "SELECT * FROM party_cost_det WHERE party_det_id = '$FTCH_E->party_det_id' AND master_cat_id = '$FTCH4->master_cat_id' AND updated = 'no'"; 
						$QURY_E1 = mysqli_query($connect,$SLCT_E1);
						if(mysqli_num_rows($QURY_E1)>0)
						{
							$FTCH_E1 = mysqli_fetch_object($QURY_E1);
							
							$del_pen_amt = $del_pen_amt +$FTCH_E1->cost_val;
						}
					}
												
					$SLCT_E = "SELECT * FROM po_entry,party_det WHERE party_det.party_det_id = po_entry.party_det_id AND po_entry.po_entry_id = '$FTCH->po_entry_id'"; 
					//echo $SLCT_E."<br/>";
					$QURY_E = mysqli_query($connect,$SLCT_E);
					$FTCH_E = mysqli_fetch_object($QURY_E);
					
					$po_id = base64_encode(base64_encode(base64_encode(base64_encode($FTCH->po_entry_id))));
					
					if($loop%2 != "0")
						$bg = "gradeX";
					else
						$bg = "class='gradeC'";
			?>
           
					<tr <?php echo $bg ?>>
					<td align="center"><?php echo $loop ?></td>
                    <?php
					if($admin_flagg==1)
					{
					?>
					<td align="center"><?php echo $FTCH_E->party_code; ?></td>
					<td align="center"><?php echo $FTCH_E->cmp_name; ?></td>
					<td align="center"><?php echo $FTCH_E->po_no; ?></td>
					<td align="center"><?php echo $FTCH_t->tot_cnt; ?><br><span title="No of Master Pieces for PO 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 Finish Designs">(<?php echo $FTCH_d->tot_pic; ?>)</span></td>
					<td align="center"><?php echo $FTCH_d2->del_cnt; ?><br><span title="No of Master Pieces for Delivery Designs">(<?php echo $FTCH_d2->tot_pic; ?>)</span></td>
					<td align="center"><a id="viewlink2<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="pending_list_view.php?code_no=<?php echo $pag_id ?>&po_id=<?php echo $po_id ?>" class="an_own"><?php echo $FTCH->cont; ?></a><br><span title="No of Master Pieces for Pending Designs">(<?php echo $FTCH_t->tot_pic; ?>)</span></td>
            		<td align="right"><?php echo number_format($del_pen_amt,2);$del_pen_amt=0; ?></td>
                    <?php
					}
					else if($admin_flagg==2)
					{
					?>
					<td align="center"><?php echo $FTCH_E->party_code; ?></td>
					<td align="center"><?php echo $FTCH_E->po_no; ?></td>
					<td align="center"><a id="viewlink2<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="pending_list_view.php?code_no=<?php echo $pag_id ?>&po_id=<?php echo $po_id ?>" class="an_own"><?php echo $FTCH->cont; ?></a><br><span title="No of Master Pieces for Pending Designs">(<?php echo $FTCH_t->tot_pic; ?>)</span></td>
            		<?php
					}
					?>
                </tr>            
            <?php
					$loop ++;
				}
			}	
			else if($page_id==3) // THIS IS FOR STOCK PENDING VIEW 
			{
				$SLCT = "SELECT *,COUNT(*) AS des_cnt,IFNULL(SUM(master_pieces),'0') AS tot_pic FROM stock_det,design_det WHERE st_fin_status ='no' AND design_det.design_det_id = stock_det.design_det_id GROUP BY design_det.design_det_id ORDER BY design_det.master_cat_id,design_det.design_det_id ASC";
				//echo $SLCT;
				$QURY = mysqli_query($connect,$SLCT);
				while($FTCH = mysqli_fetch_object($QURY))
				{						
					$SLCT_E1 = "SELECT * FROM master_cat WHERE master_cat_id = '$FTCH->master_cat_id'"; 
					//echo $SLCT_E1;
					$QURY_E1 = mysqli_query($connect,$SLCT_E1);
					$FTCH_E1 = mysqli_fetch_object($QURY_E1);
					
					if($loop%2 != "0")
						$bg = "gradeX";
					else
						$bg = "class='gradeC'";
						
					if($FTCH->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH->mas_fin_ext; }
	
					else if($FTCH->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH->cad_fin_ext; }
				
					else if($FTCH->imag_ext!=''){ $imag = "../design_images/S.".$FTCH->imag_ext; $imag1 = "../design_images/L.".$FTCH->imag_ext; }
			?>
           
					<tr <?php echo $bg ?>>
					<td align="center" style="vertical-align:middle; display:table-cell;"><?php echo $loop ?></td>
					<td align="center" style="vertical-align:middle; display:table-cell;"><?php echo $FTCH_E1->master_cat_name." ".$FTCH->design_no; ?></td>
					<td align="center" style="vertical-align:middle; display:table-cell;"><?php echo $FTCH->des_cnt; ?></td>
					<td align="center" style="vertical-align:middle; display:table-cell;"><?php echo $FTCH->tot_pic; ?></td>
					<td align="center" style="vertical-align:middle; display:table-cell;"><?php echo $FTCH->design_status; ?></td>
					<td align="center" style="vertical-align:middle; display:table-cell;"><a href="<?php echo $imag1; ?>" title="<?php echo $FTCH_E1->master_cat_name." ".$FTCH->design_no; ?>" class="lightbox" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a></td>
                </tr>            
            <?php
					$loop ++;
				}
			}	
			else if($page_id==4) // THIS IS FOR BILL PENDING VIEW 
			{	
				$bil_pen_amt = 0;
				$bill_cst=0;
				$SLCT_ppo = "SELECT IFNULL(SUM(master_pieces),'0') AS tot_pic,GROUP_CONCAT(DISTINCT po_entry.po_entry_id) AS po_entry_id, GROUP_CONCAT(DISTINCT po_entry_det.master_cat_id) AS mas_cat_id, party_det.party_det_id, po_entry_det.master_cat_id,party_code,cmp_name, COUNT(po_entry_det_id) AS cont FROM po_entry, po_entry_det,party_det,design_det WHERE design_det.design_det_id=po_entry_det.design_det_id AND po_entry.party_det_id = party_det.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' GROUP BY party_det.party_det_id";
				$QURY_ppo = mysqli_query($connect,$SLCT_ppo);
				while($FTCH_ppo = mysqli_fetch_object($QURY_ppo))
				{
					$SLCT_pr = "SELECT cost_val FROM po_delivery,po_delivery_det WHERE po_delivery.po_entry_id IN($FTCH_ppo->po_entry_id) AND po_delivery_det.po_delivery_id = po_delivery.po_delivery_id AND po_delivery_det.master_cat_id IN($FTCH_ppo->mas_cat_id)";
					$QURY_pr = mysqli_query($connect,$SLCT_pr);
					while($FTCH_pr = mysqli_fetch_array($QURY_pr))
					{
						$bill_cst = $bill_cst+$FTCH_pr['cost_val'];
					}
						
					$po_id = base64_encode(base64_encode(base64_encode(base64_encode($FTCH_ppo->party_det_id))));
					if($loop%2 != "0")
						$bg = "gradeX";
					else
						$bg = "class='gradeC'";
			?>
           
					<tr <?php echo $bg ?>>
						<td align="center"><?php echo $loop ?></td>
						<?php
						if($admin_flagg==1)
						{
						?>
							<td align="center"><?php echo $FTCH_ppo->party_code; ?></td>
							<td align="center"><?php echo $FTCH_ppo->cmp_name; ?></td>
							<td align="center"><a id="viewlink2<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="pending_list_view.php?code_no=<?php echo $pag_id ?>&po_id=<?php echo $po_id ?>" class="an_own"><?php echo $FTCH_ppo->cont; ?></a><br><span title="No of Master Pieces for Pending Designs">(<?php echo $FTCH_ppo->tot_pic; ?>)</span></td>
							<td align="right"><?php echo number_format($bill_cst,2); $bill_cst=0;?></td>
						<?php
						}
						?>
					</tr>            
	<?php
					$loop ++;					
				}
			}	
			?>
            </tbody>
            </table> 
        </div>
        </div>    
        
        <div class="fluid"><!-- Media table --></div>
        
        
        
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
