<?php require "_header.php";?>

<?php require "includeGridFilters.php";?>
<?php 
 
if ($_REQUEST["returnId"] !="" && isset($_REQUEST["returnId"]) != "") 
	{   
		$returnId = $_REQUEST["returnId"]; 
	} 
	$customer_id = $_REQUEST["customer_id"];
	if ($customer_id !="" && isset($customer_id) != "") 
	{ 
	//echo $cust_id;	exit;		
		$mode = 'edit';
		$qry="SELECT * FROM 
					lms_designation desg,
					lms_distmaster dist,
					ams_accountmaster am, 
					ams_accountgroup ag,
					lms_customer lc 
				
				WHERE 
					desg.designation_id = lc.customer_cpdesignation1 AND 
					dist.dist_id = lc.district_id AND
					am.account_groupid = ag.account_groupid AND
					lc.company_id=am.company_id AND
					lc.customer_orgname = am.account_name AND 
					customer_id = '".$customer_id."'";
		/*echo $qry;
		exit;*/
		$out = dbQuery($qry);  
		if (dbRows($out)){
			$row = dbArray($out);
			extract($row);			
		} 
		//echo "<pre>";
	//print_r($row);
	
	//exit;
	}
?>  
<!-- start custom CSS/JS -->
<style type="text/css">
        p {
            width: 750px;
        }
        .ext-ie .x-form-check-wrap, .ext-gecko .x-form-check-wrap {
            padding-top: 3px;
			
        }
        fieldset legend {
            white-space: nowrap;
        }
		label.myBold
		{
		   font-weight: bold;
		   color:#006;
		   font-size: 14px;
		}
		

</style>
<script type="text/javascript" language="javascript"> 
var returnId = '<?php  echo $returnId ?>'; 
</script>
<script type="text/javascript" src="js/addedit-customer.js"></script>
<script type="text/javascript" language="javascript"> 
Ext.onReady(function(){	
	Ext.QuickTips.init();
	var returnId = '<?php  echo $returnId ?>';  
	var customer_id= '<?php echo $customer_id; ?>';
	var mode = '<?php echo $mode;?>';
	
	if(mode == 'edit')
	{
	groupstore.on('load', function(store, records) 
							{
								CustomergridForm.getForm().findField('groupname').setValue('<?php echo $account_groupid; ?>');
								CustomergridForm.getForm().findField('groupname').setRawValue('<?php echo $account_groupname; ?>');
							});
    	
	CustomergridForm.getForm().findField('customer_orgname').setValue('<?php echo $customer_orgname; ?>');
  	
	districtsore.on('load', function(store, records) 
							{
								CustomergridForm.getForm().findField('district_id').setValue('<?php echo $dist_id; ?>');
    CustomergridForm.getForm().findField('district_id').setRawValue('<?php echo $dist_nameeng; ?>');
 
							});
    
     CustomergridForm.getForm().findField('customer_balance').setValue('<?php print $customer_balance; ?>');
     CustomergridForm.getForm().findField('customer_baltype').setValue('<?php print $customer_baltype; ?>');
	 
	 <?php if($customer_baltype == 'C'){
	 		$baltype = 'Credit';
	 		}else if($customer_baltype == 'D'){
	 		$baltype = 'Debit';
			}
	 ?>
     CustomergridForm.getForm().findField('customer_baltype').setRawValue('<?php echo $baltype; ?>');

     CustomergridForm.getForm().findField('customer_cpname1').setValue('<?php print $customer_cpname1; ?>');
     
     CustomergridForm.getForm().findField('customer_cpdesignation1').setValue('<?php print $designation_id; ?>');
     CustomergridForm.getForm().findField('customer_cpdesignation1').setRawValue('<?php echo $designation_name; ?>');		

     CustomergridForm.getForm().findField('customer_cpmobile1').setValue('<?php print $customer_cpmobile1; ?>');
	 CustomergridForm.getForm().findField('customer_cpemail1').setValue('<?php print $customer_cpemail1; ?>');
     CustomergridForm.getForm().findField('customer_remark').setValue('<?php print $customer_remark; ?>');
     CustomergridForm.getForm().findField('customer_address').setValue('<?php print $customer_address;?>');
	 
    CustomergridForm.getForm().findField('customer_tinno').setValue('<?php print $customer_tinno; ?>');
     CustomergridForm.getForm().findField('customer_cstno').setValue('<?php print  $customer_cstno; ?>');
     CustomergridForm.getForm().findField('customer_panno').setValue('<?php print $customer_panno; ?>');
     CustomergridForm.getForm().findField('customer_servicetaxno').setValue('<?php print $customer_servicetaxno; ?>');
	 CustomergridForm.getForm().findField('customer_phone1').setValue('<?php print $customer_phone1; ?>');
     CustomergridForm.getForm().findField('customer_phone2').setValue('<?php print $customer_phone2; ?>');
	 CustomergridForm.getForm().findField('customer_email').setValue('<?php print $customer_email; ?>');
     CustomergridForm.getForm().findField('customer_website').setValue('<?php print $customer_website; ?>');
     CustomergridForm.getForm().findField('customer_id').setValue('<?php print $customer_id; ?>');
     CustomergridForm.getForm().findField('account_id').setValue('<?php print $account_id; ?>');
	 //CustomerWindow.show();
    }
	CustomerWindow.show();
	
});
</script>
<!-- end custom CSS/JS -->
<div id="main-content"></div>
<?php require "_footer.php";?>