<?php
	//Start session
	session_start();
	
	//Check whether the session variable SESS_MEMBER_ID is present or not
	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		header("location: index.php");
		exit();
	}
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<title>PRODUCT ENTRY</title>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="../javascript/jquery.js"></script>
<script type="text/javascript" src="../javascript/prodentry_rel.js"></script>
<script type="text/javascript" src="../javascript/jquery.autocomplete.js"></script>
<script type="text/javascript" src="../javascript/numbertowords.js"></script>
<script type="text/javascript" src="../javascript/jquery.datepick.min.js"></script>
<script type="text/javascript" src="../javascript/jNotify.jquery.js"></script>
<script type="text/javascript" src="../javascript/jNotify.jquery.min.js"></script>
<script type="text/javascript" src="../javascript/jquery.uploadfile.min.js"></script>

<link rel="stylesheet" href="../css/jNotify.jquery.css" type="text/css" />
<link rel="stylesheet" href="../css/redmond.datepick.css" />
<link rel="stylesheet" href="../css/jquery.autocomplete.css" type="text/css" />
<link rel="stylesheet" href="../css/jNotify.jquery.css" type="text/css" />
<link rel="stylesheet" href="../css/style.css"  type="text/css" />
<link rel="stylesheet" type="text/css" href="../javascript/tooltip/css/tooltipster.bundle.min.css" />
<link href="../css/uploadfile.css" rel="stylesheet">

    <script type="text/javascript" src="../javascript/tooltip/js/tooltipster.bundle.min.js"></script>

<script type="text/javascript">
function myFunction()
{
alert("Module not available in demo version");
}
</script>
<style type="text/css">

input[type=text],textarea{
	width:100%
}

.showtotal{
	display:none;
}

</style>
</head>

<body>

<table style="display:none">
<tr  id="prototype"><td style='display:none'><textarea style='height: 32px;' name='entryid_pv[]' class='entryid_pv'></textarea></td><td></td><td><textarea style='height: 32px;' name='size_pv[]' class='size_pv'></textarea></td><td><textarea style='height: 32px;' name='price_pv[]' class='price_pv'></textarea></td><td><textarea style='height: 32px;' name='mrp_pv[]' class='mrp_pv'></textarea></td> <td><textarea name='qnty_pv[]' style='height: 32px;' class='qnty_pv'></textarea></td><td><textarea name='fresh_pv[]' style='height: 32px;' class='fresh_pv'></textarea></td><td><textarea style='height: 32px;' name='reprocess_pv[]' class='reprocess_pv'></textarea></td></tr></table>

<input  id="inline_edit" type="hidden" value="0"  />

<!--popup start-->
<div id="popDiv" class="ontop">
  <table border="1" id="popup">
    <tr >
      <td align="right" valign="middle" height="5%" ><a href="javasctipt:void()" onClick="$('.ontop').hide();$('.ajax-file-upload-statusbar').remove()"> x</a></td>
    </tr>
    <tr>
      <td align="center" valign="middle"><input type="hidden" id="doc_entryid" value=""/>
        <div id="mulitplefileuploader">Choose </div>
        <input id="file_up" value="Upload" type="button"/></td>
    </tr>
    <tr>
      <td align="center" valign="middle"><div id="att_view"></div></td>
    </tr>
  </table>
</div>
<!--popup end-->
<div id="transperent">
</div>

      <?php 
	    
		
  include '../db_connect.php';

$prodid= $_GET['id'];
$table='';
$sizeTable='';
if(($result = mysqli_query($con,"SELECT * FROM prodreg  where id='$prodid'"))&&(!empty($prodid)))
{
	$totpcost=0;
	$totscost=0;
$row = mysqli_fetch_array($result);

if($result = mysqli_query($con,"SELECT * FROM commst  where compid='$row[client]'"))
$client_detrow = mysqli_fetch_array($result);



if(($result_det = mysqli_query($con,"SELECT * FROM proddet  where srno='$prodid' order by srno"))&&(!empty($prodid))){
		$pcdArray = $_SESSION['SESS_PCD'];
	
		$table="<div id='form_bookdetails'><table width='100%' id='msview'  cellpadding='0' cellspacing='0' style='table-layout: fixed;
width: 98.7%;'>
		<thead>
			<tr >
            <th  width='10%'>$pcdArray[RMCODE]</th>
			<th style='height: 32px;' width='9%'>SKU ID</th>
			<th  width='15%'>$pcdArray[DESC]</th>
			<th style='height: 32px;' width='5%'>Qty</th>
			<th style='height: 32px;' width='5%'>Unit</th>
			<th style='height: 32px;' width='8%'>Rate</th>
			<th style='height: 32px;' width='8%'>Amount</th>
			<th style='height: 32px;' width='10%'>Remark</th>			
			<th style='height: 32px;' width='5%'></th>
			<th style='height: 32px;' width='5%'></th>
			</tr>
			</thead><tbody>";
while($row_det = mysqli_fetch_array($result_det)){
			$totpcost+=$row_det['psrate'];
			$pamount+=$row_det['pamount'];
			$qty+=$row_det['qty'];
			$sr_track=$row_det['srno'];
			$table.="<tr>
			<td style='display:none'><textarea name='entryid'>$row_det[entryid]</textarea></td>
			<td style='display:none'><textarea name='srno'>$row_det[srno]</textarea></td>
			<td style='display:none'><textarea name='jobid'>$prodid</textarea></td>
			<td width='10%'><textarea style='height: 32px; width:100%;' name='rmcode' class='rmcode' >$row_det[rmcode]</textarea></td>
			<td width='9%'><textarea style='height: 32px;' name='skuid' class='skuid'>$row_det[skuid]</textarea></td>
			<td width='15%'><textarea style='height: 32px;' name='descrip' class='descrip'>$row_det[descrip]</textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='qty' class='qty' >$row_det[qty]</textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='unit' class='unit' >$row_det[unit]</textarea></td>
			<td width='8%'><textarea style='height: 32px;' name='psrate' class='psrate' >$row_det[psrate]</textarea></td>
			<td width='8%'><textarea style='height: 32px;' name='pamount' class='pamount' >$row_det[pamount]</textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='remarks' class='remarks' >$row_det[remarks]</textarea></td>
			<td width='5%'><input type='button' id='edit' value='SAVE' class='edit filter_table' style='display:none'/></td>
			<td width='5%'><input type='button' class='deletedet  filter_table' value='X' /></td>
			</tr>";
							
}

			$sizeset_spilt = explode(",",$row['sizesetcode']);
			$ratio_spilt = explode(",",$row['ratio']);
			$diffprice_spilt = explode(",",$row['diffprice']);
			$diffmrp_spilt = explode(",",$row['diffmrp']);
			
			$sizeSQL = "SELECT * FROM prodvar  where `prodname` = '$row[code]'  order by entryid";
			if(($prodvar_data = mysqli_query($con,$sizeSQL))){
			$tr ='';
			$index=1;
			$rtind=1;
			$ind=0;
			
			$diffprice = $row[ptotal];
			
			$diffmrp = $row[grtotal];
			$sp1 = 0; 
			$sp2 = 0;
			$wsp1 = 0; 
			$wsp2 = 0;
			while($prodvar_row = mysqli_fetch_array($prodvar_data)){
				
				
					
				$priceval = round((($row[ptotal])*($diffprice_spilt[$ind]/100))+$row[ptotal]);
				$priceval2 = round((($priceval)*($diffprice_spilt[$ind]/100))+$priceval);
				$priceval3 = round((($priceval2)*($diffprice_spilt[$ind]/100))+$priceval2);
				
				if(trim($prodvar_row[size])>=42&&trim($prodvar_row[size])<=46){
				$diffprice = $priceval;}
				else if(trim($prodvar_row[size])>=48&&trim($prodvar_row[size])<=52){
				$diffprice = $priceval2;}
				else if(trim($prodvar_row[size])>53){
				$diffprice = $priceval3;}
				else if(trim($prodvar_row[size])=="3XL"||trim($prodvar_row[size])=="4XL"||trim($prodvar_row[size])=="5XL"||trim($prodvar_row[size])=="6XL"){
				$diffprice = $priceval;}
				
				
				$mrpval = round((($row[grtotal])*($diffmrp_spilt[$ind]/100))+$row[grtotal]);
				$mrpval2 = round((($mrpval)*($diffmrp_spilt[$ind]/100))+$mrpval);
				$mrpval3 = round((($mrpval2)*($diffmrp_spilt[$ind]/100))+$mrpval2);
				
				if(trim($prodvar_row[size])>=42&&trim($prodvar_row[size])<=46){
				$diffmrp = $mrpval;}
				else if(trim($prodvar_row[size])>=48&&trim($prodvar_row[size])<=52){
				$diffmrp = $mrpval2;}
				else if(trim($prodvar_row[size])>53){
				$diffmrp = $mrpval3;}
				else if(trim($prodvar_row[size])=="3XL"||trim($prodvar_row[size])=="4XL"||trim($prodvar_row[size])=="5XL"||trim($prodvar_row[size])=="6XL"){
				$diffmrp = $mrpval;}
				
				
				$wsp1 = round($diffmrp *(35/100));
				$sp1 = $diffmrp -$wsp1;
				
				$wsp2 = round($diffmrp *(37/100));
				$sp2 = $diffmrp -$wsp2;
			
				
				$tr.= "<tr><td style='display:none'><textarea style='height: 32px;' name='entryid_pv[]' class='entryid_pv'>$prodvar_row[entryid]</textarea></td><td>".($index++)."</td><td><textarea style='height: 32px;' name='size_pv[]' class='size_pv'>$prodvar_row[size]</textarea></td><td><textarea style='height: 32px;' name='price_pv[]' class='price_pv'>".$diffprice."</textarea></td><td><textarea style='height: 32px;' name='mrp_pv[]' class='mrp_pv'>".$diffmrp."</textarea></td><td><textarea name='spone_pv[]' style='height: 32px;' class='spone_pv'>$sp1</textarea></td><td><textarea name='sptwo_pv[]' style='height: 32px;' class='sptwo_pv'>$sp2</textarea></td> <td><textarea name='qnty_pv[]' style='height: 32px;' class='qnty_pv'>$prodvar_row[qnty]</textarea></td><td><textarea name='fresh_pv[]' style='height: 32px;' class='fresh_pv'>$prodvar_row[fresh]</textarea></td><td><textarea style='height: 32px;' name='reprocess_pv[]' class='reprocess_pv'>$prodvar_row[reprocess]</textarea></td></tr>";
				$ratiotr.= "<tr><td style='display:none'><textarea style='height: 32px;' name='rtentryid_pv[]' class='rtentryid_pv'>$prodvar_row[entryid]</textarea></td><td>".($rtind++)."</td><td><textarea style='height: 32px;' name='rtsize_pv[]' class='rtsize_pv'>$prodvar_row[size]</textarea></td><td><textarea style='height: 32px;' name='rtratio_pv[]' class='rtratio_pv'>$ratio_spilt[$ind]</textarea></td><td><textarea style='height: 32px;' name='mrpdiff_pv[]' class='mrpdiff_pv'>$diffmrp_spilt[$ind]</textarea></td><td><textarea style='height: 32px;' name='spdiff_pv[]' class='spdiff_pv'>$diffprice_spilt[$ind]</textarea></td></tr>";
				
				$ind++;
			}
			 
		}

		$sizeTable.= "<div class='sizechartdiv' id='$row[code]' style='display:none;position:absolute'><div class='closediv'> X </div>
       <table id='sizecharttable'  style='border: 1px solid black;background-color:white' border='1' cellspacing='0'>
 	<thead><tr>
    <th>Sr. No.</th>
    <th>Size</th>
	<th>Price</th>
	<th>MRP</th>
	<th>SP1</th>
	<th>SP2</th>
    <th>Quantity</th>
	<th>Fresh</th>
    <th>Seconds</th>
  	</tr></thead>
    $tr
  </table>
</div>";


$ratioTable.= "<div class='ratiochartdiv' id='$row[code]r' style='display:none;position:absolute'><div class='closedivval'> X </div>
       <table id='ratiocharttable'  style='border: 1px solid black;background-color:white' border='1' cellspacing='0'>
 	<thead><tr>
    <th>Sr. No.</th>
    <th>Size</th>
	<th>Ratio</th>
	<th>MRP Diff..</th>
	<th>SP Diff..</th>
	
  	</tr></thead>
    $ratiotr
  </table>
</div>";

$temp=$sr_track+1;
$table.="<tr>
			<td style='display:none'><textarea name='srno'>$temp</textarea></td>
			<td style='display:none'><textarea name='jobid'>$prodid</textarea></td>
			<td width='10%'> <textarea style='height: 32px;' name='rmcode'  class='rmcode' id='rmcode'></textarea></td>
			<td width='9%'><textarea style='height: 32px;' name='skuid' class='skuid' id='skuid'></textarea></td>
			<td width='15%'><textarea style='height: 32px;' name='descrip' class='descrip' id='descrip'></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='qty' class='qty' id='qty' ></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='unit' class='unit' ></textarea></td>
			<td width='8%'><textarea style='height: 32px;' name='psrate' class='psrate'  ></textarea></td>
			<td width='8%'><textarea style='height: 32px;' name='pamount' class='pamount' id='pamount'></textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='remarks' class='remarks' id='remarks'></textarea></td>
			<td width='5%'><input type='button' id='addnew' value='SAVE' class='addnew filter_table' style='display:none'/></td>
			<td width='5%'><input type='button' value='+' class='rmnewentry filter_table' style='display:none'/></td>
			</tr>";

$table.="</tbody></table></div>".$sizeTable.$ratioTable;


}
}
function time_formatc($temp_time)
{
list($hour, $min, $sec) = explode(':', $temp_time);

return "$hour:$min";
}


function date_formatc($temp_date)
{
list($year, $month, $day) = explode('-', $temp_date);
return "$day/$month/$year";
}
?>
      
      
<div class="main">
    <div id="formbox">
        <form id="bookingform" action=""  method="">
         
         <table width="100%" border="0" height="100%" cellspacing="2">
  <tr class="master_detrow">
    <td width="12%" align="left" >Prod Name:<span style="color:red; ">*</span></td>
   <td><input type="text" name="subprdcd" id="subprdcd" tabindex="2"/><input type="hidden" class="jobid" id="jobid"  name='jobid' value="<?php echo $prodid; ?>"  /></td>
    <td>Prod code<span style="color:red; ">*</span></td>
    <td><input type="text" name="prodcode" id="prodcode" tabindex="1"  /><input type="hidden" name="classval" id="classval" class="classval"  /></td>
    <td width="9%" align="left">&nbsp;</td>
    <td width="12%" align="left">Stock</td>
    <td><input type="text" name="stock" id="stock" tabindex="5" /></td>
    <td width="5%" align="left">&nbsp;</td>
    <td width="8%" align="left">Phy Stock </td>
    <td><input type="text" name="phystock" id="phystock" tabindex="5" /></td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Color:</td>
    <td colspan="3"  valign="top"><input type="text" name="color" id="colorc" tabindex="3" /></td>
    <td align="left"><input type="button" class="button" id="copy" value="+" style="    padding: 2px 14px;" /></td>
    <td align="left">Gst Rate</td>
    <td width="15%"><input type="hidden" name="reorder" id="reorder" tabindex="6" /> <input type="text" name="taxtype" id="taxtype" tabindex="6" /></td>
    <td width="5%" align="left">&nbsp;</td>
    <td width="8%" align="left">Status</td>
    <td width="14%"><select name="status" style="width:100%" id="status">
      <option value="" selected="selected" ></option>
      <option value="IN PRODUCTION">IN PRODUCTION</option>
      <option value="INSTOCK" >IN STOCK</option>
      <option value="OUTOFSTOCK" >OUT OF STOCK</option>
	  <option value="ACTIVE" >ACTIVE</option>
      <option value="INACTIVE" >INACTIVE</option>
      <option value="DISCONTINUE" >DISCONTINUE</option>
    </select></td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Category:</td>
    <td colspan="3"  valign="top"><input type="text" name="cat" id="cat" tabindex="7"  /></td>
    <td align="left">&nbsp;</td>
    <td align="left">Size Set Code</td>
    <td><input type="text" name="sizesetcode" id="sizesetcode"   sizechartid="<?php echo $row['code']; ?>"  class="sizesetcode"/></td>
    <td width="5%" align="left">&nbsp;</td>
    <td width="8%" align="left"><input type="button" class="button ratioflip" id="ratioflip" ratiochartid="<?php echo $row['code'].'r'; ?>" value="Ratio" /></td>
    <td><input type="text" name="ratio" id="ratio" class="ratio" value=""/></td>
    <td align="center" valign="bottom"><input type="hidden" name="ratiotot" id="ratiotot" tabindex="9"   /></td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Sub Category:</td>
    <td colspan="3"  valign="top"><input type="text" name="subcat" id="subcat" tabindex="7"  /></td>
    <td align="left">&nbsp;</td>
    <td align="left">Mrp Diff<!--Size Diff Cost--></td>
    <td><input type="text" name="diffmrp" id="diffmrp" class="diffmrp" style=""/></td>
    <td width="5%" align="left">&nbsp;</td>
    <td width="8%" align="left">SP Diff<!--Size Diff Mrp--></td>
    <td><input type="text" name="diffprice" id="diffprice" class="diffprice" style=""/></td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Description:</td>
    <td colspan="3" rowspan="2"  valign="top"><textarea name="note" style="height: 64px;" rows="2" tabindex="4" id="note"></textarea></td>
    <td align="left">&nbsp;</td>
    <td align="left"><!--Style Colors-->Image 1,2,3 & 4</td>
    <td colspan="4"><!--<textarea name="noofcolor" style="height: 40px;" rows="2" tabindex="4" id="noofcolor"></textarea>-->
    <span id="image1"  class="photoone cursor"></span>&nbsp;
    <span id="image2"  class="phototwo cursor"></span>&nbsp;
    <span id="image3"  class="photothree cursor"></span>&nbsp;
    <span id="image4"  class="photofour cursor"></span></td>
    </tr>
    <tr class="master_detrow">
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    <td colspan="4" align="right"><input type="button" class="button showtotal" id="showtotal" value="SHOW" />
      <input type="button" class="button hidetotal" id="hidetotal" value="HIDE"  style = "display:none;"/>
     <input type="button" class="button" id="print" value="PRINT" />
      <input name="Update" type="button" class="Update button" id="Update" value="UPDATE" style="display:none"  />
      <input type="button" class="save button" id="Save" tabindex="30" value="SAVE"   />
      <input type="button" class="button" id="New" value="NEW" style="display:none" />
      <input type="button" class="close button" id="Close" value="CLOSE"  /></td>
    </tr>
  <tr>
    <td align="left">HSN:</td>
    <td colspan="3"><input type="text" name="hsncode" id="hsncode" tabindex="9"  /></td>
    <td colspan="5" align="right">&nbsp;</td>
  </tr>
  <tr>
    <td align="left"></td>
    <td colspan="3">&nbsp;</td>
    <td colspan="5" align="right">
</td>
  </tr>
  
 
  <tr>
    <td height="70%" colspan="10" align="left" valign="top" >
    <div class="table_contain" id="jobdet_container" style="height: 100%;overflow-y: auto;">
    
    
    
    </div>
    
    </td>
    </tr>
  <tr>
    <td colspan="9" align="left">
<div class="rateshow" style = "display:none;" > <!--style = "display:none;"-->
<table width="100%" border="0"  >
     <tr>
       <td width="10%" align="left">&nbsp;</td>
       <td valign="top">&nbsp;</td>
       <td valign="top">&nbsp;</td>
       <td valign="top">&nbsp;</td>
       <td valign="top">&nbsp;</td>
       <td valign="top"><input type="button"  class="Calculaterate button" id="Calculaterate" value="Calculate"  /></td>
       <td align="left" >Cost:</td>
        <td colspan="2" align="left" ><input type="text" size="10"  class="tpcost calc"  name="ptotal" id="ptotal" /></td>
        </tr>
     <tr>
        <td  align="left">&nbsp;</td>
        <td valign="top">&nbsp;</td>
        <td valign="top">&nbsp;</td>
        <td valign="top">&nbsp;</td>
        <td valign="top">&nbsp;</td>
        <td valign="top">&nbsp;</td>
        <td align="left">Mark up:</td>
        <td align="left"><input type="text" name="pdiscount" id="pdiscount" class="calc" size="10"/></td>
        </tr><tr>
        <td  align="left">&nbsp;</td>
        <td width="18%" valign="top">&nbsp;</td>
        <td width="6%" valign="top">&nbsp;</td>
        <td width="14%" valign="top">&nbsp;</td>
        <td width="13%" valign="top">&nbsp;</td>
        <td width="9%">&nbsp;</td>
        <td align="left">Selling Price:</td>
        <td align="left"><input type="text" name="pnamount" id="pnamount" class="calc" size="10"/></td>
        </tr>
      <tr>
      
       
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left">Gst:</td>
        <td align="left"><span><input type="text" name="gstper" id="gstper" class="calc" style="width:30%;float:left" /></span><span><input type="text" name="gstamt" id="gstamt" class="calc" style="width:70%;float:right" /></span></td>
        </tr>
      <tr>
        <td align="left" >&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left">MRP:</td>
        <td><input type="text" name="grtotal" id="grtotal" class="calc" size="10"/></td>
          </tr>
    </table>
</div>
</td>
    </tr>
  

         </table>

     
        </form>
      </div>
      <div id="message" style="width:100%; border:thin solid;text-align: center;font-weight: bold;color: #0064D1;"> </div>

</div>
<script type="text/javascript">
<?php if($prodid!='')
{ 

	if(($nofocol_data = mysqli_query($con,"SELECT color FROM prodreg  where `gencode` = '$row[gencode]'"))){
			
			while($nofocol_row = mysqli_fetch_array($nofocol_data)){
				$noofcolor = $nofocol_row['color'].", ".$noofcolor;
			}
			//echo $noofcolor;
	}
	?>
	
	
	
$(window).load(function(){
	$('#noofcolor').val('<?php echo clean($con,$noofcolor); ?>');
	//data to be from commst

	$('#prodcode').val('<?php echo clean($con,$row['code']); ?>');
	$('#subprdcd').val('<?php echo clean($con,$row['gencode']);?>');
	$('#colorc').val('<?php echo clean($con,$row['color']); ?>');
	$('#note').val('<?php echo clean($con,$row['desc']); ?>');
	$('#hsncode').val('<?php echo clean($con,$row['hsncode']); ?>');
	$('#stock').val('<?php echo clean($con,$row['stock']);?>');
	$('#phystock').val('<?php echo clean($con,$row['phystock']);?>');
	$('#reorder').val('<?php echo clean($con,$row['reorder']);?>');
	$('#sizesetcode').val('<?php echo clean($con,$row['sizesetcode']);?>');
	$('#pdiscount').val('<?php echo clean($con,$row['pdiscount']); ?>');
	$('#pnamount').val('<?php echo clean($con,$row['pnamount']);?>');
	$('#vat').val('<?php echo clean($con,$row['vat']);?>');
	$('#grtotal').val('<?php echo clean($con,$row['grtotal']);?>');
	//$('#jobid').val('<?php echo clean($con,$row['id']); ?>');
	$('#status').val('<?php echo clean($con,$row['status']); ?>');
	$('#date').val('<?php if(clean($con,$row['date'])!='0000-00-00') echo date_formatc(clean($con,$row['date'])); ?>');
	$('#cat').val('<?php echo clean($con,$row['cat']); ?>');
	$('#subcat').val('<?php echo clean($con,$row['subcat']); ?>');
    $('#ratio').val('<?php echo clean($con,$row['ratio']); ?>');
    $('#ratiotot').val('<?php echo clean($con,$row['ratiotot']); ?>');
	
    $('#ptotal').val('<?php echo clean($con,$row['ptotal']); ?>');
	$('#pdiscount').val('<?php echo clean($con,$row['pdiscount']); ?>');
    $('#pnamount').val('<?php echo clean($con,$row['pnamount']); ?>');
    $('#vat').val('<?php echo clean($con,$row['vat']); ?>');
    $('#grtotal').val('<?php echo clean($con,$row['grtotal']); ?>');
	
	$('#diffmrp').val('<?php echo clean($con,$row['diffmrp']); ?>');
    $('#diffprice').val('<?php echo clean($con,$row['diffprice']); ?>');
    $('#taxtype').val('<?php echo clean($con,$row['taxtype']); ?>');
	
	$('#gstper').val('<?php echo clean($con,$row['gstper']); ?>');
	$('#gstamt').val('<?php echo clean($con,$row['gstamt']); ?>');
	$('#imglink1').val('<?php echo clean($con,$row['img1']);?>');
	$('#imglink2').val('<?php echo clean($con,$row['img2']);?>');
	$('#imglink3').val('<?php echo clean($con,$row['img3']); ?>');	
	$('#imglink4').val('<?php echo clean($con,$row['img4']); ?>');
	
		<?php 
//	$linksArray = explode(",", clean($con,$row['img1']));
	$link1 = '';
   	if($row['img1']==''){
		$link1 = "<img src='../images/admin.png' class='imgview' />";
		}
	else{
            $link1 = "<img src='http://geeteedecors.com/collection/$row[img1].jpg' class='imgview' alt='Image 1' />";
        }
	
	$link2 = '';
	if($row['img2']==''){
		$link2 = "<img src='../images/admin.png' class='imgview' />";
		}
	else{	
	$link2 = "<img src='http://geeteedecors.com/collection/$row[img2].jpg' class='imgview' alt='Image 2' />";	
	}
	
	$link3 = '';
	if($row['img3']==''){
		$link3 = "<img src='../images/admin.png' class='imgview' />";
		}
	else{	
	$link3 = "<img src='http://geeteedecors.com/collection/$row[img3].jpg' class='imgview' alt='Image 3' />";	
	}
	
	$link4 = '';
	if($row['img4']==''){
		$link4 = "<img src='../images/admin.png' class='imgview' />";
		}
	else{	
	$link4 = "<img src='http://geeteedecors.com/collection/$row[img4].jpg' class='imgview' alt='Image 4' />";	
	}
	
	?>
	$('#image1').append("<?php echo clean($con,$link1); ?>");
	$('#image2').append("<?php echo clean($con,$link2); ?>");
	$('#image3').append("<?php echo clean($con,$link3); ?>");
	$('#image4').append("<?php echo clean($con,$link4); ?>");


	$('#jobdet_container').html('<?php echo clean($con,$table); ?>');
	$(document).ready(function(){
	
	
	if ($('#invoiceno').val()!=''){
	$('#process').hide();}
	else{
		$('#process').show();}
	$('#Update').show();
	$('#New').show();
	$('#Save').hide();
	run();
	inline_edit();
	prodentry_rel();
	
	
	
	$(".rmcode").autocomplete(
      "../rowmaterial_fill.php?",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
  			onItemSelect:function(row){
				var tempRow=$('*:focus').closest('tr');
				if(row.data[1]!='undefined')
				tempRow.find('.descrip').val(row.data[1]);
				if(row.data[4]!='undefined')
				tempRow.find('.qty').val(row.data[4]);
				if(row.data[5]!='undefined')
				tempRow.find('.psrate').val(row.data[5]);
				if(row.data[6]!='undefined')
				tempRow.find('.skuid').val(row.data[6]);
								
			},
			showResult:function(row,data) {
    	  return row+"|"+data[0];
     		},
			
  			autoFill:false
  		});
	});
	
			

	});
<?php }
else 
 ?>
$('#jobid').focus();
	
$(window).load(function() {
	$('#transperent').hide();
});
$("#compid").autocomplete(
      "client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#name').val(row.data[0]);
				if(row.data[1]!='undefined')
				$('#cmpcity').val(row.data[1]);				
				if(row.data[2]!='undefined')
				$('#address').val(row.data[2]);
				if(row.data[3]!='undefined')
				$('#telephone').val(row.data[3]);
				if(row.data[4]!='undefined')
				$('#email').val(row.data[4]);				
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  },
  		
  			autoFill:false
  		}
    );
	
	
	$("#prodcode").autocomplete(
      "product_code_fill.php?mode=pcode",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#subprdcd').val(row.data[0]);
				if(row.data[1]!='undefined')
				$('#note').val(row.data[1]);
								
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  },
  			autoFill:false
  		});
		
		
		$("#subprdcd").autocomplete(
      "product_code_fill.php?mode=subprdcd",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#cat').val(row.data[0]);
				if(row.data[1]!='undefined')
				$('#subcat').val(row.data[1]);
				if(row.data[2]!='undefined')
				$('#note').val(row.data[2]);
				if(row.data[3]!='undefined')
				$('#sizesetcode').val(row.data[3]);
				if(row.data[10]!='undefined')
				$('#ratio').val(row.data[10]);
				if(row.data[11]!='undefined')
				$('#diffmrp').val(row.data[11]);
				if(row.data[12]!='undefined')
				$('#diffprice').val(row.data[12]);				
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  },
  			autoFill:false
  		});
		
	
		$("#cat").autocomplete(
      "../cat_by_fill.php?",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#sizesetcode').val(row.data[0]);
				if(row.data[1]!='undefined')
				$('#ratio').val(row.data[1]);
				if(row.data[2]!='undefined')
				$('#diffmrp').val(row.data[2]);
				if(row.data[3]!='undefined')
				$('#diffprice').val(row.data[3]);
								
			},
  			autoFill:false
  		}
    );
	
	
	$("#subcat").autocomplete(
      "../cat_by_fill.php?mode=subcat",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
  			autoFill:false
  		}
    );

$("#taxtype").autocomplete(
      "product_code_fill.php?mode=taxtype",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
  			autoFill:false
  		}
    );
	
	
	$("#colorc").autocomplete(
      "product_code_fill.php?mode=colorfill",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			onItemSelect:function(row){
				$('#prodcode').val('');
				if(row.data[0]!='undefined'&&$('#prodcode').val()=='')
				$('#prodcode').val($('#subprdcd').val()+row.data[0]);
				
								
			},
			showResult:function(row,data) {
    		return row;
 			 },
  			autoFill:false
  		}
    );

	$("#taxtype").autocomplete({
	 	minChars:0,
		mustMatch:1,
        data: [
            ['5', 1],
            ['6', 2],
			['12', 3],
            ['18', 4] 
        ]
    });
		
	
$(document).ready(function(){
	
$("#taxtype").change(function(){
	var taxtype = $("#taxtype").val();
	$("#gstper").val(taxtype);
});	
	
	
if (sessionStorage.prodcode)
{
  if($.trim(sessionStorage.prodcode)!='')
  {
	if (sessionStorage.prodcode)
	$('#prodcode').val(sessionStorage.prodcode);
	
	if (sessionStorage.color)
	$('#colorc').val(sessionStorage.color);
	
	if (sessionStorage.subprdcd)
	$('#subprdcd').val(sessionStorage.subprdcd);
	
	if (sessionStorage.note)
	$('#note').val(sessionStorage.note);
        
    if (sessionStorage.stock)
	$('#stock').val(sessionStorage.stock);

    if (sessionStorage.reorder)
	$('#reorder').val(sessionStorage.reorder);
	
	 if (sessionStorage.cat)
	$('#cat').val(sessionStorage.cat);	
	
	if (sessionStorage.subcat)
	$('#subcat').val(sessionStorage.subcat);	
	
	 if (sessionStorage.sizesetcode)
	$('#sizesetcode').val(sessionStorage.sizesetcode);	
	
	 if (sessionStorage.ratio)
	$('#ratio').val(sessionStorage.ratio);	
	
	if (sessionStorage.noofcolor)
	$('#noofcolor').val(sessionStorage.noofcolor);	
	
	 if (sessionStorage.status)
	$('#status').val(sessionStorage.status);
	
	 if (sessionStorage.diffprice)
	$('#diffprice').val(sessionStorage.diffprice);
	
	 if (sessionStorage.diffmrp)
	$('#diffmrp').val(sessionStorage.diffmrp);
	
	 if (sessionStorage.ptotal)
	$('#ptotal').val(sessionStorage.ptotal);
	
	 if (sessionStorage.pdiscount)
	$('#pdiscount').val(sessionStorage.pdiscount);
	
	 if (sessionStorage.pnamount)
	$('#pnamount').val(sessionStorage.pnamount);
	
	 if (sessionStorage.vat)
	$('#vat').val(sessionStorage.vat);
	
	if (sessionStorage.grtotal)
	$('#grtotal').val(sessionStorage.grtotal);
	
	if (sessionStorage.table)
	$('#jobdet_container').html(sessionStorage.table);
	
  }

}
});
	
</script>

</body>
</html>