The-Network-Crew / BPAY-for-WHMCS

(Payment Gateway Module) BPAY for the WHMCS Automation System.
https://marketplace.whmcs.com/product/7388-bpay-for-whmcs
GNU General Public License v3.0
4 stars 4 forks source link

BPAY Images: Conditional problems with displaying #3

Closed lsthompson closed 2 years ago

lsthompson commented 2 years ago

This may have some relation to Issue #1 (3 years old).

Using a Dev install of WHMCSv8, creating a new client post-module-install their Summary page DOES show the image correctly, however creating an invoice and using BPAY for it, the usual image does not appear below the Invoice module buttons.

Further, testing Invoice 1 for Client 1 also reveals a non-existent BPAY Image, even though it DOES appear on the Summary page. This would suggest that the image is either API-driven there and JPG-driven elsewhere (yet to be generated), or that the integrations in other areas is handled differently. Need to look into the how/why and start to refine this bottom-up.

CODE - SUMMARY PAGE (Present)

<div class="[tab-content client-tabs]()">
  <div class="[tab-pane active]()" id="[profileContent]()"><script>
        setTimeout(function() { 
          console.log($('textarea[name=adminnotes]').parent().parent().parent().html());

          $("</div><div id='BpayClientSummaryAdminArea' class='clientssummarybox'><div class='title'>BPAY Details</div><img src='../modules/gateways/bpay.php?cust_id=00000017' width='100%' align='middle' />")
          .insertBefore($('textarea[name=adminnotes]').parent().parent().parent());

        }, 500);
        </script><style>
#BpayClientSummaryAdminArea {
    color=green;
    }
</style>

CODE - INVOICE PAGE, Admin-side (Missing, now fixed)

<h1>Invoice #1</h1>
<script>
    setTimeout(function() { 
      $image = $("<img id='BpayAdminViewInvoice' src='../modules/gateways/bpay.php?cust_id=00000017' width='300px' style='margin-top:-20px;' />");
      $image.insertBefore( $('#tab1 table td form'));
    }, 500);
    </script>

Cause is likely to be outdated/deprecated positional reference(?)

PDFs aside, between the 2 locations it seems the difference is how they're being positioned.

lsthompson commented 2 years ago

Ref: https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore

SYNTAX:

insertBefore(newNode, referenceNode);

PARAMETERS:

newNode The node to be inserted.

referenceNode The node before which newNode is inserted. If this is null, then newNode is inserted at the end of node's child nodes.

Note: referenceNode is not an optional parameter. You must explicitly pass a Node or null. Failing to provide it or passing invalid values may behave differently in different browser versions.