';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index d824492d22c..b5043bf06d1 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -340,6 +340,15 @@ abstract class CommonObject
// No constructor as it is an abstract class
+ /**
+ * Return if an object manage the multicompany field and how.
+ *
+ * @return int 0=No entity field managed, 1=Test with field entity, 2=Test with link to thirdparty (and sales representative)
+ */
+ function getIsmultientitymanaged()
+ {
+ return $this->ismultientitymanaged;
+ }
/**
* Check an object id/ref exists
@@ -1338,16 +1347,16 @@ abstract class CommonObject
$sql = "SELECT MAX(te.".$fieldid.")";
$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
$sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id;
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id;
if (! empty($filter))
{
if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility
$sql.=$filter;
}
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')';
//print $filter.' '.$sql." ";
@@ -1363,16 +1372,16 @@ abstract class CommonObject
$sql = "SELECT MIN(te.".$fieldid.")";
$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
$sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id;
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id;
if (! empty($filter))
{
if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility
$sql.=$filter;
}
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')';
// Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index f211a0b1670..e792a4c3f0a 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -43,11 +43,6 @@ class EmailSenderProfile extends CommonObject
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'c_email_senderprofile';
-
- /**
- * @var array Does this field is linked to a thirdparty ?
- */
- protected $isnolinkedbythird = 1;
/**
* @var array Does emailsenderprofile support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php
index de8b4d7e8bf..8df350ef150 100644
--- a/htdocs/core/filemanagerdol/connectors/php/config.php
+++ b/htdocs/core/filemanagerdol/connectors/php/config.php
@@ -48,7 +48,7 @@ $Config['Enabled'] = true ;
$extEntity=(empty($entity) ? 1 : $entity); // For multicompany with external access
$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website)?'':'_'.$website).'&entity='.$extEntity.'&file=' ;
-$Config['UserFilesAbsolutePathRelative'] = (empty($website) ? ((!empty($entity) ? '/' . $entity : '') . '/medias/') : ('/websites/'.$website));
+$Config['UserFilesAbsolutePathRelative'] = (empty($website) ? ((!empty($entity) ? '/' . $entity : '') . '/medias/') : ('/website/'.$website));
// Fill the following value it you prefer to specify the absolute path for the
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 806d5d7a640..e372229de54 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -68,9 +68,9 @@ function dolWebsiteOutput($content)
global $website;
// Replace relative link / with dolibarr URL: ...href="/"...
- $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
+ $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
// Replace relative link /xxx.php with dolibarr URL: ...href="....php"
- $content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
+ $content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
// Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart="
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
@@ -101,9 +101,9 @@ function dolWebsiteReplacementOfLinks($website, $content)
$content = preg_replace('/<\?php[^\?]+\?>\n*/ims', '...php...', $content);
// Replace relative link / with dolibarr URL
- $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
+ $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
// Replace relative link /xxx.php with dolibarr URL
- $content = preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
+ $content = preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php
index 65db787734a..46b1f955177 100644
--- a/htdocs/core/website.inc.php
+++ b/htdocs/core/website.inc.php
@@ -23,6 +23,6 @@
*/
-include_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
+include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
$website=new Website($db);
$website->fetch(0,$websitekey);
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index ba976c2ee48..8fe8a14430a 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -34,7 +34,6 @@ class Holiday extends CommonObject
{
public $element='holiday';
public $table_element='holiday';
- protected $isnolinkedbythird = 1; // No field fk_soc
protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto = 'holiday';
diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
index e21bebac13f..800b1b1c06c 100644
--- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
+++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
@@ -168,6 +168,42 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN extraparams varchar(255);
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_lim_reglement datetime;
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user integer NULL;
+
+CREATE TABLE llx_websiteaccount(
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ login varchar(64) NOT NULL,
+ label varchar(255),
+ note_public text,
+ note_private text,
+ 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,
+ fk_soc integer
+) ENGINE=innodb;
+
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_key);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_status (status);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_soc (fk_soc);
+
+create table llx_websiteaccount_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL,
+ import_key varchar(14) -- import key
+) ENGINE=innodb;
+
+
+
+
+
+
+
CREATE TABLE IF NOT EXISTS llx_expensereport_ik (
rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime DEFAULT NULL,
@@ -396,3 +432,7 @@ create table llx_c_email_senderprofile
)ENGINE=innodb;
ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile(entity, label, email);
+
+
+-- May have error due to duplicate keys
+ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity);
diff --git a/htdocs/install/mysql/tables/llx_resource.key.sql b/htdocs/install/mysql/tables/llx_resource.key.sql
index 62eb21056c4..4912b02b1f9 100644
--- a/htdocs/install/mysql/tables/llx_resource.key.sql
+++ b/htdocs/install/mysql/tables/llx_resource.key.sql
@@ -15,4 +15,6 @@
-- along with this program. If not, see .
+ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity);
+
ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_websiteaccount.key.sql b/htdocs/install/mysql/tables/llx_websiteaccount.key.sql
new file mode 100644
index 00000000000..1ebab80b361
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_websiteaccount.key.sql
@@ -0,0 +1,26 @@
+-- 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_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_key);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_status (status);
+ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_soc (fk_soc);
+-- END MODULEBUILDER INDEXES
+
+--ALTER TABLE llx_websiteaccount ADD CONSTRAINT llx_websiteaccount_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid);
+
diff --git a/htdocs/install/mysql/tables/llx_websiteaccount.sql b/htdocs/install/mysql/tables/llx_websiteaccount.sql
new file mode 100644
index 00000000000..7fb846cd2f3
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_websiteaccount.sql
@@ -0,0 +1,32 @@
+-- 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_websiteaccount(
+ -- BEGIN MODULEBUILDER FIELDS
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ login varchar(64) NOT NULL,
+ label varchar(255),
+ note_public text,
+ note_private text,
+ 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,
+ fk_soc integer
+ -- END MODULEBUILDER FIELDS
+) ENGINE=innodb;
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_websiteaccount_extrafields.sql b/htdocs/install/mysql/tables/llx_websiteaccount_extrafields.sql
new file mode 100644
index 00000000000..fd4d4e3653f
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_websiteaccount_extrafields.sql
@@ -0,0 +1,23 @@
+-- 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_websiteaccount_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/website.lang b/htdocs/langs/en_US/website.lang
index 847a2cb4647..043fcb52472 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -51,4 +51,5 @@ OrEnterPageInfoManually=Or create empty page from scratch...
FetchAndCreate=Fetch and Create
ExportSite=Export site
IDOfPage=Id of page
-WebsiteAccounts=Web sites accounts
\ No newline at end of file
+WebsiteAccounts=Web site accounts
+AddWebsiteAccount=Create web site account
\ No newline at end of file
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index a6f4e8bc0f1..d128b9df5b9 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1598,7 +1598,7 @@ elseif (! empty($module))
$type=gettype($tmpobjet->$propname);
$default=$propdefault[$propname];
// Discard generic properties
- if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue;
+ if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
// Keep or not lines
if (in_array($propname, array('fk_element', 'lines'))) continue;
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 6abb2f1b9a5..29de762c486 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -44,14 +44,10 @@ class MyObject extends CommonObject
*/
public $table_element = 'myobject';
- /**
- * @var array Does this field is linked to a thirdparty ?
- */
- protected $isnolinkedbythird = 1;
/**
* @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
- protected $ismultientitymanaged = 1;
+ protected $ismultientitymanaged = 0;
/**
* @var string String with name of icon for myobject
*/
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index ed5d82c5301..6900a947a06 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -213,7 +213,8 @@ $sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql);
$sql.= " FROM ".MAIN_DB_PREFIX."myobject as t";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)";
-$sql.= " WHERE t.entity IN (".getEntity('myobject').")";
+if ($object->getIsmultientitymanaged() == 1) $sql.= " WHERE t.entity IN (".getEntity('myobject').")";
+else $sql.=" WHERE 1 = 1";
foreach($search as $key => $val)
{
$mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0);
@@ -265,7 +266,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql.= $db->plimit($limit+1, $offset);
-dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql);
if (! $resql)
{
@@ -351,9 +351,9 @@ if ($sall)
}
$moreforfilter = '';
-$moreforfilter.='
';
}
}
diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php
index 6dc093f6142..10c7c2f9f85 100644
--- a/htdocs/resource/class/dolresource.class.php
+++ b/htdocs/resource/class/dolresource.class.php
@@ -169,10 +169,11 @@ class Dolresource extends CommonObject
/**
* Load object in memory from database
*
- * @param int $id id object
- * @return int <0 if KO, >0 if OK
+ * @param int $id Id of object
+ * @param string $ref Ref of object
+ * @return int <0 if KO, >0 if OK
*/
- function fetch($id)
+ function fetch($id, $ref='')
{
global $langs;
$sql = "SELECT";
@@ -187,7 +188,8 @@ class Dolresource extends CommonObject
$sql.= " ty.label as type_label";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
- $sql.= " WHERE t.rowid = ".$this->db->escape($id);
+ if ($id) $sql.= " WHERE t.rowid = ".$this->db->escape($id);
+ else $sql.= " WHERE t.ref = '".$this->db->escape($ref)."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
@@ -751,75 +753,6 @@ class Dolresource extends CommonObject
return 0;
}
- /**
- * Load properties id_previous and id_next
- *
- * @param string $filter Optional filter
- * @param int $fieldid Name of field to use for the select MAX and MIN
- * @param int $nodbprefix Do not include DB prefix to forge table name
- * @return int <0 if KO, >0 if OK
- */
- function load_previous_next_ref($filter, $fieldid, $nodbprefix =0)
- {
- global $conf, $user;
-
- if (! $this->table_element)
- {
- dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
- return -1;
- }
-
- // this->ismultientitymanaged contains
- // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- $alias = 's';
-
-
- $sql = "SELECT MAX(te.".$fieldid.")";
- $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te";
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
- $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->id)."'";
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id;
- if (! empty($filter)) $sql.=" AND ".$filter;
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')';
-
- //print $sql." ";
- $result = $this->db->query($sql);
- if (! $result)
- {
- $this->error=$this->db->error();
- return -1;
- }
- $row = $this->db->fetch_row($result);
- $this->ref_previous = $row[0];
-
-
- $sql = "SELECT MIN(te.".$fieldid.")";
- $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te";
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
- $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->id)."'";
- if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id;
- if (! empty($filter)) $sql.=" AND ".$filter;
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')';
- // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null
-
- //print $sql." ";
- $result = $this->db->query($sql);
- if (! $result)
- {
- $this->error=$this->db->error();
- return -2;
- }
- $row = $this->db->fetch_row($result);
- $this->ref_next = $row[0];
-
- return 1;
- }
-
-
/**
* Update element resource into database
*
diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php
index 007ecd8025d..543e69b83ef 100644
--- a/htdocs/resource/contact.php
+++ b/htdocs/resource/contact.php
@@ -36,7 +36,7 @@ $langs->load("sendings");
$langs->load("companies");
$id = GETPOST('id','int');
-$ref = GETPOST('ref', 'alpha');
+$ref = GETPOST('ref','alpha');
$action = GETPOST('action','alpha');
// Security check
@@ -123,19 +123,19 @@ if ($id > 0 || ! empty($ref))
$linkback = '' . $langs->trans("BackToList") . '';
-
-
+
+
$morehtmlref='