Skip to content

Commit

Permalink
Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 2, 2019
2 parents f30d928 + c01ac05 commit 0bc90d8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 40 deletions.
22 changes: 13 additions & 9 deletions htdocs/adherents/class/subscription.class.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -128,10 +128,11 @@ public function create($user, $notrigger = false)

$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;
Expand All @@ -151,11 +152,13 @@ public function create($user, $notrigger = false)
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
Expand Down Expand Up @@ -257,7 +260,8 @@ public function update($user, $notrigger = 0)
$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
Expand Down
33 changes: 14 additions & 19 deletions htdocs/adherents/subscription/card.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -205,18 +205,18 @@
print $form->showrefnav($object, 'rowid', $linkback, 1);
print '</td></tr>';

// Type
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';

// Type
print '<tr>';
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
print'</td></tr>';

// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';

// Date start subscription
print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">';
print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1);
Expand Down Expand Up @@ -309,6 +309,12 @@

print '<table class="border" width="100%">';

// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';

// Type
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Type").'</td>';
Expand All @@ -322,17 +328,6 @@
}
print '</td></tr>';

// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';

// Date record
/*print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->datec,'dayhour').'</td>';
print '</tr>';*/

// Date subscription
print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>';
Expand Down
40 changes: 28 additions & 12 deletions htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
Expand Up @@ -649,12 +649,20 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
// 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;
Expand All @@ -664,12 +672,20 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
// 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;
Expand Down

0 comments on commit 0bc90d8

Please sign in to comment.