QRC generator (the regular plugin, not the one from Jerry or CMSB Cookbook)

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 28, 2022   (RSS)

By Codee - April 12, 2022

Hello IT,

I'm working on a site utilizing CMSB 3.56 bld 2304, and QRCode Generator 1.02.  I was just putting up a simple qrcode sample page and noticed that the "event" type is not able to provide the correct time...It seems to always be 5 hours earlier than coded in...no matter what I change the start and end time to. The following returns the correct date but start time shows as 5:30 and end time is 6:00.  Just so you know I have scanned using several different devices and scanners...it's consistently happening across the board. I have attached a screenshot of the generated QR Code as well.

Here's the sample code for this piece:

<div>Calendar Event<br><br>
<?php
echo qrCode(array(
'type' => 'event',
'title' => 'Community Dental Day',
'start' => '2022-05-21 8:30:00',
'end' => '2022-05-21 11:00:00'
));
?>
</div>

By daniel - April 12, 2022

Hi Codee,

It looks like the QR code was not generating the event dates with the correct timezone reference, so everything was being created in UTC. In the QRCodeGenerator.php plugin file, can you try replacing this line (at or around line 48):

  elseif ($type == 'event')         { $data = "BEGIN:VEVENT:\nSUMMARY:" . $options['title'] . "\nDTSTART:" . gmdate("Ymd\THis", strtotime($options['start'])) . "\nDTEND:" . gmdate("Ymd\THis", strtotime($options['end'])) . "\nEND:VEVENT";  }

with this:

  elseif ($type == 'event')         { $data = "BEGIN:VEVENT\nSUMMARY:" . $options['title'] . "\nDTSTART;TZID=".date_default_timezone_get().":" . date("Ymd\THis", strtotime($options['start'])) . "\nDTEND:" . date("Ymd\THis", strtotime($options['end'])) . "\nEND:VEVENT"; echo $data;  }

Let me know if this works for you!

Thanks,

Daniel
Technical Lead
interactivetools.com

By Codee - June 28, 2022

Hi Daniel,

Sorry for the delay in responding ~ I literally just got back to this part of their project.  Your solution mostly worked. I have attached a screen shot of the before and after.  While the time for the event was pulled, correctly, from the default/globals as you wrote, unfortunately a bunch of text was inserted between the title "Calendar Event" (in red) and the qr code sample just below it. 

If we can correct that portion then we have a solid fix.

Thank you kindly!

By daniel - June 28, 2022

Hey Codee,

It looks like some debugging code got left in the sample, so I you should just need to remove "echo $data;" so it looks like this:

 elseif ($type == 'event')         { $data = "BEGIN:VEVENT\nSUMMARY:" . $options['title'] . "\nDTSTART;TZID=".date_default_timezone_get().":" . date("Ymd\THis", strtotime($options['start'])) . "\nDTEND:" . date("Ymd\THis", strtotime($options['end'])) . "\nEND:VEVENT"; }

Can you try that out and let me know if it works?

Thanks,

Daniel
Technical Lead
interactivetools.com