<script>
$(document).ready(function(){
	//$('#journalTable').hide();
	$('select').select2();
	
	addRow();

		

	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
    var oTable = $("#test").dataTable( {
		"iDisplayLength": 10,
		 "aLengthMenu": [5,10,25,50,100],
		 "sPaginationType": "full_numbers", 
		 "aoColumns": [ { 
		 	"bSortable": false }, 
			null, 
			null, 
			null, 
			null, 
			null ]});
	/*		
    $("table.editable td").live('dblclick',function () {        
        
		var fldid = $('td:first', $(this).parents('tr')).text(); 
		var fieldname = $(this).attr('id');
        var eContent = $(this).text();
        var eCell = $(this);
            
        if(eContent.indexOf('<') >= 0 || eCell.parents('table').hasClass('oc_disable')) return false;        
            
        eCell.addClass("editing");        
        eCell.html('<input type="text" value="' + eContent + '"/>');
        
        var eInput = eCell.find("input");
        eInput.focus();
 
        eInput.keypress(function(e){
            if (e.which == 13) {
                var newContent = $(this).val();
                eCell.html(newContent).removeClass("editing");
				var dataToSend= {fldid: fldid, fieldname: fieldname, content: newContent};
			 $.ajax({
  				type: "POST",
  				url: "journaldetails_save",
				data:dataToSend,
  				success: function(){
				alert('Data has been saved...');
				}, 
			 });       
                // Here your ajax actions after pressed Enter button
            }
        });
 
        eInput.focusout(function(){
            eCell.text(eContent).removeClass("editing");            
            // Here your ajax action after focus out from input
			alert('Data not saved...');
        });        
    });

    $("table.editable").on("click",".edit",function(){
        var eRow   = $(this).parents('tr');
        var eState = $(this).attr('data-state');
        
        if(eState == null){
            $(this).html('Save');
            eState = 1;
        }
        
        eRow.find('td').each(function(){            
            if(eState == 1){
                var eContent = $(this).html();                
                if(eContent.indexOf('<') < 0){
					if($(this).index() != 0)
                    $(this).addClass("editing").html('<input type="text" value="' + eContent + '"/>');                    
					if($(this).index() == 1){
					}
                }
            }
            if(eState == 2){
                var eContent = $(this).find('input').val();                                
                if(eContent != null){
                    $(this).removeClass("editing").html(eContent);
                    // Here your ajax action after Save button pressed
			        fldid = $('td:first', $(this).parents('tr')).text(); 
			 		alert(fldid);
					/* $.ajax({
  						type: "POST",
  						url: "menu_save?id=" + fldid,
  						success: function(){
						alert('Data has been saved...');
					}, 
		});   */    // Here your ajax action after delete confirmed
	/*   				
                }
            }
        });
        
     if(eState == 1) 
            $(this).attr('data-state','2');
        else{
            $(this).removeAttr('data-state');
            $(this).html('Edit');
        }
    });
   */ 
    $("table.editable").on("click",".remove",function(){
        rRow = $(this).parents("tr");
        fldid = $('td:first', $(this).parents('tr')).text(); 
        rRow.remove();
    });
    $("table.editable").on("click",".removeline",function(){
        rRow = $(this).parents("tr");
        fldid = $('td:first', $(this).parents('tr')).text(); 
        $("#row_delete").dialog("open");
    });
    function remove_row(row){
        row.remove();
 		$.ajax({
  			type: "POST",
  			url: "journaldetails_delete",
			data:"fldid="+fldid,
  			success: function(){
				alert('Row has been deleted...');
			},
		});       // Here your ajax action after delete confirmed
    }
    $("#row_delete").dialog({
        autoOpen: false,
        resizable: false,        
        modal: true,
        buttons: {
            "Delete": function() {
                remove_row(rRow);
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close");
            }
        }
    });    
});


function saveJournal(){
	var total_credit = 0;
	var total_debit = 0;

	if(checkType() && $("#gstTransForm").validationEngine('validate') && finanEngine('financhk')){
		if(accounting.unformat($('#totalamount').val()) == 0){
			$('#gstTransForm').submit();
		}else{
			alertbox('Debit and Credit amount should be balanced!',3)
		}
	}
}

function checkType(){
	var $singleGST = ["Deemed Supply", "Imported Goods", "Apportionment"];
	if($.inArray( $('#type').val(), $singleGST ) != -1){
		var $taxCnt = 0;
		$('.itemTaxID').each(function(){
			if($(this).val() != 'No-GST' && $(this).val() != ''){
				$taxCnt++;
			}
		});
		if($taxCnt == 2){
			alertbox('You can not select two taxes!',2);
			return false;
		}else{
			return true;
		}
	}else if($('#type').val() == 'Imported Services'){
		var $taxCnt = 0;
		$('.itemTaxID').each(function(){
			if($(this).val() != 'No-GST' && $(this).val() != ''){
				$taxCnt++;
			}
		});
		if($taxCnt != 2){
			alertbox('You need to select both taxes!',2);
			return false;
		}else{
			return true;
		}
	}
	return true;
}


function editclass(obj){
		var acctCodet = obj.value;
//		$('#account_code').val(acctCodet);
        var eRow   = $(obj).parents('tr');
        var eState = $(this).attr('data-state');
        if(eState == null){
            $(this).html('Save');
            eState = 1;
        }
        eRow.find('td').each(function(){            
            if(eState == 1){
               var eContent = $(this).html();                
                if(eContent.indexOf('<') < 0){
					if($(this).index() == 1){
                    	$(this).html(parseInt($('#bill').val()) + 1);
						$('#bill').val(parseInt($('#bill').val()) + 1);
					}
					if($(this).index() == 2){
						$(this).addClass("editing")
					}
					if($(this).index() == 3){
                    	$(this).addClass("editing").html('<input type="text" id="description" value="' + eContent + '"/>');                    
					}
					if($(this).index() == 4){
                    	$(this).addClass("editing").html('<input class="tar" type="text" id="amount_dr" value="' + eContent + '"/>');                    
					}
					if($(this).index() == 5){
                    	$(this).addClass("editing").html('<input class="tar" type="text" id="amount_cr" value="' + eContent + '"/>');                    
					}
					if($(this).index() == 6){
                    	$(this).addClass("editing").html('<button onClick="saveData(this)" class=\"btn-form btn-success-form save\">Save</button>');                    
					}
                }
            }
        });
}

//tax popup
function taxPopup(me) {
		var row = $(me).parents('td');
        $('#popupModal').modal('show');
        $("#_popupTitle").html("Purchase Invoice");
        $("#_popupContent").html('' +
          '<label>Select a tax</label>' +
          '<select style="width:100%;" onchange="calculamountET()" name="listTaxPopup" id="listTaxPopup" >' +
          '<option data-taxcode = "" value="No-GST" data-tax="">No GST</option>'+
			<?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,#listTax").attr("data-taxid",$("#listTaxPopup").val() );
                 row.find("#itemTax,#listTax").val($("#listTaxPopup option:selected").attr("data-tax"));
                 row.find(".itemTaxID").val($("#listTaxPopup option:selected").val());
                 row.find(".itemTaxRate").val($("#listTaxPopup option:selected").attr("data-tax"));
                 row.find("#displayTaxCode,#displayCode").html($("#listTaxPopup option:selected").attr("data-taxcode"));
                 //calculChargeAmount();
                 //calculamountET();
        });
}


function addRow(){
	var rowCount = document.getElementById('oTable').rows.length - 1 ;
	var rowArrayId = rowCount ;
	var toBeAdded = document.getElementById('numberofrows').value;
	if (toBeAdded=='')
	    { toBeAdded = 2; }	
	else if(toBeAdded>100)
	{
	  toBeAdded = 100;
	}
  for (var i = 1; i <= toBeAdded; i++) {
    var rowToInsert = '';
    rowToInsert = "<td class='span2'><select name='accountID[]' id='accountID"+rowArrayId+"' style='width: 250px;'></select></td>";
    $("#oTable tbody").append(
		"<tr><td style='display:none'></td><td>"+ (parseInt(rowArrayId) + 1) +"</td>" +
		rowToInsert +
        "<td class='span9'><input type='text' name='description[]' class='span12 validate[required]'/>"+
        '<td class="span1"><div  class="input-prepend">'+
        						'<input data-taxid="" disabled id="itemTax" onkeyup="calculamountET()" name="itemTax" class="span6 validate[required, custom[number]]" type="text" placeholder="Tax(%)" />'+
        						'<span onclick="taxPopup(this)" style="margin-top:0;" id="displayTaxCode"  class="btn add-on">....</span>'+
        						'<input id="itemTaxRate'+ (parseInt(rowArrayId) + 1) +'" class="itemTaxRate" name="taxRate[]" type="hidden" /><input id="itemTaxID'+ (parseInt(rowArrayId) + 1) +'" class="itemTaxID" name="taxID[]" type="hidden" />'+
        '</div></td>'+
        "<td class='span4 tar'><input type='text' name='taxAmountDr[]' class='span12 validate[required] tar' onFocus = 'changeVal(this)' onBlur='formatme(this); calculate_amount()'/></td>"+
        "<td class='span4 tar'><input type='text' name='taxAmountCr[]' class='span12 validate[required] tar' onFocus = 'changeVal(this)' onBlur='formatme(this); calculate_amount()'/></td>"+        
        "</tr>");

//	$('select').select2();
	rowArrayId = rowArrayId + 1;
  }

  selectoption(toBeAdded);
  	$('select').select2({
		placeholder: 'Please',
	});
	$.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();
        });
    });	
	$("#btnAddnew").hide();
	$("#savedetails").show();
}
function changeVal(me){
	if($('#type').select2('val') != 'Apportionment'){
		var $row = $(me).parents('tr');
		var $taxFromBase = accounting.unformat($('#based_amount').val());
		if($row.find('.itemTaxRate').val()){
			var $rowVal = accounting.formatNumber((($taxFromBase*$row.find('.itemTaxRate').val())/+100),2);
			$row.find('input').index($(me));
			$row.find('td:nth-child(6) input,td:nth-child(7) input').val(accounting.formatNumber(0,2));
			$(me).val($rowVal)
		}
		console.log('um here');
	}
}
function selectoption(toBeAdded){
	var numrows = $("#numberofrows").val();
	var tablerows = $("#oTable > tbody >tr").length;
	var startrows = parseInt($("#oTable > tbody >tr").length) - numrows;
		$.ajax({
			type: "POST",
        	url: '<?php echo base_url();?>gltransaction/accountSearch',
			dataType:"json",
			success: function(content){
				if(content.status == "success") {
					var items = [];
					items.push('<option value="">-Please Select-</option>');
					for ( var i = 0; i < content.message.length; i++) {
					items.push('<option value="'+content.message[i].ID+'">'
						+ (content.message[i].acctCode).substr(0,4) + '-' + (content.message[i].acctCode).substr(4,3) + '-' + (content.message[i].acctCode).substr(7,2) + ' ['+ content.message[i].acctName + ']</option>');
					}
					for (var x = startrows; x < tablerows ; x++) {
 						var rowId = "#accountID" + x;
						jQuery(rowId).empty();
						jQuery(rowId).append(items.join('</br>'));
					}
				} else {
					$("#error").html('<p>'+content.message+'</p>');
				}
					return false;
			}
		});
}

function savedetails(){
	if($("#amountcredit").val() != $("#amountdebit").val()){ 
		alert('<?php echo $this->lang->line('message5') ?>');
		$('#description').focus();
	}else{
		var amountcredit = $("#amountcredit").val();
		var amountdebit = $("#amountdebit").val();
		var totalamount = $("#totalamount").val();
		var journalNo = $('#journal_number').val();
		var numrows = $("#numberofrows").val();
		var effdate = $('#effdate').val();
		var tablerows = $("#oTable > tbody >tr").length;
		//var startrows = parseInt($("#oTable > tbody >tr").length) - numrows; issa
		var rows = $("#oTable").dataTable().fnGetNodes();
         //s  alert(tablerows);
//	var accountno =$("#acctCode option:selected").val();
		for (var i = 0; i < tablerows ; i++){
                   
			if($(rows[i]).find("td:eq(2) option:selected").val()){
				postData = {
					'sequence' : $(rows[i]).find("td:eq(1)").html(),
					'journalNo' : journalNo,
					'acctCode' : $(rows[i]).find("td:eq(2) option:selected").val(),
					'description' : $(rows[i]).find("td:eq(3) input").val(),
					'amountdr' : $(rows[i]).find("td:eq(4) input").val(),
					'amountcr' : $(rows[i]).find("td:eq(5) input").val(),
					'amountcredit' : amountcredit,
					'amountdebit' : amountdebit,
					'totalamount' : totalamount,
					'effdate' : effdate,
				};
//				alert($(rows[i]).find("td:eq(2) option:selected").val());
 				$.ajax({
  					type: "POST",
  					dataType: "json",
					url: "<?php base_url()?>journaldetails_insert",
					data: postData ,
	  				async: false,
					success: function(content){
						if(content.status == "success") {
							
						}
					}
				});  
			}
		}
                var urls = "<?php echo base_url();?>glreports/unpostedjournal";
					window.location = urls;
	}
      
}

function calculate_amount(){
	var $flag = true;
	if($('#type').select2('val') == 'Apportionment'){
		$('#oTable tbody tr').each(function(){
			if($flag){
				var $totalTax = accounting.unformat($(this).find('td:nth-child(6) input').val())+accounting.unformat($(this).find('td:nth-child(7) input').val());
				if($totalTax && $('.itemTaxRate').val()){
					$('#based_amount').val(accounting.formatNumber((($totalTax*100)/accounting.unformat($('.itemTaxRate').val())),2));
					$flag = false;
				}
			}
		});
	}
	var numrows = $("#numberofrows").val();
	var tablerows = $("#oTable > tbody >tr").length;
	var startrows = parseInt($("#oTable > tbody >tr").length) - numrows;
	var total_credit = 0;
	var total_debit = 0;
	var taxFromBase = accounting.unformat($('#based_amount').val());
	
	for (var i = 0; i < tablerows ; i++){
		var row = $('#oTable > tbody > tr:eq(' + i + ')');
		var rowVal = 0;
		if(row.find('td:nth-child(7) input').val() && row.find('td:nth-child(7) input').val() != '0.00'){
			rowVal = 0;
			if(!row.find('.itemTaxRate').val()){
				rowVal = row.find('td:nth-child(7) input').val();
			}else{
				rowVal = ((taxFromBase*row.find('.itemTaxRate').val())/100);
			}
			if($('#type').select2('val') != 'Apportionment'){
				row.find('td:nth-child(7) input').val(accounting.formatNumber(rowVal,2));
				total_credit = total_credit + rowVal;				
			}else{
				total_credit = total_credit + accounting.unformat(row.find('td:nth-child(7) input').val());
			}
		}
		if(row.find('td:nth-child(6) input').val() && row.find('td:nth-child(6) input').val() != '0.00'){
			rowVal = 0;
			if(!row.find('.itemTaxRate').val()){
				rowVal = row.find('td:nth-child(6) input').val();
			}else{
				rowVal = ((taxFromBase*row.find('.itemTaxRate').val())/100);
			}
			if($('#type').select2('val') != 'Apportionment'){
				row.find('td:nth-child(6) input').val(accounting.formatNumber(rowVal,2));				
				total_debit = total_debit + rowVal;				
			}else{
				total_debit = total_debit + accounting.unformat(row.find('td:nth-child(6) input').val());
			}
		}
	}
	console.log(total_debit+'<->'+total_credit);
	$("#amountcredit").val(accounting.formatNumber(total_credit,2));
	$("#amountdebit").val(accounting.formatNumber(total_debit,2));
	$("#totalamount").val(accounting.formatNumber((total_debit - total_credit),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()."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 -->              
<form id="gstTransForm" action="<?php echo base_url() ?>gltransaction/gstjournal" method="post">   
		<div class="content" id="grid_content_1">
			<div class="block">
				<div class="head">
					<h2><strong><?php echo $this->lang->line('title') ?></strong></h2>
				</div><!-- head -->   
				<div class="row-fluid scRow">                
					<div class="span8 scCol">             
						<div class="block" id="grid_block_1">                  
							<div class="content np">
								<div class="controls-row">
									<div class="span4"><?php echo $this->lang->line('FormNo') ?></div>
									<div class="span4">
										<input class="span8 validate[required]" id="formNo" name="formNo" value='<?php echo "$formNo"; ?>' style="color:red;"   type="text" placeholder="Form number ..."><input  class="span4"   type="text" placeholder="Serial" disabled="disabled">
									</div>
								</div> <!-- row -->
								<div class="controls-row"><!-- Row 1-->
									<div class="span4"><?php echo $this->lang->line('type');?></div>
									<div class="span8">
										<select class="span5 validate[required]" id="type" name="type">
                                            <option></option>
                                            <?php
                                            if ($type) {
                                                foreach ($type as $row) {
                                                    ?>
                                                    <option value="<?php echo $row; ?>"> <?php echo $row; ?></option>
												<?php }
												}
											?>
                                        </select>
                                    </div>
								</div><!-- End Row 1-->
								<div class="controls-row"><!-- Row 2-->
									<div class="span4"><?php echo $this->lang->line('vendorCustomerName');?></div>
									<div class="span8">
										<?php 								
										$data = array(
										'name'=>'vendor_cust_name', 
										'id'=>'vendor_cust_name', 
										'class'=>'span5 validate[required,maxSize[100]]',); 
										echo form_input($data, set_value('vendor_cust_name')); ?>
									</div>
								</div><!-- End Row 2-->
								<div class="controls-row"><!-- Row 2-->
									<div class="span4"><?php echo $this->lang->line('gstNumber');?></div>
									<div class="span8">
										<?php 								
										$data = array(
										'name'=>'gst_number', 
										'id'=>'gst_number', 
										'class'=>'span5 validate[required,maxSize[100]]',); 
										echo form_input($data, set_value('gst_number')); ?>
									</div>
								</div><!-- End Row 2-->
								<div class="controls-row"><!-- Row 2-->
									<div class="span4"><?php echo $this->lang->line('description');?></div>
									<div class="span8">
										<?php 								
										$data = array(
										'name'=>'Description', 
										'id'=>'Description', 
										'class'=>'span12 validate[required,maxSize[100]]',); 
										echo form_input($data, set_value('Description')); ?>
									</div>
								</div><!-- End Row 2-->
								<div class="controls-row"><!-- Row 3 -->
									<div class="span2"><?php echo $this->lang->line('date');?></div>
									<div class="span2">
										<?php 								
										$data = array(
										'type'=>'text',
										'name'=>'date', 
										'id'=>'date', 
										'class'=>'span12 datepicker2 financhk',); 
										echo form_input($data, date("d-m-Y")); ?>
									</div>
									<div class="span2"><?php echo $this->lang->line('referrence');?></div>
									<div class="span5">
										<?php 								
										$data = array(
										'type'=>'text',
										'name'=>'reference', 
										'id'=>'reference', 
										'class'=>'span12  validate[required]',); 
										echo form_input($data, set_value('reference')); ?>
									</div>
								</div><!-- End Row 3 -->
							</div><!-- End Content--><div class="footer">&nbsp;
							<?php /* 
								<div class="side fr">									
									<?php 
										$data = array(
										'name'=>'hidePrompt', 
										'id'=>'hidePrompt', 
										'class'=>'btn-form btn-warning-form',
										'onClick'=>"$('#validate').validationEngine('hide');"); 
										echo form_button($data,'Hide prompts');
										$data = array(
										'name'=>'mysubmit', 
										'id'=>'mysubmit', 
										'class'=>'btn-form btn-success-form');
										$js = 'onClick="saveJournal()"';
										echo form_button($data,$this->lang->line('next'), $js);
									?>						
								</div>*/ 	?>
							</div>    <!-- footer -->                                 
						
						</div>  <!-- Block grid-->                                  
					</div>     <!-- span8 -->                               
					<div class="span4 scCol">
						<div class="block" id="grid_block_2">
							<div class="content np">
								<div class="controls-row"><!-- Row 4-->
									<div class="span5"><?php echo $this->lang->line('basedAmount');?></div>
									<div class="span7">
										<?php 								
										$data = array(
										'name'=>'based_amount', 
										'id'=>'based_amount', 
										'onBlur'=>'formatme(this)',
										'class'=>'input-small tar  validate[required]',); 
										echo form_input($data); ?>
									</div>
								</div><!-- End Row 4-->
								<div class="controls-row"><!-- Row 4-->
									<div class="span5"><?php echo $this->lang->line('controlamount');?></div>
									<div class="span7">
										<?php 								
										$data = array(
										'name'=>'totalamount', 
										'id'=>'totalamount', 
										'disabled'=>'disabled',
										'class'=>'input-small tar',); 
										echo form_input($data); ?>
									</div>
								</div><!-- End Row 4-->
                	<div class="controls-row"><!-- Row 4-->
                    	<div class="span5"><?php echo $this->lang->line('amount_dr_ttl');?></div>
                   		<div class="span7">
                            	<?php 								
								$data = array(
									'name'=>'amountdebit', 
									'id'=>'amountdebit', 
									'disabled'=>'disabled',
									'class'=>'input-small tar',); 
								echo form_input($data); ?>
                  		</div>
                 	</div><!-- End Row 4-->
                	<div class="controls-row"><!-- Row 4-->
                    	<div class="span5"><?php echo $this->lang->line('amount_cr_ttl');?></div>
                   		<div class="span7">
                            	<?php 								
								$data = array(
									'name'=>'amountcredit', 
									'id'=>'amountcredit', 
									'disabled'=>'disabled',
									'class'=>'input-small tar',); 
								echo form_input($data); ?>
                  		</div>
                 	</div><!-- End Row 4-->
				</div><!-- End Content-->
				<div class="footer">
					<div class="side fr">
						<div class="btn-group"></div>
					</div>
				</div>    <!-- footer -->                                        
			</div> <!-- Block grid-->                                   
		</div> <!-- scCol-->                                   
    </div> <!-- row-fluid scRow-->                                
	<div class="row-fluid scRow">                            
	  <div class="span12 scCol">
	 	<div class="block" id="journalTable">
        	<div class="head">
            	<h2><?php echo $this->lang->line('details') ?></h2>
                	<div class="side fr" id="btnAddnew">
						<input id="numberofrows" type="text" style="display:none;" class="input-mini tar" value="2" style="width:15px"> <?php echo $this->lang->line('row') ?>
						&nbsp;						
                 		<button id="addnew" onclick="addRow()" class="btn-icon btn-mini btn-warning-form" type="button" title="<?php echo $this->lang->line('addnew') ?>">
							<i class="i-plus-2"></i>
						</button>
							
                	</div>                                        
			</div>
                            	<?php 								
								$data = array(
									'name'=>'bill', 
									'id'=>'bill', 
									'value'=> 1,
									'type' => 'hidden'); 
								echo form_input($data); ?>
          	<div class="content np table-sorting">
            	<table cellpadding="0" cellspacing="0" width="100%" id="oTable" class="editable">
                	<thead>
                    <tr>
            			<th style="display:none"></th>
            			<th width="5">#</th>
            			<th><?php echo $this->lang->line('acctCode')?></th>
            			<th><?php echo $this->lang->line('description')?></th>
            			<th><?php echo $this->lang->line('tax')?></th>
            			<th class="tar"><?php echo $this->lang->line('amount_dr')?></th>
            			<th class="tar"><?php echo $this->lang->line('amount_cr')?></th>
            		</tr>
        			</thead>
       				 <tbody>
					</tbody>
				</table>                                         
			</div>
            <div class="footer">
            	<div class="side fr">
                	<div class="btn-group">
           			<button id="savedetails" name="mysubmit" value="mysubmit" type="button" onclick="saveJournal()" class="btn-icon btn-success-form" title="<?php echo $this->lang->line('submit') ?>">
                        <i class="i-plus-2"></i> <?php echo $this->lang->line('submit') ?></button>
       				</div><!-- btn group -->      
       			</div><!-- side fr -->      
       		</div><!-- footer -->      
		</div><!-- Block grid-->
	
	</div>
</form>
</div>                        
</div>                        
</div>
    </div> 
</div>
</div>
<div class="dialog" id="row_delete" style="display: none;" title="<?php echo $this->lang->line('delete') ?>?">
    <p><?php echo $this->lang->line('message6') ?></p>
</div>   
