<?php

ini_set('display_errors', 1);
define("ADMIN", true);
require_once("../../../common/lib.php");
require_once("../../../common/define.php");
define("TITLE_ELEMENT", 'doc_achat');
if(!isset($_SESSION['user'])){
    header("Location: /admin/login.php");
    exit();
}
require_once("../../includes/fn_module.php"); ?>
<!DOCTYPE html>
<head>
    <?php include("../../includes/inc_header_common.php"); ?>
    
    <!-- Select2 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet" />

</head>
<body>
    <div id="wrapper">
        <?php include("../../includes/inc_top.php"); ?>
        <div id="page-wrapper">
            <div class="page-header">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-8">
                            <h1><i class="fa fa-random"></i> Liste des retenues à la source (Achat)</h1>
                        </div>
                    </div>
                </div>
            </div>
            <div class="container-fluid">
                <div class="alert-container">
                    <div class="alert alert-success alert-dismissable"></div>
                    <div class="alert alert-warning alert-dismissable"></div>
                    <div class="alert alert-danger alert-dismissable"></div>
                </div>
                <div class="row" style="width:50%;float:left;">				
				
	<form method="GET" action="rapport.php">				

		<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-3 control-label text-right">Fournisseur &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="fournisseur" name="fournisseur" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_fournisseurs` order by name ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 	
	
	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-2 control-label  text-right">Du&nbsp;<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
						<input type="text" class="form-control datepicker" name="date_from" value="01-01-<? echo date("Y"); ?>" >
					</div>
				</div>
			</div>
		 </div>
	</div> 

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-2 control-label  text-right">Au&nbsp;<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
						<input type="text" class="form-control datepicker" name="date_to" value="31-12-<? echo date("Y"); ?>" >
					</div>
				</div>
			</div>
		 </div>
	</div> 



	
	
	



		</div>
	<div class="row" style="width:50%;float:left;">	
	

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Référence facture Achat &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="ref_fac_achat" name="ref_fac_achat" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_facture_achat` order by ref_bl ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['ref_bl'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 
	



	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">Montant de<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-money"></i></div>
						<input type="text" class="form-control" name="montant_from" value="0" >
					</div>
				</div>
			</div>
		 </div>
	</div>

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">Montant à<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-money"></i></div>
						<input type="text" class="form-control" name="montant_to" value="0" >
					</div>
				</div>
			</div>
		 </div>
	</div>	

	
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label " ></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
						<button type="submit" class="btn btn-default mt15" data-toggle="tooltip" data-placement="bottom" title="Rchercher">
							<i class="fa fa-search"></i><span class="hidden-sm hidden-xs"> Rchercher</span>
						</button>
				  </div>
			   </div>
		 </div>
	</div> 


</form>	
									
                    <?php
                    if($db !== false){
                        
                    } ?>
					
                </div>
            </div>
        </div>
    </div>
    
    <!-- Select2 JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
    
    <script>
        $(document).ready(function() {
            // Initialiser Select2 sur les deux éléments select
            $('#fournisseur').select2({
                theme: 'bootstrap-5',
                placeholder: 'Sélectionner un fournisseur',
                allowClear: true
            });
            
            $('#ref_fac_achat').select2({
                theme: 'bootstrap-5',
                placeholder: 'Sélectionner une référence',
                allowClear: true
            });
        });
    </script>
</body>
</html>
<?php
$_SESSION['msg_error'] = "";
$_SESSION['msg_success'] = "";
$_SESSION['msg_notice'] = ""; ?>
