CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to add More in “ACTION” Column in a custom Search?
Pages: [1]

Author Topic: How to add More in “ACTION” Column in a custom Search?  (Read 846 times)

tapash

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.34
  • MySQL version: 5.1
  • PHP version: 5.3.3
How to add More in “ACTION” Column in a custom Search?
April 14, 2015, 07:33:36 am
I have a custom search extension for contacts. Search result shows by default "VIEW EDIT" option in "ACTION" Column.

How Can I bring the "MORE" option just like the one appears if I use built in Basic search function from Search menu?

Content of my customsearch.php

Code: [Select]
<?php
class CRM_Guestsearch_Form_Search_Guestsearch extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {

      function 
__construct(&$formValues) {
        
parent::__construct($formValues);
      }

      function 
buildForm(&$form) {
        
CRM_Utils_System::setTitle(ts('Recently Registered Guest (Unassigned)'));

        
$form->assign('elements', array('name'));
      }

      function 
summary() {
        return 
NULL;
        
// return array(
        //   'summary' => 'This is a summary',
        //   'total' => 50.0,
        // );
      
}

      function &
columns() {
        
// return by reference
        
$columns = array(
          
ts('Contact Type') => 'contact_sub_type',
          
ts('Name') => 'sort_name',
          
ts('Phone') => 'phone',
          
ts('Email') => 'email',
          
ts('Date of visit') => CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME,
        );
        return 
$columns;
      }

      function 
all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE) {

        return 
$this->sql($this->select(), $offset, $rowcount, null, $includeContactIDs, NULL);
      }

      function 
select() {
        return 
"
          contact_a.id                  as contact_id  ,
          contact_a.contact_sub_type    as contact_sub_type,
          contact_a.sort_name           as sort_name,
          phone.phone ,
          email.email  ,
          date.
        " 
. CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME;
      }

      function 
from() {
        return 
"
          FROM      civicrm_contact contact_a
          LEFT JOIN civicrm_activity_contact a ON (a.contact_id = contact_a.id)
          LEFT JOIN civicrm_phone phone ON (phone.contact_id = contact_a.id)
          LEFT JOIN civicrm_email email ON (email.contact_id = contact_a.id)
          LEFT JOIN " 
. CIVICRM_GUESTSEARCH_CUSTOM_TABLE_NAME . " date ON (date.entity_id = contact_a.id)
        "
;
      }

      function 
where($includeContactIDs = false) {
        
$params = array();

        
$where = "contact_a.contact_sub_type = 'Guest' AND activity_id IS NULL ORDER BY date." . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME . " ASC ";
            return 
$where;
          }

      function 
templateFile() {
        return 
'CRM/Contact/Form/Search/Custom.tpl';
      }
    }

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: How to add More in “ACTION” Column in a custom Search?
April 14, 2015, 12:20:30 pm
Might help to check an existing custom search (e.g. Proximity Search) which exposes the task list. On quick examination it looks like you've extended CRM_Contact_Form_Search_Custom_Base which does inherit the default buildTaskList method - so it might be a permission issue. Also saw a code comment about needed to alias civicrm_contact.id as contact_id in order to use tasks (not sure if that's accurate though).
Protect your investment in CiviCRM by  becoming a Member!

tapash

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.34
  • MySQL version: 5.1
  • PHP version: 5.3.3
Re: How to add More in “ACTION” Column in a custom Search?
April 15, 2015, 12:52:59 am
Thanks for reply. I am accessing this search as an admin. SO, what permission you are talking about.

Another point related to above codes. On civicrm 4.6, when I manually select a result by using the checkbox, ACTION MENU (below search parameters) remains deactivated. Action options only activates if i select the option "Select ALL Records". How can I fix it Please?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to add More in “ACTION” Column in a custom Search?

This forum was archived on 2017-11-26.