From b6deda1111fd654086f6faf7d3dc6a0227e55b39 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 18 Feb 2019 12:28:18 +0100 Subject: [PATCH 001/253] FIX credit note used on list --- .../fourn/class/fournisseur.facture.class.php | 21 +++++++++++++++++++ htdocs/fourn/facture/list.php | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 086f154184d..4ad0b221c36 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2574,6 +2574,27 @@ class FactureFournisseur extends CommonInvoice return ($this->statut == self::STATUS_VALIDATED) && ($this->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)); } + + /** + * Is credit note used + * + * @return bool + */ + public function isCreditNoteUsed() + { + global $db; + + $isUsed = false; + + $sql = "SELECT fk_invoice_supplier FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_invoice_supplier_source=".$this->id; + $resql = $db->query($sql); + if(!empty($resql)){ + $obj = $db->fetch_object($resql); + if(!empty($obj->fk_invoice_supplier))$isUsed=true; + } + + return $isUsed; + } } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 98a6956a809..b53a07104c7 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -833,6 +833,7 @@ if ($resql) $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; + $thirdparty->id=$obj->socid; $thirdparty->name=$obj->name; $thirdparty->client=$obj->client; @@ -850,6 +851,11 @@ if ($resql) $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = $obj->total_ttc - $totalpay; + //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice + if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE && $facturestatic->statut == FactureFournisseur::STATUS_CLOSED) { + if($facturestatic->isCreditNoteUsed())$remaintopay=0; + } + print ''; if (! empty($arrayfields['f.ref']['checked'])) { From 785092544115056183e718a831e3ac419c4b797e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 22 Feb 2019 15:10:41 +0100 Subject: [PATCH 002/253] FIX amount opened on thirdparty card dont care of credit note not converted --- htdocs/societe/class/societe.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 412bf46b082..b894504bb10 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3727,7 +3727,7 @@ class Societe extends CommonObject $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; $sql .= " WHERE fk_soc = ". $this->id; if ($mode == 'supplier') { @@ -3754,7 +3754,13 @@ class Societe extends CommonObject $tmpobject=new Facture($this->db); } while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; + $tmpobject->id=$obj->rowid; + + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); + + if ($obj->fk_statut != 0 // Not a draft && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice ) @@ -3768,11 +3774,14 @@ class Societe extends CommonObject && $obj->fk_statut != 2) // Not classified as paid //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason { - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); + $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } + + if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->fk_statut == FactureFournisseur::STATUS_CLOSED && !$tmpobject->isCreditNoteUsed()) { //if credit note is converted but not used + + $outstandingOpened+=$obj->total_ttc-$paiement; + } } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } From dc7a2fbb30e34b04a5cc88af5ac6234c8be56911 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 25 Feb 2019 10:01:26 +0100 Subject: [PATCH 003/253] FIX placement function --- htdocs/societe/class/societe.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b894504bb10..7d54e7ad01e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3756,9 +3756,7 @@ class Societe extends CommonObject while($obj=$this->db->fetch_object($resql)) { $tmpobject->id=$obj->rowid; - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); + if ($obj->fk_statut != 0 // Not a draft @@ -3774,12 +3772,15 @@ class Societe extends CommonObject && $obj->fk_statut != 2) // Not classified as paid //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason { + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->fk_statut == FactureFournisseur::STATUS_CLOSED && !$tmpobject->isCreditNoteUsed()) { //if credit note is converted but not used - + if(empty($paiement)) $paiement = $tmpobject->getSommePaiement(); $outstandingOpened+=$obj->total_ttc-$paiement; } } From 6deba39c6a9d67826297d7422f8130bb95133b35 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 12 Apr 2019 10:16:13 +0200 Subject: [PATCH 004/253] FIX credit note can be split --- htdocs/core/class/commoninvoice.class.php | 23 ++++++++++++ htdocs/core/class/discount.class.php | 43 +++++++++++++++++++++++ htdocs/fourn/facture/list.php | 7 ++-- htdocs/societe/class/societe.class.php | 8 ++--- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 3aa8eb4e1ab..35ec6ad283e 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -195,6 +195,29 @@ abstract class CommonInvoice extends CommonObject } } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumFromThisCreditNotesNotUsed($multicurrency=0) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + $discountstatic=new DiscountAbsolute($this->db); + $result=$discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); + if ($result >= 0) + { + return $result; + } + else + { + $this->error=$discountstatic->error; + return -1; + } + } + /** * Renvoie tableau des ids de facture avoir issus de la facture * diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index cfe7ac24dea..2e99a83ec42 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -568,6 +568,49 @@ class DiscountAbsolute return -1; } } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql.= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; + } + else if ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql.= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; + } + else + { + $this->error=get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) return $obj->multicurrency_amount; + else return $obj->amount; + } + else + { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Return clickable ref of object (with picto or not) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 3e1827d6818..d8e18257d23 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -852,8 +852,11 @@ if ($resql) $remaintopay = $obj->total_ttc - $totalpay; //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice - if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE && $facturestatic->statut == FactureFournisseur::STATUS_CLOSED) { - if($facturestatic->isCreditNoteUsed())$remaintopay=0; + if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + + if($facturestatic->isCreditNoteUsed()){ + $remaintopay=-$facturestatic->getSumFromThisCreditNotesNotUsed(); + } } print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7d54e7ad01e..87c4956e48e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3778,11 +3778,11 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } + + //if credit note is converted but not used + if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed())$outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + - if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->fk_statut == FactureFournisseur::STATUS_CLOSED && !$tmpobject->isCreditNoteUsed()) { //if credit note is converted but not used - if(empty($paiement)) $paiement = $tmpobject->getSommePaiement(); - $outstandingOpened+=$obj->total_ttc-$paiement; - } } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } From 9c47cb6f916ed057d17ed9242139b9bd4e9e2336 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 8 Jul 2019 23:16:32 +0200 Subject: [PATCH 005/253] NEW : can choose lines while creating order from origin --- htdocs/commande/card.php | 7 +++++-- htdocs/core/class/commonobject.class.php | 11 +++++++---- htdocs/core/tpl/originproductline.tpl.php | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 7362f30e5a8..f9fd3a716f5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -232,6 +232,7 @@ if (empty($reshook)) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $selectedLines = GETPOST('toselect'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); @@ -338,6 +339,8 @@ if (empty($reshook)) for($i = 0; $i < $num; $i ++) { + if(!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : ''); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); @@ -1870,8 +1873,6 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; - print ''; - // Show origin lines if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); @@ -1883,6 +1884,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } + + print ''; } else { // Mode view $now = dol_now(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0a300476fb5..f3832ff2782 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4145,7 +4145,7 @@ abstract class CommonObject */ public function printOriginLinesList($restrictlist = '') { - global $langs, $hookmanager, $conf; + global $langs, $hookmanager, $conf, $form; print ''; print ''.$langs->trans('Ref').''; @@ -4158,8 +4158,9 @@ abstract class CommonObject { print ''.$langs->trans('Unit').''; } - print ''.$langs->trans('ReductionShort').''; - + print ''.$langs->trans('ReductionShort').''; + print ''.$form->showCheckAddButtons('checkforselect', 1).''; + print ''; $var = true; $i = 0; @@ -4200,7 +4201,7 @@ abstract class CommonObject */ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl') { - global $langs, $conf; + global $langs, $conf, $selectedLines; //var_dump($line); if (!empty($line->date_start)) @@ -4222,6 +4223,8 @@ abstract class CommonObject if ($line->date_fin_reel) $date_end=$line->date_fin_reel; } + $this->tpl['id'] = $line->id; + $this->tpl['label'] = ''; if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 2f0accd6306..e29ea678282 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -40,6 +40,10 @@ if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($this->tpl['unit']).''; print ''.$this->tpl['remise_percent'].''; + +$selected=1; +if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0; +print ''; print ''."\n"; ?> From 8198276d64856cd7fe9cf27c9d6a9e39c63dce7f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 13 Aug 2019 17:47:30 +0200 Subject: [PATCH 006/253] FIX for MAIN_MAXTABS_IN_CARD = $i card --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e9f4301f8f2..a46bd661eb2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1130,7 +1130,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { // If active tab is already present - if ($i >= $limittoshow) $limittoshow--; + if ($i > $limittoshow) $limittoshow--; } } @@ -1146,7 +1146,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $isactive=false; } - if ($i < $limittoshow || $isactive) + if ($i <= $limittoshow || $isactive) { $out.='
'; if (isset($links[$i][2]) && $links[$i][2] == 'image') From 93d64bb84e3278891a52332bae037a31df58329f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 13 Aug 2019 17:59:19 +0200 Subject: [PATCH 007/253] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a46bd661eb2..9d85ab85048 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1130,7 +1130,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { // If active tab is already present - if ($i > $limittoshow) $limittoshow--; + if ($i >= $limittoshow) $limittoshow--; } } From 18eb2a83fe7c2d01bdb34cceec389a6f9541e1f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Aug 2019 16:41:53 +0200 Subject: [PATCH 008/253] FIX #11671 CVE-2019-15062 --- htdocs/core/actions_linkedfiles.inc.php | 8 +++----- htdocs/core/class/html.formfile.class.php | 4 ++-- htdocs/user/card.php | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 297f7821599..16ba1669337 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -118,8 +118,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $link = new Link($db); - $link->id = $linkid; - $link->fetch(); + $link->fetch($linkid); $res = $link->delete($user); $langs->load('link'); @@ -153,8 +152,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $langs->load('link'); $link = new Link($db); - $link->id = GETPOST('linkid', 'int'); - $f = $link->fetch(); + $f = $link->fetch(GETPOST('linkid', 'int')); if ($f) { $link->url = GETPOST('link', 'alpha'); @@ -162,7 +160,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l { $link->url = 'http://' . $link->url; } - $link->label = GETPOST('label', 'alpha'); + $link->label = GETPOST('label', 'alphanohtml'); $res = $link->update($user); if (!$res) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2b02ada6b47..a198fba4f98 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1757,7 +1757,7 @@ class FormFile print $langs->trans('Link') . ': '; print ''; print ''; - print $langs->trans('Label') . ': '; + print $langs->trans('Label') . ': '; print ''; print '' . dol_print_date(dol_now(), "dayhour", "tzuser") . ''; print ''; @@ -1771,7 +1771,7 @@ class FormFile print ''; print img_picto('', 'object_globe').' '; print ''; - print $link->label; + print dol_escape_htmltag($link->label); print ''; print ''."\n"; print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index adcf094e7a4..460e345131c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -309,12 +309,12 @@ if (empty($reshook)) { { $error = 0; - if (!$_POST["lastname"]) { + if (! GETPOST("lastname", 'alpha')) { setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); $action = "edit"; // Go back to create page $error ++; } - if (!$_POST["login"]) { + if (! GETPOST("login", 'alpha')) { setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); $action = "edit"; // Go back to create page $error ++; From 15a765a79a04c0e375dc381972731bf9fb2409b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Aug 2019 13:28:24 +0200 Subject: [PATCH 009/253] Fix responsive --- htdocs/user/home.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 9a7d0ab94fd..711eb94500c 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -124,8 +124,9 @@ if ($resql) { $num = $db->num_rows($resql); print ''; - print ''; + print ''; print ''; + print ''; print ''; $i = 0; @@ -194,7 +195,7 @@ if ($resql) print ($entitystring?' ('.$entitystring.')':''); print ''; - print ''; + print ''; print ''; From 7f6c29fd6599e15bccf7806f37a32c751c6a86ad Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 19 Aug 2019 15:27:21 +0200 Subject: [PATCH 010/253] bad converting on php 7 is totalpaid is null display a warning error --- htdocs/expensereport/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 07318bc0571..9917682f265 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2058,7 +2058,8 @@ else $totalpaid += $objp->amount; $i++; } - $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop + if ( !is_null($totalpaid)) + $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop $remaintopay = price2num($object->total_ttc - $totalpaid); $resteapayeraffiche = $remaintopay; From def0311f9da7f0df2b082cd58a92b6143b269d2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Aug 2019 17:26:13 +0200 Subject: [PATCH 011/253] Fix translation --- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/facture/fiche-rec.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d19e925843e..203d2f22a78 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3237,8 +3237,8 @@ if ($action == 'create') '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')', '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')', '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')', - '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')', - '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')', + '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')', + '__INVOICE_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')', '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')' ); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 9b50e782454..3544aaa1049 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1015,8 +1015,8 @@ if ($action == 'create') $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B').')'; $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')'; // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; @@ -1357,8 +1357,8 @@ else $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')'; $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'; // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; From 28c18afbb6c2d7e50508adc5dc990beb534a3684 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Aug 2019 18:06:27 +0200 Subject: [PATCH 012/253] Enhance export of website --- htdocs/website/class/website.class.php | 31 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 8d90aae370a..b659edb7d16 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -823,30 +823,47 @@ class Website extends CommonObject return ''; } - $arrayreplacement=array(); + $arrayreplacementinfilename=array(); + $arrayreplacementincss=array(); + $arrayreplacementincss['modulepart=medias&file=image/'.$website->ref.'/'] = "file=image/__WEBSITE_KEY__/"; + $arrayreplacementincss['modulepart=medias&file=js/'.$website->ref.'/'] = "file=js/__WEBSITE_KEY__/"; + $arrayreplacementincss['medias/image/'.$website->ref.'/'] = "medias/image/__WEBSITE_KEY__/"; + $arrayreplacementincss['medias/js/'.$website->ref.'/'] = "medias/js/__WEBSITE_KEY__/"; + $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_small] = "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__"; + $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_mini] = "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__"; + $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo] = "file=logos%2Fthumbs%2F__LOGO_KEY__"; $srcdir = $conf->website->dir_output.'/'.$website->ref; $destdir = $conf->website->dir_temp.'/'.$website->ref.'/containers'; + // Create containers dir + dol_syslog("Create containers dir"); + dol_mkdir($conf->website->dir_temp.'/'.$website->ref.'/containers'); + + // Copy files into medias dol_syslog("Copy content from ".$srcdir." into ".$destdir); - dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement); + dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename); $srcdir = DOL_DATA_ROOT.'/medias/image/'.$website->ref; $destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/image/websitekey'; dol_syslog("Copy content from ".$srcdir." into ".$destdir); - dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement); + dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename); $srcdir = DOL_DATA_ROOT.'/medias/js/'.$website->ref; $destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/js/websitekey'; + // Copy containers files dol_syslog("Copy content from ".$srcdir." into ".$destdir); - dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacement); + dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename); + + $cssindestdir = $conf->website->dir_temp.'/'.$website->ref.'/containers/styles.css.php'; + dolReplaceInFile($cssindestdir, $arrayreplacementincss, '', 0, 0, 0); + + $htmldeaderindestdir = $conf->website->dir_temp.'/'.$website->ref.'/containers/htmlheader.html'; + dolReplaceInFile($htmldeaderindestdir, $arrayreplacementincss, '', 0, 0, 0); // Build sql file - dol_syslog("Create containers dir"); - dol_mkdir($conf->website->dir_temp.'/'.$website->ref.'/containers'); - $filesql = $conf->website->dir_temp.'/'.$website->ref.'/website_pages.sql'; $fp = fopen($filesql, "w"); if (empty($fp)) From 6d60b53dbb18d2ba1b8039de1fccf63059042463 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Aug 2019 18:25:27 +0200 Subject: [PATCH 013/253] Enhance export/import of web sites --- htdocs/website/class/website.class.php | 30 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index b659edb7d16..337f054c7c9 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -825,8 +825,8 @@ class Website extends CommonObject $arrayreplacementinfilename=array(); $arrayreplacementincss=array(); - $arrayreplacementincss['modulepart=medias&file=image/'.$website->ref.'/'] = "file=image/__WEBSITE_KEY__/"; - $arrayreplacementincss['modulepart=medias&file=js/'.$website->ref.'/'] = "file=js/__WEBSITE_KEY__/"; + $arrayreplacementincss['file=image/'.$website->ref.'/'] = "file=image/__WEBSITE_KEY__/"; + $arrayreplacementincss['file=js/'.$website->ref.'/'] = "file=js/__WEBSITE_KEY__/"; $arrayreplacementincss['medias/image/'.$website->ref.'/'] = "medias/image/__WEBSITE_KEY__/"; $arrayreplacementincss['medias/js/'.$website->ref.'/'] = "medias/js/__WEBSITE_KEY__/"; $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_small] = "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__"; @@ -858,10 +858,10 @@ class Website extends CommonObject dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename); $cssindestdir = $conf->website->dir_temp.'/'.$website->ref.'/containers/styles.css.php'; - dolReplaceInFile($cssindestdir, $arrayreplacementincss, '', 0, 0, 0); + dolReplaceInFile($cssindestdir, $arrayreplacementincss); $htmldeaderindestdir = $conf->website->dir_temp.'/'.$website->ref.'/containers/htmlheader.html'; - dolReplaceInFile($htmldeaderindestdir, $arrayreplacementincss, '', 0, 0, 0); + dolReplaceInFile($htmldeaderindestdir, $arrayreplacementincss); // Build sql file $filesql = $conf->website->dir_temp.'/'.$website->ref.'/website_pages.sql'; @@ -1029,9 +1029,24 @@ class Website extends CommonObject return -1; } + $arrayreplacement = array(); + $arrayreplacement['__WEBSITE_ID__'] = $object->id; + $arrayreplacement['__WEBSITE_KEY__'] = $object->ref; + $arrayreplacement['__N__'] = $this->db->escape("\n"); // Restore \n + $arrayreplacement['__LOGO_SMALL_KEY__'] = $this->db->escape($mysoc->logo_small); + $arrayreplacement['__LOGO_MINI_KEY__'] = $this->db->escape($mysoc->logo_mini); + $arrayreplacement['__LOGO_KEY__'] = $this->db->escape($mysoc->logo); + // Copy containers dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/containers', $conf->website->dir_output.'/'.$object->ref, 0, 1); // Overwrite if exists + // Make replacement into css and htmlheader file + $cssindestdir = $conf->website->dir_output.'/'.$object->ref.'/styles.css.php'; + $result=dolReplaceInFile($cssindestdir, $arrayreplacement); + + $htmldeaderindestdir = $conf->website->dir_output.'/'.$object->ref.'/htmlheader.html'; + $result = dolReplaceInFile($htmldeaderindestdir, $arrayreplacement); + // Now generate the master.inc.php page $filemaster=$conf->website->dir_output.'/'.$object->ref.'/master.inc.php'; $result = dolSaveMasterFile($filemaster); @@ -1046,13 +1061,6 @@ class Website extends CommonObject $sqlfile = $conf->website->dir_temp.'/'.$object->ref.'/website_pages.sql'; - $arrayreplacement = array(); - $arrayreplacement['__WEBSITE_ID__'] = $object->id; - $arrayreplacement['__WEBSITE_KEY__'] = $object->ref; - $arrayreplacement['__N__'] = $this->db->escape("\n"); // Restore \n - $arrayreplacement['__LOGO_SMALL_KEY__'] = $this->db->escape($mysoc->logo_small); - $arrayreplacement['__LOGO_MINI_KEY__'] = $this->db->escape($mysoc->logo_mini); - $arrayreplacement['__LOGO_KEY__'] = $this->db->escape($mysoc->logo); $result = dolReplaceInFile($sqlfile, $arrayreplacement); $this->db->begin(); From fb8e66a66272123f4e361905631128a659c8baa7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Aug 2019 18:34:54 +0200 Subject: [PATCH 014/253] Trans --- htdocs/admin/website.php | 4 ++-- htdocs/langs/en_US/website.lang | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 5096563ad76..8bcc6cc5417 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -618,14 +618,14 @@ if ($id) // Active print '"; // Modify link print ''; // Delete link - if ($iserasable) print ''; + if ($iserasable) print ''; else print ''; print "\n"; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index c43dfc3ebae..6b5c0a300e8 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -2,7 +2,7 @@ Shortname=Code WebsiteSetupDesc=Create here the websites you wish to use. Then go into menu Websites to edit them. DeleteWebsite=Delete website -ConfirmDeleteWebsite=Are you sure you want to delete this web site? All its pages and content will also be removed. +ConfirmDeleteWebsite=Are you sure you want to delete this web site? All its pages and content will also be removed. The files uploaded (like into the medias directory, the ECM module, ...) will remain. WEBSITE_TYPE_CONTAINER=Type of page/container WEBSITE_PAGE_EXAMPLE=Web page to use as example WEBSITE_PAGENAME=Page name/alias From 5dee861f7d2092664b6ec57f496eebad1625565b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Aug 2019 18:39:40 +0200 Subject: [PATCH 015/253] Fix typo --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 28c61aca5cd..2dbc3bb3574 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -656,7 +656,7 @@ if ($action == 'addcontainer') elseif ($tmpgeturl['http_code'] != '200') { $errorforsubresource++; - setEventMessages('Error getting link tag url'.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); + setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); $action='createcontainer'; } From 54234e011f22cfffbc434eb1e2d05a8a343a83fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2019 13:26:56 +0200 Subject: [PATCH 016/253] Add version of Sabre lib, add log on login errors. Add compatibility with twoauth --- htdocs/admin/dav.php | 12 +++++++++--- htdocs/dav/fileserver.php | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 6ac210c1ddb..005394739f0 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -68,7 +68,6 @@ $head=dav_admin_prepare_head(); dol_fiche_head($head, 'webdav', '', -1, 'action'); - if ($action == 'edit') { print '
'; @@ -76,7 +75,7 @@ if ($action == 'edit') print ''; print '
'.$langs->trans("LastUsersCreated", min($num, $max)).'
'.$langs->trans("LastUsersCreated", min($num, $max)).''.$langs->trans("FullList").'
'.dol_print_date($db->jdate($obj->datec), 'dayhour').''.dol_print_date($db->jdate($obj->datec), 'dayhour').''; print $fuserstatic->getLibStatut(3); print ''; - print ''.$actl[($obj->status?1:0)].''; + print ''.$actl[($obj->status?1:0)].''; print "'.img_edit().''.img_delete().''.img_delete().''.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'
'; - print ''; + print ''; foreach($arrayofparameters as $key => $val) { @@ -112,7 +111,7 @@ if ($action == 'edit') else { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print ''; + print ''; foreach($arrayofparameters as $key => $val) { @@ -177,6 +176,13 @@ if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) } print $message; +print '


'; + +require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php'; +$version = Sabre\DAV\Version::VERSION; +print ''.$langs->trans("BaseOnSabeDavVersion").' : '.$version.''; + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index 4e99cf92613..143f48d2033 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -72,15 +72,25 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p global $dolibarr_main_authentication; if (empty($user->login)) + { + dol_syslog("Failed to authenticate to DAV, login is not provided", LOG_WARNING); return false; + } if ($user->socid > 0) + { + dol_syslog("Failed to authenticate to DAV, use is an external user", LOG_WARNING); return false; + } if ($user->login != $username) + { + dol_syslog("Failed to authenticate to DAV, login does not match the login of loaded user", LOG_WARNING); return false; + } // Authentication mode - if (empty($dolibarr_main_authentication)) - $dolibarr_main_authentication='http,dolibarr'; + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='dolibarr'; + $dolibarr_main_authentication = preg_replace('/twoauth/', 'dolibarr', $dolibarr_main_authentication); + $authmode = explode(',', $dolibarr_main_authentication); $entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1)); From 65d11704bb4b0fdccd094e2337aebd5a7f2a764c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2019 13:46:15 +0200 Subject: [PATCH 017/253] Fix Protect DAV when $dolibarr_main_authentication is forceuser Compatibility with twoauth --- htdocs/api/class/api_login.class.php | 8 ++++++-- htdocs/dav/fileserver.php | 13 ++++++++++++- htdocs/langs/en_US/admin.lang | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 2bf464f7296..b2b1f08f8b6 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -57,12 +57,15 @@ class Login */ public function index($login, $password, $entity = '', $reset = 0) { - global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - // Authentication mode + // TODO Remove the API login. The token must be generated from backoffice only. + + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; + $dolibarr_main_authentication = preg_replace('/twoauth/', 'dolibarr', $dolibarr_main_authentication); + // Authentication mode: forceuser if ($dolibarr_main_authentication == 'forceuser') { @@ -73,6 +76,7 @@ class Login throw new RestException(403, "Your instance is set to use the automatic login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode."); } } + // Set authmode $authmode = explode(',', $dolibarr_main_authentication); diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index 143f48d2033..b056ac9730c 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -69,7 +69,7 @@ $tmpDir = $conf->dav->multidir_output[$entity]; // We need root dir, not a d $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) { global $user; global $conf; - global $dolibarr_main_authentication; + global $dolibarr_main_authentication, $dolibarr_auto_user; if (empty($user->login)) { @@ -91,6 +91,17 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='dolibarr'; $dolibarr_main_authentication = preg_replace('/twoauth/', 'dolibarr', $dolibarr_main_authentication); + // Authentication mode: forceuser + if ($dolibarr_main_authentication == 'forceuser') + { + if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; + if ($dolibarr_auto_user != $username) + { + dol_syslog("Warning: your instance is set to use the automatic forced login '".$dolibarr_auto_user."' that is not the requested login. DAV usage is forbidden in this mode."); + return false; + } + } + $authmode = explode(',', $dolibarr_main_authentication); $entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1)); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c95c9fe05cc..ee3da865377 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1932,4 +1932,5 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined -RestrictApiToIps=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. \ No newline at end of file +RestrictApiToIps=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. +BaseOnSabeDavVersion=Based on the library SabreDAV version \ No newline at end of file From c60fc6c3d42ed065b19ffd3a102cb8d28669193d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2019 13:57:25 +0200 Subject: [PATCH 018/253] Add param logcontext on dol_syslog --- htdocs/core/lib/functions.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 87f5b0a771f..75729cbb4f9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -995,10 +995,11 @@ function dol_strtoupper($utf8_string) * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 * @param int $ident 1=Increase ident of 1, -1=Decrease ident of 1 * @param string $suffixinfilename When output is a file, append this suffix into default log filename. - * @param string $restricttologhandler Output log only for this log handler + * @param string $restricttologhandler Force output of log only to this log handler + * @param array|null $logcontext If defined, an array with extra informations (can be used by some log handlers) * @return void */ -function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '') +function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '', $logcontext = null) { global $conf, $user, $debugbar; From f98d3c5c48d6ee8d3d7eb42d1804df659599a22a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2019 14:08:30 +0200 Subject: [PATCH 019/253] FIX Do not show tooltip if tooltip is empty --- htdocs/modulebuilder/template/admin/setup.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index fea88479abf..fd3ff41c799 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -103,7 +103,8 @@ if ($action == 'edit') foreach($arrayofparameters as $key => $val) { print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); print '
'; @@ -125,7 +126,8 @@ else foreach($arrayofparameters as $key => $val) { print ''; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); print '' . $conf->global->$key . ''; } From fd3f890f7b2b8b06d27820210ad016e079add6f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2019 14:15:04 +0200 Subject: [PATCH 020/253] NEW Can restrict access using DAV module to some host IPs only --- htdocs/admin/dav.php | 9 +++++++-- htdocs/api/admin/index.php | 2 +- htdocs/dav/fileserver.php | 16 ++++++++++++++++ htdocs/langs/en_US/admin.lang | 3 ++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 005394739f0..f4fbcbbdd59 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -35,7 +35,10 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); + + $arrayofparameters=array( + 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2), 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled) @@ -82,7 +85,8 @@ if ($action == 'edit') if (isset($val['enabled']) && empty($val['enabled'])) continue; print ''; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { @@ -116,7 +120,8 @@ else foreach($arrayofparameters as $key => $val) { print ''; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 0ca6786b9b2..979ce497ab1 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -130,7 +130,7 @@ print ' '; print ''; print ''; -print ''.$langs->trans("RestrictApiToIps").''; +print ''.$langs->trans("RESTICT_API_ON_IP").''; print ''; print ''; print ''; diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index b056ac9730c..4a38511305e 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -55,6 +55,22 @@ if (empty($conf->dav->enabled)) accessforbidden(); +// Restrict API to some IPs +if (! empty($conf->global->DAV_RESTICT_ON_IP)) +{ + $allowedip=explode(' ', $conf->global->DAV_RESTICT_ON_IP); + $ipremote = getUserRemoteIP(); + if (! in_array($ipremote, $allowedip)) + { + dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->DAV_RESTICT_ON_IP); + print 'DAV not allowed from the IP '.$ipremote; + header('HTTP/1.1 503 DAV not allowed from your IP '.$ipremote); + //print $conf->global->DAV_RESTICT_ON_IP; + exit(0); + } +} + + $entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1)); // settings diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ee3da865377..726ba624434 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1932,5 +1932,6 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined -RestrictApiToIps=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. +RESTICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. +RESTICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. BaseOnSabeDavVersion=Based on the library SabreDAV version \ No newline at end of file From ae87b33e818e6933edff19d3a1aa5dc26dfe3a3b Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 20 Aug 2019 17:04:41 +0200 Subject: [PATCH 021/253] NEW add entity in fetch method for contract --- htdocs/contrat/class/contrat.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0a2c59ece2c..125352d8004 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -96,6 +96,12 @@ class Contrat extends CommonObject */ public $ref_supplier; + /** + * Entity of the contract + * @var int + */ + public $entity; + /** * Client id linked to the contract * @var int @@ -624,6 +630,7 @@ class Contrat extends CommonObject $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql.= " ref_supplier, ref_customer,"; $sql.= " ref_ext,"; + $sql.= " entity,"; $sql.= " fk_user_mise_en_service, date_contrat as datecontrat,"; $sql.= " fk_user_author, fin_validite, date_cloture,"; $sql.= " fk_projet as fk_project,"; @@ -658,6 +665,7 @@ class Contrat extends CommonObject $this->ref_customer = $obj->ref_customer; $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; + $this->entity = $obj->entity; $this->statut = $obj->statut; $this->mise_en_service = $this->db->jdate($obj->datemise); From d82e60adb7e661174ffee1a9bcd40f0e69caa7c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2019 20:31:46 +0200 Subject: [PATCH 022/253] Work on namespaces test --- dev/namespacemig/README.md | 4 ++++ dev/namespacemig/aaa.class.php | 23 +++++++++++++++++++++++ dev/namespacemig/bbb.class.php | 25 +++++++++++++++++++++++++ dev/namespacemig/bbb.php | 31 +++++++++++++++++++++++++++++++ dev/namespacemig/main.inc.php | 7 +++++++ 5 files changed, 90 insertions(+) create mode 100644 dev/namespacemig/README.md create mode 100644 dev/namespacemig/aaa.class.php create mode 100644 dev/namespacemig/bbb.class.php create mode 100755 dev/namespacemig/bbb.php create mode 100644 dev/namespacemig/main.inc.php diff --git a/dev/namespacemig/README.md b/dev/namespacemig/README.md new file mode 100644 index 00000000000..981292355ab --- /dev/null +++ b/dev/namespacemig/README.md @@ -0,0 +1,4 @@ +Test to migrate Dolibarr to namespace "Dolibarr". + +Script bbb.php is a script of an external module with current code writing. +It must works after migration. \ No newline at end of file diff --git a/dev/namespacemig/aaa.class.php b/dev/namespacemig/aaa.class.php new file mode 100644 index 00000000000..1070e96f875 --- /dev/null +++ b/dev/namespacemig/aaa.class.php @@ -0,0 +1,23 @@ +do(); + +$aaa = new Aaa(); +$aaa->do(); + +echo $aaa::AAA."\n"; +echo $bbb::BBB."\n"; + +echo Aaa::AAA."\n"; +echo Bbb::BBB."\n"; + +echo faaa()."\n"; +echo fbbb()."\n"; + +echo "globalaaa=$globalaaa\n"; +echo "globalbbb=$globalbbb\n"; diff --git a/dev/namespacemig/main.inc.php b/dev/namespacemig/main.inc.php new file mode 100644 index 00000000000..5709a31f733 --- /dev/null +++ b/dev/namespacemig/main.inc.php @@ -0,0 +1,7 @@ + Date: Tue, 20 Aug 2019 20:32:17 +0200 Subject: [PATCH 023/253] Fix RESTRICT_ON_API --- htdocs/admin/dav.php | 4 +++- htdocs/api/admin/index.php | 6 +++--- htdocs/api/index.php | 8 ++++---- htdocs/dav/fileserver.php | 8 ++++---- htdocs/langs/en_US/admin.lang | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index f4fbcbbdd59..032c4f07e56 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -86,7 +86,9 @@ if ($action == 'edit') print ''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); - print $form->textwithpicto($langs->trans($key), $tooltiphelp); + $label = $langs->trans($key); + if ($key == 'DAV_RESTICT_ON_IP') $label = $langs->trans("RESTRICT_ON_IP"); + print $form->textwithpicto($label, $tooltiphelp); print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 979ce497ab1..cbf18f92222 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -80,7 +80,7 @@ if ($action == 'setproductionmode') if ($action == 'save') { - dolibarr_set_const($db, 'API_RESTICT_ON_IP', GETPOST('API_RESTICT_ON_IP', 'alpha')); + dolibarr_set_const($db, 'API_RESTRICT_ON_IP', GETPOST('API_RESTRICT_ON_IP', 'alpha')); } @@ -130,8 +130,8 @@ print ' '; print ''; print ''; -print ''.$langs->trans("RESTICT_API_ON_IP").''; -print ''; +print ''.$langs->trans("RESTRICT_API_ON_IP").''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 1f1235571cc..c63a376e806 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -207,16 +207,16 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) { // Restrict API to some IPs - if (! empty($conf->global->API_RESTICT_ON_IP)) + if (! empty($conf->global->API_RESTRICT_ON_IP)) { - $allowedip=explode(' ', $conf->global->API_RESTICT_ON_IP); + $allowedip=explode(' ', $conf->global->API_RESTRICT_ON_IP); $ipremote = getUserRemoteIP(); if (! in_array($ipremote, $allowedip)) { - dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTICT_ON_IP); + dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); print 'API not allowed from the IP '.$ipremote; header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); - //print $conf->global->API_RESTICT_ON_IP; + //print $conf->global->API_RESTRICT_ON_IP; exit(0); } } diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index 4a38511305e..dae6565bc93 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -56,16 +56,16 @@ if (empty($conf->dav->enabled)) // Restrict API to some IPs -if (! empty($conf->global->DAV_RESTICT_ON_IP)) +if (! empty($conf->global->DAV_RESTRICT_ON_IP)) { - $allowedip=explode(' ', $conf->global->DAV_RESTICT_ON_IP); + $allowedip=explode(' ', $conf->global->DAV_RESTRICT_ON_IP); $ipremote = getUserRemoteIP(); if (! in_array($ipremote, $allowedip)) { - dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->DAV_RESTICT_ON_IP); + dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->DAV_RESTRICT_ON_IP); print 'DAV not allowed from the IP '.$ipremote; header('HTTP/1.1 503 DAV not allowed from your IP '.$ipremote); - //print $conf->global->DAV_RESTICT_ON_IP; + //print $conf->global->DAV_RESTRICT_ON_IP; exit(0); } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 726ba624434..ef5d6388f6e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1932,6 +1932,6 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined -RESTICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. -RESTICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. +RESTRICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. +RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. BaseOnSabeDavVersion=Based on the library SabreDAV version \ No newline at end of file From f1b80fc19a1f01cc9457bef9eff2768af787bc68 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Tue, 20 Aug 2019 23:44:30 +0200 Subject: [PATCH 024/253] Add 'Direct Cash Payment' button in TakePOS --- htdocs/langs/en_US/cashdesk.lang | 2 ++ htdocs/takepos/admin/setup.php | 8 ++++++++ htdocs/takepos/takepos.php | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 012b6b4c804..628de17efcc 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -70,3 +70,5 @@ TerminalSelect=Select terminal you want to use: POSTicket=POS Ticket BasicPhoneLayout=Use basic layout for phones SetupOfTerminalNotComplete=Setup of terminal %s is not complete +DirectPayment=Direct payment +DirectPaymentButton=Direct cash payment button diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 3fb9d869cd0..6d33b8a19c2 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -79,6 +79,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); if ($conf->global->TAKEPOS_ORDER_NOTES==1) { @@ -223,6 +224,13 @@ $array=array(0=>$langs->trans("Numberspad"), 1=>$langs->trans("BillsCoinsPad")); print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS_NUMPAD)?'0':$conf->global->TAKEPOS_NUMPAD), 0); print "\n"; +// Direct Payment +print ''; +print $langs->trans('DirectPaymentButton'); +print ''; +print $form->selectyesno("TAKEPOS_DIRECT_PAYMENT", $conf->global->TAKEPOS_DIRECT_PAYMENT, 1); +print "\n"; + $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 7260bc81a58..4dc481a98cf 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -575,6 +575,12 @@ function TerminalsDialog() }); } +function DirectPayment(){ + console.log("DirectPayment"); + $("#poslines").load("invoice.php?place"+place+"&action=valid&pay=trans("cash");?>", function() { + }); +} + $( document ).ready(function() { PrintCategories(0); LoadProducts(0); @@ -666,6 +672,10 @@ $menus[$r++]=array('title'=>''
'.$langs->trans("FreeZone").'
', 'action'=>'FreeZone();'); $menus[$r++]=array('title'=>'
'.$langs->trans("Payment").'
', 'action'=>'CloseBill();'); +if ($conf->global->TAKEPOS_DIRECT_PAYMENT){ + $menus[$r++]=array('title'=>'
'.$langs->trans("DirectPayment").'
', 'action'=>'DirectPayment();'); +} + // BAR RESTAURANT specific menu if ($conf->global->TAKEPOS_BAR_RESTAURANT) { From d2d7fb4b04e21f6b6a2025f57c6ef8fc7206a5a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Aug 2019 03:38:57 +0200 Subject: [PATCH 025/253] Fix management of collapsing of extrafields separators. --- htdocs/core/class/extrafields.class.php | 29 ++++++++++++++---------- htdocs/core/tpl/extrafields_view.tpl.php | 8 ++++--- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 09130bb130a..c92ae311141 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1628,7 +1628,7 @@ class ExtraFields if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. //if ($computed) $value = // $value is already calculated into $value before calling this method - + $showsize=0; if ($type == 'date') { @@ -1972,24 +1972,29 @@ class ExtraFields if (count($extrafield_param_list) > 0) { $extrafield_collapse_display_value = intval($extrafield_param_list[0]); if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { - $collapse_display = ($extrafield_collapse_display_value == 2 ? false : true); + // Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup. + $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key]; + $out .= ''; $out .= ''; + +print $out; + pFooter($ok?0:1, $setuplang); if (isset($db) && is_object($db)) $db->close(); diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index 734d63fade9..342ec82d0fd 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -80,7 +80,7 @@ $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf-> if ($db->ok) { print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index da28ec88538..1b4badc39b5 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1935,4 +1935,5 @@ AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be de RESTRICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. BaseOnSabeDavVersion=Based on the library SabreDAV version -NotAPublicIp=Not a public IP \ No newline at end of file +NotAPublicIp=Not a public IP +MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server (done 1 time only after installation) to allow the foundation to count the number of Dolibarr installation. \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 375c7e4ea23..620a4b4e7f6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2205,7 +2205,7 @@ if (! function_exists("llxFooter")) */ function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages = 0) { - global $conf, $langs, $user, $object; + global $conf, $db, $langs, $user, $object; global $delayedhtmlcontent; global $contextpage, $page, $limit; @@ -2334,65 +2334,62 @@ if (! function_exists("llxFooter")) // Add code for the asynchronous anonymous first ping (for telemetry) if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) { + //print ''; if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) - || (! empty($conf->file->instance_unique_id) && (md5($conf->file->instance_unique_id) != $conf->global->MAIN_FIRST_PING_OK_ID)) + || (! empty($conf->file->instance_unique_id) && (md5($conf->file->instance_unique_id) != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled')) || GETPOST('forceping', 'alpha')) { - print "\n".''."\n"; - print "\n\n"; - ?> - - file->instance_unique_id)])) + { + print "\n".''."\n"; + print "\n\n"; + $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); + ?> + + \n"; + include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt')); + dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', 'disabled'); + } } } print "\n"; print "\n"; - - ?> - - - Date: Sat, 24 Aug 2019 12:44:23 +0200 Subject: [PATCH 078/253] FIX wrong parameters (same error in branch 9, 10, develop) --- htdocs/compta/paiement.php | 2 +- htdocs/projet/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 4888b758cc1..aa344c3df2e 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -530,7 +530,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; $sql.= ' f.datef as df, f.fk_soc as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' WHERE f.entity IN ('.getEntity('facture', $conf->entity).')'; + $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; $sql.= ' AND (f.fk_soc = '.$facture->socid; // Can pay invoices of all child of parent company if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 906cb3783f1..4c4ae4c71cf 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -258,7 +258,7 @@ $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('project', $conf->entity).")"; +$sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND p.fk_statut = 1"; if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; From 73a6b45e23ac22c070ab69c4d37e5ade23bf6c51 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 13:26:01 +0200 Subject: [PATCH 079/253] Fix load langs in takepos --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index ed3e5def318..68c7cf0ef55 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -29,7 +29,7 @@ require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -$langs->loadLangs(array("bills", "cashdesk")); +$langs->loadLangs(array("companies","commercial","bills", "cashdesk")); $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); From 686d43a12230b9673fe23b378e212999c94b533b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 13:44:21 +0200 Subject: [PATCH 080/253] NEW display membership in takepos if member link to thirdparty For some business or cases (ie: fundation), we need to know if customer is a member and membership is up to date. --- htdocs/takepos/invoice.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 17805a6b060..08822d46c6d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -692,6 +692,29 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print '

'; print $langs->trans("Customer").': '.$soc->name; print '

'; + + // Module Adherent + if (! empty($conf->adherent->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $langs->load("members"); + print '

'; + print $langs->trans("Member").': '; + $adh=new Adherent($db); + $result=$adh->fetch('', '', $invoice->socid); + if ($result > 0) + { + $adh->ref=$adh->getFullName($langs); + print $adh->getFullName($langs); + print '
'.$langs->trans("Type").': '.$adh->type; + print '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); + } + else + { + print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; + } + print '

'; + } } if ($action == "search") From cc1de15438d646e83c73facef96afaeaee0a61d1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 13:52:40 +0200 Subject: [PATCH 081/253] Update invoice.php --- htdocs/takepos/invoice.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 08822d46c6d..c628daa44ad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -707,7 +707,18 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep $adh->ref=$adh->getFullName($langs); print $adh->getFullName($langs); print '
'.$langs->trans("Type").': '.$adh->type; - print '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); + if ($adh->datefin) + { + print dol_print_date($adh->datefin, 'day'); + if ($adh->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } + else + { + print $langs->trans("SubscriptionNotReceived"); + if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated + } } else { From bb763ecb59bfafde02b8095ef4a8721dba358b86 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 14:02:25 +0200 Subject: [PATCH 082/253] Fix lang in takepos --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index e09c31664cd..4737ecbde27 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -367,7 +367,7 @@ if ($action=="valid" || $action=="history") } else { - if ($invoice->paye) $sectionwithinvoicelink.=''.$langs->trans("Payed").''; + if ($invoice->paye) $sectionwithinvoicelink.=''.$langs->trans("Paid").''; else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated'); } $sectionwithinvoicelink.=''; From 361bb724486c81e090b704f08134fd00b5074157 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 14:17:58 +0200 Subject: [PATCH 083/253] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c628daa44ad..663c7d4d006 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -725,7 +725,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; } print '

'; - } + } } if ($action == "search") From d2ff37ae723fc37295b6066f0927d1fe57a285fd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:00:49 +0200 Subject: [PATCH 084/253] NEW email template for Takepos (sending invoice) --- htdocs/takepos/admin/setup.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 6d33b8a19c2..23e6eb05c48 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -80,6 +80,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if ($conf->global->TAKEPOS_ORDER_NOTES==1) { @@ -231,6 +232,30 @@ print ''; print $form->selectyesno("TAKEPOS_DIRECT_PAYMENT", $conf->global->TAKEPOS_DIRECT_PAYMENT, 1); print "\n"; +// Email template for send invoice +print ''; +print $langs->trans('EmailTemplate'); +print ''; +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; +$formmail = new FormMail($db); +$nboftemplates = $formmail->fetchAllEMailTemplate('facture_send', $user, null, -1); // We set lang=null to get in priority record with no lang +//$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); +$arrayofmessagename=array(); +if (is_array($formmail->lines_model)) +{ + foreach($formmail->lines_model as $modelmail) + { + //var_dump($modelmail); + $moreonlabel=''; + if (! empty($arrayofmessagename[$modelmail->label])) $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; + $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; + } +} +//var_dump($arraydefaultmessage); +//var_dump($arrayofmessagename); +print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE, 'None', 1, 0, '', 0, 0, 0, '', '', 1); +print "\n"; + $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; From c4b18890d952a2e1611d08b419ebf295c1db6c4c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:12:56 +0200 Subject: [PATCH 085/253] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4737ecbde27..1e11161e8a1 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -511,7 +511,7 @@ print '
'.$sectionwithinvoicelink; print ''; print '' . $langs->trans('ReductionShort') . ''; print '' . $langs->trans('Qty') . ''; -print '' . $langs->trans('TotalHTShort') . ''; +print '' . $langs->trans('Total') . ''; print "\n"; if ($placeid > 0) From 2be125e647daa8680559a7900cacac959b8a89c1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:47:17 +0200 Subject: [PATCH 086/253] Fix display context for takepos in invoice list fix for thirdparty name and create button --- htdocs/compta/facture/list.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 284b747465d..f0c10598f82 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -605,7 +605,7 @@ if ($resql) $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; - if($user->rights->facture->creer) + if($user->rights->facture->creer && $contextpage != 'poslist') { $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); } @@ -1068,7 +1068,14 @@ if ($resql) if (! empty($arrayfields['s.nom']['checked'])) { print ''; - print $thirdpartystatic->getNomUrl(1, 'customer'); + if ($contextpage == 'poslist') + { + print $thirdpartystatic->name; + } + else + { + print $thirdpartystatic->getNomUrl(1, 'customer'); + } print ''; if (! $i) $totalarray['nbfield']++; } From 7112fcee9a6031a93294f235f132f55a3ac65906 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:54:14 +0200 Subject: [PATCH 087/253] Update list.php --- htdocs/compta/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index f0c10598f82..653f1182d78 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -687,7 +687,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -1237,7 +1237,7 @@ if ($resql) // Action column print '
'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; if (in_array($obj->id, $arrayofselected)) $selected=1; From 7b5c9818f7b25b623a68b472f7f79a3083d1898d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:58:33 +0200 Subject: [PATCH 088/253] Fix context display with takepos societe/list.php --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index daff9aec557..8f352a21b28 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -670,7 +670,7 @@ if ($moreforfilter) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); if (empty($arrayfields['customerorsupplier']['checked'])) print ''; @@ -1287,7 +1287,7 @@ while ($i < min($num, $limit)) // Action column print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; From dbcead47e1eaf8c972b0850704eafe7409341cd1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 16:05:21 +0200 Subject: [PATCH 089/253] Update list.php --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index daff9aec557..ebf03cb2d3d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -199,7 +199,7 @@ $arrayfields=array( 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5), 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6), 's.tva_intra'=>array('label'=>"VATIntraShort", 'checked'=>0), - 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), + 'customerorsupplier'=>array('label'=>'Type', 'checked'=>1), 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), 's2.nom'=>array('label'=>'ParentCompany', 'checked'=>0), From 5d0dbea920d8f794df01f92cf8976498d77bb9a9 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 24 Aug 2019 16:44:06 +0200 Subject: [PATCH 090/253] Control errors before validate invoice in TakePOS --- htdocs/langs/en_US/cashdesk.lang | 2 ++ htdocs/takepos/invoice.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 628de17efcc..856cf1de0d2 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -72,3 +72,5 @@ BasicPhoneLayout=Use basic layout for phones SetupOfTerminalNotComplete=Setup of terminal %s is not complete DirectPayment=Direct payment DirectPaymentButton=Direct cash payment button +InvoiceIsAlreadyValidated=Invoice is already validated +NoLinesToBill=No lines to bill diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 17805a6b060..0176330db0a 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -161,7 +161,17 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice->update($user); } - if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") + if ($invoice->statut != Facture::STATUS_DRAFT) + { + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } + else if (count($invoice->lines)==0) + { + dol_syslog("Sale without lines"); + dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); + } + else if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") { $invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]}); } From 07244f002b7c8e37f690fb20201b67106ffda0df Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 24 Aug 2019 18:11:47 +0200 Subject: [PATCH 091/253] else if to elseif --- htdocs/takepos/invoice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0176330db0a..c03ec826d6d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -166,12 +166,12 @@ if ($action == 'valid' && $user->rights->facture->creer) dol_syslog("Sale already validated"); dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); } - else if (count($invoice->lines)==0) + elseif (count($invoice->lines)==0) { dol_syslog("Sale without lines"); dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); } - else if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") + elseif (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") { $invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]}); } From 4040693823c01ded9f86f065de5d659926ce37d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Aug 2019 18:12:20 +0200 Subject: [PATCH 092/253] FIX Use a SCA ready workflow with Stripe module --- htdocs/core/class/conf.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3088d8a95ce..d64033d969d 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -569,6 +569,9 @@ class Conf // By default, we show state code in combo list if (! isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE=1; + // Use a SCA ready workflow with Stripe module + if (! isset($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_NEW_CHECKOUT=1; + // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. if (! empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list From 6a906a6064b89cb7bf770ef9480f44a6a115c70c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 16:38:09 +0200 Subject: [PATCH 093/253] Rename module_part parameter into modulepart into document APIs --- htdocs/api/class/api_documents.class.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 48d6bf5b903..1b98ad5f2ec 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -56,7 +56,7 @@ class Documents extends DolibarrApi * Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for * internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead). * - * @param string $module_part Name of module or area concerned by file download ('facture', ...) + * @param string $modulepart Name of module or area concerned by file download ('facture', ...) * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) * @return array List of documents * @@ -67,11 +67,11 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file = '') + public function index($modulepart, $original_file = '') { global $conf, $langs; - if (empty($module_part)) { + if (empty($modulepart)) { throw new RestException(400, 'bad value for parameter modulepart'); } if (empty($original_file)) { @@ -81,7 +81,7 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity=$conf->entity; - $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -98,6 +98,7 @@ class Documents extends DolibarrApi if (! file_exists($original_file_osencoded)) { + dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); throw new RestException(404, 'File not found'); } @@ -111,7 +112,7 @@ class Documents extends DolibarrApi * * Test sample 1: { "module_part": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }. * - * @param string $module_part Name of module or area concerned by file download ('invoice', 'order', ...). + * @param string $modulepart Name of module or area concerned by file download ('invoice', 'order', ...). * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). * @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template). * @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language). @@ -126,11 +127,11 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') + public function builddoc($modulepart, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; - if (empty($module_part)) { + if (empty($modulepart)) { throw new RestException(400, 'bad value for parameter modulepart'); } if (empty($original_file)) { @@ -147,7 +148,7 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity=$conf->entity; - $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -166,7 +167,7 @@ class Documents extends DolibarrApi $templateused=''; - if ($module_part == 'facture' || $module_part == 'invoice') + if ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $this->invoice = new Facture($this->db); @@ -181,7 +182,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } - elseif ($module_part == 'commande' || $module_part == 'order') + elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $this->order = new Commande($this->db); @@ -195,7 +196,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } - elseif ($module_part == 'propal' || $module_part == 'proposal') + elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $this->propal = new Propal($this->db); From c8078f1195220c884b7f49e8ed9cdbdfd93fb648 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 16:39:15 +0200 Subject: [PATCH 094/253] Rename module_part parameter into modulepart into document APIs --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 62d791a670a..6ca4df10d38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ Following changes may create regressions for some external modules, but were nec * Properties ->libelle_incoterms were renamed into ->label_incoterms * Removed the method liste_array() of project class. It was not used by core code. * The function show_theme() hase been renamed into showSkins() +* Rename 'module_part' parameter into 'modulepart' into document APIs, for consistency. ***** ChangeLog for 10.0.1 compared to 10.0.0 ***** From 6328585395b06519ba8a1b3c57cbbab015948db9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 16:40:21 +0200 Subject: [PATCH 095/253] Fix: the API_RESTRICT_ON_IP must be at lower level (also on explorer) --- htdocs/api/index.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index c63a376e806..dd9ff7aadcb 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -24,6 +24,8 @@ * \file htdocs/api/index.php */ +use Luracast\Restler\Format\UploadFormat; + if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu @@ -117,6 +119,21 @@ $api->r->addAuthenticationClass('DolibarrApiAccess', ''); UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); +// Restrict API to some IPs +if (! empty($conf->global->API_RESTRICT_ON_IP)) +{ + $allowedip=explode(' ', $conf->global->API_RESTRICT_ON_IP); + $ipremote = getUserRemoteIP(); + if (! in_array($ipremote, $allowedip)) + { + dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); + print 'APIs are not allowed from the IP '.$ipremote; + header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); + //print $conf->global->API_RESTRICT_ON_IP; + exit(0); + } +} + // Call Explorer file for all APIs definitions (this part is slow) if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) @@ -136,6 +153,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || { while (($file = readdir($handle))!==false) { + $regmod=array(); if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) { $module = strtolower($regmod[1]); @@ -165,6 +183,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || { if ($file_searched == 'api_access.class.php') continue; + $regapi = array(); if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) { $classname = ucwords($regapi[1]); @@ -204,23 +223,9 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || } // Call one APIs or one definition of an API +$regbis = array(); if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) { - // Restrict API to some IPs - if (! empty($conf->global->API_RESTRICT_ON_IP)) - { - $allowedip=explode(' ', $conf->global->API_RESTRICT_ON_IP); - $ipremote = getUserRemoteIP(); - if (! in_array($ipremote, $allowedip)) - { - dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); - print 'API not allowed from the IP '.$ipremote; - header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); - //print $conf->global->API_RESTRICT_ON_IP; - exit(0); - } - } - $module = $reg[1]; if ($module == 'explorer') // If we call page to explore details of a service { @@ -268,7 +273,6 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $api->r->addAPIClass($classname); } -// TODO If not found, redirect to explorer //var_dump($api->r->apiVersionMap); //exit; From 69b2d03c470fc145ad92c435520629a7a8afbfad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 16:41:59 +0200 Subject: [PATCH 096/253] FIX Api of documents work with value 'thirdparty' --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a852c78d08b..5861ad07a72 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2452,7 +2452,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } // Wrapping for third parties - elseif (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) + elseif (($modulepart == 'company' || $modulepart == 'societe' || $modulepart == 'thirdparty') && !empty($conf->societe->dir_output)) { if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i', $original_file)) From 60c3cefc53040eaaf3f311a73b4bc5db03cf7aaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 16:41:59 +0200 Subject: [PATCH 097/253] FIX Api of documents work with value 'thirdparty' --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1012b825254..c6a5cb14426 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2445,7 +2445,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } // Wrapping for third parties - elseif (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) + elseif (($modulepart == 'company' || $modulepart == 'societe' || $modulepart == 'thirdparty') && !empty($conf->societe->dir_output)) { if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i', $original_file)) From 7cb68d6438530e80f8aa6270b34baeb6fb016b85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 18:02:10 +0200 Subject: [PATCH 098/253] NEW Default for Stripe is STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION --- htdocs/core/class/conf.class.php | 4 ++-- htdocs/public/payment/newpayment.php | 32 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d64033d969d..f94c95ff246 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -569,8 +569,8 @@ class Conf // By default, we show state code in combo list if (! isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE=1; - // Use a SCA ready workflow with Stripe module - if (! isset($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_NEW_CHECKOUT=1; + // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined) + if (! isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=1; // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index daf77674190..db37b15345b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1834,7 +1834,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print '
'; - print ''; + print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -1852,7 +1853,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print ''; print ''; - if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) // Use a SCA ready method { require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; @@ -1876,8 +1877,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment } } - if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) - { + //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) + //{ print '
'; @@ -1914,7 +1915,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print '
'; - } + //} if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { @@ -1942,6 +1943,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment { print ''; print ''."\n"; + $urllogofull = 'http://home.destailleur.fr:805/dolibarr_dev/htdocs/viewimage.php?modulepart=mycompany&entity=1&file=logos%2Fthumbs%2Ffbm+logo_small.png'; + print ''."\n"; // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. print '