<script type="text/javascript">
   $(document).ready(function() {
        $('select').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();
            });
        });
    });

    function enable_lumpsum(id) {
        if (document.getElementById(id).disabled == true) {
            document.getElementById(id).disabled = false;
        } else {
            document.getElementById(id).disabled = true;
        }
        return true;
    }
    function checkOption(opt) {
        if (opt == 1) {
            $("#rowSale").attr("style", "display:none");
            $("#rowLumpSum").attr("style", "display:block");
            $("#rowAcc").attr("style", "display:none");
             $("#rowPeriode").attr("style", "display:none");
            $("#rowWakafAcrual2").attr("style", "display:none");
            $("#rowWakafAcrual3").attr("style", "display:none");

        } else 
        if (opt == 2){
            $("#rowSale").attr("style", "display:block");
            $("#rowAcc").attr("style", "display:block");
            $("#rowLumpSum").attr("style", "display:none;");
            $("#rowPeriode").attr("style", "display:block");
            $("#rowWakafAcrual2").attr("style", "display:none");
            $("#rowWakafAcrual3").attr("style", "display:none");


        }else
        if (opt == 3){
            $("#rowSale").attr("style", "display:none");
            $("#rowAcc").attr("style", "display:none");
            $("#rowLumpSum").attr("style", "display:none;");
            $("#rowPeriode").attr("style", "display:none");
            $("#rowWakafAcrual2").attr("style", "display:block");
            $("#rowWakafAcrual3").attr("style", "display:block");
            $("#accrualPercentage").val("");
             $("#wakafAcrualAmount").val("");
             $.ajax({
                type: "POST",
                url: "<?php echo base_url() ?>wakafsetup/getwakafAcrualAmount",
                success: function(data) {
                    if(data>0){
                       $("#wakafAcrualAmount").val(accounting.formatNumber(data,2));
                        $("#accrualPercentage").removeAttr("readonly");
                   }else{
                       $("#accrualPercentage").attr("readonly","readonly");
                       msg ("alert", "No sale amount allocated !!!");
                   }
                        
                }
             });
             
        }
    
        var trInfos = $("#trInfos").clone();
        $("#listDetails > tbody").empty();
         $("#listDetails > tbody").append(trInfos);
         $("#trInfos").attr("data-currentRow",0)
         $("#totalPercentage").attr("data-currentValue",0);
         $("#totalPercentage").val("");
          $("#totalAmountApplied").val("");
          

    }

    function checkCategory(opt) {
        if (opt == 1) {
            $("#specifikDetails").attr("style", "display:none");
        } else {
            $("#specifikDetails").attr("style", "display:block");
        }
    }

    function updateTotal() {
        var som = 0;
        $("#specifikDetailslist > tbody > tr").each(function() {
            var tr = $(this);
            som += 1 * accounting.unformat($(tr).find("td").eq(3).children("input:last-child").val());
            //alert($(tr).find("td").eq(1).text());
        });
        $("#sequence").val(som)
    }
    
    function addNewBene(){
        if (!$("#listCateBene").length) {
    $('' +
            '<tr><td class="span1">' + ($("#trInfos").attr("data-currentRow") * 1 + 1) + '</td>' +
            '<td class="span3" >' +
            '<select class="span12 validate[required]" id="listCateBene""><option value="0"></option>' +
<?php
if ($datatbls) {
    foreach ($datatbls as $row) {
        ?>
            '<option value= "<?php echo $row->ID; ?>"' + ' ><?php  echo str_replace("'", " ", $row->name, $count);
        ?></option>' +
        <?php
    }
}
?>
    '</select></td>' +
            '<td class="span4"><input id="beneDesc" name="beneDesc" class="span12 validate[required]" type="text" placeholder="Description"></td>' +
            '<td class="span1"><input id="percentageValue"  onkeyup="calculateTotalPercentage()" name="percentageValue" class="span12 tar validate[required,custom[number]]" type="text" placeholder=""></td>' +
            '<td class="span2"><input class="span12 tar" id="beneAmnt" disabled  name="beneAmnt" type="text"></td>' +
            '<td class="span1">' +
            '<button class="btn btn-mini btn-primary" onclick="validateRow(this)"  type="button"><span class="icon-ok-circle"></span></button>' +
            '<button id="btnCancel" class="btn btn-mini btn-danger" onclick="delRow(this)" type="button"><span class="icon-remove-circle"></span></button>' +
            '</td>' +
            '</tr>').insertBefore("#trInfos");
    
            $('#listCateBene').select2();
    } else{
    msg ("alert", "Please, do insert the current details before addind new one");
    }
    }
    
function delRow(me){
    var td = me.parentNode;
            var tr = td.parentNode;
            var tBody = tr.parentNode;
            tBody.removeChild(tr);
    }
    
    function deleteRow(me){
         var i = 0;
         var som = 0;
         var p = 0;
         delRow(me);
         $("#listDetails > tbody > tr").each (function(){
             $(this).find("td").eq(0).text(++i);
             p += accounting.unformat($(this).find("td").eq(3).text());
             som +=  accounting.unformat($(this).find("td").eq(4).text());
         });
         $("#totalAmountApplied").val(accounting.formatNumber(som,2));
         $("#totalPercentage").val(p);
         $("#trInfos").attr("data-currentRow", i-1);
         $("#totalPercentage").attr("data-currentValue",p);
         $($("#trInfos")).find("td").eq(0).text("Total");
         
    }
    
    function deleteRowSaleAmt(me){
       var tr = $(me).parent().parent();
       var t = accounting.unformat($("#saleAmntAllocated").val()) - accounting.unformat($(tr).find("td").eq(3).text()); 
       $("#saleAmntAllocated").val(accounting.formatNumber(t,2));
       delRow(me);
    }
    
    function getSaleAmount(){
      //  alert($('#saleAcctNo').validationEngine('validate'));
      // if( !$('#saleAcctNo').validationEngine('validate') && $('#wYear').validationEngine('validate') && $('#wFrom').validationEngine('validate') && $('#wTo').validationEngine('validate')){
        $("#iAmtAll").val("");
        $.ajax({
                type: "POST",
                data : {
                    year : $("#wYear").val(),
                    from : $("#wFrom").val(),
                    to : $("#wTo").val(),
                    acctno : $("#saleAcctNo").val()
                },
                url: "<?php echo base_url() ?>wakafsetup/getSaleAmount",
                success: function(data) {
                    if(data>0){
                       $("#iSaleAmt").val(accounting.formatNumber(data,2));
                       msg ("alert-inofs", "");
                   }else{
                       $("#iSaleAmt").val("");
                       msg ("alert", "No value for this periode and this account !!!");
                   }
                        
                }
       });
      //  }
     }
     
     function msg(type, message){
			$("#msg_div p").html(message);
			$("#msg_div").attr("class","alert " + type)
        }
    
    function validateRow(me){
         $.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();
            }); });
            var v = $('#listCateBene').validationEngine('validate') && $('#beneDesc').validationEngine('validate') && $('#percentageValue').validationEngine('validate');
           // if (v) {
                $('' +
                    '<tr><td class="span1" data-cateId="' + $("#listCateBene").val()+ '">' + ($("#trInfos").attr("data-currentRow") * 1 + 1) + '</td>' +
                    '<td>' + $("#listCateBene option:selected").text() + '</td>' +
                    '<td>' + $("#beneDesc").val() + '</td>' +
                    '<td class="tar">' + $("#percentageValue").val() + '</td>' +
                    '<td class="tar">' + $("#beneAmnt").val() + '</td>' +
                    '<td>' +
                       '<button id="btnCancel" class="btn btn-mini btn-danger" onclick="deleteRow(this)" type="button"><span class="icon-remove-circle"></span></button>' +
                        '</td>' +
                    '</tr>').insertBefore("#trInfos");
             $("#trInfos").attr("data-currentRow", $("#trInfos").attr("data-currentRow")*1+1);
             $("#totalPercentage").attr("data-currentValue",  $("#totalPercentage").attr("data-currentValue")*1 +1* $("#percentageValue").val() );
             delRow(me);
    //  }
    }
    
    function getAmountAllocated(){
        var amt = accounting.unformat($("#idAmountAllocated").val());
        
        if($("#bySale").is(":checked")){
            amt = accounting.unformat($("#saleAmntAllocated").val());
        }else
            if($("#byAccrual").is(":checked")){
                amt = accounting.unformat($("#acAmountAllocated").val());
            }
        return amt;
    }
    
    function calculateTotalPercentage(){
        var t = accounting.unformat($("#totalPercentage").attr("data-currentValue")) + accounting.unformat($("#percentageValue").val());
        
        //alert(t);
       var amt = getAmountAllocated();
        if(t>0 && t<=100){
            $("#totalPercentage").val(t);
            var am =  accounting.unformat($("#percentageValue").val()) /100*amt;
            $("#beneAmnt").val (accounting.formatNumber(am,2));
            $("#totalAmountApplied").val(accounting.formatNumber(t*amt/100));
        }else{
             $("#percentageValue").val(100 - $("#totalPercentage").attr("data-currentValue"));
             
             $("#beneAmnt").val (accounting.formatNumber((100 - $("#totalPercentage").attr("data-currentValue"))*amt/100,2));
             $("#totalPercentage").val(100);
             $("#totalAmountApplied").val(accounting.formatNumber(amt,2));
        }
    }
    
    function calculateSalesAmountApplied(){
        var v = (accounting.unformat($("#percentageSaleAllocated").val())/100)*accounting.unformat($("#saleAmount").val());
        $("#saleAmntAllocated").val(accounting.formatNumber(v,2));
        updateAmnt();
    }
    
    function updateAmnt(){
       
         var amt = getAmountAllocated();
         $("#listDetails > tbody > tr").each (function(){
             p = accounting.unformat($(this).find("td").eq(3).text())*amt/100;
              $(this).find("td").eq(4).text(accounting.formatNumber(p,2));
         });
         $("#totalAmountApplied").val(accounting.formatNumber( accounting.unformat($("#totalPercentage").val())*amt/100,2));
         $("#totalPercentage").val();
         $("#totalPercentage").attr("data-currentValue",p);
    }
    
    function savewakaf(){
        var trInfos = $("#trInfos").clone();
        if($('#validate').validationEngine('validate')){
             
             wDetails ='{"rs":[';
             wSaleAcct ='{"rs":[';
             frstime = true;
             firstime = true;
             
            delRow (document.getElementById("totalAmountApplied"));
            $("#listDetails > tbody > tr").each (function(){
                var tr = $(this);
                 var cateID = $(tr).find("td").eq(0).attr("data-cateId");
                 var desc = $(tr).find("td").eq(2).text();
                 var p = accounting.unformat($(tr).find("td").eq(3).text());
                 var amtAl = accounting.unformat($(tr).find("td").eq(4).text());
                
                    str ='';
                    if (firstime){
                     firstime = false;
                     str = '';
                    }else {
                       firstime = false;
                        str = ','; 
                    }
                    wDetails += str + '{"beneficiariesID":"' + cateID + '"' +
                                  ',"description":"' + desc + '"' +
                                  ',"contributionPercentage":"' + p + '"' +
                                  ',"amount":"' + amtAl + '"}';
                
                    });
            wDetails += ']}';
            
            var master ="wakafCenterID=" + $("#waqfCenter").val() + "&waqif=" + $("#waqif").val();
            
            if($("#bySale").is(":checked")){
                master = master + "&option=bySale&year=" + $("#wYear").val() + "&from=" + $("#wFrom").val();
                master = master + "&to=" + $("#wTo").val() + "&wakafAmount=" + accounting.unformat($("#saleAmntAllocated").val());
                delRow (document.getElementById("iSaleAmt"));
                $("#saleAcctList > tbody > tr").each (function(){
                var tr = $(this);
                 var accID = $(tr).find("td").eq(0).attr("data-acctNo");
                 var sAmt = accounting.unformat($(tr).find("td").eq(1).text());
                 var p = accounting.unformat($(tr).find("td").eq(2).text());
                 var amtAl = accounting.unformat($(tr).find("td").eq(3).text());
                
                    st ='';
                    if (frstime){
                     frstime = false;
                     st = '';
                    }else {
                       frstime = false;
                        st = ','; 
                    }
                    wSaleAcct += st + '{"accountID":"' + accID + '"' +
                                  ',"saleAmount":"' + sAmt + '"' +
                                  ',"contributionPercentage":"' + p + '"' +
                                  ',"amount":"' + amtAl + '"}';
                
                    });
            wSaleAcct += ']}';
            master = master + '&wSaleAcct=' + wSaleAcct;
            
            }else
            if($("#byAccrual").is(":checked")) {
                master = master + "&option=accrual&wakafAmount=" + accounting.unformat($("#acAmountAllocated").val());
            }else{
                master = master + "&option=fixedAmount&wakafAmount=" + accounting.unformat($("#idAmountAllocated").val());
            }
            
            master = master + "&wDetail=" + wDetails;
           
             $.ajax({
                type: "POST",
                data : master,
                url: "<?php echo base_url() ?>wakafsetup/saveNewWakaf",
                success: function(data) {
                       if(data>0){
                           $("#btnSubmit").text("Go to Wakaf list");
                           $("#btnSubmit").attr("onclick","");
                           $("#btnSubmit").attr("href","<?php echo base_url() ?>wakafsetup/wakafList");
                           msg ("alert-success", "Wakaf saved !!!");
                       }
                }
             });
        }
        $("#listDetails > tbody").append(trInfos);
    }
    
    function insertRow(){
        if(accounting.unformat($("#iAmtAll").val())>0){
        $('<tr><td data-acctNo="'+ $("#saleAcctNo").val() +'">' + $("#saleAcctNo option:selected").text() + '</td>' +
                '<td class="tar">' + $("#iSaleAmt").val() + '</td>' +
                '<td class="tar">' + $("#iPerAll").val() + '</td>' +
                '<td class="tar">' + $("#iAmtAll").val() + '</td>' +
                '<td><a onclick="deleteRowSaleAmt(this)" class="btn btn-danger btn-mini"><span class="icon-remove-circle"></span></a></td>' 
          ).insertBefore("#trInfosSale");
          $("#saleAmntAllocated").val(accounting.formatNumber(accounting.unformat($("#iAmtAll").val()) + accounting.unformat($("#saleAmntAllocated").val()),2));
         updateAmnt();
        }else{
             msg ("alert", "Amount Incorrect !!!");
        }
    }
    
    function calculateAmtAll(){
        var v = (accounting.unformat($("#iPerAll").val())/100)*accounting.unformat($("#iSaleAmt").val());
        $("#iAmtAll").val(accounting.formatNumber(v,2));
    }
      function calculateAmtAllAcrual(){
        var v = (accounting.unformat($("#accrualPercentage").val())/100)*accounting.unformat($("#wakafAcrualAmount").val());
        $("#acAmountAllocated").val(accounting.formatNumber(v,2));
        updateAmnt ();
    }
    
</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="zakat/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">
            <div class="row-fluid">
                <div class="span12">
                    <?php
                    $hidden = array('order_time' => date('Y-m-d H-i-s'));
                    $attrib = array('id' => 'validate');
                    echo form_open('', $attrib, $hidden);
                    ?>
                    <div class="block">
                        <div class="head">
                            <h2><?php echo $this->lang->line('title') ?></h2>
                            <div class="side fr">
                                <button class="btn" onClick="clear_form('#validate');" type="button">Clear form</button>
                            </div>
                        </div>
                        <div class="content np">    
                            <div class="controls-row">
                                <div class="span2"><?php echo $this->lang->line('waqif') ?></div>
                                <div class="span10">
                                    <select  id="waqif" class="span7 validate[required]">
                                            <option></option>
                                             <?php
                                        if (waqifList) {
                                            foreach ($waqifList as $row) {
                                                ?>
                                                  <option value="<?php echo $row->ID; ?>"> <?php echo $row->name; ?></option>
                                            <?php }
                                    } ?>
                                        </select>
                                </div>                            
                            </div>
                            
                            <div class="controls-row">
                                <div class="span2"><?php echo $this->lang->line('waqfInst') ?></div>
                                <div class="span10">
                                    <select  id="waqfCenter" class="span7 validate[required]">
                                            <option></option>
                                             <?php
                                        if ($waqfcenterList) {
                                            foreach ($waqfcenterList as $row) {
                                                ?>
                                                  <option value="<?php echo $row->ID; ?>"> <?php echo $row->name; ?></option>
                                            <?php }
                                    } ?>
                                        </select>
                                </div>                            
                            </div>
                            
                            <div class="controls-row"> <!-- row 1 -->
                                <div class="span2"><?php echo $this->lang->line('allocation') ?></div>
                                <div class="span3">
                                    <input checked="checked" type='radio' onclick='checkOption(1)' name='alocationOpt' value='1'> <?php echo $this->lang->line('fixedAmount') ?> 
                                </div>   
                                <div class="span3">
                                    <input onclick='checkOption(2)' type='radio' name='alocationOpt' id='bySale' value='2'> <?php echo $this->lang->line('percentageOfSale') ?>
                                     
                                </div>
                                 <div class="span3">
                                    <input onclick='checkOption(3)' type='radio' name='alocationOpt' id='byAccrual' value='3'> <?php echo $this->lang->line('percentageFromPreSetup') ?>
                                     
                                </div> 
                            </div><!-- End Row 1 -->

                            <div id="rowLumpSum" class="controls-row"> <!-- row 2 -->
                                <div class="span2"></div>              
                                <div class="span2 TAR" > <div class="span1 tar" ><?php echo $this->lang->line('amount') ?></div></div>
                                <div class="span4">
                                    <input class="validate[required]" onkeyup="updateAmnt()" type='text' name='idAmountAllocated' id='idAmountAllocated'>    
                                </div>                
                            </div><!-- End Row 2 -->
                            
                           
                            
                            <div id="rowWakafAcrual2" style="display:none;"   class="controls-row"> <!-- row 2 -->
                                <div class="span2"></div>              
                                <div class="span2 TAR" > <div class="TAR" ><?php echo $this->lang->line('wakafAcrualAmount') ?></div></div>
                                <div class="span4 form-inline">
                                    <input class="validate[required] span8 tar" readonly onkeyup="updateAmnt()" type='text' name='wakafAcrualAmount' id='wakafAcrualAmount'>    
                                    <div class="input-prepend input-append span4">
                                            <input class="span8 tar" type="text" onkeyup="calculateAmtAllAcrual()" id="accrualPercentage" />
                                            <span class="add-on">&#37;</span>
                                        </div>
                                </div>                
                            </div><!-- End Row 2 -->
                            
                              <div id="rowWakafAcrual3" style="display:none;"   class="controls-row"> <!-- row 2 -->
                                <div class="span2"></div>              
                                <div class="span2 TAR" > <div class="TAR" ><?php echo $this->lang->line('amountAllocated') ?></div></div>
                                <div class="span4">
                                    <input class="validate[required] span8 tar" readonly onchange="updateAmnt()" type='text' name='acAmountAllocated' id='acAmountAllocated'>    
                                   
                                </div>                
                            </div><!-- End Row 2 -->
                            
                            <div class="controls-row"></div>
                            <div style="display:none;" id="rowPeriode" class="controls-row">
                                <div class="span2"></div>
                                <div class="span2"><?php echo $this->lang->line('periode') ?></div>
                                <div class="span2">
                                    <input id="wYear" type="text" class="span12 validate[required, custom[number]]" placeholder="Year EX:2014" />
                                </div>
                                 <div class="span2">
                                    <input id="wFrom" type="text" class="span12 validate[required, custom[number]]" placeholder="From Ex:2" />
                                </div>
                                 <div class="span2">
                                     <input id="wTo" type="text" class="span12 validate[required, custom[number]]" placeholder="To Ex:3" />
                                </div>
                                <div class="span1">    <button type="button" class="btn " data-toggle="collapse" data-target="#rowAcc"><span class="icon-chevron-down"></span> </button></div>
                            </div>

                            <div id="rowAcc" style="display:none;" class="controls-row content np"> <!-- row 3 -->
                                <div class="span2"></div>              
                               
                                
                                <div class="span9">
                                    <table style="margin-bottom: 5px;" class="table table-bordered" id="saleAcctList">
            <thead>
                <th><?php echo $this->lang->line('saleaccountno') ?></th>
                <th class="tar"><?php echo $this->lang->line('saleAmount') ?></th>
                <th class="tar"><?php echo $this->lang->line('percentage') ?></th>
                <th class="tar"><?php echo $this->lang->line('amtAllo') ?></th>
                <th><?php echo $this->lang->line('action') ?></th>
            </thead>
            <tbody>
                <tr id="trInfosSale">
                    <td>
                         <?php
                                    $preselcurr = '0';
                                    $options = '';
                                    $options[NULL] = '--Please Select--';
                                    foreach ($chargeAccount as $row) {
                                        $options[$row->ID] = '[' . $row->acctCode . '] ' . $row->acctName;
                                    }
                                    $js = ' id="saleAcctNo" onchange="getSaleAmount()" class = "span12 validate[required]"';
                                    echo form_dropdown('chargeAccount', $options, $preselcurr, $js);
                                    ?>    
                    </td>
                    <td><input readonly class="span12 tar" id="iSaleAmt" type="text" /></td>
                    <td>
                    <div class="input-prepend input-append">
                                            <input class="span8 tar" type="text" onkeyup="calculateAmtAll()" id="iPerAll" />
                                            <span class="add-on">&#37;</span>
                                        </div>
                    </td>
                    <td><input readonly class="span12 tar" id="iAmtAll" type="text" /></td>
                    <td><a onclick="insertRow()" class="btn btn-primary"><i class="icon-ok-sign icon-white"></i></a></td>
                </tr>
            </tbody>
        </table>
                                </div>
    </div>
                            </div><!-- End Row 3 -->

                            <div style="display:none;" id="rowSale" class="controls-row content np"> <!-- row 2 -->
                                <div class="span2"></div>              
                                <div class="span2 TAR" ><?php echo $this->lang->line('amountallocated') ?></div>
                                
                                <div  style="margin-top: 5px;" class="span3">
                                    <?php
                                    $data = array(
                                        'placeholder' => 'Amount Aloccated',
                                        'readonly'=> 'true',
                                        'name' => 'saleAmntAllocated',
                                        'id' => 'saleAmntAllocated',
                                        'class' => 'span12 tar',);
                                    echo form_input($data, set_value('contributionPercentageLumpSum'));
                                    ?>      
                                </div> 
                                
                            </div><!-- End Row 2 -->
                              
                        </div>  <!-- content -->
                        </form>
                    </div>  <!-- block -->
                </div>  <!-- span12 -->
          
            
            
            <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('benificiaries') ?></h2>
                                             <ul class="fr 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>
                            <ul class="buttons fr">
                                <li><a href="#trInfos" onclick="addNewBene()" 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('beneCate') ?></th>
                                                        <th><?php echo $this->lang->line('nameDesc') ?></th>
                                                        <th><?php echo $this->lang->line('percentage') ?></th>
                                                        <th><?php echo $this->lang->line('amount') ?></th>
                                                        <th><?php echo $this->lang->line('action') ?></th>
                                                    </tr>
                                                </thead>
                                                <tbody>

                                                    <tr id="trInfos" data-currentRow="0" >
                                                        <td class="span8" colspan="3" style="text-align:right;">
                                                            Total 
                                                        </td>
                                                        <td class="span1">
                                                            
                                                             <div class="input-prepend input-append">
                                                                <input data-currentValue="0" readonly  class="span8 tar" id="totalPercentage" type="text">
                                                                   <span class="add-on">&#37;</span>
                                                            </div>
                                                        </td>
                                                        <td class="span2">
                                                            <input class="span12 tar" id="totalAmountApplied" data-currentAmount="0" readonly type="text" placeholder=" 0,00" />
                                                        </td>
                                                        <td>
                                                            <a class="btn" href="#trInfos" onclick="addNewBene()" title="Add New"><span class="i-plus-2"></span></a>
                                                             
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>     
                                        </div><!-- content -->
                                    </div><!-- grid block 1-->
                                </div><!-- scCol -->
                            </div><!-- row-fluid scRow-->
                            
                           
                             <div class="row-fluid scRow">  
                    <div class="span8 scCol">
                        <div class="block" id="grid_block_4">
                            <div class="content">
                                <div style="padding:0;" class="controls-row">
                                    <div id="msg_div" style="min-height: 22px;" class="alert alert-info"> <p></p> </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="span4 scCol">
                        <div class="block" id="grid_block_4">
                            <div class="content">
                                <div class="controls-row side fr">
                                     <?php
                                        $data = array(
                                            'name' => 'validate',
                                            'style' => 'margin-right:5px;',
                                            'class' => 'btn',
                                            'onClick' => "$('#validate').validationEngine('hide');");
                                        echo form_button($data, 'Hide prompts');
                                        /*$data = array(
                                            'name' => 'mysubmit',
                                            
                                            'class' => 'btn btn-primary');
                                        $js = 'onclick="savewakaf()"';
                                        echo form_submit($data, 'Submit', $js);
                                         * 
                                         */
                                        ?>
                                    <a href="#" class="btn btn-primary" onclick="savewakaf()" id="btnSubmit" >Submit</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- row-fluid scRow-->
                
    </div>  <!-- wrap -->
</div>  
</div> 
