<?php session_name('CAKEPHP'); session_start();
$PageSecurity = 4;
include('includes/session.inc');
include('includes/function_lib.php');
global $db;
$getlead=DB_query( "select * from crm_accounts where mst_leadid='".$_REQUEST['branch']."'",$db);
$row_lead=DB_fetch_array($getlead);
$leadcode=$row_lead['leadcode'];
$company_name=$row_lead['company_name'];
$address1=$row_lead['address1'];
$groupid=$row_lead['groupid'];
$city=$row_lead['city'];
$zipcode=$row_lead['zipcode'];
$country=$row_lead['country'];
$Shipping_address=$row_lead['Shipping_address'];
$Shipping_zipcode=$row_lead['Shipping_zipcode'];
$Shipping_city=$row_lead['Shipping_city'];
$Shipping_country=$row_lead['Shipping_country'];

$city_name=$s->GetFieldValue('city_master',"id='".$city."'",'city');
$countryName=$s->GetFieldValue('country_master',"id='".$country."'",'country');

$data1="";
$data1.="<input type='text' name='address1' style='width:150px;'   value='".$address1."'/>";

$data2="";
$data2.="<input name='city' type='hidden'  style='width:150px;' value='".$city."'/>";
$data2.="<input name='city1' type='text'  style='width:150px;' value='".$city_name."'/>";

$data3="";
$data3.="<input type='text' name='zipcode' style='width:150px;'  value='".$zipcode."' />";

$data4="";
$data4.="<input type='hidden' name='country' style='width:150px;'  value='".$country."' />";
$data4.="<input type='text' name='country1' style='width:150px;'  value='".$countryName."' />";

$data5="";
$data5.="<input type='text' name='Shipping_address' style='width:150px;'  value='".$Shipping_address."' />";

$data6="";
$data6.="<input type='text' name='Shipping_city' style='width:150px;'  value='".$Shipping_city."' />";

$data7="";
$data7.="<input type='text' name='Shipping_zipcode' style='width:150px;'  value='".$Shipping_zipcode."' />";

$data8="";
$data8.="<input type='text' name='Shipping_country' style='width:150px;'  value='".$Shipping_country."' />";



$data9="";

$data9.="<table align='center' width='100%;' border='1' cellpadding='3' cellspacing='0'>";
$data9.="<tr class='row1'><td class='tabledata' style='text-align:center;' colspan='13'>Item Details</td></tr>";
$data9.="<tr class='row1'>";
    $data9.="<td class='tabledata'>Sr. No.</td>";
    $data9.="<td class='tabledata'>&nbsp;</td>";
    $data9.="<td class='tabledata'>Item Code</td>";
    $data9.="<td class='tabledata'>Item Name</td>";
    $data9.="<td class='tabledata'>Qty.</td>";
    $data9.="<td class='tabledata'>Price</td>";
    $data9.="<td class='tabledata'>Per Unit</td>";
    $data9.="<td class='tabledata'>Value</td>";
    $data9.="<td class='tabledata'>Discount Type</td>";
    $data9.="<td class='tabledata'>Discount Per</td>";
    $data9.="<td class='tabledata'>Discount Price</td>";
    $data9.="<td class='tabledata'>Value After Discount</td>";
    $data9.="<td class='tabledata'>Total stock Qty</td>";
$data9.="</tr>";
 //$data9.="<tbody id='dataTable'>";
$i=0; 

//echo "select * from crm_lead_items where mst_leadid='".$_REQUEST['branch']."'";
$getitem=DB_query("select * from crm_lead_items where mst_leadid='".$_REQUEST['branch']."' and del_status=0",$db);
while($row=DB_fetch_array($getitem))
{
$item_Codeas=$s->GetFieldValue('item_master',"id='".$row['item_code']."'",'StockID');
$item_names=$s->GetFieldValue('item_master',"id='".$row['item_code']."'",'item_name');
$data9.="<tr class='row1'>";
$data9.="<td style='white-space:nowrap;' class='tabledata' width='4%'>
<input name='delitemdata[]' type='checkbox' value='' onclick='showdata(".$row['id'].")' /></td>";	
$data9.="<td class='tabledata'><input type='hidden' name='item_code[]' id='itemid_".$i."' value='".$row['item_code']."' /></td>";
$data9.="<td class='tabledata' width='6%'><input type='text'     value='".$item_Codeas."'  />
<input type='hidden'   id='stockqty1_".$i."' size='9'  value='".$row['stock_qty']."'  /></td>";
$data9.="<td class='tabledata' style='white-space:nowrap' width='6%'><input type='text'   id=''  value='".$item_names."'  /></td>";
$data9.="<td class='tabledata'><input type='text' name='stock_qty[]'  id='stock_qty2_".$i."' size='9' value='".$row['stock_qty']."'  onkeyup='calcValue(this.value,".$i.")'/></td>";
$data9.="<td class='tabledata' width='3%'><input type='text' name='stock_price[]' value='".$row['stock_price']."' id='stock_price1_".$i."'  size='6'/></td>";
$data9.="<td class='tabledata' width='6%'><input type='text' name='stock_perunit[]' onfocus='filldefaultAmt(this.value,this.id)' id='stock_perunit1_".$i."' size='9' value='".$row['stock_perunit']."'/></td>";
$data9.="<td class='tabledata'><input type='text' name='stock_value[]' value='".$row['stock_value']."' id='stock_value1_".$i."' size='9' onfocus='CalculateTotalLeadAmt1(this.value,".$i.")'/></td>";
$data9.="<td class='tabledata'><select style='width:80px;' name='PerAmo[]' id='PerAmo1_".$i."' >
            <option value='Amount' >Amount</option>
            <option value='PercentAmt'>Percent Amt</option>
          </select></td>";
$data9.="<td class='tabledata'><input type='text' style='width:35px' name='Discount[]' id='Discount1_".$i."' onkeyup='DiscountAmount(this.value,".$i.")' /></td>";
$data9.="<td class='tabledata'><input type='text' style='width:35px' name='perc[]' id='perc1_".$i."'  readonly='true' style='width:100%;' /></td>";
$data9.="<td class='tabledata'><input type='text' style='width:35px' name='value_dis[]' id='value_dis1_".$i."'  readonly='true' style='width:100%;' /></td>";



$data9.="<td class='tabledata'><input type='text' name='total_stock[]' id='total_stock1_".$i."' style='width:50px;' value='".$row['total_stock']."'  readonly='true' /></td>";
$data9.="</tr>";
$i++;}
/*$data9.="<input type='hidden' name='' value='".$i."' id='edit_cnt' /> ";
 $data9.="<tbody id='dataTable'>";
 $data9.="<tr class='row1'>";
$data9.="<td style='white-space:nowrap;' class='tabledata'><input name='delitem[]' type='checkbox' value='' />
</td>";	
$data9.="<td class='tabledata'><input type='hidden' name='item_code[]' id='itemid' value='' /></td>";
$data9.="<td class='tabledata'><input type='text' name='' id='itemcode' value='' /></td>";
$data9.="<td class='tabledata' style='white-space:nowrap'><input type='text' name='item_name[]' id='itemname' value='' /></td>";
$data9.="<td class='tabledata'><input type='text' name='stock_qty[]'  id='stock_qty' size='9' onkeyup='calcValue1(this.value,this.id)'  /></td>";
$data9.="<td class='tabledata'><input type='text' name='stock_price[]'  id='stock_price' size='6'/></td>";
$data9.="<td class='tabledata'><input type='text' name='stock_perunit[]' onfocus='filldefaultAmt(this.value,this.id)' id='stock_perunit' size='9' value='1' /></td>";
$data9.="<td class='tabledata'><input type='text' name='stock_value[]'  id='stock_value' size='9' onfocus='CalculateTotalLeadAmt(this.value,this.id)'/></td>";
$data9.="<td class='tabledata'><select style='width:80px;' name='PerAmo[]' id='PerAmo' >
            <option value='Amount' >Amount</option>
            <option value='PercentAmt'>Percent Amt</option>
          </select></td>";
$data9.="<td class='tabledata'><input type='text' style='width:35px' name='Discount[]' id='Discount' onkeyup='DiscountAmount1(this.value,this.id)' /></td>";
$data9.="<td class='tabledata'><input type='text' style='width:35px' name='perc[]' id='perc'  readonly='true' style='width:100%;' /></td>";
$data9.="<td class='tabledata'><input type='text' style='width:35px' name='value_dis[]' id='value_dis'  readonly='true' style='width:100%;' /></td>";



$data9.="<td class='tabledata'><input type='text' name='total_stock[]' id='total_stock' style='width:50px;'   readonly='true' /></td>";
$data9.="</tr>";

$data9.="<input type='hidden' name='against_leadid' id='against_leadid' value='".$_REQUEST['branch']."'>";
$data9.="</tbody>";*/
$data9.="<input type='hidden' name='count1' id='count1' value='".$i."'>";

$data9.="</table>";




echo $data=$data1."__".$data2."__".$data3."__".$data4."__".$data5."__".$data6."__".$data7."__".$data8."__".$data9;
?>
  
