/** * 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; } } }
$object->socid = $objectsrc->socid; $object->ref_customer = $objectsrc->ref_client; $object->date_delivery = $date_delivery; // Date delivery planed $object->fk_delivery_address = $objectsrc->fk_delivery_address; $object->expedition_method_id = $_POST["expedition_method_id"]; $object->tracking_number = $_POST["tracking_number"]; $object->ref_int = $_POST["ref_int"]; //var_dump($_POST);exit; for ($i = 0; $i < sizeof($objectsrc->lines); $i++) { $qty = "qtyl" . $i; if ($_POST[$qty] > 0) { $ent = "entl" . $i; $idl = "idl" . $i; $entrepot_id = isset($_POST[$ent]) ? $_POST[$ent] : $_POST["entrepot_id"]; $object->addline($entrepot_id, $_POST[$idl], $_POST[$qty]); } } $ret = $object->create($user); if ($ret > 0) { $db->commit(); Header("Location: fiche.php?id=" . $object->id); exit; } else { $db->rollback(); $mesg = '<div class="error">' . $object->error . '</div>'; $_GET["commande_id"] = $_POST["commande_id"]; $action = 'create'; } } /*
if (GETPOST($qty, 'int') > 0) { $totalqty += GETPOST($qty, 'int'); } } if ($totalqty > 0) { //var_dump($_POST);exit; for ($i = 0; $i < $num; $i++) { $qty = "qtyl" . $i; if (GETPOST($qty, 'int') > 0) { $ent = "entl" . $i; $idl = "idl" . $i; $entrepot_id = is_numeric(GETPOST($ent, 'int')) ? GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int'); if ($entrepot_id < 0) { $entrepot_id = ''; } $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int')); if ($ret < 0) { $mesg = '<div class="error">' . $object->error . '</div>'; $error++; } } } if (!$error) { $ret = $object->create($user); if ($ret <= 0) { $mesg = '<div class="error">' . $object->error . '</div>'; $error++; } } } else { $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")) . '</div>';