Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.1.0.1
- * @ Author : DeZender
- * @ Release on : 29.08.2020
- * @ Official site : http://DeZender.Net
- *
- */
- define('ADMINAREA', true);
- require '../init.php';
- $whmcs = App::self();
- $action = $whmcs->get_req_var('action');
- $warning = $whmcs->get_req_var('warning');
- if (($action == 'edit') || ($action == 'invtooltip')) {
- $reqperm = 'Manage Invoice';
- }
- else if ($action == 'createinvoice') {
- $reqperm = 'Create Invoice';
- }
- else {
- $reqperm = 'List Invoices';
- }
- namespace WHMCS
- {
- $aInt = new Admin($reqperm);
- $aInt->requiredFiles(['clientfunctions', 'invoicefunctions', 'gatewayfunctions', 'processinvoices', 'ccfunctions']);
- $invoiceModel = NULL;
- $id = \App::getFromRequest('id');
- if ($action == 'edit') {
- $invoice = new Invoice($id);
- $invoiceModel = $invoice->getModel();
- $pageicon = 'invoicesedit';
- if ($invoice->isProformaInvoice()) {
- $pagetitle = \AdminLang::trans('fields.proformaInvoiceNum') . $invoice->getData('invoicenum');
- }
- else {
- $pagetitle = \AdminLang::trans('fields.invoicenum') . $invoice->getData('invoicenum');
- }
- }
- else {
- $pageicon = 'invoices';
- $pagetitle = $aInt->lang('invoices', 'title');
- }
- }
- namespace
- {
- $aInt->title = $pagetitle;
- $aInt->sidebar = 'billing';
- $aInt->icon = $pageicon;
- $invoiceid = (int) $whmcs->get_req_var('invoiceid');
- $status = $whmcs->get_req_var('status');
- $validInvoiceStatuses = array_merge(WHMCS\Invoices::getInvoiceStatusValues(), ['Overdue', '']);
- if (!in_array($status, $validInvoiceStatuses)) {
- $status = '';
- }
- if ($action == 'invtooltip') {
- check_token('WHMCS.admin.default');
- 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>';
- $currency = getCurrency($userid);
- $result = select_query('tblinvoiceitems', '', ['invoiceid' => $id], 'id', 'ASC');
- while ($data = mysql_fetch_array($result)) {
- $lineid = $data['id'];
- echo '<tr bgcolor="#ffffff"><td width="275">' . nl2br($data['description']) . '</td><td width="100" style="text-align:right;">' . formatCurrency($data['amount']) . '</td></tr>';
- }
- $data = get_query_vals('tblinvoices', 'subtotal,credit,tax,tax2,taxrate,taxrate2,total', ['id' => $id], 'id', 'ASC');
- echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $aInt->lang('fields', 'subtotal') . ' </td><td>' . formatCurrency($data['subtotal']) . '</td></tr>';
- if ($CONFIG['TaxEnabled']) {
- if (0 < $data['tax']) {
- echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $data['taxrate'] . '% ' . $aInt->lang('fields', 'tax') . ' </td><td>' . formatCurrency($data['tax']) . '</td></tr>';
- }
- if (0 < $data['tax2']) {
- echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $data['taxrate2'] . '% ' . $aInt->lang('fields', 'tax') . ' </td><td>' . formatCurrency($data['tax2']) . '</td></tr>';
- }
- }
- echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $aInt->lang('fields', 'credit') . ' </td><td>' . formatCurrency($data['credit']) . '</td></tr>';
- echo '<tr bgcolor="#efefef" style="text-align:right;font-weight:bold;"><td>' . $aInt->lang('fields', 'totaldue') . ' </td><td>' . formatCurrency($data['total']) . '</td></tr>';
- echo '</table>';
- exit();
- }
- if ($action == 'createinvoice') {
- check_token('WHMCS.admin.default');
- if (!checkActiveGateway()) {
- $aInt->gracefulExit($aInt->lang('gateways', 'nonesetup'));
- }
- $gateway = getClientsPaymentMethod($userid);
- $invoice = WHMCS\Billing\Invoice::newInvoice($userid, $gateway);
- $invoice->save();
- $invoiceid = $invoice->id;
- logActivity('Created Manual Invoice - Invoice ID: ' . $invoiceid, $userid);
- $invoice->runCreationHooks('adminarea');
- redir('action=edit&id=' . $invoiceid);
- }
- if ($action == 'checkTransactionId') {
- check_token('WHMCS.admin.default');
- $transactionId = $whmcs->get_req_var('transid');
- $paymentMethod = $whmcs->get_req_var('paymentmethod');
- $output = ['unique' => $transactionId && !isUniqueTransactionID($transactionId, $paymentMethod) ? false : true];
- $aInt->jsonResponse($output);
- }
- $filters = new Filter();
- $selectedinvoices = $whmcs->get_req_var('selectedinvoices');
- if (!is_array($selectedinvoices)) {
- $selectedinvoices = [];
- }
- if ($whmcs->get_req_var('markpaid')) {
- check_token('WHMCS.admin.default');
- checkPermission('Manage Invoice');
- $failedInvoices = [];
- $invoiceCount = 0;
- foreach ($selectedinvoices as $invid) {
- $invid = (int) $invid;
- if (get_query_val('tblinvoices', 'status', ['id' => $invid]) == 'Paid') {
- continue;
- }
- $paymentMethod = get_query_val('tblinvoices', 'paymentmethod', ['id' => $invid]);
- if (addInvoicePayment($invid, '', '', '', $paymentMethod) === false) {
- $failedInvoices[] = $invid;
- }
- $invoiceCount++;
- }
- if (0 < count($selectedinvoices)) {
- $failedInvoices['successfulInvoicesCount'] = $invoiceCount - count($failedInvoices);
- WHMCS\Cookie::set('FailedMarkPaidInvoices', $failedInvoices);
- }
- $filters->redir();
- }
- if ($whmcs->get_req_var('markunpaid')) {
- check_token('WHMCS.admin.default');
- checkPermission('Manage Invoice');
- foreach ($selectedinvoices as $invid) {
- $invid = (int) $invid;
- $invoice = WHMCS\Billing\Invoice::find($invid);
- $invoice->status = WHMCS\Billing\Invoice::STATUS_UNPAID;
- $invoice->dateCancelled = '0000-00-00 00:00:00';
- $invoice->save();
- logActivity('Reactivated Invoice - Invoice ID: ' . $invid, $invoice->clientId);
- run_hook('InvoiceUnpaid', ['invoiceid' => $invid]);
- }
- $filters->redir();
- }
- if ($whmcs->get_req_var('markcancelled')) {
- check_token('WHMCS.admin.default');
- checkPermission('Manage Invoice');
- foreach ($selectedinvoices as $invid) {
- $invid = (int) $invid;
- $invoice = WHMCS\Billing\Invoice::find($invid);
- $invoice->status = WHMCS\Billing\Invoice::STATUS_CANCELLED;
- $invoice->dateCancelled = WHMCS\Carbon::now();
- $invoice->save();
- logActivity('Cancelled Invoice - Invoice ID: ' . $invid, $invoice->clientId);
- run_hook('InvoiceCancelled', ['invoiceid' => $invid]);
- }
- $filters->redir();
- }
- if ($whmcs->get_req_var('duplicateinvoice')) {
- check_token('WHMCS.admin.default');
- foreach ($selectedinvoices as $invid) {
- $invid = (int) $invid;
- $invoices = new WHMCS\Invoices();
- $invoices->duplicate($invid);
- }
- $filters->redir();
- }
- if ($whmcs->get_req_var('massdelete')) {
- check_token('WHMCS.admin.default');
- checkPermission('Delete Invoice');
- foreach ($selectedinvoices as $invid) {
- $invid = (int) $invid;
- $invoice = WHMCS\Billing\Invoice::find($invid);
- $userId = $invoice->clientId;
- $invoice->delete();
- logActivity('Deleted Invoice - Invoice ID: ' . $invid, $userId);
- }
- $filters->redir();
- }
- if ($whmcs->get_req_var('paymentreminder')) {
- check_token('WHMCS.admin.default');
- foreach ($selectedinvoices as $invid) {
- $invid = (int) $invid;
- $invoice = WHMCS\Billing\Invoice::find($invid);
- sendMessage('Invoice Payment Reminder', $invid);
- logActivity('Invoice Payment Reminder Sent - Invoice ID: ' . $invid, $invoice->clientId);
- }
- $filters->redir();
- }
- if ($whmcs->get_req_var('delete')) {
- check_token('WHMCS.admin.default');
- checkPermission('Delete Invoice');
- $invoiceID = App::getFromRequest('invoiceid');
- try {
- $invoice = WHMCS\Billing\Invoice::findOrFail($invoiceID);
- if ($whmcs->get_req_var('returnCredit')) {
- removeCreditOnInvoiceDelete($invoice);
- }
- $userId = $invoice->clientId;
- $invoice->delete();
- logActivity('Deleted Invoice - Invoice ID: ' . $invoiceID, $userId);
- }
- catch (Exception $e) {
- }
- $filters->redir();
- }
- ob_start();
- if ($action == '') {
- $name = 'invoices';
- $orderby = 'duedate';
- $sort = 'DESC';
- $pageObj = new WHMCS\Pagination($name, $orderby, $sort);
- $pageObj->digestCookieData();
- $tbl = new WHMCS\ListTable($pageObj, 0, $aInt);
- $tbl->setColumns([
- 'checkall',
- ['id', $aInt->lang('fields', 'invoicenum')],
- ['clientname', $aInt->lang('fields', 'clientname')],
- ['date', $aInt->lang('fields', 'invoicedate')],
- ['duedate', $aInt->lang('fields', 'duedate')],
- ['last_capture_attempt', AdminLang::trans('fields.lastCaptureAttempt'), '150'],
- ['total', $aInt->lang('fields', 'total')],
- ['paymentmethod', $aInt->lang('fields', 'paymentmethod')],
- ['status', $aInt->lang('fields', 'status')],
- '',
- ''
- ]);
- $invoicesModel = new WHMCS\Invoices($pageObj);
- if (checkPermission('View Income Totals', true)) {
- $invoicetotals = $invoicesModel->getInvoiceTotals();
- if (count($invoicetotals)) {
- echo '<div class="contentbox" style="font-size:18px;">';
- foreach ($invoicetotals as $vals) {
- 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 />';
- }
- echo '</div><br />';
- }
- }
- echo $aInt->beginAdminTabs([$aInt->lang('global', 'searchfilter')]);
- $clientid = $filters->get('clientid');
- $clientid = (is_numeric($clientid) ? $clientid : NULL);
- $invoicenum = $filters->get('invoicenum');
- $status = $filters->get('status');
- if (!in_array($status, $validInvoiceStatuses)) {
- $status = '';
- }
- echo "\n" . '<!-- Filter -->' . "\n" . '<form action="';
- echo $whmcs->getPhpSelf();
- 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" . ' ';
- echo AdminLang::trans('fields.clientname');
- echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' ';
- echo $aInt->clientSearchDropdown('clientid', $clientid, [], '', 'id');
- echo ' </td>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
- echo AdminLang::trans('fields.invoicedate');
- 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="';
- echo $invoicedate = $filters->get('invoicedate');
- 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" . ' ';
- echo AdminLang::trans('fields.invoicenum');
- echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <input type="text"' . "\n" . ' name="invoicenum"' . "\n" . ' class="form-control input-150"' . "\n" . ' value="';
- echo $invoicenum = $filters->get('invoicenum');
- echo '"' . "\n" . ' >' . "\n" . ' </td>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
- echo AdminLang::trans('fields.duedate');
- 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="';
- echo $duedate = $filters->get('duedate');
- 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" . ' ';
- echo AdminLang::trans('fields.lineitem');
- echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <input type="text"' . "\n" . ' name="lineitem"' . "\n" . ' class="form-control input-300"' . "\n" . ' value="';
- echo $lineitem = $filters->get('lineitem');
- echo '"' . "\n" . ' >' . "\n" . ' </td>' . "\n" . ' <td width="15%" class="fieldlabel">' . "\n" . ' ';
- echo AdminLang::trans('fields.datepaid');
- 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="';
- echo $datepaid = $filters->get('datepaid');
- 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" . ' ';
- echo AdminLang::trans('fields.paymentmethod');
- echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' ';
- $paymentmethod = $filters->get('paymentmethod');
- echo paymentMethodsSelection(AdminLang::trans('global.any'));
- echo ' </td>' . "\n" . ' <td class="fieldlabel">' . "\n" . ' ';
- echo AdminLang::trans('fields.lastCaptureAttempt');
- 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="';
- echo $lastCaptureAttempt = $filters->get('last_capture_attempt');
- 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" . ' ';
- echo AdminLang::trans('fields.status');
- echo ' </td>' . "\n" . ' <td class="fieldarea">' . "\n" . ' <select name="status" class="form-control select-inline">' . "\n" . ' <option value="">' . "\n" . ' ';
- echo AdminLang::trans('global.any');
- echo ' </option>' . "\n" . ' <option value="Draft"';
- echo $status == 'Draft' ? ' selected="selected"' : '';
- echo '>' . "\n" . ' ';
- echo AdminLang::trans('status.draft');
- echo ' </option>' . "\n" . ' <option value="Unpaid"';
- echo $status == 'Unpaid' ? ' selected="selected"' : '';
- echo '>' . "\n" . ' ';
- echo AdminLang::trans('status.unpaid');
- echo ' </option>' . "\n" . ' <option value="Overdue"';
- echo $status == 'Overdue' ? ' selected="selected"' : '';
- echo '>' . "\n" . ' ';
- echo AdminLang::trans('status.overdue');
- echo ' </option>' . "\n" . ' <option value="Paid"';
- echo $status == 'Paid' ? ' selected="selected"' : '';
- echo '>' . "\n" . ' ';
- echo AdminLang::trans('status.paid');
- echo ' </option>' . "\n" . ' <option value="Cancelled"';
- echo $status == 'Cancelled' ? ' selected="selected"' : '';
- echo '>' . "\n" . ' ';
- echo AdminLang::trans('status.cancelled');
- echo ' </option>' . "\n" . ' <option value="Refunded"';
- echo $status == 'Refunded' ? ' selected="selected"' : '';
- echo '>' . "\n" . ' ';
- echo AdminLang::trans('status.refunded');
- echo ' </option>' . "\n" . ' <option value="Collections"';
- echo $status == 'Collections' ? ' selected="selected"' : '';
- .......................................................................................
- ...................................................
- ........................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement