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 CiviMember (Moderator: Deepak Srivastava) »
  • Need help with UpdateMembership cron job
Pages: [1]

Author Topic: Need help with UpdateMembership cron job  (Read 1759 times)

Tolk

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
Need help with UpdateMembership cron job
August 06, 2010, 02:45:28 am
Hello all,

I am currently trying to get my membership database updated with the cron job. Unfortunately things are not quite working the way I expect them. I am trying to run the cron job via my server's control panel.
There are two issues:

1 - Commenting out the sending of a reminder. Here is where I start the commenting out - but where does it have to end?
Code: [Select]
/*            //send reminder for membership renewal
            if ( $dao->reminder_date &&
                 $dao->reminder_date != '0000-00-00' &&
                 ( $reminder_date <= $today_date ) ) {
                $memType = new CRM_Member_BAO_MembershipType( );
               
                $memType->id = $dao->membership_type_id;
                if ( $memType->find( true ) &&
                     $memType->renewal_msg_id ) {
                    $toEmail  = CRM_Contact_BAO_Contact::getPrimaryEmail( $dao->contact_id );
                   
                    if ( $toEmail ) {
                        // Set the FROM email address for reminder emails here.
                        // This must be a valid account for your SMTP service.
                        $from = "postmaster@bctbelgium.org";
                        $result = CRM_Core_BAO_MessageTemplates::sendReminder( $dao->contact_id,
                                                                               $toEmail,
                                                                               $memType->renewal_msg_id,
                                                                               $from );
                        if ( ! $result ||
                             is_a( $result, 'PEAR_Error' ) ) {
                            // we could not send an email, for now we ignore
                            // CRM-3406
                            // at some point we might decide to do something
                        }
                       
                        //set membership reminder date to NULL since we've sent the reminder.
                        CRM_Core_DAO::setFieldValue( 'CRM_Member_DAO_Membership', $dao->membership_id, 'reminder_date', 'null');
                       
                        // insert the activity log record.
                        $activityParams = array( );
                        $activityParams['subject']            = $allTypes[$dao->membership_type_id] .
                            ": Status - " . $statusLabels[$newStatus['id']] .
                            ", End Date - " . CRM_Utils_Date::customFormat(CRM_Utils_Date::isoToMysql($dao->end_date), $config->dateformatFull);
                        $activityParams['source_record_id']   = $dao->membership_id;
                        $activityParams['source_contact_id']  = $dao->contact_id;
                        $activityParams['activity_date_time'] = date('YmdHis');

                        static $actRelIds = array( );
                        if ( ! isset($actRelIds['activity_type_id']) ) {
                            $actRelIds['activity_type_id']    =
                                CRM_Core_OptionGroup::getValue( 'activity_type',
                                                                'Membership Renewal Reminder', 'name' );
                        }
                        $activityParams['activity_type_id']   = $actRelIds['activity_type_id'];
                       
                        if ( ! isset($actRelIds['activity_status_id']) ) {
                            $actRelIds['activity_status_id']  =
                                CRM_Core_OptionGroup::getValue( 'activity_status', 'Completed', 'name' );
                        }
                        $activityParams['status_id']          = $actRelIds['activity_status_id'];
                       
                        static $msgTpl = array();
                        if ( ! isset($msgTpl[$memType->renewal_msg_id]) ) {
                            $msgTpl[$memType->renewal_msg_id] = array( );
                           
                            $messageTemplate = new CRM_Core_DAO_MessageTemplates( );
                            $messageTemplate->id = $memType->renewal_msg_id;
                            if ( $messageTemplate->find(true) ) {
                                $msgTpl[$memType->renewal_msg_id]['subject'] = $messageTemplate->msg_subject;
                                $msgTpl[$memType->renewal_msg_id]['details'] = $messageTemplate->msg_text;
                            }
                            $messageTemplate->free( );
                        }
                        $activityParams['details'] = "Subject: {$msgTpl[$memType->renewal_msg_id]['subject']}
Message: {$msgTpl[$memType->renewal_msg_id]['details']}
";
                        $activity = CRM_Activity_BAO_Activity::create( $activityParams );
                    }
                }
                $memType->free( );
               
            }
            // CRM_Core_Error::debug( 'fEnd', count( $GLOBALS['_DB_DATAOBJECT']['RESULTS'] ) );
        }
    }
}
$obj = new CRM_UpdateMembershipRecord( );

echo "\n Updating ";
$obj->updateMembershipStatus( );
echo "\n\n Membership records updated. (Done) \n";


Wherever I ended it, I got "Parse error: syntax error, unexpected $end in /home/mydomain/www/www/administrator/components/com_civicrm/civicrm/bin/UpdateMembershipRecord.php on line 286" from my server.

2 - Username and password
If I want to run the cron job from my server and not via $ wget, where do I specify username, password and site key?

Do bear with me if these things seem obvious to you - this is my first attempt at using cron jobs.

Thanks for your help!
Tolk


Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Need help with UpdateMembership cron job
August 06, 2010, 11:20:08 am
1. If you want to just comment sending of reminder email, comment below code.
Quote
                        $result = CRM_Core_BAO_MessageTemplates::sendReminder( $dao->contact_id,
                                                                               $toEmail,
                                                                               $memType->renewal_msg_id,
                                                                               $from );


Quote
2 - Username and password
If I want to run the cron job from my server and not via $ wget, where do I specify username, password and site key?
Check http://wiki.civicrm.org/confluence/display/CRMDOC32/Command-line+Script+Configuration

Hth
Kurund
Found this reply helpful? Support CiviCRM

Tolk

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
Re: Need help with UpdateMembership cron job
August 06, 2010, 11:39:24 am
Thanks for your reply, Kurund,

Quote from: Kurund Jalmi on August 06, 2010, 11:20:08 am
1. If you want to just comment sending of reminder email, comment below code.
Quote
                       $result = CRM_Core_BAO_MessageTemplates::sendReminder( $dao->contact_id,
                                                                               $toEmail,
                                                                               $memType->renewal_msg_id,
                                                                               $from );

Then I got: Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/mydomain/www/www/administrator/components/com_civicrm/civicrm/bin/UpdateMembershipRecord.php on line 275 ($memType->free( );)

So I moved it down some more until I got a new error: ERROR: You need to send a valid user name and password to execute this file.

Which takes me right to question 2...

Quote
2 - Username and password
Check http://wiki.civicrm.org/confluence/display/CRMDOC32/Command-line+Script+Configuration

Yes, that is where I found that I need the password and how to setup the site key. I just did not understand how to setup my own servers cron jobs in the control panel because there I can only select the file name and not add anything before or after. But maybe that is more a question for my provider?

Thanks,
Tolk
« Last Edit: August 06, 2010, 11:46:48 am by Tolk »

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Need help with UpdateMembership cron job
August 08, 2010, 12:27:03 pm
Tolk,

If you comment properly you should not get any parse error. Also your control panel should allow you to set cron job etc. I would recommend you to hire someone from http://civicrm.org/professional list to help you on these issues.

Kurund
Found this reply helpful? Support CiviCRM

Tolk

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
Re: Need help with UpdateMembership cron job
August 10, 2010, 01:04:37 am
Quote from: Kurund Jalmi on August 08, 2010, 12:27:03 pm
Tolk,

If you comment properly you should not get any parse error. Also your control panel should allow you to set cron job etc. I would recommend you to hire someone from http://civicrm.org/professional list to help you on these issues.

Kurund

Thanks, Kurund, I already found someone there but he would have charged $ 5000 for the most important bits I need done and as a non-profit we can't do that. So he himself recommended I get as much done as I can myself (without any IT background) with the help of the forums. So here I am. And grateful for any help I can get. The rest will have to be done by a pro, though, you are right!

Tolk

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Need help with UpdateMembership cron job
August 10, 2010, 04:07:57 am
Tolk,

IMO setting up cron job and disabling email receipt during membership renewal script, should be around 10 -15 hours. ( around $1000  or less )

Kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Need help with UpdateMembership cron job

This forum was archived on 2017-11-26.