Display SQL date in script tab in EU format

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Display SQL date in script tab in EU format

Postby dspaan » Fri May 11, 2018 7:51 am

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
Regards, Dennis

Vicibox 9.0.1
Version: 2.14b0.5
SVN Version: 3199
DB Schema Version: 1588
Build: 200310-1801
dspaan
 
Posts: 1377
Joined: Fri Aug 21, 2009 1:40 pm
Location: The Netherlands

Re: Display SQL date in script tab in EU format

Postby mflorell » Fri May 11, 2018 4:01 pm

A new variable would have to be added that would contain that different formatting of the date.
mflorell
Site Admin
 
Posts: 18384
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: Display SQL date in script tab in EU format

Postby blackbird2306 » Sat May 12, 2018 9:35 am

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...)!
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: Display SQL date in script tab in EU format

Postby innovations » Sun Jan 05, 2020 4:15 am

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?
Vicibox 9.0.1 | Version 2.14-730a
Build: 191121-2256 | Asterisk: 13.29.2-vici
SVN Version: 3179 | DB Schema Version: 1582 | WebRTC Setup
innovations
 
Posts: 5
Joined: Sun Nov 17, 2019 12:10 pm

Re: Display SQL date in script tab in EU format

Postby blackbird2306 » Sun Jan 05, 2020 8:46 am

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?
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: Display SQL date in script tab in EU format

Postby innovations » Sun Jan 05, 2020 11:56 am

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.
Vicibox 9.0.1 | Version 2.14-730a
Build: 191121-2256 | Asterisk: 13.29.2-vici
SVN Version: 3179 | DB Schema Version: 1582 | WebRTC Setup
innovations
 
Posts: 5
Joined: Sun Nov 17, 2019 12:10 pm

Re: Display SQL date in script tab in EU format

Postby dspaan » Fri Jan 08, 2021 5:08 pm

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?
Regards, Dennis

Vicibox 9.0.1
Version: 2.14b0.5
SVN Version: 3199
DB Schema Version: 1588
Build: 200310-1801
dspaan
 
Posts: 1377
Joined: Fri Aug 21, 2009 1:40 pm
Location: The Netherlands

Re: Display SQL date in script tab in EU format

Postby williamconley » Thu Jan 21, 2021 12:07 pm

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.
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20256
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Re: Display SQL date in script tab in EU format

Postby dspaan » Thu Jan 21, 2021 2:14 pm

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.
Regards, Dennis

Vicibox 9.0.1
Version: 2.14b0.5
SVN Version: 3199
DB Schema Version: 1588
Build: 200310-1801
dspaan
 
Posts: 1377
Joined: Fri Aug 21, 2009 1:40 pm
Location: The Netherlands

Re: Display SQL date in script tab in EU format

Postby williamconley » Thu Jan 21, 2021 5:12 pm

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-)
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20256
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Re: Display SQL date in script tab in EU format

Postby mflorell » Thu Jan 21, 2021 8:13 pm

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
mflorell
Site Admin
 
Posts: 18384
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: Display SQL date in script tab in EU format

Postby dspaan » Mon Feb 01, 2021 1:13 pm

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.
Regards, Dennis

Vicibox 9.0.1
Version: 2.14b0.5
SVN Version: 3199
DB Schema Version: 1588
Build: 200310-1801
dspaan
 
Posts: 1377
Joined: Fri Aug 21, 2009 1:40 pm
Location: The Netherlands


Return to Support

Who is online

Users browsing this forum: No registered users and 54 guests