NEW Can link member subscription/contribution with proposal, order and invoice (#33647)

* linking member subscription contribution <-> proposal, order and invoice
This can both be done manually from an existing proposal/order/invoice to a subscription created without creating an invoice. I use this when we sell memberships as part of registration for our membership classes.

The link will also be shown on the invoice that can be created as part of the subscription contribution creation.

These links show up in the json from the API on proposals, orders and invoices. The subscription does not show anything. It is currently unknown if the API can do this link or it will have to be done manually in the GUI.

* Update html.form.class.php

---------

Co-authored-by: Jon Bendtsen <xcodeauthor@jonb.dk>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Jon Bendtsen
2025-04-01 21:36:35 +02:00
committed by GitHub
parent 65fb217432
commit 27dc84fe3b
5 changed files with 16 additions and 3 deletions

View File

@@ -3386,7 +3386,7 @@ if ($action == 'create') {
$compatibleImportElementsList = false;
if ($user->hasRight('propal', 'creer') && $object->status == Propal::STATUS_DRAFT) {
$compatibleImportElementsList = array('commande', 'propal', 'facture'); // import from linked elements
$compatibleImportElementsList = array('commande', 'propal', 'facture', 'subscription'); // import from linked elements
}
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);

View File

@@ -3349,7 +3349,7 @@ if ($action == 'create' && $usercancreate) {
$compatibleImportElementsList = false;
if ($usercancreate
&& $object->statut == Commande::STATUS_DRAFT) {
$compatibleImportElementsList = array('commande', 'propal', 'facture'); // import from linked elements
$compatibleImportElementsList = array('commande', 'propal', 'facture', 'subscription'); // import from linked elements
}
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);

View File

@@ -6292,7 +6292,7 @@ if ($action == 'create') {
if ($usercancreate
&& $object->status == Facture::STATUS_DRAFT
&& ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) {
$compatibleImportElementsList = array('commande', 'propal'); // import from linked elements
$compatibleImportElementsList = array('commande', 'propal', 'subscription'); // import from linked elements
}
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);

View File

@@ -9996,6 +9996,12 @@ class Form
'label' => 'LinkToOrder',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('commande') . ')'.($dontIncludeCompletedItems ? ' AND t.facture < 1' : ''),
'linkname' => 'commande',
'subscription' => array(
'enabled' => isModEnabled('member'),
'perms' => 1,
'label' => 'LinkToMemberSubscription',
'sql' => "SELECT a.fk_soc as socid, CONCAT(a.firstname, ' ', a.lastname) as name, a.entity as client, sub.rowid, sub.note as ref, '' as ref_client, sub.subscription as total_ht FROM " . $this->db->prefix() . "adherent as a, " . $this->db->prefix() . "subscription as sub WHERE sub.fk_adherent = a.rowid AND a.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND a.entity IN (' . getEntity('subscription') . ')',
'linkname' => 'subscription'),
),
'invoice' => array(
'enabled' => isModEnabled('invoice'),

View File

@@ -13793,6 +13793,13 @@ function getElementProperties($elementType)
$module = 'adherent';
$subelement = 'adherent';
$table_element = 'adherent';
} elseif ($elementType == 'subscription') {
$classpath = 'adherents/class';
$classfile = 'subscription';
$module = 'adherent';
$subelement = 'subscription';
$classname = 'Subscription';
$table_element = 'subscription';
} elseif ($elementType == 'usergroup') {
$classpath = 'user/class';
$module = 'user';