/**
 * 
 * @version 1.0
 * @author QQ46231996
 */
function get_variable_order($order_id)
{
    global $db;
    $variable = array();
    $result = $db->Execute('SELECT o.orders_id,o.customers_id, customers_name,delivery_name,billing_name,track_number
		FROM ' . TABLE_ORDERS . ' o LEFT JOIN orders_delivery d ON (o.orders_id=d.orders_id)
		WHERE o.orders_id=' . (int) $order_id);
    if ($result->RecordCount() > 0) {
        $variable = get_variable_customer($result->fields['customers_id']);
        foreach ($result->fields as $key => $value) {
            $variable[sprintf('{%s}', $key)] = $value;
        }
    }
    $variable['{store_name}'] = STORE_NAME;
    return $variable;
}
示例#2
0
            $where[] = 'c.customers_id IN (' . implode(',', $select_customer_id) . ')';
        }
    }
}
if (!empty($where)) {
    $where = 'WHERE ' . implode(' AND ', $where);
}
if (count($where) == 0) {
    $where = '';
}
$new_fields = ', c.customers_telephone, a.entry_company, a.entry_street_address, a.entry_city, a.entry_postcode, c.customers_authorization, c.customers_referral';
$customers_query_raw = "select distinct c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_group_pricing, a.entry_country_id, a.entry_company, ci.customers_info_date_of_last_logon, ci.customers_info_date_account_created " . $new_fields . ",\n    cgc.amount\n    from " . TABLE_CUSTOMERS . " c\n    left join " . TABLE_CUSTOMERS_INFO . " ci on c.customers_id= ci.customers_info_id\n    left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . "\n    left join " . TABLE_COUPON_GV_CUSTOMER . " cgc on c.customers_id = cgc.customer_id\n\tleft join customers_send_mail csm ON (csm.customers_id=c.customers_id)\n\t" . $where . " order by {$disp_order}";
if (isset($_POST['send_mail_btn'])) {
    $customer_send_mail = $db->Execute($customers_query_raw);
    while (!$customer_send_mail->EOF) {
        $variable = get_variable_customer($customer_send_mail->fields['customers_id']);
        $mail_tempalte = get_email_template(CONST_SEND_MAIL_NO_ORDER);
        $to_name = $variable['{customers_name}'];
        $to_address = $variable['{customers_email_address}'];
        $from_email_name = $variable['{store_name}'];
        $mail_info = get_mail_random();
        $variable = array_merge($variable, $mail_info);
        $from_email_address = $mail_info['smtp_user'];
        $email_subject = str_ireplace(array_keys($variable), array_values($variable), $mail_tempalte['subject']);
        $email_text = str_ireplace(array_keys($variable), array_values($variable), $mail_tempalte['content']);
        $send_status = jsend_mail($to_name, $to_address, $email_subject, $email_text, $from_email_name, $from_email_address, $variable);
        $temp_result = $db->Execute('SELECT count FROM customers_send_mail WHERE customers_id=' . (int) $customer_send_mail->fields['customers_id'] . ' AND email_template_id=' . (int) $mail_tempalte['email_template_id']);
        if ($temp_result->fields['count'] > 0) {
            zen_db_perform('customers_send_mail', array('count' => (int) $temp_result->fields['count'] + 1), 'update', 'customers_id=' . $customer_send_mail->fields['customers_id'] . ' and email_template_id=' . $mail_tempalte['email_template_id']);
        } else {
            zen_db_perform('customers_send_mail', array('customers_id' => $customer_send_mail->fields['customers_id'], 'email_template_id' => $mail_tempalte['email_template_id'], 'count' => 1));