diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 71660c0cd8c..571879788ee 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -53,21 +53,21 @@ class Subscription extends CommonObject * @var integer */ public $datec; - + /** * Date modification record (tms) * * @var integer */ public $datem; - + /** * Subscription start date (date subscription) * * @var integer */ public $dateh; - + /** * Subscription end date * @@ -128,10 +128,11 @@ class Subscription extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - if ($this->fk_type == null) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + + if ($this->fk_type == null) { // If type not defined, we use the type of member $type=$member->typeid; } else { $type=$this->fk_type; @@ -151,11 +152,13 @@ class Subscription extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->fk_type = $type; } if (! $error && ! $notrigger) { - // Call triggers + $this->context = array('member'=>$member); + // Call triggers $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers @@ -257,7 +260,8 @@ class Subscription extends CommonObject $result=$member->update_end_date($user); if (! $error && ! $notrigger) { - // Call triggers + $this->context = array('member'=>$member); + // Call triggers $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index a8478f35e88..e44995b263f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2019 Laurent Destailleur * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -205,18 +205,18 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print $form->showrefnav($object, 'rowid', $linkback, 1); print ''; - // Type + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').''; + print ''; + + // Type print ''; print ''.$langs->trans("Type").''; print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); print''; - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').''; - print ''; - // Date start subscription print ''.$langs->trans("DateSubscription").''; print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); @@ -309,6 +309,12 @@ if ($rowid && $action != 'edit') print ''; + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''; + print ''; + // Type print ''; print ''; @@ -322,17 +328,6 @@ if ($rowid && $action != 'edit') } print ''; - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''; - print ''; - - // Date record - /*print ''; - print ''; - print '';*/ - // Date subscription print ''; print ''; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bdd07c4e38d..07499ac8893 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -649,12 +649,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda","other","members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + $member = $this->context['member']; + if (! is_object($member)) // This should not happen + { + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($this->fk_adherent); + } + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid=0; if ($object->fk_soc > 0) $object->socid=$object->fk_soc; @@ -664,12 +672,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda","other","members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + $member = $this->context['member']; + if (! is_object($member)) // This should not happen + { + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($this->fk_adherent); + } + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid=0; if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("Type").'
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->datec,'dayhour').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->dateh, 'day').'