Merge pull request #2850 from aspangaro/develop-adherent

Members: Review (Add background in create mode / Add button cancel / move type tab in member.lib)
This commit is contained in:
Laurent Destailleur 2015-05-20 15:24:09 +02:00
commit 4d35939d77
4 changed files with 155 additions and 108 deletions

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2013 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2012-2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -45,6 +46,7 @@ $langs->load("users");
$langs->load('other'); $langs->load('other');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$cancel=GETPOST('cancel');
$backtopage=GETPOST('backtopage','alpha'); $backtopage=GETPOST('backtopage','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$rowid=GETPOST('rowid','int'); $rowid=GETPOST('rowid','int');
@ -113,7 +115,8 @@ $hookmanager->initHooks(array('membercard','globalcard'));
/* /*
* Actions * Actions
*/ */
if ($cancel) $action='';
$parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas); $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 $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'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -725,7 +728,7 @@ else
{ {
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Creation card */ /* Creation mode */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
$object->canvas=$canvas; $object->canvas=$canvas;
@ -779,7 +782,10 @@ else
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
dol_fiche_head('');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tbody>';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
@ -868,13 +874,13 @@ else
print '</td></tr>'; print '</td></tr>';
} }
// Tel pro // Pro phone
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone','alpha')?GETPOST('phone','alpha'):$object->phone).'"></td></tr>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone','alpha')?GETPOST('phone','alpha'):$object->phone).'"></td></tr>';
// Tel perso // Personal phone
print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso','alpha')?GETPOST('phone_perso','alpha'):$object->phone_perso).'"></td></tr>'; print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso','alpha')?GETPOST('phone_perso','alpha'):$object->phone_perso).'"></td></tr>';
// Tel mobile // Mobile phone
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile','alpha')?GETPOST('phone_mobile','alpha'):$object->phone_mobile).'"></td></tr>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile','alpha')?GETPOST('phone_mobile','alpha'):$object->phone_mobile).'"></td></tr>';
// Skype // Skype
@ -888,7 +894,7 @@ else
$form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
print "</td></tr>\n"; print "</td></tr>\n";
// Profil public // Public profil
print "<tr><td>".$langs->trans("Public")."</td><td>\n"; print "<tr><td>".$langs->trans("Public")."</td><td>\n";
print $form->selectyesno("public",$object->public,1); print $form->selectyesno("public",$object->public,1);
print "</td></tr>\n"; print "</td></tr>\n";
@ -915,21 +921,25 @@ else
print $form->select_dolusers($object->user_id,'userid',1); print $form->select_dolusers($object->user_id,'userid',1);
print '</td></tr>'; print '</td></tr>';
*/ */
print '<tbody>';
print "</table>\n"; print "</table>\n";
print '<br>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("AddMember").'"></div>'; dol_fiche_end();
print '<div class="center">';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
print '</div>';
print "</form>\n"; print "</form>\n";
} }
if ($action == 'edit') if ($action == 'edit')
{ {
/******************************************** /********************************************
* *
* Fiche en mode edition * Edition mode
* *
********************************************/ ********************************************/
@ -1027,6 +1037,7 @@ else
print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td>"; print "</td>";
// Photo // Photo
print '<td align="center" class="hideonsmartphone" valign="middle" width="25%" rowspan="'.$rowspan.'">'; print '<td align="center" class="hideonsmartphone" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $form->showphoto('memberphoto',$object)."\n"; print $form->showphoto('memberphoto',$object)."\n";
@ -1107,13 +1118,13 @@ else
print '</td></tr>'; print '</td></tr>';
} }
// Tel // Pro phone
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?$_POST["phone"]:$object->phone).'"></td></tr>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?$_POST["phone"]:$object->phone).'"></td></tr>';
// Tel perso // Personal phone
print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$object->phone_perso).'"></td></tr>'; print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$object->phone_perso).'"></td></tr>';
// Tel mobile // Mobile phone
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$object->phone_mobile).'"></td></tr>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$object->phone_mobile).'"></td></tr>';
// Skype // Skype
@ -1127,7 +1138,7 @@ else
$form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
print "</td></tr>\n"; print "</td></tr>\n";
// Profil public // Public profil
print "<tr><td>".$langs->trans("Public")."</td><td>\n"; print "<tr><td>".$langs->trans("Public")."</td><td>\n";
print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1); print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1);
print "</td></tr>\n"; print "</td></tr>\n";
@ -1171,7 +1182,7 @@ else
print '<br><div class="center">'; print '<br><div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -1183,7 +1194,7 @@ else
{ {
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Mode affichage */ /* View mode */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -1204,8 +1215,8 @@ else
/* /*
* Affichage onglets * Show tabs
*/ */
$head = member_prepare_head($object); $head = member_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); 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); 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') if ($action == 'resign')
{ {
$langs->load("mails"); $langs->load("mails");
@ -1536,9 +1547,8 @@ else
/* /*
* Barre d'actions * Hotbar
* */
*/
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
@ -1553,7 +1563,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</font></div>'; print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</font></div>';
} }
// Valider // Validate
if ($object->statut == -1) if ($object->statut == -1)
{ {
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
@ -1566,7 +1576,7 @@ else
} }
} }
// Reactiver // Reactivate
if ($object->statut == 0) if ($object->statut == 0)
{ {
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
@ -1597,7 +1607,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>"; print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
} }
// Resilier // Terminate
if ($object->statut >= 1) if ($object->statut >= 1)
{ {
if ($user->rights->adherent->supprimer) if ($user->rights->adherent->supprimer)

View File

@ -3,6 +3,7 @@
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 // Lien nouvelle cotisation si non brouillon et non resilie
@ -908,9 +909,13 @@ if ($rowid > 0)
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">'; print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->societe).'">'; print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->societe).'">';
print "<table class=\"border\" width=\"100%\">\n";
$today=dol_now(); dol_fiche_head('');
print "<table class=\"border\" width=\"100%\">\n";
print '<tbody>';
$today=dol_now();
$datefrom=0; $datefrom=0;
$dateto=0; $dateto=0;
$paymentdate=-1; $paymentdate=-1;
@ -1102,8 +1107,10 @@ if ($rowid > 0)
print $form->textwithpicto($tmp,$helpcontent,1,'help'); print $form->textwithpicto($tmp,$helpcontent,1,'help');
} }
print '</td></tr>'; print '</td></tr>';
print '</tbody>';
print '</table>'; print '</table>';
print '<br>';
dol_fiche_end();
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">'; print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';

View File

@ -4,6 +4,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,6 +27,7 @@
*/ */
require '../main.inc.php'; 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.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.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 // fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); $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_lastname="";
$search_login=""; $search_login="";
@ -79,21 +81,21 @@ if ($action == 'add' && $user->rights->adherent->configurer)
{ {
if ($_POST["button"] != $langs->trans("Cancel")) if ($_POST["button"] != $langs->trans("Cancel"))
{ {
$adht = new AdherentType($db); $object = new AdherentType($db);
$adht->libelle = trim($_POST["libelle"]); $object->libelle = trim($_POST["libelle"]);
$adht->cotisation = trim($_POST["cotisation"]); $object->cotisation = trim($_POST["cotisation"]);
$adht->note = trim($_POST["comment"]); $object->note = trim($_POST["comment"]);
$adht->mail_valid = trim($_POST["mail_valid"]); $object->mail_valid = trim($_POST["mail_valid"]);
$adht->vote = trim($_POST["vote"]); $object->vote = trim($_POST["vote"]);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if ($adht->libelle) if ($object->libelle)
{ {
$id=$adht->create($user); $id=$object->create($user);
if ($id > 0) if ($id > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
@ -101,7 +103,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
} }
else else
{ {
$mesg=$adht->error; $mesg=$object->error;
$action = 'create'; $action = 'create';
} }
} }
@ -117,19 +119,19 @@ if ($action == 'update' && $user->rights->adherent->configurer)
{ {
if ($_POST["button"] != $langs->trans("Cancel")) if ($_POST["button"] != $langs->trans("Cancel"))
{ {
$adht = new AdherentType($db); $object = new AdherentType($db);
$adht->id = $_POST["rowid"]; $object->id = $_POST["rowid"];
$adht->libelle = trim($_POST["libelle"]); $object->libelle = trim($_POST["libelle"]);
$adht->cotisation = trim($_POST["cotisation"]); $object->cotisation = trim($_POST["cotisation"]);
$adht->note = trim($_POST["comment"]); $object->note = trim($_POST["comment"]);
$adht->mail_valid = trim($_POST["mail_valid"]); $object->mail_valid = trim($_POST["mail_valid"]);
$adht->vote = trim($_POST["vote"]); $object->vote = trim($_POST["vote"]);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
$adht->update($user); $object->update($user);
header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]); header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]);
exit; exit;
@ -138,8 +140,8 @@ if ($action == 'update' && $user->rights->adherent->configurer)
if ($action == 'delete' && $user->rights->adherent->configurer) if ($action == 'delete' && $user->rights->adherent->configurer)
{ {
$adht = new AdherentType($db); $object = new AdherentType($db);
$adht->delete($rowid); $object->delete($rowid);
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
@ -161,8 +163,7 @@ llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_
$form=new Form($db); $form=new Form($db);
// Liste of members type // List of members type
if (! $rowid && $action != 'create' && $action != 'edit') if (! $rowid && $action != 'create' && $action != 'edit')
{ {
@ -212,8 +213,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
/* /*
* Barre d'actions * Hotbar
*
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -230,18 +230,22 @@ if (! $rowid && $action != 'create' && $action != 'edit')
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Creation d'un type adherent */ /* Creation mode */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create')
{ {
$adht = new AdherentType($db); $object = new AdherentType($db);
print_fiche_titre($langs->trans("NewMemberType")); print_fiche_titre($langs->trans("NewMemberType"));
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head('');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tbody>';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -260,7 +264,7 @@ if ($action == 'create')
print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 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(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
@ -269,11 +273,14 @@ if ($action == 'create')
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook $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)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print $adht->showOptionals($extrafields,'edit'); print $object->showOptionals($extrafields,'edit');
} }
print '<tbody>';
print "</table>\n"; print "</table>\n";
print '<br><div class="center">'; dol_fiche_end();
print '<div class="center">';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'">';
@ -284,27 +291,21 @@ if ($action == 'create')
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Edition de la fiche */ /* View mode */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($rowid > 0) if ($rowid > 0)
{ {
if ($action != 'edit') if ($action != 'edit')
{ {
$adht = new AdherentType($db); $object = new AdherentType($db);
$adht->fetch($rowid); $object->fetch($rowid);
$adht->fetch_optionals($rowid,$extralabels); $object->fetch_optionals($rowid,$extralabels);
$h=0; $head = member_type_prepare_head($object);
$head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
@ -312,25 +313,25 @@ if ($rowid > 0)
// Ref // Ref
print '<tr><td width="15%">'.$langs->trans("Ref").'</td>'; print '<tr><td width="15%">'.$langs->trans("Ref").'</td>';
print '<td>'; print '<td>';
print $form->showrefnav($adht, 'rowid', $linkback); print $form->showrefnav($object, 'rowid', $linkback);
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td width="15%">'.$langs->trans("Label").'</td><td>'.$adht->libelle.'</td></tr>'; print '<tr><td width="15%">'.$langs->trans("Label").'</td><td>'.$object->libelle.'</td></tr>';
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print yn($adht->cotisation); print yn($object->cotisation);
print '</tr>'; print '</tr>';
print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>'; print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
print yn($adht->vote); print yn($object->vote);
print '</tr>'; print '</tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
print nl2br($adht->note)."</td></tr>"; print nl2br($object->note)."</td></tr>";
print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>';
print nl2br($adht->mail_valid)."</td></tr>"; print nl2br($object->mail_valid)."</td></tr>";
// Other attributes // Other attributes
$parameters=array(); $parameters=array();
@ -338,31 +339,30 @@ if ($rowid > 0)
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
// View extrafields // View extrafields
print $adht->showOptionals($extrafields); print $object->showOptionals($extrafields);
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
/* /*
* Barre d'actions * Hotbar
*
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Edit // Edit
if ($user->rights->adherent->configurer) if ($user->rights->adherent->configurer)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$adht->id.'">'.$langs->trans("Modify").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
} }
// Add // Add
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$adht->id.'">'.$langs->trans("AddMember").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'">'.$langs->trans("AddMember").'</a></div>';
// Delete // Delete
if ($user->rights->adherent->configurer) if ($user->rights->adherent->configurer)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$adht->id.'">'.$langs->trans("DeleteType").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
} }
print "</div>"; print "</div>";
@ -381,7 +381,7 @@ if ($rowid > 0)
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE d.fk_adherent_type = t.rowid "; $sql.= " WHERE d.fk_adherent_type = t.rowid ";
$sql.= " AND d.entity IN (".getEntity().")"; $sql.= " AND d.entity IN (".getEntity().")";
$sql.= " AND t.rowid = ".$adht->id; $sql.= " AND t.rowid = ".$object->id;
if ($sall) if ($sall)
{ {
$sql.= " AND (d.firstname LIKE '%".$sall."%' OR d.lastname LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'"; $sql.= " AND (d.firstname LIKE '%".$sall."%' OR d.lastname LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'";
@ -479,7 +479,7 @@ if ($rowid > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); 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("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("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("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); print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
@ -619,19 +619,20 @@ if ($rowid > 0)
} }
/* ************************************************************************** */
/* */
/* Edition mode */
/* */
/* ************************************************************************** */
if ($action == 'edit') if ($action == 'edit')
{ {
$adht = new AdherentType($db); $object = new AdherentType($db);
$adht->id = $rowid; $object->id = $rowid;
$adht->fetch($rowid); $object->fetch($rowid);
$adht->fetch_optionals($rowid,$extralabels); $object->fetch_optionals($rowid,$extralabels);
$h=0; $head = member_type_prepare_head($object);
$head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
@ -641,24 +642,24 @@ if ($rowid > 0)
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$adht->id.'</td></tr>'; print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="libelle" size="40" value="'.$adht->libelle.'"></td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="libelle" size="40" value="'.$object->libelle.'"></td></tr>';
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("cotisation",$adht->cotisation,1); print $form->selectyesno("cotisation",$object->cotisation,1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>'; print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
print $form->selectyesno("vote",$adht->vote,1); print $form->selectyesno("vote",$object->vote,1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
print '<textarea name="comment" wrap="soft" cols="90" rows="3">'.$adht->note.'</textarea></td></tr>'; print '<textarea name="comment" wrap="soft" cols="90" rows="3">'.$object->note.'</textarea></td></tr>';
print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 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(); $doleditor->Create();
print "</td></tr>"; print "</td></tr>";
@ -668,13 +669,13 @@ if ($rowid > 0)
print '</table>'; print '</table>';
//Extra field // Extra field
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))
{ {
print '<br><br><table class="border" width="100%">'; print '<br><br><table class="border" width="100%">';
foreach($extrafields->attribute_label as $key=>$label) 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 '<tr><td width="30%">'.$label.'</td><td>'; print '<tr><td width="30%">'.$label.'</td><td>';
print $extrafields->showInputField($key,$value); print $extrafields->showInputField($key,$value);
print "</td></tr>\n"; print "</td></tr>\n";

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 $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 * Return array head with list of tabs to view object informations