Page 1 of 1

Display SQL date in script tab in EU format

PostPosted: Fri May 11, 2018 7:51 am
by dspaan
When we use the SQLdate script variable in the agent script tab it is displayed in this format YYYY-MM-DD. We would need DD-MM-YYYY. How can we achieve this?

Version: 2.14b0.5
SVN Version: 2951
DB Schema Version: 1540

Re: Display SQL date in script tab in EU format

PostPosted: Fri May 11, 2018 4:01 pm
by mflorell
A new variable would have to be added that would contain that different formatting of the date.

Re: Display SQL date in script tab in EU format

PostPosted: Sat May 12, 2018 9:35 am
by blackbird2306
Either you need to declare a new variable, but then you have to change the code at many places e.g. urlencode and preg_replace this variable, or you just convert the existing variable SQLdate, but then you are not able to use the old format in script tab.
The easiest way is to convert SQLdate directly. You need to add only one line in "vdc_script_display.php" in "srv/www/htdocs/agc" directory (about line 262 newest revision 2952):
Code: Select all
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");                          // HTTP/1.0
$SQLdate = date("d-m-Y H:i:s", strtotime($SQLdate));   // --------ADD THIS LINE
$txt = '.txt';

This will change only the SQLdate format in script tab nowhere else (e.g dispo call url...)!

Re: Display SQL date in script tab in EU format

PostPosted: Sun Jan 05, 2020 4:15 am
by innovations
blackbird2306 wrote:Either you need to declare a new variable, but then you have to change the code at many places e.g. urlencode and preg_replace this variable, or you just convert the existing variable SQLdate, but then you are not able to use the old format in script tab.
The easiest way is to convert SQLdate directly. You need to add only one line in "vdc_script_display.php" in "srv/www/htdocs/agc" directory (about line 262 newest revision 2952):
Code: Select all
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");                          // HTTP/1.0
$SQLdate = date("d-m-Y H:i:s", strtotime($SQLdate));   // --------ADD THIS LINE
$txt = '.txt';

This will change only the SQLdate format in script tab nowhere else (e.g dispo call url...)!


Will this same code work in the current version of vicidial in the form tab for custom fields if you add it to vdc_form_display.php? I tried it and its still displaying in the default format of yyyy-mm-dd. Also, there is no setting to change dob to display in a different format like there is for Agent Screen Header Date & Agent Screen Customer Date Format?

Re: Display SQL date in script tab in EU format

PostPosted: Sun Jan 05, 2020 8:46 am
by blackbird2306
This code was only meant to be used in the script tab and only changes the format of the SQLdate variable (--A--SQLdate--B--).
Can you explain in detail which custom fields you want to be displayed in altered format?

Re: Display SQL date in script tab in EU format

PostPosted: Sun Jan 05, 2020 11:56 am
by innovations
Oh I see. Thanks for the reply. I want to change the custom field "date of birth" to be displayed as mm-dd-yyyy. Its currently displayed in the yyyy-mm-dd format. I've been searching for a way to do this but haven't found a way to achieve this.

Re: Display SQL date in script tab in EU format

PostPosted: Fri Jan 08, 2021 5:08 pm
by dspaan
What would be the method of changing the format of date fields in custom fields so when you choose a date it's saved in DD-MM-YYYY?

Re: Display SQL date in script tab in EU format

PostPosted: Thu Jan 21, 2021 12:07 pm
by williamconley
dspaan wrote:What would be the method of changing the format of date fields in custom fields so when you choose a date it's saved in DD-MM-YYYY?

"Saved in" is a challenging assertion. Dates are stored in MYSQL date/time or timestamp format. But they can be displayed in any format upon retrieval. If you want them saved differently in the table, that would require a change to the field definition to make it a string instead of a date.

Vicidial does not yet have a Universal Date Display format setting. Nor does it have a "per customer/campaign/list/server" date setting. The only date formatting presently available of which I am aware is in system settings for agent/customer "current date/time" in the agent screen header, which is not related to any stored data.

Without coding changes to Vicidial: Set the date field to generic text instead of date.

Re: Display SQL date in script tab in EU format

PostPosted: Thu Jan 21, 2021 2:14 pm
by dspaan
Yeah that's what i did but when agents use a custom field with a date picker it shows the incorrect format and when you make it a free field this will of course lead to all kinds of different notations.

Re: Display SQL date in script tab in EU format

PostPosted: Thu Jan 21, 2021 5:12 pm
by williamconley
Then you'll need some custom .js to resolve your issue. I keep expecting Vicidial to have a "custom javascript insertion" method, but to date there isn't one. In apps like Lime Survey custom javascript provides massive flexibility.

Of course, it can be handled with manual editing pretty easily, but then upgrading obliterates it and it must be remodified. If handled as an "include", it's not too bad to remodify, but still it's annoying. 8-)

Re: Display SQL date in script tab in EU format

PostPosted: Thu Jan 21, 2021 8:13 pm
by mflorell
We added the following options.php settings back in 2018 for the exact purpose of allowing for custom javascript to be added to the agent script at the webserver level:

$INSERT_head_script = ''; # inserted right above the <script language="Javascript"> line after logging in
$INSERT_head_js = ''; # inserted after first javascript function
$INSERT_first_onload = ''; # inserted at the beginning of the first section of the onload function
$INSERT_window_onload = ''; # inserted at the end of the onload function
$INSERT_agent_events = ''; # inserted within the agent_events function

Re: Display SQL date in script tab in EU format

PostPosted: Mon Feb 01, 2021 1:13 pm
by dspaan
Thanks, never knew this Matt.

William: We always insert javascript in the form tab at the bottom most custom field. Just set the field type to script and point to your javascript files. We use this for instance to connect with an API that checks the validity of an e-mail address or to find a streetname after the postal code and housenumber is known.