3 * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
4 * Copyright 2015, Franck Villaume - TrivialDev
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 * Standard Alcatel-Lucent disclaimer for contributing to open source
25 * "The provided file ("Contribution") has not been tested and/or
26 * validated for release as or in products, combinations with products or
27 * other commercial use. Any use of the Contribution is entirely made at
28 * the user's own responsibility and the user can not rely on any features,
29 * functionalities or performances Alcatel-Lucent has attributed to the
32 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
33 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
35 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
36 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
37 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
38 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
39 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
40 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
45 // This page contains a form with a file-upload button
46 // so a user can choose a file to upload a .csv file and store it in task mgr
51 pm_header(array('title'=>_('Upload data into the tasks'),'group_project_id'=>$group_project_id));
53 $default = array('headers' => 1, 'full' => 1, 'sep' => ',');
55 if (session_loggedin()) {
56 $u = session_get_user();
57 $pref = $u->getPreference('csv');
59 $default = array_merge($default, unserialize($pref));
63 $bom = getIntFromRequest('bom', 0);
64 $encoding = getStringFromRequest('encoding', 'UTF-8');
65 $headers = getIntFromRequest('headers', $default['headers']);
66 $full = getIntFromRequest('full', $default['full']);
67 $sep = getFilteredStringFromRequest('sep', '/^[,;]$/', $default['sep']);
69 if (session_loggedin()) {
70 if ( ($sep !== $default['sep']) || ($headers !== $default['headers']) ) {
71 $pref = array_merge( $default, array('headers' => $headers, 'full' => $full, 'sep' => $sep));
72 $u->setPreference('csv', serialize($pref));
76 $format = $full ? 'Full CSV' : 'Normal CSV';
77 $format .= $headers ? ' with headers' : ' without headers';
78 $format .= " using '".htmlentities($sep)."' as separator.";
80 echo html_e('p', array(), _('This page allows you to export or import all the tasks using a CSV (<a href="http://en.wikipedia.org/wiki/Comma-separated_values">Comma Separated Values</a>) File. This format can be used to view tasks using Microsoft Excel.'));
81 echo html_e('h2', array(), _('Export tasks as a CSV file'));
83 echo html_e('strong', array(), _('Selected CSV Format')._(':')).' '.$format.' '.util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=format_csv&sep='.$sep.'&full='.$full.'&headers='.$headers.'&bom='.$bom.'&encoding='.$encoding, _('(Change)'));
84 echo html_e('p', array(), util_make_link('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=downloadcsv&sep='.$sep.'&full='.$full.'&headers='.$headers.'&bom='.$bom.'&encoding='.$encoding, _('Export CSV file')));
86 echo html_e('h2', array(), _('Import tasks using a CSV file'));
87 echo $HTML->openForm(array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => '/pm/task.php?group_project_id='.$group_project_id.'&group_id='.$group_id.'&func=postuploadcsv'));
88 echo html_e('p', array(), _('Choose a file in the proper .csv format for uploading.'));
89 echo html_e('input', array('type' => 'file', 'name' => 'userfile', 'required' => 'required')).html_e('br');
90 echo html_e('p', array(),
91 html_e('label', array(), html_e('input', array('type' => 'radio', 'name' => 'replace', 'value' => 1, 'checked' => 'checked')). _('Replace all tasks by the ones present in the file')).
92 html_e('label', array(), html_e('input', array('type' => 'radio', 'name' => 'replace', 'value' => 0)). _('Add the ones from the file to the existing ones')));
93 echo html_e('input', array('type' => 'submit', 'name' => 'submit', 'value' => _('Submit')));
94 echo $HTML->closeForm();
95 echo html_e('h3', array(), _('Notes'));
96 $elementsArray = array();
97 $elementsArray[] = array('content' => _('If project_task_id is empty, then a new task will be created.'));
98 $elementsArray[] = array('content' => _('If project_task_id is present, then the corresponding task will be updated.'));
99 echo $HTML->html_list($elementsArray);
101 echo html_e('h2', array(), _('Record Layout'));
103 $thArray= array(_('Field Name'), _('Description'));
104 echo $HTML->listTableTop($thArray);
106 $cells[][] = 'project_task_id';
107 $cells[][] = _('this is the ID in database');
108 echo $HTML->multiTableRow(array(), $cells);
110 $cells[][] = 'external_task_id';
111 $cells[][] = _('optional, the equivalent of project_task_id but determined by external application, such as Microsoft Project. Primarily preserved for sorting purposes only.');
112 echo $HTML->multiTableRow(array(), $cells);
114 $cells[][] = 'parent_id';
115 $cells[][] = _('the project_task_id of the parent task, if any');
116 echo $HTML->multiTableRow(array(), $cells);
118 $cells[][] = 'external_parent_id';
119 $cells[][] = _('the equivalent of parent project_task_id but determined by external application, such as Microsoft Project. Primarily preserved for matching purposes only.');
120 echo $HTML->multiTableRow(array(), $cells);
122 $cells[][] = 'title';
123 $cells[][] = _('The summary or brief description');
124 echo $HTML->multiTableRow(array(), $cells);
126 $cells[][] = 'category';
127 $cells[][] = _('The category name (must be defined, only available in full export)');
128 echo $HTML->multiTableRow(array(), $cells);
130 $cells[][] = 'duration';
131 $cells[][] = _('Duration in days');
132 echo $HTML->multiTableRow(array(), $cells);
135 $cells[][] = _('Number of hours required to complete');
136 echo $HTML->multiTableRow(array(), $cells);
138 $cells[][] = 'start_date';
139 $cells[][] = _('The start date in YYYY-MM-DD HH:MM:SS format');
140 echo $HTML->multiTableRow(array(), $cells);
142 $cells[][] = 'end_date';
143 $cells[][] = _('The end date in YYYY-MM-DD HH:MM:SS format');
144 echo $HTML->multiTableRow(array(), $cells);
146 $cells[][] = 'percent_complete';
147 $cells[][] = _('Percentage of completion');
148 echo $HTML->multiTableRow(array(), $cells);
150 $cells[][] = 'priority';
151 $cells[][] = _('integers 1 to 5');
152 echo $HTML->multiTableRow(array(), $cells);
154 $cells[][] = 'notes';
155 $cells[][] = _('optional, the details of the task or a comment to add to a task');
156 echo $HTML->multiTableRow(array(), $cells);
158 $cells[][] = 'resource1_unixname';
159 $cells[][] = _('optional, the unixname or precisely-matched realname of the assignee');
160 echo $HTML->multiTableRow(array(), $cells);
162 $cells[][] = 'resource2_unixname';
163 $cells[][] = _('optional, same as above');
164 echo $HTML->multiTableRow(array(), $cells);
166 $cells[][] = 'resource3_unixname';
167 $cells[][] = _('optional, same as above');
168 echo $HTML->multiTableRow(array(), $cells);
170 $cells[][] = 'resource4_unixname';
171 $cells[][] = _('optional, same as above');
172 echo $HTML->multiTableRow(array(), $cells);
174 $cells[][] = 'resource5_unixname';
175 $cells[][] = _('optional, same as above');
176 echo $HTML->multiTableRow(array(), $cells);
178 $cells[][] = 'dependenton1_project_task_id';
179 $cells[][] = _('optional, the task_id of a task to be dependent on');
180 echo $HTML->multiTableRow(array(), $cells);
182 $cells[][] = 'dependenton1_external_task_id';
183 $cells[][] = _('optional, the ID used by the external application');
184 echo $HTML->multiTableRow(array(), $cells);
186 $cells[][] = 'dependenton1_linktype';
187 $cells[][] = _('SS, SF, FS, FF, - The same types as Microsoft Project');
188 echo $HTML->multiTableRow(array(), $cells);
190 $cells[][] = 'dependenton2_project_task_id';
191 $cells[][] = _('repetition of dependenton1');
192 echo $HTML->multiTableRow(array(), $cells);
194 $cells[][] = 'dependenton2_external_task_id';
195 $cells[][] = _('repetition of dependenton1');
196 echo $HTML->multiTableRow(array(), $cells);
198 $cells[][] = 'dependenton2_linktype';
199 $cells[][] = _('repetition of dependenton1');
200 echo $HTML->multiTableRow(array(), $cells);
202 $cells[][] = 'dependenton3_project_task_id';
203 $cells[][] = _('repetition of dependenton1');
204 echo $HTML->multiTableRow(array(), $cells);
206 $cells[][] = 'dependenton3_external_task_id';
207 $cells[][] = _('repetition of dependenton1');
208 echo $HTML->multiTableRow(array(), $cells);
210 $cells[][] = 'dependenton3_linktype';
211 $cells[][] = _('repetition of dependenton1');
212 echo $HTML->multiTableRow(array(), $cells);
214 $cells[][] = 'dependenton4_project_task_id';
215 $cells[][] = _('repetition of dependenton1');
216 echo $HTML->multiTableRow(array(), $cells);
218 $cells[][] = 'dependenton4_external_task_id';
219 $cells[][] = _('repetition of dependenton1');
220 echo $HTML->multiTableRow(array(), $cells);
222 $cells[][] = 'dependenton4_linktype';
223 $cells[][] = _('repetition of dependenton1');
224 echo $HTML->multiTableRow(array(), $cells);
226 $cells[][] = 'dependenton5_project_task_id';
227 $cells[][] = _('repetition of dependenton1');
228 echo $HTML->multiTableRow(array(), $cells);
230 $cells[][] = 'dependenton5_external_task_id';
231 $cells[][] = _('repetition of dependenton1');
232 echo $HTML->multiTableRow(array(), $cells);
234 $cells[][] = 'dependenton5_linktype';
235 $cells[][] = _('repetition of dependenton1');
236 echo $HTML->multiTableRow(array(), $cells);
237 echo $HTML->listTableBottom();