Merge remote-tracking branch 'upstream/develop' into productmerge

This commit is contained in:
Frédéric FRANCE 2022-02-22 21:49:17 +01:00
commit b277ab9ee3
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
257 changed files with 2893 additions and 985 deletions

View File

@ -1,6 +1,7 @@
README (English) README (English)
################################################## ##################################################
Building PAD files Building PAD files
http://pad.asp-software.org/padgen.php
################################################## ##################################################
This directory contains files and docs used to build This directory contains files and docs used to build

View File

@ -30,7 +30,7 @@ return "Regis Houssin";
# script_dolibarr_versions() # script_dolibarr_versions()
sub script_dolibarr_versions sub script_dolibarr_versions
{ {
return ( "12.0.3", "11.0.5", "10.0.7", "9.0.4", "8.0.6", "7.0.5" ); return ( "14.0.5", "13.0.5", "12.0.5", "11.0.5", "10.0.7", "9.0.4", "8.0.6", "7.0.5" );
} }
sub script_dolibarr_release sub script_dolibarr_release
@ -400,6 +400,8 @@ sub script_dolibarr_check_latest
{ {
local ($ver) = @_; local ($ver) = @_;
local @vers = &osdn_package_versions("dolibarr", local @vers = &osdn_package_versions("dolibarr",
$ver >= 14.0 ? "dolibarr\\-(12\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 13.0 ? "dolibarr\\-(12\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 12.0 ? "dolibarr\\-(12\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 12.0 ? "dolibarr\\-(12\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 11.0 ? "dolibarr\\-(11\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 11.0 ? "dolibarr\\-(11\\.0\\.[0-9\\.]+)\\.tgz" :
$ver >= 10.0 ? "dolibarr\\-(10\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 10.0 ? "dolibarr\\-(10\\.0\\.[0-9\\.]+)\\.tgz" :

View File

@ -166,7 +166,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
%_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/bookmarks
%_datadir/dolibarr/htdocs/bom %_datadir/dolibarr/htdocs/bom
%_datadir/dolibarr/htdocs/cashdesk
%_datadir/dolibarr/htdocs/categories %_datadir/dolibarr/htdocs/categories
%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/collab
%_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/comm

View File

@ -247,7 +247,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
%_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/bookmarks
%_datadir/dolibarr/htdocs/bom %_datadir/dolibarr/htdocs/bom
%_datadir/dolibarr/htdocs/cashdesk
%_datadir/dolibarr/htdocs/categories %_datadir/dolibarr/htdocs/categories
%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/collab
%_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/comm

View File

@ -163,7 +163,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
%_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/bookmarks
%_datadir/dolibarr/htdocs/bom %_datadir/dolibarr/htdocs/bom
%_datadir/dolibarr/htdocs/cashdesk
%_datadir/dolibarr/htdocs/categories %_datadir/dolibarr/htdocs/categories
%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/collab
%_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/comm

View File

@ -174,7 +174,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/blockedlog
%_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/bookmarks
%_datadir/dolibarr/htdocs/bom %_datadir/dolibarr/htdocs/bom
%_datadir/dolibarr/htdocs/cashdesk
%_datadir/dolibarr/htdocs/categories %_datadir/dolibarr/htdocs/categories
%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/collab
%_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/comm

View File

@ -5,4 +5,4 @@ This directory contains samples of code to use Dolibarr business classes to buil
external interfaces that need to read/update data from/into Dolibarr. external interfaces that need to read/update data from/into Dolibarr.
You can also have a look at the Dolibarr doxygen doc that describes all files and classes: You can also have a look at the Dolibarr doxygen doc that describes all files and classes:
http://www.dolibarr.org/html_doxygen/index.html https://doxygen.dolibarr.org/

View File

@ -55,8 +55,8 @@ class AccountancyImport
$fieldname = $fieldArr[1]; $fieldname = $fieldArr[1];
} }
$debit = trim($arrayrecord[11]['val']); $debit = floatval(trim($arrayrecord[11]['val']));
$credit = trim($arrayrecord[12]['val']); $credit = floatval(trim($arrayrecord[12]['val']));
if (!empty($debit)) { if (!empty($debit)) {
$amount = $debit; $amount = $debit;
} else { } else {
@ -86,7 +86,7 @@ class AccountancyImport
$fieldname = $fieldArr[1]; $fieldname = $fieldArr[1];
} }
$debit = trim($arrayrecord[11]['val']); $debit = floatval(trim($arrayrecord[11]['val']));
if (!empty($debit)) { if (!empty($debit)) {
$sens = 'D'; $sens = 'D';
} else { } else {

View File

@ -476,7 +476,7 @@ class AccountingAccount extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '')
{ {
global $langs, $conf; global $langs, $conf, $hookmanager;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
@ -561,6 +561,15 @@ class AccountingAccount extends CommonObject
if ($withpicto != 2) { if ($withpicto != 2) {
$result .= $linkstart . $label_link . $linkend; $result .= $linkstart . $label_link . $linkend;
} }
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -221,7 +221,7 @@ class AccountingJournal extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0)
{ {
global $langs, $conf, $user; global $langs, $conf, $user, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips $notooltip = 1; // Force disable tooltips
@ -276,6 +276,15 @@ class AccountingJournal extends CommonObject
} }
$result .= $linkend; $result .= $linkend;
global $action;
$hookmanager->initHooks(array('accountingjournaldao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -331,7 +331,7 @@ class BookKeeping extends CommonObject
if (empty($this->piece_num)) { if (empty($this->piece_num)) {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sqlnum .= " WHERE entity = ".$conf->entity; // Do not use getEntity for accounting features $sqlnum .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
$resqlnum = $this->db->query($sqlnum); $resqlnum = $this->db->query($sqlnum);
if ($resqlnum) { if ($resqlnum) {
@ -460,7 +460,7 @@ class BookKeeping extends CommonObject
{ {
global $db, $conf, $langs; global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips $notooltip = 1; // Force disable tooltips
@ -512,6 +512,15 @@ class BookKeeping extends CommonObject
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }
@ -736,7 +745,7 @@ class BookKeeping extends CommonObject
$sql .= " t.date_validated as date_validation"; $sql .= " t.date_validated as date_validation";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
if (null !== $ref) { if (null !== $ref) {
$sql .= " AND t.ref = '".$this->db->escape($ref)."'"; $sql .= " AND t.ref = '".$this->db->escape($ref)."'";
} else { } else {
@ -881,7 +890,7 @@ class BookKeeping extends CommonObject
} }
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere);
} }
@ -1037,7 +1046,7 @@ class BookKeeping extends CommonObject
} }
} }
} }
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')'; $sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
if ($showAlreadyExportMovements == 0) { if ($showAlreadyExportMovements == 0) {
$sql .= " AND t.date_export IS NULL"; $sql .= " AND t.date_export IS NULL";
} }
@ -1157,7 +1166,7 @@ class BookKeeping extends CommonObject
} }
} }
} }
$sql .= ' WHERE entity IN ('.getEntity('accountancy').')'; $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere);
} }
@ -1455,7 +1464,7 @@ class BookKeeping extends CommonObject
*/ */
public function deleteByYearAndJournal($delyear = 0, $journal = '', $mode = '', $delmonth = 0) public function deleteByYearAndJournal($delyear = 0, $journal = '', $mode = '', $delmonth = 0)
{ {
global $langs; global $conf, $langs;
if (empty($delyear) && empty($journal)) { if (empty($delyear) && empty($journal)) {
$this->error = 'ErrorOneFieldRequired'; $this->error = 'ErrorOneFieldRequired';
@ -1476,7 +1485,7 @@ class BookKeeping extends CommonObject
if (!empty($journal)) { if (!empty($journal)) {
$sql .= " AND code_journal = '".$this->db->escape($journal)."'"; $sql .= " AND code_journal = '".$this->db->escape($journal)."'";
} }
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
// Exclusion of validated entries at the time of deletion // Exclusion of validated entries at the time of deletion
$sql .= " AND date_validated IS NULL"; $sql .= " AND date_validated IS NULL";
@ -1515,7 +1524,7 @@ class BookKeeping extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE piece_num = ".(int) $piecenum; $sql .= " WHERE piece_num = ".(int) $piecenum;
$sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion $sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1637,7 +1646,7 @@ class BookKeeping extends CommonObject
} }
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE piece_num = ".((int) $piecenum); $sql .= " WHERE piece_num = ".((int) $piecenum);
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1675,9 +1684,10 @@ class BookKeeping extends CommonObject
global $conf; global $conf;
$sql = "SELECT MAX(piece_num)+1 as max FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql = "SELECT MAX(piece_num)+1 as max FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE entity IN (".getEntity('accountancy').")"; $sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::getNextNumMvt", LOG_DEBUG);
dol_syslog(get_class($this)."getNextNumMvt", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -1718,7 +1728,7 @@ class BookKeeping extends CommonObject
} }
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE piece_num = ".((int) $piecenum); $sql .= " WHERE piece_num = ".((int) $piecenum);
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1781,7 +1791,7 @@ class BookKeeping extends CommonObject
$sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num,"; $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num,";
$sql .= " date_validated as date_validation"; $sql .= " date_validated as date_validation";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE entity IN (".getEntity('accountancy').")"; $sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG); dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG);
@ -1837,6 +1847,8 @@ class BookKeeping extends CommonObject
*/ */
public function transformTransaction($direction = 0, $piece_num = '') public function transformTransaction($direction = 0, $piece_num = '')
{ {
global $conf;
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
@ -1856,14 +1868,14 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = 'Error '.$this->db->lasterror(); $this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
} }
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
@ -1871,7 +1883,7 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
} }
} elseif ($direction == 1) { } elseif ($direction == 1) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
@ -1886,14 +1898,14 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = 'Error '.$this->db->lasterror(); $this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
} }
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
@ -1948,7 +1960,7 @@ class BookKeeping extends CommonObject
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) $pcgver); $sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " AND ab.entity IN (".getEntity('accountancy').")"; $sql .= " AND ab.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
$sql .= " ORDER BY account_number ASC"; $sql .= " ORDER BY account_number ASC";
dol_syslog(get_class($this)."::select_account", LOG_DEBUG); dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
@ -2012,7 +2024,7 @@ class BookKeeping extends CommonObject
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1";
$sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'"; $sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
$sql .= " AND aa.entity IN (".getEntity('accountancy').")"; $sql .= " AND aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::select_account", LOG_DEBUG); dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -2052,7 +2064,7 @@ class BookKeeping extends CommonObject
$sql .= " AND asy.rowid = ".((int) $pcgver); $sql .= " AND asy.rowid = ".((int) $pcgver);
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
$sql .= " WHERE aa.entity IN (".getEntity('accountancy').")"; $sql .= " WHERE aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
dol_syslog(get_class($this)."::select_account", LOG_DEBUG); dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -500,6 +500,7 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} }
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
$sql .= ' ORDER BY aa.account_number';
dol_syslog('htdocs/accountancy/customer/index.php'); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -199,7 +199,25 @@ for ($i = 1; $i <= 12; $i++) {
if ($j > 12) { if ($j > 12) {
$j -= 12; $j -= 12;
} }
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; $cursormonth = $j;
if ($cursormonth > 12) {
$cursormonth -= 12;
}
$cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y;
$tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt');
print '<td width="60" class="right">';
if (!empty($tmp['mday'])) {
$param = 'search_date_startday=1&search_date_startmonth='.$cursormonth.'&search_date_startyear='.$cursoryear;
$param .= '&search_date_endday='.$tmp['mday'].'&search_date_endmonth='.$tmp['mon'].'&search_date_endyear='.$tmp['year'];
$param .= '&search_month='.$tmp['mon'].'&search_year='.$tmp['year'];
print '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/list.php?'.$param.'">';
}
print $langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT));
if (!empty($tmp['mday'])) {
print '</a>';
}
print '</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -226,6 +244,7 @@ $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseRepo
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
$sql .= ' ORDER BY aa.account_number';
dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql); dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql);
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -171,7 +171,7 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S
print $s; print $s;
print "<br>\n"; print "<br>\n";
} }
if (!empty($conf->expensereport->enabled)) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several. if (!empty($conf->expensereport->enabled)) {
$step++; $step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}'); $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s); $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);

View File

@ -1057,7 +1057,7 @@ if (empty($action) || $action == 'view') {
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom centerimp">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';

View File

@ -521,7 +521,7 @@ if (empty($action) || $action == 'view') {
print $desc; print $desc;
print '</div>'; print '</div>';
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom centerimp">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';

View File

@ -774,7 +774,7 @@ if (empty($action) || $action == 'view') {
print $desc; print $desc;
print '</div>'; print '</div>';
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom centerimp">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
} }

View File

@ -716,7 +716,7 @@ if (empty($action) || $action == 'view') {
print $desc; print $desc;
print '</div>'; print '</div>';
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom centerimp">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
} }

View File

@ -374,6 +374,7 @@ $sql .= " AND ffd.product_type <= 2";
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
$sql .= ' ORDER BY aa.account_number';
dol_syslog('htdocs/accountancy/supplier/index.php'); dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -196,6 +196,9 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateall">'; print '<input type="hidden" name="action" value="updateall">';
// Mains options
print load_fiche_titre($langs->trans("MemberMainOptions"), '', ''); print load_fiche_titre($langs->trans("MemberMainOptions"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -286,51 +289,15 @@ print '</div>';
print '</form>'; print '</form>';
print '<br>';
/*
* Edit info of model document
*/
$constantes = array(
'ADHERENT_CARD_TYPE',
//'ADHERENT_CARD_BACKGROUND',
'ADHERENT_CARD_HEADER_TEXT',
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_CARD_FOOTER_TEXT'
);
print load_fiche_titre($langs->trans("MembersCards"), '', '');
$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext .= '__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext);
print '<br>'; print '<br>';
/*
* Edit info of model document
*/
$constantes = array('ADHERENT_ETIQUETTE_TYPE', 'ADHERENT_ETIQUETTE_TEXT');
print load_fiche_titre($langs->trans("MembersTickets"), '', '');
$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext .= '__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
// Defined model definition table // Defined model definition table
$def = array(); $def = array();
$sql = "SELECT nom"; $sql = "SELECT nom as name";
$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
@ -339,14 +306,15 @@ if ($resql) {
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) { while ($i < $num_rows) {
$array = $db->fetch_array($resql); $obj = $db->fetch_object($resql);
array_push($def, $array[0]); array_push($def, $obj->name);
$i++; $i++;
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print load_fiche_titre($langs->trans("MembersDocModules"), '', ''); print load_fiche_titre($langs->trans("MembersDocModules"), '', '');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -460,6 +428,55 @@ foreach ($dirmodels as $reldir) {
print '</table>'; print '</table>';
print '</div>'; print '</div>';
/*
TODO Use a global form instead of embeded form into table
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateall">';
*/
/*
* Edit info of model document
*/
$constantes = array(
'ADHERENT_CARD_TYPE',
//'ADHERENT_CARD_BACKGROUND',
'ADHERENT_CARD_HEADER_TEXT',
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_CARD_FOOTER_TEXT'
);
print load_fiche_titre($langs->trans("MembersCards"), '', '');
$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext .= '__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext);
print '<br>';
/*
* Edit info of model document
*/
$constantes = array('ADHERENT_ETIQUETTE_TYPE', 'ADHERENT_ETIQUETTE_TEXT');
print load_fiche_titre($langs->trans("MembersTickets"), '', '');
$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext .= '__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext);
//print '</form>';
print "<br>"; print "<br>";
print dol_get_fiche_end(); print dol_get_fiche_end();

View File

@ -65,6 +65,9 @@ if (GETPOST('actioncode', 'array')) {
} }
$search_agenda_label = GETPOST('search_agenda_label'); $search_agenda_label = GETPOST('search_agenda_label');
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$objcanvas = null;
// Security check // Security check
$result = restrictedArea($user, 'adherent', $id); $result = restrictedArea($user, 'adherent', $id);

View File

@ -55,6 +55,7 @@ $id = GETPOST('id') ?GETPOST('id', 'int') : $rowid;
$typeid = GETPOST('typeid', 'int'); $typeid = GETPOST('typeid', 'int');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$ref = GETPOST('ref', 'alpha');
if (!empty($conf->mailmanspip->enabled)) { if (!empty($conf->mailmanspip->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';

View File

@ -7,7 +7,7 @@
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2015-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net> * Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
@ -1805,6 +1805,7 @@ class Adherent extends CommonObject
$paiement = new Paiement($this->db); $paiement = new Paiement($this->db);
$paiement->datepaye = $paymentdate; $paiement->datepaye = $paymentdate;
$paiement->amounts = $amounts; $paiement->amounts = $amounts;
$paiement->paiementcode = $operation;
$paiement->paiementid = dol_getIdFromCode($this->db, $operation, 'c_paiement', 'code', 'id', 1); $paiement->paiementid = dol_getIdFromCode($this->db, $operation, 'c_paiement', 'code', 'id', 1);
$paiement->num_payment = $num_chq; $paiement->num_payment = $num_chq;
$paiement->note_public = $label; $paiement->note_public = $label;
@ -2164,7 +2165,7 @@ class Adherent extends CommonObject
*/ */
public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0) public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
{ {
global $conf, $langs; global $conf, $langs, $hookmanager;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
$withpictoimg = 0; $withpictoimg = 0;
@ -2282,7 +2283,15 @@ class Adherent extends CommonObject
$result .= '</span>'; $result .= '</span>';
} }
} }
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -40,6 +40,8 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
$langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other')); $langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other'));
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); $id = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');

View File

@ -119,7 +119,7 @@ print '<tr class="liste_titre"><th class="titlefieldcreate wordbreak">'.$langs->
// Name // Name
print '<tr class="oddeven"><td><label for="name">'.$langs->trans("CompanyName").'</label></td><td>'; print '<tr class="oddeven"><td><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" autofocus value="'.(GETPOSTISSET('nom') ? GETPOST('nom', 'nohtml') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_NAME) ? $conf->global->MAIN_INFO_ACCOUNTANT_NAME : '')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n"; print '<input name="nom" id="name" class="minwidth200" value="'.(GETPOSTISSET('nom') ? GETPOST('nom', 'nohtml') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_NAME) ? $conf->global->MAIN_INFO_ACCOUNTANT_NAME : '')).'"'.(empty($conf->global->MAIN_INFO_ACCOUNTANT_NAME) ? ' autofocus="autofocus"' : '').'></td></tr>'."\n";
// Address // Address
print '<tr class="oddeven"><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>'; print '<tr class="oddeven"><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>';

View File

@ -164,6 +164,9 @@ $urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentit
$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlvcal, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'vcal', '').'</span>'); $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlvcal, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'vcal', '').'</span>');
$message .= '<div class="urllink">'; $message .= '<div class="urllink">';
$message .= '<input type="text" id="onlinepaymenturl1" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'; $message .= '<input type="text" id="onlinepaymenturl1" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">';
if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
$message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'.img_picto('', 'download').'</a>';
}
$message .= '</div>'; $message .= '</div>';
$message .= ajax_autoselect('onlinepaymenturl1'); $message .= ajax_autoselect('onlinepaymenturl1');
$message .= '<br>'; $message .= '<br>';
@ -173,6 +176,9 @@ $urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event
$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlical, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', '').'</span>'); $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlical, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', '').'</span>');
$message .= '<div class="urllink">'; $message .= '<div class="urllink">';
$message .= '<input type="text" id="onlinepaymenturl2" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'; $message .= '<input type="text" id="onlinepaymenturl2" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">';
if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
$message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'.img_picto('', 'download').'</a>';
}
$message .= '</div>'; $message .= '</div>';
$message .= ajax_autoselect('onlinepaymenturl2'); $message .= ajax_autoselect('onlinepaymenturl2');
$message .= '<br>'; $message .= '<br>';
@ -182,6 +188,9 @@ $urlrss .= $urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.
$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlrss, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'rss', '').'</span>'); $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlrss, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'rss', '').'</span>');
$message .= '<div class="urllink">'; $message .= '<div class="urllink">';
$message .= '<input type="text" id="onlinepaymenturl3" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'; $message .= '<input type="text" id="onlinepaymenturl3" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">';
if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
$message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'.img_picto('', 'download').'</a>';
}
$message .= '</div>'; $message .= '</div>';
$message .= ajax_autoselect('onlinepaymenturl3'); $message .= ajax_autoselect('onlinepaymenturl3');
$message .= '<br>'; $message .= '<br>';

View File

@ -107,7 +107,7 @@ print '<td>'.$langs->trans("SendingsAbility").'</td>';
print '<td>'; print '<td>';
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
print $langs->trans("Required"); print '<span class="opacitymedium">'.img_picto($langs->trans("Required"), 'switch_on').'</span>';
/*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) /*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{ {
print '<a href="confexped.php?action=activate_sending&token='.newToken().'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="confexped.php?action=activate_sending&token='.newToken().'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';

View File

@ -222,7 +222,8 @@ if ($action == 'edit') {
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td>';
print '<td class="right">'.$langs->trans("LateWarningAfter").'</td></tr>';
foreach ($modules as $module => $delays) { foreach ($modules as $module => $delays) {
if (!empty($conf->$module->enabled)) { if (!empty($conf->$module->enabled)) {
@ -230,7 +231,7 @@ if ($action == 'edit') {
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; print '<td width="20px">'.img_object('', $delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall">'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall right">';
print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>'; print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
} }
} }
@ -242,10 +243,10 @@ if ($action == 'edit') {
// Show if meteo is enabled // Show if meteo is enabled
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">'; print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="right">';
print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO)); print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
print '</td></tr>'; print '</td></tr>';
@ -256,7 +257,7 @@ if ($action == 'edit') {
*/ */
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
foreach ($modules as $module => $delays) { foreach ($modules as $module => $delays) {
if (!empty($conf->$module->enabled)) { if (!empty($conf->$module->enabled)) {
@ -276,7 +277,7 @@ if ($action == 'edit') {
// Show if meteo is enabled // Show if meteo is enabled
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">'; print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
@ -301,7 +302,7 @@ if (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METE
} else { } else {
$str_mode_enabled = $str_mode_percentage; $str_mode_enabled = $str_mode_percentage;
} }
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>'; print '<br><a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? $conf->global->MAIN_USE_METEO_WITH_PERCENTAGE : '').'" />'; print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? $conf->global->MAIN_USE_METEO_WITH_PERCENTAGE : '').'" />';
print '<br><br>'; print '<br><br>';
@ -451,8 +452,9 @@ if ($action == 'edit') {
print $form->buttonsSaveCancel("Save", ''); print $form->buttonsSaveCancel("Save", '');
print '</form>'; print '</form>';
} else { } else {
print '<br><div class="tabsAction">'; print '<br><br><div class="tabsAction">';
print '<a class="butAction" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a></div>'; print '<a class="butAction" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
print '</div>';
} }
// End of page // End of page

View File

@ -267,9 +267,9 @@ class Dolistore
// add image or default ? // add image or default ?
if ($product->id_default_image != '') { if ($product->id_default_image != '') {
$image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.((int) $product->id).'&id_image='.((int) $product->id_default_image); $image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.urlencode(((int) $product->id)).'&id_image='.urlencode(((int) $product->id_default_image));
$images = '<a href="'.urlencode($image_url).'" class="documentpreview" target="_blank" rel="noopener noreferrer" mime="image/png" title="'.dol_escape_htmltag($product->name->language[$this->lang - 1].', '.$langs->trans('Version').' '.$product->module_version).'">'; $images = '<a href="'.$image_url.'" class="documentpreview" target="_blank" rel="noopener noreferrer" mime="image/png" title="'.dol_escape_htmltag($product->name->language[$this->lang - 1].', '.$langs->trans('Version').' '.$product->module_version).'">';
$images .= '<img src="'.urlencode($image_url).'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>'; $images .= '<img src="'.$image_url.'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>';
} else { } else {
$images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />'; $images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />';
} }
@ -277,11 +277,11 @@ class Dolistore
// free or pay ? // free or pay ?
if ($product->price > 0) { if ($product->price > 0) {
$price = '<h3>'.price(price2num($product->price, 'MT'), 0, $langs, 1, -1, -1, 'EUR').' '.$langs->trans("HT").'</h3>'; $price = '<h3>'.price(price2num($product->price, 'MT'), 0, $langs, 1, -1, -1, 'EUR').' '.$langs->trans("HT").'</h3>';
$download_link = '<a target="_blank" href="'.urlencode($this->shop_url.$product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>'; $download_link = '<a target="_blank" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
} else { } else {
$price = '<h3>'.$langs->trans('Free').'</h3>'; $price = '<h3>'.$langs->trans('Free').'</h3>';
$download_link = '<a target="_blank" rel="noopener noreferrer" href="'.urlencode($this->shop_url.$product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>'; $download_link = '<a target="_blank" rel="noopener noreferrer" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>';
$download_link .= '<br><br><a target="_blank" rel="noopener noreferrer" href="'.urlencode($this->shop_url.$product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>'; $download_link .= '<br><br><a target="_blank" href="'.$this->shop_url.urlencode($product->id).'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
} }
// Set and check version // Set and check version

View File

@ -97,7 +97,7 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc")); print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc"));
print '</td><td>'; print '</td><td>';
print '<input name="monday" id="monday" class="minwidth100" autofocus value="'.(!empty($conf->global->MAIN_INFO_OPENINGHOURS_MONDAY) ? $conf->global->MAIN_INFO_OPENINGHOURS_MONDAY : GETPOST("monday", 'alpha')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n"; print '<input name="monday" id="monday" class="minwidth100" value="'.(!empty($conf->global->MAIN_INFO_OPENINGHOURS_MONDAY) ? $conf->global->MAIN_INFO_OPENINGHOURS_MONDAY : GETPOST("monday", 'alpha')).'"'.(empty($conf->global->MAIN_INFO_OPENINGHOURS_MONDAY) ? ' autofocus="autofocus"' : '').'></td></tr>'."\n";
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc"));

View File

@ -249,7 +249,7 @@ print load_fiche_titre($langs->trans("PDF"), '', 'title_setup');
$head = pdf_admin_prepare_head(); $head = pdf_admin_prepare_head();
print dol_get_fiche_head($head, 'general', $langs->trans("PDF"), -1, 'pdf'); print dol_get_fiche_head($head, 'general', '', -1, '');
print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n"; print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n";
print "<br>\n"; print "<br>\n";

View File

@ -84,7 +84,7 @@ print load_fiche_titre($langs->trans("PDF"), '', 'title_setup');
$head = pdf_admin_prepare_head(); $head = pdf_admin_prepare_head();
print dol_get_fiche_head($head, 'other', $langs->trans("other"), -1, 'pdf'); print dol_get_fiche_head($head, 'other', '', -1, '');
$tooltiptext = ''; $tooltiptext = '';
print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFOtherDesc"), $tooltiptext)."</span><br>\n"; print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFOtherDesc"), $tooltiptext)."</span><br>\n";

View File

@ -143,6 +143,20 @@ if ($action == 'updateMask') {
} }
} }
if ($action == 'setvarworkflow') {
$param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
}
if ($action == 'setvarother') { if ($action == 'setvarother') {
$param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
@ -178,8 +192,14 @@ if ($action == 'setvarother') {
$error++; $error++;
} }
$param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); $param_delay_first_response = GETPOST('delay_first_response', 'int');
$res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$param_delay_between_responses = GETPOST('delay_between_responses', 'int');
$res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) { if (!($res > 0)) {
$error++; $error++;
} }
@ -467,7 +487,7 @@ print '</div><br>';
if (!$conf->use_javascript_ajax) { if (!$conf->use_javascript_ajax) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarother">'; print '<input type="hidden" name="action" value="setvarworkflow">';
} }
print load_fiche_titre($langs->trans("Other"), '', ''); print load_fiche_titre($langs->trans("Other"), '', '');
@ -479,8 +499,24 @@ print '<td></td>';
print '<td></td>'; print '<td></td>';
print "</tr>\n"; print "</tr>\n";
// Auto mark ticket read when created from backoffice
print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoReadTicket").'</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Auto assign ticket at user who created it // Auto assign ticket at user who created it
print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoAssignTicket").'</td>'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("TicketsAutoAssignTicket").'</td>';
print '<td class="left">'; print '<td class="left">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
@ -494,12 +530,41 @@ print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1,
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</table><br>';
if (!$conf->use_javascript_ajax) { if (!$conf->use_javascript_ajax) {
print '</form>'; print '</form>';
} }
// Define wanted maximum time elapsed before answers to tickets
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="action" value="setvarother">';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TicketsDelayBeforeFirstAnswer")."</td>";
print '<td class="left">
<input type="number" value="'.$conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE.'" name="delay_first_response">
<input type="submit" class="button small" value="'.$langs->trans("Save").'">
</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help');
print '</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TicketsDelayBetweenAnswers")."</td>";
print '<td class="left">
<input type="number" value="'.$conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE.'" name="delay_between_responses">
<input type="submit" class="button small" value="'.$langs->trans("Save").'">
</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help');
print '</td>';
print '</tr>';
print '</form>';
print '</table><br>';
// Admin var of module // Admin var of module
print load_fiche_titre($langs->trans("Notification"), '', ''); print load_fiche_titre($langs->trans("Notification"), '', '');

View File

@ -553,6 +553,7 @@ print '</form>';
print '</fieldset>'; print '</fieldset>';
$title = $langs->trans("BackupZipWizard");
print "<br>\n"; print "<br>\n";
print "<!-- Dump of a server -->\n"; print "<!-- Dump of a server -->\n";
@ -571,7 +572,7 @@ print '</span>';
print '<div id="backupfilesleft" class="fichehalfleft">'; print '<div id="backupfilesleft" class="fichehalfleft">';
print load_fiche_titre($title ? $title : $langs->trans("BackupZipWizard")); print load_fiche_titre($title);
print '<label for="zipfilename_template" class="line-height-large paddingbottom">'.$langs->trans("FileNameToGenerate").'</label><br>'; print '<label for="zipfilename_template" class="line-height-large paddingbottom">'.$langs->trans("FileNameToGenerate").'</label><br>';
$prefix = 'documents'; $prefix = 'documents';

View File

@ -254,6 +254,60 @@ $head = translation_prepare_head();
print dol_get_fiche_head($head, $mode, '', -1, ''); print dol_get_fiche_head($head, $mode, '', -1, '');
$langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang;
$newlang = new Translate('', $conf);
$newlang->setDefaultLang($langcode);
$langsenfileonly = new Translate('', $conf);
$langsenfileonly->setDefaultLang('en_US');
$newlangfileonly = new Translate('', $conf);
$newlangfileonly->setDefaultLang($langcode);
$recordtoshow = array();
// Search modules dirs
$modulesdir = dolGetModulesDirs();
$nbtotaloffiles = 0;
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
$i = 0;
foreach ($modulesdir as $keydir => $tmpsearchdir) {
$searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
// Directory of translation files
$dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels
$dir_lang_osencoded = dol_osencode($dir_lang);
$filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1);
foreach ($filearray as $file) {
$tmpfile = preg_replace('/.lang/i', '', basename($file['name']));
$moduledirname = (basename(dirname(dirname($dir_lang))));
$langkey = $tmpfile;
if ($i > 0) {
$langkey .= '@'.$moduledirname;
}
//var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
$result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
$result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
if ($result < 0) {
print 'Failed to load language file '.$tmpfile.'<br>'."\n";
} else {
$nbtotaloffiles++;
}
//print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
$result = $langsenfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
}
$i++;
}
if ($mode == 'overwrite') { if ($mode == 'overwrite') {
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
@ -348,7 +402,14 @@ if ($mode == 'overwrite') {
if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) { if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) {
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">'; print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">';
} else { } else {
//print $obj->transkey.' '.$langsenfileonly->tab_translate[$obj->transkey];
$titleforvalue = $langs->trans("Translation").' en_US for key '.$obj->transkey.':<br>'.($langsenfileonly->tab_translate[$obj->transkey] ? $langsenfileonly->trans($obj->transkey) : '<span class="opacitymedium">'.$langs->trans("None").'</span>');
/*if ($obj->lang != 'en_US') {
$titleforvalue .= '<br>'.$langs->trans("Translation").' '.$obj->lang.' '...;
}*/
print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
print dol_escape_htmltag($obj->transvalue); print dol_escape_htmltag($obj->transvalue);
print '</span>';
} }
print '</td>'; print '</td>';
@ -376,20 +437,6 @@ if ($mode == 'overwrite') {
} }
if ($mode == 'searchkey') { if ($mode == 'searchkey') {
$langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang;
$newlang = new Translate('', $conf);
$newlang->setDefaultLang($langcode);
$newlangfileonly = new Translate('', $conf);
$newlangfileonly->setDefaultLang($langcode);
$recordtoshow = array();
// Search modules dirs
$modulesdir = dolGetModulesDirs();
$nbtotaloffiles = 0;
$nbempty = 0; $nbempty = 0;
/*var_dump($langcode); /*var_dump($langcode);
var_dump($transkey); var_dump($transkey);
@ -403,41 +450,10 @@ if ($mode == 'searchkey') {
if (empty($transvalue)) { if (empty($transvalue)) {
$nbempty++; $nbempty++;
} }
if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this
setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings'); setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
} else { } else {
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
$i = 0;
foreach ($modulesdir as $keydir => $tmpsearchdir) {
$searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
// Directory of translation files
$dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels
$dir_lang_osencoded = dol_osencode($dir_lang);
$filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1);
foreach ($filearray as $file) {
$tmpfile = preg_replace('/.lang/i', '', basename($file['name']));
$moduledirname = (basename(dirname(dirname($dir_lang))));
$langkey = $tmpfile;
if ($i > 0) {
$langkey .= '@'.$moduledirname;
}
//var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
$result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
$result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
if ($result < 0) {
print 'Failed to load language file '.$tmpfile.'<br>'."\n";
} else {
$nbtotaloffiles++;
}
//print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
}
$i++;
}
// Now search into translation array // Now search into translation array
foreach ($newlang->tab_translate as $key => $val) { foreach ($newlang->tab_translate as $key => $val) {
if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) { if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) {
@ -532,8 +548,12 @@ if ($mode == 'searchkey') {
break; break;
} }
print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td class="small">'; print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td class="small">';
$titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':<br>'.($langsenfileonly->tab_translate[$key] ? $langsenfileonly->trans($key) : '<span class="opacitymedium">'.$langs->trans("None").'</span>');
print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
print dol_escape_htmltag($val); print dol_escape_htmltag($val);
print '</td><td class="right nowraponall">'; print '</span>';
print '</td>';
print '<td class="right nowraponall">';
if (!empty($newlangfileonly->tab_translate[$key])) { if (!empty($newlangfileonly->tab_translate[$key])) {
if ($val != $newlangfileonly->tab_translate[$key]) { if ($val != $newlangfileonly->tab_translate[$key]) {
// retrieve rowid // retrieve rowid

View File

@ -239,7 +239,6 @@ class Setup extends DolibarrApi
return $list; return $list;
} }
/** /**
* Get the list of states/provinces. * Get the list of states/provinces.
* *
@ -252,22 +251,29 @@ class Setup extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Number of items per page * @param int $limit Number of items per page
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $filter To filter the countries by name * @param int $country To filter on country
* @param string $filter To filter the states by name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return array List of countries * @return array List of states
* *
* @url GET dictionary/states * @url GET dictionary/states
* *
* @throws RestException * @throws RestException
*/ */
public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $sqlfilters = '') public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '')
{ {
$list = array(); $list = array();
// Note: The filter is not applied in the SQL request because it must // Note: The filter is not applied in the SQL request because it must
// be applied to the translated names, not to the names in database. // be applied to the translated names, not to the names in database.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t"; $sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
if ($country) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as d ON t.fk_region = d.code_region";
}
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
if ($country) {
$sql .= " AND d.fk_pays = ".((int) $country);
}
// Add sql filters // Add sql filters
if ($sqlfilters) { if ($sqlfilters) {
$errormessage = ''; $errormessage = '';
@ -1053,7 +1059,7 @@ class Setup extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $zipcode To filter on zipcode * @param string $zipcode To filter on zipcode
* @param string $town To filter on city name * @param string $town To filter on city name
* @param int $active Payment term is active or not {@min 0} {@max 1} * @param int $active Town is active or not {@min 0} {@max 1}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return array List of towns * @return array List of towns
* *
@ -1067,7 +1073,7 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql .= " AND t.active = ".((int) $active); $sql .= " WHERE t.active = ".((int) $active);
if ($zipcode) { if ($zipcode) {
$sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
} }
@ -1301,7 +1307,7 @@ class Setup extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Number of items per page * @param int $limit Number of items per page
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $country To filter on country * @param int $country To filter on country
* @param int $active Lega form is active or not {@min 0} {@max 1} * @param int $active Lega form is active or not {@min 0} {@max 1}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return array List of legal form * @return array List of legal form
@ -1310,7 +1316,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = '', $active = 1, $sqlfilters = '') public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@ -1318,7 +1324,7 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as t";
$sql .= " WHERE t.active = ".((int) $active); $sql .= " WHERE t.active = ".((int) $active);
if ($country) { if ($country) {
$sql .= " AND t.fk_pays = '".$this->db->escape($country)."'"; $sql .= " AND t.fk_pays = ".((int) $country);
} }
// Add sql filters // Add sql filters
if ($sqlfilters) { if ($sqlfilters) {
@ -1774,7 +1780,7 @@ class Setup extends DolibarrApi
$result = $establishment->fetch($id); $result = $establishment->fetch($id);
if ($result < 0) { if ($result < 0) {
throw new RestException(503, 'Error when retrieving state : '.$establishment->error); throw new RestException(503, 'Error when retrieving establishment : '.$establishment->error);
} elseif ($result == 0) { } elseif ($result == 0) {
throw new RestException(404, 'Establishment not found'); throw new RestException(404, 'Establishment not found');
} }

View File

@ -77,7 +77,6 @@ if (preg_match('/\/api\/index\.php/', $_SERVER["PHP_SELF"])) {
header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY'); header('Access-Control-Allow-Headers: Content-Type, Authorization, api_key, DOLAPIKEY');
} }
$res = 0; $res = 0;
if (!$res && file_exists("../main.inc.php")) { if (!$res && file_exists("../main.inc.php")) {
$res = include '../main.inc.php'; $res = include '../main.inc.php';

View File

@ -305,7 +305,7 @@ class Asset extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{ {
global $db, $conf, $langs; global $db, $conf, $langs, $hookmanager;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
@ -360,7 +360,15 @@ class Asset extends CommonObject
} }
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -518,7 +518,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Common attributes // Common attributes
$keyforbreak = 'duration'; $keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
$object->calculateCosts();
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td>'.price($object->total_cost).'</td></tr>'; print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td>'.price($object->total_cost).'</td></tr>';
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>'; print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';

View File

@ -0,0 +1,328 @@
<?php
/* Copyright (C) 2017-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 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
* 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/>.
*/
/**
* \file htdocs/bom/bom_net_needs.php
* \ingroup bom
* \brief Page to create/edit/view bom
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("mrp", "other"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomnet_needs'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
// Initialize technical objects
$object = new BOM($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomnetneeds')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
if ($object->id > 0) {
$object->calculateCosts();
}
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft);
$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1];
/*
* Actions
*/
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
$error = 0;
$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = DOL_URL_ROOT.'/bom/bom_net_needs.php?id='.($id > 0 ? $id : '__ID__');
}
}
}
if ($action == 'treeview') $object->getNetNeedsTree($TChildBom, 1);
else $object->getNetNeeds($TChildBom, 1);
}
/*
* View
*/
$form = new Form($db);
$formfile = new FormFile($db);
$title = $langs->trans('BOM');
$help_url ='EN:Module_BOM';
llxHeader('', $title, $help_url);
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$head = bomPrepareHead($object);
print dol_get_fiche_head($head, 'net_needs', $langs->trans("BillOfMaterials"), -1, 'bom');
$formconfirm = '';
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
} elseif ($reshook > 0) {
$formconfirm = $hookmanager->resPrint;
}
// Print form confirm
print $formconfirm;
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
$morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'."\n";
// Common attributes
$keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td>'.price($object->total_cost).'</td></tr>';
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
print dol_get_fiche_end();
$viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-list-alt imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':'')));
$viewlink .= dolGetButtonTitle($langs->trans('TreeStructure'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':'')));
print load_fiche_titre($langs->trans("BillOfMaterials"), $viewlink, 'cubes');
/*
* Lines
*/
$text_stock_options = $langs->trans("RealStockDesc").'<br>';
$text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'<br>';
$text_stock_options .= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? '- '.$langs->trans("DeStockOnShipment").'<br>' : '');
$text_stock_options .= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? '- '.$langs->trans("DeStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (! empty($conf->global->STOCK_CALCULATE_ON_BILL) ? '- '.$langs->trans("DeStockOnBill").'<br>' : '');
$text_stock_options .= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? '- '.$langs->trans("ReStockOnBill").'<br>' : '');
$text_stock_options .= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? '- '.$langs->trans("ReStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? '- '.$langs->trans("ReStockOnDispatchOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'<br>' : '');
print '<table id="tablelines" class="noborder noshadow" width="100%">';
print "<thead>\n";
print '<tr class="liste_titre nodrag nodrop">';
print '<td class="linecoldescription">'.$langs->trans('Product');
if (! empty($conf->global->BOM_SUB_BOM) && $action == 'treeview') {
print ' &nbsp; <a id="show_all" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'</a>&nbsp;&nbsp;';
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a>&nbsp;';
}
print '</td>';
print '<td class="linecolqty">'.$langs->trans('Quantity').'</td>';
print '<td class="linecolstock">'.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).'</td>';
print '<td class="linecoltheoricalstock">'.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'</td>';
print '</tr>';
if (! empty($TChildBom)) {
if ($action == 'treeview') {
foreach ($TChildBom as $fk_bom => $TProduct) {
$repeatChar = '&emsp;';
if (! empty($TProduct['bom'])) {
if ($TProduct['parentid'] != $object->id) print '<tr class="sub_bom_lines oddeven" parentid="'.$TProduct['parentid'].'">';
else print '<tr class="oddeven">';
print '<td class="linecoldescription">'.str_repeat($repeatChar, $TProduct['level']).$TProduct['bom']->getNomUrl(1);
print ' <a class="collapse_bom" id="collapse-'.$fk_bom.'" href="#">';
print img_picto('', 'folder-open');
print '</a>';
print '</td>';
print '<td class="linecolqty">'.$TProduct['qty'].'</td>';
print '<td class="linecolstock"></td>';
print '<td class="linecoltheoricalstock"></td>';
print '</tr>';
}
if (! empty($TProduct['product'])) {
foreach ($TProduct['product'] as $fk_product => $TInfos) {
$prod = new Product($db);
$prod->fetch($fk_product);
$prod->load_virtual_stock();
if (empty($prod->stock_reel)) $prod->stock_reel = 0;
if ($fk_bom != $object->id) print '<tr class="sub_bom_lines oddeven" parentid="'.$fk_bom.'">';
else print '<tr class="oddeven">';
print '<td class="linecoldescription">'.str_repeat($repeatChar, $TInfos['level']).$prod->getNomUrl(1).'</td>';
print '<td class="linecolqty">'.$TInfos['qty'].'</td>';
print '<td class="linecolstock">'.$prod->stock_reel.'</td>';
print '<td class="linecoltheoricalstock">'.$prod->stock_theorique.'</td>';
print '</tr>';
}
}
}
} else {
foreach ($TChildBom as $fk_product => $qty) {
$prod = new Product($db);
$prod->fetch($fk_product);
$prod->load_virtual_stock();
if (empty($prod->stock_reel)) $prod->stock_reel = 0;
print '<tr class="oddeven">';
print '<td class="linecoldescription">'.$prod->getNomUrl(1).'</td>';
print '<td class="linecolqty">'.$qty.'</td>';
print '<td class="linecolstock">'.$prod->stock_reel.'</td>';
print '<td class="linecoltheoricalstock">'.$prod->stock_theorique.'</td>';
print '</tr>';
}
}
}
print '</thead>';
print '</table>';
/*
* ButAction
*/
print '<div class="tabsAction">'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
print '</div>';
?>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
// When clicking on collapse
$(".collapse_bom").click(function() {
console.log("We click on collapse");
var id_bom_line = $(this).attr('id').replace('collapse-', '');
console.log($(this).html().indexOf('folder-open'));
if($(this).html().indexOf('folder-open') <= 0) {
$('[parentid="'+ id_bom_line +'"]').show();
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
}
else {
$('[parentid="'+ id_bom_line +'"]').hide();
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
}
return false;
});
// To Show all the sub bom lines
$("#show_all").click(function() {
console.log("We click on show all");
$("[class^=sub_bom_lines]").show();
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
return false;
});
// To Hide all the sub bom lines
$("#hide_all").click(function() {
console.log("We click on hide all");
$("[class^=sub_bom_lines]").hide();
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
return false;
});
});
</script>
<?php
}
// End of page
llxFooter();
$db->close();

View File

@ -847,7 +847,7 @@ class BOM extends CommonObject
global $action, $hookmanager; global $action, $hookmanager;
$hookmanager->initHooks(array('bomdao')); $hookmanager->initHooks(array('bomdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;
@ -1085,7 +1085,8 @@ class BOM extends CommonObject
$res = $bom_child->fetch($line->fk_bom_child); $res = $bom_child->fetch($line->fk_bom_child);
if ($res>0) { if ($res>0) {
$bom_child->calculateCosts(); $bom_child->calculateCosts();
$this->total_cost += $bom_child->total_cost; $line->childBom[] = $bom_child;
$this->total_cost += $bom_child->total_cost * $line->qty;
} else { } else {
$this->error = $bom_child->error; $this->error = $bom_child->error;
return -2; return -2;
@ -1118,6 +1119,54 @@ class BOM extends CommonObject
return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
} }
/**
* Get Net needs by product
*
* @param array $TNetNeeds Array of ChildBom and infos linked to
* @param int $qty qty needed
* @return void
*/
public function getNetNeeds(&$TNetNeeds = array(), $qty = 0)
{
if (! empty($this->lines)) {
foreach ($this->lines as $line) {
if (! empty($line->childBom)) {
foreach ($line->childBom as $childBom) $childBom->getNetNeeds($TNetNeeds, $line->qty*$qty);
} else {
$TNetNeeds[$line->fk_product] += $line->qty*$qty;
}
}
}
}
/**
* Get Net needs Tree by product or bom
*
* @param array $TNetNeeds Array of ChildBom and infos linked to
* @param int $qty qty needed
* @param int $level level of recursivity
* @return void
*/
public function getNetNeedsTree(&$TNetNeeds = array(), $qty = 0, $level = 0)
{
if (! empty($this->lines)) {
foreach ($this->lines as $line) {
if (! empty($line->childBom)) {
foreach ($line->childBom as $childBom) {
$TNetNeeds[$childBom->id]['bom'] = $childBom;
$TNetNeeds[$childBom->id]['parentid'] = $this->id;
$TNetNeeds[$childBom->id]['qty'] = $line->qty*$qty;
$TNetNeeds[$childBom->id]['level'] = $level;
$childBom->getNetNeedsTree($TNetNeeds, $line->qty*$qty, $level+1);
}
} else {
$TNetNeeds[$this->id]['product'][$line->fk_product]['qty'] += $line->qty * $qty;
$TNetNeeds[$this->id]['product'][$line->fk_product]['level'] = $level;
}
}
}
}
} }
@ -1244,6 +1293,11 @@ class BOMLine extends CommonObjectLine
public $unit_cost = 0; public $unit_cost = 0;
/**
* @var Bom array of Bom in line
*/
public $childBom = array();
/** /**
* Constructor * Constructor
* *
@ -1484,7 +1538,7 @@ class BOMLine extends CommonObjectLine
global $action, $hookmanager; global $action, $hookmanager;
$hookmanager->initHooks(array('bomlinedao')); $hookmanager->initHooks(array('bomlinedao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -84,6 +84,11 @@ function bomPrepareHead($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/bom/bom_net_needs.php?id=".$object->id;
$head[$h][1] = $langs->trans("BOMNetNeeds");
$head[$h][2] = 'net_needs';
$h++;
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0; $nbNote = 0;
if (!empty($object->note_private)) { if (!empty($object->note_private)) {

View File

@ -180,6 +180,7 @@ if ($action == 'selectlines') {
print '</tr>'; print '</tr>';
// Select of all the sub-BOM lines // Select of all the sub-BOM lines
// From this pont to the end of the file, we only take care of sub-BOM lines
$sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; $sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl';
$sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; $sql.= ' WHERE fk_bom ='. (int) $tmpbom->id;
$resql = $object->db->query($sql); $resql = $object->db->query($sql);
@ -191,7 +192,9 @@ if ($resql) {
$sub_bom_product->fetch($obj->fk_product); $sub_bom_product->fetch($obj->fk_product);
$sub_bom = new BOM($object->db); $sub_bom = new BOM($object->db);
if (!empty($obj->fk_bom_child)) {
$sub_bom->fetch($obj->fk_bom_child); $sub_bom->fetch($obj->fk_bom_child);
}
$sub_bom_line = new BOMLine($object->db); $sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid); $sub_bom_line->fetch($obj->rowid);
@ -233,20 +236,23 @@ if ($resql) {
// Efficiency // Efficiency
print '<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.'">'.$sub_bom_line->efficiency.'</td>'; print '<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.'">'.$sub_bom_line->efficiency.'</td>';
// Cost price if it's defined if (!empty($sub_bom->id)) {
if ($sub_bom_product->cost_price > 0) { $sub_bom->calculateCosts();
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom_product->cost_price * $line->qty).'</td>'; print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).'</td>';
$total_cost+= $sub_bom_product->cost_price * $line->qty; $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
} elseif ($sub_bom_product->cost_price > 0) {
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).'</td>';
$total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
} elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom_product->pmp * $line->qty).'</td>'; print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).'</td>';
$total_cost.= $sub_bom_product->pmp * $line->qty; $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
} else { // Minimum purchase price if cost price and PMP aren't defined } else { // Minimum purchase price if cost price and PMP aren't defined
$sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
$sql_supplier_price.= ' WHERE fk_product = '. (int) $sub_bom_product->id; $sql_supplier_price.= ' WHERE fk_product = '. (int) $sub_bom_product->id;
$resql_supplier_price = $object->db->query($sql_supplier_price); $resql_supplier_price = $object->db->query($sql_supplier_price);
if ($resql_supplier_price) { if ($resql_supplier_price) {
$obj = $object->db->fetch_object($resql_supplier_price); $obj = $object->db->fetch_object($resql_supplier_price);
$line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty; $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($line_cost).'</td>'; print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($line_cost).'</td>';
$total_cost+= $line_cost; $total_cost+= $line_cost;

View File

@ -344,7 +344,7 @@ class Bookmark extends CommonObject
global $action, $hookmanager; global $action, $hookmanager;
$hookmanager->initHooks(array('mybookmarkdao')); $hookmanager->initHooks(array('mybookmarkdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -10,7 +10,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -185,7 +185,8 @@ class Categorie extends CommonObject
'contact' => 'socpeople', 'contact' => 'socpeople',
'account' => 'bank_account', // old for bank account 'account' => 'bank_account', // old for bank account
'project' => 'projet', 'project' => 'projet',
'warehouse'=> 'entrepot' 'warehouse'=> 'entrepot',
'knowledgemanagement' => 'knowledgemanagement_knowledgerecord'
); );
/** /**
@ -1612,7 +1613,7 @@ class Categorie extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $moreparam = '') public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $moreparam = '')
{ {
global $langs; global $langs, $hookmanager;
$result = ''; $result = '';
$label = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label); $label = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label);
@ -1640,6 +1641,15 @@ class Categorie extends CommonObject
if ($withpicto != 2) { if ($withpicto != 2) {
$result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend; $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend;
} }
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -178,7 +178,9 @@ print '</td></tr>';
// Parent category // Parent category
print '<tr><td>'.$langs->trans("In").'</td><td>'; print '<tr><td>'.$langs->trans("In").'</td><td>';
print img_picto('', 'category', 'class="pictofixedwidth"');
print $form->select_all_categories($type, $object->fk_parent, 'parent', 64, $object->id); print $form->select_all_categories($type, $object->fk_parent, 'parent', 64, $object->id);
print ajax_combobox('parent');
print '</td></tr>'; print '</td></tr>';
$parameters = array(); $parameters = array();

View File

@ -76,11 +76,14 @@ if ($complete == 'na' || $complete == -2) {
} }
if ($fulldayevent) { if ($fulldayevent) {
$datep = dol_mktime('00', '00', 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
$datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
$datep = dol_mktime('00', '00', 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
$datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
//print $db->idate($datep); exit;
} else { } else {
$datep = dol_mktime($aphour, $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $datep = dol_mktime($aphour, $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel');
$datef = dol_mktime($p2hour, $p2min, '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); $datef = dol_mktime($p2hour, $p2min, '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel');
} }
// Security check // Security check
@ -252,8 +255,15 @@ if (empty($reshook) && $action == 'add') {
$percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
// Clean parameters // Clean parameters
if ($fulldayevent) {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
// For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
$datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
$datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
} else {
$datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
$datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
}
// Check parameters // Check parameters
if (!$datef && $percentage == 100) { if (!$datef && $percentage == 100) {
@ -513,8 +523,16 @@ if (empty($reshook) && $action == 'update') {
$object->fetch_userassigned(); $object->fetch_userassigned();
$object->oldcopy = clone $object; $object->oldcopy = clone $object;
$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser'); // Clean parameters
$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser'); if ($fulldayevent) {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
// For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
$datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
$datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
} else {
$datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
$datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
}
$object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
$object->label = GETPOST("label", "alphanohtml"); $object->label = GETPOST("label", "alphanohtml");
@ -1005,11 +1023,11 @@ if ($action == 'create') {
$datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep));
if (GETPOST('datep', 'int', 1)) { if (GETPOST('datep', 'int', 1)) {
$datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser');
} }
$datef = ($datef ? $datef : $object->datef); $datef = ($datef ? $datef : $object->datef);
if (GETPOST('datef', 'int', 1)) { if (GETPOST('datef', 'int', 1)) {
$datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser');
} }
if (empty($datef) && !empty($datep)) { if (empty($datef) && !empty($datep)) {
if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
@ -1024,16 +1042,16 @@ if ($action == 'create') {
print '<span id="dateend"'.(GETPOST("actioncode", 'aZ09') == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>'; print '<span id="dateend"'.(GETPOST("actioncode", 'aZ09') == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>';
print '</td><td>'; print '</td><td>';
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo"
} else { } else {
print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel');
} }
print ' <span class="hideonsmartphone">&nbsp; &nbsp; - &nbsp; &nbsp;</span> '; print ' <span class="hideonsmartphone">&nbsp; &nbsp; - &nbsp; &nbsp;</span> ';
//print ' - '; //print ' - ';
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
} else { } else {
print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
} }
print '</td></tr>'; print '</td></tr>';
@ -1518,20 +1536,21 @@ if ($id > 0) {
// Date start - end // Date start - end
print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").'</span></td><td colspan="3">'; print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").'</span></td><td colspan="3">';
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
} elseif (GETPOST("afaire") == 2) { } elseif (GETPOST("afaire") == 2) {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
} else { } else {
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
} }
print ' - '; print ' - ';
if (GETPOST("afaire") == 1) { if (GETPOST("afaire") == 1) {
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuser'); print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
} elseif (GETPOST("afaire") == 2) { } elseif (GETPOST("afaire") == 2) {
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuser'); print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
} else { } else {
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuser'); print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
} }
print '</td></tr>'; print '</td></tr>';
@ -1972,7 +1991,8 @@ if ($id > 0) {
if (empty($object->fulldayevent)) { if (empty($object->fulldayevent)) {
print dol_print_date($object->datep, 'dayhour', 'tzuser'); print dol_print_date($object->datep, 'dayhour', 'tzuser');
} else { } else {
print dol_print_date($object->datep, 'day', 'tzuser'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
} }
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) { if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));
@ -1985,7 +2005,8 @@ if ($id > 0) {
if (empty($object->fulldayevent)) { if (empty($object->fulldayevent)) {
print dol_print_date($object->datef, 'dayhour', 'tzuser'); print dol_print_date($object->datef, 'dayhour', 'tzuser');
} else { } else {
print dol_print_date($object->datef, 'day', 'tzuser'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
} }
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) { if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));

View File

@ -1669,7 +1669,7 @@ class ActionComm extends CommonObject
global $action; global $action;
$hookmanager->initHooks(array('actiondao')); $hookmanager->initHooks(array('actiondao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;
@ -1955,14 +1955,14 @@ class ActionComm extends CommonObject
$event = array(); $event = array();
$event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; $event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"];
$event['type'] = $type; $event['type'] = $type;
$datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
// fix for -> Warning: A non-numeric value encountered // fix for -> Warning: A non-numeric value encountered
if (is_numeric($this->db->jdate($obj->datep2))) { if (is_numeric($this->db->jdate($obj->datep2))) {
$dateend = $this->db->jdate($obj->datep2) $dateend = $this->db->jdate($obj->datep2) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
- (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600));
} else { } else {
// use start date as fall-back to avoid import erros on empty end date // use start date as fall-back to avoid pb with empty end date on ICS readers
$dateend = $datestart; $dateend = $datestart;
} }

View File

@ -201,7 +201,8 @@ if ($object->id > 0) {
if (empty($object->fulldayevent)) { if (empty($object->fulldayevent)) {
print dol_print_date($object->datep, 'dayhour', 'tzuser'); print dol_print_date($object->datep, 'dayhour', 'tzuser');
} else { } else {
print dol_print_date($object->datep, 'day', 'tzuser'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
} }
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) { if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));
@ -214,7 +215,8 @@ if ($object->id > 0) {
if (empty($object->fulldayevent)) { if (empty($object->fulldayevent)) {
print dol_print_date($object->datef, 'dayhour', 'tzuser'); print dol_print_date($object->datef, 'dayhour', 'tzuser');
} else { } else {
print dol_print_date($object->datef, 'day', 'tzuser'); $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
} }
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) { if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));

View File

@ -545,7 +545,8 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction
$newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode); $newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode);
//$param='month='.$monthshown.'&year='.$year; //$param='month='.$monthshown.'&year='.$year;
$hourminsec = '100000'; $hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
} }
@ -808,11 +809,21 @@ if ($resql) {
$event->id = $obj->id; $event->id = $obj->id;
$event->ref = $event->id; $event->ref = $event->id;
$event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin $event->fulldayevent = $obj->fulldayevent;
$event->datef = $db->jdate($obj->datep2);
// event->datep and event->datef must be GMT date.
if ($event->fulldayevent) {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
$event->datep = $db->jdate($obj->datep, $tzforfullday ? 'tzuser' : 'tzserver'); // If saved in $tzforfullday = gmt, we must invert date to be in user tz
$event->datef = $db->jdate($obj->datep2, $tzforfullday ? 'tzuser' : 'tzserver');
} else {
// Example: $obj->datep = '1970-01-01 01:00:00', jdate will return 0 if TZ of PHP server is Europe/Berlin (+1)
$event->datep = $db->jdate($obj->datep, 'tzserver');
$event->datef = $db->jdate($obj->datep2, 'tzserver');
}
//$event->datep_formated_gmt = dol_print_date($event->datep, 'dayhour', 'gmt'); //$event->datep_formated_gmt = dol_print_date($event->datep, 'dayhour', 'gmt');
//var_dump($obj->datep); //var_dump($obj->id.' '.$obj->datep.' '.dol_print_date($obj->datep, 'dayhour', 'gmt'));
//var_dump($event->datep); //var_dump($obj->id.' '.$event->datep.' '.dol_print_date($event->datep, 'dayhour', 'gmt'));
$event->type_code = $obj->type_code; $event->type_code = $obj->type_code;
$event->type_label = $obj->type_label; $event->type_label = $obj->type_label;
@ -829,7 +840,6 @@ if ($resql) {
$event->fetch_userassigned(); // This load $event->userassigned $event->fetch_userassigned(); // This load $event->userassigned
$event->priority = $obj->priority; $event->priority = $obj->priority;
$event->fulldayevent = $obj->fulldayevent;
$event->location = $obj->location; $event->location = $obj->location;
$event->transparency = $obj->transparency; $event->transparency = $obj->transparency;
$event->fk_element = $obj->fk_element; $event->fk_element = $obj->fk_element;
@ -865,25 +875,43 @@ if ($resql) {
$annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); $annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
$mois = dol_print_date($daycursor, '%m', 'tzuserrel'); $mois = dol_print_date($daycursor, '%m', 'tzuserrel');
$jour = dol_print_date($daycursor, '%d', 'tzuserrel'); $jour = dol_print_date($daycursor, '%d', 'tzuserrel');
$daycursorend = $event->date_end_in_calendar;
$anneeend = dol_print_date($daycursorend, '%Y', 'tzuserrel');
$moisend = dol_print_date($daycursorend, '%m', 'tzuserrel');
$jourend = dol_print_date($daycursorend, '%d', 'tzuserrel');
//var_dump(dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt')); // Hour at greenwich //var_dump(dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt')); // Hour at greenwich
//var_dump($annee.'-'.$mois.'-'.$jour); //var_dump($annee.'-'.$mois.'-'.$jour);
//print 'annee='.$annee.' mois='.$mois.' jour='.$jour.'<br>';
// Loop on each day covered by action to prepare an index to show on calendar // Loop on each day covered by action to prepare an index to show on calendar
$loop = true; $j = 0; $loop = true; $j = 0;
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); // $mois, $jour, $annee has been set for user tz
$daykeyend = dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend, 'gmt'); // $moisend, $jourend, $anneeend has been set for user tz
/*
print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'<br>';
print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'<br>';
print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'<br>';
print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'<br>';
print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'<br>';
print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'<br>';
*/
do { do {
//if ($event->id==408) //if ($event->id==408)
//print 'daykey='.$daykey.' '.dol_print_date($daykey, 'dayhour', 'gmt').' '.$event->datep.' '.$event->datef.'<br>'; //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'gmt').' - '.dol_print_date($event->datep, 'dayhour', 'gmt').' '.dol_print_date($event->datef, 'dayhour', 'gmt').'<br>';
//print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'tzuserrel').' - '.dol_print_date($event->datep, 'dayhour', 'tzuserrel').' '.dol_print_date($event->datef, 'dayhour', 'tzuserrel').'<br>';
$eventarray[$daykey][] = $event; $eventarray[$daykey][] = $event;
$j++; $j++;
$daykey += 60 * 60 * 24; $daykey += 60 * 60 * 24;
if ($daykey > $event->date_end_in_calendar) { //if ($daykey > $event->date_end_in_calendar) {
if ($daykey > $daykeyend) {
$loop = false; $loop = false;
} }
} while ($loop); } while ($loop);
//var_dump($eventarray);
//print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
//print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>'; //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array<br>';
} }
@ -1805,12 +1833,16 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$cssclass .= " unmovable"; $cssclass .= " unmovable";
} elseif ($event->type_code == 'ICALEVENT') { } elseif ($event->type_code == 'ICALEVENT') {
$cssclass .= " unmovable"; $cssclass .= " unmovable";
} elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { } elseif ($event->date_start_in_calendar && $event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) {
$tmpyearend = date('Y', $event->date_end_in_calendar); // If the event is on several days
$tmpmonthend = date('m', $event->date_end_in_calendar); $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel');
$tmpdayend = date('d', $event->date_end_in_calendar); $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel');
$tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel');
//var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend);
if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) { if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) {
$cssclass .= " unmovable"; $cssclass .= " unmovable unmovable-mustusefirstdaytodrag";
} else {
$cssclass .= ' movable cursormove';
} }
} else { } else {
if ($user->rights->agenda->allactions->create || if ($user->rights->agenda->allactions->create ||

View File

@ -693,7 +693,7 @@ $tmpforcreatebutton = dol_getdate(dol_now(), true);
$newparam = '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; $newparam = '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
//$param='month='.$monthshown.'&year='.$year; //$param='month='.$monthshown.'&year='.$year;
$hourminsec = '100000'; $hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
$url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
$url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
@ -953,7 +953,12 @@ while ($i < min($num, $limit)) {
// Start date // Start date
if (!empty($arrayfields['a.datep']['checked'])) { if (!empty($arrayfields['a.datep']['checked'])) {
print '<td class="center nowraponall">'; print '<td class="center nowraponall">';
if (empty($obj->fulldayevent)) {
print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser');
} else {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuser'));
}
$late = 0; $late = 0;
if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) { if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) {
$late = 1; $late = 1;
@ -967,7 +972,12 @@ while ($i < min($num, $limit)) {
// End date // End date
if (!empty($arrayfields['a.datep2']['checked'])) { if (!empty($arrayfields['a.datep2']['checked'])) {
print '<td class="center nowraponall">'; print '<td class="center nowraponall">';
if (empty($obj->fulldayevent)) {
print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser'); print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser');
} else {
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuser'));
}
print '</td>'; print '</td>';
} }

View File

@ -740,7 +740,7 @@ class Mailing extends CommonObject
global $action; global $action;
$hookmanager->initHooks(array('emailingdao')); $hookmanager->initHooks(array('emailingdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -2543,7 +2543,7 @@ if ($action == 'create') {
if (($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) if (($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
|| ($object->statut == Propal::STATUS_DRAFT && !empty($conf->global->PROPAL_ENABLE_NEGATIVE) && count($object->lines) > 0)) { || ($object->statut == Propal::STATUS_DRAFT && !empty($conf->global->PROPAL_ENABLE_NEGATIVE) && count($object->lines) > 0)) {
if ($usercanvalidate) { if ($usercanvalidate) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate&token='.newToken().'">'.$langs->trans('Validate').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>'; print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>';
} }
@ -2555,7 +2555,7 @@ if ($action == 'create') {
}*/ }*/
// Edit // Edit
if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) { if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif&token='.newToken().'">'.$langs->trans('Modify').'</a>';
} }
// ReOpen // ReOpen
@ -2578,7 +2578,7 @@ if ($action == 'create') {
// Create a sale order // Create a sale order
if (!empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { if (!empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($usercancreateorder) { if ($usercancreateorder) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a>';
} }
} }
@ -2586,7 +2586,7 @@ if ($action == 'create') {
if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) { if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) {
if ($object->statut == Propal::STATUS_SIGNED && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled))) { if ($object->statut == Propal::STATUS_SIGNED && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled))) {
if ($usercancreatepurchaseorder) { if ($usercancreatepurchaseorder) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddPurchaseOrder").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddPurchaseOrder").'</a>';
} }
} }
} }
@ -2595,7 +2595,7 @@ if ($action == 'create') {
if (!empty($conf->service->enabled) && !empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { if (!empty($conf->service->enabled) && !empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($usercancreateintervention) { if ($usercancreateintervention) {
$langs->load("interventions"); $langs->load("interventions");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddIntervention").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddIntervention").'</a>';
} }
} }
@ -2604,14 +2604,14 @@ if ($action == 'create') {
$langs->load("contracts"); $langs->load("contracts");
if ($usercancreatecontract) { if ($usercancreatecontract) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>';
} }
} }
// Create an invoice and classify billed // Create an invoice and classify billed
if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPOSAL_ARE_NOT_BILLABLE)) { if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPOSAL_ARE_NOT_BILLABLE)) {
if (!empty($conf->facture->enabled) && $usercancreateinvoice) { if (!empty($conf->facture->enabled) && $usercancreateinvoice) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
} }
$arrayofinvoiceforpropal = $object->getInvoiceArrayList(); $arrayofinvoiceforpropal = $object->getInvoiceArrayList();

View File

@ -1248,7 +1248,7 @@ class Propal extends CommonObject
break; break;
} }
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $line->product_type == 9) { if ($result > 0) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }
@ -3569,7 +3569,7 @@ class Propal extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1) public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1)
{ {
global $langs, $conf, $user; global $langs, $conf, $user, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips $notooltip = 1; // Force disable tooltips
@ -3690,6 +3690,15 @@ class Propal extends CommonObject
} }
} }
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -1486,8 +1486,11 @@ if ($resql) {
) { ) {
$with_margin_info = true; $with_margin_info = true;
} }
$total_ht = 0;
$total_margin = 0;
while ($i < min($num, $limit)) { $last_num = min($num, $limit);
while ($i < $last_num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$objectstatic->id = $obj->rowid; $objectstatic->id = $obj->rowid;
@ -1541,6 +1544,8 @@ if ($resql) {
if ($with_margin_info === true) { if ($with_margin_info === true) {
$objectstatic->fetch_lines(); $objectstatic->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($objectstatic); $marginInfo = $formmargin->getMarginInfosArray($objectstatic);
$total_ht += $obj->total_ht;
$total_margin += $marginInfo['total_margin'];
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -1959,7 +1964,7 @@ if ($resql) {
if (!$i) { if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
} }
$totalarray['val']['total_margin'] += $marginInfo['total_margin']; $totalarray['val']['total_margin'] = $total_margin;
} }
// Total margin rate // Total margin rate
if (!empty($arrayfields['total_margin_rate']['checked'])) { if (!empty($arrayfields['total_margin_rate']['checked'])) {
@ -1974,6 +1979,16 @@ if ($resql) {
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
}
if ($i >= $last_num - 1) {
if (!empty($total_ht)) {
$totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
} else {
$totalarray['val']['total_mark_rate'] = '';
}
}
} }
// Extra fields // Extra fields

View File

@ -421,7 +421,7 @@ if (empty($reshook)) {
} }
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) { if ($result > 0) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }

View File

@ -11,7 +11,7 @@
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2021-2022 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1056,7 +1056,7 @@ class Commande extends CommonOrder
return -1; return -1;
} }
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $line->product_type == 9) { if ($result > 0) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }
@ -3663,7 +3663,7 @@ class Commande extends CommonOrder
*/ */
public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0) public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0)
{ {
global $conf, $langs, $user; global $conf, $langs, $user, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips $notooltip = 1; // Force disable tooltips
@ -3764,6 +3764,15 @@ class Commande extends CommonOrder
} }
} }
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -1463,8 +1463,11 @@ if ($resql) {
) { ) {
$with_margin_info = true; $with_margin_info = true;
} }
$total_ht = 0;
$total_margin = 0;
while ($i < min($num, $limit)) { $last_num = min($num, $limit);
while ($i < $last_num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$notshippable = 0; $notshippable = 0;
@ -1510,6 +1513,8 @@ if ($resql) {
if ($with_margin_info === true) { if ($with_margin_info === true) {
$generic_commande->fetch_lines(); $generic_commande->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($generic_commande); $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
$total_ht += $obj->total_ht;
$total_margin += $marginInfo['total_margin'];
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -1879,6 +1884,16 @@ if ($resql) {
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
}
if ($i >= $last_num - 1) {
if (!empty($total_ht)) {
$totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
} else {
$totalarray['val']['total_mark_rate'] = '';
}
}
} }
// Extra fields // Extra fields

View File

@ -377,7 +377,7 @@ if ($action == 'create') {
// Type // Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td>'; print '<td>';
$formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST('type', 'alpha') : Account::TYPE_CURRENT, 'type'); $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT, 'type');
print '</td></tr>'; print '</td></tr>';
// Currency // Currency
@ -490,7 +490,7 @@ if ($action == 'create') {
print '</table>'; print '</table>';
print '<br>'; print '<br>';
$type = GETPOST('type'); $type = (GETPOSTISSET("type") ? GETPOST('type', 'int') : Account::TYPE_CURRENT); // add default value
if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) { if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
print '<table class="border centpercent">'; print '<table class="border centpercent">';
@ -870,7 +870,7 @@ if ($action == 'create') {
// Type // Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td class="maxwidth200onsmartphone">'; print '<td class="maxwidth200onsmartphone">';
$formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOST('type', 'alpha') : $object->type), 'type'); $formbank->selectTypeOfBankAccount((GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type), 'type');
print '</td></tr>'; print '</td></tr>';
// Currency // Currency
@ -1015,7 +1015,8 @@ if ($action == 'create') {
print '</table>'; print '</table>';
if (GETPOST("type") == Account::TYPE_SAVINGS || GETPOST("type") == Account::TYPE_CURRENT) { $type = (GETPOSTISSET('type') ? GETPOST('type', 'int') : $object->type); // add default current value
if ($type == Account::TYPE_SAVINGS || $type == Account::TYPE_CURRENT) {
print '<br>'; print '<br>';
//print '<div class="underbanner clearboth"></div>'; //print '<div class="underbanner clearboth"></div>';

View File

@ -1511,10 +1511,10 @@ class Account extends CommonObject
{ {
$country_code = $this->getCountryCode(); $country_code = $this->getCountryCode();
if (in_array($country_code, array('AD', 'FR', 'ES', 'GA', 'IT', 'NC'))) { if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC'))) {
return 1; // France, Spain, Gabon, ... - Not valid for CH return 1; // France, Spain, Gabon, ... - Not valid for CH
} }
if (in_array($country_code, array('AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) { if (in_array($country_code, array('AD', 'AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) {
return 2; // Australia, England... return 2; // Australia, England...
} }
return 0; return 0;

View File

@ -721,7 +721,7 @@ class PaymentVarious extends CommonObject
global $action; global $action;
$hookmanager->initHooks(array('variouspayment')); $hookmanager->initHooks(array('variouspayment'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -466,7 +466,7 @@ class CashControl extends CommonObject
global $action; global $action;
$hookmanager->initHooks(array('cashfencedao')); $hookmanager->initHooks(array('cashfencedao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -1270,7 +1270,7 @@ if (empty($reshook)) {
$object->lines[] = $line; // insert new line in current object $object->lines[] = $line; // insert new line in current object
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $line->product_type == 9) { if ($result > 0) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }
@ -1781,7 +1781,7 @@ if (empty($reshook)) {
} }
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) { if ($result > 0) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }

View File

@ -1388,7 +1388,7 @@ class FactureRec extends CommonInvoice
*/ */
public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1)
{ {
global $langs; global $langs, $hookmanager;
$result = ''; $result = '';
@ -1440,7 +1440,15 @@ class FactureRec extends CommonInvoice
$result .= $this->ref; $result .= $this->ref;
} }
$result .= $linkend; $result .= $linkend;
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -788,6 +788,9 @@ class Facture extends CommonInvoice
dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects");
foreach ($this->lines as $i => $val) { foreach ($this->lines as $i => $val) {
$newinvoiceline = $this->lines[$i]; $newinvoiceline = $this->lines[$i];
$newinvoiceline->context = $this->context;
$newinvoiceline->fk_facture = $this->id; $newinvoiceline->fk_facture = $this->id;
$newinvoiceline->origin = $this->lines[$i]->element; $newinvoiceline->origin = $this->lines[$i]->element;
@ -820,7 +823,7 @@ class Facture extends CommonInvoice
$result = $newinvoiceline->insert(); $result = $newinvoiceline->insert();
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $newinvoiceline->product_type == 9) { if ($result > 0) {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }
@ -1569,7 +1572,7 @@ class Facture extends CommonInvoice
global $action, $hookmanager; global $action, $hookmanager;
$hookmanager->initHooks(array('invoicedao')); $hookmanager->initHooks(array('invoicedao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result, 'notooltip' => $notooltip, 'addlinktonotes' => $addlinktonotes, 'save_lastsearch_value'=> $save_lastsearch_value, 'target' => $target); $parameters = array('id'=>$this->id, 'getnomurl' => &$result, 'notooltip' => $notooltip, 'addlinktonotes' => $addlinktonotes, 'save_lastsearch_value'=> $save_lastsearch_value, 'target' => $target);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -1651,8 +1651,11 @@ if ($resql) {
) { ) {
$with_margin_info = true; $with_margin_info = true;
} }
$total_ht = 0;
$total_margin = 0;
while ($i < min($num, $limit)) { $last_num = min($num, $limit);
while ($i < $last_num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$datelimit = $db->jdate($obj->datelimite); $datelimit = $db->jdate($obj->datelimite);
@ -1740,6 +1743,8 @@ if ($resql) {
if ($with_margin_info === true) { if ($with_margin_info === true) {
$facturestatic->fetch_lines(); $facturestatic->fetch_lines();
$marginInfo = $formmargin->getMarginInfosArray($facturestatic); $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
$total_ht += $obj->total_ht;
$total_margin += $marginInfo['total_margin'];
} }
print '<tr class="oddeven"'; print '<tr class="oddeven"';
@ -2231,6 +2236,16 @@ if ($resql) {
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
}
if ($i >= $last_num - 1) {
if (!empty($total_ht)) {
$totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
} else {
$totalarray['val']['total_mark_rate'] = '';
}
}
} }
// Extra fields // Extra fields

View File

@ -613,7 +613,7 @@ class Paiement extends CommonObject
// Insert payment into llx_bank // Insert payment into llx_bank
$bank_line_id = $acc->addline( $bank_line_id = $acc->addline(
$this->datepaye, $this->datepaye,
$this->paiementid, // Payment mode id or code ("CHQ or VIR for example") $this->paiementcode ? $this->paiementcode : $this->paiementid, // Payment mode code ('CB', 'CHQ' or 'VIR' for example). Use payment id if not defined for backward compatibility.
$label, $label,
$totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note) $totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note)
$this->num_payment, $this->num_payment,
@ -1151,7 +1151,7 @@ class Paiement extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0, $morecss = '') public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0, $morecss = '')
{ {
global $conf, $langs; global $conf, $langs, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips $notooltip = 1; // Force disable tooltips
@ -1209,7 +1209,15 @@ class Paiement extends CommonObject
$result .= ($this->ref ? $this->ref : $this->id); $result .= ($this->ref ? $this->ref : $this->id);
} }
$result .= $linkend; $result .= $linkend;
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -192,6 +192,7 @@ $limit = 5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.type = 'bank-transfer'"; $sql .= " WHERE p.type = 'bank-transfer'";
$sql .= " AND p.entity IN (".getEntity('invoice').")";
$sql .= " ORDER BY datec DESC"; $sql .= " ORDER BY datec DESC";
$sql .= $db->plimit($limit); $sql .= $db->plimit($limit);

View File

@ -238,7 +238,14 @@ if ($id > 0 || $ref) {
$modulepart = 'paymentbybanktransfer'; $modulepart = 'paymentbybanktransfer';
} }
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>'; print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>'; print '</td></tr>';
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>';
print '</div>'; print '</div>';

View File

@ -1260,7 +1260,7 @@ class BonPrelevement extends CommonObject
global $action, $hookmanager; global $action, $hookmanager;
$hookmanager->initHooks(array('banktransferdao')); $hookmanager->initHooks(array('banktransferdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -262,12 +262,20 @@ if ($id) {
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
if ($type == 'bank-transfer') {
$sql .= " , ".MAIN_DB_PREFIX."facture_fourn as f";
} else {
$sql .= " , ".MAIN_DB_PREFIX."facture as f"; $sql .= " , ".MAIN_DB_PREFIX."facture as f";
}
$sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid"; $sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.fk_soc = s.rowid";
if ($type == 'bank-transfer') {
$sql .= " AND pf.fk_facture_fourn = f.rowid";
} else {
$sql .= " AND pf.fk_facture = f.rowid"; $sql .= " AND pf.fk_facture = f.rowid";
}
$sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND pl.rowid = ".((int) $id); $sql .= " AND pl.rowid = ".((int) $id);
if ($socid) { if ($socid) {

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2016-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
@ -560,7 +560,7 @@ class ChargeSociales extends CommonObject
*/ */
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $short = 0, $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $short = 0, $save_lastsearch_value = -1)
{ {
global $langs, $conf, $user, $form; global $langs, $conf, $user, $form, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) { if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips $notooltip = 1; // Force disable tooltips
@ -625,7 +625,15 @@ class ChargeSociales extends CommonObject
$result .= $this->ref; $result .= $this->ref;
} }
$result .= $linkend; $result .= $linkend;
global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -455,7 +455,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$_SERVER["PHP_SELF"], $_SERVER["PHP_SELF"],
"amount", "amount",
"", "",
$classslink, $paramslink,
'class="right"', 'class="right"',
$sortfield, $sortfield,
$sortorder $sortorder

View File

@ -321,6 +321,15 @@ $dolibarr_cron_allow_cli='0';
// //
// $php_session_save_handler=''; // $php_session_save_handler='';
// force_install_lockinstall
// If this value is set to a value, it forces the creation of a file install.lock once an upgrade process into a new version end.
// The value is the octal value of permission to set on created file.
// The file install.lock prevents the use of the migration process another time. You will have to delete it manually for
// next upgrade.
// Default value: '0'
// Example: '444';
// $force_install_lockinstall='440';
//################## //##################

View File

@ -1488,7 +1488,7 @@ class Contact extends CommonObject
global $action; global $action;
$hookmanager->initHooks(array('contactdao')); $hookmanager->initHooks(array('contactdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;

View File

@ -2042,7 +2042,7 @@ class Contrat extends CommonObject
global $action; global $action;
$hookmanager->initHooks(array('contractdao')); $hookmanager->initHooks(array('contractdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) { if ($reshook > 0) {
$result = $hookmanager->resPrint; $result = $hookmanager->resPrint;
@ -2608,7 +2608,6 @@ class ContratLigne extends CommonObjectLine
*/ */
public $table_element = 'contratdet'; public $table_element = 'contratdet';
/** /**
* @var string Name to use for 'features' parameter to check module permissions with restrictedArea() * @var string Name to use for 'features' parameter to check module permissions with restrictedArea()
*/ */

View File

@ -244,6 +244,7 @@ class box_members_by_type extends ModeleBoxes
); );
} else { } else {
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'tr' => 'class="liste_total"',
'td' => 'class="liste_total"', 'td' => 'class="liste_total"',
'text' => $langs->trans("Total") 'text' => $langs->trans("Total")
); );

View File

@ -142,7 +142,7 @@ class box_members_last_subscriptions extends ModeleBoxes
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $staticmember->getNomUrl(-1, 32, 'subscription'), 'text' => $staticmember->getNomUrl(-1, 32, 'card'),
'asis' => 1, 'asis' => 1,
); );

View File

@ -196,6 +196,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes
); );
} else { } else {
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'tr' => 'class="liste_total"',
'td' => 'class="liste_total"', 'td' => 'class="liste_total"',
'text' => $langs->trans("Total"), 'text' => $langs->trans("Total"),
); );

View File

@ -5310,8 +5310,7 @@ abstract class CommonObject
$sav_charset_output = $outputlangs->charset_output; $sav_charset_output = $outputlangs->charset_output;
if (in_array(get_class($this), array('Adherent'))) { if (in_array(get_class($this), array('Adherent'))) {
$arrayofrecords = array(); // The write_file of templates of adherent class need this var $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards', $moreparams);
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
} else { } else {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
} }

View File

@ -45,6 +45,11 @@ abstract class CommonObjectLine extends CommonObject
*/ */
public $rowid; public $rowid;
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
public $picto = 'line';
/** /**
* Product/service unit code ('km', 'm', 'p', ...) * Product/service unit code ('km', 'm', 'p', ...)
* @var string * @var string

View File

@ -167,7 +167,7 @@ class Events // extends CommonObject
$sql .= " '".$this->db->escape(getUserRemoteIP())."',"; $sql .= " '".$this->db->escape(getUserRemoteIP())."',";
$sql .= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; $sql .= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').",";
$sql .= " '".$this->db->idate($this->dateevent)."',"; $sql .= " '".$this->db->idate($this->dateevent)."',";
$sql .= " ".($user->id ? "'".$this->db->escape($user->id)."'" : 'NULL').","; $sql .= " ".($user->id > 0 ? ((int) $user->id) : 'NULL').",";
$sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; $sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."',";
$sql .= " '".$this->db->escape(dol_getprefix())."'"; $sql .= " '".$this->db->escape(dol_getprefix())."'";
$sql .= ")"; $sql .= ")";

View File

@ -1558,7 +1558,7 @@ class ExtraFields
} elseif ($type == 'price') { } elseif ($type == 'price') {
//$value = price($value, 0, $langs, 0, 0, -1, $conf->currency); //$value = price($value, 0, $langs, 0, 0, -1, $conf->currency);
if ($value || $value == '0') { if ($value || $value == '0') {
$value = price($value, 0, $langs, 0, 0, -1); $value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).' '.$langs->getCurrencySymbol($conf->currency);
} }
} elseif ($type == 'select') { } elseif ($type == 'select') {
$valstr = (!empty($param['options'][$value]) ? $param['options'][$value] : ''); $valstr = (!empty($param['options'][$value]) ? $param['options'][$value] : '');

View File

@ -1106,13 +1106,13 @@ class Form
} }
print '<option value="0"'; print '<option value="0"';
if (0 == $selected) { if (0 == $selected || ($selected == -1 && getDolGlobalString('MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') == 'product')) {
print ' selected'; print ' selected';
} }
print '>'.$langs->trans("Product"); print '>'.$langs->trans("Product");
print '<option value="1"'; print '<option value="1"';
if (1 == $selected) { if (1 == $selected || ($selected == -1 && getDolGlobalString('MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') == 'service')) {
print ' selected'; print ' selected';
} }
print '>'.$langs->trans("Service"); print '>'.$langs->trans("Service");
@ -2219,9 +2219,10 @@ class Form
* 'warehouseinternal' = count products from warehouses for internal correct/transfer only * 'warehouseinternal' = count products from warehouses for internal correct/transfer only
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
* @param string $nooutput No print, return the output into a string * @param string $nooutput No print, return the output into a string
* @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase
* @return void|string * @return void|string
*/ */
public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0) public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1)
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;
@ -2261,7 +2262,7 @@ class Form
} }
} }
// mode=1 means customers products // mode=1 means customers products
$urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; $urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&status_purchase='.$status_purchase.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus;
//Price by customer //Price by customer
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
$urloption .= '&socid='.$socid; $urloption .= '&socid='.$socid;
@ -2357,7 +2358,7 @@ class Form
$out .= img_picto($langs->trans("Search"), 'search'); $out .= img_picto($langs->trans("Search"), 'search');
} }
} else { } else {
$out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus); $out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase);
} }
if (empty($nooutput)) { if (empty($nooutput)) {
@ -2453,9 +2454,10 @@ class Form
* 'warehouseopen' = count products from open warehouses, * 'warehouseopen' = count products from open warehouses,
* 'warehouseclosed' = count products from closed warehouses, * 'warehouseclosed' = count products from closed warehouses,
* 'warehouseinternal' = count products from warehouses for internal correct/transfer only * 'warehouseinternal' = count products from warehouses for internal correct/transfer only
* @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase
* @return array Array of keys for json * @return array Array of keys for json
*/ */
public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1)
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;
@ -2593,6 +2595,9 @@ class Form
} elseif ($status >= 0) { } elseif ($status >= 0) {
$sql .= " AND p.tosell = ".((int) $status); $sql .= " AND p.tosell = ".((int) $status);
} }
if ($status_purchase >= 0) {
$sql .= " AND p.tobuy = ".((int) $status_purchase);
}
// Filter by product type // Filter by product type
if (strval($filtertype) != '') { if (strval($filtertype) != '') {
$sql .= " AND p.fk_product_type = ".((int) $filtertype); $sql .= " AND p.fk_product_type = ".((int) $filtertype);
@ -7379,9 +7384,16 @@ class Form
$objecttmp = null; $objecttmp = null;
// Example of value for $objectdec:
// Bom:bom/class/bom.class.php:0:t.status=1
// Bom:bom/class/bom.class.php:0:t.status=1:ref
// Bom:bom/class/bom.class.php:0:(t.status:=:1):ref
$InfoFieldList = explode(":", $objectdesc, 4); $InfoFieldList = explode(":", $objectdesc, 4);
$vartmp = $InfoFieldList[3]; $vartmp = $InfoFieldList[3];
$InfoFieldList[4] = preg_replace('/^.*:(\w*)$/', '\1', $vartmp); // take the sort field $reg = array();
if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
$InfoFieldList[4] = $reg[1]; // take the sort field
}
$InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field $InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
$classname = $InfoFieldList[0]; $classname = $InfoFieldList[0];
@ -8111,12 +8123,9 @@ class Form
$out .= "\n".'<script>'."\n"; $out .= "\n".'<script>'."\n";
if ($addjscombo == 1) { if ($addjscombo == 1) {
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out .= 'function formatResult(record) {'."\n"; $out .= 'function formatResult(record, container) {'."\n";
if ($elemtype == 'category') { $out .= ' if ($(record.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(record.element).attr("data-html")); // If property html set, we decode html entities and use this'."\n";
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';'; $out .= ' return record.text;';
} else {
$out .= 'return record.text;';
}
$out .= '};'."\n"; $out .= '};'."\n";
$out .= 'function formatSelection(record) {'."\n"; $out .= 'function formatSelection(record) {'."\n";
if ($elemtype == 'category') { if ($elemtype == 'category') {
@ -8126,11 +8135,19 @@ class Form
} }
$out .= '};'."\n"; $out .= '};'."\n";
$out .= '$(document).ready(function () { $out .= '$(document).ready(function () {
$(\'#'.$htmlname.'\').'.$tmpplugin.'({ $(\'#'.$htmlname.'\').'.$tmpplugin.'({';
dir: \'ltr\', if ($placeholder) {
$out .= '
placeholder: {
id: \'-1\',
text: \''.dol_escape_js($placeholder).'\'
},';
}
$out .= ' dir: \'ltr\',
// Specify format function for dropdown item // Specify format function for dropdown item
formatResult: formatResult, formatResult: formatResult,
templateResult: formatResult, /* For 4.0 */ templateResult: formatResult, /* For 4.0 */
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
// Specify format function for selected item // Specify format function for selected item
formatSelection: formatSelection, formatSelection: formatSelection,
templateSelection: formatSelection /* For 4.0 */ templateSelection: formatSelection /* For 4.0 */
@ -9078,13 +9095,13 @@ class Form
if (!empty($object->photo)) { if (!empty($object->photo)) {
if (dolIsAllowedForPreview($object->photo)) { if (dolIsAllowedForPreview($object->photo)) {
if ((string) $imagesize == 'mini') { if ((string) $imagesize == 'mini') {
$file = get_exdir(0, 0, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini'); $file = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.getImageFileNameForSize($object->photo, '_mini');
} elseif ((string) $imagesize == 'small') { } elseif ((string) $imagesize == 'small') {
$file = get_exdir(0, 0, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small'); $file = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.getImageFileNameForSize($object->photo, '_small');
} else { } else {
$file = get_exdir(0, 0, 0, 0, $object, 'user').$object->photo; $file = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo;
} }
$originalfile = get_exdir(0, 0, 0, 0, $object, 'user').$object->photo; $originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo;
} }
} }
if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
@ -9746,8 +9763,8 @@ class Form
$ret .= '<div class="divadvancedsearchfieldcomp inline-block">'; $ret .= '<div class="divadvancedsearchfieldcomp inline-block">';
//$ret .= '<button type="submit" class="liste_titre button_removefilter" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>'; //$ret .= '<button type="submit" class="liste_titre button_removefilter" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
$ret .= '<a href="#" class="dropdownsearch-toggle unsetcolor paddingright">'; $ret .= '<a href="#" class="dropdownsearch-toggle unsetcolor">';
$ret .= '<span class="fas fa-filter linkobject boxfilter" title="'.dol_escape_htmltag($langs->trans("Filters")).'" id="idsubimgproductdistribution"></span>'; $ret .= '<span class="fas fa-filter linkobject boxfilter pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Filters")).'" id="idsubimgproductdistribution"></span>';
//$ret .= $langs->trans("Filters"); //$ret .= $langs->trans("Filters");
$ret .= '</a>'; $ret .= '</a>';

View File

@ -1486,58 +1486,6 @@ class FormOther
{ {
global $langs, $extrafields, $form; global $langs, $extrafields, $form;
$YYYY = substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1);
$MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
$DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
$HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
foreach ($object->fields as $key => $val) {
if (!$val['isameasure']) {
if (in_array($key, array(
'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
continue;
}
if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
continue;
}
if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
continue;
}
if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
continue;
}
if (preg_match('/^pass/', $key)) {
continue;
}
if (in_array($val['type'], array('html', 'text'))) {
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofgroupby['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => $val['position'].'-y');
$arrayofgroupby['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => $val['position'].'-m');
$arrayofgroupby['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => $val['position'].'-d');
} else {
$arrayofgroupby['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']);
}
}
}
// Add extrafields to Group by
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
}
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
continue;
}
$arrayofgroupby['te.'.$key] = array('label' => $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key]);
}
}
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
$arrayofgroupbylabel = array(); $arrayofgroupbylabel = array();
foreach ($arrayofgroupby as $key => $val) { foreach ($arrayofgroupby as $key => $val) {
$arrayofgroupbylabel[$key] = $val['label']; $arrayofgroupbylabel[$key] = $val['label'];
@ -1558,68 +1506,13 @@ class FormOther
*/ */
public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1') public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1')
{ {
global $langs, $extrafields, $form; global $form;
$YYYY = substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1);
$MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
$DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
$HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
foreach ($object->fields as $key => $val) {
if (!$val['measure']) {
if (in_array($key, array(
'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
continue;
}
if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
continue;
}
if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
continue;
}
if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
continue;
}
if (preg_match('/^pass/', $key)) {
continue;
}
if (in_array($val['type'], array('html', 'text'))) {
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofxaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => $val['position'].'-y');
$arrayofxaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => $val['position'].'-m');
$arrayofxaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => $val['position'].'-d');
} else {
$arrayofxaxis['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']);
}
}
}
// Add extrafields to X-Axis
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
}
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
continue;
}
$arrayofxaxis['te.'.$key] = array('label' => $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key]);
}
}
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
$arrayofxaxislabel = array(); $arrayofxaxislabel = array();
foreach ($arrayofxaxis as $key => $val) { foreach ($arrayofxaxis as $key => $val) {
$arrayofxaxislabel[$key] = $val['label']; $arrayofxaxislabel[$key] = $val['label'];
} }
$result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth250', 1); $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth250 maxwidth500', 1);
return $result; return $result;
} }

View File

@ -175,7 +175,7 @@ $HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); $MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); $SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
$arrayofmesures = array('t.count'=>'Count'); $arrayofmesures = array();
$arrayofxaxis = array(); $arrayofxaxis = array();
$arrayofgroupby = array(); $arrayofgroupby = array();
$arrayofyaxis = array(); $arrayofyaxis = array();
@ -411,41 +411,30 @@ print $form->searchComponent(array($object->element => $object->fields), $search
print '</div>'; print '</div>';
// Add measures into array // Add measures into array
$count = 0;
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
//var_dump($arrayofmesures);
print '<div class="divadvancedsearchfield clearboth">'; print '<div class="divadvancedsearchfield clearboth">';
foreach ($object->fields as $key => $val) { print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span></div>';
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) { print $form->multiselectarray('search_measures', $arrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields
$arrayofmesures['t.'.$key.'-sum'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
$arrayofmesures['t.'.$key.'-average'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
$arrayofmesures['t.'.$key.'-min'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
$arrayofmesures['t.'.$key.'-max'] = $langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
}
}
// Add extrafields to Measures
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) {
$arrayofmesures['te.'.$key.'-sum'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
$arrayofmesures['te.'.$key.'-average'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
$arrayofmesures['te.'.$key.'-min'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
$arrayofmesures['te.'.$key.'-max'] = $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
}
}
}
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright" title="'.$langs->trans("Measures").'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span>'.$langs->trans("Measures").'</div> ';
print $form->multiselectarray('search_measures', $arrayofmesures, $search_measures, 0, 0, 'minwidth400', 1); // Fill the array $arrayofmeasures with possible fields
print '</div>'; print '</div>';
// XAxis // XAxis
$count = 0;
$arrayofxaxis = fillArrayOfXAxis($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofxaxis, 0, $count);
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
print '<div class="divadvancedsearchfield">'; print '<div class="divadvancedsearchfield">';
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div> '; print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>';
//var_dump($arrayofxaxis);
print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis")); // Fill the array $arrayofxaxis with possible fields print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis")); // Fill the array $arrayofxaxis with possible fields
print '</div>'; print '</div>';
// Group by // Group by
$count = 0;
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count);
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
print '<div class="divadvancedsearchfield">'; print '<div class="divadvancedsearchfield">';
print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div> '; print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>';
print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields
print '</div>'; print '</div>';
@ -846,3 +835,276 @@ if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
llxFooter(); llxFooter();
$db->close(); $db->close();
/**
* Fill arrayofmesures for an object
*
* @param mixed $object Any object
* @param string $tablealias Alias of table
* @param string $labelofobject Label of object
* @param array $arrayofmesures Array of mesures already filled
* @param int $level Level
* @param int $count Count
* @return array Array of mesures
*/
function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level = 0, &$count = 0)
{
global $langs, $extrafields, $db;
if ($level > 10) { // Protection against infinite loop
return $arrayofmesures;
}
if ($level == 0) {
// Add the count of record only for the main/first level object. Parents are necessarly unique for each record.
$arrayofmesures[$tablealias.'.count'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count';
}
// Add main fields of object
foreach ($object->fields as $key => $val) {
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1))) {
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
$arrayofmesures[$tablealias.'.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
$arrayofmesures[$tablealias.'.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
$arrayofmesures[$tablealias.'.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
}
}
// Add extrafields to Measures
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1))) {
$arrayofmesures[$tablealias.'e.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
$arrayofmesures[$tablealias.'e.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
$arrayofmesures[$tablealias.'e.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
$arrayofmesures[$tablealias.'e.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
}
}
}
// Add fields for parent objects
foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4);
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1];
dol_include_once($tmptype[2]);
if (class_exists($newobject)) {
$tmpobject = new $newobject($db);
/*var_dump($val['label']);
var_dump($tmptype);
var_dump($arrayofmesures);
var_dump('t-'.$key);*/
$count++;
$arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count);
} else {
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n";
}
}
}
}
return $arrayofmesures;
}
/**
* Fill arrayofmesures for an object
*
* @param mixed $object Any object
* @param string $tablealias Alias of table
* @param string $labelofobject Label of object
* @param array $arrayofxaxis Array of xaxis already filled
* @param int $level Level
* @param int $count Count
* @return array Array of xaxis
*/
function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level = 0, &$count = 0)
{
global $langs, $extrafields, $db;
if ($level > 10) { // Protection against infinite loop
return $arrayofxaxis;
}
if ($level >= 2) {
return $arrayofxaxis;
}
$YYYY = substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1);
$MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
$DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
$HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
// Add main fields of object
foreach ($object->fields as $key => $val) {
if (empty($val['measure'])) {
if (in_array($key, array(
'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
continue;
}
if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
continue;
}
if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
continue;
}
if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
continue;
}
if (preg_match('/^pass/', $key)) {
continue;
}
if (in_array($val['type'], array('html', 'text'))) {
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofxaxis[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($val['position']+($count * 100000)).'.1');
$arrayofxaxis[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($val['position']+($count * 100000)).'.2');
$arrayofxaxis[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($val['position']+($count * 100000)).'.3');
} else {
$arrayofxaxis[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)));
}
}
}
// Add extrafields to X-Axis
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
}
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
continue;
}
$arrayofxaxis[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000));
}
}
// Add fields for parent objects
foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4);
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1];
dol_include_once($tmptype[2]);
if (class_exists($newobject)) {
$tmpobject = new $newobject($db);
/*var_dump($val['label']);
var_dump($tmptype);
var_dump($arrayofmesures);
var_dump('t-'.$key);*/
$count++;
$arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count);
} else {
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n";
}
}
}
}
return $arrayofxaxis;
}
/**
* Fill arrayofgrupby for an object
*
* @param mixed $object Any object
* @param string $tablealias Alias of table
* @param string $labelofobject Label of object
* @param array $arrayofgroupby Array of groupby already filled
* @param int $level Level
* @param int $count Count
* @return array Array of groupby
*/
function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level = 0, &$count = 0)
{
global $langs, $extrafields, $db;
if ($level > 10) { // Protection against infinite loop
return $arrayofgroupby;
}
if ($level >= 2) {
return $arrayofgroupby;
}
$YYYY = substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1);
$MM = substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1);
$DD = substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1);
$HH = substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1);
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
// Add main fields of object
foreach ($object->fields as $key => $val) {
if (!$val['isameasure']) {
if (in_array($key, array(
'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
continue;
}
if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) {
continue;
}
if (isset($val['visible']) && !dol_eval($val['visible'], 1)) {
continue;
}
if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) {
continue;
}
if (preg_match('/^pass/', $key)) {
continue;
}
if (in_array($val['type'], array('html', 'text'))) {
continue;
}
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($val['position']+($count * 100000)).'.1');
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($val['position']+($count * 100000)).'.2');
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($val['position']+($count * 100000)).'.3');
} else {
$arrayofgroupby[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)));
}
}
}
// Add extrafields to Group by
if ($object->isextrafieldmanaged) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
}
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
continue;
}
$arrayofgroupby[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000));
}
}
// Add fields for parent objects
foreach ($object->fields as $key => $val) {
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
$tmptype = explode(':', $val['type'], 4);
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
$newobject = $tmptype[1];
dol_include_once($tmptype[2]);
if (class_exists($newobject)) {
$tmpobject = new $newobject($db);
/*var_dump($val['label']);
var_dump($tmptype);
var_dump($arrayofmesures);
var_dump('t-'.$key);*/
$count++;
$arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count);
} else {
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n";
}
}
}
}
return $arrayofgroupby;
}

View File

@ -302,8 +302,8 @@ abstract class DoliDB implements Database
/** /**
* Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
* 19700101020000 -> 3600 with TZ+1 and gmt=0 * 19700101020000 -> 3600 with server TZ = +1 and $gm='tzserver'
* 19700101020000 -> 7200 whaterver is TZ if gmt=1 * 19700101020000 -> 7200 whaterver is server TZ if $gm='gmt'
* *
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @param mixed $gm 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ * @param mixed $gm 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ

View File

@ -26,6 +26,7 @@
$(document).ready(function () { $(document).ready(function () {
var timezone = jstz.determine(); var timezone = jstz.determine();
console.log("Timezone detected for user: "+timezone.name());
// Detect and save TZ and DST // Detect and save TZ and DST
var rightNow = new Date(); var rightNow = new Date();

View File

@ -1627,6 +1627,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu
if (empty($strictw3c)) { if (empty($strictw3c)) {
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page_y" value="'.newToken().'">';
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -1733,7 +1734,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu
// Submit // Submit
if (empty($strictw3c)) { if (empty($strictw3c)) {
print '<td class="center">'; print '<td class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">'; print '<input type="submit" class="button small reposition" value="'.$langs->trans("Update").'" name="update">';
print "</td>"; print "</td>";
} }
@ -1748,7 +1749,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu
print '</div>'; print '</div>';
if (!empty($strictw3c) && $strictw3c == 1) { if (!empty($strictw3c) && $strictw3c == 1) {
print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>'; print '<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans("Update").'" name="update"></div>';
print "</form>\n"; print "</form>\n";
} }
} }

View File

@ -364,8 +364,8 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $exclu
* YYYY-MM-DDTHH:MM:SSZ (RFC3339) * YYYY-MM-DDTHH:MM:SSZ (RFC3339)
* DD/MM/YY or DD/MM/YYYY (deprecated) * DD/MM/YY or DD/MM/YYYY (deprecated)
* DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (deprecated) * DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (deprecated)
* @param int $gm 1 =Input date is GM date, * @param int|string $gm 'gmt' or 1 =Input date is GM date,
* 0 =Input date is local date using PHP server timezone * 'tzserver' or 0 =Input date is date using PHP server timezone
* @return int Date as a timestamp * @return int Date as a timestamp
* 19700101020000 -> 7200 with gm=1 * 19700101020000 -> 7200 with gm=1
* 19700101000000 -> 0 with gm=1 * 19700101000000 -> 0 with gm=1
@ -408,7 +408,14 @@ function dol_stringtotime($string, $gm = 1)
$string = preg_replace('/([^0-9])/i', '', $string); $string = preg_replace('/([^0-9])/i', '', $string);
$tmp = $string.'000000'; $tmp = $string.'000000';
$date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm ? 1 : 0)); // Clean $gm
if ($gm === 1) {
$gm = 'gmt';
} elseif (empty($gm) || $gm === 'tzserver') {
$gm = 'tzserver';
}
$date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), $gm);
return $date; return $date;
} }

View File

@ -2348,15 +2348,15 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
$original_file = $dolibarr_main_data_root.'/'.$original_file; $original_file = $dolibarr_main_data_root.'/'.$original_file;
} elseif ($modulepart == 'doctemplates' && !empty($dolibarr_main_data_root)) { } elseif ($modulepart == 'doctemplates' && !empty($dolibarr_main_data_root)) {
// Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log // Wrapping for doctemplates
$accessallowed = $user->admin; $accessallowed = $user->admin;
$original_file = $dolibarr_main_data_root.'/doctemplates/'.$original_file; $original_file = $dolibarr_main_data_root.'/doctemplates/'.$original_file;
} elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { } elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) {
// Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip // Wrapping for doctemplates of websites
$accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); $accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file)));
$original_file = $dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; $original_file = $dolibarr_main_data_root.'/doctemplates/websites/'.$original_file;
} elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { } elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) {
// Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip // Wrapping for *.zip package files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip
// Dir for custom dirs // Dir for custom dirs
$tmp = explode(',', $dolibarr_main_document_root_alt); $tmp = explode(',', $dolibarr_main_document_root_alt);
$dirins = $tmp[0]; $dirins = $tmp[0];
@ -2369,11 +2369,17 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file = $conf->mycompany->dir_output.'/'.$original_file; $original_file = $conf->mycompany->dir_output.'/'.$original_file;
} elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) { } elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) {
// Wrapping for users photos // Wrapping for users photos
$accessallowed = 0;
if (preg_match('/^\d+\/photos\//', $original_file)) {
$accessallowed = 1; $accessallowed = 1;
}
$original_file = $conf->user->dir_output.'/'.$original_file; $original_file = $conf->user->dir_output.'/'.$original_file;
} elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output)) { } elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output)) {
// Wrapping for members photos // Wrapping for members photos
$accessallowed = 0;
if (preg_match('/^\d+\/photos\//', $original_file)) {
$accessallowed = 1; $accessallowed = 1;
}
$original_file = $conf->adherent->dir_output.'/'.$original_file; $original_file = $conf->adherent->dir_output.'/'.$original_file;
} elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity])) { } elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity])) {
// Wrapping pour les apercu factures // Wrapping pour les apercu factures
@ -2448,7 +2454,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} }
$original_file = $conf->expensereport->dir_output.'/'.$original_file; $original_file = $conf->expensereport->dir_output.'/'.$original_file;
} elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) { } elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) {
// Wrapping pour les apercu supplier invoice // Wrapping pour les apercu expense report
if ($fuser->rights->expensereport->{$lire}) { if ($fuser->rights->expensereport->{$lire}) {
$accessallowed = 1; $accessallowed = 1;
} }

View File

@ -665,16 +665,16 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
} }
// Sanitizing for special parameters. // Sanitizing for special parameters.
// Note: There is no reason to allow the backtopage, backtolist or backtourl parameter to contains an external URL. // Note: There is no reason to allow the backtopage, backtolist or backtourl parameter to contains an external URL. Only relative URLs are allowed.
if ($paramname == 'backtopage' || $paramname == 'backtolist' || $paramname == 'backtourl') { if ($paramname == 'backtopage' || $paramname == 'backtolist' || $paramname == 'backtourl') {
$out = str_replace('\\', '/', $out); // Can be before the loop because only 1 char is replaced. No risk to get it after other replacements. $out = str_replace('\\', '/', $out); // Can be before the loop because only 1 char is replaced. No risk to get it after other replacements.
$out = str_replace(array(':', ';', '@'), '', $out); // Can be before the loop because only 1 char is replaced. No risk to get it after other replacements. $out = str_replace(array(':', ';', '@', "\t", ' '), '', $out); // Can be before the loop because only 1 char is replaced. No risk to retreive it after other replacements.
do { do {
$oldstringtoclean = $out; $oldstringtoclean = $out;
$out = str_ireplace(array('javascript', 'vbscript', '&colon', '&#'), '', $out); $out = str_ireplace(array('javascript', 'vbscript', '&colon', '&#'), '', $out);
$out = preg_replace(array('/^[^\?]*%/'), '', $out); // We remove any % chars before the ?. Example in url: '/product/stock/card.php?action=create&backtopage=%2Fdolibarr_dev%2Fhtdocs%2Fpro%25duct%2Fcard.php%3Fid%3Dabc'
$out = preg_replace(array('/^[a-z]*\/\s*\/+/i'), '', $out); // We remove schema*// to remove external URL
} while ($oldstringtoclean != $out); } while ($oldstringtoclean != $out);
$out = preg_replace(array('/^[a-z]*\/\/+/i'), '', $out); // We remove schema*// to remove external URL
} }
// Code for search criteria persistence. // Code for search criteria persistence.
@ -870,31 +870,32 @@ if (!function_exists('dol_getprefix')) {
* Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. * Return a prefix to use for this Dolibarr instance, for session/cookie names or email id.
* The prefix is unique for instance and avoid conflict between multi-instances, even when having two instances with same root dir * The prefix is unique for instance and avoid conflict between multi-instances, even when having two instances with same root dir
* or two instances in same virtual servers. * or two instances in same virtual servers.
* This function must not use dol_hash (that is used for password hash) and need to have all context $conf loaded.
* *
* @param string $mode '' (prefix for session name) or 'email' (prefix for email id) * @param string $mode '' (prefix for session name) or 'email' (prefix for email id)
* @return string A calculated prefix * @return string A calculated prefix
*/ */
function dol_getprefix($mode = '') function dol_getprefix($mode = '')
{ {
// If prefix is for email (we need to have $conf alreayd loaded for this case) // If prefix is for email (we need to have $conf already loaded for this case)
if ($mode == 'email') { if ($mode == 'email') {
global $conf; global $conf;
if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { // If MAIL_PREFIX_FOR_EMAIL_ID is set
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') { if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') {
return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
} elseif (isset($_SERVER["SERVER_NAME"])) { } elseif (isset($_SERVER["SERVER_NAME"])) { // If MAIL_PREFIX_FOR_EMAIL_ID is set to 'SERVER_NAME'
return $_SERVER["SERVER_NAME"]; return $_SERVER["SERVER_NAME"];
} }
} }
// The recommended value (may be not defined for old versions) // The recommended value if MAIL_PREFIX_FOR_EMAIL_ID is not defined (may be not defined for old versions)
if (!empty($conf->file->instance_unique_id)) { if (!empty($conf->file->instance_unique_id)) {
return $conf->file->instance_unique_id; return sha1('dolibarr'.$conf->file->instance_unique_id);
} }
// For backward compatibility // For backward compatibility when instance_unique_id is not set
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
} }
// If prefix is for session (no need to have $conf loaded) // If prefix is for session (no need to have $conf loaded)
@ -903,15 +904,15 @@ if (!function_exists('dol_getprefix')) {
// The recommended value (may be not defined for old versions) // The recommended value (may be not defined for old versions)
if (!empty($tmp_instance_unique_id)) { if (!empty($tmp_instance_unique_id)) {
return $tmp_instance_unique_id; return sha1('dolibarr'.$tmp_instance_unique_id);
} }
// For backward compatibility // For backward compatibility when instance_unique_id is not set
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) { if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) {
return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); return sha1($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
} else {
return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
} }
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
} }
} }
@ -1104,6 +1105,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
$tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); $tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
$tmp = preg_replace('/\-\-+/', '_', $tmp); $tmp = preg_replace('/\-\-+/', '_', $tmp);
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp); $tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
$tmp = str_replace('..', '', $tmp);
return $tmp; return $tmp;
} }
@ -1127,6 +1129,7 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
$tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); $tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
$tmp = preg_replace('/\-\-+/', '_', $tmp); $tmp = preg_replace('/\-\-+/', '_', $tmp);
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp); $tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
$tmp = str_replace('..', '', $tmp);
return $tmp; return $tmp;
} }
@ -2020,7 +2023,6 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
} }
if (empty($phototoshow)) { // Show No photo link (picto of object) if (empty($phototoshow)) { // Show No photo link (picto of object)
$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">';
if ($object->element == 'action') { if ($object->element == 'action') {
$width = 80; $width = 80;
$cssclass = 'photorefcenter'; $cssclass = 'photorefcenter';
@ -2042,8 +2044,6 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
$morehtmlleft .= $nophoto; $morehtmlleft .= $nophoto;
$morehtmlleft .= '</div></div>'; $morehtmlleft .= '</div></div>';
$morehtmlleft .= '</div>';
} }
} }
} }
@ -2573,11 +2573,11 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'auto',
{ {
global $conf; global $conf;
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
//print 'gm:'.$gm.' gm==auto:'.($gm == 'auto').'<br>';
if ($gm === 'auto') { if ($gm === 'auto') {
$gm = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey); $gm = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey);
} }
//print 'gm:'.$gm.' gm === auto:'.($gm === 'auto').'<br>';exit;
// Clean parameters // Clean parameters
if ($hour == -1 || empty($hour)) { if ($hour == -1 || empty($hour)) {
@ -3733,7 +3733,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'generate', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', 'generate', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group',
'help', 'holiday', 'help', 'holiday',
'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'knowledgemanagement', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'knowledgemanagement',
'label', 'language', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'label', 'language', 'line', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lot', 'long-arrow-alt-right',
'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next',
'off', 'on', 'order', 'off', 'on', 'order',
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'puce', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'puce',
@ -3778,7 +3778,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'entity'=>'globe', 'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'entity'=>'globe',
'graph'=>'chart-line', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', 'graph'=>'chart-line', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle',
'generic'=>'file', 'holiday'=>'umbrella-beach', 'generic'=>'file', 'holiday'=>'umbrella-beach',
'info'=>'info-circle', 'inventory'=>'boxes', 'intracommreport'=>'globe-europe', 'knowledgemanagement'=>'ticket-alt', 'label'=>'layer-group', 'loan'=>'money-bill-alt', 'info'=>'info-circle', 'inventory'=>'boxes', 'intracommreport'=>'globe-europe', 'knowledgemanagement'=>'ticket-alt', 'label'=>'layer-group', 'line'=>'bars', 'loan'=>'money-bill-alt',
'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', 'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry', 'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry',
'sign-out'=>'sign-out-alt', 'sign-out'=>'sign-out-alt',
@ -10504,6 +10504,7 @@ function newToken()
/** /**
* Return the value of token currently saved into session with name 'token'. * Return the value of token currently saved into session with name 'token'.
* For ajax call, you must use this token as a parameter of the call into the js calling script (the called ajax php page must also set constant NOTOKENRENEWAL).
* *
* @return string * @return string
*/ */

View File

@ -892,11 +892,13 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
} }
if ($feature == 'expensereport') { if ($feature == 'expensereport') {
$useridtocheck = $object->fk_user_author; $useridtocheck = $object->fk_user_author;
if (!$user->rights->expensereport->readall) {
if (!in_array($useridtocheck, $childids)) { if (!in_array($useridtocheck, $childids)) {
return false; return false;
} }
} }
} }
}
if ($sql) { if ($sql) {
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -187,7 +187,8 @@ if (!function_exists('dol_loginfunction')) {
$template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/";
} }
// Set cookie for timeout management // Set cookie for timeout management. We set it as a cookie so we will be able to use it to set timeout on next page before the session start
// and the conf file is loaded.
$prefix = dol_getprefix(''); $prefix = dol_getprefix('');
$sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;
if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) {

View File

@ -114,6 +114,11 @@ function stock_admin_prepare_head()
$head[$h][2] = 'stockMouvementAttributes'; $head[$h][2] = 'stockMouvementAttributes';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/product/admin/inventory_extrafields.php';
$head[$h][1] = $langs->trans("InventoryExtraFields");
$head[$h][2] = 'inventoryAttributes';
$h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
return $head; return $head;

View File

@ -476,7 +476,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
if ($sql) { // May not be defined if module Agenda is not enabled and mailing module disabled too if ($sql) { // May not be defined if module Agenda is not enabled and mailing module disabled too
$sql .= $db->order($sortfield_new, $sortorder); $sql .= $db->order($sortfield_new, $sortorder);
dol_syslog("company.lib::show_actions_done", LOG_DEBUG); dol_syslog("ticket.lib::show_ticket_messaging", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$i = 0; $i = 0;
@ -491,7 +491,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
$result = $contactaction->fetchResources(); $result = $contactaction->fetchResources();
if ($result < 0) { if ($result < 0) {
dol_print_error($db); dol_print_error($db);
setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); setEventMessage("ticket.lib::show_ticket_messaging Error fetch ressource", 'errors');
} }
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";

View File

@ -467,7 +467,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
if ($permanent) { if ($permanent) {
header("Status: 301 Moved Permanently", false, 301); header("Status: 301 Moved Permanently", false, 301);
} }
header("Location: ".$newurl); header("Location: ".$newurl.(empty($_SERVER["QUERY_STRING"]) ? '' : '?'.$_SERVER["QUERY_STRING"]));
exit; exit;
} else { } else {
print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")"; print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")";

View File

@ -601,3 +601,59 @@ function showWebsiteTemplates(Website $website)
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }
/**
* checkPHPCode
*
* @param string $phpfullcodestringold PHP old string
* @param string $phpfullcodestring PHP new string
* @return int Error or not
*/
function checkPHPCode($phpfullcodestringold, $phpfullcodestring)
{
global $conf, $langs, $user;
$error = 0;
if (empty($phpfullcodestringold) && empty($phpfullcodestring)) {
return 0;
}
// First check forbidden commands
$forbiddenphpcommands = array();
if (empty($conf->global->WEBSITE_PHP_ALLOW_EXEC)) { // If option is not on, we disallow functions to execute commands
$forbiddenphpcommands = array("exec", "passthru", "shell_exec", "system", "proc_open", "popen", "eval", "dol_eval", "executeCLI");
}
if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) { // If option is not on, we disallow functions to write files
$forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask"));
}
foreach ($forbiddenphpcommands as $forbiddenphpcommand) {
if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors');
break;
}
}
// This char can be used to execute RCE for example using with echo `ls`
$forbiddenphpchars = array();
if (empty($conf->global->WEBSITE_PHP_ALLOW_DANGEROUS_CHARS)) { // If option is not on, we disallow functions to execute commands
$forbiddenphpchars = array("`");
}
foreach ($forbiddenphpchars as $forbiddenphpchar) {
if (preg_match('/'.$forbiddenphpchar.'/ms', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar), null, 'errors');
break;
}
}
if (!$error && empty($user->rights->website->writephp)) {
if ($phpfullcodestringold != $phpfullcodestring) {
$error++;
setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors');
}
}
return $error;
}

View File

@ -100,6 +100,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
$created = $event["created"]; $created = $event["created"];
$modified = $event["modified"]; $modified = $event["modified"];
$assignedUsers = $event["assignedUsers"]; $assignedUsers = $event["assignedUsers"];
//print $fulldayevent.' '.dol_print_date($startdate, 'dayhour', 'gmt');
// Format // Format
$summary = format_cal($format, $summary); $summary = format_cal($format, $summary);
@ -191,16 +192,16 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
// Date must be GMT dates // Date must be GMT dates
// Current date // Current date
fwrite($calfileh, "DTSTAMP:".dol_print_date($now, "dayhourxcard", true)."\n"); fwrite($calfileh, "DTSTAMP:".dol_print_date($now, "dayhourxcard", 'gmt')."\n");
// Start date // Start date
$prefix = ""; $prefix = "";
$startdatef = dol_print_date($startdate, "dayhourxcard", true); $startdatef = dol_print_date($startdate, "dayhourxcard", 'gmt');
if ($fulldayevent) { if ($fulldayevent) {
// Local time // Local time
$prefix = ";VALUE=DATE"; $prefix = ";VALUE=DATE";
$startdatef = dol_print_date($startdate, "dayxcard", false); $startdatef = dol_print_date($startdate, "dayxcard", 'gmt');
} }
fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n"); fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n");
@ -208,6 +209,9 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
// End date // End date
if ($fulldayevent) { if ($fulldayevent) {
if (empty($enddate)) { if (empty($enddate)) {
// We add 1 day needed for full day event (DTEND must be next day after event).
// This is mention in https://datatracker.ietf.org/doc/html/rfc5545:
// "The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event."
$enddate = dol_time_plus_duree($startdate, 1, "d"); $enddate = dol_time_plus_duree($startdate, 1, "d");
} }
} else { } else {
@ -217,14 +221,14 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
} }
$prefix = ""; $prefix = "";
$enddatef = dol_print_date($enddate, "dayhourxcard", true); $enddatef = dol_print_date($enddate, "dayhourxcard", 'gmt');
if ($fulldayevent) { if ($fulldayevent) {
$prefix = ";VALUE=DATE"; $prefix = ";VALUE=DATE";
$enddatef = dol_print_date($enddate + 1, "dayxcard", false); // We add 1 second so we reach the +1 day needed for full day event (DTEND must be next day after event)
// This is mention in https://datatracker.ietf.org/doc/html/rfc5545:
// Local time // "The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event."
//$enddatef .= dol_print_date($enddate+1,"dayhourxcard",false); $enddatef = dol_print_date($enddate + 1, "dayxcard", 'gmt');
} }
fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n"); fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n");
@ -256,11 +260,11 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
} }
if ($created) { if ($created) {
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n"); fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", 'gmt')."\n");
} }
if ($modified) { if ($modified) {
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n"); fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", 'gmt')."\n");
} }
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n"); fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
@ -270,7 +274,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
fwrite($calfileh, "LOCATION:".$location."\n"); fwrite($calfileh, "LOCATION:".$location."\n");
fwrite($calfileh, "TRANSP:OPAQUE\n"); fwrite($calfileh, "TRANSP:OPAQUE\n");
fwrite($calfileh, "CLASS:CONFIDENTIAL\n"); fwrite($calfileh, "CLASS:CONFIDENTIAL\n");
fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, "dayhourxcard", true)."\n"); fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, "dayhourxcard", 'gmt')."\n");
fwrite($calfileh, "END:VJOURNAL\n"); fwrite($calfileh, "END:VJOURNAL\n");
} }

View File

@ -109,7 +109,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
//$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>'; //$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? $conf->global->BARCODE_STANDARD_PRODUCT_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="value1" value="'.(!empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK) ? $conf->global->BARCODE_STANDARD_PRODUCT_MASK : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition" name="Button" value="'.$langs->trans("Modify").'"'.$disabled.'></td>'; $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition" name="modify" value="'.$langs->trans("Modify").'"'.$disabled.'></td>';
$texte .= '</tr>'; $texte .= '</tr>';
$texte .= '</table>'; $texte .= '</table>';

Some files were not shown because too many files have changed in this diff Show More