From 6e1702c1a5c40e486bc8dfa3af757bbd23a92b4d Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 17 Aug 2020 15:00:31 +0200 Subject: [PATCH 001/110] Fix infinite fetch object linked loop --- htdocs/core/lib/pdf.lib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1d9d218f7af..3c6bf0765ed 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2127,8 +2127,13 @@ function pdf_getLinkedObjects($object,$outputlangs) // We concat this record info into fields xxx_value. title is overwrote. if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order { - $elementobject->fetchObjectLinked(); - if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); + $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); + if (! empty($elementobject->linkedObjectsIds['commande'])){ + dol_include_once('/commande/commande.class.php'); + $order = new Commande($object->db); + $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); + if ($ret < 1){ $order=null; } + } } if (! is_object($order)) { From b4d2bf98fa84547e916ef1b19b4427d9cb73c9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 20 Aug 2020 12:14:40 +0200 Subject: [PATCH 002/110] Use of undefined constant state - assumed 'state' --- htdocs/includes/OAuth/Common/Storage/DoliStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php index 463afe194db..f0383fdf06f 100644 --- a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php +++ b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php @@ -242,7 +242,7 @@ class DoliStorage implements TokenStorageInterface $sql.= " WHERE service='".$this->db->escape($service)."'"; $resql = $this->db->query($sql); $result = $this->db->fetch_array($resql); - $states[$service] = $result[state]; + $states[$service] = $result['state']; $this->states[$service] = $states[$service]; return is_array($states) From eba4d44c81c4b0f7f7dea8268af519e6566c1902 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 20 Aug 2020 20:24:00 +0200 Subject: [PATCH 003/110] Fix Stripe icon in balance list --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 0de15ef9481..b29a3073c85 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1331,7 +1331,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // List of Stripe payment modes if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $object->fournisseur && !empty($stripesupplieracc)) { - print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); print ''."\n"; print ''; From 142ce7c03f810d1fd70aeff8673d2db2f6fe6158 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 04:58:21 +0200 Subject: [PATCH 004/110] Fix Missing language key --- htdocs/product/fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 563fb881152..9140de09513 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -42,7 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.cl require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; if (!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); // Load translation files required by the page -$langs->loadLangs(array('products', 'suppliers', 'bills', 'margins')); +$langs->loadLangs(array('products', 'suppliers', 'bills', 'margins', 'stocks')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); From bd5e35c15f91b8ce1993447be2cf9e2f6b74a8cd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 05:00:38 +0200 Subject: [PATCH 005/110] Fix Missing language key --- htdocs/langs/en_US/main.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8f79f9525ec..6d2892cddad 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1071,4 +1071,5 @@ SwitchInEditModeToAddTranslation=Switch in edit mode to add translations for thi NotUsedForThisCustomer=Not used for this customer AmountMustBePositive=Amount must be positive ByStatus=By status -InformationMessage=Information \ No newline at end of file +InformationMessage=Information +Used=Used From 881a9b7c047468b743ce9578038673d3aeb93adc Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 05:10:19 +0200 Subject: [PATCH 006/110] Fix Missing language key on rights --- htdocs/langs/en_US/admin.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 90b95883673..73991c172cb 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -851,6 +851,7 @@ Permission773=Delete expense reports Permission774=Read all expense reports (even for user not subordinates) Permission775=Approve expense reports Permission776=Pay expense reports +Permission777=Read expense reports of everybody Permission779=Export expense reports Permission1001=Read stocks Permission1002=Create/modify warehouses @@ -2011,4 +2012,4 @@ MeasuringUnitTypeDesc=Use here a value like "size", "surface", "volume", "weight MeasuringScaleDesc=The scale is the number of places you have to move the decimal part to match the default reference unit. For "time" unit type, it is the number of seconds. Values between 80 and 99 are reserved values. TemplateAdded=Template added TemplateUpdated=Template updated -TemplateDeleted=Template deleted \ No newline at end of file +TemplateDeleted=Template deleted From 646d5cc9c89f1c4ad9511319d52f7448d5db5747 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 05:19:57 +0200 Subject: [PATCH 007/110] Fix Missing language key on rights --- htdocs/langs/en_US/admin.lang | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 73991c172cb..acfc58b7ad2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -839,6 +839,10 @@ Permission532=Create/modify services Permission534=Delete services Permission536=See/manage hidden services Permission538=Export services +Permission561=Read bank transfer payment orders +Permission562=Create/modify a bank transfer payment order +Permission563=Send/Transmit bank transfer payment order +Permission564=Record Debits/Rejects of bank transfer payment order Permission650=Read Bills of Materials Permission651=Create/Update Bills of Materials Permission652=Delete Bills of Materials From dd87362ce372a985903e6d0c861b3ec3286d0f78 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 05:20:53 +0200 Subject: [PATCH 008/110] Fix Missing language key on rights --- htdocs/langs/en_US/admin.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index acfc58b7ad2..1e72900bd12 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -846,6 +846,9 @@ Permission564=Record Debits/Rejects of bank transfer payment order Permission650=Read Bills of Materials Permission651=Create/Update Bills of Materials Permission652=Delete Bills of Materials +Permission660=Read Manufacturing Order +Permission661=Create/Update Manufacturing Order +Permission662=Delete Manufacturing Order Permission701=Read donations Permission702=Create/modify donations Permission703=Delete donations From 76315fa6ac559b6ebc6dac89141da9e0142840b3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 05:22:31 +0200 Subject: [PATCH 009/110] Fix Missing language key on rights --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1e72900bd12..af561bf89c1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -911,6 +911,7 @@ Permission2515=Setup documents directories Permission2801=Use FTP client in read mode (browse and download only) Permission2802=Use FTP client in write mode (delete or upload files) Permission3200=Read archived events and fingerprints +Permission3301=Generate new modules Permission4001=See employees Permission4002=Create employees Permission4003=Delete employees From 065ace5301d32d32519ae3e4604f3b8495787d6d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 21 Aug 2020 05:26:07 +0200 Subject: [PATCH 010/110] Fix Missing language key on rights --- htdocs/langs/en_US/admin.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af561bf89c1..341164ee2c7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -846,9 +846,9 @@ Permission564=Record Debits/Rejects of bank transfer payment order Permission650=Read Bills of Materials Permission651=Create/Update Bills of Materials Permission652=Delete Bills of Materials -Permission660=Read Manufacturing Order -Permission661=Create/Update Manufacturing Order -Permission662=Delete Manufacturing Order +Permission660=Read Manufacturing Order (MO) +Permission661=Create/Update Manufacturing Order (MO) +Permission662=Delete Manufacturing Order (MO) Permission701=Read donations Permission702=Create/modify donations Permission703=Delete donations From ba98db934d879c4f6c0ea87ee691758a9053239b Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 21 Aug 2020 08:18:26 +0200 Subject: [PATCH 011/110] Show user on external calender events --- htdocs/comm/action/index.php | 13 ++++++++-- htdocs/user/class/user.class.php | 43 +++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 97d732f6908..1af04366651 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1061,12 +1061,21 @@ if (count($listofextcals)) $event->id = $icalevent['UID']; $event->ref = $event->id; - $event->icalname = $namecal; + $userId = $userstatic->findUserIdByEmail($namecal); + if(!empty($userId)) + { + $event->userassigned[$userId] = $userId; + } + else + { + $event->icalname = $namecal; + $event->type_code = "ICALEVENT"; + } + $event->icalcolor = $colorcal; $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. $event->datep = $datestart + $usertime; $event->datef = $dateend + $usertime; - $event->type_code = "ICALEVENT"; if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index fdda769c5f4..6d278e635fa 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3236,5 +3236,46 @@ class User extends CommonObject $this->errors[] = $this->db->lasterror(); return -1; } - } + } + + /** + * Cache the SQL results of the function "findUserIdByEmail($email)" + * + * @var array + */ + private $findUserIdByEmailCache; + + /** + * Find a user by the given e-mail or part of a e-mail and return its user id when found + * + * @param string $email The full e-mail or a part of a e-mail + * @return int|null The id of the user when found, otherwise null + */ + public function findUserIdByEmail($email) + { + if($this->findUserIdByEmailCache[$email]) + { + return $this->findUserIdByEmailCache[$email]; + } + + $sql = 'SELECT rowid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'user'; + $sql .= ' WHERE email LIKE "%'.$email.'%"'; + + $resql = $this->db->query($sql); + if (!$resql) + { + return 0; + } + + $obj = $this->db->fetch_object($resql); + if (!$obj) + { + return 0; + } + + $this->findUserIdByEmailCache[$email] = (int)$obj->rowid; + + return (int)$obj->rowid; + } } From bb1452917b20b1f61225fa1b07be389e891a2612 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 21 Aug 2020 08:33:19 +0200 Subject: [PATCH 012/110] fix wrong event percentage --- htdocs/comm/action/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 1af04366651..f75913bb144 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1065,6 +1065,7 @@ if (count($listofextcals)) if(!empty($userId)) { $event->userassigned[$userId] = $userId; + $event->percentage = -1; } else { From 22ff5a320fdbed3e4d70dbc758aecad2bf4dd4af Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 21 Aug 2020 08:40:23 +0200 Subject: [PATCH 013/110] fix not working external calender on/off --- htdocs/comm/action/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f75913bb144..e5ab1c02902 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1069,10 +1069,10 @@ if (count($listofextcals)) } else { - $event->icalname = $namecal; $event->type_code = "ICALEVENT"; } + $event->icalname = $namecal; $event->icalcolor = $colorcal; $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. $event->datep = $datestart + $usertime; From 61cce2e700684e39e5e9ccdacf4b885547238a9b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 21 Aug 2020 06:46:00 +0000 Subject: [PATCH 014/110] Fixing style errors. --- htdocs/comm/action/index.php | 5 ++--- htdocs/user/class/user.class.php | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e5ab1c02902..dafd9c4aecf 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1062,13 +1062,12 @@ if (count($listofextcals)) $event->ref = $event->id; $userId = $userstatic->findUserIdByEmail($namecal); - if(!empty($userId)) + if (!empty($userId)) { $event->userassigned[$userId] = $userId; $event->percentage = -1; } - else - { + else { $event->type_code = "ICALEVENT"; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6d278e635fa..4d250c02fb7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3248,12 +3248,12 @@ class User extends CommonObject /** * Find a user by the given e-mail or part of a e-mail and return its user id when found * - * @param string $email The full e-mail or a part of a e-mail + * @param string $email The full e-mail or a part of a e-mail * @return int|null The id of the user when found, otherwise null */ public function findUserIdByEmail($email) { - if($this->findUserIdByEmailCache[$email]) + if ($this->findUserIdByEmailCache[$email]) { return $this->findUserIdByEmailCache[$email]; } @@ -3274,8 +3274,8 @@ class User extends CommonObject return 0; } - $this->findUserIdByEmailCache[$email] = (int)$obj->rowid; + $this->findUserIdByEmailCache[$email] = (int) $obj->rowid; - return (int)$obj->rowid; + return (int) $obj->rowid; } } From d9cbd8f998c2d62a571231181e0bdd31a0c87ed8 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sat, 22 Aug 2020 18:28:15 +0200 Subject: [PATCH 015/110] NEW: Print payment method and change in TakePOS --- .../compta/paiement/class/paiement.class.php | 7 +++- htdocs/core/class/dolreceiptprinter.class.php | 31 +++++++++++++- .../install/mysql/migration/12.0.0-13.0.0.sql | 2 + htdocs/install/mysql/tables/llx_paiement.sql | 3 +- htdocs/langs/en_US/cashdesk.lang | 1 + htdocs/takepos/admin/receipt.php | 8 ++++ htdocs/takepos/invoice.php | 1 + htdocs/takepos/pay.php | 3 +- htdocs/takepos/receipt.php | 41 +++++++++++++++++++ 9 files changed, 92 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 5e01454dd75..38ad5637767 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -9,6 +9,7 @@ * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Thibault FOUCART * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Andreu Bisquerra Gaya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,6 +73,8 @@ class Paiement extends CommonObject public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency)> public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency)> + + public $takepos_change = 0; // Excess received in TakePOS cash payment public $author; public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement @@ -288,8 +291,8 @@ class Paiement extends CommonObject $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement); $note = ($this->note_public ? $this->note_public : $this->note); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, takepos_change)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".$this->takepos_change.")"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 3234b1900f2..08cf0297e15 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -186,7 +186,7 @@ class dolReceiptPrinter extends Printer 'dol_value_month' => 'DOL_VALUE_MONTH', 'dol_value_day' => 'DOL_VALUE_DAY', 'dol_value_day_letters' => 'DOL_VALUE_DAY', - //'dol_print_payment', + 'dol_print_payment' => 'DOL_PRINT_PAYMENT', 'dol_print_logo' => 'DOL_PRINT_LOGO', 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', 'dol_value_object_id' => 'InvoiceID', @@ -775,6 +775,35 @@ class dolReceiptPrinter extends Printer } } break; + case 'DOL_PRINT_PAYMENT': + $sql = "SELECT p.takepos_change as takepos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; + $sql .= " cp.code"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; + $sql .= " ORDER BY p.datep"; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $row = $this->db->fetch_object($resql); + $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12; + $spaces = str_repeat(' ', $spacestoadd); + $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; + if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->takepos_change; // Show amount with excess received if is cash payment + $this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n"); + if ($row->code == "LIQ" && $row->takepos_change>0) // Print change only in cash payments + { + $spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->takepos_change), 10, ' ', STR_PAD_LEFT)."\n"); + } + $i++; + } + } + break; default: $this->printer->text($vals[$tplline]['tag']); $this->printer->text($vals[$tplline]['value']); diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index d25f5c2975d..7870e051b1c 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -256,3 +256,5 @@ ALTER TABLE llx_projet ADD COLUMN email_msgid varchar(255); ALTER TABLE llx_ticket ADD COLUMN email_msgid varchar(255); ALTER TABLE llx_actioncomm ADD COLUMN reply_to varchar(255); +ALTER TABLE llx_paiement ADD takepos_change DOUBLE(24,8) DEFAULT 0 AFTER fk_export_compta; + diff --git a/htdocs/install/mysql/tables/llx_paiement.sql b/htdocs/install/mysql/tables/llx_paiement.sql index d0cfd727d95..9e6df8f1a4d 100644 --- a/htdocs/install/mysql/tables/llx_paiement.sql +++ b/htdocs/install/mysql/tables/llx_paiement.sql @@ -37,5 +37,6 @@ create table llx_paiement fk_user_creat integer, -- utilisateur qui a cree l'info fk_user_modif integer, -- utilisateur qui a modifie l'info statut smallint DEFAULT 0 NOT NULL, -- Satut, 0 ou 1, 1 n'est plus supprimable - fk_export_compta integer DEFAULT 0 NOT NULL -- fk_export_compta 0 pas exporte + fk_export_compta integer DEFAULT 0 NOT NULL, -- fk_export_compta 0 pas exporte + takepos_change double(24,8) DEFAULT 0 -- Excess received in TakePOS cash payment )ENGINE=innodb; diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 094c70ca687..40691eb70e7 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -121,3 +121,4 @@ GiftReceiptButton=Add a "Gift receipt" button GiftReceipt=Gift receipt ModuleReceiptPrinterMustBeEnabled=Module Receipt printer must have been enabled first AllowDelayedPayment=Allow delayed payment +PrintPaymentMethodOnReceipts=Print payment method on tickets|receipts \ No newline at end of file diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 252781ec635..c17787c0ea1 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -48,6 +48,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_PRINT_PAYMENT_METHOD", GETPOST('TAKEPOS_PRINT_PAYMENT_METHOD', 'alpha'), 'chaine', 0, '', $conf->entity); dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); @@ -216,6 +217,13 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P print '\n"; + + // Print payment method + print '\n"; } // Auto print tickets diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d4274d90444..20bf23cc215 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -241,6 +241,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->datepaye = $now; $payment->fk_account = $bankaccount; $payment->amounts[$invoice->id] = $amountofpayment; + if ($pay == 'cash') $payment->takepos_change = price2num(GETPOST('excess', 'alpha')); // If user has not used change control, add total invoice payment // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 0a1c60a5a57..f63aec61289 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -186,11 +186,12 @@ else print "var received=0;"; var invoiceid = 0 ? $invoiceid : 0); ?>; var accountid = $("#selectaccountid").val(); var amountpayed = $("#change1").val(); + var excess = $("#change2").val(); if (amountpayed > total_ttc; ?>) { amountpayed = total_ttc; ?>; } console.log("We click on the payment mode to pay amount = "+amountpayed); - parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { + parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close(); else location.reload(); }); diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 99000c278de..a03cb24d373 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -181,6 +181,47 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER) +global->TAKEPOS_PRINT_PAYMENT_METHOD) { + $sql = "SELECT p.takepos_change as takepos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; + $sql .= " cp.code"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid; + $sql .= " ORDER BY p.datep"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $row = $db->fetch_object($resql); + echo ''; + echo ''; + echo ''; + echo ''; + if ($row->code == "LIQ" && $row->takepos_change>0) // Print change only in cash payments + { + echo ''; + echo ''; + echo ''; + echo ''; + } + $i++; + } + } +} +?>
'; print $form->selectyesno("TAKEPOS_SHOW_CUSTOMER", $conf->global->TAKEPOS_SHOW_CUSTOMER, 1); print "
'; + print $langs->trans('PrintPaymentMethodOnReceipts'); + print ''; + print $form->selectyesno("TAKEPOS_PRINT_PAYMENT_METHOD", $conf->global->TAKEPOS_PRINT_PAYMENT_METHOD, 1); + print "
trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
'; + echo $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code); + echo ''; + $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; + if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->takepos_change; // Show amount with excess received if is cash payment + echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency); + echo '
'; + echo $langs->trans("Change"); + echo ''; + echo price($row->takepos_change, 1, '', 1, - 1, - 1, $conf->currency); + echo '

From e8c8cb53cb581ce28af96393bb4147a0f0c78bde Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 22 Aug 2020 18:45:54 +0200 Subject: [PATCH 016/110] Fix travis --- htdocs/takepos/admin/receipt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index c17787c0ea1..5679f861a29 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -217,7 +217,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P print ''; print $form->selectyesno("TAKEPOS_SHOW_CUSTOMER", $conf->global->TAKEPOS_SHOW_CUSTOMER, 1); print "\n"; - + // Print payment method print ''; print $langs->trans('PrintPaymentMethodOnReceipts'); From e36eb42568f6de45222d3ed27b2583d21dc2ee97 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 22 Aug 2020 18:46:39 +0200 Subject: [PATCH 017/110] Fix travis --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 38ad5637767..ab12405748b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -73,7 +73,7 @@ class Paiement extends CommonObject public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency)> public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency)> - + public $takepos_change = 0; // Excess received in TakePOS cash payment public $author; From bf28201685a65d70f82be93bf816d6e4d08f76aa Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 23 Aug 2020 07:13:43 +0200 Subject: [PATCH 018/110] Fix Missing language key --- htdocs/core/class/infobox.class.php | 4 ++-- htdocs/langs/en_US/boxes.lang | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index de00ea85e6f..ffba924b1ea 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -41,7 +41,7 @@ class InfoBox { return array( 0 => 'Home', - 27 => 'Accountancy Home' + 27 => 'AccountancyHome' ); } else @@ -74,7 +74,7 @@ class InfoBox 24 => 'expensereportindex', 25 => 'mailingindex', 26 => 'opensurveyindex', - 27 => 'Accountancy Home' + 27 => 'AccountancyHome' ); } } diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index bd62684421a..2405bfd5e64 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -100,3 +100,5 @@ SuspenseAccountNotDefined=Suspense account isn't defined BoxLastCustomerShipments=Last customer shipments BoxTitleLastCustomerShipments=Latest %s customer shipments NoRecordedShipments=No recorded customer shipment +# Pages +AccountancyHome=Accountancy From 9b7691c8d2459717e1ea7f82f95ca1386cb810bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Aug 2020 18:04:02 +0200 Subject: [PATCH 019/110] Update admin.lang --- htdocs/langs/en_US/admin.lang | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 341164ee2c7..72c741c9056 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -839,10 +839,10 @@ Permission532=Create/modify services Permission534=Delete services Permission536=See/manage hidden services Permission538=Export services -Permission561=Read bank transfer payment orders -Permission562=Create/modify a bank transfer payment order -Permission563=Send/Transmit bank transfer payment order -Permission564=Record Debits/Rejects of bank transfer payment order +Permission561=Read payment orders by credit transfer +Permission562=Create/modify payment order by credit transfer +Permission563=Send/Transmit payment order by credit transfer +Permission564=Record Debits/Rejections of credit transfer Permission650=Read Bills of Materials Permission651=Create/Update Bills of Materials Permission652=Delete Bills of Materials From 6685cc5bc8ab4b74669cfedfacbd9f95872a3044 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Aug 2020 18:07:18 +0200 Subject: [PATCH 020/110] Update admin.lang --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 72c741c9056..482f89b30e7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -859,6 +859,7 @@ Permission774=Read all expense reports (even for user not subordinates) Permission775=Approve expense reports Permission776=Pay expense reports Permission777=Read expense reports of everybody +Permission778=Create/modify expense reports of everybody Permission779=Export expense reports Permission1001=Read stocks Permission1002=Create/modify warehouses From 7eb003c6843a17a1cad2ef57a183bc3dcc326c73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Aug 2020 19:11:19 +0200 Subject: [PATCH 021/110] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3c6bf0765ed..c83b7f28ce6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2129,7 +2129,7 @@ function pdf_getLinkedObjects($object,$outputlangs) { $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); if (! empty($elementobject->linkedObjectsIds['commande'])){ - dol_include_once('/commande/commande.class.php'); + include_once DOL_DOCUMENT_ROOT.'/commande/commande.class.php'; $order = new Commande($object->db); $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); if ($ret < 1){ $order=null; } From b44d6744f9b496972491615f9c28ac445ccf6abe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Aug 2020 19:11:40 +0200 Subject: [PATCH 022/110] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c83b7f28ce6..c0c7c7d0f9b 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2132,7 +2132,7 @@ function pdf_getLinkedObjects($object,$outputlangs) include_once DOL_DOCUMENT_ROOT.'/commande/commande.class.php'; $order = new Commande($object->db); $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); - if ($ret < 1){ $order=null; } + if ($ret < 1) { $order=null; } } } if (! is_object($order)) From 7a183ea026bc0189f07ac803e006124a07eefe40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Aug 2020 19:13:30 +0200 Subject: [PATCH 023/110] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c0c7c7d0f9b..54252923ad6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2071,7 +2071,7 @@ function pdf_getTotalQty($object,$type,$outputlangs) */ function pdf_getLinkedObjects($object,$outputlangs) { - global $hookmanager; + global $db, $hookmanager; $linkedobjects=array(); @@ -2130,7 +2130,7 @@ function pdf_getLinkedObjects($object,$outputlangs) $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); if (! empty($elementobject->linkedObjectsIds['commande'])){ include_once DOL_DOCUMENT_ROOT.'/commande/commande.class.php'; - $order = new Commande($object->db); + $order = new Commande($db); $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); if ($ret < 1) { $order=null; } } From 74eac1d06a1708152b8232be83e897385724eafa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Aug 2020 19:22:01 +0200 Subject: [PATCH 024/110] Fix include regression --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 54252923ad6..6a1ebacdab1 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2129,7 +2129,7 @@ function pdf_getLinkedObjects($object,$outputlangs) { $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); if (! empty($elementobject->linkedObjectsIds['commande'])){ - include_once DOL_DOCUMENT_ROOT.'/commande/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $order = new Commande($db); $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); if ($ret < 1) { $order=null; } From a5ab711b27ca81df3328a8c6be3179a4b3eb863b Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:22:05 +0200 Subject: [PATCH 025/110] Change variable to pos_change --- htdocs/compta/paiement/class/paiement.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index ab12405748b..4ec28bf2935 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -74,7 +74,7 @@ class Paiement extends CommonObject public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency)> public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency)> - public $takepos_change = 0; // Excess received in TakePOS cash payment + public $pos_change = 0; // Excess received in TakePOS cash payment public $author; public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement @@ -291,8 +291,8 @@ class Paiement extends CommonObject $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement); $note = ($this->note_public ? $this->note_public : $this->note); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, takepos_change)"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".$this->takepos_change.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".$this->pos_change.")"; $resql = $this->db->query($sql); if ($resql) From f9913be7198f3af28325ccc90f4f27761bfcf795 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:24:46 +0200 Subject: [PATCH 026/110] Change variable to pos_change --- htdocs/core/class/dolreceiptprinter.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 08cf0297e15..b7929e6a159 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -776,7 +776,7 @@ class dolReceiptPrinter extends Printer } break; case 'DOL_PRINT_PAYMENT': - $sql = "SELECT p.takepos_change as takepos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; + $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -792,13 +792,13 @@ class dolReceiptPrinter extends Printer $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12; $spaces = str_repeat(' ', $spacestoadd); $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; - if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->takepos_change; // Show amount with excess received if is cash payment + if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment $this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n"); - if ($row->code == "LIQ" && $row->takepos_change>0) // Print change only in cash payments + if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments { $spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12; $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->takepos_change), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->pos_change), 10, ' ', STR_PAD_LEFT)."\n"); } $i++; } From ec2479a41aaee7bde7433cfd603321ede4f8bace Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:26:22 +0200 Subject: [PATCH 027/110] Update 12.0.0-13.0.0.sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 7870e051b1c..02231edfc6e 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -256,5 +256,5 @@ ALTER TABLE llx_projet ADD COLUMN email_msgid varchar(255); ALTER TABLE llx_ticket ADD COLUMN email_msgid varchar(255); ALTER TABLE llx_actioncomm ADD COLUMN reply_to varchar(255); -ALTER TABLE llx_paiement ADD takepos_change DOUBLE(24,8) DEFAULT 0 AFTER fk_export_compta; +ALTER TABLE llx_paiement ADD pos_change DOUBLE(24,8) DEFAULT 0 AFTER fk_export_compta; From e032ddc035ac1f2655fae87c5e81d410c427536e Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:27:18 +0200 Subject: [PATCH 028/110] Change variable to pos_change --- htdocs/install/mysql/tables/llx_paiement.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_paiement.sql b/htdocs/install/mysql/tables/llx_paiement.sql index 9e6df8f1a4d..d19d38312a4 100644 --- a/htdocs/install/mysql/tables/llx_paiement.sql +++ b/htdocs/install/mysql/tables/llx_paiement.sql @@ -38,5 +38,5 @@ create table llx_paiement fk_user_modif integer, -- utilisateur qui a modifie l'info statut smallint DEFAULT 0 NOT NULL, -- Satut, 0 ou 1, 1 n'est plus supprimable fk_export_compta integer DEFAULT 0 NOT NULL, -- fk_export_compta 0 pas exporte - takepos_change double(24,8) DEFAULT 0 -- Excess received in TakePOS cash payment + pos_change double(24,8) DEFAULT 0 -- Excess received in TakePOS cash payment )ENGINE=innodb; From 8f933c324a34f2368ab222bc7a51acfd18ca0238 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:28:26 +0200 Subject: [PATCH 029/110] Change variable to pos_change --- 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 20bf23cc215..a25c809b551 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -241,7 +241,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->datepaye = $now; $payment->fk_account = $bankaccount; $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'cash') $payment->takepos_change = price2num(GETPOST('excess', 'alpha')); + if ($pay == 'cash') $payment->pos_change = price2num(GETPOST('excess', 'alpha')); // If user has not used change control, add total invoice payment // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay From 915aa56a958c4a3e0b6aea622c1ef8015af20358 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:29:55 +0200 Subject: [PATCH 030/110] Change variable to pos_change --- htdocs/takepos/receipt.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index a03cb24d373..c7ca395a316 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -183,7 +183,7 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER) global->TAKEPOS_PRINT_PAYMENT_METHOD) { - $sql = "SELECT p.takepos_change as takepos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; + $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -202,18 +202,18 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) { echo ''; echo ''; $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; - if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->takepos_change; // Show amount with excess received if is cash payment + if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency); echo ''; echo ''; - if ($row->code == "LIQ" && $row->takepos_change>0) // Print change only in cash payments + if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments { echo ''; echo ''; echo $langs->trans("Change"); echo ''; echo ''; - echo price($row->takepos_change, 1, '', 1, - 1, - 1, $conf->currency); + echo price($row->pos_change, 1, '', 1, - 1, - 1, $conf->currency); echo ''; echo ''; } From 5aac080e6136027a0545412c660d05350ffe64e9 Mon Sep 17 00:00:00 2001 From: StephaneLesage Date: Mon, 24 Aug 2020 01:01:35 +0200 Subject: [PATCH 031/110] NEW Third-Party Import new fields: mother company,outstanding debt limit,bank account,incoterms --- htdocs/core/modules/modSociete.class.php | 72 ++++++++++++++++++------ 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 4b422348bee..1ed4ee2cb73 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -261,13 +261,15 @@ class modSociete extends DolibarrModules $this->export_icon[$r] = 'company'; $this->export_permission[$r] = array(array("societe", "export")); $this->export_fields_array[$r] = array( - 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", + 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 'ps.nom'=>"ParentCompany", + 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", - 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom' => 'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom'=>'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic", 't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel', - 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode' + 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode', + 's.outstanding_limit'=>'OutstandingBill', 'pbacc.ref'=>'PaymentBankAccount', 'incoterm.code'=>'IncotermLabel' ); if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix'; if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel'; @@ -280,6 +282,7 @@ class modSociete extends DolibarrModules $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); + //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", @@ -289,15 +292,17 @@ class modSociete extends DolibarrModules // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' //); $this->export_TypeFields_array[$r] = array( - 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", - 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", - 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", - 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", - 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text", - 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', - 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'r.nom' => 'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text', - 'paymode.libelle'=>'Text', 's.entity'=>'Numeric', - 's.price_level'=>'Numeric' + 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 'ps.nom'=>"Text", + 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", + 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", + 's.address'=>"Text", 's.zip'=>"Text",'s.town'=>"Text", 'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", + 's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", + 's.idprof5'=>"Text", 's.idprof6'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", + 't.libelle'=>"Text", 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', + 'st.code'=>'List:c_stcomm:libelle:code', 'payterm.libelle'=>'Text', 'paymode.libelle'=>'Text', + 's.outstanding_limit'=>'Numeric', 'pbacc.ref'=>'Text', 'incoterm.code'=>'Text', + 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', + 's.entity'=>'Numeric', 's.price_level'=>'Numeric' ); $this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto @@ -305,16 +310,19 @@ class modSociete extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON s.parent = ps.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = s.fk_pays'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = s.fk_pays'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as pbacc ON s.fk_account = pbacc.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as incoterm ON s.fk_incoterms = incoterm.rowid'; $this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' '; @@ -334,7 +342,7 @@ class modSociete extends DolibarrModules $this->export_fields_array[$r] = array( 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction', 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town", - 'd.nom'=>'State', 'r.nom' => 'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", + 'd.nom'=>'State', 'r.nom'=>'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", 'c.statut'=>"Status", 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", @@ -345,7 +353,7 @@ class modSociete extends DolibarrModules $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); $this->export_TypeFields_array[$r] = array( 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean", - 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'r.nom' => 'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", + 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'r.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", 'c.fax'=>"Text", 'c.email'=>"Text", 'c.statut'=>"Status", 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", @@ -376,7 +384,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; @@ -409,6 +417,7 @@ class modSociete extends DolibarrModules $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe 's.nom' => "Name*", 's.name_alias' => "AliasNameShort", + 's.parent' => "ParentCompany", 's.status' => "Status", 's.code_client' => "CustomerCode", 's.code_fournisseur' => "SupplierCode", @@ -445,6 +454,9 @@ class modSociete extends DolibarrModules 's.cond_reglement' => "PaymentTermsCustomer", 's.mode_reglement_supplier' => 'PaymentTypeSupplier', 's.cond_reglement_supplier' => "PaymentTermsSupplier", + 's.outstanding_limit'=>'OutstandingBill', + 's.fk_account'=>'PaymentBankAccount', + 's.fk_incoterms'=>'IncotermLabel', 's.tva_assuj' => 'VATIsUsed', 's.barcode' => 'BarCode', 's.default_lang' => 'DefaultLanguage', @@ -498,6 +510,29 @@ class modSociete extends DolibarrModules ), 's.capital' => array('rule' => 'numeric'), 's.fk_stcomm' => array('rule' => 'zeroifnull'), + 's.parent' => array( + 'rule' => 'fetchidfromref', + 'file' => '/societe/class/societe.class.php', + 'class' => 'Societe', + 'method' => 'fetch', + 'element' => 'ThirdParty' + ), + 's.outstanding_limit' => array('rule' => 'numeric'), + 's.fk_account' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/compta/bank/class/account.class.php', + 'class' => 'Account', + 'method' => 'fetch', + 'element' => 'BankAccount' +// ), +// TODO +// 's.fk_incoterms' => array( +// 'rule' => 'fetchidfromcodeid', +// 'classfile' => '/core/class/cincoterm.class.php', +// 'class' => 'Cincoterm', +// 'method' => 'fetch', +// 'dict' => 'IncotermLabel' + ) ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r] = array(//field order as per structure of table llx_societe @@ -509,6 +544,7 @@ class modSociete extends DolibarrModules 's.cond_reglement' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term', 's.mode_reglement_supplier' => 'id@'.MAIN_DB_PREFIX.'c_paiement', 's.cond_reglement_supplier' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term', + 's.fk_incoterms' => 'rowid@'.MAIN_DB_PREFIX.'c_incoterms', 's.tva_assuj' => '^[0|1]', 's.fk_multicurrency' => '^[0|1]', 's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', @@ -518,6 +554,7 @@ class modSociete extends DolibarrModules $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe 's.nom' => "TPBigCompany", 's.name_alias' => "Alias for TPBigCompany", + 's.parent' => "TPMotherCompany", 's.status' => "0 (closed) / 1 (active)", 's.code_client' => 'eg. CU01-0001 / empty / "auto"', 's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"', @@ -554,6 +591,9 @@ class modSociete extends DolibarrModules 's.cond_reglement' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"', 's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"', 's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"', + 's.outstanding_limit' => "5000", + 's.fk_account' => "rowid or ref", + 's.fk_incoterms' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_incoterms"', 's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)', 's.barcode' => '123456789', 's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/', From 721b1275fffa60e9e16f76020edc491a220447c5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 23 Aug 2020 23:20:07 +0000 Subject: [PATCH 032/110] Fixing style errors. --- htdocs/core/modules/modSociete.class.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 1ed4ee2cb73..6ce1088aa2f 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -261,7 +261,7 @@ class modSociete extends DolibarrModules $this->export_icon[$r] = 'company'; $this->export_permission[$r] = array(array("societe", "export")); $this->export_fields_array[$r] = array( - 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 'ps.nom'=>"ParentCompany", + 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 'ps.nom'=>"ParentCompany", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom'=>'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", @@ -292,7 +292,7 @@ class modSociete extends DolibarrModules // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' //); $this->export_TypeFields_array[$r] = array( - 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 'ps.nom'=>"Text", + 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 'ps.nom'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text",'s.town'=>"Text", 'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", @@ -417,7 +417,7 @@ class modSociete extends DolibarrModules $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe 's.nom' => "Name*", 's.name_alias' => "AliasNameShort", - 's.parent' => "ParentCompany", + 's.parent' => "ParentCompany", 's.status' => "Status", 's.code_client' => "CustomerCode", 's.code_fournisseur' => "SupplierCode", @@ -524,15 +524,15 @@ class modSociete extends DolibarrModules 'class' => 'Account', 'method' => 'fetch', 'element' => 'BankAccount' -// ), -// TODO -// 's.fk_incoterms' => array( -// 'rule' => 'fetchidfromcodeid', -// 'classfile' => '/core/class/cincoterm.class.php', -// 'class' => 'Cincoterm', -// 'method' => 'fetch', -// 'dict' => 'IncotermLabel' - ) + // ), + // TODO + // 's.fk_incoterms' => array( + // 'rule' => 'fetchidfromcodeid', + // 'classfile' => '/core/class/cincoterm.class.php', + // 'class' => 'Cincoterm', + // 'method' => 'fetch', + // 'dict' => 'IncotermLabel' + ) ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r] = array(//field order as per structure of table llx_societe From eebe8883771b8cf93775f003691ef77c9d050b84 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 24 Aug 2020 09:47:37 +0200 Subject: [PATCH 033/110] Some fix on assets --- htdocs/asset/class/asset.class.php | 2 +- htdocs/asset/list.php | 2 +- htdocs/asset/type.php | 23 +++++++++-------------- htdocs/core/lib/asset.lib.php | 4 ++-- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/modules/modAsset.class.php | 8 ++++---- 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 3c29fe6e7ce..945d893dab7 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -331,7 +331,7 @@ class Asset extends CommonObject $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; - $url = dol_buildpath('/assets/card.php', 1).'?id='.$this->id; + $url = dol_buildpath('/asset/card.php', 1).'?id='.$this->id; if ($option != 'nolink') { diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 0f6624f1254..549e2fc0d25 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -271,7 +271,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/assets/card.php?id='.$id); + header("Location: ".DOL_URL_ROOT.'/asset/card.php?id='.$id); exit; } diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index a2c6bab3f90..eebc85fc099 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -77,6 +77,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x' // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('assettypecard', 'globalcard')); +$permissiontoadd = $user->rights->asset->setup_advance; /* * Actions @@ -211,14 +212,6 @@ if (!$rowid && $action != 'create' && $action != 'edit') $param = ''; - $newcardbutton = ''; - if ($user->rights->asset->configurer) - { - $newcardbutton = ''.$langs->trans('NewAssetType').''; - $newcardbutton .= ''; - $newcardbutton .= ''; - } - print '
'; if ($optioncss != '') print ''; print ''; @@ -228,6 +221,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') print ''; print ''; + $newcardbutton = dolGetButtonTitle($langs->trans('NewAssetType'), '', 'fa fa-plus-circle', dol_buildpath('/asset/type.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'accountancy', 0, $newcardbutton, '', $limit); $moreforfilter = ''; @@ -238,9 +233,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') print ''; print ''.$langs->trans("Ref").''; print ''.$langs->trans("Label").''; - print ''.$langs->trans("AccountancyCodeAsset").''; - print ''.$langs->trans("AccountancyCodeDepreciationAsset").''; - print ''.$langs->trans("AccountancyCodeDepreciationExpense").''; + print ''.$langs->trans("AccountancyCodeAsset").''; + print ''.$langs->trans("AccountancyCodeDepreciationAsset").''; + print ''.$langs->trans("AccountancyCodeDepreciationExpense").''; print ' '; print "\n"; @@ -267,7 +262,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objp->accountancy_code_asset, 1); - print $accountingaccount->getNomUrl(0, 0, 0, '', 0); + print $accountingaccount->getNomUrl(0, 1, 1, '', 0); } else { print $objp->accountancy_code_asset; } @@ -279,7 +274,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1); - print $accountingaccount2->getNomUrl(0, 0, 0, '', 0); + print $accountingaccount2->getNomUrl(0, 1, 1, '', 0); } else { print $objp->accountancy_code_depreciation_asset; } @@ -291,7 +286,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1); - print $accountingaccount3->getNomUrl(0, 0, 0, '', 0); + print $accountingaccount3->getNomUrl(0, 1, 1, '', 0); } else { print $objp->accountancy_code_depreciation_expense; } diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 1b58784f6e8..5fddf4f1c46 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -88,10 +88,10 @@ function asset_prepare_head(Asset $object) // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( - // 'entity:+tabname:Title:@assets:/assets/mypage.php?id=__ID__' + // 'entity:+tabname:Title:@assets:/asset/mypage.php?id=__ID__' //); // to add new tab //$this->tabs = array( - // 'entity:-tabname:Title:@assets:/assets/mypage.php?id=__ID__' + // 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__' //); // to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets'); diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index ec75b35073c..a9f876f10cd 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -316,7 +316,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3001__+MAX_llx_menu__, 'asset', '', 3000__+MAX_llx_menu__, '/asset/card.php?mainmenu=accountancy&leftmenu=asset&action=create', 'MenuNewAsset', 2, 'assets', '$user->rights->asset->write', '', 0, 21, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3003__+MAX_llx_menu__, 'asset', '', 3000__+MAX_llx_menu__, '/asset/list.php?mainmenu=accountancy&leftmenu=asset', 'MenuListAssets', 2, 'assets', '$user->rights->asset->read', '', 0, 22, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3004__+MAX_llx_menu__, 'asset', 'asset_type', 3000__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&leftmenu=asset', 'MenuTypeAssets', 2, 'assets', '$user->rights->asset->read', '', 0, 23, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3005__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&action=create', 'MenuNewTypeAssets', 3, 'assets', '$user->rights->asset->configurer', '', 0, 24, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3005__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&action=create', 'MenuNewTypeAssets', 3, 'assets', '$user->rights->asset->setup_advance', '', 0, 24, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3006__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy', 'MenuListTypeAssets', 3, 'assets', '$user->rights->asset->read', '', 0, 25, __ENTITY__); -- Check deposit insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?mainmenu=bank&leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 65be4ba0e4b..db1da8c79fd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1446,7 +1446,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) { - $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->setup_advance)); + $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->setup_advance)); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read); } } diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index ebceca2960e..b736bdb4367 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -81,7 +81,7 @@ class modAsset extends DolibarrModules // Example: this->dirs = array("/asset/temp","/asset/subdir"); $this->dirs = array(); - // Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module. + // Config pages. Put here list of php page, stored into asset/admin directory, to use to setup module. $this->config_page_url = array("setup.php@asset"); // Dependencies @@ -115,8 +115,8 @@ class modAsset extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/assets/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/assets/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/asset/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/asset/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // // Where objecttype can be @@ -146,7 +146,7 @@ class modAsset extends DolibarrModules // Boxes/Widgets - // Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget. + // Add here list of php file(s) stored in asset/core/boxes that contains class to show a widget. $this->boxes = array( //0=>array('file'=>'assetswidget1.php@asset','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'), //1=>array('file'=>'assetswidget2.php@asset','note'=>'Widget provided by Assets'), From 9da49469551848837a3bd52b75a891d020e8188e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 24 Aug 2020 12:26:40 +0200 Subject: [PATCH 034/110] Fix for better code --- htdocs/takepos/pay.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index b2534272ae2..cea50d390aa 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -341,8 +341,7 @@ if ($conf->global->TAKEPOS_ENABLE_SUMUP) { if (!empty($conf->global->$keyforsumupbank)) { print ''; } else { - $langs->load("errors"); - $langs->load("admin"); + $langs->loadLangs(array("errors", "admin"); print ''; } } From ff621cb146506ed6acb2d2c4bb84400bfae73a3f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 24 Aug 2020 12:27:19 +0200 Subject: [PATCH 035/110] Update pay.php --- htdocs/takepos/pay.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index cea50d390aa..031c3cc8f2d 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -341,7 +341,7 @@ if ($conf->global->TAKEPOS_ENABLE_SUMUP) { if (!empty($conf->global->$keyforsumupbank)) { print ''; } else { - $langs->loadLangs(array("errors", "admin"); + $langs->loadLangs(array("errors", "admin")); print ''; } } From 4c887d6110b86fe1f2bc9bf23dc3b1f10bb0568c Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 24 Aug 2020 14:53:34 +0200 Subject: [PATCH 036/110] Fix for non-numeric value in payment --- htdocs/fourn/facture/paiement.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index db5bc9acfb5..df5d62d1e5f 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -129,7 +129,8 @@ if (empty($reshook)) $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $paiement_id = 0; $totalpayment = 0; - $atleastonepaymentnotnull = 0; + $atleastonepaymentnotnull = 0; + $multicurrency_totalpayment = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date $tmpinvoice = new FactureFournisseur($db); @@ -171,7 +172,7 @@ if (empty($reshook)) } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); - $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $multicurrency_amounts[$cursorfacid] = GETPOST($key) ? price2num(trim(GETPOST($key))) : 0; $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; $result = $tmpinvoice->fetch($cursorfacid); From 0e9677fd3417f3f9ef8501814ca594a94b797711 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 24 Aug 2020 15:59:05 +0200 Subject: [PATCH 037/110] allow default settings for "cond_reglement_id" and "mode_reglement_id" (cherry picked from commit 2e5475d181af2e8ceb6ea220424fd1329e72e342) --- htdocs/comm/propal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f275f16ee03..794344fd5f8 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1556,12 +1556,12 @@ if ($action == 'create') // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements( empty($soc->cond_reglement_id) ? (GETPOST('cond_reglement_id', 'int') ? GETPOST('cond_reglement_id', 'int') : '' ) : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print ''; // Mode of payment print ''.$langs->trans('PaymentMode').''; - $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements(empty($soc->mode_reglement_id) ? (GETPOST('mode_reglement_id', 'int') ? GETPOST('mode_reglement_id', 'int') : '' ) : $soc->mode_reglement_id, 'mode_reglement_id'); print ''; // Bank Account From a60968e95b5d50b8aaff176adfd662b9135514c0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 24 Aug 2020 14:17:15 +0000 Subject: [PATCH 038/110] Fixing style errors. --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 794344fd5f8..4f2c0de238b 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1556,7 +1556,7 @@ if ($action == 'create') // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements( empty($soc->cond_reglement_id) ? (GETPOST('cond_reglement_id', 'int') ? GETPOST('cond_reglement_id', 'int') : '' ) : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements(empty($soc->cond_reglement_id) ? (GETPOST('cond_reglement_id', 'int') ? GETPOST('cond_reglement_id', 'int') : '' ) : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print ''; // Mode of payment From 05d82a06846a06adcfc34e39cdcd81012ebb01b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Aug 2020 17:07:30 +0200 Subject: [PATCH 039/110] FIX Error management. Do no try to approve PO if validation fails. --- htdocs/fourn/commande/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 19e6f100609..9341bc24c4b 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -854,11 +854,12 @@ if (empty($reshook)) } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step - if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) + if (!$error && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) { $action = 'confirm_approve'; // can make standard or first level approval also if permission is set } From 4c851884e54e82c3bdcf6dce87d357003153d077 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 25 Aug 2020 12:16:44 +0200 Subject: [PATCH 040/110] Address feedback --- htdocs/comm/action/index.php | 2 +- htdocs/user/class/user.class.php | 40 ++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e5ab1c02902..8327aedf9ce 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1062,7 +1062,7 @@ if (count($listofextcals)) $event->ref = $event->id; $userId = $userstatic->findUserIdByEmail($namecal); - if(!empty($userId)) + if (!empty($userId) && $userId > 0) { $event->userassigned[$userId] = $userId; $event->percentage = -1; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6d278e635fa..42d2f8705fb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3240,42 +3240,62 @@ class User extends CommonObject /** * Cache the SQL results of the function "findUserIdByEmail($email)" - * + * + * NOTE: findUserIdByEmailCache[...] === -1 means not found in database + * * @var array */ private $findUserIdByEmailCache; /** - * Find a user by the given e-mail or part of a e-mail and return its user id when found + * Find a user by the given e-mail and return it's user id when found * - * @param string $email The full e-mail or a part of a e-mail - * @return int|null The id of the user when found, otherwise null + * NOTE: + * Use AGENDA_DISABLE_EXACT_USER_EMAIL_COMPARE_FOR_EXTERNAL_CALENDAR + * to disable exact e-mail search + * + * @param string $email The full e-mail (or a part of a e-mail) + * @return int <0 = user was not found, >0 = The id of the user */ public function findUserIdByEmail($email) { - if($this->findUserIdByEmailCache[$email]) + if ($this->findUserIdByEmailCache[$email]) { return $this->findUserIdByEmailCache[$email]; } + $this->findUserIdByEmailCache[$email] = -1; + + global $conf; + $sql = 'SELECT rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'user'; - $sql .= ' WHERE email LIKE "%'.$email.'%"'; + + if (!empty($conf->global->AGENDA_DISABLE_EXACT_USER_EMAIL_COMPARE_FOR_EXTERNAL_CALENDAR)) + { + $sql .= ' WHERE email LIKE "%'.$email.'%"'; + } + else + { + $sql .= ' WHERE email = "'.$email.'"'; + } + + $sql .= ' LIMIT 1'; $resql = $this->db->query($sql); if (!$resql) { - return 0; + return -1; } $obj = $this->db->fetch_object($resql); if (!$obj) { - return 0; + return -1; } - $this->findUserIdByEmailCache[$email] = (int)$obj->rowid; + $this->findUserIdByEmailCache[$email] = (int) $obj->rowid; - return (int)$obj->rowid; + return $this->findUserIdByEmailCache[$email]; } } From 2cbb4081fe88a565c1a4d559e10229059c300f24 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 25 Aug 2020 10:20:48 +0000 Subject: [PATCH 041/110] Fixing style errors. --- htdocs/user/class/user.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 42d2f8705fb..30300ff7d91 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3240,9 +3240,9 @@ class User extends CommonObject /** * Cache the SQL results of the function "findUserIdByEmail($email)" - * + * * NOTE: findUserIdByEmailCache[...] === -1 means not found in database - * + * * @var array */ private $findUserIdByEmailCache; @@ -3270,13 +3270,12 @@ class User extends CommonObject $sql = 'SELECT rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'user'; - + if (!empty($conf->global->AGENDA_DISABLE_EXACT_USER_EMAIL_COMPARE_FOR_EXTERNAL_CALENDAR)) { $sql .= ' WHERE email LIKE "%'.$email.'%"'; } - else - { + else { $sql .= ' WHERE email = "'.$email.'"'; } From 458bc66327bb0369b6dfbeb8d7e87ecc0e54c735 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Tue, 25 Aug 2020 17:25:34 +0200 Subject: [PATCH 042/110] Update list.php --- htdocs/commande/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 300736dc69b..cb63f14ab63 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -210,6 +210,7 @@ if (empty($reshook)) $search_total_ht = ''; $search_total_vat = ''; $search_total_ttc = ''; + $search_warehouse = ''; $search_multicurrency_code = ''; $search_multicurrency_tx = ''; $search_multicurrency_montant_ht = ''; From 0adf267f668e322adda4abf6948c3e67e2ccc817 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 25 Aug 2020 21:31:04 +0200 Subject: [PATCH 043/110] Fix Accountancy Listbyaccount Error missing formfile->getDocumentsLink --- htdocs/accountancy/bookkeeping/listbyaccount.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 25f664d955e..5a1056f8d50 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -2,8 +2,8 @@ /* Copyright (C) 2016 Neil Orley * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2018 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -293,6 +294,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri */ $formaccounting = new FormAccounting($db); +$formfile = new FormFile($db); $formother = new FormOther($db); $form = new Form($db); @@ -551,7 +553,7 @@ while ($i < min($num, $limit)) // Show the break account print ""; - print ''; + print ''; if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); else print ''.$langs->trans("Unknown").''; print ''; From 9268955256825d9059727b0f22409dcfb71828b7 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 26 Aug 2020 09:40:20 +0200 Subject: [PATCH 044/110] FIX set sales representatives on create company card --- htdocs/societe/card.php | 2 +- htdocs/societe/class/societe.class.php | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d2f27419e76..401f7b2175b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -539,7 +539,7 @@ if (empty($reshook)) // Links with users $salesreps = GETPOST('commercial', 'array'); - $result = $object->setSalesRep($salesreps); + $result = $object->setSalesRep($salesreps, true); if ($result < 0) { $error++; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 918674ba23a..30511855e91 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4133,9 +4133,10 @@ class Societe extends CommonObject * Sets sales representatives of the thirdparty * * @param int[]|int $salesrep User ID or array of user IDs + * @param bool $onlyAdd Only add (no delete before) * @return int <0 if KO, >0 if OK */ - public function setSalesRep($salesrep) + public function setSalesRep($salesrep, $onlyAdd = false) { global $user; @@ -4144,16 +4145,18 @@ class Societe extends CommonObject $salesrep = array($salesrep); } - // Get current users - $existing = $this->getSalesRepresentatives($user, 1); - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $salesrep); - $to_add = array_diff($salesrep, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $salesrep; + $to_del = array(); // Nothing to delete + $to_add = $salesrep; + if ($onlyAdd === false) { + // Get current users + $existing = $this->getSalesRepresentatives($user, 1); + + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $salesrep); + $to_add = array_diff($salesrep, $existing); + } } $error = 0; From 9b3f13458fc1d95e92d01142dbd0b4abe76e9bbe Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Wed, 26 Aug 2020 16:02:31 +0200 Subject: [PATCH 045/110] FIX: missing entity check --- htdocs/compta/prelevement/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 936fbebcf6e..9b9e8e08ce5 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -180,6 +180,7 @@ print '
'; $limit=5; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql.= " WHERE entity IN (" . getEntity('prelevement') . ")"; $sql.= " ORDER BY datec DESC"; $sql.= $db->plimit($limit); From 243f59b9e90820e23cebf7a3f21cfcad2d102e15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Aug 2020 17:09:45 +0200 Subject: [PATCH 046/110] FIX Missing transaction on PO actions --- htdocs/fourn/commande/card.php | 79 +++++++++++++++++++++++++++++----- htdocs/fourn/facture/card.php | 4 +- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9341bc24c4b..3fb7ae18cbc 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -653,7 +653,9 @@ if (empty($reshook)) */ if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && !GETPOST('cancel', 'alpha')) { - $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); + $db->begin(); + + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); if ($lineid) { @@ -783,9 +785,13 @@ if (empty($reshook)) $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } + + $db->commit(); } else { + $db->rollback(); + dol_print_error($db, $object->error); exit; } @@ -794,6 +800,8 @@ if (empty($reshook)) // Remove a product line if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) { + $db->begin(); + $result = $object->deleteline($lineid); if ($result > 0) { @@ -812,16 +820,23 @@ if (empty($reshook)) $ret = $object->fetch($object->id); // Reload to get new records $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); - /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ + // Reset action to avoid asking again confirmation on failure $action = ''; } + + if (!$error) { + $db->commit(); + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } else { + $db->rollback(); + } } // Validate @@ -830,6 +845,8 @@ if (empty($reshook)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) ) { + $db->begin(); + $object->date_commande = dol_now(); $result = $object->valid($user); if ($result >= 0) @@ -849,7 +866,10 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + if ($result < 0) { + $error++; + dol_print_error($db, $result); + } } } else @@ -863,10 +883,18 @@ if (empty($reshook)) { $action = 'confirm_approve'; // can make standard or first level approval also if permission is set } + + if (! $error) { + $db->commit(); + } else { + $db->rollback(); + } } if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { + $db->begin(); + $idwarehouse = GETPOST('idwarehouse', 'int'); $qualified_for_stock_change = 0; @@ -906,14 +934,22 @@ if (empty($reshook)) } $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } + + if (!$error) { + $db->commit(); + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + exit; + } else { + $db->rollback(); + } } if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) @@ -942,6 +978,8 @@ if (empty($reshook)) if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { + $db->begin(); + $result = $object->commande($user, GETPOST("datecommande"), GETPOST("methode", 'int'), GETPOST('comment', 'alphanohtml')); if ($result > 0) { @@ -958,13 +996,21 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } $action = ''; - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } + + if (!$error) { + $db->commit(); + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + exit; + } else { + $db->rollback(); + } } @@ -1014,6 +1060,8 @@ if (empty($reshook)) // Set status of reception (complete, partial, ...) if ($action == 'livraison' && $user->rights->fournisseur->commande->receptionner) { + $db->begin(); + if (GETPOST("type") != '') { $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); @@ -1027,17 +1075,26 @@ if (empty($reshook)) } elseif ($result == -3) { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } else { + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Delivery")), null, 'errors'); } + + if (! $error) { + $db->commit(); + } else { + $db->rollback(); + } } if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) @@ -1971,7 +2028,7 @@ elseif (!empty($object->id)) $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= ''; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 10cf8ee1b6f..6e502b88ac0 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1827,7 +1827,9 @@ if ($action == 'create') print ''; // Ref supplier - print ''.$langs->trans('RefSupplier').''; + print ''.$langs->trans('RefSupplier').'id > 0) print ' autofocus'; + print '>'; print ''; print ''.$langs->trans('Type').''; From 236d2862afa725f91bd752ed3811e7d67e508cdd Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 26 Aug 2020 21:56:50 +0200 Subject: [PATCH 047/110] Fix install table --- ..._attribute_combination_price_level.key.sql | 21 +++++++++++++++++++ ...duct_attribute_combination_price_level.sql | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.key.sql diff --git a/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.key.sql b/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.key.sql new file mode 100644 index 00000000000..4c191193754 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.key.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2020 John BOTELLA +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + + +ALTER TABLE llx_product_attribute_combination_price_level ADD UNIQUE( fk_product_attribute_combination, fk_price_level); + diff --git a/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.sql b/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.sql index ae068b71ed0..70086f82068 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute_combination_price_level.sql @@ -25,4 +25,3 @@ CREATE TABLE llx_product_attribute_combination_price_level variation_price_percentage INTEGER NULL )ENGINE=innodb; -ALTER TABLE llx_product_attribute_combination_price_level ADD UNIQUE( fk_product_attribute_combination, fk_price_level); From aa8ec1cd9c5c037e97e937e315a69af33bd2fc0d Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 27 Aug 2020 09:32:00 +0200 Subject: [PATCH 048/110] Fix empty ref in contract list tool tip --- htdocs/contrat/services_list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 38aae136b39..7279ab98781 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -199,7 +199,7 @@ $now = dol_now(); $form = new Form($db); -$sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,"; +$sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,"; $sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; $sql .= " cd.rowid, cd.description, cd.statut,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,"; @@ -564,6 +564,8 @@ while ($i < min($num, $limit)) $contractstatic->id = $obj->cid; $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid; + $contractstatic->ref_customer = $obj->ref_customer; + $contractstatic->ref_supplier = $obj->ref_supplier; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; From c2590433fe3cbddcdb1dca125ab34c8c9b933cba Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 27 Aug 2020 10:11:18 +0200 Subject: [PATCH 049/110] Show ref in contract form on interventions --- htdocs/core/class/html.formcontract.class.php | 19 ++++++++++++++++--- htdocs/fichinter/card.php | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 6dce90d372b..860bcc2ca67 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -58,9 +58,10 @@ class FormContract * @param string $htmlname Nom de la zone html * @param int $maxlength Maximum length of label * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) { // phpcs:enable global $db, $user, $conf, $langs; @@ -70,6 +71,10 @@ class FormContract // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; + if($showRef) + { + $sql .= ', c.ref_customer, c.ref_supplier'; + } $sql .= ' FROM '.MAIN_DB_PREFIX.'contrat as c'; $sql .= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; @@ -105,6 +110,13 @@ class FormContract // Do nothing } else { $labeltoshow = dol_trunc($obj->ref, 18); + + if($showRef) + { + if($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer; + if($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier; + } + //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) @@ -166,9 +178,10 @@ class FormContract * @param string $htmlname Nom de la zone html * @param int $maxlength Maximum length of label * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) { global $langs; @@ -176,7 +189,7 @@ class FormContract print '
'; print ''; print ''; - $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty); + $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); print ''; print '
'; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a4fa1fff132..5925bb079a2 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -906,7 +906,7 @@ if ($action == 'create') { $langs->load("contracts"); print ''.$langs->trans("Contract").''; - $numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1); + $numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1, 1); if ($numcontrat == 0) { print '   '; @@ -1238,7 +1238,7 @@ if ($action == 'create') if ($action == 'contrat') { $formcontract = new Formcontract($db); - $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1); + $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1); } else { if ($object->fk_contrat) { From 8ff24282d9f3e02884a06c59db05b1bfb4e3e63a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 27 Aug 2020 08:16:32 +0000 Subject: [PATCH 050/110] Fixing style errors. --- htdocs/core/class/html.formcontract.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 860bcc2ca67..c0ea71ee6f8 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -71,7 +71,7 @@ class FormContract // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; - if($showRef) + if ($showRef) { $sql .= ', c.ref_customer, c.ref_supplier'; } @@ -111,10 +111,10 @@ class FormContract } else { $labeltoshow = dol_trunc($obj->ref, 18); - if($showRef) + if ($showRef) { - if($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer; - if($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier; + if ($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer; + if ($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier; } //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; From 2abdfe08d7ddabeb309916862a64faf83813c00b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 18:27:05 +0200 Subject: [PATCH 051/110] FIX Email collector decode subject FIX Cloning email collector clone also rules and operations --- htdocs/admin/emailcollector_card.php | 8 +- .../class/emailcollector.class.php | 102 +++++++++++++++--- .../class/emailcollectorfilter.class.php | 2 +- 3 files changed, 94 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 2c1e0948e01..fb08286e0a3 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -660,12 +660,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { + // Edit print ''; // Clone print ''; - print ''; + // Collect now + if (count($object->actions) > 0) { + print ''; + } else { + print ''; + } print ''; } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 91b1b697398..8c8e0daeb26 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -246,7 +246,36 @@ class EmailCollector extends CommonObject */ public function create(User $user, $notrigger = false) { - return $this->createCommon($user, $notrigger); + $id = $this->createCommon($user, $notrigger); + + if (is_array($this->filters) && count($this->filters)) { + $emailcollectorfilter = new EmailCollectorFilter($this->db); + + foreach($this->filters as $filter) { + $emailcollectorfilter->type = $filter['type']; + $emailcollectorfilter->rulevalue = $filter['rulevalue']; + $emailcollectorfilter->fk_emailcollector = $this->id; + $emailcollectorfilter->status = $filter['status']; + + $emailcollectorfilter->create($user); + } + } + + if (is_array($this->filters) && count($this->filters)) { + $emailcollectoroperation = new EmailCollectorAction($this->db); + + foreach($this->actions as $operation) { + $emailcollectoroperation->type = $operation['type']; + $emailcollectoroperation->actionparam = $operation['actionparam']; + $emailcollectoroperation->fk_emailcollector = $this->id; + $emailcollectoroperation->status = $operation['status']; + $emailcollectoroperation->position = $operation['position']; + + $emailcollectoroperation->create($user); + } + } + + return $id; } /** @@ -269,6 +298,10 @@ class EmailCollector extends CommonObject // Load source object $object->fetchCommon($fromid); + + $object->fetchFilters(); // Rules + $object->fetchActions(); // Operations + // Reset some properties unset($object->id); unset($object->fk_user_creat); @@ -295,7 +328,7 @@ class EmailCollector extends CommonObject // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); + $result = $object->create($user); if ($result < 0) { $error++; $this->error = $object->error; @@ -605,6 +638,7 @@ class EmailCollector extends CommonObject * Fetch filters * * @return int <0 if KO, >0 if OK + * @see fetchActions() */ public function fetchFilters() { @@ -636,6 +670,7 @@ class EmailCollector extends CommonObject * Fetch actions * * @return int <0 if KO, >0 if OK + * @see fetchFilters() */ public function fetchActions() { @@ -1085,7 +1120,7 @@ class EmailCollector extends CommonObject dol_syslog("Start of loop on email", LOG_INFO, 1); - $i = 0; + $iforemailloop = 0; foreach ($arrayofemail as $imapemail) { if ($nbemailprocessed > 1000) @@ -1093,7 +1128,7 @@ class EmailCollector extends CommonObject break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect } - $i++; + $iforemailloop++; $header = imap_fetchheader($connection, $imapemail, 0); $header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines @@ -1107,9 +1142,12 @@ class EmailCollector extends CommonObject if (!empty($headers['in-reply-to']) && empty($headers['In-Reply-To'])) { $headers['In-Reply-To'] = $headers['in-reply-to']; } if (!empty($headers['references']) && empty($headers['References'])) { $headers['References'] = $headers['references']; } if (!empty($headers['message-id']) && empty($headers['Message-ID'])) { $headers['Message-ID'] = $headers['message-id']; } + $headers['Subject'] = $this->decodeSMTPSubject($headers['Subject']); - dol_syslog("** Process email ".$i." References: ".$headers['References']); + + dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']); + //print "Process mail ".$iforemailloop." Subject: ".dol_escape_htmltag($headers['Subject'])." References: ".dol_escape_htmltag($headers['References'])." In-Reply-To: ".dol_escape_htmltag($headers['In-Reply-To'])."
\n"; // If there is a filter on trackid if ($searchfilterdoltrackid > 0) @@ -1135,6 +1173,17 @@ class EmailCollector extends CommonObject $nbemailprocessed++; continue; // Exclude email } + // Note: we can have + // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) + $isanswer = 0; + if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) $isanswer = 1; + //if ($headers['In-Reply-To'] != $headers['Message-ID'] && empty($headers['References'])) $isanswer = 1; // If in-reply-to differs of message-id, this is a reply + //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; + + if (!$isanswer) { + $nbemailprocessed++; + continue; // Exclude email + } } if ($searchfilterisnotanswer > 0) { if (!empty($headers['In-Reply-To'])) @@ -1142,7 +1191,7 @@ class EmailCollector extends CommonObject // Note: we can have // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) $isanswer = 0; - if (preg_match('/Re:\s+/i', $headers['Subject'])) $isanswer = 1; + if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) $isanswer = 1; //if ($headers['In-Reply-To'] != $headers['Message-ID'] && empty($headers['References'])) $isanswer = 1; // If in-reply-to differs of message-id, this is a reply //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; if ($isanswer) { @@ -1152,6 +1201,7 @@ class EmailCollector extends CommonObject } } + //print "Process mail ".$iforemailloop." Subject: ".dol_escape_htmltag($headers['Subject'])." selected
\n"; $thirdpartystatic = new Societe($this->db); $contactstatic = new Contact($this->db); @@ -1277,10 +1327,12 @@ class EmailCollector extends CommonObject $reg = array(); if (!empty($headers['References'])) { - $arrayofreferences = preg_split('/\s+/', $headers['References']); + $arrayofreferences = preg_split('/(,|\s+)/', $headers['References']); + //var_dump($headers['References']); + //var_dump($arrayofreferences); foreach ($arrayofreferences as $reference) { - //print "Process reference ".dol_escape_htmltag($reference)."
\n"; + //print "Process mail ".$iforemailloop." email_msgid ".$msgid.", date ".dol_print_date($date, 'dayhour').", subject ".$subject.", reference ".dol_escape_htmltag($reference)."
\n"; if (preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote($host, '/').'/', $reference, $reg)) { // This is a Dolibarr reference $trackid = $reg[1].$reg[2]; @@ -1459,6 +1511,7 @@ class EmailCollector extends CommonObject // Make Operation dol_syslog("Execute action ".$operation['type']." actionparam=".$operation['actionparam'].' thirdpartystatic->id='.$thirdpartystatic->id.' contactstatic->id='.$contactstatic->id.' projectstatic->id='.$projectstatic->id); + dol_syslog("Execute action fk_element_id=".$fk_element_id." fk_element_type=".$fk_element_type); $actioncode = 'EMAIL_IN'; // If we scan the Sent box, we use the code for out email @@ -1646,7 +1699,11 @@ class EmailCollector extends CommonObject if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { $actioncomm->fk_element = $fk_element_id; + $actioncomm->elementid = $fk_element_id; $actioncomm->elementtype = $fk_element_type; + if (is_object($objectemail) && $objectemail->module) { + $actioncomm->elementtype .= '@'.$objectemail->module; + } } //$actioncomm->extraparams = $extraparams; @@ -1654,6 +1711,13 @@ class EmailCollector extends CommonObject // Overwrite values with values extracted from source email $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); + /*var_dump($fk_element_id); + var_dump($fk_element_type); + var_dump($alreadycreated); + var_dump($operation['type']); + var_dump($actioncomm); + exit;*/ + if ($errorforthisaction) { $errorforactions++; @@ -2276,10 +2340,14 @@ class EmailCollector extends CommonObject } /** - * Decode a subject string + * Decode a subject string according to RFC2047 + * Example: '=?Windows-1252?Q?RE=A0:_ABC?=' => 'RE : ABC...' + * Example: '=?UTF-8?Q?A=C3=A9B?=' => 'AéB' + * Example: '=?UTF-8?B?2KLYstmF2KfbjNi0?=' => + * Example: '=?utf-8?B?UkU6IG1vZHVsZSBkb2xpYmFyciBnZXN0aW9ubmFpcmUgZGUgZmljaGllcnMg?= =?utf-8?B?UsOpZsOpcmVuY2UgZGUgbGEgY29tbWFuZGUgVFVHRURJSklSIOKAkyBwYXNz?= =?utf-8?B?w6llIGxlIDIyLzA0LzIwMjA=?=' * * @param string $subject Subject - * @return string Decoded subject + * @return string Decoded subject (in UTF-8) */ protected function decodeSMTPSubject($subject) { @@ -2287,20 +2355,22 @@ class EmailCollector extends CommonObject // Can use also imap_mime_header_decode($str) // Can use also mb_decode_mimeheader($str) // Can use also iconv_mime_decode($str, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8') - if (function_exists('iconv_mime_decode')) { - $subject = iconv_mime_decode($subject, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); - } elseif (function_exists('imap_mime_header_decode')) { + if (function_exists('imap_mime_header_decode') && function_exists('iconv_mime_decode')) { $elements = imap_mime_header_decode($subject); + //var_dump($elements); $newstring = ''; if (!empty($elements)) { $num = count($elements); for ($i = 0; $i < $num; $i++) { - $newstring .= ($newstring ? ' ' : '').$elements[$i]->text; + $stringinutf8 = (in_array(strtoupper($elements[$i]->charset), array('default', 'UTF-8')) ? $elements[$i]->text : iconv_mime_decode($elements[$i]->text, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, $elements[$i]->charset)); + $newstring .= $stringinutf8; } $subject = $newstring; } - } elseif (function_exists('mb_decode_mimeheader')) { - $subject = mb_decode_mimeheader($subject); + } elseif (!function_exists('mb_decode_mimeheader')) { + $subject = mb_decode_mimeheader($subject); + } elseif (function_exists('iconv_mime_decode')) { + $subject = iconv_mime_decode($subject, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); } return $subject; diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 5982b5ffd20..40c8a91d235 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -169,7 +169,7 @@ class EmailCollectorFilter extends CommonObject { $langs->load("errors"); $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SearchString")); - return -1; + return -2; } return $this->createCommon($user, $notrigger); From 0309510ab88c286bdd6ec253341127241c025327 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 18:50:08 +0200 Subject: [PATCH 052/110] Fix avoid duplicate event recorded from email collector --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 19 +++++++++++-------- .../class/emailcollector.class.php | 9 ++++----- htdocs/projet/class/project.class.php | 5 ++++- htdocs/theme/eldy/global.inc.php | 4 +++- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index eb723013f81..6d9bb13e2c1 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1782,7 +1782,7 @@ if ($id > 0) } // Description - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)); print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1e860217d03..2d371f80be5 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -666,12 +666,13 @@ class ActionComm extends CommonObject /** * Load object from database * - * @param int $id Id of action to get - * @param string $ref Ref of action to get - * @param string $ref_ext Ref ext to get - * @return int <0 if KO, >0 if OK + * @param int $id Id of action to get + * @param string $ref Ref of action to get + * @param string $ref_ext Ref ext to get + * @param string $email_msgid Email msgid + * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '', $ref_ext = '') + public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '') { global $langs; @@ -692,6 +693,7 @@ class ActionComm extends CommonObject $sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_element as elementid, a.elementtype,"; $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; + $sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,"; $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; $sql .= " s.nom as socname,"; $sql .= " u.firstname, u.lastname as lastname"; @@ -700,9 +702,10 @@ class ActionComm extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; $sql .= " WHERE "; - if ($ref) $sql .= " a.id=".$ref; // No field ref, we use id - elseif ($ref_ext) $sql .= " a.ref_ext='".$this->db->escape($ref_ext)."'"; - else $sql .= " a.id=".$id; + if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id + elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'"; + elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'"; + else $sql .= " a.id = ".((int) $id); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 8c8e0daeb26..a62b58c1c2b 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1643,10 +1643,10 @@ class EmailCollector extends CommonObject // Create event elseif ($operation['type'] == 'recordevent') { - $alreadycreated = 0; - // TODO Check if $msgid already in database for $conf->entity + $actioncomm = new ActionComm($this->db); - if (!$alreadycreated) + $alreadycreated = $actioncomm->fetch(0, '', '', $msgid); + if ($alreadycreated == 0) { if ($projectstatic->id > 0) { @@ -1672,7 +1672,6 @@ class EmailCollector extends CommonObject $descriptionfull = dol_concatdesc($descriptionfull, $header); // Insert record of emails sent - $actioncomm = new ActionComm($this->db); $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; @@ -1736,7 +1735,7 @@ class EmailCollector extends CommonObject { $projecttocreate = new Project($this->db); - $alreadycreated = $projecttocreate->fetch(0, '', $msgid); + $alreadycreated = $projecttocreate->fetch(0, '', '', $msgid); if ($alreadycreated == 0) { if ($thirdpartystatic->id > 0) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 9069899af47..2c5f0a1ddb8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -471,10 +471,11 @@ class Project extends CommonObject * * @param int $id Id of object to load * @param string $ref Ref of project + * @param string $ref_ext Ref ext of project * @param string $email_msgid Email msgid * @return int >0 if OK, 0 if not found, <0 if KO */ - public function fetch($id, $ref = '', $email_msgid = '') + public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '') { global $conf; @@ -491,6 +492,8 @@ class Project extends CommonObject $sql .= " WHERE entity IN (".getEntity('project').")"; if (! empty($ref)) { $sql .= " AND ref = '".$this->db->escape($ref)."'"; + } elseif (! empty($ref_ext)) { + $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; } else { $sql .= " AND email_msgid = '".$this->db->escape($email_msgid)."'"; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 01e2194e992..f0340291ee8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3321,7 +3321,9 @@ table.hidepaginationprevious .paginationprevious { table.hidepaginationnext .paginationnext { display: none; } - +.tabBar .arearef .pagination.paginationref { + max-width: calc(30%); +} /* Set the color for hover lines */ From 8b95aa63eba2d76d9d3387a69fa5b7a1b8c9897d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 18:59:36 +0200 Subject: [PATCH 053/110] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fbbdf81ff93..1daec4b0001 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1992,7 +1992,7 @@ ImportSetup=Setup of module Import InstanceUniqueID=Unique ID of the instance SmallerThan=Smaller than LargerThan=Larger than -IfTrackingIDFoundEventWillBeLinked=Note that If a tracking ID is found into incoming email, the event will be automatically linked to the related objects. +IfTrackingIDFoundEventWillBeLinked=Note that If a tracking ID of an object is found into incoming email, or if the email is an answer of an email aready collected and linked to an object, the event will be automatically linked to the known related object too. WithGMailYouCanCreateADedicatedPassword=With a GMail account, if you enabled the 2 steps validation, it is recommanded to create a dedicated second password for the application instead of using your own account passsword from https://myaccount.google.com/. EmailCollectorTargetDir=It may be a desired behaviour to move the email into another tag/directory when it was processed successfully. Just set name of directory here to use this feature (Do NOT use special characters in name). Note that you must also use a read/write login account. EmailCollectorLoadThirdPartyHelp=You can use this action to use the email content to find and load an existing thirdparty in your database. The found (or created) thirdparty will be used for following actions that need it. In the parameter field you can use for example 'EXTRACT:BODY:Name:\s([^\s]*)' if you want to extract the name of the thirdparty from a string 'Name: name to find' found into the body. From a80950dfa4afd7def42143fe1f0b946f3c9af45a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 19:41:32 +0200 Subject: [PATCH 054/110] Fix regression --- htdocs/emailcollector/class/emailcollector.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index a62b58c1c2b..c8af89ba97e 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1225,6 +1225,7 @@ class EmailCollector extends CommonObject dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject); $overview[0]->subject = $this->decodeSMTPSubject($overview[0]->subject); + $overview[0]->from = $this->decodeSMTPSubject($overview[0]->from); // Removed emojis @@ -1314,6 +1315,7 @@ class EmailCollector extends CommonObject } $fk_element_id = 0; $fk_element_type = ''; + $contactid = 0; $thirdpartyid = 0; $projectid = 0; $ticketid = 0; // Analyze TrackId in field References. For example: @@ -2356,12 +2358,11 @@ class EmailCollector extends CommonObject // Can use also iconv_mime_decode($str, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8') if (function_exists('imap_mime_header_decode') && function_exists('iconv_mime_decode')) { $elements = imap_mime_header_decode($subject); - //var_dump($elements); $newstring = ''; if (!empty($elements)) { $num = count($elements); for ($i = 0; $i < $num; $i++) { - $stringinutf8 = (in_array(strtoupper($elements[$i]->charset), array('default', 'UTF-8')) ? $elements[$i]->text : iconv_mime_decode($elements[$i]->text, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, $elements[$i]->charset)); + $stringinutf8 = (in_array(strtoupper($elements[$i]->charset), array('DEFAULT', 'UTF-8')) ? $elements[$i]->text : iconv_mime_decode($elements[$i]->text, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, $elements[$i]->charset)); $newstring .= $stringinutf8; } $subject = $newstring; From 6715eaee095f713a48910a9ef9c6ce3776a987e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 19:44:17 +0200 Subject: [PATCH 055/110] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index c0ea71ee6f8..d4ce1cbb0fe 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -70,11 +70,8 @@ class FormContract if (!empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; // Search all contacts - $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; - if ($showRef) - { - $sql .= ', c.ref_customer, c.ref_supplier'; - } + $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut,'; + $sql .= ' c.ref_customer, c.ref_supplier'; $sql .= ' FROM '.MAIN_DB_PREFIX.'contrat as c'; $sql .= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; From 741489fdc080e288d9c1833ddad788f6e6ab356e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 19:52:05 +0200 Subject: [PATCH 056/110] FIX #14564 --- htdocs/admin/stock.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 0df5deea2f2..090a72327d8 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -498,6 +498,12 @@ if ($virtualdiffersfromphysical) print '
'; } +print '
'; + + +print ''; +print ''; +print ''; /* @@ -648,9 +654,15 @@ foreach ($dirmodels as $reldir) print ''; +print '
'; + // Other +print '
'; +print ''; +print ''; + print load_fiche_titre($langs->trans("Other"), '', ''); print ''; From 3b4508b44fb3e6547d24779b284fab01dccfd67a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 19:59:46 +0200 Subject: [PATCH 057/110] Update paiement.class.php --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 4ec28bf2935..c7dd83ee253 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -292,7 +292,7 @@ class Paiement extends CommonObject $note = ($this->note_public ? $this->note_public : $this->note); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".$this->pos_change.")"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")"; $resql = $this->db->query($sql); if ($resql) From 7730569dff1e66e364a0166ac9711b27456f0596 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 21:00:01 +0200 Subject: [PATCH 058/110] Update card.php --- htdocs/comm/propal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4f2c0de238b..cf3dac232fc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1556,12 +1556,12 @@ if ($action == 'create') // Terms of payment print ''; // Mode of payment print ''; // Bank Account From f997d11761480f32bb0d6c6258622b63add3c7f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 21:02:01 +0200 Subject: [PATCH 059/110] Update card.php --- htdocs/comm/propal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index cf3dac232fc..cd4432707cd 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1556,12 +1556,12 @@ if ($action == 'create') // Terms of payment print ''; // Mode of payment print ''; // Bank Account From fe4acf4e4ed19399fb92f6d9a82e9b89b9e804ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 21:18:40 +0200 Subject: [PATCH 060/110] NEW Add focus when editing on product/stock/product.php Close #14548 --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5567813db79..c8a38dd0ea6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -199,12 +199,12 @@ class Form if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(numeric|amount)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) // if wysiwyg is enabled $typeofdata = 'ckeditor' { $tmp = explode(':', $typeofdata); @@ -217,7 +217,7 @@ class Form } $valuetoshow = ($editvalue ? $editvalue : $value); - $ret .= '
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements(empty($soc->cond_reglement_id) ? (GETPOST('cond_reglement_id', 'int') ? GETPOST('cond_reglement_id', 'int') : '' ) : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements(empty($soc->cond_reglement_id) ? (GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : '') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(empty($soc->mode_reglement_id) ? (GETPOST('mode_reglement_id', 'int') ? GETPOST('mode_reglement_id', 'int') : '' ) : $soc->mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements(empty($soc->mode_reglement_id) ? (GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : '') : $soc->mode_reglement_id, 'mode_reglement_id'); print '
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements(empty($soc->cond_reglement_id) ? (GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : '') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1); print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(empty($soc->mode_reglement_id) ? (GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : '') : $soc->mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id'); print '