PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / controllers / configuration.php
vikappointments / admin / controllers Last commit date
analytics.php 4 years ago apiban.php 4 years ago apilog.php 4 years ago apiplugin.php 4 years ago apiuser.php 4 years ago backup.php 4 years ago calendar.php 4 years ago city.php 4 years ago closure.php 1 month ago configapp.php 4 years ago configcldays.php 2 years ago configcron.php 4 years ago configemp.php 4 years ago configsmsapi.php 4 years ago configuration.php 1 month ago conversion.php 1 year ago country.php 4 years ago coupon.php 4 years ago coupongroup.php 4 years ago cronjob.php 2 years ago cronjoblog.php 4 years ago customer.php 4 months ago customf.php 1 year ago dashboard.php 4 years ago emplocwdays.php 4 years ago employee.php 1 year ago emprates.php 4 years ago export.php 4 years ago exportres.php 4 years ago file.php 4 months ago findreservation.php 1 month ago group.php 4 years ago import.php 4 years ago index.html 4 years ago invoice.php 1 month ago langcustomf.php 4 years ago langemployee.php 4 years ago langgroup.php 4 years ago langmedia.php 4 years ago langoption.php 4 years ago langoptiongroup.php 4 years ago langpackage.php 4 years ago langpackgroup.php 4 years ago langpayment.php 4 years ago langservice.php 4 years ago langstatuscode.php 4 years ago langsubscr.php 4 years ago langtax.php 4 years ago location.php 4 years ago mailtext.php 2 years ago makerecurrence.php 1 month ago media.php 4 years ago multiorder.php 4 years ago option.php 4 months ago optiongroup.php 4 years ago package.php 2 years ago packgroup.php 4 years ago packorder.php 1 year ago payment.php 4 years ago rate.php 4 years ago reportsemp.php 4 years ago reportsser.php 4 years ago reservation.php 1 month ago restriction.php 4 years ago review.php 4 years ago service.php 1 year ago serworkday.php 4 months ago state.php 4 years ago statuscode.php 4 years ago subscription.php 4 years ago subscrorder.php 4 years ago tag.php 4 years ago tax.php 4 years ago usernote.php 4 years ago waitinglist.php 4 years ago webhook.php 4 years ago wizard.php 1 year ago
configuration.php
688 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 VAPLoader::import('libraries.mvc.controllers.admin');
15
16 /**
17 * VikAppointments configuration controller.
18 *
19 * @since 1.7
20 */
21 class VikAppointmentsControllerConfiguration extends VAPControllerAdmin
22 {
23 /**
24 * Task used to save the record data set in the request.
25 * After saving, the user is redirected to the management
26 * page of the record that has been saved.
27 *
28 * @return boolean
29 */
30 public function save()
31 {
32 $app = JFactory::getApplication();
33 $input = $app->input;
34 $user = JFactory::getUser();
35
36 /**
37 * Added token validation.
38 *
39 * @since 1.7
40 */
41 if (!JSession::checkToken())
42 {
43 // back to main list, missing CSRF-proof token
44 $app->enqueueMessage(JText::translate('JINVALID_TOKEN'), 'error');
45 $this->cancel();
46
47 return false;
48 }
49
50 // check user permissions
51 if (!$user->authorise('core.access.config', 'com_vikappointments'))
52 {
53 // back to main list, not authorised to access the configuration
54 $app->enqueueMessage(JText::translate('JERROR_ALERTNOAUTHOR'), 'error');
55 $this->cancel();
56
57 return false;
58 }
59
60 $args = array();
61
62 ////////////////////////////////////////////////////
63 ////////////////////// GLOBAL //////////////////////
64 ////////////////////////////////////////////////////
65
66 // SYSTEM
67
68 $args['agencyname'] = $input->getString('agencyname', '');
69 $args['companylogo'] = $input->getString('companylogo', '');
70 $args['ismultilang'] = $input->getUint('ismultilang', 0);
71 $args['router'] = $input->getUint('router', 0);
72 $args['showfooter'] = $input->getUint('showfooter', 0);
73 $args['googleapikey'] = $input->getString('googleapikey', '');
74 $args['sitetheme'] = $input->getString('sitetheme');
75 $args['refreshtime'] = $input->getInt('refreshtime', 30);
76
77 // date & time
78 $args['dateformat'] = $input->getString('dateformat');
79 $args['timeformat'] = $input->getString('timeformat');
80 $args['formatduration'] = $input->getUint('formatduration', 0);
81 $args['minuteintervals'] = $input->getUint('minuteintervals');
82 $args['openingtime'] = $input->getString('openingtime');
83 $args['closingtime'] = $input->getString('closingtime');
84
85 // booking
86 $args['minrestr'] = $input->getUint('minrestr', 0);
87 $args['mindate'] = $input->getUint('mindate', 0);
88 $args['maxdate'] = $input->getUint('maxdate', 0);
89 $args['keepapplock'] = $input->getUint('keepapplock', 15);
90 $args['showphprefix'] = $input->getUint('showphprefix', 0);
91 $args['conversion_track'] = $input->getUint('conversion_track', 0);
92
93 // CALENDARS
94
95 $args['calendarlayoutsite'] = $input->getString('calendarlayoutsite');
96 $args['calendarweekdays'] = $input->getUint('calendarweekdays');
97 $args['numcals'] = $input->getUint('numcals');
98 $args['nummonths'] = $input->getUint('nummonths');
99 $args['calsfrom'] = $input->getUint('calsfrom');
100 $args['calsfromyear'] = $input->getUint('calsfromyear');
101 $args['legendcal'] = $input->getUint('legendcal', 0);
102 $args['firstday'] = $input->getUint('firstday');
103 $args['calhourheight'] = $input->getUint('calhourheight');
104
105 // GDPR
106
107 $args['gdpr'] = $input->getUint('gdpr', 0);
108 $args['policylink'] = $input->getString('policylink', '');
109
110 // TIMEZONE
111
112 $args['multitimezone'] = $input->getUint('multitimezone', 0);
113
114 // APPOINTMENTS SYNC
115
116 $args['synckey'] = $input->getString('synckey', 'secret');
117
118 // ZIP RESTRICTIONS
119
120 $args['zipcfid'] = $input->getInt('zipcfid', 0);
121 $args['zipcodesfrom'] = $input->get('zip_code_from', array(), 'array');
122 $args['zipcodesto'] = $input->get('zip_code_to', array(), 'array');
123
124 // COLUMNS
125
126 $args['listablecols'] = $input->get('listablecols', array(), 'array');
127 $args['listablecf'] = $input->get('listablecf', array(), 'array');
128
129 ////////////////////////////////////////////////////
130 ////////////////////// E-MAIL //////////////////////
131 ////////////////////////////////////////////////////
132
133 // E-MAIL
134
135 $args['adminemail'] = $input->getString('adminemail', '');
136 $args['senderemail'] = $input->getString('senderemail', '');
137 $args['replytoemail'] = $input->getString('replytoemail', '');
138
139 // NOTIFICATIONS
140
141 $args['mailcustwhen'] = $input->getString('mailcustwhen', []);
142 $args['mailempwhen'] = $input->getString('mailempwhen', []);
143 $args['mailadminwhen'] = $input->getString('mailadminwhen', []);
144 $args['notifyonstatuschange'] = $input->getUint('notifyonstatuschange', 0);
145
146 // TEMPLATES
147
148 $args['mailtmpl'] = $input->getString('mailtmpl', '');
149 $args['adminmailtmpl'] = $input->getString('adminmailtmpl', '');
150 $args['empmailtmpl'] = $input->getString('empmailtmpl', '');
151 $args['cancmailtmpl'] = $input->getString('cancmailtmpl', '');
152 $args['stockmailtmpl'] = $input->getString('stockmailtmpl', '');
153
154 // ATTACHMENTS
155
156 $args['mailattach'] = $input->getString('mailattach', array());
157 $args['icsattach'] = array(
158 $input->getUint('icsattach1', 0),
159 $input->getUint('icsattach2', 0),
160 $input->getUint('icsattach3', 0),
161 );
162 $args['csvattach'] = array(
163 $input->getUint('csvattach1', 0),
164 $input->getUint('csvattach2', 0),
165 $input->getUint('csvattach3', 0),
166 );
167
168 ////////////////////////////////////////////////////
169 ///////////////////// CURRENCY /////////////////////
170 ////////////////////////////////////////////////////
171
172 // CURRENCY
173
174 $args['currencysymb'] = $input->getString('currencysymb', '');
175 $args['currencyname'] = $input->getString('currencyname', '');
176 $args['currsymbpos'] = $input->getInt('currsymbpos', 1);
177 $args['currdecimalsep'] = $input->getString('currdecimalsep', '.');
178 $args['currthousandssep'] = $input->getString('currthousandssep', ',');
179 $args['currdecimaldig'] = $input->getUint('currdecimaldig', 2);
180
181 // CONVERSION
182
183 $args['currency_ecb_enabled'] = $input->getUint('currency_ecb_enabled', 0);
184 $args['currency_floatrates_enabled'] = $input->getUint('currency_floatrates_enabled', 0);
185 $args['currency_currencyapi_enabled'] = $input->getUint('currency_currencyapi_enabled', 0);
186 $args['currency_currencyapi_key'] = $input->getString('currency_currencyapi_key', '');
187 $args['currency_currencyapi_cache'] = $input->getUint('currency_currencyapi_cache', 5);
188
189 ////////////////////////////////////////////////////
190 /////////////////////// SHOP ///////////////////////
191 ////////////////////////////////////////////////////
192
193 // SHOP
194
195 $args['defstatus'] = $input->getString('defstatus');
196 $args['selfconfirm'] = $input->getUint('selfconfirm', 0);
197 $args['showcheckout'] = $input->getUint('showcheckout', 0);
198 $args['loginreq'] = $input->getUint('loginreq', 0);
199 $args['printorders'] = $input->getUint('printorders', 0);
200 $args['invoiceorders'] = $input->getUint('invoiceorders', 0);
201 $args['showcountdown'] = $input->getUint('showcountdown', 0);
202 $args['editablefields'] = $input->getString('editablefields', '');
203
204 // cart
205 $args['enablecart'] = $input->getUint('enablecart', 0);
206 $args['maxcartsize'] = $input->getInt('maxcartsize', -1);
207 $args['cartallowsync'] = $input->getUint('cartallowsync', 0);
208 $args['shoplink'] = $input->getInt('shoplink', 0);
209 $args['shoplinkcustom'] = $input->getString('shoplinkcustom', '');
210 $args['confcartdisplay'] = $input->getUint('confcartdisplay', 0);
211
212 // restrictions
213 $args['restrtimeline'] = $input->getUint('restrtimeline', 0);
214
215 // cancellation
216 $args['enablecanc'] = $input->getUint('enablecanc', 0);
217 $args['canctime'] = $input->getUint('canctime', 0);
218 $args['usercredit'] = $input->getUint('usercredit', 0);
219
220 // deposit
221 $args['usedeposit'] = $input->getUint('usedeposit', 0);
222 $args['depositafter'] = $input->getFloat('depositafter', 300);
223 $args['depositvalue'] = $input->getFloat('depositvalue', 40);
224 $args['deposittype'] = $input->getInt('deposittype', 1);
225
226 // WAITING LIST
227
228 $args['enablewaitlist'] = $input->getUint('enablewaitlist', 0);
229 $args['waitlistsmscont'] = $input->get('waitlistsmscont', array(), 'array');
230 $args['waitlistmailtmpl'] = $input->getString('waitlistmailtmpl', '');
231
232 // RECURRING APPOINTMENTS
233
234 $args['enablerecur'] = $input->getUint('enablerecur', 0);
235 $args['minamountrecur'] = $input->getUint('minamountrecur', 1);
236 $args['maxamountrecur'] = $input->getUint('maxamountrecur', 12);
237 $args['repeatbyrecur'] = array();
238 $args['fornextrecur'] = array();
239
240 for ($i = 1; $i <= 8; $i++)
241 {
242 $args['repeatbyrecur'][] = $input->getUint('repeatby' . $i, 0);
243 }
244
245 for ($i = 1; $i <= 4; $i++)
246 {
247 $args['fornextrecur'][] = $input->getUint('fornext' . $i, 0);
248 }
249
250 // REVIEWS
251
252 $args['enablereviews'] = $input->getUint('enablereviews', 0);
253 $args['revservices'] = $input->getUint('revservices', 0);
254 $args['revemployees'] = $input->getUint('revemployees', 0);
255 $args['revcommentreq'] = $input->getUint('revcommentreq', 0);
256 $args['revminlength'] = $input->getUint('revminlength');
257 $args['revmaxlength'] = $input->getUint('revmaxlength');
258 $args['revlimlist'] = $input->getUint('revlimlist', 5);
259 $args['revlangfilter'] = $input->getUint('revlangfilter', 0);
260 $args['revautopublished'] = $input->getUint('revautopublished', 0);
261 $args['revloadmode'] = $input->getUint('revloadmode', 1);
262
263 // PACKAGES
264
265 $args['enablepackages'] = $input->getUint('enablepackages', 0);
266 $args['packsperrow'] = $input->getUint('packsperrow', 3);
267 $args['maxpackscart'] = $input->getInt('maxpackscart', -1);
268 $args['packsreguser'] = $input->getUint('packsreguser', 0);
269 $args['packsmandatory'] = $input->getUint('packsmandatory', 0);
270 $args['packmailtmpl'] = $input->getString('packmailtmpl', '');
271
272 // SUBSCRIPTIONS
273
274 $args['subscrreguser'] = $input->getUint('subscrreguser', 0);
275 $args['subscrmandatory'] = $input->getUint('subscrmandatory', 0);
276 $args['subscrthreshold'] = $input->getUint('subscrthreshold', 0);
277
278 // INVOICE
279
280 VAPLoader::import('libraries.invoice.factory');
281 $invGen = VAPInvoiceFactory::getGenerator();
282
283 // details
284 $args['deftax'] = $input->getUint('deftax', 0);
285 $args['usetaxbd'] = $input->getUint('usetaxbd', 0);
286
287 $invoice['number'] = $input->getUint('attr_invoicenumber', 1);
288 $invoice['suffix'] = $input->getString('attr_invoicesuffix', '');
289 $invoice['datetype'] = $input->getUint('attr_datetype', 1);
290 $invoice['legalinfo'] = $input->getString('attr_legalinfo', '');
291 $invoice['sendinvoice'] = $input->getUint('attr_sendinvoice', 0);
292
293 $invGen->setParams($invoice);
294
295 // properties
296
297 $properties = new stdClass;
298 $properties->pageOrientation = $input->getString('prop_page_orientation', 'P');
299 $properties->pageFormat = $input->getString('prop_page_format', 'A4');
300 $properties->unit = $input->getString('prop_unit', 'mm');
301 $properties->imageScaleRatio = max(array(5, $input->getFloat('prop_scale', 125))) / 100;
302
303 $invGen->setConstraints($properties);
304
305 // update invoice details here
306 $invGen->save();
307
308 ////////////////////////////////////////////////////
309 ///////////////////// LISTINGS /////////////////////
310 ////////////////////////////////////////////////////
311
312 // EMPLOYEES
313
314 $args['emplistlim'] = $input->getUint('emplistlim');
315 $args['emplistmode'] = $input->get('emplistmode', array(), 'array');
316 $args['empdesclength'] = $input->getUint('empdesclength', 256);
317 $args['emplinkhref'] = $input->getUint('emplinkhref', 1);
318 $args['empgroupfilter'] = $input->getUint('empgroupfilter', 0);
319 $args['empordfilter'] = $input->getUint('empordfilter', 0);
320 $args['empajaxsearch'] = $input->getUint('empajaxsearch', 0);
321
322 // SERVICES
323
324 $args['serdesclength'] = $input->getUint('serdesclength', 256);
325 $args['serlinkhref'] = $input->getUint('serlinkhref', 1);
326
327 ////////////////////////////////////////////////////
328
329 // get configuration model
330 $config = $this->getModel();
331
332 // Save all configuration.
333 // Do not care of any errors.
334 $changed = $config->saveAll($args);
335
336 if ($changed)
337 {
338 // display generic successful message
339 $app->enqueueMessage(JText::translate('JLIB_APPLICATION_SAVE_SUCCESS'));
340 }
341
342 // redirect to configuration page
343 $this->cancel();
344
345 return true;
346 }
347
348 /**
349 * Redirects the users to the main records list.
350 *
351 * @return void
352 */
353 public function cancel()
354 {
355 $this->setRedirect('index.php?option=com_vikappointments&view=editconfig');
356 }
357
358 /**
359 * AJAX end-point used to validate the requested ZIP code
360 * against the specified ones.
361 *
362 * @return void
363 */
364 public function testzip()
365 {
366 $input = JFactory::getApplication()->input;
367 $config = VAPFactory::getConfig();
368
369 /**
370 * Added token validation.
371 *
372 * @since 1.7
373 */
374 if (!JSession::checkToken())
375 {
376 // missing CSRF-proof token
377 UIErrorFactory::raiseError(403, JText::translate('JINVALID_TOKEN'));
378 }
379
380 $zip = $input->get('zipcode', '', 'string');
381 $pool = $input->get('pool', null, 'array');
382 $field = $input->get('field', null, 'int');
383
384 if (!is_null($pool))
385 {
386 // a specific validation pool was provided, temporarily
387 // update the configuration to apply the validation
388 // against the given zip codes
389 $tmpCodes = $config->get('zipcodes', '');
390 $config->set('zipcodes', $pool);
391 }
392
393 if (!is_null($field))
394 {
395 // a specific validation field was provided, temporarily
396 // update the configuration to apply the validation by
397 // through the specified custom field
398 $tmpField = $config->get('zipcfid', '');
399 $config->set('zipcfid', $field);
400 }
401
402 // validate specified zip code
403 $result = (int) VikAppointments::validateZipCode($zip, array(-1));
404
405 if (!is_null($pool))
406 {
407 // restore previous value
408 $config->set('zipcodes', $tmpCodes);
409 }
410
411 if (!is_null($field))
412 {
413 // restore previous value
414 $config->set('zipcfid', $tmpField);
415 }
416
417 // return response to caller
418 $this->sendJSON($result);
419 }
420
421 /**
422 * AJAX end-point used to import a list of ZIP codes
423 * contained within the uploaded file.
424 *
425 * The file must contain only one ZIP code per line.
426 * The system will sort the zip codes and will try
427 * to group them in case of contiguous codes.
428 *
429 * @return void
430 */
431 public function uploadzip()
432 {
433 /**
434 * Added token validation.
435 *
436 * @since 1.7
437 */
438 if (!JSession::checkToken())
439 {
440 // missing CSRF-proof token
441 UIErrorFactory::raiseError(403, JText::translate('JINVALID_TOKEN'));
442 }
443
444 // handle file upload
445 $dest = VAPADMIN . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR;
446 $result = VikAppointments::uploadFile('file', $dest);
447
448 if (!$result->status)
449 {
450 // unable to upload the file
451 UIErrorFactory::raiseError(500, JText::translate('VAPCONFIGUPLOADFILEERR'));
452 }
453
454 // extract data from file
455 $handle = fopen($result->path, 'r');
456
457 $zips = array();
458
459 while (!feof($handle))
460 {
461 // accept only letters and digits
462 $zip = strtoupper(preg_replace('/[^A-Z0-9]/i', '', fgets($handle)));
463
464 if ($zip)
465 {
466 $zips[] = $zip;
467 }
468 }
469
470 fclose($handle);
471
472 // delete file
473 unlink($result->path);
474
475 $data = array();
476
477 if (count($zips))
478 {
479 sort($zips);
480
481 $from_zip = array();
482 $to_zip = array();
483
484 $start = $zips[0];
485 $end = $zips[0];
486 $ok = false;
487
488 for ($i = 1; $i < count($zips); $i++)
489 {
490 if (is_numeric($zips[$i - 1]) && ($zips[$i - 1] + 1) == $zips[$i])
491 {
492 $end = $zips[$i];
493 $ok = true;
494 }
495 else
496 {
497 $from_zip[] = $start;
498 $to_zip[] = $end;
499
500 $start = $zips[$i];
501 $end = $zips[$i];
502 $ok = false;
503 }
504
505 if ($i == count($zips) - 1)
506 {
507 $from_zip[] = $start;
508 $to_zip[] = $end;
509 }
510 }
511
512 // iterate all zip codes
513 for ($i = 0; $i < count($from_zip); $i++)
514 {
515 // copy interval within the response
516 $data[] = array(
517 'from' => $from_zip[$i],
518 'to' => $to_zip[$i],
519 );
520 }
521 }
522
523 // send response to caller
524 $this->sendJSON($data);
525 }
526
527 /**
528 * Tries to render a preview of the selected e-mail template.
529 *
530 * @return void
531 */
532 public function mailpreview()
533 {
534 $app = JFactory::getApplication();
535 $input = $app->input;
536 $dbo = JFactory::getDbo();
537
538 /**
539 * Added token validation (GET only).
540 *
541 * @since 1.7
542 */
543 if (!JSession::checkToken('get'))
544 {
545 // back to main list, missing CSRF-proof token
546 $app->enqueueMessage(JText::translate('JINVALID_TOKEN'), 'error');
547 $this->cancel();
548
549 return false;
550 }
551
552 $id = $input->get('id', 0, 'uint');
553 $alias = $input->get('alias', '', 'string');
554 $file = $input->get('file', '', 'string');
555 $lang = $input->get('langtag', '', 'string');
556
557 $options = array();
558
559 // always flag as test mode
560 $options['test'] = true;
561
562 // load mail factory
563 VAPLoader::import('libraries.mail.factory');
564
565 // build base arguments
566 $args = array($alias);
567
568 if ($alias == 'package')
569 {
570 if (!$id)
571 {
572 // find latest package order
573 $q = $dbo->getQuery(true)
574 ->select($dbo->qn('id'))
575 ->from($dbo->qn('#__vikappointments_package_order'))
576 ->order($dbo->qn('id') . ' DESC');
577
578 $dbo->setQuery($q, 0, 1);
579 $id = (int) $dbo->loadResult();
580
581 if (!$id)
582 {
583 throw new Exception('Before to see a preview of the e-mail template, you have to create at least a package first.', 400);
584 }
585 }
586
587 // inject package ID within the arguments
588 $args[] = $id;
589 }
590 else if ($alias == 'stock')
591 {
592 // pass test attributes to retrieve some junk data
593 $options['start'] = $app->input->getUint('start');
594 $options['limit'] = $app->input->getUint('limit');
595 }
596 else
597 {
598 if (!$id)
599 {
600 // find latest appointment
601 $q = $dbo->getQuery(true)
602 ->select($dbo->qn('id'))
603 ->from($dbo->qn('#__vikappointments_reservation'))
604 ->where($dbo->qn('closure') . ' = 0')
605 ->order($dbo->qn('id') . ' DESC');
606
607 if ($alias == 'waitlist')
608 {
609 // exclude parent orders
610 $q->where($dbo->qn('id_parent') . ' > 0');
611 }
612
613 $dbo->setQuery($q, 0, 1);
614 $id = (int) $dbo->loadResult();
615
616 if (!$id)
617 {
618 throw new Exception('Before to see a preview of the e-mail template, you have to create at least an appointment first.', 400);
619 }
620 }
621
622 // inject appointment ID within the arguments
623 $args[] = $id;
624 }
625
626 if ($lang)
627 {
628 // force language tag too
629 $options['lang'] = $lang;
630 }
631
632 if ($alias == 'cancellation')
633 {
634 // we should include a sample cancellation reason
635 // text to make it visible for styling
636 $options['cancellation_reason'] = 'The cancellation reason will be printed here in case the system supports it.';
637 }
638 else if ($alias == 'waitlist')
639 {
640 // recover first appointment assigned to order ID
641 VAPLoader::import('libraries.order.factory');
642 $order = VAPOrderFactory::getAppointments($args[1]);
643 $args[1] = array_shift($order->appointments);
644
645 // inject junk waiting list data
646 $args[] = array(
647 'id_service' => $args[1]->service->id,
648 'id_employee' => $args[1]->employee->id,
649 'jid' => 0,
650 'email' => 'no-reply@domain.com',
651 );
652
653 // use current date
654 $args[] = JFactory::getDate()->format('Y-m-d');
655
656 // use junk times
657 $args[] = array(600, 660, 720);
658 }
659
660 $args[] = $options;
661
662 // instantiate provider by using the fetched arguments
663 $mail = call_user_func_array(array('VAPMailFactory', 'getInstance'), $args);
664
665 // overwrite template file
666 $mail->setFile($file);
667
668 // get mail subject (page title)
669 $title = $mail->getSubject();
670
671 // render mail template (page body)
672 $tmpl = $mail->getHtml();
673
674 // include style to prevent body from having margins
675 $tmpl = '<style>body{margin:0;padding:0;}</style>' . $tmpl;
676
677 $data = array(
678 'title' => $title,
679 'body' => $tmpl,
680 );
681
682 // display resulting template
683 $base = VAPBASE . DIRECTORY_SEPARATOR . 'layouts';
684 echo JLayoutHelper::render('document.blankpage', $data, $base);
685 exit;
686 }
687 }
688