BxBasePaymentsServices.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * System services related to Payments.
  11. */
  12. class BxBasePaymentsServices extends BxDol
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceGetPayments()
  19. {
  20. return BxDolPayments::getInstance()->getPayments();
  21. }
  22. /**
  23. * @page service Service Calls
  24. * @section bx_system_general System Services
  25. * @subsection bx_system_general-payments Payments
  26. * @subsubsection bx_system_general-get_cart_items_count get_cart_items_count
  27. *
  28. * @code bx_srv('system', 'get_cart_items_count', [], 'TemplPaymentsServices'); @endcode
  29. * @code {{~system:get_cart_items_count:TemplPaymentsServices~}} @endcode
  30. *
  31. * Get number of items in shopping cart for currently logged in profile.
  32. *
  33. * @see BxBasePaymentsServices::serviceGetChartStats
  34. */
  35. /**
  36. * @ref bx_system_general-get_cart_items_count "get_cart_items_count"
  37. */
  38. public function serviceGetCartItemsCount()
  39. {
  40. return BxDolPayments::getInstance()->getCartItemsCount();
  41. }
  42. /**
  43. * @page service Service Calls
  44. * @section bx_system_general System Services
  45. * @subsection bx_system_general-payments Payments
  46. * @subsubsection bx_system_general-get_orders_count get_orders_count
  47. *
  48. * @code bx_srv('system', 'get_orders_count', ["new"], 'TemplPaymentsServices'); @endcode
  49. * @code {{~system:get_orders_count:TemplPaymentsServices["new"]~}} @endcode
  50. *
  51. * Get number of order by type for currently logged in profile.
  52. * @param $sType type, for example: new
  53. *
  54. * @see BxBasePaymentsServices::serviceGetOrdersCount
  55. */
  56. /**
  57. * @ref bx_system_general-get_orders_count "get_orders_count"
  58. */
  59. public function serviceGetOrdersCount($sType)
  60. {
  61. return BxDolPayments::getInstance()->getOrdersCount($sType);
  62. }
  63. /**
  64. * @page service Service Calls
  65. * @section bx_system_general System Services
  66. * @subsection bx_system_general-payments Payments
  67. * @subsubsection bx_system_general-get_invoices_count get_invoices_count
  68. *
  69. * @code bx_srv('system', 'get_invoices_count', ["unpaid"], 'TemplPaymentsServices'); @endcode
  70. * @code {{~system:get_invoices_count:TemplPaymentsServices["unpaid"]~}} @endcode
  71. *
  72. * Get number of invoices by type for currently logged in profile.
  73. * @param $sType type, for example: unpaid
  74. *
  75. * @see BxBasePaymentsServices::serviceGetInvoicesCount
  76. */
  77. /**
  78. * @ref bx_system_general-get_invoices_count "get_invoices_count"
  79. */
  80. public function serviceGetInvoicesCount($sType)
  81. {
  82. return BxDolPayments::getInstance()->getInvoicesCount($sType);
  83. }
  84. public function serviceGetLiveUpdatesCart($aMenuItemParent, $aMenuItemChild, $iCount = 0)
  85. {
  86. $iCountNew = BxDolPayments::getInstance()->getCartItemsCount();
  87. if($iCountNew == $iCount)
  88. return false;
  89. return array(
  90. 'count' => $iCountNew, // required
  91. 'method' => 'bx_menu_show_live_update(oData)', // required
  92. 'data' => array(
  93. 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array(
  94. 'content' => '{count}'
  95. )),
  96. 'mi_parent' => $aMenuItemParent,
  97. 'mi_child' => $aMenuItemChild
  98. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  99. );
  100. }
  101. public function serviceGetLiveUpdatesOrders($aMenuItemParent, $aMenuItemChild, $iCount = 0)
  102. {
  103. $iCountNew = BxDolPayments::getInstance()->getOrdersCount('new');
  104. if($iCountNew == $iCount)
  105. return false;
  106. return array(
  107. 'count' => $iCountNew, // required
  108. 'method' => 'bx_menu_show_live_update(oData)', // required
  109. 'data' => array(
  110. 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array(
  111. 'content' => '{count}'
  112. )),
  113. 'mi_parent' => $aMenuItemParent,
  114. 'mi_child' => $aMenuItemChild
  115. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  116. );
  117. }
  118. public function serviceGetLiveUpdatesInvoices($aMenuItemParent, $aMenuItemChild, $iCount = 0)
  119. {
  120. $iCountNew = BxDolPayments::getInstance()->getInvoicesCount('unpaid');
  121. if($iCountNew == $iCount)
  122. return false;
  123. return array(
  124. 'count' => $iCountNew, // required
  125. 'method' => 'bx_menu_show_live_update(oData)', // required
  126. 'data' => array(
  127. 'code' => BxDolTemplate::getInstance()->parseHtmlByTemplateName('menu_item_addon', array(
  128. 'content' => '{count}'
  129. )),
  130. 'mi_parent' => $aMenuItemParent,
  131. 'mi_child' => $aMenuItemChild
  132. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  133. );
  134. }
  135. }
  136. /** @} */