コード例 #1
0
ファイル: functions.php プロジェクト: vinothtimes/dchqtest
function JB_expire_subscription(&$invoice_row, $send_email = true)
{
    $now = gmdate("Y-m-d H:i:s");
    $sql = "UPDATE subscription_invoices SET `status`='Expired', subscr_end='{$now}' WHERE invoice_id='" . JB_escape_sql($invoice_row['invoice_id']) . "' ";
    @JB_mysql_query($sql) or JB_mail_error(mysql_error() . $sql);
    $sql = "UPDATE `employers` SET `can_view_blocked`='N', `subscription_can_view_resume`='N', `subscription_can_post`='N', `subscription_can_premium_post`='N', views_quota=0, posts_quota=0, p_posts_quota=0, quota_timestamp=0 WHERE ID='" . JB_escape_sql($invoice_row['employer_id']) . "' ";
    @JB_mysql_query($sql) or JB_mail_error(mysql_error() . $sql);
    if (JB_EMAIL_SUBSCR_EXP_SWITCH == 'YES' && $send_email) {
        $sql = "Select * from employers WHERE ID='" . JB_escape_sql($invoice_row['employer_id']) . "'";
        $result = JB_mysql_query($sql) or JB_mail_error(mysql_error() . $sql);
        $e_row = mysql_fetch_array($result, MYSQL_ASSOC);
        //$invoice_row = JB_get_subscription_invoice_row ($row['invoice_id']); // reload invoice
        $template_r = JB_get_email_template(130, $e_row['lang']);
        $template = mysql_fetch_array($template_r);
        $msg = $template['EmailText'];
        $from = $template['EmailFromAddress'];
        $from_name = $template['EmailFromName'];
        $subject = $template['EmailSubject'];
        $msg = str_replace("%FNAME%", $e_row['FirstName'], $msg);
        $msg = str_replace("%LNAME%", $e_row['LastName'], $msg);
        $msg = str_replace("%SITE_NAME%", JB_SITE_NAME, $msg);
        $msg = str_replace("%INVOICE_CODE%", "S" . $invoice_row['invoice_id'], $msg);
        $msg = str_replace("%ITEM_NAME%", $invoice_row['item_name'], $msg);
        $msg = str_replace("%SUB_START%", JB_get_formatted_time(JB_get_local_time($invoice_row['subscr_date'])), $msg);
        $msg = str_replace("%SUB_END%", JB_get_formatted_time(JB_get_local_time($invoice_row['subscr_end'])), $msg);
        $msg = str_replace("%SUB_DURATION%", $invoice_row['months_duration'], $msg);
        $msg = str_replace("%INVOICE_AMOUNT%", JB_convert_to_default_currency_formatted($invoice_row['currency_code'], $invoice_row['amount']), $msg);
        $msg = str_replace("%PAYMENT_METHOD%", $invoice_row['payment_method'], $msg);
        $msg = str_replace("%SITE_CONTACT_EMAIL%", JB_SITE_CONTACT_EMAIL, $msg);
        $msg = str_replace("%SITE_URL%", JB_BASE_HTTP_PATH, $msg);
        $to = $e_row['Email'];
        $to_name = jb_get_formatted_name($e_row['FirstName'], $e_row['LastName']);
        $email_id = JB_queue_mail($to, $to_name, $from, $from_name, $subject, $msg, '', 130);
        JB_process_mail_queue(1, $email_id);
    }
}
コード例 #2
0
function JB_complete_membership_invoice($invoice_id, $payment_method)
{
    global $label;
    $now = gmdate("Y-m-d H:i:s");
    // qwerty
    if ($payment_method == '') {
        $payment_method = $invoice_row['payment_method'];
    }
    $invoice_row = JB_get_membership_invoice_row($invoice_id);
    if ($payment_method == '') {
        $payment_method = $invoice_row['payment_method'];
    }
    if ($invoice_row['status'] == 'Confirmed' || $invoice_row['status'] == 'Pending') {
        if ($invoice_row['reason'] != 'jb_credit_advanced') {
            // bank and check modules have the option to advance membership before payment is received. If the credit was given in advance, then this invoice would have a jb_payment_deferred status
            JB_start_membership($invoice_row);
        }
        $sql = "UPDATE membership_invoices SET `status`='Completed', `payment_method`='" . jb_escape_sql($payment_method) . "', `processed_date`='{$now}' WHERE invoice_id='" . jb_escape_sql($invoice_id) . "'";
        $result = JB_mysql_query($sql) or JB_mail_error("[{$sql}]" . mysql_error());
        if (JB_EMAIL_ORDER_COMPLETED_SWITCH == 'YES') {
            // send conformation.
            // get the user's record to send to
            if ($invoice_row['user_type'] == 'C') {
                // user's membership?
                $sql = "Select * from users WHERE ID='" . jb_escape_sql($invoice_row['user_id']) . "'";
            } else {
                $sql = "Select * from employers WHERE ID='" . jb_escape_sql($invoice_row['user_id']) . "'";
            }
            $result = JB_mysql_query($sql) or die(mysql_error());
            $e_row = mysql_fetch_array($result, MYSQL_ASSOC);
            $invoice_row = JB_get_membership_invoice_row($invoice_id);
            // reload invoice
            $template_r = JB_get_email_template(110, $e_row['lang']);
            $template = mysql_fetch_array($template_r);
            $msg = $template['EmailText'];
            $from = $template['EmailFromAddress'];
            $from_name = $template['EmailFromName'];
            $subject = $template['EmailSubject'];
            $msg = str_replace("%FNAME%", $e_row['FirstName'], $msg);
            $msg = str_replace("%LNAME%", $e_row['LastName'], $msg);
            $msg = str_replace("%SITE_NAME%", JB_SITE_NAME, $msg);
            $msg = str_replace("%INVOICE_CODE%", "M" . $invoice_row['invoice_id'], $msg);
            $msg = str_replace("%ITEM_NAME%", $invoice_row['item_name'], $msg);
            $msg = str_replace("%MEM_START%", JB_get_formatted_time(JB_get_local_time($invoice_row['member_date'])), $msg);
            if ($invoice_row['months_duration'] == '0') {
                $invoice_row['member_end'] = $label['member_not_expire'];
                $invoice_row['months_duration'] = $label['member_not_expire'];
            }
            $msg = str_replace("%MEM_END%", JB_get_formatted_time($invoice_row['member_end']), $msg);
            $msg = str_replace("%MEM_DURATION%", $invoice_row['months_duration'], $msg);
            $msg = str_replace("%INVOICE_AMOUNT%", JB_convert_to_default_currency_formatted($invoice_row['currency_code'], $invoice_row['amount']), $msg);
            $msg = str_replace("%PAYMENT_METHOD%", $payment_method, $msg);
            $msg = str_replace("%SITE_CONTACT_EMAIL%", JB_SITE_CONTACT_EMAIL, $msg);
            $msg = str_replace("%SITE_URL%", JB_BASE_HTTP_PATH, $msg);
            preg_match('#%INVOICE_TAX=\\[(.+?)\\]%#', $msg, $m);
            $tax_rate = $m[1];
            $invoice_tax = $invoice_row['amount'] - $invoice_row['amount'] / (1.0 + $tax_rate);
            $invoice_tax = JB_convert_to_default_currency_formatted($invoice_row['currency_code'], $invoice_tax);
            $msg = str_replace($m[0], $invoice_tax, $msg);
            $to = $e_row['Email'];
            $to_name = JB_get_formatted_name($e_row['FirstName'], $e_row['LastName']);
            $email_id = JB_queue_mail($to, $to_name, $from, $from_name, $subject, $msg, '', 110);
            JB_process_mail_queue(1, $email_id);
        }
    }
}