Clean code

This commit is contained in:
Laurent Destailleur 2017-10-20 23:48:42 +02:00
parent 3bca0ad07d
commit 19a5780f7f
31 changed files with 684 additions and 209 deletions

View File

@ -206,7 +206,7 @@ if (count($object->records) > 0)
if ($website)
{
$virtualurl='';
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
$dataroot=DOL_DATA_ROOT.'/collab/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
@ -238,7 +238,7 @@ if (count($object->records) > 0)
print '</div>';
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
$urlint=$urlwithroot.'/public/collab/index.php?website='.$website;
//if (! empty($object->virtualhost))
//{
print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
@ -246,7 +246,7 @@ if (count($object->records) > 0)
print '</a>';
//}
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/collab/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>';
}
@ -347,7 +347,7 @@ if (count($object->records) > 0)
$websitepage = new WebSitePage($db);
$websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
$realpage=$urlwithroot.'/public/collab/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">';

View File

@ -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."<br>";
@ -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

View File

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

View File

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

View File

@ -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', '<span style="background: #ddd; border: 1px solid #ccc; border-radius: 4px;">...php...</span>', $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);

View File

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

View File

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

View File

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

View File

@ -15,4 +15,6 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
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);

View File

@ -0,0 +1,26 @@
-- 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_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);

View File

@ -0,0 +1,32 @@
-- 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_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;

View File

@ -0,0 +1,23 @@
-- 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_websiteaccount_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -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
WebsiteAccounts=Web site accounts
AddWebsiteAccount=Create web site account

View File

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

View File

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

View File

@ -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.='<div class="divsearchfield">';
/*$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';
$moreforfilter.= '</div>';*/
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook

View File

@ -47,7 +47,6 @@ class Product extends CommonObject
public $table_element='product';
public $fk_element='fk_product';
protected $childtables=array('supplier_proposaldet', 'propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object
protected $isnolinkedbythird = 1; // No field fk_soc
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
/**

View File

@ -44,10 +44,6 @@ class Inventory extends CommonObject
*/
public $table_element = 'inventory';
/**
* @var array Does this field is linked to a thirdparty ?
*/
protected $isnolinkedbythird = 1;
/**
* @var array Does inventory support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/

View File

@ -46,7 +46,6 @@ class Productlot extends CommonObject
public $picto='barcode';
public $isnolinkedbythird = 1;
public $ismultientitymanaged = 1;
/**

View File

@ -16,7 +16,7 @@
*/
/**
* \file htdocs/public/websites/index.php
* \file htdocs/public/website/index.php
* \ingroup website
* \brief Page to output pages
* \author Laurent Destailleur
@ -66,8 +66,8 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_AP
if (empty($pageid))
{
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
$object=new Website($db);
$object->fetch(0, $websitekey);
@ -138,11 +138,11 @@ if ($pageid == 'css') // No more used ?
//if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
//else
header('Cache-Control: no-cache');
$original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/styles.css.php';
$original_file=$dolibarr_main_data_root.'/website/'.$websitekey.'/styles.css.php';
}
else
{
$original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/page'.$pageid.'.tpl.php';
$original_file=$dolibarr_main_data_root.'/website/'.$websitekey.'/page'.$pageid.'.tpl.php';
}
// Find the subdirectory name as the reference

View File

@ -16,7 +16,7 @@
*/
/**
* \file htdocs/public/websites/styles.css.php
* \file htdocs/public/website/styles.css.php
* \ingroup website
* \brief Page to output style page. Called with <link rel="stylesheet" href="styles.css.php?websiteid=123" type="text/css" />
*/
@ -65,8 +65,8 @@ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_AP
if (empty($pageid))
{
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
$object=new Website($db);
if ($websiteid)
@ -97,7 +97,7 @@ if (empty($pageid))
// Security: Delete string ../ into $original_file
global $dolibarr_main_data_root;
$original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php';
$original_file=$dolibarr_main_data_root.'/website/'.$website.'/styles.css.php';
// Find the subdirectory name as the reference
$refname=basename(dirname($original_file)."/");

View File

@ -43,7 +43,7 @@ $langs->load("main");
// Get parameters
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$ref = GETPOST('ref');
$ref = GETPOST('ref','alpha');
$description = GETPOST('description');
$confirm = GETPOST('confirm');
$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
@ -58,8 +58,8 @@ if (! $user->rights->resource->read)
accessforbidden();
$object = new Dolresource($db);
$objectFetchRes = $object->fetch($id);
if (! ($objectFetchRes > 0)) dol_print_error($db, $object->error);
$result = $object->fetch($id, $ref);
if (! ($result > 0)) dol_print_error($db, $object->error);
$extrafields = new ExtraFields($db);
@ -68,7 +68,7 @@ $extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('resource_card','globalcard'));
$parameters=array('resource_id'=>$id);
$parameters=array('resource_id'=>$object->id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -159,17 +159,17 @@ if (empty($reshook))
*
* Put here all code to build page
****************************************************/
$pagetitle = $langs->trans('ResourceCard');
llxHeader('',$pagetitle,'');
$form = new Form($db);
$formresource = new FormResource($db);
if ( $objectFetchRes > 0 )
if ($object->id > 0)
{
$head=resource_prepare_head($object);
if ($action == 'edit' )
{
if ( ! $user->rights->resource->write )
@ -189,7 +189,7 @@ if ( $objectFetchRes > 0 )
// Ref
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("ResourceFormLabel_ref").'</td>';
print '<td><input size="12" name="ref" value="'.(GETPOST('ref') ? GETPOST('ref') : $object->ref).'"></td></tr>';
print '<td><input class="minwidth200" name="ref" value="'.(GETPOST('ref') ? GETPOST('ref') : $object->ref).'"></td></tr>';
// Type
print '<tr><td>'.$langs->trans("ResourceType").'</td>';
@ -200,7 +200,7 @@ if ( $objectFetchRes > 0 )
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
print '<textarea name="description" cols="80" rows="'.ROWS_3.'">'.($_POST['description'] ? GETPOST('description','alpha') : $object->description).'</textarea>';
print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($_POST['description'] ? GETPOST('description','alpha') : $object->description).'</textarea>';
print '</td></tr>';
// Other attributes
@ -232,7 +232,7 @@ if ( $objectFetchRes > 0 )
// Confirm deleting resource line
if ($action == 'delete')
{
$formconfirm = $form->formconfirm("card.php?&id=".$id,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResource"),"confirm_delete_resource",'','',1);
$formconfirm = $form->formconfirm("card.php?&id=".$object->id,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResource"),"confirm_delete_resource",'','',1);
}
// Print form confirm
@ -246,7 +246,7 @@ if ( $objectFetchRes > 0 )
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
@ -302,7 +302,7 @@ if ( $objectFetchRes > 0 )
if($user->rights->resource->write)
{
print '<div class="inline-block divButAction">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=edit" class="butAction">'.$langs->trans('Modify').'</a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit" class="butAction">'.$langs->trans('Modify').'</a>';
print '</div>';
}
}
@ -312,7 +312,7 @@ if ( $objectFetchRes > 0 )
if($user->rights->resource->delete)
{
print '<div class="inline-block divButAction">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=delete" class="butActionDelete">'.$langs->trans('Delete').'</a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete" class="butActionDelete">'.$langs->trans('Delete').'</a>';
print '</div>';
}
}

View File

@ -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."<br>";
$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."<br>";
$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
*

View File

@ -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 = '<a href="' . DOL_URL_ROOT . '/resource/list.php' . (! empty($socid) ? '?id=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Object
print '<table width="100%" class="border">';
@ -152,7 +152,7 @@ if ($id > 0 || ! empty($ref))
print '</div>';
dol_fiche_end();
print '<br>';
if (! empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1;

View File

@ -40,7 +40,7 @@ $langs->load("resource");
$langs->load("companies");
$id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$ref = GETPOST('ref','alpha');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
@ -100,20 +100,20 @@ if ($object->id)
$totalsize+=$file['size'];
}
$linkback = '<a href="' . DOL_URL_ROOT . '/resource/list.php' . (! empty($socid) ? '?id=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Resource type
@ -131,10 +131,10 @@ if ($object->id)
print '</div>';
dol_fiche_end();
$modulepart = 'dolresource';
$permission = $user->rights->resource->write;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}

View File

@ -33,7 +33,7 @@ $langs->load('companies');
$langs->load("interventions");
$id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$ref = GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
// Security check
@ -67,18 +67,18 @@ if ($id > 0 || ! empty($ref))
dol_fiche_head($head, 'note', $langs->trans('ResourceSingular'), -1, 'resource');
$linkback = '<a href="' . DOL_URL_ROOT . '/resource/list.php' . (! empty($socid) ? '?id=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Resource type
@ -88,11 +88,11 @@ if ($id > 0 || ! empty($ref))
print $object->type_label;
print '</td>';
print '</tr>';
print "</table>";
print '</div>';
$permission=$user->rights->resource->write;
$cssclass='titlefield';
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';

View File

@ -30,12 +30,11 @@
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.'/websites/class/websiteaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/website/class/websiteaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$langs->load("companies");
$langs->loadLangs(array("companies","website"));
$search_status=GETPOST('search_status');
@ -52,12 +51,60 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='a.login';
if (! $sortfield) $sortfield='t.login';
if (! $sortorder) $sortorder='ASC';
// Initialize technical objects
$object=new Societe($db);
$objectwebsiteaccount=new WebsiteAccount($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('websiteaccountlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('websitethirdparty'));
// Initialize array of search criterias
$search_all=trim(GETPOST("search_all",'alpha'));
$search=array();
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach($objectwebsiteaccount->fields as $key => $val)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label'];
}
// Definition of fields for list
$arrayfields=array();
foreach($objectwebsiteaccount->fields as $key => $val)
{
// If $val['visible']==0, then we never show the field
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']);
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
if ($id > 0)
{
$result = $object->fetch($id);
}
/*
* Actions
@ -76,12 +123,32 @@ if (empty($reshook))
exit;
}
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$actioncode='';
$search_agenda_label='';
foreach($objectwebsiteaccount->fields as $key => $val)
{
$search[$key]='';
}
$toselect='';
$search_array_options=array();
}
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
|| GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
{
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass='WebsiteAccount';
$objectlabel='WebsiteAccount';
$permtoread = $user->rights->societe->lire;
$permtodelete = $user->rights->societe->supprimer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -91,21 +158,34 @@ if (empty($reshook))
*/
$contactstatic = new Contact($db);
$objectwebsiteaccount = new WebsiteAccount($db);
$form = new Form($db);
$langs->load("companies");
$object = new Societe($db);
$result = $object->fetch($id);
$title = $langs->trans("WebisteAccounts");
$title = $langs->trans("WebsiteAccounts");
llxHeader('', $title);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($id > 0) $param.='&id='.urlencode($id);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
foreach($search as $key => $val)
{
$param.= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$head = societe_prepare_head($object);
dol_fiche_head($head, 'websites', $langs->trans("ThirdParty"), - 1, 'company');
dol_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company');
$linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
@ -150,7 +230,7 @@ dol_fiche_end();
$morehtmlcenter = '';
if (! empty($conf->website->enabled)) {
if (! empty($user->rights->societe->lire)) {
$morehtmlcenter .= '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create' . $out . '">' . $langs->trans("AddWebsiteAccount") . '</a>';
$morehtmlcenter .= '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create' . $param . '">' . $langs->trans("AddWebsiteAccount") . '</a>';
} else {
$morehtmlcenter .= '<a class="butActionRefused" href="#">' . $langs->trans("AddAction") . '</a>';
}
@ -158,15 +238,6 @@ if (! empty($conf->website->enabled)) {
print '<br>';
$param = '&id=' . $id;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"])
$param .= '&contextpage=' . $contextpage;
if ($limit > 0 && $limit != $conf->liste_limit)
$param .= '&limit=' . $limit;
print_barre_liste($langs->trans("WebsiteAccounts"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, - 1, '', '', '', '', 0, 1, 1);
// Build and execute select
@ -185,7 +256,8 @@ $sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql);
$sql.= " FROM ".MAIN_DB_PREFIX."websiteaccount 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)";
$sql.= " WHERE t.entity IN (".getEntity('websiteaccount').")";
if ($objectwebsiteaccount->getIsmultientitymanaged() == 1) $sql.= " WHERE t.entity IN (".getEntity('websiteaccount').")";
else $sql.=" WHERE 1 = 1";
foreach($search as $key => $val)
{
$mode_search=(($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key]))?1:0);
@ -237,7 +309,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)
{
@ -245,6 +316,363 @@ if (! $resql)
exit;
}
$num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
foreach($search as $key => $val)
{
$param.= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->mymodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton.' '.$morehtmlcenter, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
}
/*$moreforfilter = '';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';*/
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Rest of fields search
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
}
// Action column
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$sortonfield = "ef.".$key;
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n";
}
}
}
// Hook fields
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Rest of fields title
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
}
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
foreach ($extrafields->attribute_computed as $key => $val)
{
if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}
// Loop on record
// --------------------------------------------------------------------
$i=0;
$totalarray=array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
// Store properties in $object
$objectwebsiteaccount->id = $obj->rowid;
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (isset($obj->$key)) $objectwebsiteaccount->$key = $obj->$key;
}
// Show here line of result
print '<tr class="oddeven">';
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Discard some field output at end
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser');
elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
elseif ($key == 'ref') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Rest of fields
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Keep only field not yet already output
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser');
elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print '</tr>';
$i++;
}
// Show total line
if (isset($totalarray['pos']))
{
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
}
// If no record found
if ($num == 0)
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
$db->free($resql);
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
$formfile = new FormFile($db);
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->mymodule->read;
$delallowed=$user->rights->mymodule->create;
print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
}
}

View File

@ -1566,7 +1566,7 @@ div.mainmenu.tools {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/tools.png',1) ?>);
}
div.mainmenu.websites {
div.mainmenu.website {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/externalsite.png',1) ?>);
}

View File

@ -1602,7 +1602,7 @@ div.mainmenu.tools {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/tools.png',1) ?>);
}
div.mainmenu.websites {
div.mainmenu.website {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/externalsite.png',1) ?>);
}

View File

@ -44,18 +44,15 @@ class WebsiteAccount extends CommonObject
*/
public $table_element = 'websiteaccount';
/**
* @var array Does this field is linked to a thirdparty ?
*/
protected $isnolinkedbythird = 1;
/**
* @var array Does websiteaccount 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 websiteaccount
*/
public $picto = 'websiteaccount@website';
public $picto = 'object_globe';
/**

View File

@ -1143,16 +1143,16 @@ if (count($object->records) > 0)
{
// ***** Part for web sites
print '<div class="websiteelection hideonsmartphoneimp minwwidth100">';
print '<div class="websiteselection hideonsmartphoneimp minwwidth100">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddWebsite")).'" name="createsite">';
print '</div>';
print '<div class="websiteelection hideonsmartphoneimp">';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Website").': ';
print '</div>';
// List of website
print '<div class="websiteelection">';
print '<div class="websiteselection">';
$out='';
$out.='<select name="website" class="minwidth100" id="website">';
if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>';
@ -1245,14 +1245,14 @@ if (count($object->records) > 0)
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteelection hideonsmartphoneimp minwidth100">';
print '<div class="websiteselection hideonsmartphoneimp minwidth100">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
print '</div>';
print '<div class="websiteelection hideonsmartphoneimp">';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': ';
print '</div>';
print '<div class="websiteelection">';
print '<div class="websiteselection">';
if ($action != 'add')
{
@ -1433,7 +1433,7 @@ if (count($object->records) > 0)
}
else
{
print '<div class="websiteelection">';
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';