Merge pull request #10808 from ATM-Marc/FIX_8.0_shipment_hooks

FIX: several hooks in shipping/delivery cards
This commit is contained in:
Laurent Destailleur 2019-03-14 18:07:57 +01:00 committed by GitHub
commit 4f84a1614c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 865 additions and 840 deletions

View File

@ -1141,6 +1141,12 @@ if ($action == 'create')
$line = $object->lines[$indiceAsked]; $line = $object->lines[$indiceAsked];
$parameters = array('i' => $indiceAsked, 'line' => $line, 'num' => $numAsked);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if(empty($reshook))
{
// Show product and description // Show product and description
$type=$line->product_type?$line->product_type:$line->fk_product_type; $type=$line->product_type?$line->product_type:$line->fk_product_type;
// Try to enhance type detection using date_start and date_end for free lines where type // Try to enhance type detection using date_start and date_end for free lines where type
@ -1583,6 +1589,7 @@ if ($action == 'create')
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
print '</tr>'; print '</tr>';
} }
}
$indiceAsked++; $indiceAsked++;
} }
@ -1986,6 +1993,11 @@ else if ($id || $ref)
print '</td></tr>'; print '</td></tr>';
} }
// Other attributes
$parameters = array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>"; print "</table>";
print '</div>'; print '</div>';
@ -2139,6 +2151,12 @@ else if ($id || $ref)
// Loop on each product to send/sent // Loop on each product to send/sent
for ($i = 0 ; $i < $num_prod ; $i++) for ($i = 0 ; $i < $num_prod ; $i++)
{
$parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if(empty($reshook))
{ {
print '<!-- origin line id = '.$lines[$i]->origin_line_id.' -->'; // id of order line print '<!-- origin line id = '.$lines[$i]->origin_line_id.' -->'; // id of order line
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -2434,6 +2452,7 @@ else if ($id || $ref)
print '</tr>'; print '</tr>';
} }
} }
}
// TODO Show also lines ordered but not delivered // TODO Show also lines ordered but not delivered

View File

@ -42,6 +42,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm')); $langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm'));
$hookmanager->initHooks(array('ordershipmentcard'));
$id=GETPOST('id','int'); // id of order $id=GETPOST('id','int'); // id of order
$ref= GETPOST('ref','alpha'); $ref= GETPOST('ref','alpha');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
@ -613,6 +615,7 @@ if ($id > 0 || ! empty($ref))
$sql.= " cd.qty,"; $sql.= " cd.qty,";
$sql.= ' cd.date_start,'; $sql.= ' cd.date_start,';
$sql.= ' cd.date_end,'; $sql.= ' cd.date_end,';
$sql.= ' cd.special_code,';
$sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc'; $sql.= ' p.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.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
@ -648,7 +651,12 @@ if ($id > 0 || ! empty($ref))
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$parameters = array('i' => $i, 'line' => $objp, 'num' => $num);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if(empty($reshook))
{
// Show product and description // Show product and description
$type=isset($objp->type)?$objp->type:$objp->product_type; $type=isset($objp->type)?$objp->type:$objp->product_type;
@ -805,7 +813,7 @@ if ($id > 0 || ! empty($ref))
} }
} }
} }
}
$i++; $i++;
} }
$db->free($resql); $db->free($resql);

View File

@ -346,7 +346,7 @@ else
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="ref" value="'.$object->ref.'">'; print '<input type="hidden" name="ref" value="'.$object->ref.'">';
dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), 0, 'sending'); dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), -1, 'sending');
/* /*
* Confirmation de la suppression * Confirmation de la suppression
@ -607,30 +607,30 @@ else
$var=true; $var=true;
while ($i < $num_prod) while ($i < $num_prod)
{ {
$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)) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if ($object->lines[$i]->fk_product > 0) if ($object->lines[$i]->fk_product > 0) {
{
$product = new Product($db); $product = new Product($db);
$product->fetch($object->lines[$i]->fk_product); $product->fetch($object->lines[$i]->fk_product);
// Define output language // Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
if (empty($newlang)) $newlang = $object->thirdparty->default_lang; if (empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) if (!empty($newlang)) {
{
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label; $label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
} } else
else
$label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label); $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
print '<td>'; print '<td>';
@ -645,13 +645,10 @@ else
//print $description; //print $description;
print $form->textwithtooltip($text, $description, 3, '', '', $i); print $form->textwithtooltip($text, $description, 3, '', '', $i);
print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end); print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) 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) : ''; print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? '<br>' . dol_htmlentitiesbr($object->lines[$i]->description) : '';
} }
} } else {
else
{
print "<td>"; print "<td>";
if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service');
else $text = img_object($langs->trans('Product'), 'product'); else $text = img_object($langs->trans('Product'), 'product');
@ -689,6 +686,7 @@ else
print $line->showOptionals($extrafieldsline, $mode, array('style' => $bc[$var], 'colspan' => $colspan), $i); print $line->showOptionals($extrafieldsline, $mode, array('style' => $bc[$var], 'colspan' => $colspan), $i);
print '</tr>'; print '</tr>';
} }
}
$i++; $i++;
} }