<?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="src/plugins/datatables/media/css/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="src/plugins/datatables/media/css/dataTables.bootstrap4.css">
	<link rel="stylesheet" type="text/css" href="src/plugins/datatables/media/css/responsive.dataTables.css">
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); 

	
	$action=$_REQUEST['action'];
	$page = $_REQUEST["page"];
	if($action=='search'){

		$userdet=$_POST['userdet'];
		$names="%".$userdet."%";
		$q="SELECT * FROM adduser WHERE is_cable=1  AND actv=0 AND name LIKE '$names' OR phone='$userdet' OR vc LIKE '$names' OR stb LIKE '$names' OR custid LIKE '$names' OR msoacno LIKE '$names' LIMIT 20";


	}else{

		$start_limit = 0;
                $end_limit = 100 ;

                if ($page != '' && floatval($page) > 1)
                {
                    $start_limit = ($page - 1) * 100;
                    $end_limit=($page)*100;
                }
                
                	//SELECT * FROM db_sales WHERE company_id='$comid' ORDER BY id DESC LIMIT $start_limit, $end_limit

		$q="SELECT * FROM adduser WHERE is_cable=1 AND actv=0 ORDER BY name LIMIT $start_limit, $end_limit";
	}


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

			font-size: 12px;
		}

		td{

			font-size: 11px;
            color:red;
            
		}
       
    	</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>
	<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">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Deactive Cable Customer</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="index.php">Home</a></li>
									<li class="breadcrumb-item active" aria-current="page">Deactive Cable Customer</li>
								</ol>
							</nav>
						</div>
						<div class="col-md-6 col-sm-12 text-right">
							<form action="deactcust.php?action=search" method="POST">
							<div class="row">
								<div class="col-9">
								<input type="text" class="form-control" placeholder="User Search" name="userdet">

								</div>
								<div class="col-3">
									<button type="submit" class="btn btn-danger"><i class="fa fa-search"></i></button>
								</div>
							</div>
							
							
							</form>
							<!-- <div class="dropdown">
								<a class="btn btn-secondary dropdown-toggle" href="#" role="button" data-toggle="dropdown">
									January 2018
								</a>
								<div class="dropdown-menu dropdown-menu-right">
									<a class="dropdown-item" href="#">Export List</a>
									<a class="dropdown-item" href="#">Policies</a>
									<a class="dropdown-item" href="#">View Assets</a>
								</div>
							</div> -->
						</div>
					</div>
				</div>
				<!-- 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">Deactive Cable Customer List</h5>
						</div>
					</div>
					<div class="row">
						<table class="stripe hover multiple-select-row data-table-export nowrap">
							<thead>
								<tr>
									<th class="table-plus datatable-nosort">Name</th>
									<th>MSO No</th>
									<!-- <th>Phone</th>	 -->
									<th>Stb</th>	
									<th>VC</th>	
									<th>Price</th>	
									<!-- <th>Ac NO</th>	 -->	
									<th>Last Pay Dt.</th>
									<th>Last Pay Amt.</th>
									
									<th>Action</th>	
								</tr>
							</thead>
							<tbody>
								<?
									$getc=mysqli_query($con,$q);
									while($arr=mysqli_fetch_array($getc)){

										$getar=f(q("SELECT * FROM tbl_area WHERE arid='$arr[area_id]'"));
										$getusr=f(q("SELECT * FROM tbl_login WHERE user_id='$arr[id]'"));
										$getmso=f(q("SELECT * FROM tbl_mso WHERE m_id='$arr[mso]'"));
										$msoname=$getmso['m_name'];
										if($arr['actv']==0){
								?>
								<tr>
									<td class="table-plus"><?=$arr['name']?><br>

										Username: <?=$getusr['l_read']?><br><br>

										<?php if($arr['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>

										Phone: <?php echo $arr['phone']?><br>
										A/C No: <?php echo $arr['custid']?><br>
										Area : <?php echo $arr['area_name']?><br>
										MSO: <?php echo $msoname?><br>
										Month: <?php echo $arr['bl_month']?>, <?php echo $arr['bl_year']?><br>
										Remarks: <?php echo $arr['bl_remarks']?>
									</td>
									<td><?php echo $arr['msoacno']?></td>
									<!-- <td><?=$arr['phone']?></td>	 -->
									<td><?php echo substr($arr['stb'],0,26);?></td>	
									<td><?php echo substr($arr['vc'],0,26);?></td>	
									<td><?=$arr['price']?></td>	
									<!-- <td><?=$arr['custid']?></td>	 -->	
									<td><?=$arr['lpaydt']?></td>
									<td><?=$arr['lpayamt']?></td>
									<td>
										<div class="dropdown">
											<a class="btn btn-outline-primary dropdown-toggle" href="#" role="button" data-toggle="dropdown" style="color: black;">
												<i class="fa fa-ellipsis-h"></i>
											</a>
											<div class="dropdown-menu dropdown-menu-right">
												
												<? if($ltype!=2){?><a class="dropdown-item" href="addcuser.php?action=edit&cid=<?=$arr['id']?>"><i class="fa fa-pencil"></i> EDIT</a>
												<a class="dropdown-item" href="addcuser.php?action=delete&cid=<?=$arr['id']?>" onclick="return confirm('Are you sure you want to delete this item?');"><i class="fa fa-trash"></i> Delete</a><? } ?>
												<a class="dropdown-item" href="channeladd.php?custid=<?=$arr['id']?>"><i class="fa fa-tv"></i> Add Channel</a>
												<a class="dropdown-item" href="generatebill.php?custid=<?=$arr['id']?>"><i class="fa fa-cog"></i> Generate Bill</a>
												<a class="dropdown-item" href="otherbills.php?custid=<?=$arr['id']?>"><i class="fa fa-cog"></i> Other Bills</a>
												
													

												
											</div>
										</div>



									<!-- <a href="addcuser.php?action=edit&cid=<?=$arr['id']?>">EDIT</a><br>
									<a href="addcuser.php?action=delete&cid=<?=$arr['id']?>" onclick="return confirm('Are you sure you want to delete this item?');">DELETE</a><br>
									<a href="addchannel.php?custid=<?=$arr['id']?>">Add Channel</a> -->
									

									</td>
								</tr>
								<? } } ?>	
							</tbody>
						</table><br>
						<div class="col-md-12">
                        <div class="card">
                            <div class="card-body">
                                
                        <?php
                        $arrc = f(q("SELECT COUNT(*) AS total FROM `adduser` WHERE is_cable=1 AND actv=0"));
                        $total_pages = $arrc['total'];
                        $total_pages = ceil($total_pages / 100);
                        
                        if ($page == "")
                        {
                            $page = 1;
                        }
                        
                        $prev_page = $page - 1;
                        $next_page = $page + 1;                     
                        
                        ?>
                        <p class="pagination">
                            <a href="cablecust.php?page=<?php if($page == 1){ echo '1'; }else{ echo $prev_page; } ?>">&laquo;</a>
                        <?php 
                        
                        
                        for ($i = 1; $i <= $total_pages; $i++)
                        {
                            ?>
                            <a href="cablecust.php?page=<?php echo  $i ?>" <?php if($page==$i){?> class="active" <?php } ?>><?php echo  $i ?></a>
                            <?php 
                        }
                        ?>
                            <a href="cablecust.php?page=<?php if($page == $total_pages){ echo $total_pages; }else{ echo $next_page  ; } ?>">&raquo;</a>
                        </p>
                    


                             </div>
                        </div>
                    </div> 
					</div>
				</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>