CiviCRM Forums
News: You can learn more about CiviCRM from our new free book: Understanding CiviCRM. Also Check the CiviCRM Blog for updated information on CiviCRM
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 02, 2010, 08:53:17 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Implementing Phone Campaigns  (Read 318 times)
Manonline
I’m new here
*

Karma: 0
Offline Offline

CiviCRM: 3.0.3
CMS: Drupal 6.15
MySQL: 5.1.32
PHP: 5.2.9

Posts: 16



View Profile WWW
« on: March 11, 2010, 10:10:23 am »

Hello everybody, first I'm sorry for my English.

I need to do something similar like the CiviMail campaigns, but with phone calls. I'm new in CiviCRM, but I have some time in Drupal. I'm not PHP Coder, but I do something.

I didn't find anywhere a function provided by CiviCRM to create phone campaigns, so I wrote a Drupal module to use de CiviCRM API, but I have a few problems creating activities.

The module creates two Activity Types: "Phone Campaign" and "Campaign Phone Call". Theoricly, when a "Phone Campaign" activity is created, the module creates much "Campaign Phone Call" as target in "Phone Campaign" are.

I can create activity types with the API, but I couldn't create activities, or I'm not implementing the hooks in the right way.

Here is the code where the hook_civicrm_post is implemented:

Code:
<?php

function civicrm_phonecampaign_civicrm_post($op$objectName$objectId, &$objectRef) {
  
Logger::debug_var("op        "$op);
  
Logger::debug_var("objectName"$objectName);
  
Logger::debug_var("objectId  "$objectId);
  
Logger::debug_var("objectRef "$objectRef);
  if (
$op == 'create' && $objectName == 'Activity') {
    
$atid db_result(db_query('SELECT activity_type_id FROM civicrm_activity WHERE id=%d'$objectId));
    
$activity db_result(db_query('SELECT label FROM civicrm_option_value WHERE value=%d'$atid));
    if (
$activity == 'Phone Campaign') {
      
$result db_query('SELECT target_contact_id FROM civicrm_activity_target WHERE activity_id = %d'$objectId);

      while (
$row  =  db_fetch_array($result))  {
        
$idsarr[] = $row['target_contact_id'];
      }

      
$iatid db_result(db_query("SELECT value FROM civicrm_option_value WHERE label='Campaign Phone Call'"));
      
$source_contact_id db_result(db_query('SELECT source_contact_id FROM civicrm_activity WHERE id = %d'$objectId));
      
$assignee_contact_id db_result(db_query('SELECT assignee_contact_id FROM civicrm_activity WHERE id = %d'$objectId));
      
$subject db_result(db_query('SELECT subject FROM civicrm_activity WHERE id = %d'$objectId));
      
$details db_result(db_query('SELECT details FROM civicrm_activity WHERE id = %d'$objectId));
      
$activity_date_time db_result(db_query('SELECT activity_date_time FROM civicrm_activity WHERE id = %d'$objectId));
      
$status_id db_result(db_query('SELECT status_id FROM civicrm_activity WHERE id = %d'$objectId));

      foreach (
$idsarr as $tcid) {
        
$params = array(
          
'activity_type_id' => $iatid,
          
'source_contact_id' => $source_contact_id,
          
'assignee_contact_id' => $assignee_contact_id,
          
'target_contact_id' => $tcid,
          
'subject' => $subject,
          
'details' => $details,
          
'status_id' => $status_id,
          
'activity_date_time' => $activity_date_time
        
);
        
$act civicrm_activity_create($params);
      }
    }
  }
}

if anyone can give me a clue, I will be wondered Smiley

thanks in advance,
mano.
« Last Edit: March 11, 2010, 10:44:46 am by Manonline » Logged
peterd
Forum Godess / God
I’m (like) Lobo ;)
*****

Karma: 71
Offline Offline

CiviCRM: 2.2 >> 3.2
CMS: Drupal 6
Posts: 1910



View Profile WWW
« Reply #1 on: March 11, 2010, 10:59:49 am »

hey - you need to do a search on forum/blog for civiengage and for willsbrownburger - there are two projects for doing phone canvassing that are being worked on and integrated in to civicrm - check here http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+for+Canvassing+and+GOTV

would be great if your code, time or money could help this happen
Logged

pete davis : www.fuzion.co.nz : connect + campaign + communicate
Manonline
I’m new here
*

Karma: 0
Offline Offline

CiviCRM: 3.0.3
CMS: Drupal 6.15
MySQL: 5.1.32
PHP: 5.2.9

Posts: 16



View Profile WWW
« Reply #2 on: March 12, 2010, 07:30:52 am »

Yes, but the code doesn't work, and I need help to find out what I'm doing wrong to improve it. If anyone can help me implementing those hooks I'll be wondered.
Logged
xavier
Forum Godess / God
I live on this forum
*****

Karma: 58
Offline Offline

Posts: 1272


View Profile WWW
« Reply #3 on: March 12, 2010, 11:18:28 pm »

Not sure I understand what you want to do:
on the post hook after a user has created an activity, you want to create another activity ?

Otherwise, avoid doing the sql directly, try rather to use the apis, or the BAO/DAO Objects if the apis don't exist.

X+
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM