2001-04-08 08:50:18 +02:00
|
|
|
<?php
|
2006-06-11 19:26:54 +02:00
|
|
|
/**
|
|
|
|
* Addressbook - birthday reminder on home-page
|
|
|
|
*
|
|
|
|
* @package addressbook
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-06-11 19:26:54 +02:00
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['addressbook'] &&
|
2009-06-15 15:48:09 +02:00
|
|
|
($days = $GLOBALS['egw_info']['user']['preferences']['addressbook']['mainscreen_showbirthdays']) &&
|
|
|
|
$GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
|
2006-06-11 19:26:54 +02:00
|
|
|
{
|
|
|
|
echo "\n<!-- Birthday info -->\n";
|
|
|
|
|
|
|
|
if (!(int) $days) $days = 1; // old pref
|
2001-04-08 08:50:18 +02:00
|
|
|
|
2009-06-08 18:21:14 +02:00
|
|
|
$contacts = new addressbook_bo();
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2007-05-01 11:51:03 +02:00
|
|
|
$month_start = date('*-m-*',$contacts->now_su);
|
2006-06-11 19:26:54 +02:00
|
|
|
$bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family');
|
2007-05-01 11:51:03 +02:00
|
|
|
|
|
|
|
if (($month_end = date('*-m-*',$contacts->now_su+$days*24*3600)) != $month_start)
|
2001-04-08 08:50:18 +02:00
|
|
|
{
|
2007-05-27 09:03:39 +02:00
|
|
|
if (($bdays2 =& $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'),'n_given,n_family')))
|
2006-06-11 19:26:54 +02:00
|
|
|
{
|
|
|
|
$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
|
|
|
|
}
|
|
|
|
unset($bdays2);
|
2001-04-08 08:50:18 +02:00
|
|
|
}
|
2006-06-11 19:26:54 +02:00
|
|
|
unset($month_start); unset($month_end);
|
2001-04-08 08:50:18 +02:00
|
|
|
|
2006-06-11 19:26:54 +02:00
|
|
|
if ($bdays)
|
2001-04-08 08:50:18 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$portalbox = CreateObject('phpgwapi.listbox',
|
|
|
|
Array(
|
2006-06-11 19:26:54 +02:00
|
|
|
'title' => lang('Birthdays'),
|
2005-07-03 16:15:23 +02:00
|
|
|
'primary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
|
|
|
|
'secondary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
|
|
|
|
'tertiary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
|
2003-08-28 16:16:30 +02:00
|
|
|
'width' => '100%',
|
|
|
|
'outerborderwidth' => '0',
|
2005-07-03 16:15:23 +02:00
|
|
|
'header_background_image' => $GLOBALS['egw']->common->image($GLOBALS['egw']->common->get_tpl_dir('phpgwapi'),'bg_filler')
|
2003-08-28 16:16:30 +02:00
|
|
|
)
|
|
|
|
);
|
2005-07-03 16:15:23 +02:00
|
|
|
$app_id = $GLOBALS['egw']->applications->name2id('addressbook');
|
2001-10-21 12:49:29 +02:00
|
|
|
$GLOBALS['portal_order'][] = $app_id;
|
2006-06-11 19:26:54 +02:00
|
|
|
foreach(Array(
|
2003-08-28 16:16:30 +02:00
|
|
|
'up' => Array('url' => '/set_box.php', 'app' => $app_id),
|
|
|
|
'down' => Array('url' => '/set_box.php', 'app' => $app_id),
|
|
|
|
'close' => Array('url' => '/set_box.php', 'app' => $app_id),
|
|
|
|
'question' => Array('url' => '/set_box.php', 'app' => $app_id),
|
|
|
|
'edit' => Array('url' => '/set_box.php', 'app' => $app_id)
|
2006-06-11 19:26:54 +02:00
|
|
|
) as $key => $contactue)
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
2006-06-11 19:26:54 +02:00
|
|
|
$portalbox->set_controls($key,$contactue);
|
2003-08-28 16:16:30 +02:00
|
|
|
}
|
|
|
|
$portalbox->data = Array();
|
2006-06-11 19:26:54 +02:00
|
|
|
for($n = 0; $n <= $days; ++$n)
|
2001-04-08 08:50:18 +02:00
|
|
|
{
|
2006-06-11 19:26:54 +02:00
|
|
|
$day = date('-m-d',$contacts->now_su+$n*24*3600);
|
|
|
|
foreach($bdays as $contact)
|
2003-02-15 21:52:18 +01:00
|
|
|
{
|
2006-06-11 19:26:54 +02:00
|
|
|
if(substr($contact['bday'],-6) == $day)
|
|
|
|
{
|
2007-05-01 11:51:03 +02:00
|
|
|
if (!$ab_lang_loaded++) $GLOBALS['egw']->translation->add_app('addressbook');
|
2006-06-11 19:26:54 +02:00
|
|
|
switch($n)
|
|
|
|
{
|
2008-05-10 14:02:49 +02:00
|
|
|
case 0:
|
2006-06-11 19:26:54 +02:00
|
|
|
$text = lang("Today is %1's birthday!", $contact['n_given'].' '.$contact['n_family']);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$text = lang("Tomorrow is %1's birthday.", $contact['n_given'].' '.$contact['n_family']);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
list($y,$m,$d) = explode('-',$contact['bday']);
|
2009-06-15 15:48:09 +02:00
|
|
|
if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = '';
|
2006-06-11 19:26:54 +02:00
|
|
|
$text = lang("In %1 days (%2) is %3's birthday.",$n,
|
|
|
|
$GLOBALS['egw']->common->dateformatorder($y,$m,$d,true),
|
|
|
|
$contact['n_given'].' '.$contact['n_family']);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$portalbox->data[] = array(
|
|
|
|
'text' => $text,
|
2008-05-10 14:02:49 +02:00
|
|
|
'link' => $GLOBALS['egw']->link('/index.php','menuaction=addressbook.addressbook_ui.view&contact_id=' . $contact['id'])
|
2006-06-11 19:26:54 +02:00
|
|
|
);
|
|
|
|
}
|
2003-02-15 21:52:18 +01:00
|
|
|
}
|
2003-08-28 16:16:30 +02:00
|
|
|
}
|
|
|
|
if(count($portalbox->data))
|
|
|
|
{
|
|
|
|
echo $portalbox->draw();
|
2001-04-08 08:50:18 +02:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
unset($portalbox);
|
2006-06-11 19:26:54 +02:00
|
|
|
unset($days); unset($day);
|
|
|
|
unset($n); unset($y); unset($m); unset($d);
|
2001-04-08 08:50:18 +02:00
|
|
|
}
|
2006-06-11 19:26:54 +02:00
|
|
|
unset($contacts); unset($bdays);
|
|
|
|
|
|
|
|
echo "\n<!-- Birthday info -->\n";
|
|
|
|
}
|