function fiche(&$PDOdb, &$expedition, &$TImport)
{
    global $langs, $db;
    llxHeader();
    $head = shipping_prepare_head($expedition);
    $title = $langs->trans("Shipment");
    dol_fiche_head($head, 'dispatch', $title, 0, 'dispatch');
    enteteexpedition($expedition);
    echo '<br>';
    if ($expedition->statut == 0) {
        //Form pour import de fichier
        if ($conf->global->DISPATCH_USE_IMPORT_FILE) {
            $form = new TFormCore('auto', 'formimport', 'post', true);
            echo $form->hidden('action', 'SAVE');
            echo $form->hidden('id', $expedition->id);
            echo $form->fichier('Fichier à importer', 'file1', '', 80);
            echo $form->btsubmit('Envoyer', 'btsend');
            $form->end();
        }
        ?>
		<script>
			$(document).ready(function() {

				$('#lot_number').change(function() {
					var lot_number = $(this).val();

					$.ajax({
						url: 'script/interface.php',
						method: 'GET',
						data: {
							lot_number: lot_number,
							productid: $('#lineexpeditionid').find(':selected').attr('fk-product'),
							type:'get',
							get:'autocomplete_asset'
						}
					}).done(function(results) {
						var json_results = $.parseJSON(results);

						$('#numserie option').remove();
						cpt = 0;
						$.each(json_results, function(index) {
							var obj = json_results[index];
							cpt ++;
							$('#numserie').append($('<option>', {
								value: obj.serial_number,
								text: obj.serial_number + ' - ' + obj.qty + ' ' +obj.unite_string
							}));

							$('#quantity').val(obj.qty);
							if(obj.unite != 'unité(s)'){
								$('#quantity_unit').show();
								$('#units_lable').remove();
								$('#quantity_unit option[value='+obj.unite+']').attr("selected","selected");
							}
							else{
								$('#quantity_unit').hide();
								$('#quantity_unit option[value=0]').attr("selected","selected");
								$('#quantity').after('<span id="units_lable"> unité(s)</span>');
							}
						});
					});
				});
				
				$('#lineexpeditionid').change(function() {
					var productid = $(this).find(':selected').attr('fk-product');

					$.ajax({
						url: 'script/interface.php',
						method: 'GET',
						data: {
							productid: productid,
							type:'get',
							get:'autocomplete_lot_number'
						}
					}).done(function(results) {
						var json_results = $.parseJSON(results);

						$('#lot_number option').remove();
						
						$.each(json_results, function(index) {
							var obj = json_results[index];
							
							$('#lot_number').append($('<option>', {
								value: obj.lot_number,
								text: obj.label
							}));
						});
					});
				});
			});
		</script>
		<?php 
        //Form pour ajouter un équipement directement
        $DoliForm = new FormProduct($db);
        $form = new TFormCore('auto', 'formaddasset', 'post', true);
        echo $form->hidden('action', 'edit');
        echo $form->hidden('mode', 'addasset');
        echo $form->hidden('id', $expedition->id);
        $TLotNumber = array(' -- aucun produit sélectionné -- ');
        /*$sql = "SELECT DISTINCT(lot_number),rowid, SUM(contenancereel_value) as qty, contenancereel_units as unit FROM ".MAIN_DB_PREFIX."asset GROUP BY lot_number ORDER BY lot_number ASC";
        
        		$PDOdb->Execute($sql);
        		$Tres = $PDOdb->Get_All();
        		foreach($Tres as $res){
        			
        			$asset = new TAsset;
        			$asset->load($PDOdb, $res->rowid);
        			$asset->load_asset_type($PDOdb);
        			//pre($asset,true);exit;
        			$TLotNumber[$res->lot_number] = $res->lot_number." / ".$res->qty." ".(($asset->assetType->measuring_units == 'unit') ? 'unité(s)' : measuring_units_string($res->unit,$asset->assetType->measuring_units));
        		}
        		*/
        $TSerialNumber = array(' -- aucun lot sélectionné -- ');
        /*$sql = "SELECT DISTINCT(serial_number),contenancereel_value, contenancereel_units FROM ".MAIN_DB_PREFIX."asset ORDER BY serial_number ASC";
        		$PDOdb->Execute($sql);
        		while ($PDOdb->Get_line()) {
        			$TSerialNumber[$PDOdb->Get_field('serial_number')] = $PDOdb->Get_field('serial_number').' / '.$PDOdb->Get_field('contenancereel_value')." ".measuring_units_string($PDOdb->Get_field('contenancereel_units'),'weight');
        		}
        		*/
        echo 'Produit expédié<select id="lineexpeditionid" name="lineexpeditionid"><option value=""></option>';
        $TProduct = array('');
        $sql = "SELECT DISTINCT(ed.rowid),p.rowid as fk_product,p.ref,p.label ,ed.qty\n\t\t\t\tFROM " . MAIN_DB_PREFIX . "product as p\n\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "commandedet as cd ON (cd.fk_product = p.rowid)\n\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "expeditiondet as ed ON (ed.fk_origin_line = cd.rowid)\n\t\t\t\tWHERE ed.fk_expedition = " . $expedition->id . "";
        $PDOdb->Execute($sql);
        while ($obj = $PDOdb->Get_line()) {
            //$TProduct[$PDOdb->Get_field('rowid')] = $PDOdb->Get_field('ref').' - '.$PDOdb->Get_field('label');
            echo '<option value="' . $obj->rowid . '" fk-product="' . $obj->fk_product . '">' . $obj->ref . ' - ' . $obj->label . ' x ' . $obj->qty . '</option>';
        }
        echo '</select><br />';
        //echo $form->combo('Produit expédié', 'lineexpeditionid', $TProduct, '').'<br>';
        echo $form->combo('Numéro de Lot', 'lot_number', $TLotNumber, '') . '<br>';
        echo $form->combo('Numéro de série à ajouter', 'numserie', $TSerialNumber, '') . '<br>';
        echo $form->texte('Quantité', 'quantity', '', 10) . " " . $DoliForm->load_measuring_units('quantity_unit" id="quantity_unit', 'weight');
        echo $form->btsubmit('Ajouter', 'btaddasset');
        $form->end();
        echo '<br>';
    }
    tabImport($TImport, $expedition);
    llxFooter();
}
function fiche(&$commande, &$TImport)
{
    global $langs, $db, $conf;
    llxHeader();
    $head = ordersupplier_prepare_head($commande);
    $title = $langs->trans("SupplierOrder");
    dol_fiche_head($head, 'recepasset', $title, 0, 'order');
    entetecmd($commande);
    $form = new TFormCore('auto', 'formrecept', 'post', true);
    echo $form->hidden('action', 'SAVE');
    echo $form->hidden('id', $commande->id);
    if ($commande->statut < 5 && $conf->global->DISPATCH_USE_IMPORT_FILE) {
        echo $form->fichier('Fichier à importer', 'file1', '', 80);
        echo $form->btsubmit('Envoyer', 'btsend');
    }
    tabImport($TImport, $commande);
    $form->end();
    _list_already_dispatched($commande);
    llxFooter();
}