mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Extrafields "link to object" now use a combo selection and getNomUrl
This commit is contained in:
parent
66d2c29fe1
commit
e865f41b86
|
|
@ -4663,10 +4663,9 @@ abstract class CommonObject
|
|||
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param mixed $showsize Value for css to define size. May also be a numeric.
|
||||
* @param int $objectid Current object id
|
||||
* @return string
|
||||
*/
|
||||
function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0)
|
||||
function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
|
||||
{
|
||||
global $conf,$langs,$form;
|
||||
|
||||
|
|
@ -4676,6 +4675,8 @@ abstract class CommonObject
|
|||
$form=new Form($this->db);
|
||||
}
|
||||
|
||||
$objectid = $this->id;
|
||||
|
||||
$label=$val['label'];
|
||||
$type =$val['type'];
|
||||
$size =$val['css'];
|
||||
|
|
@ -5178,6 +5179,328 @@ abstract class CommonObject
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return HTML string to show a field into a page
|
||||
* Code very similar with showOutputField of extra fields
|
||||
*
|
||||
* @param array $val Array of properties for field to show
|
||||
* @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 $moreparam To add more parametes on html input tag
|
||||
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param mixed $showsize Value for css to define size. May also be a numeric.
|
||||
* @return string
|
||||
*/
|
||||
function showOutputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
|
||||
{
|
||||
global $conf,$langs,$form;
|
||||
|
||||
if (! is_object($form))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
$form=new Form($this->db);
|
||||
}
|
||||
|
||||
$objectid = $this->id;
|
||||
|
||||
$label=$val['label'];
|
||||
$type =$val['type'];
|
||||
$size =$val['css'];
|
||||
|
||||
// Convert var to be able to share same code than showOutputField of extrafields
|
||||
if (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
|
||||
if (is_array($val['arrayofkeyval'])) $type='select';
|
||||
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link';
|
||||
|
||||
//$elementtype=$this->attribute_elementtype[$key]; // seems to not be used
|
||||
$default=$val['default'];
|
||||
$computed=$val['computed'];
|
||||
$unique=$val['unique'];
|
||||
$required=$val['required'];
|
||||
$param=$val['param'];
|
||||
if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
|
||||
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
|
||||
{
|
||||
$type='link';
|
||||
$param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
|
||||
}
|
||||
$langfile=$val['langfile'];
|
||||
$list=$val['list'];
|
||||
$hidden=(abs($val['visible'])!=1 ? 1 : 0);
|
||||
$help=$val['help'];
|
||||
|
||||
if ($hidden) return '';
|
||||
|
||||
// If field is a computed field, value must become result of compute
|
||||
if ($computed)
|
||||
{
|
||||
// Make the eval of compute string
|
||||
//var_dump($computed);
|
||||
$value = dol_eval($computed, 1, 0);
|
||||
}
|
||||
|
||||
$showsize=0;
|
||||
if ($type == 'date')
|
||||
{
|
||||
$showsize=10;
|
||||
$value=dol_print_date($value,'day');
|
||||
}
|
||||
elseif ($type == 'datetime')
|
||||
{
|
||||
$showsize=19;
|
||||
$value=dol_print_date($value,'dayhour');
|
||||
}
|
||||
elseif ($type == 'int')
|
||||
{
|
||||
$showsize=10;
|
||||
}
|
||||
elseif ($type == 'double')
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$value=price($value);
|
||||
}
|
||||
}
|
||||
elseif ($type == 'boolean')
|
||||
{
|
||||
$checked='';
|
||||
if (!empty($value)) {
|
||||
$checked=' checked ';
|
||||
}
|
||||
$value='<input type="checkbox" '.$checked.' '.($moreparam?$moreparam:'').' readonly disabled>';
|
||||
}
|
||||
elseif ($type == 'mail')
|
||||
{
|
||||
$value=dol_print_email($value,0,0,0,64,1,1);
|
||||
}
|
||||
elseif ($type == 'url')
|
||||
{
|
||||
$value=dol_print_url($value,'_blank',32,1);
|
||||
}
|
||||
elseif ($type == 'phone')
|
||||
{
|
||||
$value=dol_print_phone($value, '', 0, 0, '', ' ', 1);
|
||||
}
|
||||
elseif ($type == 'price')
|
||||
{
|
||||
$value=price($value,0,$langs,0,0,-1,$conf->currency);
|
||||
}
|
||||
elseif ($type == 'select')
|
||||
{
|
||||
$value=$params['options'][$value];
|
||||
}
|
||||
elseif ($type == 'sellist')
|
||||
{
|
||||
$param_list=array_keys($params['options']);
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
|
||||
$selectkey="rowid";
|
||||
$keyList='rowid';
|
||||
|
||||
if (count($InfoFieldList)>=3)
|
||||
{
|
||||
$selectkey = $InfoFieldList[2];
|
||||
$keyList=$InfoFieldList[2].' as rowid';
|
||||
}
|
||||
|
||||
$fields_label = explode('|',$InfoFieldList[1]);
|
||||
if(is_array($fields_label)) {
|
||||
$keyList .=', ';
|
||||
$keyList .= implode(', ', $fields_label);
|
||||
}
|
||||
|
||||
$sql = 'SELECT '.$keyList;
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0];
|
||||
if (strpos($InfoFieldList[4], 'extra')!==false)
|
||||
{
|
||||
$sql.= ' as main';
|
||||
}
|
||||
if ($selectkey=='rowid' && empty($value)) {
|
||||
$sql.= " WHERE ".$selectkey."=0";
|
||||
} elseif ($selectkey=='rowid') {
|
||||
$sql.= " WHERE ".$selectkey."=".$this->db->escape($value);
|
||||
}else {
|
||||
$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
|
||||
}
|
||||
|
||||
//$sql.= ' AND entity = '.$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$value=''; // value was used, so now we reste it to use it to build final output
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// Several field into label (eq table:code|libelle:rowid)
|
||||
$fields_label = explode('|',$InfoFieldList[1]);
|
||||
|
||||
if(is_array($fields_label) && count($fields_label)>1)
|
||||
{
|
||||
foreach ($fields_label as $field_toshow)
|
||||
{
|
||||
$translabel='';
|
||||
if (!empty($obj->$field_toshow)) {
|
||||
$translabel=$langs->trans($obj->$field_toshow);
|
||||
}
|
||||
if ($translabel!=$field_toshow) {
|
||||
$value.=dol_trunc($translabel,18).' ';
|
||||
}else {
|
||||
$value.=$obj->$field_toshow.' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$translabel='';
|
||||
if (!empty($obj->{$InfoFieldList[1]})) {
|
||||
$translabel=$langs->trans($obj->{$InfoFieldList[1]});
|
||||
}
|
||||
if ($translabel!=$obj->{$InfoFieldList[1]}) {
|
||||
$value=dol_trunc($translabel,18);
|
||||
}else {
|
||||
$value=$obj->{$InfoFieldList[1]};
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
||||
}
|
||||
elseif ($type == 'radio')
|
||||
{
|
||||
$value=$params['options'][$value];
|
||||
}
|
||||
elseif ($type == 'checkbox')
|
||||
{
|
||||
$value_arr=explode(',',$value);
|
||||
$value='';
|
||||
if (is_array($value_arr))
|
||||
{
|
||||
foreach ($value_arr as $keyval=>$valueval) {
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$params['options'][$valueval].'</li>';
|
||||
}
|
||||
}
|
||||
$value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
||||
}
|
||||
elseif ($type == 'chkbxlst')
|
||||
{
|
||||
$value_arr = explode(',', $value);
|
||||
|
||||
$param_list = array_keys($params['options']);
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
|
||||
$selectkey = "rowid";
|
||||
$keyList = 'rowid';
|
||||
|
||||
if (count($InfoFieldList) >= 3) {
|
||||
$selectkey = $InfoFieldList[2];
|
||||
$keyList = $InfoFieldList[2] . ' as rowid';
|
||||
}
|
||||
|
||||
$fields_label = explode('|', $InfoFieldList[1]);
|
||||
if (is_array($fields_label)) {
|
||||
$keyList .= ', ';
|
||||
$keyList .= implode(', ', $fields_label);
|
||||
}
|
||||
|
||||
$sql = 'SELECT ' . $keyList;
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
|
||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||
$sql .= ' as main';
|
||||
}
|
||||
// $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
|
||||
// $sql.= ' AND entity = '.$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst',LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$value = ''; // value was used, so now we reste it to use it to build final output
|
||||
$toprint=array();
|
||||
while ( $obj = $this->db->fetch_object($resql) ) {
|
||||
|
||||
// Several field into label (eq table:code|libelle:rowid)
|
||||
$fields_label = explode('|', $InfoFieldList[1]);
|
||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||
if (is_array($fields_label) && count($fields_label) > 1) {
|
||||
foreach ( $fields_label as $field_toshow ) {
|
||||
$translabel = '';
|
||||
if (! empty($obj->$field_toshow)) {
|
||||
$translabel = $langs->trans($obj->$field_toshow);
|
||||
}
|
||||
if ($translabel != $field_toshow) {
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
|
||||
} else {
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->$field_toshow.'</li>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$translabel = '';
|
||||
if (! empty($obj->{$InfoFieldList[1]})) {
|
||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||
}
|
||||
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
|
||||
} else {
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->{$InfoFieldList[1]}.'</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
||||
|
||||
} else {
|
||||
dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
|
||||
}
|
||||
}
|
||||
elseif ($type == 'link')
|
||||
{
|
||||
$out='';
|
||||
|
||||
// only if something to display (perf)
|
||||
if ($value)
|
||||
{
|
||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
||||
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
$classname=$InfoFieldList[0];
|
||||
$classpath=$InfoFieldList[1];
|
||||
if (! empty($classpath))
|
||||
{
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
if ($classname && class_exists($classname))
|
||||
{
|
||||
$object = new $classname($this->db);
|
||||
$object->fetch($value);
|
||||
$value=$object->getNomUrl(3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
|
||||
return 'Error bad setup of extrafield';
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($type == 'text')
|
||||
{
|
||||
$value=dol_htmlentitiesbr($value);
|
||||
}
|
||||
elseif ($type == 'password')
|
||||
{
|
||||
$value=preg_replace('/./i','*',$value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$showsize=round($size);
|
||||
if ($showsize > 48) $showsize=48;
|
||||
}
|
||||
|
||||
//print $type.'-'.$size;
|
||||
$out=$value;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to show lines of extrafields with output datas
|
||||
|
|
|
|||
|
|
@ -809,7 +809,13 @@ class ExtraFields
|
|||
*/
|
||||
function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf,$langs,$form;
|
||||
|
||||
if (! is_object($form))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
$form=new Form($this->db);
|
||||
}
|
||||
|
||||
$keyprefix = $keyprefix.'options_'; // Because we work on extrafields
|
||||
|
||||
|
|
@ -885,10 +891,6 @@ class ExtraFields
|
|||
// Do not show current date when field not required (see select_date() method)
|
||||
if (!$required && $value == '') $value = '-1';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
global $form;
|
||||
if (! is_object($form)) $form=new Form($this->db);
|
||||
|
||||
// TODO Must also support $moreparam
|
||||
$out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1);
|
||||
}
|
||||
|
|
@ -1125,12 +1127,8 @@ class ExtraFields
|
|||
}
|
||||
elseif ($type == 'checkbox')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
$form = new Form($db);
|
||||
|
||||
$value_arr=explode(',',$value);
|
||||
$out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
|
||||
|
||||
}
|
||||
elseif ($type == 'radio')
|
||||
{
|
||||
|
|
@ -1280,9 +1278,6 @@ class ExtraFields
|
|||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
$form = new Form($db);
|
||||
|
||||
$out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
|
||||
|
||||
} else {
|
||||
|
|
@ -1293,33 +1288,9 @@ class ExtraFields
|
|||
}
|
||||
elseif ($type == 'link')
|
||||
{
|
||||
$out='';
|
||||
|
||||
$param_list=array_keys($param['options']);
|
||||
// 0 : ObjectName
|
||||
// 1 : classPath
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
|
||||
{
|
||||
$valuetoshow=$value;
|
||||
if (!empty($value))
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
$resfetch=$object->fetch($value);
|
||||
if ($resfetch > 0)
|
||||
{
|
||||
$valuetoshow=$object->ref;
|
||||
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
|
||||
}
|
||||
}
|
||||
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$valuetoshow.'" >';
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
|
||||
$out.='Error bad setup of extrafield';
|
||||
}
|
||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
||||
$showempty=(($val['notnull'] == 1 && $val['default'] != '')?0:1);
|
||||
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
|
||||
}
|
||||
elseif ($type == 'password')
|
||||
{
|
||||
|
|
@ -1357,11 +1328,13 @@ class ExtraFields
|
|||
$computed=$this->attribute_computed[$key];
|
||||
$unique=$this->attribute_unique[$key];
|
||||
$required=$this->attribute_required[$key];
|
||||
$params=$this->attribute_param[$key];
|
||||
$param=$this->attribute_param[$key];
|
||||
$perms=$this->attribute_perms[$key];
|
||||
$langfile=$this->attribute_langfile[$key];
|
||||
$list=$this->attribute_list[$key];
|
||||
$hidden=$this->attribute_hidden[$key]; // warning, do not rely on this. If your module need a hidden data, it must use its own table.
|
||||
$hidden=(abs($list)!=1 ? 1 : 0);
|
||||
|
||||
if ($hidden) return '';
|
||||
|
||||
// If field is a computed field, value must become result of compute
|
||||
if ($computed)
|
||||
|
|
@ -1418,11 +1391,11 @@ class ExtraFields
|
|||
}
|
||||
elseif ($type == 'select')
|
||||
{
|
||||
$value=$params['options'][$value];
|
||||
$value=$param['options'][$value];
|
||||
}
|
||||
elseif ($type == 'sellist')
|
||||
{
|
||||
$param_list=array_keys($params['options']);
|
||||
$param_list=array_keys($param['options']);
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
|
||||
$selectkey="rowid";
|
||||
|
|
@ -1499,7 +1472,7 @@ class ExtraFields
|
|||
}
|
||||
elseif ($type == 'radio')
|
||||
{
|
||||
$value=$params['options'][$value];
|
||||
$value=$param['options'][$value];
|
||||
}
|
||||
elseif ($type == 'checkbox')
|
||||
{
|
||||
|
|
@ -1508,7 +1481,7 @@ class ExtraFields
|
|||
if (is_array($value_arr))
|
||||
{
|
||||
foreach ($value_arr as $keyval=>$valueval) {
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$params['options'][$valueval].'</li>';
|
||||
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>';
|
||||
}
|
||||
}
|
||||
$value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
||||
|
|
@ -1517,7 +1490,7 @@ class ExtraFields
|
|||
{
|
||||
$value_arr = explode(',', $value);
|
||||
|
||||
$param_list = array_keys($params['options']);
|
||||
$param_list = array_keys($param['options']);
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
|
||||
$selectkey = "rowid";
|
||||
|
|
@ -1589,22 +1562,26 @@ class ExtraFields
|
|||
// only if something to display (perf)
|
||||
if ($value)
|
||||
{
|
||||
$param_list=array_keys($params['options']);
|
||||
// 0 : ObjectName
|
||||
// 1 : classPath
|
||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
||||
|
||||
$InfoFieldList = explode(":", $param_list[0]);
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
|
||||
{
|
||||
$object = new $InfoFieldList[0]($this->db);
|
||||
$object->fetch($value);
|
||||
$value=$object->getNomUrl(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
|
||||
$out.='Error bad setup of extrafield';
|
||||
}
|
||||
$classname=$InfoFieldList[0];
|
||||
$classpath=$InfoFieldList[1];
|
||||
if (! empty($classpath))
|
||||
{
|
||||
dol_include_once($InfoFieldList[1]);
|
||||
if ($classname && class_exists($classname))
|
||||
{
|
||||
$object = new $classname($this->db);
|
||||
$object->fetch($value);
|
||||
$value=$object->getNomUrl(3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
|
||||
return 'Error bad setup of extrafield';
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($type == 'text')
|
||||
|
|
@ -1624,10 +1601,6 @@ class ExtraFields
|
|||
//print $type.'-'.$size;
|
||||
$out=$value;
|
||||
|
||||
if (!empty($hidden)) {
|
||||
$out='';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5172,11 +5172,13 @@ class Form
|
|||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->$confkeyforautocompletemode) && ! $forcecombo)
|
||||
{
|
||||
$objectdesc=$classname.':'.$classpath;
|
||||
$urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php';
|
||||
//if ($objecttmp->element == 'societe') $urlforajaxcall = DOL_URL_ROOT.'/societe/ajax/company.php';
|
||||
|
||||
// No immediate load of all database
|
||||
$urloption='htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.($moreparams?$moreparams:'');
|
||||
// Activate the auto complete using ajax call.
|
||||
$out.= ajax_autocompleter($preselectedvalue, $htmlname, DOL_URL_ROOT.'/core/ajax/selectobject.php', $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
|
||||
$out.= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
|
||||
$out.= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
|
||||
if ($placeholder) $placeholder=' placeholder="'.$placeholder.'"';
|
||||
$out.= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$preselectedvalue.'"'.$placeholder.' />';
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ if ($action == 'presend')
|
|||
|
||||
$object->fetch_projet();
|
||||
|
||||
if (! in_array($object->element, array('societe', 'user')))
|
||||
if (! in_array($object->element, array('societe', 'user', 'member')))
|
||||
{
|
||||
// TODO get also the main_lastdoc field of $object. If not found, try to guess with following code
|
||||
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
|
|
@ -75,19 +77,17 @@ if ($action == 'presend')
|
|||
}
|
||||
|
||||
// Build document if it not exists
|
||||
if (! in_array($object->element, array('societe', 'user')))
|
||||
if (! in_array($object->element, array('societe', 'user', 'member')))
|
||||
{
|
||||
if (! $file || ! is_readable($file)) {
|
||||
if ($object->element != 'member')
|
||||
{
|
||||
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
exit();
|
||||
}
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
$file = $fileparams['fullname'];
|
||||
if ((! $file || ! is_readable($file)) && method_exists($object, 'generateDocument'))
|
||||
{
|
||||
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
exit();
|
||||
}
|
||||
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||
$file = $fileparams['fullname'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ foreach($object->fields as $key => $val)
|
|||
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int');
|
||||
elseif ($val['type'] == 'text') $value = GETPOST($key, 'none');
|
||||
else $value = GETPOST($key, 'alpha');
|
||||
print $object->showInputField($val, $key, $value, '', '', '', 0, 0);
|
||||
print $object->showInputField($val, $key, $value, '', '', '', 0);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,22 +36,10 @@ foreach($object->fields as $key => $val)
|
|||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
$defaultcss='minwidth100';
|
||||
if ($val['type'] == 'text')
|
||||
{
|
||||
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
|
||||
print GETPOST($key,'none')?GETPOST($key,'none'):$object->$key;
|
||||
print '</textarea>';
|
||||
}
|
||||
elseif (is_array($val['arrayofkeyval']))
|
||||
{
|
||||
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cssforinput = empty($val['css'])?$defaultcss:$val['css'];
|
||||
print '<input class="flat'.($cssforinput?' '.$cssforinput:'').'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):$object->$key).'">';
|
||||
}
|
||||
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key;
|
||||
elseif ($val['type'] == 'text') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key;
|
||||
else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key;
|
||||
print $object->showInputField($val, $key, $value, '', '', '', 0);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
|
|
|||
84
htdocs/core/tpl/commonfields_view.tpl.php
Normal file
84
htdocs/core/tpl/commonfields_view.tpl.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/* Copyright (C) 2017 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/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $object (invoice, order, ...)
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*/
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE commonfields_view.tpl.php -->
|
||||
<?php
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (abs($val['visible']) != 1) continue; // Discard such field from form
|
||||
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
|
||||
|
||||
$value=$object->$key;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
||||
//print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
//if ($key == 'targetsrcfile3') break; // key used for break on second column
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
$alreadyoutput = 1;
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if ($alreadyoutput)
|
||||
{
|
||||
//if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column
|
||||
continue;
|
||||
}
|
||||
|
||||
if (abs($val['visible']) != 1) continue; // Discard such field from form
|
||||
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
|
||||
|
||||
$value=$object->$key;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
||||
//print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- END PHP TEMPLATE commonfields_view.tpl.php -->
|
||||
|
|
@ -111,7 +111,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
|
|||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="'.$fieldid.'" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value,'','','',0,$object->id);
|
||||
print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ NbOfCompaniesContacts=Unique contacts/addresses
|
|||
MailNoChangePossible=Recipients for validated emailing can't be changed
|
||||
SearchAMailing=Search mailing
|
||||
SendMailing=Send emailing
|
||||
SendMail=Send email
|
||||
SentBy=Sent by
|
||||
MailingNeedCommand=Sending an emailing can be performed from command line. Ask your server administrator to launch the following command to send the emailing to all recipients:
|
||||
MailingNeedCommand2=You can however send them online by adding parameter MAILING_LIMIT_SENDBYWEB with value of max number of emails you want to send by session. For this, go on Home - Setup - Other.
|
||||
|
|
|
|||
|
|
@ -610,6 +610,7 @@ SendByMail=Send by EMail
|
|||
MailSentBy=Email sent by
|
||||
TextUsedInTheMessageBody=Email body
|
||||
SendAcknowledgementByMail=Send confirmation email
|
||||
SendMail=Send email
|
||||
EMail=E-mail
|
||||
NoEMail=No email
|
||||
Email=Email
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ NoWidget=No widget
|
|||
GoToApiExplorer=Go to API explorer
|
||||
ListOfPermissionsDefined=List of defined permissions
|
||||
EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION)
|
||||
VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0)
|
||||
SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0)
|
||||
SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax.
|
||||
|
|
|
|||
|
|
@ -51,5 +51,6 @@ OrEnterPageInfoManually=Or create empty page from scratch...
|
|||
FetchAndCreate=Fetch and Create
|
||||
ExportSite=Export site
|
||||
IDOfPage=Id of page
|
||||
WebsiteAccount=Web site account
|
||||
WebsiteAccounts=Web site accounts
|
||||
AddWebsiteAccount=Create web site account
|
||||
|
|
@ -48,7 +48,7 @@ class MyObject extends CommonObject
|
|||
*/
|
||||
public $ismultientitymanaged = 0;
|
||||
/**
|
||||
* @var string String with name of icon for myobject
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'myobject@mymodule';
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ class MyObject extends CommonObject
|
|||
* 'type' if the field format.
|
||||
* 'label' the translation key.
|
||||
* 'enabled' is a condition when the field must be managed.
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
|
|
@ -315,7 +315,7 @@ class MyObject extends CommonObject
|
|||
|
||||
if ($withpicto)
|
||||
{
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
}
|
||||
$result.= $linkstart . $this->ref . $linkend;
|
||||
|
|
|
|||
|
|
@ -320,52 +320,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">'."\n";
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (abs($val['visible']) != 1) continue; // Discard such field from form
|
||||
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
//if ($key == 'targetsrcfile3') break; // key used for break on second column
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
$alreadyoutput = 1;
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if ($alreadyoutput)
|
||||
{
|
||||
//if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Common attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
|
@ -390,7 +346,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
if (empty($reshook))
|
||||
{
|
||||
// Send
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'."\n";
|
||||
|
||||
if ($user->rights->mymodule->write)
|
||||
{
|
||||
|
|
@ -429,15 +385,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
// Documents
|
||||
$comref = dol_sanitizeFileName($object->ref);
|
||||
/*$comref = dol_sanitizeFileName($object->ref);
|
||||
$relativepath = $comref . '/' . $comref . '.pdf';
|
||||
$filedir = $conf->mymodule->dir_output . '/' . $comref;
|
||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||
$genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('mymodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
|
||||
*/
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ while ($i < min($num, $limit))
|
|||
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 == 'ref' || $key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
|
||||
elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3);
|
||||
else print $obj->$key;
|
||||
print '</td>';
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ class Website extends CommonObject
|
|||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'website';
|
||||
/**
|
||||
* @var string String with name of icon for websiteaccount. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'globe';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
|
@ -648,21 +652,23 @@ class Website extends CommonObject
|
|||
$result = '';
|
||||
$companylink = '';
|
||||
|
||||
$label = '<u>' . $langs->trans("MyModule") . '</u>';
|
||||
$label = '<u>' . $langs->trans("WebSite") . '</u>';
|
||||
$label.= '<div width="100%">';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
$label.= '<b>' . $langs->trans('Nom') . ':</b> ' . $this->ref;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
|
||||
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
|
||||
$link.= '>';
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
|
||||
$linkstart.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
|
||||
$linkstart.= '>';
|
||||
$linkend='</a>';
|
||||
|
||||
$linkstart = $linkend = '';
|
||||
|
||||
if ($withpicto)
|
||||
{
|
||||
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
}
|
||||
$result.= $link . $this->ref . $linkend;
|
||||
$result.= $linkstart . $this->ref . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,23 +43,21 @@ class WebsiteAccount extends CommonObject
|
|||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'websiteaccount';
|
||||
|
||||
/**
|
||||
* @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 = 0;
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for websiteaccount
|
||||
* @var string String with name of icon for websiteaccount. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'object_globe';
|
||||
public $picto = 'globe';
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format.
|
||||
* 'label' the translation key.
|
||||
* 'enabled' is a condition when the field must be managed.
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
|
|
@ -284,9 +282,12 @@ class WebsiteAccount extends CommonObject
|
|||
$result = '';
|
||||
$companylink = '';
|
||||
|
||||
$this->ref = $this->login;
|
||||
|
||||
$label = '<u>' . $langs->trans("WebsiteAccount") . '</u>';
|
||||
$label.= '<br>';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
$label.= '<b>' . $langs->trans('Login') . ':</b> ' . $this->ref;
|
||||
//$label.= '<b>' . $langs->trans('WebSite') . ':</b> ' . $this->ref;
|
||||
|
||||
$url = dol_buildpath('/website/websiteaccount_card.php',1).'?id='.$this->id;
|
||||
|
||||
|
|
@ -317,7 +318,7 @@ class WebsiteAccount extends CommonObject
|
|||
|
||||
if ($withpicto)
|
||||
{
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
}
|
||||
$result.= $linkstart . $this->ref . $linkend;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ class WebsitePage extends CommonObject
|
|||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public $picto = 'label';
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
@ -408,17 +412,19 @@ class WebsitePage extends CommonObject
|
|||
$label.= '<div width="100%">';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
|
||||
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
|
||||
$link.= '>';
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
|
||||
$linkstart.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
|
||||
$linkstart.= '>';
|
||||
$linkend='</a>';
|
||||
|
||||
$linkstart = $linkend = '';
|
||||
|
||||
if ($withpicto)
|
||||
{
|
||||
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
}
|
||||
$result.= $link . $this->ref . $linkend;
|
||||
$result.= $linkstart . $this->ref . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
85
htdocs/website/lib/websiteaccount.lib.php
Normal file
85
htdocs/website/lib/websiteaccount.lib.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/* Copyright (C) 2017 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/website/lib/websiteaccount.lib.php
|
||||
* \ingroup website
|
||||
* \brief Library files with common functions for WebsiteAccount
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare array of tabs for WebsiteAccount
|
||||
*
|
||||
* @param WebsiteAccount $object WebsiteAccount
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function websiteaccountPrepareHead($object)
|
||||
{
|
||||
global $db, $langs, $conf;
|
||||
|
||||
$langs->load("monmodule@monmodule");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = dol_buildpath("/website/websiteaccount_card.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
|
||||
{
|
||||
$nbNote = 0;
|
||||
if(!empty($object->fields['note_private'])) $nbNote++;
|
||||
if(!empty($object->fields['note_public'])) $nbNote++;
|
||||
$head[$h][0] = dol_buildpath('/monmodule/websiteaccount_note.php', 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
/*
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->monmodule->dir_output . "/websiteaccount/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = dol_buildpath("/monmodule/websiteaccount_document.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = dol_buildpath("/monmodule/websiteaccount_agenda.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
*/
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
//$this->tabs = array(
|
||||
// 'entity:+tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__'
|
||||
//); // to add new tab
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'websiteaccount@website');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
*
|
||||
* 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
|
||||
|
|
@ -53,8 +52,8 @@ if (! $res) die("Include of main fails");
|
|||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
|
||||
dol_include_once('/website/class/websiteaccount.class.php');
|
||||
//dol_include_once('/website/lib/websiteaccount.lib.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/website/class/websiteaccount.class.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("website","other"));
|
||||
|
|
@ -259,7 +258,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' .dol_buildpath('/website/websiteaccount_list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback='';
|
||||
if ($socid) $linkback = '<a href="' .DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
if ($fk_website) $linkback = '<a href="' .DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
/*
|
||||
|
|
@ -314,52 +315,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">'."\n";
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (abs($val['visible']) != 1) continue; // Discard such field from form
|
||||
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
//if ($key == 'targetsrcfile3') break; // key used for break on second column
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
$alreadyoutput = 1;
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if ($alreadyoutput)
|
||||
{
|
||||
//if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Common attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
|
@ -384,7 +341,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
if (empty($reshook))
|
||||
{
|
||||
// Send
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n";
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'."\n";
|
||||
|
||||
if ($user->rights->website->write)
|
||||
{
|
||||
|
|
@ -423,29 +380,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
// Documents
|
||||
$comref = dol_sanitizeFileName($object->ref);
|
||||
/*$comref = dol_sanitizeFileName($object->ref);
|
||||
$relativepath = $comref . '/' . $comref . '.pdf';
|
||||
$filedir = $conf->website->dir_output . '/' . $comref;
|
||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||
$genallowed = $user->rights->website->read; // If you can read, you can build the PDF to read content
|
||||
$delallowed = $user->rights->website->create; // If you can create/edit, you can remove a file on card
|
||||
print $formfile->showdocuments('website', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
|
||||
*/
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('websiteaccount'));
|
||||
/*$linktoelem = $form->showLinkToObjectBlock($object, null, array('websiteaccount'));
|
||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||
|
||||
*/
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
$MAXEVENT = 10;
|
||||
|
||||
// List of actions on element
|
||||
/*
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT);
|
||||
*/
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user