diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 450c294f19e..2999833e81e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -234,8 +234,8 @@ function societe_prepare_head(Societe $object) $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."website_account as n"; - $sql.= " WHERE fk_soc = ".$object->id; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_account as n"; + $sql.= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; $resql=$db->query($sql); if ($resql) { 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 7ca1d16d67e..21feb62b978 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 @@ -84,6 +84,9 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- For 8.0 +DROP TABLE llx_website_account; +DROP TABLE llx_website_account_extrafields; + ALTER TABLE llx_paiementfourn ADD COLUMN fk_user_modif integer AFTER fk_user_author; -- delete old permission no more used diff --git a/htdocs/install/mysql/tables/llx_societe_account.sql b/htdocs/install/mysql/tables/llx_societe_account.sql index 7a0f87cbe5d..4123a3b05e2 100644 --- a/htdocs/install/mysql/tables/llx_societe_account.sql +++ b/htdocs/install/mysql/tables/llx_societe_account.sql @@ -13,7 +13,8 @@ -- 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 +-- Table to store accounts of thirdparties on external websites (like on stripe field site = 'stripe') +-- or on local website (fk_website). CREATE TABLE llx_societe_account( -- BEGIN MODULEBUILDER FIELDS diff --git a/htdocs/install/mysql/tables/llx_website_account.key.sql b/htdocs/install/mysql/tables/llx_website_account.key.sql deleted file mode 100644 index 2114d3c0f85..00000000000 --- a/htdocs/install/mysql/tables/llx_website_account.key.sql +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright (C) 2016 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/. - - --- 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_import_key (import_key); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_status (status); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_soc (fk_soc); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_website (fk_website); --- 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_website_account ADD CONSTRAINT llx_website_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); - diff --git a/htdocs/install/mysql/tables/llx_website_account.sql b/htdocs/install/mysql/tables/llx_website_account.sql deleted file mode 100644 index 373ba53f484..00000000000 --- a/htdocs/install/mysql/tables/llx_website_account.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Copyright (C) 2016 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( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - login varchar(64) 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, - 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; \ No newline at end of file diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 6b2199925be..7340a319534 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -334,7 +334,7 @@ class SocieteAccount extends CommonObject $label.= '' . $langs->trans('Login') . ': ' . $this->ref; //$label.= '' . $langs->trans('WebSite') . ': ' . $this->ref; - $url = dol_buildpath('/societe/societeaccount_card.php',1).'?id='.$this->id; + $url = dol_buildpath('/website/websiteaccount_card.php',1).'?id='.$this->id; if ($option != 'nolink') { diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 3ce1477a9c3..3563283ba05 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -31,7 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/website/class/websiteaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -57,12 +57,12 @@ if (! $sortorder) $sortorder='ASC'; // Initialize technical objects $object=new Societe($db); -$objectwebsiteaccount=new WebsiteAccount($db); +$objectwebsiteaccount=new SocieteAccount($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount'); +$extralabels = $extrafields->fetch_name_optionals_label('thirdpartyaccount'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty @@ -252,9 +252,9 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."website_account as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."websiteaccount_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('websiteaccount').")"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe_account as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_account_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('societeaccount').")"; else $sql.=" WHERE 1 = 1"; $sql.=" AND fk_soc = ".$object->id; foreach($search as $key => $val) @@ -335,9 +335,9 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit); $topicmail="Information"; -$modelmail="websiteaccount"; -$objecttmp=new WebsiteAccount($db); -$trackid='websiteaccount'.$object->id; +$modelmail="societeaccount"; +$objecttmp=new SocieteAccount($db); +$trackid='thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 5a46425cb66..c3d18b889e7 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -44,7 +44,7 @@ class Website extends CommonObject */ public $table_element = 'website'; /** - * @var array Does websiteaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var array Does website support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 1; /** diff --git a/htdocs/website/lib/websiteaccount.lib.php b/htdocs/website/lib/websiteaccount.lib.php index 95ae071d971..0b63be45188 100644 --- a/htdocs/website/lib/websiteaccount.lib.php +++ b/htdocs/website/lib/websiteaccount.lib.php @@ -22,17 +22,15 @@ */ /** - * Prepare array of tabs for WebsiteAccount + * Prepare array of tabs for SocieteAccount * - * @param WebsiteAccount $object WebsiteAccount - * @return array Array of tabs + * @param SocieteAccount $object SocieteAccount + * @return array Array of tabs */ function websiteaccountPrepareHead($object) { global $db, $langs, $conf; - $langs->load("monmodule@monmodule"); - $h = 0; $head = array(); diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 850888320dd..9a1ad910672 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -16,9 +16,9 @@ */ /** - * \file htdocs/Website/websiteaccount_card.php + * \file htdocs/website/websiteaccount_card.php * \ingroup website - * \brief Page to create/edit/view websiteaccount + * \brief Page to create/edit/view thirdparty website account */ // Load Dolibarr environment @@ -38,7 +38,7 @@ if (! $res) die("Include of main fails"); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); -include_once(DOL_DOCUMENT_ROOT.'/website/class/websiteaccount.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'); include_once(DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php'); // Load translation files required by the page @@ -53,12 +53,12 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new WebsiteAccount($db); +$object=new SocieteAccount($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount'); +$extralabels = $extrafields->fetch_name_optionals_label('societeaccount'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Initialize array of search criterias