Fix: Missing extrafields

New: Can resiliate/edit member status from list.
This commit is contained in:
Laurent Destailleur 2012-05-09 16:03:15 +02:00
parent c8d72ef92a
commit f995d0d9cb
4 changed files with 101 additions and 55 deletions

View File

@ -14,6 +14,7 @@ For users:
- New: Add bank account on payment list of invoice card. - New: Add bank account on payment list of invoice card.
- New: Cloning project allow to clones task, notes, files, contacts. - New: Cloning project allow to clones task, notes, files, contacts.
- New: Enhance default style. - New: Enhance default style.
- New: Can edit and resiliate member status from list.
For developers: For developers:
- New: A module can overwrite templates parts. - New: A module can overwrite templates parts.

View File

@ -43,6 +43,7 @@ $langs->load("users");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$backtopage=GETPOST('backtopage','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$rowid=GETPOST('rowid','int'); $rowid=GETPOST('rowid','int');
$typeid=GETPOST('typeid','int'); $typeid=GETPOST('typeid','int');
@ -331,6 +332,12 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$rowid=$object->id; $rowid=$object->id;
$action=''; $action='';
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
} }
else else
{ {
@ -505,8 +512,16 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confir
$result=$object->delete($rowid); $result=$object->delete($rowid);
if ($result > 0) if ($result > 0)
{ {
Header("Location: liste.php"); if (! empty($backtopage))
exit; {
header("Location: ".$backtopage);
exit;
}
else
{
Header("Location: liste.php");
exit;
}
} }
else else
{ {
@ -548,37 +563,45 @@ if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm ==
} }
} }
if ($user->rights->adherent->supprimer && $action == 'confirm_resign' && $confirm == 'yes') if ($user->rights->adherent->supprimer && $action == 'confirm_resign')
{ {
$adht = new AdherentType($db); if ($confirm == 'yes')
$adht->fetch($object->typeid); {
$adht = new AdherentType($db);
$adht->fetch($object->typeid);
$result=$object->resiliate($user); $result=$object->resiliate($user);
if ($result >= 0 && ! count($object->errors)) if ($result >= 0 && ! count($object->errors))
{ {
if ($object->email && $_POST["send_mail"]) if ($object->email && $_POST["send_mail"])
{ {
$result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
} }
if ($result < 0) if ($result < 0)
{ {
$errmsg.=$object->error; $errmsg.=$object->error;
} }
// supprime l'utilisateur des divers abonnements .. // supprime l'utilisateur des divers abonnements ..
if ($object->del_to_abo() < 0) if ($object->del_to_abo() < 0)
{ {
// error // error
$errmsg.=$langs->trans("FaildToRemoveFromMailmanList").': '.$object->error."<br>\n"; $errmsg.=$langs->trans("FaildToRemoveFromMailmanList").': '.$object->error."<br>\n";
} }
} }
else else
{ {
if ($object->error) $errmsg=$object->error; if ($object->error) $errmsg=$object->error;
else $errmsgs=$object->errors; else $errmsgs=$object->errors;
$action=''; $action='';
} }
}
if (! empty($backtopage) && ! $errmsg)
{
header("Location: ".$backtopage);
exit;
}
} }
if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes')
@ -819,8 +842,8 @@ if ($action == 'edit')
$res=$object->fetch($rowid); $res=$object->fetch($rowid);
if ($res < 0) { dol_print_error($db,$object->error); exit; } if ($res < 0) { dol_print_error($db,$object->error); exit; }
//$res=$object->fetch_optionals($object->id,$extralabels); $res=$object->fetch_optionals($object->id,$extralabels);
//if ($res < 0) { dol_print_error($db); exit; } if ($res < 0) { dol_print_error($db); exit; }
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
@ -874,6 +897,7 @@ if ($action == 'edit')
print '<input type="hidden" name="action" value="update" />'; print '<input type="hidden" name="action" value="update" />';
print '<input type="hidden" name="rowid" value="'.$rowid.'" />'; print '<input type="hidden" name="rowid" value="'.$rowid.'" />';
print '<input type="hidden" name="statut" value="'.$object->statut.'" />'; print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
print '<input type="hidden" name="backtopage" value="'.((! empty($backtopage) && $backtopage != '1') ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -1052,7 +1076,6 @@ if ($rowid && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
//$object = new Adherent($db);
$res=$object->fetch($rowid); $res=$object->fetch($rowid);
if ($res < 0) { dol_print_error($db,$object->error); exit; } if ($res < 0) { dol_print_error($db,$object->error); exit; }
$res=$object->fetch_optionals($object->id,$extralabels); $res=$object->fetch_optionals($object->id,$extralabels);
@ -1182,15 +1205,18 @@ if ($rowid && $action != 'edit')
// Cree un tableau formulaire // Cree un tableau formulaire
$formquestion=array(); $formquestion=array();
if ($object->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false')); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false'));
$ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ((! empty($backtopage) && $backtopage != '1') ? $backtopage : $_SERVER["HTTP_REFERER"]));
$ret=$form->form_confirm("fiche.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirm remove member // Confirm remove member
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",'',0,1); $formquestion=array();
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ((! empty($backtopage) && $backtopage != '1') ? $backtopage : $_SERVER["HTTP_REFERER"]));
$ret=$form->form_confirm("fiche.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -1199,7 +1225,8 @@ if ($rowid && $action != 'edit')
*/ */
if ($action == 'add_spip') if ($action == 'add_spip')
{ {
$ret=$form->form_confirm("fiche.php?rowid=$rowid","Ajouter dans spip","Etes-vous sur de vouloir ajouter cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_add_spip"); $langs->load("mailmanspip");
$ret=$form->form_confirm("fiche.php?rowid=".$rowid,"Add to spip","Etes-vous sur de vouloir ajouter cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_add_spip");
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -1208,6 +1235,7 @@ if ($rowid && $action != 'edit')
*/ */
if ($action == 'del_spip') if ($action == 'del_spip')
{ {
$langs->load("mailmanspip");
$ret=$form->form_confirm("fiche.php?rowid=$rowid","Supprimer dans spip","Etes-vous sur de vouloir effacer cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_del_spip"); $ret=$form->form_confirm("fiche.php?rowid=$rowid","Supprimer dans spip","Etes-vous sur de vouloir effacer cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_del_spip");
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -1506,7 +1534,7 @@ if ($rowid && $action != 'edit')
} }
// Action SPIP // Action SPIP
if ($conf->global->ADHERENT_USE_SPIP) if ($conf->mailmanspip->enabled && $conf->global->ADHERENT_USE_SPIP)
{ {
$isinspip=$object->is_in_spip(); $isinspip=$object->is_in_spip();
if ($isinspip == 1) if ($isinspip == 1)

View File

@ -31,16 +31,6 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
$langs->load("members"); $langs->load("members");
$langs->load("companies"); $langs->load("companies");
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) { $sortorder="ASC"; }
if (! $sortfield) { $sortfield="d.nom"; }
$action=GETPOST("action"); $action=GETPOST("action");
$filter=GETPOST("filter"); $filter=GETPOST("filter");
$statut=GETPOST("statut"); $statut=GETPOST("statut");
@ -54,6 +44,16 @@ $search_email=GETPOST("search_email");
$search_categ=GETPOST("search_categ"); $search_categ=GETPOST("search_categ");
$sall=GETPOST("sall"); $sall=GETPOST("sall");
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) { $sortorder=($filter=='outofdate'?"ASC":"DESC"); }
if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.nom"); }
if (GETPOST("button_removefilter")) if (GETPOST("button_removefilter"))
{ {
$search=""; $search="";
@ -333,12 +333,16 @@ if ($resql)
print '<td align="center">'; print '<td align="center">';
if ($user->rights->adherent->creer) if ($user->rights->adherent->creer)
{ {
print "<a href=\"fiche.php?rowid=$objp->rowid&action=edit&return=liste.php\">".img_edit()."</a>"; print "<a href=\"fiche.php?rowid=".$objp->rowid."&action=edit&backtopage=1\">".img_edit()."</a>";
} }
print '&nbsp;'; print '&nbsp;';
if ($user->rights->adherent->supprimer) if ($user->rights->adherent->supprimer && $objp->statut == -1)
{ {
print "<a href=\"fiche.php?rowid=$objp->rowid&action=resign&return=liste.php\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>"; print "<a href=\"fiche.php?rowid=".$objp->rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png')."</a>";
}
if ($user->rights->adherent->supprimer && $objp->statut == 1)
{
print "<a href=\"fiche.php?rowid=".$objp->rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
} }
print "</td>"; print "</td>";

View File

@ -2207,7 +2207,7 @@ class Form
$more.=$input['value']; $more.=$input['value'];
$more.='</td></tr>'."\n"; $more.='</td></tr>'."\n";
} }
array_push($inputarray,$input['name']); if ($input['type'] != 'hidden') array_push($inputarray,$input['name']);
} }
} }
$more.='</table>'."\n"; $more.='</table>'."\n";
@ -2228,6 +2228,18 @@ class Form
} }
$pageyes=$page.'&action='.$action.'&confirm=yes'; $pageyes=$page.'&action='.$action.'&confirm=yes';
$pageno=($useajax == 2?$page.'&confirm=no':''); $pageno=($useajax == 2?$page.'&confirm=no':'');
// Add hidden fields
if (is_array($formquestion))
{
foreach ($formquestion as $key => $input)
{
if ($input['type'] == 'hidden')
{
$pageyes.='&'.$input['name'].'='.urlencode($input['value']);
$pageno.=($useajax == 2?$page.'&'.$input['name'].'='.urlencode($input['value']):'');
}
}
}
// New code using jQuery only // New code using jQuery only
$formconfirm.= '<div id="'.$dialogconfirm.'" title="'.dol_escape_htmltag($title).'" style="display: none;">'; $formconfirm.= '<div id="'.$dialogconfirm.'" title="'.dol_escape_htmltag($title).'" style="display: none;">';
@ -2237,7 +2249,7 @@ class Form
$formconfirm.= '<script type="text/javascript"> $formconfirm.= '<script type="text/javascript">
$(function() { $(function() {
var choice=\'ko\'; var choice=\'ko\';
var $inputarray='.json_encode($inputarray).'; var $inputarray='.json_encode($inputarray).';
var button=\''.$button.'\'; var button=\''.$button.'\';
var dialogconfirm=\''.$dialogconfirm.'\'; var dialogconfirm=\''.$dialogconfirm.'\';
@ -2296,10 +2308,10 @@ class Form
$formconfirm.= '<table width="100%" class="valid">'."\n"; $formconfirm.= '<table width="100%" class="valid">'."\n";
// Ligne titre // Line title
$formconfirm.= '<tr class="validtitre"><td class="validtitre" colspan="3">'.img_picto('','recent').' '.$title.'</td></tr>'."\n"; $formconfirm.= '<tr class="validtitre"><td class="validtitre" colspan="3">'.img_picto('','recent').' '.$title.'</td></tr>'."\n";
// Ligne formulaire // Line form fields
if ($more) if ($more)
{ {
$formconfirm.='<tr class="valid"><td class="valid" colspan="3">'."\n"; $formconfirm.='<tr class="valid"><td class="valid" colspan="3">'."\n";
@ -2307,7 +2319,7 @@ class Form
$formconfirm.='</td></tr>'."\n"; $formconfirm.='</td></tr>'."\n";
} }
// Ligne message // Line with question
$formconfirm.= '<tr class="valid">'; $formconfirm.= '<tr class="valid">';
$formconfirm.= '<td class="valid">'.$question.'</td>'; $formconfirm.= '<td class="valid">'.$question.'</td>';
$formconfirm.= '<td class="valid">'; $formconfirm.= '<td class="valid">';
@ -2319,6 +2331,7 @@ class Form
$formconfirm.= '</table>'."\n"; $formconfirm.= '</table>'."\n";
// Add hidden fields
if (is_array($formquestion)) if (is_array($formquestion))
{ {
foreach ($formquestion as $key => $input) foreach ($formquestion as $key => $input)