<?php echo $header; ?>

<style> 
input[type=text] {
  width: 30px;
  font-size:11px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white;
  background-image: url('searchicon.png');
  background-position: 2px 2px; 
  background-repeat: no-repeat;
  padding-top: 1px;
  padding-bottom: 1px;
}
.list .left{
  text-align:left;
  padding:2px;
}


input[class=currency] {
  text-align:right;
}

input[class=GemCounts] {
  width: 20px;
  text-align:center;
  padding-left:2px;
  padding-right:2px;
}
select{
    box-sizing: border-box;
    margin: 0;
    border: 1px solid #aaa;
    box-shadow: 0 1px 0 1px rgba(0,0,0,.04);
    border-radius: .5em;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
    background-position: right .7em top 50%, 0 0;
    background-size: .65em auto, 100%;
}
</style>

<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/order.png" alt="" /> Production Status & Costs </h1>
      <div class="buttons" id="newProductButton">	  
		 <a onclick="newproductshow()" class="button">New Order</a>
	  </div>
      <div class="buttons" id="oldProductButton" style="display:none;">	  
		 <a onclick="oldproductshow()" class="button">Existing Orders</a>
	  </div>
      <div class="buttons" id="filter">	  
			<a onclick="redirectFilter();"  value="filter"  id="filter"  name="filter" class="button">Filter</a>
	  </div>	  
	  <h1 style="float:right;">Product:<input type="text" name="filter_product" id="filter_product" value="<?php echo $filter_product; ?>" size="12" size=12 class="prdname" style="width:60px;" />&nbsp;&nbsp;&nbsp;</h1>
    </div>
    <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form"  onsubmit="return validateForm()">
            <?php if ($orders) { ?>
			
						
        <table class="list newProduct"  style="display:none;">
          <thead>
            <tr>
              <!-- <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td> 
              <td class="right"><?php if ($sort == 'o.order_id') { ?>
                <a href="<?php echo $sort_order; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_order_id; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_order; ?>"><?php echo $column_order_id; ?></a>
                <?php } ?></td>   -->
				<td class="center">Order ID  <br> Product</td>
				
              <td class="center">Metals</td>
              <td class="center">Gems</td>
              <td class="center">Shape</td>
              <td class="center">Size</td>
              <td class="center">Count</td>
              <td class="center">Weight</td>			  
			  <td class="center" colspan=2>Cost & Qty</td>
			  
            </tr>
          </thead>
          <tbody>
            <tr  > 
              <td class="center" style="height:200px; " ><input type="text" name="prdname" value="" class="prdname" style="width:100px;font-size:12px;border: 1px solid #ccc;border-radius: 4px;height:100px;" Rows="3" />	</td>			  
			  <td class="center" >
					M1: <select name="Metal1"  >
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($metalCodes as $metalCode) { ?>
								<option value="<?php echo $metalCode['metal_id']; ?>"><?php echo $metalCode['metal_code']; ?></option>
						<?php } ?>
					</select>
					<input type="text" name="M1Weight" value="" class="currency" />				
					<br><br>
					M2: <select name="Metal2" style="">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($metalCodes as $metalCode) { ?>
								<option value="<?php echo $metalCode['metal_id']; ?>"><?php echo $metalCode['metal_code']; ?></option>
						<?php } ?>
					</select>
					<input type="text" name="M2Weight" value="" class="currency" />					
			  </td>			  
			  <td class="center" >
					G1: <select name="Gem1">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemCodes as $gemCode) { ?>
								<option value="<?php echo $gemCode['gemstone_id']; ?>"><?php echo $gemCode['gemname']; ?></option>
						<?php } ?>
					</select><br><br>
					G2: <select name="Gem2">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemCodes as $gemCode) { ?>
								<option value="<?php echo $gemCode['gemstone_id']; ?>"><?php echo $gemCode['gemname']; ?></option>
						<?php } ?>
					</select><br><br>
					G3: <select name="Gem3">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemCodes as $gemCode) { ?>
								<option value="<?php echo $gemCode['gemstone_id']; ?>"><?php echo $gemCode['gemname']; ?></option>
						<?php } ?>
					</select><br><br>
					G4: <select name="Gem4">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemCodes as $gemCode) { ?>
								<option value="<?php echo $gemCode['gemstone_id']; ?>"><?php echo $gemCode['gemname']; ?></option>
						<?php } ?>
					</select><br><br>
					G4: <select name="Gem5">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemCodes as $gemCode) { ?>
								<option value="<?php echo $gemCode['gemstone_id']; ?>"><?php echo $gemCode['gemname']; ?></option>
						<?php } ?>
					</select>
			  </td>			  
			  <td class="center">
					<select name="G1ShapeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $shape) { ?>
								<option value="<?php echo $shape['shape_id']; ?>"><?php echo $shape['shape']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G2ShapeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $shape) { ?>
								<option value="<?php echo $shape['shape_id']; ?>"><?php echo $shape['shape']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G3ShapeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $shape) { ?>
								<option value="<?php echo $shape['shape_id']; ?>"><?php echo $shape['shape']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G4ShapeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $shape) { ?>
								<option value="<?php echo $shape['shape_id']; ?>"><?php echo $shape['shape']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G5ShapeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $shape) { ?>
								<option value="<?php echo $shape['shape_id']; ?>"><?php echo $shape['shape']; ?></option>
						<?php } ?>
					</select>
			  </td>		  
			  <td class="center">
					<select name="G1SizeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G2SizeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G3SizeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G4SizeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
						<?php } ?>
					</select>
					<br><br>
					<select name="G5SizeId">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
						<?php } ?>
					</select>
			  </td>
			  <td class="center">
					 <input type="text" name="G1Count" value="" class="currency" /> <br><br>
					 <input type="text" name="G2Count" value="" class="currency" /><br><br>
					 <input type="text" name="G3Count" value="" class="currency" /><br><br>
					 <input type="text" name="G4Count" value="" class="currency" /><br><br>
					 <input type="text" name="G5Count" value="" class="currency" />
			  </td>			  
			  <td class="center">
					 <input type="text" name="G1Wt" value="" class="currency" /><br><br>
					 <input type="text" name="G2Wt" value="" class="currency" /><br><br>
					 <input type="text" name="G3Wt" value="" class="currency" /><br><br>
					 <input type="text" name="G4Wt" value="" class="currency" /><br><br>
					 <input type="text" name="G5Wt" value="" class="currency" />
			  </td>			  
			  
			  <td class="right" style="border-right-style:hidden;">
				Setting: <select name="Setting">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($settingCodes as $settingCode) { ?>
					<option value="<?php echo $settingCode['Id']; ?>"><?php echo $settingCode['Code']; ?></option>
                  <?php } ?>
                </select>
				<br><br>				
			    Casting: <select name="Casting">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($castingCodes as $castingCode) { ?>
						<option value="<?php echo $castingCode['Id']; ?>"><?php echo $castingCode['Code']; ?></option>
                  <?php } ?>
                </select>
				<br><br>				
				Rhodium: <select name="Rhodium">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($rhodiumCodes as $rhodiumCode) { ?>
						<option value="<?php echo $rhodiumCode['Id']; ?>"><?php echo $rhodiumCode['Code']; ?></option>
                  <?php } ?>
                </select>
				<br><br>				
				Plating: <select name="Plating">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($platingCodes as $platingCode) { ?>
						<option value="<?php echo $platingCode['Id']; ?>"><?php echo $platingCode['Code']; ?></option>
                  <?php } ?>
                </select>
			  </td>
			  <td class="right" style="border-left-style:hidden;">				
				FilPol: <input type="text" name="FilingPolishing" value="" class="currency" />
				<br><br> 
				Oth Codes: <select name="OtherCode">  
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($otherCodes as $otherCode) { ?>
						<option value="<?php echo $otherCode['Id']; ?>"><?php echo $otherCode['Code']; ?></option>
                  <?php } ?>
                </select>				
				<br><br>  
				Oth Cost: <input type="text" name="OtherCost" value="" class="currency" />
				<br><br>				
				Prod Qty: <input type="text" name="OrdProdQty" value="1" class="currency" />
			  </td>				
            <tr>
			<td class="right"  colspan=9 >
			    <div class="buttons">	  
					<a onclick="SetUpdate('Insert','NEW');$('#form').submit();"  value="Insert"  id="Insert" name='Insert'  class="button">Insert</a>
					<!--    <a onclick="" class="button">Insert </a> -->
				  </div>
			</td>
            </tr>
          </tbody>
        </table>

						
        <table class="list oldProduct" >
          <thead>
            <tr>
              <!-- <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td> 
              <td class="right"><?php if ($sort == 'o.order_id') { ?>
                <a href="<?php echo $sort_order; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_order_id; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_order; ?>"><?php echo $column_order_id; ?></a>
                <?php } ?></td>   -->
				<td class="center">Image</td>				
				<td class="center">Order ID  <br> Product</td>				
              <td class="center">Metal</td>              
              <td class="center">Gem</td>
              <td class="center">Shape</td>
              <td class="center">Size</td>
              <td class="center">Count</td>
              <td class="center">Weight</td>			  
			  <td class="center oldProduct">Sett / FilPol / Rhodium</td>
			  <td class="center oldProduct">Casting / Plating</td>
			  <td class="center oldProduct">Oth Codes /Cost</td>
			  <td class="center oldProduct">Prod <br>Comp</td>	
			  
            </tr>
          </thead>
          <tbody>			
			
            <?php foreach ($orders as $order) {
				//if ($this->user->isLogged()==1 || $order['manuf_user_Id']==$this->user->isLogged())
				if(1)
				{
				?>
			 
            <tr > <!--
              <td style="text-align: center;"><?php if ($order['selected']) { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" />
                <?php } ?></td> -->
				
              <!-- <td class="center"><table><tr><td><img src="<?php echo $order['image']; ?>" width=50 height=50/></td><td><?php echo $order['order_id']; ?><br><?php echo $order['name'].'</br>'.$order['RingSize']; ?></td></tr></table></td> -->
			  <td class="center"><?php if($order['image'] <> ""){ ?><a href="<?php echo $order['image']; ?>" target="_blank"><img src="<?php echo $order['image']; ?>" width=50 height=50/></a><?php } ?> </td>
			  <td><?php echo $order['order_id']; ?><br><?php echo $order['name'].'</br>'.$order['RingSize']; ?></td>
			  <td class="center">
				M1: <?php echo $order['M1']; ?>
				<?php if($order['M1'] != "" ){ ?>			
					<input type="text" name="M1Weight<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['M1Wt'],2)); ?>" />
				<?php } ?><br>				
				<?php if($order['M2'] != "" ){ ?> 				
					M2: <?php echo $order['M2']; ?>
					<input type="text" name="M2Weight<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['M2Wt'],2)); ?>"  />
				<?php } ?>
			  </td>
			  
			  <td class="center">
				<?php if($order['G1'] != "" ){ ?>
						G1: <?php echo $order['G1']; ?>
				<?php } ?>
				<?php if($order['G2'] != "" ){ ?>
						</br></br>G2: <?php echo $order['G2']; ?>
				<?php } ?>
				<?php if($order['G3'] != "" ){ ?>
						</br></br>G3: <?php echo $order['G3']; ?>
				<?php } ?>
				<?php if($order['G4'] != "" ){ ?>
						</br></br>G4: <?php echo $order['G4']; ?>
				<?php } ?>
				<?php if($order['G5'] != "" ){ ?>
						</br></br>G5: <?php echo $order['G5']; ?>
				<?php } ?>
			  </td>
			  <td class="center">
				<?php if($order['G1'] != "" ){ ?>
					<select name="G1ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G1ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
				<?php } ?>
				<?php if($order['G2'] != "" ){ ?>
					</br></br><select name="G2ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G2ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
				<?php } ?>
				<?php if($order['G3'] != "" ){ ?>
					</br></br><select name="G3ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G3ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
				<?php } ?>
				<?php if($order['G4'] != "" ){ ?>
					</br></br><select name="G4ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G4ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
				<?php } ?>
				<?php if($order['G5'] != "" ){ ?>
					</br></br><select name="G5ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G5ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
				<?php } ?>
			  </td>
			  <td class="center">
				<?php if($order['G1'] != "" ){ ?>
					<select name="G1SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G1SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code'] ; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
				<?php } ?>
				<?php if($order['G2'] != "" ){ ?>
					</br></br><select name="G2SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G2SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
				<?php } ?>
				<?php if($order['G3'] != "" ){ ?>
					</br></br><select name="G3SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G3SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
				<?php } ?>
				<?php if($order['G4'] != "" ){ ?>
					</br></br><select name="G4SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G4SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
				<?php } ?>
				<?php if($order['G5'] != "" ){ ?>
					</br></br><select name="G5SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_id'] == $order['G5SizeId']) { ?>
								<option value="<?php echo $gemsize['size_id']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_id']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
				<?php } ?>
			  </td>	
			  <td class="center">
				<?php if($order['G1'] != "" ){ ?>
					<input type="text" name="G1Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G1#'],2); ?>" class="GemCounts" />
				<?php } ?>
				<?php if($order['G2'] != "" ){ ?>
					</br></br><input type="text" name="G2Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G2#'],2); ?>" class="GemCounts" />
				<?php } ?>
				<?php if($order['G3'] != "" ){ ?>
					</br></br><input type="text" name="G3Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G3#'],2); ?>" class="GemCounts" />
				<?php } ?>
				<?php if($order['G4'] != "" ){ ?>
					</br></br><input type="text" name="G4Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G4#'],2); ?>" class="GemCounts" />
				<?php } ?>
				<?php if($order['G5'] != "" ){ ?>
					</br></br><input type="text" name="G5Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G5#'],2); ?>" class="GemCounts" />
				<?php } ?>
			  </td>
			  <td class="center">
				<?php if($order['G1'] != "" ){ ?>
					<input type="text" name="G1Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G1Wt'],2)); ?>" class="currency" />
				<?php } ?>
				<?php if($order['G2'] != "" ){ ?>
					</br></br><input type="text" name="G2Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G2Wt'],2)); ?>" class="currency" />
				<?php } ?>
				<?php if($order['G3'] != "" ){ ?>
					</br></br><input type="text" name="G3Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G3Wt'],2)); ?>" class="currency" />
				<?php } ?>
				<?php if($order['G4'] != "" ){ ?>
					</br></br><input type="text" name="G4Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G4Wt'],2)); ?>" class="currency" />
				<?php } ?>
				<?php if($order['G5'] != "" ){ ?>
					</br></br><input type="text" name="G5Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G5Wt'],2)); ?>" class="currency" />
				<?php } ?>
			  </td>		  
			  
			  <!-- <td class="right"><input type="text" name="<?php echo $order['order_id']; ?>Setting" value="<?php  printf("%.2f", round($order['Setting'],2)); ?>" class="currency" /></td> -->
			  
			  <td class="left">
			  Setting:<select name="Setting<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none . $order['Setting']; ?></option>
                  <?php foreach ($settingCodes as $settingCode) { ?>
                  <?php if ($settingCode['Id'] == $order['Setting']) { ?>
                  <option value="<?php echo $settingCode['Id']; ?>" selected="selected"><?php echo $settingCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $settingCode['Id']; ?>"><?php echo $settingCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </br>Filing: <input type="text" name="FilingPolishing<?php echo $order['order_id']; ?>" value="<?php printf("%.2f",  round($order['FilingPolishing'],2)); ?>" />
			  </br>Rhodium: <select name="Rhodium<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($rhodiumCodes as $rhodiumCode) { ?>
                  <?php if ($rhodiumCode['Id'] == $order['Rhodium']) { ?>
                  <option value="<?php echo $rhodiumCode['Id']; ?>" selected="selected"><?php echo $rhodiumCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $rhodiumCode['Id']; ?>"><?php echo $rhodiumCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </td>	
			  <td class="center">Casting: <select name="Casting<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($castingCodes as $castingCode) { ?>
                  <?php if ($castingCode['Id'] == $order['Casting']) { ?>
                  <option value="<?php echo $castingCode['Id']; ?>" selected="selected"><?php echo $castingCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $castingCode['Id']; ?>"><?php echo $castingCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  
			  </br></br>Plating:<select name="Plating<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($platingCodes as $platingCode) { ?>
                  <?php if ($platingCode['Id'] == $order['Plating']) { ?>
                  <option value="<?php echo $platingCode['Id']; ?>" selected="selected"><?php echo $platingCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $platingCode['Id']; ?>"><?php echo $platingCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </td>	
			  <td class="center">OtherCode:
			  	<select name="OtherCode<?php echo $order['order_id']; ?>">  
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($otherCodes as $otherCode) { ?>
                  <?php if ($otherCode['Id'] == $order['otherCode']) { ?>
						<option value="<?php echo $otherCode['Id']; ?>" selected="selected"><?php echo $otherCode['Code']; ?></option>
                  <?php } else { ?>
						<option value="<?php echo $otherCode['Id']; ?>"><?php echo $otherCode['Code']; ?></option>
                  <?php } } ?>  
                </select>
				</br></br>OtherCost: <input type="text" name="OtherCost<?php echo $order['order_id']; ?>" value="<?php printf("%.2f",  round($order['OtherCost'],2)); ?>" class="currency" />
				<input type="hidden" name="OrdProdQty<?php echo $order['order_id']; ?>" value="<?php printf("%.2f",  round($order['OrdProdQty'],2)); ?>" class="currency" /> 
			  </td>			  
			
              <td style="text-align: center;">
			    <?php if ($order['ProdComplete']) { ?>
                <input type="checkbox" name="ProdComplete<?php echo $order['order_id']; ?>" value="1" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="ProdComplete<?php echo $order['order_id']; ?>" value="0" />
                <?php } ?>				

			    <div class="buttons">	  
					<a onclick="SetUpdate('Update','<?php echo $order['order_id']; ?>' );$('#form').submit();"  value="Update"  id="Update"  name="Update" class="button">Update</a>
				</div>
				
			  </td>	
            </tr>
            <?php } } ?>
			
            <?php } else { ?>
            <tr>
              <td class="center" colspan="15"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>			
			
          </tbody>
        </table>
		   <input type="hidden" name="InsertUpdateFlag" id="InsertUpdateFlag" value="Update" />
		   <input type="hidden" name="processOrderId" id="processOrderId" value="Update" />

      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>

  </div>
</div>
<script type="text/javascript"><!--

function SetUpdate(action,order_id){
	document.forms["form"]["InsertUpdateFlag"].value =  action;
	document.forms["form"]["processOrderId"].value =  order_id;	
}
function newproductshow(){
  $(".newProduct").show();
  $(".oldProduct").hide();
  $("#newProductButton").hide();  
  $("#oldProductButton").show();  
  $(".pagination").hide();  
  
}
function oldproductshow(){
  $(".newProduct").hide();
  $(".oldProduct").show();
  $("#oldProductButton").hide();  
  $("#newProductButton").show();  
  $(".pagination").show();  
}

function filter() {
	url = 'index.php?route=sale/orderstockist&token=<?php echo $token; ?>';
	
	var filter_order_id = $('input[name=\'filter_order_id\']').attr('value');
	
	if (filter_order_id) {
		url += '&filter_order_id=' + encodeURIComponent(filter_order_id);
	}
	
	var filter_customer = $('input[name=\'filter_customer\']').attr('value');
	
	if (filter_customer) {
		url += '&filter_customer=' + encodeURIComponent(filter_customer);
	}
	
	var filter_order_status_id = $('select[name=\'filter_order_status_id\']').attr('value');
	
	if (filter_order_status_id != '*') {
		url += '&filter_order_status_id=' + encodeURIComponent(filter_order_status_id);
	}	

	var filter_total = $('input[name=\'filter_total\']').attr('value');

	if (filter_total) {
		url += '&filter_total=' + encodeURIComponent(filter_total);
	}	
	
	var filter_date_added = $('input[name=\'filter_date_added\']').attr('value');
	
	if (filter_date_added) {
		url += '&filter_date_added=' + encodeURIComponent(filter_date_added);
	}
	
	var filter_date_modified = $('input[name=\'filter_date_modified\']').attr('value');
	
	if (filter_date_modified) {
		url += '&filter_date_modified=' + encodeURIComponent(filter_date_modified);
	}
				
	location = url;
}
//--></script>  
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script> 
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
//--></script> 
<script type="text/javascript"><!--
$.widget('custom.catcomplete', $.ui.autocomplete, {
	_renderMenu: function(ul, items) {
		var self = this, currentCategory = '';
		
		$.each(items, function(index, item) {
			if (item.category != currentCategory) {
				ul.append('<li class="ui-autocomplete-category">' + item.category + '</li>');
				
				currentCategory = item.category;
			}
			
			self._renderItem(ul, item);
		});
	}
});

$('input[name=\'filter_customer\']').catcomplete({
	delay: 0,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=sale/customer/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						category: item.customer_group,
						label: item.name,
						value: item.customer_id
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('input[name=\'filter_customer\']').val(ui.item.label);
						
		return false;
	}
});
//--></script> 
<script>
// defaultingNewOrder();
function defaultingNewOrder(){ 	 
  
  document.forms["form"]["OrdProdQty"].value = 1;
  document.forms["form"]["OtherCost"].value = 1.2;
  document.forms["form"]["FilingPolishing"].value = 1.3;
  document.forms["form"]["Plating"].value = 1;
  document.forms["form"]["OtherCode"].value = 1;
  document.forms["form"]["Rhodium"].value = 1;
  document.forms["form"]["Casting"].value = 1;
  document.forms["form"]["Setting"].value = 1;
  
  document.forms["form"]["prdname"].value = "Test Prdouct";
  document.forms["form"]["Metal1"].value = 14;
  document.forms["form"]["M1Weight"].value = 12.2;
  
  
  document.forms["form"]["Gem1"].value = 23;
  document.forms["form"]["G1Wt"].value = 13.4;
  document.forms["form"]["G1SizeId"].value = "2 mm";
  document.forms["form"]["G1Count"].value = 4;
  document.forms["form"]["G1ShapeId"].value = 14;
  
}
function validateForm() {

  formAction = $('input[name=\'InsertUpdateFlag\']').attr('value');
  OrderId = document.forms["form"]["processOrderId"].value ;


  if( formAction == 'Insert'){ 
	
  
  var prdname = document.forms["form"]["prdname"].value;
  if (prdname == "") {
    alert("Product Name must be filled out");
    return false;
  }

  var Metal1 = document.forms["form"]["Metal1"].value;
  if (Metal1 == "") {
    alert("Metal 1 must be selected");
    return false;
  }
  var M1Weight = document.forms["form"]["M1Weight"].value;
  if (M1Weight == "") {
    alert("Metal 1 - Weight must be filled out");
    return false;
  } 
  var Metal2 = document.forms["form"]["Metal2"].value;
  if (Metal2 != 0) {
		var M2Weight = document.forms["form"]["M2Weight"].value;
		if (M2Weight == "") {
			alert("Metal 2 - Weight must be filled out");
			return false;
		} 
  }else{
	  document.forms["form"]["Metal2"].value=0;
	  document.forms["form"]["M2Weight"].value=0;
  }
  
  var Gem1 = document.forms["form"]["Gem1"].value;
  if (Gem1 != 0) {   
   
		var G1ShapeId = document.forms["form"]["G1ShapeId"].value;
		if (G1ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G1SizeId = document.forms["form"]["G1SizeId"].value;
		if (G1SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G1Count = document.forms["form"]["G1Count"].value;
		if (G1Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G1Wt = document.forms["form"]["G1Wt"].value;
		if (G1Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
	}else{	  
			document.forms["form"]["Gem1"].value = 0;
			document.forms["form"]["G1Wt"].value = 0;
			document.forms["form"]["G1SizeId"].value = 0;
			document.forms["form"]["G1Count"].value = 0;
			document.forms["form"]["G1ShapeId"].value = 0;
  }
	
  var Gem2 = document.forms["form"]["Gem2"].value;
  if (Gem2 != 0) {   
   
		var G2ShapeId = document.forms["form"]["G2ShapeId"].value;
		if (G2ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G2SizeId = document.forms["form"]["G2SizeId"].value;
		if (G2SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G2Count = document.forms["form"]["G2Count"].value;
		if (G2Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G2Wt = document.forms["form"]["G2Wt"].value;
		if (G2Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}		  
	}else{	  
			document.forms["form"]["Gem2"].value = 0;
			document.forms["form"]["G2Wt"].value = 0;
			document.forms["form"]["G2SizeId"].value = 0;
			document.forms["form"]["G2Count"].value = 0;
			document.forms["form"]["G2ShapeId"].value = 0;
  }
	
  var Gem3 = document.forms["form"]["Gem3"].value;
  if (Gem3 != 0) {   
   
		var G3ShapeId = document.forms["form"]["G3ShapeId"].value;
		if (G3ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G3SizeId = document.forms["form"]["G3SizeId"].value;
		if (G3SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G3Count = document.forms["form"]["G3Count"].value;
		if (G3Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G3Wt = document.forms["form"]["G3Wt"].value;
		if (G3Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
	}else{	  
			document.forms["form"]["Gem3"].value = 0;
			document.forms["form"]["G3Wt"].value = 0;
			document.forms["form"]["G3SizeId"].value = 0;
			document.forms["form"]["G3Count"].value = 0;
			document.forms["form"]["G3ShapeId"].value = 0;
  }
	
  var Gem4 = document.forms["form"]["Gem4"].value;
  if (Gem4 != 0) {   
   
		var G4ShapeId = document.forms["form"]["G4ShapeId"].value;
		if (G4ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G4SizeId = document.forms["form"]["G4SizeId"].value;
		if (G4SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G4Count = document.forms["form"]["G4Count"].value;
		if (G4Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G4Wt = document.forms["form"]["G4Wt"].value;
		if (G4Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
	}else{	  
			document.forms["form"]["Gem4"].value = 0;
			document.forms["form"]["G4Wt"].value = 0;
			document.forms["form"]["G4SizeId"].value = 0;
			document.forms["form"]["G4Count"].value = 0;
			document.forms["form"]["G4ShapeId"].value = 0;
	}
	
  var Gem5 = document.forms["form"]["Gem5"].value;
  if (Gem5 != 0) {   
		var G5ShapeId = document.forms["form"]["G5ShapeId"].value;
		if (G5ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G5SizeId = document.forms["form"]["G5SizeId"].value;
		if (G5SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G5Count = document.forms["form"]["G5Count"].value;
		if (G5Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G5Wt = document.forms["form"]["G5Wt"].value;
		if (G5Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
  }else{	  
		document.forms["form"]["Gem5"].value = 0;
		document.forms["form"]["G5Wt"].value = 0;
		document.forms["form"]["G5SizeId"].value = 0;
		document.forms["form"]["G5Count"].value = 0;
		document.forms["form"]["G5ShapeId"].value = 0;
  }
         
  var Setting = document.forms["form"]["Setting"].value;
  if (Setting == 0) {   
    alert("Setting must be selected");
    return false;
  } 
  var Casting = document.forms["form"]["Casting"].value;
  if (Casting == 0) {   
    alert("Casting must be selected");
    return false;
  }
  var Rhodium = document.forms["form"]["Rhodium"].value;
  if (Rhodium == 0) {   
    alert("Rhodium must be selected");
    return false;
  }
  var Plating = document.forms["form"]["Plating"].value;
  if (Plating == 0) {   
    alert("Plating must be selected");
    return false;
  }
  var FilingPolishing = document.forms["form"]["FilingPolishing"].value;
  if (FilingPolishing == "") {
    alert("Filing Polishing must be filled out");
    return false;
  }

  var OtherCost = document.forms["form"]["OtherCost"].value;
  if (OtherCost == "" || OtherCost == 0) {
    //alert("Other Cost must be filled out");
    //return false;
  }else{
	var OtherCode = document.forms["form"]["OtherCode"].value;
	if (OtherCode == 0) {   
		alert("OtherCode must be selected");
		return false;
	}  
  }
  var OrdProdQty = document.forms["form"]["OrdProdQty"].value;
  if (OrdProdQty == "") {
    alert("Product Qty must be filled out");
    return false;
  }
  
  }else{
	  
	  
	  
	// Update Section

  var M1Weight = document.forms["form"]["M1Weight"+OrderId].value;
  if (M1Weight == "") {
    alert("Metal 1 - Weight must be filled out");
    return false;
  } 
  
  if (document.contains(document.getElementById("M2Weight"+OrderId))) {
		var M2Weight = document.forms["form"]["M2Weight"+OrderId].value;
		if (M2Weight == "") {
			alert("Metal 2 - Weight must be filled out");
			return false;
		}
  }

  
  if (document.contains(document.getElementById("G1ShapeId"+OrderId))) {
   
		var G1ShapeId = document.forms["form"]["G1ShapeId"+OrderId].value;
		if (G1ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G1SizeId = document.forms["form"]["G1SizeId"+OrderId].value;
		if (G1SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G1Count = document.forms["form"]["G1Count"+OrderId].value;
		if (G1Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G1Wt = document.forms["form"]["G1Wt"+OrderId].value;
		if (G1Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
	}
	
	if (document.contains(document.getElementById("G2ShapeId"+OrderId))) {
  
   
		var G2ShapeId = document.forms["form"]["G2ShapeId"+OrderId].value;
		if (G2ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G2SizeId = document.forms["form"]["G2SizeId"+OrderId].value;
		if (G2SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G2Count = document.forms["form"]["G2Count"+OrderId].value;
		if (G2Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G2Wt = document.forms["form"]["G2Wt"+OrderId].value;
		if (G2Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}		  
	}
	
	if (document.contains(document.getElementById("G3ShapeId"+OrderId))) {
   
		var G3ShapeId = document.forms["form"]["G3ShapeId"+OrderId].value;
		if (G3ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G3SizeId = document.forms["form"]["G3SizeId"+OrderId].value;
		if (G3SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G3Count = document.forms["form"]["G3Count"+OrderId].value;
		if (G3Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G3Wt = document.forms["form"]["G3Wt"+OrderId].value;
		if (G3Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
	}
	
	if (document.contains(document.getElementById("G4ShapeId"+OrderId))) {
   
		var G4ShapeId = document.forms["form"]["G4ShapeId"+OrderId].value;
		if (G4ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G4SizeId = document.forms["form"]["G4SizeId"+OrderId].value;
		if (G4SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G4Count = document.forms["form"]["G4Count"+OrderId].value;
		if (G4Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G4Wt = document.forms["form"]["G4Wt"+OrderId].value;
		if (G4Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
	}
	
	if (document.contains(document.getElementById("G5ShapeId"+OrderId))) {
 
		var G5ShapeId = document.forms["form"]["G5ShapeId"+OrderId].value;
		if (G5ShapeId == 0) {
			alert("Gem 1 Shape must be selected");
			return false;
		}	 
		var G5SizeId = document.forms["form"]["G5SizeId"+OrderId].value;
		if (G5SizeId == 0) {
			alert("Gem 1 Size must be selected");
			return false;
		}
		var G5Count = document.forms["form"]["G5Count"+OrderId].value;
		if (G5Count == "") {
			alert("Gem 1 Count must be filled out");
			return false;
		}	
		var G5Wt = document.forms["form"]["G5Wt"+OrderId].value;
		if (G5Wt == "") {
			alert("Gem 1 Weight must be filled out");
			return false;
		}	  
  }
   /*
  var Setting = document.forms["form"]["Setting"+OrderId].value;
  if (Setting == 0) {   
    alert("Setting must be selected");
    return false;
  } 
  var Casting = document.forms["form"]["Casting"+OrderId].value;
  if (Casting == 0) {   
    alert("Casting must be selected");
    return false;
  }
  var Rhodium = document.forms["form"]["Rhodium"+OrderId].value;
  if (Rhodium == 0) {   
    alert("Rhodium must be selected");
    return false;
  }
  var Plating = document.forms["form"]["Plating"+OrderId].value;
  if (Plating == 0) {   
    alert("Plating must be selected");
    return false;
  }
  var FilingPolishing = document.forms["form"]["FilingPolishing"+OrderId].value;
  if (FilingPolishing == "") {
    alert("Filing Polishing must be filled out");
    return false;
  }
  var OtherCost = document.forms["form"]["OtherCost"+OrderId].value;
  if (OtherCost == "") {
    alert("Other Cost must be filled out");
    return false;
  }  
  
  */
  var OtherCost = document.forms["form"]["OtherCost"+OrderId].value;
  var OtherCode = document.forms["form"]["OtherCode"+OrderId].value;
  if (OtherCost > 0 && OtherCode == 0) {   
    alert("OtherCode must be selected");
    return false;
  }
 // return false;
	  
	  
  }
  
}
  
</script>
<script type="text/javascript">
//function redirectFilter()
	
    document.getElementById("filter").onclick = function () {
		var filter_product = $('input[name=\'filter_product\']').attr('value');
		url = "<?php echo $action; ?>" + '&filter_product=' + filter_product;
        location.href = url.replace(/&amp;/g, '&');
    };
//}
</script>
<?php echo $footer; ?>