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 create a cron job to get pdf letters of contacts with upcoming birthdays
Pages: [1] 2

Author Topic: how to create a cron job to get pdf letters of contacts with upcoming birthdays  (Read 1832 times)

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 08, 2012, 01:04:30 pm
Hello,

I am quite new with civicrm. I use it with Drupal 7

Could someone please put me on track to perform the following.
I would like to  create a cron job (that would be run monthly) that performs the following actions that I can already execute manually on my installation

-perform an existing custom search of upcoming birthdays (i have already installed this custom search (php) )
-select all contact results and the action create pdf letter to send to all contacts
-reuse a template for the letter
-send the resulting pdf by email to 1 adress

thanks!


Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 09, 2012, 12:29:01 pm
Perhaps someone else knows some tricks that I don't, but I think this would need to be custom coded as a CiviCRM Extension or as a Drupal Module. You can use the API for parts of the job, but not all.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 09, 2012, 02:46:46 pm
is the custom search for upcoming birthdays something you cooked up? if so can you share it back with the community?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 10, 2012, 07:25:38 am
ypu may find these custom searches here...

http://wiki.civicrm.org/confluence/display/CRMDOC40/Upcoming+Birthday+and+Anniversary+searches

Still looking for more guidance on how to automate this process

thanks

matthewboh

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 2
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 10, 2012, 09:39:11 am
Following - looking for same automation

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 11, 2012, 03:46:32 am
Hi,

Most of the building blocks are there, but you will need to stitches them together yourself/fund the dev

I'm looking at developing an API to generate the pdf for one contact/template, will contribute back when done

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 24, 2012, 07:06:39 am
hello,

ok first step would be to get the list of contact filtered with the birthdates of coming month.

I started to search in the API (civicrm/ajax/doc#)

I see the rest comand to get contacts:
/fr/civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=Contact&action=get
or the php one:
$results=civicrm_api("Contact","get", array (version=3','sequential' =>'1'));
Both work fine.

Now I wonder how could I customize it for my custom birthday search ?
Should I try to access the url with the custom search id (csid) and post the variable (month and day start/end ) ?
Is there a way to customize the php call to API ? I would prefer this one...

thanks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 24, 2012, 07:26:12 am
btw, if you want to discover the api, civicrm/api/explorer makes it easy to change the param and see the result.

The easiest is probably to add a custom api civicrm_api('contact','getbirthday') and put the query into there

(if you create a function civicrm_api3_contact_getbirthday into api/Contact/Getbirthday.php you get it working)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 24, 2012, 10:38:31 am
I am trying to make this new API action/entity.

Any advice where I could find some info about  DB queries in civicrm ? or how to display he actual SQL query for debugging ?

Thanks

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 24, 2012, 12:54:35 pm
A simple test to filter on birthdays in November doens't work .
Can you tell me why?

in API Contact.php , I am adding a parameter for the where clause of query

$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
$newParams[]=array('0'=>'month(birth_date)','1'=>'=','2'=>"11",'3'=>0,'4'=>0 );
 

Thanks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 24, 2012, 03:29:06 pm
you can log the sql queries generated using the devel module on drupal, not quite sure how on D7 (never tried), probably the same.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
June 24, 2012, 06:19:29 pm

there is no devel module integration with D7 :( (u need to use DBTNG etc to use devel and we cannot work around it)

check:

http://book.civicrm.org/developer/development-environment/debugging

on how to log queries. Your other option is to enable mysql query logging on your localhost and check that log

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
July 12, 2012, 04:48:29 am
I managed to create an object with the contacts that have their birthday in the given timeframe.

Now I am looking what method (from which class) to call in order to generate the pdf letter to these contact ID's .

Could someone point me to it ?

thanks

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
July 12, 2012, 08:17:28 am

check:

CRM/Utils/PDF/Utils.php

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bendev

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: drupal 7
  • MySQL version: 5.1
  • PHP version: 5.3
Re: how to create a cron job to get pdf letters of contacts with upcoming birthdays
July 12, 2012, 09:13:31 am
I have the impression this is rather in
/CRM/Contact/Form/Task/PDFLetterCommon.php
but I don't see what method to call with my contactIDs as parameter

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • how to create a cron job to get pdf letters of contacts with upcoming birthdays

This forum was archived on 2017-11-26.