30require 
'../main.inc.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
 
   33require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
 
   34require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
 
   36require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
 
   37if (isModEnabled(
'project')) {
 
   38  require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
 
   39  require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
 
   41if (isModEnabled(
'stock')) {
 
   42  require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
 
   44if (isModEnabled(
"propal")) {
 
   45  require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
 
   47if (isModEnabled(
"product") || isModEnabled(
"service")) {
 
   48  require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
 
   52$langs->loadLangs(array(
'orders', 
'sendings', 
'companies', 
'bills', 
'propal', 
'deliveries', 
'stocks', 
'productbatch', 
'incoterm', 
'other'));
 
   56$action = 
GETPOST(
'action', 
'aZ09');
 
   58$hookmanager->initHooks(array(
'ordershipmentcard'));
 
   63if (!empty($user->socid)) {
 
   64  $socid = $user->socid;
 
   73$extrafields->fetch_name_optionals_label($object->table_element);
 
   76include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php'; 
 
   80  $socid = $user->socid;
 
   91$parameters = array(
'socid' => $socid);
 
   92$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
   99  if ($action == 
'classin') {
 
  101    $object->setProject(
GETPOST(
'projectid', 
'int'));
 
  104  if ($action == 
'confirm_cloture' && 
GETPOST(
'confirm', 
'alpha') == 
'yes') {
 
  106    $result = $object->cloture($user);
 
  107  } elseif ($action == 
'setref_client' && $user->hasRight(
'commande', 
'creer')) {
 
  109    $result = $object->set_ref_client($user, 
GETPOST(
'ref_client'));
 
  115  if ($action == 
'setdatedelivery' && $user->hasRight(
'commande', 
'creer')) {
 
  116    $datedelivery = 
dol_mktime(
GETPOST(
'liv_hour', 
'int'), 
GETPOST(
'liv_min', 
'int'), 0, 
GETPOST(
'liv_month', 
'int'), 
GETPOST(
'liv_day', 
'int'), 
GETPOST(
'liv_year', 
'int'));
 
  119    $result = $object->setDeliveryDate($user, $datedelivery);
 
  134  if ($action == 
'setmode' && $user->hasRight(
'commande', 
'creer')) {
 
  136    $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id', 
'int'));
 
  142  if ($action == 
'setavailability' && $user->hasRight(
'commande', 
'creer')) {
 
  144    $result = $object->availability(
GETPOST(
'availability_id'));
 
  150  if ($action == 
'setdemandreason' && $user->hasRight(
'commande', 
'creer')) {
 
  152    $result = $object->demand_reason(
GETPOST(
'demand_reason_id'));
 
  158  if ($action == 
'setconditions' && $user->hasRight(
'commande', 
'creer')) {
 
  160    $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id', 
'int'));
 
  164  } elseif ($action == 
'set_incoterms' && isModEnabled(
'incoterm')) {
 
  166    $result = $object->setIncoterms(
GETPOST(
'incoterm_id', 
'int'), 
GETPOST(
'location_incoterms', 
'alpha'));
 
  173  if ($action == 
'setshippingmethod' && $user->hasRight(
'commande', 
'creer')) {
 
  175    $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id', 
'int'));
 
  182  if ($action == 
'setwarehouse' && $user->hasRight(
'commande', 
'creer')) {
 
  184    $result = $object->setWarehouse(
GETPOST(
'warehouse_id', 
'int'));
 
  190  if ($action == 
'update_extras') {
 
  191    $object->oldcopy = 
dol_clone($object, 2);
 
  194    $ret = $extrafields->setOptionalsFromPost(
null, $object, 
GETPOST(
'attribute', 
'restricthtml'));
 
  201      $result = $object->insertExtraFields(
'SHIPMENT_MODIFY');
 
  209      $action = 
'edit_extras';
 
  213  if ($action == 
'set_thirdparty' && $user->hasRight(
'commande', 
'creer')) {
 
  215    $object->setValueFrom(
'fk_soc', $socid, 
'', 
'', 
'date', 
'', $user, 
'ORDER_MODIFY');
 
  217    header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
 
  221  include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
 
  228$form = 
new Form($db);
 
  231if (isModEnabled(
'project')) {
 
  235$title = $object->ref.
" - ".$langs->trans(
'Shipments');
 
  236$help_url = 
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
 
  240if ($id > 0 || !empty($ref)) {
 
  242  if ($object->fetch($id, $ref) > 0) {
 
  243    $object->loadExpeditions(1);
 
  245    $product_static = 
new Product($db);
 
  248    $soc->fetch($object->socid);
 
  250    $author = 
new User($db);
 
  251    $author->fetch($object->user_author_id);
 
  254    print 
dol_get_fiche_head($head, 
'shipping', $langs->trans(
"CustomerOrder"), -1, 
'order');
 
  260    if ($action == 
'cloture') {
 
  261      $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".urlencode($id), $langs->trans(
"CloseShipment"), $langs->trans(
"ConfirmCloseShipment"), 
"confirm_cloture");
 
  265    $parameters = array(
'formConfirm' => $formconfirm);
 
  266    $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action); 
 
  267    if (empty($reshook)) {
 
  268      $formconfirm .= $hookmanager->resPrint;
 
  269    } elseif ($reshook > 0) {
 
  270      $formconfirm = $hookmanager->resPrint;
 
  279    $linkback = 
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ? 
'?socid='.$socid : 
'').
'">'.$langs->trans(
"BackToList").
'</a>';
 
  282    $morehtmlref = 
'<div class="refidno">';
 
  284    $morehtmlref .= $form->editfieldkey(
"RefCustomer", 
'ref_customer', $object->ref_client, $object, $user->hasRight(
'commande', 
'creer'), 
'string', 
'', 0, 1);
 
  285    $morehtmlref .= $form->editfieldval(
"RefCustomer", 
'ref_customer', $object->ref_client, $object, $user->hasRight(
'commande', 
'creer'), 
'string', 
'', 
null, 
null, 
'', 1);
 
  287    $morehtmlref .= 
'<br>'.$soc->getNomUrl(1);
 
  289    if (isModEnabled(
'project')) {
 
  290      $langs->load(
"projects");
 
  291      $morehtmlref .= 
'<br>';
 
  293        $morehtmlref .= 
img_picto($langs->trans(
"Project"), 
'project', 
'class="pictofixedwidth"');
 
  294        if ($action != 
'classify') {
 
  295          $morehtmlref .= 
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
 
  297        $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 
'classify' ? 
'projectid' : 
'none'), 0, 0, 0, 1, 
'', 
'maxwidth300');
 
  299        if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
 
  301          $proj->fetch($objectsrc->fk_project);
 
  302          $morehtmlref .= $proj->getNomUrl(1);
 
  304            $morehtmlref .= 
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
 
  309    $morehtmlref .= 
'</div>';
 
  312    dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref);
 
  315    print 
'<div class="fichecenter">';
 
  316    print 
'<div class="fichehalfleft">';
 
  317    print 
'<div class="underbanner clearboth"></div>';
 
  319    print 
'<table class="border centpercent tableforfield">';
 
  323      $filterabsolutediscount = 
"fk_facture_source IS NULL"; 
 
  324      $filtercreditnote = 
"fk_facture_source IS NOT NULL"; 
 
  326      $filterabsolutediscount = 
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
 
  327      $filtercreditnote = 
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
 
  330    print 
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td colspan="2">';
 
  332    $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
 
  333    $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
 
  334    $absolute_discount = 
price2num($absolute_discount, 
'MT');
 
  335    $absolute_creditnote = 
price2num($absolute_creditnote, 
'MT');
 
  339    $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id);
 
  340    $cannotApplyDiscount = 1;
 
  341    include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
 
  345    print 
'<tr><td>'.$langs->trans(
'Date').
'</td>';
 
  346    print 
'<td colspan="2">';
 
  348    if ($object->hasDelay() && empty($object->delivery_date)) { 
 
  349      print 
' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(), 
"warning");
 
  355    print 
'<tr><td height="10">';
 
  356    print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
  357    print $langs->trans(
'DateDeliveryPlanned');
 
  360    if ($action != 
'editdate_livraison') {
 
  361      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate_livraison&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetDeliveryDate'), 1).
'</a></td>';
 
  363    print 
'</tr></table>';
 
  364    print 
'</td><td colspan="2">';
 
  365    if ($action == 
'editdate_livraison') {
 
  366      print 
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
 
  367      print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  368      print 
'<input type="hidden" name="action" value="setdatedelivery">';
 
  369      print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 
'liv_', 1, 1, 
'', 
"setdate_livraison", 1, 0);
 
  370      print 
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
 
  374      if ($object->hasDelay() && !empty($object->delivery_date)) {
 
  375        print 
' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(), 
"warning");
 
  382    print 
'<tr><td height="10">';
 
  383    print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
  384    print $langs->trans(
'AvailabilityPeriod');
 
  386    if ($action != 
'editavailability') {
 
  387      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editavailability&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetAvailability'), 1).
'</a></td>';
 
  389    print 
'</tr></table>';
 
  390    print 
'</td><td colspan="2">';
 
  391    if ($action == 
'editavailability') {
 
  392      $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id, 
'availability_id', 1);
 
  394      $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id, 
'none', 1);
 
  400    print 
'<table width="100%" class="nobordernopadding"><tr><td>';
 
  401    print $langs->trans(
'SendingMethod');
 
  403    if ($action != 
'editshippingmethod' && $user->hasRight(
'expedition', 
'creer')) {
 
  404      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editshippingmethod&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetShippingMode'), 1).
'</a></td>';
 
  406    print 
'</tr></table>';
 
  407    print 
'</td><td colspan="2">';
 
  408    if ($action == 
'editshippingmethod') {
 
  409      $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id, 
'shipping_method_id', 1);
 
  411      $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id, 
'none');
 
  417    if (isModEnabled(
'stock') && 
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
 
  418      require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
 
  421      print 
'<table width="100%" class="nobordernopadding"><tr><td>';
 
  422      print $langs->trans(
'Warehouse');
 
  424      if ($action != 
'editwarehouse' && $user->hasRight(
'commande', 
'creer')) {
 
  425        print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editwarehouse&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetWarehouse'), 1).
'</a></td>';
 
  427      print 
'</tr></table>';
 
  428      print 
'</td><td colspan="2">';
 
  429      if ($action == 
'editwarehouse') {
 
  430        $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id, 
'warehouse_id', 1);
 
  432        $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id, 
'none');
 
  439    print 
'<tr><td height="10">';
 
  440    print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
  441    print $langs->trans(
'Source');
 
  443    if ($action != 
'editdemandreason') {
 
  444      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdemandreason&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetDemandReason'), 1).
'</a></td>';
 
  446    print 
'</tr></table>';
 
  447    print 
'</td><td colspan="2">';
 
  448    if ($action == 
'editdemandreason') {
 
  449      $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id, 
'demand_reason_id', 1);
 
  451      $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id, 
'none');
 
  492    $tmparray = $object->getTotalWeightVolume();
 
  493    $totalWeight = $tmparray[
'weight'];
 
  494    $totalVolume = $tmparray[
'volume'];
 
  495    if ($totalWeight || $totalVolume) {
 
  496      print 
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
 
  497      print 
'<td colspan="2">';
 
  498      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');
 
  500      print 
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
 
  501      print 
'<td colspan="2">';
 
  502      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');
 
  509    if (isModEnabled(
'incoterm')) {
 
  511      print 
'<table width="100%" class="nobordernopadding"><tr><td>';
 
  512      print $langs->trans(
'IncotermLabel');
 
  513      print 
'<td><td class="right">';
 
  514      if ($user->hasRight(
'commande', 
'creer')) {
 
  515        print 
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'/expedition/shipment.php?id='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit().
'</a>';
 
  519      print 
'</td></tr></table>';
 
  521      print 
'<td colspan="2">';
 
  522      if ($action != 
'editincoterm') {
 
  523        print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
 
  525        print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : 
''), (!empty($object->location_incoterms) ? $object->location_incoterms : 
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
 
  531    $extrafields->fetch_name_optionals_label($expe->table_element);
 
  535    include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
 
  540    print 
'<div class="fichehalfright">';
 
  541    print 
'<div class="underbanner clearboth"></div>';
 
  543    print 
'<table class="border centpercent tableforfield">';
 
  545    if (isModEnabled(
"multicurrency") && ($object->multicurrency_code != $conf->currency)) {
 
  547      print 
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT', 
'multicurrency_total_ht', 
'', $object, 0).
'</td>';
 
  548      print 
'<td class="nowrap">'.price($object->multicurrency_total_ht, 
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
 
  552      print 
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT', 
'multicurrency_total_tva', 
'', $object, 0).
'</td>';
 
  553      print 
'<td class="nowrap">'.price($object->multicurrency_total_tva, 
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
 
  557      print 
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC', 
'multicurrency_total_ttc', 
'', $object, 0).
'</td>';
 
  558      print 
'<td class="nowrap">'.price($object->multicurrency_total_ttc, 
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
 
  563    print 
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'AmountHT').
'</td>';
 
  564    print 
'<td>'.price($object->total_ht, 0, 
'', 1, -1, -1, $conf->currency).
'</td>';
 
  568    print 
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($object->total_tva, 0, 
'', 1, -1, -1, $conf->currency).
'</td>';
 
  572    if ($mysoc->localtax1_assuj == 
"1" || $object->total_localtax1 != 0) {    
 
  573      print 
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
 
  574      print 
'<td>'.price($object->total_localtax1, 1, 
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
 
  576    if ($mysoc->localtax2_assuj == 
"1" || $object->total_localtax2 != 0) {    
 
  577      print 
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
 
  578      print 
'<td>'.price($object->total_localtax2, 1, 
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
 
  582    print 
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($object->total_ttc, 0, 
'', 1, -1, -1, $conf->currency).
'</td>';
 
  590    print 
'<div class="clearboth"></div><br>';
 
  597    print 
'<table id="tablelines" class="noborder noshadow" width="100%">';
 
  599    $sql = 
"SELECT cd.rowid, cd.fk_product, cd.product_type as type, cd.label, cd.description,";
 
  600    $sql .= 
" cd.price, cd.tva_tx, cd.subprice,";
 
  601    $sql .= 
" cd.qty, cd.fk_unit,";
 
  602    $sql .= 
' cd.date_start,';
 
  603    $sql .= 
' cd.date_end,';
 
  604    $sql .= 
' cd.special_code,';
 
  605    $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,';
 
  606    $sql .= 
' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,';
 
  607    $sql .= 
' p.surface, p.surface_units, p.volume, p.volume_units';
 
  608    $sql .= 
', p.tobatch, p.tosell, p.tobuy, p.barcode';
 
  609    $sql .= 
', u.short_label as unit_order';
 
  610    $sql .= 
" FROM ".MAIN_DB_PREFIX.
"commandedet as cd";
 
  611    $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
 
  612    $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_units as u ON cd.fk_unit = u.rowid";
 
  613    $sql .= 
" WHERE cd.fk_commande = ".((int) $object->id);
 
  614    $sql .= 
" ORDER BY cd.rang, cd.rowid";
 
  618    $resql = $db->query($sql);
 
  620      $num = $db->num_rows($resql);
 
  623      print 
'<tr class="liste_titre">';
 
  624      print 
'<th>'.$langs->trans(
"Description").
'</th>';
 
  625      print 
'<th class="center">'.$langs->trans(
"QtyOrdered").
'</th>';
 
  626      print 
'<th class="center">'.$langs->trans(
"QtyShipped").
'</th>';
 
  627      print 
'<th class="center">'.$langs->trans(
"KeepToShip").
'</th>';
 
  628      if (isModEnabled(
'stock')) {
 
  629        print 
'<th class="center">'.$langs->trans(
"RealStock").
'</th>';
 
  631        print 
'<th> </th>';
 
  636      $toBeShipped = array();
 
  637      $toBeShippedTotal = 0;
 
  639        $objp = $db->fetch_object($resql);
 
  641        $parameters = array(
'i' => $i, 
'line' => $objp, 
'num' => $num);
 
  642        $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
 
  647        if (empty($reshook)) {
 
  649          $type = isset($objp->type) ? $objp->type : $objp->product_type;
 
  653          if (!empty($objp->date_start)) {
 
  656          if (!empty($objp->date_end)) {
 
  660          print 
'<tr class="oddeven">';
 
  663          if ($objp->fk_product > 0) {
 
  666              $object->fetch_thirdparty();
 
  669              $prod->id = $objp->fk_product;
 
  670              $prod->entity = $objp->entity;
 
  671              $prod->getMultiLangs();
 
  673              $outputlangs = $langs;
 
  675              if (empty($newlang) && 
GETPOST(
'lang_id', 
'aZ09')) {
 
  676                $newlang = 
GETPOST(
'lang_id', 
'aZ09');
 
  678              if (empty($newlang)) {
 
  679                $newlang = $object->thirdparty->default_lang;
 
  681              if (!empty($newlang)) {
 
  683                $outputlangs->setDefaultLang($newlang);
 
  686              $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $objp->product_label;
 
  688              $label = (!empty($objp->label) ? $objp->label : $objp->product_label);
 
  692            print 
'<a name="'.$objp->rowid.
'"></a>'; 
 
  695            $product_static->type = $type;
 
  696            $product_static->id = $objp->fk_product;
 
  697            $product_static->ref = $objp->ref;
 
  698            $product_static->entity = $objp->entity;
 
  699            $product_static->status = $objp->tosell;
 
  700            $product_static->status_buy = $objp->tobuy;
 
  701            $product_static->status_batch = $objp->tobatch;
 
  702            $product_static->barcode = $objp->barcode;
 
  704            $product_static->weight = $objp->weight;
 
  705            $product_static->weight_units = $objp->weight_units;
 
  706            $product_static->length = $objp->length;
 
  707            $product_static->length_units = $objp->length_units;
 
  708            $product_static->width = $objp->width;
 
  709            $product_static->width_units = $objp->width_units;
 
  710            $product_static->height = $objp->height;
 
  711            $product_static->height_units = $objp->height_units;
 
  712            $product_static->surface = $objp->surface;
 
  713            $product_static->surface_units = $objp->surface_units;
 
  714            $product_static->volume = $objp->volume;
 
  715            $product_static->volume_units = $objp->volume_units;
 
  717            $text = $product_static->getNomUrl(1);
 
  718            $text .= 
' - '.$label;
 
  720            $description .= $product_static->show_photos(
'product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
 
  721            print $form->textwithtooltip($text, $description, 3, 
'', 
'', $i);
 
  724            print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end));
 
  728              print ($objp->description && $objp->description != $objp->product_label) ? 
'<br>'.dol_htmlentitiesbr($objp->description) : 
'';
 
  735              $text = 
img_object($langs->trans(
'Service'), 
'service');
 
  737              $text = 
img_object($langs->trans(
'Product'), 
'product');
 
  740            if (!empty($objp->label)) {
 
  741              $text .= 
' <strong>'.$objp->label.
'</strong>';
 
  742              print $form->textwithtooltip($text, $objp->description, 3, 
'', 
'', $i);
 
  744              print $text.
' '.nl2br($objp->description);
 
  748            print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end));
 
  753          print 
'<td class="center">'.$objp->qty.($objp->unit_order ? 
' '.$objp->unit_order : 
'').
'</td>';
 
  756          $qtyProdCom = $objp->qty;
 
  757          print 
'<td class="center">';
 
  759          $qtyAlreadyShipped = (!empty($object->expeditions[$objp->rowid]) ? $object->expeditions[$objp->rowid] : 0);
 
  760          print $qtyAlreadyShipped;
 
  761          print($objp->unit_order ? 
' '.$objp->unit_order : 
'').
'</td>';
 
  764          print 
'<td class="center">';
 
  766            $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
 
  767            $toBeShippedTotal += $toBeShipped[$objp->fk_product];
 
  768            print $toBeShipped[$objp->fk_product];
 
  770            print 
'0 <span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
 
  772          print($objp->unit_order ? 
' '.$objp->unit_order : 
'').
'</td>';
 
  774          if ($objp->fk_product > 0) {
 
  776            $product->fetch($objp->fk_product);
 
  777            $product->load_stock(
'warehouseopen');
 
  781            print 
'<td class="center">';
 
  782            print $product->stock_reel;
 
  783            if ($product->stock_reel < $toBeShipped[$objp->fk_product]) {
 
  784              print 
' '.img_warning($langs->trans(
"StockTooLow"));
 
  786                $nbPiece = $toBeShipped[$objp->fk_product] - $product->stock_reel;
 
  787                print 
'   '.$langs->trans(
"GoTo").
' <a href="'.DOL_URL_ROOT.
'/product/stock/product.php?id='.((int) $product->id).
'&action=correction&nbpiece='.urlencode($nbPiece).
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?id='.((
int) $object->id)).
'">'.$langs->trans(
"CorrectStock").
'</a>';
 
  792            print 
'<td class="center"><span class="opacitymedium">('.$langs->trans(
"Service").
')</span></td>';
 
  794            print 
'<td> </td>';
 
  801            $product->get_sousproduits_arbo();
 
  805            $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
 
  807            if (count($prods_arbo) > 0) {
 
  808              foreach ($prods_arbo as $key => $value) {
 
  810                if ($value[
'stock'] < $value[
'stock_alert']) {
 
  813                print 
'<tr class="oddeven"><td>      -> <a href="'.DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
'">'.$value[
'fullpath'].
'</a> ('.$value[
'nb'].
')</td>';
 
  814                print 
'<td class="center"> '.$value[
'nb_total'].
'</td>';
 
  815                print 
'<td> </td>';
 
  816                print 
'<td> </td>';
 
  817                print 
'<td class="center">'.$value[
'stock'].
' '.$img.
'</td></tr>'.
"\n";
 
  827        print 
'<tr '.$bc[
false].
'><td colspan="5">'.$langs->trans(
"NoArticleOfTypeProduct").
'<br>';
 
  842    if (empty($user->socid)) {
 
  843      print 
'<div class="tabsAction">';
 
  847        if ($user->hasRight(
'expedition', 
'creer')) {
 
  848          print 
'<a class="butAction" href="'.DOL_URL_ROOT.
'/expedition/card.php?action=create&origin=commande&object_id='.$id.
'">'.$langs->trans(
"CreateShipment").
'</a>';
 
  849          if ($toBeShippedTotal <= 0) {
 
  850            print 
' '.img_warning($langs->trans(
"WarningNoQtyLeftToSend"));
 
  853          print 
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"CreateShipment").
'</a>';
 
  863      print $langs->trans(
"ValidateOrderFirstBeforeShipment");
 
  867      if ($user->hasRight(
'expedition', 
'creer')) {
 
  869        print 
'<div class="tabsAction">';
 
  871        print 
'<form method="GET" action="'.DOL_URL_ROOT.
'/expedition/card.php">';
 
  872        print 
'<input type="hidden" name="action" value="create">';
 
  874        print 
'<input type="hidden" name="shipping_method_id" value="'.$object->shipping_method_id.
'">';
 
  875        print 
'<input type="hidden" name="origin" value="commande">';
 
  876        print 
'<input type="hidden" name="origin_id" value="'.$object->id.
'">';
 
  877        print 
'<input type="hidden" name="projectid" value="'.$object->fk_project.
'">';
 
  880        $langs->load(
"stocks");
 
  884        if (isModEnabled(
'stock')) {
 
  886          print $langs->trans(
"WarehouseSource");
 
  889          print $formproduct->selectWarehouses(!empty($object->warehouse_id) ? $object->warehouse_id : 
'ifone', 
'entrepot_id', 
'', 1, 0, 0, 
'', 0, 0, array(), 
'minwidth200');
 
  890          if (count($formproduct->cache_warehouses) <= 0) {
 
  891            print 
'   '.$langs->trans(
"WarehouseSourceNotDefined").
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create">'.$langs->trans(
"AddOne").
'</a>';
 
  896        print 
'<input type="submit" class="butAction" named="save" value="'.$langs->trans(
"CreateShipment").
'">';
 
  897        if ($toBeShippedTotal <= 0) {
 
  898          print 
' '.img_warning($langs->trans(
"WarningNoQtyLeftToSend"));
 
  909        print 
'<div class="tabsAction">';
 
  910        print 
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
"CreateShipment").
'</a>';
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage customers orders.
 
const STATUS_CLOSED
Closed (Sent, billed or not)
 
const STATUS_DRAFT
Draft status.
 
Class to manage shipments.
 
Class to manage products or services.
 
const TYPE_PRODUCT
Regular product.
 
const TYPE_SERVICE
Service.
 
Class to manage projects.
 
Class to manage third parties objects (customers, suppliers, prospects...)
 
Class to manage translations.
 
Class to manage Dolibarr users.
 
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
 
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
 
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
 
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
 
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
 
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
 
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
 
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
 
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
 
show_list_sending_receive($origin, $origin_id, $filter='')
List sendings and receive receipts.