<?php

ini_set('display_errors', 1);
define("ADMIN", true);
require_once("../../common/lib.php");
require_once("../../common/define.php");
define("TITLE_ELEMENT", 'Inventaire 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"); ?>

</head>
<script>


jQuery(document).ready(function($) {
	// $(".col-lg-6 select").chosen();
});
</script>

<!-- Select2 CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0-beta.1/css/select2.min.css" rel="stylesheet" />

<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<!-- Select2 JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0-beta.1/js/select2.min.js"></script>

<script>
$(document).ready(function() {
    $('.mySelect').select2({
        placeholder: "Sélectionnez une option",
        allowClear: true // Permet de supprimer la sélection
    });
});
</script>


<style>
.chosen-container-single{
	width:auto !important;
}
</style>

<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-cubes"></i> Mouvement de l'article</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" >				
				
	<form method="GET" action="listing.php">				

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 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_in" value="01-01-<? echo date('Y'); ?>" >
					</div>
				</div>
			</div>
		 </div>
	</div> 

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">Jusqu'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_out" value="<? echo date('d-m-Y'); ?>" >
					</div>
				</div>
			</div>
		 </div>
	</div> 

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Article <span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select name="product" class="form-control mySelect">
						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_produitsachat` order by desingnation ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									$designation = $row['desingnation'];
									// Vérifier si la longueur dépasse 100 caractères
									if (strlen($designation) > 100) {
										// Troncature à 100 caractères avec "..." ajouté à la fin
										$designation = substr($designation, 0, 100) . '...';
									}									
									
									echo '<option value="a_'.$row['id'].'">'. $designation.' - Achat</option>';
								}	
							}	
							//========
							$query = "SELECT * FROM `pm_produits` order by desingnation ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){	
									echo '<option value="v_'.$row['id'].'">'. $row['desingnation'].' - Vente</option>';
								}	
							}	
							
														
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Type de mouvement &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select name="mouvement" class="form-control">
						<option value="0">Tous</option>
						<option value="pm_be">Bon d'entrée - Achat</option>
						<option value="pm_br">Bon de retour - Achat</option>
						<option value="pm_bf">Bon de fabrication - Achat</option>
						<option value="pm_bl">Bon de livraison - Vente</option>
						<option value="pm_brv">Bon de retour - Vente</option>
					 </select>
				  </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>
</body>
</html>
<?php
$_SESSION['msg_error'] = "";
$_SESSION['msg_success'] = "";
$_SESSION['msg_notice'] = ""; ?>


