From de5a15282cce9965f94f0ada5ae54505a25aa63a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 20 May 2015 06:25:43 +0200 Subject: [PATCH] Adherent review --- htdocs/adherents/card.php | 66 ++++++----- htdocs/adherents/card_subscriptions.php | 15 ++- htdocs/adherents/type.php | 140 ++++++++++++------------ htdocs/core/lib/member.lib.php | 31 +++++- 4 files changed, 146 insertions(+), 106 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 3659f476ca0..100d1e23e74 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Marcos GarcĂ­a * Copyright (C) 2012-2013 Philippe Grand + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -45,6 +46,7 @@ $langs->load("users"); $langs->load('other'); $action=GETPOST('action','alpha'); +$cancel=GETPOST('cancel'); $backtopage=GETPOST('backtopage','alpha'); $confirm=GETPOST('confirm','alpha'); $rowid=GETPOST('rowid','int'); @@ -113,7 +115,8 @@ $hookmanager->initHooks(array('membercard','globalcard')); /* * Actions -*/ + */ +if ($cancel) $action=''; $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -236,7 +239,7 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) + if ($action == 'update' && $cancel='' && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -725,7 +728,7 @@ else { /* ************************************************************************** */ /* */ - /* Creation card */ + /* Creation mode */ /* */ /* ************************************************************************** */ $object->canvas=$canvas; @@ -779,7 +782,10 @@ else print ''; print ''; + dol_fiche_head(''); + print ''; + print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) @@ -868,13 +874,13 @@ else print ''; } - // Tel pro + // Pro phone print ''; - // Tel perso + // Personal phone print ''; - // Tel mobile + // Mobile phone print ''; // Skype @@ -888,7 +894,7 @@ else $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); print "\n"; - // Profil public + // Public profil print "\n"; @@ -915,21 +921,25 @@ else print $form->select_dolusers($object->user_id,'userid',1); print ''; */ - + print ''; print "
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhoneMobile").'
".$langs->trans("Public")."\n"; print $form->selectyesno("public",$object->public,1); print "
\n"; - print '
'; - print '
'; + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; print "\n"; - } if ($action == 'edit') { /******************************************** - * - * Fiche en mode edition + * + * Edition mode * ********************************************/ @@ -1027,6 +1037,7 @@ else print ''.$langs->trans("Nature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print ""; + // Photo print ''; print $form->showphoto('memberphoto',$object)."\n"; @@ -1107,13 +1118,13 @@ else print ''; } - // Tel + // Pro phone print ''.$langs->trans("PhonePro").'phone).'">'; - // Tel perso + // Personal phone print ''.$langs->trans("PhonePerso").'phone_perso).'">'; - // Tel mobile + // Mobile phone print ''.$langs->trans("PhoneMobile").'phone_mobile).'">'; // Skype @@ -1127,7 +1138,7 @@ else $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); print "\n"; - // Profil public + // Public profil print "".$langs->trans("Public")."\n"; print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1); print "\n"; @@ -1171,7 +1182,7 @@ else print '
'; print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -1183,7 +1194,7 @@ else { /* ************************************************************************** */ /* */ - /* Mode affichage */ + /* View mode */ /* */ /* ************************************************************************** */ @@ -1204,8 +1215,8 @@ else /* - * Affichage onglets - */ + * Show tabs + */ $head = member_prepare_head($object); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); @@ -1296,7 +1307,7 @@ else print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); } - // Confirm resiliate + // Confirm terminate if ($action == 'resign') { $langs->load("mails"); @@ -1536,9 +1547,8 @@ else /* - * Barre d'actions - * - */ + * Hotbar + */ print '
'; if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') @@ -1553,7 +1563,7 @@ else print '
'.$langs->trans("Modify").'
'; } - // Valider + // Validate if ($object->statut == -1) { if ($user->rights->adherent->creer) @@ -1566,7 +1576,7 @@ else } } - // Reactiver + // Reactivate if ($object->statut == 0) { if ($user->rights->adherent->creer) @@ -1597,7 +1607,7 @@ else print '
'.$langs->trans("SendCardByMail")."
"; } - // Resilier + // Terminate if ($object->statut >= 1) { if ($user->rights->adherent->supprimer) diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 3761b75f384..dabbf142730 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -3,6 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -707,7 +708,7 @@ if ($rowid > 0) /* - * Barre d'actions + * Hotbar */ // Lien nouvelle cotisation si non brouillon et non resilie @@ -908,9 +909,13 @@ if ($rowid > 0) print ''; print ''; print ''; - print "\n"; - $today=dol_now(); + dol_fiche_head(''); + + print "
\n"; + print ''; + + $today=dol_now(); $datefrom=0; $dateto=0; $paymentdate=-1; @@ -1102,8 +1107,10 @@ if ($rowid > 0) print $form->textwithpicto($tmp,$helpcontent,1,'help'); } print ''; + print ''; print '
'; - print '
'; + + dol_fiche_end(); print '
'; print ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 46f87644399..e830254fd97 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -26,6 +27,7 @@ */ require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -59,7 +61,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); -if (GETPOST('button_removefilter')) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_lastname=""; $search_login=""; @@ -79,21 +81,21 @@ if ($action == 'add' && $user->rights->adherent->configurer) { if ($_POST["button"] != $langs->trans("Cancel")) { - $adht = new AdherentType($db); + $object = new AdherentType($db); - $adht->libelle = trim($_POST["libelle"]); - $adht->cotisation = trim($_POST["cotisation"]); - $adht->note = trim($_POST["comment"]); - $adht->mail_valid = trim($_POST["mail_valid"]); - $adht->vote = trim($_POST["vote"]); + $object->libelle = trim($_POST["libelle"]); + $object->cotisation = trim($_POST["cotisation"]); + $object->note = trim($_POST["comment"]); + $object->mail_valid = trim($_POST["mail_valid"]); + $object->vote = trim($_POST["vote"]); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$adht); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - if ($adht->libelle) + if ($object->libelle) { - $id=$adht->create($user); + $id=$object->create($user); if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -101,7 +103,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) } else { - $mesg=$adht->error; + $mesg=$object->error; $action = 'create'; } } @@ -117,19 +119,19 @@ if ($action == 'update' && $user->rights->adherent->configurer) { if ($_POST["button"] != $langs->trans("Cancel")) { - $adht = new AdherentType($db); - $adht->id = $_POST["rowid"]; - $adht->libelle = trim($_POST["libelle"]); - $adht->cotisation = trim($_POST["cotisation"]); - $adht->note = trim($_POST["comment"]); - $adht->mail_valid = trim($_POST["mail_valid"]); - $adht->vote = trim($_POST["vote"]); + $object = new AdherentType($db); + $object->id = $_POST["rowid"]; + $object->libelle = trim($_POST["libelle"]); + $object->cotisation = trim($_POST["cotisation"]); + $object->note = trim($_POST["comment"]); + $object->mail_valid = trim($_POST["mail_valid"]); + $object->vote = trim($_POST["vote"]); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$adht); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - $adht->update($user); + $object->update($user); header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]); exit; @@ -138,8 +140,8 @@ if ($action == 'update' && $user->rights->adherent->configurer) if ($action == 'delete' && $user->rights->adherent->configurer) { - $adht = new AdherentType($db); - $adht->delete($rowid); + $object = new AdherentType($db); + $object->delete($rowid); header("Location: ".$_SERVER["PHP_SELF"]); exit; } @@ -161,8 +163,7 @@ llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_ $form=new Form($db); -// Liste of members type - +// List of members type if (! $rowid && $action != 'create' && $action != 'edit') { @@ -212,8 +213,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') /* - * Barre d'actions - * + * Hotbar */ print '
'; @@ -230,12 +230,12 @@ if (! $rowid && $action != 'create' && $action != 'edit') /* ************************************************************************** */ /* */ -/* Creation d'un type adherent */ +/* Creation mode */ /* */ /* ************************************************************************** */ if ($action == 'create') { - $adht = new AdherentType($db); + $object = new AdherentType($db); print_fiche_titre($langs->trans("NewMemberType")); @@ -264,7 +264,7 @@ if ($action == 'create') print ''.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid',$adht->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,90); + $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,90); $doleditor->Create(); print ''; @@ -273,7 +273,7 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $adht->showOptionals($extrafields,'edit'); + print $object->showOptionals($extrafields,'edit'); } print ''; print "\n"; @@ -291,27 +291,21 @@ if ($action == 'create') /* ************************************************************************** */ /* */ -/* Edition de la fiche */ +/* View mode */ /* */ /* ************************************************************************** */ if ($rowid > 0) { if ($action != 'edit') { - $adht = new AdherentType($db); - $adht->fetch($rowid); - $adht->fetch_optionals($rowid,$extralabels); + $object = new AdherentType($db); + $object->fetch($rowid); + $object->fetch_optionals($rowid,$extralabels); - $h=0; - - $head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id; - $head[$h][1] = $langs->trans("Card"); - $head[$h][2] = 'card'; - $h++; + $head = member_type_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); - print ''; $linkback = ''.$langs->trans("BackToList").''; @@ -319,25 +313,25 @@ if ($rowid > 0) // Ref print ''; print ''; // Label - print ''; + print ''; print ''; print ''; print '"; + print nl2br($object->note).""; print '"; + print nl2br($object->mail_valid).""; // Other attributes $parameters=array(); @@ -345,31 +339,30 @@ if ($rowid > 0) if (empty($reshook) && ! empty($extrafields->attribute_label)) { // View extrafields - print $adht->showOptionals($extrafields); + print $object->showOptionals($extrafields); } print '
'.$langs->trans("Ref").''; - print $form->showrefnav($adht, 'rowid', $linkback); + print $form->showrefnav($object, 'rowid', $linkback); print '
'.$langs->trans("Label").''.$adht->libelle.'
'.$langs->trans("Label").''.$object->libelle.'
'.$langs->trans("SubscriptionRequired").''; - print yn($adht->cotisation); + print yn($object->cotisation); print '
'.$langs->trans("VoteAllowed").''; - print yn($adht->vote); + print yn($object->vote); print '
'.$langs->trans("Description").''; - print nl2br($adht->note)."
'.$langs->trans("WelcomeEMail").''; - print nl2br($adht->mail_valid)."
'; print '
'; /* - * Barre d'actions - * + * Hotbar */ print '
'; // Edit if ($user->rights->adherent->configurer) { - print ''; + print ''; } // Add - print ''; + print ''; // Delete if ($user->rights->adherent->configurer) { - print ''; + print ''; } print "
"; @@ -388,7 +381,7 @@ if ($rowid > 0) $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_adherent_type = t.rowid "; $sql.= " AND d.entity IN (".getEntity().")"; - $sql.= " AND t.rowid = ".$adht->id; + $sql.= " AND t.rowid = ".$object->id; if ($sall) { $sql.= " AND (d.firstname LIKE '%".$sall."%' OR d.lastname LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'"; @@ -486,7 +479,7 @@ if ($rowid > 0) print ''; print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Nature"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); @@ -626,19 +619,20 @@ if ($rowid > 0) } + /* ************************************************************************** */ + /* */ + /* Edition mode */ + /* */ + /* ************************************************************************** */ + if ($action == 'edit') { - $adht = new AdherentType($db); - $adht->id = $rowid; - $adht->fetch($rowid); - $adht->fetch_optionals($rowid,$extralabels); + $object = new AdherentType($db); + $object->id = $rowid; + $object->fetch($rowid); + $object->fetch_optionals($rowid,$extralabels); - $h=0; - - $head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id; - $head[$h][1] = $langs->trans("Card"); - $head[$h][2] = 'card'; - $h++; + $head = member_type_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); @@ -648,24 +642,24 @@ if ($rowid > 0) print ''; print ''; - print ''; + print ''; - print ''; + print ''; print ''; print ''; print ''; + print ''; print '"; @@ -675,13 +669,13 @@ if ($rowid > 0) print '
'.$langs->trans("Ref").''.$adht->id.'
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; - print $form->selectyesno("cotisation",$adht->cotisation,1); + print $form->selectyesno("cotisation",$object->cotisation,1); print '
'.$langs->trans("VoteAllowed").''; - print $form->selectyesno("vote",$adht->vote,1); + print $form->selectyesno("vote",$object->vote,1); print '
'.$langs->trans("Description").''; - print '
'.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid',$adht->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,90); + $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,90); $doleditor->Create(); print "
'; - //Extra field + // Extra field if (empty($reshook) && ! empty($extrafields->attribute_label)) { print '

'; foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($adht->array_options['options_'.$key])?$adht->array_options['options_'.$key]:'')); + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); print '\n"; diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 19e9f08e94d..695c3d65629 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -107,6 +108,34 @@ function member_prepare_head(Adherent $object) return $head; } +/** + * Return array head with list of tabs to view object informations + * + * @param Adherent $object Member + * @return array head + */ +function member_type_prepare_head(AdherentType $object) +{ + global $langs, $conf, $user; + + $h=0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype','remove'); + + return $head; +} /** * Return array head with list of tabs to view object informations
'.$label.''; print $extrafields->showInputField($key,$value); print "