<?php
session_start(); 
ob_start();
include("../../pidbco/pidbjoin.php");
$sujpath="./";

if(isset($_POST['viewallcust']))
{
 ?>	
<div id="marketingdiv123">
	<table id="example1" class="table table-bordered table-striped" >
            <thead >
                    <tr >
                    <th>#</th>
                    <th>Name</th>                    	
                    <th>Mobile</th>
                    <th>Status</th>               
                    <th width="20%"></th>
                    </tr>
            </thead>
            <tbody>
          <?php
          $k = 1;
          $brasel = mysqli_query($con, "SELECT * FROM `p_customers`  ORDER BY `cid` DESC");
		  while($ressel = mysqli_fetch_array($brasel)){	
          ?>
          <tr>
          	<td><?php echo $k; ?></td>
          	<td>
          	  <a data-toggle="modal" data-target=".viewallcustomr<?php echo $ressel['cid']; ?>" style="cursor: pointer;text-decoration: none; color: #000;" title="View">
          	  <?php echo $ressel['cname']; ?> </a> 
            </td>
          	<td>
          		<a data-toggle="modal" data-target=".viewallcustomr<?php echo $ressel['cid']; ?>" style="cursor: pointer;text-decoration: none; color: #000;" title="View">
          		<?php echo $ressel['cmob']; ?></a> </td>
          	<td><?php if($ressel['cstatus']== '1'){ echo "Active"; } else { echo "InActive"; } ?></td>
          	
          	<td>
          	<a  data-toggle="modal" data-target="#billview" href="#" title="Edit" onClick="edit_customer('<?php echo base64_encode($ressel['cid']); ?>');">
			<i class="fa fa-pencil" style="font-size:15px;"></i></a> &nbsp;
			<a data-toggle="modal" data-target="#reason" style="cursor: pointer;text-decoration: none;" title="Delete" onClick="delete_customer('<?php echo base64_encode($ressel['cid']); ?>');">
			<i class="fa fa-trash-o" style="font-size:15px;"></i></a>   
			
			
			
			
			
			<div class="modal fade viewallcustomr<?php echo $ressel['cid']; ?>" tabindex="-1" role="dialog" aria-hidden="true">
				<div class="modal-dialog modal-lg">
			       <div class="modal-content ">
                       <div class="modal-header">
						  <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>						  
						</div>
						<div class="modal-body">
							
					  <div class="row" >		
					  <div class="col-md-12">		
						
						<table id="datatable-fixed-header" class="table table-striped table-bordered">
						 <tr>
						 	<th colspan="2"><span style=" text-align: center;">CUSTOMER DETAILS</span></th>
						 </tr>
						  <tr>
						  	<td width="30%">Name</td>
						  	<td><?php echo $ressel['cname']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>Contact Person</td>
						  	<td><?php echo $ressel['ccontact']; ?></td>
						  </tr>
						  <tr>
						  	<td>Mobile</td>
						  	<td><?php echo $ressel['cmob']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>Email</td>
						  	<td><?php echo $ressel['cemail']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>District</td>
						  	<td><?php echo $ressel['cdistrict']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>State</td>
						  	<td><?php echo $ressel['cstate']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>Country</td>
						  	<td><?php echo $ressel['ccountry']; ?></td>
						  </tr>
						  
			
			   </table></div></div></div></div></div></div>
			
			
			    		
          	</td>
          	
          </tr>
          
          
     <?php $k=$k+1; } ?>	
          	
      </tbody></table>	
     <script>
      $(document).ready(function() {
        $("#example1").DataTable();
      });
      </script>
  </div>                  	

<?php	
}










/* ---------  View All Sales ------------- */

if(isset($_POST['viewallsales']))
{
?>	
<div id="marketingdiv123">
	<table id="example1" class="table table-bordered table-striped" >
       <thead >
       <tr>
          <th>#</th>
          <th>Bill No.</th>                                        	
          <th>Branch</th>
          <th>Customer</th>
          <th>Order No</th>
          <th>Amount</th>
          <th>Date</th>
          <th></th>
       </tr>
       </thead>
      <tbody>
     <?php 
$sq = mysqli_query($con, "SELECT * FROM `p_billing` ORDER BY `bid` DESC ");
$k=1;
while($rs = mysqli_fetch_array($sq)){
 $rdate = $rs['bdate'];
 $exp = explode("-",$rdate);
 $yearr =  substr($exp[0], 0, 4);
 $bill_dat = $exp[2].'/'.$exp[1].'/'.$yearr; 
 
 $comid = $rs['bcomp'];	
 $sq1 = mysqli_query($con,"SELECT c_comp FROM `p_company` WHERE `cid`='$comid' ");
 $rs1 = mysqli_fetch_array($sq1);	
 $cusid = $rs['bcust'];
 $sq2 = mysqli_query($con,"SELECT cname FROM `p_customers` WHERE `cid`='$cusid' ");
 $rs2 = mysqli_fetch_array($sq2);
?>
<tr>
<td><?php echo $k; ?></td>
<td><?php echo $rs['bill_no']; ?></td>
<td><?php echo $rs['bbranch']; ?></td>
<td><?php echo $rs2['cname']; ?></td>
<td><?php echo $rs['border_no']; ?></td>
<td><?php echo $rs['bamnt']; ?></td>
<td><?php echo $bill_dat; ?></td>
<td>
&nbsp;<a href="invoice/index.php?bill=<?php echo base64_encode($rs['bid']); ?>" style=" cursor: pointer;" target="_blank"><span class="fa fa-print" style="font-size:14px;"></span></a>	
&nbsp;&nbsp;  <a href="" data-toggle="modal" data-target="#myModal<?php echo $rs['bid']; ?>" style=" cursor: pointer;"><span class="glyphicon glyphicon-eye-open" style="font-size:14px;"></span></a> &nbsp; &nbsp;                	
    <a onClick="edit_sales('<?php echo base64_encode($rs['bid']); ?>');" style=" cursor: pointer;" ><span class="fa fa-pencil" style="font-size:14px;"></span></a> &nbsp; &nbsp;
    <a onClick="delete_sales('<?php echo base64_encode($rs['bid']); ?>');" style=" cursor: pointer;" ><span class="fa fa-trash-o" style="font-size:14px;"></span></a> 	
</td>	
</tr>	
	
	
	
	<div class="modal fade" id="myModal<?php echo $rs['bid']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header" style=" background-color: #E8E8E8;">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Order No #<?php echo $rs["border_no"]; ?></h4>
      </div>
      <div class="modal-body" id="myModal2">
  
    <div style=" width:550px; ">
     <div style=" float:left; width:150px;  font-size:14px; color:#0000FF; ">Company Name</div><div style="width:375px; ">: &nbsp;&nbsp; <?php echo $rs1['c_comp']; ?></div>
     <div style=" float:left; width:150px;font-size:14px;color:#0000FF;">Branch </div><div style="width:375px;">: &nbsp;&nbsp; <?php echo $rs["bbranch"]; ?></div>
     <div style=" float:left; width:150px;font-size:14px;color:#0000FF;">Customer </div><div style="width:375px;">: &nbsp;&nbsp; <?php echo $rs2['cname']; ?></div>
     <div style=" float:left; width:150px;font-size:14px;color:#0000FF;">Amount </div><div style="width:375px;">: &nbsp;&nbsp; <?php echo $rs["bamnt"]; ?></div>
     <div style=" float:left; width:150px;font-size:14px;color:#0000FF;">Discount Amount </div><div style="width:375px;">: &nbsp;&nbsp; <?php echo $rs["bdiscount"]; ?></div>
     <div style=" float:left; width:150px;font-size:14px;color:#0000FF;">Net Amount</div><div style="width:375px;">: &nbsp;&nbsp; <?php echo $rs["bnet"]; ?></div>
     <div style=" float:left; width:150px;font-size:14px;color:#0000FF;">Remarks </div><div style="width:375px;">: &nbsp;&nbsp; <?php echo $rs["bremarks"]; ?></div>
  </div>
  
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
       
      </div>
    </div>
  </div>
</div>  
	
	
	
      <?php $k=$k+1; } ?>	
          	
      </tbody></table>	
     <script>
      $(document).ready(function() {
        $("#example1").DataTable();
      });
      </script>
  </div>                  	

<?php	
}





























/* ----------- Vendors List     ------- */
if(isset($_POST['viewallvendr']))
{
?>	



<div id="marketingdiv123">
	<table id="example1" class="table table-bordered table-striped" >
            <thead >
                    <tr >
                    <th>#</th>
                    <th>Name</th>                    	
                    <th>Mobile</th>
                    <th>Status</th>               
                    <th width="20%"></th>
                    </tr>
            </thead>
            <tbody>
                    	
                    	
          <?php
          $k = 1;
          $brasel = mysqli_query($con, "SELECT * FROM `p_vendor` WHERE `v_status`='1' ORDER BY `vid` DESC");
		  while($ressel = mysqli_fetch_array($brasel)){	
          ?>
          <tr>
          	<td><?php echo $k; ?></td>
          	<td>
          	  <a data-toggle="modal" data-target=".viewallvendr<?php echo $ressel['vid']; ?>" style="cursor: pointer;text-decoration: none; color: #000;" title="View">
          	  <?php echo $ressel['v_company']; ?> </a> 
            </td>
          	<td>
          		<a data-toggle="modal" data-target=".viewallvendr<?php echo $ressel['vid']; ?>" style="cursor: pointer;text-decoration: none; color: #000;" title="View">
          		<?php echo $ressel['cmob']; ?></a> </td>
          	<td><?php if($ressel['cstatus']== '1'){ echo "Active"; } else { echo "InActive"; } ?></td>
          	
          	<td>
          	<a  data-toggle="modal" data-target="#billview" href="#" title="Edit" onClick="edit_customer('<?php echo base64_encode($ressel['vid']); ?>');">
			<i class="fa fa-pencil" style="font-size:15px;"></i></a> &nbsp;
			<a data-toggle="modal" data-target="#reason" style="cursor: pointer;text-decoration: none;" title="Delete" onClick="delete_customer('<?php echo base64_encode($ressel['vid']); ?>');">
			<i class="fa fa-trash-o" style="font-size:15px;"></i></a>   
			
			
			
			
			
			<div class="modal fade viewallcustomr<?php echo $ressel['vid']; ?>" tabindex="-1" role="dialog" aria-hidden="true">
				<div class="modal-dialog modal-lg">
			       <div class="modal-content ">
                       <div class="modal-header">
						  <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>						  
						</div>
						<div class="modal-body">
							
					  <div class="row" >		
					  <div class="col-md-12">		
						
						<table id="datatable-fixed-header" class="table table-striped table-bordered">
						 <tr>
						 	<th colspan="2"><span style=" text-align: center;">CUSTOMER DETAILS</span></th>
						 </tr>
						  <tr>
						  	<td width="30%">Name</td>
						  	<td><?php echo $ressel['cname']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>Contact Person</td>
						  	<td><?php echo $ressel['ccontact']; ?></td>
						  </tr>
						  <tr>
						  	<td>Mobile</td>
						  	<td><?php echo $ressel['cmob']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>Email</td>
						  	<td><?php echo $ressel['cemail']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>District</td>
						  	<td><?php echo $ressel['cdistrict']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>State</td>
						  	<td><?php echo $ressel['cstate']; ?></td>
						  </tr>
						  
						  <tr>
						  	<td>Country</td>
						  	<td><?php echo $ressel['ccountry']; ?></td>
						  </tr>
						  
			
			   </table></div></div></div></div></div></div>
			
			
			    		
          	</td>
          	
          </tr>
          
          
     <?php $k=$k+1; } ?>	
          	
      </tbody></table>	
     <script>
      $(document).ready(function() {
        $("#example1").DataTable();
      });
      </script>
  </div>  




<?php	
}

?>