From e6c93424ce47ae223f012b2caf43636cf874d063 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 May 2013 15:41:59 +0200 Subject: [PATCH] Qual: Normalized tabs --- htdocs/contact/fiche.php | 44 --------- htdocs/contact/note.php | 169 ++++++++++++++++++++++++++++++++ htdocs/core/lib/contact.lib.php | 7 ++ htdocs/core/tpl/notes.tpl.php | 5 +- 4 files changed, 179 insertions(+), 46 deletions(-) create mode 100644 htdocs/contact/note.php diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index abb19b2cc91..94e8fadf3bf 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -504,22 +504,6 @@ else print $form->selectarray('priv',$selectarray,(isset($_POST["priv"])?$_POST["priv"]:$object->priv),0); print ''; - // Note Public - print ''.$langs->trans("NotePublic").''; - print ''; - $doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); - print $doleditor->Create(1); - //print ''; - print ''; - - // Note Private - print ''.$langs->trans("NotePrivate").''; - print ''; - $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); - print $doleditor->Create(1); - //print ''; - print ''; - // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -721,24 +705,6 @@ else print $form->selectarray('priv',$selectarray,$object->priv,0); print ''; - // Note Public - print ''.$langs->trans("NotePublic").''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); - print $doleditor->Create(1); - // print ''; - print ''; - - // Note Private - print ''.$langs->trans("NotePrivate").''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); - print $doleditor->Create(1); - // print ''; - print ''; - // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -938,16 +904,6 @@ else print $object->LibPubPriv($object->priv); print ''; - // Note Public - print ''.$langs->trans("NotePublic").''; - print nl2br($object->note_public); - print ''; - - // Note Private - print ''.$langs->trans("NotePrivate").''; - print nl2br($object->note_private); - print ''; - // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php new file mode 100644 index 00000000000..c876c67fe01 --- /dev/null +++ b/htdocs/contact/note.php @@ -0,0 +1,169 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2013 Florian Henry + * + * 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 . + */ + +/** + * \file htdocs/contact/note.php + * \brief Tab for notes on contact + * \ingroup societe + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + +$action = GETPOST('action'); + +$langs->load("companies"); + +// Security check +$id = GETPOST('id','int'); +if ($user->societe_id) $id=$user->societe_id; +$result = restrictedArea($user, 'societe', $id, '&societe'); + +$object = new Contact($db); +if ($id > 0) $object->fetch($id); + +/* + * Actions + */ + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ +if ($action == 'setnote_public' && $user->rights->societe->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); + if ($result < 0) setEventMessage($object->error,'errors'); +} + +else if ($action == 'setnote_private' && $user->rights->societe->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); + if ($result < 0) setEventMessage($object->error,'errors'); +} + +/* + * View + */ + +$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + +$form = new Form($db); + +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$title,$help_url); + +if ($id > 0) +{ + /* + * Affichage onglets + */ + if (! empty($conf->notification->enabled)) $langs->load("mails"); + + $head = contact_prepare_head($object); + + dol_fiche_head($head, 'note', $title,0,'contact'); + + + print '
'; + print ''; + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Name + print ''; + print ''; + + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + + print ''; + } + + else + { + print ''; + } + } + + // Civility + print ''; + + // Date To Birth + print ''; + if (! empty($object->birthday)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + print ''; + } + else + { + print '"; + } + print ""; + + print "
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback); + print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); + + print '   '; + //var_dump($birthdatearray); + $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; + $agemonth=convertSecondToTime($now-$object->birthday,'month')-1; + if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + + + print '   -   '; + if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); + else print $langs->trans("BirthdayAlertOff"); + print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown")."
"; + + print '
'; + + $colwidth='20'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + + dol_fiche_end(); +} + +llxFooter(); +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index b81b47ca198..bbbce42315b 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -66,6 +66,13 @@ function contact_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'contact'); + // Notes + $head[$h][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Note"); + $head[$h][2] = 'note'; + $h++; + + // Info $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index e0acf0489e8..4f1578e72f1 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -14,7 +14,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ $module = $object->element; @@ -26,14 +25,16 @@ $permission=(isset($permission)?$permission:(isset($user->rights->$module->creer $moreparam=(isset($moreparam)?$moreparam:''); // Special cases -if ($module == 'propal') { $permission=$user->rights->propale->creer;} +if ($module == 'propal') { $permission=$user->rights->propale->creer;} elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;} elseif ($module == 'project') { $permission=$user->rights->projet->creer;} elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;} elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;} elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;} elseif ($module == 'societe') { $permission=$user->rights->societe->creer;} +elseif ($module == 'contact') { $permission=$user->rights->societe->creer;} elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;} +//else dol_print_error('','Bad value '.$module.' for param module'); if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:100'; else $typeofdata='textarea:12:100';