* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * 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/adherents/type.php * \ingroup member * \brief Member's type setup */ require '../main.inc.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'; $langs->load("members"); $rowid = GETPOST('rowid','int'); $action = GETPOST('action','alpha'); $search_lastname = GETPOST('search_lastname','alpha'); $search_login = GETPOST('search_login','alpha'); $search_email = GETPOST('search_email','alpha'); $type = GETPOST('type','alpha'); $status = GETPOST('status','alpha'); $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="DESC"; } if (! $sortfield) { $sortfield="d.lastname"; } // Security check $result=restrictedArea($user,'adherent',$rowid,'adherent_type'); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); if (GETPOST('button_removefilter')) { $search_lastname=""; $search_login=""; $search_email=""; $type=""; $sall=""; } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('membertypecard')); /* * Actions */ if ($action == 'add' && $user->rights->adherent->configurer) { if ($_POST["button"] != $langs->trans("Cancel")) { $adht = 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"]); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$adht); if ($adht->libelle) { $id=$adht->create($user->id); if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { $mesg=$adht->error; $action = 'create'; } } else { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); $action = 'create'; } } } 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"]); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$adht); $adht->update($user->id); header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]); exit; } } if ($action == 'delete' && $user->rights->adherent->configurer) { $adht = new AdherentType($db); $adht->delete($rowid); header("Location: ".$_SERVER["PHP_SELF"]); exit; } if ($action == 'commentaire' && $user->rights->adherent->configurer) { $don = new Don($db); $don->fetch($rowid); $don->update_note(dol_html_entity_decode(GETPOST('commentaire'), ENT_QUOTES)); } /* * View */ llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); $form=new Form($db); // Liste of members type if (! $rowid && $action != 'create' && $action != 'edit') { print_fiche_titre($langs->trans("MembersTypes")); $sql = "SELECT d.rowid, d.libelle, d.cotisation, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql.= " WHERE d.entity IN (".getEntity().")"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ""; print ''; print ''; print ''; print ''; print ''; print ""; $i++; } print "
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("SubscriptionRequired").''.$langs->trans("VoteAllowed").' 
'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.''.$objp->libelle.''.yn($objp->cotisation).''.yn($objp->vote).'rowid.'">'.img_edit().'
"; } else { dol_print_error($db); } /* * Barre d'actions * */ print '
'; // New type if ($user->rights->adherent->configurer) { print ''; } print "
"; } /* ************************************************************************** */ /* */ /* Creation d'un type adherent */ /* */ /* ************************************************************************** */ if ($action == 'create') { $form = new Form($db); $adht = new AdherentType($db); print_fiche_titre($langs->trans("NewMemberType")); if ($mesg) print '
'.$mesg.'
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Other attributes $parameters=array(); $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 "
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("cotisation",1,1); print '
'.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote",0,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->Create(); print '
\n"; print '
'; print '
    '; print '
'; print "
\n"; } /* ************************************************************************** */ /* */ /* Edition de la fiche */ /* */ /* ************************************************************************** */ if ($rowid > 0) { if ($action != 'edit') { $adht = new AdherentType($db); $adht->fetch($rowid); $adht->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++; dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); print ''; $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; print ''; // Label print ''; print ''; print ''; print '"; print '"; // Other attributes $parameters=array(); $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)) { // View extrafields print $adht->showOptionals($extrafields); } print '
'.$langs->trans("Ref").''; print $form->showrefnav($adht, 'rowid', $linkback); print '
'.$langs->trans("Label").''.$adht->libelle.'
'.$langs->trans("SubscriptionRequired").''; print yn($adht->cotisation); print '
'.$langs->trans("VoteAllowed").''; print yn($adht->vote); print '
'.$langs->trans("Description").''; print nl2br($adht->note)."
'.$langs->trans("WelcomeEMail").''; print nl2br($adht->mail_valid)."
'; print ''; /* * Barre d'actions * */ print '
'; // Edit if ($user->rights->adherent->configurer) { print ''; } // Add print ''; // Delete if ($user->rights->adherent->configurer) { print ''; } print "
"; // Show list of members (nearly same code than in page liste.php) $membertypestatic=new AdherentType($db); $now=dol_now(); $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, "; $sql.= " d.datefin,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " t.libelle as type, t.cotisation"; $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; if ($sall) { $sql.= " AND (d.firstname LIKE '%".$sall."%' OR d.lastname LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'"; $sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'"; $sql.= " OR d.town LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')"; } if ($status != '') { $sql.= " AND d.statut IN (".$status.")"; // Peut valoir un nombre ou liste de nombre separes par virgules } if ($action == 'search') { if (isset($_POST['search']) && $_POST['search'] != '') { $sql.= " AND (d.firstname LIKE '%".$_POST['search']."%' OR d.lastname LIKE '%".$_POST['search']."%')"; } } if (! empty($search_lastname)) { $sql.= " AND (d.firstname LIKE '%".$search_lastname."%' OR d.lastname LIKE '%".$search_lastname."%')"; } if (! empty($search_login)) { $sql.= " AND d.login LIKE '%".$search_login."%'"; } if (! empty($search_email)) { $sql.= " AND d.email LIKE '%".$search_email."%'"; } if ($filter == 'uptodate') { $sql.=" AND datefin >= ".$db->idate($now); } if ($filter == 'outofdate') { $sql.=" AND datefin < ".$db->idate($now); } // Count total nb of records $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($result); else dol_print_error($db); } // Add order and limit $sql.= " ".$db->order($sortfield,$sortorder); $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $titre=$langs->trans("MembersList"); if ($status != '') { if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } } elseif ($action == 'search') { $titre=$langs->trans("MembersListQualified"); } if ($type > 0) { $membertype=new AdherentType($db); $result=$membertype->fetch($type); $titre.=" (".$membertype->libelle.")"; } $param="&rowid=".$rowid; if (! empty($status)) $param.="&status=".$status; if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; if (! empty($search_login)) $param.="&search_login=".$search_login; if (! empty($search_email)) $param.="&search_email=".$search_email; if (! empty($filter)) $param.="&filter=".$filter; if ($sall) { print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; } print '
'; print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); print ''; 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("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); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; $var=True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($resql); $datefin=$db->jdate($objp->datefin); $adh=new Adherent($db); $adh->lastname=$objp->lastname; $adh->firstname=$objp->firstname; // Lastname $var=!$var; print ''; if ($objp->societe != '') { print ''."\n"; } else { print ''."\n"; } // Login print "\n"; // Type /*print ''; */ // Moral/Physique print "\n"; // EMail print "\n"; // Statut print '"; // Date fin cotisation if ($datefin) { print ''; } else { print ''; } // Actions print '"; print "\n"; $i++; } print "
'; print ''; print ' '; print ' '; print ''; print '  '; print ''; print '
'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).''.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'".$objp->login."'; $membertypestatic->id=$objp->type_id; $membertypestatic->libelle=$objp->type; print $membertypestatic->getNomUrl(1,12); print '".$adh->getmorphylib($objp->morphy)."".dol_print_email($objp->email,0,0,1)."'; print $adh->LibStatut($objp->statut,$objp->cotisation,$datefin,2); print "'; if ($datefin < time() && $objp->statut > 0) { print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate")); } else { print dol_print_date($datefin,'day'); } print ''; if ($objp->cotisation == 'yes') { print $langs->trans("SubscriptionNotReceived"); if ($objp->statut > 0) print " ".img_warning(); } else { print ' '; } print ''; if ($user->rights->adherent->creer) { print ''.img_edit().''; } print ' '; if ($user->rights->adherent->supprimer) { print ''.img_picto($langs->trans("Resiliate"),'disable.png').''; } print "
\n"; if ($num > $conf->liste_limit) { print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); } } else { dol_print_error($db); } } if ($action == 'edit') { $form = new Form($db); $adht = new AdherentType($db); $adht->id = $rowid; $adht->fetch($rowid); $adht->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++; dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '"; // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook print '
'.$langs->trans("Ref").''.$adht->id.'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("cotisation",$adht->cotisation,1); print '
'.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote",$adht->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->Create(); print "
'; //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]:'')); print '\n"; } print '
'.$label.''; print $extrafields->showInputField($key,$value); print "


'; } print '
   '; print '
'; print "
"; } } $db->close(); llxFooter(); ?>