Example #1
0
function payeer_link($params)
{
    global $_LANG;
    if (isset($params['convertto'])) {
        $params['curr'] = getCurrency(0, $params['convertto']);
    }
    $m_url = $params['payeer_url'];
    $m_shop = $params['payeer_shop'];
    $m_orderid = $params['invoiceid'];
    $m_amount = $params['amount'];
    $m_curr = $params['curr']['code'];
    $m_desc = base64_encode($params['payeer_comment']);
    $m_key = $params['payeer_secret_key'];
    $arHash = array($m_shop, $m_orderid, $m_amount, $m_curr, $m_desc, $m_key);
    $sign = strtoupper(hash('sha256', implode(':', $arHash)));
    $code = '
		<form id = "form_payment_payeer" method="GET" action="' . $m_url . '">
			<input type="hidden" name="m_shop" value="' . $m_shop . '">
			<input type="hidden" name="m_orderid" value="' . $m_orderid . '">
			<input type="hidden" name="m_amount" value="' . $m_amount . '">
			<input type="hidden" name="m_curr" value="' . $m_curr . '">
			<input type="hidden" name="m_desc" value="' . $m_desc . '">
			<input type="hidden" name="m_sign" value="' . $sign . '">
			<input type="submit" name="m_process" value="' . $_LANG['invoicespaynow'] . '" />
		</form>
		';
    return $code;
}
Example #2
0
function widget_open_invoices($vars)
{
    global $_ADMINLANG, $currency;
    $title = $_ADMINLANG['home']['openinvoices'];
    if (!function_exists("getGatewaysArray")) {
        require ROOTDIR . "/includes/gatewayfunctions.php";
    }
    $gatewaysarray = getGatewaysArray();
    $content = '<table class="table table-condensed">
<tr style="background-color:#efefef;font-weight:bold;text-align:center"><td>' . $_ADMINLANG['fields']['invoicenum'] . '</td><td>' . $_ADMINLANG['fields']['clientname'] . '</td><td>' . $_ADMINLANG['fields']['invoicedate'] . '</td><td>' . $_ADMINLANG['fields']['duedate'] . '</td><td>' . $_ADMINLANG['fields']['totaldue'] . '</td><td>' . $_ADMINLANG['fields']['paymentmethod'] . '</td><td width="20"></td></tr>
';
    $id = '';
    $query = "SELECT tblinvoices.*,tblinvoices.total-COALESCE((SELECT SUM(amountin) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id),0) AS invoicebalance,tblclients.firstname,tblclients.lastname FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.status='Unpaid' ORDER BY duedate,date ASC LIMIT 0,5";
    $result = full_query($query);
    while ($data = mysql_fetch_array($result)) {
        $id = $data["id"];
        $invoicenum = $data["invoicenum"];
        $userid = $data["userid"];
        $firstname = $data["firstname"];
        $lastname = $data["lastname"];
        $date = $data["date"];
        $duedate = $data["duedate"];
        $total = $data["total"];
        $invoicebalance = $data["invoicebalance"];
        $paymentmethod = $data["paymentmethod"];
        $paymentmethod = $gatewaysarray[$paymentmethod];
        $date = fromMySQLDate($date);
        $duedate = fromMySQLDate($duedate);
        $currency = getCurrency($userid);
        if (!$invoicenum) {
            $invoicenum = $id;
        }
        $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="invoices.php?action=edit&id=' . $id . '">' . $invoicenum . '</a></td><td>' . $firstname . ' ' . $lastname . '</td><td>' . $date . '</td><td>' . $duedate . '</td><td>' . formatCurrency($total) . '</td><td>' . $paymentmethod . '</td><td><a href="invoices.php?action=edit&id=' . $id . '"><img src="images/edit.gif" border="0" /></a></td></tr>';
    }
    if (!$id) {
        $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">' . $_ADMINLANG['global']['norecordsfound'] . '</td></tr>';
    }
    $content .= '</table>
<div class="widget-footer">
    <a href="invoices.php?status=Unpaid" class="btn btn-info btn-sm">' . $_ADMINLANG['home']['viewall'] . ' &raquo;</a>
</div>';
    return array('title' => $title, 'content' => $content);
}
Example #3
0
function chartdata_income()
{
    global $currency;
    $currency = getCurrency();
    $chartdata = array();
    $chartdata['cols'][] = array('label' => 'Day', 'type' => 'string');
    $chartdata['cols'][] = array('label' => 'Income', 'type' => 'number');
    $chartdata['cols'][] = array('label' => 'Expenditure/Refunds', 'type' => 'number');
    for ($i = 14; $i >= 0; $i--) {
        $date = mktime(0, 0, 0, date("m"), date("d") - $i, date("Y"));
        $data = get_query_vals("tblaccounts", "SUM(amountin/rate),SUM(amountout/rate)", "date LIKE '" . date("Y-m-d", $date) . "%'");
        if (!$data[0]) {
            $data[0] = 0;
        }
        if (!$data[1]) {
            $data[1] = 0;
        }
        $chartdata['rows'][] = array('c' => array(array('v' => date("dS", $date)), array('v' => (int) $data[0], 'f' => formatCurrency($data[0])), array('v' => (int) $data[1], 'f' => formatCurrency($data[1]))));
    }
    return $chartdata;
}
Example #4
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
function tcoconvertcurrency($amount, $currency, $invoiceid)
{
    $result = select_query("tblcurrencies", "id", array("code" => $currency));
    $data = mysql_fetch_array($result);
    $currencyid = $data['id'];
    if (!$currencyid) {
        logTransaction($GATEWAY['name'], $_POST, "Unrecognised Currency");
        exit;
    }
    $result = select_query("tblinvoices", "userid,total", array("id" => $invoiceid));
    $data = mysql_fetch_array($result);
    $userid = $data['userid'];
    $total = $data['total'];
    $currency = getCurrency($userid);
    if ($currencyid != $currency['id']) {
        $amount = convertCurrency($amount, $currencyid, $currency['id']);
        if ($total < $amount + 1 && $amount - 1 < $total) {
            $amount = $total;
        }
    }
    return $amount;
}
    die("This file cannot be accessed directly");
}
$reportdata["title"] = "Direct Debit Processing";
$reportdata["description"] = "This report displays all Unpaid invoices assigned to the Direct Debit payment method and the associated bank account details stored for their owners ready for processing";
$reportdata["tableheadings"] = array("Invoice ID", "Client Name", "Invoice Date", "Due Date", "Subtotal", "Tax", "Credit", "Total", "Bank Name", "Bank Account Type", "Bank Code", "Bank Account Number");
$query = "SELECT tblinvoices.*,tblclients.firstname,tblclients.lastname,tblclients.bankname,tblclients.banktype,tblclients.bankcode,tblclients.bankacct FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.paymentmethod='directdebit' AND tblinvoices.status='Unpaid' ORDER BY duedate ASC";
$result = full_query($query);
while ($data = mysql_fetch_array($result)) {
    $id = $data["id"];
    $userid = $data["userid"];
    $client = $data["firstname"] . " " . $data["lastname"];
    $date = $data["date"];
    $duedate = $data["duedate"];
    $subtotal = $data["subtotal"];
    $credit = $data["credit"];
    $tax = $data["tax"] + $data["tax2"];
    $total = $data["total"];
    $bankname = $data["bankname"];
    $banktype = $data["banktype"];
    $bankcode = $data["bankcode"];
    $bankacct = $data["bankacct"];
    $currency = getCurrency($userid);
    $date = fromMySQLDate($date);
    $duedate = fromMySQLDate($duedate);
    $subtotal = formatCurrency($subtotal);
    $credit = formatCurrency($credit);
    $tax = formatCurrency($tax);
    $total = formatCurrency($total);
    $reportdata["tablevalues"][] = array('<a href="invoices.php?action=edit&id=' . $id . '">' . $id . '</a>', $client, $date, $duedate, $subtotal, $tax, $credit, $total, $bankname, $banktype, $bankcode, $bankacct);
}
$reportdata["footertext"] = "";
    die("This file cannot be accessed directly");
}
$reportdata["title"] = "Affiliates Overview";
$reportdata["description"] = "An overview of affiliates for the current year";
$reportdata["tableheadings"] = array('Affiliate ID', 'Affiliate Name', 'Visitors', 'Pending Commissions', 'Available to Withdraw', 'Withdrawn Amount', 'YTD Total Commissions Paid');
$result = select_query("tblaffiliates", "tblaffiliates.id,tblaffiliates.clientid,tblaffiliates.visitors,tblaffiliates.balance,tblaffiliates.withdrawn,tblclients.firstname,tblclients.lastname,tblclients.companyname", "", "visitors", "DESC", "", "tblclients ON tblclients.id=tblaffiliates.clientid");
while ($data = mysql_fetch_array($result)) {
    $affid = $data['id'];
    $clientid = $data['clientid'];
    $visitors = $data['visitors'];
    $balance = $data['balance'];
    $withdrawn = $data['withdrawn'];
    $firstname = $data['firstname'];
    $lastname = $data['lastname'];
    $companyname = $data['companyname'];
    $name = $firstname . ' ' . $lastname;
    if ($companyname) {
        $name .= ' (' . $companyname . ')';
    }
    $result2 = select_query("tblaffiliatespending", "COUNT(*),SUM(tblaffiliatespending.amount)", array("affiliateid" => $affid), "clearingdate", "DESC", "", "tblaffiliatesaccounts ON tblaffiliatesaccounts.id=tblaffiliatespending.affaccid INNER JOIN tblhosting ON tblhosting.id=tblaffiliatesaccounts.relid INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid INNER JOIN tblclients ON tblclients.id=tblhosting.userid");
    $data = mysql_fetch_array($result2);
    $pendingcommissions = $data[0];
    $pendingcommissionsamount = $data[1];
    $result2 = select_query("tblaffiliateshistory", "SUM(amount)", "affiliateid={$affid} AND date LIKE '" . date("Y") . "-%'");
    $data = mysql_fetch_array($result2);
    $ytdtotal = $data[0];
    $currency = getCurrency($clientid);
    $pendingcommissionsamount = formatCurrency($pendingcommissionsamount);
    $ytdtotal = formatCurrency($ytdtotal);
    $reportdata["tablevalues"][] = array('<a href="affiliates.php?action=edit&id=' . $affid . '">' . $affid . '</a>', $name, $visitors, $pendingcommissionsamount, $balance, $withdrawn, $ytdtotal);
}
Example #7
0
 function tco_reoccuring_request()
 {
     global $whmcs;
     $whmcs->load_function("gateway");
     $whmcs->load_function("client");
     $whmcs->load_function("invoice");
     $GATEWAY = getGatewayVariables("tco");
     $invoiceid = $description = (int) $_POST['invoiceid'];
     $vendorid = $GATEWAY['vendornumber'];
     $apiusername = $GATEWAY['apiusername'];
     $apipassword = $GATEWAY['apipassword'];
     $demomode = $GATEWAY['demomode'];
     $recurrings = getRecurringBillingValues($invoiceid);
     if (!$recurrings) {
         $url = "../../viewinvoice.php?id=" . $invoiceid;
         header("Location:" . $url);
         exit;
     }
     $primaryserviceid = $recurrings['primaryserviceid'];
     $first_payment_amount = $recurrings['firstpaymentamount'] ? $recurrings['firstpaymentamount'] : $recurrings['recurringamount'];
     $recurring_amount = $recurrings['recurringamount'];
     if ($recurrings['recurringcycleunits'] == "Months") {
         $billing_cycle = $recurrings['recurringcycleperiod'] . " Month";
     } else {
         if ($recurrings['recurringcycleunits'] == "Years") {
             $billing_cycle = $recurrings['recurringcycleperiod'] . " Year";
         }
     }
     $billing_duration = "Forever";
     $startup_fee = $first_payment_amount - $recurring_amount;
     $url = "https://www.2checkout.com/api/products/create_product";
     $name = "Recurring Subscription for Invoice #" . $invoiceid;
     if ($demomode = "on") {
         $query_string = "name=" . $name . "&price=" . $recurring_amount . "&startup_fee=" . $startup_fee . "&demo=Y&recurring=1&recurrence=" . $billing_cycle . "&duration=" . $billing_duration . "&description=" . $description;
     } else {
         $query_string = "name=" . $name . "&price=" . $recurring_amount . "&startup_fee=" . $startup_fee . "&recurring=1&recurrence=" . $billing_cycle . "&duration=" . $billing_duration . "&description=" . $description;
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERPWD, $apiusername . ":" . $apipassword);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
     $response = curl_exec($ch);
     curl_close($ch);
     if (!function_exists("json_decode")) {
         exit("JSON Module Required in PHP Build for 2CheckOut Gateway");
     }
     $response = json_decode($response, true);
     if (!count($response['errors']) && $response['response_code'] == "OK") {
         logTransaction("2Checkout Recurring", print_r($response, true), "Ok");
         $product_id = $response['product_id'];
         $assigned_product_id = $response['assigned_product_id'];
         $purchaseroutine = !$GATEWAY['purchaseroutine'] ? "s" : "";
         $result = select_query("tblinvoices", "userid", array("id" => $invoiceid));
         $data = mysql_fetch_array($result);
         $userid = $data[0];
         $clientsdetails = getClientsDetails($userid);
         $currency = getCurrency($userid);
         global $CONFIG;
         $lang = $clientsdetails['language'];
         if (!$lang) {
             $lang = $CONFIG['Language'];
         }
         $lang = strtolower($lang);
         if ($lang == "chinese") {
             $lang = "zh";
         } else {
             if ($lang == "danish") {
                 $lang = "da";
             } else {
                 if ($lang == "dutch") {
                     $lang = "nl";
                 } else {
                     if ($lang == "french") {
                         $lang = "fr";
                     } else {
                         if ($lang == "german") {
                             $lang = "gr";
                         } else {
                             if ($lang == "greek") {
                                 $lang = "el";
                             } else {
                                 if ($lang == "italian") {
                                     $lang = "it";
                                 } else {
                                     if ($lang == "japanese") {
                                         $lang = "jp";
                                     } else {
                                         if ($lang == "norwegian") {
                                             $lang = "no";
                                         } else {
                                             if ($lang == "portuguese") {
                                                 $lang = "pt";
                                             } else {
                                                 if ($lang == "slovenian") {
                                                     $lang = "sl";
                                                 } else {
                                                     if ($lang == "spanish") {
                                                         $lang = "es_la";
                                                     } else {
                                                         if ($lang == "swedish") {
                                                             $lang = "sv";
                                                         } else {
                                                             if ($lang == "english") {
                                                                 $lang = "en";
                                                             } else {
                                                                 $lang = "";
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($lang) {
             $lang = "&lang=" . $lang;
         }
         if ($clientsdetails['country'] != "US" || $clientsdetails['country'] != "CA") {
             $clientsdetails['state'] = "XX";
         }
         $url = "https://www.2checkout.com/checkout/" . $purchaseroutine . "purchase?sid=" . $vendorid . "&quantity=1&product_id=" . $assigned_product_id . "&tco_currency=" . $currency['code'] . "&merchant_order_id=" . $primaryserviceid . "&card_holder_name=" . $clientsdetails['firstname'] . " " . $clientsdetails['lastname'] . "&street_address=" . $clientsdetails['address1'] . "&city=" . $clientsdetails['city'] . "&state=" . $clientsdetails['state'] . "&zip=" . $clientsdetails['postcode'] . "&country=" . $clientsdetails['country'] . "&email=" . $clientsdetails['email'] . "&phone=" . $clientsdetails['phonenumber'] . $lang;
         header("Location:" . $url);
         exit;
         return null;
     }
     $apierror = "Errors => " . print_r($response, true);
     logTransaction("2Checkout Recurring", $apierror, "Error");
     $url = "../../viewinvoice.php?id=" . $invoiceid . "&paymentfailed=true";
     header("Location:" . $url);
     exit;
 }
Example #8
0
 public function getBalanceFormatted()
 {
     global $currency;
     $userid = $this->getData("userid");
     $currency = getCurrency($userid);
     $balance = $this->getData("balance");
     return "<span class=\"" . (0 < $balance ? "textred" : "textgreen") . "\">" . formatCurrency($balance) . "</span>";
 }
Example #9
0
             }
             $filename = trim($filename);
             $filename = preg_replace("/[^a-zA-Z0-9-_. ]/", "", $filename);
             mt_srand(time());
             $rand = mt_rand(100000, 999999);
             $newfilename = $rand . "_" . $filename;
             move_uploaded_file($_FILES['attachments']['tmp_name'][$num], $projectsdir . $newfilename);
             $attachments[] = $newfilename;
             update_query("mod_project", array("attachments" => implode(",", $attachments)), array("id" => $projectid));
             project_management_log($projectid, $vars['_lang']['clientaddedattachment'] . " " . $filename);
         }
     }
     redir("m=project_management&a=view&id=" . $projectid);
 }
 global $currency;
 $currency = getCurrency($_SESSION['uid']);
 $tplvars['project'] = array("id" => $data['id'], "title" => $data['title'], "adminid" => $data['adminid'], "adminname" => get_query_val("tbladmins", "CONCAT(firstname,' ',lastname)", array("id" => $data['adminid'])), "created" => fromMySQLDate($data['created'], 0, 1), "duedate" => fromMySQLDate($data['duedate'], 0, 1), "duein" => project_management_daysleft($data['duedate']), "lastmodified" => fromMySQLDate($data['lastmodified'], 0, 1), "totaltime" => $totaltime, "status" => $data['status']);
 if (!$tplvars['project']['adminname']) {
     $tplvars['project']['adminname'] = "None";
 }
 $ticketids = $data['ticketids'];
 $invoiceids = $data['invoiceids'];
 $attachments = $data['attachments'];
 $ticketinvoicelinks = $tickets = $invoices = $attachmentsarray = array();
 $ticketids = explode(",", $ticketids);
 foreach ($ticketids as $ticketnum) {
     if ($ticketnum) {
         $result = select_query("tbltickets", "id,tid,c,title,status,lastreply", array("tid" => $ticketnum));
         $data = mysql_fetch_array($result);
         $ticketid = $data['id'];
         if ($ticketid) {
Example #10
0
function getAdminHomeStats($type = "")
{
    global $currency;
    $stats = array();
    $currency = getCurrency(0, 1);
    if (!$type || $type == "income") {
        $result = full_query("SELECT SUM((amountin-fees-amountout)/rate) FROM tblaccounts WHERE date LIKE '" . date("Y-m-d") . "%'");
        $data = mysql_fetch_array($result);
        $todaysincome = formatCurrency($data[0]);
        $stats['income']['today'] = $todaysincome;
        $result = full_query("SELECT SUM((amountin-fees-amountout)/rate) FROM tblaccounts WHERE date LIKE '" . date("Y-m-") . "%'");
        $data = mysql_fetch_array($result);
        $todaysincome = formatCurrency($data[0]);
        $stats['income']['thismonth'] = $todaysincome;
        $result = full_query("SELECT SUM((amountin-fees-amountout)/rate) FROM tblaccounts WHERE date LIKE '" . date("Y-") . "%'");
        $data = mysql_fetch_array($result);
        $todaysincome = formatCurrency($data[0]);
        $stats['income']['thisyear'] = $todaysincome;
        if ($type == "income") {
            return $stats;
        }
    }
    $result = full_query("SELECT SUM(total)-COALESCE(SUM((SELECT SUM(amountin) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id)),0) FROM tblinvoices WHERE tblinvoices.status='Unpaid' AND duedate<'" . date("Ymd") . "'");
    $data = mysql_fetch_array($result);
    $overdueinvoices = $data[0];
    $stats['invoices']['overduebalance'] = $data[1];
    $result = full_query("SELECT COUNT(*) FROM tblcancelrequests INNER JOIN tblhosting ON tblhosting.id=tblcancelrequests.relid WHERE (tblhosting.domainstatus!='Cancelled' AND tblhosting.domainstatus!='Terminated')");
    $data = mysql_fetch_array($result);
    $stats['cancellations']['pending'] = $data[0];
    $stats['orders']['today']['active'] = $stats['orders']['today']['fraud'] = $stats['orders']['today']['pending'] = $stats['orders']['today']['cancelled'] = 0;
    $query = "SELECT status,COUNT(*) FROM tblorders WHERE date LIKE '" . date("Y-m-d") . "%' GROUP BY status";
    $result = full_query($query);
    while ($data = mysql_fetch_array($result)) {
        $stats['orders']['today'][strtolower($data[0])] = $data[1];
    }
    $stats['orders']['today']['total'] = $stats['orders']['today']['active'] + $stats['orders']['today']['fraud'] + $stats['orders']['today']['pending'] + $stats['orders']['today']['cancelled'];
    $stats['orders']['yesterday']['active'] = $stats['orders']['yesterday']['fraud'] = $stats['orders']['yesterday']['pending'] = $stats['orders']['yesterday']['cancelled'] = 0;
    $query = "SELECT status,COUNT(*) FROM tblorders WHERE date LIKE '" . date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . "%' GROUP BY status";
    $result = full_query($query);
    while ($data = mysql_fetch_array($result)) {
        $stats['orders']['yesterday'][strtolower($data[0])] = $data[1];
    }
    $stats['orders']['yesterday']['total'] = $stats['orders']['yesterday']['active'] + $stats['orders']['yesterday']['fraud'] + $stats['orders']['yesterday']['pending'] + $stats['orders']['yesterday']['cancelled'];
    $query = "SELECT COUNT(*) FROM tblorders WHERE date LIKE '" . date("Y-m-") . "%'";
    $result = full_query($query);
    $data = mysql_fetch_array($result);
    $stats['orders']['thismonth']['total'] = $data[0];
    $query = "SELECT COUNT(*) FROM tblorders WHERE date LIKE '" . date("Y-") . "%'";
    $result = full_query($query);
    $data = mysql_fetch_array($result);
    $stats['orders']['thisyear']['total'] = $data[0];
    global $disable_admin_ticket_page_counts;
    if (!$disable_admin_ticket_page_counts) {
        $allactive = $awaitingreply = 0;
        $ticketcounts = array();
        $query = "SELECT tblticketstatuses.title,(SELECT COUNT(*) FROM tbltickets WHERE tbltickets.status=tblticketstatuses.title),showactive,showawaiting FROM tblticketstatuses ORDER BY sortorder ASC";
        $result = full_query($query);
        while ($data = mysql_fetch_array($result)) {
            $stats['tickets'][preg_replace("/[^a-z0-9]/", "", strtolower($data[0]))] = $data[1];
            if ($data['showactive']) {
                $allactive += $data[1];
            }
            if ($data['showawaiting']) {
                $awaitingreply += $data[1];
            }
        }
        $result = select_query("tbltickets", "COUNT(*)", "status!='Closed' AND flag='" . (int) $_SESSION['adminid'] . "'");
        $data = mysql_fetch_array($result);
        $flaggedtickets = $data[0];
        $stats['tickets']['allactive'] = $allactive;
        $stats['tickets']['awaitingreply'] = $awaitingreply;
        $stats['tickets']['flaggedtickets'] = $flaggedtickets;
    }
    $query = "SELECT COUNT(*) FROM tbltodolist WHERE status!='Completed' AND status!='Postponed' AND duedate<='" . date("Y-m-d") . "'";
    $result = full_query($query);
    $data = mysql_fetch_array($result);
    $stats['todoitems']['due'] = $data[0];
    $query = "SELECT COUNT(*) FROM tblnetworkissues WHERE status!='Scheduled' AND status!='Resolved'";
    $result = full_query($query);
    $data = mysql_fetch_array($result);
    $stats['networkissues']['open'] = $data[0];
    $result = select_query("tblbillableitems", "COUNT(*)", array("invoicecount" => "0"));
    $data = mysql_fetch_array($result);
    $stats['billableitems']['uninvoiced'] = $data[0];
    $result = select_query("tblquotes", "COUNT(*)", array("validuntil" => array("sqltype" => ">", "value" => date("Ymd"))));
    $data = mysql_fetch_array($result);
    $stats['quotes']['valid'] = $data[0];
    return $stats;
}
Example #11
0
function widget_income_forecast($vars)
{
    global $whmcs, $_ADMINLANG, $currency, $currencytotal, $data;
    $title = $_ADMINLANG['home']['incomeforecast'];
    function ah_formatstat($billingcycle, $stat)
    {
        global $data, $currency, $currencytotal;
        $value = array_key_exists($billingcycle, $data) ? $data[$billingcycle][$stat] : '';
        if (!$value) {
            $value = 0;
        }
        if ($stat == "sum") {
            if ($billingcycle == "Monthly") {
                $currencytotal += $value * 12;
            } elseif ($billingcycle == "Quarterly") {
                $currencytotal += $value * 4;
            } elseif ($billingcycle == "Semi-Annually") {
                $currencytotal += $value * 2;
            } elseif ($billingcycle == "Annually") {
                $currencytotal += $value;
            } elseif ($billingcycle == "Biennially") {
                $currencytotal += $value / 2;
            } elseif ($billingcycle == "Triennially") {
                $currencytotal += $value / 3;
            }
            $value = formatCurrency($value);
        }
        return $value;
    }
    $incomestats = array();
    $result = select_query("tblhosting,tblclients", "currency,billingcycle,COUNT(*),SUM(amount)", "tblclients.id = tblhosting.userid AND (domainstatus = 'Active' OR domainstatus = 'Suspended') GROUP BY currency, billingcycle");
    while ($data = mysql_fetch_array($result)) {
        $incomestats[$data['currency']][$data['billingcycle']]["count"] = $data[2];
        $incomestats[$data['currency']][$data['billingcycle']]["sum"] = $data[3];
    }
    $result = select_query("tblhostingaddons,tblhosting,tblclients", "currency,tblhostingaddons.billingcycle,COUNT(*),SUM(recurring)", "tblhostingaddons.hostingid=tblhosting.id AND tblclients.id=tblhosting.userid AND (tblhostingaddons.status='Active' OR tblhostingaddons.status='Suspended') GROUP BY currency, tblhostingaddons.billingcycle");
    while ($data = mysql_fetch_array($result)) {
        if (isset($incomestats[$data['currency']][$data['billingcycle']]["count"])) {
            $incomestats[$data['currency']][$data['billingcycle']]["count"] += $data[2];
        } else {
            $incomestats[$data['currency']][$data['billingcycle']]["count"] = $data[2];
        }
        if (isset($incomestats[$data['currency']][$data['billingcycle']]["sum"])) {
            $incomestats[$data['currency']][$data['billingcycle']]["sum"] += $data[3];
        } else {
            $incomestats[$data['currency']][$data['billingcycle']]["sum"] = $data[3];
        }
    }
    $result = select_query("tbldomains,tblclients", "currency,COUNT(*),SUM(recurringamount/registrationperiod)", "tblclients.id=tbldomains.userid AND tbldomains.status='Active' GROUP BY currency");
    while ($data = mysql_fetch_array($result)) {
        if (isset($incomestats[$data['currency']]["Annually"]["count"])) {
            $incomestats[$data['currency']]["Annually"]["count"] += $data[1];
        } else {
            $incomestats[$data['currency']]["Annually"]["count"] = $data[1];
        }
        if (isset($incomestats[$data['currency']]["Annually"]["sum"])) {
            $incomestats[$data['currency']]["Annually"]["sum"] += $data[2];
        } else {
            $incomestats[$data['currency']]["Annually"]["sum"] = $data[2];
        }
    }
    $content = '';
    if (count($incomestats)) {
        $content = '<div class="row">';
        foreach ($incomestats as $currency => $data) {
            $currency = getCurrency("", $currency);
            $currencytotal = 0;
            $content .= '<div class="' . (count($incomestats) > 1 ? 'col-md-6' : '') . ' text-center">' . "<span class=\"textred\"><b>{$currency['code']} " . $_ADMINLANG['currencies']['currency'] . "</b></span><br />\n    " . $_ADMINLANG['billingcycles']['monthly'] . ": " . ah_formatstat('Monthly', 'sum') . " (" . ah_formatstat('Monthly', 'count') . ")<br />\n    " . $_ADMINLANG['billingcycles']['quarterly'] . ": " . ah_formatstat('Quarterly', 'sum') . " (" . ah_formatstat('Quarterly', 'count') . ")<br />\n    " . $_ADMINLANG['billingcycles']['semiannually'] . ": " . ah_formatstat('Semi-Annually', 'sum') . " (" . ah_formatstat('Semi-Annually', 'count') . ")<br />\n    " . $_ADMINLANG['billingcycles']['annually'] . ": " . ah_formatstat('Annually', 'sum') . " (" . ah_formatstat('Annually', 'count') . ")<br />\n    " . $_ADMINLANG['billingcycles']['biennially'] . ": " . ah_formatstat('Biennially', 'sum') . " (" . ah_formatstat('Biennially', 'count') . ")<br />\n    " . $_ADMINLANG['billingcycles']['triennially'] . ": " . ah_formatstat('Triennially', 'sum') . " (" . ah_formatstat('Triennially', 'count') . ")<br />\n    <span class=\"textgreen\"><b>" . $_ADMINLANG['billing']['annualestimate'] . ": " . formatCurrency($currencytotal) . "</b></span></div>";
        }
        $content .= '</div>';
    } else {
        $content = '<div align="center">No Active or Suspended Products/Services Found to build Forecast</div>';
    }
    $content = '<div id="incomeforecast">' . $content . '</div>';
    return array('title' => $title, 'content' => $content);
}
Example #12
0
}
$gatewaysarray = array();
$result = select_query("tblpaymentgateways", "gateway", array("setting" => "name"));
while ($data = mysql_fetch_array($result)) {
    $gatewaysarray[] = $data['gateway'];
}
if (!in_array($paymentmethod, $gatewaysarray)) {
    $apiresults = array("result" => "error", "message" => "Invalid Payment Method. Valid options include " . implode(",", $gatewaysarray));
    return null;
}
if ($clientip) {
    $remote_ip = $clientip;
}
$_SESSION['uid'] = $_POST['clientid'];
global $currency;
$currency = getCurrency($_POST['clientid']);
$_SESSION['cart'] = array();
if (is_array($pid)) {
    foreach ($pid as $i => $prodid) {
        if ($prodid) {
            $proddomain = $domain[$i];
            $prodbillingcycle = $billingcycle[$i];
            $configoptionsarray = array();
            $customfieldsarray = array();
            $domainfieldsarray = array();
            $addonsarray = array();
            if ($addons[$i]) {
                $addonsarray = explode(",", $addons[$i]);
            }
            if ($configoptions[$i]) {
                $configoptionsarray = unserialize(base64_decode($configoptions[$i]));
function hook_stregistrar_OrderDomainPricingOverride($params)
{
    $domain = explode('.', $params['domain']);
    $sld = $domain[0];
    $tld = '.' . $domain[1];
    $config = __getSTRegistrarModuleConfig();
    $premiumFee = 0;
    if (strlen($sld) == 2) {
        $premiumFee = $config['twoLetterFee'];
    } elseif (strlen($sld) == 1) {
        $premiumFee = $config['oneLetterFee'];
    }
    $currency = getCurrency($_SESSION['uid']);
    if (($regularPrice = __getDomainRegistrationPrice($tld, $params['regperiod'], $currency['id'])) === false) {
        die;
        return false;
    }
    $total = $regularPrice + $premiumFee * $currency['rate'];
    ob_clean();
    return $total;
}
Example #14
0
$filter_base = sprintf("sort=%d&filter[start_date]=%s&filter[end_date]=%s&filter[textsearch]=%s&filter[amount]=%s&view=%s", $_GET['sort'], $filter['start_date'], $filter['end_date'], isset($filter['textsearch']) ? $filter['textsearch'] : '', isset($filter['amount']) ? $filter['amount'] : '', $view);
$result = WFO::SQL($q);
$total_shown = 0;
$count = 1;
$prev_date = "";
$cur_date = $ts_start_date;
while ($tr = mysql_fetch_object($result)) {
    //id des factures liées
    $id_invoices = array();
    $result_invoices = mysql_query("SELECT id_invoice as id , num_facture , ref_contrat " . "FROM webfinance_transaction_invoice AS wf_tr_inv LEFT JOIN webfinance_invoices AS wf_inv ON (wf_tr_inv.id_invoice = wf_inv.id_facture) " . "WHERE wf_tr_inv.id_transaction=" . $tr->id) or wf_mysqldie();
    while ($invoice_obj = mysql_fetch_object($result_invoices)) {
        $id_invoices[] = $invoice_obj;
    }
    mysql_free_result($result_invoices);
    //currency
    list($currency, $ex) = getCurrency($tr->id_account);
    if (empty($tr->exchange_rate)) {
        $tr->exchange_rate = 1;
    }
    //s�parer les mois
    $current_month = ucfirst(strftime("%B %Y", $tr->ts_date));
    if (!empty($prev_date)) {
        if (date("m", $prev_date) != date("m", $tr->ts_date)) {
            echo "<tr class=\"row_even\"><td colspan='8' align='center'><b>{$current_month}</b></td></tr>";
        }
    } else {
        echo "<tr class=\"row_even\"><td colspan='8' align='center'><b>{$current_month}</b></td></tr>";
        $cur_date = $tr->ts_date;
    }
    $prev_date = $tr->ts_date;
    $total_shown += $tr->amount / $tr->exchange_rate;
Example #15
0
 // Get transaction
 $transactionQuery = select_query('gateway_mollie', '', array('paymentid' => $_POST['id']), null, null, 1);
 if (mysql_num_rows($transactionQuery) != 1) {
     logTransaction('mollieunknown', $_POST, 'Callback - Failure 2 (Transaction not found)');
     header('HTTP/1.1 500 Transaction not found');
     exit;
 }
 $transaction = mysql_fetch_assoc($transactionQuery);
 $_GATEWAY = getGatewayVariables('mollie' . $transaction['method']);
 if ($transaction['status'] != 'open') {
     logTransaction($_GATEWAY['paymentmethod'], array_merge($transaction, $_POST), 'Callback - Failure 3 (Transaction not open)');
     header('HTTP/1.1 500 Transaction not open');
     exit;
 }
 // Get user and transaction currencies
 $userCurrency = getCurrency($transaction['userid']);
 $transactionCurrency = select_query('tblcurrencies', '', array('id' => $transaction['currencyid']));
 $transactionCurrency = mysql_fetch_assoc($transactionCurrency);
 // Check payment
 $mollie = new Mollie_API_Client();
 $mollie->setApiKey($_GATEWAY['key']);
 $payment = $mollie->payments->get($_POST['id']);
 if ($payment->isPaid()) {
     // Add conversion, when there is need to. WHMCS only supports currencies per user. WHY?!
     if ($transactionCurrency['id'] != $userCurrency['id']) {
         $transaction['amount'] = convertCurrency($transaction['amount'], $transaction['currencyid'], $userCurrency['id']);
     }
     // Check invoice
     $invoiceid = checkCbInvoiceID($transaction['invoiceid'], $_GATEWAY['paymentmethod']);
     checkCbTransID($transaction['paymentid']);
     // Add invoice
Example #16
0
function getCurrencyName()
{
    $currency = getCurrency();
    return $currency['name'];
}
Example #17
0
    $fieldlist = array();
    foreach ($incfields as $fieldname) {
        if (array_key_exists($fieldname, $filterfields)) {
            $reportdata["tableheadings"][] = $filterfields[$fieldname];
            if ($fieldname == "clientname") {
                $fieldname = "(SELECT CONCAT(firstname,' ',lastname) FROM tblclients WHERE id=tblaccounts.userid)";
            }
            $fieldlist[] = $fieldname;
        }
    }
    if (in_array('currency', $incfields) && !in_array('userid', $incfields)) {
        $fieldlist[] = 'userid';
    }
    if ($whmcs->get_req_var('datefrom') && $whmcs->get_req_var('dateto')) {
        $filters[] = "date>='" . toMySQLDate($whmcs->get_req_var('datefrom')) . "' AND date<='" . toMySQLDate($whmcs->get_req_var('dateto')) . " 23:59:59'";
    }
    $result = select_query("tblaccounts", implode(',', $fieldlist), implode(' AND ', $filters), "date", "ASC");
    while ($data = mysql_fetch_assoc($result)) {
        if (isset($data['currency'])) {
            $currency = getCurrency($data['userid'], $data['currency']);
            $data['currency'] = $currency['code'];
            if (!in_array('userid', $incfields)) {
                unset($data['userid']);
            }
        }
        if (isset($data['gateway'])) {
            $data['gateway'] = $gateways->getDisplayName($data['gateway']);
        }
        $reportdata["tablevalues"][] = $data;
    }
}
Example #18
0
function genQuotePDF($id)
{
    global $whmcs;
    global $CONFIG;
    global $_LANG;
    global $currency;
    $companyname = html_entity_decode($CONFIG['CompanyName']);
    $companyurl = $CONFIG['Domain'];
    $companyaddress = html_entity_decode($CONFIG['InvoicePayTo']);
    $companyaddress = explode("\r\n", $companyaddress);
    $quotenumber = $id;
    $result = select_query("tblquotes", "", array("id" => $id));
    $data = mysql_fetch_array($result);
    $subject = html_entity_decode($data['subject']);
    $stage = $data['stage'];
    $datecreated = fromMySQLDate($data['datecreated']);
    $validuntil = fromMySQLDate($data['validuntil']);
    $userid = $data['userid'];
    $proposal = $data['proposal'] ? html_entity_decode($data['proposal']) . "\r\n" : "";
    $notes = $data['customernotes'] ? html_entity_decode($data['customernotes']) . "\r\n" : "";
    $currency = getCurrency($userid, $data['currency']);
    if ($userid) {
        getUsersLang($userid);
        $stage = getQuoteStageLang($stage);
        $clientsdetails = getClientsDetails($userid);
        foreach ($clientsdetails as $k => $v) {
            $clientsdetails[$k] = html_entity_decode($v);
        }
    } else {
        $clientsdetails['firstname'] = html_entity_decode($data['firstname']);
        $clientsdetails['lastname'] = html_entity_decode($data['lastname']);
        $clientsdetails['companyname'] = html_entity_decode($data['companyname']);
        $clientsdetails['email'] = html_entity_decode($data['email']);
        $clientsdetails['address1'] = html_entity_decode($data['address1']);
        $clientsdetails['address2'] = html_entity_decode($data['address2']);
        $clientsdetails['city'] = html_entity_decode($data['city']);
        $clientsdetails['state'] = html_entity_decode($data['state']);
        $clientsdetails['postcode'] = html_entity_decode($data['postcode']);
        $clientsdetails['country'] = html_entity_decode($data['country']);
        $clientsdetails['phonenumber'] = html_entity_decode($data['phonenumber']);
    }
    $taxlevel1 = getTaxRate(1, $clientsdetails['state'], $clientsdetails['country']);
    $taxlevel2 = getTaxRate(2, $clientsdetails['state'], $clientsdetails['country']);
    require ROOTDIR . "/includes/countries.php";
    $clientsdetails['country'] = $countries[$clientsdetails['country']];
    $subtotal = formatCurrency($data['subtotal']);
    $tax1 = formatCurrency($data['tax1']);
    $tax2 = formatCurrency($data['tax2']);
    $total = formatCurrency($data['total']);
    $lineitems = array();
    $result = select_query("tblquoteitems", "", array("quoteid" => $id), "id", "ASC");
    while ($data = mysql_fetch_array($result)) {
        $line_id = $data['id'];
        $line_desc = $data['description'];
        $line_qty = $data['quantity'];
        $line_unitprice = $data['unitprice'];
        $line_discount = $data['discount'];
        $line_taxable = $data['taxable'];
        $line_total = format_as_currency($line_qty * $line_unitprice * (1 - $line_discount / 100));
        $lineitems[] = array("id" => $line_id, "description" => htmlspecialchars(html_entity_decode($line_desc, ENT_QUOTES)), "qty" => $line_qty, "unitprice" => $line_unitprice, "discount" => $line_discount, "taxable" => $line_taxable, "total" => formatCurrency($line_total));
    }
    $tplvars = array();
    $tplvars['companyname'] = $companyname;
    $tplvars['companyurl'] = $companyurl;
    $tplvars['companyaddress'] = $companyaddress;
    $tplvars['paymentmethod'] = $paymentmethod;
    $tplvars['quotenumber'] = $quotenumber;
    $tplvars['subject'] = $subject;
    $tplvars['stage'] = $stage;
    $tplvars['datecreated'] = $datecreated;
    $tplvars['validuntil'] = $validuntil;
    $tplvars['userid'] = $userid;
    $tplvars['clientsdetails'] = $clientsdetails;
    $tplvars['proposal'] = $proposal;
    $tplvars['notes'] = $notes;
    $tplvars['taxlevel1'] = $taxlevel1;
    $tplvars['taxlevel2'] = $taxlevel2;
    $tplvars['subtotal'] = $subtotal;
    $tplvars['tax1'] = $tax1;
    $tplvars['tax2'] = $tax2;
    $tplvars['total'] = $total;
    foreach ($tplvars as $k => $v) {
        $tplvars[$k] = html_entity_decode($v, ENT_QUOTES);
    }
    $tplvars['lineitems'] = $lineitems;
    $invoice = new WHMCS_Invoice();
    $invoice->pdfCreate($_LANG['quotenumber'] . $id);
    $invoice->pdfAddPage("quotepdf.tpl", $tplvars);
    $pdfdata = $invoice->pdfOutput();
    getUsersLang("");
    return $pdfdata;
}
Example #19
0
 public function getCurrency()
 {
     return getCurrency($this->getID());
 }
Example #20
0
 public function getInvoiceTotals()
 {
     global $currency;
     $invoicesummary = array();
     $result = full_query("SELECT currency,COUNT(tblinvoices.id),SUM(total) FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.status='Paid' GROUP BY tblclients.currency");
     while ($data = mysql_fetch_array($result)) {
         $invoicesummary[$data[0]]['paid'] = $data[2];
     }
     $result = full_query("SELECT currency,COUNT(tblinvoices.id),SUM(total)-COALESCE(SUM((SELECT SUM(amountin) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id)),0) FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.status='Unpaid' AND tblinvoices.duedate>='" . date("Ymd") . "' GROUP BY tblclients.currency");
     while ($data = mysql_fetch_array($result)) {
         $invoicesummary[$data[0]]['unpaid'] = $data[2];
     }
     $result = full_query("SELECT currency,COUNT(tblinvoices.id),SUM(total)-COALESCE(SUM((SELECT SUM(amountin) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id)),0) FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.status='Unpaid' AND tblinvoices.duedate<'" . date("Ymd") . "' GROUP BY tblclients.currency");
     while ($data = mysql_fetch_array($result)) {
         $invoicesummary[$data[0]]['overdue'] = $data[2];
     }
     $totals = array();
     foreach ($invoicesummary as $currency => $vals) {
         $currency = getCurrency("", $currency);
         if (!isset($vals['paid'])) {
             $vals['paid'] = 0;
         }
         if (!isset($vals['unpaid'])) {
             $vals['unpaid'] = 0;
         }
         if (!isset($vals['overdue'])) {
             $vals['overdue'] = 0;
         }
         $paid = formatCurrency($vals['paid']);
         $unpaid = formatCurrency($vals['unpaid']);
         $overdue = formatCurrency($vals['overdue']);
         $totals[] = array("currencycode" => $currency['code'], "paid" => $paid, "unpaid" => $unpaid, "overdue" => $overdue);
     }
     return $totals;
 }
    gp_LogGatewayTrans("PayPal", $ipnValid[1], "Invalid IPN");
    exit;
}
// Check that the payment status is completed
if ($ipnValid[1]['payment_status'] !== "Completed") {
    gp_LogGatewayTrans("PayPal", $ipnValid[1], $ipnValid[1]['payment_status']);
    exit;
}
//Check that we havn't credited for it already
$query = 'SELECT * FROM tblaccounts WHERE transid=\'' . $ipnValid[1]['txn_id'] . '\'';
if (mysql_num_rows(mysql_query($query))) {
    exit;
}
$gpSettings = gp_LoadSettings();
//Begin to credit the client
//TODO: Uncomment
//$clientId = 1;
$clientId = gp_LoadUserFromHash($ipnValid[1]['custom']);
gp_LogGatewayTrans("PayPal", $ipnValid[1], "Successful");
if ($clientId) {
    //Apply the Credit
    // Get the clients currency and apply the rate
    $currency = getCurrency($clientId);
    //Write the Transactions
    mysql_query("INSERT INTO `tblaccounts` (userid,gateway,`date`,description,amountin,fees,transid,invoiceid,`rate`)\n   \t\t\t\t\t\t values ({$clientId},'paypal',now(),'" . $gpSettings['SystemName'] . " Credit'," . $ipnValid[1]['mc_gross'] . "," . $ipnValid[1]['mc_fee'] . ",'" . $ipnValid[1]['txn_id'] . "',0,'" . $currency['rate'] . "')");
    //Increase the credit balance
    mysql_query("UPDATE `tblclients` set credit = credit + " . $ipnValid[1]['mc_gross'] . " where id = {$clientId}");
    //Add it to the credit log
    mysql_query("INSERT INTO `tblcredit` (clientid,date,description,amount)\n\t\t\t\t\t values ({$clientId},now(),'" . $gpSettings['SystemName'] . " Credit " . $ipnValid[1]['payer_email'] . "'," . $ipnValid[1]['mc_gross'] . ")");
    run_hook("groupPay_paymentComplete", array("clientId" => $clientId, "paypalInfo" => $ipnValid[1]));
}
Example #22
0
         break;
     case 'bill':
         # the response is a one time bill, we need to add the bill to the database
         $oBill = $confirmed_resource;
         insert_query('mod_gocardless', array('invoiceid' => $invoiceID, 'billcreated' => 1, 'resource_id' => $oBill->id));
         break;
     default:
         # we cannot handle anything other than a bill or preauths
         header('HTTP/1.1 400 Bad Request');
         exit('Your request could not be completed');
         break;
 }
 if ($gateway['instantpaid'] == on) {
     # The "Instant Activation" option is enabled, so we need to mark now
     # convert currency where necessary (GoCardless only handles GBP)
     $aCurrency = getCurrency($res['userid']);
     if ($gateway['convertto'] && $aCurrency['id'] != $gateway['convertto']) {
         # the users currency is not the same as the GoCardless currency, convert to the users currency
         $oBill->amount = convertCurrency($oBill->amount, $gateway['convertto'], $aCurrency['id']);
         $oBill->gocardless_fee = convertCurrency($oBill->gocardless_fee, $gateway['convertto'], $aCurrency['id']);
         # currency conversion on the setup fee bill
         if (isset($oSetupBill)) {
             $oSetupBill->amount = convertCurrency($oBill->amount, $gateway['convertto'], $aCurrency['id']);
             $oSetupBill->gocardless_fee = convertCurrency($oBill->gocardless_fee, $gateway['convertto'], $aCurrency['id']);
         }
     }
     # check if we are handling a preauth setup fee
     # if we are then we need to add it to the total bill
     if (isset($oSetupBill)) {
         addInvoicePayment($invoiceID, $oSetupBill->id, $oSetupBill->amount, $oSetupBill->gocardless_fees, $gateway['paymentmethod']);
         logTransaction($gateway['paymentmethod'], 'Setup fee of ' . $oSetupBill->amount . ' raised and logged for invoice ' . $invoiceID . ' with GoCardless ID ' . $oSetupBill->id, 'Successful');
Example #23
0
if ($get == "name") {
    widgetoutput($name);
}
if ($get == "description") {
    $description = str_replace(array("\r", "\n", "\r\n"), "", nl2br($description));
    widgetoutput($description);
}
if ($get == "configoption") {
    widgetoutput($data['configoption'] . $configoptionnum);
}
if ($get == "orderurl") {
    $systemurl = $CONFIG['SystemSSLURL'] ? $CONFIG['SystemSSLURL'] . '/' : $CONFIG['SystemURL'] . '/';
    if ($carttpl == "ajax") {
        widgetoutput($systemurl . "order/?pid={$pid}");
    } else {
        widgetoutput($systemurl . "cart.php?a=add&pid={$pid}&{$carttpl}=cart");
    }
}
if ($get == "price") {
    $currency = $currency ? getCurrency('', $currency) : getCurrency();
    $result = select_query("tblpricing", "", array("type" => "product", "currency" => $currency['id'], "relid" => $pid));
    $data = mysql_fetch_array($result);
    $price = $data[$billingcycle];
    $price = formatCurrency($price);
    widgetoutput($price);
}
function widgetoutput($value)
{
    echo "document.write('" . addslashes($value) . "');";
    exit;
}
Example #24
0
        $gateway = $gatewaysarray[$gateway];
        $tabledata[] = array($clientlink, $date, $gateway, $description, $amountin, $fees, $amountout, "<a href=\"" . $PHP_SELF . "?action=edit&id=" . $id . "\"><img src=\"images/edit.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"" . $aInt->lang("global", "edit") . "\"></a>", "<a href=\"#\" onClick=\"doDelete('" . $id . "');return false\"><img src=\"images/delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"" . $aInt->lang("global", "delete") . "\"></a>");
    }
    echo $aInt->sortableTable(array($aInt->lang("fields", "clientname"), $aInt->lang("fields", "date"), $aInt->lang("fields", "paymentmethod"), $aInt->lang("fields", "description"), $aInt->lang("transactions", "amountin"), $aInt->lang("transactions", "fees"), $aInt->lang("transactions", "amountout"), "", ""), $tabledata, $tableformurl, $tableformbuttons);
    if (checkPermission("View Income Totals", true)) {
        echo "\n<table cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#cccccc\" width=\"600\" align=\"center\">\n<tr bgcolor=\"#f4f4f4\" style=\"text-align:center;font-weight:bold;\"><td></td><td>";
        echo $aInt->lang("transactions", "totalincome");
        echo "</td><td>";
        echo $aInt->lang("transactions", "totalfees");
        echo "</td><td>";
        echo $aInt->lang("transactions", "totalexpenditure");
        echo "</td><td>";
        echo $aInt->lang("transactions", "totalbalance");
        echo "</td></tr>\n";
        foreach ($totals as $currency => $values) {
            $currency = getCurrency("", $currency);
            echo "<tr bgcolor=\"#ffffff\" style=\"text-align:center;\"><td bgcolor=\"#f4f4f4\"><b>" . $currency['code'] . "</b></td><td>" . formatCurrency($values['in']) . "</td><td>" . formatCurrency($values['fees']) . "</td><td>" . formatCurrency($values['out']) . "</td><td bgcolor=\"#f4f4f4\"><b>" . formatCurrency($values['total']) . "</b></td></tr>";
        }
        if (!count($totals)) {
            echo "<tr bgcolor=\"#ffffff\" style=\"text-align:center;\"><td colspan=\"5\">" . $aInt->lang("transactions", "nototals") . "</td></tr>";
        }
        echo "</table>\n\n";
    }
} else {
    if ($action == "edit") {
        $result = select_query("tblaccounts", "", array("id" => $id));
        $data = mysql_fetch_array($result);
        $id = $data['id'];
        $userid = $data['userid'];
        $date = $data['date'];
        $date = fromMySQLDate($date);
Example #25
0
 # loop through batch of bills and process appropriately, adding the
 # bill amount to the invoice once complete
 foreach ($val['bills'] as $aBill) {
     # get the associated invoiceID based on the bill ID
     $invoiceID = mysql_result(full_query("SELECT `invoiceid` FROM `mod_gocardless` WHERE `resource_id` = '" . mysql_real_escape_string($aBill['id']) . "' OR `setup_id` = '" . mysql_real_escape_string($aBill['id']) . "'"), 0, 0);
     # verify we have been able to get the invoice ID
     if ($invoiceID) {
         # get the userID to process the currency
         $userID = mysql_result(select_query('tblinvoices', 'userid', array('id' => $invoiceID)), 0, 0);
         # verify the invoice ID (to ensure it exists) and transaction ID to ensure it is unique
         checkCBInvoiceID($invoiceID, $gateway['paymentmethod']);
         checkCBTransID($aBill['id']);
         # calculate GoCardless fees
         $aBill['fees'] = $aBill['amount'] - $aBill['amount_minus_fees'];
         # convert the currency where necessary
         $aCurrency = getCurrency($userID);
         if ($gateway['convertto'] && $aCurrency['id'] != $gateway['convertto']) {
             # the users currency is not the same as the GoCardless currency, convert to the users currency
             $aBill['amount'] = convertCurrency($aBill['amount'], $gateway['convertto'], $aCurrency['id']);
             $aBill['fees'] = convertCurrency($aBill['fees'], $gateway['convertto'], $aCurrency['id']);
         }
         # if we get to this point, we have verified the callback and performed sanity checks
         # add a payment to the invoice and create a transaction log
         addInvoicePayment($invoiceID, $aBill['id'], $aBill['amount'], $aBill['fees'], $gateway['paymentmethod']);
         logTransaction($gateway['paymentmethod'], 'Bill payment completed (' . $aBill['id'] . '). Invoice #' . $invoiceID, 'Successful');
         # clean up for next loop
         unset($invoiceID, $userID);
     } else {
         header('HTTP/1.1 400 Bad Request');
         logTransaction($gateway['paymentmethod'], 'Could not find invoice with ID. callback.php ' . __LINE__ . $invoiceID, 'Failed');
         exit(__LINE__ . ': Could not get invoice ID for ' . htmlentities($aBill['id']));
$search = $whmcs->get_req_var("search");
$domain = $whmcs->get_req_var("domain");
$bulkdomains = $whmcs->get_req_var("bulkdomains");
$tld = $whmcs->get_req_var("tld");
$tlds = $whmcs->get_req_var("tlds");
$ext = $whmcs->get_req_var("ext");
$direct = $whmcs->get_req_var("direct");
$sld = "";
$invalidtld = "";
$availabilityresults = array();
$search_tlds = array();
$tldslist = array();
$client = new WHMCS_ClientArea();
$uid = $client->getUserID();
$currencyid = isset($_SESSION['currency']) ? $_SESSION['currency'] : "";
$currency = getCurrency($uid, $currencyid);
$smartyvalues['currency'] = $currency;
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : "";
$domain = isset($_REQUEST['domain']) ? $_REQUEST['domain'] : "";
$document_download = isset($_REQUEST['dl']) ? $_REQUEST['dl'] : "";
$search_domain = $_POST['search_domain'] != "Enter Domain to Find" ? $_POST['search_domain'] : "";
$current_date = date('Y-m-d');
$where = array("registrar" => "domainku");
if ($domain || $search_domain) {
    $where["domain"] = $domain ? $domain : $search_domain;
    $where_document = array("domain" => $domain);
}
$query = full_query("\n    SELECT  t.id, t.userid, t.type, t.domain, t.registrar, t.registrationdate, t.registrationperiod, t.status AS domstatus, i.status, o.nameservers, o.transfersecret,\n                m.domain AS coza_domain, m.domainid AS coza_domainid, m.userid AS coza_userid, m.id_doc_storage_name, m.id_doc_type, m.le_doc_storage_name, \n                m.le_doc_type, m.su_doc_storage_name, m.su_doc_type, m.domain_approval_date, m.domain_status,\n                c.firstname, c.lastname, c.companyname, c.email, c.address1, c.address2, c.city, c.state, c.postcode, c.country, c.phonenumber\n        FROM tbldomains t \n        LEFT JOIN mod_domaincloudregistrar m ON t.domain = m.domain \n        LEFT JOIN tblorders o ON t.orderid = o.id\n        LEFT JOIN tblinvoices i ON o.invoiceid = i.id\n        LEFT JOIN tblclients c ON t.userid = c.id\n        WHERE t.userid = " . $uid . " AND t.status <> 'Cancelled' AND t.status <> 'Expired' AND " . (!empty($domain) || !empty($search_domain) ? "t.domain LIKE '" . (!empty($domain) ? $domain : $search_domain) . "%'" : "t.domain LIKE '%.id'") . ";\n    ");
$rows = array();
while ($row = mysql_fetch_array($query)) {
    $rows[] = $row;
Example #27
0
<script language="javascript" src="feeds/productpricing.php?pid=1&currencyid=1"></script>
<script language="javascript" src="feeds/productpricing.php?pid=5&currencyid=2"></script>
*/
$result = select_query("tblproducts", "", array("id" => $pid));
$data = mysql_fetch_array($result);
$pid = $data['id'];
$paytype = $data['paytype'];
if (!$pid) {
    widgetoutput('Product ID Not Found');
}
if (!$currencyid) {
    $result = select_query("tblcurrencies", "id", "", "id", "ASC");
    $data = mysql_fetch_array($result);
    $currencyid = $data['id'];
}
$currency = getCurrency('', $currencyid);
$result = select_query("tblpricing", "", array("type" => "product", "currency" => $currencyid, "relid" => $pid));
$data = mysql_fetch_array($result);
$msetupfee = $data['msetupfee'];
$qsetupfee = $data['qsetupfee'];
$ssetupfee = $data['ssetupfee'];
$asetupfee = $data['asetupfee'];
$bsetupfee = $data['bsetupfee'];
$tsetupfee = $data['tsetupfee'];
$monthly = $data['monthly'];
$quarterly = $data['quarterly'];
$semiannually = $data['semiannually'];
$annually = $data['annually'];
$biennially = $data['biennially'];
$triennially = $data['triennially'];
$systemurl = $CONFIG['SystemSSLURL'] ? $CONFIG['SystemSSLURL'] : $CONFIG['SystemURL'];
    <table border="0" cellspacing="0" cellpadding="1">
      <?php 
// Affichage des factures existantes pour ce client
// Affichage par année, avec une séparation lisible
$q = "\nSELECT\n  YEAR(f.date_facture) AS annee,\n  SUM(IF(f.type_doc='facture' AND f.is_abandoned=0,\n    (fl.qtt*fl.prix_ht)/f.exchange_rate, 0)) AS ca_ht_total,\n  SUM( IF(f.type_doc='facture' AND f.is_paye=0 AND f.is_abandoned=0,\n  (fl.qtt*fl.prix_ht)/f.exchange_rate, 0)) AS du_ht_total,\n  SUM( IF(f.type_doc='facture' AND f.is_paye=0 AND f.is_abandoned=0,\n  (fl.qtt*fl.prix_ht*(100+f.tax)/100)/f.exchange_rate, 0)) AS du_ttc_total\nFROM webfinance_invoices f\nLEFT JOIN webfinance_invoice_rows fl ON f.id_facture=fl.id_facture\nWHERE f.id_client = {$Client->id}\nGROUP BY YEAR(date_facture)\nORDER BY f.date_facture DESC";
$result = mysql_query($q) or wf_mysqldie();
$Facture = new Facture();
while ($year = mysql_fetch_object($result)) {
    printf('<tr><td style="border-bottom: solid 1px #777;" colspan="6"><b style="font-size: 16px;">%s</b> - <b><i>Encours %s&euro; HT - %s&euro; TTC</i></b> - <i>%s&euro; HT</i></td></tr>', $year->annee, number_format($year->du_ht_total, 2, ',', ' '), number_format($year->du_ttc_total, 2, ',', ' '), number_format($year->ca_ht_total, 2, ',', ' '));
    $q = "SELECT f.id_facture\n                FROM webfinance_invoices as f\n                WHERE f.id_client=" . $Client->id . "\n                AND year(f.date_facture) = '" . $year->annee . "'\n                ORDER BY f.date_facture DESC";
    $result2 = mysql_query($q) or die("{$q}: " . mysql_error());
    $count = 0;
    //            $total_du = 0;
    while (list($id_invoice) = mysql_fetch_array($result2)) {
        $facture = $Facture->getInfos($id_invoice);
        list($currency, $exchange) = getCurrency($facture->id_compte);
        // Récupération du texte des lignes facturées pour afficher en infobulle.
        $description = "<b>" . $facture->nice_date_facture . "</b><br/>";
        foreach ($facture->lignes as $l) {
            $l->description = preg_replace("/\r\n/", " ", $l->description);
            $l->description = preg_replace("/\"/", "", $l->description);
            $l->description = preg_replace("/\\'/", "", $l->description);
            $l->description = preg_replace("/\n/", "<br>", $l->description);
            $description .= $l->description . "<br/>";
        }
        //              if ((! $facture->is_paye) && ($facture->type_doc=="facture")) {
        //                $total_du += $facture->total;
        //              }
        $pdf = sprintf('&nbsp;<a href="gen_facture.php?id=%d"><img src="/imgs/icons/pdf.png" alt="FA" /></a>', $facture->id_facture);
        if ($facture->type_doc == "facture") {
            $icon = $facture->is_paye ? "paid.gif" : "not_paid.gif";
Example #29
0
 $userid = $data['userid'];
 $created = $data['created'];
 $duedate = $data['duedate'];
 $ticketids = $data['ticketids'];
 $projectstatus = $data['status'];
 $created = fromMySQLDate($created);
 $duedate = fromMySQLDate($duedate);
 $admin = $adminid ? getAdminName($adminid) : "None";
 if ($userid) {
     $clientsdetails = getClientsDetails($userid);
     $client = "<a href=\"clientssummary.php?userid=" . $clientsdetails['userid'] . "\">" . $clientsdetails['firstname'] . " " . $clientsdetails['lastname'];
     if ($clientsdetails['companyname']) {
         $client .= " (" . $clientsdetails['companyname'] . ")";
     }
     $client .= "</a>";
     $currency = getCurrency();
 } else {
     $client = "None";
 }
 $ticketinvoicelinks = array();
 foreach ($ticketids as $i => $ticketnum) {
     if ($ticketnum) {
         $ticketnum = get_query_val("tbltickets", "tid", array("tid" => $ticketnum));
         $ticketinvoicelinks[] = "description LIKE '%Ticket #" . $ticketnum . "%'";
         continue;
     }
 }
 $ticketinvoicesquery = !empty($ticketinvoicelinks) ? "(\".implode(' AND '," . $ticketinvoicelinks . ").\") OR " : "";
 $totalinvoiced = get_query_val("tblinvoices", "SUM(subtotal+tax+tax2)", "id IN (SELECT invoiceid FROM tblinvoiceitems WHERE description LIKE '%Project #" . $projectid . "%' OR " . $ticketinvoicesquery . " (type='Project' AND relid='" . $projectid . "'))");
 $totalinvoiced = $userid ? formatCurrency($totalinvoiced) : format_as_currency($totalinvoiced);
 $totalpaid = get_query_val("tblinvoices", "SUM(subtotal+tax+tax2)", "id IN (SELECT invoiceid FROM tblinvoiceitems WHERE description LIKE '%Project #" . $projectid . "%' OR " . $ticketinvoicesquery . " (type='Project' AND relid='" . $projectid . "')) AND status='Paid'");
Example #30
0
function removeCurrency($item)
{
    $q2 = "DELETE FROM `vaultCurrency` WHERE `vcID` = " . $item;
    $r2 = $GLOBALS['mysqli']->query($q2);
    getCurrency();
}