garf3r Posted January 16, 2015 Share Posted January 16, 2015 Hi there, new to the forum Ok so i have a crm and i'm trying to add bits, been pretty succesful at most of it, however i've added a new field "status" and i want to be able to search this field, i've tried copying and changing the existing code, but it doesn't seem to be grabbing it. So here's some exisiting code (that works and searches the field marked "Address" 'address' => array( 'title' => _l('Address:'), 'field' => array( 'type' => 'text', 'name' => 'search[address]', 'value' => isset($search['address'])?$search['address']:'', 'size' => 15, ) ), 'status' => array( 'title' => _l('Status:'), 'field' => array( 'type' => 'text', 'name' => 'search[status]', 'value' => isset($search['status'])?$search['status']:'', 'size' => 15, ) ), I thought a simple name change like above would work, but it doesn't pull anything through, anyone got any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/293981-search-code-not-working/ Share on other sites More sharing options...
QuickOldCar Posted January 16, 2015 Share Posted January 16, 2015 Is this a custom CRM or a well known one? The little snippet does not help much as all we see is a simple array. If you changed those values and did not work is obviously more to this than just changing those words. Some things to think about... This could be part of a class or function that is using a prepared query with static values or expecting just what they coded it for. What is now setting $search['status']? A lot more information would be needed and code seen to determine what changes are needed. Quote Link to comment https://forums.phpfreaks.com/topic/293981-search-code-not-working/#findComment-1503125 Share on other sites More sharing options...
garf3r Posted January 16, 2015 Author Share Posted January 16, 2015 It's the Ultimate Client Manager from code canyon? I could supply the files if needed, most of it has just been a case of changing fields etc, but the search for this doesn't seem to hook it Quote Link to comment https://forums.phpfreaks.com/topic/293981-search-code-not-working/#findComment-1503132 Share on other sites More sharing options...
garf3r Posted January 16, 2015 Author Share Posted January 16, 2015 I'm just guessing here, i found this in the user.php public static function get_users($search=array(),$mysql=false){ // limit based on customer id /*if(!isset($_REQUEST['customer_id']) || !(int)$_REQUEST['customer_id']){ return array(); }*/ // build up a custom search sql query based on the provided search fields $sql = "SELECT *,u.user_id AS id "; $sql .= ", u.name AS name "; $from = " FROM `"._DB_PREFIX."user` u "; $where = " WHERE 1 "; $where .= " AND u.customer_id = 0 "; if(isset($search['generic']) && $search['generic']){ $str = mysql_real_escape_string($search['generic']); $where .= " AND ( "; $where .= " u.name LIKE '%$str%' OR "; $where .= " u.email LIKE '%$str%' OR "; $where .= " u.phone LIKE '%$str%' OR "; $where .= " u.mobile LIKE '%$str%' "; $where .= ' ) '; } if(isset($search['customer_id']) && $search['customer_id']){ /*$str = mysql_real_escape_string($search['customer_id']); $where .= " AND u.customer_id = '$str'"; $sql .= " , c.primary_user_id AS is_primary "; $from .= " LEFT JOIN `"._DB_PREFIX."customer` c ON u.customer_id = c.customer_id ";*/ set_error('Bad usage of get_user() - please report this error.'); return array(); } if(isset($search['security_role_id']) && (int)$search['security_role_id']>0){ $str = (int)$search['security_role_id']; $from .= " LEFT JOIN `"._DB_PREFIX."user_role` ur ON u.user_id = ur.user_id"; $where .= " AND ur.security_role_id = $str"; } foreach(array('email') as $key){ if(isset($search[$key]) && $search[$key] !== ''&& $search[$key] !== false){ $str = mysql_real_escape_string($search[$key]); $where .= " AND u.`$key` LIKE '$str'"; } } I'm guessing it may be something to do with that? Quote Link to comment https://forums.phpfreaks.com/topic/293981-search-code-not-working/#findComment-1503140 Share on other sites More sharing options...
garf3r Posted January 19, 2015 Author Share Posted January 19, 2015 This is my array 'status' => array( 'title' => _l('Status (do not use)'), 'field' => array( 'type' => 'select', 'name' => 'search[status]', 'value' => isset($search['status'])?$search['status']:'', 'blank' => ' - Status - ', 'options' => array( _Quote => _l('Quote'), _Application => _l('Application'), 'On Risk' => _l('On Risk'), _Dead => _l('Dead'), _NTU => _l('NTU'), _Cancelled => _l('Cancelled'), _TestLead => _l('Test Lead'), ), ), ), And this is my search string (which comes up blank) if(isset($search['status']) && trim($search['status'])){ $str = (int)$search['status']; // search all the customer site addresses. $sql .= " LEFT JOIN `"._DB_PREFIX."customer` cur ON (c.customer_id = cur.status)"; $where .= " AND (cur.status = '$str')"; } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/293981-search-code-not-working/#findComment-1503378 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.