From 34727286f1c6e154681acc9ca90dec8113b2882a Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 25 Jun 2017 22:03:06 +0200 Subject: [PATCH 001/130] Let's time to refactoring the tpl folder Propose to refactoring all the file present in /tpl folder for hamonisation with the rest of dolibarr file. Good resolution for this summer --- htdocs/core/tpl/bloc_showhide.tpl.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index 2c5d71c79d5..60ea83043a8 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -49,15 +49,15 @@ $(document).ready(function() { }); -
-
-
+'.img_picto('', '1uparrow.png').''."\n"; +print '
'.img_picto('', '1downarrow.png').'
'."\n"; +print '
'.$title.'
'."\n"; +print '
'."\n"; -
- - - -
-
- - \ No newline at end of file +include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php'; +print '

'; +?> + From fe749cbd95cdc155ee87e35928fc77b054be9497 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sun, 25 Jun 2017 22:27:38 +0200 Subject: [PATCH 002/130] Update bloc_showhide.tpl.php --- htdocs/core/tpl/bloc_showhide.tpl.php | 52 ++++++++++++++------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index 60ea83043a8..a98e8314097 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -21,35 +21,37 @@ if (isset($parameters['showblocbydefault'])) $hide=(empty($parameters['showblocb if (isset($object->extraparams[$blocname]['showhide'])) $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false); ?> - - +print '$("#show-'.$blocname.'").click(function(){'."\n"; +print ' setShowHide(1);'."\n"; +print ' $("#'.$blocname.'").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n"; +print ' $(this).hide();'."\n"; +print ' $("#hide-'.$blocname.'").show();'."\n"; +print '});'."\n"; + +print 'function setShowHide(status) {'."\n"; +print ' var id = '.$object->id."\n"; +print ' var element = '.$object->element."\n"; +print ' var htmlelement = '.$blocname."\n"; +print ' var type = "showhide";'."\n"; +print ' $.get("'.dol_buildpath('/core/ajax/extraparams.php', 1); +print '?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);'."\n"; +print '}'."\n"; + +print '});'."\n"; +print ''."\n"; -'.img_picto('', '1uparrow.png').''."\n"; print '
Date: Thu, 29 Jun 2017 10:14:48 +0200 Subject: [PATCH 003/130] NEW : filter on extrafield on product list (as in company list) --- htdocs/product/list.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 8a8eda5b65a..ab56a9e044b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -593,7 +593,26 @@ else { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; + if (! empty($arrayfields["ef.".$key]['checked'])) { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } + print ''; + } } } // Fields from hook From 1f9bd2538e59698f045f4ab6b229ac5da656dfe7 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Sun, 2 Jul 2017 22:20:07 +0200 Subject: [PATCH 004/130] new addMoreBoxStatsCustomer hook --- htdocs/comm/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a51ef902eb6..0a290af1507 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -604,11 +604,17 @@ if ($id > 0) if ($link) $boxstat.=''; } + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action); + if(empty($reshook)){ + $boxstat.= $hookmanager->resPrint; + } + $boxstat.=''; $boxstat.=''; $boxstat.='
'; - print $boxstat; + print $boxstat; $now=dol_now(); From 30153f8c2ef592a1b90641936fba08129c9ef155 Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Mon, 3 Jul 2017 07:21:15 +0200 Subject: [PATCH 005/130] add in bookkeeping date lim reglement Date lim reglement for export Sage and Iris correct avoir when write in bookkeeping --- htdocs/accountancy/class/bookkeeping.class.php | 7 +++++++ htdocs/accountancy/journal/purchasesjournal.php | 12 ++++++++---- htdocs/accountancy/journal/sellsjournal.php | 12 ++++++++---- .../mysql/tables/llx_accounting_bookkeeping.sql | 1 + .../mysql/tables/llx_accounting_bookkeeping_tmp.sql | 1 + 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 51ef317e917..947a05a5e9e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -71,6 +71,7 @@ class BookKeeping extends CommonObject /** */ public $doc_date; + public $date_lim_reglement; public $doc_type; public $doc_ref; public $fk_doc; @@ -255,6 +256,7 @@ class BookKeeping extends CommonObject $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; $sql .= "doc_date"; + $sql .= ", date_lim_reglement"; $sql .= ", doc_type"; $sql .= ", doc_ref"; $sql .= ", fk_doc"; @@ -277,6 +279,7 @@ class BookKeeping extends CommonObject $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($this->doc_date) . "'"; + $sql .= ",'" . $this->db->idate($this->date_lim_reglement) . "'"; $sql .= ",'" . $this->db->escape($this->doc_type) . "'"; $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; $sql .= "," . $this->fk_doc; @@ -441,6 +444,7 @@ class BookKeeping extends CommonObject // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.'('; $sql .= 'doc_date,'; + $sql .= 'date_lim_reglement,'; $sql .= 'doc_type,'; $sql .= 'doc_ref,'; $sql .= 'fk_doc,'; @@ -463,6 +467,7 @@ class BookKeeping extends CommonObject $sql .= 'entity'; $sql .= ') VALUES ('; $sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'" . $this->db->idate($this->doc_date) . "'") . ','; + $sql .= ' ' . (! isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'" . $this->db->idate($this->date_lim_reglement) . "'") . ','; $sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ','; $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; @@ -537,6 +542,7 @@ class BookKeeping extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; + $sql .= " t.date_lim_reglement,"; $sql .= " t.doc_type,"; $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; @@ -574,6 +580,7 @@ class BookKeeping extends CommonObject $this->id = $obj->rowid; $this->doc_date = $this->db->jdate($obj->doc_date); + $this->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $this->doc_type = $obj->doc_type; $this->doc_ref = $obj->doc_ref; $this->fk_doc = $obj->fk_doc; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 963ae4f19af..7bd8edc0fc0 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -88,7 +88,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $idpays = $mysoc->country_id; -$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; +$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, "; $sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; @@ -154,6 +154,7 @@ if ($result) { } $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); + $tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr); $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; $tabfac[$obj->rowid]["refsologest"] = $obj->ref; $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier; @@ -218,6 +219,7 @@ if ($action == 'writebookkeeping') { if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'supplier_invoice'; @@ -230,7 +232,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt <= 0) ? $mt : 0; + $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; @@ -267,6 +269,7 @@ if ($action == 'writebookkeeping') { if ($accountingaccount->fetch(null, $k, true)) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'supplier_invoice'; @@ -280,7 +283,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; @@ -314,6 +317,7 @@ if ($action == 'writebookkeeping') { // get compte id and label $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'supplier_invoice'; @@ -327,7 +331,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index edaf3a87f27..3f51c1985e5 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -92,7 +92,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $idpays = $mysoc->country_id; -$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; +$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; @@ -175,6 +175,7 @@ if ($result) { // Invoice lines $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); + $tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr); $tabfac[$obj->rowid]["ref"] = $obj->facnumber; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->label_compte; @@ -233,6 +234,7 @@ if ($action == 'writebookkeeping') { if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'customer_invoice'; @@ -246,7 +248,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; - $bookkeeping->credit = ($mt < 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; @@ -280,6 +282,7 @@ if ($action == 'writebookkeeping') { if ($accountingaccount->fetch(null, $k, true)) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'customer_invoice'; @@ -292,7 +295,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0) ? $mt : 0; + $bookkeeping->debit = ($mt < 0) ? -$mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; @@ -326,6 +329,7 @@ if ($action == 'writebookkeeping') { if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; $bookkeeping->doc_ref = $val["ref"]; $bookkeeping->date_create = $now; $bookkeeping->doc_type = 'customer_invoice'; @@ -338,7 +342,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0) ? $mt : 0; + $bookkeeping->debit = ($mt < 0) ? -$mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index ad1160c356d..5c5ed42fac0 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -40,6 +40,7 @@ CREATE TABLE llx_accounting_bookkeeping multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet + date_lim_reglement datetime, -- | date limite de reglement fk_user_author integer NOT NULL, -- | user creating fk_user_modif integer, -- | user making last change date_creation datetime, -- FEC:EcritureDate | creation date diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping_tmp.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping_tmp.sql index 79954769cef..8744429a8fe 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping_tmp.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping_tmp.sql @@ -40,6 +40,7 @@ CREATE TABLE llx_accounting_bookkeeping_tmp multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet + date_lim_reglement datetime, -- | date limite de reglement fk_user_author integer NOT NULL, -- | user creating fk_user_modif integer, -- | user making last change date_creation datetime, -- FEC:EcritureDate | creation date From 67f11103a37caf61e5d1b295d44855f4e7b27071 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Tue, 4 Jul 2017 21:56:47 +0200 Subject: [PATCH 006/130] fix indent --- htdocs/comm/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 0a290af1507..f46d8060f4c 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -604,17 +604,17 @@ if ($id > 0) if ($link) $boxstat.=''; } - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action); - if(empty($reshook)){ - $boxstat.= $hookmanager->resPrint; - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action); + if(empty($reshook)){ + $boxstat.= $hookmanager->resPrint; + } $boxstat.=''; $boxstat.=''; $boxstat.=''; - print $boxstat; + print $boxstat; $now=dol_now(); From bec5bde363e5ed22c91ea1aa9a26f18b315da2c0 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Thu, 6 Jul 2017 12:18:54 +0200 Subject: [PATCH 007/130] Move addMoreBoxStatsCustomer after table tag --- htdocs/comm/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index f46d8060f4c..e93bddb2e0b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -604,16 +604,16 @@ if ($id > 0) if ($link) $boxstat.=''; } + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; + $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action); if(empty($reshook)){ $boxstat.= $hookmanager->resPrint; } - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - print $boxstat; $now=dol_now(); From 3a89591fb46953e6d3b3ad3eb2cde6239daba333 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Thu, 6 Jul 2017 15:48:22 +0200 Subject: [PATCH 008/130] Adding Hook for tooltip on project --- htdocs/projet/class/project.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b22ea32f646..cfb6c45437d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -991,7 +991,7 @@ class Project extends CommonObject } $linkclose=''; - if (empty($notooltip) && $user->rights->propal->lire) + if (empty($notooltip)) { if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { @@ -1000,6 +1000,17 @@ class Project extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; + + if (! is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('projectdao')); + $parameters=array('id'=>$this->id); + // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); + if ($reshook > 0) + $linkclose = $hookmanager->resPrint; } $picto = 'projectpub'; From c36c2408c2d76bbd2b4367819535b966f6208c6d Mon Sep 17 00:00:00 2001 From: dolibarr95 Date: Thu, 13 Jul 2017 15:31:46 +0200 Subject: [PATCH 009/130] 'int' for $rate variable see : https://github.com/Dolibarr/dolibarr/pull/7149#issuecomment-315076031 --- htdocs/admin/multicurrency.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index ac5ab678109..b17b962d5ac 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -81,7 +81,7 @@ if ($action == 'add_currency') $langs->loadCacheCurrencies(''); $code = GETPOST('code', 'alpha'); - $rate = GETPOST('rate', 'alpha'); + $rate = GETPOST('rate', 'int'); $currency = new MultiCurrency($db); $currency->code = $code; $currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code; @@ -100,7 +100,7 @@ elseif ($action == 'update_currency') if ($submit == $langs->trans('Modify')) { $fk_multicurrency = GETPOST('fk_multicurrency', 'int'); - $rate = GETPOST('rate', 'float'); + $rate = GETPOST('rate', 'int'); $currency = new MultiCurrency($db); if ($currency->fetch($fk_multicurrency) > 0) From de24c0e3675a98cdee0253db938f06c78d727a76 Mon Sep 17 00:00:00 2001 From: dolibarr95 Date: Thu, 13 Jul 2017 16:21:02 +0200 Subject: [PATCH 010/130] Keep alpha for $rate var --- htdocs/admin/multicurrency.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b17b962d5ac..c8a04985b84 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -81,7 +81,7 @@ if ($action == 'add_currency') $langs->loadCacheCurrencies(''); $code = GETPOST('code', 'alpha'); - $rate = GETPOST('rate', 'int'); + $rate = GETPOST('rate', 'alpha'); $currency = new MultiCurrency($db); $currency->code = $code; $currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code; From f1c23f25f0c15a7f8ebc985393cb4a491d123762 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 13 Jul 2017 16:49:58 +0200 Subject: [PATCH 011/130] Fix updateline extrafields contrat fail --- htdocs/contrat/class/contrat.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e4bee39c39e..65ea14219d1 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1601,8 +1601,8 @@ class Contrat extends CommonObject if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_option; - $contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element); + $contractline->array_options=$array_options; + $contractline->id= $rowid; $result=$contractline->insertExtraFields(); if ($result < 0) { From 2c5bdaf4ad6c447d33d6d27d85f211d69bb62cd3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 16 Jul 2017 08:23:27 +0200 Subject: [PATCH 012/130] Fix: Trusty become default linux the July 18th 2017 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6eced4be075..010f5c8ca18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ # from Dolibarr GitHub repository. # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ +dist: precise sudo: required language: php From 885fc3c5b74a03e0762f22e913f54234c4196179 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 17 Jul 2017 11:04:48 +0200 Subject: [PATCH 013/130] Fix lost search value in list if come from thirdparty card --- htdocs/comm/propal/list.php | 1 + htdocs/commande/list.php | 1 + htdocs/compta/facture/list.php | 1 + htdocs/contrat/list.php | 7 +++++++ htdocs/fichinter/list.php | 9 ++++++++- htdocs/fourn/facture/list.php | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 93c93850652..0fd9ddb4c7c 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -353,6 +353,7 @@ if ($resql) $soc = new Societe($db); $soc->fetch($socid); $title = $langs->trans('ListOfProposals') . ' - '.$soc->name; + if (empty($search_societe)) $search_societe = $soc->name; } else { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e62ae11d5cd..d91d1737281 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -578,6 +578,7 @@ if ($resql) $soc = new Societe($db); $soc->fetch($socid); $title = $langs->trans('ListOfOrders') . ' - '.$soc->name; + if (empty($search_company)) $search_company = $soc->name; } else { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 982f61f5067..5a05c7c43ac 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -423,6 +423,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); + if (empty($search_societe)) $search_societe = $soc->name; } $param='&socid='.$socid; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 8a22f7ee324..1f23c9aad0a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -306,6 +306,13 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); + if ($socid) + { + $soc = new Societe($db); + $soc->fetch($socid); + if (empty($search_name)) $search_name = $soc->name; + } + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index bafafb40dd1..373cb9b99cf 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -211,7 +211,14 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - + + if ($socid) + { + $soc = new Societe($db); + $soc->fetch($socid); + if (empty($search_company)) $search_company = $soc->name; + } + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 77064191d24..8022eb7ef17 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -394,6 +394,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); + if (empty($search_societe)) $search_societe = $soc->name; } $param='&socid='.$socid; From ccbeb162cfed29abc9198a4cbfe8358b14c9b6d5 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 17 Jul 2017 11:27:57 +0200 Subject: [PATCH 014/130] FIX : Buying prices must always be in positive valueo --- htdocs/compta/facture.php | 2 +- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 34ed1383e14..a5e4334228d 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -771,7 +771,7 @@ if (empty($reshook)) $line->fk_parent_line = $fk_parent_line; $line->subprice =-$line->subprice; // invert price for object - $line->pa_ht = -$line->pa_ht; + $line->pa_ht = $line->pa_ht; $line->total_ht=-$line->total_ht; $line->total_tva=-$line->total_tva; $line->total_ttc=-$line->total_ttc; diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 86d2549a8bc..88ba07cc24b 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -611,3 +611,7 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (14 -- VMYSQL4.1 ALTER TABLE llx_c_type_resource CHANGE COLUMN rowid rowid integer NOT NULL AUTO_INCREMENT; ALTER TABLE llx_import_model MODIFY COLUMN type varchar(50); + +-- Negative buying prices + +UPDATE llx_facturedet SET buy_price_ht = ABS(buy_price_ht) From 76eac7ce6a387d9fcfdf5be017169e3e69cecd56 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 18 Jul 2017 10:13:10 +0200 Subject: [PATCH 015/130] Fix : creating user from member was failing due to column size difference --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index f1c94f346cf..e09d364a0e2 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -544,4 +544,6 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, -- VMYSQL4.1 ALTER TABLE llx_establishment CHANGE COLUMN fk_user_mod fk_user_mod integer NULL; -- VPGSQL8.2 ALTER TABLE llx_establishment ALTER COLUMN fk_user_mod DROP NOT NULL; -ALTER TABLE llx_multicurrency_rate ADD COLUMN entity integer DEFAULT 1; \ No newline at end of file +ALTER TABLE llx_multicurrency_rate ADD COLUMN entity integer DEFAULT 1; + +ALTER TABLE llx_user MODIFY COLUMN login varchar(50); \ No newline at end of file From 2a50a78497b59a91f1b0399b028af761751c7d3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 10:04:58 +0200 Subject: [PATCH 016/130] Fix hack to solve link to restrictions --- htdocs/core/class/html.form.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 321a4752006..59142e4c060 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5458,6 +5458,14 @@ class Form { $listofidcompanytoscan=$object->thirdparty->id; if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent; + if (($object->fk_project > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) + { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpproject=new Project($this->db); + $tmpproject->fetch($object->fk_project); + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan.=','.$tmpproject->socid; + unset($tmpproject); + } $possiblelinks=array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal',1).')'), From d35dbdea923ce3115631d289784a03e53d030353 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 18 Jul 2017 10:16:59 +0200 Subject: [PATCH 017/130] Change column size in sql table creation also --- htdocs/install/mysql/tables/llx_user.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 6b3c5b83f6d..84d74fa52d9 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -33,7 +33,7 @@ create table llx_user tms timestamp, fk_user_creat integer, fk_user_modif integer, - login varchar(24) NOT NULL, + login varchar(50) NOT NULL, pass varchar(128), pass_crypted varchar(128), pass_temp varchar(128), -- temporary password when asked for forget password From 97fe41d60319348e77dafd7297f56bce7f62bf7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 12:49:19 +0200 Subject: [PATCH 018/130] A info int smtp header --- htdocs/core/class/smtps.class.php | 49 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c99ca2c4850..3859f0de2b0 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -271,7 +271,7 @@ class SMTPs { $this->_moreinheader = $_val; } - + /** * get trackid * @@ -291,7 +291,7 @@ class SMTPs { return $this->_moreinheader; } - + /** * Set errors to * @@ -411,7 +411,7 @@ class SMTPs function _server_authenticate() { global $conf; - + // Send the RFC2554 specified EHLO. // This improvment as provided by 'SirSir' to // accomodate both SMTP AND ESMTP capable servers @@ -441,7 +441,7 @@ class SMTPs { $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); return $_retVal; - } + } } // Send Authentication to Server // Check for errors along the way @@ -882,7 +882,7 @@ class SMTPs if ( $_strReplyTo ) $this->_msgReplyTo = $this->_strip_email($_strReplyTo); } - + /** * Retrieves the Address from which mail will be the reply-to * @@ -892,15 +892,15 @@ class SMTPs function getReplyTo($_part = true) { $_retValue = ''; - + if ( $_part === true ) $_retValue = $this->_msgReplyTo; else $_retValue = $this->_msgReplyTo[$_part]; - + return $_retValue; } - + /** * Inserts given addresses into structured format. * This method takes a list of given addresses, via an array @@ -1196,6 +1196,8 @@ class SMTPs */ function getHeader() { + global $conf; + $_header = 'From: ' . $this->getFrom('org') . "\r\n" . 'To: ' . $this->getTO() . "\r\n"; @@ -1212,13 +1214,13 @@ class SMTPs if ( $this->getBCC() ) $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; */ - + $host=$this->getHost(); $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix $host=dol_getprefix('email'); - + //NOTE: Message-ID should probably contain the username of the user who sent the msg $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; $_header .= 'Date: ' . date("r") . "\r\n"; @@ -1237,7 +1239,7 @@ class SMTPs } if ( $this->getMoreInHeader() ) $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; - + //$_header .= // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; @@ -1258,9 +1260,10 @@ class SMTPs $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; + $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; $_header .= 'Mime-Version: 1.0' . "\r\n"; - + return $_header; } @@ -1289,17 +1292,17 @@ class SMTPs $strContentAltText = html_entity_decode(strip_tags($strContent)); $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); } - + // Make RFC2045 Compliant //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. - + $this->_msgContent[$strType] = array(); $this->_msgContent[$strType]['mimeType'] = $strMimeType; $this->_msgContent[$strType]['data'] = $strContent; $this->_msgContent[$strType]['dataText'] = $strContentAltText; - + if ( $this->getMD5flag() ) $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); //} @@ -1313,7 +1316,7 @@ class SMTPs function getBodyContent() { global $conf; - + // Generate a new Boundary string $this->_setBoundary(); @@ -1361,7 +1364,7 @@ class SMTPs $content .= "\r\n"; $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; - + if (key_exists('image', $this->_msgContent)) // If inline image found { $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; @@ -1369,7 +1372,7 @@ class SMTPs $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; } - + // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment' @@ -1429,18 +1432,18 @@ class SMTPs $content.= "\r\n"; $content.= "--" . $this->_getBoundary('related') . "\r\n"; } - + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part { $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; $content .= "\r\n"; $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; - + $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; $content.= "\r\n". $_content['dataText'] . "\r\n"; $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - } - + } + $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' // . 'charset="' . $this->getCharSet() . '"'; . 'charset=' . $this->getCharSet() . ''; @@ -1462,7 +1465,7 @@ class SMTPs { $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; } - + $content .= "\r\n"; } } From 5f32c3d34ae42cb79f49ee594950606c32081e49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 12:49:42 +0200 Subject: [PATCH 019/130] Work on new india vat system --- dev/resources/iso-normes/world_tax_rates.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/resources/iso-normes/world_tax_rates.txt b/dev/resources/iso-normes/world_tax_rates.txt index e5bb64a86f2..740062288dc 100644 --- a/dev/resources/iso-normes/world_tax_rates.txt +++ b/dev/resources/iso-normes/world_tax_rates.txt @@ -1 +1,4 @@ -http://www.taxrates.cc/index.html \ No newline at end of file +http://www.taxrates.cc/index.html + +For India: VAT=IGST/CGST=Localtax1/SGST=Localtax2: https://cleartax.in/s/what-is-sgst-cgst-igst + From cfbd47bd78e628f7bc440c87667f5e5048dd5a6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 14:09:37 +0200 Subject: [PATCH 020/130] Fix field null --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 1 + htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 1 + htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ 3 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index dd0aba11632..6dc2521ca5d 100755 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -1106,6 +1106,7 @@ ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_d ALTER TABLE llx_projet_task MODIFY COLUMN duration_effective real DEFAULT 0 NULL; ALTER TABLE llx_projet_task MODIFY COLUMN planned_workload real DEFAULT 0 NULL; +-- VPGSQL8.2 ALTER TABLE llx_projet_task ALTER COLUMN planned_workload DROP NOT NULL; -- add extrafield on ficheinter lines CREATE TABLE llx_fichinterdet_extrafields diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index c997d511fdb..63bc1a8d7a3 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -110,6 +110,7 @@ ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 ALTER TABLE llx_projet_task MODIFY COLUMN duration_effective real DEFAULT 0 NULL; ALTER TABLE llx_projet_task MODIFY COLUMN planned_workload real DEFAULT 0 NULL; +-- VPGSQL8.2 ALTER TABLE llx_projet_task ALTER COLUMN planned_workload DROP NOT NULL; ALTER TABLE llx_commande_fournisseur MODIFY COLUMN date_livraison datetime; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index d18da18ac6a..faf196a9802 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -467,6 +467,8 @@ DELETE FROM llx_categorie_project WHERE fk_categorie NOT IN (SELECT rowid FROM l ALTER TABLE llx_inventory ADD COLUMN ref varchar(48); +-- VPGSQL8.2 ALTER TABLE llx_projet_task ALTER COLUMN planned_workload DROP NOT NULL; + CREATE TABLE llx_loan_schedule ( rowid integer AUTO_INCREMENT PRIMARY KEY, From 0179160f6cb937e3818c4ced09b316b948c4722b Mon Sep 17 00:00:00 2001 From: Articoder InfoSec Team Date: Fri, 14 Jul 2017 15:57:22 -0700 Subject: [PATCH 021/130] Reason: similar change is present elsewhere in the code Notes: please review carefully before accepting. patch propagation. manual test run. Reviewed By: https://github.com/dchichkov Cherry picked from: === From 0d62bd704e7a61d66842a7c91cf3e50a249461f9 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 22 Jun 2016 18:59:51 +0200 Subject: [PATCH] Fix: Bad column totalizing if MAIN_SHOW_HT_ON_SUMMARY activated --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 321c2456ddd..46104845ba0 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -378,7 +378,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; $total_ttc += $obj->total_ttc; - $total += $obj->total; + $total += $obj->total_hc; $totalam += $obj->am; $i++; From 5e1dbdc608469111ad763c3608561c3f9653dfa9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 14:33:32 +0200 Subject: [PATCH 022/130] Update index.php --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 46104845ba0..103ec747e37 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -378,7 +378,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; $total_ttc += $obj->total_ttc; - $total += $obj->total_hc; + $total += $obj->total_ht; $totalam += $obj->am; $i++; From 4b0638dd408d458ae6ae13ee8f495f04dd296ffe Mon Sep 17 00:00:00 2001 From: hguibourgdev Date: Sat, 15 Jul 2017 19:04:10 +0200 Subject: [PATCH 023/130] Update list.php FIX copy-paste error (sell versus buy) --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index af5e500fbf5..13793438a7b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -311,7 +311,7 @@ else if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); - if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); + if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); // Add where from extra fields if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { From 7ac5054df8c9a1b00f0f48bf7533e164ce9eb55d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 14:47:44 +0200 Subject: [PATCH 024/130] Update list.php --- htdocs/fichinter/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 373cb9b99cf..1e508b4f7e8 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -212,7 +212,7 @@ if ($result) { $num = $db->num_rows($result); - if ($socid) + if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); From f6060b976dc3a4f58c41034280d66b7be13b10c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 14:48:18 +0200 Subject: [PATCH 025/130] Update list.php --- htdocs/contrat/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 1f23c9aad0a..6c28dbe631e 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -306,7 +306,7 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); - if ($socid) + if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); From f701a52d2d77e8f032d5c4bae2d2c0cbc5627136 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 18 Jul 2017 19:33:25 +0200 Subject: [PATCH 026/130] fix missing line into PR 6012 --- htdocs/core/actions_sendmails.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index a796a94c68c..1998808bf11 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -391,6 +391,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; + if (is_array($attachedfiles) && count($attachedfiles)>0) { + $object->attachedfiles = $attachedfiles; + } // Call of triggers if (! empty($trigger_name)) From 74db61ce1513d51a3b587e291d68b2d03420c24f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Jul 2017 15:50:57 +0200 Subject: [PATCH 027/130] Fix translation --- htdocs/langs/en_US/website.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index cc2f31143ce..1eda648880d 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -7,7 +7,7 @@ WEBSITE_PAGENAME=Page name/alias WEBSITE_HTML_HEADER=HTML Header WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS content -PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is read from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. +PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. MediaFiles=Media library EditCss=Edit Style/CSS EditMenu=Edit menu From 69aed8ac7f03d794d4fb3849b27364655a5c8c8a Mon Sep 17 00:00:00 2001 From: "cam.lafit" Date: Wed, 19 Jul 2017 16:27:34 +0200 Subject: [PATCH 028/130] Allow RUM on creation step * close #4932 --- htdocs/societe/rib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index d571e218e51..21a415f2268 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -203,6 +203,7 @@ if (empty($reshook)) $account->proprio = GETPOST('proprio','alpha'); $account->owner_address = GETPOST('owner_address','alpha'); $account->frstrecur = GETPOST('frstrecur'); + $account->rum = GETPOST('rum','alpha'); // This test can be done only once properties were set if ($account->needIBAN() == 1) @@ -871,7 +872,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // RUM print ''.$langs->trans("RUM").''; - print ''.$langs->trans("RUMWillBeGenerated").''; + print '
'.$langs->trans("RUMWillBeGenerated").''; // FRSTRECUR print ''.$langs->trans("WithdrawMode").''; From f0d95fcbd94c6d8bd1fc375a0e0cbeda0765da59 Mon Sep 17 00:00:00 2001 From: "cam.lafit" Date: Wed, 19 Jul 2017 16:29:56 +0200 Subject: [PATCH 029/130] fixup! Allow RUM on creation step --- htdocs/langs/fr_FR/withdrawals.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/withdrawals.lang b/htdocs/langs/fr_FR/withdrawals.lang index 4b684330e3d..f84031127dd 100644 --- a/htdocs/langs/fr_FR/withdrawals.lang +++ b/htdocs/langs/fr_FR/withdrawals.lang @@ -75,7 +75,7 @@ ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les fa StatisticsByLineStatus=Statistiques par statut des lignes RUM=RUM RUMLong=Référence Unique de Mandat -RUMWillBeGenerated=Le numéro de RUM sera généré une fois les informations de compte bancaire sont enregistrées +RUMWillBeGenerated=Si vide le numéro de RUM sera généré une fois les informations de compte bancaire sont enregistrées WithdrawMode=Mode de prélévement (FRST ou RECUR) WithdrawRequestAmount=Montant de la demande de prélèvement WithdrawRequestErrorNilAmount=Impossible de créer une demande de prélèvement pour un montant nul From 84f621fde33ae245fc014b889242a03b41b131cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Jul 2017 16:31:15 +0200 Subject: [PATCH 030/130] Fix migration on pgsql --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 4 ++++ htdocs/install/pgsql/functions/functions.sql | 2 ++ 2 files changed, 6 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index faf196a9802..386ae968505 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -573,3 +573,7 @@ UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement c UPDATE llx_bank SET label= '(payment_salary)' WHERE label LIKE 'Règlement salaire'; ALTER TABLE llx_mailing_cibles MODIFY COLUMN source_url varchar(255); + +-- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +-- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); + diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 2e4125e39e4..06ef2ed41e3 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -163,6 +163,8 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user_extrafields FOR CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_product_price_by_qty FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -- Add triggers for timestamp fields named date_m From f438097ecb6e15a007414790543613ebde145244 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 20 Jul 2017 14:59:24 +0200 Subject: [PATCH 031/130] Fix extrafield save on update --- htdocs/contrat/class/contrat.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e08e10a0966..35a9e98b31f 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1278,6 +1278,15 @@ class Contrat extends CommonObject //// End call triggers } } + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } // Commit or rollback if ($error) From 3b8f60f90e0a22460ff177448e6d94d159fc7997 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Jul 2017 16:49:20 +0200 Subject: [PATCH 032/130] Fix pb of recursive include in website module --- htdocs/core/lib/website.lib.php | 35 +++++++++++++++++++++++++ htdocs/core/website.inc.php | 28 ++++++++++++++++++++ htdocs/langs/en_US/website.lang | 9 ++++--- htdocs/public/websites/index.php | 8 +++--- htdocs/theme/eldy/style.css.php | 5 ++++ htdocs/theme/md/style.css.php | 6 ++++- htdocs/websites/class/website.class.php | 35 +++++++++---------------- htdocs/websites/index.php | 34 ++++++++++++++---------- 8 files changed, 115 insertions(+), 45 deletions(-) create mode 100644 htdocs/core/website.inc.php diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 37f01a0ffe3..336a82b4697 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -64,3 +64,38 @@ function dolWebsiteOutput($content) print $content; } + +/** + * Clean an HTML page to report only content, so we can include it into another page + * It outputs content of file sanitized from html and body part. + * + * @param string $contentfile Path to file to include (must include website root. Example: 'mywebsite/mypage.php') + * @return void + */ +function dolIncludeHtmlContent($contentfile) +{ + global $conf, $db, $langs, $mysoc, $user, $website; + global $includehtmlcontentopened; + + $MAXLEVEL=20; + + $fullpathfile=DOL_DATA_ROOT.'/websites/'.$contentfile; + //$content = file_get_contents($fullpathfile); + //print preg_replace(array('/^.*]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ + + if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0; + $includehtmlcontentopened++; + if ($includehtmlcontentopened > $MAXLEVEL) + { + print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n"; + return; + } + $res = include $fullpathfile; // Include because we want to execute code content + if (! $res) + { + print 'ERROR: FAILED TO INCLUDE PAGE '.$contentfile.".\n"; + } + + $includehtmlcontentopened--; +} + diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php new file mode 100644 index 00000000000..65db787734a --- /dev/null +++ b/htdocs/core/website.inc.php @@ -0,0 +1,28 @@ + + * +* 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 . +* or see http://www.gnu.org/ +*/ + +/** + * \file htdocs/core/website.inc.php + * \brief Common file loaded used by all website pages (after master.inc.php) + * The global variable $website must be defined. + */ + + +include_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; +$website=new Website($db); +$website->fetch(0,$websitekey); diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 1eda648880d..b3af3d3e0fc 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -19,8 +19,9 @@ AddPage=Add page HomePage=Home Page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this. -PageDeleted=Page '%s' of website %s deleted -PageAdded=Page '%s' added +PageContent=Page/Content +PageDeleted=Page/Content '%s' of website %s deleted +PageAdded=Page/Content '%s' added ViewSiteInNewTab=View site in new tab ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page @@ -29,4 +30,6 @@ ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on %s
then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server. PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. -NoPageYet=No pages yet \ No newline at end of file +NoPageYet=No pages yet +SyntaxHelp=Help on code syntax +YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.
You can also include content of another Page/Content with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?> \ No newline at end of file diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index 0bc85dce463..a2dcbfc3dc6 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -47,7 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; -$website=GETPOST('website', 'alpha'); +$websitekey=GETPOST('website', 'alpha'); $pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); $accessallowed = 1; @@ -69,7 +69,7 @@ if (empty($pageid)) require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; $object=new Website($db); - $object->fetch(0, $website); + $object->fetch(0, $websitekey); if (empty($object->id)) { if (empty($pageid)) @@ -125,11 +125,11 @@ if ($pageid == 'css') // No more used ? //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); //else header('Cache-Control: no-cache'); - $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php'; + $original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/styles.css.php'; } else { - $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/page'.$pageid.'.tpl.php'; + $original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/page'.$pageid.'.tpl.php'; } // Find the subdirectory name as the reference diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b82fd096cfe..7bd3d913782 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3347,6 +3347,11 @@ a.websitebuttonsitepreview img { width: 26px; display: inline-block; } +.websitehelp { + vertical-align: middle; + float: right; + padding-top: 8px; +} /* ============================================================================== */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index fb774e8793b..b190a3fad67 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3428,7 +3428,11 @@ a.websitebuttonsitepreview img { .websiteiframenoborder { border: 0px; } - +.websitehelp { + vertical-align: middle; + float: right; + padding-top: 8px; +} /* ============================================================================== */ /* Module agenda */ diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index a77079c94a6..7f973a15200 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -48,11 +48,6 @@ class Website extends CommonObject */ public $table_element = 'website'; - /** - * @var WebsitePage[] Lines of all pages - */ - public $lines = array(); - /** * @var int */ @@ -85,13 +80,7 @@ class Website extends CommonObject * @var string */ public $virtualhost; - - - public $records; - - /** - */ - + /** * Constructor @@ -218,7 +207,7 @@ class Website extends CommonObject $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + $sql .= " WHERE t.ref = '" . $this->db->escape($ref) . "'"; } else { $sql .= ' WHERE t.rowid = ' . $id; } @@ -230,7 +219,7 @@ class Website extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->description = $obj->description; @@ -297,7 +286,7 @@ class Website extends CommonObject if (count($sqlwhere) > 0) { $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); } - + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield,$sortorder); } @@ -314,7 +303,7 @@ class Website extends CommonObject $line = new self($this->db); $line->id = $obj->rowid; - + $line->entity = $obj->entity; $line->ref = $obj->ref; $line->description = $obj->description; @@ -354,7 +343,7 @@ class Website extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->entity)) { $this->entity = trim($this->entity); } @@ -552,7 +541,7 @@ class Website extends CommonObject $result.= $link . $this->ref . $linkend; return $result; } - + /** * Retourne le libelle du status d'un user (actif, inactif) * @@ -607,8 +596,8 @@ class Website extends CommonObject if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } - - + + /** * Initialise object with example values * Id must be 0 if object instance is a specimen @@ -618,9 +607,9 @@ class Website extends CommonObject public function initAsSpecimen() { global $user; - + $this->id = 0; - + $this->entity = 1; $this->ref = 'myspecimenwebsite'; $this->description = 'A specimen website'; @@ -632,7 +621,7 @@ class Website extends CommonObject $this->date_creation = dol_now(); $this->tms = dol_now(); - + } } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 2c9c364edac..535c1a063df 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -245,7 +245,7 @@ if ($action == 'updatecss') // Html header file $htmlheadercontent = ''."\n"; - $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\n"; $htmlheadercontent.= ''."\n"; $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); @@ -264,7 +264,7 @@ if ($action == 'updatecss') // Css file $csscontent = ''."\n"; - $csscontent.= ''."\n"; + $csscontent.= ''."\n"; $csscontent.= '"."\n"; @@ -372,12 +372,13 @@ if ($action == 'updatemeta') // Now generate the master.inc.php page - dol_syslog("We regenerate the master file"); + dol_syslog("We regenerate the master file (because we update meta)"); dol_delete_file($filemaster); $mastercontent = ''."\n"; $result = file_put_contents($filemaster, $mastercontent); if (! empty($conf->global->MAIN_UMASK)) @@ -565,8 +566,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent =''; $tplcontent.= "\n"; $tplcontent.= ''."\n"; @@ -746,12 +749,9 @@ if (count($object->records) > 0) $urlext=$virtualurl; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; - //if (! empty($object->virtualhost)) - //{ - print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); - print ''; - //} + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); @@ -822,7 +822,6 @@ if (count($object->records) > 0) } print ''; - //print $form->selectarray('page', $array); if ($action == 'preview') { @@ -843,8 +842,6 @@ if (count($object->records) > 0) } } - print ''; - print '
'; print '
'; print '
'; + print '
'; + if (GETPOST('editcontent', 'alpha')) + { + $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource"); + print $form->textwithpicto($langs->trans("SyntaxHelp"), $htmltext, 1, 'help', 'inline-block', 0, 2, 'tooltipsubstitution'); + } + print '
'; + + + if ($action == 'preview') { // Adding jquery code to change on the fly url of preview ext From fa3ed50f3a01fdd670943abaa05277d4022e4df0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Jul 2017 18:23:42 +0200 Subject: [PATCH 033/130] Fix sql syntax --- htdocs/websites/class/website.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index 7f973a15200..1d67eb4ebb0 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -133,7 +133,7 @@ class Website extends CommonObject $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'fk_user_create'; + $sql.= 'fk_user_create,'; $sql.= 'date_creation'; $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; From dfb49fc47b983216f8b1cf90277fbfee77661561 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Jul 2017 18:36:18 +0200 Subject: [PATCH 034/130] Fix update tms --- htdocs/websites/class/website.class.php | 12 ++++++------ htdocs/websites/class/websitepage.class.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index df8d4b07e79..d7cb1559982 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -208,7 +208,7 @@ class Website extends CommonObject $sql .= " t.fk_user_create,"; $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.tms"; + $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (null !== $ref) { $sql .= " WHERE t.ref = '" . $this->db->escape($ref) . "'"; @@ -233,7 +233,7 @@ class Website extends CommonObject $this->fk_user_create = $obj->fk_user_create; $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->tms = $this->db->jdate($obj->tms); + $this->date_modification = $this->db->jdate($obj->date_modification); } $this->db->free($resql); @@ -277,7 +277,7 @@ class Website extends CommonObject $sql .= " t.fk_user_create,"; $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; - $sql .= " t.tms"; + $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; // Manage filter @@ -317,7 +317,7 @@ class Website extends CommonObject $this->fk_user_create = $obj->fk_user_create; $this->fk_user_modif = $obj->fk_user_modif; $line->date_creation = $this->db->jdate($obj->date_creation); - $line->tms = $this->db->jdate($obj->tms); + $line->date_modification = $this->db->jdate($obj->date_modification); $this->records[$line->id] = $line; } @@ -373,8 +373,8 @@ class Website extends CommonObject $sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").','; $sql .= ' virtualhost = '.(($this->virtualhost != '')?"'".$this->db->escape($this->virtualhost)."'":"null").','; $sql .= ' fk_user_modif = '.(! isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; - $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; - $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); + $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null'); + $sql .= ', tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'"); $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 77e5d5862ec..7d99678fcb6 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -381,8 +381,8 @@ class WebsitePage extends CommonObject $sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").','; $sql .= ' content = '.(isset($this->content)?"'".$this->db->escape($this->content)."'":"null").','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; - $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; - //$sql .= ' tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'"); + $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null'); + $sql .= ', tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'"); $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); From df61a5f0452a83a15862b9e8435221e4ca16dfd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Jul 2017 20:05:49 +0200 Subject: [PATCH 035/130] Debug module website --- htdocs/admin/websites.php | 42 +++++++++++++++++++++++++++++++++++++-- htdocs/websites/index.php | 14 ++++++------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index ee75a811347..f4eddfbf092 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -114,7 +114,7 @@ $tabfieldcheck[1] = array(); $elementList = array(); $sourceList=array(); -// Actions add or modify an entry into a dictionary +// Actions add or modify a website if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',',$tabfield[$id]); @@ -133,7 +133,7 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) $fieldnamekey=$listfield[$f]; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } - if ($value == 'ref' && (preg_match('/[a-zA-Z0-9]/', $_POST[$value]))) + if ($value == 'ref' && ! preg_match('/^[a-z0-9]+$/i', $_POST[$value])) { $ok=0; $fieldnamekey=$listfield[$f]; @@ -141,6 +141,12 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) } } + // Clean parameters + if (! empty($_POST['ref'])) + { + $websitekey=strtolower($_POST['ref']); + } + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd','alpha')) { @@ -160,6 +166,12 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) } } + /* $website=new Website($db); + $website->ref= + $website->description= + $website->virtualhost= + $website->create($user); */ + // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields @@ -178,6 +190,9 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) if ($value == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } + if ($value == 'ref') { + $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]); + } if ($i) $sql.=","; if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; @@ -189,6 +204,29 @@ if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) $result = $db->query($sql); if ($result) // Add is ok { + global $dolibarr_main_data_root; + $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$websitekey; + $filehtmlheader=$pathofwebsite.'/htmlheader.html'; + $filecss=$pathofwebsite.'/styles.css.php'; + $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; + $fileindex=$pathofwebsite.'/index.php'; + + // Css file + $csscontent = ''."\n"; + $csscontent.= ''."\n"; + $csscontent.= '"."\n"; + $csscontent.= ''."\n"; + $csscontent.= 'body { margin: 0; }'."\n"; + + dol_syslog("Save file css into ".$filecss); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filecss, $csscontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filecss, octdec($conf->global->MAIN_UMASK)); + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); unset($_POST); // Clean $_POST array, we keep only } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 3a03c16a17c..b937337e95c 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -130,7 +130,7 @@ if ($pageid > 0 && $action != 'add') global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; -$filehtmlheader=$pathofwebsite.'/header.html'; +$filehtmlheader=$pathofwebsite.'/htmlheader.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -433,7 +433,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= 'ref.'/header.html"); ?>'."\n"; + $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -592,7 +592,7 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= 'ref.'/header.html"); ?>'."\n"; + $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -845,12 +845,10 @@ if (count($object->records) > 0) { print '   '; - if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; - else print ''; print ''; print ''; - //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; - //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; + else print ''; print ''; } } @@ -973,7 +971,7 @@ if ($action == 'editcss') // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('//s', '', $csscontent); - if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'; + if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'."\n".'body { margin: 0; }'; $htmlheader = @file_get_contents($filehtmlheader); // Clean the php css file to remove php code and get only html part From 1fd3ab56a83dd79bf6a826d6dfc90067fedeeac5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 00:01:27 +0200 Subject: [PATCH 036/130] Fix edit of css and htmlheader --- htdocs/websites/index.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b937337e95c..d9ea42096c7 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -48,7 +48,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); - print ''; + print ''; // top menu and left menu area if (empty($conf->dol_hide_topmenu)) @@ -250,10 +250,13 @@ if ($action == 'updatecss') $res = $object->fetch(0, $website); // Html header file - $htmlheadercontent = ''."\n"; + $htmlheadercontent.= '"."\n"; + $htmlheadercontent = ''."\n"; $htmlheadercontent.= ''."\n"; $htmlheadercontent.= ''."\n"; - $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); + $htmlheadercontent.= preg_replace(array('//','/<\/html>/'),array('',''),GETPOST('WEBSITE_HTML_HEADER')); dol_syslog("Save file css into ".$filehtmlheader); @@ -269,12 +272,12 @@ if ($action == 'updatecss') } // Css file - $csscontent = ''."\n"; - $csscontent.= ''."\n"; $csscontent.= '"."\n"; - $csscontent.= ''."\n"; + $csscontent = '/* BEGIN DOLIBARR-WEBSITE-CSS-ADDED-HEADER */'."\n"; + $csscontent.= '/* File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. */'."\n"; + $csscontent.= '/* END */'."\n"; $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); dol_syslog("Save file css into ".$filecss); @@ -969,15 +972,19 @@ if ($action == 'editcss') $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part - $csscontent = preg_replace('//s', '', $csscontent); + $csscontent = preg_replace('/^<\?php[^\?]+\?>/ims', '', $csscontent); + $csscontent = preg_replace('/\/\* BEGIN DOLIBARR.*END \*\/\n*/ims', '', $csscontent); + + if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'."\n".'body { margin: 0; }'; - if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'."\n".'body { margin: 0; }'; $htmlheader = @file_get_contents($filehtmlheader); - // Clean the php css file to remove php code and get only html part - $htmlheader = preg_replace('//s', '', $htmlheader); + // Clean the php htmlheader file to remove php code and get only html part + $htmlheader = preg_replace('/^<\?php[^\?]+\?>/ims', '', $htmlheader); + $htmlheader = preg_replace('/\n*/ims', '', $htmlheader); if (! trim($htmlheader)) $htmlheader=''; + else $htmlheader=''.$htmlheader.''; dol_fiche_head(); From 5318e513c11cb70740056718bc5ca6baf70ed5d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 02:29:24 +0200 Subject: [PATCH 037/130] Debug module website --- htdocs/public/websites/index.php | 2 +- htdocs/websites/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index a2dcbfc3dc6..991ca11b683 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -177,7 +177,7 @@ if (! file_exists($original_file_osencoded)) // Output page content define('USEDOLIBARRSERVER', 1); -print "\n".''."\n"; +print ''."\n"; include_once $original_file_osencoded; diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 535c1a063df..0b621577463 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -1112,7 +1112,7 @@ if ($action == 'preview') { $objectpage->fetch($pageid); - $out = "\n".''."\n"; + $out = ''."\n"; $out.='
'."\n"; From 28254655e9939c312873bdef987be63e3f37130a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 02:30:02 +0200 Subject: [PATCH 038/130] Debug module website --- htdocs/core/lib/website.lib.php | 22 ++++-- htdocs/langs/en_US/website.lang | 2 +- htdocs/public/websites/index.php | 43 +++++++---- htdocs/websites/class/websitepage.class.php | 19 +++-- htdocs/websites/index.php | 86 ++++++++++++++------- 5 files changed, 114 insertions(+), 58 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 336a82b4697..d5d4f2d3826 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -31,17 +31,17 @@ function dolWebsiteOutput($content) { global $db, $langs, $conf, $user; - global $dolibarr_main_url_root; + global $dolibarr_main_url_root, $dolibarr_main_data_root; dol_syslog("dolWebsiteOutput start"); + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + if (! defined('USEDOLIBARRSERVER')) { - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $symlinktomediaexists=1; // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server @@ -55,9 +55,17 @@ function dolWebsiteOutput($content) } else { - $content=preg_replace('/()/', '\1medias/\4\5', $content, -1, $nbrep); + $content=preg_replace('/()/', '\1medias/\4\5', $content, -1, $nbrep); } } + else + { + global $website; + + // Replace relative link with dolibarr URL + $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); + $content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + } dol_syslog("dolWebsiteOutput end"); diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 07304f2a464..c9cf66fc6d1 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -33,4 +33,4 @@ PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be serve VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined NoPageYet=No pages yet SyntaxHelp=Help on code syntax -YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.
You can also include content of another Page/Content with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?> +YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.

You can also include content of another Page/Content with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>

To include a link to download a file stored into the documents/medias directory, use syntax:
<a href="/document.php?modulepart=medias&file=filename.ext">. diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index a2dcbfc3dc6..84e0a72f9fd 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -49,6 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; $websitekey=GETPOST('website', 'alpha'); $pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); +$pageref=GETPOST('pageref', 'aZ09')?GETPOST('pageref', 'aZ09'):''; $accessallowed = 1; $type=''; @@ -70,7 +71,8 @@ if (empty($pageid)) $object=new Website($db); $object->fetch(0, $websitekey); - if (empty($object->id)) + + if (empty($object->id)) { if (empty($pageid)) { @@ -84,23 +86,34 @@ if (empty($pageid)) $objectpage=new WebsitePage($db); - if ($object->fk_default_home > 0) + if ($pageref) { - $result=$objectpage->fetch($object->fk_default_home); + $result=$objectpage->fetch(0, $object->id, $pageref); if ($result > 0) - { - $pageid = $objectpage->id; - } + { + $pageid = $objectpage->id; + } } - - if (empty($pageid)) + else { - $array=$objectpage->fetchAll($object->id); - if (is_array($array) && count($array) > 0) - { - $firstrep=reset($array); - $pageid=$firstrep->id; - } + if ($object->fk_default_home > 0) + { + $result=$objectpage->fetch($object->fk_default_home); + if ($result > 0) + { + $pageid = $objectpage->id; + } + } + + if (empty($pageid)) + { + $array=$objectpage->fetchAll($object->id); + if (is_array($array) && count($array) > 0) + { + $firstrep=reset($array); + $pageid=$firstrep->id; + } + } } } if (empty($pageid)) @@ -177,7 +190,7 @@ if (! file_exists($original_file_osencoded)) // Output page content define('USEDOLIBARRSERVER', 1); -print "\n".''."\n"; +print ''."\n"; include_once $original_file_osencoded; diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 7d99678fcb6..60661a1af02 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -181,9 +181,9 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one. found - * @param string $website_id Web site id - * @param string $page Page name + * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one found. + * @param string $website_id Web site id (page name must also be filled if this parameter is used) + * @param string $page Page name (website id must also be filled if this parameter is used) * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -205,12 +205,17 @@ class WebsitePage extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level $sql .= ' WHERE 1 = 1'; - if (null !== $website_id) { - $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; - if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'"; - } else { + if ($id > 0) + { $sql .= ' AND t.rowid = ' . $id; } + else + { + if (null !== $website_id) { + $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'"; + if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'"; + } + } $sql .= $this->db->plimit(1); $resql = $this->db->query($sql); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index d9ea42096c7..1130d760649 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -48,7 +48,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); - print ''; + print ''; // top menu and left menu area if (empty($conf->dol_hide_topmenu)) @@ -89,6 +89,7 @@ $error=0; $website=GETPOST('website', 'alpha'); $page=GETPOST('page', 'alpha'); $pageid=GETPOST('pageid', 'int'); +$pageref=GETPOST('pageref', 'aZ09'); $action=GETPOST('action','alpha'); if (GETPOST('delete')) { $action='delete'; } @@ -123,9 +124,10 @@ if ($website) } if ($pageid < 0) $pageid = 0; -if ($pageid > 0 && $action != 'add') +if (($pageid > 0 || $pageref) && $action != 'add') { - $res = $objectpage->fetch($pageid); + $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); + $pageid = $objectpage->id; } global $dolibarr_main_data_root; @@ -167,6 +169,11 @@ if ($action == 'add') $error++; $action='create'; } + else if (! preg_match('/^[a-z0-9]+$/i', $objectpage->pageurl)) + { + $error++; + setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); + } if (empty($objectpage->title)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); @@ -250,13 +257,16 @@ if ($action == 'updatecss') $res = $object->fetch(0, $website); // Html header file + $htmlheadercontent =''; + /* Not required. htmlheader.html is never call as a standalone page $htmlheadercontent.= '"."\n"; - $htmlheadercontent = ''."\n"; - $htmlheadercontent.= ''."\n"; + */ + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\n"; $htmlheadercontent.= ''."\n"; - $htmlheadercontent.= preg_replace(array('//','/<\/html>/'),array('',''),GETPOST('WEBSITE_HTML_HEADER')); + $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER')); dol_syslog("Save file css into ".$filehtmlheader); @@ -272,11 +282,12 @@ if ($action == 'updatecss') } // Css file + $csscontent =''; $csscontent.= '"."\n"; - $csscontent = '/* BEGIN DOLIBARR-WEBSITE-CSS-ADDED-HEADER */'."\n"; - $csscontent.= '/* File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. */'."\n"; + $csscontent.= '/* BEGIN DOLIBARR-WEBSITE-CSS-ADDED-HEADER */'."\n"; + $csscontent.= '/* File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THE FILE styles.css.php. Change affects all pages of website. */'."\n"; $csscontent.= '/* END */'."\n"; $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); @@ -353,8 +364,22 @@ if ($action == 'updatemeta') $objectpage->fk_website = $object->id; + // Check parameters + if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) + { + $error++; + setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); + $action='editmeta'; + } + $res = $objectpage->fetch($pageid, $object->fk_website); - if ($res > 0) + if ($res <= 0) + { + $error++; + dol_print_error($db, 'Page not found'); + } + + if (! $error) { $objectpage->old_object = clone $objectpage; @@ -388,7 +413,8 @@ if ($action == 'updatemeta') $mastercontent = ''."\n"; $result = file_put_contents($filemaster, $mastercontent); if (! empty($conf->global->MAIN_UMASK)) @@ -435,7 +461,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; @@ -462,10 +488,6 @@ if ($action == 'updatemeta') $db->rollback(); } } - else - { - dol_print_error($db, 'Page not found'); - } } // Update page @@ -594,7 +616,7 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; @@ -803,7 +825,7 @@ if (count($object->records) > 0) if ($action != 'add') { $out=''; - $out.=''; if ($atleastonepage) { if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one @@ -822,7 +844,7 @@ if (count($object->records) > 0) $out.=''; } @@ -848,8 +870,8 @@ if (count($object->records) > 0) { print '   '; - print ''; print ''; + print ''; if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; @@ -865,7 +887,7 @@ if (count($object->records) > 0) $websitepage = new WebSitePage($db); $websitepage->fetch($pageid); - $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; + $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; print '
'; @@ -876,7 +898,7 @@ if (count($object->records) > 0) $urlext=$virtualurl.'/'.$pagealias.'.php'; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); print ''; @@ -972,18 +994,18 @@ if ($action == 'editcss') $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part - $csscontent = preg_replace('/^<\?php[^\?]+\?>/ims', '', $csscontent); + $csscontent = preg_replace('/^<\?php[^\?]+\?>\n*/ims', '', $csscontent); $csscontent = preg_replace('/\/\* BEGIN DOLIBARR.*END \*\/\n*/ims', '', $csscontent); - if (! trim($csscontent)) $csscontent='/* CSS content (all website) */'."\n".'body { margin: 0; }'; + if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n".'body.bodywebsite { margin: 0; }'; $htmlheader = @file_get_contents($filehtmlheader); // Clean the php htmlheader file to remove php code and get only html part - $htmlheader = preg_replace('/^<\?php[^\?]+\?>/ims', '', $htmlheader); + $htmlheader = preg_replace('/^<\?php[^\?]+\?>\n*/ims', '', $htmlheader); $htmlheader = preg_replace('/\n*/ims', '', $htmlheader); - if (! trim($htmlheader)) $htmlheader=''; + if (! trim($htmlheader)) $htmlheader=''; else $htmlheader=''.$htmlheader.''; dol_fiche_head(); @@ -1136,11 +1158,12 @@ if ($action == 'preview') { if ($pageid > 0) { + // Ouput page under the Dolibarr top menu $objectpage->fetch($pageid); - $out = "\n".''."\n"; + $out = ''."\n"; - $out.='
'."\n"; + $out.='
'."\n"; $csscontent = @file_get_contents($filecss); @@ -1148,11 +1171,18 @@ if ($action == 'preview') $out.=$csscontent; $out.=''."\n"; - // Replace php code + $out.='
'."\n"; + + // Replace php code. Note $objectpage->content come from database and does not contains body tags. $content = preg_replace('/<\?php.*\?>/ims', '...php...', $objectpage->content); + // Replace internal relative links with Dolibarr links + // TODO + + $out.=$content."\n"; + $out.='
'; $out.='
'; $out.= "\n".''."\n\n"; From 302ee97d3137c71a06146ef76c0a0a8f10def664 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 02:36:10 +0200 Subject: [PATCH 039/130] Debug module website --- htdocs/core/lib/website.lib.php | 3 ++- htdocs/langs/en_US/website.lang | 8 ++++---- htdocs/websites/index.php | 6 ++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index d5d4f2d3826..9bf00e8d6e3 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -62,8 +62,9 @@ function dolWebsiteOutput($content) { global $website; - // Replace relative link with dolibarr URL + // Replace relative link / with dolibarr URL $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); + // Replace relative link /xxx.php with dolibarr URL $content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); } diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index c9cf66fc6d1..aeff9078d0f 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -19,9 +19,9 @@ AddPage=Add page HomePage=Home Page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this. -PageContent=Page/Content -PageDeleted=Page/Content '%s' of website %s deleted -PageAdded=Page/Content '%s' added +PageContent=Page/Contenair +PageDeleted=Page/Contenair '%s' of website %s deleted +PageAdded=Page/Contenair '%s' added ViewSiteInNewTab=View site in new tab ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page @@ -33,4 +33,4 @@ PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be serve VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined NoPageYet=No pages yet SyntaxHelp=Help on code syntax -YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.

You can also include content of another Page/Content with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>

To include a link to download a file stored into the documents/medias directory, use syntax:
<a href="/document.php?modulepart=medias&file=filename.ext">. +YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.

You can also include content of another Page/Container with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>

To include a link to download a file stored into the documents/medias directory, use syntax:
<a href="/document.php?modulepart=medias&file=filename.ext">. diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 1130d760649..a576a00e025 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -1176,8 +1176,10 @@ if ($action == 'preview') // Replace php code. Note $objectpage->content come from database and does not contains body tags. $content = preg_replace('/<\?php.*\?>/ims', '...php...', $objectpage->content); - // Replace internal relative links with Dolibarr links - // TODO + // Replace relative link / with dolibarr URL + $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$object->ref.'&pageid='.$object->fk_default_home.'"', $content, -1, $nbrep); + // Replace relative link /xxx.php with dolibarr URL + $content = preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$object->ref.'&pageref=\2"', $content, -1, $nbrep); $out.=$content."\n"; From 48d79357a0d6b7463cca5786f80bc660bcb5f1b3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 21 Jul 2017 10:03:09 +0200 Subject: [PATCH 040/130] New: add specific translation for title of documents --- .../commande/doc/pdf_einstein.modules.php | 34 ++++++------ .../modules/facture/doc/pdf_crabe.modules.php | 54 +++++++++---------- .../modules/propale/doc/pdf_azur.modules.php | 30 +++++------ htdocs/langs/en_US/bills.lang | 1 + htdocs/langs/en_US/orders.lang | 1 + htdocs/langs/en_US/propal.lang | 1 + 6 files changed, 62 insertions(+), 59 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 396ac54e9b5..a3ae305549d 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -45,28 +45,28 @@ class pdf_einstein extends ModelePDFCommandes * @var DoliDb Database handler */ public $db; - + /** * @var string model name */ public $name; - + /** * @var string model description (short text) */ public $description; - + /** * @var string document type */ public $type; - + /** * @var array() Minimum version of PHP required by module. * e.g.: PHP ≥ 5.3 = array(5, 3) */ - public $phpmin = array(5, 2); - + public $phpmin = array(5, 2); + /** * Dolibarr version of the loaded document * @public string @@ -240,11 +240,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -263,10 +263,10 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -317,16 +317,16 @@ class pdf_einstein extends ModelePDFCommandes $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } } - + // Affiche notes $notetoshow=empty($object->note_public)?'':$object->note_public; if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) @@ -478,7 +478,7 @@ class pdf_einstein extends ModelePDFCommandes // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -585,7 +585,7 @@ class pdf_einstein extends ModelePDFCommandes $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } */ - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -1201,7 +1201,7 @@ class pdf_einstein extends ModelePDFCommandes * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="Order") + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle") { global $conf,$langs,$hookmanager; @@ -1294,7 +1294,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=2; // Show list of linked objects diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 0de3a8df3d7..03bfe9e8112 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -255,16 +255,16 @@ class pdf_crabe extends ModelePDFFactures // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); $nbpayments = count($object->getListOfPayments()); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -284,10 +284,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Invoice")); + $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -509,7 +509,7 @@ class pdf_crabe extends ModelePDFFactures $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars - + if ($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R'); @@ -769,7 +769,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 4); - + // Loop on each deposits and credit notes included $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; @@ -822,7 +822,7 @@ class pdf_crabe extends ModelePDFFactures $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; $sql.= " ORDER BY p.datep"; - + $resql=$this->db->query($sql); if ($resql) { @@ -1052,7 +1052,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); @@ -1071,7 +1071,7 @@ class pdf_crabe extends ModelePDFFactures else { // FIXME amount of vat not supported with multicurrency - + //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1141,26 +1141,26 @@ class pdf_crabe extends ModelePDFFactures } //} - + // VAT // Situations totals migth be wrong on huge amounts if ($object->situation_cycle_ref && $object->situation_counter > 1) { - + $sum_pdf_tva = 0; foreach($this->tva as $tvakey => $tvaval){ $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object } - + if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) $coef_fix_tva = $object->total_tva / $sum_pdf_tva; - + foreach($this->tva as $tvakey => $tvaval) { $this->tva[$tvakey]=$tvaval * $coef_fix_tva; } } - + } - + foreach($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 @@ -1416,7 +1416,7 @@ class pdf_crabe extends ModelePDFFactures if (empty($hidetop)) { $pdf->SetXY($this->posxqty-1, $tab_top+1); - + if($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); @@ -1430,14 +1430,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } } - + if ($this->situationinvoice) { $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height); - + if (empty($hidetop)) { - + $pdf->SetXY($this->posxprogress, $tab_top+1); - + if($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); @@ -1450,9 +1450,9 @@ class pdf_crabe extends ModelePDFFactures { $pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); } - + } - + } if($conf->global->PRODUCT_USE_UNITS) { @@ -1559,7 +1559,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $title=$outputlangs->transnoentities("Invoice"); + $title=$outputlangs->transnoentities("PdfInvoiceTitle"); if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); @@ -1573,7 +1573,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref); - if ($object->statut == Facture::STATUS_DRAFT) + if ($object->statut == Facture::STATUS_DRAFT) { $pdf->SetTextColor(128,0,0); $textref.=' - '.$outputlangs->trans("NotValidated"); @@ -1635,7 +1635,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R'); } - + if ($object->type != 2) { $posy+=3; @@ -1666,7 +1666,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=1; // Show list of linked objects diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 3eb284ec7fc..250796dd9d5 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -273,7 +273,7 @@ class pdf_azur extends ModelePDFPropales $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -292,10 +292,10 @@ class pdf_azur extends ModelePDFPropales $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); + $pdf->SetSubject($outputlangs->transnoentities("PdfCommercialProposalTitle")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -322,19 +322,19 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0; $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; - + //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); - + $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); $tab_height = 130; @@ -383,7 +383,7 @@ class pdf_azur extends ModelePDFPropales $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs); if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; - } + } if ($notetoshow) { $tab_top = 88 + $height_incoterms; @@ -452,7 +452,7 @@ class pdf_azur extends ModelePDFPropales $curX = $this->posxdesc-1; $showpricebeforepagebreak=1; - + $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); @@ -554,14 +554,14 @@ class pdf_azur extends ModelePDFPropales // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; $localtax2_rate=$object->lines[$i]->localtax2_tx; $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; - + $localtax2_type=$object->lines[$i]->localtax2_type; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; @@ -669,7 +669,7 @@ class pdf_azur extends ModelePDFPropales { $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs); } - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -1428,7 +1428,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('','B',$default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $title=$outputlangs->transnoentities("CommercialProposal"); + $title=$outputlangs->transnoentities("PdfCommercialProposalTitle"); $pdf->MultiCell(100, 4, $title, '', 'R'); $pdf->SetFont('','B',$default_font_size); @@ -1481,7 +1481,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=2; // Show list of linked objects diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 189ef5c1fe2..03ddb1f958e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -45,6 +45,7 @@ InvoiceHasAvoir=Was source of one or several credit notes CardBill=Invoice card PredefinedInvoices=Predefined Invoices Invoice=Invoice +PdfInvoiceTitle=Invoice Invoices=Invoices InvoiceLine=Invoice line InvoiceCustomer=Customer invoice diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 363fb504a5b..07d7268a8f0 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -4,6 +4,7 @@ SuppliersOrdersArea=Suppliers orders area OrderCard=Order card OrderId=Order Id Order=Order +PdfOrderTitle=Order Orders=Orders OrderLine=Order line OrderDate=Order date diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index aefe8e89cd2..61a8d4ff99c 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -6,6 +6,7 @@ ProposalsDraft=Draft commercial proposals ProposalsOpened=Open commercial proposals Prop=Commercial proposals CommercialProposal=Commercial proposal +PdfCommercialProposalTitle=Commercial proposal ProposalCard=Proposal card NewProp=New commercial proposal NewPropal=New proposal From 827e04f130036683c5b32ec081d55270e914c130 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 11:58:55 +0200 Subject: [PATCH 041/130] Fix missing css --- htdocs/websites/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index a576a00e025..a2e867bfd15 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -465,7 +465,8 @@ if ($action == 'updatemeta') $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= $objectpage->content."\n"; $tplcontent.= ''."\n"; //var_dump($filetpl);exit; From a6960187f4657de7de53ca6536cfffaab51c1777 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 12:01:16 +0200 Subject: [PATCH 042/130] Fix missing css --- htdocs/websites/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index a2e867bfd15..1cc8fffaa20 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -621,7 +621,8 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= $objectpage->content."\n"; $tplcontent.= ''."\n"; From 23d9353a3dd3a2f6878eb40b6010299c826916e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 12:21:48 +0200 Subject: [PATCH 043/130] Fix title in html header --- htdocs/core/lib/functions.lib.php | 6 ++++-- htdocs/websites/index.php | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index fae3c4eae5e..1bd2b770d1a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -806,17 +806,19 @@ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) * @param string $stringtoescape String to escape * @param int $keepb 1=Preserve b tags (otherwise, remove them) * @param int $keepn 1=Preserve \r\n strings (otherwise, remove them) + * @param int $onlytags Only special chars like (", &, >, > ...) are replaced, not all chars that has an existing entity. * @return string Escaped string * * @see dol_string_nohtmltag */ -function dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0) +function dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $onlytags=0) { // escape quotes and backslashes, newlines, etc. $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); if (! $keepb) $tmp=strtr($tmp, array(""=>'',''=>'')); if (! $keepn) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); - return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); + if ($onlytags) return htmlspecialchars($tmp,ENT_COMPAT,'UTF-8'); + else return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 1cc8fffaa20..de292128ef5 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -450,15 +450,16 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title, 0, 0, 1).''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -607,14 +608,15 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite $tplcontent.= "// END PHP ?>\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title, 0, 0, 1).''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; From 058e88c6f3558b2d3aa4e7a7a6e8afc05d6b5240 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 12:26:11 +0200 Subject: [PATCH 044/130] Fix title in html header --- htdocs/core/lib/functions.lib.php | 6 ++---- htdocs/websites/index.php | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1bd2b770d1a..fae3c4eae5e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -806,19 +806,17 @@ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) * @param string $stringtoescape String to escape * @param int $keepb 1=Preserve b tags (otherwise, remove them) * @param int $keepn 1=Preserve \r\n strings (otherwise, remove them) - * @param int $onlytags Only special chars like (", &, >, > ...) are replaced, not all chars that has an existing entity. * @return string Escaped string * * @see dol_string_nohtmltag */ -function dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $onlytags=0) +function dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0) { // escape quotes and backslashes, newlines, etc. $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); if (! $keepb) $tmp=strtr($tmp, array(""=>'',''=>'')); if (! $keepn) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); - if ($onlytags) return htmlspecialchars($tmp,ENT_COMPAT,'UTF-8'); - else return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); + return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index de292128ef5..6d1b61975ed 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -450,15 +450,15 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title, 0, 0, 1).''."\n"; + $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -608,14 +608,14 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite $tplcontent.= "// END PHP ?>\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title, 0, 0, 1).''."\n"; + $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; From 168f167934a3e8d52f2966abb608d48e4a25b9d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 12:42:21 +0200 Subject: [PATCH 045/130] Tooltip --- htdocs/admin/websites.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index f4eddfbf092..e25878b3aaa 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -438,7 +438,11 @@ if ($id) { print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).''; - else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); + elseif (! empty($tabhelp[$id][$value])) + { + if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual'); + else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + } else print $valuetoshow; print ''; } From 374e46af0039da970258005cb39a412f2331bdf5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 12:53:15 +0200 Subject: [PATCH 046/130] Fix ducplicate code --- htdocs/websites/index.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 6d1b61975ed..62bdb6c5657 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -446,8 +446,15 @@ if ($action == 'updatemeta') dol_delete_file($filetpl); + // TODO Same code than into updatecontent $tplcontent =''; - $tplcontent.= ''."\n"; + $tplcontent.= "\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n"; @@ -598,7 +605,8 @@ if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite // Now create the .tpl file with code to be able to make dynamic changes dol_delete_file($filetpl); - $tplcontent =''; + // TODO Same code than into updatemeta + $tplcontent =''; $tplcontent.= " Date: Fri, 21 Jul 2017 12:55:50 +0200 Subject: [PATCH 047/130] Fix ducplicate code --- htdocs/websites/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 62bdb6c5657..437f91f2203 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -477,6 +477,11 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= $objectpage->content."\n"; $tplcontent.= ''."\n"; + + $tplcontent.= '"."\n"; + //var_dump($filetpl);exit; $result = file_put_contents($filetpl, $tplcontent); if (! empty($conf->global->MAIN_UMASK)) From aacef21cb80b77c5b84ec93388fd6e95fe647de7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 13:38:13 +0200 Subject: [PATCH 048/130] Can clone a page --- .../install/mysql/migration/6.0.0-7.0.0.sql | 2 ++ .../install/mysql/tables/llx_website_page.sql | 2 +- htdocs/langs/en_US/website.lang | 2 +- htdocs/websites/class/websitepage.class.php | 19 ++++++++------- htdocs/websites/index.php | 24 +++++++++++++++++-- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 43c2b813536..8e87f3e6bba 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -28,4 +28,6 @@ ALTER TABLE llx_facture_fourn ADD COLUMN date_pointoftax date DEFAULT NULL; ALTER TABLE llx_facture_fourn ADD COLUMN date_valid date; +ALTER TABLE llx_website_page MODIFY COLUMN pageurl varchar(255); + diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql index 69b6c417528..ff7cbb47a16 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_website_page ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, fk_website integer NOT NULL, - pageurl varchar(16) NOT NULL, + pageurl varchar(255) NOT NULL, title varchar(255), description varchar(255), keywords varchar(255), diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index aeff9078d0f..41418ab5eae 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -9,7 +9,7 @@ WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS content PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. MediaFiles=Media library -EditCss=Edit Style/CSS +EditCss=Edit Style/CSS or HTML header EditMenu=Edit menu EditPageMeta=Edit Meta EditPageContent=Edit Content diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 60661a1af02..d313905a3bc 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -482,17 +482,17 @@ class WebsitePage extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ public function createFromClone($fromid) { + global $user, $langs; + dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; - $object = new Websitepage($this->db); + $object = new self($this->db); $this->db->begin(); @@ -502,14 +502,17 @@ class WebsitePage extends CommonObject $object->id = 0; // Clear fields - // ... + $object->ref = 'copy_of_'.$object->ref; + $object->pageurl = 'copy_of_'.$object->pageurl; + $object->title = $langs->trans("CopyOf").' '.$object->title; // Create clone $result = $object->create($user); // Other options if ($result < 0) { - $error ++; + $error++; + $this->error = $object->error; $this->errors = $object->errors; dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } @@ -522,7 +525,7 @@ class WebsitePage extends CommonObject } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 437f91f2203..e723f9312c0 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -101,6 +101,8 @@ if (GETPOST('editmenu')) { $action='editmenu'; } if (GETPOST('setashome')) { $action='setashome'; } if (GETPOST('editmeta')) { $action='editmeta'; } if (GETPOST('editcontent')) { $action='editcontent'; } +if (GETPOST('createfromclone')) { $action='createfromclone'; } +if (GETPOST('createpagefromclone')) { $action='createpagefromclone'; } if (empty($action)) $action='preview'; @@ -505,10 +507,22 @@ if ($action == 'updatemeta') } // Update page -if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')))) +if (($action == 'updatecontent' || $action == 'createpagefromclone') + || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')))) { $object->fetch(0, $website); + if ($action == 'createpagefromclone') + { + $objectpage = new WebsitePage($db); + $result = $objectpage->createFromClone($pageid); + if ($result < 0) + { + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + $action='preview'; + } + } + // Check symlink to medias and restore it if ko $pathtomedias=DOL_DATA_ROOT.'/medias'; $pathtomediasinwebsite=$pathofwebsite.'/medias'; @@ -785,7 +799,7 @@ if (count($object->records) > 0) //print ''; print ''; print ''; - print ''; + //print ''; } print '
'; @@ -834,6 +848,11 @@ if (count($object->records) > 0) $atleastonepage=(is_array($array) && count($array) > 0); print '
'; + + print '
'; + print ''; + print '
'; + print '
'; print $langs->trans("Page").': '; print '
'; @@ -891,6 +910,7 @@ if (count($object->records) > 0) print ''; if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; + print ''; print ''; } } From 6830fe4f91163ec3c10b59d94428d085ce9dcd32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 13:38:49 +0200 Subject: [PATCH 049/130] Fix generic clone function --- htdocs/core/class/commonobject.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ddfb2780f3f..f1ec086cd03 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5023,7 +5023,7 @@ abstract class CommonObject */ public function createFromCloneCommon(User $user, $fromid) { - global $user; + global $user, $langs; $error = 0; @@ -5039,6 +5039,8 @@ abstract class CommonObject $object->id = 0; // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; // ... // Create clone @@ -5046,7 +5048,8 @@ abstract class CommonObject // Other options if ($result < 0) { - $error ++; + $error++; + $this->error = $object->error; $this->errors = $object->errors; dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); } From 27682d9ef3c0c21d4e6dc6f46212682b54b228e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 14:52:54 +0200 Subject: [PATCH 050/130] Update rib.php --- htdocs/societe/rib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 21a415f2268..09ee533004c 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -872,7 +872,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // RUM print ''.$langs->trans("RUM").''; - print '
'.$langs->trans("RUMWillBeGenerated").''; + print '
'.$langs->trans("RUMWillBeGenerated").''; // FRSTRECUR print ''.$langs->trans("WithdrawMode").''; From 5965bec5013d34a5e57993e2a99db35f9b13e8f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 15:06:53 +0200 Subject: [PATCH 051/130] Update multicurrency.php --- htdocs/admin/multicurrency.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index c8a04985b84..16214ccb066 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -100,7 +100,7 @@ elseif ($action == 'update_currency') if ($submit == $langs->trans('Modify')) { $fk_multicurrency = GETPOST('fk_multicurrency', 'int'); - $rate = GETPOST('rate', 'int'); + $rate = price2num(GETPOST('rate', 'alpha')); $currency = new MultiCurrency($db); if ($currency->fetch($fk_multicurrency) > 0) From b9df364fbeb56d10874cd4decf86ba108c35e3e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 17:55:43 +0200 Subject: [PATCH 052/130] Fix include --- htdocs/websites/index.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index e723f9312c0..895627cf9f5 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -414,7 +414,7 @@ if ($action == 'updatemeta') $mastercontent = ''."\n"; @@ -432,11 +432,12 @@ if ($action == 'updatemeta') dol_delete_file($fileoldalias); } - $aliascontent = 'id.".tpl.php';\n"; - $aliascontent.= '?>'."\n"; - $result = file_put_contents($filealias, $aliascontent); + $aliascontent = 'ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; + $aliascontent.= '?>'."\n"; + $result = file_put_contents($filealias, $aliascontent); if (! empty($conf->global->MAIN_UMASK)) @chmod($filealias, octdec($conf->global->MAIN_UMASK)); @@ -452,7 +453,7 @@ if ($action == 'updatemeta') $tplcontent =''; $tplcontent.= "'."\n"; $result = file_put_contents($filemaster, $mastercontent); if (! empty($conf->global->MAIN_UMASK)) @@ -612,7 +613,8 @@ if (($action == 'updatecontent' || $action == 'createpagefromclone') $aliascontent = 'id.".tpl.php';\n"; + $aliascontent.= 'global $dolibarr_main_data_root;'."\n"; + $aliascontent.= 'require $dolibarr_main_data_root.\'/websites/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; $aliascontent.= '?>'."\n"; $result = file_put_contents($filealias, $aliascontent); if (! empty($conf->global->MAIN_UMASK)) @@ -628,7 +630,7 @@ if (($action == 'updatecontent' || $action == 'createpagefromclone') $tplcontent =''; $tplcontent.= " Date: Fri, 21 Jul 2017 18:33:45 +0200 Subject: [PATCH 053/130] Work on website module --- htdocs/websites/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 895627cf9f5..8bf42c7d530 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -435,7 +435,8 @@ if ($action == 'updatemeta') $aliascontent = 'ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; + $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\';'; + $aliascontent.= 'else require $dolibarr_main_data_root.\'/websites/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; $aliascontent.= '?>'."\n"; $result = file_put_contents($filealias, $aliascontent); if (! empty($conf->global->MAIN_UMASK)) @@ -614,7 +615,8 @@ if (($action == 'updatecontent' || $action == 'createpagefromclone') $aliascontent = 'ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; + $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\';'; + $aliascontent.= 'else require $dolibarr_main_data_root.\'/websites/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; $aliascontent.= '?>'."\n"; $result = file_put_contents($filealias, $aliascontent); if (! empty($conf->global->MAIN_UMASK)) From 2514c02817b51b3026b48e0cfea5874034d115b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 19:01:06 +0200 Subject: [PATCH 054/130] Fix when there is several php part in same page --- htdocs/langs/en_US/website.lang | 4 ++-- htdocs/websites/index.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 41418ab5eae..151ac85d532 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -14,8 +14,8 @@ EditMenu=Edit menu EditPageMeta=Edit Meta EditPageContent=Edit Content Website=Web site -Webpage=Web page -AddPage=Add page +Webpage=Web page/container +AddPage=Add page/container HomePage=Home Page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this. diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 8bf42c7d530..cda5d0ee836 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -1215,7 +1215,7 @@ if ($action == 'preview') $out.='
'."\n"; // Replace php code. Note $objectpage->content come from database and does not contains body tags. - $content = preg_replace('/<\?php.*\?>/ims', '...php...', $objectpage->content); + $content = preg_replace('/<\?php[^\?]+\?>\n*/ims', '...php...', $objectpage->content); // Replace relative link / with dolibarr URL $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$object->ref.'&pageid='.$object->fk_default_home.'"', $content, -1, $nbrep); From 2e63393bf237d142066a9e92cae150a555a291e4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 21 Jul 2017 19:35:08 +0200 Subject: [PATCH 055/130] Fix: wrong values if array used to force entity 0 --- htdocs/core/modules/DolibarrModules.class.php | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index d682aa2db97..f98357bb698 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -48,22 +48,22 @@ class DolibarrModules // Can not be abstract, because we need to insta * @var string Publisher name */ public $editor_name; - + /** * @var string URL of module at publisher site */ - public $editor_web; - + public $editor_web; + /** * @var string Family */ public $family; - + /** * @var int module_position */ public $module_position=500; - + /** * @var string Module name */ @@ -171,7 +171,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * @var string Module description (long text) */ public $descriptionlong; - + /** * @var string[] Module language files */ @@ -211,7 +211,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * @var bool Module is enabled globally (Multicompany support) */ public $core_enabled; - + /** * @var string Relative path to module style sheet * @deprecated @@ -219,8 +219,8 @@ class DolibarrModules // Can not be abstract, because we need to insta */ public $style_sheet = ''; - - + + /** * Constructor. Define names, constants, directories, boxes, permissions * @@ -468,9 +468,9 @@ class DolibarrModules // Can not be abstract, because we need to insta { global $langs; $langs->load("admin"); - + if (empty($this->descriptionlong)) return ''; - + // If module description translation does not exist using its unique id, we can use its name to find translation if (is_array($this->langfiles)) { @@ -481,7 +481,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } return $langs->trans($this->descriptionlong); } - + /** * Gives the publisher name * @@ -491,7 +491,7 @@ class DolibarrModules // Can not be abstract, because we need to insta { return $this->editor_name; } - + /** * Gives the publisher url * @@ -501,7 +501,7 @@ class DolibarrModules // Can not be abstract, because we need to insta { return $this->editor_url; } - + /** * Gives module version (translated if param $translated is on) * For 'experimental' modules, gives 'experimental' translation @@ -705,7 +705,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data') { @@ -723,7 +723,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data') { @@ -741,7 +741,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'data') { @@ -759,7 +759,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,6) == 'update') { @@ -899,19 +899,19 @@ class DolibarrModules // Can not be abstract, because we need to insta //$titre = $this->boxes[$key][0]; $file = $this->boxes[$key]['file']; //$note = $this->boxes[$key][2]; - + // TODO If the box is also included by another module and the other module is still on, we should not remove it. // For the moment, we manage this with hard coded exception //print "Remove box ".$file.'
'; if ($file == 'box_graph_product_distribution.php') { - if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) + if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) { dol_syslog("We discard disabling of module ".$file." because another module still active require it."); continue; } } - + if (empty($file)) $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; // For backward compatibility if ($this->db->type == 'sqlite3') { @@ -986,7 +986,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $status = isset($this->cronjobs[$key]['status'])?$this->cronjobs[$key]['status']:''; $priority = isset($this->cronjobs[$key]['priority'])?$this->cronjobs[$key]['priority']:''; $test = isset($this->cronjobs[$key]['test'])?$this->cronjobs[$key]['test']:''; // Line must be visible - + // Search if boxes def already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; $sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'"; @@ -1124,55 +1124,55 @@ class DolibarrModules // Can not be abstract, because we need to insta * * @return int Error count (0 if ok) */ - function insert_tabs() - { - global $conf; + function insert_tabs() + { + global $conf; - $err=0; + $err=0; - if (! empty($this->tabs)) - { - $i=0; - foreach ($this->tabs as $key => $value) - { - if (is_array($value) && count($value) == 0) continue; // Discard empty arrays + if (! empty($this->tabs)) + { + $i=0; + foreach ($this->tabs as $key => $value) + { + if (is_array($value) && count($value) == 0) continue; // Discard empty arrays - $entity=$conf->entity; - $newvalue = $value; + $entity=$conf->entity; + $newvalue = $value; - if (is_array($value)) - { - $newvalue = $value['data']; - if (isset($value['entity'])) $entity = $value['entity']; - } + if (is_array($value)) + { + $newvalue = $value['data']; + if (isset($value['entity'])) $entity = $value['entity']; + } - if ($newvalue) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; - $sql.= "name"; - $sql.= ", type"; - $sql.= ", value"; - $sql.= ", note"; - $sql.= ", visible"; - $sql.= ", entity"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= $this->db->encrypt($this->const_name."_TABS_".$i,1); - $sql.= ", 'chaine'"; - $sql.= ", ".$this->db->encrypt($value,1); - $sql.= ", null"; - $sql.= ", '0'"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + if ($newvalue) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; + $sql.= "name"; + $sql.= ", type"; + $sql.= ", value"; + $sql.= ", note"; + $sql.= ", visible"; + $sql.= ", entity"; + $sql.= ")"; + $sql.= " VALUES ("; + $sql.= $this->db->encrypt($this->const_name."_TABS_".$i,1); + $sql.= ", 'chaine'"; + $sql.= ", ".$this->db->encrypt($newvalue,1); + $sql.= ", null"; + $sql.= ", '0'"; + $sql.= ", ".$entity; + $sql.= ")"; - dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); - $this->db->query($sql); - } - $i++; - } - } - return $err; - } + dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); + $this->db->query($sql); + } + $i++; + } + } + return $err; + } /** * Adds constants From f97ecd0a45e7e64424f262b7fd8b038faf18bd87 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2017 20:16:53 +0200 Subject: [PATCH 056/130] The css files is also parsed with function to clean images --- htdocs/core/lib/website.lib.php | 1 + htdocs/langs/en_US/website.lang | 2 ++ htdocs/websites/index.php | 59 +++++++++++++++++++-------------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 9bf00e8d6e3..354da07c6f2 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -56,6 +56,7 @@ function dolWebsiteOutput($content) else { $content=preg_replace('/()/', '\1medias/\4\5', $content, -1, $nbrep); + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep); } } else diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 151ac85d532..3b29f51e29d 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -34,3 +34,5 @@ VirtualHostUrlNotDefined=URL of the virtual host served by external web server n NoPageYet=No pages yet SyntaxHelp=Help on code syntax YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.

You can also include content of another Page/Container with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>

To include a link to download a file stored into the documents/medias directory, use syntax:
<a href="/document.php?modulepart=medias&file=filename.ext">. +ClonePage=Clone page/container +CloneSite=Clone site \ No newline at end of file diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index cda5d0ee836..0ae1902613c 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -260,16 +260,22 @@ if ($action == 'updatecss') // Html header file $htmlheadercontent =''; - /* Not required. htmlheader.html is never call as a standalone page - $htmlheadercontent.= '"."\n"; - */ - $htmlheadercontent.= ''."\n"; - $htmlheadercontent.= ''."\n"; - $htmlheadercontent.= ''."\n"; + + $htmlheadercontent.= "\n"; + $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER')); + $htmlheadercontent.= "\n".'"."\n"; + dol_syslog("Save file css into ".$filehtmlheader); dol_mkdir($pathofwebsite); @@ -285,14 +291,23 @@ if ($action == 'updatecss') // Css file $csscontent =''; - $csscontent.= '"."\n"; - $csscontent.= '/* BEGIN DOLIBARR-WEBSITE-CSS-ADDED-HEADER */'."\n"; - $csscontent.= '/* File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THE FILE styles.css.php. Change affects all pages of website. */'."\n"; - $csscontent.= '/* END */'."\n"; + $csscontent.= "// END PHP ?>\n"; + $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); + $csscontent.= "\n".'"."\n"; + + dol_syslog("Save file css into ".$filecss); dol_mkdir($pathofwebsite); @@ -1035,19 +1050,19 @@ if ($action == 'editcss') $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part - $csscontent = preg_replace('/^<\?php[^\?]+\?>\n*/ims', '', $csscontent); - $csscontent = preg_replace('/\/\* BEGIN DOLIBARR.*END \*\/\n*/ims', '', $csscontent); + $csscontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $csscontent); + + $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n".'body.bodywebsite { margin: 0; }'; $htmlheader = @file_get_contents($filehtmlheader); // Clean the php htmlheader file to remove php code and get only html part - $htmlheader = preg_replace('/^<\?php[^\?]+\?>\n*/ims', '', $htmlheader); - $htmlheader = preg_replace('/\n*/ims', '', $htmlheader); + $htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $htmlheader); - if (! trim($htmlheader)) $htmlheader=''; - else $htmlheader=''.$htmlheader.''; + if (! trim($htmlheader)) $htmlheader=''."\n".''."\n".''; + else $htmlheader=''."\n".$htmlheader."\n".''; dol_fiche_head(); @@ -1084,12 +1099,6 @@ if ($action == 'editcss') print '';*/ print ''; - /*print ''; - print $langs->trans('WEBSITE_CSS_URL'); - print ''; - print ''; - print '';*/ - print ''; dol_fiche_end(); From f64a9968a9d96a851de1109ccd60ab8e887c623f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 01:00:43 +0200 Subject: [PATCH 057/130] Debug modulebuilder --- htdocs/core/lib/files.lib.php | 21 +++++++++- htdocs/core/lib/modulebuilder.lib.php | 2 + htdocs/langs/en_US/modulebuilder.lang | 2 +- htdocs/modulebuilder/index.php | 40 +++++++++++++++++++ .../template/class/myobject.class.php | 12 +++--- .../core/modules/modMyModule.class.php | 10 ++--- .../modulebuilder/template/myobject_list.php | 3 +- 7 files changed, 74 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 77502f1737c..6711ed2825f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -448,12 +448,12 @@ function dol_filemtime($pathoffile) * Make replacement of strings into a file. * * @param string $srcfile Source file (can't be a directory) - * @param array $arrayreplacement Array with strings to replace + * @param array $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...) * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. * @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' * @param int $indexdatabase Index new file into database. * @return int <0 if error, 0 if nothing done (dest file already exists), >0 if OK - * @see dolCopyr + * @see dolCopyr dolReplaceRegExInFile */ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0) { @@ -514,6 +514,23 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, return 1; } +/** + * Make replacement of strings into a file. + * + * @param string $srcfile Source file (can't be a directory) + * @param array $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...) + * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. + * @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' + * @param int $indexdatabase Index new file into database. + * @return int <0 if error, 0 if nothing done (dest file already exists), >0 if OK + * @see dolCopyr dolReplaceInFile + */ +function dolReplaceRegExInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0) +{ + // TODO + +} + /** * Copy a file to another file. * diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index af9ab67d8fe..0741dcef978 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -77,6 +77,8 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask) $i++; $typephp=''; $texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; + $texttoinsert.= " 'visible'=>".$val['visible'].","; + $texttoinsert.= " 'enabled'=>".$val['enabled'].","; if ($val['position']) $texttoinsert.= " 'position'=>".$val['position'].","; if ($val['notnull']) $texttoinsert.= " 'notnull'=>".$val['notnull'].","; if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].","; diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 9a7fbb7b3bc..a3ba8a7455b 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -13,7 +13,7 @@ FilesForObjectInitialized=Files for new object '%s' initialized FilesForObjectUpdated=Files for object '%s' updated (.sql files and .class.php file) ModuleBuilderDescdescription=Enter here all general information that describe your module ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have within easy reach all the rules to develop. Also this text content will be included into the generated documentation (see last tab). You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) -ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. +ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A CRUD DAO class, SQL files, page to list record of objects, to create/edit/view a record and an API will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 4afaf136e19..18d543c7933 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -217,6 +217,46 @@ if ($dirins && $action == 'initobject' && $module && $objectname) else { // Copy is ok + if ($destfile == 'class/'.$objectname.'.txt') + { + // Regenerate left menu entry in descriptor + $stringtoadd=''; + // TODO Loop on each .txt file in class dir. + $stringtoadd.=" +\t\t\$this->menu[\$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject', + 'url'=>'/mymodule/myobject_list.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1100+\$r, + 'enabled'=>'\$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both +\t\t\$this->menu[\$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule_myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject', + 'url'=>'/mymodule/myobject_card.php?action=create', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1100+\$r, + 'enabled'=>'\$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + "; + $moduledescriptorfile=$dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + // TODO Allow a replace with regex using dolReplaceRegexInFile + dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); + + // Add module descriptor to list of files to replace "MyObject' string with real name of object. + $filetogenerate[]='core/modules/mod'.$module.'.class.php'; + } } } } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f8882b68c56..a68e0ff0da5 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -63,12 +63,12 @@ class MyObject extends CommonObject * @var array Array with all fields and their property */ public $fields=array( - 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'position'=>10, 'notnull'=>true, 'index'=>true, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity'=>array('type'=>'integer', 'label'=>'Entity', 'notnull'=>true, 'index'=>true), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'searchall'=>1), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'notnull'=>true, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'notnull'=>true, 'position'=>500), - 'status'=>array('type'=>'integer', 'label'=>'Status', 'index'=>true, 'position'=>1000), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>true, 'index'=>true, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity'=>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'searchall'=>1), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), + 'status'=>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), ); // END MODULEBUILDER PROPERTIES diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 8c7da67b7ab..3943e1b9314 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -226,7 +226,7 @@ class modMyModule extends DolibarrModules // Example to declare a new Top Menu entry and its Left menu entry: /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r]=array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry 'titre'=>'MyModule', 'mainmenu'=>'mymodule', @@ -238,12 +238,12 @@ class modMyModule extends DolibarrModules 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - // $r++; + /* END MODULEBUILDER TOPMENU */ // Example to declare a Left Menu entry into an existing Top menu entry: /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'List MyObject', 'mainmenu'=>'mymodule', @@ -255,8 +255,7 @@ class modMyModule extends DolibarrModules 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=mymodule&fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'New MyObject', 'mainmenu'=>'mymodule', @@ -268,7 +267,6 @@ class modMyModule extends DolibarrModules 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $r++; END MODULEBUILDER LEFTMENU MYOBJECT */ diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 9d1019affee..6430944bec7 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -123,7 +123,8 @@ foreach($object->fields as $key => $val) $arrayfields=array(); foreach($object->fields as $key => $val) { - $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>1); + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) From 7562412554d730b03659da48c7770477a338cc3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 01:21:28 +0200 Subject: [PATCH 058/130] Minor fixes --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/modulebuilder/index.php | 32 +++++++++++++------ .../template/class/myobject.class.php | 12 +++---- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a4de6f7470c..9d897396036 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1058,7 +1058,7 @@ RestoreDesc2=Restore archive file (zip file for example) of documents directory RestoreDesc3=Restore the data, from a backup dump file, into the database of the new Dolibarr installation or into the database of this current installation (%s). Warning, once restore is finished, you must use a login/password, that existed when backup was made, to connect again. To restore a backup database into this current installation, you can follow this assistant. RestoreMySQL=MySQL import ForcedToByAModule= This rule is forced to %s by an activated module -PreviousDumpFiles=Available database backup dump files +PreviousDumpFiles=Generated database backup files WeekStartOnDay=First day of week RunningUpdateProcessMayBeRequired=Running the upgrade process seems to be required (Programs version %s differs from database version %s) YouMustRunCommandFromCommandLineAfterLoginToUser=You must run this command from command line after login to a shell with user %s or you must add -W option at end of command line to provide %s password. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 18d543c7933..239126b061e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1229,11 +1229,13 @@ elseif (! empty($module)) print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); print ''; print ''.$langs->trans("Type").''; - print ''.$langs->trans("Position").''; print ''.$langs->trans("NotNull").''; - print ''.$langs->trans("SearchAll").''; //print ''.$langs->trans("DefaultValue").''; print ''.$langs->trans("DatabaseIndex").''; + print ''.$langs->trans("Enabled").''; + print ''.$langs->trans("Visible").''; + print ''.$langs->trans("Position").''; + print ''.$langs->trans("SearchAll").''; print ''.$langs->trans("Comment").''; print ''; print ''; @@ -1241,11 +1243,13 @@ elseif (! empty($module)) print ''; print ''; print ''; - print ''; print ''; - print ''; //print ''; print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -1277,6 +1281,8 @@ elseif (! empty($module)) $propsearchall=$propval['searchall']; //$propdefault=$propval['default']; $propindex=$propval['index']; + $propenabled=$propval['enabled']; + $propvisible=$propval['visible']; $propcomment=$propval['comment']; print ''; @@ -1290,21 +1296,27 @@ elseif (! empty($module)) print ''; print $proptype; print ''; - print ''; - print $propposition; - print ''; print ''; print $propnotnull?'X':''; print ''; - print ''; - print $propsearchall?'X':''; - print ''; /*print ''; print $propdefault; print '';*/ print ''; print $propindex?'X':''; print ''; + print ''; + print $propenabled?$propenabled:''; + print ''; + print ''; + print $propvisible?$propvisible:''; + print ''; + print ''; + print $propposition; + print ''; + print ''; + print $propsearchall?'X':''; + print ''; print ''; print $propcomment; print ''; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index a68e0ff0da5..a371d5fad8a 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -63,12 +63,12 @@ class MyObject extends CommonObject * @var array Array with all fields and their property */ public $fields=array( - 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>true, 'index'=>true, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity'=>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'searchall'=>1), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500), - 'status'=>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>true, 'index'=>true, 'visible'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity'=>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true, 'visible'=>0, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'visible'=>1, 'searchall'=>1), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'visible'=>-1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'visible'=>-1, 'position'=>500), + 'status'=>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'visible'=>1, 'position'=>1000), ); // END MODULEBUILDER PROPERTIES From 5207b84e8b993200275705ad1e09b7b5cf34ddcb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 01:56:38 +0200 Subject: [PATCH 059/130] Fix compatibility with indian IGST/CSGST/SGST --- htdocs/admin/dict.php | 6 +++--- htdocs/compta/facture/card.php | 2 +- htdocs/install/mysql/data/llx_c_tva.sql | 11 +++++++---- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 3 +++ htdocs/langs/en_IN/main.lang | 4 ++++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 72888a8deb3..ae26dce060d 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -249,7 +249,7 @@ $tabfield[6] = "code,libelle,type,color,position"; $tabfield[7] = "code,libelle,country,accountancy_code,deductible"; $tabfield[8] = "code,libelle,country_id,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); $tabfield[9] = "code,label,unicode"; -$tabfield[10]= "country_id,country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; +$tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[11]= "element,source,code,libelle,position"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; $tabfield[13]= "code,libelle,type,accountancy_code"; @@ -286,7 +286,7 @@ $tabfieldvalue[6] = "code,libelle,type,color,position"; $tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible"; $tabfieldvalue[8] = "code,libelle,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); $tabfieldvalue[9] = "code,label,unicode"; -$tabfieldvalue[10]= "country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldvalue[10]= "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[11]= "element,source,code,libelle,position"; $tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; $tabfieldvalue[13]= "code,libelle,type,accountancy_code"; @@ -323,7 +323,7 @@ $tabfieldinsert[6] = "code,libelle,type,color,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible"; $tabfieldinsert[8] = "code,libelle,fk_country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10]= "fk_pays,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[10]= "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[11]= "element,source,code,libelle,position"; $tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; $tabfieldinsert[13]= "code,libelle,type,accountancy_code"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 63b978a9e04..d77f83cbb2e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1440,7 +1440,7 @@ if (empty($reshook)) { if (GETPOST('type') < 0 && ! GETPOST('search_idprod')) { - setEventMessages($langs->trans('ErrorChooseBetweenFreeAntryOrPredefinedProduct'), null, 'errors'); + setEventMessages($langs->trans('ErrorChooseBetweenFreeEntryOrPredefinedProduct'), null, 'errors'); $error ++; } } diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 3b401abd37d..7f9c5f97ea4 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -133,10 +133,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 3 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 34, 3, '0','0','VAT Rate 0',1); -- INDIA (id country=117) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '12.5','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1172, 117, '4','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1173, 117, '1','0','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '12.5','0','VAT standard rate',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1172, 117, '4','0','VAT reduced rate',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1173, 117, '1','0','VAT super-reduced rate',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0',0); + +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'IGST+CGST', 8, 8, '1', 0, '0', 0, 'IGST+CGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'SGST', 0, 0, '0', 16, '1', 0, 'SGST', 1); -- IRELAND (id country=8) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (81, 8, '0','0','VAT Rate 0',1); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 386ae968505..43f4162e9cb 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -577,3 +577,6 @@ ALTER TABLE llx_mailing_cibles MODIFY COLUMN source_url varchar(255); -- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -- VPGSQL8.2 CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); + +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'IGST-CGST', 8, 8, '1', 0, '0', 0, 'IGST-CGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'SGST', 0, 0, '0', 16, '1', 0, 'SGST', 1); diff --git a/htdocs/langs/en_IN/main.lang b/htdocs/langs/en_IN/main.lang index 80f13de139f..13a90b526c4 100644 --- a/htdocs/langs/en_IN/main.lang +++ b/htdocs/langs/en_IN/main.lang @@ -24,3 +24,7 @@ LinkToProposal=Link to quotation LinkToSupplierProposal=Link to supplier quotation SearchIntoCustomerProposals=Customer quotations SearchIntoSupplierProposals=Supplier quotations + +AmountVAT=Amount tax IGST +AmountLT1=Amount tax CGST +AmountLT2=Amount tax SGST From e36911360b76052bc6c4714e87e2696dafd9ecfd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 02:22:16 +0200 Subject: [PATCH 060/130] Update changelog --- ChangeLog | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9cd6f11d1b8..cdbd8ce4b95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,10 +4,126 @@ English Dolibarr ChangeLog ***** ChangeLog for 6.0.0 compared to 5.0.* ***** +NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). +NEW: Add a payment module for Stripe. +NEW: Add module "Product variant" (like red, blue for the product shoes) +NEW: Accountancy - Activate multi-journal & Add journal_label to database (FEC) +NEW: Add a tracking id into mass emailing. +NEW: Add calculation function for Loan schedule +NEW: Add "depends on" and "required by" into module informations +NEW: Add hidden option THIRDPARTY_INCLUDE_PARENT_IN_LINKTO +NEW: Add key __USERID__ and __ENTITYID__ as key for dynamic filters. +NEW: Add last activation author and ip of modules +NEW: Add mass actions (pdf merge and delete) for interventions +NEW: Add module resources import/export +NEW: Add option PROJECT_THIRDPARTY_REQUIRED +NEW: Add page statistics for project tasks +NEW: add property to show warnings when activating modules +NEW: add rapport file for supplier paiement +NEW: Add statistics on supplier tab. +NEW: Add tooltip help on shipment weight and volume calculation +NEW: An external module can hook and add mass actions +NEW: Better reponsive design +NEW: Bookmarks are into a combo list. +NEW: Bulk actions available on supplier orders +NEW: Can add a background image on login page +NEW: Can change customer from POS +NEW: Can clone expense report on another user +NEW: Can control constants values into file integrity checker +NEW: Can define default values for create forms. +NEW: Can define default filters for list pages. +NEW: Can define default sort order for list pages. +NEW: Can deploy an external module from the module setup area. +NEW: Can disable all overwrote translations in one click. +NEW: Can edit background color for odd and even lines in tables +NEW: Can filter on code in dictionnaries +NEW: Can filter on year and product tags on the product statistic page +NEW: Can import users +NEW: Can read time spent of others (hierarchy only or all if granted) +NEW: Can send an email to a user from its card. +NEW: Can send email to multiple destinaries from the mailform combo list. +NEW: Can set margins of PDFs +NEW: Can set number of dump to keep with job "local database backup" +NEW: Can sort customer balance summary on date. +NEW: Can sort thumbs visible on product card. +NEW: Can use a credit note into a "down payment/deposit". +NEW: Can use dol_fiche_end without showing bottom border. +NEW: Can use translations into all substitutions (watermark, freetext...) +NEW: Change to allow a specific numbering rule for invoice with POS module. +NEW: convert exceiss received to reduc +NEW: custom dir is enabled dy default on first install. +NEW: Description of feature of a module visible into a dedicated popup. +NEW: Direct open of card after a search if one record only found. +NEW: download button +NEW: Enable bulk actions delete on supplier invoices. +NEW: Extrafields support formulas to be computed using PHP expressions. +NEW: Feature to crop/resize images available on user and expense reports. +NEW: Filechecker can include custom dir and report added files. +NEW: fix listview class and add a demo for product list +NEW: [FP17] Accountancy - Add select field in list of accounts +NEW: get amount base on hourly rate for ficheinter +NEW: hidden Easter egg to display commitstrip strip on login page +NEW: Include an hourglass icon when we click on online payment button +NEW: Index upload files into database. +NEW: Introduce mass action on product list ('delete' for the moment) +NEW: Introduce mass actions on contacts +NEW: Introduce option MAIN_HTTP_CONTENT_SECURITY_POLICY +NEW: It's easier to switch between sandbox and live for paypal +NEW: Mass action delete available on project and tasks +NEW: Move login information on home page into a widget +NEW: new demo entry page +NEW: No external check of version without explicit click in about page. +NEW: ODT docs for USER USERGROUP CONTRACT and PRODUCT class +NEW: odt usergroup +NEW: On invoices generated by template, we save if invoice come from a source template. +NEW: option to copy into attachement files of events, files send by mail (with auto event creation) +NEW: PDF with numbertoword +NEW: Permit multiple file upload in linked documents +NEW: PHP 7.1 compatibility +NEW: Reduce memory usage by removing deprecated constant loading. +NEW: Report page and menu for suppliers paiements +NEW: Show by default README.md file found into root dir of ext module. +NEW: Show company into combo list of projects +NEW: show files in the bank statement + download +NEW: Show local taxes in facture list +NEW: Show local taxes in supplier facture list +NEW: Small PDF template for products +NEW: Option SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT +NEW: The substitution keys available for emailing edition are now visible into a popup. +NEW: Uniformize behaviour: Action to make order is an action button. +NEW: Use autocompletion on the "Add widget list". +NEW: Use html5 type "number" on select field for year and duration. +NEW: Can use pdktk to concat mass pdf because tcpdf generate avoid to split large file into multiple smaller file (all have same size) encounter issue with mailer provider virtual delivery service +NEW: Default theme of v6 is cleaner. +NEW: When down payment is entered, discount to reuse into final invoice is automatically created. This save one click into invoice workflow. +NEW: Add UI to configure MEMBER_NEWFORM_FORCETYPE +NEW: #2763 Go to document block after clicking in Generate document button +NEW: #6280: Generate PDF after creating an invoice from a customer order +NEW: #6915 Simplest change. +NEW: Uniformize the look and feel with v6 new look. + For developers: NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... NEW: Big refactorization of multicompany transverse mode. NEW: getEntity function use true $shared value by default. +NEW: Add font-awesome css. +NEW: Add function ajax_autoselect +NEW: Add function dolMd2Html +NEW: Add hook doUpgrade2 +NEW: Add hook "formatNotificationMessage" +NEW: Add index and constraints keys on supplier proposal detail table +NEW: Add phpunit to check the engine is defined into sql create files. +NEW: Add project and Hook to Loan +NEW: Add REST API to push a file. +NEW: Allow extrafields list select to be dependands on other standard list and not only other extrafields list +NEW: Architecture to manage search criteria persistance (using save_lastsearch_values=1 on exit links and restore_lastsearch_values=1 in entry links) +NEW: data files are now also parsed by phpunit for sql syntax +NEW: Hook to allow inserting custom product head #6001 +NEW: Introduce fields that can be computed during export in export profiles. +NEW: Introduce function dol_compress_dir +NEW: Removed commande_pdf_create, contract_pdf_create,expedition_pdf_create, facture_pdf_create, delivery_order_pdf_create, task_pdf_create, project_pdf_create, propale_pdf_create, supplier_invoice_pdf_create, supplier_order_pdf_create, supplier_proposal_pdf_create deprecated functions +NEW: tooltip can be on hover or on click with textwithpicto function. +NEW: Upgrade jquery to 3.3.1 and jquery-ui to 1.12 WARNING: From a0d9890c999574770e5a3443987b677831678693 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 02:31:06 +0200 Subject: [PATCH 061/130] Fix packager --- build/makepack-dolibarr.pl | 4 +++- htdocs/modulebuilder/template/class/api_myobject.class.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c2d983653cb..46eff3e8dc6 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -972,9 +972,11 @@ if ($nboftargetok) { $ret=`$cmd`; $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/actions_mymodule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_api_class.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindes.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_card.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_list.php`; $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/scripts/myobject.php`; diff --git a/htdocs/modulebuilder/template/class/api_myobject.class.php b/htdocs/modulebuilder/template/class/api_myobject.class.php index 44e2dd2fcc4..e3e38cefd38 100644 --- a/htdocs/modulebuilder/template/class/api_myobject.class.php +++ b/htdocs/modulebuilder/template/class/api_myobject.class.php @@ -19,7 +19,7 @@ use Luracast\Restler\RestException; /** - * \file htdocs/modulebuilder/template/class/myobject_api_class.class.php + * \file htdocs/modulebuilder/template/class/api_myobject.class.php * \ingroup mymodule * \brief File for API management of myobject. */ From e0f07694050d0a338beeb0cb555b48f417d6ae86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 02:31:33 +0200 Subject: [PATCH 062/130] Fix packager --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 46eff3e8dc6..41b54022ee4 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -976,7 +976,7 @@ if ($nboftargetok) { $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/api_myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindes.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/mymoduleindex.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_card.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_list.php`; $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/scripts/myobject.php`; From 4803f2d29acc5a0afd4afa57de6889f6f15b5bd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 11:26:25 +0200 Subject: [PATCH 063/130] Fix package v6 --- build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_generic.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + 4 files changed, 4 insertions(+) diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 33dc951309d..55898481691 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -162,6 +162,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 42a89675abf..e5b346278ab 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -242,6 +242,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 9dd2100b02c..04a3138d9f9 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -159,6 +159,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index d780c47da99..c77661fe420 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -170,6 +170,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/api %_datadir/dolibarr/htdocs/asterisk %_datadir/dolibarr/htdocs/barcode +%_datadir/dolibarr/htdocs/blockedlog %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories From 1f5a71f2c92a538ef0086ba0181a9a7514f3901d Mon Sep 17 00:00:00 2001 From: hguibourgdev Date: Sat, 22 Jul 2017 12:18:54 +0200 Subject: [PATCH 064/130] New : Prepare toolkit for alert warning --- htdocs/langs/en_US/stocks.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 746268f7e98..231f5bb3a2e 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -67,6 +67,7 @@ NoPredefinedProductToDispatch=No predefined products for this object. So no disp DispatchVerb=Dispatch StockLimitShort=Limit for alert StockLimit=Stock limit for alert +StockLimitDesc="" (empty) default value means no alert.
"0" can be used with 'Stock can be negative' configuration. PhysicalStock=Physical stock RealStock=Real Stock RealStockDesc=Physical or real stock is the stock you currently have into your internal warehouses/emplacements. @@ -142,4 +143,4 @@ OptionMULTIPRICESIsOn=Option "several prices per segment" is on. It means a prod ProductStockWarehouseCreated=Stock limit for alert and desired optimal stock correctly created ProductStockWarehouseUpdated=Stock limit for alert and desired optimal stock correctly updated ProductStockWarehouseDeleted=Stock limit for alert and desired optimal stock correctly deleted -AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock \ No newline at end of file +AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock From 44023606c65d74217fd02867e62aa5e0692f3346 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 12:47:35 +0200 Subject: [PATCH 065/130] Fix pb in dolGetFirstLineOfText. Add PHPunit --- htdocs/core/lib/files.lib.php | 1 + htdocs/core/lib/functions.lib.php | 51 +++++++++++++++++++---- test/phpunit/FunctionsLibTest.php | 67 ++++++++++++++++++++++++++++++- 3 files changed, 111 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 29706e15341..5d3c209bdc7 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -323,6 +323,7 @@ function dol_dir_is_emtpy($folder) * * @param string $file Filename * @return int <0 if KO, Number of lines in files if OK + * @see dol_nboflines */ function dol_count_nb_of_line($file) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a12e4c18ba4..a099b33eee7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4488,22 +4488,57 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') * Return first line of text. Cut will depends if content is HTML or not. * * @param string $text Input text + * @param int $nboflines Nb of lines to get (default is 1 = first line only) * @return string Output text * @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag */ -function dolGetFirstLineOfText($text) +function dolGetFirstLineOfText($text, $nboflines=1) { - if (dol_textishtml($text)) + if ($nboflines == 1) { - $firstline=preg_replace('/]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters - $firstline=preg_replace('/]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters + if (dol_textishtml($text)) + { + $firstline=preg_replace('/]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters + $firstline=preg_replace('/]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters + } + else + { + $firstline=preg_replace('/[\n\r].*/','',$text); + } + return $firstline.((strlen($firstline) != strlen($text))?'...':''); } else { - $firstline=preg_replace('/[\n\r].*/','',$text); + $ishtml=0; + if (dol_textishtml($text)) + { + $text=preg_replace('/\n/','',$text); + $ishtml=1; + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); + } + else + { + $repTable = array("\t" => " ", "\n" => "
", "\r" => " ", "\0" => " ", "\x0B" => " "); + } + + $text = strtr($text, $repTable); + if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support + else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. + $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + $firstline=''; + $i=0; + $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator + while (($i < $nba) && ($i < ($nboflines * 2))) + { + if ($i % 2 == 0) $firstline .= $a[$i]; + elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml?"
\n":"\n"); + $i++; + } + unset($a); + return $firstline.(($i < $nba)?'...':''); } - return $firstline.((strlen($firstline) != strlen($text))?'...':''); } @@ -4665,7 +4700,7 @@ function dol_nboflines($s,$maxchar=0) /** - * Return nb of lines of a formated text with \n and
(we can't have both \n and br) + * Return nb of lines of a formated text with \n and
(WARNING: string must not have mixed \n and br separators) * * @param string $text Text * @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut) @@ -4701,6 +4736,8 @@ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8') } } } + + unset($a); return $nblines; } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 3345d780b7e..814adfb390b 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -120,10 +120,75 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase + /** + * testDolGetFirstLineOfText + * + * @return void + */ + public function testDolGetFirstLineOfText() + { + // Nb of line is same than entry text + + $input="aaaa"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa", $result); + + $input="aaaa\nbbbbbbbbbbbb\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); + + $input="aaaa
bbbbbbbbbbbb
"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb", $result); + + // Nb of line is lower + + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); + + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); + + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); + + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb...", $result); + + // Nb of line is higher + + $input="aaaa
bbbbbbbbbbbb
cccccc"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); + + $input="aaaa
bbbbbbbbbbbb
cccccc
"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); + + $input="aaaa
bbbbbbbbbbbb
cccccc
\n"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
\nbbbbbbbbbbbb
\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); + } + + /** * testDolBuildPath * - * @return boolean + * @return void */ public function testDolBuildPath() { From 340203cc18a08d39b255058aef47bc40ce2ad708 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 16:05:51 +0200 Subject: [PATCH 066/130] Fix vat label for India --- htdocs/core/class/html.form.class.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0f16a25c43f..8be11fcea06 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4417,7 +4417,7 @@ class Form dol_syslog(__METHOD__, LOG_DEBUG); - $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.recuperableonly"; + $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql.= " WHERE t.fk_pays = c.rowid"; $sql.= " AND t.active > 0"; @@ -4436,8 +4436,20 @@ class Form $this->cache_vatrates[$i]['rowid'] = $obj->rowid; $this->cache_vatrates[$i]['code'] = $obj->code; $this->cache_vatrates[$i]['txtva'] = $obj->taux; - $this->cache_vatrates[$i]['libtva'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or * $this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly; + $this->cache_vatrates[$i]['localtax1'] = $obj->localtax1; + $this->cache_vatrates[$i]['localtax1_type'] = $obj->localtax1_type; + $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2; + $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type; + + $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or * + $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1?$obj->localtax1:'0').'/'.($obj->localtax2?$obj->localtax2:'0').($obj->code?' ('.$obj->code.')':''); // Must never be used as key, only label + $positiverates=''; + if ($obj->taux) $positiverates.=($positiverates?'/':'').$obj->taux; + if ($obj->localtax1) $positiverates.=($positiverates?'/':'').$obj->localtax1; + if ($obj->localtax2) $positiverates.=($positiverates?'/':'').$obj->localtax2; + if (empty($positiverates)) $positiverates='0'; + $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code?' ('.$obj->code.')':''); // Must never be used as key, only label } return $num; @@ -4611,7 +4623,16 @@ class Form $selectedfound=true; } } - $return.= '>'.vatrate($rate['libtva']); + $return.= '>'; + //if (! empty($conf->global->MAIN_VAT_SHOW_POSITIVE_RATES)) + if ($mysoc->country_code == 'IN' || ! empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES)) + { + $return.= $rate['labelpositiverates']; + } + else + { + $return.= vatrate($rate['label']); + } //$return.=($rate['code']?' '.$rate['code']:''); $return.= (empty($rate['code']) && $rate['nprtva']) ? ' *': ''; // We show the * (old behaviour only if new vat code is not used) From 6470b62f56f7f7fb7efa07e8b6bb9198782e3954 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 16:13:21 +0200 Subject: [PATCH 067/130] Fix bad rounding --- htdocs/compta/tva/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 618ba11a37e..9fb2b890b24 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -263,18 +263,18 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) print ""; print '' . $langs->trans("VATDue") . ''; // need to add translation - print '' . price(price2num($total, 1)) . ''; + print '' . price(price2num($total, 'MT')) . ''; print "\n"; print ""; print '' . $langs->trans("VATPaid") . ''; - print '' . price(price2num($obj->mm, 1)) . "\n"; + print '' . price(price2num($obj->mm, 'MT')) . "\n"; print "\n"; $restopay = $total - $obj->mm; print ""; print '' . $langs->trans("VATRestopay") . ''; // need to add translation - print '' . price(price2num($restopay, 1)) . ''; + print '' . price(price2num($restopay, 'MT')) . ''; print "\n"; print ''; From 9e6666e511a83973f8de26a45c46570ab5b416b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 16:40:19 +0200 Subject: [PATCH 068/130] Fix translation keys for taxes --- dev/translation/sanity_check_en_langfiles.php | 62 +++++++++---------- htdocs/compta/tva/index.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/langs/en_US/compta.lang | 32 +++++++--- htdocs/langs/en_US/main.lang | 9 +++ 5 files changed, 66 insertions(+), 41 deletions(-) diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 9136c192739..f65cefd7f94 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -25,7 +25,7 @@ $path=dirname(__FILE__).'/'; $web=0; // Test if batch mode -if (substr($sapi_type, 0, 3) == 'cgi') +if (substr($sapi_type, 0, 3) == 'cgi') { $web=1; } @@ -35,9 +35,9 @@ if ($web) { echo ""; echo ""; - + echo ""; - + echo ""; } @@ -142,9 +142,9 @@ foreach ($files AS $file) { } } -foreach ($langstrings_3d AS $filename => $file) +foreach ($langstrings_3d AS $filename => $file) { - foreach ($file AS $linenum => $value) + foreach ($file AS $linenum => $value) { $keys = array_keys($langstrings_full, $value); if (count($keys)>1) @@ -173,11 +173,11 @@ $sininstallandadmin=''; $sother=''; $count = 0; -foreach ($dups as $string => $pages) +foreach ($dups as $string => $pages) { $count++; $s=''; - + // Keyword $string if ($web) $s.=""; if ($web) $s.=""; @@ -188,32 +188,32 @@ foreach ($dups as $string => $pages) if ($web) $s.=""; if ($web) $s.=""; if (! $web) $s.= ' : '; - + // Loop on each files keyword was found $duplicateinsamefile=0; $inmain=0; $inadmin=0; - foreach ($pages AS $file => $lines) + foreach ($pages AS $file => $lines) { if ($file == 'main.lang') { $inmain=1; $inadmin=0; } if ($file == 'admin.lang' && ! $inmain) { $inadmin=1; } - + $s.=$file." "; - + // Loop on each line keword was found into file. $listoffilesforthisentry=array(); - foreach ($lines as $line => $translatedvalue) + foreach ($lines as $line => $translatedvalue) { if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1; $listoffilesforthisentry[$file]=1; - + $s.= "(".$line." - ".htmlentities($translatedvalue).") "; } if ($web) $s.="
"; } if ($web) $s.=""; $s.="\n"; - + if ($duplicateinsamefile) $sduplicateinsamefile .= $s; else if ($inmain) $sinmainandother .= $s; else if ($inadmin) $sininstallandadmin .= $s; @@ -252,7 +252,7 @@ if ($web) if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true')) { print "***** Strings in en_US that are never used:\n"; - + $unused=array(); foreach ($langstrings_dist AS $value => $line) { @@ -288,7 +288,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0; if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0; if (preg_match('/^newLT/', $value)) $qualifiedforclean=0; - if (preg_match('/^LT\d/', $value)) $qualifiedforclean=0; + if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0; if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0; if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0; if (preg_match('/^Language_/', $value)) $qualifiedforclean=0; @@ -315,7 +315,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a // orders if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0; if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0; - // other.lang + // other.lang if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0; if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0; if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0; @@ -336,17 +336,17 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0; if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0; if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0; - + if (preg_match('/sms/i', $value)) $qualifiedforclean=0; if (preg_match('/TF_/i', $value)) $qualifiedforclean=0; if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0; if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0; - + if (! $qualifiedforclean) { - continue; + continue; } - + //$search = '\'trans("'.$value.'")\''; $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"'; $string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*'; @@ -356,7 +356,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a $unused[$value] = $line; echo $line; // $trad contains the \n } - else + else { unset($output); //print 'X'.$output.'Y'; @@ -364,7 +364,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a } if (empty($unused)) print "No string not used found.\n"; - else + else { $filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang'; print "Strings in en_US that are never used are saved into file ".$filetosave.":\n"; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 9fb2b890b24..89accf57492 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -117,7 +117,7 @@ $textprevyear="".img_previo $textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; print $conf->dol_optimize_smallscreen; -print load_fiche_titre($langs->trans("VAT"), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png'); +print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png'); print $langs->trans("VATReportBuildWithOptionDefinedInModule").'
'; print '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')
'; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2fcf1fa4ff2..530be07da39 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -871,7 +871,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // VAT if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) { - $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy",$langs->trans("VAT"),1,$user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat'); + $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy",$langs->transcountry("VAT", $mysoc->country_code),1,$user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create",$langs->trans("New"),2,$user->rights->tax->charges->creer); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/tva/reglement.php?leftmenu=tax_vat",$langs->trans("List"),2,$user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 79ad6cfd628..4c6dc5bf169 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -30,18 +30,34 @@ Piece=Accounting Doc. AmountHTVATRealReceived=Net collected AmountHTVATRealPaid=Net paid VATToPay=VAT sells -VATReceived=VAT received -VATToCollect=VAT purchases -VATSummary=VAT Balance -LT2SummaryES=IRPF Balance +VATReceived=Tax received +VATToCollect=Tax purchases +VATSummary=Tax Balance +VATPaid=Tax paid +LT1Summary=Tax 2 summary +LT2Summary=Tax 3 summary LT1SummaryES=RE Balance -VATPaid=VAT paid -LT2PaidES=IRPF Paid +LT2SummaryES=IRPF Balance +LT1SummaryIN=CGST Balance +LT2SummaryIN=SGST Balance +LT1Paid=Tax 2 paid +LT2Paid=Tax 3 paid LT1PaidES=RE Paid -LT2CustomerES=IRPF sales -LT2SupplierES=IRPF purchases +LT2PaidES=IRPF Paid +LT1PaidIN=CGST Paid +LT2PaidIN=SGST Paid +LT1Customer=Tax 2 sales +LT1Supplier=Tax 2 purchases LT1CustomerES=RE sales LT1SupplierES=RE purchases +LT1CustomerIN=CGST sales +LT1SupplierIN=CGST purchases +LT2Customer=Tax 3 sales +LT2Supplier=Tax 3 purchases +LT2CustomerES=IRPF sales +LT2SupplierES=IRPF purchases +LT2CustomerIN=SGST sales +LT2SupplierIN=SGST purchases VATCollected=VAT collected ToPay=To pay SpecialExpensesArea=Area for all special payments diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 88b9d2a3fb0..f3f9a4a1902 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -356,17 +356,26 @@ Totalforthispage=Total for this page TotalTTC=Total (inc. tax) TotalTTCToYourCredit=Total (inc. tax) to your credit TotalVAT=Total tax +TotalVATIN=Total IGST TotalLT1=Total tax 2 TotalLT2=Total tax 3 TotalLT1ES=Total RE TotalLT2ES=Total IRPF +TotalLT1IN=Total CGST +TotalLT2IN=Total SGST HT=Net of tax TTC=Inc. tax INCT=Inc. all taxes VAT=Sales tax +VATIN=IGST VATs=Sales taxes +VATINs=IGST taxes +LT1=Sales tax 2 +LT2=Sales tax 3 LT1ES=RE LT2ES=IRPF +LT1IN=CGST +LT2IN=SGST VATRate=Tax Rate Average=Average Sum=Sum From 437d620fe4ca448fd07c746a08d6b693b3fce3de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 20:01:29 +0200 Subject: [PATCH 069/130] Add support of language in website module --- .../install/mysql/migration/6.0.0-7.0.0.sql | 3 +- .../install/mysql/tables/llx_website_page.sql | 2 + htdocs/langs/en_US/website.lang | 5 +- htdocs/websites/class/websitepage.class.php | 30 +++- htdocs/websites/index.php | 163 +++++++++++------- 5 files changed, 137 insertions(+), 66 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 8e87f3e6bba..3fe48dd531b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -29,5 +29,6 @@ ALTER TABLE llx_facture_fourn ADD COLUMN date_pointoftax date DEFAULT NULL; ALTER TABLE llx_facture_fourn ADD COLUMN date_valid date; ALTER TABLE llx_website_page MODIFY COLUMN pageurl varchar(255); - +ALTER TABLE llx_website_page ADD COLUMN lang varchar(6); +ALTER TABLE llx_website_page ADD COLUMN fk_page integer; diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql index ff7cbb47a16..13ab3558c98 100644 --- a/htdocs/install/mysql/tables/llx_website_page.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -25,6 +25,8 @@ CREATE TABLE llx_website_page title varchar(255), description varchar(255), keywords varchar(255), + lang varchar(6), + fk_page integer, content mediumtext, -- text is not enough in size status integer, fk_user_create integer, diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 3b29f51e29d..efae27e68dd 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -35,4 +35,7 @@ NoPageYet=No pages yet SyntaxHelp=Help on code syntax YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.

You can also include content of another Page/Container with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>

To include a link to download a file stored into the documents/medias directory, use syntax:
<a href="/document.php?modulepart=medias&file=filename.ext">. ClonePage=Clone page/container -CloneSite=Clone site \ No newline at end of file +CloneSite=Clone site +ConfirmClonePage=Please enter code/alias of new page and if it is a translation of the cloned page. +PageIsANewTranslation=The new page is a translation of the current page ? +LanguageMustNotBeSameThanClonedPage=You clone a page as a translation. The language of the new page must be different than language of source page. \ No newline at end of file diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index d313905a3bc..73158fac7be 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -127,6 +127,8 @@ class WebsitePage extends CommonObject $sql.= 'description,'; $sql.= 'keywords,'; $sql.= 'content,'; + $sql.= 'lang,'; + $sql.= 'fk_page,'; $sql.= 'status,'; $sql.= 'date_creation,'; $sql.= 'tms'; @@ -137,6 +139,8 @@ class WebsitePage extends CommonObject $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; $sql .= ' '.(! isset($this->keywords)?'NULL':"'".$this->db->escape($this->keywords)."'").','; $sql .= ' '.(! isset($this->content)?'NULL':"'".$this->db->escape($this->content)."'").','; + $sql .= ' '.(! isset($this->lang)?'NULL':"'".$this->db->escape($this->lang)."'").','; + $sql .= ' '.(empty($this->fk_page)?'NULL':$this->db->escape($this->fk_page)).','; $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); @@ -199,6 +203,8 @@ class WebsitePage extends CommonObject $sql .= " t.description,"; $sql .= " t.keywords,"; $sql .= " t.content,"; + $sql .= " t.lang,"; + $sql .= " t.fk_page,"; $sql .= " t.status,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; @@ -232,6 +238,8 @@ class WebsitePage extends CommonObject $this->description = $obj->description; $this->keywords = $obj->keywords; $this->content = $obj->content; + $this->lang = $obj->lang; + $this->fk_page = $obj->fk_page; $this->status = $obj->status; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); @@ -277,6 +285,8 @@ class WebsitePage extends CommonObject $sql .= " t.description,"; $sql .= " t.keywords,"; $sql .= " t.content,"; + $sql .= " t.lang,"; + $sql .= " t.fk_page,"; $sql .= " t.status,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; @@ -319,6 +329,8 @@ class WebsitePage extends CommonObject $record->description = $obj->description; $record->keywords = $obj->keywords; $record->content = $obj->content; + $record->lang = $obj->lang; + $record->fk_page = $obj->fk_page; $record->status = $obj->status; $record->date_creation = $this->db->jdate($obj->date_creation); $record->date_modification = $this->db->jdate($obj->date_modification); @@ -385,6 +397,8 @@ class WebsitePage extends CommonObject $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; $sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").','; $sql .= ' content = '.(isset($this->content)?"'".$this->db->escape($this->content)."'":"null").','; + $sql .= ' lang = '.(isset($this->lang)?"'".$this->db->escape($this->lang)."'":"null").','; + $sql .= ' fk_page = '.(empty($this->fk_page)?"null":$this->db->escape($this->fk_page)).','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null'); $sql .= ', tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'"); @@ -482,10 +496,13 @@ class WebsitePage extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param int $fromid Id of object to clone + * @param string $newref New ref/alias of page + * @param string $newlang New language + * @param int $istranslation 1=New page is a translation of the cloned page. + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone($fromid, $newref, $newlang='', $istranslation=0) { global $user, $langs; @@ -502,9 +519,12 @@ class WebsitePage extends CommonObject $object->id = 0; // Clear fields - $object->ref = 'copy_of_'.$object->ref; - $object->pageurl = 'copy_of_'.$object->pageurl; + $object->ref = $newref; + $object->pageurl = $newref; $object->title = $langs->trans("CopyOf").' '.$object->title; + if (! empty($newlang)) $object->lang=$newlang; + if ($istranslation) $object->fk_page = $fromid; + else $object->fk_page = 0; // Create clone $result = $object->create($user); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 0ae1902613c..f9519ee4cf0 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -71,6 +71,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; @@ -163,7 +164,8 @@ if ($action == 'add') $objectpage->title = GETPOST('WEBSITE_TITLE'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); - $objectpage->keywords = GETPOST('WEBSITE_KEYWORD'); + $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS'); + $objectpage->lang = GETPOST('WEBSITE_LANG'); if (empty($objectpage->pageurl)) { @@ -404,6 +406,7 @@ if ($action == 'updatemeta') $objectpage->title = GETPOST('WEBSITE_TITLE'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS'); + $objectpage->lang = GETPOST('WEBSITE_LANG'); $res = $objectpage->update($user); if (! $res > 0) @@ -524,58 +527,78 @@ if ($action == 'updatemeta') } // Update page -if (($action == 'updatecontent' || $action == 'createpagefromclone') +if (($action == 'updatecontent' || $action == 'confirm_createpagefromclone') || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview')))) { $object->fetch(0, $website); - if ($action == 'createpagefromclone') + if ($action == 'confirm_createpagefromclone') { - $objectpage = new WebsitePage($db); - $result = $objectpage->createFromClone($pageid); - if ($result < 0) + $istranslation=(GETPOST('is_a_translation','aZ09')=='on'?1:0); + if ($istranslation) { - setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - $action='preview'; + if (GETPOST('newlang','aZ09') == $objectpage->lang) + { + $error++; + setEventMessages($langs->trans("LanguageMustNotBeSameThanClonedPage"), null, 'errors'); + $action='preview'; + } + } + + if (! $error) + { + $objectpage = new WebsitePage($db); + $result = $objectpage->createFromClone($pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation); + if ($result < 0) + { + $error++; + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + $action='createpagefromclone'; + } } } - // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $res = 0; + + if (! $error) { - dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists - $result = symlink($pathtomedias, $pathtomediasinwebsite); + // Check symlink to medias and restore it if ko + $pathtomedias=DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite=$pathofwebsite.'/medias'; + if (! is_link(dol_osencode($pathtomediasinwebsite))) + { + dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + $result = symlink($pathtomedias, $pathtomediasinwebsite); + } + + /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) + { + $object->virtualhost = GETPOST('previewsite', 'alpha'); + $object->update($user); + }*/ + + $objectpage->fk_website = $object->id; + + if ($pageid > 0) + { + $res = $objectpage->fetch($pageid); + } + else + { + $res=0; + if ($object->fk_default_home > 0) + { + $res = $objectpage->fetch($object->fk_default_home); + } + if (! ($res > 0)) + { + $res = $objectpage->fetch(0, $object->id); + } + } } - /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) - { - $object->virtualhost = GETPOST('previewsite', 'alpha'); - $object->update($user); - }*/ - - $objectpage->fk_website = $object->id; - - if ($pageid > 0) - { - $res = $objectpage->fetch($pageid); - } - else - { - $res=0; - if ($object->fk_default_home > 0) - { - $res = $objectpage->fetch($object->fk_default_home); - } - if (! ($res > 0)) - { - $res = $objectpage->fetch(0, $object->id); - } - } - - if ($res > 0) + if (! $error && $res > 0) { if ($action == 'updatecontent') { @@ -709,7 +732,7 @@ if (($action == 'updatecontent' || $action == 'createpagefromclone') } else { - setEventMessages($langs->trans("NoPageYet"), null, 'warnings'); + if (! $error) setEventMessages($langs->trans("NoPageYet"), null, 'warnings'); } } @@ -720,6 +743,7 @@ if (($action == 'updatecontent' || $action == 'createpagefromclone') */ $form = new Form($db); +$formadmin = new FormAdmin($db); $help_url=''; @@ -916,13 +940,26 @@ if (count($object->records) > 0) print ''; - if ($action == 'preview') + if ($action == 'preview' || $action == 'createpagefromclone') { $disabled=''; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; if ($pageid > 0) { + // Confirmation to delete + if ($action == 'createpagefromclone') { + // Create an array for form + $formquestion = array( + array('type' => 'text', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME") ,'value'=> 'copy_of_'.$objectpage->pageurl), + array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), + array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200'))); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 250); + + print $formconfirm; + } + print '   '; print ''; @@ -938,7 +975,7 @@ if (count($object->records) > 0) print '
'; - if ($website && $pageid > 0 && $action == 'preview') + if ($website && $pageid > 0 && ($action == 'preview' || $action == 'createpagefromclone')) { $websitepage = new WebSitePage($db); $websitepage->fetch($pageid); @@ -965,7 +1002,7 @@ if (count($object->records) > 0) // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } - if (! in_array($action, array('editcss','editmenu','create'))) + if (! in_array($action, array('editcss','editmenu','create','createpagefromclone'))) { if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; @@ -984,7 +1021,7 @@ if (count($object->records) > 0) - if ($action == 'preview') + if ($action == 'preview' || $action == 'createpagefromclone') { // Adding jquery code to change on the fly url of preview ext if (! empty($conf->use_javascript_ajax)) @@ -1126,38 +1163,46 @@ if ($action == 'editmeta' || $action == 'create') print ''; print '/public/websites/index.php?website='.urlencode($website).'&pageid='.urlencode($pageid); print ''; - $pageurl=dol_escape_htmltag($objectpage->pageurl); - $pagetitle=dol_escape_htmltag($objectpage->title); - $pagedescription=dol_escape_htmltag($objectpage->description); - $pagekeywords=dol_escape_htmltag($objectpage->keywords); + $pageurl=$objectpage->pageurl; + $pagetitle=$objectpage->title; + $pagedescription=$objectpage->description; + $pagekeywords=$objectpage->keywords; + $pagelang=$objectpage->lang; } - if (GETPOST('WEBSITE_PAGENAME')) $pageurl=GETPOST('WEBSITE_PAGENAME'); - if (GETPOST('WEBSITE_TITLE')) $pagetitle=GETPOST('WEBSITE_TITLE'); - if (GETPOST('WEBSITE_DESCRIPTION')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION'); - if (GETPOST('WEBSITE_KEYWORDS')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS'); + if (GETPOST('WEBSITE_PAGENAME')) $pageurl=GETPOST('WEBSITE_PAGENAME','alpha'); + if (GETPOST('WEBSITE_TITLE')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); + if (GETPOST('WEBSITE_DESCRIPTION')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION','alpha'); + if (GETPOST('WEBSITE_KEYWORDS')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS','alpha'); + if (GETPOST('WEBSITE_LANG')) $pagelang=GETPOST('WEBSITE_LANG','aZ09'); print ''; print $langs->trans('WEBSITE_PAGENAME'); print ''; - print ''; + print ''; print ''; print ''; print $langs->trans('WEBSITE_TITLE'); print ''; - print ''; + print ''; print ''; print ''; print $langs->trans('WEBSITE_DESCRIPTION'); print ''; - print ''; + print ''; print ''; print ''; print $langs->trans('WEBSITE_KEYWORDS'); print ''; - print ''; + print ''; + print ''; + + print ''; + print $langs->trans('Language'); + print ''; + print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG'); print ''; print ''; @@ -1204,7 +1249,7 @@ print "
\n\n"; -if ($action == 'preview') +if ($action == 'preview' || $action == 'createpagefromclone') { if ($pageid > 0) { From 2a133f4a3f5de2e15da737efa48f107512d829ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 20:12:00 +0200 Subject: [PATCH 070/130] Generate table for extrafields --- htdocs/langs/en_US/modulebuilder.lang | 1 + htdocs/modulebuilder/index.php | 18 +++++++++++---- .../template/sql/llx_myobject_extrafields.sql | 23 +++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index a3ba8a7455b..063e1c8d332 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -51,6 +51,7 @@ WidgetFile=Widget file ReadmeFile=Readme file ChangeLog=ChangeLog file SqlFile=Sql file +SqlFileExtraFields=Sql file for complementary attributes SqlFileKey=Sql file for keys AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 239126b061e..0b5c1da7039 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -110,8 +110,9 @@ if ($dirins && $action == 'initmodule' && $modulename) dol_delete_file($destdir.'/myobject_card.php'); dol_delete_file($destdir.'/myobject_list.php'); dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); - dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/sql/llx_myobject_extrafields.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); dol_delete_file($destdir.'/scripts/myobject.php'); dol_delete_file($destdir.'/img/object_myobject.png'); dol_delete_file($destdir.'/class/myobject.class.php'); @@ -189,9 +190,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'myobject_card.php'=>strtolower($objectname).'_card.php', 'myobject_list.php'=>strtolower($objectname).'_list.php', 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', @@ -377,9 +379,10 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) 'myobject_card.php'=>strtolower($objectname).'_card.php', 'myobject_list.php'=>strtolower($objectname).'_list.php', 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', @@ -423,6 +426,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) // File of sql $fileforsql = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.sql'; + $fileforsqlextra = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'_extrafields.sql'; $fileforsqlkey = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.key.sql'; @@ -1179,6 +1183,7 @@ elseif (! empty($module)) $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; + $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; print '
'; print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.''; @@ -1190,6 +1195,9 @@ elseif (! empty($module)) print ' '.$langs->trans("SqlFile").' : '.$pathtosql.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; + print ' '.$langs->trans("SqlFileExtraFields").' : '.$pathtosqlextra.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; print ' '.$langs->trans("SqlFileKey").' : '.$pathtosqlkey.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; diff --git a/htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql b/htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql new file mode 100644 index 00000000000..72c672a92f8 --- /dev/null +++ b/htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- 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 . + +create table llx_myobject_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 583452114b93e07780cc23b9ae681ba4202a6433 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 20:19:10 +0200 Subject: [PATCH 071/130] Split editor in 2 (html source and wysiwyg) --- htdocs/langs/en_US/website.lang | 3 ++- htdocs/websites/index.php | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index b3af3d3e0fc..fa53c0bf2bd 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -12,7 +12,8 @@ MediaFiles=Media library EditCss=Edit Style/CSS EditMenu=Edit menu EditPageMeta=Edit Meta -EditPageContent=Edit Content +EditPageSource=Edit HTML Source +EditPageContent=Edit with CKEditor Website=Web site Webpage=Web page AddPage=Add page diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 0b621577463..9fbd6e6a4e0 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -98,6 +98,7 @@ if (GETPOST('editcss')) { $action='editcss'; } if (GETPOST('editmenu')) { $action='editmenu'; } if (GETPOST('setashome')) { $action='setashome'; } if (GETPOST('editmeta')) { $action='editmeta'; } +if (GETPOST('editsource')) { $action='editsource'; } if (GETPOST('editcontent')) { $action='editcontent'; } if (empty($action)) $action='preview'; @@ -665,6 +666,10 @@ if ($action == 'editmeta') { print ''; } +if ($action == 'editsource') +{ + print ''; +} if ($action == 'editcontent') { print ''; @@ -677,7 +682,7 @@ if ($action == 'edit') // Add a margin under toolbar ? $style=''; -if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;'; //var_dump($objectpage);exit; print '
'; @@ -835,6 +840,7 @@ if (count($object->records) > 0) if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; + print ''; print ''; //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; @@ -891,7 +897,7 @@ if (count($object->records) > 0) print '
'; print '
'; - if (GETPOST('editcontent', 'alpha')) + if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) { $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource"); print $form->textwithpicto($langs->trans("SyntaxHelp"), $htmltext, 1, 'help', 'inline-block', 0, 2, 'tooltipsubstitution'); @@ -1083,6 +1089,25 @@ if ($action == 'editmenu') print '
'.$langs->trans("FeatureNotYetAvailable").''; } +if ($action == 'editsource') +{ + /* + * Editing global variables not related to a specific theme + */ + + $csscontent = @file_get_contents($filecss); + + $contentforedit = ''; + /*$contentforedit.=''."\n";*/ + $contentforedit .= $objectpage->content; + + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); + $doleditor->Create(0, '', false); +} + if ($action == 'editcontent') { /* From 7904e994a7f2ed39f24d27ea01b6cae0759b68c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 23:43:40 +0200 Subject: [PATCH 072/130] FIX When disconnected, the search box jump to login instead of error. --- htdocs/core/ajax/selectsearchbox.php | 9 +++++++++ htdocs/langs/en_US/other.lang | 1 + htdocs/main.inc.php | 12 +++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 2e837fcbaae..2d92bc8f938 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -31,8 +31,17 @@ if (! isset($usedbyinclude) || empty($usedbyinclude)) if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','1'); $res=@include '../../main.inc.php'; + if ($res == 'ERROR_NOT_LOGGED') + { + $langs->load("other"); + $arrayresult['jumptologin']=array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); + exit; + } } include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index e519f7af405..bd52f5dcaa2 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -18,6 +18,7 @@ NextMonthOfInvoice=Following month (number 1-12) of invoice date TextNextMonthOfInvoice=Following month (text) of invoice date ZipFileGeneratedInto=Zip file generated into %s. DocFileGeneratedInto=Doc file generated into %s. +JumpToLogin=Disconnected. Go to login page... YearOfInvoice=Year of invoice date PreviousYearOfInvoice=Previous year of invoice date diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1edc67d582f..090a35d6c83 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -457,9 +457,7 @@ if (! defined('NOLOGIN')) $passwordtotest = GETPOST('password','none',2); $entitytotest = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1)); - // Validation of login/pass/entity - // If ok, the variable login will be returned - // If error, we will put error message in session under the name dol_loginmesg + // Define if we received data to test the login. $goontestloop=false; if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true; if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) $goontestloop=true; @@ -473,6 +471,9 @@ if (! defined('NOLOGIN')) $langs->setDefaultLang($langcode); } + // Validation of login/pass/entity + // If ok, the variable login will be returned + // If error, we will put error message in session under the name dol_loginmesg if ($test && $goontestloop) { $login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode); @@ -531,9 +532,10 @@ if (! defined('NOLOGIN')) // End test login / passwords if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest))) // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success. { - // We show login page + // No data to test login, so we show the login page dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." showing the login form and exit"); - dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:'')); + if (defined('NOREDIRECTBYMAINTOLOGIN')) return 'ERROR_NOT_LOGGED'; + else dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:'')); exit; } From 0963a649b7c359d825d27c0054f3099980275fa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2017 23:49:28 +0200 Subject: [PATCH 073/130] Update doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index cdbd8ce4b95..2417a7db682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ NEW: Add a payment module for Stripe. NEW: Add module "Product variant" (like red, blue for the product shoes) NEW: Accountancy - Activate multi-journal & Add journal_label to database (FEC) NEW: Add a tracking id into mass emailing. +NEW: Tax system more compatible with the new tax roollout in India (IGST / CGST / SGST). NEW: Add calculation function for Loan schedule NEW: Add "depends on" and "required by" into module informations NEW: Add hidden option THIRDPARTY_INCLUDE_PARENT_IN_LINKTO From 63b8835885e3abebd8af584961af9c5c82a47152 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 23 Jul 2017 11:42:18 +0200 Subject: [PATCH 074/130] Fix: remove unused $_COOKIE['DOLENTITY'] --- htdocs/master.inc.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index fc1c41895a4..a8d068cfd7d 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -160,10 +160,6 @@ else if (defined('DOLENTITY') && is_numeric(DOLENTITY)) // For public page wit { $conf->entity = DOLENTITY; } -else if (!empty($_COOKIE['DOLENTITY'])) // For other application with MultiCompany module (TODO: We should remove this. entity to use should never be stored into client side) -{ - $conf->entity = $_COOKIE['DOLENTITY']; -} // Sanitize entity if (! is_numeric($conf->entity)) $conf->entity=1; From c934f1bd13cce511ce8013ad8a717cb5140fad63 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 23 Jul 2017 12:07:20 +0200 Subject: [PATCH 075/130] Fix: remove unused old code --- htdocs/user/logout.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 37ff691fdcc..4421c6d6298 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -50,13 +50,6 @@ if ($result < 0) { $error++; } // Define url to go after disconnect $urlfrom=empty($_SESSION["urlfrom"])?'':$_SESSION["urlfrom"]; -// Destroy some cookies -// TODO external module -if (! empty($conf->phenix->enabled) && ! empty($conf->phenix->cookie)) -{ - setcookie($conf->phenix->cookie, '', 1, "/"); -} - // Define url to go $url=DOL_URL_ROOT."/index.php"; // By default go to login page if ($urlfrom) $url=DOL_URL_ROOT.$urlfrom; From 336400d9ea709863dcabf7475906bee6c9b15acb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Jul 2017 16:20:53 +0200 Subject: [PATCH 076/130] Can clone a page onto another website --- htdocs/core/class/html.formwebsite.class.php | 1254 ++++++++++++++++++ htdocs/websites/class/websitepage.class.php | 4 +- htdocs/websites/index.php | 9 +- 3 files changed, 1263 insertions(+), 4 deletions(-) create mode 100644 htdocs/core/class/html.formwebsite.class.php diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php new file mode 100644 index 00000000000..666311d1744 --- /dev/null +++ b/htdocs/core/class/html.formwebsite.class.php @@ -0,0 +1,1254 @@ + + * + * 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 . + */ + +/** + * \file htdocs/core/class/html.formwebsite.class.php + * \ingroup core + * \brief File of class to manage component html for module website + */ + + +/** + * Class to manage component html for module website + */ +class FormWebsite +{ + private $db; + public $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + + return 1; + } + + + /** + * Return HTML select list of export models + * + * @param string $selected Id modele pre-selectionne + * @param string $htmlname Name of HTML select + * @param int $useempty Show empty value or not + * @return string Html component + */ + function selectWebsite($selected='',$htmlname='exportmodelid',$useempty=0) + { + $out=''; + + $sql = "SELECT rowid, ref"; + $sql.= " FROM ".MAIN_DB_PREFIX."website"; + $sql.= " WHERE 1 = 1"; + $sql.= " ORDER BY rowid"; + $result = $this->db->query($sql); + if ($result) + { + $out.='"; + } + else { + dol_print_error($this->db); + } + + return $out; + } + + + /** + * Return list of export models + * + * @param string $selected Id modele pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string $type Type des modeles recherches + * @param int $useempty Affiche valeur vide dans liste + * @return void + */ + function select_import_model($selected='',$htmlname='importmodelid',$type='',$useempty=0) + { + $sql = "SELECT rowid, label"; + $sql.= " FROM ".MAIN_DB_PREFIX."import_model"; + $sql.= " WHERE type = '".$type."'"; + $sql.= " ORDER BY rowid"; + $result = $this->db->query($sql); + if ($result) + { + print '"; + } + else { + dol_print_error($this->db); + } + } + + + /** + * Return list of ecotaxes with label + * + * @param string $selected Preselected ecotaxes + * @param string $htmlname Name of combo list + * @return integer + */ + function select_ecotaxes($selected='',$htmlname='ecotaxe_id') + { + global $langs; + + $sql = "SELECT e.rowid, e.code, e.libelle, e.price, e.organization,"; + $sql.= " c.label as country"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; + $sql.= " ORDER BY country, e.organization ASC, e.code ASC"; + + dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + print ''; + return 0; + } + else + { + dol_print_error($this->db); + return 1; + } + } + + + /** + * Return list of revenue stamp for country + * + * @param string $selected Value of preselected revenue stamp + * @param string $htmlname Name of combo list + * @param string $country_code Country Code + * @return string HTML select list + */ + function select_revenue_stamp($selected='',$htmlname='revenuestamp',$country_code='') + { + global $langs; + + $out=''; + + $sql = "SELECT r.taux"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_revenuestamp as r,".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE r.active = 1 AND r.fk_pays = c.rowid"; + $sql.= " AND c.code = '".$country_code."'"; + + dol_syslog(get_class($this).'::select_revenue_stamp', LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $out.=''; + return $out; + } + else + { + dol_print_error($this->db); + return ''; + } + } + + + /** + * Return a HTML select list to select a percent + * + * @param integer $selected pourcentage pre-selectionne + * @param string $htmlname nom de la liste deroulante + * @param int $disabled Disabled or not + * @param int $increment increment value + * @param int $start start value + * @param int $end end value + * @param int $showempty Add also an empty line + * @return string HTML select string + */ + function select_percent($selected=0,$htmlname='percent',$disabled=0,$increment=5,$start=0,$end=100,$showempty=0) + { + $return = ''; + + return $return; + } + + /** + * Return select list for categories (to use in form search selectors) + * + * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. + * @param integer $selected Preselected value + * @param string $htmlname Name of combo list + * @param int $nocateg Show also an entry "Not categorized" + * @param int $showempty Add also an empty line + * @param string $morecss More CSS + * @return string Html combo list code + * @see select_all_categories + */ + function select_categories($type, $selected=0, $htmlname='search_categ', $nocateg=0, $showempty=1, $morecss='') + { + global $conf, $langs; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + + // For backward compatibility + if (is_numeric($type)) + { + dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + } + + // Load list of "categories" + $static_categs = new Categorie($this->db); + $tab_categs = $static_categs->get_full_arbo($type); + + $moreforfilter = ''; + // Enhance with select2 + if ($conf->use_javascript_ajax) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox('select_categ_'.$htmlname); + $moreforfilter.=$comboenhancement; + } + + // Print a select with each of them + $moreforfilter.=''; + + return $moreforfilter; + } + + + /** + * Return select list for categories (to use in form search selectors) + * + * @param string $selected Preselected value + * @param string $htmlname Name of combo list (example: 'search_sale') + * @param User $user Object user + * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status + * @param int $showempty 1=show also an empty value + * @param string $morecss More CSS + * @return string Html combo list code + */ + function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0,$showempty=1,$morecss='') + { + global $conf,$langs; + $langs->load('users'); + + $out = ''; + // Enhance with select2 + if ($conf->use_javascript_ajax) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + + $comboenhancement = ajax_combobox($htmlname); + if ($comboenhancement) + { + $out.=$comboenhancement; + } + } + // Select each sales and print them in a select input + $out.=''; + + return $out; + } + + /** + * Return list of project and tasks + * + * @param int $selectedtask Pre-selected task + * @param int $projectid Project id + * @param string $htmlname Name of html select + * @param int $modeproject 1 to restrict on projects owned by user + * @param int $modetask 1 to restrict on tasks associated to user + * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists + * @param int $useempty 0=Allow empty values + * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id + * @return void + */ + function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0, $disablechildoftaskid=0) + { + global $user, $langs; + + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + + //print $modeproject.'-'.$modetask; + $task=new Task($this->db); + $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode); + if ($tasksarray) + { + print ''; + } + else + { + print '
'.$langs->trans("NoProject").'
'; + } + } + + /** + * Write lines of a project (all lines of a project if parent = 0) + * + * @param int $inc Cursor counter + * @param int $parent Id of parent task we want to see + * @param array $lines Array of task lines + * @param int $level Level + * @param int $selectedtask Id selected task + * @param int $selectedproject Id selected project + * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id + * @return void + */ + private function _pLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0, $disablechildoftaskid=0) + { + global $langs, $user, $conf; + + $lastprojectid=0; + + $numlines=count($lines); + for ($i = 0 ; $i < $numlines ; $i++) + { + if ($lines[$i]->fk_parent == $parent) + { + $var = !$var; + + //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines + + // Break on a new project + if ($parent == 0) // We are on a task at first level + { + if ($lines[$i]->fk_project != $lastprojectid) // Break found on project + { + if ($i > 0) print ''; + print '\n"; + + $lastprojectid=$lines[$i]->fk_project; + $inc++; + } + } + + $newdisablechildoftaskid=$disablechildoftaskid; + + // Print task + if (isset($lines[$i]->id)) // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0 + { + // Check if we must disable entry + $disabled=0; + if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid))) + { + $disabled++; + if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid=$lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too + } + + print '\n"; + $inc++; + } + + $level++; + if ($lines[$i]->id) $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid); + $level--; + } + } + } + + + /** + * Output a HTML thumb of color or a text if not defined. + * + * @param string $color String with hex (FFFFFF) or comma RGB ('255,255,255') + * @param string $textifnotdefined Text to show if color not defined + * @return string HTML code for color thumb + * @see selectColor + */ + static function showColor($color, $textifnotdefined='') + { + $textcolor='FFF'; + if ($color) + { + $tmp=explode(',', $color); + if (count($tmp) > 1) // This is a comma RGB ('255','255','255') + { + $r = $tmp[0]; + $g = $tmp[1]; + $b = $tmp[2]; + } + else + { + $hexr=$color[0].$color[1]; + $hexg=$color[2].$color[3]; + $hexb=$color[4].$color[5]; + $r = hexdec($hexr); + $g = hexdec($hexg); + $b = hexdec($hexb); + } + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright > 0.6) $textcolor='000'; + } + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $color = colorArrayToHex(colorStringToArray($color,array()),''); + + if ($color) print ''; + else print $textifnotdefined; + } + + /** + * Output a HTML code to select a color + * + * @param string $set_color Pre-selected color + * @param string $prefix Name of HTML field + * @param string $form_name Deprecated. Not used. + * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code + * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') + * @return void + * @deprecated Use instead selectColor + * @see selectColor() + */ + function select_color($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='') + { + print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors); + } + + /** + * Output a HTML code to select a color. Field will return an hexa color like '334455'. + * + * @param string $set_color Pre-selected color + * @param string $prefix Name of HTML field + * @param string $form_name Deprecated. Not used. + * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code + * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813') + * @param string $morecss Add css style into input field + * @return string + * @see showColor + */ + static function selectColor($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='', $morecss='') + { + // Deprecation warning + if ($form_name) { + dol_syslog(__METHOD__ . ": form_name parameter is deprecated", LOG_WARNING); + } + + global $langs,$conf; + + $out=''; + + if (! is_array($arrayofcolors) || count($arrayofcolors) < 1) + { + $langs->load("other"); + if (empty($conf->dol_use_jmobile)) + { + $out.= ''; + $out.= ''; + $out.= ''; + } + $out.= ''; + } + else // In most cases, this is not used. We used instead function with no specific list of colors + { + if (empty($conf->dol_use_jmobile)) + { + $out.= ''; + $out.= ''; + $out.= ''; + } + $out.= ''; + } + + return $out; + } + + /** + * Creation d'un icone de couleur + * + * @param string $color Couleur de l'image + * @param string $module Nom du module + * @param string $name Nom de l'image + * @param int $x Largeur de l'image en pixels + * @param int $y Hauteur de l'image en pixels + * @return void + */ + function CreateColorIcon($color,$module,$name,$x='12',$y='12') + { + global $conf; + + $file = $conf->$module->dir_temp.'/'.$name.'.png'; + + // On cree le repertoire contenant les icones + if (! file_exists($conf->$module->dir_temp)) + { + dol_mkdir($conf->$module->dir_temp); + } + + // On cree l'image en vraies couleurs + $image = imagecreatetruecolor($x,$y); + + $color = substr($color,1,6); + + $rouge = hexdec(substr($color,0,2)); //conversion du canal rouge + $vert = hexdec(substr($color,2,2)); //conversion du canal vert + $bleu = hexdec(substr($color,4,2)); //conversion du canal bleu + + $couleur = imagecolorallocate($image,$rouge,$vert,$bleu); + //print $rouge.$vert.$bleu; + imagefill($image,0,0,$couleur); //on remplit l'image + // On cree la couleur et on l'attribue a une variable pour ne pas la perdre + ImagePng($image,$file); //renvoie une image sous format png + ImageDestroy($image); + } + + /** + * Return HTML combo list of week + * + * @param string $selected Preselected value + * @param string $htmlname Nom de la zone select + * @param int $useempty Affiche valeur vide dans liste + * @return string + */ + function select_dayofweek($selected='',$htmlname='weekid',$useempty=0) + { + global $langs; + + $week = array( 0=>$langs->trans("Day0"), + 1=>$langs->trans("Day1"), + 2=>$langs->trans("Day2"), + 3=>$langs->trans("Day3"), + 4=>$langs->trans("Day4"), + 5=>$langs->trans("Day5"), + 6=>$langs->trans("Day6")); + + $select_week = ''; + return $select_week; + } + + /** + * Return HTML combo list of month + * + * @param string $selected Preselected value + * @param string $htmlname Name of HTML select object + * @param int $useempty Show empty in list + * @param int $longlabel Show long label + * @return string + */ + function select_month($selected='',$htmlname='monthid',$useempty=0,$longlabel=0) + { + global $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + if ($longlabel) $montharray = monthArray($langs, 0); // Get array + else $montharray = monthArray($langs, 1); + + $select_month = ''; + return $select_month; + } + + /** + * Return HTML combo list of years + * + * @param string $selected Preselected value (''=current year, -1=none, year otherwise) + * @param string $htmlname Name of HTML select object + * @param int $useempty Affiche valeur vide dans liste + * @param int $min_year Offset of minimum year into list (by default current year -10) + * @param int $max_year Offset of maximum year into list (by default current year + 5) + * @param int $offset Offset + * @param int $invert Invert + * @param string $option Option + * @return string + */ + function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') + { + print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option); + } + + /** + * Return HTML combo list of years + * + * @param string $selected Preselected value (''=current year, -1=none, year otherwise) + * @param string $htmlname Name of HTML select object + * @param int $useempty Affiche valeur vide dans liste + * @param int $min_year Offset of minimum year into list (by default current year -10) + * @param int $max_year Offset of maximum year into list (by default current year + 5) + * @param int $offset Offset + * @param int $invert Invert + * @param string $option Option + * @return string + */ + function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') + { + $out=''; + + $currentyear = date("Y")+$offset; + $max_year = $currentyear+$max_year; + $min_year = $currentyear-$min_year; + if(empty($selected) && empty($useempty)) $selected = $currentyear; + + $out.= '\n"; + + return $out; + } + + /** + * Show form to select address + * + * @param int $page Page + * @param string $selected Id condition pre-selectionne + * @param int $socid Id of third party + * @param string $htmlname Nom du formulaire select + * @param string $origin Origine de l'appel pour pouvoir creer un retour + * @param int $originid Id de l'origine + * @return void + */ + function form_address($page, $selected, $socid, $htmlname='address_id', $origin='', $originid='') + { + global $langs,$conf; + global $form; + + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + $form->select_address($selected, $socid, $htmlname, 1); + print ''; + $langs->load("companies"); + print '   '.$langs->trans("AddAddress").''; + print '
'; + } + else + { + if ($selected) + { + require_once DOL_DOCUMENT_ROOT .'/societe/class/address.class.php'; + $address=new Address($this->db); + $result=$address->fetch_address($selected); + print ''.$address->label.''; + } + else + { + print " "; + } + } + } + + + + /** + * Get array with HTML tabs with boxes of a particular area including personalized choices of user. + * Class 'Form' must be known. + * + * @param User $user Object User + * @param String $areacode Code of area for pages ('0'=value for Home page) + * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) + */ + static function getBoxesArea($user,$areacode) + { + global $conf,$langs,$db; + + include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + + $confuserzone='MAIN_BOXES_'.$areacode; + + // $boxactivated will be array of boxes enabled into global setup + // $boxidactivatedforuser will be array of boxes choosed by user + + $selectboxlist=''; + $boxactivated=InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone)?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) + + $boxidactivatedforuser=array(); + foreach($boxactivated as $box) + { + if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user + } + + // Define selectboxlist + $arrayboxtoactivatelabel=array(); + if (! empty($user->conf->$confuserzone)) + { + $boxorder=''; + $langs->load("boxes"); // Load label of boxes + foreach($boxactivated as $box) + { + if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user + $label=$langs->transnoentitiesnoconv($box->boxlabel); + if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')'; + //$label = ''.$label; KO with select2. No html rendering. + $arrayboxtoactivatelabel[$box->id]=$label; // We keep only boxes not shown for user, to show into combo list + } + foreach($boxidactivatedforuser as $boxid) + { + if (empty($boxorder)) $boxorder.='A:'; + $boxorder.=$boxid.','; + } + + //var_dump($boxidactivatedforuser); + + // Class Form must have been already loaded + $selectboxlist.='
'; + $selectboxlist.=''; + $selectboxlist.=''; + $selectboxlist.=''; + $selectboxlist.=''; + $selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); + if (empty($conf->use_javascript_ajax)) $selectboxlist.=' '; + $selectboxlist.='
'; + $selectboxlist.=ajax_combobox("boxcombo"); + } + + // Javascript code for dynamic actions + if (! empty($conf->use_javascript_ajax)) + { + $selectboxlist.=''."\n"; + } + + // Define boxlista and boxlistb + $nbboxactivated=count($boxidactivatedforuser); + + if ($nbboxactivated) + { + $langs->load("boxes"); + $langs->load("projects"); + + $emptybox=new ModeleBoxes($db); + + $boxlista.="\n\n"; + $boxlista.='
'."\n"; + + // Define $box_max_lines + $box_max_lines=5; + if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES; + + $ii=0; + foreach ($boxactivated as $key => $box) + { + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 + if (preg_match('/^A/i',$box->box_order)) // column A + { + $ii++; + //print 'box_id '.$boxactivated[$ii]->box_id.' '; + //print 'box_order '.$boxactivated[$ii]->box_order.'
'; + // Show box + $box->loadBox($box_max_lines); + $boxlista.= $box->outputBox(); + } + } + + if (empty($conf->browser->phone)) + { + $emptybox->box_id='A'; + $emptybox->info_box_head=array(); + $emptybox->info_box_contents=array(); + $boxlista.= $emptybox->outputBox(array(),array()); + } + $boxlista.= "
\n"; + $boxlista.= "\n"; + + $boxlistb.= "\n\n"; + $boxlistb.= '\n"; + $boxlistb.= "\n"; + + } + + return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb); + } + + + /** + * Return a HTML select list of bank accounts + * + * @param string $htmlname Name of select zone + * @param string $dictionarytable Dictionary table + * @param string $keyfield Field for key + * @param string $labelfield Label field + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function select_dictionary($htmlname,$dictionarytable,$keyfield='code',$labelfield='label',$selected='',$useempty=0,$moreattrib='') + { + global $langs, $conf; + + $langs->load("admin"); + + $sql = "SELECT rowid, ".$keyfield.", ".$labelfield; + $sql.= " FROM ".MAIN_DB_PREFIX.$dictionarytable; + $sql.= " ORDER BY ".$labelfield; + + dol_syslog(get_class($this)."::select_dictionary", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + if ($num) + { + print '"; + } + else + { + print $langs->trans("DictionaryEmpty"); + } + } + else { + dol_print_error($this->db); + } + } + +} + diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 73158fac7be..7d5e59830e1 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -500,9 +500,10 @@ class WebsitePage extends CommonObject * @param string $newref New ref/alias of page * @param string $newlang New language * @param int $istranslation 1=New page is a translation of the cloned page. + * @param int $newwebsite 0=Same web site, 1=New web site * @return int New id of clone */ - public function createFromClone($fromid, $newref, $newlang='', $istranslation=0) + public function createFromClone($fromid, $newref, $newlang='', $istranslation=0, $newwebsite=0) { global $user, $langs; @@ -525,6 +526,7 @@ class WebsitePage extends CommonObject if (! empty($newlang)) $object->lang=$newlang; if ($istranslation) $object->fk_page = $fromid; else $object->fk_page = 0; + if (! empty($newwebsite)) $object->fk_website=$newwebsite; // Create clone $result = $object->create($user); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index d692295d2a5..14bb0b3a90f 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -66,12 +66,12 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, } - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; @@ -549,7 +549,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if (! $error) { $objectpage = new WebsitePage($db); - $result = $objectpage->createFromClone($pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation); + $result = $objectpage->createFromClone($pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation, GETPOST('newwebsite','int')); if ($result < 0) { $error++; @@ -745,6 +745,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $form = new Form($db); $formadmin = new FormAdmin($db); +$formwebsite = new FormWebsite($db); $help_url=''; @@ -958,7 +959,9 @@ if (count($object->records) > 0) $formquestion = array( array('type' => 'text', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME") ,'value'=> 'copy_of_'.$objectpage->pageurl), array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200'))); + array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), + array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("Website"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) + ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 250); From 7eee529c9f166dad8a77cd08cf1c69c18012895f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Jul 2017 16:28:56 +0200 Subject: [PATCH 077/130] Can use - and _ into website alias --- htdocs/websites/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 14bb0b3a90f..c8ba93c86f1 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -174,10 +174,11 @@ if ($action == 'add') $error++; $action='create'; } - else if (! preg_match('/^[a-z0-9]+$/i', $objectpage->pageurl)) + else if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) { - $error++; setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); + $error++; + $action='create'; } if (empty($objectpage->title)) { From f3de6cfd3275b29cbee9323d6fb57c316415c53c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Jul 2017 17:44:26 +0200 Subject: [PATCH 078/130] Support for robots and .htaccess file --- htdocs/websites/index.php | 125 ++++++++++++++++++++++++++++++++++---- 1 file changed, 112 insertions(+), 13 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index c8ba93c86f1..0f1e813e3ed 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -138,6 +138,8 @@ global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; $filehtmlheader=$pathofwebsite.'/htmlheader.html'; $filecss=$pathofwebsite.'/styles.css.php'; +$filerobot=$pathofwebsite.'/robots.txt'; +$filehtaccess=$pathofwebsite.'/.htaccess'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -311,7 +313,6 @@ if ($action == 'updatecss') $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; $csscontent.= "// END PHP ?>"."\n"; - dol_syslog("Save file css into ".$filecss); dol_mkdir($pathofwebsite); @@ -326,6 +327,70 @@ if ($action == 'updatecss') } + // Css file + $robotcontent =''; + + /*$robotcontent.= "\n";*/ + + $robotcontent.= GETPOST('WEBSITE_ROBOT'); + + /*$robotcontent.= "\n".'"."\n";*/ + + dol_syslog("Save file robot into ".$filerobot); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filerobot, $robotcontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); + + if (! $result) + { + $error++; + setEventMessages('Failed to write file '.$filerobot, null, 'errors'); + } + + + // Css file + $htaccesscontent =''; + + /*$robotcontent.= "\n";*/ + + $htaccesscontent.= GETPOST('WEBSITE_HTACCESS'); + + /*$robotcontent.= "\n".'"."\n";*/ + + dol_syslog("Save file htaccess into ".$filehtaccess); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filehtaccess, $htaccesscontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); + + if (! $result) + { + $error++; + setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); + } + + // Message if no error if (! $error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -1098,30 +1163,49 @@ if ($action == 'editcss') $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $csscontent); - $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); - if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n".'body.bodywebsite { margin: 0; }'; - $htmlheader = @file_get_contents($filehtmlheader); // Clean the php htmlheader file to remove php code and get only html part $htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $htmlheader); - if (! trim($htmlheader)) $htmlheader=''."\n".''."\n".''; else $htmlheader=''."\n".$htmlheader."\n".''; + $robotcontent = @file_get_contents($filerobot); + // Clean the php htmlheader file to remove php code and get only html part + $robotcontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $robotcontent); + if (! trim($robotcontent)) + { + $robotcontent.="# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; + $robotcontent.="User-agent: *\n"; + $robotcontent.="Allow: /public/\n"; + $robotcontent.="Disallow: /administrator/\n"; + } + + $htaccesscontent = @file_get_contents($filehtaccess); + // Clean the php htmlheader file to remove php code and get only html part + $htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $htaccesscontent); + if (! trim($htaccesscontent)) + { + $htaccesscontent.="# Order allow,deny\n"; + $htaccesscontent.="# Deny from all\n"; + } + //else $htaccesscontent=''."\n".$htaccesscontent."\n".'';*/ + dol_fiche_head(); print ''."\n"; print ''; + // Website print ''; + // CSS file print ''; + // Common HTML header print ''; + + // Robot file + print ''; + + // .htaccess + print ''; print '
'; print $langs->trans('WebSite'); print ''; print $website; print '
'; print $langs->trans('WEBSITE_CSS_INLINE'); print ''; @@ -1129,11 +1213,9 @@ if ($action == 'editcss') $doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'CSS', 'css'); - /*print '';*/ print '
'; print $langs->trans('WEBSITE_HTML_HEADER'); print ''; @@ -1141,9 +1223,26 @@ if ($action == 'editcss') $doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheader, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'HTML Header', 'html'); - /*print '';*/ + print '
'; + print $langs->trans('WEBSITE_ROBOT'); + print ''; + + $doleditor=new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + print $doleditor->Create(1, '', true, 'Robot file', 'txt'); + + print '
'; + print $langs->trans('WEBSITE_HTACCESS'); + print ''; + + $doleditor=new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'txt'); + print '
'; @@ -1242,7 +1341,7 @@ if ($action == 'editsource') * Editing global variables not related to a specific theme */ - $csscontent = @file_get_contents($filecss); + //$csscontent = @file_get_contents($filecss); $contentforedit = ''; /*$contentforedit.='