* Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2015 Juanjo Menent * Copyright (C) 2018 Frédéric France * Copyright (C) 2018 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/expedition/shipment.php * \ingroup expedition * \brief Tab shipments/delivery receipts on the order */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page $langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm','other')); $id = GETPOST('id', 'int'); // id of order $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $hookmanager->initHooks(array('ordershipmentcard')); // Security check $socid=0; if (! empty($user->socid)) $socid=$user->socid; $result=restrictedArea($user, 'commande', $id); $object = new Commande($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once /* * Actions */ $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Categorisation dans projet if ($action == 'classin') { $object = new Commande($db); $object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } if ($action == 'confirm_cloture' && GETPOST('confirm', 'alpha') == 'yes') { $object = new Commande($db); $object->fetch($id); $result = $object->cloture($user); } // Positionne ref commande client elseif ($action == 'setref_client' && $user->rights->commande->creer) { $result = $object->set_ref_client($user, GETPOST('ref_client')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'setdatedelivery' && $user->rights->commande->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object = new Commande($db); $object->fetch($id); $result = $object->set_date_livraison($user, $datelivraison); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } /* if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $object->setDeliveryAddress(GETPOST('delivery_address_id','int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } */ if ($action == 'setmode' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } if ($action == 'setavailability' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $result = $object->availability(GETPOST('availability_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } if ($action == 'setdemandreason' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } if ($action == 'setconditions' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } // shipping method if ($action == 'setshippingmethod' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // warehouse if ($action == 'setwarehouse' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } if ($error) $action = 'edit_extras'; } if ($action == 'set_thirdparty' && $user->rights->commande->creer) { $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; } /* * View */ $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } llxHeader('', $langs->trans('OrderCard'), ''); if ($id > 0 || !empty($ref)) { $object = new Commande($db); if ($object->fetch($id, $ref) > 0) { $object->loadExpeditions(1); $product_static = new Product($db); $soc = new Societe($db); $soc->fetch($object->socid); $author = new User($db); $author->fetch($object->user_author_id); $res = $object->fetch_optionals(); $head = commande_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), -1, 'order'); $formconfirm = ''; // Confirm validation if ($action == 'cloture') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id, $langs->trans("CloseShipment"), $langs->trans("ConfirmCloseShipment"), "confirm_cloture"); } // Call Hook formConfirm $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; // Order card $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); // Project if (! empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.='
'; $morehtmlref.=''; $morehtmlref.=''; $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.='
'; } else { $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (! empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); $morehtmlref.=''; $morehtmlref.=$proj->ref; $morehtmlref.=''; } else { $morehtmlref.=''; } } } $morehtmlref.='
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; print '
'; print ''; // Discounts for third party if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } print ''; // Date print ''; print ''; print ''; // Delivery date planned print ''; // Note on several rows //print ''; print ''; // Shipping Method print ''; print ''; // Warehouse if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); print ''; print ''; } // Terms of payment /* print ''; // Mode of payment print '';*/ // Availability print ''; // Source print ''; print ''; print ''; print ''; } // TODO How record was recorded OrderMode (llx_c_input_method) // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; print ''; } $expe = new Expedition($db); $extrafields->fetch_name_optionals_label($expe->table_element); // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); $absolute_discount = price2num($absolute_discount, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT'); $thirdparty = $soc; $discount_type = 0; $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); $cannotApplyDiscount = 1; include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
'.$langs->trans('Date').''; print dol_print_date($object->date, 'daytext'); if ($object->hasDelay() && empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } print '
'; print ''; if ($action != 'editdate_livraison') print ''; print '
'; print $langs->trans('DateDeliveryPlanned'); print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; print '
'; if ($action == 'editdate_livraison') { print '
'; print ''; print ''; print $form->selectDate($object->date_livraison > 0 ? $object->date_livraison : -1, 'liv_', '', '', '', "setdatedelivery"); print ''; print '
'; } else { print dol_print_date($object->date_livraison, 'daytext'); if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } print '
'.$langs->trans('NotePublic').' :
'; //print nl2br($object->note_public); //print '
'; print ''; if ($action != 'editshippingmethod' && $user->rights->expedition->creer) print ''; print '
'; print $langs->trans('SendingMethod'); print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'
'; print '
'; if ($action == 'editshippingmethod') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); } print '
'; print ''; if ($action != 'editwarehouse' && $user->rights->commande->creer) print ''; print '
'; print $langs->trans('Warehouse'); print 'id.'">'.img_edit($langs->trans('SetWarehouse'), 1).'
'; print '
'; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); } else { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); } print '
'; print ''; if ($action != 'editconditions' && $object->statut == Expedition::STATUS_VALIDATED) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print '
'; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); } print '
'; print ''; if ($action != 'editmode' && $object->statut == Expedition::STATUS_VALIDATED) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print '
'; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); } print '
'; print ''; if ($action != 'editavailability') print ''; print '
'; print $langs->trans('AvailabilityPeriod'); print 'id.'">'.img_edit($langs->trans('SetAvailability'), 1).'
'; print '
'; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); } print '
'; print ''; if ($action != 'editdemandreason') print ''; print '
'; print $langs->trans('Source'); print 'id.'">'.img_edit($langs->trans('SetDemandReason'), 1).'
'; print '
'; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); } $tmparray = $object->getTotalWeightVolume(); $totalWeight = $tmparray['weight']; $totalVolume = $tmparray['volume']; if ($totalWeight || $totalVolume) { print '
'.$langs->trans("CalculatedWeight").''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print '
'.$langs->trans("CalculatedVolume").''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print '
'; print '
'; print $langs->trans('IncotermLabel'); print ''; if ($user->rights->commande->creer) print ''.img_edit().''; else print ' '; print '
'; print '
'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '
'; print '
'; print '
'; print '
'; print '
'; print ''; if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print ''; print ''; print ''; // Multicurrency Amount VAT print ''; print ''; print ''; // Multicurrency Amount TTC print ''; print ''; print ''; } // Total HT print ''; print ''; print ''; // Total VAT print ''; print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { print ''; print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF { print ''; print ''; } // Total TTC print ''; print ''; print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$langs->trans('AmountHT').''.price($object->total_ht, 0, '', 1, -1, -1, $conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva, 0, '', 1, -1, -1, $conf->currency).'
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc, 0, '', 1, -1, -1, $conf->currency).'
'; print '
'; print '
'; print '
'; print '

'; /** * Lines or orders with quantity shipped and remain to ship * Note: Qty shipped are already available into $object->expeditions[fk_product] */ print ''; $sql = "SELECT cd.rowid, cd.fk_product, cd.product_type as type, cd.label, cd.description,"; $sql.= " cd.price, cd.tva_tx, cd.subprice,"; $sql.= " cd.qty,"; $sql.= ' cd.date_start,'; $sql.= ' cd.date_end,'; $sql.= ' cd.special_code,'; $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc,'; $sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,'; $sql.= ' p.surface, p.surface_units, p.volume, p.volume_units'; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " WHERE cd.fk_commande = ".$object->id; $sql.= " ORDER BY cd.rang, cd.rowid"; //print $sql; dol_syslog("shipment.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print ''; print ''; print ''; print ''; print ''; if (!empty($conf->stock->enabled)) { print ''; } else { print ''; } print "\n"; $toBeShipped = array(); $toBeShippedTotal = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $parameters = array('i' => $i, 'line' => $objp, 'num' => $num); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Show product and description $type = isset($objp->type) ? $objp->type : $objp->product_type; // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. if (!empty($objp->date_start)) $type = 1; if (!empty($objp->date_end)) $type = 1; print ''; // Product label if ($objp->fk_product > 0) { // Define output language if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); $prod = new Product($db); $prod->id = $objp->fk_product; $prod->entity = $objp->entity; $prod->getMultiLangs(); $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; if (empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; } else $label = (! empty($objp->label)?$objp->label:$objp->product_label); print ''; } else { print "\n"; } // Qty ordered print ''; // Qty already shipped $qtyProdCom = $objp->qty; print ''; // Qty remains to ship print ''; if ($objp->fk_product > 0) { $product = new Product($db); $product->fetch($objp->fk_product); $product->load_stock('warehouseopen'); } if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && !empty($conf->stock->enabled)) { print ''; } else { print ''; } print "\n"; // Show subproducts lines if ($objp->fk_product > 0 && !empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Set tree of subproducts in product->sousprods $product->get_sousproduits_arbo(); //var_dump($product->sousprods);exit; // Define a new tree with quantiies recalculated $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); //var_dump($prods_arbo); if (count($prods_arbo) > 0) { foreach ($prods_arbo as $key => $value) { $img = ''; if ($value['stock'] < $value['stock_alert']) { $img = img_warning($langs->trans("StockTooLow")); } print ''; print ''; print ''; print ''; print ''."\n"; } } } } $i++; } $db->free($resql); if (!$num) { print '
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("RealStock").' 
'; print ''; // ancre pour retourner sur la ligne // Show product and description $product_static->type=$type; $product_static->id=$objp->fk_product; $product_static->ref=$objp->ref; $product_static->entity = $objp->entity; $product_static->weight=$objp->weight; $product_static->weight_units=$objp->weight_units; $product_static->length=$objp->length; $product_static->length_units=$objp->length_units; $product_static->width=$objp->width; $product_static->width_units=$objp->width_units; $product_static->height=$objp->height; $product_static->height_units=$objp->height_units; $product_static->surface=$objp->surface; $product_static->surface_units=$objp->surface_units; $product_static->volume=$objp->volume; $product_static->volume_units=$objp->volume_units; $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { print ($objp->description && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; } print '
"; if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); if (!empty($objp->label)) { $text .= ' '.$objp->label.''; print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); } else { print $text.' '.nl2br($objp->description); } // Show range print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); print "'.$objp->qty.''; // Nb of sending products for this line of order $qtyAlreadyShipped = (!empty($object->expeditions[$objp->rowid]) ? $object->expeditions[$objp->rowid] : 0); print $qtyAlreadyShipped; print ''; if ($type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; $toBeShippedTotal += $toBeShipped[$objp->fk_product]; print $toBeShipped[$objp->fk_product]; } else { print '0 ('.$langs->trans("Service").')'; } print ''; print $product->stock_reel; if ($product->stock_reel < $toBeShipped[$objp->fk_product]) { print ' '.img_warning($langs->trans("StockTooLow")); } print ' 
      -> '.$value['fullpath'].' ('.$value['nb'].') '.$value['nb_total'].'  '.$value['stock'].' '.$img.'
'.$langs->trans("NoArticleOfTypeProduct").'
'; } print "
"; } else { dol_print_error($db); } print ''; /* * Boutons Actions */ if (empty($user->socid)) { print '
'; // Bouton expedier sans gestion des stocks if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { print ''.$langs->trans("CreateShipment").''; if ($toBeShippedTotal <= 0) { print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend")); } } else { print ''.$langs->trans("CreateShipment").''; } } print "
"; } // Bouton expedier avec gestion des stocks if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) { print $langs->trans("ValidateOrderFirstBeforeShipment"); } if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { //print load_fiche_titre($langs->trans("CreateShipment")); print '
'; print '
'; print ''; //print ''; print ''; print ''; print ''; print ''; //print ''; $langs->load("stocks"); //print ''; if (!empty($conf->stock->enabled)) { //print ''; //print ''; } //print ''; //print "
'; print $langs->trans("WarehouseSource"); //print ''; print $formproduct->selectWarehouses(!empty($object->warehouse_id) ? $object->warehouse_id : 'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200'); if (count($formproduct->cache_warehouses) <= 0) { print '   '.$langs->trans("WarehouseSourceNotDefined").' '.$langs->trans("AddOne").''; } //print ''; print ''; if ($toBeShippedTotal <= 0) { print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend")); } //print '
"; print "
\n"; print '
'; $somethingshown = 1; } else { print ''; } } show_list_sending_receive('commande', $object->id); } else { /* Order not found */ setEventMessages($langs->trans("NonExistentOrder"), null, 'errors'); } } // End of page llxFooter(); $db->close();