34require 
'../../main.inc.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
 
   36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
 
   37require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
 
   38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
 
   39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
 
   40require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
 
   41require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
 
   43if (isModEnabled(
'project')) {
 
   44  require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
 
   48$langs->loadLangs(array(
"bills", 
"orders", 
"sendings", 
"companies", 
"deliveries", 
"products", 
"stocks", 
"receptions"));
 
   50if (isModEnabled(
'productbatch')) {
 
   51  $langs->load(
'productbatch');
 
   57$lineid = 
GETPOST(
'lineid', 
'int');
 
   58$action = 
GETPOST(
'action', 
'aZ09');
 
   59$fk_default_warehouse = 
GETPOST(
'fk_default_warehouse', 
'int');
 
   60$cancel = 
GETPOST(
'cancel', 
'alpha');
 
   61$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   64  $socid = $user->socid;
 
   67$hookmanager->initHooks(array(
'ordersupplierdispatch'));
 
   71if (GETPOSTISSET(
"projectid")) {
 
   72  $projectid = 
GETPOST(
"projectid", 
'int');
 
   77if ($id > 0 || !empty($ref)) {
 
   78  $result = $object->fetch($id, $ref);
 
   82  $result = $object->fetch_thirdparty();
 
   88if (empty($conf->reception->enabled)) {
 
   89  $permissiontoreceive = $user->hasRight(
"fournisseur", 
"commande", 
"receptionner");
 
   90  $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"fournisseur", 
"commande", 
"receptionner")) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"fournisseur", 
"commande_advance", 
"check")));
 
   92  $permissiontoreceive = $user->hasRight(
"reception", 
"creer");
 
   93  $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"reception", 
"creer")) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"reception", 
"reception_advance", 
"validate")));
 
   97$result = 
restrictedArea($user, 
'fournisseur', $object, 
'commande_fournisseur', 
'commande');
 
   99if (!isModEnabled(
'stock')) {
 
  103$usercancreate  = ($user->hasRight(
"fournisseur", 
"commande", 
"creer") || $user->hasRight(
"supplier_order", 
"creer"));
 
  104$permissiontoadd  = $usercancreate; 
 
  111$parameters = array();
 
  112$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
  117if ($action == 
'checkdispatchline' && $permissiontocontrol) {
 
  123  $result = $supplierorderdispatch->fetch($lineid);
 
  126    setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 
'errors');
 
  131    $result = $supplierorderdispatch->setStatut(1);
 
  133      setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 
'errors');
 
  140    $result = $object->calcAndSetStatusDispatch($user);
 
  154if ($action == 
'uncheckdispatchline' && $permissiontocontrol) {
 
  160  $result = $supplierorderdispatch->fetch($lineid);
 
  163    setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 
'errors');
 
  168    $result = $supplierorderdispatch->setStatut(0);
 
  170      setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 
'errors');
 
  176    $result = $object->calcAndSetStatusDispatch($user);
 
  190if ($action == 
'denydispatchline' && $permissiontocontrol) {
 
  196  $result = $supplierorderdispatch->fetch($lineid);
 
  199    setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 
'errors');
 
  204    $result = $supplierorderdispatch->setStatut(2);
 
  206      setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 
'errors');
 
  212    $result = $object->calcAndSetStatusDispatch($user);
 
  226if ($action == 
'dispatch' && $permissiontoreceive) {
 
  233  foreach ($_POST as $key => $value) {
 
  236    if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
 
  241      $prod = 
"product_".$reg[1].
'_'.$reg[2];
 
  242      $qty = 
"qty_".$reg[1].
'_'.$reg[2];
 
  243      $ent = 
"entrepot_".$reg[1].
'_'.$reg[2];
 
  245        $ent = $fk_default_warehouse;
 
  247      $pu = 
"pu_".$reg[1].
'_'.$reg[2]; 
 
  248      $fk_commandefourndet = 
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
 
  250      if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 
  251        if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
 
  252          $dto = 
GETPOST(
"dto_".$reg[1].
'_'.$reg[2], 
'int');
 
  256          $saveprice = 
"saveprice_".$reg[1].
'_'.$reg[2];
 
  261      if ((
float) 
GETPOST($qty) != 0) {
 
  262        if (!(
GETPOST($ent, 
'int') > 0)) {
 
  263          dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
 
  264          $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
 
  265          setEventMessages($langs->trans(
'ErrorFieldRequired', $text), 
null, 
'errors');
 
  270          $result = $object->dispatchProduct($user, 
GETPOST($prod, 
'int'), 
GETPOST($qty), 
GETPOST($ent, 
'int'), 
GETPOST($pu), 
GETPOST(
'comment'), 
'', 
'', 
'', 
GETPOST($fk_commandefourndet, 
'int'), $notrigger);
 
  276          if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 
  277            if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
 
  284              if (GETPOSTISSET($saveprice)) {
 
  286                $sql = 
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
 
  287                $sql .= 
" SET unitprice='".price2num(
GETPOST($pu), 
'MU').
"'";
 
  288                $sql .= 
", price=".price2num(
GETPOST($pu), 
'MU').
"*quantity";
 
  289                $sql .= 
", remise_percent = ".((float) $dto);
 
  290                $sql .= 
" WHERE fk_soc=".((int) $object->socid);
 
  291                $sql .= 
" AND fk_product=".((int) 
GETPOST($prod, 
'int'));
 
  293                $resql = $db->query($sql);
 
  301    if (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
 
  307      $prod = 
'product_batch_'.$reg[1].
'_'.$reg[2];
 
  308      $qty = 
'qty_'.$reg[1].
'_'.$reg[2];
 
  309      $ent = 
'entrepot_'.$reg[1].
'_'.$reg[2];
 
  310      $pu = 
'pu_'.$reg[1].
'_'.$reg[2];
 
  311      $fk_commandefourndet = 
'fk_commandefourndet_'.$reg[1].
'_'.$reg[2];
 
  312      $lot = 
'lot_number_'.$reg[1].
'_'.$reg[2];
 
  313      $dDLUO = 
dol_mktime(12, 0, 0, 
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'month', 
'int'), 
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'day', 
'int'), 
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'year', 
'int'));
 
  314      $dDLC = 
dol_mktime(12, 0, 0, 
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'month', 
'int'), 
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'day', 
'int'), 
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'year', 
'int'));
 
  316      $fk_commandefourndet = 
'fk_commandefourndet_'.$reg[1].
'_'.$reg[2];
 
  318      if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 
  319        if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
 
  320          $dto = 
GETPOST(
"dto_".$reg[1].
'_'.$reg[2], 
'int');
 
  324          $saveprice = 
"saveprice_".$reg[1].
'_'.$reg[2];
 
  330        if (!(
GETPOST($ent, 
'int') > 0)) {
 
  331          dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
 
  332          $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline).
'-'.($reg[1] + 1);
 
  333          setEventMessages($langs->trans(
'ErrorFieldRequired', $text), 
null, 
'errors');
 
  337        if (!(
GETPOST($lot, 
'alpha') || $dDLUO || $dDLC)) {
 
  338          dol_syslog(
'No dispatch for line '.$key.
' as serial/eat-by/sellby date are not set');
 
  339          $text = $langs->transnoentities(
'atleast1batchfield').
', '.$langs->transnoentities(
'Line').
' '.($numline).
'-'.($reg[1] + 1);
 
  340          setEventMessages($langs->trans(
'ErrorFieldRequired', $text), 
null, 
'errors');
 
  345          $result = $object->dispatchProduct($user, 
GETPOST($prod, 
'int'), 
GETPOST($qty), 
GETPOST($ent, 
'int'), 
GETPOST($pu), 
GETPOST(
'comment'), $dDLUO, $dDLC, 
GETPOST($lot, 
'alpha'), 
GETPOST($fk_commandefourndet, 
'int'), $notrigger);
 
  351          if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 
  352            if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
 
  353              $dto = 
GETPOST(
"dto_".$reg[1].
'_'.$reg[2], 
'int');
 
  355              if (GETPOSTISSET($saveprice)) {
 
  357                $sql = 
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
 
  358                $sql .= 
" SET unitprice = ".price2num(
GETPOST($pu), 
'MU', 2);
 
  359                $sql .= 
", price = ".price2num(
GETPOST($pu), 
'MU', 2).
" * quantity";
 
  360                $sql .= 
", remise_percent = ".price2num((empty($dto) ? 0 : $dto), 3, 2).
"'";
 
  361                $sql .= 
" WHERE fk_soc = ".((int) $object->socid);
 
  362                $sql .= 
" AND fk_product=".((int) 
GETPOST($prod, 
'int'));
 
  364                $resql = $db->query($sql);
 
  374    $result = $object->calcAndSetStatusDispatch($user, 
GETPOST(
'closeopenorder') ? 1 : 0, 
GETPOST(
'comment'));
 
  381  if ($result >= 0 && !$error) {
 
  386    header(
"Location: dispatch.php?id=".$id);
 
  394if ($action == 
'confirm_deleteline' && $confirm == 
'yes' && $permissiontoreceive) {
 
  398  $result = $supplierorderdispatch->fetch($lineid);
 
  400    $qty = $supplierorderdispatch->qty;
 
  401    $entrepot = $supplierorderdispatch->fk_entrepot;
 
  402    $product = $supplierorderdispatch->fk_product;
 
  404    $comment = $supplierorderdispatch->comment;
 
  405    $eatby = $supplierorderdispatch->eatby;
 
  406    $sellby = $supplierorderdispatch->sellby;
 
  407    $batch = $supplierorderdispatch->batch;
 
  409    $result = $supplierorderdispatch->delete($user);
 
  412    $errors = $object->errors;
 
  416    if ($entrepot > 0 && isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) && empty($supplierorderdispatch->fk_reception)) {
 
  419        $mouv->origin = &$object;
 
  420        $mouv->setOrigin($object->element, $object->id);
 
  421        $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, 
'', $eatby, $sellby, $batch);
 
  423          $errors = $mouv->errors;
 
  438if ($action == 
'updateline' && $permissiontoreceive) {
 
  443  $result = $supplierorderdispatch->fetch($lineid);
 
  445    $qty = $supplierorderdispatch->qty;
 
  446    $entrepot = $supplierorderdispatch->fk_entrepot;
 
  447    $product = $supplierorderdispatch->fk_product;
 
  449    $comment = $supplierorderdispatch->comment;
 
  450    $eatby = $supplierorderdispatch->eatby;
 
  451    $sellby = $supplierorderdispatch->sellby;
 
  452    $batch = $supplierorderdispatch->batch;
 
  455    $supplierorderdispatch->fk_entrepot = 
GETPOST(
'fk_entrepot');
 
  456    $result = $supplierorderdispatch->update($user);
 
  460    $errors = $supplierorderdispatch->errors;
 
  463    if ($entrepot > 0 && isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
 
  466        $mouv->origin = &$object;
 
  467        $mouv->setOrigin($object->element, $object->id);
 
  468        $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, 
'', $eatby, $sellby, $batch);
 
  470          $errors = $mouv->errors;
 
  473          $mouv->origin = &$object;
 
  474          $result = $mouv->reception($user, $product, $supplierorderdispatch->fk_entrepot, $supplierorderdispatch->qty, $price, $comment, $eatby, $sellby, $batch);
 
  476            $errors = $mouv->errors;
 
  498$form = 
new Form($db);
 
  500$warehouse_static = 
new Entrepot($db);
 
  503$title = $object->ref.
" - ".$langs->trans(
'OrderDispatch');
 
  504$help_url = 
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
 
  505$morejs = array(
'/fourn/js/lib_dispatch.js.php');
 
  507llxHeader(
'', $title, $help_url, 
'', 0, 0, $morejs);
 
  509if ($id > 0 || !empty($ref)) {
 
  511  $soc->fetch($object->socid);
 
  513  $author = 
new User($db);
 
  514  $author->fetch($object->user_author_id);
 
  518  $title = $langs->trans(
"SupplierOrder");
 
  524  if ($action == 
'ask_deleteline') {
 
  525    $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'), 
'confirm_deleteline', 
'', 0, 1);
 
  529  $parameters = array(
'lineid' => $lineid);
 
  531  $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
 
  532  if (empty($reshook)) {
 
  533    $formconfirm .= $hookmanager->resPrint;
 
  534  } elseif ($reshook > 0) {
 
  535    $formconfirm = $hookmanager->resPrint;
 
  543  $linkback = 
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php'.(!empty($socid) ? 
'?socid='.$socid : 
'').
'">'.$langs->trans(
"BackToList").
'</a>';
 
  545  $morehtmlref = 
'<div class="refidno">';
 
  547  $morehtmlref .= $form->editfieldkey(
"RefSupplier", 
'ref_supplier', $object->ref_supplier, $object, 0, 
'string', 
'', 0, 1);
 
  548  $morehtmlref .= $form->editfieldval(
"RefSupplier", 
'ref_supplier', $object->ref_supplier, $object, 0, 
'string', 
'', 
null, 
null, 
'', 1);
 
  550  $morehtmlref .= 
'<br>'.$object->thirdparty->getNomUrl(1);
 
  552  if (isModEnabled(
'project')) {
 
  553    $langs->load(
"projects");
 
  554    $morehtmlref .= 
'<br>';
 
  556      $morehtmlref .= 
img_picto($langs->trans(
"Project"), 
'project', 
'class="pictofixedwidth"');
 
  557      if ($action != 
'classify' && $caneditproject) {
 
  558        $morehtmlref .= 
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
 
  560      $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 
'classify' ? 
'projectid' : 
'none'), 0, 0, 0, 1, 
'', 
'maxwidth300');
 
  562      if (!empty($object->fk_project)) {
 
  564        $proj->fetch($object->fk_project);
 
  565        $morehtmlref .= $proj->getNomUrl(1);
 
  567          $morehtmlref .= 
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
 
  572  $morehtmlref .= 
'</div>';
 
  575  dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref);
 
  578  print 
'<div class="fichecenter">';
 
  579  print 
'<div class="underbanner clearboth"></div>';
 
  581  print 
'<table class="border tableforfield" width="100%">';
 
  584  if ($object->methode_commande_id > 0) {
 
  585    print 
'<tr><td class="titlefield">'.$langs->trans(
"Date").
'</td><td>';
 
  586    if ($object->date_commande) {
 
  591    if ($object->methode_commande) {
 
  592      print 
'<tr><td>'.$langs->trans(
"Method").
'</td><td>'.$object->getInputMethod().
'</td></tr>';
 
  597  print 
'<tr><td class="titlefield">'.$langs->trans(
"AuthorRequest").
'</td>';
 
  598  print 
'<td>'.$author->getNomUrl(1, 
'', 0, 0, 0).
'</td>';
 
  601  $parameters = array();
 
  602  $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action); 
 
  619    print 
'<br><span class="opacitymedium">'.$langs->trans(
"OrderStatusNotReadyToDispatch").
'</span>';
 
  629    require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
 
  631    $formproduct->loadWarehouses();
 
  633    $listwarehouses = $entrepot->list_array(1);
 
  636    if (empty($conf->reception->enabled)) {
 
  637      print 
'<form method="POST" action="dispatch.php?id='.$object->id.
'">';
 
  639      print 
'<form method="post" action="'.dol_buildpath(
'/reception/card.php', 1).
'?originid='.$object->id.
'&origin=supplierorder">';
 
  642    print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  643    if (empty($conf->reception->enabled)) {
 
  644      print 
'<input type="hidden" name="action" value="dispatch">';
 
  646      print 
'<input type="hidden" name="action" value="create">';
 
  649    print 
'<div class="div-table-responsive-no-min">';
 
  650    print 
'<table class="noborder centpercent">';
 
  653    $products_dispatched = array();
 
  654    $sql = 
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
 
  655    $sql .= 
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
 
  656    $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
 
  657    $sql .= 
" WHERE cfd.fk_commande = ".((int) $object->id);
 
  658    $sql .= 
" GROUP BY l.rowid, cfd.fk_product";
 
  660    $resql = $db->query($sql);
 
  662      $num = $db->num_rows($resql);
 
  667          $objd = $db->fetch_object($resql);
 
  668          $products_dispatched[$objd->rowid] = 
price2num($objd->qty, 
'MS');
 
  676    $sql = 
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
 
  677    $sql .= 
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
 
  680    $parameters = array();
 
  681    $reshook = $hookmanager->executeHooks(
 
  682      'printFieldListSelect',
 
  690    $sql .= $hookmanager->resPrint;
 
  692    $sql .= 
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
 
  693    $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
 
  694    $sql .= 
" WHERE l.fk_commande = ".((int) $object->id);
 
  695    if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
 
  696      $sql .= 
" AND l.product_type = 0";
 
  700    $parameters = array();
 
  701    $reshook = $hookmanager->executeHooks(
 
  702      'printFieldListWhere',
 
  710    $sql .= $hookmanager->resPrint;
 
  713    $sql .= 
" ORDER BY l.rang, p.ref, p.label";
 
  715    $resql = $db->query($sql);
 
  717      $num = $db->num_rows($resql);
 
  721        print 
'<tr class="liste_titre">';
 
  723        print 
'<td>'.$langs->trans(
"Description").
'</td>';
 
  724        if (isModEnabled(
'productbatch')) {
 
  725          print 
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
 
  726          if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
  727            print 
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
 
  729          if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
  730            print 
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
 
  737        print 
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
 
  738        print 
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
 
  739        print 
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
 
  740        print 
' <td class="right">'.$langs->trans(
"QtyToDispatchShort");
 
  741        print 
'<br><a href="#" id="autoreset">'.img_picto($langs->trans(
"Reset"), 
'eraser', 
'class="pictofixedwidth opacitymedium"').$langs->trans(
"Reset").
'</a></td>';
 
  742        print 
'<td width="32"></td>';
 
  744        if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
 
  745          if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
 
  746            print 
'<td class="right">'.$langs->trans(
"Price").
'</td>';
 
  747            print 
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
 
  748            print 
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
 
  752        print 
'<td align="right">'.$langs->trans(
"Warehouse");
 
  755        if (count($listwarehouses) > 1) {
 
  756          print 
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0, 
'', 0, 0, $disabled, 
'', 
'minwidth100 maxwidth300', 1);
 
  757        } elseif (count($listwarehouses) == 1) {
 
  758          print 
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, 
'', 0, 0, $disabled, 
'', 
'minwidth100 maxwidth300', 1);
 
  764        $parameters = array();
 
  765        $reshook = $hookmanager->executeHooks(
 
  766          'printFieldListTitle',
 
  774        print $hookmanager->resPrint;
 
  783      $conf->cache[
'product'] = array();
 
  787        $objp = $db->fetch_object($resql);
 
  790        if (!$objp->fk_product > 0) {
 
  793          $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0;
 
  794          $remaintodispatch = 
price2num($objp->qty - ((
float) $alreadydispatched), 5); 
 
  795          if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) {
 
  796            $remaintodispatch = 0;
 
  799          if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
 
  808            print 
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
 
  810            print 
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
 
  811            print 
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.(float) $alreadydispatched.
'">';
 
  812            print 
'<tr class="oddeven">';
 
  814            if (empty($conf->cache[
'product'][$objp->fk_product])) {
 
  815              $tmpproduct = 
new Product($db);
 
  816              $tmpproduct->fetch($objp->fk_product);
 
  817              $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
 
  819              $tmpproduct = $conf->cache[
'product'][$objp->fk_product];
 
  822            $linktoprod = $tmpproduct->getNomUrl(1);
 
  823            $linktoprod .= 
' - '.$objp->label.
"\n";
 
  825            if (isModEnabled(
'productbatch')) {
 
  826              if ($objp->tobatch) {
 
  831                print 
'<td class="dispatch_batch_number"></td>';
 
  832                if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
  833                  print 
'<td class="dispatch_dlc"></td>';
 
  835                if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
  836                  print 
'<td class="dispatch_dluo"></td>';
 
  843                print 
'<td class="dispatch_batch_number">';
 
  844                print 
'<span class="opacitymedium small">'.$langs->trans(
"ProductDoesNotUseBatchSerial").
'</small>';
 
  846                if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
  847                  print 
'<td class="dispatch_dlc"></td>';
 
  849                if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
  850                  print 
'<td class="dispatch_dluo"></td>';
 
  854              print 
'<td colspan="4">';
 
  860            $up_ht_disc = $objp->subprice;
 
  861            if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) {
 
  862              $up_ht_disc = 
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 
'MU');
 
  866            print 
'<td class="right">'.$objp->sref.
'</td>';
 
  869            print 
'<td class="right">'.$objp->qty.
'</td>';
 
  872            print 
'<td class="right">'.$alreadydispatched.
'</td>';
 
  874            if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
 
  876              print 
'<td class="right">';
 
  886                'is_information_row' => 
true,
 
  891              $reshook = $hookmanager->executeHooks(
 
  892                'printFieldListValue',
 
  900              print $hookmanager->resPrint;
 
  904              print 
'<tr class="oddeven" name="'.$type.$suffix.
'">';
 
  906              print 
'<input name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
 
  907              print 
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
 
  909              print 
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
 
  910              if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) { 
 
  911                print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc, 
'MU').
'">';
 
  913                print 
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc, 
'MU').
'">';
 
  919              print 
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
 
  921              if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
  922                print 
'<td class="nowraponall">';
 
  924                print $form->selectDate($dlcdatesuffix, 
'dlc'.$suffix, 
'', 
'', 1, 
'');
 
  927              if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
  928                print 
'<td class="nowraponall">';
 
  930                print $form->selectDate($dluodatesuffix, 
'dluo'.$suffix, 
'', 
'', 1, 
'');
 
  933              print 
'<td colspan="3"> </td>'; 
 
  937              $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan;
 
  938              $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
 
  939              print 
'<td class="right">';
 
  949                'is_information_row' => 
true,
 
  954              $reshook = $hookmanager->executeHooks(
 
  955                'printFieldListValue',
 
  963              print $hookmanager->resPrint;
 
  967              print 
'<tr class="oddeven" name="'.$type.$suffix.
'">';
 
  968              print 
'<td colspan="'.$colspan.
'">';
 
  969              print 
'<input name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
 
  970              print 
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
 
  972              print 
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
 
  973              if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) { 
 
  974                print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc, 
'MU').
'">';
 
  976                print 
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc, 
'MU').
'">';
 
  983            print 
'<td class="right">';
 
  984            print 
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"), 
'eraser', 
'class="pictofixedwidth opacitymedium"').
'</a>';
 
  985            print 
'<input id="qty'.$suffix.
'" name="qty'.$suffix.
'" type="text" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET(
'qty'.$suffix) ? 
GETPOST(
'qty'.$suffix, 
'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).
'">';
 
  989            if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
 
  991              print 
img_picto($langs->trans(
'AddStockLocationLine'), 
'split.png', 
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"'); 
  994              print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"'); 
  998            if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { 
  999              if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) { 
 1001                print '<td class="right
">'; 
 1002                print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">'; 
 1006                print '<td class="right
">'; 
 1007                print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">'; 
 1011                print '<td class="center
">'; 
 1012                print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">'; 
 1018            print '<td class="right
">'; 
 1019            if (count($listwarehouses) > 1) { 
 1020              print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ?GETPOST("entrepot
".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot
".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); 
 1021            } elseif (count($listwarehouses) == 1) { 
 1022              print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ?GETPOST("entrepot
".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot
".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); 
 1024              $langs->load("errors
"); 
 1025              print $langs->trans("ErrorNoWarehouseDefined
"); 
 1029            // Enable hooks to append additional columns 
 1030            $parameters = array( 
 1031              'is_information_row' => false, // this is a dispatch form row 
 1033              'suffix' => $suffix, 
 1036            $reshook = $hookmanager->executeHooks( 
 1037              'printFieldListValue', 
 1043              setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 
 1045            print $hookmanager->resPrint; 
 1054      dol_print_error($db); 
 1061      $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); 
 1063      print '<div class="center
">'; 
 1064      $parameters = array(); 
 1065      $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been 
 1067      if (empty($reshook)) { 
 1068        if (empty($conf->reception->enabled)) { 
 1069          print $langs->trans("Comment").' : '; 
 1070          print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="'; 
 1071          print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref); 
 1072          // print ' / 
'.$object->ref_supplier; // Not yet available 
 1073          print '" class="flat
"><br>'; 
 1075          print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel; 
 1078        $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
"); 
 1081        print '<input type="hidden
" name="backtopageforcancel
" value="'.$_SERVER["PHP_SELF"].'?
id=
'.$object->id.'">'; 
 1082        print '<input type="submit
" class="button" name="dispatch
" value="'.dol_escape_htmltag($dispatchBt).'"'; 
 1084        if (!$permissiontoreceive) { 
 1087        if (count($listwarehouses) <= 0) { 
 1099    // Message if nothing to dispatch 
 1102      if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { 
 1103        print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all 
 1105        print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched. 
 1112  print dol_get_fiche_end(); 
 1114  // traitement entrepot par défaut 
 1115  print '<script type="text/javascript
"> 
 1116      $(document).ready(function () { 
 1117        $("select[
name=fk_default_warehouse]
").change(function() { 
 1118          var fk_default_warehouse = $("option:selected
", this).val(); 
 1119          $("select[
name^=entrepot_]
").val(fk_default_warehouse).change(); 
 1122              $("#autoreset
").click(function() { 
 1123          $(".qtydispatchinput
").each(function(){ 
 1124            id = $(this).attr("id"); 
 1125            idtab = id.split("_
"); 
 1129              $("#qty_dispatched_0_
"+idtab[2]).val("0
"); 
 1131              obj = $(this).parent().parent(); 
 1132              nameobj = obj.attr("name"); 
 1133              nametab = nameobj.split("_
"); 
 1135              $("tr[
name^=\
'"+nametab[0]+"_\'][name$=\'_"+nametab[2]+"\']:last .splitbutton").show(); 
 1140        $(".resetline").click(function(){ 
 1141          id = $(this).attr("id"); 
 1142          id = id.split("reset_"); 
 1143          console.log("Reset trigger for id = qty_"+id[1]); 
 1144          $("#qty_"+id[1]).val(""); 
 1150  $sql = 
"SELECT p.rowid as pid, p.ref, p.label,";
 
 1151  $sql .= 
" e.rowid as warehouse_id, e.ref as entrepot,";
 
 1152  $sql .= 
" cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec";
 
 1153  $sql .= 
" ,cd.rowid, cd.subprice";
 
 1154  if ($conf->reception->enabled) {
 
 1155    $sql .= 
" ,cfd.fk_reception, r.date_delivery";
 
 1157  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"product as p,";
 
 1158  $sql .= 
" ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
 
 1159  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet";
 
 1160  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"entrepot as e ON cfd.fk_entrepot = e.rowid";
 
 1161  if ($conf->reception->enabled) {
 
 1162    $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"reception as r ON cfd.fk_reception = r.rowid";
 
 1164  $sql .= 
" WHERE cfd.fk_commande = ".((int) $object->id);
 
 1165  $sql .= 
" AND cfd.fk_product = p.rowid";
 
 1166  $sql .= 
" ORDER BY cfd.rowid ASC";
 
 1168  $resql = $db->query($sql);
 
 1170    $num = $db->num_rows($resql);
 
 1178      print 
'<div class="div-table-responsive">';
 
 1179      print 
'<table id="dispatch_received_products" class="noborder centpercent">';
 
 1181      print 
'<tr class="liste_titre">';
 
 1183      if ($conf->reception->enabled) {
 
 1184        print 
'<td>'.$langs->trans(
"Reception").
'</td>';
 
 1187      print 
'<td>'.$langs->trans(
"Product").
'</td>';
 
 1188      print 
'<td class="center">'.$langs->trans(
"DateCreation").
'</td>';
 
 1189      print 
'<td class="center">'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
 
 1190      if (isModEnabled(
'productbatch')) {
 
 1191        print 
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
 
 1192        if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
 1193          print 
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
 
 1195        if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
 1196          print 
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
 
 1199      print 
'<td class="right">'.$langs->trans(
"QtyDispatched").
'</td>';
 
 1200      print 
'<td>'.$langs->trans(
"Warehouse").
'</td>';
 
 1201      print 
'<td>'.$langs->trans(
"Comment").
'</td>';
 
 1204      if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
 
 1205        print 
'<td class="center" colspan="2">'.$langs->trans(
"Status").
'</td>';
 
 1206      } elseif (isModEnabled(
"reception")) {
 
 1207        print 
'<td class="center"></td>';
 
 1210      print 
'<td class="center" colspan="2"></td>';
 
 1216        $objp = $db->fetch_object($resql);
 
 1218        if ($action == 
'editline' && $lineid == $objp->dispatchlineid) {
 
 1219          print 
'<form name="editdispatchedlines" id="editdispatchedlines" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'#line_'.
GETPOST(
'lineid', 
'int').
'" method="POST"> 
 1220          <input type="hidden" name="token" value="'.newToken().
'"> 
 1221          <input type="hidden" name="action" value="updateline"> 
 1222          <input type="hidden" name="mode" value=""> 
 1223          <input type="hidden" name="lineid" value="'.$objp->dispatchlineid.
'">';
 
 1226        print 
'<tr class="oddeven" id="line_'.$objp->dispatchlineid.
'" >';
 
 1229        if (isModEnabled(
"reception")) {
 
 1230          print 
'<td class="nowraponall">';
 
 1231          if (!empty($objp->fk_reception)) {
 
 1233            $reception->fetch($objp->fk_reception);
 
 1234            print $reception->getNomUrl(1);
 
 1241        print 
'<td class="tdoverflowmax150">';
 
 1242        if (empty($conf->cache[
'product'][$objp->fk_product])) {
 
 1243          $tmpproduct = 
new Product($db);
 
 1244          $tmpproduct->fetch($objp->fk_product);
 
 1245          $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
 
 1247          $tmpproduct = $conf->cache[
'product'][$objp->fk_product];
 
 1249        print $tmpproduct->getNomUrl(1);
 
 1250        print 
' - '.$objp->label;
 
 1254        print 
'<td class="center">'.dol_print_date($db->jdate($objp->datec), 
'day').
'</td>';
 
 1257        print 
'<td class="center">'.dol_print_date($db->jdate($objp->date_delivery), 
'day').
'</td>';
 
 1260        if (isModEnabled(
'productbatch')) {
 
 1262            include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
 
 1264            $lot->fetch(0, $objp->pid, $objp->batch);
 
 1265            print 
'<td class="dispatch_batch_number">'.$lot->getNomUrl(1).
'</td>';
 
 1266            if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
 1267              print 
'<td class="dispatch_dlc">'.dol_print_date($lot->sellby, 
'day').
'</td>';
 
 1269            if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
 1270              print 
'<td class="dispatch_dluo">'.dol_print_date($lot->eatby, 
'day').
'</td>';
 
 1273            print 
'<td class="dispatch_batch_number"></td>';
 
 1274            if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 
 1275              print 
'<td class="dispatch_dlc"></td>';
 
 1277            if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
 
 1278              print 
'<td class="dispatch_dluo"></td>';
 
 1284        print 
'<td class="right">';
 
 1285        if ($action == 
'editline' && $lineid == $objp->dispatchlineid) {
 
 1286          print 
'<input style="width: 50px;" type="text" min="1" name="qty" value="'.$objp->qty.
'" />';
 
 1290        print 
'<input type="hidden" name="price" value="'.$objp->subprice.
'" />';
 
 1294        print 
'<td class="tdoverflowmax150">';
 
 1295        if ($action == 
'editline' && $lineid == $objp->dispatchlineid) {
 
 1296          if (count($listwarehouses) > 1) {
 
 1297            print $formproduct->selectWarehouses(
GETPOST(
"fk_entrepot") ?
GETPOST(
"fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : 
''), 
"fk_entrepot", 
'', 1, 0, $objp->fk_product, 
'', 1, 1, null, 
'csswarehouse');
 
 1298          } elseif (count($listwarehouses) == 1) {
 
 1299            print $formproduct->selectWarehouses(
GETPOST(
"fk_entrepot") ?
GETPOST(
"fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : 
''), 
"fk_entrepot", 
'', 0, 0, $objp->fk_product, 
'', 1, 1, null, 
'csswarehouse');
 
 1301            $langs->load(
"errors");
 
 1302            print $langs->trans(
"ErrorNoWarehouseDefined");
 
 1305          $warehouse_static->id = $objp->warehouse_id;
 
 1306          $warehouse_static->label = $objp->entrepot;
 
 1307          print $warehouse_static->getNomUrl(1);
 
 1312        print 
'<td class="tdoverflowmax300" style="white-space: pre;">'.$objp->comment.
'</td>';
 
 1315        if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) {
 
 1316          print 
'<td class="right">';
 
 1317          $supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
 
 1319          print $supplierorderdispatch->getLibStatut(5);
 
 1323          print 
'<td class="center">';
 
 1324          if (!$permissiontocontrol) {
 
 1325            if (empty($objp->status)) {
 
 1326              print 
'<a class="button buttonRefused" href="#">'.$langs->trans(
"Approve").
'</a>';
 
 1327              print 
'<a class="button buttonRefused" href="#">'.$langs->trans(
"Deny").
'</a>';
 
 1329              print 
'<a class="button buttonRefused" href="#">'.$langs->trans(
"Disapprove").
'</a>';
 
 1330              print 
'<a class="button buttonRefused" href="#">'.$langs->trans(
"Deny").
'</a>';
 
 1334            if ($object->statut == 5) {
 
 1337            if (empty($objp->status)) {
 
 1338              print 
'<a class="button'.($disabled ? 
' buttonRefused' : 
'').
'" href="'.$_SERVER[
"PHP_SELF"].
"?id=".$id.
"&action=checkdispatchline&lineid=".$objp->dispatchlineid.
'">'.$langs->trans(
"Approve").
'</a>';
 
 1339              print 
'<a class="button'.($disabled ? 
' buttonRefused' : 
'').
'" href="'.$_SERVER[
"PHP_SELF"].
"?id=".$id.
"&action=denydispatchline&lineid=".$objp->dispatchlineid.
'">'.$langs->trans(
"Deny").
'</a>';
 
 1341            if ($objp->status == 1) {
 
 1342              print 
'<a class="button'.($disabled ? 
' buttonRefused' : 
'').
'" href="'.$_SERVER[
"PHP_SELF"].
"?id=".$id.
"&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.
'">'.$langs->trans(
"Reinit").
'</a>';
 
 1343              print 
'<a class="button'.($disabled ? 
' buttonRefused' : 
'').
'" href="'.$_SERVER[
"PHP_SELF"].
"?id=".$id.
"&action=denydispatchline&lineid=".$objp->dispatchlineid.
'">'.$langs->trans(
"Deny").
'</a>';
 
 1345            if ($objp->status == 2) {
 
 1346              print 
'<a class="button'.($disabled ? 
' buttonRefused' : 
'').
'" href="'.$_SERVER[
"PHP_SELF"].
"?id=".$id.
"&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.
'">'.$langs->trans(
"Reinit").
'</a>';
 
 1347              print 
'<a class="button'.($disabled ? 
' buttonRefused' : 
'').
'" href="'.$_SERVER[
"PHP_SELF"].
"?id=".$id.
"&action=checkdispatchline&lineid=".$objp->dispatchlineid.
'">'.$langs->trans(
"Approve").
'</a>';
 
 1351        } elseif (isModEnabled(
"reception")) {
 
 1352          print 
'<td class="right">';
 
 1353          if (!empty($reception->id)) {
 
 1354            print $reception->getLibStatut(5);
 
 1360        if ($action != 
'editline' || $lineid != $objp->dispatchlineid) {
 
 1361          if (empty($reception->id) || ($reception->statut == Reception::STATUS_DRAFT)) { 
 
 1362            print 
'<td class="linecoledit center">';
 
 1363            print 
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.newToken().
'&lineid='.$objp->dispatchlineid.
'#line_'.$objp->dispatchlineid.
'">';
 
 1368            print 
'<td class="linecoldelete center">';
 
 1369            print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=ask_deleteline&token='.newToken().
'&lineid='.$objp->dispatchlineid.
'#dispatch_received_products">';
 
 1374            print 
'<td></td><td></td>';
 
 1377          print 
'<td class="center valignmiddle">';
 
 1378          print 
'<input type="submit" class="button button-save" id="savelinebutton" name="save" value="'.$langs->trans(
"Save").
'" />';
 
 1380          print 
'<td class="center valignmiddle">';
 
 1381          print 
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'" />';
 
 1387        if ($action == 
'editline' && $lineid == $objp->dispatchlineid) {
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage table commandefournisseurdispatch.
Class to manage predefined suppliers products.
const STATUS_RECEIVED_PARTIALLY
Received partially.
const STATUS_CANCELED
Order canceled.
const STATUS_RECEIVED_COMPLETELY
Received completely.
const STATUS_ACCEPTED
Accepted.
const STATUS_ORDERSENT
Order sent, shipment on process.
Class to manage warehouses.
Class to manage stock movements.
Class to manage products or services.
Class with list of lots and properties.
Class to manage projects.
Class to manage receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
ordersupplier_prepare_head(CommandeFournisseur $object)
Prepare array with list of tabs.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete 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...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
$conf db name
Only used if Module[ID]Name translation string is not found.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.