Fix regression in creation of invoice

Uniformize code
This commit is contained in:
Laurent Destailleur 2016-11-08 11:23:40 +01:00
parent e39e20b1a4
commit b4c20f1b1a
5 changed files with 77 additions and 40 deletions

View File

@ -776,6 +776,8 @@ class FormFile
/** /**
* Show a Document icon with link(s) * 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 $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. * @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.

View File

@ -587,9 +587,10 @@ class CommandeFournisseur extends CommonOrder
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option On what the link points * @param string $option On what the link points
* @param int $notooltip 1=Disable tooltip
* @return string Chain with URL * @return string Chain with URL
*/ */
public function getNomUrl($withpicto=0,$option='') public function getNomUrl($withpicto=0,$option='',$notooltip=0)
{ {
global $langs, $conf; global $langs, $conf;
@ -606,14 +607,28 @@ class CommandeFournisseur extends CommonOrder
if (! empty($this->total_ttc)) if (! empty($this->total_ttc))
$label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); $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>'; $linkend='</a>';
$picto='order'; if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';
$result.=$link.$this->ref.$linkend; $result.=$linkstart.$this->ref.$linkend;
return $result; return $result;
} }

View File

@ -1765,9 +1765,10 @@ class FactureFournisseur extends CommonInvoice
* @param int $max Max length of shown ref * @param int $max Max length of shown ref
* @param int $short 1=Return just URL * @param int $short 1=Return just URL
* @param string $moretitle Add more text to title tooltip * @param string $moretitle Add more text to title tooltip
* @param int $notooltip 1=Disable tooltip
* @return string String with URL * @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; global $langs, $conf;
@ -1802,10 +1803,23 @@ class FactureFournisseur extends CommonInvoice
$ref=$this->ref; $ref=$this->ref;
if (empty($ref)) $ref=$this->id; 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>'; $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; $result.=$linkstart.($max?dol_trunc($ref,$max):$ref).$linkend;
return $result; return $result;
} }

View File

@ -412,6 +412,7 @@ if (empty($reshook))
$id = $object->createFromCurrent($user); $id = $object->createFromCurrent($user);
if ($id <= 0) { if ($id <= 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -571,8 +572,6 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
$db->begin();
$tmpproject = GETPOST('projectid', 'int'); $tmpproject = GETPOST('projectid', 'int');
// Creation facture // Creation facture
@ -745,6 +744,8 @@ if (empty($reshook))
} }
} }
} }
}
}
if ($error) if ($error)
{ {
@ -773,8 +774,6 @@ if (empty($reshook))
exit; exit;
} }
} }
}
}
// Edit line // Edit line
elseif ($action == 'updateline' && $user->rights->fournisseur->facture->creer) elseif ($action == 'updateline' && $user->rights->fournisseur->facture->creer)

View File

@ -506,8 +506,8 @@ foreach ($listofreferent as $key => $value)
$element->fetch($idofelement); $element->fetch($idofelement);
if ($idofelementuser) $elementuser->fetch($idofelementuser); if ($idofelementuser) $elementuser->fetch($idofelementuser);
// Special cases
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
if ($tablename == 'don') $total_ht_by_line=$element->amount; if ($tablename == 'don') $total_ht_by_line=$element->amount;
elseif ($tablename == 'projet_task') elseif ($tablename == 'projet_task')
{ {
@ -737,6 +737,7 @@ foreach ($listofreferent as $key => $value)
$element->fetch($idofelement); $element->fetch($idofelement);
if ($idofelementuser) $elementuser->fetch($idofelementuser); if ($idofelementuser) $elementuser->fetch($idofelementuser);
// Special cases
if ($tablename != 'expensereport_det') if ($tablename != 'expensereport_det')
{ {
if(method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if(method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
@ -787,6 +788,7 @@ foreach ($listofreferent as $key => $value)
} }
else else
{ {
// Show ref with link
if ($element instanceof Task) if ($element instanceof Task)
{ {
print $element->getNomUrl(1,'withproject','time'); print $element->getNomUrl(1,'withproject','time');
@ -798,17 +800,22 @@ foreach ($listofreferent as $key => $value)
$filename=dol_sanitizeFileName($element->ref); $filename=dol_sanitizeFileName($element->ref);
$filedir=$conf->{$element_doc}->dir_output . '/' . 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'; $element_doc='commande_fournisseur';
$filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($element->ref); $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'; $element_doc='facture_fournisseur';
$filename = get_exdir($element->id,2,0,0,$this,'product').dol_sanitizeFileName($element->ref); $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); $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"; print "</td>\n";