1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - timesheet * |
---|
4 | * http://www.eGroupWare.org * |
---|
5 | * Maintained and further developed by RalfBecker@outdoor-training.de * |
---|
6 | * Based on Webtimesheet by Craig Knudsen <cknudsen@radix.net> * |
---|
7 | * http://www.radix.net/~cknudsen * |
---|
8 | * Originaly modified by Mark Peters <skeeter@phpgroupware.org> * |
---|
9 | * -------------------------------------------- * |
---|
10 | * This program is free software; you can redistribute it and/or modify it * |
---|
11 | * under the terms of the GNU General Public License as published by the * |
---|
12 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
13 | * option) any later version. * |
---|
14 | \**************************************************************************/ |
---|
15 | |
---|
16 | |
---|
17 | class uitimesheet |
---|
18 | { |
---|
19 | var $dbb; |
---|
20 | var $template; |
---|
21 | var $cat; |
---|
22 | var $debug = False; |
---|
23 | var $cat_id; |
---|
24 | var $theme; |
---|
25 | var $link_tpl; |
---|
26 | var $public_functions = array( |
---|
27 | 'index' => True, |
---|
28 | 'view' => True, |
---|
29 | 'edit' => True, |
---|
30 | 'update'=> True, |
---|
31 | 'delete' => True, |
---|
32 | 'close' => True, |
---|
33 | 'import_mail' => True, |
---|
34 | 'search' => True, |
---|
35 | 'header' => True, |
---|
36 | 'footer' => True |
---|
37 | ); |
---|
38 | |
---|
39 | |
---|
40 | var $prefs; |
---|
41 | /** |
---|
42 | * instance of the bo-class |
---|
43 | * |
---|
44 | * @var botimesheet |
---|
45 | */ |
---|
46 | var $bo; |
---|
47 | /** |
---|
48 | * reference to instance of the link-class of bo |
---|
49 | * |
---|
50 | * @var bolink |
---|
51 | */ |
---|
52 | var $link; |
---|
53 | /** |
---|
54 | * instance of the etemplate class |
---|
55 | * |
---|
56 | * @var etemplate |
---|
57 | */ |
---|
58 | var $tmpl; |
---|
59 | /** |
---|
60 | * reference to the html object of etemplate |
---|
61 | * |
---|
62 | * @var html |
---|
63 | */ |
---|
64 | var $html; |
---|
65 | /** |
---|
66 | * allowed units and hours per day, can be overwritten by the projectmanager configuration, default all units, 8h |
---|
67 | * |
---|
68 | * @var string |
---|
69 | */ |
---|
70 | var $duration_format = ','; // comma is necessary! |
---|
71 | |
---|
72 | var $icons = array( |
---|
73 | 'type' => array( |
---|
74 | 'task' => 'task.png', 'task_alt' => 'Task', |
---|
75 | 'phone' => 'phone.gpng', 'phone_alt' => 'Phonecall', |
---|
76 | 'note' => 'note.png', 'note_alt' => 'Note', |
---|
77 | 'confirm' => 'confirm.png', 'confirm_alt' => 'Confirmation', |
---|
78 | 'reject' => 'reject.png', 'reject_alt' => 'Reject', |
---|
79 | 'email' => 'email.png', 'email_alt' => 'Email' ), |
---|
80 | 'action' => array( |
---|
81 | 'new' => 'new.png', 'new_alt' => 'Add Sub', |
---|
82 | 'view' => 'view.png', 'view_alt' => 'View Subs', |
---|
83 | 'parent' => 'parent.png', 'parent_alt' => 'View other Subs', |
---|
84 | 'edit' => 'edit.png', 'edit_alt' => 'Edit', |
---|
85 | 'addfile' => 'addfile.png', 'addfile_alt' => 'Add a file', |
---|
86 | 'delete' => 'delete.png', 'delete_alt' => 'Delete', |
---|
87 | 'close' => 'done.png', 'close_alt' => 'Close' ), |
---|
88 | 'status' => array( |
---|
89 | 'billed' => 'billed.png', 'billed_alt' => 'billed', |
---|
90 | 'done' => 'done.png', 'done_alt' => 'done', |
---|
91 | 'will-call' => 'will-call.png', 'will-call_alt' => 'will-call', |
---|
92 | 'call' => 'call.png', 'call_alt' => 'call', |
---|
93 | 'ongoing' => 'ongoing.png', 'ongoing_alt' => 'ongoing', |
---|
94 | 'offer' => 'offer.png', 'offer_alt' => 'offer' ) |
---|
95 | ); |
---|
96 | var $filters = array( |
---|
97 | 'none' => 'no Filter', |
---|
98 | 'done' => 'done', |
---|
99 | 'responsible' => 'responsible', |
---|
100 | 'responsible-open-today' => 'responsible open', |
---|
101 | 'responsible-open-overdue' => 'responsible overdue', |
---|
102 | 'responsible-upcoming' => 'responsible upcoming', |
---|
103 | 'delegated' => 'delegated', |
---|
104 | 'delegated-open-today' => 'delegated open', |
---|
105 | 'delegated-open-overdue' => 'delegated overdue', |
---|
106 | 'delegated-upcoming' => 'delegated upcomming', |
---|
107 | 'own' => 'own', |
---|
108 | 'own-open-today' => 'own open', |
---|
109 | 'own-open-overdue' => 'own overdue', |
---|
110 | 'own-upcoming' => 'own upcoming', |
---|
111 | 'open-today' => 'open', |
---|
112 | 'open-overdue' => 'overdue', |
---|
113 | 'upcoming' => 'upcoming', |
---|
114 | ); |
---|
115 | var $messages = array( |
---|
116 | 'edit' => 'timesheet - Edit', |
---|
117 | 'add' => 'timesheet - New', |
---|
118 | 'add_sub' => 'timesheet - New Subproject', |
---|
119 | 'sp' => '- Subprojects from', |
---|
120 | 're' => 'Re:' |
---|
121 | ); |
---|
122 | |
---|
123 | |
---|
124 | var $optionldap; |
---|
125 | |
---|
126 | /** |
---|
127 | * Constructor |
---|
128 | * |
---|
129 | * @return uitimesheet |
---|
130 | */ |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | function uitimesheet() |
---|
135 | { |
---|
136 | |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | //print_r($GLOBALS); |
---|
143 | |
---|
144 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
145 | $this->bo = CreateObject('timesheet.botimesheet',1); |
---|
146 | $this->cat = &$this->bo->cat; |
---|
147 | //echo "pwnre".$this->bo->owner." ".$this->bo->today." ".$this->bo->evento; |
---|
148 | $this->dbb = CreateObject('class.DBAccess',1); |
---|
149 | $this->cat = &$this->bo->cat; |
---|
150 | |
---|
151 | |
---|
152 | $this->resources = &$this->bo->resources; |
---|
153 | |
---|
154 | $this->project = &$this->bo->project; |
---|
155 | |
---|
156 | $this->tarea = &$this->bo->tarea; |
---|
157 | |
---|
158 | print_debug('BO Owner',$this->bo->owner); |
---|
159 | |
---|
160 | $this->template = $GLOBALS['phpgw']->template; |
---|
161 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('timesheet'); |
---|
162 | |
---|
163 | $this->cat_id = $this->bo->cat_id; |
---|
164 | |
---|
165 | $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
166 | $this->link_tpl->set_unknowns('remove'); |
---|
167 | $this->link_tpl->set_file( |
---|
168 | Array( |
---|
169 | 'link_picture' => 'link_pict.tpl' |
---|
170 | ) |
---|
171 | ); |
---|
172 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
173 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
174 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
175 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
176 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
177 | |
---|
178 | |
---|
179 | |
---|
180 | $this->ds = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
181 | if(!$this->ds) |
---|
182 | $this->ds = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
183 | if(!@is_object($GLOBALS['phpgw']->translation)) |
---|
184 | { |
---|
185 | $GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation'); |
---|
186 | } |
---|
187 | $this->user_context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
188 | $this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context']; |
---|
189 | |
---|
190 | /*************************************************/ |
---|
191 | |
---|
192 | $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; |
---|
193 | |
---|
194 | //print_debug('UI',$this->_debug_sqsof()); |
---|
195 | |
---|
196 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
197 | { |
---|
198 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
199 | } |
---|
200 | $this->html = &$GLOBALS['phpgw']->html; |
---|
201 | } |
---|
202 | |
---|
203 | /* Public functions */ |
---|
204 | |
---|
205 | |
---|
206 | |
---|
207 | function index($params='') |
---|
208 | |
---|
209 | { |
---|
210 | |
---|
211 | if (!$params) |
---|
212 | { |
---|
213 | foreach(array('date','year','month','day') as $field) |
---|
214 | { |
---|
215 | if (isset($_GET[$field])) |
---|
216 | { |
---|
217 | $params[$field] = $_REQUEST[$field]; |
---|
218 | } |
---|
219 | } |
---|
220 | } |
---|
221 | //$todos = $this->get_todos($todo_label); |
---|
222 | |
---|
223 | $GLOBALS['phpgw']->redirect($this->page('search',$params)); |
---|
224 | |
---|
225 | } |
---|
226 | |
---|
227 | |
---|
228 | |
---|
229 | function page($_page='',$params='') |
---|
230 | { |
---|
231 | if($_page == '') |
---|
232 | { |
---|
233 | $page_ = explode('.',$this->bo->prefs['timesheet']['defaulttimesheet']); |
---|
234 | $_page = $page_[0]; |
---|
235 | |
---|
236 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
237 | { |
---|
238 | $_page = 'month'; |
---|
239 | } |
---|
240 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
241 | { |
---|
242 | $_page = 'month'; |
---|
243 | $GLOBALS['phpgw']->preferences->add('timesheet','defaulttimesheet','month'); |
---|
244 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
245 | } |
---|
246 | } |
---|
247 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
248 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
249 | { |
---|
250 | $page_app = 'timesheet'; |
---|
251 | } |
---|
252 | else |
---|
253 | { |
---|
254 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
255 | } |
---|
256 | if (is_array($params)) |
---|
257 | { |
---|
258 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
259 | } |
---|
260 | else |
---|
261 | { |
---|
262 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
263 | } |
---|
264 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
265 | } |
---|
266 | |
---|
267 | |
---|
268 | |
---|
269 | // NDEE: printer-friendly |
---|
270 | function printer_friendly($body,$app_header='') |
---|
271 | { |
---|
272 | $_SESSION['timesheet']['category'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); |
---|
273 | $_SESSION['timesheet']['resources'] = $this->resources->formated_list('select','all',$this->bo->resources_id,'True'); |
---|
274 | if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) |
---|
275 | $_SESSION['timesheet']['cals'] = $this->bo->list_cals(); |
---|
276 | |
---|
277 | |
---|
278 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
279 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
280 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
281 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
282 | if ($app_header && $this->always_app_header) |
---|
283 | { |
---|
284 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['timesheet']['title'].' - '.$app_header; |
---|
285 | } |
---|
286 | |
---|
287 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
288 | |
---|
289 | return $new_body; |
---|
290 | } |
---|
291 | |
---|
292 | |
---|
293 | |
---|
294 | |
---|
295 | |
---|
296 | |
---|
297 | |
---|
298 | function header() |
---|
299 | { |
---|
300 | $cols = 8; |
---|
301 | if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) |
---|
302 | { |
---|
303 | $cols++; |
---|
304 | } |
---|
305 | |
---|
306 | $tpl = $GLOBALS['phpgw']->template; |
---|
307 | $tpl->set_unknowns('remove'); |
---|
308 | |
---|
309 | if (!file_exists($file = $this->template_dir.'/header.inc.php')) |
---|
310 | { |
---|
311 | $file = PHPGW_SERVER_ROOT . '/timesheet/templates/default/header.inc.php'; |
---|
312 | } |
---|
313 | |
---|
314 | include($file); |
---|
315 | $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); |
---|
316 | if($refer[2] != 'view') { |
---|
317 | $header = $tpl->fp('out','head'); |
---|
318 | unset($tpl); |
---|
319 | echo $header; |
---|
320 | } |
---|
321 | unset($tpl); |
---|
322 | } |
---|
323 | |
---|
324 | function footer() |
---|
325 | { |
---|
326 | $menuaction = $_GET['menuaction']; |
---|
327 | list(,,$method) = explode('.',$menuaction); |
---|
328 | |
---|
329 | if (@$this->bo->printer_friendly) |
---|
330 | { |
---|
331 | return; |
---|
332 | } |
---|
333 | |
---|
334 | $p = $GLOBALS['phpgw']->template; |
---|
335 | |
---|
336 | $p->set_file( |
---|
337 | Array( |
---|
338 | 'footer' => 'footer.tpl', |
---|
339 | 'form_button' => 'form_button_script.tpl' |
---|
340 | ) |
---|
341 | ); |
---|
342 | $p->set_block('footer','footer_table','footer_table'); |
---|
343 | $p->set_block('footer','footer_row','footer_row'); |
---|
344 | $p->set_block('footer','blank_row','blank_row'); |
---|
345 | $p->set_block('footer','num_dias','num_dias'); |
---|
346 | |
---|
347 | $m = $this->bo->month; |
---|
348 | $y = $this->bo->year; |
---|
349 | |
---|
350 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
351 | $mes_hoje = (int)substr($hoje,4,2); |
---|
352 | $mes_footer = (int)substr($_POST['date'],4,2); |
---|
353 | if($_GET['sday']) |
---|
354 | { |
---|
355 | if($_GET['month'] == $mes_hoje) |
---|
356 | { |
---|
357 | $day = $this->bo->day; |
---|
358 | } |
---|
359 | else |
---|
360 | { |
---|
361 | $day = $_GET['sday']; |
---|
362 | } |
---|
363 | } |
---|
364 | else |
---|
365 | { |
---|
366 | $day = $this->bo->day; |
---|
367 | $dia_ini = $day; |
---|
368 | } |
---|
369 | if($mes_footer == $mes_hoje) |
---|
370 | { |
---|
371 | $dia_ini = (int)substr($hoje,6,2); |
---|
372 | $day = $dia_ini; |
---|
373 | } |
---|
374 | |
---|
375 | /********************************************************************************************/ |
---|
376 | |
---|
377 | } |
---|
378 | |
---|
379 | |
---|
380 | |
---|
381 | |
---|
382 | |
---|
383 | |
---|
384 | /****************************************************************************************/ |
---|
385 | |
---|
386 | |
---|
387 | function edit($cd=0,$readsess=0) |
---|
388 | { |
---|
389 | |
---|
390 | $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
391 | |
---|
392 | |
---|
393 | |
---|
394 | |
---|
395 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
396 | { |
---|
397 | $this->index(); |
---|
398 | } |
---|
399 | |
---|
400 | if($readsess) |
---|
401 | { |
---|
402 | |
---|
403 | $event = $this->bo->restore_from_appsession; |
---|
404 | if(!$event['owner']) |
---|
405 | { |
---|
406 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
407 | } |
---|
408 | $can_edit = True; |
---|
409 | } |
---|
410 | else |
---|
411 | { |
---|
412 | |
---|
413 | |
---|
414 | $this->bo->event_init(); |
---|
415 | $this->bo->add_attribute('id',0); |
---|
416 | |
---|
417 | $can_edit = True; |
---|
418 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
419 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['timesheet']['workdaystarts'])); |
---|
420 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
421 | $endmin = $startmin + (int)$this->bo->prefs['timesheet']['defaultlength']; |
---|
422 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
423 | |
---|
424 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
425 | if ($subject != '0') |
---|
426 | { |
---|
427 | $description = (string)(get_var('description',array('GET'),0)); |
---|
428 | $description1 = (string)(get_var('description1',array('GET'),0)); |
---|
429 | $location = (string)(get_var('location',array('GET'),0)); |
---|
430 | } |
---|
431 | else |
---|
432 | unset($subject); |
---|
433 | |
---|
434 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
435 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
436 | |
---|
437 | //echo "kkkk".$this->bo->year; |
---|
438 | if(@$this->bo->prefs['timesheet']['default_private']) |
---|
439 | { |
---|
440 | $this->bo->set_class(False); |
---|
441 | } |
---|
442 | else |
---|
443 | { |
---|
444 | $this->bo->set_class(True); |
---|
445 | } |
---|
446 | |
---|
447 | $event = $this->bo->restore_from_appsession; |
---|
448 | |
---|
449 | } |
---|
450 | if(isset($_REQUEST['error'])){ |
---|
451 | $cd=$_REQUEST['error']; |
---|
452 | } |
---|
453 | $this->edit_form( |
---|
454 | Array( |
---|
455 | 'event' => $event, |
---|
456 | 'cd' => $cd, |
---|
457 | 'plain' => $_GET['plain'] |
---|
458 | ) |
---|
459 | ); |
---|
460 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
461 | } |
---|
462 | |
---|
463 | |
---|
464 | function edit_form($param) |
---|
465 | { |
---|
466 | |
---|
467 | |
---|
468 | if(isset($_REQUEST['id'])){ |
---|
469 | $event=$this->select($_REQUEST['id']); |
---|
470 | }else{ |
---|
471 | $event=$this->select_init(); |
---|
472 | } |
---|
473 | |
---|
474 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
475 | |
---|
476 | |
---|
477 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
478 | |
---|
479 | |
---|
480 | |
---|
481 | |
---|
482 | |
---|
483 | |
---|
484 | |
---|
485 | |
---|
486 | if(!is_array($param)) |
---|
487 | { |
---|
488 | $this->index(); |
---|
489 | } |
---|
490 | |
---|
491 | if(isset($param['event'])) |
---|
492 | { |
---|
493 | $event = $param['event']; |
---|
494 | } |
---|
495 | |
---|
496 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
497 | |
---|
498 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
499 | |
---|
500 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
501 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
502 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
503 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
504 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding timesheet'); |
---|
505 | if ($param['plain'] != "True"){ |
---|
506 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
507 | } |
---|
508 | else{ |
---|
509 | $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; |
---|
510 | $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; |
---|
511 | } |
---|
512 | |
---|
513 | $p = &$GLOBALS['phpgw']->template; |
---|
514 | $p->set_file( |
---|
515 | Array( |
---|
516 | 'edit' => 'edit.tpl', |
---|
517 | 'form_button' => 'form_button_script.tpl' |
---|
518 | ) |
---|
519 | ); |
---|
520 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
521 | $p->set_block('edit','list','list'); |
---|
522 | $p->set_block('edit','hr','hr'); |
---|
523 | |
---|
524 | $vars = Array( |
---|
525 | 'font' => $this->theme['font'], |
---|
526 | 'bg_color' => $this->theme['bg_text'], |
---|
527 | 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'timesheet.uitimesheet.update')), |
---|
528 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=timesheet.uitimesheet.accounts_popup'), |
---|
529 | 'common_hidden' => '<input type="hidden" name="timesheet[id]" value="'.$event['id'].'">'."\n". |
---|
530 | '<input type="hidden" name="timesheet[parent]" value="'.$event['parent'].'">'."\n" |
---|
531 | .'<input type="hidden" name="timesheet[infolog]" value="'.$event['infolog'].'">'."\n" |
---|
532 | .'<input type="hidden" name="timesheet[project]" value="'.$event['project'].'">'."\n" |
---|
533 | .'<input type="hidden" name="timesheet[tracker]" value="'.$event['tracker'].'">'."\n" |
---|
534 | . '<input type="hidden" name="timesheet[owner]" value="'.$event['owner'].'">'."\n" |
---|
535 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
536 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
537 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') |
---|
538 | ); |
---|
539 | |
---|
540 | $p->set_var($vars); |
---|
541 | |
---|
542 | // ts_type |
---|
543 | //echo $event['type']; |
---|
544 | |
---|
545 | |
---|
546 | // Display Categories |
---|
547 | if(strpos($event['category'],',')) |
---|
548 | { |
---|
549 | $temp_cats = explode(',',$event['category']); |
---|
550 | @reset($temp_cats); |
---|
551 | while(list($key,$value) = each($temp_cats)) |
---|
552 | { |
---|
553 | $check_cats[] = (int)$value; |
---|
554 | } |
---|
555 | } |
---|
556 | elseif($event['category']) |
---|
557 | { |
---|
558 | $check_cats[] = (int)$event['category']; |
---|
559 | } |
---|
560 | else |
---|
561 | { |
---|
562 | $check_cats[] = 0; |
---|
563 | } |
---|
564 | $var['category'] = Array( |
---|
565 | 'field' => lang('Category'), |
---|
566 | 'data' => '<select name="timesheet[category]" onchange="javascript:updateTitleField(this)" >'.$this->cat->formated_list('select','all',$check_cats,True).'</select>' |
---|
567 | ); |
---|
568 | |
---|
569 | |
---|
570 | // Display proyectos |
---|
571 | // Location |
---|
572 | |
---|
573 | |
---|
574 | |
---|
575 | // |
---|
576 | /* if(strpos($event['project'],',')) |
---|
577 | { |
---|
578 | $temp_cats = explode(',',$event['project']); |
---|
579 | @reset($temp_cats); |
---|
580 | while(list($key,$value) = each($temp_cats)) |
---|
581 | { |
---|
582 | $check_cats[] = (int)$value; |
---|
583 | } |
---|
584 | } |
---|
585 | elseif($event['project']) |
---|
586 | { |
---|
587 | $check_cats[] = (int)$event['project']; |
---|
588 | } |
---|
589 | else |
---|
590 | { |
---|
591 | $check_cats[] = 0; |
---|
592 | } |
---|
593 | $var['project'] = Array( |
---|
594 | 'field' => lang('project'), |
---|
595 | 'data' => '<select name="timesheet[project]" onchange="javascript:updateTitleField(this)" >'.$this->project->formated_list('select','name,name','',True).'</select>' |
---|
596 | );*/ |
---|
597 | |
---|
598 | |
---|
599 | // Display tarea |
---|
600 | // Location |
---|
601 | |
---|
602 | |
---|
603 | |
---|
604 | // |
---|
605 | /* if(strpos($event['tarea'],',')) |
---|
606 | { |
---|
607 | $temp_cats = explode(',',$event['tarea']); |
---|
608 | @reset($temp_cats); |
---|
609 | while(list($key,$value) = each($temp_cats)) |
---|
610 | { |
---|
611 | $check_cats[] = (int)$value; |
---|
612 | } |
---|
613 | } |
---|
614 | elseif($event['tarea']) |
---|
615 | { |
---|
616 | $check_cats[] = (int)$event['tarea']; |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | $check_cats[] = 0; |
---|
621 | } |
---|
622 | $var['tarea'] = Array( |
---|
623 | 'field' => lang('tarea'), |
---|
624 | 'data' => '<select name="timesheet[tarea]" onchange="javascript:updateTitleField(this)" >'.$this->tarea->formated_list('select','name,name','',True).'</select>' |
---|
625 | );*/ |
---|
626 | |
---|
627 | |
---|
628 | |
---|
629 | |
---|
630 | |
---|
631 | |
---|
632 | // asunto |
---|
633 | $var['title'] = Array( |
---|
634 | 'field' => lang('title'), |
---|
635 | 'data' => '<input type="text" name="timesheet[title]" maxlength="255" value="'.$event['title'].'">' |
---|
636 | ); |
---|
637 | |
---|
638 | |
---|
639 | |
---|
640 | |
---|
641 | // Full Description |
---|
642 | $var['description'] = Array( |
---|
643 | 'field' => lang('Description'), |
---|
644 | 'data' => '<textarea name="timesheet[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['descripcion'].'</textarea>' |
---|
645 | ); |
---|
646 | |
---|
647 | |
---|
648 | |
---|
649 | |
---|
650 | $valorfechainicio=$this->bo->time2array($event['fechainicio'],$alarm = 0); |
---|
651 | $start=$valorfechainicio['mday']."/".$valorfechainicio['month']."/".$valorfechainicio['year']; |
---|
652 | $var['startdate'] = Array( |
---|
653 | 'field' => lang('Start Date'), |
---|
654 | |
---|
655 | 'data' => $jscal->input('start[str]',$start) |
---|
656 | ); |
---|
657 | |
---|
658 | // Time |
---|
659 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
660 | { |
---|
661 | $stra .= '<input type="radio" name="start[ampm]" value="am"'.($valorfechainicio['hourcompleta'] >= 12?'':' checked').'>am'."\n" |
---|
662 | . '<input type="radio" name="start[ampm]" value="pm"'.($valorfechainicio['hourcompleta'] >= 12?' checked':'').'>pm'."\n"; |
---|
663 | } |
---|
664 | $var['starttime'] = Array( |
---|
665 | 'field' => lang('Start Time'), |
---|
666 | 'data' => '<input name="start[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($event['fechainicio'],$hourformat).'" maxlength="2">:<input name="start[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$stra |
---|
667 | ); |
---|
668 | |
---|
669 | // End Date |
---|
670 | //$end = $this->bo->maketime($event['fechafin']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
671 | |
---|
672 | |
---|
673 | |
---|
674 | $eee=$this->bo->maketime($GLOBALS['phpgw']->datetime->users_localtime); |
---|
675 | $valorfechaend=$this->bo->time2array($eee,$alarm = 0); |
---|
676 | |
---|
677 | //echo $valorfechaend['month']."rrr ".$event['fechafin']." ".$eee; |
---|
678 | $valorfechaend=$this->bo->time2array($event['fechafin'],$alarm = 0); |
---|
679 | $end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year']; |
---|
680 | |
---|
681 | |
---|
682 | |
---|
683 | |
---|
684 | |
---|
685 | $var['enddate'] = Array( |
---|
686 | 'field' => lang('End Date'), |
---|
687 | 'data' => $jscal->input('end[str]',$end) |
---|
688 | ); |
---|
689 | |
---|
690 | // End Time |
---|
691 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
692 | { |
---|
693 | $strb = '<input type="radio" name="end[ampm]" value="am"'.($valorfechaend['hourcompleta'] >= 12?'':' checked').'>am'."\n" |
---|
694 | . '<input type="radio" name="end[ampm]" value="pm"'.($valorfechaend['hourcompleta'] >= 12?' checked':'').'>pm'."\n"; |
---|
695 | } |
---|
696 | $var['endtime'] = Array( |
---|
697 | 'field' => lang('End Time'), |
---|
698 | 'data' => '<input name="end[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($event['fechafin'],$hourformat).'" maxlength="2">:<input name="end[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$strb |
---|
699 | ); |
---|
700 | |
---|
701 | |
---|
702 | |
---|
703 | |
---|
704 | |
---|
705 | |
---|
706 | /*********************************************************************/ |
---|
707 | |
---|
708 | |
---|
709 | |
---|
710 | |
---|
711 | |
---|
712 | |
---|
713 | // $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); |
---|
714 | |
---|
715 | if (!isset($this->fields)) |
---|
716 | { |
---|
717 | $this->custom_fields = CreateObject('timesheet.bocustom_fields'); |
---|
718 | $this->fields = &$this->custom_fields->fields; |
---|
719 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
720 | } |
---|
721 | // $this->output_template_array($p,'row','list',$var['access']); |
---|
722 | unset($var['access']); |
---|
723 | |
---|
724 | $preserved = False; |
---|
725 | foreach($this->fields as $field => $data) |
---|
726 | { |
---|
727 | |
---|
728 | if (!$data['disabled']) |
---|
729 | { |
---|
730 | |
---|
731 | |
---|
732 | if (isset($var[$field])) |
---|
733 | { |
---|
734 | |
---|
735 | |
---|
736 | switch($field) |
---|
737 | { |
---|
738 | case 'startdate': |
---|
739 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
740 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
741 | break; |
---|
742 | case 'enddate': |
---|
743 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
744 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
745 | break; |
---|
746 | case 'recure_type': |
---|
747 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
748 | $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>'); |
---|
749 | $p->parse('row','hr',True); |
---|
750 | $this->output_template_array($p,'row','list',$var['recure_type']); |
---|
751 | $this->output_template_array($p,'row','list',$var['recure_enddate']); |
---|
752 | $this->output_template_array($p,'row','list',$var['recure_day']); |
---|
753 | $this->output_template_array($p,'row','list',$var['recure_interval']); |
---|
754 | break; |
---|
755 | default: |
---|
756 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
757 | |
---|
758 | } |
---|
759 | } |
---|
760 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
761 | { |
---|
762 | |
---|
763 | |
---|
764 | $lang = lang($name = substr($field,1)); |
---|
765 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
766 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
767 | $v = array( |
---|
768 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
769 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
770 | ); |
---|
771 | if ($data['title']) |
---|
772 | { |
---|
773 | $v['tr_color'] = $this->theme['th_bg']; |
---|
774 | } |
---|
775 | if (!$data['length'] && $data['title']) |
---|
776 | { |
---|
777 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
778 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
779 | $p->parse('row','hr',True); |
---|
780 | } |
---|
781 | else |
---|
782 | { |
---|
783 | $this->output_template_array($p,'row','list',$v); |
---|
784 | } |
---|
785 | } |
---|
786 | } |
---|
787 | else // preserve disabled fields |
---|
788 | { |
---|
789 | |
---|
790 | |
---|
791 | switch ($field) |
---|
792 | { |
---|
793 | case 'owner': |
---|
794 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
795 | break; |
---|
796 | case 'recure_type': |
---|
797 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
798 | { |
---|
799 | $preserved[$field] = $event[$field]; |
---|
800 | } |
---|
801 | break; |
---|
802 | case 'startdate': |
---|
803 | case 'enddate': |
---|
804 | $field = substr($field,0,-4); |
---|
805 | default: |
---|
806 | $preserved[$field] = $event[$field]; |
---|
807 | } |
---|
808 | } |
---|
809 | } |
---|
810 | unset($var); |
---|
811 | if (is_array($preserved)) |
---|
812 | { |
---|
813 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
814 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
815 | } |
---|
816 | $p->set_var('submit_button',lang('Save')); |
---|
817 | |
---|
818 | $delete_button = $cancel_button = ''; |
---|
819 | if ($event['id'] > 0) |
---|
820 | { |
---|
821 | $var = Array( |
---|
822 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
823 | 'action_text_button' => lang('Delete'), |
---|
824 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
825 | 'action_extra_field' => '', |
---|
826 | 'button_id' => 'delete_button' |
---|
827 | ); |
---|
828 | $p->set_var($var); |
---|
829 | $delete_button = $p->fp('out','form_button'); |
---|
830 | } |
---|
831 | $p->set_var('delete_button',$delete_button); |
---|
832 | $p->set_var('alert_msg',lang('Required field (category) is empty')); |
---|
833 | |
---|
834 | if ($this->bo->return_to) |
---|
835 | { |
---|
836 | $var = Array( |
---|
837 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
838 | 'action_text_button' => lang('Cancel'), |
---|
839 | 'action_confirm_button' => '', |
---|
840 | 'action_extra_field' => '', |
---|
841 | 'button_id' => 'cancel_button' |
---|
842 | ); |
---|
843 | $p->set_var($var); |
---|
844 | $cancel_button = $p->fp('out','form_button'); |
---|
845 | } |
---|
846 | $p->set_var('cancel_button',$cancel_button); |
---|
847 | $p->pparse('out','edit_entry'); |
---|
848 | } |
---|
849 | |
---|
850 | function output_template_array(&$p,$row,$list,$var) |
---|
851 | { |
---|
852 | if (!isset($var['hidden_vars'])) |
---|
853 | { |
---|
854 | $var['hidden_vars'] = ''; |
---|
855 | } |
---|
856 | if (!isset($var['tr_color'])) |
---|
857 | { |
---|
858 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
859 | } |
---|
860 | $p->set_var($var); |
---|
861 | $p->parse($row,$list,True); |
---|
862 | } |
---|
863 | |
---|
864 | |
---|
865 | function get_organizations($context, $selected='', $recursive = false) |
---|
866 | { |
---|
867 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
868 | |
---|
869 | return ($recursive ? |
---|
870 | $s->get_organizations($context, $selected, false ,true) : |
---|
871 | $s->get_sectors($selected, false, false)); |
---|
872 | } |
---|
873 | |
---|
874 | |
---|
875 | |
---|
876 | |
---|
877 | /**********************************************/ |
---|
878 | |
---|
879 | |
---|
880 | function _debug_sqsof() |
---|
881 | { |
---|
882 | $data = array( |
---|
883 | 'filter' => $this->bo->filter, |
---|
884 | 'cat_id' => $this->bo->cat_id, |
---|
885 | 'owner' => $this->bo->owner, |
---|
886 | 'year' => $this->bo->year, |
---|
887 | 'month' => $this->bo->month, |
---|
888 | 'day' => $this->bo->day, |
---|
889 | 'sortby' => $this->bo->sortby, |
---|
890 | 'num_months' => $this->bo->num_months |
---|
891 | ); |
---|
892 | Return _debug_array($data,False); |
---|
893 | } |
---|
894 | |
---|
895 | |
---|
896 | |
---|
897 | |
---|
898 | /***********************************/ |
---|
899 | |
---|
900 | |
---|
901 | |
---|
902 | |
---|
903 | function search() |
---|
904 | { |
---|
905 | |
---|
906 | //print_r($_REQUEST); |
---|
907 | |
---|
908 | |
---|
909 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
910 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
911 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['timesheet']['title'].' - '.lang('Search Results'); |
---|
912 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
913 | |
---|
914 | $error = ''; |
---|
915 | |
---|
916 | $matches = 0; |
---|
917 | |
---|
918 | //$event = $this->bo->read_entry($ts_id); |
---|
919 | $event = $this->get_event_ids($adicional); |
---|
920 | |
---|
921 | |
---|
922 | //$event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
923 | |
---|
924 | |
---|
925 | $matches = count($event); |
---|
926 | |
---|
927 | //echo "matches" . $matches; |
---|
928 | |
---|
929 | if ($matches == 1) |
---|
930 | { |
---|
931 | $quantity = lang('1 match found').'.'; |
---|
932 | } |
---|
933 | elseif ($matches > 0) |
---|
934 | { |
---|
935 | $quantity = lang('%1 matches found',$matches).'.'; |
---|
936 | } |
---|
937 | else |
---|
938 | { |
---|
939 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
940 | return; |
---|
941 | } |
---|
942 | |
---|
943 | $p = $GLOBALS['phpgw']->template; |
---|
944 | $p->set_file( |
---|
945 | Array( |
---|
946 | 'search_form' => 'search.tpl' |
---|
947 | ) |
---|
948 | ); |
---|
949 | $p->set_block('search_form','search','search'); |
---|
950 | $p->set_block('search_form','search_list_header','search_list_header'); |
---|
951 | $p->set_block('search_form','search_list','search_list'); |
---|
952 | $p->set_block('search_form','search_list_footer','search_list_footer'); |
---|
953 | |
---|
954 | |
---|
955 | $script=''; |
---|
956 | |
---|
957 | |
---|
958 | |
---|
959 | if($matches > 0) |
---|
960 | { |
---|
961 | $p->parse('rows','search_list_header',True); |
---|
962 | } |
---|
963 | |
---|
964 | //if($info){ |
---|
965 | foreach($event as $id => $data) |
---|
966 | { |
---|
967 | |
---|
968 | |
---|
969 | $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
970 | |
---|
971 | |
---|
972 | |
---|
973 | |
---|
974 | $info = array( |
---|
975 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
976 | 'date' => $GLOBALS['phpgw']->common->show_date($datetime), |
---|
977 | |
---|
978 | |
---|
979 | 'id' => $data['id'], |
---|
980 | 'proyecto' => $data['proyecto'], |
---|
981 | 'title' => $data['title'], |
---|
982 | 'descripcion' => $data['descripcion'], |
---|
983 | 'fechainicio' => $data['fechainicio'], |
---|
984 | 'fechafin' => $data['fechafin'], |
---|
985 | 'fechamodif' => $data['fechamodif'], |
---|
986 | 'category' =>$data['category'], |
---|
987 | |
---|
988 | 'actualizo' => $data['actualizo'], |
---|
989 | 'owner' => $data['owner'], |
---|
990 | 'ownername' => $data['ownername'], |
---|
991 | 'infolog' => $data['infolog'], |
---|
992 | 'tracker' => $data['tracker'], |
---|
993 | |
---|
994 | |
---|
995 | 'accionagregar' =>'index.php?menuaction=timesheet.uitimesheet.edit&parent='. $data['id'], |
---|
996 | 'accionmodificar' =>'index.php?menuaction=timesheet.uitimesheet.edit&id='. $data['id'], |
---|
997 | 'accioneditar' =>'', |
---|
998 | 'accionagregartimet'=>'', |
---|
999 | 'accionborrar' => $data['id'] |
---|
1000 | ); |
---|
1001 | |
---|
1002 | |
---|
1003 | |
---|
1004 | //'accionagregar' =>'index.php?menuaction=timesheet.uitimesheet.edit&parent='. $data['id'] |
---|
1005 | $p->set_var($info); |
---|
1006 | $p->set_var($data); |
---|
1007 | $p->parse('rows','search_list',True); |
---|
1008 | } |
---|
1009 | // } |
---|
1010 | if($matches > 0) |
---|
1011 | { |
---|
1012 | $p->parse('rows','search_list_footer',True); |
---|
1013 | } |
---|
1014 | |
---|
1015 | $p->pparse('out','search'); |
---|
1016 | } |
---|
1017 | |
---|
1018 | |
---|
1019 | function get_event_ids($search) |
---|
1020 | { |
---|
1021 | //echo "tamannn".count($search)." ".$search[0]; |
---|
1022 | |
---|
1023 | $from =""; |
---|
1024 | //if (isset($_REQUEST['id'])){ |
---|
1025 | |
---|
1026 | // $from = ' and t1.ts_id='.$_REQUEST['id']; |
---|
1027 | // } |
---|
1028 | |
---|
1029 | $sql = 'select t1.* from phpgw_timesheet t1 where ts_owner='.$this->bo->owner |
---|
1030 | . $from; |
---|
1031 | //.$search; |
---|
1032 | //. 'WHERE (phpgw_cal_user.ts_id = phpgw_cal.ts_id) ' |
---|
1033 | //. $where . $extra; |
---|
1034 | |
---|
1035 | |
---|
1036 | //echo "FULL SQL : ".$sql."<br>\n"; |
---|
1037 | |
---|
1038 | |
---|
1039 | if($this->debug) |
---|
1040 | { |
---|
1041 | echo "FULL SQL : ".$sql."<br>\n"; |
---|
1042 | } |
---|
1043 | |
---|
1044 | //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar"); |
---|
1045 | |
---|
1046 | |
---|
1047 | $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); |
---|
1048 | while( $GLOBALS['phpgw']->db->next_record() ) |
---|
1049 | { |
---|
1050 | // |
---|
1051 | |
---|
1052 | $valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('ts_start'),$alarm = 0); |
---|
1053 | $ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year']; |
---|
1054 | |
---|
1055 | $valorfechaend=$this->bo->time2array($GLOBALS['phpgw']->db->f('ts_end'),$alarm = 0); |
---|
1056 | $end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year']; |
---|
1057 | |
---|
1058 | $valorfechaend2=$this->bo->time2array($GLOBALS['phpgw']->db->f('ts_modified'),$alarm = 0); |
---|
1059 | $end2=$valorfechaend2['mday']."/".$valorfechaend2['month']."/".$valorfechaend2['year']; |
---|
1060 | |
---|
1061 | $retval[] = array( |
---|
1062 | 'id' => $GLOBALS['phpgw']->db->f('ts_id'), |
---|
1063 | 'proyecto' => $GLOBALS['phpgw']->db->f('list_project'), |
---|
1064 | 'title' => $GLOBALS['phpgw']->db->f('ts_title'), |
---|
1065 | 'descripcion' => $GLOBALS['phpgw']->db->f('ts_description'), |
---|
1066 | 'fechainicio' => $ini, |
---|
1067 | 'fechafin' => $end, |
---|
1068 | 'fechamodif' => $end2, |
---|
1069 | 'category' =>$GLOBALS['phpgw']->db->f('ts_cat'), |
---|
1070 | |
---|
1071 | 'actualizo' => $GLOBALS['phpgw']->db->f('ts_modifier'), |
---|
1072 | 'owner' => $GLOBALS['phpgw']->db->f('ts_owner'), |
---|
1073 | 'infolog' => $GLOBALS['phpgw']->db->f('list_infolog'), |
---|
1074 | 'tracker' => $GLOBALS['phpgw']->db->f('list_tracker') |
---|
1075 | |
---|
1076 | |
---|
1077 | |
---|
1078 | ); |
---|
1079 | |
---|
1080 | |
---|
1081 | } |
---|
1082 | |
---|
1083 | |
---|
1084 | |
---|
1085 | |
---|
1086 | return $retval; |
---|
1087 | } |
---|
1088 | |
---|
1089 | |
---|
1090 | |
---|
1091 | |
---|
1092 | |
---|
1093 | |
---|
1094 | |
---|
1095 | |
---|
1096 | |
---|
1097 | |
---|
1098 | |
---|
1099 | function update() |
---|
1100 | { |
---|
1101 | |
---|
1102 | |
---|
1103 | |
---|
1104 | # $vars = get_defined_vars(); |
---|
1105 | # print_r($vars); |
---|
1106 | /*foreach($_POST as $k=>$v){ |
---|
1107 | $$k=$v; |
---|
1108 | echo $$k."<br>"; |
---|
1109 | } |
---|
1110 | foreach($_POST as $nombre_campo => $valor){ |
---|
1111 | $asignacion = "\$" . $nombre_campo . "='" . $valor . "';"; |
---|
1112 | echo $asignacion."<br>"; |
---|
1113 | } */ |
---|
1114 | |
---|
1115 | |
---|
1116 | |
---|
1117 | |
---|
1118 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1119 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1120 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['timesheet']['title'].' - '.lang('Search Results'); |
---|
1121 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1122 | |
---|
1123 | $error = ''; |
---|
1124 | |
---|
1125 | $matches = 0; |
---|
1126 | |
---|
1127 | |
---|
1128 | |
---|
1129 | |
---|
1130 | |
---|
1131 | list($dia,$mes,$ano)=split("/",$_POST['start']['str']); |
---|
1132 | |
---|
1133 | $starttime = $this->bo->maketime2($_POST['start']['hour'],$_POST['start']['min'],0,$dia,$mes,$ano,$_POST['start']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1134 | //echo $starttime; |
---|
1135 | |
---|
1136 | list($dia2,$mes2,$ano2)=split("/",$_POST['end']['str']); |
---|
1137 | |
---|
1138 | $endtime = $this->bo->maketime2($_POST['end']['hour'],$_POST['end']['min'],0,$dia2,$mes2,$ano2,$_POST['end']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1139 | //echo "gggg".$_POST['end2']['month']; |
---|
1140 | if($_POST['end2']['str']['month']>0){ |
---|
1141 | list($dia3,$mes3,$ano3)=split("/",$_POST['end2']['str']); |
---|
1142 | $endtime2 = $this->bo->maketime2($_POST['end2']['hour'],$_POST['end2']['min'],0,$dia3,$mes3,$ano3,$_POST['end2']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1143 | }else{ |
---|
1144 | $endtime2=0; |
---|
1145 | } |
---|
1146 | |
---|
1147 | //$starttime = $this->bo->maketime2($starthora,$startmin,0,$startfecha) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1148 | //echo "kkkk3".$_POST['exec']['accesso']; |
---|
1149 | if($_REQUEST['timesheet']['parent']==""){ |
---|
1150 | $parent=0; |
---|
1151 | |
---|
1152 | }else{ |
---|
1153 | $parent=$_REQUEST['timesheet']['parent']; |
---|
1154 | |
---|
1155 | } |
---|
1156 | |
---|
1157 | |
---|
1158 | |
---|
1159 | $valores="&title=".$_POST['timesheet']['title']."&description=".$_POST['timesheet']['description']."&category=".$_POST['timesheet']['category']."&project=".$_POST['project']."&infolog=".$_POST['infolog']."&tracker=".$_POST['tracker']; |
---|
1160 | |
---|
1161 | //$GLOBALS['phpgw']->redirect($this->page($valores,'')); |
---|
1162 | if($_POST['timesheet']['title']==""){ |
---|
1163 | $GLOBALS['phpgw']->redirect($this->page('edit&error=40'.$valores,'')); |
---|
1164 | |
---|
1165 | } |
---|
1166 | if($_POST['timesheet']['description']==""){ |
---|
1167 | $GLOBALS['phpgw']->redirect($this->page('edit&error=48'.$valores,'')); |
---|
1168 | } |
---|
1169 | |
---|
1170 | |
---|
1171 | |
---|
1172 | |
---|
1173 | |
---|
1174 | |
---|
1175 | // $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1176 | if(isset($_POST['timesheet']['id'])&&$_POST['timesheet']['id']>0){ |
---|
1177 | $sql = "update phpgw_timesheet set ts_project='".$_POST['timesheet']['project']."',ts_title='".$_POST['timesheet']['title']."',ts_description='".$_POST['timesheet']['description']."',ts_start=".$starttime." ,ts_end=".$endtime.",ts_cat='".$_POST['timesheet']['category']."' ,ts_modifier_name='".$this->get_account_name($_POST['timesheet']['owner'],"gecos")."',ts_modified=".$GLOBALS['phpgw']->datetime->users_localtime.",ts_modifier= ".$_POST['timesheet']['owner']." ,ts_owner_name='". $this->get_account_name($_POST['timesheet']['owner'],'gecos')."',ts_infolog='".$_POST['timesheet']['infolog']."',ts_tracker='".$_POST['timesheet']['tracker']."' where ts_id='".$_POST['timesheet']['id']."'"; |
---|
1178 | }else{ |
---|
1179 | $sql = "insert into phpgw_timesheet (ts_project,ts_title,ts_description,ts_start ,ts_end,ts_cat ,ts_owner,ts_modified,ts_modifier,ts_infolog,ts_tracker,ts_owner_name,ts_modifier_name) |
---|
1180 | values ('".$_POST['timesheet']['project']."','".$_POST['timesheet']['title']."','".$_POST['timesheet']['description']."',".$starttime.",".$endtime.",'".$_POST['timesheet']['category']."',".$_POST['timesheet']['owner'].",".$GLOBALS['phpgw']->datetime->users_localtime.",".$_POST['timesheet']['owner'].",'".$_POST['timesheet']['infolog']."','".$_POST['timesheet']['tracker']."','". $this->get_account_name($_POST['timesheet']['owner'],'gecos')."','".$this->get_account_name($_POST['timesheet']['owner'],"gecos")."')"; |
---|
1181 | |
---|
1182 | |
---|
1183 | |
---|
1184 | |
---|
1185 | } |
---|
1186 | |
---|
1187 | $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); |
---|
1188 | |
---|
1189 | |
---|
1190 | ExecMethod('timesheet.uitimesheet.index',$parms); |
---|
1191 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1192 | return ""; |
---|
1193 | } |
---|
1194 | |
---|
1195 | |
---|
1196 | |
---|
1197 | |
---|
1198 | function get_account_name($account_id,$valor) |
---|
1199 | { |
---|
1200 | $acct_type = $this->get_type($account_id); |
---|
1201 | |
---|
1202 | /* jakjr: using justthese with ldap_search */ |
---|
1203 | //$justthese = array("cn","uid","givenname","sn","gecos"); |
---|
1204 | |
---|
1205 | /* search the dn for the given uid */ |
---|
1206 | |
---|
1207 | $justthese = array("uidnumber", "cn", "mail","gecos","dn"); |
---|
1208 | // $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese); |
---|
1209 | |
---|
1210 | if(($acct_type == 'g') && $this->group_context) |
---|
1211 | { |
---|
1212 | $sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese); |
---|
1213 | } |
---|
1214 | else |
---|
1215 | { |
---|
1216 | $sri = @ldap_search($this->ds, $this->user_context, '(uidnumber=' . (int)$account_id . ')', $justthese); |
---|
1217 | } |
---|
1218 | |
---|
1219 | //echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese; |
---|
1220 | if(!$sri) |
---|
1221 | return False; |
---|
1222 | $allValues = ldap_get_entries($this->ds, $sri); |
---|
1223 | $retorna=""; |
---|
1224 | if($acct_type =='g') |
---|
1225 | { |
---|
1226 | if($valor=='gecos') { |
---|
1227 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8'); |
---|
1228 | } |
---|
1229 | if($valor=='uidnumber') { |
---|
1230 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8'); |
---|
1231 | } |
---|
1232 | if($valor=='cn') { |
---|
1233 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); |
---|
1234 | } |
---|
1235 | |
---|
1236 | if($valor=='mail') { |
---|
1237 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8'); |
---|
1238 | } |
---|
1239 | if($valor=='dn') { |
---|
1240 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8'); |
---|
1241 | } |
---|
1242 | |
---|
1243 | } |
---|
1244 | else |
---|
1245 | { |
---|
1246 | if($valor=='gecos') { |
---|
1247 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8'); |
---|
1248 | } |
---|
1249 | if($valor=='uidnumber') { |
---|
1250 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8'); |
---|
1251 | } |
---|
1252 | if($valor=='cn') { |
---|
1253 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); |
---|
1254 | } |
---|
1255 | |
---|
1256 | if($valor=='mail') { |
---|
1257 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8'); |
---|
1258 | } |
---|
1259 | if($valor=='dn') { |
---|
1260 | $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8'); |
---|
1261 | } |
---|
1262 | |
---|
1263 | |
---|
1264 | |
---|
1265 | |
---|
1266 | } |
---|
1267 | return $retorna; |
---|
1268 | } |
---|
1269 | |
---|
1270 | |
---|
1271 | |
---|
1272 | |
---|
1273 | |
---|
1274 | function get_type($account_id) |
---|
1275 | { |
---|
1276 | $allValues = array(); |
---|
1277 | /* jakjr: using justthese with ldap_search */ |
---|
1278 | $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype")); |
---|
1279 | if(!$sri) |
---|
1280 | return False; |
---|
1281 | $allValues = ldap_get_entries($this->ds, $sri); |
---|
1282 | |
---|
1283 | if ($allValues[0]['phpgwaccounttype'][0]) |
---|
1284 | { |
---|
1285 | return $allValues[0]['phpgwaccounttype'][0]; |
---|
1286 | } |
---|
1287 | |
---|
1288 | $allValues = array(); |
---|
1289 | /* jakjr: using justthese with ldap_search */ |
---|
1290 | $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype")); |
---|
1291 | if(!$sri) |
---|
1292 | return False; |
---|
1293 | $allValues = ldap_get_entries($this->ds, $sri); |
---|
1294 | |
---|
1295 | if ($allValues[0]['phpgwaccounttype'][0]) |
---|
1296 | { |
---|
1297 | return $allValues[0]['phpgwaccounttype'][0]; |
---|
1298 | } |
---|
1299 | return False; |
---|
1300 | } |
---|
1301 | |
---|
1302 | |
---|
1303 | |
---|
1304 | |
---|
1305 | |
---|
1306 | |
---|
1307 | |
---|
1308 | function select($id) |
---|
1309 | { |
---|
1310 | |
---|
1311 | |
---|
1312 | $sql = "select * from phpgw_timesheet where ts_id='".$id."'"; |
---|
1313 | |
---|
1314 | $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); |
---|
1315 | |
---|
1316 | if( $GLOBALS['phpgw']->db->next_record() ) |
---|
1317 | { |
---|
1318 | |
---|
1319 | |
---|
1320 | |
---|
1321 | $retval = array( |
---|
1322 | 'id' => $GLOBALS['phpgw']->db->f('ts_id'), |
---|
1323 | 'proyecto' => $GLOBALS['phpgw']->db->f('ts_project'), |
---|
1324 | 'title' => $GLOBALS['phpgw']->db->f('ts_title'), |
---|
1325 | 'descripcion' => $GLOBALS['phpgw']->db->f('ts_description'), |
---|
1326 | 'fechainicio' => $GLOBALS['phpgw']->db->f('ts_start'), |
---|
1327 | 'fechafin' => $GLOBALS['phpgw']->db->f('ts_end'), |
---|
1328 | 'fechamodif' => $GLOBALS['phpgw']->db->f('ts_modified'), |
---|
1329 | 'category' =>$GLOBALS['phpgw']->db->f('ts_cat'), |
---|
1330 | |
---|
1331 | 'actualizo' => $GLOBALS['phpgw']->db->f('ts_modifier'), |
---|
1332 | 'owner' => $GLOBALS['phpgw']->db->f('ts_owner'), |
---|
1333 | 'ownername' => $GLOBALS['phpgw']->db->f('ts_owner_name'), |
---|
1334 | 'infolog' => $GLOBALS['phpgw']->db->f('ts_infolog'), |
---|
1335 | 'tracker' => $GLOBALS['phpgw']->db->f('ts_tracker') |
---|
1336 | ); |
---|
1337 | |
---|
1338 | } |
---|
1339 | |
---|
1340 | //echo "iddd".$id." 56666 ".$retval['id']; |
---|
1341 | |
---|
1342 | |
---|
1343 | return $retval; |
---|
1344 | |
---|
1345 | } |
---|
1346 | |
---|
1347 | |
---|
1348 | function select_init() |
---|
1349 | { |
---|
1350 | $name=""; |
---|
1351 | if(isset($_REQUEST['title'])){ |
---|
1352 | $name=$_REQUEST['title']; |
---|
1353 | } |
---|
1354 | |
---|
1355 | |
---|
1356 | $description=""; |
---|
1357 | if(isset($_REQUEST['description'])){ |
---|
1358 | $description=$_REQUEST['description']; |
---|
1359 | } |
---|
1360 | |
---|
1361 | |
---|
1362 | $retval = array( |
---|
1363 | 'id' => 0, |
---|
1364 | 'proyecto' => $_REQUEST['project'], |
---|
1365 | 'asunto' => $name, |
---|
1366 | 'title' => $name, |
---|
1367 | 'descripcion' => $description, |
---|
1368 | 'fechainicio' => $GLOBALS['phpgw']->datetime->users_localtime, |
---|
1369 | 'fechafin' => $GLOBALS['phpgw']->datetime->users_localtime, |
---|
1370 | 'fechamodif' => $GLOBALS['phpgw']->datetime->users_localtime, |
---|
1371 | 'category' =>0, |
---|
1372 | 'ownername'=>$this->get_account_name($this->bo->owner,"gecos"), |
---|
1373 | 'actualizo' => $this->bo->owner, |
---|
1374 | 'owner' => $this->bo->owner, |
---|
1375 | 'infolog' => $_REQUEST['infolog'], |
---|
1376 | 'tracker' => $_REQUEST['tracker'] |
---|
1377 | ); |
---|
1378 | |
---|
1379 | |
---|
1380 | |
---|
1381 | |
---|
1382 | |
---|
1383 | |
---|
1384 | |
---|
1385 | |
---|
1386 | |
---|
1387 | return $retval; |
---|
1388 | |
---|
1389 | } |
---|
1390 | |
---|
1391 | |
---|
1392 | function delete() |
---|
1393 | { |
---|
1394 | |
---|
1395 | |
---|
1396 | |
---|
1397 | # $vars = get_defined_vars(); |
---|
1398 | # print_r($vars); |
---|
1399 | /*foreach($_POST as $k=>$v){ |
---|
1400 | $$k=$v; |
---|
1401 | echo $$k."<br>"; |
---|
1402 | } |
---|
1403 | foreach($_POST as $nombre_campo => $valor){ |
---|
1404 | $asignacion = "\$" . $nombre_campo . "='" . $valor . "';"; |
---|
1405 | echo $asignacion."<br>"; |
---|
1406 | } */ |
---|
1407 | |
---|
1408 | |
---|
1409 | |
---|
1410 | |
---|
1411 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1412 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1413 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['infolog']['title'].' - '.lang('Search Results'); |
---|
1414 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1415 | |
---|
1416 | $error = ''; |
---|
1417 | |
---|
1418 | $matches = 0; |
---|
1419 | |
---|
1420 | |
---|
1421 | |
---|
1422 | |
---|
1423 | // $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1424 | |
---|
1425 | $sql = "delete from phpgw_timesheet where ts_id='".$_GET['id']."'"; |
---|
1426 | |
---|
1427 | |
---|
1428 | $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); |
---|
1429 | |
---|
1430 | ExecMethod('timesheet.uitimesheet.index',$parms); |
---|
1431 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1432 | |
---|
1433 | return ""; |
---|
1434 | } |
---|
1435 | |
---|
1436 | |
---|
1437 | } |
---|
1438 | |
---|
1439 | ?> |
---|