From 4ae60284fb95c6f6b2438660f2032c1011f588db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jul 2017 00:00:08 +0200 Subject: [PATCH 1/3] Debug modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 2 +- .../template/class/myobject.class.php | 16 ++++++++-------- .../modulebuilder/template/myobject_list.php | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 457b6fd3fcd..c2f267c20ee 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -25,7 +25,7 @@ EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files relat DangerZone=Danger zone BuildPackage=Build package/documentation BuildDocumentation=Build documentation -ModuleIsNotActive=This module was not activated yet. Ggo into %s to make it live or click here: +ModuleIsNotActive=This module was not activated yet. Go into %s to make it live or click here: ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description EditorName=Name of editor diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index b3c7a99d24e..f75e40f2730 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -74,7 +74,8 @@ class MyObject extends CommonObject * @var array Array with all fields and their property */ public $fields=array( - 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>true, 'index'=>true, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'index'=>true, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>true, 'index'=>true, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), 'qty' =>array('type'=>'double(24,8)', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1), @@ -84,8 +85,8 @@ class MyObject extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>true, 'position'=>1000, 'nullifempty'=>1), ); // END MODULEBUILDER PROPERTIES - - + + // If this object has a subtable with lines @@ -129,11 +130,10 @@ class MyObject extends CommonObject * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param string $option On what the link point to * @param int $notooltip 1=Disable tooltip - * @param int $maxlen Max length of visible user name * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='') { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -144,18 +144,18 @@ class MyObject extends CommonObject $result = ''; $companylink = ''; - $label = '' . $langs->trans("MyModule") . ''; + $label = '' . $langs->trans("MyObject") . ''; $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - $url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id; + $url = $url = dol_buildpath('/mymodule/m_card.php',1).'?id='.$this->id; $linkclose=''; if (empty($notooltip)) { if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowProject"); + $label=$langs->trans("ShowMyObject"); $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index b0f95ba6ff4..fb26f9dde0e 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -18,9 +18,8 @@ /** * \file htdocs/modulebuilder/template/myobject_list.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example of a php page - * Put here some comments + * \ingroup mymodule + * \brief List page for monmodule */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); @@ -472,6 +471,13 @@ while ($i < min($num, $limit)) $obj = $db->fetch_object($resql); if ($obj) { + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + // Show here line of result print ''; foreach($object->fields as $key => $val) @@ -480,11 +486,13 @@ while ($i < min($num, $limit)) $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 ''; if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); - elseif ($key == 'status') print ''.$object->getLibStatut(3).''; + elseif ($key == 'ref') print $object->getNomUrl(1); + elseif ($key == 'status') print $object->getLibStatut(3); else print $obj->$key; print ''; if (! $i) $totalarray['nbfield']++; @@ -514,7 +522,7 @@ while ($i < min($num, $limit)) { if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; - } + } } } } @@ -529,6 +537,7 @@ while ($i < min($num, $limit)) $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 ''; From b50236da4c3b384db86a43e0bef952224f526ae2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jul 2017 00:07:17 +0200 Subject: [PATCH 2/3] Fix dir created at install --- htdocs/install/step1.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index a8d17388d41..bf2caf1b255 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -423,13 +423,11 @@ if (! $error && $db->connected && $action == "set") // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification $dir[0] = $main_data_dir."/mycompany"; $dir[1] = $main_data_dir."/users"; - $dir[2] = $main_data_dir."/custom"; - $dir[3] = $main_data_dir."/facture"; - $dir[4] = $main_data_dir."/propale"; - $dir[5] = $main_data_dir."/ficheinter"; - $dir[6] = $main_data_dir."/produit"; - $dir[7] = $main_data_dir."/doctemplates"; - $dir[7] = $main_data_dir."/extensions"; + $dir[2] = $main_data_dir."/facture"; + $dir[3] = $main_data_dir."/propale"; + $dir[4] = $main_data_dir."/ficheinter"; + $dir[5] = $main_data_dir."/produit"; + $dir[6] = $main_data_dir."/doctemplates"; // Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas $num=count($dir); From e571616d524c0ee66c8a66b7a0629f9a2960ebc8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jul 2017 00:21:01 +0200 Subject: [PATCH 3/3] Debug modulebuilder --- htdocs/modulebuilder/template/myobject_card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 9b3029c659d..b5de4c0226c 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -129,8 +129,8 @@ if (empty($reshook)) { foreach ($object->fields as $key => $val) { - if (in_array($key, array('entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields - + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields + $object->$key=GETPOST($key,'alpha'); if ($val['notnull'] && $object->$key == '') { @@ -169,7 +169,7 @@ if (empty($reshook)) foreach ($object->fields as $key => $val) { $object->$key=GETPOST($key,'alpha'); - if (in_array($key, array('entity', 'datec', 'tms'))) continue; + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; if ($val['notnull'] && $object->$key == '') { $error++;