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

    #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;
    }
    .span3 {
        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 savePayment(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(),
                                    payto : $("#payto").val(),
                                   // locationID : $("#location").val(), 
                                    paymentMethodID : $("#paymentmethood").val(), 
                                    amountPaid : $("#amountpaid").val(), 
                                    formNo :  $("#formNo").val(),
                                    paymentDate : $("#createdDate").val(),
                                    referenceNo: $("#refno").val(),
                                    bankID : $("#bank").val(),
                                    projectID : $("#project").val(),
                                    
                                    lineNo : $("#paymentDetails").attr("data-currentRow")*1+1,
                                    amountIncludedTax : accounting.unformat($("#amountIT").val()),
                                    itemAccountID : $("#accountID").val(),
                                    itemdescription: $("#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/savenewpaywithOutItem",
                     success: function(data) {
                     var resul = eval ("(" + data + ")"); 
                     var incTax = 'Exclusive Tax';
                     if($('#inclusiveTax').attr('checked') == 'checked')  incTax = 'Inclusive Tax';
                      $("#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="tar">' + accounting.formatNumber($("#amountExcludedTax").val(),2) + '</td>'+
                              '<td class="tac">' + $("#itemTax").val() + ' | ' + $("#displayTaxCode").text() + '</td>'+
                              '<td class="tar"></td>'+
                              '<td class="tar">' + accounting.formatNumber($("#taxAmount").val(),2) + '</td>'+
                              '<td class="tar">' + 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,
                                    amountIncludedTax : accounting.unformat($("#amountIT").val()),
                                    itemAccountID : $("#accountID").val(),
                                    itemdescription: $("#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/savenewpaywithoutItemDetailOnly",
                    success: function(data) {
                     msg ("alert alert-success","Details successfully saved");
                      var resul = eval ("(" + data + ")"); 
                      var incTax = 'Exclusive Tax';
                     if($('#inclusiveTax').attr('checked') == 'checked')  incTax = 'Inclusive Tax';

                      $("#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 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) {
        $temp = str_replace(array("\n", "\r","'"), " ", $row2->name, $count);
        ?>
                             '<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 $temp; ?></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 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) {
      $temp = str_replace(array("\n", "\r","'"), " ", $row->acctName, $count);
        ?>
        '<option value="<?php echo $row->ID; ?>"><?php echo substr($row->acctCode,0,4).'-'.substr($row->acctCode,4,3).'-'.substr($row->acctCode,7) . " | ";
        echo $temp; ?></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: 10/08/2014
                    '<td class="span1"><div  class="input-prepend"><input data-taxid="" id="itemTax" disabled="disabled" onkeyup="calculAmount()" onchange="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: 10/08/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 = "savePayment(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();
         $('#listTax').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();
	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);
        }
   });	
}

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(accounting.formatNumber($("#amountExcludedTax").val(),2));
                  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;
                  $("#amountIT").val("0.00");
                  $("#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() . "AccountPayables/home" ?>'> <?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="span4 scCol">
                                <div class="block ns" id="grid_block_1">
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('formno') ?></div>
                                        <div class="span5">
                                            <input class="span12 validate[required]" id="formNo" name="formNo" value='<?php echo "$formNo"; ?>' style="color:red;"   type="text" placeholder="Form number ...">
                                        </div>
                                        <div class="span3">
                                            <input class="span11" type="text" placeholder="Serial" disabled="disabled">
                                        </div>
                                    </div> <!-- row -->
                                    
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('date') ?></div>
                                        <div class="span8">
                                            <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="span4"><?php echo $this->lang->line('payto') ?></div>
                                        <div class="span8">
                                            <textarea style="min-height:85px;" id="payto" class="span12 validate[required]" placeholder="<?php echo $this->lang->line('payto') ?>"></textarea>
                                        </div><!-- span -->
                                    </div> <!-- row -->


                                    
                                </div><!-- grid block 1-->
                            </div><!-- scCol -->

                            <div class="span4 scCol">
                                <div class="block" id="grid_block_3">
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('bank') ?></div>
                                        <div class="span8">
                                            <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="span4"><?php echo $this->lang->line('acctno') ?></div>
                                        <div class="span8">
                                            <input id="acctNo" class="span12 tar" disabled type="text" placeholder="0">
                                        </div><!-- span -->
                                    </div> <!-- row -->

                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('balance') ?></div>
                                        <div class="span8">
                                            <input id="balance" disabled class="span12 validate[required] tar" type="text" placeholder="0.00">
                                        </div><!-- span -->
                                    </div> <!-- row -->

                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('project') ?></div>
                                        <div class="span8">
                                            <select id="project" class="span10">
                                                <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-3"></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="span4 scCol">
                                <div class="block ns" id="grid_block_2">
                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('amountpaid') ?></div>
                                        <div class="span8">
                                            <input id="amountpaid" onkeyup="calculateOutOfBallance();" class="span12 validate[required] tar" type="text" placeholder="0.00">
                                        </div><!-- span -->
                                    </div> <!-- row -->



                                    <div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('refno') ?></div>
                                        <div class="span8">
                                            <input id="refno" class="span12 validate[required]" type="text" placeholder="Ref no">
                                        </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>

                                    <!--div class="controls-row">
                                        <div class="span4"><?php echo $this->lang->line('location') ?></div>
                                        <div class="span8">
                                            <select class="span10" id="location">
                                                <option></option>
                                                <?php
                                                if ($location != '') {
                                                    foreach ($location as $row) {
                                                        ?>
                                                        <option value="<?php echo $row->fldid; ?>"><?php echo $row->city . " | " . $row->address; ?></option>
    <?php }
} ?>
                                            </select>
                                            <div class="btn-group span1">
                                                <button class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown">
                                                    <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <li><a target="_blank" href="<?php echo base_url() ?>ItemSetup/location"  id="btnLocation">
                                                            <i class="icon-plus-sign"></i><?php echo $this->lang->line('addLocation') ?></a></li>
                                                    <li><a href="#" onclick="refreshLocation()"><i class="icon-refresh"></i><?php echo $this->lang->line('refreshlist') ?></a></li>
                                                </ul>
                                            </div> 
                                        </div>
                                    </div -->
                                    
                                    
                                </div><!-- grid block 1-->
                            </div><!-- scCol -->
                            
                        </div><!-- row-fluid scRow-->
                    </div><!-- content -->
                </div><!-- bloc -->
                
                 <div class="row-fluid scRow">                            
                    <div class="span12 scCol">
                        <textarea style="margin-top:10px;" id="memo" class="span12" placeholder="Memo"></textarea>
                        </div>
                </div>

                <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 class="tar"><?php echo $this->lang->line('amount') ?></th>
                                            <th><?php echo $this->lang->line('tax') ?></th>
                                            <th><?php echo $this->lang->line('incTax') ?></th>
                                            <th class="tar"><?php echo $this->lang->line('taxAmount') ?></th>
                                            <th class="tac"><?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 class="footer">
                                    <div class="side fr">                                    
                                            <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('addNewPayment') ?></button>                                        
                                    </div><!-- side fr -->      
                                </div><!-- footer -->      
                            </div><!-- content -->

                        </div><!-- grid block 1-->
                    </div><!-- scCol -->




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

                <div class="row-fluid scRow"> 
                    <div class="span6 scCol">
                        <div class="block" id="grid_block_4">
                            <div class="content np">
                              
                            </div>    
                        </div><!-- grid block 1-->
                    </div><!-- 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('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('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('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><!-- scCol -->
                </div><!-- row-fluid scRow-->
            </form>
        </div><!-- grid 1 -->
    </div><!-- wrap -->
</div><!-- content -->



