<style type="text/css">
    .amount{
        text-align: right !important;
    }
    
    .quantity {
        text-align: center !important;
    }
.input-prepend span, input-prepend button{
	height:18px;
	padding:3px;
	}
#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 td {
	font-size:11px;
	}
#content .wrap #grid_content_1 .row-fluid.scRow .row-fluid.scRow .span12.scCol #grid_block_6 .content.np #listpmt tbody #trInfospmt td .row-fluid .controls-row .span3 {
	font-weight: bold;
}
</style>

<script>

				  function calculamount(){
					
					//if ($("#itemTax").attr("data-taxid")=="") {
					//	taxPopup ();
					//}
					var j_itemAmountET =accounting.unformat($("#itemunitprice").val())*accounting.unformat($("#itemqte").val());
					$("#itemAmountET").val(accounting.formatNumber(j_itemAmountET,2));
					
					var j_itemTaxAmount=j_itemAmountET*accounting.unformat($("#itemTax").val())/100;
					$("#itemTaxAmount").val(accounting.formatNumber(j_itemTaxAmount,2));
					$("#itemAmountIT").val(accounting.formatNumber(j_itemTaxAmount+j_itemAmountET,2));
					
				}
				
			function calculpmtAmount() { 
			  var t = accounting.unformat($("#pmtAmount").val()) * accounting.unformat($("#listTax option:selected").attr("data-tax")) /100;
			  $("#pmttaxAmount").val(accounting.formatNumber(t,2));
			  $("#pmtAmountIT").val(accounting.formatNumber(t+  accounting.unformat($("#pmtAmount").val())*1,2));
		  }

				   function EndEdit(me){
					 
					 var dID = $(me).attr("data-itemId");
					 	 $(''+
					 '<tr>' +
                                             '<td class="span1">' + $(me).parent().parent().find("td").eq(0).html() + '</td>' +
						'<td>' +  $("#itemcode").val() + '</td>'+
                        '<td>' + $("#itemname").val() + '</td>'+
                        '<td>' + $("#itemdes").val() + '</td>'+
                        '<td class="amount">' + accounting.formatNumber($("#itemunitprice").val(),2) + '</td>'+
                        '<td>' + $("#itemqte").val() + '</td>'+
                        '<td class="amount">' + $("#itemAmountET").val() + '</td>'+
                        '<td>' + $("#itemTax").val() + '</td>'+
                        '<td class="amount">' + $("#itemTaxAmount").val() + '</td>'+
                        '<td class="amount">' + $("#itemAmountIT").val() + '</td>'+
                         '<td>'+
						'<button data-taxcode="' + $(me).attr("data-taxcode") + '" data-taxrate="' + $(me).attr("data-taxrate") +'"  onclick="editRow(this)" data-taxid="' + $(me).attr("data-taxid") + '" data-myid="' + $(me).attr("data-myid") +'" class="btn btn-mini"><i class="icon-pencil"></i></button>' +
                         ' <button my-id="' + dID + '" class="btn btn-mini btn-danger"><i class="icon-trash icon-white"></i></button>'+
						'</td>'+
                    '</tr>'
					  ).insertBefore( "#trInfos" );
					  delRowInvoice(me);
					   getTotal ();
					 }
					 
				  function cancelEdit(me){
					 
					 var dID = $(me).attr("data-itemId");
					 	 $(''+
					 '<tr>' +
						'<td>' +  $("#itemcode").attr("data-previewvalue") + '</td>'+
                        '<td>' + $("#itemname").attr("data-previewvalue") + '</td>'+
                        '<td>' + $("#itemdes").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#itemunitprice").attr("data-previewvalue") + '</td>'+
                        '<td>' + $("#itemqte").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#itemAmountET").attr("data-previewvalue") + '</td>'+
                        '<td>' + $("#itemTax").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#itemTaxAmount").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#itemAmountIT").attr("data-previewvalue") + '</td>'+
                        '<td>'+
						'<button data-taxcode="' + $(me).attr("data-taxcode") + '" data-taxrate="' + $(me).attr("data-taxrate") +'"  onclick="editRow(this)" data-taxid="' + $(me).attr("data-taxid") + '" data-myid="' + $(me).attr("data-myid") +'" class="btn btn-mini"><i class="icon-pencil"></i></button>' +
                         ' <button my-id="' + dID + '" class="btn btn-mini btn-danger"><i class="icon-trash icon-white"></i></button>'+
						'</td>'+
                    '</tr>'
					  ).insertBefore( "#trInfos" );
					  delRowInvoice(me);
					   getTotal ();
					 }
					 
				function getTotal (){
					
						 var n =$("#listDetails > tbody > tr").length - 2;
						 var totalAmount =0;
						 var impot = 0;
						 var total = 0;
						 var i = 0;
						 for (i=0; i<=n; i++) {
							 
								totalAmount= totalAmount + accounting.unformat($('#listDetails > tbody > tr:eq(' + i + ') > td:eq(3)').text())*1; 
								impot= impot + accounting.unformat($('#listDetails > tbody > tr:eq(' + i + ') > td:eq(5)').text())*1; 
								total= total + accounting.unformat($('#listDetails > tbody > tr:eq(' + i + ') > td:eq(6)').text())*1; 
								
						 }
					
						
						 $("#totalallocated").val(accounting.formatNumber(totalAmount,2));
					
						$("#totaltaxamount").val(accounting.formatNumber(impot,2));
					
						$("#totalpaid").val(accounting.formatNumber(total,2));
					}
	     
		
			  function delRowInvoice(me){
				  var td=me.parentNode;
				  var tr=td.parentNode;
				  var tBody=tr.parentNode;
				  tBody.removeChild(tr);
				  getTotal ();
			  }
			  
			  function msg(n,type, message){
	$("#msg_div" + n +" p").html(message);
	$("#msg_div").attr("class","alert " + type);
}
			  
				  function editRowPayment (me){
                                       var  tr = $(me).parent().parent();
                                        if (!$("#pmtAccount").length) {
					 $(tr).replaceWith( '<tr><td>'+ $(me).parent().parent().find("td").eq(0).html()  +'</td>' +
							'<td class="span2" ><select data-lineNo="' + $(me).parent().parent().find("td").eq(0).html() + '" data-previewvalue="' + $(me).parent().parent().find("td").eq(1).html() + '" name="pmtAccount" id="pmtAccount" class= "span12 validate[required]"><option></option>' +
									 <?php
				if($pmtAccount){
				 foreach($pmtAccount as $row){
					 ?>
                     '<option  value="<?php echo $row->ID; ?>"><?php echo $row->acctCode." | "; echo str_replace("'", " ",$row->acctName, $count); ?></option>'+
			    <?php }} ?>
							 '</select></td>'+
													'<td class="span4"><input data-previewvalue="' + $(me).parent().parent().find("td").eq(2).html() + '"  id="pmtdesc" name="pmtdesc"  type="text" class="span12 validate[required]" placeholder="Description" value="' + $(me).parent().parent().find("td").eq(2).html() + '"></td>'+
													'<td class="span1"><input data-previewvalue="' + $(me).parent().parent().find("td").eq(3).html() + '" class="span12" id="pmtAmount" onkeyup="calculpmtAmount()" name="pmtAmount" value="' + $(me).parent().parent().find("td").eq(3).html() + '" class="input-mini validate[required, custom[number]]" type="text" placeholder="Amount"></td>'+
													'<td class="span2"><select data-previewvalue="' + $(me).parent().parent().find("td").eq(4).html() + '" onclick="calculpmtAmount()" name="listTax" id="listTax"  class= "span12 validate[required]"><option></option>' +
									 <?php if($taxmaster){
					 foreach($taxmaster as $row2){
					 ?>
                     '<option value="<?php echo $row2->ID; ?>" data-code="<?php echo $row2->code; ?>" data-tax="<?php echo $row2->taxPercentage; ?>">' + 
					 '<?php echo $row2->code." | ".$row2->taxPercentage; ?></option>'+
			    <?php }} ?>
							 '</select></td>'+
										'<td class="span1"> <input data-previewvalue="' + $(me).parent().parent().find("td").eq(5).html() + '" id="pmttaxAmount" value="' + $(me).parent().parent().find("td").eq(5).html() + '"  name="pmttaxAmount" class="span12" type="text" placeholder="Amount"></td>'+
													'<td class="span1"><input data-previewvalue="' + $(me).parent().parent().find("td").eq(6).html() + '" onkeydown="return false;" id="pmtAmountIT" value="' + $(me).parent().parent().find("td").eq(6).html() + '"name="pmtAmountIT" class="span12" type="text" placeholder="Amount (Exclude Tax)"></td>'+
						'<td class="span1">'+
						 	'<button data-myid="' + $(me).attr("data-myid") + '" data-accid="' + $(me).attr("data-accid") + '" data-taxid="' + $(me).attr("data-taxid") + '" onclick = "updatePdetails(this)" class="btn btn-mini btn-primary" type="button"><i class="icon-trash icon-ok-circle"></i></button>'+
						 	'<button data-myid="' + $(me).attr("data-myid") + '" data-accid="' + $(me).attr("data-accid") + '" data-taxid="' + $(me).attr("data-taxid") + '" onclick="delCancelEditpmt(this)" id="btnCancelpmt" class="btn btn-mini" type="button"><i class="icon-remove-circle"></i></button>'+
						'</td>'+
                    '</tr>'
					  );
					
					$("#pmtAccount").val($(me).attr("data-accid"));
 					$("#listTax").val($(me).attr("data-taxid"));
                                        $("#pmtAccount").select2();
                                        $("#listTax").select2();
					}else{
						msg (2,"alert","Please, do save the current details before addind new one");
						}
				 }	
				 
				 function delCancelEditpmt (me){
                                  var  tr = $(me).parent().parent();
					 $("#pmtAccount").val($(me).attr("data-accid"));
 					$("#listTax").val($(me).attr("data-taxid"));
					 	$(tr).replaceWith( '<tr>' +
                                                 '<td>' +  $("#pmtAccount").attr("data-lineNo") + '</td>'+
						'<td>' +  $("#pmtAccount").attr("data-previewvalue") + '</td>'+
                        '<td>' + $("#pmtdesc").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#pmtAmount").attr("data-previewvalue") + '</td>'+
                        '<td>' + $("#listTax").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#pmttaxAmount").attr("data-previewvalue") + '</td>'+
                        '<td class="amount">' + $("#pmtAmountIT").attr("data-previewvalue") + '</td>'+
                        '<td>'+
						'<button onclick="editRowPayment(this)" data-myid="' + $(me).attr("data-myid") + '" data-accid="' + $(me).attr("data-accid") + '" data-taxid="' + $(me).attr("data-taxid") + '" class="btn btn-mini"><i class="icon-pencil"></i></button>' +
                         ' <button onclick="deleteRowPdetails(this)" data-myid="' + $(me).attr("data-myid") + '" class="btn btn-mini btn-danger"><i class="icon-trash icon-white"></i></button>'+
						'</td>'+
                    '</tr>'
					  );
					 }	
					 
					 
					 function updatePdetails(me) {
                                              var  tr = $(me).parent().parent();
						 $.ajax({
							  type: "POST",
							  data: {
								    rowID  : $(me).attr("data-myid"),
									accountID : $("#pmtAccount").val(),
									amountIncludedTax : $("#pmtAmountIT").val(),
									amountExcludedTax :  $("#pmtAmount").val(),
									taxID : $("#listTax").val(),
									taxRate : $("#listTax").attr("data-tax"),
									taxAmount : $("#pmttaxAmount").val(),
									itemdescription : $("#pmtdesc").val(),
									
								  },
							  url: "<?php echo base_url() ?>OthersPayment/updatepayitemwithoutitem",
							  success: function(data) {
									 msg (2,"alert alert-success","Details successfully updated");
									 $(tr).replaceWith( '<tr>' +
                                                                                       '<td>' +  $("#pmtAccount").attr("data-lineNo") + '</td>'+
											'<td>' +  $("#pmtAccount option:selected").text() + '</td>'+
											'<td>' + $("#pmtdesc").val() + '</td>'+
											'<td class="amount">' + accounting.formatNumber($("#pmtAmount").val(),2) + '</td>'+
											'<td>' + $("#listTax option:selected").attr("data-code") + ' | ' + $("#listTax option:selected").attr("data-tax") + '</td>'+
											'<td class="amount">' + $("#pmttaxAmount").val() + '</td>'+
											'<td class="amount">' + $("#pmtAmountIT").val() + '</td>'+
											'<td>'+
											'<button onclick="editRowPayment(this)" data-myid="' + $(me).attr("data-myid") + '" data-accid="' + $("#pmtAccount").val() + '" data-taxid="' + $("#listTax").val() + '" class="btn btn-mini"><i class="icon-pencil"></i></button>' +
											 '<button data-myid="' + $(me).attr("data-myid") + '" class="btn btn-mini btn-danger"><i class="icon-trash icon-white"></i</button>'+
											'</td>'+
										'</tr>'
										  );
									   getTotal();
									 } });
								 
						}
					
				function  deleteRowPdetails(me){
							$('#popupModal').modal('show');
						  $("#_popupTitle").html("Confirm delete");
						  $("#_popupContent").html("Your about to delete definively this row. <br/> Click on ok to confirm");
						  
						  $('#_popupFooter').empty();
							 $('#_popupFooter').append('<button class="btn btn-danger" id="detButton">Ok</button>' +
						  '<button class="btn" id="canb">Cancel</button>');
						  $("#_popupTitle").html("Confirm delete");
						  $( "#canb" ).click(function() {
							  $('#popupModal').modal('hide');
						  });
						  
						     $( "#detButton" ).click(function() {
							  $('#popupModal').modal('hide');
							   $.ajax({
					 				 type: "POST",
								  data: {
										rowID :$(me).attr("data-myid")					  
						  				},
					 			 url: "<?php echo base_url() ?>OthersPayment/deletePaymentWithoutItem",
							  	 success: function(data) {
										 msg (1,"alert alert-success","Details successfully deleted");
							 			 delRowInvoice(me);
							             getTotal();
						 
						  			}} ); 
							 });
					}
                function addnewrow(){
                     n = $("#trInfospmt").attr("data-currentRow")*1 + 1;
                     if (!$("#accountID").length) {
                     $(''+
                         '<tr><td>' + n +'</td>'+
                            '<td class="span2" ><select data-lineNo="' + n + '" data-previewvalue="' + n + '" name="accountID" id="accountID" class= "span12 validate[required]"><option></option>' +
									 <?php
				if($pmtAccount){
				 foreach($pmtAccount as $row){
					 ?>
                     '<option  value="<?php echo $row->ID; ?>"><?php echo $row->acctCode." | "; echo str_replace("'", " ",$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" onkeyup="calculAmount()" name="amountExcludedTax" class="span12 validate[required, custom[number]] amount" type="text" placeholder="Amount"></td>'+
                    '<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 = "savenewrow()" class="btn btn-mini btn-primary" type="button"><i class="icon-ok-circle"></i></button>'+
                            '<button onclick="delRowInvoice(this)" id="btnCancel" class="btn btn-mini btn-danger" type="button"><i class="icon-remove-circle"></i></button>'+
                    '</td>'+
'</tr>').insertBefore( "#trInfospmt" );
        $('#accountID').select2();
         $('#listTax').select2();
            }else{
                    msg (2,"alert","Please, do save the current details before addind new one");
                    }
                }
		 function calculAmount(){
                var am = accounting.unformat($("#listTax option:selected").attr("data-tax"))*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 savenewrow(){
             $.ajax({
                    type: "POST",
                    data: {
                              otherPaymentID : $("#masterID").val(),
                                    
                                    lineNo : $("#trInfospmt").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: $("#listTax").val(),
                                    taxRate: $("#listTax option:selected").attr("data-tax")

                            },
                    url: "<?php echo base_url() ?>OthersPayment/savenewpaywithoutItemDetailOnly",
                    success: function(data) {
                     msg (1,"alert alert-success","Details successfully saved");
                      var resul = eval ("(" + data + ")"); 
                      $("#trInfospmt").attr("data-currentRow", $("#trInfospmt").attr("data-currentRow")*1+1);
                    $(''+
                        '<tr><td>' +  $("#trInfospmt").attr("data-currentRow") +'</td>'+
                              '<td>' +  $("#accountID option:selected").text() + '</td>'+
                              '<td>' + $("#itemDesc").val() + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#amountExcludedTax").val(),2) + '</td>'+
                              '<td>' + $("#listTax option:selected").attr("data-tax") + ' | ' + $("#listTax option:selected").attr("data-taxcode") + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#taxAmount").val(),2) + '</td>'+
                              '<td class="amount">' + accounting.formatNumber($("#amountIT").val(),2) + '</td>'+
                              '<td>'+
                            '<button onclick="editRowPayment(this)" data-myid="' + resul.detailID + '" data-accid="' + $("#pmtAccount").val() + '" data-taxid="' + $("#listTax").val() + '" class="btn btn-mini"><i class="icon-pencil"></i></button>' +
                             '<button data-myid="' + resul.detailID + '" class="btn btn-mini btn-danger"><i class="icon-trash icon-white"></i</button>'+
                            '</td>'+
                    '</tr>'
                ).insertBefore( "#trInfospmt" );
                    $("#btnCancel").trigger("click");
                    getTotal();
                    msg (1,"alert alert-success","Details successfully saved");
               }
             }); //end ajax
        }
            </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()."gl/home" ?>'> <?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                <li class="active"><?php echo $this->lang->line('title') ?></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">
                 
	<div class="row-fluid">
		<div class="alert alert-info">
			<strong><?php echo $this->lang->line('title') ?></strong>
		</div>
	</div>
     <?php
  $memo ="";
   if ($otherPay){	 
	 foreach($otherPay as $row){
		 $memo = $row->memo;
	?> 
   <div class="block">
        <div class="content">
            
	<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="span8">
                    <input type="hidden" id="masterID" value="<?php echo $row->ID; ?>" />
				<input disabled="disabled" type="text" value="<?php echo $row->formNo; ?>" class="span12" />             
            </div><!-- span -->
            </div><!-- control row -->
            
            
            <div class="controls-row">
         	<div class="span4"><?php echo $this->lang->line('date') ?></div>
         	<div class="span8">
				<input disabled="disabled" type="text" value="<?php echo date(element('dtFormat', $this->session->userdata('logged_in')),strtotime($row->paymentDate)); ?>" class="span12" />             
            </div><!-- span -->
            </div><!-- control row -->
            
             
            
          <div class="controls-row">
         	<div class="span4"><?php echo $this->lang->line('payto'); ?></div>
         	<div class="span8">
               <textarea disabled="disabled" class="span12"><?php echo $row->payTo; ?></textarea>
         	</div>
         </div> <!-- row -->
          <div class="controls-row">
         	<div class="span4"><?php echo $this->lang->line('project') ?></div>
         	<div class="span8">
				<input disabled="disabled" type="text" value="<?php echo $row->project_name; ?>" class="span12" />         
            </div><!-- span -->
            </div><!-- control 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('amountpaid') ?></div>
         	   <div class="span8">
                       <input disabled="disabled" type="text" value="<?php echo number_format($row->amountPaid,2); ?>" class="span12" />
         	</div>
           </div> <!-- row -->
           
             <div class="controls-row">
         	 <div class="span4"><?php echo $this->lang->line('refno') ?></div>
         	   <div class="span8">
                <input disabled="disabled" type="text" value="<?php echo $row->referenceNo; ?>" class="span12" />
         	</div>
           </div> <!-- row -->
            <div class="controls-row">
         	<div class="span4"><?php echo $this->lang->line('paymentmethood') ?></div>
         	<div class="span8">
              <input disabled="disabled" type="text" value="<?php echo $row->methodPay; ?>" class="span12" />
         	</div>
         </div> <!-- row -->
           
            <div class="controls-row">
         		<div class="span4"><?php echo $this->lang->line('location') ?></div>
         		<div class="span8">
               		 <textarea class="span12" disabled="disabled" ><?php echo $row->code.' | '.$row->address; ?></textarea>
         		</div>
            </div> <!-- row -->
        </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('bank') ?></div>
         	<div class="span8">
				<input disabled="disabled" type="text" value="<?php echo $row->bankShortName.' | '.$row->branch; ?>" class="span12" />            
            </div><!-- span -->
            </div><!-- control row -->
             <div class="controls-row">
         	<div class="span4"><?php echo $this->lang->line('acctno') ?></div>
         	<div class="span8">
				<input disabled="disabled" type="text" value="<?php echo $row->bankAccountNo; ?>" class="span12" />            
            </div><!-- span -->
            </div><!-- control row -->
            <div class="controls-row">
         	<div class="span4"><?php echo $this->lang->line('balance') ?></div>
         	<div class="span8">
				<input disabled="disabled" type="text" value="<?php echo $row->currentBalance; ?>" class="span12" />             
            </div><!-- span -->
            
            </div><!-- control row -->
            
           
          
        </div><!-- grid block 1-->
      </div><!-- scCol -->
    </div><!-- row-fluid scRow-->
    
    </div><!-- content -->
      
    </div><!-- block-->
    <?php } } ?>
    
    
    
      
	
	<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 fr">
                    	<li><a class="block_toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                        	<span class="i-arrow-down-3"></span></a></li>
                    </ul> 
                             <ul class="buttons fr">
                                <li><a href="#" title="Add New"</a></li>
                                <li><a href="#trInfos" onclick="addnewrow()" title="Add New"><span class="i-plus-2"></span></a></li>
                            </ul>
                 	
                     
             	 </div><!-- head -->
          <div class="content np">
   				<table id="listDetails" 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="amount"><?php echo $this->lang->line('amount') ?></th>
                        <th><?php echo $this->lang->line('tax') ?></th>
                        <th class="amount"><?php echo $this->lang->line('taxAmount') ?></th>
                        <th class="amount"><?php echo $this->lang->line('amountIncludeTax') ?></th>
                        <th><?php echo $this->lang->line('action') ?></th>
                    </tr>
                </thead>
                <tbody>
                                 <?php
				 $tAllocated=0;
				 $t_taxAmount=0;
				 $tpaid=0;
                                 $lastrow = 0;
				 if($pdetails) {
				 foreach($pdetails as $rowD){
                                      if ($lastrow < $rowD->lineNo)
                                            $lastrow = $rowD->lineNo;
					     $tAllocated += $rowD->amountExcludedTax; ;
						 $t_taxAmount+= $rowD->taxAmount;
				 		 $tpaid += $rowD->amountIncludedTax;
					 ?>
                     <tr>
                         <td><?php echo $rowD->lineNo; ?></td>
                    	<td><?php echo $rowD->acctCode . ' | '. $rowD->acctName ;?></td>
                        <td><?php echo $rowD->itemdescription; ?></td>
                        <td class="amount"><?php echo number_format($rowD->amountExcludedTax,2); ?></td>
                        <td><?php echo $rowD->code . ' | '. $rowD->taxPercentage; ?></td>
                        <td class="amount"><?php echo number_format($rowD->taxAmount,2); ?></td>
                        <td class="amount"><?php echo number_format($rowD->amountIncludedTax,2); ?></td>
                       <td>
                         <button onclick="editRowPayment(this)" data-taxcode="<?php echo $rowD->code?>" data-taxpercentage="<?php echo $rowD->taxPercentage?>" data-taxid="<?php echo $rowD->taxid?>" data-accid= "<?php echo $rowD->accountID?>" data-myid="<?php echo $rowD->itemID; ?>" class="btn btn-mini"><i class="icon-pencil"></i></button>
                         <button onclick="deleteRowPdetails(this)" data-myid="<?php echo $rowD->itemID; ?>" class="btn btn-mini btn-danger"><i class="icon-trash icon-white"></i></button>
                        </td>
                    </tr>
                     <?php }
					 } else {?>
                         <div class="alert alert-error">
                     No pmts found ...
    </div>
                     <?php }?>
                <tr id="trInfospmt" data-currentRow="<?php echo $lastrow; ?>">
                	<td colspan="8">
                	    <div id="msg_div2" 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><!-- 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 class="controls-row">
                      <div class="span12">
                             <textarea disabled="disabled" placeholder="<?php echo $this->lang->line('memo') ?>" style="height: 170px;" id="memo" class="span12"><?php echo $memo; ?></textarea>
                      </div><!-- span -->
                   </div><!-- row control -->
                  
              </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 amount" value="<?php echo number_format($tAllocated,2);?>" type="text" placeholder="0" 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" value="<?php echo number_format($t_taxAmount,2); ?>" class="span12 amount" type="text" disabled="disabled"  placeholder="0">
                      </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" value="<?php echo number_format($tpaid,2); ?>" class="span12 amount" type="text" placeholder="0">
                      </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 amount" type="text" placeholder="0">
                      </div>
                  </div><!-- row control -->
                 
              </div>    
        </div><!-- grid block 1-->
      </div><!-- scCol -->
    </div><!-- row-fluid scRow-->
</div><!-- grid 1 -->
</div><!-- wrap -->
</div><!-- content -->
                    
                    
   