2
0
forked from Wavyzz/dolibarr

Tab notes and linked files supported by module builder

This commit is contained in:
Laurent Destailleur
2017-09-29 15:44:43 +02:00
parent d2d77d4625
commit b50a0df6fb
3 changed files with 22 additions and 7 deletions

View File

@@ -29,7 +29,7 @@
*/
function myobjectPrepareHead($object)
{
global $langs, $conf;
global $db, $langs, $conf;
$langs->load("mymodule@mymodule");
@@ -40,17 +40,30 @@ function myobjectPrepareHead($object)
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
if (isset($object->fields['note_public']) || isset($object->fields['note_pricate']))
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
{
$head[$h][0] = dol_buildpath("/mymodule/myobject_note.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Notes");
$nbNote = 0;
if(!empty($object->fields['note_private'])) $nbNote++;
if(!empty($object->fields['note_public'])) $nbNote++;
$head[$h][0] = dol_buildpath('/mymodule/myobject_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->mymodule->dir_output . "/myobject/" . 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("/mymodule/myobject_document.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Documents");
$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("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Events");
$head[$h][2] = 'agenda';