dolibarr  9.0.0
doc_generic_supplier_proposal_odt.modules.php
1 <?php
2 /* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
5  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * or see http://www.gnu.org/
20 */
21 
28 require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
29 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
34 
35 
40 {
45  public $emetteur;
46 
51  public $phpmin = array(5, 4);
52 
57  public $version = 'dolibarr';
58 
59 
65  function __construct($db)
66  {
67  global $conf, $langs, $mysoc;
68 
69  // Load translation files required by the page
70  $langs->loadLangs(array("main","companies"));
71 
72  $this->db = $db;
73  $this->name = "ODT templates";
74  $this->description = $langs->trans("DocumentModelOdt");
75  $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
76 
77  // Dimension page pour format A4
78  $this->type = 'odt';
79  $this->page_largeur = 0;
80  $this->page_hauteur = 0;
81  $this->format = array($this->page_largeur,$this->page_hauteur);
82  $this->marge_gauche=0;
83  $this->marge_droite=0;
84  $this->marge_haute=0;
85  $this->marge_basse=0;
86 
87  $this->option_logo = 1; // Affiche logo
88  $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
89  $this->option_modereg = 0; // Affiche mode reglement
90  $this->option_condreg = 0; // Affiche conditions reglement
91  $this->option_codeproduitservice = 0; // Affiche code produit-service
92  $this->option_multilang = 1; // Dispo en plusieurs langues
93  $this->option_escompte = 0; // Affiche si il y a eu escompte
94  $this->option_credit_note = 0; // Support credit notes
95  $this->option_freetext = 1; // Support add of a personalised text
96  $this->option_draft_watermark = 0; // Support add of a watermark on drafts
97 
98  // Recupere emetteur
99  $this->emetteur=$mysoc;
100  if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
101  }
102 
103 
110  function info($langs)
111  {
112  global $conf, $langs;
113 
114  // Load translation files required by the page
115  $langs->loadLangs(array('companies', 'errors'));
116 
117  $form = new Form($this->db);
118 
119  $texte = $this->description.".<br>\n";
120  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122  $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123  $texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124  if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125  {
126  $texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127  $texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128  $texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129  }
130  $texte.= '<table class="nobordernopadding" width="100%">';
131 
132  // List of directories area
133  $texte.= '<tr><td>';
134  $texttitle=$langs->trans("ListOfDirectories");
135  $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136  $listoffiles=array();
137  foreach($listofdir as $key=>$tmpdir)
138  {
139  $tmpdir=trim($tmpdir);
140  $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141  if (! $tmpdir) {
142  unset($listofdir[$key]); continue;
143  }
144  if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145  else
146  {
147  $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148  if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149  }
150  }
151  $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152  // Add list of substitution keys
153  $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154  $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
155 
156  $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157  $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158  $texte.= '<textarea class="flat" cols="60" name="value1">';
159  $texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160  $texte.= '</textarea>';
161  $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162  $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163  $texte.= '<br></div></div>';
164 
165  // Scan directories
166  $nbofiles=count($listoffiles);
167  if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168  {
169  $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
170  //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171  $texte.=count($listoffiles);
172  //$texte.=$nbofiles?'</a>':'';
173  $texte.='</b>';
174  }
175 
176  if ($nbofiles)
177  {
178  $texte.='<div id="div_'.get_class($this).'" class="hidden">';
179  foreach($listoffiles as $file)
180  {
181  $texte.=$file['name'].'<br>';
182  }
183  $texte.='<div id="div_'.get_class($this).'">';
184 
185  if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186  {
187  // Model for creation
189  $texte.= '<table width="50%;">';
190  $texte.= '<tr>';
191  $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192  $texte.= '<td colspan="">';
193  $texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194  $texte.= "</td></tr>";
195 
196  $texte.= '<tr>';
197  $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198  $texte.= '<td colspan="">';
199  $texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200  $texte.= "</td></tr>";
201  $texte.= '<tr>';
202 
203  $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204  $texte.= '<td colspan="">';
205  $texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206  $texte.= "</td></tr>";
207  $texte.= '</table>';
208  }
209  }
210 
211  $texte.= '</td>';
212 
213  $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214  $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215  $texte.= '</td>';
216  $texte.= '</tr>';
217 
218  $texte.= '</table>';
219  $texte.= '</form>';
220 
221  return $texte;
222  }
223 
224  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
236  function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
237  {
238  // phpcs:enable
239  global $user, $langs, $conf, $mysoc, $hookmanager;
240 
241  if (empty($srctemplatepath))
242  {
243  dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
244  return -1;
245  }
246 
247  // Add odtgeneration hook
248  if (! is_object($hookmanager))
249  {
250  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251  $hookmanager=new HookManager($this->db);
252  }
253  $hookmanager->initHooks(array('odtgeneration'));
254  global $action;
255 
256  if (! is_object($outputlangs)) $outputlangs=$langs;
257  $sav_charset_output=$outputlangs->charset_output;
258  $outputlangs->charset_output='UTF-8';
259 
260  // Load translation files required by the page
261  $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
262 
263  if ($conf->supplier_proposal->dir_output)
264  {
265  // If $object is id instead of object
266  if (! is_object($object))
267  {
268  $id = $object;
269  $object = new SupplierProposal($this->db);
270  $result=$object->fetch($id);
271  if ($result < 0)
272  {
273  dol_print_error($this->db,$object->error);
274  return -1;
275  }
276  }
277 
278  $dir = $conf->supplier_proposal->dir_output;
279  $objectref = dol_sanitizeFileName($object->ref);
280  if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281  $file = $dir . "/" . $objectref . ".odt";
282 
283  if (! file_exists($dir))
284  {
285  if (dol_mkdir($dir) < 0)
286  {
287  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
288  return -1;
289  }
290  }
291 
292  if (file_exists($dir))
293  {
294  //print "srctemplatepath=".$srctemplatepath; // Src filename
295  $newfile=basename($srctemplatepath);
296  $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297  $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298  $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
299 
300  $newfiletmp=$objectref.'_'.$newfiletmp;
301 
302  // Get extension (ods or odt)
303  $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304  if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305  {
306  $format=$conf->global->MAIN_DOC_USE_TIMING;
307  if ($format == '1') $format='%Y%m%d%H%M%S';
308  $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309  }
310  else
311  {
312  $filename=$newfiletmp.'.'.$newfileformat;
313  }
314  $file=$dir.'/'.$filename;
315  //print "newdir=".$dir;
316  //print "newfile=".$newfile;
317  //print "file=".$file;
318  //print "conf->propal->dir_temp=".$conf->propal->dir_temp;
319 
320  dol_mkdir($conf->supplier_proposal->dir_temp);
321 
322 
323  // If BILLING contact defined on invoice, we use it
324  $usecontact=false;
325  $arrayidcontact=$object->getIdContact('external','BILLING');
326  if (count($arrayidcontact) > 0)
327  {
328  $usecontact=true;
329  $result=$object->fetch_contact($arrayidcontact[0]);
330  }
331 
332  // Recipient name
333  if (! empty($usecontact))
334  {
335  // On peut utiliser le nom de la societe du contact
336  if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337  else $socobject = $object->thirdparty;
338  }
339  else
340  {
341  $socobject=$object->thirdparty;
342  }
343 
344  // Make substitution
345  $substitutionarray=array(
346  '__FROM_NAME__' => $this->emetteur->name,
347  '__FROM_EMAIL__' => $this->emetteur->email,
348  '__TOTAL_TTC__' => $object->total_ttc,
349  '__TOTAL_HT__' => $object->total_ht,
350  '__TOTAL_VAT__' => $object->total_vat
351  );
352  complete_substitutions_array($substitutionarray, $langs, $object);
353  // Call the ODTSubstitution hook
354  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355  $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
356 
357  // Line of free text
358  $newfreetext='';
359  $paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360  if (! empty($conf->global->$paramfreetext))
361  {
362  $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
363  }
364 
365  // Open and load template
366  require_once ODTPHP_PATH.'odf.php';
367  try {
368  $odfHandler = new odf(
369  $srctemplatepath,
370  array(
371  'PATH_TO_TMP' => $conf->supplier_proposal->dir_temp,
372  'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373  'DELIMITER_LEFT' => '{',
374  'DELIMITER_RIGHT' => '}'
375  )
376  );
377  }
378  catch (Exception $e)
379  {
380  $this->error=$e->getMessage();
381  dol_syslog($e->getMessage(), LOG_INFO);
382  return -1;
383  }
384  // After construction $odfHandler->contentXml contains content and
385  // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
386  // [!-- BEGIN lines --]*[!-- END lines --]
387  //print html_entity_decode($odfHandler->__toString());
388  //print exit;
389 
390 
391  // Make substitutions into odt of freetext
392  try {
393  $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394  }
395  catch (OdfException $e)
396  {
397  dol_syslog($e->getMessage(), LOG_INFO);
398  }
399 
400  // Define substitution array
401  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402  $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403  $array_user=$this->get_substitutionarray_user($user,$outputlangs);
404  $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405  $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406  $array_other=$this->get_substitutionarray_other($outputlangs);
407 
408  $tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
409  complete_substitutions_array($tmparray, $outputlangs, $object);
410 
411  // Call the ODTSubstitution hook
412  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413  $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
414 
415  foreach($tmparray as $key=>$value)
416  {
417  try {
418  if (preg_match('/logo$/',$key)) // Image
419  {
420  if (file_exists($value)) $odfHandler->setImage($key, $value);
421  else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422  }
423  else // Text
424  {
425  $odfHandler->setVars($key, $value, true, 'UTF-8');
426  }
427  }
428  catch(OdfException $e)
429  {
430  dol_syslog($e->getMessage(), LOG_INFO);
431  }
432  }
433  // Replace tags of lines
434  try
435  {
436  $foundtagforlines = 1;
437  try {
438  $listlines = $odfHandler->setSegment('lines');
439  }
440  catch(OdfException $e)
441  {
442  // We may arrive here if tags for lines not present into template
443  $foundtagforlines = 0;
444  dol_syslog($e->getMessage(), LOG_INFO);
445  }
446  if ($foundtagforlines)
447  {
448  foreach ($object->lines as $line)
449  {
450  $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
451  complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452  // Call the ODTSubstitutionLine hook
453  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454  $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
455  foreach($tmparray as $key => $val)
456  {
457  try
458  {
459  $listlines->setVars($key, $val, true, 'UTF-8');
460  }
461  catch(OdfException $e)
462  {
463  dol_syslog($e->getMessage(), LOG_INFO);
464  }
465  catch(SegmentException $e)
466  {
467  dol_syslog($e->getMessage(), LOG_INFO);
468  }
469  }
470  $listlines->merge();
471  }
472  $odfHandler->mergeSegment($listlines);
473  }
474  }
475  catch(OdfException $e)
476  {
477  $this->error=$e->getMessage();
478  dol_syslog($this->error, LOG_WARNING);
479  return -1;
480  }
481 
482  // Replace labels translated
483  $tmparray=$outputlangs->get_translations_for_substitutions();
484  foreach($tmparray as $key=>$value)
485  {
486  try {
487  $odfHandler->setVars($key, $value, true, 'UTF-8');
488  }
489  catch(OdfException $e)
490  {
491  dol_syslog($e->getMessage(), LOG_INFO);
492  }
493  }
494 
495  // Call the beforeODTSave hook
496  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497  $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
498 
499  // Write new file
500  if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501  try {
502  $odfHandler->exportAsAttachedPDF($file);
503  } catch (Exception $e) {
504  $this->error=$e->getMessage();
505  dol_syslog($e->getMessage(), LOG_INFO);
506  return -1;
507  }
508  }
509  else {
510  try {
511  $odfHandler->saveToDisk($file);
512  } catch (Exception $e) {
513  $this->error=$e->getMessage();
514  dol_syslog($e->getMessage(), LOG_INFO);
515  return -1;
516  }
517  }
518  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519  $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
520 
521  if (! empty($conf->global->MAIN_UMASK))
522  @chmod($file, octdec($conf->global->MAIN_UMASK));
523 
524  $odfHandler=null; // Destroy object
525 
526  $this->result = array('fullpath'=>$file);
527 
528  return 1; // Success
529  }
530  else
531  {
532  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533  return -1;
534  }
535  }
536 
537  return -1;
538  }
539 }
img_warning($titlealt='default', $moreatt='')
Show warning logo.
get_substitutionarray_lines($line, $outputlangs)
Define array with couple substitution key => substitution value.
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Class to build documents using ODF templates generator.
get_substitutionarray_object($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
get_substitutionarray_user($user, $outputlangs)
Define array with couple subtitution key => subtitution value.
write_file($object, $outputlangs, $srctemplatepath, $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Classe mere des modeles de propale.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
$version
Dolibarr version of the loaded document string.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Class to manage hooks.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
type
Definition: viewcat.php:284
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple subtitution key => subtitution value.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:59
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
get_substitutionarray_thirdparty($object, $outputlangs)
Define array with couple subtitution key => subtitution value.
Class to manage price ask supplier.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
get_substitutionarray_other($outputlangs)
Define array with couple subtitution key => subtitution value.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...