Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    5
    Plugin Contributions
    0

    Default Need to filter customers by specific admins.

    I'm working on a site in which there are specific admins/dealers who need to be connected to certain customers, such that the customers, orders and reports sections will only show the customers that that admin is authorized for/connected to.
    Does anyone know of such a thing, or would it be fairly simple to write? (I know a decent amount of php, but I'm not that familiar with the internal workings of zen cart, if I saw something similar enough I might be able to translate it to what I need.)

    General Info:
    Zen Cart 1.50
    Fresh Install
    upload via FTP and run zc_install

  2. #2
    Join Date
    Dec 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Need to filter customers by specific admins.

    I think I've got it mostly figured out.
    First, a small SQL patch like so:

    ALTER TABLE group_pricing ADD admin_id integer(1) NULL default NULL after group_percentage;

    Then a function (whereever you put functions, still haven't figured that one out yet):
    Code:
    function customer_allowed($cust_id){
    
    	global $db;
    
    	$profile = $db_>Execute("select profile_name from ".TABLE_ADMIN_PROFILES." where profile_id=(select admin_profile from ".TABLE_ADMIN." where admin_id = '".$_SESSION['admin_id']."')")
    
    	if($profile->fields['profile_name']=="Master Dealer") {
        	$who_allow = $db->Execute("select admin_id from ".TABLE_GROUP_PRICING." where group_id =(select customers_group_pricing from ".TABLE_CUSTOMERS." where customers_id='".$cust_id."')");
          if ($who_allow->fields['admin_id']==$_SESSION['admin_id'])
          {
          	return 'true';
          }
          else{
            return 'false';
          }
    	}
    	else {
    		return 'true';
    	}
    }
    I would then call that function on each row of the report or what have you.

    What I'm not sure about yet is how to create a dropdown in the group pricing page with all the admins by name, which would set the admin id in the group_pricing table.

    Any thoughts, comments or questions would be appreciated, thanks! If I get this working I will post it as a plugin, so others can benefit.

  3. #3
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default Re: Need to filter customers by specific admins.

    What I have always done, as I am not an expert coder, is to look at what is already there to see how it's done and then copy and modify it to my purpose. The admin functions are in admin/includes/functions. There are ways to hook into the core code and most proficient module authors use the admin/includes/functions/extra_functions directory to put their specific function files although some put them in the /function directory or modify a core file depending on what needs to happen.

    I think in the wiki there is more info about proper coding practices and I do recall some posts here, and I think there might even be a mod in the free downloads that maps the code hierarchy. It's sort of complicated when you first start but it does get easier like anything.

    Regarding the drop down, you will probably want to use the built in function zen_draw_pull_down_menu. When in doubt, I personally have always found the developers toolkit in the admin section under tools/developers tool kit to be a lifesaver. In my mind this was one of the best tools put in the admin section for people that want to extend the cart. Again, it always helps to look at other mods or features that use similar aspects of what you want so you can quickly pick up the structure and coding style to achieve what you want.

    Welcome to the forum, good luck, ask questions as this is a (usually) very friendly and helpful place, and I look forward to seeing your mod in the free downloads sections!
    Last edited by lankeeyankee; 1 Sep 2012 at 02:51 AM.

    Zen Cart and it's community are the best!!

 

 

Similar Threads

  1. v150 Looking For Plugin - Connect admins to specific customers only.
    By nullset9 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 26 Aug 2012, 06:15 PM
  2. Replies: 0
    Last Post: 12 Jul 2012, 01:47 AM
  3. filter specific categories using Category/Manufacturer Filter
    By orhonch in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 4 Dec 2011, 12:31 AM
  4. Need list of customers only in specific state
    By dcfxking in forum General Questions
    Replies: 4
    Last Post: 21 May 2008, 04:36 PM
  5. distributors(moded customers) login as admins...
    By elhector in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 31 Jan 2008, 12:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR