<style type="text/css">
    .amount{
        text-align: right;
    }
    .btn-group button {
        height:30px;}
    .input-append select {
        width:140px;}

    #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 #trInfosCharge td .row-fluid .controls-row .span3 {
        font-weight: bold;
    }
</style>
<script type="application/javascript">

    $(document).ready(function(){

        $('select').select2();
        /*****GST Register supplier's color change start******/    
        function format(state) {
        var text = state.text.match(/\(GST\)/g);
        var modTxt = state.text.replace("(GST)","");
        if(text != null)  return '<span style="color:#85c420;">'+modTxt+"</span>";
        else              return modTxt;
        }
        $("#supplier").select2({
        formatResult: format,
        formatSelection: format,
        escapeMarkup: function(m) { return m; }
        });
        /*****GST Register supplier's color change end******/
        $.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();
        });
        });	
        jQuery('.datepicker2').datepicker({
            dateFormat : 'dd-mm-yy',
            changeMonth : true,
            changeYear : true
        }); 


        getTotal();
    });

function getLatestItemPrice(){
     $.ajax({
            type: "POST",
            data : {
                option :'purchase',
                itemID : $("#itemComboList").val(),
                datePrice : '<?php echo date('Y-m-d'); ?>',
                supplierID : '-1'
            },
            url: "<?php echo base_url() ?>aptransaction/getUmList",
            dataType:'JSON',
            success: function(data) {
                //console.log(data['unitPrice'][0].price);
                
                if(data['unitPrice']){
                    $("#itemunitprice").val(accounting.formatNumber(data['unitPrice'][0].price,2));
                }
                
                var option = '<option value="'+data['items'][0].unitOfMeasureID+'" >'+data['items'][0].umCode+'</option>';
                if(data['umConv']){
                    for(i = 0; i<data['umConv'].length; i++){
                        option += '<option value="'+data['umConv'][i].from_um+'">'+data['umConv'][i].fromCode+'</option>';
                    }
                }
                $('.umConvList').text('').append('<select class="umIDlist span12">'+
                                        option+
                                        '</select>');
                $('.umConvList select').select2();
            }
      });
}

    function loadSupplierDefaultValue(me){
var companyCurrID = <?php echo element('compCurrency', $this->session->userdata('logged_in'))?>;
		$('#currency').attr("value",'');
		$('#exchange_rate').attr("value",'');
		var effdate = $('#createdDate').val();
		var postData = {
					supplier : $("#supplier option:selected").val(),
					effdate : effdate
				};
		$.ajax({
			type: "POST",
			data: postData,
			url: "<?php echo base_url() ?>supplier/loadSupplierDefaultValue",
			success: function(data) {
				var result = eval ("(" + data + ")"); 
				$('#currency').attr("value",result.records[0].currency);
				$('#currency').attr("data-ID",result.records[0].currencyID);
				if(result.records[0].currencyID == companyCurrID ){
					$('#exchange_rate').attr("value",accounting.formatNumber('1',5));
				}else{
					$('#exchange_rate').attr("value",accounting.formatNumber(result.records[0].exchangeRate,5));
				}
				$('#termstatus').val(result.records[0].termsID).change();
				$.ajax({
					type: "POST",
					data: "term="+ result.records[0].termsID,
					url: "<?php echo base_url() ?>term/getTermDescription",
					success: function(data) {
					$('#termDescription').html(data);
					}
				});
			}
		});
    }

    function refreshSupplier(){
        //<span style="color:#85c420;">'+modTxt+"</span>
        $.ajax({
            type: "POST",
            url: "<?php echo base_url() ?>supplier/refreshSupplier",
            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++)
                    if(resul.records[i].gstRegNo != ''){
                        opt=opt + '<option value="' + resul.records[i].id + '">' + resul.records[i].supplierName + ' (GST)</option>';
                    }else{
                        opt=opt + '<option value="' + resul.records[i].id + '">' + resul.records[i].supplierName + '</option>';
                    }
                $('#supplier').empty();
              $('#supplier').append(opt);
            }
         });
         
    }




    function getItemCode(me){
    $.ajax({
    type: "POST",
    data: "itemCode="+$(me).val(),
    url: "<?php echo base_url() ?>itemSetup/getItemCodes",
    success: function(data) {
    $("#itemcode").attr("data-source", data);
    }
    });
    }

    function refreshTerms(){
    $.ajax({
    type: "POST",
    url: "<?php echo base_url() ?>term/refreshTerms",
    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].termName + '</option>';
    $('#termstatus').empty();
    $('#termstatus').append(opt);
    }
    });

    }
    function displaysItemDefaultValue(){
        $("#itemdes").val($("#itemComboList option:selected").attr("data-desc"));
        $("#itemunitprice").val(accounting.formatNumber($("#itemComboList option:selected").attr("data-price"),2));
        getLatestItemPrice();
    }

    function refreshItems(){
    $.ajax({
    type: "POST",
    url: "<?php echo base_url() ?>po_transaction/refreshItems",
    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 data-price="'+ resul.records[i].price +'" data-description="' + resul.records[i].description + '" value="' + resul.records[i].id + '">' + resul.records[i].name + '[' + resul.records[i].code + ']' + '</option>';
    $('#itemComboList').empty();
    $('#itemComboList').append(opt);
    }
    });

    }

    function refreshProject(){
    $.ajax({
    type: "POST",
    url: "<?php echo base_url() ?>project/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() ?>term/getTermDescription",
			success: function(data) {
			$('#termDescription').html(data);
			}
		});
    }


    function saveBalanceRow(){
        if( $("#parchaseDetailForm").validationEngine('validate')){
            
            getTotal();
            var openingAmount = <?php echo (!empty($openingAmount))?$openingAmount:'0'; ?>;
            var totalAmount = accounting.unformat($('#totalpayable').val())+accounting.unformat($("#itemAmountET").val());
            if(totalAmount > openingAmount){
                alertbox('Total amount does not match Opening balance of Inventory',3);
                return false;
            }

            var receiveID = false;
            if($('#receiveID').val() != ''){
                receiveID = $('#receiveID').val();
            }
            var data = {
                        receiveID : receiveID,
                        itemID : $('#itemComboList').select2('val'),
                        itemdescription: $("#itemdes").val(),
                        unitPrice: accounting.unformat($("#itemunitprice").val()),
                        umID:$('.umIDlist').select2('val'),
                        quantity : $("#itemqte").val(),
                        amount: accounting.unformat($("#itemAmountET").val()),
                        totalAmount: accounting.unformat($("#itemAmountET").val()),
                        exchangeRate : 1,
                        currencyID : 1,
                        lineNo:  $("#listDetails").attr("data-currentRow") *1 +1,
                        locationID: $('#itemLoc').select2('val')
                    };
            $.ajax({
                type: "POST",
                data: data,
                url: "<?php echo base_url() ?>inventory/inventoryBalanceAdd",
                dataType:'JSON',
                success: function(data) {
                    $('#receiveID').val(data);
                    $(''+
                    '<tr><td>' + ( $("#listDetails").attr("data-currentRow") *1 +1) + '</td>' +
                    '<td>' +  $("#itemComboList option:selected").text() + '</td>'+
                    '<td>' + $("#itemdes").val() + '</td>'+
                    '<td class="amount">' + accounting.formatNumber( $("#itemunitprice").val(),2) + '</td>'+
                    '<td>' + $(".umIDlist").select2('data').text + '</td>'+
                    '<td class="amount">' + $("#itemqte").val() + '</td>'+
                    '<td class="amount">' + accounting.formatNumber($("#itemAmountET").val(),2) + '</td>'+
                    '<td >' + $("#itemLoc option:selected").text() + '</td>'+
                    '<td>'+
                    '<button onclick="editRow(this)" data-recvid="'+data+'" data-itemid="'+$("#itemComboList").select2('val')+'" data-umid="'+$(".umIDlist").select2('val')+'" data-locationid="'+$("#itemLoc").select2('val')+'" name="edit" type="button" class="btn-icon btn-mini btn-warning-form edit" title="Edit"><span class="i-pen"></span></button>\
                    <button onclick="deleteBalanceRow(this)" data-recvid="'+data+'" class="btn-icon btn-mini btn-danger-form" type="button"><i class="i-trashcan"></i></button>'+
                    '</td>'+
                    '</tr>'
                    ).insertBefore( "#trInfos" );
                    $("#listDetails").attr("data-currentRow", $("#listDetails").attr("data-currentRow") *1 +1);
                    $("#btnCancel").trigger("click");
                    $("#calcul").trigger( "click" );
                    msg (1,"alert alert-success","Details successfully saved");

                    getTotal();
                } //end function
            });//end ajax
        }else {
            msg (1,"alert alert-error", "Data incorrect or invalid ...");
        }
    }
    
    function deleteBalanceRow(me){
        $('#popupModal').modal('show');
        $("#_popupTitle").html("Confirm delete");
        $("#_popupContent").html("Your are about to delete this row. <br/> Click on ok to confirm");

        $('#_popupFooter').empty();
        $('#_popupFooter').append('<button class="btn-form btn-success-form" id="detButton">Ok</button>' +
                                '<button class="btn-form btn-danger-form" id="canb">Cancel</button>');
        $("#_popupTitle").html("Confirm delete");
        $( "#canb" ).click(function() {
            $('#popupModal').modal('hide');
        });
        $( "#detButton" ).click(function() {
            $('#popupModal').modal('hide');
            $.ajax({
                type: "POST",
                data: "detailsId="+ $(me).attr("data-recvID"),
                url: "<?php echo base_url() ?>inventory/inventoryBalanceDelete",
                success: function(data) {
                    msg (1,"alert alert-success","Data deleted succesfuly ...");
                    var td=me.parentNode;
                    var tr=td.parentNode;
                    var tBody=tr.parentNode;
                    tBody.removeChild(tr);
                    getTotal();
                }
            });
        });

        $( "#calcul" ).trigger( "click" );
    }

    /*	function getItemDetails(me){
    $("#itemname").val("");
    $("#itemdes").val("");
    $.ajax({
    type: "POST",
    data: "code="+ me.value,
    url: "<?php echo base_url() ?>itemsetup/getItemDetails",
    success: function(data) {
    if(data!="item Not found"){
    var resul = eval ("(" + data + ")");
    $("#itemname").val(resul.description);
    $("#itemdes").val(resul.name);
    $("#itemTax").val(resul.tax);
    $("#itemTax").attr("data-taxid",resul.taxID);
    $("#displayTaxCode").text(resul.taxcode); 
    }else{
    $("#itemdes").attr("placeholder",data);
    $("#itemname").attr("placeholder",data);
    $("#itemTax").val("");
    $("#itemTaxAmount").val("");
    $("#itemAmountIT").val("");
    $("#itemTax").attr("data-taxid",""); 
    $("#displayTaxCode").html("");
    }
    }
    });
    } */

    function calculamountET(){
        if($("#totalamount").val()=="NaN"){
            $("#totalpayable").val("0");
        }

        var j_itemAmountET =accounting.unformat($("#itemunitprice").val())*accounting.unformat($("#itemqte").val());
        $("#itemAmountET").val(accounting.formatNumber(j_itemAmountET,2));
    }

    function calculunitprice(){
        $("#itemunitprice").val(accounting.unformat($("#itemAmountET").val())/accounting.unformat($("#itemqte").val()))
    }

    function update(me){
        var tr = $(me).parents('tr');
        getTotal();
        var openingAmount = <?php echo $openingAmount; ?>;
        var totalAmount = accounting.unformat($('#totalpayable').val())+accounting.unformat($("#itemAmountET").val());
        if(totalAmount > openingAmount){
            alertbox('Total amount does not match Opening balance of Inventory',3);
            return false;
        }

        var data = {
                        receiveID : $(me).attr('data-recvid'),
                        unitPrice: accounting.unformat($("#itemunitprice").val()),
                        quantity : $("#itemqte").val(),
                        amount: accounting.unformat($("#itemAmountET").val()),
                        totalAmount: accounting.unformat($("#itemAmountET").val()),
                    };

        $.ajax({
            type: "POST",
            data: data,
            url: "<?php echo base_url() ?>inventory/updateBalance",
            success: function(data) {
                
                msg (1,"alert alert-success","Data updated succesfuly ...");
                tr.find('td:nth-child(4)').removeClass('span3').html(accounting.formatNumber($("#itemunitprice").val(),2));
                tr.find('td:nth-child(6)').removeClass('span3').html($("#itemqte").val());
                tr.find('td:nth-child(7)').removeClass('span3').html(accounting.formatNumber($("#itemAmountET").val(),2));
                tr.find('td:nth-child(9) button:nth-child(1) span').addClass('i-pen').removeClass('i-checkmark-3');
                tr.find('td:nth-child(9) button:nth-child(1)').attr('onclick','editRow(this)');
                getTotal();
            }
        });
    }

    function adjustUm(me){
        var tr = $(me).parents('tr');
        var balItm = accounting.unformat(tr.find('td:nth-child(6) input').val());
        var totalAmount = accounting.unformat(tr.find('td:nth-child(7) input').val());
        tr.find('#itemunitprice').val(totalAmount/balItm);
    }

    function editRow(me){
        
        if (!$("#itemqte").length) {
            var tr = $(me).parents('tr');
            tr.find('td:nth-child(4)').addClass('span3').html('<input id="itemunitprice" disabled="disabled" class="span12 tar" type="text" value="'+tr.find('td:nth-child(4)').text()+'" />');
            tr.find('td:nth-child(6)').addClass('span3').html('<input onkeyup="adjustUm(this)" id="itemqte" class="span12 tar" type="text" value="'+tr.find('td:nth-child(6)').text()+'" />');
            tr.find('td:nth-child(7)').addClass('span3').html('<input onkeyup="adjustUm(this)" id="itemAmountET" class="span12 tar" type="text" value="'+accounting.unformat(tr.find('td:nth-child(7)').text())+'" />');
            tr.find('td:nth-child(9) button:nth-child(1) span').removeClass('i-pen').addClass('i-checkmark-3');
            tr.find('td:nth-child(9) button:nth-child(1)').attr('onclick','update(this)');    
        }else{
            msg(1,"alert","Please, do save the current details before adding new one");
        }
    }

    function addRowInvoice(){
        if (!$("#itemComboList").length && !$("#itemqte").length) {
            $(''+
            '<tr><td class="span1">' + ( $("#listDetails tBody tr").length *1) + '</td>' +
            '<td class="span3" >' +
            '<select id="itemComboList" class="span12 validate[required]" onchange="displaysItemDefaultValue()"><option></option>' +
            <?php
            if ($items) {
                foreach ($items as $row) {
                    ?>
                    '<option data-desc= "<?php echo addslashes($row->description); ?>"'+
                    'value="<?php echo $row->ID; ?>"><?php echo addslashes($row->name)." [".$row->itemCode."]"; ?></option>'+
                <?php
                }
            }
            ?>
            '</select>' +
            '</td>' +
            '<td class="span3"><input id="itemdes" name="itemdes" class="span12 validate[required]" type="text" placeholder="Description"></td>'+
            '<td class="span1"><input id="itemunitprice" onkeyup="calculamountET()" name="itemunitprice" class="span12 amount validate[required,custom[number]]" type="text" placeholder="Unit Priece"></td>'+
            '<td class="span1 umConvList"></td>'+
            '<td class="span1"><input id="itemqte" onkeyup="calculamountET()"  name="itemqte" class="span12 amount validate[required,custom[integer]]" type="text" placeholder="Qty"></td>'+
            '<td class="span1"><input id="itemAmountET" name="itemAmountET" onkeyup="calculunitprice()" class="span12 amount validate[required]" type="text" placeholder="Amount (Exclude Tax)"></td>'+
            '<td class="span3" >' +
            '<select id="itemLoc" class="span10 validate[required]" ><option></option>' +
            <?php
            if ($location) {
                foreach ($location as $row) {
                    ?>
                    '<option data-desc= "<?php echo $row->desc; ?>"\
                    value="<?php echo $row->fldid; ?>"><?php echo $row->code." | ".$row->desc; ?></option>'+
                <?php
                }
            }
            ?>
            '</select></td>' +
            '<td class="span1">'+
            '<button class="btn-icon btn-mini btn-success-form" onclick="saveBalanceRow()" type="button"><span class="i-checkmark-3"></span></button>'+
            '<br /><button id="btnCancel" class="btn-icon btn-mini btn-danger-form" onclick="delRowInvoice(this)" type="button"><span class="i-cross"></span></button>'+
            '</td>'+
            '</tr>'
            ).insertBefore( "#trInfos" );
            $("#itemComboList,#itemLoc").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(1,"alert","Please, do save the current details before adding new one");
        }
    }
    function msg(n,type, message){
        $("#msg_div"+n +" p").html(message);
        $("#msg_div"+n).attr("class","alert " + type);
    }
    function getTotal (){
        //$("#impotpayable").val("");

        $("#totalpayable").val("");
        var n =$("#listDetails > tbody > tr").length-1;
        var totalAmount =0;
        var impot = 0;
        var total = 0;
        for (i=0; i<=n; i++) {
            totalAmount= totalAmount + accounting.unformat($('#listDetails > tbody > tr:eq(' + i + ') > td:eq(6)').text())*1;
        }

        $("#totalpayable").val(accounting.formatNumber(totalAmount,2));

    }

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

    function displaysAdress(){
    $("#shiptoDesc").html("");
    $("#shiptoDesc").html($("#shiptoAddress option:selected").attr("data-line1") +
    "&#10;" + $("#shiptoAddress option:selected").attr("data-line2") +
    "&#10;" + $("#shiptoAddress option:selected").attr("data-line3"));
    }



</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('addBalance') ?></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="parchaseDetailForm" action="#">    
                <input id="receiveID" type="hidden" name="receiveID" value="">                
                <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('addBalance') ?></h2>
                                <ul class="buttons">
                                    <li><a class="block_toggle collapsed" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                                            <span class="i-arrow-down-3"></span></a></li>
                                </ul>                                        
                            </div><!-- head -->
                            <div class="content np">
                                <table data-currentRow="0" id="listDetails" cellpadding="0" cellspacing="0" width="100%">
                                    <thead>
                                        <tr> <th width="5px">#</th>
                                            <th><?php echo $this->lang->line('item') ?></th>
                                            <th><?php echo $this->lang->line('itemDesc') ?></th>
                                            <th class="tar"><?php echo $this->lang->line('unitPrice') ?></th>
                                            <th><?php echo $this->lang->line('um') ?></th>
                                            <th class="tar"><?php echo $this->lang->line('balance') ?></th>
                                            <th class="tar"><?php echo $this->lang->line('amount') ?></th>
                                            <th><?php echo $this->lang->line('location') ?></th>
                                            <th><?php echo $this->lang->line('action') ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php 
                                    if(!empty($openingBalance)): 
                                        $i=0;
                                        foreach($openingBalance as $row):
                                    ?>
                                        <tr>
                                            <td><?php echo ++$i; ?></td>
                                            <td><?php echo $row->name; ?></td>
                                            <td><?php echo $row->description; ?></td>
                                            <td class="tar"><?php echo number_format($row->unitPrice,2); ?></td>
                                            <td><?php echo $row->desc; ?></td>
                                            <td class="tar"><?php echo $row->quantityReceived; ?></td>
                                            <td class="tar"><?php echo number_format($row->totalAmount,2); ?></td>
                                            <td><?php echo $row->location; ?></td>
                                            <td>
                                            <?php if($row->quantityReceived == $row->balanceItem): ?>
                                                <button onclick="editRow(this)" data-recvID="<?php echo $row->receiveID; ?>" data-itemID="<?php echo $row->itemID; ?>" data-umID="<?php echo $row->umID; ?>" data-locationID="<?php echo $row->locationID; ?>"  name="edit" type="button" class="btn-icon btn-mini btn-warning-form edit" title="Edit"><span class="i-pen"></span></button>
                                                <button onclick="deleteBalanceRow(this)" data-recvID="<?php echo $row->receiveID; ?>" class="btn-icon btn-mini btn-danger-form" type="button"><i class="i-trashcan"></i></button>
                                            <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php
                                        endforeach;
                                    endif; ?>
                                        <tr id="trInfos">
                                            <td colspan="9">
                                                <div id="msg_div1" 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">
                                        <div class="btn-group">
                                            <button style="margin-right:6px;" onclick="$('#parchaseDetailForm').validationEngine('hide');" class="btn-form btn-warning-form" type="button" name="validat">Hide prompts</button>
                                            <button id="addRow" onclick="addRowInvoice()" class="btn-icon btn-mini btn-warning-form" type="button">
                                                <i class="i-plus-2"></i><?php echo $this->lang->line('addNewItem') ?></button>
                                        </div><!-- btn group -->      
                                    </div><!-- side fr -->      
                                </div><!-- footer -->      
                            </div><!-- content -->
                        </div><!-- grid block 1-->
                    </div><!-- scCol -->                    
                </div><!-- row-fluid scRow-->
                <div class="row-fluid scRow"> 
                    <div class="span5 scCol">
                        <div class="block" id="grid_block_4">
                            <div class="content np">

                                <div class="controls-row">
                                    <div class="span3"><?php echo $this->lang->line('totalAmount') ?></div>
                                    <div class="span8">
                                        <input id="totalpayable" disabled="disabled"  class="span12 amount" type="text" placeholder="0">
                                    </div>
                                </div><!-- row control -->
                            </div>    
                        </div><!-- grid block 1-->
                    </div><!-- scCol -->
                </div>
            </form>
        </div><!-- grid 1 -->
    </div><!-- wrap -->
</div><!-- content -->
</div>
</div>

