diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 7c0d155c950..1d1261edf5f 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -228,3 +228,43 @@ CREATE TABLE llx_c_ticketsup_type ALTER TABLE llx_facturedet_rec ADD COLUMN date_start_fill integer DEFAULT 0; ALTER TABLE llx_facturedet_rec ADD COLUMN date_end_fill integer DEFAULT 0; + + + +CREATE TABLE llx_societe_account( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1, + login varchar(128) NOT NULL, + pass_encoding varchar(24) NOT NULL, + pass_crypted varchar(128), + pass_temp varchar(128), -- temporary password when asked for forget password + fk_soc integer, + site varchar(128), + fk_website integer, + note_private text, + date_last_login datetime, + date_previous_login datetime, + date_creation datetime NOT NULL, + tms timestamp NOT NULL, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_rowid (rowid); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_login (login); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_status (status); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_website (fk_website); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_soc (fk_soc); +-- END MODULEBUILDER INDEXES + +ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website_soc(entity, fk_soc, login, site, fk_website); + +ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); +ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); + diff --git a/htdocs/install/mysql/tables/llx_website_account.key.sql b/htdocs/install/mysql/tables/llx_societe_account.key.sql similarity index 59% rename from htdocs/install/mysql/tables/llx_website_account.key.sql rename to htdocs/install/mysql/tables/llx_societe_account.key.sql index 1302ec50d2c..ece860300c1 100644 --- a/htdocs/install/mysql/tables/llx_website_account.key.sql +++ b/htdocs/install/mysql/tables/llx_societe_account.key.sql @@ -15,14 +15,15 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_website_account ADD INDEX idx_website_account_rowid (rowid); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_login (login); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_status (status); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_website (fk_website); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_soc (fk_soc); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_rowid (rowid); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_login (login); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_status (status); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_website (fk_website); +ALTER TABLE llx_societe_account ADD INDEX idx_societe_account_fk_soc (fk_soc); -- END MODULEBUILDER INDEXES -ALTER TABLE llx_website_account ADD UNIQUE INDEX uk_website_account_login_website_soc(login, fk_website, fk_soc); +ALTER TABLE llx_societe_account ADD UNIQUE INDEX uk_societe_account_login_website_soc(entity, fk_soc, login, site, fk_website); -ALTER TABLE llx_website_account ADD CONSTRAINT llx_website_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); +ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); +ALTER TABLE llx_societe_account ADD CONSTRAINT llx_societe_account_fk_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); diff --git a/htdocs/install/mysql/tables/llx_website_account.sql b/htdocs/install/mysql/tables/llx_societe_account.sql similarity index 78% rename from htdocs/install/mysql/tables/llx_website_account.sql rename to htdocs/install/mysql/tables/llx_societe_account.sql index 373ba53f484..9938d47bfb5 100644 --- a/htdocs/install/mysql/tables/llx_website_account.sql +++ b/htdocs/install/mysql/tables/llx_societe_account.sql @@ -12,17 +12,20 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see http://www.gnu.org/licenses/. +-- +-- Table to store accounts of thirdparties on websites - -CREATE TABLE llx_website_account( +CREATE TABLE llx_societe_account( -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - login varchar(64) NOT NULL, + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer DEFAULT 1, + login varchar(128) NOT NULL, pass_encoding varchar(24) NOT NULL, pass_crypted varchar(128), pass_temp varchar(128), -- temporary password when asked for forget password fk_soc integer, - fk_website integer NOT NULL, + site varchar(128), -- name of external web site + fk_website integer, -- id of local web site note_private text, date_last_login datetime, date_previous_login datetime, diff --git a/htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql b/htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql deleted file mode 100644 index 9970f8bc680..00000000000 --- a/htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql +++ /dev/null @@ -1,20 +0,0 @@ --- =================================================================== --- Copyright (C) 2017 Laurent Destailleur --- --- 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_website_account_extrafields ADD INDEX idx_website_account_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_website_account_extrafields.sql b/htdocs/install/mysql/tables/llx_website_account_extrafields.sql deleted file mode 100644 index 7bec7e958d9..00000000000 --- a/htdocs/install/mysql/tables/llx_website_account_extrafields.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Copyright (C) 2017 Laurent Destailleur --- --- 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 http://www.gnu.org/licenses/. - -CREATE TABLE llx_website_account_extrafields -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - fk_object integer NOT NULL, - import_key varchar(14) -- import key -) ENGINE=innodb; - diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 8dd4e573e37..8c350b12d79 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -78,7 +78,7 @@ ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and w StatisticsByLineStatus=Statistics by status of lines RUM=UMR RUMLong=Unique Mandate Reference -RUMWillBeGenerated=UMR number will be generated once bank account information are saved +RUMWillBeGenerated=If empty, UMR number will be generated once bank account information are saved WithdrawMode=Direct debit mode (FRST or RECUR) WithdrawRequestAmount=Amount of Direct debit request: WithdrawRequestErrorNilAmount=Unable to create direct debit request for empty amount. diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index bf7f05ba50a..6327261bbcb 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -413,6 +413,24 @@ if ($socid && $action != 'edit' && $action != "create") dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + if (! (empty($conf->stripe->enabled))) + { + print '
'; + print '
'; + + print '
'; + print ''; + + // Prospect/Customer + print ''; + + print '
'.$langs->trans('StripeCustomerRef').''; + print $object->getStripeCustomerAccount(); + print '
'; + print '
'; + print '
'; + print ''; + } if (! (empty($conf->stripe->enabled))) { @@ -979,7 +997,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // RUM print ''.$langs->trans("RUM").''; - print '
'.$langs->trans("RUMWillBeGenerated").''; + print '
'.$langs->trans("RUMWillBeGenerated").'
'; print ''.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index a87d80c265e..801d0e17057 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -52,7 +52,7 @@ class Stripe extends CommonObject /** - * Return stripe account + * Return main company OAuth Connect stripe account * * @param string $mode 'StripeTest' or 'StripeLive' * @return int ??? @@ -92,17 +92,18 @@ class Stripe extends CommonObject /** * getStripeCustomerAccount * - * @param int $id ??? - * @return int ??? + * @param int $id Id of third party + * @return string Stripe customer ref 'cu_xxxxxxxxxxxxx' */ public function getStripeCustomerAccount($id) { global $conf; - $sql = "SELECT s.key_account as key_account, s.entity, e.fk_object"; - $sql .= " FROM " . MAIN_DB_PREFIX . "stripe_entity as s"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "entity_extrafields as e ON s.entity=e.fk_object"; - $sql .= " WHERE e.fk_soc=" . $id . " "; + $sql = "SELECT sa.key_account as key_account, sa.entity"; + $sql.= " FROM " . MAIN_DB_PREFIX . "llx_societe_accounts as sa"; + $sql.= " WHERE sa.fk_soc = " . $id; + $sql.= " AND sa.entity IN (".getEntity('societe').")"; + $sql.= " AND site = 'stripe'"; dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql);