<style>
/* 
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
@media only screen and (max-width: 560px), (min-device-width: 568px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
	display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
	position: absolute;
	top: -9999px;
	left: -9999px;
}
tr {
	border: 0px solid #ccc;
}
td {
	/* Behave  like a "row" */
	border: none;
	/*border-bottom: 1px solid #eee; */
	position: relative;
	padding-left: 50%;
}
td:before {
	/* Now like a table header */
	position: unset; /*absolute causing issues*/
	/* Top/left values mimic padding */
	top: 6px;
	left: 6px;
	width: 45%;
	padding-right: 10px;
	white-space: nowrap;
}
/*
Label the data
*/
td:nth-of-type(1):before {content: "S.No";}
td:nth-of-type(2):before {content: "Name";}
td:nth-of-type(3):before {content: "Email";}
td:nth-of-type(4):before {content: "Phone";}
td:nth-of-type(5):before {content: "Status";}
td:nth-of-type(6):before {content: "Actions";}
.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {
  max-width: 20%;  
}
}
@media only screen and (max-width: 480px), (min-device-width: 300px) and (max-device-width: 480px) {
	.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {
	  max-width: 100%;  
	}
	td:nth-of-type(1)::before {
	  content: "";
	}
}
.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {
  max-width: 100px !important;
  }
</style>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css" rel="stylesheet"></link>
<script src="assets/plugins/jquery/jquery.min.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
	$('.submit-pop').click(function () {		
		var btn_id = this.id;	
		var strarray = btn_id.split('-');	
		var shop_id = strarray[1];	
		var amount = $('#amount-'+shop_id).val();			
		if(amount == '' || amount == 'undefined'){
			alert("Enter payment amount");
			return false;
		} else if(amount<=0){
			alert("Enter a valid amount");
			return false;
		}
		if(shop_id != '' && shop_id != 'undefined'){		
			$.ajax({url:"ajax/ajax.php?action=shop_mark_paid&shop_id="+shop_id+"&amount="+amount,success:function(result){								
				if(result=='success'){
					$("#ajax_result-"+shop_id).html('<span style="color:green;">The payment has been submitted</span>');
					//$('#myModal'+shop_id).modal('hide');
					//alert('Payment has been submitted');
					//window.location = "<?php //echo BASE_URL;?>lcontrol/index.php?page=view_task&id=<?php //echo $taskId; ?>&success=Assigned the technician";
					//location.reload();
				} else {
					//alert(result);
					$("#ajax_result-"+shop_id).html('<span style="color:red;">'+result+'</span>');					
					//alert('Something went wrong');
				}													
			}});
		} else {
			alert("something went wrong");
			return false;
		}
			
	});		
});	
</script>
<div class="page-content-wrapper">
                <div class="page-content">
                    <div class="page-bar">
                        <div class="page-title-breadcrumb">
                            <div class=" pull-left">
                                <div class="page-title">Manage Shop</div>
                            </div>
                            <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.php?page=home">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li><a class="parent-item" href="index.php?page=manage_purchase_partner">Purchase Partner</a>&nbsp;<i class="fa fa-angle-right"></i></li><li class="active">Manage Shop</li>
                            </ol>
                        </div>
                    </div>
                    
	 <div class="row">
                        <div class="col-md-12">
                            <div class="card card-topline-red">
                                <div class="card-head">
                                    <header>Manage Shop</header>
                                    <div class="tools">
                                        <!--<a class="fa fa-repeat btn-color box-refresh" href="javascript:;"></a>-->
	                                    <a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
	                                    <a class="t-close btn-color fa fa-times" href="javascript:;"></a>
                                    </div>
                                </div>
                                <div style="margin: 10px;">
	                                <form name="form" id="form" action="" method="post">	
									<input type="text" style="margin-right: 8px;" name="searchvalue" id="searchvalue" placeholder="Keywords.."  value="<?php if(isset($_POST['searchvalue'])) { echo $_POST['searchvalue']; }  ?>" />
									<select name="status" id="status">
	                                	<option value="">--- Select Status --</option>
	                                	<?php while($statRec = mysqli_fetch_array($statRs)){ ?>
	                                		<option value="<?php echo $statRec['status']; ?>" <?php if(isset($_REQUEST['status']) && $_REQUEST['status']==$statRec['status']){ echo 'selected'; }?> ><?php echo $statRec['status']; ?></option>
	                                	<?php } ?>
	                                </select>
	                                <select name="paid" id="paid">
	                                	<option value="">--- Is Paid --</option>	                                	
	                                	<option value="yes" <?php if(isset($_REQUEST['paid']) && $_REQUEST['paid']=='yes'){ echo 'selected'; }?> >Yes</option>
	                                	<option value="no" <?php if(isset($_REQUEST['paid']) && $_REQUEST['paid']=='no'){ echo 'selected'; }?> >No</option>
	                                </select>
                                    <select name="partner" id="partner">
	                                	<option value="">--- Purchase Partner --</option>
	                                	<option value="yes" <?php if(isset($_REQUEST['partner']) && $_REQUEST['partner']=='yes'){ echo 'selected'; }?> >Yes</option>
	                                	<option value="no" <?php if(isset($_REQUEST['partner']) && $_REQUEST['partner']=='no'){ echo 'selected'; }?> >No</option>
	                                </select>
									<button class="btn" name="submit1">Search</button>&nbsp;
									<button class="btn" name="clear">Clear</button>						
									</form>
								</div>
                                <div class="card-body ">
                                    <div class="row p-b-20">
                                        <div class="col-md-12 col-sm-12 col-12">
                                            <div class="btn-group">
                                                <button onclick="location.href = 'index.php?page=add_purchase_partner';" id="addRow1" class="btn btn-info">
                                                    Add Shop <i class="fa fa-plus"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <!--<div class="col-md-6 col-sm-6 col-6">
                                            <div class="btn-group pull-right">
                                                <button class="btn deepPink-bgcolor  btn-outline dropdown-toggle" data-toggle="dropdown">Tools
                                                    <i class="fa fa-angle-down"></i>
                                                </button>
                                                <ul class="dropdown-menu pull-right">
                                                    <li>
                                                        <a href="javascript:;">
                                                            <i class="fa fa-print"></i> Print </a>
                                                    </li>
                                                    <li>
                                                        <a href="javascript:;">
                                                            <i class="fa fa-file-pdf-o"></i> Save as PDF </a>
                                                    </li>
                                                    <li>
                                                        <a href="javascript:;">
                                                            <i class="fa fa-file-excel-o"></i> Export to Excel </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>-->
                                    </div>
                                    <?php if(isset($_REQUEST['success'])){ ?><div class="alert alert-success"><?php echo urldecode($_REQUEST['success']); ?></div></div><?php } ?>
                                    <?php if(isset($execDetails) && mysqli_num_rows($execDetails)>0) { ?>
                                    <table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="example4">
                                        <thead>
                                            <tr>
                                                <!--<th>
                                                    <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                        <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" />
                                                        <span></span>
                                                    </label>
                                                </th>-->
                                                <th> Code </th>
                                                <th> Name </th>
                                                <th> Email </th>
                                                <th> Phone </th>
                                                <th> Status </th>
                                                <th> Payment </th>
                                                <th> Actions </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        	<?php
                                        	if(isset($_GET['p']) && is_numeric($_GET['p']) && ($_GET['p'] > 1)) {
												$slNo = ($_GET['p']*30-29);
											} else {
												$slNo = 1;
											}
												while($resDetails = mysqli_fetch_array($execDetails)) {	
													//check if category added (atleast 1). if so show activate link
													$chkCatRs = mysqli_query($con, "SELECT id FROM `tbl_purchase_partner_categories` WHERE `partner_id` = '".$resDetails['id']."'");
													if(mysqli_num_rows($chkCatRs)>0){
														$showLink = TRUE;
													} else {
														$showLink = FALSE;
													}
													?>
                                            <tr class="odd gradeX" <?php if($resDetails['featured']=='yes'){ echo 'style="background-color:#e2b2fc;"'; }?>>
                                                <!--<td>
                                                    <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                        <input type="checkbox" class="checkboxes" value="1" />
                                                        <span></span>
                                                    </label>
                                                </td>-->
                                                <td><?php echo SHOP_ID.$resDetails['id']; ?></td>
                                                <td><?php echo $resDetails['building_name']; ?></td>
                                                <td><?php echo $resDetails['email']; ?></td>
                                                <td><?php echo $resDetails['phone']; ?></td>
                                                <td>
                                                	<div class="">
                                                		<a target="_blank" class="btn btn-xs deepPink-bgcolor dropdown-toggle no-margin" href="index.php?page=view_purchase_partner&id=<?php echo $resDetails['id']; ?>">View</a><br>
                                                	</div>
                                                	<div class="pt-2">
	                                                	<?php if($resDetails['status']=='Active'){?>
                                                    	<span class="label label-sm label-success"> <?php echo $resDetails['status'];?> </span>
														<?php } else { ?>
                                                            <span class="label label-sm label-warning"> <?php echo $resDetails['status'];?> </span>
                                                        <?php } ?>
                                                    </div>                                                	
                                                </td>                   
                                                <td style="width:100px;">
                                                	<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal<?php echo $resDetails['id'];?>">Mark Paid</button>
                                                </td>                             
                                                <td class="valigntop">
                                                	<?php if($showAssign){ ?>                                                		
                                                		<a class="btn btn-xs deepPink-bgcolor" href="index.php?page=view_purchase_order&id=<?php echo $orderId; ?>&action=assign&partner_id=<?php echo $resDetails['id']; ?>">Assign</a>
                                                	<?php } else { ?>
                                                    <div class="btn-group">
                                                        <button class="btn btn-xs deepPink-bgcolor dropdown-toggle no-margin" type="button" data-toggle="dropdown" aria-expanded="false"> Actions
                                                            <i class="fa fa-angle-down"></i>
                                                        </button>
                                                        <ul class="dropdown-menu pull-left" role="menu">     
                                                        	<li>
                                                                <a target="_blank" href="index.php?page=admin_login&action=shop_login&shop_id=<?php echo $resDetails['id']; ?>">
                                                                    <i class="icon-user"></i> Login </a>
                                                            </li>
                                                        	<li>
                                                                <a target="_blank" href="index.php?page=view_purchase_partner&id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-user"></i> View Details </a>
                                                            </li>                                                       
                                                            <li>
                                                                <a target="_blank" href="index.php?page=add_purchase_partner&id=<?php echo $resDetails['id']; ?>">
                                                                    <i class="icon-user"></i> Edit Details </a>
                                                            </li>   
                                                            <li>
                                                                <a target="_blank" href="index.php?page=shop_assign_category&shop_id=<?php echo $resDetails['id']; ?>">
                                                                    <i class="icon-docs"></i>Assign Categories </a>
                                                            </li> 
                                                            <li>
                                                                <a target="_blank" href="index.php?page=purchase_commission&shop_id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-docs"></i> Commission Report </a>
                                                            </li> 
                                                            <li>
                                                                <a target="_blank" href="index.php?page=purchase_incomes&shop_id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-docs"></i> Payments to <?php echo(SITE_NAME); ?> </a>
                                                            </li>
                                                            <?php if($resDetails['featured']=='yes'){ ?>
                                                            <li>
                                                                <a href="index.php?page=manage_purchase_partner&action=rem_partner&id=<?php echo $resDetails['id']; ?>&p=<?php echo $p;?>">
                                                                    <i class="icon-docs"></i> Remove from Partner </a>
                                                            </li>
                                                            <?php } else { ?>
                                                            <!--<li>                                                                
                                                                <!--<a href="index.php?page=manage_purchase_partner&action=mark_paid&id=<?php echo $resDetails['id']; ?>" >
                                                                    <i class="icon-docs"></i> Mark Paid </a>-->
                                                                   
                                                            <!--</li>-->
                                                            <!--<li>
                                                                <a href="index.php?page=manage_purchase_partner&action=make_partner&id=<?php echo $resDetails['id']; ?>">
                                                                    <i class="icon-docs"></i> Make Purchase Partner </a>
                                                            </li>-->
                                                            <?php } ?>
                                                            <?php if($resDetails['status']=='Active'){ ?>
                                                            <li>
                                                                <a onclick="return confirm('Are you sure to disable the partner?');" href="index.php?page=manage_purchase_partner&action=disable&id=<?php echo $resDetails['id']; ?>&p=<?php echo $p;?>">
                                                                    <i class="icon-user"></i> Disable </a>
                                                            </li>
                                                            <?php } else { 
                                                            	//if($showLink){ ?>
                                                            <li>
                                                                <a href="index.php?page=manage_purchase_partner&action=activate&id=<?php echo $resDetails['id']; ?>">
                                                                    <i class="icon-user"></i> Activate </a>
                                                            </li>
                                                            <?php } 
															//} ?>
                                                            <!--<li>
                                                                <a href="index.php?page=send_mail&shop_id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-docs"></i> Send Mail </a>
                                                            </li> 
                                                            <li>
                                                                <a href="#">
                                                                    <i class="icon-docs"></i> Send SMS </a>
                                                            </li>-->                                                            
                                                            <li>
                                                                <a target="_blank" href="index.php?page=change_password&action=partner_pass&id=<?php echo $resDetails['id']; ?>">
                                                                    <i class="icon-user"></i> Change Password </a>
                                                            </li>
                                                            <li>
                                                                <a  onclick="return confirm('Are you sure to delete this partner?');" href="index.php?page=manage_purchase_partner&action=delete&del_id=<?php echo $resDetails['id']; ?>&p=<?php echo $p; ?>">
                                                                    <i class="icon-docs"></i> Delete </a>
                                                            </li>                                                           
                                                        </ul>
                                                        
                                                        <!-- The Modal -->
															<div class="modal fade" id="myModal<?php echo $resDetails['id'];?>">
															  <div class="modal-dialog">
															    <div class="modal-content">						
															      <!-- Modal Header -->
															      <div class="modal-header">
															        <h4 class="modal-title">Mark Paid</h4>
															        <button type="button" class="close" data-dismiss="modal">&times;</button>
															      </div>						
															      <!-- Modal body -->
															      <div class="modal-body">
															      	<div id="ajax_result-<?php echo $resDetails['id'];?>"></div>						      	
															      	 <form name="regForm" id="regForm<?php echo $resDetails['id'];?>" action="" method="post">
															      	 																																			
																		<div class="form-group">
																		  <label for="email" class="col-12 col-form-label">Enter Amount</label>
																		  <div class="col-12">
																		    <input class="form-control col-12" name="amount" id="amount-<?php echo $resDetails['id'];?>" type="text" value="<?php if(isset($_POST['amount']) && $_POST['amount']!=''){ echo $_POST['amount']; } ?>">
																		  </div>
																		</div>																						
																		<div class="form-group row justify-content-md-center mt-4 mb-2">			
																			 <div class="col-12">				 	
																				  <button id="btn-<?php echo $resDetails['id'];?>" type="button" name="submit" data-backdrop="static" class="btn btn-primary submit-pop">Submit</button>					    
																			  </div>
																	    </div>
																	</form>
															      </div>						
															      <!-- Modal footer -->
															      <div class="modal-footer">
															        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
															      </div>						
															    </div>
															  </div>
															</div>
															<script>
															/*$( "form" ).submit(function( event ) {
															  event.preventDefault();
															});*/
															</script>
														<!-- The Modal -->
                                                        
                                                        
                                                    </div>
                                                    <?php } ?>
                                                </td>
                                            </tr>
                                            <?php ++$slNo; } ?>                                            
                                        </tbody>
                                    </table>
                                    <div style="float: left; width: 100%;"> <?php echo $pageNums; ?> </div>
                                    <?php } else { ?>
                                    	<div class="alert alert-danger">Sorry! No Results Found.</div>					        		
					        		<?php }	?> 
                                </div>
                            </div>
                        </div>
                    </div>
                    

</div>
</div>