Last active
December 18, 2015 03:38
-
-
Save betobaz/5719477 to your computer and use it in GitHub Desktop.
Job para actualizar el campo birthday_today_c para indicar que el contacto cumple años el día. Se requiere crear un campo personalizado de tipo casilla de verificación que se llame birthday_today_c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
array_push($job_strings, 'contacts_birthday_job'); | |
function contacts_birthday_job(){ | |
clearContactsBirthday(); | |
$GLOBALS['log']->debug('JOB::contacts_birthday_job:start'); | |
setBirthday(); | |
return true; | |
} | |
function clearContactsBirthday(){ | |
global $db; | |
$GLOBALS['log']->debug('JOB::contacts_birthday_job::clearContactsBirthday'); | |
$query = "update contacts_cstm | |
set birthday_today_c = 0 | |
where birthday_today_c = 1"; | |
require_once("modules/Contacts/Contact.php"); | |
$res = $db->query($query); | |
while($row = $db->fetchByAssoc($res)){ | |
$focus = new Contact(); | |
$focus->retrieve($row['id']); | |
$focus->birthday_today_c = 0; | |
$focus->save(); | |
} | |
} | |
function setBirthday(){ | |
global $db; | |
$mesDia = TimeDate::getInstance()->getNow(true)->format('m-d'); | |
$query = "select id from contacts where DATE_FORMAT(birthdate, '%m-%d') = '$mesDia' and deleted = 0"; | |
require_once("modules/Contacts/Contact.php"); | |
$res = $db->query($query); | |
while($row = $db->fetchByAssoc($res)){ | |
$focus = new Contact(); | |
$focus->retrieve($row['id']); | |
$GLOBALS['log']->debug('JOB::contacts_birthday_job:: El contacto ' . $focus->first_name. ' Cumple anios'); | |
$GLOBALS['log']->debug('JOB::contacts_birthday_job:: El contacto ' . $focus->id ); | |
$focus->birthday_today_c = 1; | |
$focus->save(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mod_string['LBL_CONTACTS_BIRTHDAY_JOB'] = 'Contacts Birthday Job'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment