From 3eb5b06472ac674f4bad2f027375ca9ec81aeb4e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Dec 2018 22:26:06 +0100 Subject: [PATCH 01/20] FIX: Generation of FEC:CompteLib --- htdocs/accountancy/journal/bankjournal.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6e6a84b1884..172ae6e3748 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -573,35 +573,35 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'payment_donation') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'payment_loan') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else { if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. From cbcf097ec1761f2a8cf9af2642c65f6bedb2535d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 29 Dec 2018 23:20:30 +0100 Subject: [PATCH 02/20] FIX: #10221 Html codes in accounting export --- htdocs/accountancy/journal/bankjournal.php | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6e6a84b1884..e19658ad87f 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1152,28 +1152,28 @@ function getSourceDocRef($val, $typerecord) // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING $ref = $val['ref']; if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { - $ref = $langs->trans('Supplier'); + $ref = $langs->transnoentitiesnoconv('Supplier'); } if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { - $ref = $langs->trans('Customer'); + $ref = $langs->transnoentitiesnoconv('Customer'); } if ($ref == '(SocialContributionPayment)') { - $ref = $langs->trans('SocialContribution'); + $ref = $langs->transnoentitiesnoconv('SocialContribution'); } if ($ref == '(DonationPayment)') { - $ref = $langs->trans('Donation'); + $ref = $langs->transnoentitiesnoconv('Donation'); } if ($ref == '(SubscriptionPayment)') { - $ref = $langs->trans('Subscription'); + $ref = $langs->transnoentitiesnoconv('Subscription'); } if ($ref == '(ExpenseReportPayment)') { - $ref = $langs->trans('Employee'); + $ref = $langs->transnoentitiesnoconv('Employee'); } if ($ref == '(LoanPayment)') { - $ref = $langs->trans('Loan'); + $ref = $langs->transnoentitiesnoconv('Loan'); } if ($ref == '(payment_salary)') { - $ref = $langs->trans('Employee'); + $ref = $langs->transnoentitiesnoconv('Employee'); } $sqlmid = ''; @@ -1182,63 +1182,63 @@ function getSourceDocRef($val, $typerecord) $sqlmid = 'SELECT payfac.fk_facture as id, f.facnumber as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; - $ref = $langs->trans("Invoice"); + $ref = $langs->transnoentitiesnoconv("Invoice"); } elseif ($typerecord == 'payment_supplier') { $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; - $ref = $langs->trans("SupplierInvoice"); + $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); } elseif ($typerecord == 'payment_expensereport') { $sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; - $ref = $langs->trans("ExpenseReport"); + $ref = $langs->transnoentitiesnoconv("ExpenseReport"); } elseif ($typerecord == 'payment_salary') { $sqlmid = 'SELECT s.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; - $ref = $langs->trans("SalaryPayment"); + $ref = $langs->transnoentitiesnoconv("SalaryPayment"); } elseif ($typerecord == 'sc') { $sqlmid = 'SELECT sc.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; $sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"]; - $ref = $langs->trans("SocialContribution"); + $ref = $langs->transnoentitiesnoconv("SocialContribution"); } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; - $ref = $langs->trans("PaymentVat"); + $ref = $langs->transnoentitiesnoconv("PaymentVat"); } elseif ($typerecord == 'payment_donation') { $sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; - $ref = $langs->trans("Donation"); + $ref = $langs->transnoentitiesnoconv("Donation"); } elseif ($typerecord == 'payment_loan') { $sqlmid = 'SELECT l.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; $sqlmid .= " WHERE l.rowid=" . $val["paymentloanid"]; - $ref = $langs->trans("LoanPayment"); + $ref = $langs->transnoentitiesnoconv("LoanPayment"); } elseif ($typerecord == 'payment_various') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; - $ref = $langs->trans("VariousPayment"); + $ref = $langs->transnoentitiesnoconv("VariousPayment"); } // Add warning if (empty($sqlmid)) @@ -1260,6 +1260,6 @@ function getSourceDocRef($val, $typerecord) else dol_print_error($db); } - $ref = dol_trunc($langs->trans("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 return $ref; } From a2075b9d2c771dc68a90f579c14209f013af8b5a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 30 Dec 2018 20:32:44 +0100 Subject: [PATCH 03/20] V9 look & Feel, etc --- htdocs/compta/sociales/list.php | 2 +- htdocs/compta/tva/list.php | 2 +- htdocs/langs/en_US/blockedlog.lang | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 636cb92978a..be3e7ea5791 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/compta/list/index.php + * \file htdocs/compta/sociales/list.php * \ingroup tax * \brief Page to list all social contributions */ diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 7c0d813c2cb..f0bb433c65c 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -166,7 +166,7 @@ if ($result) print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit); print '
'; - print ''; + print '
'."\n"; print ''; print ''; diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 0dac5a6fd8c..5081b1c0384 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,6 +1,6 @@ BlockedLog=Unalterable Logs Field=Field -BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF535). +BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF525). Fingerprints=Archived events and fingerprints FingerprintsDesc=This is the tool to browse or extract the unalterable logs. Unalterable logs are generated and archived locally into a dedicated table, in real time when you record a business event. You can use this tool to export this archive and save it into an external support (some countries, like France, ask that you do it every year). Note that, there is no feature to purge this log and every change tried to be done directly into this log (by a hacker for example) will be reported with a non-valid fingerprint. If you really need to purge this table because you used your application for a demo/test purpose and want to clean your data to start your production, you can ask your reseller or integrator to reset your database (all your data will be removed). CompanyInitialKey=Company initial key (hash of genesis block) From c4dbf415302002736e73dcf843af8b173c9d0d55 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 30 Dec 2018 21:21:40 +0100 Subject: [PATCH 04/20] Look & feel --- htdocs/compta/bank/treso.php | 77 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index ef471aea693..3d9ba5e376d 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -115,11 +115,10 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print ''; print ''; - print ''; + print ''; print ''; // Current balance - print ''; print ''; print ''; @@ -133,7 +132,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Remainder to pay in future - $sqls = array(); + $sqls = array(); // Customer invoices $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; @@ -142,9 +141,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice - $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Supplier invoices $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; @@ -153,51 +152,51 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql.= " WHERE ff.entity = ".$conf->entity; $sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice - $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Social contributions $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; - $sql.= ", cs.fk_account"; + $sql.= ", cs.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; $sql.= " WHERE cs.entity = ".$conf->entity; $sql.= " AND cs.paye = 0"; // Not paid - $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution + $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sqls[] = $sql; - // others sql - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if(empty($reshook) and isset($hookmanager->resArray['sql'])){ - $sqls[] = $hookmanager->resArray['sql']; - } + // others sql + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook) and isset($hookmanager->resArray['sql'])){ + $sqls[] = $hookmanager->resArray['sql']; + } $error=0; $tab_sqlobjOrder=array(); $tab_sqlobj=array(); - foreach($sqls as $sql){ - $resql = $db->query($sql); - if($resql){ - while($sqlobj = $db->fetch_object($resql)){ - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($resql); - }else{ - $error++; - } - } + foreach($sqls as $sql){ + $resql = $db->query($sql); + if($resql){ + while($sqlobj = $db->fetch_object($resql)){ + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); + } + $db->free($resql); + }else{ + $error++; + } + } // Sort array if (! $error) { array_multisort($tab_sqlobjOrder,$tab_sqlobj); - //Apply distinct filter + // Apply distinct filter foreach ($tab_sqlobj as $key=>$value) { $tab_sqlobj[$key] = "'" . serialize($value) . "'"; } @@ -262,13 +261,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done } - $parameters = array('obj' => $obj); - $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if(empty($reshook)){ - $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; - $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; - $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; - } + $parameters = array('obj' => $obj); + $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; + $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; + $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; + } $total_ttc = $obj->total_ttc; if ($paiement) $total_ttc = $obj->total_ttc - $paiement; @@ -307,7 +306,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; } - // solde + // solde print ''; print ''; print ''; From 8b380489f249f379c943c3506222edc5e70e1ae9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jan 2019 19:53:59 +0100 Subject: [PATCH 05/20] Update commonobject.class.php Conflicts: htdocs/core/class/commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3b7da9fc1ed..bc414ed722c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5024,8 +5024,6 @@ abstract class CommonObject $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $new_array_options[$key] = $this->db->idate($this->array_options[$key]); - break; case 'datetime': // If data is a string instead of a timestamp, we convert it if (! is_int($this->array_options[$key])) { From 5f9bbbcdd77a5637d759cf0d9e42c2230507d0cf Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Thu, 3 Jan 2019 11:12:14 +0100 Subject: [PATCH 06/20] Fix migration --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 28d080584d1..b2842a39548 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -180,6 +180,7 @@ CREATE TABLE llx_emailcollector_emailcollector( -- END MODULEBUILDER FIELDS ) ENGINE=innodb; +ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN login varchar(128); ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_entity (entity); ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status); From dbbfdd984a846bf25b5bf5142edd647dad2cc391 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Thu, 3 Jan 2019 11:47:27 +0100 Subject: [PATCH 07/20] Fix emailcollector can't be used without syntax rules --- htdocs/admin/emailcollector_card.php | 9 +- htdocs/admin/emailcollector_list.php | 94 ++++++++++--------- htdocs/core/class/html.form.class.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + .../modulebuilder/template/myobject_list.php | 19 ++-- 5 files changed, 71 insertions(+), 54 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 2fb5013b4f9..eaef18c9543 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -384,7 +384,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringserver = ''; $connectstringsource = ''; $connectstringtarget = ''; - + if (function_exists('imap_open')) { $connectstringserver = $object->getConnectStringIMAP(); @@ -397,7 +397,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $morehtml .= 'IMAP functions not available on your PHP'; } - + if (! $connection) { $morehtml .= 'Failed to open IMAP connection '.$connectstringsource; @@ -412,7 +412,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { imap_close($connection); } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'
'.$morehtml.'
', '', 0, '', '', 0, ''); print '
'; @@ -487,6 +487,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); print '
'; print ''; print ''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 71169ddffb0..cacebb8e55d 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -120,8 +120,6 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); /* * Actions - * - * Put here all code to do according to value of "$action" parameter */ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } @@ -165,8 +163,6 @@ if (empty($reshook)) /* * View - * - * Put here all code to render page */ $form=new Form($db); @@ -212,20 +208,20 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object) $sql.=$hookmanager->resPrint; /* If a group by is required - $sql.= " GROUP BY " - foreach($object->fields as $key => $val) - { - $sql.='t.'.$key.', '; - } - // Add fields from extrafields - if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; - $sql=preg_replace('/, $/','', $sql); - */ +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +*/ $sql.=$db->order($sortfield,$sortorder); @@ -305,8 +301,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( -//'presend'=>$langs->trans("SendByMail"), -//'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -324,7 +320,7 @@ print ''; $newcardbutton=''; //if ($user->rights->emailcollector->creer) - //{ +//{ $newcardbutton=''.$langs->trans('New').''; $newcardbutton.= ''; $newcardbutton.= ''; @@ -333,6 +329,10 @@ $newcardbutton.= ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) +/*$topicmail=""; +$modelmail=""; +$objecttmp=new EmailCollector($db); +$trackid='xxxx'.$object->id;*/ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) @@ -343,8 +343,8 @@ if ($sall) $moreforfilter = ''; /*$moreforfilter.='
'; - $moreforfilter.= $langs->trans('MyFilter') . ': '; - $moreforfilter.= '
';*/ +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '';*/ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -371,11 +371,11 @@ print '
'.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").''.$langs->trans("BankBalance").'
'.$langs->trans("CurrentBalance").''.price($solde).'
'.$langs->trans("FutureBalance").' ('.$object->currency_code.')'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; print ''; + $htmltext=$langs->transnoentitiesnoconv("OperationParamDesc"); + //var_dump($htmltext); + print $form->textwithpicto('', $htmltext); print '
'; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -397,11 +397,14 @@ print ''."\n"; print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -444,15 +447,22 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; print $object->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 51a36d758ee..3c0278511d9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -450,7 +450,7 @@ class Form if ($notabs == 2) $tag='div'; if ($notabs == 3) $tag='span'; // Sanitize tooltip - $htmltext=str_replace("\\","\\\\",$htmltext); + //$htmltext=str_replace("\\","\\\\",$htmltext); $htmltext=str_replace("\r","",$htmltext); $htmltext=str_replace("\n","",$htmltext); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1606cc3a7c0..6fbc49d8359 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1846,6 +1846,7 @@ WithoutDolTrackingID=Dolibarr Tracking ID not found FormatZip=Zip MainMenuCode=Menu entry code (mainmenu) ECMAutoTree=Show automatic ECM tree +OperationParamDesc=Define values to use for action, or how to extract values. For example:
VALUE:abc
REGEX:SUBJECT:([^\s]*)
REGEX:BODY:My company name is\s([^\s]*) ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 4150ca75ca7..23c2614eb0f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -88,13 +88,13 @@ $pagenext = $page + 1; //if (! $sortorder) $sortorder="DESC"; // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('myobject'); // Load $extrafields->attributes['myobject'] -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,'','search_'); // Default sort order (if not yet defined by previous GETPOST) if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. @@ -474,11 +474,14 @@ while ($i < min($num, $limit)) print '
'; foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; $i++; } @@ -493,16 +524,12 @@ if (empty($action) || $action=="view") print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); print ""; - print '"; - print '"; - print '"; - + foreach($arrayofpaymentmode as $key => $val) + { + print '"; + } print "
'; - print ''; + print ''; print '
'.$langs->trans("Cash").''; - print price($object->cash, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans("Cheque").''; - print price($object->cheque, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans("Card").''; - print price($object->card, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print "
\n"; print '
'; @@ -516,6 +543,8 @@ if (empty($action) || $action=="view") if ($object->status == CashControl::STATUS_DRAFT) { print ''; + + print ''; } print ''; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index fdf77b17961..071be33fd1f 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -276,6 +276,18 @@ class CashControl extends CommonObject return $result; } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } /** * Return label of the status diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c85e48f09e7..a2187e3b344 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -286,7 +286,7 @@ if ($resql) print "

"; print $langs->trans("Cash").": ".price($cash)."

"; print $langs->trans("PaymentTypeCB").": ".price($bank)."

"; - print $langs->trans("PaymentTypeCheque").": ".price($cheque)."

"; + print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."

"; print "

"; //save totals to DB diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 31a6549cc27..b8b4237cc93 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -149,6 +149,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) if ($action == "update_extras" && ! empty($permissiontoadd)) { $object->fetch(GETPOST('id','int')); + $attributekey = GETPOST('attribute','alpha'); $attributekeylong = 'options_'.$attributekey; $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha'); @@ -169,6 +170,12 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) // Action to delete if ($action == 'confirm_delete' && ! empty($permissiontodelete)) { + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + $result=$object->delete($user); if ($result > 0) { diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 73b2b4f6b37..ba14b343954 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -42,4 +42,7 @@ Place=Place TakeposConnectorNecesary='TakePOS Connector' required OrderPrinters=Order printers SearchProduct=Search product -AmountAtEndOfPeriod=Amount at end of period (day, month or year) \ No newline at end of file +AmountAtEndOfPeriod=Amount at end of period (day, month or year) +TheoricalAmount=Theorical amount +RealAmount=Real amount +CashFenceDone=Cash fence done for the period \ No newline at end of file diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index f9b3db7a99e..84a23ab979d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -118,7 +118,7 @@ if (empty($reshook)) $error=0; $permissiontoadd = $user->rights->mymodule->write; - $permissiontodelete = $user->rights->mymodule->delete; + $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record From cf84fdf7c7bd9d29316365391d383d9ced19ea7b Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Thu, 3 Jan 2019 20:07:58 +0100 Subject: [PATCH 12/20] Translate option "Simplify interface for blind persons" --- ChangeLog | 2 +- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 834f274fdb3..bbc242f2747 100644 --- a/ChangeLog +++ b/ChangeLog @@ -78,7 +78,7 @@ NEW: tag odt line_product_ref_fourn for supplier doc lines NEW: The binding step in accountancy has a country filter with autocompletion NEW: Top menu is always on screen with MD theme. NEW: Withdraw request massaction can include already partially paid invoices - +NEW: Option "Simplify interface for blind persons" For developers: NEW: Add lib for multiselect with checkboxes diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6fbc49d8359..ebc0d89468b 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1855,3 +1855,5 @@ DisabledResourceLinkContact=Disable feature to link a resource to contacts ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both) +MAIN_OPTIMIZEFORTEXTBROWSER=Simplify interface for blind person +MAIN_OPTIMIZEFORTEXTBROWSERDesc=Enable this option if you are a blind person, or use application from a text browser like lynx or links. \ No newline at end of file From 1ae11c554b5e71c186563d6f9d008ea15772c459 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Thu, 3 Jan 2019 21:35:25 +0100 Subject: [PATCH 13/20] Fix regression if style --- htdocs/core/tpl/contacts.tpl.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 9ae34602ef6..f1dfdf3d7a8 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -157,6 +157,8 @@ if ($permission) { -
+
trans("User"); ?> trans("ThirdPartyContact"); ?> From 082b126c06f0473b6b2a10cf326560b39b0aec4a Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Thu, 3 Jan 2019 22:39:51 +0100 Subject: [PATCH 14/20] FIX Can't switch page when html editing without save or cancel --- htdocs/website/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index bb9d6ae43e0..16b73934fce 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1857,7 +1857,7 @@ if (! GETPOST('hide_websitemenu')) if ($action != 'addcontainer') { $out=''; - $out.=''; if ($atleastonepage) { if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one @@ -1893,7 +1893,7 @@ if (! GETPOST('hide_websitemenu')) } //print ''; - print ''; + print ''; // Print nav arrows From 5638ac8f4d2131ec55260091c5e7f1f2bede1bad Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 4 Jan 2019 15:22:59 +0100 Subject: [PATCH 15/20] FIX title on picto no more visible Conflicts: htdocs/core/lib/functions.lib.php --- htdocs/core/lib/functions.lib.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5ab77002b5f..dbae1b0264e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3015,8 +3015,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'note','switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', - 'skype','twitter','facebook' + 'note', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', + 'jabber','skype','twitter','facebook' ) )) { $fakey = $pictowithoutext; @@ -3103,16 +3103,23 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-play'; $facolor = '#444'; } + elseif ($pictowithoutext == 'jabber') { + $fakey = 'fa-comment-o'; + } + elseif ($pictowithoutext == 'split') { + $fakey = 'fa-code-fork'; + } else { $fakey = 'fa-'.$pictowithoutext; $facolor = '#444'; $marginleftonlyshort=0; } + $reg=array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.= ($morecss?' ':'').$reg[1]; } - $enabledisablehtml = ''; + $enabledisablehtml = ''; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml.= $titlealt; } @@ -3128,11 +3135,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme } else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { - $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module + $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module } // If we ask an image into $url/$mymodule/img (instead of default path) - if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { + if (preg_match('/^([^@]+)@([^@]+)$/i', $picto, $regs)) { $picto = $regs[1]; $path = $regs[2]; // $path is $mymodule } From 2c474de61ebdd380569480d045f9fa65b9eb22a2 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 4 Jan 2019 15:44:09 +0100 Subject: [PATCH 16/20] FIX Update of timespent when date is empty --- htdocs/projet/class/task.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 50c7f0d007f..49e0c34a0dc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1362,6 +1362,18 @@ class Task extends CommonObject $ret = 0; + // Check parameters + if ($this->timespent_date == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")); + return -1; + } + if (! ($this->timespent_fk_user > 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("User")); + return -1; + } + // Clean parameters if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); From 3b6d6eec9afe8aa2cf955c01e55925adb3c7c528 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 4 Jan 2019 18:06:54 +0100 Subject: [PATCH 17/20] Fix cach on image for website --- htdocs/website/samples/wrapper.html | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/htdocs/website/samples/wrapper.html b/htdocs/website/samples/wrapper.html index fb6a10b1264..32ed05e49c1 100644 --- a/htdocs/website/samples/wrapper.html +++ b/htdocs/website/samples/wrapper.html @@ -1,11 +1,12 @@ entity; $original_file=GETPOST("file","alpha"); @@ -54,17 +55,26 @@ if (! empty($hashp)) // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; if (preg_match('/\.(html|htm)$/i',$original_file)) $attachment = false; -if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'alpha')?true:false; -if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; +if (isset($_GET["attachment"])) $attachment = GETPOST("attachment",'none')?true:false; +if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) $attachment=false; // Define mime type $type = 'application/octet-stream'; -if (GETPOST('type','alpha')) $type=GETPOST('type','alpha'); +if (GETPOST('type','none')) $type=GETPOST('type','alpha'); else $type=dol_mimetype($original_file); // Security: Delete string ../ into $original_file $original_file=str_replace("../","/", $original_file); +// Cache or not +if (GETPOST("cache",'none') || image_format_supported($original_file) >= 0) +{ + // Important: Following code is to avoid page request by browser and PHP CPU at + // each Dolibarr page access. + header('Cache-Control: max-age=3600, public, must-revalidate'); + header('Pragma: cache'); // This is to avoid having Pragma: no-cache +} + // Find the subdirectory name as the reference $refname=basename(dirname($original_file)."/"); @@ -110,15 +120,13 @@ else // Permissions are ok and file found, so we return it //top_httphead($type); + header('Content-Type: '.$type); header('Content-Description: File Transfer'); if ($encoding) header('Content-Encoding: '.$encoding); // Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open) if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); header('Content-Length: ' . dol_filesize($fullpath_original_file)); - // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); readfile($fullpath_original_file_osencoded); } From 3485d0b4e5b7770061147a0a14df1e041d9881b0 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 4 Jan 2019 18:39:02 +0100 Subject: [PATCH 18/20] Fix regression when editing html source --- htdocs/website/index.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 16b73934fce..e4d0e8e6145 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1857,7 +1857,14 @@ if (! GETPOST('hide_websitemenu')) if ($action != 'addcontainer') { $out=''; - $out.=''; + } + else + { + $out.=''; - $out.=ajax_combobox('pageid'); + if ($atleastonepage && $action != 'editsource') + { + $out.=ajax_combobox('pageid'); + } + else + { + $out.=''; + $out.=ajax_combobox('pageid'); + } print $out; } else From 89f24f6fe8de0c043c2a05b5bb5f736eeeec2bc9 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 4 Jan 2019 18:58:36 +0100 Subject: [PATCH 19/20] Fix cache not working on css files --- htdocs/website/index.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index e4d0e8e6145..e56808f8f9e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -910,6 +910,7 @@ if ($action == 'updatecss') $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $csscontent.= "ob_start();\n"; + $csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; $csscontent.= "header('Content-type: text/css');\n"; $csscontent.= "// END PHP ?>\n"; @@ -942,6 +943,7 @@ if ($action == 'updatecss') $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $jscontent.= "ob_start();\n"; + $jscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; $jscontent.= "header('Content-type: application/javascript');\n"; $jscontent.= "// END PHP ?>\n"; @@ -974,6 +976,7 @@ if ($action == 'updatecss') $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $robotcontent.= "ob_start();\n"; + $robotcontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; $robotcontent.= "header('Content-type: text/css');\n"; $robotcontent.= "// END PHP ?>\n";*/ @@ -1000,20 +1003,21 @@ if ($action == 'updatecss') // Css file $htaccesscontent =''; - /*$robotcontent.= "\n";*/ + /*$htaccesscontent.= "\n";*/ $htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none'); - /*$robotcontent.= "\n".'"."\n";*/ + /*$htaccesscontent.= "\n".'"."\n";*/ dol_syslog("Save file htaccess into ".$filehtaccess); From e47cf24fa18d0af7584aea543affc52e06bb5397 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 4 Jan 2019 19:10:25 +0100 Subject: [PATCH 20/20] Try to fix chrome xss protection --- htdocs/website/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index e56808f8f9e..0c7ae842c9b 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -24,6 +24,8 @@ define('NOSCANPOSTFORINJECTION',1); define('NOSTYLECHECK',1); +header('X-XSS-Protection: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';