diff --git a/htdocs/adherents/fiche_subscription.php b/htdocs/adherents/fiche_subscription.php new file mode 100644 index 00000000000..92e016e1d93 --- /dev/null +++ b/htdocs/adherents/fiche_subscription.php @@ -0,0 +1,335 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/adherents/fiche_subscription.php + \ingroup adherent + \brief Page d'ajout, edition, suppression d'une fiche adhésion + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); +require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); +require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); + +$langs->load("companies"); +$langs->load("bills"); +$langs->load("members"); +$langs->load("users"); + +$user->getrights('adherent'); + +$adh = new Adherent($db); +$subscription = new Cotisation($db); +$errmsg=''; + +$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; +$typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"]; + +if (! $user->rights->adherent->cotisation->lire) + accessforbidden(); + +/* + * Actions + */ + +if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update' && ! $_POST["cancel"]) +{ + // Charge objet actuel + $result=$subscription->fetch($_POST["rowid"]); + if ($result > 0) + { + // Modifie valeures + + + $result=$subscription->update($user,0); + if ($result >= 0 && ! sizeof($subscription->errors)) + { + Header("Location: fiche_subscription.php?rowid=".$subscription->id); + exit; + } + else + { + if ($adh->error) + { + $errmsg=$adh->error; + } + else + { + foreach($adh->errors as $error) + { + if ($errmsg) $errmsg.='
'; + $errmsg.=$error; + } + } + $action=''; + } + } +} + +if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') +{ + $result=$subscription->fetch($rowid); + $result=$subscription->delete($rowid); + if ($result > 0) + { + Header("Location: card_subscriptions.php?rowid=".$subscription->fk_adherent); + exit; + } + else + { + $mesg=$adh->error; + } +} + + + +/* + * + */ + +llxHeader(); + + +if ($errmsg) +{ + print '
'.$errmsg.'
'; + print "\n"; +} + + +if ($user->rights->adherent->cotisation->creer && $action == 'edit') +{ + /******************************************** + * + * Fiche en mode edition + * + ********************************************/ + + + + /* + * Affichage onglets + */ + $head = member_prepare_head($adh); + + dolibarr_fiche_head($head, 'general', $langs->trans("Member")); + + + print '
'; + print ""; + print ""; + print "statut."\">"; + + print ''; + + $htmls = new Form($db); + + // Ref + print ''; + + // Nom + print ''; + // Photo + $rowspan=17; + $rowspan+=sizeof($adho->attribute_label); + print ''; + print ''; + + // Prenom + print ''; + print ''; + + // Login + print ''; + + // Password + print ''; + + // Type + print '"; + + // Physique-Moral + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Morale"); + print ""; + + // Société + print ''; + + // Adresse + print ''; + + // Cp + print ''; + + // Pays + print ''; + + // Tel + print ''; + + // Tel perso + print ''; + + // Tel mobile + print ''; + + // EMail + print ''; + + // Date naissance + print "\n"; + + // Url photo + print ''; + + // Profil public + print "\n"; + + // Attributs supplémentaires + foreach($adho->attribute_label as $key=>$value) + { + print "\n"; + } + + print ''; + + print '
'.$langs->trans("Ref").''.$adh->id.' 
'.$langs->trans("Lastname").''; + print ' '; + print '
'.$langs->trans("Firstname").'
'.$langs->trans("Login").'
'.$langs->trans("Password").'
'.$langs->trans("Type").''; + $htmls->select_array("type", $adht->liste_array(), $adh->typeid); + print "
".$langs->trans("Person").""; + $htmls->select_array("morphy", $morphys, $adh->morphy); + print "
'.$langs->trans("Company").'
'.$langs->trans("Address").''; + print '
'.$langs->trans("Zip").'/'.$langs->trans("Town").'
'.$langs->trans("Country").''; + $htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); + print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhoneMobile").'
'.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').'
".$langs->trans("Birthday")."\n"; + $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); + print "
URL photo
".$langs->trans("Public")."\n"; + print $htmls->selectyesno("public",$adh->public,1); + print "
$valuearray_options["options_$key"]."\">
'; + print ''; + print '       '; + print ''; + print '
'; + print '
'; + + print ''; +} + +if ($rowid && $action != 'edit') +{ + /* ************************************************************************** */ + /* */ + /* Mode affichage */ + /* */ + /* ************************************************************************** */ + + $subscription->fetch($rowid); + + $html = new Form($db); + + /* + * Affichage onglets + */ + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id; + $head[$h][1] = $langs->trans("SubscriptionCard"); + $head[$h][2] = 'general'; + $h++; + + dolibarr_fiche_head($head, 'general', $langs->trans("Subscription")); + + if ($msg) print '
'.$msg.'
'; + + //$result=$subscription->load_previous_next_id($adh->next_prev_filter); + //if ($result < 0) dolibarr_print_error($db,$subscription->error); + //$previous_id = $adh->id_previous?''.img_previous().'':''; + //$next_id = $adh->id_next?''.img_next().'':''; + + // Confirmation de la suppression de l'adhérent + if ($action == 'delete') + { + //$formquestion=array(); + //$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").''; + $text=$langs->trans("ConfirmDeleteSubscription"); + if ($conf->global->ADHERENT_BANK_USE) $text.='
'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); + $html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$subscription->id,$langs->trans("DeleteSubscription"),$text,"confirm_delete",$formquestion); + print '
'; + } + + print '
'; + print ''; + + // Ref + print ''; + print ''; + + // Date + print ''; + print ''; + + // Amount + print ''; + + print "
'.$langs->trans("Ref").''; + if ($previous_id || $next_id) print '
'; + print $subscription->id; + if ($previous_id || $next_id) print ''.$previous_id.''.$next_id.'
'; + print '
'.$langs->trans("Date").''.dolibarr_print_date($subscription->dateh,'dayhour').'
'.$langs->trans("Amount").''.$subscription->amount.'
\n"; + print '
'; + + print "\n"; + + + /* + * Barre d'actions + * + */ + print '
'; + +// if ($user->rights->adherent->cotisation->creer) +// { +// print "id."&action=edit\">".$langs->trans("Edit").""; +// } + + // Supprimer + if ($user->rights->adherent->cotisation->creer) + { + print "id."&action=delete\">".$langs->trans("Delete")."\n"; + } + + print '
'; + print "
\n"; + +} + + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?>