diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php
index 784f6d4dea7..dcc8b671259 100644
--- a/htdocs/adherents/card_subscriptions.php
+++ b/htdocs/adherents/card_subscriptions.php
@@ -53,6 +53,10 @@ $result=restrictedArea($user,'adherent',$rowid,'','cotisation');
$object = new Adherent($db);
$extrafields = new ExtraFields($db);
$adht = new AdherentType($db);
+
+// fetch optionals attributes and labels
+$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
+
$errmsg='';
$errmsgs=array();
@@ -379,6 +383,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
$invoice->socid=$object->fk_soc;
$invoice->date=$datecotisation;
+ // Possibility to add external linked objects with hooks
+ $invoice->linked_objects['subscription'] = $crowid;
+ if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects']))
+ {
+ $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']);
+ }
+
$result=$invoice->create($user);
if ($result <= 0)
{
diff --git a/htdocs/adherents/fiche_subscription.php b/htdocs/adherents/fiche_subscription.php
index 6b980a4df1c..28fb2268d4c 100644
--- a/htdocs/adherents/fiche_subscription.php
+++ b/htdocs/adherents/fiche_subscription.php
@@ -33,35 +33,49 @@ $langs->load("members");
$langs->load("users");
$adh = new Adherent($db);
-$subscription = new Cotisation($db);
+$object = 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"];
+$action=GETPOST("action",'alpha');
+$rowid=GETPOST("rowid","int")?GETPOST("rowid","int"):GETPOST("id","int");
+$typeid=GETPOST("typeid","int");
+$cancel=GETPOST('cancel');
if (! $user->rights->adherent->cotisation->lire)
accessforbidden();
+$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php
+$permissiondellink=$user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
+$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php
+
/*
* Actions
*/
+if ($cancel) $action='';
+
+//include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+
+include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
+
+//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
+
+
if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update' && ! $_POST["cancel"])
{
// Charge objet actuel
- $result=$subscription->fetch($_POST["rowid"]);
+ $result=$object->fetch($_POST["rowid"]);
if ($result > 0)
{
$db->begin();
$errmsg='';
- if ($subscription->fk_bank)
+ if ($object->fk_bank)
{
$accountline=new AccountLine($db);
- $result=$accountline->fetch($subscription->fk_bank);
+ $result=$accountline->fetch($object->fk_bank);
// If transaction consolidated
if ($accountline->rappro)
@@ -84,31 +98,31 @@ if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update
if (! $errmsg)
{
// Modifie valeures
- $subscription->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
- $subscription->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
- $subscription->note=$_POST["note"];
- $subscription->amount=$_POST["amount"];
- //print 'datef='.$subscription->datef.' '.$_POST['datesubendday'];
+ $object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+ $object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
+ $object->note=$_POST["note"];
+ $object->amount=$_POST["amount"];
+ //print 'datef='.$object->datef.' '.$_POST['datesubendday'];
- $result=$subscription->update($user);
- if ($result >= 0 && ! count($subscription->errors))
+ $result=$object->update($user);
+ if ($result >= 0 && ! count($object->errors))
{
$db->commit();
- header("Location: fiche_subscription.php?rowid=".$subscription->id);
+ header("Location: fiche_subscription.php?rowid=".$object->id);
exit;
}
else
{
$db->rollback();
- if ($subscription->error)
+ if ($object->error)
{
- $errmsg=$subscription->error;
+ $errmsg=$object->error;
}
else
{
- foreach($subscription->errors as $error)
+ foreach($object->errors as $error)
{
if ($errmsg) $errmsg.='
';
$errmsg.=$error;
@@ -126,11 +140,11 @@ if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->adherent->cotisation->creer)
{
- $result=$subscription->fetch($rowid);
- $result=$subscription->delete($user);
+ $result=$object->fetch($rowid);
+ $result=$object->delete($user);
if ($result > 0)
{
- header("Location: card_subscriptions.php?rowid=".$subscription->fk_adherent);
+ header("Location: card_subscriptions.php?rowid=".$object->fk_adherent);
exit;
}
else
@@ -145,11 +159,12 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
* View
*/
-llxHeader('',$langs->trans("SubscriptionCard"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros');
-
$form = new Form($db);
+llxHeader('',$langs->trans("SubscriptionCard"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros');
+
+
dol_htmloutput_errors($errmsg);
@@ -161,8 +176,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
*
********************************************/
- $subscription->fetch($rowid);
- $result=$adh->fetch($subscription->fk_adherent);
+ $object->fetch($rowid);
+ $result=$adh->fetch($object->fk_adherent);
/*
* Affichage onglets
@@ -170,12 +185,12 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
$h = 0;
$head = array();
- $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id;
+ $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$object->id;
$head[$h][1] = $langs->trans("SubscriptionCard");
$head[$h][2] = 'general';
$h++;
- $head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$subscription->id;
+ $head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
@@ -184,7 +199,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print '';
print "";
print "";
- print "fk_bank."\">";
+ print "fk_bank."\">";
dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment');
@@ -196,7 +211,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
// Ref
print '