<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
	
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php echo $PROJECT_TITLE ?></title>

<script type="text/javascript" src="js/po_delivery_upd_JS.js"></script>
<script type="text/javascript" src="js/cnt_chkbox_JS.js"></script>

<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.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 onload="document.getElementById('listpage').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="home.php">Dashboard</a></li>
                <li><a href="javascript:">Purchase Order Delivery</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="po_delivery_list.php" id="listpage" title="List Purchase Order Delivery" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
    	</ul>            
  		<?php
		$po_id	=	base64_decode(base64_decode(base64_decode($_GET['po_id'])));
		$po_del_id	=	base64_decode(base64_decode(base64_decode($_GET['po_del_id'])));
		//echo $po_del_id;
		$page_id= base64_encode(base64_encode(base64_encode(2))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for add		 
		
		$SLCT_po = "SELECT * FROM po_entry WHERE po_entry_id='$po_id'";
		//echo $SLCT_po;
		$QURY_po = mysqli_query($connect,$SLCT_po);
		$FTCH_po = mysqli_fetch_object($QURY_po);	
		
		$SLCT_pod = "SELECT * FROM po_delivery WHERE po_delivery_id='$po_del_id'";
		$QURY_pod = mysqli_query($connect,$SLCT_pod);
		$FTCH_pod = mysqli_fetch_object($QURY_pod);			
		
		$SLCT_tp = "SELECT * FROM party_det WHERE party_det_id = '$FTCH_po->party_det_id'";
		//echo $SLCT_tp;
		$QURY_tp = mysqli_query($connect,$SLCT_tp);
		$FTCH_tp = mysqli_fetch_object($QURY_tp);
		$po_id_en	=	base64_encode(base64_encode(base64_encode($po_id)));			 
		?>

    	<!-- Chart --><!-- 6 + 6 -->
        <form id="validate" name="checklist" class="main" method="post" action="bl/po_delivery_BL.php?po_en_id=<?php echo $po_id_en; ?>&page_id=<?php echo $page_id; ?>" onsubmit="checkTheBox();">
		<fieldset>
		<input name="po_id" type="hidden" value="<?php echo $po_id;?>" />
		<input name="po_del_id" type="hidden" value="<?php echo $po_del_id;?>" />
        <div class="fluid">
            <div class="widget">
                <div class="formRow">
                    <div class="grid2"><label>PO No:<span class="req"></span></label></div>
                    <div class="grid4"><input type="text" value="<?php echo $FTCH_po->po_no; ?>" name="po_no" id="po_no" readonly="readonly" disabled="disabled"/></div><div class="clear"></div>
                </div>
                
                 <?php if($admin_flagg==1){ ?>
                <div class="formRow">
                    <div class="grid2"><label>Company Code / Name:<span class="req"></span></label></div>
                    <div class="grid4"><input type="text" value="<?php echo $FTCH_tp->party_code. " / " . $FTCH_tp->cmp_name; ?>" name="cmp_nam" id="cmp_nam" disabled="disabled" readonly="readonly"/></div><div class="clear"></div>                
                </div>
                 <?php }else if($admin_flagg==2){ ?>
                 <div class="formRow">
                    <div class="grid2"><label>Company Code :<span class="req"></span></label></div>
                    <div class="grid4"><input type="text" value="<?php echo $FTCH_tp->party_code; ?>" name="cmp_nam" id="cmp_nam" disabled="disabled" readonly="readonly"/></div><div class="clear"></div>                
                </div>
                 <?php } ?>
                                
                <div class="formRow">
                    <div class="grid2"><label>Order Date:<span class="req"></span></label></div>
                    <div class="grid4"><input type="text" value="<?php echo str_replace("-","/",$FTCH_po->po_date); ?>" name="pod" id="pod" readonly="readonly" disabled="disabled"/></div><div class="clear"></div>
                </div>
                <div class="formRow">
                    <div class="grid2"><label>Delivery Date:<span class="req"></span></label></div>
                    <div class="grid4"><?php echo str_replace("-","/",$FTCH_pod->delivery_date); ?></div><div class="clear"></div>
                </div>
            </div>
        </div>
        
    	
        <div class="widget"> <!--style="width:600px; margin-left:150px;"-->
        <div class="whead"><span class="titleIcon check"><input type="checkbox" id="titleCheck" name="titleCheck" onclick="ckall(),tot_admt_cal1();" onfocus="foc(this.id)" onblur="stnon(this.id)"/></span><h6>Design List</h6><h6 style="float:right; margin-right:50px;"><input type="text" id="cnt_chk" name="cnt_chk" value="" readonly="readonly" disabled="disabled" style="width:50px; font-size:12px; text-align:center;" /></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 check" id="checkAll">
                <thead>
                    <tr>
                        <td width="20"><img src="images/elements/other/tableArrows.png" alt="" /></td>
                        <th width="26">S.No<span class="sorting" style="display: block;"></span></th>
                        <th width="95">Design No</th>
                        <th width="95" align="center">No of Dies</th>
                         <?php if($admin_flagg==1){ ?>
                        <th width="88">Cost</th>
                        <?php } ?>
                        <th width="78">Image</th>
                       <!-- <th width="60">Remarks</th>-->   
                    </tr>
                </thead>
            <tbody>
            <?php
			$loop=1;
			$SLCT_t = "SELECT  * FROM po_delivery_det WHERE cancelled ='no' AND po_delivery_id = '$po_del_id' ORDER BY design_det_id ASC";
			//echo $SLCT_t;
			$QURY_t = mysqli_query($connect,$SLCT_t);
			if(mysqli_num_rows($QURY_t)>0)
			{
			while($FTCH = mysqli_fetch_object($QURY_t))
			{			
				
						$design_id	=	base64_encode(base64_encode(base64_encode($FTCH->design_det_id)));
						
						$SLCT_c = "SELECT  * FROM design_det WHERE design_det_id = '$FTCH->design_det_id'";
						$QURY_c = mysqli_query($connect,$SLCT_c);
						$FTCH_c = mysqli_fetch_object($QURY_c);
						
						$SLCT_d = "SELECT  * FROM master_cat WHERE master_cat_id = '$FTCH_c->master_cat_id'";
						$QURY_d = mysqli_query($connect,$SLCT_d);
						$FTCH_d = mysqli_fetch_object($QURY_d);
						
						$SLCT_dt = "SELECT * FROM design_det WHERE design_det_id = '$FTCH->design_det_id'"; 
						$QURY_dt = mysqli_query($connect,$SLCT_dt);
						$FTCH_dt = mysqli_fetch_object($QURY_dt);			
															
						
						if($loop%2 != "0")
							$bg = "gradeX";
						else
							$bg = "class='gradeC'";
						 if($FTCH_dt->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH_dt->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH_dt->mas_fin_ext; }

						else if($FTCH_dt->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH_dt->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH_dt->cad_fin_ext; }
						
						else if($FTCH_dt->imag_ext!=''){ $imag = "../design_images/S.".$FTCH_dt->imag_ext; $imag1 = "../design_images/L.".$FTCH_dt->imag_ext; }
			?>
                            <tr <?php echo $bg ?>>
                                <td style="display:table-cell;vertical-align:middle;">
								<input type="checkbox" name="category[]" id="category<?php echo $loop ?>" value="<?php echo $FTCH->design_det_id ?>" onchange="cnt_chk_fn(<?php echo $loop ?>),tot_admt_cal(<?php echo $loop ?>);" onfocus="foc(this.id)" onblur="stnon(this.id)"/></td>
                                <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $loop ?></td>
                                <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_d->master_cat_name." ".$FTCH_dt->design_no; ?></td>
                               	<td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_dt->master_pieces; ?></td>
                               	<?php /*?> <td align="center" style="display:table-cell;vertical-align:middle"><?php if($num_rows>0){ echo $FTCH_cd->cost_val; ?><input type="hidden" name="cost_val[<?php echo $loop ?>]" id="cost_val<?php echo $loop ?>" value="<?php echo $FTCH_cd->cost_val; ?>" /> <?php } else { echo "Cost Empty";?><input type="hidden" name="cost_val[<?php echo $loop ?>]" id="cost_val<?php echo $loop ?>" value="empty" /><?php }?></td><?php */?>
                                 <?php if($admin_flagg==1){ ?>
                                <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH->cost_val; ?>
								<input type="hidden" name="cost_val[<?php echo $loop ?>]" id="cost_val<?php echo $loop ?>" value="<?php echo $FTCH->cost_val; ?>" /></td>
                               	<?php } else if($admin_flagg==2){ ?>
                                <input type="hidden" name="cost_val[<?php echo $loop ?>]" id="cost_val<?php echo $loop ?>" value="<?php echo $FTCH->cost_val; ?>" /></td>
                                <?php } ?>
							   <?php /*?> <td class="center" align="center"><a href=""><img src="design_images/S.<?php echo $FTCH_dt->imag_ext; ?>" width="60" height="60"/></a></td> <?php */?>
                                <td class="center" align="center">
                                	<div class="body" align="center">
                                        <a href="<?php echo $imag1; ?>" class="lightbox" rel="group" title="<?php echo $FTCH_d->master_cat_name." ".$FTCH_dt->design_no; ?>"><img src="<?php echo $imag; ?>" width="60" height="60"/></a>
                                    </div>
                              	</td>                             
                            </tr>
            
            <?php
				$loop ++;
				}
			}
			?>
            </tbody>
            </table> 
        </div>
        </div>    
       
         <?php if(mysqli_num_rows($QURY_t)>0){ ?>
        <div class="fluid">
		<div class="widget">
           <div class="formRow">
           		<div class="grid2"><label>Total Cost:<span class="req"></span></label></div>
            	<div class="grid2"><input type="text" value="" name="tot_cost" id="tot_cost" readonly="readonly" disabled="disabled"/></div>
           		<input type="button" value="Submit" class="buttonM bBlack formSubmit" onclick="checkTheBox();" 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 } ?>  
       
       
        </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>
