From 28eb9d07b292f256304f41a4a83da2ea1fb9e97b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 20 Jul 2013 09:07:10 +0200 Subject: [PATCH] Task 149 : add # of notes and doc in tab + have always last 3 tabs be notes, doc and info --- htdocs/core/lib/company.lib.php | 36 +++++++++++++++---------------- htdocs/core/lib/contract.lib.php | 10 ++++++++- htdocs/core/lib/fichinter.lib.php | 8 +++++++ htdocs/core/lib/invoice.lib.php | 12 +++++++---- htdocs/core/lib/order.lib.php | 22 +++++++++++-------- htdocs/core/lib/propal.lib.php | 12 +++++++---- 6 files changed, 64 insertions(+), 36 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 774e16e6e68..b114eecf0ad 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -86,7 +86,24 @@ function societe_prepare_head($object) if ($user->societe_id == 0) { - // Notes + if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'consumption'; + $h++; + } + + // Notifications + if (! empty($conf->notification->enabled)) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Notifications"); + $head[$h][2] = 'notify'; + $h++; + } + + // Notes $nbNote = 0; if(!empty($object->note_private)) $nbNote++; if(!empty($object->note_public)) $nbNote++; @@ -96,14 +113,6 @@ function societe_prepare_head($object) $head[$h][2] = 'note'; $h++; - if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Referers"); - $head[$h][2] = 'consumption'; - $h++; - } - // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; @@ -113,15 +122,6 @@ function societe_prepare_head($object) if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; $head[$h][2] = 'document'; $h++; - - // Notifications - if (! empty($conf->notification->enabled)) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Notifications"); - $head[$h][2] = 'notify'; - $h++; - } } // Log diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index f4359e17b6b..a116f2d851f 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -55,14 +55,22 @@ function contract_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; - $head[$h][1] = $langs->trans("Note"); + $head[$h][1] = $langs->trans("Notes"); + if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; $head[$h][2] = 'note'; $h++; } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files')); $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); + if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 6a3187fb5fb..4b437d46e34 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -67,14 +67,22 @@ function fichinter_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); + if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; $head[$h][2] = 'note'; $h++; } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files')); $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); + if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 75b1bc95d00..3ad2787826f 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -74,18 +74,22 @@ function facture_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); + if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; $head[$h][2] = 'note'; $h++; } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files')); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; - /*$filesdir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($fac->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listoffiles=dol_dir_list($filesdir,'files',1); - $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ $head[$h][1] = $langs->trans('Documents'); + if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index b7de009663e..25fa766aa3d 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -82,22 +82,26 @@ function commande_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'order'); - $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; - /*$filesdir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($commande->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listoffiles=dol_dir_list($filesdir,'files',1); - $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ - $head[$h][1] = $langs->trans('Documents'); - $head[$h][2] = 'documents'; - $h++; - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); + if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; $head[$h][2] = 'note'; $h++; } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files')); + $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; + $head[$h][2] = 'documents'; + $h++; $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index db011bf3fad..34ab3bb5355 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -78,18 +78,22 @@ function propal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); + if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')'; $head[$h][2] = 'note'; $h++; } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files')); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; - /*$filesdir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($propal->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listoffiles=dol_dir_list($filesdir,'files',1); - $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ $head[$h][1] = $langs->trans('Documents'); + if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; $head[$h][2] = 'document'; $h++;