Fix regression in creation of invoice
Uniformize code
This commit is contained in:
parent
e39e20b1a4
commit
b4c20f1b1a
@ -776,6 +776,8 @@ class FormFile
|
||||
|
||||
/**
|
||||
* Show a Document icon with link(s)
|
||||
* You may want to call this into a div like this:
|
||||
* print '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>';
|
||||
*
|
||||
* @param string $modulepart propal, facture, facture_fourn, ...
|
||||
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||
|
||||
@ -587,9 +587,10 @@ class CommandeFournisseur extends CommonOrder
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param string $option On what the link points
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @return string Chain with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto=0,$option='')
|
||||
public function getNomUrl($withpicto=0,$option='',$notooltip=0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
@ -606,14 +607,28 @@ class CommandeFournisseur extends CommonOrder
|
||||
if (! empty($this->total_ttc))
|
||||
$label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$picto='order';
|
||||
$url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id;
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label=$langs->trans("ShowOrder");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip"';
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend='</a>';
|
||||
|
||||
$picto='order';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
|
||||
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
$result.=$link.$this->ref.$linkend;
|
||||
$result.=$linkstart.$this->ref.$linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -1765,9 +1765,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param int $max Max length of shown ref
|
||||
* @param int $short 1=Return just URL
|
||||
* @param string $moretitle Add more text to title tooltip
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='')
|
||||
public function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='',$notooltip=0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
@ -1802,10 +1803,23 @@ class FactureFournisseur extends CommonInvoice
|
||||
$ref=$this->ref;
|
||||
if (empty($ref)) $ref=$this->id;
|
||||
|
||||
$linkstart='<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label=$langs->trans("ShowSupplierInvoice");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip"';
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend.' ');
|
||||
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend.' ');
|
||||
$result.=$linkstart.($max?dol_trunc($ref,$max):$ref).$linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -412,6 +412,7 @@ if (empty($reshook))
|
||||
|
||||
$id = $object->createFromCurrent($user);
|
||||
if ($id <= 0) {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
@ -506,7 +507,7 @@ if (empty($reshook))
|
||||
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $line->product_type == 9) {
|
||||
$fk_parent_line = $result;
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -571,8 +572,6 @@ if (empty($reshook))
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$tmpproject = GETPOST('projectid', 'int');
|
||||
|
||||
// Creation facture
|
||||
@ -745,34 +744,34 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error)
|
||||
if ($error)
|
||||
{
|
||||
$langs->load("errors");
|
||||
$db->rollback();
|
||||
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='create';
|
||||
$_GET['socid']=$_POST['socid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$outputlangs = $langs;
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result < 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
$db->rollback();
|
||||
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='create';
|
||||
$_GET['socid']=$_POST['socid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$outputlangs = $langs;
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error($db,$object->error,$object->errors);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
dol_print_error($db,$object->error,$object->errors);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -506,8 +506,8 @@ foreach ($listofreferent as $key => $value)
|
||||
$element->fetch($idofelement);
|
||||
if ($idofelementuser) $elementuser->fetch($idofelementuser);
|
||||
|
||||
// Special cases
|
||||
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
|
||||
|
||||
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
||||
elseif ($tablename == 'projet_task')
|
||||
{
|
||||
@ -737,6 +737,7 @@ foreach ($listofreferent as $key => $value)
|
||||
$element->fetch($idofelement);
|
||||
if ($idofelementuser) $elementuser->fetch($idofelementuser);
|
||||
|
||||
// Special cases
|
||||
if ($tablename != 'expensereport_det')
|
||||
{
|
||||
if(method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
|
||||
@ -787,28 +788,34 @@ foreach ($listofreferent as $key => $value)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show ref with link
|
||||
if ($element instanceof Task)
|
||||
{
|
||||
print $element->getNomUrl(1,'withproject','time');
|
||||
print ' - '.dol_trunc($element->label, 48);
|
||||
}
|
||||
else print $element->getNomUrl(1);
|
||||
|
||||
|
||||
$element_doc = $element->element;
|
||||
$filename=dol_sanitizeFileName($element->ref);
|
||||
$filedir=$conf->{$element_doc}->dir_output . '/' . dol_sanitizeFileName($element->ref);
|
||||
|
||||
if($element_doc === 'order_supplier') {
|
||||
if ($element_doc === 'order_supplier') {
|
||||
$element_doc='commande_fournisseur';
|
||||
$filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($element->ref);
|
||||
}
|
||||
else if($element_doc === 'invoice_supplier') {
|
||||
else if ($element_doc === 'invoice_supplier') {
|
||||
$element_doc='facture_fournisseur';
|
||||
$filename = get_exdir($element->id,2,0,0,$this,'product').dol_sanitizeFileName($element->ref);
|
||||
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($element->id,2,0,0,null,'invoice_supplier').dol_sanitizeFileName($element->ref);
|
||||
}
|
||||
|
||||
print $formfile->getDocumentsLink($element_doc, $filename, $filedir);
|
||||
print '<div class="inline-block valignmiddle">'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'</div>';
|
||||
|
||||
// Show supplier ref
|
||||
if (! empty($element->ref_supplier)) print ' - '.$element->ref_supplier;
|
||||
// Show customer ref
|
||||
if (! empty($element->ref_customer)) print ' - '.$element->ref_customer;
|
||||
}
|
||||
|
||||
print "</td>\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user