From ba98db934d879c4f6c0ea87ee691758a9053239b Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 21 Aug 2020 08:18:26 +0200 Subject: [PATCH 01/25] 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 02/25] 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 03/25] 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 04/25] 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 05/25] 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 ''; print $form->selectyesno("TAKEPOS_SHOW_CUSTOMER", $conf->global->TAKEPOS_SHOW_CUSTOMER, 1); print "\n"; + + // Print payment method + print ''; + print $langs->trans('PrintPaymentMethodOnReceipts'); + print ''; + print $form->selectyesno("TAKEPOS_PRINT_PAYMENT_METHOD", $conf->global->TAKEPOS_PRINT_PAYMENT_METHOD, 1); + 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) trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?> +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 $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code); + 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 + 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 + { + echo ''; + echo ''; + echo $langs->trans("Change"); + echo ''; + echo ''; + echo price($row->takepos_change, 1, '', 1, - 1, - 1, $conf->currency); + echo ''; + echo ''; + } + $i++; + } + } +} +?>

From e8c8cb53cb581ce28af96393bb4147a0f0c78bde Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 22 Aug 2020 18:45:54 +0200 Subject: [PATCH 06/25] 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 07/25] 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 a5ab711b27ca81df3328a8c6be3179a4b3eb863b Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 23 Aug 2020 22:22:05 +0200 Subject: [PATCH 08/25] 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 09/25] 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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 14/25] 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 15/25] 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 16/25] 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 0e9677fd3417f3f9ef8501814ca594a94b797711 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 24 Aug 2020 15:59:05 +0200 Subject: [PATCH 17/25] 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 18/25] 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 4c851884e54e82c3bdcf6dce87d357003153d077 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 25 Aug 2020 12:16:44 +0200 Subject: [PATCH 19/25] 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 20/25] 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 21/25] 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 aa8ec1cd9c5c037e97e937e315a69af33bd2fc0d Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 27 Aug 2020 09:32:00 +0200 Subject: [PATCH 22/25] 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 3b4508b44fb3e6547d24779b284fab01dccfd67a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 19:59:46 +0200 Subject: [PATCH 23/25] 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 24/25] 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 ''.$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 ''; // Mode of payment 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 ''; // 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 25/25] 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 ''.$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 ''; // Mode of payment 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 ''; // Bank Account