<style type="text/css">
    .btn-group button {
        height:30px;}

    .amount{
        text-align: right;
    }

    .quantity {
        text-align: center;
    }
    #content .wrap #grid_content_1 .row-fluid.scRow .row-fluid.scRow .span12.scCol #grid_block_5 .content.np #listDetails tbody #trInfos td .row-fluid .controls-row .span3 {
        font-size: 11px;
        color: #000;
        font-weight: bold;
    }
    .test {
        font-size: 10px;
    }

    tbody {
        font-size: 10px;
    }
    #content .wrap #grid_content_1 .row-fluid.scRow .row-fluid.scRow .span12.scCol #grid_block_6 .content.np #listCharge tbody #trInfos td .row-fluid .controls-row .span3 {
        font-weight: bold;
    }
</style>
<script type="application/javascript">
     window.onbeforeunload = function (e) {
        if (accounting.unformat( $('#outofbalance').val() ) !== 0 ){
  var message = "The out of balance is different of zero, Confirm leave ",
  e = e || window.event;
  // For IE and Firefox
  if (e) {
    e.returnValue = message;
  }

  // For Safari
  return message;
        }
};
$(document).ready(function(){
});

//Tell the validator not to ignore hidden items
//var validator = $('#paymentDetail').validate({ignore: null});
//Tell the validator to only ignore inputs of type 'hidden'
//var validator = $('#paymentDetail').validate({ignore: 'input[type=hidden]'});

 
$( document ).ready(function() {
        $('select').select2();
        jQuery('.datepicker2').datepicker({
                        dateFormat : 'dd-mm-yy',
                        changeMonth : true,
                        changeYear : true
                        });
        $.each($(".select2-container"), function (i, n) {
            $(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
            $(n).prepend($(n).next());
            $(n).delay(500).queue(function () {
                $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
                $(this).dequeue();
            });
        });	
                                  $("#amountpaid").dblclick(function() {
                                          $(this).val($("#totalpaid").val());
                                  });
                          });

			   
				
				
                                function getItemCode(me){
                                        $.ajax({
                                                type: "POST",
                                                data: "itemCode="+$(me).val(),
                                                url: "<?php echo base_url() ?>purchasetransaction/getItemCodes",
                                                success: function(data) {
                                                   $("#itemcode").attr("data-source", data);
                                                }
                                         });
                                }
				
			
                                function refreshProject(){
                                        $.ajax({
                                                type: "POST",
                                                url: "<?php echo base_url() ?>purchasetransaction/refreshProject",
                                                success: function(data) {
						
                                                   var resul = eval ("(" + data + ")"); 
                               var n=resul.records.length;
                               var i=0;
                               var opt='' +
                                                '<option></option>';
                                for (i=0;i<n;i++)
                                        opt=opt + '<option value="' + resul.records[i].id +'">' + resul.records[i].projectName + '</option>';
                                                        $('#project').empty();
                                $('#project').append(opt);
                                                }
                                         });
                                }
				
			
			
                                function getTermDescription(me){
                                        $.ajax({
                                                type: "POST",
                                                data: "term="+ me.value,
                                                url: "<?php echo base_url() ?>purchasetransaction/getTermDescription",
                                                success: function(data) {
                                                        $('#termDescription').html(data);
                                                }
                                         });
                                }
				
  function displaybanksInfos() {
    $("#acctNo").val($("#bank option:selected").attr("data-bankAccountNo"));
   // $("#balance").val($("#bank option:selected").attr("data-currentBalance"));
  }
				
                                
function saveReceive(me){

    if ($("#itemcode").attr("itemID")=="")
            $("#itemname").val("");
     if( $("#paymentDetail").validationEngine('validate') && finanEngine('financhk')){
            if ( $("#paymentId").val()=="null"){
                $(me).attr("disabled","disabled");
                    getTotal();
                    $.ajax({
                    type: "POST",
                    data: {
                                    memo : $("#memo").val(),
                                    receiveFrom : $("#receiveFrom").val(),
                                   // locationID : $("#location").val(), 
                                    paymentMethodID : $("#paymentmethood").val(), 
                                    totalReceived : accounting.unformat($("#amountpaid").val()), 
                                    formNo :  $("#formNo").val(),
                                    paymentDate : $("#createdDate").val(),
                                    referenceNo: $("#refno").val(),
                                    bankID : $("#bank").val(),
                                    projectID : $("#project").val(),
                                    
                                    exchangeRate : $("#exchangeRate").val(),
                                    
                                    lineNo : $("#paymentDetails").attr("data-currentRow")*1+1,
                                    amountIncludedTax : accounting.unformat($("#amountIT").val()),
                                    accountID : $("#accountID").val(),
                                    description: $("#itemDesc").val(),
                                    amountExcludedTax: accounting.unformat($("#amountExcludedTax").val()),
                                    taxAmount : accounting.unformat($("#taxAmount").val()),
                                    taxID: $("#itemTax").attr("data-taxid"),
                                    taxRate: $("#itemTax").val()

                            },
                     url: "<?php echo base_url() ?>gltransaction/savenewotherreveive",
                     success: function(data) {
                     var resul = eval ("(" + data + ")"); 
                      $("#paymentId").val(resul.paymentID);
                      $("#paymentDetails").attr("data-currentRow", $("#paymentDetails").attr("data-currentRow")*1+1);
                      $(''+
                       '<tr><td>' +  $("#paymentDetails").attr("data-currentRow") +'</td>'+
                              '<td>' +  $("#accountID option:selected").text() + '</td>'+
                              '<td>' + $("#itemDesc").val() + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#amountExcludedTax").val(),2) + '</td>'+
                              '<td>' + $("#itemTax").val() + ' | ' + $("#displayTaxCode").text()  + '</td>'+                              
                              '<td class="tar"></td>'+
                              '<td class="amount">' + accounting.formatNumber($("#taxAmount").val(),2) + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#amountIT").val(),2) + '</td>'+
                              '<td>' +
                              '</td>'+
                        '</tr>'
                            ).insertBefore( "#trInfos" );
                            $("#btnCancel").trigger("click");
                            getTotal();
                    msg ("alert alert-success","Details successfully saved");
                    } //end function
             });//end ajax
            }else{ //savedetailonly
                $(me).attr("disabled","disabled");
                    $.ajax({
                    type: "POST",
                    data: {
                              otherPaymentID : $("#paymentId").val(),
                                    
                                    lineNo : $("#paymentDetails").attr("data-currentRow")*1+1,
                                    
                                    accountID : $("#accountID").val(),
                                    description: $("#itemDesc").val(),
                                    amountExcludedTax: accounting.unformat($("#amountExcludedTax").val()),
                                    amountIncludedTax : accounting.unformat($("#amountIT").val()),
                                    taxAmount : accounting.unformat($("#taxAmount").val()),
                                     taxID: $("#itemTax").attr("data-taxid"),
                                    taxRate: $("#itemTax").val()

                            },
                    url: "<?php echo base_url() ?>gltransaction/saveotherReceiveDetailOnly",
                    success: function(data) {
                     msg ("alert alert-success","Details successfully saved");
                      var resul = eval ("(" + data + ")"); 
                      $("#paymentDetails").attr("data-currentRow", $("#paymentDetails").attr("data-currentRow")*1+1);
                    $(''+
                        '<tr><td>' +  $("#paymentDetails").attr("data-currentRow") +'</td>'+
                              '<td>' +  $("#accountID option:selected").text() + '</td>'+
                              '<td>' + $("#itemDesc").val() + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#amountExcludedTax").val(),2) + '</td>'+
                              '<td class="tac">' + $("#itemTax").val() + ' | ' + $("#displayTaxCode").text() + '</td>'+                              
                              '<td class="tar"></td>'+
                              '<td class="amount">' + accounting.formatNumber($("#taxAmount").val(),2) + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#amountIT").val(),2) + '</td>'+
                              '<td>' +
                              '</td>'+
                    '</tr>'
                ).insertBefore( "#trInfos" );
                    $("#btnCancel").trigger("click");
                    getTotal();
                    msg ("alert alert-success","Details successfully saved");
               }
             }); //end ajax
            } //end if data valide
            }else {
                    msg ("alert alert-error", "Data incorrect or invalid ...");
            }
    }





function addRow(){
    n = $("#paymentDetails").attr("data-currentRow")*1 + 1;
    if (!$("#accountID").length) {
             $(''+
             '<tr><td class="span1">' + n +'</td>'+
                            '<td class="span2"> <select name="accountID" id="accountID" class="span12 validate[required]"><option></option>' +
<?php
if ($chargeAccount) {
    foreach ($chargeAccount as $row) {
        ?>
                '<option value="<?php echo $row->ID; ?>"><?php echo substr($row->acctCode, 0, 4) . '-' . substr($row->acctCode, 4, 3) . '-' . substr($row->acctCode, 7) . " | ";
        echo str_replace(array("\n", "\r", "'"), " ", $row->acctName, $count);
        ?></option>'+
    <?php }
}
?>
                             '</select></td>'+
                    '<td class="span4"><input  id="itemDesc" name="itemDesc"  type="text" class="span12 validate[required]" placeholder="Description"></td>'+
                    '<td class="span1"><input id="amountExcludedTax" onblur="modAmount()" onfocus="modAmount()" name="amountExcludedTax" class="span12 validate[required, custom[number]] amount" type="text" placeholder="Amount"></td>'+
                                        //add by fadhirul hilmi; Date: 08/10/2014
                    '<td class="span1"><div  class="input-prepend"><input data-taxid="" id="itemTax" disabled="disabled" onkeyup="calculAmount()" name="itemTax" class="span6 validate[required, custom[number]]" type="text" placeholder="Tax(%)"><span onclick="taxPopup ()" style="margin-top:0;" id="displayTaxCode"  class="btn add-on">....</span></div></td>'+
                    '<td class="span1 tac"><div  class="input-prepend"><input data-taxid="" id="inclusiveTax" onkeyup="calculAmount()" onchange="calculAmount()" name="incTax" class="tac" type="checkbox"></div></td>'+
                                        //edit by fadhirul hilmi; Date: 08/10/2014
                                        /*'<td class="span2"><select onchange="calculAmount()" name="listTax" id="listTax"  class= "span12"><option></option>' +
<?php /* if ($taxmaster) {
  foreach ($taxmaster as $row2) {
  ?>
  '<option value="<?php echo $row2->ID; ?>" data-taxcode ="<?php echo $row2->code; ?>" data-tax="<?php echo $row2->taxPercentage; ?>">' +
  '<?php echo $row2->code . " | " . $row2->taxPercentage;
  ?></option>'+
  <?php }
  } */ ?>
                             '</select></td>' +*/'<td class="span1"><input id="taxAmount" disabled name="taxAmount" class="span12 amount" type="text" placeholder="Amount"></td>'+
                                                                            '<td class="span1"><input disabled  id="amountIT" name="amountIT" class="span12 amount" type="text" placeholder="Amount (Exclude Tax)"></td>'+
                    '<td class="span1">'+
                            '<button onclick = "saveReceive(this)" class="btn-icon btn-mini btn-success-form" type="button"><i class="i-checkmark-3"></i></button>'+
                            '<button onclick="delRow(this)" id="btnCancel" class="btn-icon btn-mini btn-danger-form" type="button"><i class="i-cross"></i></button>'+
                    '</td>'+
'</tr>').insertBefore( "#trInfos" );
        $('#accountID').select2();
		
        $.each($(".select2-container"), function (i, n) {
            $(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
            $(n).prepend($(n).next());
            $(n).delay(500).queue(function () {
                $(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
                $(this).dequeue();
            });
        });
		
            }else{
                    msg ("alert","Please, do save the current details before adding new one");
                    }
}
  

  function getTotal (){
	  
         $("#totalamount").val("");
  
        $("#impotpayable").val("");
  
        $("#totalpayable").val("");
         var n =$("#paymentDetails > tbody > tr").length-1;
         var totalAmount =0;
         var impot = 0;
         var total = 0;
         for (i=0; i<=n; i++) {
                        totalAmount= totalAmount + accounting.unformat($('#paymentDetails > tbody > tr:eq(' + i + ') > td:eq(3)').text())*1; 
                        impot= impot + accounting.unformat($('#paymentDetails > tbody > tr:eq(' + i + ') > td:eq(6)').text()) *1; 
                        total= total + accounting.unformat($('#paymentDetails > tbody > tr:eq(' + i + ') > td:eq(7)').text())*1; 
         }
	
	
	
         $("#totalallocated").val(accounting.formatNumber(totalAmount,2));
  
        $("#totaltaxamount").val(accounting.formatNumber(impot,2));
  
        $("#totalpaid").val(accounting.formatNumber(total,2));
	
      //  $("#outofbalance").val(accounting.formatNumber(total-impot-totalAmount,2));
      calculateOutOfBallance();
	
  }
					
					
function msg(type, message){
	
        $("#msg_div p").html(message);
        $("#msg_div").attr("class","alert " + type);
}

function delRow(me){
        var td=me.parentNode;
        var tr=td.parentNode;
        var tBody=tr.parentNode;
        tBody.removeChild(tr);
}

function refreshLocation(){
 $.ajax({
        type: "POST",
        url: "<?php echo base_url() ?>purchasetransaction/refreshLocation",
        success: function(data) {
	
           var resul = eval ("(" + data + ")"); 
           var n=resul.records.length;
           var i=0;
           var opt='' +
                '<option></option>';
                for (i=0;i<n;i++)
                        opt=opt + '<option value="' + resul.records[i].id +'">' + resul.records[i].location + '</option>';
                $('#location').empty();
                $('#location').append(opt);
        }
   });	
}

//add by fadhirul hilmi; Date: 08/10/2014
function taxPopup () {
        $('#popupModal').modal('show');
        $("#_popupTitle").html("Purchase Invoice");
        $("#_popupContent").html('' +
          '<label>Select a tax</label>' +
          '<select style="width:100%;" onchange="calculAmount()" name="listTaxPopup" id="listTaxPopup"  class= "validate[required]">' +
<?php
if ($taxmaster) {
    foreach ($taxmaster as $row2) {
        ?>
                                     '<option data-taxcode="<?php echo $row2->code ?>" value="<?php echo $row2->ID; ?>" data-tax="' + <?php echo $row2->taxPercentage; ?> + '">' + 
                                                         '<?php echo $row2->code . " | " . $row2->taxPercentage . " | ";
        echo str_replace(array("\n", "\r", "'"), " ", $row2->name, $count);
        ?></option>'+
    <?php }
}
?>
                                                         '</select>');
                  $("#listTaxPopup").select2();
	
        $('#_popupFooter').empty();
           $('#_popupFooter').append('<button class="btn-form btn-success-form" id="confButton">Ok</button>' +
        '<button class="btn-form btn-danger-form" id="canb">Cancel</button>');
        $("#_popupTitle").html("Tax Master");
        $( "#canb" ).click(function() {
                $('#popupModal').modal('hide');
        });
        $( "#confButton" ).click(function() {
                $('#popupModal').modal('hide');
                 $("#itemTax").attr("data-taxid",$("#listTaxPopup").val() );
                 $("#itemTax").val ($("#listTaxPopup option:selected").attr("data-tax"));
                 $("#displayTaxCode").html($("#listTaxPopup option:selected").attr("data-taxcode"));
                 calculAmount();
        });
	
	
}

function refreshPayMethod(){
        $.ajax({
        type: "POST",
        url: "<?php echo base_url() ?>OthersPayment/refreshPayMethod",
        success: function(data) {
	
           var resul = eval ("(" + data + ")"); 
           var n=resul.records.length;
           var i=0;
           var opt='' +
                '<option></option>';
                for (i=0;i<n;i++)
                        opt=opt + '<option value="' + resul.records[i].id +'">' + resul.records[i].name + '</option>';
                $('#paymentmethood').empty();
                $('#paymentmethood').append(opt);
        }
   });	
}
        
        function modAmount(){
            if($("#amountExcludedTax").attr('data-actual') != $("#amountExcludedTax").val() && $('#inclusiveTax').attr("checked") != "checked"){
                $("#amountExcludedTax").attr('data-actual',accounting.unformat($("#amountExcludedTax").val()));
                calculAmount();  
            }else{
                $('#inclusiveTax').attr("checked",false);
                calculAmount();
            }
        }
        

        function calculAmount(){
                if($('#inclusiveTax').attr("checked") == "checked"){
                  var am = accounting.unformat($("#itemTax").val())*accounting.unformat($("#amountExcludedTax").val())/106;
                  $("#amountIT").val("0.00");
                  $("#amountIT").val($("#amountExcludedTax").val());
                  if(!$("#amountExcludedTax").attr('data-actual')){
                    $("#amountExcludedTax").attr('data-actual',accounting.unformat($("#amountExcludedTax").val()));
                  }
                  $("#amountExcludedTax").val(accounting.formatNumber((accounting.unformat($("#amountExcludedTax").val()) - am),2))
                  
                  $("#taxAmount").val(accounting.formatNumber(am,2));
                }else{

                    if($("#amountExcludedTax").attr('data-actual')){
                        $("#amountExcludedTax").val($("#amountExcludedTax").attr('data-actual'));
                        //$("#amountExcludedTax").attr('data-actual','0')
                    }
                    var am = accounting.unformat($("#itemTax").val())*accounting.unformat($("#amountExcludedTax").val())/100;
                    $("#taxAmount").val("0.00");
                    $("#amountIT").val("0.00");
                    if  (!isNaN(am)){
                          $("#taxAmount").val(accounting.formatNumber(am,2));
                          $("#amountIT").val(accounting.formatNumber(am*1 + 1*accounting.unformat($("#amountExcludedTax").val()),2));
                   }
                }
        }
        
      function calculateOutOfBallance(){
               $("#outofbalance").val(accounting.formatNumber(accounting.unformat($("#amountpaid").val())-accounting.unformat($("#totalpaid").val()),2));
            }

</script>

<div id="content"> 
    <div class="wrap">
        <div class="head">
            <div class="info">
                <!--<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
<?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>-->
                <ul class="breadcrumb">
                    <li><a href='<?php echo base_url() . "home" ?>'><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                    <li><a href='<?php echo base_url() . "GeneralLedger" ?>'> <?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                    <li class="active"><?php echo $this->lang->line('titlewithout') ?></li>
                </ul>
            </div>
            <div class="search">
                <form action="<?php echo base_url() ?>admin/search" method="post">
                    <input name="search_text" type="text" placeholder="search..."/>                                
                    <button type="submit"><span class="i-magnifier"></span></button>
                </form>
            </div>
        </div><!-- head --> 
        <div class="content" id="grid_content_1">
            <form id="paymentDetail" action="#">
                <input type="hidden" name="paymentId" id="paymentId" value="null" />                

                <div class="block">
                    <div class="head">
                        <h2><strong><?php echo $this->lang->line('titlewithout') ?></strong></h2>
                        
                    </div><!-- head -->
                    <div class="content np">
                        <div class="row-fluid scRow">  

                            <div class="span6 scCol">
                                <div class="block ns" id="grid_block_1">							
                                    <div class="controls-row"> <!-- row 1 -->
                                        <div class="span3"><?php echo $this->lang->line('formno') ?></div>
                                        <div class="span2">
                                            <input class="span12 validate[required]" id="formNo" name="formNo" value='<?php echo "$formNo"; ?>' 
                                                   style="color:red;" type="text" placeholder="Form number ...">
                                        </div>
                                        <div class="span7">
                                            <input  class="span12" type="text" placeholder="Serial" disabled="disabled">
                                        </div>
                                    </div> <!-- row --> 
                                    <div class="controls-row">
                                        <div class="span3"><?php echo $this->lang->line('date') ?></div>
                                        <div class="span9">
                                            <div class="input-prepend span12"><span class="add-on span2"><i class="i-calendar"></i></span>
                                                <?php
                                                $data = array(
                                                    'name' => 'createdDate',
                                                    'id' => 'createdDate',
                                                    'type' => 'text',
                                                    'onkeydown' => 'return false',
                                                    'class' => 'span10 datepicker2 validate[required] financhk',);
                                                echo form_input($data, date("d-m-Y"));
                                                ?>
                                            </div>
                                        </div>
                                    </div> <!-- row -->
                                    <div class="controls-row">
                                        <div class="span3"><?php echo $this->lang->line('bank') ?></div>
                                        <div class="span9">
                                            <select onchange="displaybanksInfos()" name="bank" id="bank" class="span12 validate[required]"><option></option>' +
                                                <?php
                                                if ($bankaccount) {
                                                    foreach ($bankaccount as $row) {
                                                        ?>
                                                        '<option data-currentBalance="<?php echo $row->currentBalance; ?>" data-bankAccountNo="<?php echo $row->bankAccountNo; ?>"  value="<?php echo $row->ID; ?>"><?php echo $row->bankShortName . " | ";
                                                echo str_replace(array("\n", "\r", "'"), " ", $row->branch, $count);
                                                ?></option>'+
    <?php }
}
?>
                                            </select>
                                        </div>
                                    </div> <!-- row -->
                                    <div class="controls-row">
                                        <div class="span3"><?php echo $this->lang->line('acctno') ?></div>
                                        <div class="span9">
                                            <input id="acctNo" class="span12 tar" disabled type="text" placeholder="0">
                                        </div><!-- span -->
                                    </div> <!-- row -->
                                    <script type="text/javascript">
                                        function changeRcvFrom() {
                                            if ($('#rcvType').val() == 1) {
                                                var rcvFromCont = '<textarea style="min-height:85px;" id="receiveFrom" class="span12 validate[required]" placeholder="<?php echo $this->lang->line('receiveFrom') ?>"></textarea>';
                                                $('#rcvTypeCont').html(rcvFromCont);
                                            } else {
                                                var customerList = '<select id="receiveFrom" class="span12  validate[required]">' +
                                                        '<option value="null">Select Customer</option>' +
<?php foreach ($customer as $row): ?>
                                                    '<option value="<?php echo $row->customerName ?>"><?php echo $row->customerName ?></option> ' +
<?php endforeach; ?>
                                                '</select>';
                                                $('#rcvTypeCont').html(customerList);
                                                $('#receiveFrom').select2()
                                            }
                                            console.log(customerList);
                                        }
                                    </script>
                                    <div class="controls-row"><!-- row 3 -->
                                        <div class="span3"><?php echo $this->lang->line('receiveType') ?></div>
                                        <div class="span9">
                                            <select id="rcvType" class="span12" onchange="changeRcvFrom()">
                                                <option value="1">Other Receive</option>
                                                <option value="2">Deposit Payment</option>
                                            </select>
                                        </div>
                                    </div> <!-- row -->   
                                     <div class="controls-row">
                                        <div class="span3"><?php echo $this->lang->line('project') ?></div>
                                        <div class="span9">
                                            <select id="project" class="span11">
                                                <option></option>
                                                <?php
                                                if ($project != '') {
                                                    foreach ($project as $row) {
                                                        ?>
                                                        <option value="<?php echo $row->ID; ?>"><?php echo $row->project_name; ?></option>
    <?php }
}
?>
                                            </select>
                                            <div class="btn-group span1">
                                                <button class="btn-icon btn-small dropdown-toggle" data-toggle="dropdown">
                                                    <span class="i-arrow-down-2"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <!-- dropdown menu links -->
                                                    <li><a target="_blank" href="<?php echo base_url() ?>project/ProjectSetup"  id="btnNewPro">
                                                            <i class="i-plus-2"></i><?php echo $this->lang->line('addnewproject') ?></a></li>
                                                    <li><a href="#" onclick="refreshProject()">
                                                            <i class="i-ccw"></i><?php echo $this->lang->line('refreshlist') ?></a></li>
                                                </ul>
                                            </div> <!-- btn group -->
                                        </div><!-- span -->
                                    </div> <!-- row control -->
                                </div><!-- grid block 1-->
                            </div><!-- scCol -->

                            <div class="span6 scCol">
                                <div class="block ns" id="grid_block_2">
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('receiveFrom') ?></div>
                                        <div id="rcvTypeCont" class="span8">
                                            <textarea style="min-height:45px;" id="receiveFrom" class="span10 validate[required]" 
                                                      placeholder="<?php echo $this->lang->line('receiveFrom') ?>">
                                            </textarea>                                    
                                        </div><!-- span -->
                                    </div> <!-- row -->
                                   
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('amountReceived') ?></div>
                                        <div class="span8">
                                            <input id="amountpaid" onkeyup="calculateOutOfBallance()" class="span10 validate[required] tar" type="text" placeholder="0.00">
                                        </div><!-- span -->
                                    </div> <!-- row -->
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('paymentmethood') ?></div>
                                        <div class="span8">
                                            <select class="span10 validate[required]" id="paymentmethood">
                                                <option></option>
                                                <?php
                                                if ($paymentmethod != '') {
                                                    foreach ($paymentmethod as $row) {
                                                        ?>
                                                        <option value="<?php echo $row->ID; ?>"><?php echo $row->name ?></option>
    <?php }
}
?>
                                            </select>
                                            <div class="btn-group span1">
                                                <button class="btn-icon btn-small dropdown-toggle" data-toggle="dropdown">
                                                    <span class="i-arrow-down-2"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <!-- dropdown menu links -->
                                                    <li><a target="_blank" href="<?php echo base_url() ?>setting/masterCodeSetup"  id="btnLocation">
                                                            <i class="i-plus-3"></i><?php echo $this->lang->line('addpaymethod') ?></a></li>
                                                    <li><a href="#" onclick="refreshPayMethod()">
                                                            <i class="i-ccw"></i><?php echo $this->lang->line('refreshlist') ?></a></li>
                                                </ul>
                                            </div> <!-- btn group -->
                                        </div>
                                    </div><!--ctrl row -->
                                     <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('refno') ?></div>
                                        <div class="span8">
                                            <input id="refno" class="span10 validate[required]" type="text" placeholder="Ref no">
                                        </div><!-- span -->
                                    </div> <!-- row -->
                                     <div class="controls-row">
                                        <div class="span4">Exchange Rate</div>
                                        <div class="span8">
                                            <input id="exchangeRate" value="1.000" class="span10 validate[required]" type="text" placeholder="<?php echo $this->lang->line('exchangeRate') ?>">
                                        </div><!-- span -->
                                    </div> <!-- row -->
                                </div><!-- block 2 grid-->
                            </div><!-- span6 scCol -->
                        </div><!-- row-fluid scRow-->					

                        <div class="row-fluid scRow">                            
                            <div class="span12 scCol">
                                <div class="block ns" id="grid_block_3">
                                    <div class="controls-row"><!-- Row 4-->
                                        <div class="span1"><?php echo form_label($this->lang->line('memo'), 'memo'); ?></div>
                                        <div class="span11">
                                            <textarea rows="1" id="memo" name="memo" class="span12"></textarea>
                                        </div>
                                    </div><!-- End Row 4-->
                                </div><!--block_3 -->
                            </div><!--span12 scCol -->
                        </div><!--row-fluid scRow -->
                    </div><!-- content class -->
                </div><!-- block -->

                <div class="row-fluid scRow">                            
                    <div class="span12 scCol">
                        <div class="block" id="grid_block_4">
                            <div class="head">
                                <h2><?php echo $this->lang->line('paymentdetails') ?></h2>
                                <ul class="buttons">
                                    <li><a class="block_toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                                            <span class="i-arrow-down-3"></span></a></li>
                                </ul>                                        
                            </div><!-- head -->
                            <div class="content np">
                                <table data-currentRow="0" id="paymentDetails" cellpadding="0" cellspacing="0" width="100%">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th><?php echo $this->lang->line('account') ?></th>
                                            <th><?php echo $this->lang->line('description') ?></th>
                                            <th><?php echo $this->lang->line('amount') ?></th>
                                            <th><?php echo $this->lang->line('tax') ?></th>
                                            <th><?php echo $this->lang->line('incTax') ?></th>
                                            <th><?php echo $this->lang->line('taxAmount') ?></th>
                                            <th><?php echo $this->lang->line('amountIncludeTax') ?></th>
                                            <th class="tac"><?php echo $this->lang->line('action') ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr id="trInfos">
                                            <td colspan="9">
                                                <div id="msg_div" class="alert alert-info">
                                                    <h4><?php echo $this->lang->line('lastMessage') ?></h4>
                                                    <p style="padding-top:10px;"><?php echo $this->lang->line('noMessage') ?></p>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div><!-- content -->
                            <div class="footer">
                                <div class="side fr">
                                    <div class="btn-group">
                                        <button style="margin-right:6px;" onclick="$('#paymentDetail').validationEngine('hide');" class="btn-form btn-warning-form" type="button" name="validat">Hide prompts</button>
                                        <button id="addRowCharge" onclick="addRow()" class="btn-icon btn-warning-form" type="button">
                                            <i class="i-plus-2"></i><?php echo $this->lang->line('addNewCharge') ?></button>
                                    </div><!-- btn group -->      
                                </div><!-- side fr -->      
                            </div><!-- footer -->     
                        </div><!-- block-->

                    </div><!-- span12 -->
                </div><!-- row-fluid scRow-->

        </div><!-- block -->



        <div class="content">    
            <div class="row-fluid scRow">  
                <div class="span12 scCol">
                    <div class="block">						
                        <div class="head">
                            <h2><?php echo $this->lang->line('totalAmounts') ?></h2>
                            <ul class="buttons">
                                <li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
                            </ul>
                        </div>							
                        <div class="content np">
                            <div class="span6 scCol">
                                <div class="block" id="grid_block_4">							

                                </div><!-- grid block 1-->
                            </div><!-- span6 scCol -->           
                            <div class="span6 scCol">
                                <div class="block" id="grid_block_4">
                                    <div class="content np">                            
                                        <div class="controls-row">
                                            <div class="span4"><?php echo $this->lang->line('totalpaid') ?></div>
                                            <div class="span8">
                                                <input id="totalpaid" disabled="disabled"  class="span12 tar" type="text" placeholder="0.00">
                                            </div>
                                        </div><!-- row control -->

                                        <div class="controls-row">
                                            <div class="span4"><?php echo $this->lang->line('totalallocated') ?></div>
                                            <div class="span8">
                                                <input id="totalallocated" class="span12 tar" type="text" placeholder="0.00" disabled="disabled" >
                                            </div>
                                        </div><!-- row control -->
                                        <div class="controls-row">
                                            <div class="span4"><?php echo $this->lang->line('totaltaxamount') ?></div>
                                            <div class="span8">
                                                <input id="totaltaxamount" class="span12 tar" type="text" disabled="disabled"  placeholder="0.00">
                                            </div>
                                        </div><!-- row control --> 

                                        <div class="controls-row">
                                            <div class="span4"><?php echo $this->lang->line('outofbalance') ?></div>
                                            <div class="span8">
                                                <input id="outofbalance" disabled="disabled"  class="span12 tar" type="text" placeholder="0.00">
                                            </div>
                                        </div><!-- row control -->
                                    </div>    
                                </div><!-- grid block 1-->
                            </div><!-- span6 scCol -->					
                        </div><!-- content np-->
                        <div class="footer">
                            <div class="side fr">
                                <div class="btn-group">

                                </div><!-- btn group -->      
                            </div><!-- side fr -->      
                        </div><!-- footer --> 
                    </div><!-- block-->
                </div><!-- span12-->	
            </div><!--row-fluid scRow -->
        </div> <!--content total -->	

        </form>		
    </div><!-- content class -->		
</div><!--wrap -->
</div><!--content id -->



