<?php debug_backtrace() || die ("Direct access not permitted"); ?>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>
    <?php
    echo TITLE_ELEMENT;
    if(defined("SITE_TITLE")) echo " | ".SITE_TITLE; ?>
</title>

<?php
if(defined("TEMPLATE")){ ?>
    <link rel="icon" type="image/png" href="<?php echo DOCBASE; ?>templates/<?php echo TEMPLATE; ?>/images/favicon.png">
    <?php
} ?>
    
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="<?php echo DOCBASE; ?>common/bootstrap/css/bootstrap1.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700">
<link rel="stylesheet" href="<?php echo DOCBASE; ?>common/css/shortcodes.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo DOCBASE.ADMIN_FOLDER; ?>/css/layout.css">
<link rel="stylesheet" href="<?php echo DOCBASE; ?>common/js/plugins/magnific-popup/magnific-popup.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

<link rel="stylesheet" href="<?php echo DOCBASE; ?>admin/js/chosen.css">

<script src="//code.jquery.com/jquery-1.9.1.js"></script>

<script src="<?php echo DOCBASE; ?>common/js/modernizr-2.6.1.min.js"></script>
<script src="<?php echo DOCBASE; ?>common/bootstrap/js/bootstrap.min.js"></script>
<script src="<?php echo DOCBASE.ADMIN_FOLDER; ?>/js/jquery-ui.js"></script>
<script src="<?php echo DOCBASE; ?>common/js/custom.js"></script>
<script src="<?php echo DOCBASE; ?>common/js/plugins/magnific-popup/jquery.magnific-popup.min.js"></script>

<script src="<?php echo DOCBASE; ?>admin/js/chosen.jquery.js"></script>


<script>
// ============ SMART SEARCH ====================
jQuery(document).ready(function($) {
	
var array_module_smart = ['produits'];
// var module_name_smart = '' ;
var module_name_smart = 'test' ;

	if(jQuery.inArray(module_name_smart, array_module_smart) != -1){
		// $("#table_produits_product select").chosen();
		// $(".col-lg-6 select").chosen();
	}
	
});
</script>
<script>
    $(function(){
        <?php
        if(isset($_SESSION['msg_error']) && isset($_SESSION['msg_success']) && isset($_SESSION['msg_notice'])){
            
            if(!is_array($_SESSION['msg_error'])) $_SESSION['msg_error'] = array();
            if(!is_array($_SESSION['msg_success'])) $_SESSION['msg_success'] = array();
            if(!is_array($_SESSION['msg_notice'])) $_SESSION['msg_notice'] = array();
            
            $_SESSION['msg_error'] = array_unique($_SESSION['msg_error']);
            $_SESSION['msg_success'] = array_unique($_SESSION['msg_success']);
            $_SESSION['msg_notice'] = array_unique($_SESSION['msg_notice']); ?>
            
            var msg_error = '<?php echo str_replace(addslashes("\n"), "\n", addslashes(implode("<br>", $_SESSION['msg_error']))); ?>';
            var msg_success = '<?php echo str_replace(addslashes("\n"), "\n", addslashes(implode("<br>", $_SESSION['msg_success']))); ?>';
            var msg_notice = '<?php echo str_replace(addslashes("\n"), "\n", addslashes(implode("<br>", $_SESSION['msg_notice']))); ?>';
            
            var button_close = '<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>';
            if(msg_error != '') $('.alert-container .alert-danger').html(msg_error+button_close).show();
            if(msg_success != '') $('.alert-container .alert-success').html(msg_success+button_close).show();
            if(msg_success != '') $('#button_generat_facture').show();
            if(msg_notice != '') $('.alert-container .alert-warning').html(msg_notice+button_close).show();
            <?php
        } ?>
        
        $('[data-toggle="tooltip"]').tooltip();
        
        $('select[data-filter]').each(function(){
            var target = $(this);
            var currval = $(this).val();
            var curropt = $('option[value="'+currval+'"]', target);
            var input = $('select').filter('<?php if(defined("MODULE")) : ?>[name^="<?php echo MODULE; ?>_'+target.attr('data-filter')+'"],<?php endif; ?>[name="'+target.attr('data-filter')+'"]');
            input.on('change', function(){
                var val = $(this).val();
                $('option[value!=""]', target).hide().prop('selected', false);
                $('option[rel="'+val+'"]', target).show();
                if(curropt.attr('rel') == val) curropt.prop('selected', true);
            });
            input.trigger('change');
        });
        
        $(window).on('resize', function(){
            var h = $(this).height() - 50;
            $('.side-nav').css('max-height', h);
        });
        $(window).trigger('resize');
		
		
			// ========= GET product bon d'entré partielle =========
			
			$(document).on( "click",".get_bc",function() {
				var id_prd = $(this).attr("name");
				$("#dioalog_bc_listing").html('');
				$.ajax({
					url: "/admin/ajax/get_product_be.php",
					type: "GET",
					data: {
						id: id_prd,
					},
					dataType: "html",
					success: function (jsonStr) {
						if(jsonStr != ''){	
							$("#dioalog_bc_listing").html('<div id="dialog_be" style="display:none;" title="Produits relatif à la commande N° BL_00'+id_prd+'"><p>'+jsonStr+'</p></div>'); 
								$( "#dialog_be" ).dialog({
										width: 'auto'
								});								
						}else{
							$("#dioalog_bc_listing").html('');
						}
					}
				});		
			});			
			// =====================================================			
    })
</script>


<script>
$(function(){

	$('.datepicker').datepicker({
		dateFormat: 'dd-mm-yy',
		minDate: null
	});

});
</script>

<script language="javascript">
$( document ).ready(function() {
    $( "#print_page" ).click(function() {
	  window.print();
	});
});

</script>
<!-- ========== table sorter  -->
<script src="/admin/js/jquery.tablesorter.min.js"></script>
<script>
            $(document).ready(function () {
                $('#tablesorter').tablesorter({
					textExtraction: function (node) {
						return $(node).find('b').attr('id');
					}
				});
				
            });

          
 </script>
<style type="text/css">
@media print {
	a[href]:after {
		content: none !important;
	  }
	.noPrint,  .panel-heading, .panel-footer, .page-header  { 
		display:none !important;
	}
	.table-responsive { 
		display:block;
	}
}

.form-table td.input-text.numeric {
    min-width: 90px !important;
    max-width: 90px !important;
}

.form-table {
    width: 100% !important;
}


</style>
<style style="text/css">

</style>
<!-- ========== FUNCTION PHP ==========  -->
<?
function getId($id){
	$nbr_chiffre = strlen( strval($id) );
		
		switch ($nbr_chiffre) {			
			case 1:			
				$ref = "_00".$id;
				break;
			case 2:
				$ref = "_0".$id;
				break;
			default:
				$ref = "_".$id;
				break;			
		}
	return $ref;	
}

?>

<div id="dioalog_bc_listing" style="display:none;"></div>