Example #1
0
 public function ajax_search($search_key)
 {
     // return results based on an ajax search.
     $ajax_results = array();
     $search_key = trim($search_key);
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) {
         //$sql = "SELECT * FROM `"._DB_PREFIX."vendor` c WHERE ";
         //$sql .= " c.`vendor_name` LIKE %$search_key%";
         //$results = qa($sql);
         $results = $this->get_vendors(array('generic' => $search_key));
         if (count($results)) {
             foreach ($results as $result) {
                 // what part of this matched?
                 if (preg_match('#' . preg_quote($search_key, '#') . '#i', $result['name']) || preg_match('#' . preg_quote($search_key, '#') . '#i', $result['last_name']) || preg_match('#' . preg_quote($search_key, '#') . '#i', $result['phone'])) {
                     // we matched the vendor contact details.
                     $match_string = _l('Vendor Contact: ');
                     $match_string .= _shl($result['vendor_name'], $search_key);
                     $match_string .= ' - ';
                     $match_string .= _shl($result['name'], $search_key);
                     // hack
                     $_REQUEST['vendor_id'] = $result['vendor_id'];
                     $ajax_results[] = '<a href="' . module_user::link_open_contact($result['user_id']) . '">' . $match_string . '</a>';
                 } else {
                     $match_string = _l('Vendor: ');
                     $match_string .= _shl($result['vendor_name'], $search_key);
                     $ajax_results[] = '<a href="' . $this->link_open($result['vendor_id']) . '">' . $match_string . '</a>';
                     //$ajax_results [] = $this->link_open($result['vendor_id'],true);
                 }
             }
         }
     }
     return $ajax_results;
 }
Example #2
0
 public function ajax_search($search_key)
 {
     // return results based on an ajax search.
     $ajax_results = array();
     $search_key = trim($search_key);
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) {
         $results = $this->get_widgets(array('generic' => $search_key));
         if (count($results)) {
             foreach ($results as $result) {
                 $match_string = _l('Widget: ');
                 $match_string .= _shl($result['name'], $search_key);
                 $ajax_results[] = '<a href="' . $this->link_open($result['widget_id']) . '">' . $match_string . '</a>';
             }
         }
     }
     return $ajax_results;
 }
Example #3
0
 public function ajax_search($search_key)
 {
     // return results based on an ajax search.
     $ajax_results = array();
     $search_key = trim($search_key);
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) {
         $results = $this->get_invoices(array('generic' => $search_key));
         if (count($results)) {
             foreach ($results as $result) {
                 $match_string = _l('Invoice: ');
                 $match_string .= _shl($result['name'], $search_key);
                 $match_string .= ' for ';
                 $match_string .= dollar($result['cached_total'], true, $result['currency_id']);
                 $match_string .= ' (' . ($result['date_paid'] && $result['date_paid'] != '0000-00-00' ? _l('Paid') : _l('Unpaid')) . ')';
                 $ajax_results[] = '<a href="' . $this->link_open($result['invoice_id']) . '">' . $match_string . '</a>';
             }
         }
     }
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2) && is_numeric($search_key)) {
         $sql = "SELECT * FROM `" . _DB_PREFIX . "invoice_payment` WHERE `amount` = '" . mysql_real_escape_string($search_key) . "' ORDER BY date_paid DESC LIMIT 5";
         $results = qa($sql);
         if (count($results)) {
             foreach ($results as $result) {
                 $match_string = _l('Invoice Payment: ');
                 $match_string .= dollar($result['amount'], true, $result['currency_id']) . ' on ' . print_date($result['date_paid']);
                 $ajax_results[] = '<a href="' . $this->link_open($result['invoice_id']) . '">' . $match_string . '</a>';
             }
         }
         $sql = "SELECT * FROM `" . _DB_PREFIX . "invoice` WHERE `cached_total` = '" . mysql_real_escape_string($search_key) . "' ORDER BY date_create DESC LIMIT 5";
         $results = qa($sql);
         if (count($results)) {
             foreach ($results as $result) {
                 $match_string = _l('Invoice: ');
                 $match_string .= htmlspecialchars($result['name']);
                 $match_string .= ' for ';
                 $match_string .= dollar($result['cached_total'], true, $result['currency_id']);
                 $match_string .= ' (' . ($result['date_paid'] && $result['date_paid'] != '0000-00-00' ? _l('Paid') : _l('Unpaid')) . ')';
                 $ajax_results[] = '<a href="' . $this->link_open($result['invoice_id']) . '">' . $match_string . '</a>';
             }
         }
     }
     return $ajax_results;
 }
Example #4
0
 public function ajax_search($search_key)
 {
     // return results based on an ajax search.
     $ajax_results = array();
     $search_key = trim($search_key);
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) {
         $searchable_fields = get_multiple('extra_default', array('searchable' => 1));
         if (count($searchable_fields)) {
             $sql = "SELECT * FROM `" . _DB_PREFIX . "extra` ext WHERE ";
             foreach ($searchable_fields as $searchable_field) {
                 $sql .= ' (ext.`owner_table` = "' . mysql_real_escape_string($searchable_field['owner_table']) . '" AND ext.`extra_key` = "' . mysql_real_escape_string($searchable_field['extra_key']) . '" AND ext.`extra` LIKE "%' . mysql_real_escape_string($search_key) . '%") OR ';
             }
             $sql = rtrim($sql, ' OR');
             $results = qa($sql);
             foreach ($results as $result) {
                 $match_string = _shl(htmlspecialchars($result['extra']), $search_key);
                 $link = '#';
                 $result['owner_table'] = preg_replace('#[^a-z]#', '', $result['owner_table']);
                 if (is_callable('module_' . $result['owner_table'] . '::link_open')) {
                     eval('$link = module_' . $result['owner_table'] . '::link_open(' . $result['owner_id'] . ');');
                 }
                 $ajax_results[] = '<a href="' . $link . '">' . ucwords($result['owner_table']) . ' ' . htmlspecialchars($result['extra_key']) . ': ' . $match_string . '</a>';
             }
         }
     }
     return $ajax_results;
 }
Example #5
0
 public function ajax_search($search_key)
 {
     // return results based on an ajax search.
     $ajax_results = array();
     $search_key = trim($search_key);
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) {
         //$sql = "SELECT * FROM `"._DB_PREFIX."customer` c WHERE ";
         //$sql .= " c.`customer_name` LIKE %$search_key%";
         //$results = qa($sql);
         $results = $this->get_products(array('general' => $search_key));
         if (count($results)) {
             foreach ($results as $result) {
                 $match_string = _l('Product: ');
                 $match_string .= _shl($result['name'], $search_key);
                 $ajax_results[] = '<a href="' . $this->link_open($result['product_id']) . '">' . $match_string . '</a>';
                 //$ajax_results [] = $this->link_open($result['customer_id'],true);
             }
         }
     }
     return $ajax_results;
 }
Example #6
0
 public function ajax_search($search_key)
 {
     // return results based on an ajax search.
     $ajax_results = array();
     $search_key = trim($search_key);
     if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) {
         //$sql = "SELECT * FROM `"._DB_PREFIX."newsletter` c WHERE ";
         //$sql .= " c.`newsletter_name` LIKE %$search_key%";
         //$results = qa($sql);
         $results = $this->get_newsletters(array('subject' => $search_key, 'group_results' => 1));
         if (mysql_num_rows($results)) {
             while ($result = mysql_fetch_assoc($results)) {
                 // what part of this matched?
                 /*if(
                       preg_match('#'.preg_quote($search_key,'#').'#i',$result['name']) ||
                       preg_match('#'.preg_quote($search_key,'#').'#i',$result['last_name']) ||
                       preg_match('#'.preg_quote($search_key,'#').'#i',$result['phone'])
                   ){
                       // we matched the newsletter contact details.
                       $match_string = _l('Newsletter Contact: ');
                       $match_string .= _shl($result['newsletter_name'],$search_key);
                       $match_string .= ' - ';
                       $match_string .= _shl($result['name'],$search_key);
                       // hack
                       $_REQUEST['newsletter_id'] = $result['newsletter_id'];
                       $ajax_results [] = '<a href="'.module_user::link_open_contact($result['user_id']) . '">' . $match_string . '</a>';
                   }else{*/
                 $match_string = _l('Newsletter: ');
                 $match_string .= _shl($result['subject'], $search_key);
                 $ajax_results[] = '<a href="' . $this->link_open($result['newsletter_id']) . '">' . $match_string . '</a>';
                 //$ajax_results [] = $this->link_open($result['newsletter_id'],true);
                 /*}*/
             }
         }
     }
     return $ajax_results;
 }