Skip to content

Commit

Permalink
Merge branch '8.0' of https://github.com/Dolibarr/dolibarr.git into 8…
Browse files Browse the repository at this point in the history
….0_fix9964
  • Loading branch information
atm-florian committed Dec 1, 2018
2 parents c422904 + e4bc9f8 commit 6236f72
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 28 deletions.
Expand Up @@ -275,34 +275,37 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
dol_mkdir($conf->expedition->dir_temp);


// If BILLING contact defined on invoice, we use it
// If SHIPMENT contact defined on invoice, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external','BILLING');
$arrayidcontact=$object->getIdContact('external','SHIPPING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}

// Recipient name
if (! empty($usecontact))
{
$contactobject = null;
if (! empty($usecontact)) {
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else $socobject = $object->thirdparty;
}
else
{
$socobject=$object->thirdparty;
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
$socobject = $object->contact;
else {
$socobject = $object->thirdparty;
// if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
$socobject = $object->thirdparty;
}

// Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
Expand Down Expand Up @@ -411,6 +414,28 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
{
}
}

if ($usecontact && is_object($contactobject)) {
$tmparray=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
}

// Replace tags of object + external modules
$tmparray=$this->get_substitutionarray_shipment($object,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);
Expand Down
22 changes: 10 additions & 12 deletions htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
Expand Up @@ -286,20 +286,18 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
}

// Recipient name
$contactobject=null;
if (! empty($usecontact))
{
$contactobject = null;
if (! empty($usecontact)) {
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
$socobject = $object->contact;
else {
$socobject = $object->thirdparty;
// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
$contactobject = $object->contact;
}
}
else
{
$socobject=$object->thirdparty;
$socobject = $object->thirdparty;
// if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
$contactobject = $object->contact;
}
} else {
$socobject = $object->thirdparty;
}

// Fetch info for linked propal
Expand Down
Binary file modified htdocs/install/doctemplates/shipment/template_shipment.odt 100644 → 100755
Binary file not shown.
2 changes: 1 addition & 1 deletion htdocs/ticket/class/actions_ticket.class.php
Expand Up @@ -23,7 +23,7 @@
* \brief File Class ticket
*/

require_once "ticket.class.php";
require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
Expand Down

0 comments on commit 6236f72

Please sign in to comment.