daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Feb 9th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version         :   3.0.8.0
  8. * @ Author          :   DeZender
  9. * @ Release on      :   25.09.2017
  10. * @ Official site   :   http://DeZender.Net
  11. *
  12. */
  13.  
  14. function getClientsDetails($userid = '', $contactid = '')
  15. {
  16.     if (!($userid)) {
  17.         $userid = $_SESSION['uid'];
  18.     }
  19.  
  20.     $client = new \WHMCS\Client( $userid );
  21.     $details = $client->getDetails( $contactid );
  22.     return $details;
  23. }
  24.  
  25. function getClientsStats($userid)
  26. {
  27.     global $CONFIG;
  28.     global $currency;
  29.     $currency = getCurrency( $userid );
  30.     $stats = array(  );
  31.     $result = full_query( 'SELECT COUNT(*),SUM(total)-COALESCE(SUM((SELECT SUM(amountin)-SUM(amountout) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id)),0),(SELECT SUM(amountin-fees-amountout) FROM tblaccounts WHERE userid=' . (int) $userid . '),(SELECT credit FROM tblclients WHERE id=' . (int) $userid . ') FROM tblinvoices WHERE userid=' . (int) $userid . ' AND status=\'Unpaid\' AND (select count(id) from tblinvoiceitems where invoiceid=tblinvoices.id and type=\'Invoice\')<=0' );
  32.     $data = mysql_fetch_array( $result );
  33.     $stats['numdueinvoices'] = $data[0];
  34.     $stats['dueinvoicesbalance'] = formatCurrency( $data[1] );
  35.     $stats['income'] = formatCurrency( $data[2] );
  36.     $stats['incredit'] = ((0 < $data[3] ? true : false));
  37.     $stats['creditbalance'] = formatCurrency( $data[3] );
  38.     $result = full_query( 'SELECT COUNT(*),SUM(total)-COALESCE(SUM((SELECT SUM(amountin)-SUM(amountout) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id)),0) FROM tblinvoices WHERE userid=' . (int) $userid . ' AND status=\'Unpaid\' AND duedate<' . date( 'Ymd' ) . ' AND (select count(id) from tblinvoiceitems where invoiceid=tblinvoices.id and type=\'Invoice\')<=0' );
  39.     $data = mysql_fetch_array( $result );
  40.     $stats['numoverdueinvoices'] = $data[0];
  41.     $stats['overdueinvoicesbalance'] = formatCurrency( $data[1] );
  42.     $draftInvoices = \WHMCS\Database\Capsule::table( 'tblinvoices' )->selectRaw( 'COUNT(\'id\') as invoice_count,' . "\n" . '        SUM(total) - COALESCE(' . "\n" . '            SUM(' . "\n" . '                (' . "\n" . '                    SELECT SUM(amountin)-SUM(amountout) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id' . "\n" . '                )' . "\n" . '            ),' . "\n" . '            0' . "\n" . '        ) as balance' )->where( 'userid', '=', $userid )->where( 'status', '=', 'Draft' )->first(  );
  43.     $stats['numDraftInvoices'] = $draftInvoices->invoice_count;
  44.     $stats['draftInvoicesBalance'] = formatCurrency( $draftInvoices->balance );
  45.     $invoicestats = array(  );
  46.     $result = select_query( 'tblinvoices', 'status,COUNT(*),SUM(total)', 'userid=' . (int) $userid . ' GROUP BY status' );
  47.  
  48.     while ($data = mysql_fetch_array( $result )) {
  49.         $invoicestats[$data[0]] = $data;
  50.     }
  51.  
  52.     $stats['numpaidinvoices'] = ((isset( $invoicestats['Paid'][1] ) ? $invoicestats['Paid'][1] : 0));
  53.     $stats['paidinvoicesamount'] = ((isset( $invoicestats['Paid'][2] ) ? formatCurrency( $invoicestats['Paid'][2] ) : formatCurrency( 0 )));
  54.     $stats['numunpaidinvoices'] = ((isset( $invoicestats['Unpaid'][1] ) ? $invoicestats['Unpaid'][1] : 0));
  55.     $stats['unpaidinvoicesamount'] = ((isset( $invoicestats['Unpaid'][2] ) ? formatCurrency( $invoicestats['Unpaid'][2] ) : formatCurrency( 0 )));
  56.     $stats['numcancelledinvoices'] = ((isset( $invoicestats['Cancelled'][1] ) ? $invoicestats['Cancelled'][1] : 0));
  57.     $stats['cancelledinvoicesamount'] = ((isset( $invoicestats['Cancelled'][2] ) ? formatCurrency( $invoicestats['Cancelled'][2] ) : formatCurrency( 0 )));
  58.     $stats['numrefundedinvoices'] = ((isset( $invoicestats['Refunded'][1] ) ? $invoicestats['Refunded'][1] : 0));
  59.     $stats['refundedinvoicesamount'] = ((isset( $invoicestats['Refunded'][2] ) ? formatCurrency( $invoicestats['Refunded'][2] ) : formatCurrency( 0 )));
  60.     $stats['numcollectionsinvoices'] = ((isset( $invoicestats['Collections'][1] ) ? $invoicestats['Collections'][1] : 0));
  61.     $stats['collectionsinvoicesamount'] = ((isset( $invoicestats['Collections'][2] ) ? formatCurrency( $invoicestats['Collections'][2] ) : formatCurrency( 0 )));
  62.     $productstats = array(  );
  63.     $result = full_query( 'SELECT tblproducts.type,domainstatus,COUNT(*) FROM tblhosting INNER JOIN tblproducts ON tblhosting.packageid=tblproducts.id WHERE tblhosting.userid=' . (int) $userid . ' GROUP BY domainstatus,tblproducts.type' );
  64.  
  65.     while ($data = mysql_fetch_array( $result )) {
  66.         $productstats[$data[0]][$data[1]] = $data[2];
  67.     }
  68.  
  69.     $stats['productsnumactivehosting'] = ((isset( $productstats['hostingaccount']['Active'] ) ? $productstats['hostingaccount']['Active'] : 0));
  70.     $stats['productsnumhosting'] = 0;
  71.     if (array_key_exists( 'hostingaccount', $productstats ) && is_array( $productstats['hostingaccount'] )) {
  72.         foreach ($productstats['hostingaccount'] as $status => $count) {
  73.             $stats['productsnumhosting'] += $count;
  74.         }
  75.     }
  76.  
  77.     $stats['productsnumactivereseller'] = ((isset( $productstats['reselleraccount']['Active'] ) ? $productstats['reselleraccount']['Active'] : 0));
  78.     $stats['productsnumreseller'] = 0;
  79.     if (array_key_exists( 'reselleraccount', $productstats ) && is_array( $productstats['reselleraccount'] )) {
  80.         foreach ($productstats['reselleraccount'] as $status => $count) {
  81.             $stats['productsnumreseller'] += $count;
  82.         }
  83.     }
  84.  
  85.     $stats['productsnumactiveservers'] = ((isset( $productstats['server']['Active'] ) ? $productstats['server']['Active'] : 0));
  86.     $stats['productsnumservers'] = 0;
  87.     if (array_key_exists( 'server', $productstats ) && is_array( $productstats['server'] )) {
  88.         foreach ($productstats['server'] as $status => $count) {
  89.             $stats['productsnumservers'] += $count;
  90.         }
  91.     }
  92.  
  93.     $stats['productsnumactiveother'] = ((isset( $productstats['other']['Active'] ) ? $productstats['other']['Active'] : 0));
  94.     $stats['productsnumother'] = 0;
  95.     if (array_key_exists( 'other', $productstats ) && is_array( $productstats['other'] )) {
  96.         foreach ($productstats['other'] as $status => $count) {
  97.             $stats['productsnumother'] += $count;
  98.         }
  99.     }
  100.  
  101.     $stats['productsnumactive'] = $stats['productsnumactivehosting'] + $stats['productsnumactivereseller'] + $stats['productsnumactiveservers'] + $stats['productsnumactiveother'];
  102.     $stats['productsnumtotal'] = $stats['productsnumhosting'] + $stats['productsnumreseller'] + $stats['productsnumservers'] + $stats['productsnumother'];
  103.     $domainstats = array(  );
  104.     $result = select_query( 'tbldomains', 'status,COUNT(*)', 'userid=' . (int) $userid . ' GROUP BY status' );
  105.  
  106.     while ($data = mysql_fetch_array( $result )) {
  107.         $domainstats[$data[0]] = $data[1];
  108.     }
  109.  
  110.     $stats['numactivedomains'] = ((isset( $domainstats['Active'] ) ? $domainstats['Active'] : 0));
  111.     $stats['numdomains'] = 0;
  112.  
  113.     foreach ($domainstats as $count) {
  114.         $stats['numdomains'] += $count;
  115.     }
  116.  
  117.     $quotestats = array(  );
  118.     $result = select_query( 'tblquotes', 'stage,COUNT(*)', 'userid=' . (int) $userid . ' GROUP BY stage' );
  119.  
  120.     while ($data = mysql_fetch_array( $result )) {
  121.         $quotestats[$data[0]] = $data[1];
  122.     }
  123.  
  124.     $stats['numacceptedquotes'] = ((isset( $quotestats['Accepted'] ) ? $quotestats['Accepted'] : 0));
  125.     $stats['numquotes'] = 0;
  126.  
  127.     foreach ($quotestats as $count) {
  128.         $stats['numquotes'] += $count;
  129.     }
  130.  
  131.     $statusfilter = array(  );
  132.     $result = select_query( 'tblticketstatuses', 'title', array( 'showactive' => '1' ) );
  133.  
  134.     while ($data = mysql_fetch_array( $result )) {
  135.         $statusfilter[] = $data[0];
  136.     }
  137.  
  138.     $ticketstats = array(  );
  139.     $result = select_query( 'tbltickets', 'status,COUNT(*)', 'userid=' . (int) $userid . ' AND merged_ticket_id = 0 GROUP BY status' );
  140.  
  141.     while ($data = mysql_fetch_array( $result )) {
  142.         $ticketstats[$data[0]] = $data[1];
  143.     }
  144.  
  145.     $stats['numactivetickets'] = $stats['numtickets'] = 0;
  146.  
  147.     foreach ($ticketstats as $status => $count) {
  148.         if (in_array( $status, $statusfilter )) {
  149.             $stats['numactivetickets'] += $count;
  150.         }
  151.  
  152.         $stats['numtickets'] += $count;
  153.     }
  154.  
  155.     $result = select_query( 'tblaffiliatesaccounts', 'COUNT(*)', array( 'clientid' => $userid ), '', '', '', 'tblaffiliates ON tblaffiliatesaccounts.affiliateid=tblaffiliates.id' );
  156.     $data = mysql_fetch_array( $result );
  157.     $stats['numaffiliatesignups'] = $data[0];
  158.     $stats['isAffiliate'] = ((get_query_val( 'tblaffiliates', 'id', array( 'clientid' => (int) $userid ) ) ? true : false));
  159.     return $stats;
  160. }
  161.  
  162. /**
  163.  * Creates a dropdown list of available countries.
  164.  *
  165.  * @param string $selected
  166.  * @param string $fieldname
  167.  * @param int $tabindex
  168.  * @param bool $selectInline
  169.  * @param bool $disable
  170.  *
  171.  * @return string
  172.  */
  173. function getCountriesDropDown($selected = '', $fieldname = '', $tabindex = '', $selectInline = true, $disable = false)
  174. {
  175.     global $CONFIG;
  176.     global $_LANG;
  177.  
  178.     if (!($selected)) {
  179.         $selected = $CONFIG['DefaultCountry'];
  180.     }
  181.  
  182.     if (!($fieldname)) {
  183.         $fieldname = 'country';
  184.     }
  185.     if ($tabindex) {
  186.         $tabindex = ' tabindex="' . $tabindex . '"';
  187.     }
  188.     if ($disable) {
  189.         $disable = ' disabled';
  190.     }
  191.      else {
  192.         $disable = '';
  193. ............................................................
  194. ................................
  195. .............
RAW Paste Data
Top