BxBaseModPaymentCommissions.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BasePayment Base classes for Payment like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModPaymentCommissions extends BxDol
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. function __construct()
  16. {
  17. parent::__construct();
  18. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  19. }
  20. /**
  21. * @page service Service Calls
  22. * @section bx_base_payment Base Payment
  23. * @subsection bx_base_payment-integration Integration
  24. * @subsubsection bx_base_payment-get_invoices_url get_invoices_url
  25. *
  26. * @code bx_srv('bx_payment', 'get_invoices_url', [...], 'Commissions'); @endcode
  27. *
  28. * Get invoices page URL.
  29. *
  30. * @return string with invoices page URL.
  31. *
  32. * @see BxBaseModPaymentOrders::serviceGetOrdersUrl
  33. */
  34. /**
  35. * @ref bx_base_payment-get_invoices_url "get_invoices_url"
  36. */
  37. public function serviceGetInvoicesUrl()
  38. {
  39. if(!$this->_oModule->isLogged())
  40. return '';
  41. return $this->_oModule->_oConfig->getUrl('URL_INVOICES');
  42. }
  43. /**
  44. * @page service Service Calls
  45. * @section bx_base_payment Base Payment
  46. * @subsection bx_base_payment-integration Integration
  47. * @subsubsection bx_base_payment-get_invoices_count get_invoices_count
  48. *
  49. * @code bx_srv('bx_payment', 'get_invoices_count', [...], 'Commissions'); @endcode
  50. *
  51. * Get invoices count by type.
  52. *
  53. * @param $sType string value with type.
  54. * @param $iProfileId (optional) integer value with profile ID. If empty value is provided then currently logged in profile will be used.
  55. * @return integer value with invoices count.
  56. *
  57. * @see BxBaseModPaymentOrders::serviceGetOrdersCount
  58. */
  59. /**
  60. * @ref bx_base_payment-get_invoices_count "get_invoices_count"
  61. */
  62. public function serviceGetInvoicesCount($sType, $iProfileId = 0)
  63. {
  64. if(!in_array($sType, array('unpaid', 'overdue')))
  65. return 0;
  66. $iProfileId = !empty($iProfileId) ? $iProfileId : $this->_oModule->getProfileId();
  67. if(empty($iProfileId))
  68. return 0;
  69. return $this->_oModule->_oDb->getInvoices(array('type' => 'status', 'status' => $sType, 'committent_id' => $iProfileId, 'count' => true));
  70. }
  71. }
  72. /** @} */