diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php
index 04bc9bbc8fd..679bb9e181f 100644
--- a/htdocs/actioncomm.class.php
+++ b/htdocs/actioncomm.class.php
@@ -513,23 +513,25 @@ class ActionComm
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
- * \param maxlength Nombre de caract�res max dans libell�
+ * \param maxlength Nombre de caracteres max dans libelle
* \param class Force style class on a link
+ * \param option ''=Link to action,'birthday'=Link to contact
* \return string Chaine avec URL
* \remarks Utilise $this->id, $this->code et $this->libelle
*/
- function getNomUrl($withpicto=0,$maxlength,$class='')
+ function getNomUrl($withpicto=0,$maxlength,$class='',$option='')
{
global $langs;
$result='';
- $lien = 'id.'">';
+ if ($option=='birthday') $lien = 'id.'">';
+ else $lien = 'id.'">';
$lienfin='';
- if ($langs->trans("Action".$this->code) != "Action".$this->code || ! $this->libelle)
+ if ($langs->trans("Action".$this->type_code) != "Action".$this->type_code || ! $this->libelle)
{
- $libelle=$langs->trans("Action".$this->code);
- $libelleshort=$langs->trans("Action".$this->code,'','','','',$maxlength);
+ $libelle=$langs->trans("Action".$this->type_code);
+ $libelleshort=$langs->trans("Action".$this->type_code,'','','','',$maxlength);
}
else
{
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 30043f2485e..1ea40e93dae 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -580,7 +580,8 @@ if ($_GET["id"])
$act = new ActionComm($db);
$result=$act->fetch($_GET["id"]);
-
+ if ($result < 0) dolibarr_print_error($db,$act->error);
+
$societe = new Societe($db);
if ($act->societe->id)
{
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index ed1498ba72c..612a1027043 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -34,6 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
$filtera = isset($_REQUEST["userasked"])?$_REQUEST["userasked"]:(isset($_REQUEST["filtera"])?$_REQUEST["filtera"]:'');
$filtert = isset($_REQUEST["usertodo"])?$_REQUEST["usertodo"]:(isset($_REQUEST["filtert"])?$_REQUEST["filtert"]:'');
$filterd = isset($_REQUEST["userdone"])?$_REQUEST["userdone"]:(isset($_REQUEST["filterd"])?$_REQUEST["filterd"]:'');
+$showbirthday = isset($_REQUEST["showbirthday"])?$_REQUEST["showbirthday"]:0;
$page = $_GET["page"];
$sortfield=$_GET["sortfield"];
@@ -64,6 +65,8 @@ if (! $user->rights->agenda->allactions->read || $_GET["filter"]=='mine')
$year=isset($_REQUEST["year"])?$_REQUEST["year"]:date("Y");
$month=isset($_REQUEST["month"])?$_REQUEST["month"]:date("m");
+$langs->load("other");
+
/*
* Actions
@@ -136,6 +139,7 @@ if ($filtert) $param.="&filtert=".$filtert;
if ($filterd) $param.="&filterd=".$filterd;
if ($time) $param.="&time=".$_REQUEST["time"];
if ($socid) $param.="&socid=".$_REQUEST["socid"];
+if ($showbirthday) $param.="&showbirthday=1";
if ($_GET["type"]) $param.="&type=".$_REQUEST["type"];
// Show navigation bar
@@ -145,6 +149,9 @@ $nav.=" ".$year;
$nav.=" \n";
$nav.="".img_next($langs->trans("Next"))."\n";
+// Must be after the nav definition
+$param.='&year='.$year.'&month='.$month;
+
print_fiche_titre($title,$nav,"");
// Filters
@@ -155,6 +162,7 @@ if ($canedit)
print '';
print '';
print '';
+ print '';
print '
';
print '';
print '';
@@ -167,7 +175,7 @@ if ($canedit)
print img_picto($langs->trans("ViewList"),'object_list').' ';
print ' ';
print ' ';
- print img_picto($langs->trans("ViewCal"),'object_calendar').' ';
+ print img_picto($langs->trans("ViewCal"),'object_calendar').' ';
print ' | ';
print '
';
@@ -193,15 +201,18 @@ if ($canedit)
// Get event in an array
+$actionarray=array();
+
$sql = 'SELECT a.id,a.label,';
$sql.= ' '.$db->pdate('a.datep').' as datep,';
$sql.= ' '.$db->pdate('a.datep2').' as datep2,';
$sql.= ' '.$db->pdate('a.datea').' as datea,';
$sql.= ' '.$db->pdate('a.datea2').' as datea2,';
$sql.= ' a.percent,';
-$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done';
-$sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
-$sql.= ' WHERE 1=1';
+$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
+$sql.= ' ca.code';
+$sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'c_actioncomm as ca';
+$sql.= ' WHERE a.fk_action = ca.id';
if ($_GET["action"] == 'show_day')
{
$sql.= ' AND datep BETWEEN '.$db->idate(dolibarr_mktime(0,0,0,$month,$_GET["day"],$year));
@@ -217,15 +228,15 @@ if ($filtera > 0 || $filtert > 0 || $filterd > 0)
}
if ($status == 'done') { $sql.= " AND a.percent = 100"; }
if ($status == 'todo') { $sql.= " AND a.percent < 100"; }
+// \TODO Limit select on dates
$sql .= ' ORDER BY datep';
-// \TODO Add filters on dates
//print $sql;
-$actionarray=array();
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
+ $i=0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
@@ -233,8 +244,7 @@ if ($resql)
$action->id=$obj->id;
$action->datep=$obj->datep;
$action->datef=$obj->datep2;
- //$action->date=$obj->datea;
- //$action->dateend=$obj->datea2;
+ $action->type_code=$obj->code;
$action->libelle=$obj->label;
$action->percentage=$obj->percent;
$action->author->id=$obj->fk_user_author;
@@ -285,6 +295,66 @@ else
dolibarr_print_error($db);
}
+if ($showbirthday)
+{
+ // Add events in array
+ $sql = 'SELECT sp.rowid, sp.name, sp.firstname,';
+ $sql.= ' '.$db->pdate('sp.birthday').' as birthday';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
+ $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))';
+ if ($_GET["action"] == 'show_day')
+ {
+ $sql.= ' AND birthday BETWEEN '.$db->idate(dolibarr_mktime(0,0,0,$month,$_GET["day"],$year));
+ $sql.= ' AND '.$db->idate(dolibarr_mktime(23,59,59,$month,$_GET["day"],$year));
+ }
+ // \TODO Limit select on dates
+ $sql .= ' ORDER BY birthday';
+ //print $sql;
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i=0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $action=new ActionComm($db);
+ $action->id=$obj->rowid; // We put contact id in action id for birthdays events
+ $action->datep=$obj->birthday;
+ $action->datef=$obj->birthday;
+ $action->type_code='BIRTHDAY';
+ $action->libelle=$langs->trans("Birthday").' '.$obj->firstname.' '.$obj->name;
+ $action->percentage=100;
+
+ $action->date_start_in_calendar=$action->datep;
+ $action->date_end_in_calendar=$action->datef;
+ $action->ponctuel=0;
+
+ // Add an entry in actionarray for each day
+ $daycursor=$action->date_start_in_calendar;
+ $annee = date('Y',$daycursor);
+ $mois = date('m',$daycursor);
+ $jour = date('d',$daycursor);
+
+ $loop=true;
+ $daykey=dolibarr_mktime(0,0,0,$mois,$jour,$annee);
+ do
+ {
+ $actionarray[$daykey][]=$action;
+ $daykey+=60*60*24;
+ if ($daykey > $action->date_end_in_calendar) $loop=false;
+ }
+ while ($loop);
+ $i++;
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+}
+
// Define theme_datacolor array
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
if (is_readable($color_file))
@@ -293,6 +363,16 @@ if (is_readable($color_file))
}
if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220));
+$link='';
+if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
+else $link.=$langs->trans("AgendaHideBirthdayEvents");
+$link.='';
+print_fiche_titre('',$link);
+
if ($_GET["action"] != 'show_day')
{
echo '';
@@ -426,43 +506,51 @@ function show_day_events($db, $day, $month, $year, $style, $actionarray, $maxPri
// Show rect of event
$colorindex=0;
if ($action->author->id == $user->id || $action->usertodo->id == $user->id || $action->userdone->id == $user->id) $colorindex=1;
+ if ($action->type_code == 'BIRTHDAY') $colorindex=2;
$color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]);
//print "x".$color;
print '';
print '';
- $tmpyearstart = date('Y',$action->date_start_in_calendar);
- $tmpmonthstart = date('m',$action->date_start_in_calendar);
- $tmpdaystart = date('d',$action->date_start_in_calendar);
- $tmpyearend = date('Y',$action->date_end_in_calendar);
- $tmpmonthend = date('m',$action->date_end_in_calendar);
- $tmpdayend = date('d',$action->date_end_in_calendar);
- // Hour start
- if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour)
+ if ($action->type_code != 'BIRTHDAY')
{
- print dolibarr_print_date($action->date_start_in_calendar,'%H:%M');
+ $tmpyearstart = date('Y',$action->date_start_in_calendar);
+ $tmpmonthstart = date('m',$action->date_start_in_calendar);
+ $tmpdaystart = date('d',$action->date_start_in_calendar);
+ $tmpyearend = date('Y',$action->date_end_in_calendar);
+ $tmpmonthend = date('m',$action->date_end_in_calendar);
+ $tmpdayend = date('d',$action->date_end_in_calendar);
+ // Hour start
+ if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour)
+ {
+ print dolibarr_print_date($action->date_start_in_calendar,'%H:%M');
+ if ($action->date_end_in_calendar && $action->date_start_in_calendar != $action->date_end_in_calendar)
+ {
+ if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend)
+ print '-';
+ //else
+ //print '...';
+ }
+ }
if ($action->date_end_in_calendar && $action->date_start_in_calendar != $action->date_end_in_calendar)
{
- if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend)
- print '-';
- //else
- //print '...';
+ if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend)
+ {
+ print '...';
+ }
}
- }
- if ($action->date_end_in_calendar && $action->date_start_in_calendar != $action->date_end_in_calendar)
- {
- if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend)
+ // Hour end
+ if ($action->date_end_in_calendar && $action->date_start_in_calendar != $action->date_end_in_calendar)
{
- print '...';
+ if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour)
+ print dolibarr_print_date($action->date_end_in_calendar,'%H:%M');
}
+ print ' ';
+ print $action->getNomUrl(0,14,'cal_event');
}
- // Hour end
- if ($action->date_end_in_calendar && $action->date_start_in_calendar != $action->date_end_in_calendar)
+ else // It's a birthday
{
- if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour)
- print dolibarr_print_date($action->date_end_in_calendar,'%H:%M');
+ print $action->getNomUrl(0,14,'cal_event','birthday');
}
- print ' ';
- print $action->getNomUrl(0,14,'cal_event');
print ' | ';
print ''.$action->getLibStatut(3);
print ' |
';
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index 26c35a72944..b9bc079b8ea 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -126,8 +126,8 @@ if ($_GET["action"] == 'edit')
print $contact->getCivilityLabel();
print '';
- // Birthday
- print '| '.$langs->trans("BirthdayDate").' | ';
+ // Date To Birth
+ print ' |
| '.$langs->trans("DateToBirth").' | ';
$html=new Form($db);
if ($contact->birthday)
{
@@ -135,7 +135,7 @@ if ($_GET["action"] == 'edit')
}
else
{
- print $html->select_date(0,'birthday',0,0,1,"perso");
+ print $html->select_date('','birthday',0,0,1,"perso");
}
print ' | ';
@@ -192,19 +192,18 @@ else
print $contact->getCivilityLabel();
print '
';
- // Birthday
+ // Date To Birth
if ($contact->birthday)
{
- print '| '.$langs->trans("BirthdayDate").' | '.dolibarr_print_date($contact->birthday,"day");
-
- if ($contact->birthday_alert)
- print ' (alerte anniversaire active) | ';
- else
- print ' (alerte anniversaire inactive)';
+ print '
| '.$langs->trans("DateToBirth").' | '.dolibarr_print_date($contact->birthday,"day");
+ print ' (';
+ if ($contact->birthday_alert) print 'alerte anniversaire active';
+ else print 'alerte anniversaire inactive';
+ print ') | ';
}
else
{
- print '
| '.$langs->trans("Birthday").' | '.$langs->trans("Unknown")." | ";
+ print '
| '.$langs->trans("DateToBirth").' | '.$langs->trans("Unknown")." | ";
}
print "
";
diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang
index 942d7d1a7ef..228aa93e2c8 100644
--- a/htdocs/langs/en_US/agenda.lang
+++ b/htdocs/langs/en_US/agenda.lang
@@ -42,3 +42,5 @@ AgendaUrlOptions2=login=%s to restrict output to actions created by, affe
AgendaUrlOptions3=logina=%s to restrict output to actions created by user %s.
AgendaUrlOptions4=logint=%s to restrict output to actions affected to user %s.
AgendaUrlOptions5=logind=%s to restrict output to actions done by user %s.
+AgendaShowBirthdayEvents=Show birthday's contacts
+AgendaHideBirthdayEvents=Hide birthday's contacts
\ No newline at end of file
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 4c0563cc86a..eee094f459b 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -62,7 +62,6 @@ Fax=Fax
Zip=Zip Code
Town=Town
Web=Web
-Birthday=Birthday
VATIsUsed=VAT is used
VATIsNotUsed=VAT is not used
ThirdPartyEMail=%s
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index feebe6554f7..b5965660e65 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -22,6 +22,7 @@ AddTrip=Add trip
Tools=Tools
Birthday=Birthday
BirthdayDate=Birthday
+DateToBirth=Date to birth
Notify_NOTIFY_VAL_FICHINTER=Validate intervention
Notify_NOTIFY_VAL_FAC=Validate bill
NbOfAttachedFiles=Number of attached files/documents
diff --git a/htdocs/langs/es_ES/companies.lang b/htdocs/langs/es_ES/companies.lang
index 9f6eaee3d08..7f8cfa739cb 100644
--- a/htdocs/langs/es_ES/companies.lang
+++ b/htdocs/langs/es_ES/companies.lang
@@ -60,7 +60,6 @@ Fax=Fax
Zip=Código postal
Town=Población
Web=Web
-Birthday=Fecha de nacimiento
VATIsUsed=Sujeto a IVA
VATIsNotUsed=No sujeto a IVA
ThirdPartyEMail=%s
diff --git a/htdocs/langs/es_ES/other.lang b/htdocs/langs/es_ES/other.lang
index d78cff64683..b1eb6339071 100644
--- a/htdocs/langs/es_ES/other.lang
+++ b/htdocs/langs/es_ES/other.lang
@@ -23,6 +23,7 @@ AddTrip=Crear desplazamiento
Tools=Utilidades
Birthday=Aniversario
BirthdayDate=Fecha aniversario
+DateToBirth=Fecha de nacimiento
Notify_NOTIFY_VAL_FICHINTER=Validación ficha intervención
Notify_NOTIFY_VAL_FAC=Validación factura
NbOfAttachedFiles=Número archivos/documentos adjuntos
diff --git a/htdocs/langs/fr_BE/companies.lang b/htdocs/langs/fr_BE/companies.lang
index 53de95edc3b..feaa8b818d1 100644
--- a/htdocs/langs/fr_BE/companies.lang
+++ b/htdocs/langs/fr_BE/companies.lang
@@ -46,7 +46,6 @@ Fax=Fax
Zip=Code postal
Town=Ville
Web=Web
-Birthday=Anniversaire
VATIsUsed=Utilise la TVA
##### Professionnal ID #####
ProfId1Short=Id prof. 1
diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang
index d7b6143490e..460f4e10f93 100644
--- a/htdocs/langs/fr_FR/agenda.lang
+++ b/htdocs/langs/fr_FR/agenda.lang
@@ -42,3 +42,5 @@ AgendaUrlOptions2=login=%s pour limiter l'export aux actions cr
AgendaUrlOptions3=logina=%s pour limiter l'export aux actions crées par l'utilisateur %s.
AgendaUrlOptions4=logint=%s pour limiter l'export aux actions affectées à l'utilisateur %s.
AgendaUrlOptions5=logind=%s pour limiter l'export aux actions réalisées par l'utilisateur %s.
+AgendaShowBirthdayEvents=Afficher anniversaires contacts
+AgendaHideBirthdayEvents=Cacher anniversaires contacts
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang
index c9b34eb6102..846f9d60807 100644
--- a/htdocs/langs/fr_FR/companies.lang
+++ b/htdocs/langs/fr_FR/companies.lang
@@ -62,7 +62,6 @@ Fax=Fax
Zip=Code postal
Town=Ville
Web=Web
-Birthday=Date de naissance
VATIsUsed=Assujetti à TVA
VATIsNotUsed=Non assujetti à TVA
ThirdPartyEMail=%s
diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang
index a889b3beaef..e0d570c2ef5 100644
--- a/htdocs/langs/fr_FR/other.lang
+++ b/htdocs/langs/fr_FR/other.lang
@@ -22,6 +22,7 @@ AddTrip=Cr
Tools=Outils
Birthday=Anniversaire
BirthdayDate=Date anniversaire
+DateToBirth=Date de naissance
Notify_NOTIFY_VAL_FICHINTER=Validation fiche intervention
Notify_NOTIFY_VAL_FAC=Validation facture
NbOfAttachedFiles=Nombre de fichiers/documents liés
diff --git a/htdocs/langs/nl_BE/companies.lang b/htdocs/langs/nl_BE/companies.lang
index c20ea411315..c12c5b309e0 100644
--- a/htdocs/langs/nl_BE/companies.lang
+++ b/htdocs/langs/nl_BE/companies.lang
@@ -49,7 +49,6 @@ Fax=Fax
Zip=Postcode
Town=Stad
Web=Website
-Birthday=Verjaardag
VATIsUsed=Gebruik BTW
ThirdPartyEMail=%s
##### Professionnal ID #####