mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
Merge branch 'develop' into patch-30
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018-2019 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,8 +17,8 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -68,37 +68,37 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
global $conf, $langs, $mysoc;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("main","companies"));
|
||||
$langs->loadLangs(array("main", "companies"));
|
||||
|
||||
$this->db = $db;
|
||||
$this->name = "ODT templates";
|
||||
$this->description = $langs->trans("DocumentModelOdt");
|
||||
$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
|
||||
$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
|
||||
|
||||
// Dimension page pour format A4
|
||||
// Page size for A4 format
|
||||
$this->type = 'odt';
|
||||
$this->page_largeur = 0;
|
||||
$this->page_hauteur = 0;
|
||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||
$this->marge_gauche=0;
|
||||
$this->marge_droite=0;
|
||||
$this->marge_haute=0;
|
||||
$this->marge_basse=0;
|
||||
$this->format = array($this->page_largeur, $this->page_hauteur);
|
||||
$this->marge_gauche = 0;
|
||||
$this->marge_droite = 0;
|
||||
$this->marge_haute = 0;
|
||||
$this->marge_basse = 0;
|
||||
|
||||
$this->option_logo = 1; // Affiche logo
|
||||
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
|
||||
$this->option_modereg = 0; // Affiche mode reglement
|
||||
$this->option_condreg = 0; // Affiche conditions reglement
|
||||
$this->option_codeproduitservice = 0; // Affiche code produit-service
|
||||
$this->option_multilang = 1; // Dispo en plusieurs langues
|
||||
$this->option_escompte = 0; // Affiche si il y a eu escompte
|
||||
$this->option_credit_note = 0; // Support credit notes
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
||||
$this->option_logo = 1; // Affiche logo
|
||||
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
|
||||
$this->option_modereg = 0; // Affiche mode reglement
|
||||
$this->option_condreg = 0; // Affiche conditions reglement
|
||||
$this->option_codeproduitservice = 0; // Affiche code produit-service
|
||||
$this->option_multilang = 1; // Dispo en plusieurs langues
|
||||
$this->option_escompte = 0; // Affiche si il y a eu escompte
|
||||
$this->option_credit_note = 0; // Support credit notes
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
||||
|
||||
// Recupere emetteur
|
||||
$this->emetteur=$mysoc;
|
||||
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
|
||||
$this->emetteur = $mysoc;
|
||||
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
|
||||
}
|
||||
|
||||
|
||||
@@ -110,83 +110,88 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
*/
|
||||
public function info($langs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf, $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("errors","companies"));
|
||||
$langs->loadLangs(array("errors", "companies"));
|
||||
|
||||
$form = new Form($this->db);
|
||||
|
||||
$texte = $this->description.".<br>\n";
|
||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
|
||||
$texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
|
||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
|
||||
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
|
||||
$texte .= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
|
||||
$texte .= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
// List of directories area
|
||||
$texte.= '<tr><td>';
|
||||
$texttitle=$langs->trans("ListOfDirectories");
|
||||
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
|
||||
$listoffiles=array();
|
||||
foreach($listofdir as $key=>$tmpdir)
|
||||
$texte .= '<tr><td>';
|
||||
$texttitle = $langs->trans("ListOfDirectories");
|
||||
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
|
||||
$listoffiles = array();
|
||||
foreach ($listofdir as $key=>$tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (! $tmpdir) {
|
||||
$tmpdir = trim($tmpdir);
|
||||
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (!$tmpdir) {
|
||||
unset($listofdir[$key]); continue;
|
||||
}
|
||||
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
|
||||
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
|
||||
else
|
||||
{
|
||||
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
|
||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
|
||||
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
|
||||
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
|
||||
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
|
||||
// Add list of substitution keys
|
||||
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
|
||||
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
|
||||
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
|
||||
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
|
||||
|
||||
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
|
||||
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
|
||||
$texte.= '<textarea class="flat" cols="60" name="value1">';
|
||||
$texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
|
||||
$texte.= '</textarea>';
|
||||
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
|
||||
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
|
||||
$texte.= '<br></div></div>';
|
||||
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
|
||||
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
|
||||
$texte .= '<textarea class="flat" cols="60" name="value1">';
|
||||
$texte .= $conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
|
||||
$texte .= '</textarea>';
|
||||
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
|
||||
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
|
||||
$texte .= '<br></div></div>';
|
||||
|
||||
// Scan directories
|
||||
$nbofiles=count($listoffiles);
|
||||
if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
|
||||
$nbofiles = count($listoffiles);
|
||||
if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
|
||||
{
|
||||
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
|
||||
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
|
||||
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
|
||||
$texte.=count($listoffiles);
|
||||
$texte .= count($listoffiles);
|
||||
//$texte.=$nbofiles?'</a>':'';
|
||||
$texte.='</b>';
|
||||
$texte .= '</b>';
|
||||
}
|
||||
|
||||
if ($nbofiles)
|
||||
{
|
||||
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
|
||||
foreach($listoffiles as $file)
|
||||
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
|
||||
foreach ($listoffiles as $file)
|
||||
{
|
||||
$texte.=$file['name'].'<br>';
|
||||
$texte .= $file['name'].'<br>';
|
||||
}
|
||||
$texte.='<div id="div_'.get_class($this).'">';
|
||||
$texte .= '</div>';
|
||||
}
|
||||
// Add input to upload a new template file.
|
||||
$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
|
||||
$texte .= '<input type="hidden" value="COMMANDE_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
|
||||
$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
|
||||
$texte .= '</div>';
|
||||
|
||||
$texte.= '</td>';
|
||||
$texte .= '</td>';
|
||||
|
||||
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
||||
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
|
||||
$texte.= '</td>';
|
||||
$texte.= '</tr>';
|
||||
$texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';
|
||||
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
|
||||
$texte .= '</td>';
|
||||
$texte .= '</tr>';
|
||||
|
||||
$texte.= '</table>';
|
||||
$texte.= '</form>';
|
||||
$texte .= '</table>';
|
||||
$texte .= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
@@ -206,7 +211,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user,$langs,$conf,$mysoc,$hookmanager;
|
||||
global $user, $langs, $conf, $mysoc, $hookmanager;
|
||||
|
||||
if (empty($srctemplatepath))
|
||||
{
|
||||
@@ -215,28 +220,28 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
}
|
||||
|
||||
// Add odtgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
if (!is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('odtgeneration'));
|
||||
global $action;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
$outputlangs->charset_output='UTF-8';
|
||||
if (!is_object($outputlangs)) $outputlangs = $langs;
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
$outputlangs->charset_output = 'UTF-8';
|
||||
|
||||
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
|
||||
|
||||
if ($conf->commande->dir_output)
|
||||
{
|
||||
// If $object is id instead of object
|
||||
if (! is_object($object))
|
||||
if (!is_object($object))
|
||||
{
|
||||
$id = $object;
|
||||
$object = new Commande($this->db);
|
||||
$result=$object->fetch($id);
|
||||
$result = $object->fetch($id);
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error($this->db, $object->error);
|
||||
@@ -244,16 +249,16 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
}
|
||||
}
|
||||
|
||||
$dir = $conf->commande->dir_output;
|
||||
$dir = $conf->commande->multidir_output[$object->entity];
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
|
||||
$file = $dir . "/" . $objectref . ".odt";
|
||||
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
|
||||
$file = $dir."/".$objectref.".odt";
|
||||
|
||||
if (! file_exists($dir))
|
||||
if (!file_exists($dir))
|
||||
{
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -261,25 +266,25 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
if (file_exists($dir))
|
||||
{
|
||||
//print "srctemplatepath=".$srctemplatepath; // Src filename
|
||||
$newfile=basename($srctemplatepath);
|
||||
$newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile);
|
||||
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
|
||||
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
|
||||
$newfiletmp=$objectref.'_'.$newfiletmp;
|
||||
$newfile = basename($srctemplatepath);
|
||||
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
|
||||
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
|
||||
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
|
||||
$newfiletmp = $objectref.'_'.$newfiletmp;
|
||||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
|
||||
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
|
||||
{
|
||||
$format=$conf->global->MAIN_DOC_USE_TIMING;
|
||||
if ($format == '1') $format='%Y%m%d%H%M%S';
|
||||
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
|
||||
$format = $conf->global->MAIN_DOC_USE_TIMING;
|
||||
if ($format == '1') $format = '%Y%m%d%H%M%S';
|
||||
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename=$newfiletmp.'.'.$newfileformat;
|
||||
$filename = $newfiletmp.'.'.$newfileformat;
|
||||
}
|
||||
$file=$dir.'/'.$filename;
|
||||
$file = $dir.'/'.$filename;
|
||||
//print "newdir=".$dir;
|
||||
//print "newfile=".$newfile;
|
||||
//print "file=".$file;
|
||||
@@ -289,20 +294,20 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
|
||||
|
||||
// If CUSTOMER contact defined on order, we use it
|
||||
$usecontact=false;
|
||||
$arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
||||
if (count($arrayidcontact) > 0)
|
||||
{
|
||||
$usecontact=true;
|
||||
$result=$object->fetch_contact($arrayidcontact[0]);
|
||||
$usecontact = true;
|
||||
$result = $object->fetch_contact($arrayidcontact[0]);
|
||||
}
|
||||
|
||||
// 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 CUSTOMER contact and we dont use it as recipient we store the contact object for later use
|
||||
@@ -311,11 +316,11 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
}
|
||||
else
|
||||
{
|
||||
$socobject=$object->thirdparty;
|
||||
$socobject = $object->thirdparty;
|
||||
}
|
||||
|
||||
// Make substitution
|
||||
$substitutionarray=array(
|
||||
$substitutionarray = array(
|
||||
'__FROM_NAME__' => $this->emetteur->name,
|
||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
||||
'__TOTAL_TTC__' => $object->total_ttc,
|
||||
@@ -324,15 +329,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||
// Call the ODTSubstitution hook
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
|
||||
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Line of free text
|
||||
$newfreetext='';
|
||||
$paramfreetext='ORDER_FREE_TEXT';
|
||||
if (! empty($conf->global->$paramfreetext))
|
||||
$newfreetext = '';
|
||||
$paramfreetext = 'ORDER_FREE_TEXT';
|
||||
if (!empty($conf->global->$paramfreetext))
|
||||
{
|
||||
$newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray);
|
||||
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
|
||||
}
|
||||
|
||||
// Open and load template
|
||||
@@ -342,15 +347,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
$srctemplatepath,
|
||||
array(
|
||||
'PATH_TO_TMP' => $conf->commande->dir_temp,
|
||||
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
||||
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
||||
'DELIMITER_LEFT' => '{',
|
||||
'DELIMITER_RIGHT' => '}'
|
||||
)
|
||||
);
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->error=$e->getMessage();
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
@@ -365,31 +370,31 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
try {
|
||||
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
catch (OdfException $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
|
||||
// Define substitution array
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
|
||||
$array_objet=$this->get_substitutionarray_object($object, $outputlangs);
|
||||
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
|
||||
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
|
||||
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
|
||||
$array_other=$this->get_substitutionarray_other($outputlangs);
|
||||
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
|
||||
$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
|
||||
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
|
||||
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
|
||||
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
|
||||
$array_other = $this->get_substitutionarray_other($outputlangs);
|
||||
// retrieve contact information for use in object as contact_xxx tags
|
||||
$array_thirdparty_contact = array();
|
||||
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
|
||||
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
|
||||
|
||||
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
|
||||
// Call the ODTSubstitution hook
|
||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
||||
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
foreach($tmparray as $key=>$value)
|
||||
foreach ($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/', $key)) // Image
|
||||
@@ -402,7 +407,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
catch (OdfException $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
@@ -414,7 +419,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
try {
|
||||
$listlines = $odfHandler->setSegment('lines');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
catch (OdfException $e)
|
||||
{
|
||||
// We may arrive here if tags for lines not present into template
|
||||
$foundtagforlines = 0;
|
||||
@@ -424,22 +429,22 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
{
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
$tmparray=$this->get_substitutionarray_lines($line, $outputlangs);
|
||||
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||
// Call the ODTSubstitutionLine hook
|
||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
||||
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach($tmparray as $key => $val)
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
|
||||
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
foreach ($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
catch (OdfException $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
catch (SegmentException $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
@@ -449,21 +454,21 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
catch (OdfException $e)
|
||||
{
|
||||
$this->error=$e->getMessage();
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Replace labels translated
|
||||
$tmparray=$outputlangs->get_translations_for_substitutions();
|
||||
foreach($tmparray as $key=>$value)
|
||||
$tmparray = $outputlangs->get_translations_for_substitutions();
|
||||
foreach ($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
catch (OdfException $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
@@ -471,44 +476,44 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
|
||||
// Call the beforeODTSave hook
|
||||
|
||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
||||
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Write new file
|
||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||
try {
|
||||
$odfHandler->exportAsAttachedPDF($file);
|
||||
}catch (Exception $e){
|
||||
$this->error=$e->getMessage();
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
$odfHandler->saveToDisk($file);
|
||||
$odfHandler->saveToDisk($file);
|
||||
} catch (Exception $e) {
|
||||
$this->error=$e->getMessage();
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
||||
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
$odfHandler = null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,17 +18,17 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/commande/doc/pdf_proforma.modules.php
|
||||
* \ingroup commande
|
||||
* \brief Fichier de la classe permettant de generer les commandes au modele Proforma
|
||||
* \brief File of Class to generate PDF orders with template Proforma
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/doc/pdf_einstein.modules.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/doc/pdf_eratosthene.modules.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
@@ -36,9 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
* Classe permettant de generer les commandes au modele Proforma
|
||||
* Class to generate PDF orders with template Proforma
|
||||
*/
|
||||
class pdf_proforma extends pdf_einstein
|
||||
class pdf_proforma extends pdf_eratosthene
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user