<?php $PageSecurity = 11;
include('includes/session.inc');
//include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
if($_REQUEST['id']=='Consolidate')
{?>

<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border:#666666 solid 1px;">
              <tr class="row1">
                <td class="tabledata">S.No</td>
				 <td class="tabledata"></td>
				<td class="tabledata" style="width:40px;">Item Code</td>
				<td class="tabledata">Shade/Item Name. </td>
				<td class="tabledata" style="width:250px;">Item Desc. </td>
                <td class="tabledata">Qty</td>
                <td class="tabledata">Price</td>
                <td class="tabledata">Total Amt</td>
                <td class="tabledata">Excise Duty Rate</td>
                <td class="tabledata">ED Amt</td>
              </tr>
		<!-------------Add ITEMS IN THE ITEM LIST AT TIME OF EDIT----------------------->
<?php 
 $i=0;
  $ItemSQL=DB_query("Select * from salesorder_details where masterId='".$_REQUEST['SalesId']."' and del_status='0'",$db);
  while($item_row1=DB_fetch_array($ItemSQL))
  {
 
	//echo "select * from item_master where id='".$item_row1[ItemCode]."'";
	 $itemquery=DB_query("select * from item_master where id='".$item_row1[ItemCode]."'" , $db);
	$item_row=DB_fetch_array($itemquery);
	 //echo "select StockID,item_name,unit, make ,grade, color from item_master where StockID='".$itemlist[$i]."'" ;
	
		if($i%2==0)
		{$bg="#CCCCCC";}
		else
		$bg="#C8BECB";
	
	?>
	
	<tr bgcolor="<?php //echo $bg;?>"  class="row1">
	<td class="tabledata"><a href="index.php?route=CRM/TelephonicEdit&action=Edit&SOrderId=<?php echo $_REQUEST['SOrderId'];?>&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&act=delitem&id=<?php echo $item_row1['id'];?>"><img src="images/delete.gif" /></a>
	<?php //echo $i+1;?></td>
	 <td class="tabledata"><input type="hidden" name="row_id[<?php echo $i; ?>]" id="row_id" value="<?php echo $item_row1['id']?>" /></td>	
	<td  class="tabledata">
	<input type="hidden" name="itemid[<?php echo $i; ?>]" value="<?php echo $item_row['id'];?>" />
	<input type="hidden" name="item_code[<?php echo $i;?>]" id="item_code_<?php echo $i;?>" value="<?php echo $item_row['StockID'];?>">	
				<?php echo $item_row['StockID'];?>
   <input type="hidden" value="<?php echo $item_row['StockID'];?>" tabindex=""  readonly="" id="washing_profile" name="itemcode[]"   />
   <input type="hidden" name="salesdetailid[<?php echo $i;?>]" value="<?php echo $item_row1['id'];?>"  />
   <input type="hidden" name="itemid[<?php echo $i;?>]" value="<?php echo $item_row['id'];?>" />
	</td>	
   <td class="tabledata">
				<?php echo $item_row['item_name'];?>
                </td>
   <td class="tabledata" style="white-space:nowrap"><?php echo $item_row['item_desc'];?></td>
   
   <td class="tabledata"><input type="text" style="width:50" name="Qty[<?php echo $i;?>]" id="qty_<?php echo $i;?>" value="<?php echo $item_row1['Quantity']?>" size="6" /></td>
   
    <td class="tabledata"><input type="text" name="price[<?php echo $i;?>]" id="price_<?php echo $i;?>" value="<?php echo $item_row1['Rate']?>" style="width:60px;" onkeyup="calculateTotalAmt(this.value,this.id)" size="6" /></td>
   
    <td class="tabledata"><input type="text" name="stock_qty[<?php echo $i;?>]" id="totalamt_<?php echo $i;?>" style="width:70px;" value="<?php echo $item_row1['Amount']?>" readonly="true" size="6"  />
   
   <?php $item_row1['EDRate']; ?>
   </td>
    <td class="tabledata">
   <select name="EDRate[<?php echo $i;?>]" id="exciserate_<?php echo $i?>" style="width:107px;" onchange="calculateExcise(this.value,this.id)">
    		<option value="0">--Select--</option>
    		<?php
    		$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
			$ServiceRes=DB_query($ServiceSql,$db);
			while($ServiceRow=DB_fetch_array($ServiceRes))
			{
			
			?>
			<option value="<?php echo $ServiceRow['id']?>"<?php echo ($item_row1['EDRate']==$ServiceRow['id']?'selected':''); ?>><?php echo $ServiceRow['caption']?></option>
			<?php	
			}
    		
    		?>
    		</select>
   
   <?php //echo $s->GetFieldValue('excise_tax',"id=".$item_row1['EDRate']."",'caption');?>
   
   </td>
   <td class="tabledata">
   <div id='hid_ED_div_<?php echo $i?>'>  
   <input size="10" type="text" name="EDAmt[<?php echo $i?>]" id="excisevalue_<?php echo $i ?>" value="<?php echo $item_row1['EDAmt']?>" >
   
   </div>
   </td>
  </tr>
  <?php  $i++;
   }  ?>	
  <input type="hidden" name="" value="<?php echo $i;?>" id="edit_cnt" /> 
  <?php 
  {
  ?>
<!------Add Extra Items--------->	
<tbody id="dataTable">
				<tr class="row1">
<td style="white-space:nowrap;" class="tabledata"><input name="delitem[]" type="checkbox" value="<?php echo $item_row['id'];?>" />
</td>	
<td style="white-space:nowrap;" class="tabledata"><input name="delitem[]" type="checkbox" value="<?php echo $item_row['id'];?>" /></td>
<td class="tabledata"><input type="hidden" name="item_code1[]" id="itemid" /></td>	
<td class="tabledata"><input type="text" name="" value="" id="itemcode" size="6" /></td>
<td class="tabledata" style="white-space:nowrap"><input type="text" name="" value="" id="itemname" /></td>
<td class="tabledata"><input type="text" name="" value="" id="itemdesc" size="40"/></td>
<td class="tabledata"><input type="text" name="Qty1[]" value="" id="qty" size="6"/></td>
<td class="tabledata"><input type="text" name="price1[]" value="" id="price" onkeyup="calculateTotalAmt(this.value,this.id)" size="6"/></td>
<td class="tabledata"><input type="text" name="stock_qty1[]" value="" id="totalamt" readonly="true" size="9"/></td><td class="tabledata"><select name="EDRate[]" id="exciserate" style="width:107px" 
		onchange="calculateExcise(this.value,this.id)">
      <option value="0">--Select--</option>
      <?php
    		$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
			$ServiceRes=DB_query($ServiceSql,$db);
			while($ServiceRow=DB_fetch_array($ServiceRes))
			{
			?>
      <option value="<?php echo $ServiceRow['id']?>" <?php echo($edit_EDRate==$ServiceRow['id']?'selected':'') ?>><?php echo $ServiceRow['caption'];?></option>
      <?php	
			}
    		?>
    </select></td>
   <td class="tabledata"><input type="text" name="EDAmt1[]" value="" id="excisevalue" size="10"/></td>
   <input type="hidden" name="ApprovalStatus1[]" value="Pending">
  </tr>
 </tbody>
<?php } ?>
  
 <!------Add Extra Items--------->	 
  
</table>
<?php } else
 { ?>
 	
 	<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border:#666666 solid 1px;">
              <tr class="row1">
                <td class="tabledata">S.No</td>	
                <td class="tabledata"></td>			
				<td class="tabledata" style="width:40px;">Item Code</td>
				<td class="tabledata">Shade/Item Name. </td>
				<td class="tabledata" style="width:250px;">Item Desc. </td>
                <td class="tabledata">Qty</td>
                <td class="tabledata">Price</td>
                <td class="tabledata">Total Amt</td>
                <td class="tabledata">MRP /Unit</td>
                <td class="tabledata">Ass Price</td>
                <td class="tabledata">Total Ass Value</td>
                <td class="tabledata">Excise Duty Rate</td>
                <td class="tabledata">ED Amt</td>
              </tr>
		<!-------------Add ITEMS IN THE ITEM LIST AT TIME OF EDIT----------------------->
<?php 
 $i=0;
  $ItemSQL=DB_query("Select * from salesorder_details where masterId='".$_REQUEST['SalesId']."' and del_status='0'",$db);
  while($item_row1=DB_fetch_array($ItemSQL))
  {
 
	//echo "select * from item_master where id='".$item_row1[ItemCode]."'";
	 $itemquery=DB_query("select * from item_master where id='".$item_row1[ItemCode]."'" , $db);
	$item_row=DB_fetch_array($itemquery);
	 //echo "select StockID,item_name,unit, make ,grade, color from item_master where StockID='".$itemlist[$i]."'" ;
	
		if($i%2==0)
		{$bg="#CCCCCC";}
		else
		$bg="#C8BECB";
	
	?>
	
	<tr bgcolor="<?php //echo $bg;?>"  class="row1">
	<td class="tabledata"><a href="index.php?route=CRM/TelephonicEdit&action=Edit&SOrderId=<?php echo $_REQUEST['SOrderId'];?>&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&act=delitem&id=<?php echo $item_row1['id'];?>"><img src="images/delete.gif" /></a>
	<?php //echo $i+1;?></td>
	<td  class="tabledata"><input type="hidden" name="row_id[<?php echo $i; ?>]" id="row_id" value="<?php echo $item_row1['id']?>" /></td>	
	<td  class="tabledata">
	<input type="hidden" name="itemid[<?php echo $i; ?>]" value="<?php echo $item_row['id'];?>" />
	<input type="hidden" name="item_code[<?php echo $i;?>]" id="item_code_<?php echo $i;?>" value="<?php echo $item_row['StockID'];?>">	
				<?php echo $item_row['StockID'];?>
   <input type="hidden" value="<?php echo $item_row['StockID'];?>" tabindex=""  readonly="" id="washing_profile" name="itemcode[]"   />
   <input type="hidden" name="salesdetailid[<?php echo $i;?>]" value="<?php echo $item_row1['id'];?>"  />
   <input type="hidden" name="itemid[<?php echo $i;?>]" value="<?php echo $item_row['id'];?>" />
	</td>	
   <td class="tabledata1">
				<?php echo $item_row['item_name'];?>
                </td>
   <td class="tabledata" style="white-space:nowrap"><?php echo $item_row['item_desc'];?></td>
   
   <td  class="tabledata"><input type="text" style="width:50" name="Qty[<?php echo $i;?>]" id="qty_<?php echo $i;?>" value="<?php echo $item_row1['Quantity']?>" size="6" /></td>
   
   <td  class="tabledata"><input type="text" name="price[<?php echo $i;?>]" id="price_<?php echo $i;?>" value="<?php echo $item_row1['Rate']?>" size="6" onkeyup="calculateTotalAmt(this.value,this.id)" /></td>
   
   <td  class="tabledata"><input type="text" name="stock_qty[<?php echo $i;?>]" id="totalamt_<?php echo $i;?>" size="6" value="<?php echo $item_row1['Amount']?>" readonly="true"  />
   
   <?php $item_row1['EDRate']; ?>
   </td>
   <td class="tabledata"><input type="text" name="mrp_per[<?php echo $i;?>]" value="<?php echo $item_row1['mrp_unit']; ?>" id="mrpper_<?php echo $i;?>"  size="9" onkeyup="calassprice(this.value,this.id)" /></td>
<td class="tabledata"><input type="text" name="ass_price[<?php echo $i;?>]" value="<?php echo $item_row1['ass_price']; ?>" id="ass_price_<?php echo $i;?>" readonly="readonly"  size="9"/></td>
<td class="tabledata"><input type="text" name="total_ass_price[<?php echo $i;?>]" value="<?php echo $item_row1['total_ass_price']; ?>" id="totalassamt_<?php echo $i;?>" readonly="true" size="25" onfocus="calass_amount(this.id)" /></td>

   
   
  <td  class="tabledata">
   <select name="EDRate[<?php echo $i;?>]" id="exciserate_<?php echo $i?>" style="width:107px;" onchange="calculateExcise1(this.value,this.id)">
    		<option value="0">--Select--</option>
    		<?php
    		$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
			$ServiceRes=DB_query($ServiceSql,$db);
			while($ServiceRow=DB_fetch_array($ServiceRes))
			{
			
			?>
			<option value="<?php echo $ServiceRow['id']?>"<?php echo ($item_row1['EDRate']==$ServiceRow['id']?'selected':''); ?>><?php echo $ServiceRow['caption']?></option>
			<?php	
			}
    		
    		?>
    		</select>
   
   <?php //echo $s->GetFieldValue('excise_tax',"id=".$item_row1['EDRate']."",'caption');?>
   
   </td>
   <td  class="tabledata">
   <div id='hid_ED_div_<?php echo $i?>'>  
   <input size="10" type="text" name="EDAmt[<?php echo $i?>]" id="excisevalue_<?php echo $i ?>" value="<?php echo $item_row1['EDAmt']?>" >
   
   </div>
   </td>
  </tr>
  <?php  $i++;
   }  ?>	
  <input type="hidden" name="" value="<?php echo $i;?>" id="edit_cnt" /> 
 
<!------Add Extra Items--------->	
<tbody id="dataTable">
				<tr class="row1">
<td style="white-space:nowrap;" class="tabledata"><input name="delitem[]" type="checkbox" value="<?php echo $item_row['id'];?>" />
</td>	
<td class="tabledata"><input type="hidden" name="item_code1[]" id="itemid" /></td>
<td class="tabledata"><input type="text" name="" value="" id="itemcode" size="6" /></td>
<td class="tabledata" style="white-space:nowrap"><input type="text" name="" value="" id="itemname" /></td>
<td class="tabledata"><input type="text" name="" value="" id="itemdesc" size="40"/></td>
<td class="tabledata"><input type="text" name="Qty1[]" value="" id="qty" size="6" /></td>
<td class="tabledata"><input type="text" name="price1[]" value="" id="price" onkeyup="calculateTotalAmt(this.value,this.id)" size="6"/></td>
<td class="tabledata"><input type="text" name="stock_qty1[]" value="" id="totalamt" readonly="true" size="9"/></td>
<td class="tabledata"><input type="text" name="mrp_per1[]" value="" id="mrpper"  size="9" onkeyup="calassprice(this.value,this.id)" /></td>
<td class="tabledata"><input type="text" name="ass_price1[]" value="" id="ass_price" readonly="readonly"  size="9"/></td>
<td class="tabledata"><input type="text" name="total_ass_price1[]" value="" id="totalassamt" readonly="true" size="25" onfocus="calass_amount(this.id)" /></td>

<td class="tabledata"><select name="EDRate1[]" id="exciserate" style="width:107px" 
		onchange="calculateExcise1(this.value,this.id)">
      <option value="0">--Select--</option>
      <?php
    		$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
			$ServiceRes=DB_query($ServiceSql,$db);
			while($ServiceRow=DB_fetch_array($ServiceRes))
			{
			?>
      <option value="<?php echo $ServiceRow['id']?>" <?php echo($edit_EDRate==$ServiceRow['id']?'selected':'') ?>><?php echo $ServiceRow['caption'];?></option>
      <?php	
			}
    		?>
    </select></td>
   <td class="tabledata"><input type="text" name="EDAmt1[]" value="" id="excisevalue" size="10"/></td>
   <input type="hidden" name="ApprovalStatus1[]" value="Pending">
  </tr>
  </tbody>
	
<?php } ?>	


