forked from Wavyzz/dolibarr
Merge branch 'Dolibarr:develop' into daraelmin-stats-adh-by-status
This commit is contained in:
@@ -93,11 +93,11 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
$objecttmp = new $objectclass($db);
|
||||
if ($objecttmp->element == 'expensereport') {
|
||||
$thirdparty = new User($db);
|
||||
}
|
||||
if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
|
||||
} elseif ($objecttmp->element == 'contact') {
|
||||
$thirdparty = new Contact($db);
|
||||
} elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
|
||||
$thirdparty = new Adherent($db);
|
||||
}
|
||||
if ($objecttmp->element == 'holiday') {
|
||||
} elseif ($objecttmp->element == 'holiday') {
|
||||
$thirdparty = new User($db);
|
||||
}
|
||||
|
||||
@@ -110,14 +110,13 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
|
||||
if ($objecttmp->element == 'societe') {
|
||||
$thirdpartyid = $objecttmp->id;
|
||||
}
|
||||
if ($objecttmp->element == 'expensereport') {
|
||||
} elseif ($objecttmp->element == 'contact') {
|
||||
$thirdpartyid = $objecttmp->id;
|
||||
} elseif ($objecttmp->element == 'expensereport') {
|
||||
$thirdpartyid = $objecttmp->fk_user_author;
|
||||
}
|
||||
if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
|
||||
} elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
|
||||
$thirdpartyid = $objecttmp->fk_member;
|
||||
}
|
||||
if ($objecttmp->element == 'holiday') {
|
||||
} elseif ($objecttmp->element == 'holiday') {
|
||||
$thirdpartyid = $objecttmp->fk_user;
|
||||
}
|
||||
if (empty($thirdpartyid)) {
|
||||
@@ -268,6 +267,10 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($objectobj->fk_user_author);
|
||||
$sendto = $fuser->email;
|
||||
} elseif ($objectobj->element == 'contact') {
|
||||
$fcontact = new Contact($db);
|
||||
$fcontact->fetch($objectobj->id);
|
||||
$sendto = $fcontact->email;
|
||||
} elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
|
||||
$fadherent = new Adherent($db);
|
||||
$fadherent->fetch($objectobj->fk_member);
|
||||
@@ -510,31 +513,28 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
$trackid = 'thi'.$thirdparty->id;
|
||||
if ($objecttmp->element == 'expensereport') {
|
||||
$trackid = 'use'.$thirdparty->id;
|
||||
}
|
||||
if ($objecttmp->element == 'holiday') {
|
||||
} elseif ($objecttmp->element == 'contact') {
|
||||
$trackid = 'ctc'.$thirdparty->id;
|
||||
} elseif ($objecttmp->element == 'holiday') {
|
||||
$trackid = 'use'.$thirdparty->id;
|
||||
}
|
||||
} else {
|
||||
$trackid = strtolower(get_class($objecttmp));
|
||||
if (get_class($objecttmp) == 'Contrat') {
|
||||
if (get_class($objecttmp) == 'Contact') {
|
||||
$trackid = 'ctc';
|
||||
} elseif (get_class($objecttmp) == 'Contrat') {
|
||||
$trackid = 'con';
|
||||
}
|
||||
if (get_class($objecttmp) == 'Propal') {
|
||||
} elseif (get_class($objecttmp) == 'Propal') {
|
||||
$trackid = 'pro';
|
||||
}
|
||||
if (get_class($objecttmp) == 'Commande') {
|
||||
} elseif (get_class($objecttmp) == 'Commande') {
|
||||
$trackid = 'ord';
|
||||
}
|
||||
if (get_class($objecttmp) == 'Facture') {
|
||||
} elseif (get_class($objecttmp) == 'Facture') {
|
||||
$trackid = 'inv';
|
||||
}
|
||||
if (get_class($objecttmp) == 'Supplier_Proposal') {
|
||||
} elseif (get_class($objecttmp) == 'Supplier_Proposal') {
|
||||
$trackid = 'spr';
|
||||
}
|
||||
if (get_class($objecttmp) == 'CommandeFournisseur') {
|
||||
} elseif (get_class($objecttmp) == 'CommandeFournisseur') {
|
||||
$trackid = 'sor';
|
||||
}
|
||||
if (get_class($objecttmp) == 'FactureFournisseur') {
|
||||
} elseif (get_class($objecttmp) == 'FactureFournisseur') {
|
||||
$trackid = 'sin';
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ if ($action == 'setModuleOptions' && !empty($user->admin)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09');
|
||||
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString($keyforuploaddir))));
|
||||
|
||||
foreach ($listofdir as $key => $tmpdir) {
|
||||
$tmpdir = trim($tmpdir);
|
||||
$tmpdir = preg_replace('/DOL_DATA_ROOT\/*/', '', $tmpdir); // Clean string if we found a hardcoded DOL_DATA_ROOT
|
||||
@@ -144,6 +145,8 @@ if ($action == 'setModuleOptions' && !empty($user->admin)) {
|
||||
break; // So we take the first directory found into setup $conf->global->$keyforuploaddir
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($upload_dir) {
|
||||
$result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', '');
|
||||
if ($result <= 0) {
|
||||
|
||||
@@ -220,7 +220,9 @@ class box_actions extends ModeleBoxes
|
||||
if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) {
|
||||
$actioncejour = false;
|
||||
$contents = $this->info_box_contents;
|
||||
$nblines = count($contents);
|
||||
if (is_countable($contents) && count($contents) > 0) {
|
||||
$nblines = count($contents);
|
||||
}
|
||||
if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo")) {
|
||||
$out .= '<div id="dialogboxaction" title="'.$nblines." ".$langs->trans("ActionsToDo").'">';
|
||||
$out .= '<table width=100%>';
|
||||
|
||||
@@ -166,4 +166,37 @@ abstract class CommonObjectLine extends CommonObject
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
|
||||
* @return string HTML Code for Kanban thumb.
|
||||
*/
|
||||
public function getKanbanView($option = '')
|
||||
{
|
||||
global $langs;
|
||||
$return = '<div class="box-flex-item box-flex-grow-zero">';
|
||||
$return .= '<div class="info-box info-box-sm">';
|
||||
$return .= '<span class="info-box-icon bg-infobox-action">';
|
||||
$return .= img_picto('', $this->picto);
|
||||
//$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
|
||||
$return .= '</span>';
|
||||
$return .= '<div class="info-box-content">';
|
||||
$return .= '<span class="info-box-ref">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : '').'</span>';
|
||||
if (property_exists($this, 'date_delivery')) {
|
||||
$return .= '<br><span class="info-box-label opacitymedium">'.dol_print_date($this->db->jdate($this->date_delivery), "dayhour").'</span>';
|
||||
}
|
||||
if (property_exists($this, 'town') && !empty($this->town)) {
|
||||
$return .= '<br><span class="info-box-label opacitymedium">'.$langs->trans("Town").'</span>';
|
||||
$return .= '<span class="info-box-label "> : '.$this->town.'</span>';
|
||||
}
|
||||
if (method_exists($this, 'getLibStatut')) {
|
||||
$return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).'</div>';
|
||||
}
|
||||
$return .= '</div>';
|
||||
$return .= '</div>';
|
||||
$return .= '</div>';
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,10 @@ class FormTicket
|
||||
* @param string $mode Mode ('create' or 'edit')
|
||||
* @param int $public 1=If we show the form for the public interface
|
||||
* @param Contact|null $with_contact [=NULL] Contact to link to this ticket if exists
|
||||
* @param string $action [=''] Action in card
|
||||
* @return void
|
||||
*/
|
||||
public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null)
|
||||
public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null, $action = '')
|
||||
{
|
||||
global $conf, $langs, $user, $hookmanager;
|
||||
|
||||
@@ -636,7 +637,7 @@ class FormTicket
|
||||
|
||||
// Other attributes
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) {
|
||||
print $ticketstat->showOptionals($extrafields, 'create');
|
||||
}
|
||||
|
||||
@@ -1567,7 +1567,9 @@ function dol_meta_create($object)
|
||||
}
|
||||
|
||||
if (is_dir($dir)) {
|
||||
$nblines = count($object->lines);
|
||||
if (is_countable($object->lines) && count($object->lines) > 0) {
|
||||
$nblines = count($object->lines);
|
||||
}
|
||||
$client = $object->thirdparty->name." ".$object->thirdparty->address." ".$object->thirdparty->zip." ".$object->thirdparty->town;
|
||||
$meta = "REFERENCE=\"".$object->ref."\"
|
||||
DATE=\"" . dol_print_date($object->date, '')."\"
|
||||
@@ -1651,6 +1653,7 @@ function dol_init_file_process($pathtoscan = '', $trackid = '')
|
||||
*/
|
||||
function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null, $trackid = '', $generatethumbs = 1, $object = null)
|
||||
{
|
||||
|
||||
global $db, $user, $conf, $langs;
|
||||
|
||||
$res = 0;
|
||||
|
||||
@@ -1718,7 +1718,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
|
||||
* @param string $name A name for the html component
|
||||
* @param string $label Label shown in Popup title top bar
|
||||
* @param string $buttonstring button string
|
||||
* @param string $url Relative Url to open
|
||||
* @param string $url Relative Url to open. For example '/project/card.php'
|
||||
* @param string $disabled Disabled text
|
||||
* @param string $morecss More CSS
|
||||
* @param string $backtopagejsfields The back to page must be managed using javascript instead of a redirect.
|
||||
@@ -1752,13 +1752,16 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di
|
||||
}
|
||||
|
||||
//print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="file_manager">';
|
||||
$out .= '<!-- a link for button to open url into a dialog popup backtopagejsfields = '.$backtopagejsfields.' -->';
|
||||
$out .= '<!-- a link for button to open url into a dialog popup with backtopagejsfields = '.$backtopagejsfields.' -->';
|
||||
$out .= '<a class="cursorpointer classlink button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title="'.dol_escape_htmltag($label).'"';
|
||||
if (empty($conf->use_javascript_ajax)) {
|
||||
$out .= ' href="'.DOL_URL_ROOT.$url.'" target="_blank"';
|
||||
}
|
||||
$out .= '>'.$buttonstring.'</a>';
|
||||
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
// Add code to open url using the popup. Add also hidden field to retreive the returned variables
|
||||
$out .= '<!-- code to open popup and variables to retreive returned variables -->';
|
||||
$out .= '<div id="idfordialog'.$name.'" class="hidden">div for dialog</div>';
|
||||
$out .= '<div id="varforreturndialogid'.$name.'" class="hidden">div for returned id</div>';
|
||||
$out .= '<div id="varforreturndialoglabel'.$name.'" class="hidden">div for returned label</div>';
|
||||
@@ -4080,12 +4083,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cubes',
|
||||
'currency', 'multicurrency',
|
||||
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice',
|
||||
'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt',
|
||||
'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye',
|
||||
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus',
|
||||
'generate', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group',
|
||||
'help', 'holiday',
|
||||
'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'knowledgemanagement',
|
||||
'label', 'language', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lot', 'long-arrow-alt-right',
|
||||
'label', 'language', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lock', 'lot', 'long-arrow-alt-right',
|
||||
'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next',
|
||||
'off', 'on', 'order',
|
||||
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce',
|
||||
@@ -4244,7 +4247,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
'dynamicprice'=>'#a69944',
|
||||
'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', 'language'=>'#555',
|
||||
//'dolly'=>'#a69944', 'dollyrevert'=>'#a69944',
|
||||
'lot'=>'#a69944',
|
||||
'lock'=>'#ddd', 'lot'=>'#a69944',
|
||||
'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'inventory'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944',
|
||||
'other'=>'#ddd', 'world'=>'#986c6a',
|
||||
'partnership'=>'#6c6aa8', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'reception'=>'#a69944', 'resize'=>'#444', 'rss'=>'#cba',
|
||||
@@ -4544,7 +4547,7 @@ function img_view($titlealt = 'default', $float = 0, $other = 'class="valignmidd
|
||||
|
||||
$moreatt = ($float ? 'style="float: right" ' : '').$other;
|
||||
|
||||
return img_picto($titlealt, 'view.png', $moreatt);
|
||||
return img_picto($titlealt, 'eye', $moreatt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -12061,7 +12064,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n
|
||||
$out .= $actionstatic->getNomUrl(1, -1, 'valignmiddle').' ';
|
||||
}
|
||||
|
||||
if (!empty($user->rights->agenda->allactions->create) ||
|
||||
if ($user->hasRight('agenda', 'allactions', 'create') ||
|
||||
(($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && !empty($user->rights->agenda->myactions->create))) {
|
||||
$out .= '<a class="timeline-btn" href="'.DOL_MAIN_URL_ROOT.'/comm/action/card.php?action=edit&token='.newToken().'&id='.$actionstatic->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'"><i class="fa fa-pencil" title="'.$langs->trans("Modify").'" ></i></a>';
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ function propal_prepare_head($object)
|
||||
$head[$h][2] = 'comm';
|
||||
$h++;
|
||||
|
||||
if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
|
||||
if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && isModEnabled('expedition_bon') && $user->rights->expedition->lire)
|
||||
|| (isModEnabled("expedition") && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) {
|
||||
$langs->load("sendings");
|
||||
$text = '';
|
||||
|
||||
@@ -409,7 +409,7 @@ class mailing_contacts1 extends MailingTargets
|
||||
}
|
||||
|
||||
// Filter on language
|
||||
if ($filter_lang != '') {
|
||||
if (!empty($filter_lang)) {
|
||||
$sql .= " AND sp.default_lang LIKE '".$this->db->escape($filter_lang)."%'";
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ class mailing_contacts1 extends MailingTargets
|
||||
|
||||
//print "xx".$key;
|
||||
if ($key == 'prospects') {
|
||||
$sql .= " AND s.client=2";
|
||||
$sql .= " AND s.client = 2";
|
||||
}
|
||||
foreach ($prospectlevel as $codelevel => $valuelevel) {
|
||||
if ($key == 'prospectslevel'.$codelevel) {
|
||||
@@ -426,10 +426,10 @@ class mailing_contacts1 extends MailingTargets
|
||||
}
|
||||
}
|
||||
if ($key == 'customers') {
|
||||
$sql .= " AND s.client=1";
|
||||
$sql .= " AND s.client = 1";
|
||||
}
|
||||
if ($key == 'suppliers') {
|
||||
$sql .= " AND s.fournisseur=1";
|
||||
$sql .= " AND s.fournisseur = 1";
|
||||
}
|
||||
|
||||
// Filter on job position
|
||||
@@ -440,7 +440,6 @@ class mailing_contacts1 extends MailingTargets
|
||||
|
||||
$sql .= " ORDER BY sp.email";
|
||||
// print "wwwwwwx".$sql;
|
||||
|
||||
// Stocke destinataires dans cibles
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
|
||||
@@ -241,7 +241,7 @@ class modAgenda extends DolibarrModules
|
||||
'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
|
||||
'langs'=>'commercial',
|
||||
'position'=>101,
|
||||
'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)',
|
||||
'perms'=>'($user->hasRight("agenda", "myactions", "create")||$user->hasRight("agenda", "allactions", "create"))',
|
||||
'enabled'=>'$conf->agenda->enabled',
|
||||
'target'=>'',
|
||||
'user'=>2
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019-2022 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
|
||||
@@ -51,7 +51,7 @@ class modBookCal extends DolibarrModules
|
||||
|
||||
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
|
||||
// It is used to group modules by family in module setup page
|
||||
$this->family = "other";
|
||||
$this->family = "projects";
|
||||
|
||||
// Module position in the family on 2 digits ('01', '10', '20', ...)
|
||||
$this->module_position = '50';
|
||||
@@ -68,8 +68,6 @@ class modBookCal extends DolibarrModules
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
|
||||
$this->version = 'development';
|
||||
// Url to the file with your last numberversion of this module
|
||||
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
||||
|
||||
// Key used in llx_const table to save module status enabled/disabled (where BOOKCAL is value of property name of module in uppercase)
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
@@ -140,7 +138,6 @@ class modBookCal extends DolibarrModules
|
||||
|
||||
// Prerequisites
|
||||
$this->phpmin = array(7, 0); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(17, -3); // Minimum version of Dolibarr required by module
|
||||
|
||||
// Messages at activation
|
||||
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...)
|
||||
|
||||
@@ -111,6 +111,7 @@ class modFournisseur extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
// Add ability ODT for Supplier orders
|
||||
$this->const[$r][0] = "SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_orders";
|
||||
@@ -118,6 +119,14 @@ class modFournisseur extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
// Add ability ODT for Supplier Invoices
|
||||
$this->const[$r][0] = "SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
// Boxes
|
||||
$this->boxes = array(
|
||||
0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
|
||||
@@ -872,7 +881,7 @@ class modFournisseur extends DolibarrModules
|
||||
|
||||
$this->remove($options);
|
||||
|
||||
//ODT template
|
||||
//ODT template for Supplier Orders
|
||||
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt';
|
||||
$dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_orders';
|
||||
$dest = $dirodt.'/template_supplier_order.odt';
|
||||
@@ -888,11 +897,38 @@ class modFournisseur extends DolibarrModules
|
||||
}
|
||||
}
|
||||
|
||||
$sql = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".((int) $conf->entity),
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'order_supplier', ".((int) $conf->entity).")",
|
||||
$sql_order = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".((int) $conf->entity),
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."', 'order_supplier', ".((int) $conf->entity).")",
|
||||
);
|
||||
|
||||
//ODT template for Supplier Invoice
|
||||
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt';
|
||||
$dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_invoices';
|
||||
$dest = $dirodt.'/template_supplier_invoices.odt';
|
||||
|
||||
if (file_exists($src) && !file_exists($dest)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_mkdir($dirodt);
|
||||
$result = dol_copy($src, $dest, 0, 0);
|
||||
if ($result < 0) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$sql_invoice = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'invoice_supplier' AND entity = ".((int) $conf->entity),
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."', 'invoice_supplier', ".((int) $conf->entity).")",
|
||||
);
|
||||
|
||||
$sql = array_merge($sql_order, $sql_invoice);
|
||||
*/
|
||||
|
||||
$sql = $sql_order;
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,503 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* 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-2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019 Tim Otte <otte@meuser.it>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/supplier_invoce/doc/doc_generic_supplier_invoice_odt.modules.php
|
||||
* \ingroup facture
|
||||
* \brief File of class to build ODT documents for supplier invoices
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.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';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to build documents using ODF templates generator
|
||||
*/
|
||||
class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices
|
||||
{
|
||||
/**
|
||||
* Issuer
|
||||
* @var Societe
|
||||
*/
|
||||
public $issuer;
|
||||
|
||||
/**
|
||||
* @var array Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.6 = array(5, 6)
|
||||
*/
|
||||
public $phpmin = array(5, 6);
|
||||
|
||||
/**
|
||||
* @var string Dolibarr version of the loaded document
|
||||
*/
|
||||
public $version = 'dolibarr';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $conf, $langs, $mysoc;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("main", "companies"));
|
||||
|
||||
$this->db = $db;
|
||||
$this->name = "ODT templates";
|
||||
$this->description = $langs->trans("DocumentModelOdt");
|
||||
$this->scandir = 'SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
|
||||
// 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->option_logo = 1; // Display logo
|
||||
$this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
|
||||
$this->option_modereg = 0; // Display payment mode
|
||||
$this->option_condreg = 0; // Display payment terms
|
||||
$this->option_codeproduitservice = 0; // Display product-service code
|
||||
$this->option_multilang = 1; // Available in several languages
|
||||
$this->option_escompte = 0; // Displays if there has been a discount
|
||||
$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 issuer
|
||||
$this->issuer = $mysoc;
|
||||
if (!$this->issuer->country_code) {
|
||||
$this->issuer->country_code = substr($langs->defaultlang, -2); // By default if not defined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return description of a module
|
||||
*
|
||||
* @param Translate $langs Lang object to use for output
|
||||
* @return string Description
|
||||
*/
|
||||
public function info($langs)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("errors", "companies"));
|
||||
|
||||
$form = new Form($this->db);
|
||||
|
||||
$texte = $this->description.".<br>\n";
|
||||
$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="SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH">';
|
||||
$texte .= '<table class="nobinvoicenopadding" width="100%">';
|
||||
|
||||
// List of directories area
|
||||
$texte .= '<tr><td>';
|
||||
$texttitle = $langs->trans("ListOfDirectories");
|
||||
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_INVOICE_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) {
|
||||
unset($listofdir[$key]);
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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
|
||||
|
||||
$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->SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH;
|
||||
$texte .= '</textarea>';
|
||||
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
|
||||
$texte .= '<input type="submit" class="button small" value="'.$langs->trans("Modify").'" name="Button">';
|
||||
$texte .= '<br></div></div>';
|
||||
|
||||
// Scan directories
|
||||
$nbofiles = count($listoffiles);
|
||||
if (!empty($conf->global->SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH)) {
|
||||
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
|
||||
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
|
||||
$texte .= count($listoffiles);
|
||||
//$texte.=$nbofiles?'</a>':'';
|
||||
$texte .= '</b>';
|
||||
}
|
||||
|
||||
if ($nbofiles) {
|
||||
$texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
|
||||
// Show list of found files
|
||||
foreach ($listoffiles as $file) {
|
||||
$texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=supplier_invoices/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a><br>';
|
||||
}
|
||||
$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="SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
|
||||
$texte .= '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
|
||||
$texte .= '</div>';
|
||||
$texte .= '</td>';
|
||||
|
||||
|
||||
$texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';
|
||||
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
|
||||
$texte .= '</td>';
|
||||
$texte .= '</tr>';
|
||||
|
||||
$texte .= '</table>';
|
||||
$texte .= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Function to build a document on disk using the generic odt module.
|
||||
*
|
||||
* @param Commande $object Object source to build document
|
||||
* @param Translate $outputlangs Lang output object
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||
* @param int $hidedetails Do not show line details
|
||||
* @param int $hidedesc Do not show desc
|
||||
* @param int $hideref Do not show ref
|
||||
* @return int 1 if OK, <=0 if KO
|
||||
*/
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $langs, $conf, $mysoc, $hookmanager;
|
||||
|
||||
if (empty($srctemplatepath)) {
|
||||
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Add odtgeneration hook
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$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';
|
||||
|
||||
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
|
||||
|
||||
if ($conf->fournisseur->facture->dir_output) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if ($object->specimen) {
|
||||
$dir = $conf->fournisseur->facture->dir_output;
|
||||
$file = $dir."/SPECIMEN.pdf";
|
||||
} else {
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
|
||||
//$dir = $conf->fournisseur->facture->dir_output.'/'.$objectref;
|
||||
$dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$objectref;
|
||||
$file = $dir."/".$objectref.".pdf";
|
||||
if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
|
||||
$file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($dir)) {
|
||||
if (dol_mkdir($dir) < 0) {
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
//$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)) {
|
||||
$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;
|
||||
}
|
||||
$file = $dir.'/'.$filename;
|
||||
//print "newdir=".$dir;
|
||||
//print "newfile=".$newfile;
|
||||
//print "file=".$file;
|
||||
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
|
||||
|
||||
dol_mkdir($conf->fournisseur->facture->dir_temp);
|
||||
if (!is_writable($conf->fournisseur->facture->dir_temp)) {
|
||||
$this->error = "Failed to write in temp directory ".$conf->fournisseur->facture->dir_temp;
|
||||
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If CUSTOMER contact defined on invoice, we use it
|
||||
$usecontact = false;
|
||||
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
||||
if (count($arrayidcontact) > 0) {
|
||||
$usecontact = true;
|
||||
$result = $object->fetch_contact($arrayidcontact[0]);
|
||||
}
|
||||
|
||||
// Recipient name
|
||||
$contactobject = null;
|
||||
if (!empty($usecontact)) {
|
||||
// We can use the company of contact instead of thirdparty company
|
||||
if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
|
||||
$object->contact->fetch_thirdparty();
|
||||
$socobject = $object->contact->thirdparty;
|
||||
$contactobject = $object->contact;
|
||||
} else {
|
||||
$socobject = $object->thirdparty;
|
||||
// if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
|
||||
$contactobject = $object->contact;
|
||||
}
|
||||
} else {
|
||||
$socobject = $object->thirdparty;
|
||||
}
|
||||
|
||||
// Make substitution
|
||||
$substitutionarray = array(
|
||||
'__FROM_NAME__' => $this->issuer->name,
|
||||
'__FROM_EMAIL__' => $this->issuer->email,
|
||||
'__TOTAL_TTC__' => $object->total_ttc,
|
||||
'__TOTAL_HT__' => $object->total_ht,
|
||||
'__TOTAL_VAT__' => $object->total_tva
|
||||
);
|
||||
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
|
||||
|
||||
// Line of free text
|
||||
$newfreetext = '';
|
||||
$paramfreetext = 'INVOICE_FREE_TEXT';
|
||||
if (!empty($conf->global->$paramfreetext)) {
|
||||
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
|
||||
}
|
||||
|
||||
// Open and load template
|
||||
require_once ODTPHP_PATH.'odf.php';
|
||||
try {
|
||||
$odfHandler = new odf(
|
||||
$srctemplatepath,
|
||||
array(
|
||||
'PATH_TO_TMP' => $conf->fournisseur->dir_temp,
|
||||
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
||||
'DELIMITER_LEFT' => '{',
|
||||
'DELIMITER_RIGHT' => '}'
|
||||
)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
// After construction $odfHandler->contentXml contains content and
|
||||
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
|
||||
// [!-- BEGIN lines --]*[!-- END lines --]
|
||||
//print html_entity_decode($odfHandler->__toString());
|
||||
//print exit;
|
||||
|
||||
|
||||
// Make substitutions into odt of freetext
|
||||
try {
|
||||
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
|
||||
} 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);
|
||||
// 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');
|
||||
}
|
||||
|
||||
$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
|
||||
|
||||
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) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
}
|
||||
// Replace tags of lines
|
||||
try {
|
||||
$foundtagforlines = 1;
|
||||
try {
|
||||
$listlines = $odfHandler->setSegment('lines');
|
||||
} catch (OdfException $e) {
|
||||
// We may arrive here if tags for lines not present into template
|
||||
$foundtagforlines = 0;
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
if ($foundtagforlines) {
|
||||
$linenumber = 0;
|
||||
foreach ($object->lines as $line) {
|
||||
$linenumber++;
|
||||
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
|
||||
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) {
|
||||
try {
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
} catch (SegmentException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
} catch (OdfException $e) {
|
||||
$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) {
|
||||
try {
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
} catch (OdfException $e) {
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// Write new file
|
||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||
try {
|
||||
$odfHandler->exportAsAttachedPDF($file);
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
dol_syslog($e->getMessage(), LOG_INFO);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$odfHandler->saveToDisk($file);
|
||||
} catch (Exception $e) {
|
||||
$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
|
||||
|
||||
if (!empty($conf->global->MAIN_UMASK)) {
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
$odfHandler = null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
} else {
|
||||
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/propale/doc/pdf_azur.modules.php
|
||||
* \file htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
|
||||
* \ingroup propale
|
||||
* \brief File of the class allowing to generate the supplier propals to the Aurore model
|
||||
* \brief File of the class allowing to generate the supplier proposals to the Aurore model
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
@@ -74,7 +74,7 @@ if ($action == 'presend') {
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
// Load traductions files required by page
|
||||
$outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions'));
|
||||
$outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions', 'sendings'));
|
||||
}
|
||||
|
||||
$topicmail = '';
|
||||
|
||||
@@ -167,8 +167,9 @@ if ($massaction == 'presend') {
|
||||
$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); // For proposal, order, invoice, conferenceorbooth, ...
|
||||
if (in_array($objecttmp->element, array('societe', 'conferenceorboothattendee'))) {
|
||||
$thirdpartyid = $objecttmp->id;
|
||||
}
|
||||
if ($objecttmp->element == 'expensereport') {
|
||||
} elseif ($objecttmp->element == 'contact') {
|
||||
$thirdpartyid = $objecttmp->id;
|
||||
} elseif ($objecttmp->element == 'expensereport') {
|
||||
$thirdpartyid = $objecttmp->fk_user_author;
|
||||
}
|
||||
if (empty($thirdpartyid)) {
|
||||
@@ -205,6 +206,10 @@ if ($massaction == 'presend') {
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($thirdpartyid);
|
||||
$liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">";
|
||||
} elseif ($objecttmp->element == 'contact') {
|
||||
$fcontact = new Contact($db);
|
||||
$fcontact->fetch($thirdpartyid);
|
||||
$liste['contact'] = $fcontact->getFullName($langs)." <".$fcontact->email.">";
|
||||
} elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
|
||||
$fadherent = new Adherent($db);
|
||||
$fadherent->fetch($objecttmp->fk_member);
|
||||
@@ -236,17 +241,23 @@ if ($massaction == 'presend') {
|
||||
} else {
|
||||
$formmail->withtopic = 1;
|
||||
}
|
||||
$formmail->withfile = 1; // $formmail->withfile = 2 to allow to upload files is not yet supported in mass action
|
||||
// Add a checkbox "Attach also main document"
|
||||
if (isset($withmaindocfilemail)) {
|
||||
$formmail->withmaindocfile = $withmaindocfilemail;
|
||||
} else { // Do an automatic definition of $formmail->withmaindocfile
|
||||
$formmail->withmaindocfile = 1;
|
||||
if ($objecttmp->element != 'societe') {
|
||||
$formmail->withfile = '<span class="hideonsmartphone opacitymedium">'.$langs->trans("OnlyPDFattachmentSupported").'</span>';
|
||||
$formmail->withmaindocfile = -1; // Add a checkbox "Attach also main document" but not checked by default
|
||||
if ($objecttmp->element == 'contact') {
|
||||
$formmail->withfile = 0;
|
||||
$formmail->withmaindocfile = 0; // Add a checkbox "Attach also main document"
|
||||
} else {
|
||||
$formmail->withfile = 1; // $formmail->withfile = 2 to allow to upload files is not yet supported in mass action
|
||||
// Add a checkbox "Attach also main document"
|
||||
if (isset($withmaindocfilemail)) {
|
||||
$formmail->withmaindocfile = $withmaindocfilemail;
|
||||
} else { // Do an automatic definition of $formmail->withmaindocfile
|
||||
$formmail->withmaindocfile = 1;
|
||||
if ($objecttmp->element != 'societe') {
|
||||
$formmail->withfile = '<span class="hideonsmartphone opacitymedium">' . $langs->trans("OnlyPDFattachmentSupported") . '</span>';
|
||||
$formmail->withmaindocfile = -1; // Add a checkbox "Attach also main document" but not checked by default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$formmail->withbody = 1;
|
||||
$formmail->withdeliveryreceipt = 1;
|
||||
$formmail->withcancel = 1;
|
||||
|
||||
@@ -1148,7 +1148,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
||||
jQuery("#multicurrency_price_ttc").val('').hide();
|
||||
jQuery("#title_up_ttc, #title_up_ttc_currency").hide();
|
||||
<?php } ?>
|
||||
jQuery("#fourn_ref, #tva_tx, #title_vat").hide();
|
||||
jQuery("#tva_tx, #title_vat").hide();
|
||||
/* jQuery("#title_fourn_ref").hide(); */
|
||||
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
|
||||
jQuery("#buying_price").show();
|
||||
|
||||
Reference in New Issue
Block a user