$dispatchdetail->load($PDOdb, $rowid);
        $dispatchdetail->delete($PDOdb);
        setEventMessage('Ligne supprimée');
    } elseif (isset($_POST['btaddasset'])) {
        //var_dump($_POST);exit;
        $numserie = GETPOST('numserie');
        $asset = new TAsset();
        if ($asset->loadBy($PDOdb, $numserie, 'serial_number')) {
            _addExpeditiondetLine($PDOdb, $TImport, $expedition, $numserie);
            setEventMessage('Numéro de série enregistré');
        } else {
            setEventMessage('Aucun équipement pour ce numéro de série', 'errors');
        }
    }
}
fiche($PDOdb, $expedition, $TImport);
function _loadDetail(&$PDOdb, &$expedition)
{
    $TImport = array();
    foreach ($expedition->lines as $line) {
        $sql = "SELECT a.rowid as id,a.serial_number,p.ref,p.rowid, ea.fk_expeditiondet, ea.lot_number, ea.weight_reel, ea.weight_reel_unit\n\t\t\t\t\tFROM " . MAIN_DB_PREFIX . "expeditiondet_asset as ea\n\t\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON ( a.rowid = ea.fk_asset)\n\t\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "product as p ON (p.rowid = a.fk_product)\n\t\t\t\t\tWHERE ea.fk_expeditiondet = " . $line->line_id . "\n\t\t\t\t\t\tORDER BY ea.rang ASC";
        $PDOdb->Execute($sql);
        $Tres = $PDOdb->Get_All();
        foreach ($Tres as $res) {
            $TImport[] = array('ref' => $res->ref, 'numserie' => $res->serial_number, 'fk_product' => $res->rowid, 'fk_expeditiondet' => $res->fk_expeditiondet, 'lot_number' => $res->lot_number, 'quantity' => $res->weight_reel, 'quantity_unit' => $res->weight_reel_unit);
        }
    }
    return $TImport;
}
function _addExpeditiondetLine(&$PDOdb, &$TImport, &$expedition, $numserie)
{
function run(&$PDOdb, &$dashboard, $withHeader = true)
{
    echo fiche($dashboard, 'view', $withHeader);
}
                }
                //var_dump($diff_array, $TQtyDispatched,$TQtyWished);
                //exit('la'.$status);
                $commandefourn->setStatus($user, $status);
                $commandefourn->statut = $status;
                if (method_exists($commandefourn, 'log')) {
                    $commandefourn->log($user, $status, time());
                }
                // removed in 4.0
                setEventMessage('Equipements créés / produits ventilés');
            }
        }
    }
}
//if(is_array($TImport)) usort($TImport,'_by_ref');
fiche($commandefourn, $TImport);
function searchProductInCommandeLine($array, $idprod)
{
    $line = false;
    foreach ($array as $item) {
        if ($item->fk_product == $idprod) {
            $line = $item;
            break;
        }
    }
    return $line;
}
function _by_ref(&$a, &$b)
{
    if ($a['ref'] < $b['ref']) {
        return -1;
     break;
 case 'unset-expert':
     $query->load($PDOdb, GETPOST('id'));
     $query->expert = 0;
     $query->save($PDOdb);
     fiche($query);
     break;
 case 'view':
     $query->load($PDOdb, GETPOST('id'));
     fiche($query);
     break;
 case 'add':
     if (empty($user->rights->query->all->create)) {
         accessforbidden();
     }
     fiche($query);
     break;
 case 'run':
     $query->load($PDOdb, GETPOST('id'));
     run($PDOdb, $query);
     break;
 case 'run-in':
     $query->load($PDOdb, GETPOST('id'));
     run($PDOdb, $query, 2);
     break;
 case 'preview':
     $query->load($PDOdb, GETPOST('id'));
     run($PDOdb, $query, true);
     break;
 default:
     liste();
    case 'save':
        if (GETPOST('bt_cancel') != '') {
            header('location:' . dol_buildpath('/remise/admin/remise.php?type=' . GETPOST('type'), 1));
        } else {
            $remise->load($PDOdb, GETPOST('id'));
            $remise->set_values($_POST);
            $remise->save($PDOdb);
            setEventMessage($langs->trans('RemiseSaved'));
            header('location:' . dol_buildpath('/remise/admin/remise.php?type=' . GETPOST('type') . '&TListTBS[lPrice][orderBy][date_maj]=DESC', 1));
        }
    case 'edit':
        $remise->load($PDOdb, GETPOST('id'));
        fiche($remise, $type, 'edit');
        break;
    case 'new':
        fiche($remise, $type, 'edit');
        break;
    default:
        liste($type);
        break;
}
function fiche(&$remise, $type, $mode)
{
    global $conf, $langs, $db;
    $page_name = "RemiseSetup";
    llxHeader('', $langs->trans($page_name));
    $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
    print_fiche_titre($langs->trans($page_name), $linkback);
    // Configuration header
    $head = remiseAdminPrepareHead();
    dol_fiche_head($head, $type, $page_name, 0, "remise@remise");