예제 #1
0
 $referrals = array();
 $result = select_query("tblaffiliatesaccounts", "tblaffiliatesaccounts.*,tblproducts.name,tblhosting.userid,tblhosting.domainstatus,tblhosting.amount,tblhosting.firstpaymentamount,tblhosting.regdate,tblhosting.billingcycle", array("affiliateid" => $affiliateid), $orderby, $sort, $limit, "tblhosting ON tblhosting.id=tblaffiliatesaccounts.relid INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid INNER JOIN tblclients ON tblclients.id=tblhosting.userid");
 while ($data = mysql_fetch_array($result)) {
     $affaccid = $data['id'];
     $lastpaid = $data['lastpaid'];
     $relid = $data['relid'];
     $userid = $data['userid'];
     $firstpaymentamount = $data['firstpaymentamount'];
     $amount = $data['amount'];
     $date = $data['regdate'];
     $service = $data['name'];
     $billingcycle = $data['billingcycle'];
     $status = $data['domainstatus'];
     $date = fromMySQLDate($date);
     $currency = getCurrency($userid);
     $commission = calculateAffiliateCommission($affiliateid, $relid, $lastpaid);
     $commission = formatCurrency($commission);
     if (!$domain) {
         $domain = "";
     }
     $lastpaid = $lastpaid == "0000-00-00" ? "Never" : fromMySQLDate($lastpaid);
     $status = $_LANG["clientarea" . strtolower($status)];
     $billingcyclelang = strtolower($billingcycle);
     $billingcyclelang = str_replace(" ", "", $billingcyclelang);
     $billingcyclelang = str_replace("-", "", $billingcyclelang);
     $billingcyclelang = $_LANG["orderpaymentterm" . $billingcyclelang];
     if ($billingcycle == "Free" || $billingcycle == "Free Account") {
         $amountdesc = $billingcyclelang;
     } else {
         if ($billingcycle == "One Time") {
             $amountdesc = formatCurrency($firstpaymentamount) . " " . $billingcyclelang;
예제 #2
0
 function AffiliatePayment($affaccid, $hostingid)
 {
     global $CONFIG;
     $payout = false;
     if ($affaccid) {
         $result = select_query("tblaffiliatesaccounts", "", array("id" => $affaccid));
     } else {
         $result = select_query("tblaffiliatesaccounts", "", array("relid" => $hostingid));
     }
     $data = mysql_fetch_array($result);
     $affaccid = $data['id'];
     $affid = $data['affiliateid'];
     $lastpaid = $data['lastpaid'];
     $relid = $data['relid'];
     $commission = calculateAffiliateCommission($affid, $relid, $lastpaid);
     $result = select_query("tblproducts", "tblproducts.affiliateonetime", array("tblhosting.id" => $relid), "", "", "", "tblhosting ON tblhosting.packageid=tblproducts.id");
     $data = mysql_fetch_array($result);
     $affiliateonetime = $data['affiliateonetime'];
     if ($affiliateonetime) {
         if ($lastpaid == "0000-00-00") {
             $payout = true;
         } else {
             $error = "This product is setup for a one time affiliate payment only and the commission has already been paid";
         }
     } else {
         $payout = true;
     }
     $result = select_query("tblaffiliates", "onetime", array("id" => $affid));
     $data = mysql_fetch_array($result);
     $onetime = $data['onetime'];
     if ($onetime && $lastpaid != "0000-00-00") {
         $payout = false;
         $error = "This affiliate is setup for a one time commission only on all products and that has already been paid";
     }
     if ($affaccid && $payout) {
         if ($CONFIG['AffiliatesDelayCommission']) {
             $clearingdate = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + $CONFIG['AffiliatesDelayCommission'], date("Y")));
             insert_query("tblaffiliatespending", array("affaccid" => $affaccid, "amount" => $commission, "clearingdate" => $clearingdate));
         } else {
             update_query("tblaffiliates", array("balance" => "+=" . $commission), array("id" => (int) $affid));
             insert_query("tblaffiliateshistory", array("affiliateid" => $affid, "date" => "now()", "affaccid" => $affaccid, "amount" => $commission));
         }
         update_query("tblaffiliatesaccounts", array("lastpaid" => "now()"), array("id" => $affaccid));
     }
     return $error;
 }