
  var yourdata = 'Your Data';
  var Successfully = 'Successfully Save !!';
  var Updated = 'Successfully Updated !!';
  var Deleted = 'Successful has Been Deleted !!';
  var Showing = 'Successful Showing !!';


$(document).ready(function() {
$('#log-form').on('submit', function(e){
$("#signin").attr("disabled", true);
$("#signin").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
e.preventDefault();  
$.post("login.php",$(this).serialize(),function(data){
         if(data=='Bangladesh'){          
             window.location.href = "app/auth/";
        } else {
            $("#signin").attr("disabled", false);                                  
            $(".login-box-msg").html('<span style="text-align:center;color:#ff0000;font-weight: bold;"> <span class="fa fa-info-sign"></span> &nbsp; '+data+' !</span>');
            $("#signin").html('Sign In');
       }
   });
  });
});
function pagecall(dir,viewid,load=false) {
  if (load === false) {
   $(".preloader").css('display','flex');
  }
   $(viewid).load(dir,function() {
    if (load === false) {
     $('.preloader').hide();
    }   // $('.preloader').css('height', 0);
   // setTimeout(function () {$('.preloader').children().hide();}, 200);
   });
}
// $(document).on("contextmenu", function () {return false;});
$(document).on("click",".selin",function () {$(this).select();});
//  $(document).on("input",".inlock",function () {this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');});
$(document).on("input",".nosp",function(){this.value = this.value.replace(/\s/g,'');   });

$(document).on("click","[data-toggle=collapse]",function () {$(this).find("svg").toggleClass("fa-caret-left fa-caret-down");});

$(document).on("click",".actived tr",function () {$(this).addClass('selected').siblings().removeClass('selected');});

let encurrency = Intl.NumberFormat("en-BD", {
    style: "currency",
    currency: "BDT",
});

let bdcurrency = Intl.NumberFormat("bn-BD", {
    style: "currency",
    currency: "BDT",
});

let bdbn = Intl.NumberFormat("bn-BD");

let bden = Intl.NumberFormat("en-BD");

// encurrency.format(1000);

$(document).on("click",".inputselect",function () {$(this).select();});
// $(document).on("input",".inlock",function () {this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');});
$(document).on("input",".inputspace",function(){this.value = this.value.replace(/\s/g,'');   });


  function copy(element) {
   var $temp = $("<input>");
   $("body").append($temp);
   $temp.val($(element).text()).select();
   document.execCommand("copy");
   $temp.remove();
   $(element).parent().prepend("<b id='mm'>Copy Text</b>");
   $("#mm").fadeOut(3000);
  }
  
  function vtype(intype){
     const ttype = {P:"Payment",PD:"D-Payment",SR_DP: "Sales Return F-Charge",R:"Receipt",P_RT_R:"Purchase retrun Receipt",SR_P: "Sales Return Payment",W_R:"Cash Sale Receipt",R_R:"Retail Sale Receipt",R_I:"Ins Sale Receipt",SR_D: "Sales Return Discount",RD:"D-Receipt",C:"Contra",OP:"Opening",SOP:"Opening",JUR:"Journal",EPUR:"Purchase",EPRET:"Purchase Retrun",GPUR:"Purchase",ECSL:"Sale",ERSL:"Sale",INSL:"Ins-Sale", ESRTN: "Sales Retrun",EADJ:"Adjustment",ITRA:"i-Transfer",OPINS:"INS-Opening",INSR:"INS-Receive",INSD:"INS-Discount"};
     return ttype[intype];
  }


  function printMe(divName,bgcss=false) {
    var wview ="toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=650, height=550, left=400, top=50";
    var doc=window.open("","",wview);
    doc.document.open();
    doc.document.write('<!DOCTYPE html><html lang="en"><meta http-equiv="content-type" content="text/html;charset=UTF-8"/>');
    doc.document.write('<head><title>PRINT</title>');
    doc.document.write('<link rel="stylesheet" href="../../plugins/print/css/print.css"><link rel="stylesheet" href="../../plugins/font-awesome/css/all.css"><link rel="stylesheet" href="../../plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css"><link rel="stylesheet" href="../../plugins/icheck-bootstrap/icheck-bootstrap.min.css"><link rel="stylesheet" href="../../dist/css/adminlte.min2167.css?v=3.2.0"><link rel="stylesheet" href="../../dist/css/custom.css">');
    doc.document.write('<style type="text/css">body{ margin:0px;font-style: normal;font-family:SolaimanLipi,Arial, sans-serif;font-style: normal;color:#000;text-decoration:none;} </style>');
    doc.document.write('</head><body onLoad="self.print()">');
    if (bgcss!==false && bgcss!=='header') {$(divName).find(".bgimg").css(bgcss);}else if(bgcss=='header') {$(divName).find("#header").toggleClass('d-none');}
    doc.document.write($(divName).html());
    if (bgcss!==false && bgcss!=='header') {$(divName).find(".bgimg").removeAttr('style');}else if(bgcss=='header') {$(divName).find("#header").toggleClass('d-none');}
    doc.document.write('</body></html>');
    doc.document.close();
    doc.focus();
  }

  function pdfMe(element){ 
    var vou_name= $('#vounameset').val();     

      
 var downdate = new Date().toLocaleString();
  var opt = 
    {
      margin:       1,
      filename:     vou_name+'WellDiv.pdf',
      image:        { type: 'jpeg', quality: 0.98 },
      html2canvas:  { scale: 2},
      jsPDF:        { unit: 'mm', format: 'a4', orientation: 'portrait' },
      pagebreak:    { mode: 'avoid-all', before: '#page2el' }
    };
    html2pdf().set(opt).from($(element).html()).save();   
  }

function BfpdfMe(content) {
  var vou_name = $('#vounameset').val();

  var doc = new jspdf.jsPDF();
  var totalPagesExp = '{total_pages_count_string}';
  doc.autoTable({
    html: content,
    useCss: true,
    styles: {
      font: 'SolaimanLipi',
      fontStyle: 'normal',
    },
    didDrawPage: function (data) {
      var str = 'Page ' + doc.internal.getNumberOfPages()
      // Total page number plugin only available in jspdf v1.0+
      if (typeof doc.putTotalPages === 'function') {
        str = str + ' of ' + totalPagesExp
      }
      doc.setFontSize(10)
      // jsPDF 1.4+ uses getWidth, <1.4 uses .width
      var pageSize = doc.internal.pageSize
      var pageHeight = pageSize.height ? pageSize.height : pageSize.getHeight()
      doc.text(str, data.settings.margin.left, pageHeight - 10)
    }
    // margin: { top: 30 }
  })
  if (typeof doc.putTotalPages === 'function') {
    doc.putTotalPages(totalPagesExp)
  }
  var downdate = new Date().toLocaleString();

  doc.save(vou_name + 'WellDiv Report.pdf');
}


function ExcelMe(tid, type, dl) {
    var elt = document.querySelector(tid);
    var wb = XLSX.utils.table_to_book(elt, { sheet: "sheet1" });
    return dl ?
        XLSX.write(wb, { bookType: type, bookSST: true, type: 'base64' }) :
        XLSX.writeFile(wb, 'Document.' + (type || 'xls'));
}
        
        //// For Sorting Table  ////
        
      $(document).ready(function() {
          $(document).on('click', 'th', function () {
          let stable = $(this).closest('.sort');
          if (stable.length) {
    
          var index = $(this).index(),
              rows = [],
              thClass = $(this).hasClass('asc') ? 'desc' : 'asc';
    
          $(stable).find('th').removeClass('asc desc');
          $(this).addClass(thClass);
    
          $(stable).find('tbody tr').each(function (index, row) {
            rows.push($(row).detach());
          });
    
          rows.sort(function (a, b) {
            var aValue = $(a).find('td').eq(index).text(),
                bValue = $(b).find('td').eq(index).text();
    
            return aValue > bValue
                 ? 1
                 : aValue < bValue
                 ? -1
                 : 0;
          });
    
          if ($(this).hasClass('desc')) {
            rows.reverse();
          }
    
          $.each(rows, function (index, row) {
            $(stable).find('tbody').append(row);
          });
         }
        }); 
      }); 

        //// For Sorting Table  ////