<?php
if($_REQUEST['Id']!='' && $_REQUEST['action']=='rev')
{
	$sql1=DB_query("Select * from quotation where id='".$_REQUEST['Id']."'",$db);
	$result1=DB_fetch_array($sql1);
	?>
<h2 align="center">Revise Quotation</h2>	
<table width="80%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" style="border:1px solid #CCC;" align="center">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
  <tr>
    <th width="25%" nowrap="nowrap" scope="row"><strong>Branch</strong></th>
    <td width="25%" nowrap="nowrap">
    <select name="site" style="width:98%;" id="site" onchange="getCode(this.value)">
    <?php 
    $site_sql=DB_query("Select loccode, locationname from locations where loccode='".$result1['site']."'",$db);
    while($site_row=DB_fetch_array($site_sql))
	{?>
		<option value="<?php echo $site_row['loccode']?>"<?php echo($_REQUEST['site']==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname']?></option>
	<?php 	
	}
    ?>
    </select></td>
    <th width="25%"><strong>Quotation No.</strong></th>
    <td width="25%" id="CODE"><input name="quotationNo" type="text" value="<?php echo $result1['quotationNo'];?>" size="25"  style="width:98%;"/></td>
  </tr>
  <tr>
    <th scope="row"><strong>Date </strong></th>
    <td nowrap="nowrap"><input type="text" name="quotationDate" value="<?php echo $result1['quotationDate'];?>" style="width:98%;" class="datepicker"/></td>
    <th nowrap="nowrap">Format</th>
    <td nowrap="nowrap"><select name="format" style="width:98%;">
      <option value="Standard">Standard</option>
    </select></td>
  </tr>
  <tr>
    <th nowrap="nowrap"><strong>Party Name</strong></th>
    <td nowrap="nowrap">
    <select name="party" style="width:98%;" onchange="enquiryDetails(this.value)">
      <?php 
      $client_sql=DB_query("Select client_code,c_name from clientmaster where client_code='".$result1['party']."'",$db);
	  while($client_row=DB_fetch_array($client_sql))
	  {?>
	  	<option value="<?php echo $client_row['client_code'];?>"<?php echo($_REQUEST['party']==$client_row['client_code']?'selected':'')?>><?php echo $client_row['c_name'];?></option>
	  <?php 	
	  }
      ?>
    </select></td>
    <th scope="row"><strong>Type of Quotation</strong></th>
    <td><select name="quotationType" style="width:98%;">
      <option value="M"<?php echo($result1['quotationType']=='M'?'selected':'')?>>Material</option>
      <option value="E"<?php echo($result1['quotationType']=='E'?'selected':'')?>>Export</option>
      <option value="R"<?php echo($result1['quotationType']=='R'?'selected':'')?>>Retail</option>
    </select></td>
    </tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="4">
 
    <table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
    <td colspan="2" valign="top"><div id="enquiryId">
    	<table width="100%" cellpadding="2" cellspacing="1" border="0">
        	<tr>
            <th nowrap="nowrap" width="50%"><strong>Against Enquiry</strong></th>
            <td nowrap="nowrap" width="50%">
          
            <select name="enquiryNo" style="width:98%;" onchange="showEnqDetails(this.value)">
              <?php 
             $enq_sql=DB_query("Select id,enquiryNo from enquiry where id='".$result1['enquiryNo']."'",$db);
			while($enq_row=DB_fetch_array($enq_sql))
			{?>
				<option value="<?php echo $enq_row['id'];?>"<?php echo($_REQUEST['enquiryNo']==$enq_row['id']?'selected':'')?>><?php echo $enq_row['enquiryNo'];?></option>	
			<?php 	
			}
            ?>
            </select></td>
   		 </tr>
   		 <?php 
   		 $address_sql=DB_query("Select pre_address1,pre_address2,pre_address3,pre_country,pre_state,pre_city from clientmaster where client_code='".$result1['party']."'",$db);
		 $address_result=DB_fetch_array($address_sql);
   		 
   		 $countryName=$s->getField('country_master','id',$address_result['pre_country'],'country');
		 $stateName=$s->getField('state_master','id',$address_result['pre_state'],'state');
		 $cityName=$s->getField('city_master','id',$address_result['pre_city'],'city');
   		 ?>
         <tr>
            <th scope="row" rowspan="3"><strong>Address</strong></th>
            <td><input name="partyaddress1" type="text" value="<?php echo $address_result['pre_address1'];?>" size="25"  style="width:98%;"/></td>
            </tr>
            <tr>
            <td><input name="partyaddress2" type="text" value="<?php echo $address_result['pre_address2'];?>" size="25"  style="width:98%;"/></td>
            </tr>
            <tr>
            <td><input name="partyaddress3" type="text" value="<?php echo $address_result['pre_address3'].",".$cityName.",".$stateName.",".$countryName;?>" size="25"  style="width:98%;"/></td>
            </tr>
     </table></div>
    </td>
    <td valign="top"><div id="enqdetailsId"><table width="100%" border="0" cellspacing="1" cellpadding="1">
  <?php     if($myrow['source']=='CC'){echo "Cold Call";}
if($result1['source']=='EC'){$source="Existing Customer";}
if($result1['source']=='SG'){$source="Self Generated";}
if($result1['source']=='EMP'){$source="Employee";}
if($result1['source']=='PTN'){$source="Partner";}
if($result1['source']=='DM'){$source="Direct Mail";}
if($result1['source']=='WEB'){$source="Web Site";}
if($result1['source']=='O'){$source="Other";} ?>
      <tr>
        <th width="50%" scope="row"><strong>Source Through </strong></th>
        <td width="50%">	
        <input name="source" type="text" value="<?php echo $source;?>" size="25"  style="width:98%;"/></td>
      </tr>
      
      <tr>
        <th scope="row"><strong>Contact Person</strong></th>
        <td><input type="text" name="partyContact" style="width: 98%" value="<?php echo $result1['partyContact'];?>" /></td>
      </tr>
     <?php 
     $mobile_sql=DB_query("Select phone from contact_information_master where person='".$result1['partyContact']."'",$db);
     $mobile_res=DB_fetch_array($mobile_sql)
     ?>
      <tr>
        <th scope="row"><strong>Mobile No.</strong></th>
        <td><input name="ContactMobile" type="text" value="<?php echo $mobile_res['phone'];?>" size="25" style="width:98%;"/></td>
      </tr>
    </table></div>
    <table border="0" width="100%"><tr><th width="50%">Valid Till</th><td width="50%"><input name="validTill" type="text" value="<?php echo $result1['validTill'];?>" size="12" class="datepicker"  style="width:98%;"/></td></tr></table>	
    </td>
    </tr>
</table>

</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<th>Item Code</th>
<th>Item Name</th>
<th>Unit</th>
<th>Qty</th>
<th>Price</th>
<th>Per Unit(s)</th>
<th>Value</th>
<th>Discount Type</th>
<th>Discount</th>
<th>Discounted Price</th>
<th>Date Of Requisition</th>
</tr>
<?php 
$details_sql=DB_query("Select * from quotation_details where parentId='".$_REQUEST['Id']."'",$db);
	$i=0;
	while($details_row=DB_fetch_array($details_sql))
	{
		$item_sql=DB_query("Select * from item_master where StockID='".$details_row['itemCode']."'",$db);
		$item_row=DB_fetch_array($item_sql);
	
	?>
<tr bgcolor="#FFFFFF">
<td><?php echo $details_row['itemCode']?><input type="hidden" name="itemCode[<?php echo $i;?>]" value="<?php echo $details_row['itemCode']?>" id="itemCode_<?php echo $i;?>" /></td>
<td><?php echo $item_row['item_name']?></td>
<td><?php 
$unitName=$s->getField('unitsofmeasure','unitid',$item_row['unit'],'unitname');
echo $unitName?></td>
<td><?php echo $details_row['quantity']?><input type="hidden" name="quantity[<?php echo $i;?>]" value="<?php echo $details_row['quantity']?>" id="quantity_<?php echo $i;?>" /></td>
<td><?php echo $details_row['price']?><input type="hidden" name="price[<?php echo $i;?>]" value="<?php echo $details_row['price']?>" id="price_<?php echo $i;?>" /></td>
<td><?php echo $details_row['PerUnits']?><input type="hidden" name="PerUnits[<?php echo $i;?>]" id="PerUnits_<?php echo $i;?>" value="<?php echo $details_row['pricePer']?>" /></td>
<td><?php echo $details_row['totalValue']?><input type="hidden" name="totalValue[<?php echo $i;?>]" id="totalValue_<?php echo $i;?>" value="<?php echo $details_row['totalValue']?>" /></td>
<td>
<select name="discountType[<?php echo $i;?>]" id="discountType_<?php echo $i;?>" style="width: 98%">
	<option value="A"<?php echo($details_row['discountType']=='A'?'selected':'')?>>Amount</option>
	<option value="P"<?php echo($details_row['discountType']=='P'?'selected':'')?>>Percent</option>
</select>
</td>
<td><input type="text" name="discount[<?php echo $i;?>]" id="discount_<?php echo $i;?>" value="<?php echo $details_row['discount']?>" size="15" onblur="calculateDiscount(this.value,<?php echo $i;?>)" /></td>
<td><input type="text" name="valueAfterDisc[<?php echo $i;?>]" id="valueAfterDisc_<?php echo $i;?>" value="<?php echo $details_row['valueAfterDisc']?>" size="15"/></td>
<td><?php echo $details_row['requisitionDate']?><input type="hidden" name="requisitionDate[<?php echo $i;?>]" id="requisitionDate_<?php echo $i;?>" value="<?php echo $details_row['requisitionDate']?>" size="15"/></td>
</tr>
<?php 	
} }
?>
</table>
