<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}
$parent_name='';
$ledger_name='';
$transactionbank='';
$veh_num='';
$sdate_12 ='';
$page='1';
include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();
$msg = '';

			$from='';
			$to='';
			$amount='';
			$pay_date='';
			$cashed='';
			$cheque_no='';
			$cheque_date=date('d-m-Y');
			$bankname='';
			$branchname='';
			$neft_reference_no='';
			$purpose='';
			$sum_in_letters='';
			$editid = '';
			
			
if(isset($_REQUEST['savesalaryreturnreciept']))
{
if(isset($_REQUEST['bankcheck']) && $_REQUEST['bankcheck']!='')
{
		$bankcheck=2;
		$to=$_REQUEST['received_from'];
		$transactionbank=$_POST['transactionbank'];
		if($_REQUEST['transactiontype']=='cheque')
		{
		$cheque_no=$_REQUEST['cheque_no'];
		$cheque_date=date('Y-m-d',strtotime($_REQUEST['cheque_date']));
		$bankname=$_REQUEST['bankname'];
		$branchname=$_REQUEST['branchname'];
		$referenceno='';
		}
		else
		{
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno=$_REQUEST['referenceno'];
		}
}
else
{
		$to=1;
		$transactionbank=0;
		$bankcheck=1;
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno='';
}
$from=$_POST['received_to'];

$sal_advid=$_REQUEST['clientid'];
$pay_date=date('Y-m-d',strtotime($_POST['pay_date']));
$add_date=date("Y-m-d H:i:s");
$amount=$_POST['received_cash'];
$sum_in_letters=$_POST['sum_in_letters'];
$purpose=$_POST['purpose'];
$sql=mysql_query("insert into cf_reciept (`from`,`to`,`amount`,`purpose`,`pay_date`,`add_date`,`cashed`,`cheque_no`,`cheque_date`,`bankname`,`branchname`,`neft_reference_no`,`sum_in_words`,`transaction_bank`,`type_status`,`sal_advid`,`ledgr_rec_ids`) values ('$from','$to','$amount','$purpose','$pay_date','$add_date','$bankcheck','$cheque_no','$cheque_date','$bankname','$branchname','$referenceno','$sum_in_letters','$transactionbank','3','$sal_advid','$from')");
mysql_query("update cf_salary_adv set `paidamt`=`paidamt`+$amount where sal_adv_id = '$sal_advid'");
header("location:salary_advance_list.php");
}
			
			
if(isset($_REQUEST['savereciept']))
{
if(isset($_REQUEST['bankcheck']) && $_REQUEST['bankcheck']!='')
{
		$bankcheck=2;
		$to=$_REQUEST['received_from'];
		$transactionbank=$_POST['transactionbank'];
		if($_REQUEST['transactiontype']=='cheque')
		{
		$cheque_no=$_REQUEST['cheque_no'];
		$cheque_date=date('Y-m-d',strtotime($_REQUEST['cheque_date']));
		$bankname=$_REQUEST['bankname'];
		$branchname=$_REQUEST['branchname'];
		$referenceno='';
		}
		else
		{
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno=$_REQUEST['referenceno'];
		}
}
else
{
		$to=195;
		$transactionbank=0;
		$bankcheck=1;
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno='';
}


	$chk_payment=$_POST['chk_payment'];


if($chk_payment==1){
	$from=$_POST['vendor_ledger'];
}else{
	$from=$_POST['received_to'];
}



$pay_date=date('Y-m-d',strtotime($_POST['pay_date']));
$add_date=date("Y-m-d H:i:s");
$amount=$_POST['received_cash'];
$sum_in_letters=$_POST['sum_in_letters'];
$purpose=$_POST['purpose'];

$chk_payment=$_POST['chk_payment'];
if($chk_payment==1){
	/* $sq_accpayable=mysql_query("select * from cf_acountspayable where ledgerid = '$from'");
 $result_accpayable=mysql_fetch_array($sq_accpayable);
 $pay_id = $result_accpayable['pay_id'];
 if($pay_id>0){
 	
 }*/
 
mysql_query("update cf_acountspayable set `pendingamount`=`pendingamount`+$amount where ledgerid= '$from'"); 
}else{
	$sql=mysql_query("insert into cf_reciept (`from`,`to`,`amount`,`purpose`,`pay_date`,`add_date`,`cashed`,`cheque_no`,`cheque_date`,`bankname`,`branchname`,`neft_reference_no`,`sum_in_words`,`transaction_bank`,`type_status`,`ledgr_rec_ids`) values ('$from','$to','$amount','$purpose','$pay_date','$add_date','$bankcheck','$cheque_no','$cheque_date','$bankname','$branchname','$referenceno','$sum_in_letters','$transactionbank','1','$from')");

}





header("location:reciept-list.php");
}


if(isset($_REQUEST['advt']))
{
/*$tripid = $_REQUEST['tripid'];

 $sq_drvadt=mysql_query("select * from cf_tripsheet where trip_id = '$tripid'");
 $resdrv=mysql_fetch_array($sq_drvadt);
 $advance_amt = $resdrv['advance_amt'];
 $cashmemo = $resdrv['cash_memo'];
 
 echo $chekpaidamt = $advance_amt-$cashmemo;
 echo "<br/>";
 echo $amt_advtpaid = $resdrv['amt_advt_paid'];
 echo "<br/>";
 echo $paidamt = $chekpaidamt-$amt_advtpaid;
 
 
 mysql_query("update cf_tripsheet set `amt_advt_paid`=`amt_advt_paid`+$amount");*/
 
 
} 

if(isset($_REQUEST['saveaccreciept']))
{
if(isset($_REQUEST['bankcheck']) && $_REQUEST['bankcheck']!='')
{
		$bankcheck=2;
		$to=$_REQUEST['received_from'];
		$transactionbank=$_POST['transactionbank'];
		if($_REQUEST['transactiontype']=='cheque')
		{
		$cheque_no=$_REQUEST['cheque_no'];
		$cheque_date=date('Y-m-d',strtotime($_REQUEST['cheque_date']));
		$bankname=$_REQUEST['bankname'];
		$branchname=$_REQUEST['branchname'];
		$referenceno='';
		}
		else
		{
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno=$_REQUEST['referenceno'];
		}
}
else
{
		$to=195;
		$transactionbank=0;
		$bankcheck=1;
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno='';
}
$from=$_POST['received_to'];

$pay_date=date('Y-m-d',strtotime($_POST['pay_date']));
$add_date=date("Y-m-d H:i:s");
$amount=$_POST['received_cash'];
$sum_in_letters=$_POST['sum_in_letters'];
$purpose=$_POST['purpose'];



$hiddenrcpttype=$_POST['hiddenrcpttype'];
if($hiddenrcpttype=='accrcvble')//---------Driver Advance -------
{
	$typestatus = '2';
	
	$driv_advid=$_POST['driv_advid'];
	$sql=mysql_query("insert into cf_reciept (`from`,`to`,`amount`,`purpose`,`pay_date`,`add_date`,`cashed`,`cheque_no`,`cheque_date`,`bankname`,`branchname`,`neft_reference_no`,`sum_in_words`,`transaction_bank`,`type_status`,`sal_advid`,`ledgr_rec_ids`) values ('$from','$to','$amount','$purpose','$pay_date','$add_date','$bankcheck','$cheque_no','$cheque_date','$bankname','$branchname','$referenceno','$sum_in_letters','$transactionbank','$typestatus','$driv_advid','$from')");
	
}
else if($hiddenrcpttype=='accopbal')//------Account Receivable-------
{
	$typestatus = '4';
	
	$sql=mysql_query("insert into cf_reciept (`from`,`to`,`amount`,`purpose`,`pay_date`,`add_date`,`cashed`,`cheque_no`,`cheque_date`,`bankname`,`branchname`,`neft_reference_no`,`sum_in_words`,`transaction_bank`,`type_status`,`ledgr_rec_ids`) values ('$from','$to','$amount','$purpose','$pay_date','$add_date','$bankcheck','$cheque_no','$cheque_date','$bankname','$branchname','$referenceno','$sum_in_letters','$transactionbank','$typestatus','$from')");
	
}


$lastid = mysql_insert_id();


 $tripid = $_REQUEST['tripid'];

 $sq_drvadt=mysql_query("select * from cf_tripsheet where trip_id = '$tripid'");
 $resdrv=mysql_fetch_array($sq_drvadt);
 $advance_amt = $resdrv['advance_amt'];
 $cashmemo = $resdrv['cash_memo'];
 
 $chekpaidamt = $advance_amt-$cashmemo;
 $amt_advtpaid = $resdrv['amt_advt_paid'];
 $paidamt = $chekpaidamt-$amt_advtpaid;

  $drvtype = $_REQUEST['drvtype'];
  if($drvtype == 1){
  mysql_query("update cf_tripsheet set `amt_advt_paid`=`amt_advt_paid`+$amount where  trip_id = '$tripid'");
  }else if($drvtype == 2){
  mysql_query("update cf_driver_adv  set `amt_advt_paid`=`amt_advt_paid`+$amount where  driv_adv_id = '$tripid'");
  }
  
$hiddenclient=$_POST['hiddenclient'];
$hiddenaccid=$_POST['hiddenaccid'];

if($hiddenrcpttype=='accopbal')
{
mysql_query("update  cf_accountsreceivable set `receiveamount`=`receiveamount`-$amount where ledgerid=$hiddenaccid");  // nithya
}
else
{
mysql_query("update cf_sales set sales_receivable=sales_receivable-$amount where sales_id='$hiddenaccid'");
}

header("location:accounts-receivable.php");

}



if(isset($_POST['updatereciept']))
{


$editid=$_REQUEST['editreciept'];

if(isset($_REQUEST['bankcheck']) && $_REQUEST['bankcheck']!='')
{
		$bankcheck=2;
		$transactionbank=$_POST['transactionbank'];
		$to=$_REQUEST['received_from'];
		if($_REQUEST['transactiontype']=='cheque')
		{
		$cheque_no=$_REQUEST['cheque_no'];
		$cheque_date=date('Y-m-d',strtotime($_REQUEST['cheque_date']));
		$bankname=$_REQUEST['bankname'];
		$branchname=$_REQUEST['branchname'];
		$referenceno='';
		}
		else
		{
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno=$_REQUEST['referenceno'];
		}
}
else
{
		$to=195;
		$transactionbank=0;	
		$bankcheck=1;
		$cheque_no='';
		$cheque_date='';
		$bankname='';
		$branchname='';
		$referenceno='';
}
$from=$_POST['received_to'];

$pay_date=date('Y-m-d',strtotime($_POST['pay_date']));
$add_date=date("Y-m-d H:i:s");
$amount=$_POST['received_cash'];
$oldreceiptamount=$_POST['oldreceived_cash'];
$sum_in_letters=$_POST['sum_in_letters'];
$purpose=$_POST['purpose'];

$sql=mysql_query("update cf_reciept set `from`='$from',`to`='$to',`amount`='$amount',`purpose`='$purpose',`pay_date`='$pay_date',`add_date`='$add_date',`cashed`='$bankcheck',`cheque_no`='$cheque_no',`cheque_date`='$cheque_date',`bankname`='$bankname',`branchname`='$branchname',`neft_reference_no`='$referenceno',`sum_in_words`='$sum_in_letters',`transaction_bank`='$transactionbank' where reciept_id='$editid'");


/// nithya
mysql_query("update  cf_accountsreceivable set `receiveamount`=`receiveamount`+$oldreceiptamount where ledgerid=$to"); 
mysql_query("update  cf_accountsreceivable set `receiveamount`=`receiveamount`-$amount where ledgerid=$to");  

header("location:reciept-list.php");

}
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OIL FILL</title>
<link href="css/styles.css" rel="stylesheet"  />

<link href="css/menu.css" rel="stylesheet" type="text/css" />
<style>
.newcategoryProfile{ background:#FFFFFF; position:absolute; width:400px; height:250px; z-index:5;
					-webkit-box-shadow: 0px 0px 35px 1px rgba(0,0,0,0.75);
					-moz-box-shadow: 0px 0px 35px 1px rgba(0,0,0,0.75);
					box-shadow: 0px 0px 35px 1px rgba(0,0,0,0.75);}


</style>
<link type="text/css" href="css_date/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/trippopup.js" type="text/javascript"></script>
<!----------------------------css for auto complete-------------------------------->
<link rel="stylesheet" href="css/chosen.css">

<!--end-->

<script type='text/javascript' src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />

<script type="text/javascript" src="scripts_date/jquery-calendar-1.7.2.js"></script>
<script language="javascript">

$(document).ready(function(){
$('#pay_date').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});

$(document).ready(function(){
$('#add_date').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});

$(document).ready(function(){
$('#cheque_date').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});

function test_skill(junkVal) {

   // var junkVal=document.getElementById('rupees').value;
    //junkVal=Math.floor(junkVal);
    var obStr=new String(junkVal);
    numReversed=obStr.split("");
    actnumber=numReversed.reverse();

    if(Number(junkVal) >=0){
        //do nothing
    }
    else{
        alert('wrong Number cannot be converted');
        return false;
    }
    if(Number(junkVal)==0){
        document.getElementById('sum_in_letters').value=obStr+''+'Rupees Zero Only';
        return false;
    }
    if(actnumber.length>9){
        alert('Oops!!!! the Number is too big to covertes');
        return false;
    }

    var iWords=["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
    var ePlace=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'];
    var tensPlace=['dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];

    var iWordsLength=numReversed.length;
    var totalWords="";
    var inWords=new Array();
    var finalWord="";
    j=0;
    for(i=0; i<iWordsLength; i++){
        switch(i)
        {
        case 0:
            if(actnumber[i]==0 || actnumber[i+1]==1 ) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j];
            break;
        case 1:
            tens_complication();
            break;
        case 2:
            if(actnumber[i]==0) {
                inWords[j]='';
            }
            else if(actnumber[i-1]!=0 && actnumber[i-2]!=0) {
                inWords[j]=iWords[actnumber[i]]+' Hundred and';
            }
            else {
                inWords[j]=iWords[actnumber[i]]+' Hundred';
            }
            break;
        case 3:
            if(actnumber[i]==0 || actnumber[i+1]==1) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            if(actnumber[i+1] != 0 || actnumber[i] > 0){
                inWords[j]=inWords[j]+" Thousand";
            }
            break;
        case 4:
            tens_complication();
            break;
        case 5:
            if(actnumber[i]==0 || actnumber[i+1]==1 ) {
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j]+" Lakh";
            break;
        case 6:
            tens_complication();
            break;
        case 7:
            if(actnumber[i]==0 || actnumber[i+1]==1 ){
                inWords[j]='';
            }
            else {
                inWords[j]=iWords[actnumber[i]];
            }
            inWords[j]=inWords[j]+" Crore";
            break;
        case 8:
            tens_complication();
            break;
        default:
            break;
        }
        j++;
    }

    function tens_complication() {
        if(actnumber[i]==0) {
            inWords[j]='';
        }
        else if(actnumber[i]==1) {
            inWords[j]=ePlace[actnumber[i-1]];
        }
        else {
            inWords[j]=tensPlace[actnumber[i]];
        }
    }
    inWords.reverse();
    for(i=0; i<inWords.length; i++) {
        finalWord+=inWords[i];
    }
        return finalWord;
    //document.getElementById('container').innerHTML=obStr+'  '+;
       
}
 
    //document.getElementById('container').innerHTML=finalWord;
 function paisa_conver(junkVal){

   junkVal = junkVal.split('.')[0];
 
        var finalWord1 = test_skill(junkVal);
		
    console.log(finalWord1);
    
            var finalWord2;
    var val = document.getElementById('received_cash').value;
 var enteredvalue = document.getElementById('received_cash').value;

        if(val.indexOf('.')!=-1)
    {
          val = val.substring(val.indexOf('.')+1,val.length);
            if(val.length==0){
              finalWord2 = "Rupees Only.";
           }else{
            //   document.getElementById('rupees').value = val;
   paisa = enteredvalue.split('.')[1];
   //console.log(paisa);
   if(paisa){
   
             finalWord2 = "Rupees and"+test_skill(paisa) + " paisa only";
      }else{
    finalWord2 = "Rupees Only.";
   }
    // 
           }
     
    } else{
          finalWord2 = "Rupees Only.";
    }
	
    document.getElementById('sum_in_letters').value=finalWord1 +" "+finalWord2;
 
 
 
 
}

function changeview()
{
if($('#bankcheck').is(':checked')){
$(".fromacc").css("display", "block");
}
else
{
$(".fromacc").css("display", "none");
}
}
function checktranstype(type)
{
if(type=='cheque')
{
$(".chequedetails").css("display", "block");
$(".neftdetails").css("display", "none");
}
if(type=='neft')
{
$(".neftdetails").css("display", "block");
$(".chequedetails").css("display", "none");
}

}


$(document).ready(function(){
		document.getElementById('vendorDiv').style.display="none";

var received_cash=document.getElementById('received_cash').value;

if(received_cash!='' && received_cash!='undefined' && received_cash!=0)
{
paisa_conver(received_cash);

}

});

function getPayment()
{	
	var lfckv = document.getElementById("chk_payment").checked;
          
	if(lfckv==true){
		document.getElementById('vendorDiv').style.display="block";
		document.getElementById('ledgerDiv').style.display="none";
	}else{
		document.getElementById('vendorDiv').style.display="none";
		document.getElementById('ledgerDiv').style.display="block";
	}
	
}

/*function getVndr(val)
{
	alert(val);
}*/
</script>
</head>

<body>
<!------------------popup area (view, edit)--------------->



<!---------------popup area ends------------------>
<div class="viewEmployeePopup login-popup"  id="login-box" style="height: 220px;width:500px;
overflow-x: scroll;">
    <a href="#" class="close">
    <img src="" class="btn_close" title="Close Window" alt="Close" />
    </a>
    <div id="view_emp"></div>
</div>
<div class="wrapper">
  <div>
<?php 
	include("header.php");
?>
 
</div>
 
 <div class="tabbedArea">
   

   
   <div id="popup" align="center"  style="margin-left: 400px;"></div>
   
   <div class="tabBody">
    <h1 align="" style="margin-left:80px">Add Cash Reciept</h1>
<form action="" name="voucherfrm" id="voucherfrm" method="post" accept-charset="utf-8">
<div style="display:none;"></div>		
			
			<table  border="0" cellspacing="0" cellpadding="0" style="width:90%;" >
			
			<?php
			if(isset($_GET['edit']) && $_GET['edit']=='update')
			{
			
			$editid = $_GET['id'];
			$array=mysql_query("select * from cf_reciept where reciept_id='$editid'");
			if($array && mysql_num_rows($array)>0){
			
			while($res=mysql_fetch_array($array))
			{
			
			
			$from=$res['from'];
			$to=$res['to'];
			$amount=$res['amount'];
			$pay_date=date('d-m-Y',strtotime($res['pay_date']));
			$cashed=$res['cashed'];
			$cheque_no=$res['cheque_no'];
			$cheque_date=$res['cheque_date'];
			$bankname=$res['bankname'];
			$branchname=$res['branchname'];
			$neft_reference_no=$res['neft_reference_no'];
			$purpose=$res['purpose'];
			$sum_in_letters=$res['sum_in_words'];
			$transactionbank=$res['transaction_bank'];

			}
			}
			}
			?>
				<tr>
    <td width="200" align="center" valign="middle"></td>
    <td width="600" align="center" valign="middle" style="border:#333333 0px solid;">
		<table width="97%" border="0" cellspacing="0" cellpadding="0" class="tableListrec" style="margin-top:0px;">
               <tr>
        <td colspan="2" style="padding-left:0px;">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:0px;">
		
		<?php
		
					$tin_sql=mysql_query("select max(reciept_id) as max_id from cf_reciept");
				  if($tin_sql && mysql_num_rows($tin_sql)>0)
				  {
				  while($tin_row=mysql_fetch_array($tin_sql))
				  {
				  $max_id=$tin_row['max_id']+1;
				  }
				  }
				  else
				  {
				  $max_id=1;
				  }
		
		?>
  <tr><td style="border:0px;"><b>No : </b>CSH RCPT <?=$max_id?>(CASH RECIEPT) <input type="hidden" name="editreciept" id="editreciept" value="<?=$editid?>" /></td>
    <td style="border:0px;"><b>Pay Date : </b>
		<input type="text" name="pay_date" id="pay_date"  class="slabinput input1" style="width:70px;" value="<?=$pay_date?>" required="required"/></td>
    <td style="border:0px;"><b>Add Date : </b>
		<input type="text" name="add_date" id="add_date"  class="slabinput input1" style="width:70px;" value="<?=$pay_date?>" required="required" /></td>
  </tr>
</table>
         </td>
      </tr>
      <tr>
        <td style="border:0px;" valign="top" colspan="2">
	
			          
                    
		</td>					
      </tr>
	  <!-- <tr>
        <td colspan="2" align="left">&nbsp;</td>
      </tr> -->
      <tr>
        <td height="30" align="left" colspan="2">
        <div class="ui-widget">
        <label>Acc Payable : </label><input type="checkbox" value="1" id="chk_payment" name="chk_payment" onChange="getPayment();"/>
		<div id="ledgerDiv">
<label >Ledgername : </label>	
<?php 
	//echo 	$clientid=$_GET['clientid'];
	//echo $sq_tripno="select * from cf_ledger where groupid = 8 and empid='$clientid' and ledgerid != '195'";
?>
       <select class="chzn-select restselect input45 received_to" name="received_to" >
     
       <?php
	   
	    if(isset($_GET['amt']) && $_GET['amt']!='')
	   {
        $amount=$_GET['amt'];
	    }
		
	   if(isset($_GET['reciepttype']) && ($_GET['reciepttype']=='accrcvble' || $_GET['reciepttype']=='accopbal' || $_GET['reciepttype']=='salaryadvt'))
	   {
	   	$clientid=$_GET['clientid'];
		
		if($_GET['advt'] == 'adv')
			{
         		$sq_tripno="select * from cf_ledger where groupid = 23 and empid='$clientid' and ledgerid != '195'";
			}
			else if($_GET['salreturn'] == 'returnsal')
			{
				$sq_tripno="select * from cf_ledger where ledgerid = 73";
			}
			else
			{
				$sq_tripno="select * from cf_ledger where ledgertype='clientledger' and empid='$clientid' and ledgerid != '195'";
			}	
		
	    }
		else
		{		
		?>
		<option value="">Select Ledger</option>
		<?php
		 $sq_tripno="select * from cf_ledger where ledgerid != '195'";
		}
   $arrtripno1=mysql_query($sq_tripno);
   while($restripno=mysql_fetch_array($arrtripno1))
   {
  ?>
   <option  <?php if($restripno['ledgerid']==$to) { ?> selected="selected" <?php } ?> value="<?=$restripno['ledgerid']?>" ><?=$restripno['ledgername']?></option>
        <?php
    }
  ?>
     </select>
 
</div>	
<br/>
<div id="vendorDiv">
<label >Ledgernamessss : </label>	
<select  class="chzn-select restselect input45 vendor_ledger" name="vendor_ledger"  id="vendor_ledger" >
                      <option value="">Select Vendor </option>
                      <?php 
                        $sq_arr="SELECT * FROM `cf_ledger` inner join cf_reseller on empid=cf_reseller.reseller_id where ledgertype='vendorledger' and ledgerid != '195'";
                        $array=mysql_query($sq_arr);
                        while($res=mysql_fetch_array($array))
                        {
                        ?>
                      <option value="<?=$res['ledgerid']?>" >
                        <?=$res['ledgername']?>
                      </option>
                      <?php
                        }
                 		?>
                    </select>
</div>	
				
	</div>	 
		<span class="" style="float:right;">Bank  <input type="checkbox" name="bankcheck" id="bankcheck" <?php if($cashed==2) {?> checked="checked" <?php } ?> value="1" onClick="changeview()" ></span></td>
		
      </tr>
     
	 <tr>
        <td height="30" colspan="2" align="left">
		<?php if($cashed==1 || $cashed=='') {?>
		<span class="fromacc" style="display:none;">
		<?php } 
		elseif($cashed==2 )
		{
		?> <span class="fromacc" style="display:block;">
		<?php } ?>
		<div class="ui-widget"><label for="ledgerreceived">Bank A/c : </label>
		  <table width="500" border="1">
  <tr><td><!--<select  name="received_from" class="input1" >
     <option value="">Select Ledger</option>
       <?php 
         $sq_tripno="select * from cf_ledger where groupid=12 and ledgerid != '195'";
   $arrtripno1=mysql_query($sq_tripno);
   while($restripno=mysql_fetch_array($arrtripno1))
   {
  ?>
   <option  <?php if($restripno['ledgerid']==$to) { ?> selected="selected" <?php } ?>  value="<?=$restripno['ledgerid']?>" ><?=$restripno['ledgername']?></option>
        <?php
    }
  ?>
     </select>--></td>
	 
	 <td><select  name="transactionbank" class="input1" >
     <option value="">Select Bank</option>
       <?php 
         $sq_bankno="select * from cf_bank ";
   $arrbankno1=mysql_query($sq_bankno);
   while($resbankno=mysql_fetch_array($arrbankno1))
   {
  ?>
   <option  <?php if($resbankno['bank_id']==$transactionbank) { ?> selected="selected" <?php } ?>  value="<?=$resbankno['bank_id']?>" ><?=$resbankno['bankname']?></option>
        <?php
    }
  ?>
     </select></td>
	 
	 <td>
	 
	 <input type="radio" name="transactiontype" <?php if($cheque_no!=0) { ?> checked="checked" <?php } ?> value="cheque" class="transactiontype" onClick="checktranstype('cheque')">Cheque
<input type="radio" name="transactiontype" <?php if($neft_reference_no!=0) { ?> checked="checked" <?php } ?> value="neft" class="transactiontype" onClick="checktranstype('neft')">NEFT</td></tr></table> </div>

<?php if($cheque_no!=0) {?>
		 <div class="chequedetails" style="display:block;">
		<?php } 
		else
		{
		?> <div class="chequedetails" style="display:none;">
		<?php } ?>
	
	 <table width="200" border="1">
  <tr>
    <td>Cheque No:</td>
    <td><input type="text" name="cheque_no" id="cheque_no" value="<?=$cheque_no?>" class="input1" ></td>
  </tr>
  <tr>
    <td>Cheque Date</td>
    <td><input type="text" name="cheque_date" id="cheque_date" value="<?=date('d-m-Y',strtotime($cheque_date))?>" class="input1" ></td>
  </tr>
  <tr>
    <td>Bank Name</td>
    <td><input type="text" name="bankname" id="bankname" value="<?=$bankname?>" class="input1" ></td>
  </tr>
    <tr>
    <td>Branch Name</td>
    <td><input type="text" name="branchname" id="branchname" value="<?=$branchname?>" class="input1" ></td>
  </tr>
</table>
		</div>
		<?php if($neft_reference_no!=0) {?>
		 <div class="neftdetails" style="display:block;">
		<?php } 
		else
		{
		?> <div class="neftdetails" style="display:none;">
		<?php } ?>
		
	 <table width="200" border="1">
  <tr>
    <td>Reference No:</td>
    <td><input type="text" name="referenceno" id="referenceno" value="<?=$neft_reference_no?>" class="input1" ></td>
  </tr>
 
</table>
		</div>
		</span>
	 </td> 
      </tr>
	  
	     
      
      <tr>
        <td height="30" align="left"><h4>Sum of Rs (in words) : <br />
		 #
		 <input name="sum_in_letters" class="slabinput" id="sum_in_letters" style="width:348px; " onKeyUp="PleaseConvert()" readonly="readonly" value="<?=$sum_in_letters?>" type="text"/>		  </h4></td>
        <td rowspan="2" align="" style="border:#cccccc 1px solid; vertical-align:middle"><h4>Amount : </h4>
		
		<input name="oldreceived_cash" class="slabinput input1" id="oldreceived_cash" value="<?=$amount?>" style="width:150px;"   type="hidden" />

		<input name="received_cash" class="slabinput input1" id="received_cash" value="<?=$amount?>" style="width:150px;"  onKeyUp="paisa_conver(this.value)" type="text" required="required"/>
		
				</td>
      </tr>
      <tr>
        <td height="30" align="left"><h4>For : </h4>
		<?php  if(isset($_GET['reciepttype'])=='salaryadvt'){ 
		$eid = $_GET['empid'];
		$sq_emp=mysql_query("select * from cf_employee where e_id = '$eid'");
		$resemp=mysql_fetch_array($sq_emp);
		$pur = $resemp['e_fname'].' ADV RETURN';
		?>
		<textarea name="purpose" class="slabinput input1" id="purpose" style="height:50px; width: 350px;" cols="30" rows="6" ><?=$pur?></textarea>
		<?php }else
		{?>	
		<textarea name="purpose" class="slabinput input1" id="purpose" style="height:50px; width: 350px;" cols="30" rows="6"><?=$purpose?></textarea>
		<?php } ?>
			</td>
        </tr>

	  <tr>
        <td align="left">&nbsp;</td>
        <td align="left">		
		<b>Sign : </b>
		  admin admin </td>
      </tr>
     <!-- <tr>
        <td colspan="2" align="left">&nbsp;</td>
      </tr> -->
    </table>
	
	</td>
    <td width="52" align="center" valign="middle" style="padding-left:80px;"><br />
      <br />
    <div class="submit">
	<?php if($editid !='' )
	{ ?>
	
	<input type="submit" name="updatereciept" alt="Update" class="input1" value="Update"/></div>
	<?php }
	 else
	{
	if(isset($_GET['reciepttype']) && $_GET['reciepttype']=='accrcvble')
	   {
	       $accid='';
		   if(!empty($_GET['accid']))
		   {
				$accid=$_GET['accid']; 		
		   }
	
		
	   ?>
	    <input type="text" name="driv_advid" id="driv_advid" value="<?=$_GET['tripid']?>"/>
	    <input type="text" name="hiddenclient" id="hiddenclient" value="<?=$clientid?>"/>
	    <input type="text" name="hiddenaccid" id="hiddenaccid" value="<?=$accid?>"/>
		<input type="text" name="hiddenrcpttype" id="hiddenrcpttype" value="<?=$_GET['reciepttype']?>"/>
		 
	<input  name="saveaccreciept" alt="Save" class="input1" type="submit" value="Save11"/>
<?php 	}
	elseif(isset($_GET['reciepttype']) && $_GET['reciepttype']=='accopbal')
	   {
	   	   $accid='';
		   if(!empty($_GET['accid']))
		   {
				$accid=$_GET['accid']; 		
		   }
	   ?>
	  
	   <input type="hidden" name="hiddenclient" id="hiddenclient" value="<?=$clientid?>"/>
	     <input type="hidden" name="hiddenaccid" id="hiddenaccid" value="<?=$accid?>"/>
		 <input type="hidden" name="hiddenrcpttype" id="hiddenrcpttype" value="<?=$_GET['reciepttype']?>"/>
	<input  name="saveaccreciept" alt="Save" class="input1" type="submit" value="Save22"/>
<?php 	}
elseif(isset($_GET['reciepttype']) && $_GET['reciepttype']=='salaryadvt')
	   {
	   	   $accid='';
		   if(!empty($_GET['accid']))
		   {
				$accid=$_GET['accid']; 		
		   }
	   ?>
	   <input type="hidden" name="hiddenclient" id="hiddenclient" value="<?=$clientid?>"/>
	     <input type="hidden" name="hiddenaccid" id="hiddenaccid" value="<?=$accid?>"/>
		 <input type="hidden" name="hiddenrcpttype" id="hiddenrcpttype" value="<?=$_GET['reciepttype']?>"/>
	<input  name="savesalaryreturnreciept" alt="Save" class="input1" type="submit" value="Save"/>
<?php 	}
else
{
 ?>	
 <input  name="savereciept" alt="Save" class="input1" type="submit" value="Save"/>

<?php
}
 	}?>	   <br />
	  <input type="hidden" name="save" />
      <br />
	
	
    </td>
    <td width="148" align="left" valign="middle">&nbsp;</td>
  </tr>	
			
  
 </table>	

	
	<div id="list">
   

  </div>

 </div>
 <div class="footer"><p>Powered by <a href="http://www.aadhocc.co.uk/" target="_blank">Aadhocc</a></p></div>
 
</div>
<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>
	</form>		
</body>
<!----------------------- script for autocomplete------------------------------>
		<script src="js/chosen.jquery.min.js" type="text/javascript">
		</script>
		<script type="text/javascript"> 
			$(".chzn-select").chosen({search_contains: true}); 
		</script>

<!----------------end of script -------------------------------->

</html>
