3 * interface/main/holidays/import_holidays.php holidays/clinic handle import/download holidays files
5 * Copyright (C) 2016 Sharon Cohen <sharonco@matrix.co.il>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @author sharonco <sharonco@matrix.co.il>
20 * @link http://www.open-emr.org
25 require_once('../../globals.php');
26 require_once($GLOBALS['srcdir'] . '/acl.inc');
27 require_once("Holidays_Controller.php");
29 if (!acl_check('admin', 'super')) {
30 die(xlt('Not authorized'));
33 $holidays_controller = new Holidays_Controller();
34 $csv_file_data = $holidays_controller->get_file_csv_data();
36 //this part download the CSV file after the click on the href link
37 if ($_GET['download_file']==1) {
38 $target_file=$holidays_controller->get_target_file();
39 if (! file_exists($target_file)) {
40 echo xlt('file missing');
42 header('HTTP/1.1 200 OK');
43 header('Cache-Control: no-cache, must-revalidate');
44 header("Pragma: no-cache");
46 header("Content-type: text/csv");
47 header("Content-Disposition: attachment; filename=holiday.csv");
48 readfile($target_file);
55 // end download section
59 if (!empty($_POST['bn_upload'])) {
60 //Upload and save the csv
61 $saved = $holidays_controller->upload_csv($_FILES);
63 $csv_file_data = $holidays_controller->get_file_csv_data();
67 if (!empty($_POST['import_holidays'])) {
68 //Import from the csv file to the calendar external table
69 $saved = $holidays_controller->import_holidays_from_csv();
72 if (!empty($_POST['sync'])) {
73 //Upload and save the csv
74 $saved = $holidays_controller->create_holiday_event();
82 <title
><?php
echo xlt('Holidays management'); ?
></title
>
83 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
87 <body
class="body_top">
90 echo "<p style='color:green'>" .
91 xlt('Successfully Completed');
93 } elseif (!empty($_POST['bn_upload']) &&
94 !empty($_POST['import_holidays']) &&
95 !empty($_POST['sync'])
97 echo "<p style='color:red'>" .
98 xlt('Operation Failed');
102 <form method
='post' action
='import_holidays.php' enctype
='multipart/form-data'
103 onsubmit
='return top.restoreSession()'>
106 <table border
='1' cellpadding
='4'>
107 <tr bgcolor
='#dddddd' class='dehead'>
108 <td align
='center' colspan
='2'>
109 <?php
echo xlt('CSV'); ?
>
113 <td
class='detail' nowrap
>
114 <?php
echo htmlspecialchars(xl('CSV File')); ?
>
115 <input type
="hidden" name
="MAX_FILE_SIZE" value
="350000000" />
117 <td
class='detail' nowrap
>
118 <input type
="file" name
="form_file" size
="40" />
122 <td
class='detail' nowrap
>
123 <?php
echo xlt('File on server (modification date)'); ?
>
125 <td
class='detail' nowrap
>
127 if (!empty($csv_file_data)) {?
>
129 <?php
$path=explode("/", $holidays_controller->get_target_file());?
>
130 <?php
$filename=$path[count($path)-1];?
>
131 <?php
unset($path[count($path)-1]);?
>
133 <a href
="#" onclick
='window.open("import_holidays.php?download_file=1")'><?php
echo text($csv_file_data['date']);?
></a
>
136 echo htmlspecialchars(xl('File not found'));
141 <tr bgcolor
='#dddddd'>
142 <td align
='center' class='detail' colspan
='2'>
143 <input type
='submit' name
='bn_upload' value
='<?php echo xla('Upload
/ Save
') ?>' />
153 <form method
='post' action
='import_holidays.php' onsubmit
='return top.restoreSession()'>
154 <input type
='submit' name
='import_holidays' value
='<?php echo xla('Import holiday events
') ?>'></br
>
160 <?php
echo xlt('CSV to calendar_external table'); ?
></br
>
161 <?php
echo xlt('If the csv file has been uploaded, then click on the "Import holiday events" button. NOTE that clicking on the button will remove all the existing rows in the calendar_external table')?
>
166 <form method
='post' action
='import_holidays.php' onsubmit
='return top.restoreSession()'>
167 <input type
='submit' name
='sync' value
='<?php echo xla('Synchronize
') ?>' /></br
>
171 <?php
echo xlt('calendar_external to events'); ?
></br
>
172 <?php
echo xlt('If you have already filled the calendar_external table, then click on "Synchronize" button to have the holidays in the calendar view. NOTE that clicking on the button will remove all the existing items in the calendar view related to holidays')?
>