} else {
        $to = module_user::get_contacts(array('customer_id' => $invoice['customer_id']));
        // hunt for 'accounts' extra field
        $field_to_find = strtolower(module_config::c('accounts_extra_field_name', 'Accounts'));
        foreach ($to as $contact) {
            $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $contact['user_id']));
            foreach ($extras as $e) {
                if (strtolower($e['extra_key']) == $field_to_find) {
                    // this is the accounts contact - woo!
                    $to_select = $contact['email'];
                }
            }
        }
        if (!$to_select && $customer['primary_user_id']) {
            $primary = module_user::get_user($customer['primary_user_id']);
            if ($primary) {
                $to_select = $primary['email'];
            }
        }
    }
} else {
    if ($invoice['member_id']) {
        $member = module_member::get_member($invoice['member_id']);
        $to = array($member);
        $replace['customer_name'] = $member['first_name'];
    } else {
        $to = array();
    }
}
$template->assign_values($replace);
module_email::print_compose(array('title' => _l('Email Invoice: %s', $invoice['name']), 'find_other_templates' => 'invoice_email', 'current_template' => $template_name, 'customer_id' => $invoice['customer_id'], 'company_id' => isset($invoice['company_id']) ? $invoice['company_id'] : 0, 'to' => $to, 'to_select' => $to_select, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_invoice::link_open($invoice_id), 'success_callback' => 'module_invoice::email_sent', 'success_callback_args' => array('invoice_id' => $invoice_id, 'template_name' => $template_name), 'invoice_id' => $invoice_id, 'cancel_url' => module_invoice::link_open($invoice_id), 'attachments' => array(array('path' => $pdf, 'name' => basename($pdf), 'preview' => module_invoice::link_generate($invoice_id, array('arguments' => array('go' => 1, 'print' => 1), 'page' => 'invoice_admin', 'full' => false))))));
Beispiel #2
0
 public static function email_invoice_to_customer($invoice_id, $debug = false)
 {
     // this is a copy of some of the code in invoie_admin_email.php
     // used in the CRON job when sending out automated emails.
     $invoice = module_invoice::get_invoice($invoice_id);
     // template for sending emails.
     // are we sending the paid one? or the dueone.
     $template_name = '';
     $template_prefix = isset($invoice['invoice_template_email']) && strlen($invoice['invoice_template_email']) ? $invoice['invoice_template_email'] : 'invoice_email';
     if (isset($invoice['credit_note_id']) && $invoice['credit_note_id']) {
         $template_name = 'credit_note_email';
     } else {
         if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
             $template_name = $template_prefix . '_paid';
         } else {
             if ($invoice['overdue'] && $invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
                 $template_name = $template_prefix . '_overdue';
             } else {
                 $template_name = $template_prefix . '_due';
             }
         }
     }
     $template_name = hook_filter_var('invoice_email_template', $template_name, $invoice_id, $invoice);
     if (class_exists('module_company', false) && isset($invoice_data['company_id']) && (int) $invoice_data['company_id'] > 0) {
         module_company::set_current_company_id($invoice_data['company_id']);
     }
     $template = module_template::get_template_by_key($template_name);
     if (!$template || $template->template_key != $template_name) {
         // backup default templates incase someone has chosen a template that doesn't exist (eg: created invoice_email_MINE_due but not invoice_email_MINE_paid )
         $template_prefix = 'invoice_email';
         if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
             $template_name = $template_prefix . '_paid';
         } else {
             if ($invoice['overdue'] && $invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
                 $template_name = $template_prefix . '_overdue';
             } else {
                 $template_name = $template_prefix . '_due';
             }
         }
     }
     $replace = module_invoice::get_replace_fields($invoice_id, $invoice);
     if (defined('_BLOCK_EMAILS') && _BLOCK_EMAILS) {
         $pdf = false;
     } else {
         $pdf = module_invoice::generate_pdf($invoice_id);
     }
     $send_email_to = array();
     $to = array();
     if ($invoice['customer_id']) {
         $customer = module_customer::get_customer($invoice['customer_id']);
         $replace['customer_name'] = $customer['customer_name'];
         if ($invoice['user_id']) {
             // this invoice has a manually assigned user, only send the invoice to this user.
             // todo: should we also send to accounts? not sure - see if peopel complain
             $primary = module_user::get_user($invoice['user_id']);
             if ($primary) {
                 $send_email_to[] = $primary;
             }
         } else {
             $to = module_user::get_contacts(array('customer_id' => $invoice['customer_id']));
             // hunt for 'accounts' extra field
             $field_to_find = strtolower(module_config::c('accounts_extra_field_name', 'Accounts'));
             foreach ($to as $contact) {
                 $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $contact['user_id']));
                 foreach ($extras as $e) {
                     if (strtolower($e['extra_key']) == $field_to_find) {
                         // this is the accounts contact - woo!
                         $send_email_to[] = $contact;
                     }
                 }
             }
             if (!count($send_email_to) && $customer['primary_user_id']) {
                 $primary = module_user::get_user($customer['primary_user_id']);
                 if ($primary) {
                     $send_email_to[] = $primary;
                 }
             }
         }
     } else {
         if ($invoice['member_id']) {
             $member = module_member::get_member($invoice['member_id']);
             $to = array($member);
             $replace['customer_name'] = $member['first_name'];
         } else {
             $to = array();
         }
     }
     $template->assign_values($replace);
     $html = $template->render('html');
     // send an email to this user.
     $email = module_email::new_email();
     $email->replace_values = $replace;
     // todo: send to all customer contacts ?
     if ($send_email_to) {
         foreach ($send_email_to as $send_email_t) {
             if (!empty($send_email_t['user_id'])) {
                 $email->set_to('user', $send_email_t['user_id']);
             } else {
                 if (!empty($send_email_t['email'])) {
                     $email->set_to_manual($send_email_t['email']);
                 }
             }
         }
     } else {
         foreach ($to as $t) {
             if (!empty($t['user_id'])) {
                 $email->set_to('user', $t['user_id']);
             } else {
                 if (!empty($t['email'])) {
                     $email->set_to_manual($t['email']);
                 }
             }
             break;
             // only 1? todo: all?
         }
     }
     $email->set_bcc_manual(module_config::c('admin_email_address', ''), '');
     //$email->set_from('user',); // nfi
     $email->set_subject($template->description);
     // do we send images inline?
     $email->set_html($html);
     if ($pdf) {
         $email->add_attachment($pdf);
     }
     $email->invoice_id = $invoice_id;
     $email->customer_id = $invoice['customer_id'];
     $email->prevent_duplicates = true;
     if ($email->send($debug)) {
         // it worked successfully!!
         // record a log on the invoice when it's done.
         self::email_sent(array('invoice_id' => $invoice_id, 'template_name' => $template_name));
         return true;
     } else {
         /// log err?
         return false;
     }
 }
Beispiel #3
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (isset($_REQUEST['member_id'])) {
    $links = array();
    $member_id = $_REQUEST['member_id'];
    if ($member_id && $member_id != 'new') {
        $member = module_member::get_member($member_id);
        // we have to load the menu here for the sub plugins under member
        // set default links to show in the bottom holder area.
        array_unshift($links, array("name" => _l('Member:') . ' <strong>' . htmlspecialchars($member['first_name'] . ' ' . $member['last_name']) . '</strong>', "icon" => "images/icon_arrow_down.png", 'm' => 'member', 'p' => 'member_admin', 'default_page' => 'member_admin_edit', 'order' => 1, 'menu_include_parent' => 0));
    } else {
        $member = array('name' => 'New Member');
        array_unshift($links, array("name" => "New Member Details", "icon" => "images/icon_arrow_down.png", 'm' => 'member', 'p' => 'member_admin', 'default_page' => 'member_admin_edit', 'order' => 1, 'menu_include_parent' => 0));
    }
} else {
    include 'member_admin_list.php';
}
Beispiel #4
0
 public static function get_finance_recurring_items($hook, $search)
 {
     /**
      * next_due_date
      * url
      * type (i or e)
      * amount
      * currency_id
      * days
      * months
      * years
      * last_transaction_finance_id
      * account_name
      * categories
      * finance_recurring_id
      */
     // find list of all members.
     // then go through and fine list of all upcoming subscription payments.
     // add these ones (and future ones up to (int)module_config::c('finance_recurring_months',6) months from todays date.
     $end_date = isset($search['date_to']) && !empty($search['date_to']) ? strtotime(input_date($search['date_to'])) : strtotime("+" . (int) module_config::c('finance_recurring_months', 6) . ' months');
     /*$sql = "SELECT s.*, sm.*";
       $sql .= " FROM `"._DB_PREFIX."subscription_member` sm ";
       $sql .= " LEFT JOIN `"._DB_PREFIX."subscription` s USING (subscription_id)";
       $sql .= " WHERE sm.`deleted` = 0";
       $members =  qa($sql);
       $sql = "SELECT s.*, sc.*";
       $sql .= " FROM `"._DB_PREFIX."subscription_customer` sc ";
       $sql .= " LEFT JOIN `"._DB_PREFIX."subscription` s USING (subscription_id)";
       $sql .= " WHERE sc.`deleted` = 0";
       $customers =  qa($sql);
       $items = array_merge($members,$customers);*/
     //$members = module_member::ge
     $sql = "SELECT s.*, so.*";
     $sql .= " FROM `" . _DB_PREFIX . "subscription_owner` so ";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "subscription` s USING (subscription_id)";
     $sql .= " WHERE so.`deleted` = 0";
     $sql .= " GROUP BY `owner_table`, `owner_id`";
     $items = qa($sql);
     //$members = module_member::get_members(array());
     $return = array();
     foreach ($items as $member) {
         $subscriptions = module_subscription::get_subscriptions_by($member['owner_table'], $member['owner_id']);
         /*if(isset($member['member_id']) && $member['member_id']){
         
                     }else if(isset($member['customer_id']) && $member['customer_id']){
                         $subscriptions = module_subscription::get_subscriptions_by_customer($member['customer_id']);
                     }else{
                         $subscriptions = array();
                     }*/
         foreach ($subscriptions as $subscription) {
             $time = strtotime($subscription['next_generation_date'] ? $subscription['next_generation_date'] : $subscription['next_due_date']);
             if (!$time) {
                 continue;
             }
             switch ($member['owner_table']) {
                 case 'customer':
                     $type = 'customer';
                     $member_name = module_customer::link_open($member['owner_id'], true);
                     $subscription_invoices = self::get_subscription_history($subscription['subscription_id'], $member['owner_table'], $member['owner_id']);
                     break;
                 case 'website':
                     $type = 'website';
                     $member_name = module_website::link_open($member['owner_id'], true);
                     $subscription_invoices = self::get_subscription_history($subscription['subscription_id'], $member['owner_table'], $member['owner_id']);
                     break;
                 case 'member':
                     $type = 'member';
                     $member_name = module_member::link_open($member['owner_id'], true);
                     $subscription_invoices = self::get_subscription_history($subscription['subscription_id'], $member['owner_table'], $member['owner_id']);
                     break;
                 default:
                     $subscription_invoices = array();
                     $member_name = 'unknown2';
                     $type = 'unknown2';
             }
             $subscription_name = module_subscription::link_open($subscription['subscription_id'], true);
             foreach ($subscription_invoices as $subscription_invoice_id => $subscription_invoice) {
                 if ($subscription_invoice['invoice_id']) {
                     $subscription_invoices[$subscription_invoice_id] = array_merge($subscription_invoice, module_invoice::get_invoice($subscription_invoice['invoice_id'], 2));
                 }
             }
             $original = true;
             $c = 0;
             while ($time < $end_date) {
                 if ($c++ > 200) {
                     break;
                 }
                 $next_time = 0;
                 if (!$subscription['days'] && !$subscription['months'] && !$subscription['years']) {
                     // it's a once off..
                     // add it to the list but dont calculate the next one.
                 } else {
                     if (!$original) {
                         // work out when the next one will be.
                         $next_time = self::_calculate_next_time($time, $subscription);
                         $time = $next_time;
                     } else {
                         $original = false;
                         // it's the original one.
                         $next_time = $time;
                     }
                 }
                 if ($next_time) {
                     // don't show it here if an invoice has already been generated.
                     // because invoice will already be in the list as outstanding
                     foreach ($subscription_invoices as $subscription_invoice) {
                         if (isset($subscription_invoice['date_create']) && $subscription_invoice['date_create'] == date('Y-m-d', $next_time)) {
                             //echo 'match';
                             continue 2;
                         }
                     }
                     $return[] = array('next_due_date' => date('Y-m-d', $next_time), 'url' => _l('Subscription: %s', $member_name), 'type' => 'i', 'amount' => $subscription['amount'], 'currency_id' => $subscription['currency_id'], 'days' => $subscription['days'], 'months' => $subscription['months'], 'years' => $subscription['years'], 'last_transaction_finance_id' => 0, 'account_name' => '', 'categories' => '', 'finance_recurring_id' => 0, 'last_transaction_text' => '(see member page)', 'end_date' => '0000-00-00', 'start_date' => $subscription['start_date'], 'recurring_text' => _l('Payment from %s %s on subscription %s', $type, $member_name, $subscription_name));
                 }
             }
         }
     }
     return $return;
 }
Beispiel #5
0
 /**
  * @static
  * @param $args
  * @return array
  *
  * The newsletter system requests updated customer / user data from this group plugin.
  * It does this when building the member list, and also 
  */
 public static function newsletter_callback($args)
 {
     if (!isset($args['owner_table']) || !$args['owner_table']) {
         return array();
     }
     switch ($args['owner_table']) {
         case 'user':
             if ((int) $args['owner_id'] > 0) {
                 $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name";
                 $sql .= " , pu.user_id ";
                 $sql .= " , c.customer_id ";
                 $sql .= " ,c.credit ";
                 $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`";
                 $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code ";
                 $sql .= ' FROM `' . _DB_PREFIX . "user` pu";
                 $sql .= " LEFT JOIN `" . _DB_PREFIX . "customer` c ON pu.customer_id = c.customer_id";
                 $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'";
                 $sql .= " WHERE pu.user_id = " . (int) $args['owner_id'];
                 $user = qa1($sql);
                 if (!is_array($user) || !isset($user['user_id']) || !$user['user_id']) {
                     return false;
                 }
                 if (isset($args['basic']) && $args['basic']) {
                     return $user;
                 }
                 //                    $name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name']));
                 //                    $user['first_name'] = array_shift($name_parts);
                 //                    $user['last_name'] = implode(' ',$name_parts);
                 // get extras for the user.
                 $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id']));
                 foreach ($extras as $extra) {
                     if (!strlen(trim($extra['extra']))) {
                         continue;
                     }
                     $key = $extra['extra_key'];
                     $x = 1;
                     while (isset($user[$key])) {
                         $key = $extra['extra_key'] . $x;
                         $x++;
                     }
                     $user[$key] = trim($extra['extra']);
                 }
                 // get extras for the customer.
                 if (isset($user['customer_id']) && $user['customer_id'] > 0) {
                     $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id']));
                     foreach ($extras as $extra) {
                         if (!strlen(trim($extra['extra']))) {
                             continue;
                         }
                         $key = $extra['extra_key'];
                         $x = 1;
                         while (isset($user[$key])) {
                             $key = $extra['extra_key'] . $x;
                             $x++;
                         }
                         $user[$key] = trim($extra['extra']);
                     }
                 }
                 if ($user['customer_id']) {
                     $user['_edit_link'] = module_user::link_open_contact($user['user_id'], false, $user);
                 } else {
                     $user['_edit_link'] = module_user::link_open($user['user_id'], false, $user);
                 }
                 return $user;
             }
             break;
         case 'customer':
             if (module_config::c('newsletter_send_all_customer_contacts', 1)) {
                 // update - we use the above 'user' callback and return a listing for each contact in the array.
                 // using the special _multi flag hack to tell our newsletter plugin that this result contains multiple entries.
                 $users = array('_multi' => true);
                 $sql = "SELECT u.user_id FROM `" . _DB_PREFIX . "user` u WHERE u.customer_id = " . (int) $args['owner_id'];
                 $contacts = qa($sql);
                 foreach ($contacts as $contact) {
                     $data_args = array('owner_id' => $contact['user_id'], 'owner_table' => 'user');
                     $users[$contact['user_id']] = self::newsletter_callback($data_args);
                     if ($users[$contact['user_id']]) {
                         $users[$contact['user_id']]['data_args'] = json_encode($data_args);
                     }
                 }
                 return $users;
             } else {
                 $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name";
                 $sql .= " ,c.credit ";
                 $sql .= " , pu.user_id ";
                 $sql .= " , c.customer_id ";
                 $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`";
                 $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code ";
                 $sql .= " FROM `" . _DB_PREFIX . "customer` c ";
                 $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'";
                 $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id";
                 $sql .= " WHERE c.customer_id = " . (int) $args['owner_id'];
                 $user = qa1($sql);
                 if (!$user || !isset($user['customer_id'])) {
                     return array();
                 }
                 //$name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name']));
                 //$user['first_name'] = array_shift($name_parts);
                 //$user['last_name'] = implode(' ',$name_parts);
                 if (isset($args['basic']) && $args['basic']) {
                     return $user;
                 }
                 // get extras for the customer.
                 $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id']));
                 foreach ($extras as $extra) {
                     if (!strlen(trim($extra['extra']))) {
                         continue;
                     }
                     $key = $extra['extra_key'];
                     $x = 1;
                     while (isset($user[$key])) {
                         $key = $extra['extra_key'] . $x;
                         $x++;
                     }
                     $user[$key] = trim($extra['extra']);
                 }
                 if (isset($user['user_id']) && $user['user_id'] > 0) {
                     // get extras for the user.
                     $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id']));
                     foreach ($extras as $extra) {
                         if (!strlen(trim($extra['extra']))) {
                             continue;
                         }
                         $key = $extra['extra_key'];
                         $x = 1;
                         while (isset($user[$key])) {
                             $key = $extra['extra_key'] . $x;
                             $x++;
                         }
                         $user[$key] = trim($extra['extra']);
                     }
                 }
                 $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user);
                 return $user;
             }
         case 'website':
             $sql = "SELECT c.customer_name AS company_name";
             $sql .= " ,c.credit ";
             $sql .= " ,w.name AS website_name";
             $sql .= " ,w.url AS website_url";
             $sql .= " , pu.user_id ";
             $sql .= " , c.customer_id ";
             $sql .= " , pu.name AS user_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`";
             $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code ";
             $sql .= " FROM `" . _DB_PREFIX . "website` w ";
             $sql .= ' LEFT JOIN `' . _DB_PREFIX . "customer` c ON w.customer_id = c.customer_id";
             $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'";
             $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id";
             $sql .= " WHERE w.website_id = " . (int) $args['owner_id'];
             $user = qa1($sql);
             $name_parts = explode(" ", preg_replace('/\\s+/', ' ', $user['user_name']));
             $user['first_name'] = array_shift($name_parts);
             $user['last_name'] = implode(' ', $name_parts);
             if (isset($args['basic']) && $args['basic']) {
                 return $user;
             }
             // get extras for the website.
             $extras = module_extra::get_extras(array('owner_table' => 'website', 'owner_id' => $args['owner_id']));
             foreach ($extras as $extra) {
                 if (!strlen(trim($extra['extra']))) {
                     continue;
                 }
                 $key = $extra['extra_key'];
                 $x = 1;
                 while (isset($user[$key])) {
                     $key = $extra['extra_key'] . $x;
                     $x++;
                 }
                 $user[$key] = trim($extra['extra']);
             }
             // then get extras for the company
             $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id']));
             foreach ($extras as $extra) {
                 if (!strlen(trim($extra['extra']))) {
                     continue;
                 }
                 $key = $extra['extra_key'];
                 $x = 1;
                 while (isset($user[$key])) {
                     $key = $extra['extra_key'] . $x;
                     $x++;
                 }
                 $user[$key] = trim($extra['extra']);
             }
             if (isset($user['user_id']) && $user['user_id'] > 0) {
                 // get extras for the user.
                 $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id']));
                 foreach ($extras as $extra) {
                     if (!strlen(trim($extra['extra']))) {
                         continue;
                     }
                     $key = $extra['extra_key'];
                     $x = 1;
                     while (isset($user[$key])) {
                         $key = $extra['extra_key'] . $x;
                         $x++;
                     }
                     $user[$key] = trim($extra['extra']);
                 }
             }
             $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user);
             return $user;
         case 'ticket':
             //echo 'Getting ticket for '.$args['owner_id'] . ' and basic is '.var_export($args['basic'],true);exit;
             return module_ticket::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']);
         case 'member':
             return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']);
         case 'newsletter_subscription':
             return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']);
     }
     return array();
 }
<form action="" method="post">

<?php 
$search_bar = array('elements' => array('name' => array('title' => _l('Names, Phone or Email:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : ''))));
if (class_exists('module_group', false) && module_member::can_i('view', 'Member Groups')) {
    $search_bar['elements']['group'] = array('title' => _l('Group:'), 'field' => array('type' => 'select', 'name' => 'search[group_id]', 'value' => isset($search['group_id']) ? $search['group_id'] : '', 'options' => module_group::get_groups('member'), 'options_array_id' => 'name'));
}
if (class_exists('module_newsletter', false)) {
    $search_bar['elements']['group'] = array('title' => _l('Newsletter:'), 'field' => array('type' => 'select', 'name' => 'search[group_id2]', 'value' => isset($search['group_id2']) ? $search['group_id2'] : '', 'options' => module_group::get_groups('newsletter_subscription'), 'options_array_id' => 'name'));
}
echo module_form::search_bar($search_bar);
$table_manager = module_theme::new_table_manager();
$columns = array();
$columns['member_name'] = array('title' => 'Member Name', 'callback' => function ($member) {
    echo module_member::link_open($member['member_id'], true);
}, 'cell_class' => 'row_action');
$columns['member_business'] = array('title' => 'Business', 'callback' => function ($member) {
    echo htmlspecialchars($member['business']);
});
$columns['member_phone'] = array('title' => 'Phone', 'callback' => function ($member) {
    echo htmlspecialchars($member['phone']);
});
$columns['member_mobile'] = array('title' => 'Mobile', 'callback' => function ($member) {
    echo htmlspecialchars($member['mobile']);
});
$columns['member_email'] = array('title' => 'Email Address', 'callback' => function ($member) {
    echo htmlspecialchars($member['email']);
});
if (class_exists('module_subscription', false)) {
    $columns['member_subscription'] = array('title' => 'Subscription', 'callback' => function ($member) {
        foreach ($total_unpaid as $id => $t) {
            $total_unpaid[$id] = dollar($t, true, $id);
        }
        ?>

            <tr>
                <td><?php 
        switch ($subscribed_customer['owner_table']) {
            case 'customer':
                echo module_customer::link_open($subscribed_customer['owner_id'], true);
                break;
            case 'website':
                echo module_website::link_open($subscribed_customer['owner_id'], true);
                break;
            case 'member':
                echo module_member::link_open($subscribed_customer['owner_id'], true);
                break;
        }
        ?>
</td>
                <td><?php 
        echo print_date($subscribed_customer['start_date']);
        ?>
</td>
                <td><?php 
        echo print_date($subscribed_customer['next_due_date']);
        ?>
</td>
                <td>
                    <?php 
        echo count($history);
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
$module->page_title = _l('Member Statistics');
$member_id = isset($_REQUEST['member_id']) ? (int) $_REQUEST['member_id'] : false;
$newsletter_member_id = isset($_REQUEST['newsletter_member_id']) ? (int) $_REQUEST['newsletter_member_id'] : false;
if ($member_id) {
    $member_data = module_newsletter::get_member($member_id);
} else {
    if ($newsletter_member_id) {
        $member_data = module_newsletter::get_newsletter_member($newsletter_member_id);
    } else {
        set_error('Sorry no member id specified');
        redirect_browser(module_member::link_list(0));
    }
}
// quick hack to save settings.
$redirect = false;
foreach ($member_data as $member_d) {
    if (isset($_REQUEST['receive_email']) && $member_d['newsletter_member_id'] && isset($_REQUEST['receive_email'][$member_d['newsletter_member_id']])) {
        module_newsletter::save_member($member_d['newsletter_member_id'], array('receive_email' => (int) $_REQUEST['receive_email'][$member_d['newsletter_member_id']]));
        $redirect = true;
    }
}
if ($redirect) {
    redirect_browser($_SERVER['REQUEST_URI']);
}
print_heading('Member Newsletter History/Statistics');
?>
        </td>
        <td>
            <?php 
    $total_members += count($subscription_report['members']);
    echo count($subscription_report['members']);
    ?>
 <br/>
            <ul>
                <?php 
    foreach ($subscription_report['members'] as $member_id => $member_data) {
        ?>

                    <li>
                        <?php 
        echo module_member::link_open($member_id, true);
        ?>
 (<?php 
        echo $member_data['received_payments'] . ' = ' . dollar($member_data['received_total']);
        ?>
)
                        <?php 
        if ($member_data['unpaid_payments'] > 0) {
            ?>

                            <strong><?php 
            echo $member_data['unpaid_payments'];
            ?>
 UNPAID! = <?php 
            echo dollar($member_data['unpaid_total']);
            ?>
Beispiel #10
0
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if ($subscription['subscription_owner_id']) {
    $subscription_owner = get_single('subscription_owner', 'subscription_owner_id', $subscription['subscription_owner_id']);
    if (count($subscription_owner)) {
        ob_start();
        ?>
	    <table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tableclass_full">
	        <tbody>
	        <tr>
	            <td>
	                <?php 
        switch ($subscription_owner['owner_table']) {
            case 'member':
                $member_name = module_member::link_open($subscription_owner['owner_id'], true);
                break;
            case 'website':
                $member_name = module_website::link_open($subscription_owner['owner_id'], true);
                break;
            case 'customer':
                $member_name = module_customer::link_open($subscription_owner['owner_id'], true);
                break;
        }
        $subscription_name = module_subscription::link_open($subscription['subscription_id'], true);
        _e('This is a subscription payment for %s %s on the subscription: %s', $subscription_owner['owner_table'], $member_name, $subscription_name);
        ?>
	            </td>
	        </tr>
	        </tbody>
	    </table>
$templates = array();
foreach (module_newsletter::get_templates() as $template) {
    $templates[$template['newsletter_template_id']] = $template['newsletter_template_name'];
}
$settings = array('heading' => array('title' => 'Newsletter Settings', 'main' => true, 'type' => 'h2'), 'settings' => array(array('key' => 'newsletter_default_from_name', 'default' => module_config::c('admin_system_name'), 'type' => 'text', 'description' => 'What sender name your newsletters will come from'), array('key' => 'newsletter_default_from_email', 'default' => module_config::c('admin_email_address'), 'type' => 'text', 'description' => 'What email address your newsletters will come from'), array('key' => 'newsletter_default_template', 'default' => 1, 'type' => 'select', 'options' => $templates, 'description' => 'Default template to use'), array('key' => 'newsletter_convert_links', 'default' => 1, 'type' => 'select', 'options' => get_yes_no(), 'description' => 'Convert all links into trackable click links', 'help' => 'When a user clicks a link in your newsletter it will record who, when and which link they clicked'), array('key' => 'newsletter_convert_images', 'default' => 1, 'type' => 'select', 'options' => get_yes_no(), 'description' => 'Convert all images into trackable images', 'help' => 'If this option is enabled you can tell when users see the images in your newsletters'), array('key' => 'newsletter_default_bounce', 'default' => module_config::c('admin_email_address'), 'type' => 'text', 'description' => 'What email address your bounced newsletters will go to (eg: bounce@yourwebsite.com)', 'help' => 'Please setup a NEW email address for bounces. Do not use an existing email address.'), array('key' => 'newsletter_bounce_host', 'default' => $_SERVER['HTTP_HOST'], 'type' => 'text', 'description' => 'POP3 incoming server address to access the bounce email account (eg: mail.yourwebsite.com)', 'help' => 'You can put the port number in like this:  mail.yourwebsite.com'), array('key' => 'newsletter_bounce_port', 'default' => '110', 'type' => 'text', 'description' => 'POP3 incoming server port (eg: 110 or 995)', 'help' => '110 is normal, 995 is ssl'), array('key' => 'newsletter_bounce_ssl', 'default' => '/ssl', 'type' => 'text', 'description' => 'SSL or TLS setting', 'help' => 'Set this to blank, or /ssl, or /tls or other options from php.net/imap_connect'), array('key' => 'newsletter_bounce_username', 'default' => '', 'type' => 'text', 'description' => 'POP3 username to access the bounce email account'), array('key' => 'newsletter_bounce_password', 'default' => '', 'type' => 'text', 'description' => 'POP3 password to access the bounce email account'), array('key' => 'newsletter_bounce_threshold', 'default' => 3, 'type' => 'number', 'description' => 'Bounce Threshold', 'help' => 'How many bounces before we unsubscribe this member'), array('key' => 'newsletter_send_burst_count', 'default' => 40, 'type' => 'number', 'description' => 'Burst Count', 'help' => 'How many emails the server will try to sent at the same time. Setting this too high may get you banned by your hosting provider.'), array('key' => 'newsletter_send_burst_break', 'default' => 2, 'type' => 'number', 'description' => 'Burst Wait', 'help' => 'Seconds to wait between sending batches of newsletters'), array('key' => 'newsletter_subscribe_redirect_double', 'default' => '', 'type' => 'text', 'description' => 'Subscribe Redirect (double opt-in)', 'help' => 'Full URL (including http://) to where the user is taken after confirming their double opt-in'), array('key' => 'newsletter_subscribe_redirect', 'default' => '', 'type' => 'text', 'description' => 'Subscribe Redirect', 'help' => 'Full URL (including http://) to where the user is taken after subscribing'), array('key' => 'newsletter_unsubscribe_redirect', 'default' => '', 'type' => 'text', 'description' => 'Un-Subscribe Redirect URL', 'help' => 'Full URL (including http://) to where the user is taken after confirming their unsubscription')));
module_config::print_settings_form($settings);
print_heading('Subscription Form');
?>
<p><?php 
_e('Here is a link to the newsletter subscription form. When people fill this out they will appear in the "Members" area:');
?>
 <a href="<?php 
echo module_member::link_public_subscribe();
?>
" target="_blank"><?php 
echo module_member::link_public_subscribe();
?>
</a> <?php 
_e('(this form can be edited from Settings > Templates)');
?>
</p>
    <?php 
print_heading('Un-Subscription Form');
?>
<p><?php 
_e('Here is a link to the newsletter un-subscription form. People can click this and enter their email to be manually removed from receiving emails:');
?>
 <a href="<?php 
echo module_newsletter::unsubscribe_url();
?>
" target="_blank"><?php 
Beispiel #12
0
 public static function render($newsletter_id, $send_id = false, $newsletter_member_id = false, $render_type = 'preview')
 {
     $newsletter = self::get_newsletter($newsletter_id);
     if (!$newsletter || $newsletter['newsletter_id'] != $newsletter_id) {
         return;
     }
     $newsletter_content = $newsletter['content'];
     if ($send_id) {
         $send_data = self::get_send($send_id);
         if ($send_data && $send_data['newsletter_id'] != $newsletter_id) {
             return;
         }
     }
     $replace = self::get_replace_fields($newsletter_id, $send_id, $newsletter_member_id);
     $template_html = '';
     if ($newsletter['newsletter_template_id']) {
         // load template in.
         $template = self::get_newsletter_template($newsletter['newsletter_template_id']);
         $replace['TEMPLATE_PATH'] = full_link($template['directory']);
         // check if there's a template file for this template
         // and pass the processing off to it's module.
         // this can replace the newsletter_content variable with something
         // more advanced like a listing from a WP database.
         if (!_DEMO_MODE) {
             // todo - run the content url
             // execute any php code inside the template.
             ob_start();
             @eval(' ?>' . $template['body'] . '<?php ');
             $template_html = ob_get_clean();
             if (!$template_html) {
                 $template_html = $template['body'];
             }
         } else {
             $template_html = $template['body'];
         }
         if ($template && $template['directory'] && is_dir($template['directory'])) {
             if (is_file($template['directory'] . 'render.php')) {
                 $return_html = false;
                 include $template['directory'] . 'render.php';
                 // do we return the html right from here?
                 if ($return_html) {
                     return $template_html;
                 }
             }
         }
     }
     if (!preg_match('#\\{BODY\\}#i', $template_html)) {
         $template_html .= '{BODY}';
     }
     //$template_html = str_replace('{BODY}',$newsletter_content,$template_html);
     // replace any content from our newsletter variables.
     $replace['BODY'] = $newsletter_content;
     // custom for send.
     // TODO: we build up a list of 'recipients' based on a search (or whatever) from any part of the application.
     // the list will be a CSV style file, with column headers. Each column can be linked into here as a replacement variable.
     // eg: the customer list will be "Customer Name" "Primary Contact" etc..
     // maybe tie this into the pagination function? so the table can be exported from anywhere?
     // store this listing of contacts as-is as new rows in the database. allow the user to edit this listing like a spreadsheet (ie: add new rows from another search, remove rows, edit details).
     // try to store a link back to the original record where this item came from (eg: a link to edit customer)
     // but always keep the original (eg:) email address of the customer on file, so if customer record changes the history will still show old address etc..
     // unsubscribes will add this users email to a separate black list, so that future sends will flag these members as unsubscribed.
     // admin has the option to ignore these unsubscribes if they want.
     // bounces will add this users email to a separate bounce list. after a certain number of bounces (from settings) we stop sending this user emails
     // and we notify future sends that this list of members wont be emailed due to bounces. (same warning/info listing that shows about unsubscribed users)
     // todo: end :)
     // nite dave!
     $final_newsletter_html = $template_html;
     // do HTML loop twice so we catch all conversions
     // ignore certain links for the below process
     // todo: doing this breaks link tracking on unsub/view online links.
     // option1: put every single unique link into the link table (eg, with member id on it)
     // option2: like old newsletter system, append newsletter member id onto end of all redirected links. then we can store a single "unsub" url in the db and it will redirect correctly.
     // todo - put generic url's in for unsub, view online, member details, etc..
     // todo - redirect opened links in external hook, append a new member id and new member id hash onto each redirect url.
     // todo - modify the unsub / view online / etc.. to look for these new appended memberid/memberhash variables along with existing old system ones.
     /*$special_link_replace_items = array(
           'UNSUBSCRIBE'=>self::unsubscribe_url($newsletter_id,$newsletter_member_id,$send_id),
           'VIEW_ONLINE'=>self::view_online_url($newsletter_id,$newsletter_member_id,$send_id),
           'LINK_ACCOUNT'=>'#',
           'SENDTOFRIEND'=>'#',
           'MEMBER_URL'=>'#',
       );*/
     $special_link_replace_items = array();
     // only contains the member_url at the moment.
     // are we a member?
     if ($newsletter_member_id > 0) {
         $member_data = self::get_newsletter_member($newsletter_member_id);
         if ($member_data && $member_data['member_id'] > 0) {
             $special_link_replace_items['MEMBER_URL'] = module_member::link_public_details($member_data['member_id']);
         }
     }
     for ($x = 0; $x < 2; $x++) {
         foreach ($replace as $key => $val) {
             if (isset($special_link_replace_items[$key])) {
                 continue;
             }
             // do these ones later.
             if ($render_type == 'preview' && !strlen(trim($val))) {
                 continue;
             }
             //$val = str_replace('//','////',$val); // todo- check this is correct in older version
             //$val = str_replace('\\','\\\\',$val); // todo- check this is correct in older version
             $final_newsletter_html = str_replace('{' . strtoupper($key) . '}', $val, $final_newsletter_html);
         }
     }
     if ($send_id && $render_type != 'preview') {
         // we process links and images for tracking purposes.
         if (module_config::c('newsletter_convert_links', 1)) {
             // check if there have been any converted links for this send already.
             $page_index = 1;
             foreach (array("href") as $type) {
                 preg_match_all('/<[^>]*(' . $type . '=(["\'])([^"\']+)\\2)/', $final_newsletter_html, $links);
                 if (is_array($links[3])) {
                     foreach ($links[3] as $link_id => $l) {
                         //if(!preg_match('/^\{/',$l) && !preg_match('/^#/',$l) && !preg_match('/^mailto:/',$l)){
                         if (!preg_match('/^\\{/', $l) && !preg_match('/^#/', $l) && !stripos($links[0][$link_id], '<link') && !(preg_match('/^\\w+:/', $l) && !preg_match('/^http/', $l))) {
                             //echo $links[0][$link_id] ."<br>";
                             $search = preg_quote($links[1][$link_id], "/");
                             //echo $search."<br>\n";
                             $l = preg_replace("/[\\?|&]phpsessid=([\\w\\d]+)/i", '', $l);
                             $l = ltrim($l, '/');
                             $newlink = (!preg_match('/^http/', $l) ? full_link('') : '') . $l;
                             // we are sending this out, we need to store a link to this in the db
                             // to record clicks etc..
                             // check if this link already exists in the database for this send.
                             $sql = "SELECT * FROM `" . _DB_PREFIX . "newsletter_link` WHERE `send_id` = " . (int) $send_id . " AND `link_url` = '" . mysql_real_escape_string($newlink) . "' AND `page_index` = " . (int) $page_index;
                             $existing = qa1($sql);
                             $db_link_id = false;
                             if ($existing && $existing['link_id']) {
                                 $db_link_id = $existing['link_id'];
                             } else {
                                 if ($render_type != 'preview') {
                                     // todo - don't re-create a link in the db if this send is bogus. like what if someone sends, then modifies the newsletter content, then goes back and views the stats. all the page index will be out of date. eep1!!!
                                     $db_link_id = update_insert('link_id', false, 'newsletter_link', array('send_id' => $send_id, 'link_url' => $newlink, 'page_index' => $page_index));
                                     //$sql = "INSERT INTO `"._DB_PREFIX."newsletter_link` SET `send_id` = ".(int)$send_id.", `link_url` = '".mysql_real_escape_string($newlink)."'";
                                     //query($sql);
                                     //$link_id = mysql_insert_id();
                                 }
                             }
                             if ($db_link_id) {
                                 $newlink = self::link_to_link($send_id, $db_link_id, $newsletter_member_id ? $newsletter_member_id : '');
                                 $replace = $type . '="' . $newlink . '"';
                                 //echo $replace."<br>\n";
                                 //preg_match('/'.$search."/",$template,$matches);print_r($matches);
                                 $final_newsletter_html = preg_replace('/' . $search . '/', $replace, $final_newsletter_html, 1);
                             }
                             $page_index++;
                         }
                     }
                 }
             }
         }
         if (module_config::c('newsletter_convert_images', 1)) {
             foreach (array("src", "background") as $type) {
                 preg_match_all('/' . $type . '=(["\'])([^"\']+)\\1/', $final_newsletter_html, $links);
                 if (is_array($links[2])) {
                     foreach ($links[2] as $link_id => $l) {
                         //if(!preg_match('/^\{/',$l) && !preg_match('/^#/',$l) && !preg_match('/^mailto:/',$l)){
                         if (!preg_match('/^\\{/', $l) && !preg_match('/^#/', $l) && !(preg_match('/^\\w+:/', $l) && !preg_match('/^http/', $l))) {
                             //echo $links[0][$link_id] ."<br>";
                             $search = preg_quote($links[0][$link_id], "/");
                             //echo $search."<br>\n";
                             $l = preg_replace("/[\\?|&]phpsessid=([\\w\\d]+)/i", '', $l);
                             $l = html_entity_decode(ltrim($l, '/'));
                             $newlink = (!preg_match('/^http/', $l) ? full_link('') : '') . $l;
                             // we are sending this out, we need to store a link to this in the db
                             // to record clicks etc..
                             // check if this link already exists in the database for this send.
                             $sql = "SELECT * FROM `" . _DB_PREFIX . "newsletter_image` WHERE `send_id` = " . (int) $send_id . " AND `image_url` = '" . mysql_real_escape_string($newlink) . "'";
                             $existing = qa1($sql);
                             if ($existing && $existing['image_id']) {
                                 $image_id = $existing['image_id'];
                             } else {
                                 $sql = "INSERT INTO `" . _DB_PREFIX . "newsletter_image` SET `send_id` = " . (int) $send_id . ", `image_url` = '" . mysql_real_escape_string($newlink) . "'";
                                 query($sql);
                                 $image_id = mysql_insert_id();
                             }
                             $newlink = self::link_to_image($send_id, $image_id, $newsletter_member_id ? $newsletter_member_id : '');
                             $replace = $type . '="' . $newlink . '"';
                             //echo $replace."<br>\n";
                             //preg_match('/'.$search."/",$template,$matches);print_r($matches);
                             $final_newsletter_html = preg_replace('/' . $search . '/', $replace, $final_newsletter_html, 1);
                         }
                     }
                 }
             }
         }
     }
     foreach ($special_link_replace_items as $key => $val) {
         if ($render_type == 'preview' && !strlen(trim($val))) {
             continue;
         }
         //$val = str_replace('//','////',$val); // todo- check this is correct in older version
         //$val = str_replace('\\','\\\\',$val); // todo- check this is correct in older version
         $final_newsletter_html = str_replace('{' . strtoupper($key) . '}', $val, $final_newsletter_html);
     }
     // todo - a text version of the html version.
     return $final_newsletter_html;
 }
}
$module->page_title = _l('Member: %s', htmlspecialchars($member['first_name'] . ' ' . $member['last_name']));
?>

<form action="" method="post" id="member_form">
	<input type="hidden" name="_process" value="save_member" />
	<input type="hidden" name="member_id" value="<?php 
echo $member_id;
?>
" />

    <?php 
module_form::set_required(array('fields' => array('first_name' => 'Name', 'email' => 'Email')));
module_form::prevent_exit(array('valid_exits' => array('.submit_button', '.submit_small')));
hook_handle_callback('layout_column_half', 1);
$fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Member Information'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array(array('title' => _l('First Name'), 'field' => array('name' => 'first_name', 'type' => 'text', 'value' => $member['first_name'])), array('title' => _l('Last Name'), 'field' => array('name' => 'last_name', 'type' => 'text', 'value' => $member['last_name'])), array('title' => _l('Business Name'), 'field' => array('name' => 'business', 'type' => 'text', 'value' => $member['business'])), array('title' => _l('Email'), 'field' => array('name' => 'email', 'type' => 'text', 'value' => $member['email'])), array('title' => _l('Phone'), 'field' => array('name' => 'phone', 'type' => 'text', 'value' => $member['phone'])), array('title' => _l('Mobile'), 'field' => array('name' => 'mobile', 'type' => 'text', 'value' => $member['mobile'])), array('title' => _l('External'), 'ignore' => !($member_id > 0), 'field' => array('type' => 'html', 'value' => '<a href="' . module_member::link_public_details($member_id) . '" target="_blank">' . _l('Edit Details') . '</a>', 'help' => 'You can send this link to your customer so they can edit their details.'))), 'extra_settings' => array('owner_table' => 'member', 'owner_key' => 'member_id', 'owner_id' => $member_id, 'layout' => 'table_row'));
echo module_form::generate_fieldset($fieldset_data);
if ($member_id && (int) $member_id > 0) {
    hook_handle_callback('member_edit', $member_id);
}
hook_handle_callback('layout_column_half', 2);
if ($member_id && (int) $member_id > 0) {
    if (class_exists('module_group', false)) {
        module_group::display_groups(array('title' => 'Member Groups', 'description' => _l('These are for you to group your members. The member cannot see or change these groups. You can choose members based on these groups.'), 'owner_table' => 'member', 'owner_id' => $member_id, 'view_link' => $module->link_open($member_id)));
        if (class_exists('module_newsletter', false)) {
            module_group::display_groups(array('title' => 'Newsletter', 'description' => _l('The member can choose which of the below subscriptions they would like to receive. The member can see and change these subscriptions themselves. You can choose members based on these subscriptions.'), 'owner_table' => 'newsletter_subscription', 'owner_id' => $member_id));
        }
    }
}
hook_handle_callback('layout_column_half', 'end');
$form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('ignore' => !($member_id > 0), 'type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . $module->link_open(false) . "';")));