<?php include "top.php"; ?>
<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
	<title>Cable Customer List</title>
	<link rel="stylesheet" type="text/css" href="https://sarmac.b-cdn.net/plugins/datatables/media/css/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="https://sarmac.b-cdn.net/plugins/datatables/media/css/dataTables.bootstrap4.css">
	<link rel="stylesheet" type="text/css" href="https://sarmac.b-cdn.net/plugins/datatables/media/css/responsive.dataTables.css">
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); 

	$action=$_REQUEST['action'];
    
    if($action=='startb'){
        $mnth=$_POST['mnth'];
    $yrs=$_POST['yrs'];
        $delcom=mysqli_query($con,"DELETE FROM tbl_multi WHERE m_done=1");
        $insid=$_POST['multirows'];
            $idss=explode(",",$insid);
         
            foreach($idss as $vals){

                $chks=f(q("SELECT * FROM tbl_multi WHERE m_custid='$vals'"));
                if($chks['m_custid']==''){

                    $res= mysqli_query($con,"INSERT INTO  tbl_multi SET m_custid='$vals',m_done=0,mnth='$mnth',yrs='$yrs'");
                   
                }

            

            }

    }
            

    $cnts=f(q("SELECT COUNT(*) AS cnt FROM tbl_multi"));
    $ks=$cnts['cnt'];


	


	?>
	<style type="text/css">
		
		th{

			font-size: 12px;
		}

		td{

			font-size: 11px;
		}
	</style>
	<style>
/* Pagination with Rounded Borders */
.pagination {
  display: inline-block;
}

.pagination a {
  color: black;
  float: left;
  padding: 8px 16px;
  text-decoration: none;
  border: 1px solid #000;
}

.pagination a.active {
  background-color: #4CAF50;
  color: white;
  border: 1px solid #4CAF50;
}

.pagination a:hover:not(.active) {background-color: #fff;color: #000;}

.pagination a:first-child {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

.pagination a:last-child {
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}

</style>
<script type="text/javascript">function CheckUncheckAlll(){
   var  selectAllCheckbox=document.getElementById("checkUncheckAll");
   if(selectAllCheckbox.checked==true){
    var checkboxes =  document.getElementsByName("rowSelectCheckBox");
     for(var i=0, n=checkboxes.length;i<n;i++) {
      checkboxes[i].checked = true;
      checkboxes[i].onclick();
     }
    }else {
     var checkboxes =  document.getElementsByName("rowSelectCheckBox");
     for(var i=0, n=checkboxes.length;i<n;i++) {
      checkboxes[i].checked = false;
      checkboxes[i].onclick();
     }
    }
   }</script>
<script type="text/javascript">
                         function setids(idss){

                            var eids=document.getElementById('multirows').value;
                            var n = eids.search(idss);
                            //var array=eids.split(",");
                           // alert(array);
                            // var a = array.find(function(element) { 
                            //           return element = idss; 
                            //         }); 
                            // alert(a);
                            if(n=='-1'){

                                eids=eids+','+idss;
                                // document.getElementById('multirow').value=eids; 
                                document.getElementById('multirows').value=eids;  
                            }else{

                                     eids=eids.replace(idss, "");
                                    //  document.getElementById('multirow').value=eids;
                                     document.getElementById('multirows').value=eids; 

                            }


                       } 


                </script>
                <script src="encoder.js">
</script>
<link rel="stylesheet" type="text/css" href="loading.css"/>
<link rel="stylesheet" type="text/css" href="loading-btn.css"/>
<?php include "ajax.php"; ?>
	<div class="main-container">
		<div class="pd-ltr-20 customscroll customscroll-10-p height-100-p xs-pd-20-10">
			<div class="min-height-200px">
				
				<!-- Default Basic Forms Start -->
				<div class="pd-20 bg-white border-radius-4 box-shadow mb-30"  style="overflow: scroll;">
                <div class="clearfix mb-20">
						<div class="pull-left">
							<h5 class="text-blue">START GENERATE BILL</h5>
						</div>
					</div>
                    <form action="<?php echo $_SERVER['PHP_SELF']?>?action=search" method="POST">
                    <div class="row">
                       <div class="col-lg-9">
                       <div class="form-group row">
							<label class="col-sm-12 col-md-12 col-form-label">

                                    Your going to generate bill for <?php echo $ks;?> Customers 


                            </label>
							
                            
						</div>
                       </div>
                       
                       <div class="col-lg-3">
                           <button type="button" class="btn btn-danger ld-ext-right" onclick="countClicks()" id="sendbtn">Start <div class="ld ld-ring ld-spin"></div></button>                 
                        </div>
                        <div id="shootres" class="col-lg-12"></div>
                    </div>
                     </form>

                </div>
                
				
				

			</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>

	<script src="src/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
	<script src="src/plugins/datatables/media/js/dataTables.bootstrap4.js"></script>
	<script src="src/plugins/datatables/media/js/dataTables.responsive.js"></script>
	<script src="src/plugins/datatables/media/js/responsive.bootstrap4.js"></script>
	<!-- buttons for Export datatable -->
	<script src="src/plugins/datatables/media/js/button/dataTables.buttons.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.bootstrap4.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.print.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.html5.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.flash.js"></script>
	<script src="src/plugins/datatables/media/js/button/pdfmake.min.js"></script>
	<script src="src/plugins/datatables/media/js/button/vfs_fonts.js"></script>
	<script>
		$('document').ready(function(){
			$('.data-table').DataTable({
				scrollCollapse: true,
				autoWidth: false,
				responsive: true,
				columnDefs: [{
					targets: "datatable-nosort",
					orderable: false,
				}],
				"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
				"language": {
					"info": "_START_-_END_ of _TOTAL_ entries",
					searchPlaceholder: "Search"
				},
			});
			$('.data-table-export').DataTable({
				scrollCollapse: true,
				autoWidth: false,
				responsive: true,
				paging: false,
				lengthchange: false,
				searching: false,
				ordering: false,
				columnDefs: [{
					targets: "datatable-nosort",
					orderable: false,
				}],
				"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
				"language": {
					"info": "_START_-_END_ of _TOTAL_ entries",
					searchPlaceholder: "Search"
				},
				// dom: 'Bfrtip',
				// buttons: [
				// 'copy', 'csv', 'pdf', 'print'
				// ]
			});
			var table = $('.select-row').DataTable();
			$('.select-row tbody').on('click', 'tr', function () {
				if ($(this).hasClass('selected')) {
					$(this).removeClass('selected');
				}
				else {
					table.$('tr.selected').removeClass('selected');
					$(this).addClass('selected');
				}
			});
			var multipletable = $('.multiple-select-row').DataTable();
			$('.multiple-select-row tbody').on('click', 'tr', function () {
				$(this).toggleClass('selected');
			});
		});
	</script>
</body>
</html>