コード例 #1
0
    public static function output()
    {
        add_action('wc_crm_restrict_list_logs', 'WC_CRM_Screen_Activity_Filters::restrict_list_logs');
        ?>
		<div class="wrap wc-crm-page-logs-table"  id="wc-crm-page">
			<h2><?php 
        _e('Activity', 'wc_crm');
        ?>
</h2>
			<?php 
        wc_crm_print_notices();
        ?>
			<form method="post">
				<input type="hidden" name="page" value="<?php 
        echo WC_CRM_TOKEN;
        ?>
">
				<?php 
        $customers_table = WC_CRM()->tables['activity'];
        $customers_table->views();
        $customers_table->prepare_items();
        $customers_table->display();
        ?>
			</form>
		</div>
		<?php 
    }
コード例 #2
0
 public function g_screen_option()
 {
     if (!isset($_GET['c_id'])) {
         $option = 'per_page';
         $args = array('label' => __('Groups', 'wc_crm'), 'default' => 20, 'option' => 'logs_per_page');
         add_screen_option($option, $args);
         WC_CRM()->tables['groups'] = new WC_CRM_Table_Groups();
     }
 }
コード例 #3
0
 /**
  * Install WC
  */
 public static function install()
 {
     global $wpdb;
     if (!defined('WC_CRM_INSTALLING')) {
         define('WC_CRM_INSTALLING', true);
     }
     // Ensure needed classes are loaded
     include_once 'admin/class-wc-crm-admin-notices.php';
     // Queue upgrades/setup wizard
     $current_wc_crm_version = get_option(WC_CRM_TOKEN . '_version', null);
     $current_db_version = get_option(WC_CRM_TOKEN . '_db_version', null);
     $major_wc_version = substr(WC_CRM()->_version, 0, strrpos(WC_CRM()->_version, '.'));
     $major_cur_version = substr($current_wc_crm_version, 0, strrpos($current_wc_crm_version, '.'));
     if (!is_null($current_wc_crm_version) && version_compare($major_cur_version, $major_wc_version, '>')) {
         self::remove_tables();
     }
     self::create_tables();
     self::create_roles();
     WC_CRM_Admin_Notices::remove_all_notices();
     // No versions? This is a new install :)
     if (is_null($current_wc_crm_version) && is_null($current_db_version) && apply_filters('wc_crm_enable_setup_wizard', true)) {
         WC_CRM_Admin_Notices::add_notice('crm_install');
         set_transient('_wc_crm_activation_redirect', 1, 30);
     } elseif (!is_null($current_wc_crm_version) && version_compare($major_cur_version, $major_wc_version, '>')) {
         WC_CRM_Admin_Notices::add_notice('crm_install');
         set_transient('_wc_crm_activation_redirect', 1, 30);
         $current_db_version = '2.6.0';
         self::update_db_version($current_db_version);
         // No customers? Let user run wizard again..
     } elseif (!get_option('wc_crm_customers_loaded')) {
         WC_CRM_Admin_Notices::add_notice('crm_install');
         // Show welcome screen for major updates only
     } elseif (version_compare($current_wc_crm_version, $major_wc_version, '<')) {
         set_transient('_wc_crm_activation_redirect', 1, 30);
     }
     if (!is_null($current_db_version) && version_compare($current_db_version, max(array_keys(self::$db_updates)), '<')) {
         WC_CRM_Admin_Notices::add_notice('crm_update');
     } else {
         self::update_db_version();
     }
     self::update_crm_version();
     /*
      * Deletes all expired transients. The multi-table delete syntax is used
      * to delete the transient record from table a, and the corresponding
      * transient_timeout record from table b.
      *
      * Based on code inside core's upgrade_network() function.
      */
     $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\tAND b.option_value < %d";
     $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time()));
     // Trigger action
     do_action('wc_crm_installed');
 }
コード例 #4
0
        /**
         * Intro text/links shown on all about pages.
         */
        private function intro()
        {
            // Drop minor version if 0
            $major_version = substr(WC_CRM()->_version, 0, 3);
            ?>
		<h1><?php 
            printf(__('Welcome to WooCommerce CRM %s', 'wc_crm'), $major_version);
            ?>
</h1>

		<div class="about-text woocommerce-about-text">
			<?php 
            if (!empty($_GET['wc-installed'])) {
                $message = __('Thanks, all done!', 'wc_crm');
            } elseif (!empty($_GET['wc-updated'])) {
                $message = __('Thank you for updating to the latest version!', 'wc_crm');
            } else {
                $message = __('Thanks for installing!', 'wc_crm');
            }
            printf(__('%s WooCommerce Customer Relationship Manager %s is more powerful, stable and secure than ever before. We hope you enjoy using it.', 'wc_crm'), $message, $major_version);
            ?>
		</div>

		<div class="wc-badge"><?php 
            printf(__('Version %s', 'wc_crm'), WC_CRM()->_version);
            ?>
</div>
		<p class="woocommerce-actions">
			<a href="<?php 
            echo esc_url(admin_url(add_query_arg(array('page' => WC_CRM_TOKEN . '-settings'), 'admin.php')));
            ?>
" class="button button-primary"><?php 
            _e('Settings', 'wc_crm');
            ?>
</a>
			<a href="http://actualityextensions.com/documentation/" class="docs button button-primary"><?php 
            _e('Docs', 'wc_crm');
            ?>
</a>
		<?php 
        }
if (function_exists('is_multisite') && is_multisite()) {
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    if (!is_plugin_active('woocommerce/woocommerce.php')) {
        return;
    }
} else {
    if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
        return;
    }
    // Check if WooCommerce is active
}
// Load plugin class files
require_once 'includes/class-wc-crm.php';
/**
 * Returns the main instance of WC_CRM to prevent the need to use globals.
 *
 * @since    2.7.0
 * @return object WC_CRM
 */
global $wpdb;
$wpdb->wc_crm_customermeta = $wpdb->prefix . "wc_crm_customermeta";
function WC_CRM()
{
    $instance = WC_CRM::instance(__FILE__, '3.0.1');
    /*if ( is_null( $instance->settings ) ) {
    		$instance->settings = WC_CRM_Settings::instance( $instance );
    	}*/
    return $instance;
}
WC_CRM();
コード例 #6
0
function wc_crm_get_statuses_options()
{
    global $wpdb;
    $sql = "SELECT * FROM {$wpdb->prefix}wc_crm_statuses";
    $statuses = WC_CRM()->statuses;
    $result = $wpdb->get_results($sql);
    if ($result) {
        foreach ($result as $r) {
            $statuses[$r->status_slug] = $r->status_name;
        }
    }
    return $statuses;
}
コード例 #7
0
 function column_customer_status($item)
 {
     if ($item['status'] && !empty($item['status'])) {
         $default_statuses = WC_CRM()->statuses;
         $_status = $item['status'];
         if (array_key_exists($_status, $default_statuses)) {
             $customer_status = '<div style="position: relative;"><span class="' . $_status . ' tips" data-tip="' . esc_attr($_status) . '"></span></div>';
         } else {
             $custom_status = wc_crm_get_status_by_slug($_status);
             if ($custom_status) {
                 $s = wc_crm_get_status_icon_code($custom_status['status_icon']);
                 $customer_status = sprintf('<i data-icomoon="%s" data-fip-value="%s" style="color: %s;" class="tips" data-tip="' . esc_attr($custom_status['status_name']) . '"></i>', $s, $custom_status['status_icon'], $custom_status['status_colour']);
             } else {
                 $customer_status = '<div style="position: relative;">' . $_status . '</div>';
             }
         }
         return $customer_status;
     } else {
         return '<div style="position: relative;"><span class="Customer tips" data-tip="Customer"></span></div>';
     }
 }
コード例 #8
0
 function check_customer_status($status = '')
 {
     if (empty($status)) {
         return false;
     }
     $def_statuses = WC_CRM()->statuses;
     if (in_array($status, $def_statuses)) {
         return $status;
     }
     global $wpdb;
     $table = $wpdb->prefix . "wc_crm_statuses";
     $check_sql = "SELECT status_slug FROM {$table} WHERE status_slug = '{$status}' || status_name = '{$status}'  LIMIT 1";
     $slug_check = $wpdb->get_var($check_sql);
     if ($slug_check) {
         $status = $slug_check;
     } else {
         $status = $this->add_customer_status($status);
     }
     return $status;
 }
コード例 #9
0
        public function customers_table()
        {
            return new WC_Crm_Customers_Table();
        }
        public function email_handling()
        {
            return new WC_Crm_Email_Handling();
        }
        public function phone_call()
        {
            return new WC_Crm_Email_Handling();
        }
        public function orders()
        {
            return WC_Crm_Orders::instance();
        }
    }
}
/**
 * Returns the main instance of WC_CRM to prevent the need to use globals.
 *
 * @since  2.1
 * @return WooCommerce_Customer_Relationship_Manager
 */
function WC_CRM()
{
    return WooCommerce_Customer_Relationship_Manager::instance();
}
// Global for backwards compatibility.
$GLOBALS['woocommerce'] = WC_CRM();
コード例 #10
0
        public static function output()
        {
            add_action('wc_crm_restrict_list_customers', 'WC_CRM_Screen_Customer_Filters::restrict_list_customers');
            echo '<div class="wrap" id="wc-crm-page">';
            self::page_title();
            $group = '';
            if (isset($_REQUEST['group']) && !empty($_REQUEST['group']) && $_REQUEST['group'] > 0) {
                $group = '&group=' . $_REQUEST['group'];
            }
            ?>
			<?php 
            wc_crm_print_notices();
            ?>
			<form method="get" id="wc_crm_customers_form" action="">
				<input type="hidden" name="page" value="<?php 
            echo WC_CRM_TOKEN;
            ?>
">
				<?php 
            $customers_table = WC_CRM()->tables['customers'];
            $customers_table->views();
            ?>
					<p class="search-box">
					<?php 
            $ss = '';
            if (!empty($_GET['s'])) {
                $ss = $_GET['s'];
            }
            ?>
						<label for="post-search-input" class="screen-reader-text"><?php 
            _e('Search', 'wc_crm');
            ?>
</label>
						<input type="search" value="<?php 
            echo $ss;
            ?>
" name="s" id="post-search-input">
						<input type="submit" value="<?php 
            _e('Search Customers', 'wc_crm');
            ?>
" class="button" id="search-submit" name="">
					</p>
					<?php 
            $customers_table->prepare_items();
            $customers_table->display();
            ?>
			</form>
			<div id="customer_notes_popup" class="overlay_media_popup">
			    <div class="media-modal wp-core-ui">
			    	<a href="#" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text">Close</span></span></a>
			    	<div class="media-modal-content">
			    		<div class="media-frame mode-select wp-core-ui hide-menu">
			    			<div class="media-frame-title"><h1>Customer Notes</h1></div>
			    			<div class="media-frame-content">
			    				<iframe src="" frameborder="0"></iframe>
			    			</div>
			    		</div>
			    	</div>
			    </div>
			    <div class="media-modal-backdrop"></div>
			</div>
			</div>
		<?php 
        }
コード例 #11
0
ファイル: customers.php プロジェクト: sajidshah/le-dolci
/**
 * Renders CRM page.
 */
function wc_customer_relationship_manager_render_list_page()
{
    echo '<div class="wrap" id="wc-crm-page">';
    wc_crm_page_title($_REQUEST);
    wc_crm_page_messages($_REQUEST);
    if (isset($_GET['message']) && $_GET['message'] == 1) {
        echo '<div id="message" class="updated fade"><p>Customer added.</p></div>';
    }
    if (isset($_GET['message']) && $_GET['message'] == 2 && isset($_GET['added_rows']) && !empty($_GET['added_rows'])) {
        echo '<div id="message" class="updated fade"><p>' . $_GET['added_rows'] . ' customers have been imported successfully.</p></div>';
    }
    $group = '';
    if (isset($_REQUEST['group']) && !empty($_REQUEST['group']) && $_REQUEST['group'] > 0) {
        $group = '&group=' . $_REQUEST['group'];
    }
    $statuses = wc_crm_get_statuses();
    $page_action = '';
    if (isset($_GET['order_list'])) {
        $page_action = 'order_list';
    } elseif (isset($_GET['product_list'])) {
        $page_action = 'product_list';
    } else {
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'email' && !isset($_REQUEST['send'])) {
            $page_action = 'email';
        } else {
            if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'phone_call' && !isset($_POST['save_phone_call'])) {
                $page_action = 'phone_call';
            }
        }
    }
    ?>
	<form method="<?php 
    echo empty($page_action) ? 'get' : 'post';
    ?>
" id="wc_crm_customers_form" action="admin.php?page=wc-customer-relationship-manager<?php 
    echo $group;
    ?>
">
		<input type="hidden" name="page" value="wc-customer-relationship-manager">
		<?php 
    switch ($page_action) {
        case 'order_list':
            require_once 'classes/wc_crm_order_list.php';
            $wc_crm_order_list = new WC_Crm_Order_List();
            $wc_crm_order_list->prepare_items();
            $wc_crm_order_list->display();
            break;
        case 'product_list':
            require_once 'classes/wc_crm_product_list.php';
            $wc_crm_product_list = new WC_Crm_Product_List();
            $wc_crm_product_list->prepare_items();
            $wc_crm_product_list->display();
            break;
        case 'email':
            WC_Crm_Email_Handling::display_form();
            break;
        case 'phone_call':
            WC_Crm_Phone_Call::display_form();
            break;
        default:
            $customers_table = WC_CRM()->customers_table();
            $customers_table->views();
            ?>
				<p class="search-box">
				<?php 
            $ss = '';
            if (!empty($_GET['s'])) {
                $ss = $_GET['s'];
            }
            ?>
					<label for="post-search-input" class="screen-reader-text"><?php 
            _e('Search', 'wc_customer_relationship_manager');
            ?>
</label>
					<input type="search" value="<?php 
            echo $ss;
            ?>
" name="s" id="post-search-input">
					<input type="submit" value="<?php 
            _e('Search Customers', 'wc_customer_relationship_manager');
            ?>
" class="button" id="search-submit" name="">
				</p>
				<?php 
            $customers_table->prepare_items();
            $customers_table->display();
            break;
    }
    ?>
	</form>
	<div id="customer_notes_popup" class="overlay_media_popup">
	    <div class="media-modal wp-core-ui">
	    	<a href="#" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text">Close</span></span></a>
	    	<div class="media-modal-content">
	    		<div class="media-frame mode-select wp-core-ui hide-menu">
	    			<div class="media-frame-title"><h1>Customer Notes</h1></div>
	    			<div class="media-frame-content">
	    				<iframe src="" frameborder="0"></iframe>
	    			</div>
	    		</div>
	    	</div>
	    </div>
	    <div class="media-modal-backdrop"></div>
	</div>
	</div>
<?php 
}
コード例 #12
0
ファイル: admin-init.php プロジェクト: sajidshah/le-dolci
<?php

/**
 * Admin init logic
 *
 * @author   Actuality Extensions
 * @package  WooCommerce_Customer_Relationship_Manager
 * @since    1.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
include WC_CRM()->plugin_path() . '/admin/group-functions.php';
require_once WC_CRM()->plugin_path() . '/admin/customers.php';
require_once WC_CRM()->plugin_path() . '/admin/groups.php';
require_once WC_CRM()->plugin_path() . '/admin/logs.php';
require_once WC_CRM()->plugin_path() . '/admin/customer_details.php';
require_once WC_CRM()->plugin_path() . '/admin/import.php';
require_once WC_CRM()->plugin_path() . '/admin/settings.php';
コード例 #13
0
    /**
     * Setup Wizard Header
     */
    public function setup_wizard_header()
    {
        ?>
		<!DOCTYPE html>
		<html xmlns="http://www.w3.org/1999/xhtml" <?php 
        language_attributes();
        ?>
>
		<head>
			<meta name="viewport" content="width=device-width" />
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<title><?php 
        _e('WooCommerce &rsaquo; Setup Wizard', 'wc_crm');
        ?>
</title>
			<?php 
        wp_print_scripts(WC_CRM_TOKEN . '-setup');
        ?>
			<?php 
        do_action('admin_print_styles');
        ?>
			<?php 
        #do_action( 'admin_head' );
        ?>
		</head>
		<body class="wc-setup wp-core-ui">
			<h2 id="logos">
				<img id="ae-logo" src="<?php 
        echo esc_url(WC_CRM()->assets_url);
        ?>
img/ae-logo.png" alt="Actuality Extensions" />
			</h2>
		<?php 
    }
コード例 #14
0
ファイル: import.php プロジェクト: sajidshah/le-dolci
 public static function add_crm_import_page()
 {
     add_submenu_page(WC_CRM()->id, __("Import", 'wc_customer_relationship_manager'), __("Import", 'wc_customer_relationship_manager'), 'manage_woocommerce', 'wc_crm_import', array(__CLASS__, 'render_import_page'));
 }
コード例 #15
0
ファイル: wc_crm_install.php プロジェクト: sajidshah/le-dolci
 /**
  * Add the menu item
  */
 function add_menu()
 {
     $hook = add_menu_page(__('Customers', 'wc_customer_relationship_manager'), __('Customers', 'wc_customer_relationship_manager'), 'manage_woocommerce', WC_CRM()->id, 'wc_customer_relationship_manager_render_list_page', null, '56.3');
     $new_customer_hook = add_submenu_page(WC_CRM()->id, isset($_GET['user_id']) && !empty($_GET['user_id']) ? __("Edit Customer", 'wc_customer_relationship_manager') : __("Add New Customer", 'wc_customer_relationship_manager'), '<span id="wc_crm_add_new_customer">' . __("Add New", 'wc_customer_relationship_manager') . '</span>', 'manage_woocommerce', 'wc_new_customer', 'wc_customer_relationship_manager_render_new_customer_page');
     $logs_hook = add_submenu_page(WC_CRM()->id, __("Activity", 'wc_customer_relationship_manager'), __("Activity", 'wc_customer_relationship_manager'), 'manage_woocommerce', 'wc_crm_logs', 'wc_customer_relationship_manager_render_logs_page');
     $accounts_hook = add_submenu_page(WC_CRM()->id, __('Accounts', 'wc_customer_relationship_manager'), __('Accounts', 'wc_customer_relationship_manager'), 'manage_woocommerce', 'edit.php?post_type=wc_crm_accounts');
     $groups_hook = add_submenu_page(WC_CRM()->id, __("Groups", 'wc_customer_relationship_manager'), __("Groups", 'wc_customer_relationship_manager'), 'manage_woocommerce', 'wc_user_grps', 'wc_customer_relationship_manager_render_groups_list_page');
     add_submenu_page(WC_CRM()->id, __("Settings", 'wc_customer_relationship_manager'), __("Settings", 'wc_customer_relationship_manager'), 'manage_woocommerce', 'wc_crm_settings', 'wc_customer_relationship_manager_render_settings_page');
     add_action("load-{$hook}", 'wc_customer_relationship_manager_add_options');
     add_action("load-{$logs_hook}", 'wc_customer_relationship_manager_logs_add_options');
     add_action("load-{$new_customer_hook}", 'wc_customer_relationship_manager_new_customer_add_options');
     add_action("load-{$groups_hook}", 'wc_customer_relationship_manager_groups_add_options');
 }
コード例 #16
0
        public function output()
        {
            $GLOBALS['hide_save_button'] = true;
            if (isset($_GET['action']) && $_GET['action'] == 'delete') {
                $this->delete_status();
            }
            if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id']) && !empty($_GET['id'])) {
                $data = wc_crm_get_status($_GET['id']);
                ?>
	    <div class="wrap">
	      <h2><?php 
                _e('Edit Status ', 'wc_customer_relationship_manager');
                ?>
</h2>
	      <form method="post" action="" enctype="multipart/form-data" id="wc_crm_customer_statuses">
	        <input type="hidden" value="wc_crm_add_customer_status" name="action">
	        <input type="hidden" value="<?php 
                echo $_GET['id'];
                ?>
" name="status_id">  
	        <table class="form-table">
	          <tbody>
	            <tr class="form-field form-required">
	              <th scope="row">
	                <label for="status_name"><?php 
                _e('Name', 'wc_customer_relationship_manager');
                ?>
</label>
	              </th>
	              <td>
	                <input id="status_name" type="text" aria-required="true" size="40" value="<?php 
                echo $data['status_name'];
                ?>
" name="status_name">
	              </td>
	            </tr>
	            <tr class="form-field">
	              <th scope="row">
	                <label for="status_slug"><?php 
                _e('Slug', 'wc_customer_relationship_manager');
                ?>
</label>
	              </th>
	              <td>
	                <input id="status_slug" type="text" aria-required="true" size="40" value="<?php 
                echo $data['status_slug'];
                ?>
" name="status_slug">
	              </td>
	            </tr>
	            <tr class="form-field form-required">
	              <th scope="row">
	                <label for="status_icon"><?php 
                _e('Icon', 'wc_customer_relationship_manager');
                ?>
</label>
	              </th>
	              <td>
	                <input id="status_icon" type="text" aria-required="true" size="40" value="<?php 
                echo $data['status_icon'];
                ?>
" name="status_icon">
	              </td>
	            </tr>
	            <tr class="form-field form-required">
	              <th scope="row">
	                <label for="status_colour"><?php 
                _e('Colour', 'wc_customer_relationship_manager');
                ?>
</label>
	              </th>
	              <td>
	                <input id="status_colour" type="text" aria-required="true" size="40" value="<?php 
                echo $data['status_colour'];
                ?>
" name="status_colour">
	              </td>
	            </tr>
	          </tbody>
	        </table>
	        <p class="submit"><input type="submit" value="Save Status" class="button button-primary" id="submit" name="submit"></p>
	        <p><a href="<?php 
                echo admin_url('admin.php?page=wc_crm_settings&tab=statuses');
                ?>
"><?php 
                _e('Back to statuses list', 'wc_customer_relationship_manager');
                ?>
</a></p>
	        <?php 
                wp_nonce_field('wc-crm-settings');
                ?>
	      </form>
	    </div>
	    <?php 
            } else {
                ?>
	    <div class="wrap nosubsub" id="wc-crm-page">
	      <h2><?php 
                _e('Customer Status ', 'wc_customer_relationship_manager');
                ?>
</h2>
	      <div id="col-container">
	        <div id="col-right">
	          <div class="col-wrap">
	            <form method="post" action="">
	              <?php 
                require_once WC_CRM()->plugin_path() . '/admin/classes/wc_crm_statuses_table.php';
                $statuses_table = new WC_CRM_Statuses_Table();
                $statuses_table->prepare_items();
                $statuses_table->display();
                ?>
	              <?php 
                wp_nonce_field('wc-crm-settings');
                ?>
	            </form>
	          </div>
	        </div><!-- /col-right -->
	        <div id="col-left">
	          <div class="col-wrap">
	            <div class="form-wrap">
	              <form method="post" action="" enctype="multipart/form-data"  id="wc_crm_customer_statuses">
	                <input type="hidden" value="wc_crm_add_customer_status" name="action">   
	                <div class="form-field form-required">
	                  <label for="status_name"><?php 
                _e('Name', 'wc_customer_relationship_manager');
                ?>
</label>
	                  <input id="status_name" type="text" aria-required="true" size="40" value="" name="status_name">
	                </div>
	                 <div class="form-field">
	                  <label for="status_slug"><?php 
                _e('Slug', 'wc_customer_relationship_manager');
                ?>
</label>
	                  <input id="status_slug" type="text" aria-required="true" size="40" value="" name="status_slug">
	                </div>
	                <div class="form-field form-required">
	                  <label for="status_icon"><?php 
                _e('Icon', 'wc_customer_relationship_manager');
                ?>
</label>
	                  <input id="status_icon" type="text" aria-required="true" size="40" value="" name="status_icon">
	                </div>
	                <div class="form-field form-required">
	                  <label for="status_colour"><?php 
                _e('Colour', 'wc_customer_relationship_manager');
                ?>
</label>
	                  <input id="status_colour" type="text" aria-required="true" size="40" value="" name="status_colour">
	                </div>
	                <p class="submit"><input type="submit" value="Add New Status" class="button button-primary" id="submit" name="submit"></p>
	                <?php 
                wp_nonce_field('wc-crm-settings');
                ?>
	              </form>
	            </div>
	          </div>
	        </div><!-- /col-left -->
	      </div><!-- /col-container -->
	    </div>
	    <?php 
            }
        }
コード例 #17
0
 /**
  * Handle CSV file download
  */
 function export_csv()
 {
     header('Content-Type: application/csv');
     header('Content-Disposition: attachment; filename=customers_' . date('Y-m-d') . '.csv');
     header('Pragma: no-cache');
     $__wc_crm_customer_details = new WC_Crm_Customer_Details(0, 0);
     $__wc_crm_customer_details->init_address_fields('', '', false);
     $__b_address = $__wc_crm_customer_details->billing_fields;
     $__s_address = $__wc_crm_customer_details->shipping_fields;
     $o = WC_CRM()->orders();
     $data = $o->get_orders();
     echo '"Customer name",';
     foreach ($__b_address as $key => $label) {
         if ($key == 'first_name' || $key == 'last_name') {
             continue;
         }
         echo '"Billing ' . $label['label'] . '",';
     }
     foreach ($__s_address as $key => $label) {
         if ($key == 'first_name' || $key == 'last_name') {
             continue;
         }
         echo '"Shipping ' . $label['label'] . '",';
     }
     echo '"Username",';
     echo '"Last purchase date",';
     echo '"Number of orders",';
     echo '"Total value",';
     echo "\"Subscribed\"\n";
     if (woocommerce_crm_mailchimp_enabled()) {
         $members = woocommerce_crm_get_members();
     }
     foreach ($data as $item) {
         //$item = get_object_vars ( $customer );
         if ($item['user_id']) {
             $user_id = $item['user_id'];
             $wc_crm_customer_details = new WC_Crm_Customer_Details($user_id, 0);
             $wc_crm_customer_details->init_address_fields('', '', false);
             $b_address = $wc_crm_customer_details->billing_fields;
             $s_address = $wc_crm_customer_details->shipping_fields;
             $data = get_user_meta($item['user_id']);
             echo '"' . $data['first_name'][0] . ' ' . $data['last_name'][0] . '",';
             foreach ($b_address as $key => $value) {
                 if ($key == 'first_name' || $key == 'last_name') {
                     continue;
                 }
                 if ($key == 'country') {
                     echo '"' . $item['country'] . '",';
                     continue;
                 }
                 if ($key == 'email') {
                     echo '"' . $item['email'] . '",';
                     continue;
                 }
                 $field_name = 'billing_' . $key;
                 $field_value = get_user_meta($user_id, $field_name, true);
                 echo '"' . $field_value . '",';
             }
             foreach ($s_address as $key => $value) {
                 if ($key == 'first_name' || $key == 'last_name') {
                     continue;
                 }
                 $field_name = 'shipping_' . $key;
                 $field_value = get_user_meta($user_id, $field_name, true);
                 echo '"' . $field_value . '",';
             }
             $user = @get_userdata($user_id);
             echo '"' . (isset($user->user_login) ? $user->user_login : __('Guest', 'wc_customer_relationship_manager')) . '",';
             $item['num_orders'] = wc_crm_get_num_orders($item['user_id']);
             $item['total_spent'] = wc_crm_get_order_value($item['user_id']);
         } else {
             $order_id = $item['order_id'];
             $user_id = 0;
             $order = new WC_Order($order_id);
             $wc_crm_customer_details_g = new WC_Crm_Customer_Details(0, $order_id);
             $wc_crm_customer_details_g->init_address_fields('', '', false);
             $b_address = $wc_crm_customer_details_g->billing_fields;
             $s_address = $wc_crm_customer_details_g->shipping_fields;
             $first_name = get_post_meta($item['order_id'], '_billing_first_name', true);
             $last_name = get_post_meta($item['order_id'], '_billing_last_name', true);
             echo '"' . $first_name . ' ' . $last_name . '",';
             foreach ($b_address as $key => $value) {
                 if ($key == 'first_name' || $key == 'last_name') {
                     continue;
                 }
                 if ($key == 'country') {
                     echo '"' . $item['country'] . '",';
                     continue;
                 }
                 if ($key == 'email') {
                     echo '"' . $item['email'] . '",';
                     continue;
                 }
                 $name_var = 'billing_' . $key;
                 $field_value = $wc_crm_customer_details_g->order->{$name_var};
                 echo '"' . $field_value . '",';
             }
             foreach ($s_address as $key => $value) {
                 if ($key == 'first_name' || $key == 'last_name') {
                     continue;
                 }
                 $var_name = 'shipping_' . $key;
                 $field_value = $wc_crm_customer_details_g->order->{$name_var};
                 echo '"' . $field_value . '",';
             }
             echo '"' . __('Guest', 'wc_customer_relationship_manager') . '",';
             $item['num_orders'] = wc_crm_get_num_orders($item['email'], '_billing_email', true);
             $item['total_spent'] = wc_crm_get_order_value($item['email'], '_billing_email', true);
         }
         $total_spent = wc_crm_price_num_decimals($item['total_spent']);
         $last_purchase = $item['order_id'] ? woocommerce_crm_get_pretty_time($item['order_id'], true) : '';
         echo '"' . $last_purchase . '",';
         echo '"' . $item['num_orders'] . '",';
         if (woocommerce_crm_mailchimp_enabled()) {
             $enrolled_plain = in_array($item['email'], $members) ? 'yes' : 'no';
             echo '"' . $total_spent . '",';
             echo '"' . $enrolled_plain . "\"\n";
         } else {
             echo '"' . $total_spent . "\"\n";
         }
     }
 }
コード例 #18
0
    /**
     * Add group admin panel
     *
     * Shows the interface for adding new groups
     */
    public static function add_group()
    {
        if (wc_crm_notice_count('error') == 0) {
            $_POST = array();
        }
        // Grab the submitted data
        $group_name = isset($_POST['group_name']) ? (string) stripslashes($_POST['group_name']) : '';
        $group_slug = isset($_POST['group_slug']) ? wc_sanitize_taxonomy_name(stripslashes((string) $_POST['group_slug'])) : '';
        $group_type = isset($_POST['group_type']) ? (string) stripslashes($_POST['group_type']) : '';
        $group_total_spent_mark = isset($_POST['group_total_spent_mark']) ? (string) stripslashes($_POST['group_total_spent_mark']) : '';
        $group_total_spent = isset($_POST['group_total_spent']) ? (string) stripslashes($_POST['group_total_spent']) : '';
        $group_user_role = isset($_POST['group_user_role']) ? (string) stripslashes($_POST['group_user_role']) : '';
        $group_customer_status = isset($_POST['group_customer_status']) ? $_POST['group_customer_status'] : array();
        $group_product_categories = isset($_POST['group_product_categories']) ? $_POST['group_product_categories'] : array();
        $group_order_status = isset($_POST['group_order_status']) ? $_POST['group_order_status'] : array();
        $group_last_order = isset($_POST['group_last_order']) ? (string) stripslashes($_POST['group_last_order']) : '';
        $group_last_order_from = isset($_POST['group_last_order_from']) ? (string) stripslashes($_POST['group_last_order_from']) : '';
        $group_last_order_to = isset($_POST['group_last_order_to']) ? (string) stripslashes($_POST['group_last_order_to']) : '';
        ?>
		<div class="wrap woocommerce">
			<div class="icon32 icon32-groups" id="icon-woocommerce"><br/></div>
		    <h2><?php 
        _e('Customer Groups', 'woocommerce');
        ?>
</h2>
		    <?php 
        wc_crm_print_notices();
        ?>
		    <br class="clear" />
		    <div id="col-container">
		    	<div id="col-right">
		    		<div class="col-wrap">
			    		<form action="admin.php?page=wc_crm-groups" method="post">
			    			<?php 
        WC_CRM()->tables['groups']->prepare_items();
        WC_CRM()->tables['groups']->display();
        ?>
			    		</form>
		    		</div>
		    	</div>
		    	<div id="col-left">
		    		<div class="col-wrap">
		    			<div class="form-wrap">
		    				<h3><?php 
        _e('Add New group', 'wc_crm');
        ?>
</h3>
		    				<p><?php 
        _e('Groups are used to organise your customers. Please Note: you cannot rename a group later.', 'wc_crm');
        ?>
</p>
		    				<form action="admin.php?page=wc_crm-groups" method="post" style=" padding-bottom: 150px;">
								<div class="form-field">
									<label for="f_group_name"><?php 
        _e('Name', 'woocommerce');
        ?>
</label>
									<input name="group_name" id="f_group_name" type="text" value="<?php 
        echo $group_name;
        ?>
" />
									<p class="description"><?php 
        _e('Name for the group.', 'wc_crm');
        ?>
</p>
								</div>

								<div class="form-field">
									<label for="f_group_slug"><?php 
        _e('Slug', 'woocommerce');
        ?>
</label>
									<input name="group_slug" id="f_group_slug" type="text" value="<?php 
        echo $group_slug;
        ?>
" maxlength="28" />
									<p class="description"><?php 
        _e('Unique slug/reference for the group; must be shorter than 28 characters.', 'wc_crm');
        ?>
</p>
								</div>

								<div class="form-field">
									<label for="f_group_type"><?php 
        _e('Type', 'wc_crm');
        ?>
</label>
									<select name="group_type" id="f_group_type">
										<option value="dynamic" <?php 
        selected($group_type, 'dynamic');
        ?>
 ><?php 
        _e('Dynamic', 'wc_crm');
        ?>
</option>
										<option value="static" <?php 
        selected($group_type, 'static');
        ?>
 ><?php 
        _e('Static', 'wc_crm');
        ?>
</option>
										<?php 
        do_action('wc_crm_customer_group_types');
        ?>
									</select>
									<p class="description"><?php 
        _e('Determines how you select group for customers.', 'wc_crm');
        ?>
</p>
								</div>
								<div class="form-field dynamic_group_type">
									<label for="group_total_spent"><?php 
        _e('Total Spent', 'wc_crm');
        ?>
</label>
									<select name="group_total_spent_mark" id="group_total_spent_mark">
										<option value="equal" <?php 
        selected($group_total_spent_mark, 'equal');
        ?>
><?php 
        _e('=', 'wc_crm');
        ?>
</option>
										<option value="greater" <?php 
        selected($group_total_spent_mark, 'greater');
        ?>
><?php 
        _e('&gt;', 'wc_crm');
        ?>
</option>
										<option value="less" <?php 
        selected($group_total_spent_mark, 'less');
        ?>
><?php 
        _e('&lt;', 'wc_crm');
        ?>
</option>
										<option value="greater_or_equal" <?php 
        selected($group_total_spent_mark, 'greater_or_equal');
        ?>
><?php 
        _e('&ge;', 'wc_crm');
        ?>
</option>
										<option value="less_or_equal" <?php 
        selected($group_total_spent_mark, 'less_or_equal');
        ?>
><?php 
        _e('&le;', 'wc_crm');
        ?>
</option>
									</select>
									<input type="number" step="any" id="group_total_spent" name="group_total_spent" value="<?php 
        echo $group_total_spent;
        ?>
">
								</div>
								<div class="form-field dynamic_group_type">
									<label for="group_user_role"><?php 
        _e('User Role', 'wc_crm');
        ?>
</label>
									<select name="group_user_role" id="group_user_role"  class="wc-enhanced-select">
										<option value="any">
								            	<?php 
        _e('Any', 'wc_crm');
        ?>
							            </option>
													<option value="guest">
								            	<?php 
        _e('Guest', 'wc_crm');
        ?>
							            </option>
													<?php 
        global $wp_roles;
        foreach ($wp_roles->role_names as $role => $name) {
            ?>
								            <option value="<?php 
            echo strtolower($name);
            ?>
" <?php 
            selected($group_user_role, strtolower($name));
            ?>
>
								            	<?php 
            _e($name, 'wc_crm');
            ?>
								            </option>
								          <?php 
        }
        ?>
									</select>
								</div>
								<div class="form-field dynamic_group_type">
									<label for="group_customer_status"><?php 
        _e('Customer Status', 'wc_crm');
        ?>
</label>
									<select name="group_customer_status[]" id="group_customer_status" multiple="multiple" data-placeholder="<?php 
        _e('Choose a Customer Status...', 'wc_crm');
        ?>
" class="wc-enhanced-select">
										<?php 
        $statuses = wc_crm_get_statuses();
        foreach ($statuses as $status) {
            ?>
								            <option value="<?php 
            echo strtolower($status->status_slug);
            ?>
" <?php 
            echo in_array(strtolower($status->status_slug), $group_customer_status) ? 'selected="selected"' : '';
            ?>
>
								            	<?php 
            echo $status->status_name;
            ?>
								            </option>
								          <?php 
        }
        ?>
									</select>
								</div>
								<div class="form-field dynamic_group_type">
									<label for="group_product_categories"><?php 
        _e('Product Category', 'wc_crm');
        ?>
</label>
									<select name="group_product_categories[]" id="group_product_categories" multiple="multiple" data-placeholder="<?php 
        _e('Choose a Product Category...', 'wc_crm');
        ?>
" class="wc-enhanced-select">
										<?php 
        $all_cat = get_terms(array('product_cat'), array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false));
        if (!empty($all_cat)) {
            foreach ($all_cat as $cat) {
                ?>
							            	<option value="<?php 
                echo $cat->term_id;
                ?>
" <?php 
                echo in_array($cat->term_id, $group_product_categories) ? 'selected="selected"' : '';
                ?>
>
							            		<?php 
                echo $cat->name;
                ?>
							            	</option>
							          	<?php 
            }
        }
        ?>
									</select>
								</div>
								<div class="form-field dynamic_group_type">
									<label for="group_order_status"><?php 
        _e('Order Status', 'wc_crm');
        ?>
</label>
									<select name="group_order_status[]" id="group_order_status" multiple="multiple" data-placeholder="<?php 
        _e('Choose a Product Category...', 'wc_crm');
        ?>
" class="wc-enhanced-select">
										<?php 
        $wc_statuses = wc_get_order_statuses();
        if (!empty($wc_statuses)) {
            foreach ($wc_statuses as $key => $status_name) {
                ?>
					            	<option value="<?php 
                echo $key;
                ?>
" <?php 
                echo in_array($key, $group_order_status) ? 'selected="selected"' : '';
                ?>
>
					            		<?php 
                echo $status_name;
                ?>
					            	</option>
					          	<?php 
            }
        }
        ?>
									</select>
								</div>
								<div class="form-field dynamic_group_type">
									<label for="group_last_order"><?php 
        _e('Last Order', 'wc_crm');
        ?>
</label>
									<div class="wrap_date">
										<select name="group_last_order" id="group_last_order">
											<option value="between" <?php 
        selected($group_last_order, 'between');
        ?>
><?php 
        _e('Between', 'wc_crm');
        ?>
</option>
											<option value="before"  <?php 
        selected($group_last_order, 'before');
        ?>
><?php 
        _e('Before', 'wc_crm');
        ?>
</option>
											<option value="after"   <?php 
        selected($group_last_order, 'after');
        ?>
><?php 
        _e('After', 'wc_crm');
        ?>
</option>
										</select>
									</div>
									<div class="wrap_date">
										<input type="text" id="group_last_order_from" name="group_last_order_from" value="<?php 
        echo $group_last_order_from;
        ?>
">
										<i class="ico_calendar"></i>
									</div>
									<div class="wrap_date group_last_order_between" style="height: 30px; line-height: 30px; padding: 0 10px;">
										to
									</div>
									<div class="wrap_date group_last_order_between">
										<input type="text" id="group_last_order_to" name="group_last_order_to" value="<?php 
        echo $group_last_order_to;
        ?>
">
										<i class="ico_calendar"></i>
									</div>
									<div class="clear"></div>
								</div>

								<p class="submit"><input type="submit" name="wc_crm_add_new_group" id="submit" class="button" value="<?php 
        _e('Add group', 'wc_crm');
        ?>
"></p>
								<?php 
        wp_nonce_field('wc-crm-add-new-group');
        ?>
		    				</form>
		    			</div>
		    		</div>
		    	</div>
		    </div>
		    <script type="text/javascript">
			/* <![CDATA[ */

				jQuery('a.delete').click(function(){
		    		var answer = confirm ("<?php 
        _e('Are you sure you want to delete this group?', 'wc_crm');
        ?>
");
					if (answer) return true;
					return false;
		    	});

			/* ]]> */
			</script>
		</div>
		<?php 
    }
コード例 #19
0
 function prepare_items()
 {
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $user = get_current_user_id();
     $screen = get_current_screen();
     $o = WC_CRM()->orders();
     if ($screen->id == 'wc_crm_accounts') {
         global $post;
         $account_id = $post->ID;
         $emails = get_post_meta($account_id, '_wc_crm_customer_email');
         if (!empty($emails)) {
             $this->data = $o->get_orders($emails);
             usort($this->data, array(&$this, 'usort_reorder'));
             $this->items = $this->data;
         } else {
             $this->items = array();
         }
     } else {
         $option = $screen->get_option('per_page', 'option');
         $per_page = get_user_meta($user, $option, true);
         if (empty($per_page) || $per_page < 1) {
             $per_page = $screen->get_option('per_page', 'default');
         }
         $current_page = $this->get_pagenum();
         $this->data = $o->get_orders();
         usort($this->data, array(&$this, 'usort_reorder'));
         $total_items = $o->orders_ount;
         $this->found_data = array_slice($this->data, ($current_page - 1) * $per_page, $per_page);
         $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
         $this->items = $this->found_data;
     }
 }