';
if ($soc->outstanding_limit)
{
@@ -2454,7 +2454,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
print '';
- print '';
+ print ''; // Close fichecenter
print '
';
diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php
index 1f8b440749f..74a2243d633 100644
--- a/htdocs/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php
@@ -39,7 +39,7 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
// Load translation files required by the page
$langs->load("orders");
-$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc');
+$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$total=0; $ilink=0;
foreach($linkedObjectBlock as $key => $objectlink)
diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
index a9fbb5da2eb..bef705a21ab 100644
--- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
@@ -38,7 +38,7 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("bills");
-$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc');
+$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$total=0; $ilink=0;
foreach($linkedObjectBlock as $key => $objectlink)
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 9c403b98104..0d76b83cb8a 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -489,7 +489,10 @@ class Conf
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
// By default, suppliers objects can be linked to all projects
- $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
+ if (! isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
+
+ // By default we enable feature to bill time spent
+ if (! isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1;
// MAIN_HTML_TITLE
if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 711c48053f1..df000b2e857 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -6672,7 +6672,8 @@ class Form
'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'),
- 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')')
+ 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'),
+ 'ticket'=>array('enabled'=>$conf->ticket->enabled , 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')')
);
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index be389a94283..5f63d4db66c 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -130,15 +130,35 @@ class FormFile
$out .= '';
- $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
- $maxphp=@ini_get('upload_max_filesize'); // En inconnu
+ $max=$conf->global->MAIN_UPLOAD_DOC; // In Kb
+ $maxphp=@ini_get('upload_max_filesize'); // In unknown
if (preg_match('/k$/i', $maxphp)) $maxphp=$maxphp*1;
if (preg_match('/m$/i', $maxphp)) $maxphp=$maxphp*1024;
if (preg_match('/g$/i', $maxphp)) $maxphp=$maxphp*1024*1024;
if (preg_match('/t$/i', $maxphp)) $maxphp=$maxphp*1024*1024*1024;
- // Now $max and $maxphp are in Kb
+ $maxphp2=@ini_get('post_max_size'); // In unknown
+ if (preg_match('/k$/i', $maxphp2)) $maxphp2=$maxphp2*1;
+ if (preg_match('/m$/i', $maxphp2)) $maxphp2=$maxphp2*1024;
+ if (preg_match('/g$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024;
+ if (preg_match('/t$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024*1024;
+ // Now $max and $maxphp and $maxphp2 are in Kb
$maxmin = $max;
- if ($maxphp > 0) $maxmin=min($max, $maxphp);
+ $maxphptoshow = $maxphptoshowparam = '';
+ if ($maxphp > 0)
+ {
+ $maxmin=min($max, $maxphp);
+ $maxphptoshow = $maxphp;
+ $maxphptoshowparam = 'upload_max_filesize';
+ }
+ if ($maxphp2 > 0)
+ {
+ $maxmin=min($max, $maxphp2);
+ if ($maxphp2 < $maxphp)
+ {
+ $maxphptoshow = $maxphp2;
+ $maxphptoshowparam = 'post_max_size';
+ }
+ }
if ($maxmin > 0)
{
@@ -168,7 +188,7 @@ class FormFile
{
$langs->load('other');
$out .= ' ';
- $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphp), 1);
+ $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1);
}
}
else
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index 6f712fa6c4d..a7797f91833 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -733,40 +733,97 @@ class FormTicket
print ajax_combobox('select'.$htmlname);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Clear list of attached files in send mail form (also stored in session)
+ *
+ * @return void
+ */
+ public function clear_attached_files()
+ {
+ // phpcs:enable
+ global $conf,$user;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ // Set tmp user directory
+ $vardir=$conf->user->dir_output."/".$user->id;
+ $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
+ if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
+
+ $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
+ unset($_SESSION["listofpaths".$keytoavoidconflict]);
+ unset($_SESSION["listofnames".$keytoavoidconflict]);
+ unset($_SESSION["listofmimes".$keytoavoidconflict]);
+ }
+
/**
* Show the form to add message on ticket
*
- * @param string $width Width of form
- * @return void
+ * @param string $width Width of form
+ * @return void
*/
public function showMessageForm($width = '40%')
{
- global $conf, $langs, $user, $mysoc;
+ global $conf, $langs, $user, $hookmanager, $form, $mysoc;
+
+ $formmail = new FormMail($this->db);
+ $addfileaction = 'addfile';
+
+ if (! is_object($form)) $form=new Form($this->db);
// Load translation files required by the page
$langs->loadLangs(array('other', 'mails'));
- $addfileaction = 'addfile';
+ // Clear temp files. Must be done at beginning, before call of triggers
+ if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
+ {
+ $this->clear_attached_files();
+ }
- $form = new Form($this->db);
- $formmail = new FormMail($this->db);
+ // Define output language
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ $outputlangs->load('other');
+ }
+ // Get message template for $this->param["models"] into c_email_templates
+ $arraydefaultmessage = -1;
+ if ($this->param['models'] != 'none')
+ {
+ $model_id=0;
+ if (array_key_exists('models_id', $this->param))
+ {
+ $model_id=$this->param["models_id"];
+ }
+
+ $arraydefaultmessage=$formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one
+ }
// Define list of attached files
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
- if (!empty($_SESSION["listofpaths"])) {
- $listofpaths = explode(';', $_SESSION["listofpaths"]);
+ $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
+
+ if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
+ {
+ if (! empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit']))
+ {
+ foreach($this->param['fileinit'] as $file)
+ {
+ $this->add_attached_files($file, basename($file), dol_mimetype($file));
+ }
+ }
}
- if (!empty($_SESSION["listofnames"])) {
- $listofnames = explode(';', $_SESSION["listofnames"]);
- }
-
- if (!empty($_SESSION["listofmimes"])) {
- $listofmimes = explode(';', $_SESSION["listofmimes"]);
- }
+ if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
+ if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
+ if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
// Define output language
$outputlangs = $langs;
@@ -808,6 +865,7 @@ class FormTicket
print ' |