* Build a receiving receipt */ if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) { $object->fetch($id); $result = $object->create_delivery($user); if ($result > 0) { Header("Location: " . DOL_URL_ROOT . '/livraison/fiche.php?id=' . $result); exit; } else { $mesg = $object->error; } } if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) { $object->fetch($id); $object->fetch_thirdparty(); $result = $object->valid($user); // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) { $newlang = $_REQUEST['lang_id']; } if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->client->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $result = expedition_pdf_create($db, $object, $object->modelpdf, $outputlangs); if ($result <= 0) {
/** * Création automatique des expéditions à partir de la liste des expédiables, uniquement avec les quantité expédiables */ function createShipping($TIDCommandes, $TEnt_comm) { global $user, $langs, $conf; $db =& $this->db; dol_include_once('/expedition/class/expedition.class.php'); dol_include_once('/core/modules/expedition/modules_expedition.php'); // Option pour la génération PDF $hidedetails = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; $hidedesc = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0; $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0; $nbShippingCreated = 0; if (count($TIDCommandes) > 0) { $TIDCommandes = $this->orderCommandeByClient($TIDCommandes); foreach ($TIDCommandes as $id_commande) { $this->isOrderShippable($id_commande); $shipping = new Expedition($db); $shipping->origin = 'commande'; $shipping->origin_id = $id_commande; $shipping->date_delivery = $this->order->date_livraison; $shipping->note_public = $this->order->note_public; $shipping->note_private = $this->order->note_private; $shipping->weight_units = 0; $shipping->weight = "NULL"; $shipping->sizeW = "NULL"; $shipping->sizeH = "NULL"; $shipping->sizeS = "NULL"; $shipping->size_units = 0; $shipping->socid = $this->order->socid; $shipping->modelpdf = !empty($conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF) ? $conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF : 'rouget'; foreach ($this->order->lines as $line) { if ($this->TlinesShippable[$line->id]['stock'] > 0) { $shipping->addline($TEnt_comm[$this->order->id], $line->id, $this->TlinesShippable[$line->id]['qty_shippable'] > $this->TlinesShippable[$line->id]['to_ship'] ? $this->TlinesShippable[$line->id]['to_ship'] : $this->TlinesShippable[$line->id]['qty_shippable']); } } $nbShippingCreated++; $shipping->create($user); // Valider l'expédition if (!empty($conf->global->SHIPPABLE_ORDER_AUTO_VALIDATE_SHIPPING)) { $shipping->statut = 0; $shipping->valid($user); } // Génération du PDF if (!empty($conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF)) { $TFiles[] = $this->shipment_generate_pdf($shipping, $hidedetails, $hidedesc, $hideref); } } if ($nbShippingCreated > 0) { if ($conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF) { $this->generate_global_pdf($TFiles); } setEventMessage($langs->trans('NbShippingCreated', $nbShippingCreated)); $dol_version = (double) DOL_VERSION; if ($conf->global->SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT) { header("Location: " . $_SERVER["PHP_SELF"]); } else { if ($dol_version <= 3.6) { header("Location: " . dol_buildpath('/expedition/liste.php', 2)); } else { header("Location: " . dol_buildpath('/expedition/list.php', 2)); } exit; } } else { setEventMessage($langs->trans('NoOrderSelectedOrAlreadySent'), 'warnings'); $dol_version = (double) DOL_VERSION; if ($conf->global->SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT) { header("Location: " . $_SERVER["PHP_SELF"]); } else { if ($dol_version <= 3.6) { header("Location: " . dol_buildpath('/expedition/liste.php', 2)); } else { header("Location: " . dol_buildpath('/expedition/list.php', 2)); } exit; } } } else { setEventMessage($langs->trans('NoOrderSelectedOrAlreadySent'), 'warnings'); $dol_version = (double) DOL_VERSION; if ($conf->global->SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT) { header("Location: " . $_SERVER["PHP_SELF"]); } else { if ($dol_version <= 3.6) { header("Location: " . dol_buildpath('/expedition/liste.php', 2)); } else { header("Location: " . dol_buildpath('/expedition/list.php', 2)); } exit; } } }