* Actions
 */
$action = $_REQUEST['action'];
switch ($action) {
    case 'createShipping':
        if (!empty($_REQUEST['subCreateShip'])) {
            $TIDCommandes = $_REQUEST['TIDCommandes'];
            $TEnt_comm = $_REQUEST['TEnt_comm'];
            $order = new ShippableOrder($db);
            $order->createShipping($TIDCommandes, $TEnt_comm);
        }
        if (!empty($_REQUEST['subSetSent'])) {
            $TIDCommandes = $_REQUEST['TIDCommandes'];
            $order = new Commande($db);
            foreach ($TIDCommandes as $idCommande) {
                $order->setStatut(2, $idCommande, 'commande');
            }
        }
        break;
    case 'remove_file':
        $file = GETPOST('file');
        if (!empty($file)) {
            $file = DOL_DATA_ROOT . '/shippableorder/' . $file;
            $ret = dol_delete_file($file, 0, 0, 0);
            if ($ret) {
                setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
            } else {
                setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
            }
        }
        break;
     $sql .= ")";
     if ($db->query($sql)) {
         $db->commit();
     } else {
         $db->rollback();
     }
 }
 while ($ii < $nn) {
     include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
     $objectsrc = new Commande($db);
     dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
     $result = $objectsrc->fetch($orders_id[$ii]);
     if ($result > 0) {
         if ($closeOrders) {
             $objectsrc->classifyBilled();
             $objectsrc->setStatut(3);
         }
         $lines = $objectsrc->lines;
         if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) {
             $objectsrc->fetch_lines();
             $lines = $objectsrc->lines;
         }
         $fk_parent_line = 0;
         $num = count($lines);
         for ($i = 0; $i < $num; $i++) {
             $desc = $lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle;
             if ($lines[$i]->subprice < 0) {
                 // Negative line, we create a discount line
                 $discount = new DiscountAbsolute($db);
                 $discount->fk_soc = $object->socid;
                 $discount->amount_ht = abs($lines[$i]->total_ht);
     $sql .= ", '" . $object->element . "'";
     $sql .= ")";
     if ($db->query($sql)) {
         $db->commit();
     } else {
         $db->rollback();
     }
 }
 while ($ii < $nn) {
     dol_include_once('/commande/class/commande.class.php');
     $srcobject = new Commande($db);
     dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
     $result = $srcobject->fetch($orders_id[$ii]);
     if ($result > 0) {
         $srcobject->classer_facturee();
         $srcobject->setStatut(3);
         $lines = $srcobject->lines;
         if (empty($lines) && method_exists($srcobject, 'fetch_lines')) {
             $lines = $srcobject->fetch_lines();
         }
         $fk_parent_line = 0;
         $num = count($lines);
         for ($i = 0; $i < $num; $i++) {
             $desc = $lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle;
             if ($lines[$i]->subprice < 0) {
                 // Negative line, we create a discount line
                 $discount = new DiscountAbsolute($db);
                 $discount->fk_soc = $object->socid;
                 $discount->amount_ht = abs($lines[$i]->total_ht);
                 $discount->amount_tva = abs($lines[$i]->total_tva);
                 $discount->amount_ttc = abs($lines[$i]->total_ttc);