Work on website module

This commit is contained in:
Laurent Destailleur 2017-11-03 15:56:16 +01:00
parent 458be3c814
commit a346a1a5e9
14 changed files with 72 additions and 55 deletions

View File

@ -5263,7 +5263,7 @@ abstract class CommonObject
* Return HTML string to show a field into a page * Return HTML string to show a field into a page
* Code very similar with showOutputField of extra fields * Code very similar with showOutputField of extra fields
* *
* @param array $val Array of properties for field to show * @param array $val Array of properties of field to show
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parametes on html input tag * @param string $moreparam To add more parametes on html input tag
@ -5283,7 +5283,6 @@ abstract class CommonObject
} }
$objectid = $this->id; $objectid = $this->id;
$label=$val['label']; $label=$val['label'];
$type =$val['type']; $type =$val['type'];
$size =$val['css']; $size =$val['css'];
@ -5307,8 +5306,8 @@ abstract class CommonObject
} }
$langfile=$val['langfile']; $langfile=$val['langfile'];
$list=$val['list']; $list=$val['list'];
$hidden=(abs($val['visible'])!=1 ? 1 : 0);
$help=$val['help']; $help=$val['help'];
$hidden=(($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
if ($hidden) return ''; if ($hidden) return '';
@ -5320,21 +5319,37 @@ abstract class CommonObject
$value = dol_eval($computed, 1, 0); $value = dol_eval($computed, 1, 0);
} }
$showsize=0; if (empty($showsize))
{
if ($type == 'date') if ($type == 'date')
{ {
$showsize=10; $showsize=10;
$value=dol_print_date($value,'day');
} }
elseif ($type == 'datetime') elseif ($type == 'datetime')
{ {
$showsize=19; $showsize=19;
$value=dol_print_date($value,'dayhour');
} }
elseif ($type == 'int') elseif ($type == 'int' || $type == 'integer')
{ {
$showsize=10; $showsize=10;
} }
else
{
$showsize=round($size);
if ($showsize > 48) $showsize=48;
}
}
if ($key == 'ref') $value=$this->getNomUrl(1, '', 0, '', 1);
elseif ($key == 'status') $value=$this->getLibStatut(3);
elseif ($type == 'date')
{
$value=dol_print_date($value,'day');
}
elseif ($type == 'datetime')
{
$value=dol_print_date($value,'dayhour');
}
elseif ($type == 'double') elseif ($type == 'double')
{ {
if (!empty($value)) { if (!empty($value)) {
@ -5569,11 +5584,6 @@ abstract class CommonObject
{ {
$value=preg_replace('/./i','*',$value); $value=preg_replace('/./i','*',$value);
} }
else
{
$showsize=round($size);
if ($showsize > 48) $showsize=48;
}
//print $type.'-'.$size; //print $type.'-'.$size;
$out=$value; $out=$value;

View File

@ -1315,7 +1315,7 @@ class ExtraFields
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $value Value to show * @param string $value Value to show
* @param string $moreparam To add more parametes on html input tag (only checkbox use html input for output rendering) * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering)
* @return string Formated value * @return string Formated value
*/ */
function showOutputField($key,$value,$moreparam='') function showOutputField($key,$value,$moreparam='')
@ -1334,7 +1334,7 @@ class ExtraFields
$perms=$this->attribute_perms[$key]; $perms=$this->attribute_perms[$key];
$langfile=$this->attribute_langfile[$key]; $langfile=$this->attribute_langfile[$key];
$list=$this->attribute_list[$key]; $list=$this->attribute_list[$key];
$hidden=(abs($list)!=1 ? 1 : 0); $hidden=(($list != 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.

View File

@ -209,10 +209,10 @@ function societe_prepare_head(Societe $object)
if (! empty($conf->website->enabled) && (!empty($user->rights->societe->lire) )) if (! empty($conf->website->enabled) && (!empty($user->rights->societe->lire) ))
{ {
$head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id;
$head[$h][1] = $langs->trans("WebSites"); $head[$h][1] = $langs->trans("WebSiteAccounts");
$nbNote = 0; $nbNote = 0;
$sql = "SELECT COUNT(n.rowid) as nb"; $sql = "SELECT COUNT(n.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."websiteaccount as n"; $sql.= " FROM ".MAIN_DB_PREFIX."website_account as n";
$sql.= " WHERE fk_soc = ".$object->id; $sql.= " WHERE fk_soc = ".$object->id;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)

View File

@ -26,9 +26,11 @@
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (abs($val['visible']) != 1) continue; // Discard such field from form // Discard if extrafield is a hidden field on form
if (abs($val['visible']) != 1) continue;
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
if ($key == 'status') continue; // Status is alreadt in dol_banner if ($key == 'status') continue; // Status is already in dol_banner
$value=$object->$key; $value=$object->$key;

View File

@ -42,7 +42,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
{ {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{ {
// Discard if extrafield is a hidden field // Discard if extrafield is a hidden field on form
if (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 1) continue; if (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 1) continue;
// Load language if required // Load language if required

View File

@ -63,6 +63,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
-- For 7.0 -- For 7.0
UPDATE llx_website SET entity = 1 WHERE entity IS NULL;
-- VMYSQL4.3 ALTER TABLE llx_website MODIFY COLUMN entity integer NOT NULL DEFAULT 1;
-- VPGSQL8.2 ALTER TABLE llx_website ALTER COLUMN entity SET NOT NULL;
ALTER TABLE llx_user ADD COLUMN birth date; ALTER TABLE llx_user ADD COLUMN birth date;
-- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY; -- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY;

View File

@ -20,7 +20,7 @@
CREATE TABLE llx_website CREATE TABLE llx_website
( (
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
entity integer DEFAULT 1, entity integer NOT NULL DEFAULT 1,
ref varchar(128) NOT NULL, ref varchar(128) NOT NULL,
description varchar(255), description varchar(255),
status integer DEFAULT 1, status integer DEFAULT 1,

View File

@ -815,6 +815,7 @@ BulkActions=Bulk actions
ClickToShowHelp=Click to show tooltip help ClickToShowHelp=Click to show tooltip help
WebSite=Web site WebSite=Web site
WebSites=Web sites WebSites=Web sites
WebSiteAccounts=Web site accounts
ExpenseReport=Expense report ExpenseReport=Expense report
ExpenseReports=Expense reports ExpenseReports=Expense reports
HR=HR HR=HR

View File

@ -488,12 +488,10 @@ while ($i < min($num, $limit))
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) if (! empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'.($align?' class="'.$align.'"':'').'>'; print '<td';
if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); if ($align) print ' class="'.$align.'"';
elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); print '>';
elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); print $object->showOutputField($val, $key, $obj->$key, '');
elseif ($key == 'status') print $object->getLibStatut(3);
else print $obj->$key;
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))
@ -510,12 +508,12 @@ while ($i < min($num, $limit))
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
print '<td';
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
print '<td';
if ($align) print ' align="'.$align.'"'; if ($align) print ' align="'.$align.'"';
print '>'; print '>';
$tmpkey='options_'.$key; $tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print $extrafields->showOutputField($key, $obj->$tmpkey, '');
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))

View File

@ -255,7 +255,7 @@ $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql); $sql=preg_replace('/, $/','', $sql);
$sql.= " FROM ".MAIN_DB_PREFIX."websiteaccount as t"; $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 (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').")"; if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('websiteaccount').")";
else $sql.=" WHERE 1 = 1"; else $sql.=" WHERE 1 = 1";
@ -488,12 +488,11 @@ while ($i < min($num, $limit))
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) if (! empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'.($align?' class="'.$align.'"':'').'>'; print '<td';
if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); if ($align) print ' class="'.$align.'"';
elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); print '>';
elseif ($key == 'ref' || $key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3); else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
else print $obj->$key;
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))
@ -510,12 +509,12 @@ while ($i < min($num, $limit))
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
print '<td';
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
print '<td';
if ($align) print ' align="'.$align.'"'; if ($align) print ' align="'.$align.'"';
print '>'; print '>';
$tmpkey='options_'.$key; $tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print $extrafields->showOutputField($key, $obj->$tmpkey, '');
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))

View File

@ -44,7 +44,11 @@ class Website extends CommonObject
*/ */
public $table_element = 'website'; public $table_element = 'website';
/** /**
* @var string String with name of icon for websiteaccount. Must be the part after the 'object_' into object_myobject.png * @var array Does websiteaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 1;
/**
* @var string String with name of icon for website. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto = 'globe'; public $picto = 'globe';

View File

@ -77,7 +77,7 @@ class WebsiteAccount extends CommonObject
public $fields=array( public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',), 'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',),
'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>-1, 'enabled'=>1, 'position'=>30), 'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>-2, 'enabled'=>1, 'position'=>30),
'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1), 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1),
'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,), 'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1),
@ -117,11 +117,11 @@ class WebsiteAccount extends CommonObject
/** /**
* @var int Name of subtable line * @var int Name of subtable line
*/ */
//public $table_element_line = 'websiteaccountdet'; //public $table_element_line = 'website_accountdet';
/** /**
* @var int Field with ID of parent key if this field has a parent * @var int Field with ID of parent key if this field has a parent
*/ */
//public $fk_element = 'fk_websiteaccount'; //public $fk_element = 'fk_website_account';
/** /**
* @var int Name of subtable class that manage subtable lines * @var int Name of subtable class that manage subtable lines
*/ */
@ -129,7 +129,7 @@ class WebsiteAccount extends CommonObject
/** /**
* @var array Array of child tables (child tables to delete before deleting a record) * @var array Array of child tables (child tables to delete before deleting a record)
*/ */
//protected $childtables=array('websiteaccountdet'); //protected $childtables=array('website_accountdet');
/** /**
* @var WebsiteAccountLine[] Array of subtable lines * @var WebsiteAccountLine[] Array of subtable lines
*/ */
@ -319,12 +319,11 @@ class WebsiteAccount extends CommonObject
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
if ($withpicto) $result .= $linkstart;
{ if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
$result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend); if ($withpicto != 2) $result.= $this->ref;
if ($withpicto != 2) $result.=' '; $result .= $linkend;
}
$result.= $linkstart . $this->ref . $linkend;
return $result; return $result;
} }

View File

@ -44,7 +44,7 @@ class WebsitePage extends CommonObject
*/ */
public $table_element = 'website_page'; public $table_element = 'website_page';
/** /**
* @var string String with name of icon for websiteaccount. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for websitepage. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto = 'label'; public $picto = 'label';

View File

@ -41,7 +41,7 @@ function websiteaccountPrepareHead($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) /*if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
{ {
$nbNote = 0; $nbNote = 0;
if(!empty($object->fields['note_private'])) $nbNote++; if(!empty($object->fields['note_private'])) $nbNote++;
@ -51,7 +51,7 @@ function websiteaccountPrepareHead($object)
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }*/
/* /*
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';