<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged birthday</title>
<link>https://overflow.efficy.io/?qa=tag/birthday</link>
<description>Powered by Question2Answer</description>
<item>
<title>Who want the birthday widget back? there it is</title>
<link>https://overflow.efficy.io/?qa=2223/who-want-the-birthday-widget-back-there-it-is</link>
<description>&lt;p&gt;Dear partners and Efficy workers, &lt;/p&gt;

&lt;p&gt;as far as I work with Efficy, The birthday widget is here to help me to remember the birthday of my pretty awesome coworkers. &lt;/p&gt;

&lt;p&gt;since Pascal is out of the serverscripts language I ve remake the widget with real improvement.&lt;br&gt;
Have it as a tribute to the community that loved it. &lt;/p&gt;

&lt;p&gt;in macroWidgetsCustom this will add the entry in the available widget list only for the users of the SPECIAL group : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;WidgetTemplate5@SPECIAL {[&amp;lt;%Macro(&quot;$MACRO$&quot;, $KEY$=5, $KIND$=&quot;Macro&quot;, $TITLE$=&quot;Today's Birthdays&quot;,
    $ICON$=&quot;../efficy/img/user16.gif&quot;, $COLLAPSED$=&quot;$COLLAPSE$&quot;, $SENTITY$=&quot;User&quot;,
    $CONFIG$=|{url:&quot;dialog?entity=Acti&amp;amp;_MACRO=BirthdayEfficy&amp;amp;_MACROFILE=MacroWidgets.txt&quot;}|)%&amp;gt;]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the same file : This will drag the magic back on line : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;BirthdayEfficy [
    &amp;lt;%LoadScript(&quot;serverscripts/NL_server_birthday.js&quot;)%&amp;gt;
    &amp;lt;%RunScript(&quot;getBirthdays&quot;)%&amp;gt;
]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;then add a NL&lt;em&gt;server&lt;/em&gt;birthday.js file in your custom/serverscripts with this content : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getBirthdays(){
    var result = '&amp;lt;table style=&quot;width: 100%; margin-bottom: 0px;&quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th colspan=2&amp;gt;A venir&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;';

    var picBirthday = '&amp;lt;img src=&quot;&amp;lt;%GetCustomBase()%&amp;gt;img/birthday2.gif&quot; style=&quot;width: 100%;&quot;/&amp;gt;';
    var isBirthday = false;

    var 
        qh = 0,
        context = Database.OpenTemporaryContext(),
        sql = &quot;&quot;;

    sql += &quot;select TOP 3 &quot;;
    sql += &quot;    U.FULLNAME  &quot;;
    sql += &quot;    ,left(convert(nvarchar(10), C.BIRTHDAY, 103), 5) as birthday  &quot;;
    sql += &quot;    ,case when cast(getdate() as date) &amp;gt; cast(year(getdate()) as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4) &quot;;
    sql += &quot;        then cast(year(getdate()) +1 as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4) &quot;;
    sql += &quot;        else cast(year(getdate()) as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4) &quot;;
    sql += &quot;    end as nextBirthday &quot;;
    sql += &quot;    ,case when getdate() &amp;gt; cast(year(getdate()) as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4) &quot;;
    sql += &quot;        then datediff(day, GETDATE(), cast(year(getdate()) +1 as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4)) &quot;;
    sql += &quot;        else datediff(day, GETDATE(), cast(year(getdate()) as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4)) &quot;;
    sql += &quot;    end as daysToBirthday &quot;;

    sql += &quot;from  &quot;;
    sql += &quot;    ADMIN.ACC_ACCOUNTS U &quot;;
    sql += &quot;    inner join ADMIN.CONTACTS C on C.K_CONTACT = U.K_CONTACT &quot;;
    sql += &quot;where C.BIRTHDAY is not null &quot;;
    sql += &quot;order by  &quot;;
    sql += &quot;    case when cast(getdate() as date) &amp;gt; cast(year(getdate()) as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4) &quot;;
    sql += &quot;        then datediff(day, GETDATE(), cast(year(getdate()) +1 as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4)) &quot;;
    sql += &quot;        else datediff(day, GETDATE(), cast(year(getdate()) as nvarchar(4)) + right(convert(nvarchar(8),C.BIRTHDAY,112), 4)) &quot;;
    sql += &quot;    end asc&quot;;

    var ds = Database.ExecuteSystemSQLQuery(qh, context, sql, &quot;&quot;, true, true, 1);
    ds.First;

    var today = new NL_date();
    today = today.toString(&quot;dd/MM&quot;);

    while (!ds.EoF) {
        if (today == ds.FieldByName(&quot;birthday&quot;).AsString) {
            result = '&amp;lt;table style=&quot;width: 100%; margin-bottom: 0px;&quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th colspan=2&amp;gt;C\'est le grand jour&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;';
            result += '&amp;lt;tr&amp;gt;&amp;lt;td colspan=2&amp;gt;' + ds.FieldByName(&quot;FULLNAME&quot;).AsString + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
            result += '&amp;lt;tr&amp;gt;&amp;lt;th colspan=2&amp;gt;A venir&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;';
            isBirthday = true;
        }
        else{
            result += &quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&quot; + ds.FieldByName(&quot;FULLNAME&quot;).AsString + &quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&quot; + ds.FieldByName(&quot;birthday&quot;).AsString + &quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&quot;;
        }

        ds.Next;
    }

    result += &quot;&amp;lt;/table&amp;gt;&quot;;

    result = (isBirthday)? picBirthday + result: result;

    return result
}

function NL_date(_date){
    this.date;

    this.date = (_date)? _date : new Date();
}

NL_date.prototype.toString = function(_format){


    var result = &quot;&quot;;

    var yyyy = this.date.getFullYear().toString();
    var MM = (this.date.getMonth()+1).toString();
    var dd  = this.date.getDate().toString();

    dd = (dd.length == 2)? dd: &quot;0&quot; + dd;
    MM = (MM.length == 2)? MM: &quot;0&quot; + MM;

    result = (_format)? _format: &quot;yyyyMMdd&quot;;
    result = result.replace(/yyyy/i, yyyy);
    result = result.replace(/MM/, MM);
    result = result.replace(/dd/i, dd);

    return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Feel free to change the Ugly hardcoded labels I ve used in there... (line 2 and 42)&lt;br&gt;
And finally add in your custom/img folder a gif you want to appear for the birthday (i ve called it 100% width it s going to be huge^^)&lt;/p&gt;

&lt;p&gt;I personnaly recommand my selection : &lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://media.giphy.com/media/ToMjGpM3hk5UL5UMQ4o/giphy.gif&quot;&gt;https://media.giphy.com/media/ToMjGpM3hk5UL5UMQ4o/giphy.gif&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;have the preview here : &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://media.giphy.com/media/ToMjGpM3hk5UL5UMQ4o/giphy.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;

&lt;p&gt;Last part add  the users you want to a group called SPECIAL (don't add your boss imho)&lt;/p&gt;

&lt;p&gt;Enjoy&lt;/p&gt;
</description>
<category>Efficy Partners</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=2223/who-want-the-birthday-widget-back-there-it-is</guid>
<pubDate>Tue, 24 Jan 2017 16:27:22 +0000</pubDate>
</item>
</channel>
</rss>