/** * * @param unknown $object */ static function createShippingFromOrderOnBillPayed(&$object) { global $conf, $langs, $db, $user; if (empty($conf->global->GRAPEFRUIT_SHIPPING_CREATE_FROM_ORDER_WHERE_BILL_PAID) || $object->element != 'facture') { return true; } if (empty($object->linked_objects)) { $object->fetchObjectLinked(null, null, $object->id, 'facture'); } if (empty($object->linkedObjects['commande'])) { return false; } dol_include_once('/expedition/class/expedition.class.php'); $TNotCopy = array('db', 'element', 'table_element', 'fk_element'); foreach ($object->linkedObjects['commande'] as &$commande) { $expedition = new Expedition($db); foreach ($commande as $k => $v) { if (!in_array($k, $TNotCopy)) { $expedition->{$k} = $commande->{$k}; } } $expedition->tracking_number = ''; $expedition->size = 0; $expedition->weight = 0; $expedition->sizeS = $expedition->sizeH = $expedition->sizeW = 0; // TODO Should use this->trueDepth $expedition->width = 0; $expedition->height = 0; $expedition->weight_units = 0; $expedition->size_units = 0; if (empty($conf->global->GRAPEFRUIT_SHIPPING_CREATE_FROM_ORDER_WHERE_BILL_PAID_WAREHOUSE)) { setEventMessage($langs->trans('DefaultWarehouseRequired')); return false; } foreach ($expedition->lines as &$line) { $line->entrepot_id = (int) $conf->global->GRAPEFRUIT_SHIPPING_CREATE_FROM_ORDER_WHERE_BILL_PAID_WAREHOUSE; $line->origin_line_id = $line->id; } $res = $expedition->create($user); if ($res > 0) { $expedition->add_object_linked($commande->element, $commande->id); setEventMessage($langs->trans('ShippingCreated')); } else { var_dump($expedition); exit; } } return true; }
// 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'; } } /* * Build a receiving receipt */ if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) {
/** * 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; } } }