Little debug of option WEBSITE_USE_WEBSITE_ACCOUNTS

This commit is contained in:
Laurent Destailleur 2018-07-05 02:31:49 +02:00
parent 9842978b85
commit 5883899bc7
10 changed files with 26 additions and 89 deletions

View File

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

View File

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

View File

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

View File

@ -1,29 +0,0 @@
-- Copyright (C) 2016 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/.
-- 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);

View File

@ -1,36 +0,0 @@
-- Copyright (C) 2016 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(
-- 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;

View File

@ -334,7 +334,7 @@ class SocieteAccount extends CommonObject
$label.= '<b>' . $langs->trans('Login') . ':</b> ' . $this->ref;
//$label.= '<b>' . $langs->trans('WebSite') . ':</b> ' . $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')
{

View File

@ -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 '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
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)

View File

@ -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;
/**

View File

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

View File

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