Merge branch '8.0' of git@github.com:Dolibarr/dolibarr.git into 9.0

Conflicts:
	htdocs/expedition/card.php
	htdocs/livraison/card.php
This commit is contained in:
Laurent Destailleur 2019-03-14 19:06:21 +01:00
commit a35a2faacb
4 changed files with 873 additions and 836 deletions

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi
// Load translation files required by the page
$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm'));
$hookmanager->initHooks(array('ordershipmentcard'));
$id=GETPOST('id','int'); // id of order
$ref= GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
@ -612,6 +614,7 @@ if ($id > 0 || ! empty($ref))
$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.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
@ -647,164 +650,169 @@ if ($id > 0 || ! empty($ref))
{
$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');
// 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 '<tr class="oddeven">';
// Product label
if ($objp->fk_product > 0)
if(empty($reshook))
{
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
// 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 '<tr class="oddeven">';
// Product label
if ($objp->fk_product > 0)
{
$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))
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
$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 '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // 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;
$text=$product_static->getNomUrl(1);
$text.= ' - '.$label;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'<br>';
$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)?'<br>'.dol_htmlentitiesbr($objp->description):'';
}
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
print '</td>';
}
else
$label = (! empty($objp->label)?$objp->label:$objp->product_label);
print '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // 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;
$text=$product_static->getNomUrl(1);
$text.= ' - '.$label;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'<br>';
$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)?'<br>'.dol_htmlentitiesbr($objp->description):'';
print "<td>";
if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
if (! empty($objp->label)) {
$text.= ' <strong>'.$objp->label.'</strong>';
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 "</td>\n";
}
print '</td>';
}
else
{
print "<td>";
if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
// Qty ordered
print '<td align="center">' . $objp->qty . '</td>';
if (! empty($objp->label)) {
$text.= ' <strong>'.$objp->label.'</strong>';
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 "</td>\n";
}
// Qty ordered
print '<td align="center">' . $objp->qty . '</td>';
// Qty already shipped
$qtyProdCom=$objp->qty;
print '<td align="center">';
// Nb of sending products for this line of order
$qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
print $qtyAlreadyShipped;
print '</td>';
// Qty remains to ship
print '<td align="center">';
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 '</td>';
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))
{
// Qty already shipped
$qtyProdCom=$objp->qty;
print '<td align="center">';
print $product->stock_reel;
if ($product->stock_reel < $toBeShipped[$objp->fk_product])
// Nb of sending products for this line of order
$qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
print $qtyAlreadyShipped;
print '</td>';
// Qty remains to ship
print '<td align="center">';
if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
print ' '.img_warning($langs->trans("StockTooLow"));
$toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
$toBeShippedTotal += $toBeShipped[$objp->fk_product];
print $toBeShipped[$objp->fk_product];
}
else
{
print '0 ('.$langs->trans("Service").')';
}
print '</td>';
}
else
{
print '<td>&nbsp;</td>';
}
print "</tr>\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)
if ($objp->fk_product > 0)
{
foreach($prods_arbo as $key => $value)
$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 '<td align="center">';
print $product->stock_reel;
if ($product->stock_reel < $toBeShipped[$objp->fk_product])
{
$img='';
if ($value['stock'] < $value['stock_alert'])
print ' '.img_warning($langs->trans("StockTooLow"));
}
print '</td>';
}
else
{
print '<td>&nbsp;</td>';
}
print "</tr>\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=img_warning($langs->trans("StockTooLow"));
$img='';
if ($value['stock'] < $value['stock_alert'])
{
$img=img_warning($langs->trans("StockTooLow"));
}
print '<tr class="oddeven"><td>&nbsp; &nbsp; &nbsp; -> <a href="'.DOL_URL_ROOT."/product/card.php?id=".$value['id'].'">'.$value['fullpath'].'</a> ('.$value['nb'].')</td>';
print '<td align="center"> '.$value['nb_total'].'</td>';
print '<td>&nbsp</td>';
print '<td>&nbsp</td>';
print '<td align="center">'.$value['stock'].' '.$img.'</td></tr>'."\n";
}
print '<tr class="oddeven"><td>&nbsp; &nbsp; &nbsp; -> <a href="'.DOL_URL_ROOT."/product/card.php?id=".$value['id'].'">'.$value['fullpath'].'</a> ('.$value['nb'].')</td>';
print '<td align="center"> '.$value['nb_total'].'</td>';
print '<td>&nbsp</td>';
print '<td>&nbsp</td>';
print '<td align="center">'.$value['stock'].' '.$img.'</td></tr>'."\n";
}
}
}
$i++;
}
$db->free($resql);

View File

@ -324,7 +324,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE u.rowid = x.fk_user_author";
$sql.= " AND x.entity = ".$conf->entity;
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',',$childids).')';

View File

@ -604,85 +604,94 @@ else
}
while ($i < $num_prod)
{
print '<tr class="oddeven">';
if ($object->lines[$i]->fk_product > 0)
$parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
$product = new Product($db);
$product->fetch($object->lines[$i]->fk_product);
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
print '<tr class="oddeven">';
if ($object->lines[$i]->fk_product > 0)
{
$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);
}
$product = new Product($db);
$product->fetch($object->lines[$i]->fk_product);
$label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
$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($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
}
else
{
$label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
}
print '<td>';
// Affiche ligne produit
$text = '<a href="' . DOL_URL_ROOT . '/product/card.php?id=' . $object->lines[$i]->fk_product . '">';
if ($object->lines[$i]->fk_product_type == 1) $text .= img_object($langs->trans('ShowService'), 'service');
else $text .= img_object($langs->trans('ShowProduct'), 'product');
$text .= ' ' . $object->lines[$i]->product_ref . '</a>';
$text .= ' - ' . $label;
$description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($object->lines[$i]->description));
//print $description;
print $form->textwithtooltip($text, $description, 3, '', '', $i);
print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
{
print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '<br>' . dol_htmlentitiesbr($object->lines[$i]->description) : '';
}
}
else
$label = ( ! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label);
print '<td>';
// Affiche ligne produit
$text = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$object->lines[$i]->fk_product.'">';
if ($object->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
else $text.= img_object($langs->trans('ShowProduct'),'product');
$text.= ' '.$object->lines[$i]->product_ref.'</a>';
$text.= ' - '.$label;
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->description));
//print $description;
print $form->textwithtooltip($text,$description,3,'','',$i);
print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
print (! empty($object->lines[$i]->description) && $object->lines[$i]->description!=$object->lines[$i]->product_label)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->description):'';
}
}
else
{
print "<td>";
if ($object->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
print "<td>";
if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service');
else $text = img_object($langs->trans('Product'), 'product');
if (! empty($object->lines[$i]->label)) {
$text.= ' <strong>'.$object->lines[$i]->label.'</strong>';
print $form->textwithtooltip($text,$object->lines[$i]->description,3,'','',$i);
} else {
print $text.' '.nl2br($object->lines[$i]->description);
if (!empty($object->lines[$i]->label)) {
$text .= ' <strong>' . $object->lines[$i]->label . '</strong>';
print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i);
} else {
print $text . ' ' . nl2br($object->lines[$i]->description);
}
print_date_range($objp->date_start, $objp->date_end);
print "</td>\n";
}
print_date_range($objp->date_start,$objp->date_end);
print "</td>\n";
}
print '<td align="center">' . $object->lines[$i]->qty_asked . '</td>';
print '<td align="center">' . $object->lines[$i]->qty_shipped . '</td>';
print '<td align="center">'.$object->lines[$i]->qty_asked.'</td>';
print '<td align="center">'.$object->lines[$i]->qty_shipped.'</td>';
print "</tr>";
print "</tr>";
//Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines)>0) {
$colspan=2;
$mode = ($object->statut == 0) ? 'edit' : 'view';
$line = new LivraisonLigne($db);
$line->fetch_optionals($object->lines[$i]->id);
if ($action = 'create_delivery') {
$srcLine = new ExpeditionLigne($db);
$expeditionLineExtrafields = new Extrafields($db);
$expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
$srcLine->fetch_optionals($expedition->lines[$i]->id);
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
// Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines) > 0) {
$colspan = 2;
$mode = ($object->statut == 0) ? 'edit' : 'view';
$line = new LivraisonLigne($db);
$line->fetch_optionals($object->lines[$i]->id);
if ($action = 'create_delivery') {
$srcLine = new ExpeditionLigne($db);
$expeditionLineExtrafields = new Extrafields($db);
$expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
$srcLine->fetch_optionals($expedition->lines[$i]->id);
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
}
print '<tr class="oddeven">';
print $line->showOptionals($extrafieldsline, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), $i);
print '</tr>';
}
print '<tr class="oddeven">';
print $line->showOptionals($extrafieldsline, $mode, array('style'=>'class="oddeven"', 'colspan'=>$colspan),$i);
print '</tr>';
}
$i++;