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) »
  • Developer Discussion »
  • Report and Search UI Discussion (Moderators: CiviTeacher.com, TwoMice) »
  • "Add these Contacts to Group" how to implement this?
Pages: [1]

Author Topic: "Add these Contacts to Group" how to implement this?  (Read 1304 times)

3524

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal
  • MySQL version: 5.1.72-cll
  • PHP version: 5.3.28
"Add these Contacts to Group" how to implement this?
June 02, 2014, 04:53:58 am
Hi community,

since hours i try to find out, why the Button "Add these Contacts to Group" is not working. "Print Report", "PDF" and Export to CSV just works fine. But not the very important Add button.

i reduced my code (built after "http://wiki.civicrm.org/confluence/display/CRMDOC/Report+Showing+Individuals+and+Related+Groups") to the minimum possible (of course i would like to do more fancy things with multiple left join's etc (which btw works also fine).

here is the reduced code:
Code: [Select]
<?php
 
require_once 'CRM/Report/Form.php';
class 
CRM_Report_Form_Contact_whoiswho extends CRM_Report_Form {
 
    function 
preProcess( ) {
        
parent::preProcess( );
    }
 
    function 
__construct( ) {
parent::__construct( );
    }

 
    function 
postProcess( ) {
    
$this->beginPostProcess( );   
   
    
// the query parts
    
$mySelect =     "SELECT civicrm_contact.id, civicrm_contact.sort_name ";
    
$myFrom =   "FROM civicrm_contact  ";
    
$myWhere =      "WHERE civicrm_contact.id=1 ";  
    
$myOrderBy =    "";

 
 
 
    
//concatenate the query parts to get the full query
    
$myQuery = $mySelect . $myFrom . $myWhere . $myOrderBy;
        
    
$this->_columnHeaders =
            array( 
                   
                   
'sort_name' =>    array( 'title' => 'Name' ),
                   
'id' =>        array( 'title' => 'CiviCRM ID' ),
                 );
                 
 
    
// fetch the query results
    
$this->buildRows ( $myQuery, $rows );
    
$this->doTemplateAssignment( $rows );
    
$this->endPostProcess( $rows );
    }
}

any hints where i have to look into? help would be appreciated!

thx in advance!

Cheers
3524

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 05:25:29 am
At least the user should have the administer report permission. Other than that the report looks good to have an add To Group button and drop down. It could be that you have customized the template of the report. 
Developer at Edeveloper / CiviCoop

3524

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal
  • MySQL version: 5.1.72-cll
  • PHP version: 5.3.28
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 05:38:56 am
Hi jaapjansma,

thanks for the reply and so fast!

The user i am testing with has full rights (admin). Maybe i was not so clear. there is the functionality shown, but it does not add the contacts (or in my example the contact) to the group selected. it runns something, but also with the civicrm loggin functionality enabled, it does not even give an error.

This sentense i might not understand:
"It could be that you have customized the template of the report."
i have customized the template (it's in my "custom code" folder). and everything goes fine but the "add to group"- button

hope i could make myselfe more clear.


jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 06:22:37 am
Quote
"It could be that you have customized the template of the report."
i have customized the template (it's in my "custom code" folder). and everything goes fine but the "add to group"- button

What I mean is that you might have something in your template which causes the disfunctioning of the add-to-group.
Developer at Edeveloper / CiviCoop

3524

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal
  • MySQL version: 5.1.72-cll
  • PHP version: 5.3.28
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 06:33:11 am
Ah ok, now i get it. thanks.

no, that's not the case. i have only the line "
{include file="CRM/Report/Form.tpl"}" in the template and no changes in the included template.

so i guess it is in the code. are there other reports, who are good as a basis to change? i need only contact information with some custom fields.


jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 06:40:10 am
Maybe you should rename the id column to 'civicrm_contact_id' this one seems to be used in the standard civicrm reports.
Developer at Edeveloper / CiviCoop

3524

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal
  • MySQL version: 5.1.72-cll
  • PHP version: 5.3.28
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 08:58:22 am
hm... changed it like this:
Code: [Select]
<?php
 
require_once 'CRM/Report/Form.php';
class 
CRM_Report_Form_Contact_whoiswho extends CRM_Report_Form {
 
    function 
preProcess( ) {
        
parent::preProcess( );
    }
 
    function 
__construct( ) {
parent::__construct( );
    }

 
    function 
postProcess( ) {
    
$this->beginPostProcess( );   
   
    
// the query parts
    
$mySelect =     "SELECT civicrm_contact.id as civicrm_contact_id, civicrm_contact.sort_name as civicrm_contact_sort_name ";
    
$myFrom =   "FROM civicrm_contact ";
    
$myWhere =      "WHERE civicrm_contact.id=1 ";  
    
$myOrderBy =    "";

 
 
 
    
//concatenate the query parts to get the full query
    
$myQuery = $mySelect . $myFrom . $myWhere . $myOrderBy;
        
    
$this->_columnHeaders =
            array( 
                   
                   
'civicrm_contact_sort_name' =>    array( 'title' => 'Name' ),
                   
'civicrm_contact_id' =>        array( 'title' => 'CiviCRM ID' ),
                 );
                 
 
    
// fetch the query results
    
$this->buildRows ( $myQuery, $rows );
    
$this->doTemplateAssignment( $rows );
    
$this->endPostProcess( $rows );
    }
}

changes in select and the _columnHeader array. but nothing changed so far. did i miss, what you ment?
i made the same with the second field (sort_name). it still works, but add to group still does not... :(

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: "Add these Contacts to Group" how to implement this?
June 02, 2014, 12:00:12 pm
I am not sure if I can help any futher. To me this looks like it should work. Can you check if the add-to-group works from within the contact summary report. If that does work you can look into the code for that report to see how it differs with yours.
Developer at Edeveloper / CiviCoop

3524

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal
  • MySQL version: 5.1.72-cll
  • PHP version: 5.3.28
Re: "Add these Contacts to Group" how to implement this?
June 03, 2014, 01:15:14 am
well i tried this allready, but not with the desired result... i think i will give "custom search" a chance for this problem, it might do the job too in our case.
anyway. many thanks to your help jaapjansma.
 i will post what solution i came up with, so maybe it's a help for someone else...

3524

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal
  • MySQL version: 5.1.72-cll
  • PHP version: 5.3.28
Re: "Add these Contacts to Group" how to implement this?
June 05, 2014, 08:13:19 am
ok, i ported now everything to a "custom search" which does everything we want.
So if someone reads this which is not sooooo familiar with civicrm: think well about what you want to do with the search results. if you need somthing from the "action"menue, you might better go with "custom search" than "custom report".

so cheers! thanks for your help jaapjansma!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Report and Search UI Discussion (Moderators: CiviTeacher.com, TwoMice) »
  • "Add these Contacts to Group" how to implement this?

This forum was archived on 2017-11-26.