From 30889783358d0293dfe43a52b8f66347b607a86b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 1 Nov 2024 16:32:29 +0100 Subject: [PATCH] Update dashboard.php --- dashboard/dashboard.php | 45 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php index 430ee1b2..b6c67ef3 100644 --- a/dashboard/dashboard.php +++ b/dashboard/dashboard.php @@ -1436,29 +1436,26 @@ function members_menu( $arg ) { function members_module( $url ) { global $current_user; -$time = current_time( 'timestamp',1); - -$request = "/adherentsplus/".doliconnector($current_user, 'fk_member', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null)); -$productadhesion = doliconst("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS"); -$requestp = "/products/".$productadhesion."?includesubproducts=true&includetrans=true"; -$product = callDoliApi("GET", $requestp, null, dolidelay('product', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); - -if ( isset($_POST["update_membership"]) && function_exists('doliconnect_membership') ) { -$typeadherent = isset($_POST["typeadherent"]) ? $_POST["typeadherent"] : null; -$adherent = doliconnect_membership($current_user, $_POST["update_membership"], $typeadherent, dolidelay('member', true)); -//print var_dump($adherent); -$request = "/adherentsplus/".doliconnector($current_user, 'fk_member', true); -$adherent = callDoliApi("GET", $request, null, dolidelay('member', true)); -print dolialert('success', __( 'Your membership has been updated.', 'doliconnect')); -} - -print '
'.__( 'Manage my subscription', 'doliconnect').'
'; + $time = current_time( 'timestamp',1); + $adherent = doliConnect('member', $current_user, false, esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null)); + + $request = "/adherentsplus/".$adherent->id; + $productadhesion = doliconst("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS"); + $requestp = "/products/".$productadhesion."?includesubproducts=true&includetrans=true"; + $product = callDoliApi("GET", $requestp, null, dolidelay('product', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); + + if ( isset($_POST["update_membership"]) && function_exists('doliconnect_membership') ) { + $typeadherent = isset($_POST["typeadherent"]) ? $_POST["typeadherent"] : null; + $adherent = doliconnect_membership($current_user, $_POST["update_membership"], $typeadherent, dolidelay('member', true)); + //print var_dump($adherent); + $request = "/adherentsplus/".$adherent->id; + $adherent = callDoliApi("GET", $request, null, dolidelay('member', true)); + print dolialert('success', __( 'Your membership has been updated.', 'doliconnect')); + } -if ( !empty(doliconnector($current_user, 'fk_member')) && doliconnector($current_user, 'fk_member') > 0 && doliconnector($current_user, 'fk_soc') > 0 ) { -$adherent = callDoliApi("GET", $request, null, dolidelay('member', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); -} + print '
'.__( 'Manage my subscription', 'doliconnect').'
'; -if ( !empty(doliconnector($current_user, 'fk_member')) && doliconnector($current_user, 'fk_member') > 0 && !empty($adherent->typeid) ) { +if ( isset($adherent->id) && $adherent->id > 0 && !empty($adherent->typeid) ) { $request= "/adherentsplus/type/".$adherent->typeid; $adherenttype = callDoliApi("GET", $request, null, dolidelay('member', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); } @@ -1530,7 +1527,7 @@ function members_module( $url ) { } } - if ( !empty(doliconnector($current_user, 'fk_member')) && doliconnector($current_user, 'fk_member') > 0 && !empty($adherent->typeid) ) { + if ( isset($adherent->id) && $adherent->id > 0 && !empty($adherent->typeid) ) { $request= "/adherentsplus/type/".$adherent->typeid; $adherenttype = callDoliApi("GET", $request, null, dolidelay('member', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); //print var_dump($adherenttype); @@ -1580,8 +1577,8 @@ function members_module( $url ) { print "
    "; $limit=12; $page = doliPG(isset($_GET['pg'])?$_GET['pg']:null); - if (doliconnector($current_user, 'fk_member') > 0) { - $object = callDoliApi("GET", "/subscriptions?sortfield=dateadh&sortorder=DESC&limit=".$limit."&page=".$page."&pagination_data=true&sqlfilters=t.fk_adherent:=:".doliconnector($current_user, 'fk_member'), null, dolidelay('member', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); + if (isset($adherent->id) && $adherent->id > 0) { + $object = callDoliApi("GET", "/subscriptions?sortfield=dateadh&sortorder=DESC&limit=".$limit."&page=".$page."&pagination_data=true&sqlfilters=t.fk_adherent:=:".$adherent->id, null, dolidelay('member', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); if ( doliversion('21.0.0') && isset($object->data) ) { $listcotisation = $object->data; } else { $listcotisation = $object; } } if ( isset($listcotisation) && !isset($listcotisation->error) && $listcotisation != null ) {