<? include "top.php"; ?>
<!DOCTYPE html>
<html>
   <head>
      <?php include('include/head.php'); 
         $stdt=$_POST['stdt'];
            $logusers=$_POST['logusers'];
            $paytype=$_POST['paytype'];
            $customer=1;

            if($logusers=='0'){

                $comname="All Companty";
             }else{
    
                $getc=f(q("SELECT * FROM tbl_company WHERE c_id='$logusers'"));
                $comname=$getc['c_name'];
             }

             if($paytype=='1'){

                $ctype='Active';
             }else{

                $ctype='Deactive';
             }

         ?>
      <title>Company wise <?php echo $ctype?> customer list for <?php echo $comname?> </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">
      <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
      <style type="text/css">
         th{
         font-size: 13px !important;
         }
         td{
         font-size: 12px !important;
         }
      </style>
   </head>
   <body>
      <table class="stripe hover multiple-select-row data-table-export nowrap">
         <thead>
            <tr>
               <th class="table-plus datatable-nosort">Sl. No</th>
               <?php if($logusers=='0'){?><th>Company</th><?php } ?>
               <th>Customer Name</th>
               <th>Acno</th>
               <th>MSO Name</th>
               <? if($customer=='1'){ ?>
               <th>VC NO</th>
               <th>STB NO</th>
               <? }else{?>
               <th>IP</th>
               <th>userid</th>
               <? } ?>
               <th>Email</th>
               <th>Phone</th>
               <th>Area</th>
               <th>Address</th>
               <th>Status</th>
               
            </tr>
         </thead>
         <tbody>
            <?  
                if($logusers=='0'){

                    $sqll="SELECT * FROM `adduser` WHERE is_cable='1' AND actv='$paytype'";
                    
                   // $sql=mysqli_query($con,"SELECT * FROM `adduser` WHERE is_cable='$customer' AND actv='$paytype'");

                }else{
                    $sqll="SELECT * FROM `adduser` WHERE is_cable='1' AND actv='$paytype' AND com_id='$logusers'";
                   
                }
                //echo $sqll;
                $sql=mysqli_query($con,$sqll);

               while($row=mysqli_fetch_array($sql)){$c++;
               
					  
                        $getco=f(q("SELECT * FROM tbl_company WHERE c_id='$row[com_id]'"));
                        $coname=$getco['c_name'];
               ?>
            <tr>
               <td class="table-plus"><?=$c?></td>
               <?php if($logusers=='0'){?><td><?php echo $coname;?></td><?php } ?>
               <td><?=$row['name']?></td>
               <td><?=$row['custid']?></td>
               <td><?php 
                    $getmso = f(q("SELECT * FROM tbl_mso WHERE m_id='$row[mso]'"));
                    echo htmlspecialchars($getmso['m_name'] ?? 'N/A');
                ?></td>
               <td><?=$row['vc']?></td>
               <td><?=$row['stb']?></td>
               <td><?=$row['email']?></td>
               <td><?=$row['phone']?></td>
               <td><?=$row['area_name']?></td>
               <td><?=$row['address']?></td>
               <td><?php if($row['actv']==1){?> <small style="color:white;padding:5px;background-color: green;border-radius: 5px;">Active </small> <?php }else{?> <small style="color:white;padding:5px;background-color: red;border-radius: 5px;">Deactive</small> <?php } ?><br></td>
               
            </tr>
            <?} ?>	
         <tfoot>
            <tr>
               <td class="table-plus"></td>
               <?php if($logusers=='0'){?><td></td><?php } ?>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
            </tr>
         </tfoot>
         </tbody>
      </table>
      <?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,
         		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>
      <script type="text/javascript"></script>
   </body>
</html>

