Add table to store thirparty account in external web sites

This commit is contained in:
Laurent Destailleur 2018-03-12 15:59:03 +01:00
parent f40e6e25c6
commit 7362b3f3d7
8 changed files with 84 additions and 64 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -1,20 +0,0 @@
-- ===================================================================
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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/>.
--
-- ===================================================================
ALTER TABLE llx_website_account_extrafields ADD INDEX idx_website_account_extrafields (fk_object);

View File

@ -1,23 +0,0 @@
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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;

View File

@ -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.

View File

@ -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 '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Prospect/Customer
print '<tr><td class="titlefield">'.$langs->trans('StripeCustomerRef').'</td><td>';
print $object->getStripeCustomerAccount();
print '</td></tr>';
print '</table>';
print '</div>';
print '</div>';
print '</div>';
}
if (! (empty($conf->stripe->enabled)))
{
@ -979,7 +997,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
// RUM
print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"><br>'.$langs->trans("RUMWillBeGenerated").'</td></tr>';
print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));

View File

@ -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);