From 6f97d163f95046d662dd98420499f30086abfcb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Dec 2019 22:41:34 +0100 Subject: [PATCH 1/4] Fix: the stripe_account is not filled --- htdocs/stripe/class/stripe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 931cfbfa83e..160bb28bef3 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -246,8 +246,8 @@ class Stripe extends CommonObject } // Create customer in Dolibarr - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_account (fk_soc, login, key_account, site, status, entity, date_creation, fk_user_creat)"; - $sql .= " VALUES (".$object->id.", '', '".$this->db->escape($customer->id)."', 'stripe', ".$status.", ".$conf->entity.", '".$this->db->idate(dol_now())."', ".$user->id.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)"; + $sql .= " VALUES (".$object->id.", '', '".$this->db->escape($customer->id)."', 'stripe', '".$this->db->escape($stripearrayofkeysbyenv[$status]['publishable_key'])."', ".$status.", ".$conf->entity.", '".$this->db->idate(dol_now())."', ".$user->id.")"; $resql = $this->db->query($sql); if (!$resql) { From 4333cf2040d6a1fd36968b20729d8a2733b965a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Dec 2019 12:53:10 +0100 Subject: [PATCH 2/4] Show the stripe accoutn of a cu_ and a card_ --- htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_societe_rib.sql | 3 ++- htdocs/societe/class/companypaymentmode.class.php | 1 + htdocs/societe/paymentmodes.php | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 3ee1d145b3c..7436d8d8c3d 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -34,5 +34,5 @@ -- For v12 - +ALTER TABLE llx_societe_rib ADD COLUMN stripe_account varchar(128); diff --git a/htdocs/install/mysql/tables/llx_societe_rib.sql b/htdocs/install/mysql/tables/llx_societe_rib.sql index 45084179908..7d00d9fb1dd 100644 --- a/htdocs/install/mysql/tables/llx_societe_rib.sql +++ b/htdocs/install/mysql/tables/llx_societe_rib.sql @@ -28,7 +28,7 @@ create table llx_societe_rib fk_soc integer NOT NULL, datec datetime, tms timestamp, - + -- For BAN bank varchar(255), -- bank name code_banque varchar(128), -- bank code @@ -66,6 +66,7 @@ create table llx_societe_rib --For Stripe stripe_card_ref varchar(128), -- 'card_...' + stripe_account varchar(128), -- 'pk_live_...' comment varchar(255), ipaddress varchar(68), diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index aa0c083f4f7..781a25ac8c0 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -110,6 +110,7 @@ class CompanyPaymentMode extends CommonObject 'preapproval_key' =>array('type'=>'varchar(255)', 'label'=>'Preapproval key', 'enabled'=>1, 'visible'=>-2, 'position'=>160), 'total_amount_of_all_payments' =>array('type'=>'double(24,8)', 'label'=>'Total amount of all payments', 'enabled'=>1, 'visible'=>-2, 'position'=>165), 'stripe_card_ref' =>array('type'=>'varchar(128)', 'label'=>'Stripe card ref', 'enabled'=>1, 'visible'=>-2, 'position'=>170), + 'stripe_account' =>array('type'=>'varchar(128)', 'label'=>'Stripe account', 'enabled'=>1, 'visible'=>-2, 'position'=>171), 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>175), 'starting_date' =>array('type'=>'date', 'label'=>'Starting date', 'enabled'=>1, 'visible'=>-2, 'position'=>180), 'ending_date' =>array('type'=>'date', 'label'=>'Ending date', 'enabled'=>1, 'visible'=>-2, 'position'=>185), diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 9bf2a40f069..52af815827f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -847,7 +847,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $permissiontowrite = $user->rights->societe->creer; // Stripe customer key 'cu_....' stored into llx_societe_account print ''; - print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid', 'Publishable key '.$site_account); + print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') @@ -859,7 +859,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; } - print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key '.$site_account, 'globe').''; } print ''; if (empty($stripecu)) @@ -913,7 +913,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $url = 'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc; } - print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key '.$site_account, 'globe').''; } print ''; if (empty($stripesupplieracc)) @@ -1065,7 +1065,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; } - print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key '.$companypaymentmodetemp->stripe_account, 'globe').''; } print ''; print ''; From ea4c236311527795128fea2552848b79bfb7b693 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Dec 2019 13:05:03 +0100 Subject: [PATCH 3/4] fix alignment --- htdocs/admin/defaultvalues.php | 4 ++-- htdocs/admin/translation.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 8ddd453b458..29043720dee 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -193,14 +193,14 @@ $enabledisablehtml .= $langs->trans("EnableDefaultValues").' '; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index c3b38ca7a45..5e98d7c5503 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -208,14 +208,14 @@ $enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' '; if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } From ece8390277b289d123800cdc9be0b3756e5696ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Dec 2019 13:23:18 +0100 Subject: [PATCH 4/4] Add tables to store translation of all objects (like llx_product_lang) --- htdocs/admin/ihm.php | 6 ++-- .../install/mysql/migration/11.0.0-12.0.0.sql | 19 ++++++++++++ .../mysql/tables/llx_object_lang.key.sql | 20 ++++++++++++ .../install/mysql/tables/llx_object_lang.sql | 31 +++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_object_lang.key.sql create mode 100644 htdocs/install/mysql/tables/llx_object_lang.sql diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index fa83d5d4839..fc34171a3e5 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -83,7 +83,7 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); + //dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"], 'chaine', 0, '', $conf->entity); @@ -241,13 +241,15 @@ print ''; // Default language print ''.$langs->trans("DefaultLanguage").''; print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 2); +print ''; print ''; print ' '; print ''; // Multilingual GUI print ''.$langs->trans("EnableMultilangInterface").''; -print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1); +//print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1); +print ajax_constantonoff('MAIN_MULTILANGS'); print ''; print ' '; print ''; diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 7436d8d8c3d..b0ecc2b9639 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -36,3 +36,22 @@ ALTER TABLE llx_societe_rib ADD COLUMN stripe_account varchar(128); + +create table llx_object_lang +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_object integer DEFAULT 0 NOT NULL, + type_object varchar(32) NOT NULL, -- 'thirdparty', 'contact', '...' + property varchar(32) NOT NULL, + lang varchar(5) DEFAULT 0 NOT NULL, + value text, + import_key varchar(14) DEFAULT NULL +)ENGINE=innodb; + + + +ALTER TABLE llx_object_lang ADD UNIQUE INDEX uk_object_lang (fk_object, type_object, property, lang); + + + + diff --git a/htdocs/install/mysql/tables/llx_object_lang.key.sql b/htdocs/install/mysql/tables/llx_object_lang.key.sql new file mode 100644 index 00000000000..31cda3c8bfa --- /dev/null +++ b/htdocs/install/mysql/tables/llx_object_lang.key.sql @@ -0,0 +1,20 @@ +-- ============================================================================ +-- Copyright (C) 2019 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_object_lang ADD UNIQUE INDEX uk_object_lang (fk_object, type_object, property, lang); diff --git a/htdocs/install/mysql/tables/llx_object_lang.sql b/htdocs/install/mysql/tables/llx_object_lang.sql new file mode 100644 index 00000000000..9bbc296d27c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_object_lang.sql @@ -0,0 +1,31 @@ +-- ============================================================================ +-- Copyright (C) 2019 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 . +-- +-- ============================================================================ + + +-- Table to store some translations of values of objects + +create table llx_object_lang +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_object integer DEFAULT 0 NOT NULL, + type_object varchar(32) NOT NULL, -- 'thirdparty', 'contact', '...' + property varchar(32) NOT NULL, + lang varchar(5) DEFAULT 0 NOT NULL, + value text, + import_key varchar(14) DEFAULT NULL +)ENGINE=innodb;