/**
     * 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 
    }
Ejemplo n.º 2
0
function wc_crm_get_statuses_slug()
{
    $st = wc_crm_get_statuses();
    $new_st = array();
    if (!empty($st)) {
        foreach ($st as $s) {
            $new_st[$s->status_slug] = $s->status_name;
        }
    }
    return $new_st;
}
 function get_views()
 {
     $customer_status = WC_CRM_Screen_Customer_Filters::get_filter_data('status');
     $_statuses = array();
     $all = 0;
     if ($customer_status) {
         foreach ($customer_status as $st) {
             $_statuses[$st->status] = $st->count;
             $all += (int) $st->count;
         }
     }
     $views = array();
     $current = !empty($_REQUEST['_customer_status']) ? $_REQUEST['_customer_status'] : 'all';
     //All link
     $class = $current == 'all' ? ' class="current"' : '';
     $all_url = 'admin.php?page=' . WC_CRM_TOKEN;
     $views['all'] = "<a href='{$all_url}' {$class} >All <span class='count'>({$all})</span></a>";
     $statuses = wc_crm_get_statuses();
     if ($customer_status && $statuses) {
         foreach ($statuses as $st) {
             if (isset($_statuses[$st->status_slug])) {
                 $count = $_statuses[$st->status_slug];
                 $url = add_query_arg(array('_customer_status' => $st->status_slug), 'admin.php?page=' . WC_CRM_TOKEN);
                 $class = $current == $st->status_slug ? ' class="current"' : '';
                 $views[$st->status_slug] = "<a href='{$url}' {$class} >{$st->status_name} <span class='count'>({$count})</span></a>";
             }
         }
     }
     return $views;
 }
Ejemplo n.º 4
0
 function prepare_items()
 {
     $columns = $this->get_columns();
     $hidden = array();
     self::$data = wc_crm_get_statuses(true, true);
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     usort(self::$data, array(&$this, 'usort_reorder'));
     $per_page = 10;
     $current_page = $this->get_pagenum();
     $total_items = count(self::$data);
     if ($_GET['page'] == 'wc_user_grps' || $_GET['page'] == 'wc_crm_settings' && !empty($_GET['tab']) && $_GET['tab'] == 'statuses') {
         // only ncessary because we have sample data
         $this->found_data = array_slice(self::$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;
     } else {
         $this->items = self::$data;
     }
 }
Ejemplo n.º 5
0
/**
 * 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 
}
Ejemplo n.º 6
0
 function get_bulk_actions()
 {
     $screen = get_current_screen();
     if ($screen->id != 'wc_crm_accounts') {
         $actions = array('email' => __('Send Email', 'wc_customer_relationship_manager'), 'export_csv' => __('Export Contacts', 'wc_customer_relationship_manager'));
         $statuses = wc_crm_get_statuses();
         foreach ($statuses as $status) {
             $actions[$status->status_slug] = sprintf(__('Mark as %s', 'wc_customer_relationship_manager'), $status->status_name);
         }
         $groups = wc_get_static_groups();
         foreach ($groups as $group) {
             $actions['crm_add_to_group_' . $group->ID] = sprintf(__('Add to %s', 'wc_customer_relationship_manager'), $group->group_name);
         }
         return $actions;
     }
     return array();
 }