Advertisement
Guest User

Untitled

a guest
Jan 11th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.38 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. define('ADMINAREA', true);
  15. require '../init.php';
  16. $whmcs = App::self();
  17. $action = $whmcs->get_req_var('action');
  18. $warning = $whmcs->get_req_var('warning');
  19. if (($action == 'edit') || ($action == 'invtooltip')) {
  20. $reqperm = 'Manage Invoice';
  21. }
  22. else if ($action == 'createinvoice') {
  23. $reqperm = 'Create Invoice';
  24. }
  25. else {
  26. $reqperm = 'List Invoices';
  27. }
  28.  
  29. namespace WHMCS
  30. {
  31. $aInt = new Admin($reqperm);
  32. $aInt->requiredFiles(['clientfunctions', 'invoicefunctions', 'gatewayfunctions', 'processinvoices', 'ccfunctions']);
  33. $invoiceModel = NULL;
  34. $id = \App::getFromRequest('id');
  35.  
  36. if ($action == 'edit') {
  37. $invoice = new Invoice($id);
  38. $invoiceModel = $invoice->getModel();
  39. $pageicon = 'invoicesedit';
  40.  
  41. if ($invoice->isProformaInvoice()) {
  42. $pagetitle = \AdminLang::trans('fields.proformaInvoiceNum') . $invoice->getData('invoicenum');
  43. }
  44. else {
  45. $pagetitle = \AdminLang::trans('fields.invoicenum') . $invoice->getData('invoicenum');
  46. }
  47. }
  48. else {
  49. $pageicon = 'invoices';
  50. $pagetitle = $aInt->lang('invoices', 'title');
  51. }
  52. }
  53.  
  54. namespace
  55. {
  56. $aInt->title = $pagetitle;
  57. $aInt->sidebar = 'billing';
  58. $aInt->icon = $pageicon;
  59. $invoiceid = (int) $whmcs->get_req_var('invoiceid');
  60. $status = $whmcs->get_req_var('status');
  61. $validInvoiceStatuses = array_merge(WHMCS\Invoices::getInvoiceStatusValues(), ['Overdue', '']);
  62.  
  63. if (!in_array($status, $validInvoiceStatuses)) {
  64. $status = '';
  65. }
  66.  
  67. if ($action == 'invtooltip') {
  68. check_token('WHMCS.admin.default');
  69. echo '<table bgcolor="#cccccc" cellspacing="1" cellpadding="3"><tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>' . $aInt->lang('fields', 'description') . '</td><td>' . $aInt->lang('fields', 'amount') . '</td></tr>';
  70. $currency = getCurrency($userid);
  71. $result = select_query('tblinvoiceitems', '', ['invoiceid' => $id], 'id', 'ASC');
  72.  
  73. while ($data = mysql_fetch_array($result)) {
  74. $lineid = $data['id'];
  75. echo '<tr bgcolor="#ffffff"><td width="275">' . nl2br($data['description']) . '</td><td width="100" style="text-align:right;">' . formatCurrency($data['amount']) . '</td></tr>';
  76. }
  77.  
  78. $data = get_query_vals('tblinvoices', 'subtotal,credit,tax,tax2,taxrate,taxrate2,total', ['id' => $id], 'id', 'ASC');
  79. echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $aInt->lang('fields', 'subtotal') . '&nbsp;</td><td>' . formatCurrency($data['subtotal']) . '</td></tr>';
  80.  
  81. if ($CONFIG['TaxEnabled']) {
  82. if (0 < $data['tax']) {
  83. echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $data['taxrate'] . '% ' . $aInt->lang('fields', 'tax') . '&nbsp;</td><td>' . formatCurrency($data['tax']) . '</td></tr>';
  84. }
  85.  
  86. if (0 < $data['tax2']) {
  87. echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $data['taxrate2'] . '% ' . $aInt->lang('fields', 'tax') . '&nbsp;</td><td>' . formatCurrency($data['tax2']) . '</td></tr>';
  88. }
  89. }
  90.  
  91. echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $aInt->lang('fields', 'credit') . '&nbsp;</td><td>' . formatCurrency($data['credit']) . '</td></tr>';
  92. echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $aInt->lang('fields', 'totaldue') . '&nbsp;</td><td>' . formatCurrency($data['total']) . '</td></tr>';
  93. echo '</table>';
  94. exit();
  95. }
  96.  
  97. if ($action == 'createinvoice') {
  98. check_token('WHMCS.admin.default');
  99.  
  100. if (!checkActiveGateway()) {
  101. $aInt->gracefulExit($aInt->lang('gateways', 'nonesetup'));
  102. }
  103.  
  104. $gateway = getClientsPaymentMethod($userid);
  105. $invoice = WHMCS\Billing\Invoice::newInvoice($userid, $gateway);
  106. $invoice->save();
  107. $invoiceid = $invoice->id;
  108. logActivity('Created Manual Invoice - Invoice ID: ' . $invoiceid, $userid);
  109. $invoice->runCreationHooks('adminarea');
  110. redir('action=edit&id=' . $invoiceid);
  111. }
  112.  
  113. if ($action == 'checkTransactionId') {
  114. check_token('WHMCS.admin.default');
  115. $transactionId = $whmcs->get_req_var('transid');
  116. $paymentMethod = $whmcs->get_req_var('paymentmethod');
  117. $output = ['unique' => $transactionId && !isUniqueTransactionID($transactionId, $paymentMethod) ? false : true];
  118. $aInt->jsonResponse($output);
  119. }
  120.  
  121. $filters = new Filter();
  122. $selectedinvoices = $whmcs->get_req_var('selectedinvoices');
  123.  
  124. if (!is_array($selectedinvoices)) {
  125. $selectedinvoices = [];
  126. }
  127.  
  128. if ($whmcs->get_req_var('markpaid')) {
  129. check_token('WHMCS.admin.default');
  130. checkPermission('Manage Invoice');
  131. $failedInvoices = [];
  132. $invoiceCount = 0;
  133.  
  134. foreach ($selectedinvoices as $invid) {
  135. $invid = (int) $invid;
  136.  
  137. if (get_query_val('tblinvoices', 'status', ['id' => $invid]) == 'Paid') {
  138. continue;
  139. }
  140.  
  141. $paymentMethod = get_query_val('tblinvoices', 'paymentmethod', ['id' => $invid]);
  142.  
  143. if (addInvoicePayment($invid, '', '', '', $paymentMethod) === false) {
  144. $failedInvoices[] = $invid;
  145. }
  146.  
  147. $invoiceCount++;
  148. }
  149.  
  150. if (0 < count($selectedinvoices)) {
  151. $failedInvoices['successfulInvoicesCount'] = $invoiceCount - count($failedInvoices);
  152. WHMCS\Cookie::set('FailedMarkPaidInvoices', $failedInvoices);
  153. }
  154.  
  155. $filters->redir();
  156. }
  157.  
  158. if ($whmcs->get_req_var('markunpaid')) {
  159. check_token('WHMCS.admin.default');
  160. checkPermission('Manage Invoice');
  161.  
  162. foreach ($selectedinvoices as $invid) {
  163. $invid = (int) $invid;
  164. $invoice = WHMCS\Billing\Invoice::find($invid);
  165. $invoice->status = WHMCS\Billing\Invoice::STATUS_UNPAID;
  166. $invoice->dateCancelled = '0000-00-00 00:00:00';
  167. $invoice->save();
  168. logActivity('Reactivated Invoice - Invoice ID: ' . $invid, $invoice->clientId);
  169. run_hook('InvoiceUnpaid', ['invoiceid' => $invid]);
  170. }
  171.  
  172. $filters->redir();
  173. }
  174.  
  175. if ($whmcs->get_req_var('markcancelled')) {
  176. check_token('WHMCS.admin.default');
  177. checkPermission('Manage Invoice');
  178.  
  179. foreach ($selectedinvoices as $invid) {
  180. $invid = (int) $invid;
  181. $invoice = WHMCS\Billing\Invoice::find($invid);
  182. $invoice->status = WHMCS\Billing\Invoice::STATUS_CANCELLED;
  183. $invoice->dateCancelled = WHMCS\Carbon::now();
  184. $invoice->save();
  185. logActivity('Cancelled Invoice - Invoice ID: ' . $invid, $invoice->clientId);
  186. run_hook('InvoiceCancelled', ['invoiceid' => $invid]);
  187. }
  188.  
  189. $filters->redir();
  190. }
  191.  
  192. if ($whmcs->get_req_var('duplicateinvoice')) {
  193. check_token('WHMCS.admin.default');
  194.  
  195. foreach ($selectedinvoices as $invid) {
  196. $invid = (int) $invid;
  197. $invoices = new WHMCS\Invoices();
  198. $invoices->duplicate($invid);
  199. }
  200.  
  201. $filters->redir();
  202. }
  203.  
  204. if ($whmcs->get_req_var('massdelete')) {
  205. check_token('WHMCS.admin.default');
  206. checkPermission('Delete Invoice');
  207.  
  208. foreach ($selectedinvoices as $invid) {
  209. $invid = (int) $invid;
  210. $invoice = WHMCS\Billing\Invoice::find($invid);
  211. $userId = $invoice->clientId;
  212. $invoice->delete();
  213. logActivity('Deleted Invoice - Invoice ID: ' . $invid, $userId);
  214. }
  215.  
  216. $filters->redir();
  217. }
  218.  
  219. if ($whmcs->get_req_var('paymentreminder')) {
  220. check_token('WHMCS.admin.default');
  221.  
  222. foreach ($selectedinvoices as $invid) {
  223. $invid = (int) $invid;
  224. $invoice = WHMCS\Billing\Invoice::find($invid);
  225. sendMessage('Invoice Payment Reminder', $invid);
  226. logActivity('Invoice Payment Reminder Sent - Invoice ID: ' . $invid, $invoice->clientId);
  227. }
  228.  
  229. $filters->redir();
  230. }
  231.  
  232. if ($whmcs->get_req_var('delete')) {
  233. check_token('WHMCS.admin.default');
  234. checkPermission('Delete Invoice');
  235. $invoiceID = App::getFromRequest('invoiceid');
  236.  
  237. try {
  238. $invoice = WHMCS\Billing\Invoice::findOrFail($invoiceID);
  239.  
  240. if ($whmcs->get_req_var('returnCredit')) {
  241. removeCreditOnInvoiceDelete($invoice);
  242. }
  243.  
  244. $userId = $invoice->clientId;
  245. $invoice->delete();
  246. logActivity('Deleted Invoice - Invoice ID: ' . $invoiceID, $userId);
  247. }
  248. catch (Exception $e) {
  249. }
  250.  
  251. $filters->redir();
  252. }
  253.  
  254. ob_start();
  255.  
  256. if ($action == '') {
  257. $name = 'invoices';
  258. $orderby = 'duedate';
  259. $sort = 'DESC';
  260. $pageObj = new WHMCS\Pagination($name, $orderby, $sort);
  261. $pageObj->digestCookieData();
  262. $tbl = new WHMCS\ListTable($pageObj, 0, $aInt);
  263. $tbl->setColumns([
  264. 'checkall',
  265. ['id', $aInt->lang('fields', 'invoicenum')],
  266. ['clientname', $aInt->lang('fields', 'clientname')],
  267. ['date', $aInt->lang('fields', 'invoicedate')],
  268. ['duedate', $aInt->lang('fields', 'duedate')],
  269. ['last_capture_attempt', AdminLang::trans('fields.lastCaptureAttempt'), '150'],
  270. ['total', $aInt->lang('fields', 'total')],
  271. ['paymentmethod', $aInt->lang('fields', 'paymentmethod')],
  272. ['status', $aInt->lang('fields', 'status')],
  273. '',
  274. ''
  275. ]);
  276. $invoicesModel = new WHMCS\Invoices($pageObj);
  277.  
  278. if (checkPermission('View Income Totals', true)) {
  279. $invoicetotals = $invoicesModel->getInvoiceTotals();
  280.  
  281. if (count($invoicetotals)) {
  282. echo '<div class="contentbox" style="font-size:18px;">';
  283.  
  284. foreach ($invoicetotals as $vals) {
  285. echo '<b>' . $vals['currencycode'] . '</b> ' . $aInt->lang('status', 'paid') . ': <span class="textgreen"><b>' . $vals['paid'] . '</b></span> ' . $aInt->lang('status', 'unpaid') . ': <span class="textred"><b>' . $vals['unpaid'] . '</b></span> ' . $aInt->lang('status', 'overdue') . ': <span class="textblack"><b>' . $vals['overdue'] . '</b></span><br />';
  286. }
  287.  
  288. echo '</div><br />';
  289. }
  290. }
  291.  
  292. echo $aInt->beginAdminTabs([$aInt->lang('global', 'searchfilter')]);
  293. $clientid = $filters->get('clientid');
  294. $clientid = (is_numeric($clientid) ? $clientid : NULL);
  295. $invoicenum = $filters->get('invoicenum');
  296. $status = $filters->get('status');
  297.  
  298. if (!in_array($status, $validInvoiceStatuses)) {
  299. $status = '';
  300. }
  301.  
  302. echo "\n" . '<!-- Filter -->' . "\n" . '<form action="';
  303. echo $whmcs->getPhpSelf();
  304. echo '" method="post">' . "\n\n" . '<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">' . "\n" . ' <tr>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
  305. echo AdminLang::trans('fields.clientname');
  306. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' ';
  307. echo $aInt->clientSearchDropdown('clientid', $clientid, [], '', 'id');
  308. echo ' </td>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
  309. echo AdminLang::trans('fields.invoicedate');
  310. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <div class="form-group date-picker-prepend-icon">' . "\n" . ' <label for="inputInvoiceDate" class="field-icon">' . "\n" . ' <i class="fal fa-calendar-alt"></i>' . "\n" . ' </label>' . "\n" . ' <input id="inputInvoiceDate"' . "\n" . ' type="text"' . "\n" . ' name="invoicedate"' . "\n" . ' value="';
  311. echo $invoicedate = $filters->get('invoicedate');
  312. echo '"' . "\n" . ' class="form-control date-picker-search"' . "\n" . ' data-opens="left"' . "\n" . ' />' . "\n" . ' </div>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td class="fieldlabel">' . "\n" . ' ';
  313. echo AdminLang::trans('fields.invoicenum');
  314. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <input type="text"' . "\n" . ' name="invoicenum"' . "\n" . ' class="form-control input-150"' . "\n" . ' value="';
  315. echo $invoicenum = $filters->get('invoicenum');
  316. echo '"' . "\n" . ' >' . "\n" . ' </td>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
  317. echo AdminLang::trans('fields.duedate');
  318. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <div class="form-group date-picker-prepend-icon">' . "\n" . ' <label for="inputDueDate" class="field-icon">' . "\n" . ' <i class="fal fa-calendar-alt"></i>' . "\n" . ' </label>' . "\n" . ' <input id="inputDueDate"' . "\n" . ' type="text"' . "\n" . ' name="duedate"' . "\n" . ' value="';
  319. echo $duedate = $filters->get('duedate');
  320. echo '"' . "\n" . ' class="form-control date-picker-search"' . "\n" . ' data-opens="left"' . "\n" . ' />' . "\n" . ' </div>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td class="fieldlabel">' . "\n" . ' ';
  321. echo AdminLang::trans('fields.lineitem');
  322. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <input type="text"' . "\n" . ' name="lineitem"' . "\n" . ' class="form-control input-300"' . "\n" . ' value="';
  323. echo $lineitem = $filters->get('lineitem');
  324. echo '"' . "\n" . ' >' . "\n" . ' </td>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
  325. echo AdminLang::trans('fields.datepaid');
  326. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <div class="form-group date-picker-prepend-icon">' . "\n" . ' <label for="inputDatePaid" class="field-icon">' . "\n" . ' <i class="fal fa-calendar-alt"></i>' . "\n" . ' </label>' . "\n" . ' <input id="inputDatePaid"' . "\n" . ' type="text"' . "\n" . ' name="datepaid"' . "\n" . ' value="';
  327. echo $datepaid = $filters->get('datepaid');
  328. echo '"' . "\n" . ' class="form-control date-picker-search"' . "\n" . ' data-opens="left"' . "\n" . ' />' . "\n" . ' </div>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td class="fieldlabel">' . "\n" . ' ';
  329. echo AdminLang::trans('fields.paymentmethod');
  330. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' ';
  331. $paymentmethod = $filters->get('paymentmethod');
  332. echo paymentMethodsSelection(AdminLang::trans('global.any'));
  333. echo ' </td>' . "\n" . ' <td class="fieldlabel">' . "\n" . ' ';
  334. echo AdminLang::trans('fields.lastCaptureAttempt');
  335. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <div class="form-group date-picker-prepend-icon">' . "\n" . ' <label for="inputLastCaptureAttempt" class="field-icon">' . "\n" . ' <i class="fal fa-calendar-alt"></i>' . "\n" . ' </label>' . "\n" . ' <input id="inputLastCaptureAttempt"' . "\n" . ' type="text"' . "\n" . ' name="last_capture_attempt"' . "\n" . ' value="';
  336. echo $lastCaptureAttempt = $filters->get('last_capture_attempt');
  337. echo '"' . "\n" . ' class="form-control date-picker-search"' . "\n" . ' data-opens="left"' . "\n" . ' />' . "\n" . ' </div>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td class="fieldlabel">' . "\n" . ' ';
  338. echo AdminLang::trans('fields.status');
  339. echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <select name="status" class="form-control select-inline">' . "\n" . ' <option value="">' . "\n" . ' ';
  340. echo AdminLang::trans('global.any');
  341. echo ' </option>' . "\n" . ' <option value="Draft"';
  342. echo $status == 'Draft' ? ' selected="selected"' : '';
  343. echo '>' . "\n" . ' ';
  344. echo AdminLang::trans('status.draft');
  345. echo ' </option>' . "\n" . ' <option value="Unpaid"';
  346. echo $status == 'Unpaid' ? ' selected="selected"' : '';
  347. echo '>' . "\n" . ' ';
  348. echo AdminLang::trans('status.unpaid');
  349. echo ' </option>' . "\n" . ' <option value="Overdue"';
  350. echo $status == 'Overdue' ? ' selected="selected"' : '';
  351. echo '>' . "\n" . ' ';
  352. echo AdminLang::trans('status.overdue');
  353. echo ' </option>' . "\n" . ' <option value="Paid"';
  354. echo $status == 'Paid' ? ' selected="selected"' : '';
  355. echo '>' . "\n" . ' ';
  356. echo AdminLang::trans('status.paid');
  357. echo ' </option>' . "\n" . ' <option value="Cancelled"';
  358. echo $status == 'Cancelled' ? ' selected="selected"' : '';
  359. echo '>' . "\n" . ' ';
  360. echo AdminLang::trans('status.cancelled');
  361. echo ' </option>' . "\n" . ' <option value="Refunded"';
  362. echo $status == 'Refunded' ? ' selected="selected"' : '';
  363. echo '>' . "\n" . ' ';
  364. echo AdminLang::trans('status.refunded');
  365. echo ' </option>' . "\n" . ' <option value="Collections"';
  366. echo $status == 'Collections' ? ' selected="selected"' : '';
  367. .......................................................................................
  368. ...................................................
  369. ........................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement