* * http://www.radix.net/~cknudsen * * Originaly modified by Mark Peters * * -------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * \**************************************************************************/ class uitimesheet { var $dbb; var $template; var $cat; var $debug = False; var $cat_id; var $theme; var $link_tpl; var $public_functions = array( 'index' => True, 'view' => True, 'edit' => True, 'update'=> True, 'delete' => True, 'close' => True, 'import_mail' => True, 'search' => True, 'header' => True, 'footer' => True ); var $prefs; /** * instance of the bo-class * * @var botimesheet */ var $bo; /** * reference to instance of the link-class of bo * * @var bolink */ var $link; /** * instance of the etemplate class * * @var etemplate */ var $tmpl; /** * reference to the html object of etemplate * * @var html */ var $html; /** * allowed units and hours per day, can be overwritten by the projectmanager configuration, default all units, 8h * * @var string */ var $duration_format = ','; // comma is necessary! var $icons = array( 'type' => array( 'task' => 'task.png', 'task_alt' => 'Task', 'phone' => 'phone.gpng', 'phone_alt' => 'Phonecall', 'note' => 'note.png', 'note_alt' => 'Note', 'confirm' => 'confirm.png', 'confirm_alt' => 'Confirmation', 'reject' => 'reject.png', 'reject_alt' => 'Reject', 'email' => 'email.png', 'email_alt' => 'Email' ), 'action' => array( 'new' => 'new.png', 'new_alt' => 'Add Sub', 'view' => 'view.png', 'view_alt' => 'View Subs', 'parent' => 'parent.png', 'parent_alt' => 'View other Subs', 'edit' => 'edit.png', 'edit_alt' => 'Edit', 'addfile' => 'addfile.png', 'addfile_alt' => 'Add a file', 'delete' => 'delete.png', 'delete_alt' => 'Delete', 'close' => 'done.png', 'close_alt' => 'Close' ), 'status' => array( 'billed' => 'billed.png', 'billed_alt' => 'billed', 'done' => 'done.png', 'done_alt' => 'done', 'will-call' => 'will-call.png', 'will-call_alt' => 'will-call', 'call' => 'call.png', 'call_alt' => 'call', 'ongoing' => 'ongoing.png', 'ongoing_alt' => 'ongoing', 'offer' => 'offer.png', 'offer_alt' => 'offer' ) ); var $filters = array( 'none' => 'no Filter', 'done' => 'done', 'responsible' => 'responsible', 'responsible-open-today' => 'responsible open', 'responsible-open-overdue' => 'responsible overdue', 'responsible-upcoming' => 'responsible upcoming', 'delegated' => 'delegated', 'delegated-open-today' => 'delegated open', 'delegated-open-overdue' => 'delegated overdue', 'delegated-upcoming' => 'delegated upcomming', 'own' => 'own', 'own-open-today' => 'own open', 'own-open-overdue' => 'own overdue', 'own-upcoming' => 'own upcoming', 'open-today' => 'open', 'open-overdue' => 'overdue', 'upcoming' => 'upcoming', ); var $messages = array( 'edit' => 'timesheet - Edit', 'add' => 'timesheet - New', 'add_sub' => 'timesheet - New Subproject', 'sp' => '- Subprojects from', 're' => 'Re:' ); var $optionldap; /** * Constructor * * @return uitimesheet */ function uitimesheet() { //print_r($GLOBALS); $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); $this->bo = CreateObject('timesheet.botimesheet',1); $this->cat = &$this->bo->cat; //echo "pwnre".$this->bo->owner." ".$this->bo->today." ".$this->bo->evento; $this->dbb = CreateObject('class.DBAccess',1); $this->cat = &$this->bo->cat; $this->resources = &$this->bo->resources; $this->project = &$this->bo->project; $this->tarea = &$this->bo->tarea; print_debug('BO Owner',$this->bo->owner); $this->template = $GLOBALS['phpgw']->template; $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('timesheet'); $this->cat_id = $this->bo->cat_id; $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); $this->link_tpl->set_unknowns('remove'); $this->link_tpl->set_file( Array( 'link_picture' => 'link_pict.tpl' ) ); $this->link_tpl->set_block('link_picture','link_pict','link_pict'); $this->link_tpl->set_block('link_picture','pict','pict'); $this->link_tpl->set_block('link_picture','link_open','link_open'); $this->link_tpl->set_block('link_picture','link_close','link_close'); $this->link_tpl->set_block('link_picture','link_text','link_text'); $this->ds = $GLOBALS['phpgw']->common->ldapConnect(); if(!$this->ds) $this->ds = $GLOBALS['phpgw']->common->ldapConnect(); if(!@is_object($GLOBALS['phpgw']->translation)) { $GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation'); } $this->user_context = $GLOBALS['phpgw_info']['server']['ldap_context']; $this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context']; /*************************************************/ $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; //print_debug('UI',$this->_debug_sqsof()); if (!is_object($GLOBALS['phpgw']->html)) { $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); } $this->html = &$GLOBALS['phpgw']->html; } /* Public functions */ function index($params='') { if (!$params) { foreach(array('date','year','month','day') as $field) { if (isset($_GET[$field])) { $params[$field] = $_REQUEST[$field]; } } } //$todos = $this->get_todos($todo_label); $GLOBALS['phpgw']->redirect($this->page('search',$params)); } function page($_page='',$params='') { if($_page == '') { $page_ = explode('.',$this->bo->prefs['timesheet']['defaulttimesheet']); $_page = $page_[0]; if ($_page=='planner_cat' || $_page=='planner_user') { $_page = 'month'; } elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) { $_page = 'month'; $GLOBALS['phpgw']->preferences->add('timesheet','defaulttimesheet','month'); $GLOBALS['phpgw']->preferences->save_repository(); } } if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... { $page_app = 'timesheet'; } else { $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; } if (is_array($params)) { $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; } else { $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; } return $GLOBALS['phpgw']->link('/index.php',$params); } // NDEE: printer-friendly function printer_friendly($body,$app_header='') { $_SESSION['timesheet']['category'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); $_SESSION['timesheet']['resources'] = $this->resources->formated_list('select','all',$this->bo->resources_id,'True'); if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) $_SESSION['timesheet']['cals'] = $this->bo->list_cals(); unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); unset($GLOBALS['phpgw_info']['flags']['noappheader']); unset($GLOBALS['phpgw_info']['flags']['noappfooter']); if ($app_header && $this->always_app_header) { $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['timesheet']['title'].' - '.$app_header; } $GLOBALS['phpgw']->common->phpgw_header(); return $new_body; } function header() { $cols = 8; if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) { $cols++; } $tpl = $GLOBALS['phpgw']->template; $tpl->set_unknowns('remove'); if (!file_exists($file = $this->template_dir.'/header.inc.php')) { $file = PHPGW_SERVER_ROOT . '/timesheet/templates/default/header.inc.php'; } include($file); $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); if($refer[2] != 'view') { $header = $tpl->fp('out','head'); unset($tpl); echo $header; } unset($tpl); } function footer() { $menuaction = $_GET['menuaction']; list(,,$method) = explode('.',$menuaction); if (@$this->bo->printer_friendly) { return; } $p = $GLOBALS['phpgw']->template; $p->set_file( Array( 'footer' => 'footer.tpl', 'form_button' => 'form_button_script.tpl' ) ); $p->set_block('footer','footer_table','footer_table'); $p->set_block('footer','footer_row','footer_row'); $p->set_block('footer','blank_row','blank_row'); $p->set_block('footer','num_dias','num_dias'); $m = $this->bo->month; $y = $this->bo->year; $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); $mes_hoje = (int)substr($hoje,4,2); $mes_footer = (int)substr($_POST['date'],4,2); if($_GET['sday']) { if($_GET['month'] == $mes_hoje) { $day = $this->bo->day; } else { $day = $_GET['sday']; } } else { $day = $this->bo->day; $dia_ini = $day; } if($mes_footer == $mes_hoje) { $dia_ini = (int)substr($hoje,6,2); $day = $dia_ini; } /********************************************************************************************/ } /****************************************************************************************/ function edit($cd=0,$readsess=0) { $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); if(!$this->bo->check_perms(PHPGW_ACL_ADD)) { $this->index(); } if($readsess) { $event = $this->bo->restore_from_appsession; if(!$event['owner']) { $this->bo->add_attribute('owner',$this->bo->owner); } $can_edit = True; } else { $this->bo->event_init(); $this->bo->add_attribute('id',0); $can_edit = True; $participants = (string)(get_var('participants',array('GET'),FALSE)); $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['timesheet']['workdaystarts'])); $startmin = (int)(get_var('minute',array('GET'),0)); $endmin = $startmin + (int)$this->bo->prefs['timesheet']['defaultlength']; $endhour = $starthour + $this->bo->normalizeminutes($endmin); $subject = (string)(get_var('title',array('GET'),0)); if ($subject != '0') { $description = (string)(get_var('description',array('GET'),0)); $description1 = (string)(get_var('description1',array('GET'),0)); $location = (string)(get_var('location',array('GET'),0)); } else unset($subject); $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); //echo "kkkk".$this->bo->year; if(@$this->bo->prefs['timesheet']['default_private']) { $this->bo->set_class(False); } else { $this->bo->set_class(True); } $event = $this->bo->restore_from_appsession; } if(isset($_REQUEST['error'])){ $cd=$_REQUEST['error']; } $this->edit_form( Array( 'event' => $event, 'cd' => $cd, 'plain' => $_GET['plain'] ) ); $GLOBALS['phpgw']->common->phpgw_footer(); } function edit_form($param) { if(isset($_REQUEST['id'])){ $event=$this->select($_REQUEST['id']); }else{ $event=$this->select_init(); } unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); if(!is_array($param)) { $this->index(); } if(isset($param['event'])) { $event = $param['event']; } $hourformat = substr($this->bo->users_timeformat,0,1); $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw_info']['flags']['noappheader'] = True; $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding timesheet'); if ($param['plain'] != "True"){ $GLOBALS['phpgw']->common->phpgw_header(); } else{ $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; } $p = &$GLOBALS['phpgw']->template; $p->set_file( Array( 'edit' => 'edit.tpl', 'form_button' => 'form_button_script.tpl' ) ); $p->set_block('edit','edit_entry','edit_entry'); $p->set_block('edit','list','list'); $p->set_block('edit','hr','hr'); $vars = Array( 'font' => $this->theme['font'], 'bg_color' => $this->theme['bg_text'], 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'timesheet.uitimesheet.update')), 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=timesheet.uitimesheet.accounts_popup'), 'common_hidden' => ''."\n". ''."\n" .''."\n" .''."\n" .''."\n" . ''."\n" . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? ''."\n":''), 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') ); $p->set_var($vars); // ts_type //echo $event['type']; // Display Categories if(strpos($event['category'],',')) { $temp_cats = explode(',',$event['category']); @reset($temp_cats); while(list($key,$value) = each($temp_cats)) { $check_cats[] = (int)$value; } } elseif($event['category']) { $check_cats[] = (int)$event['category']; } else { $check_cats[] = 0; } $var['category'] = Array( 'field' => lang('Category'), 'data' => '' ); // Display proyectos // Location // /* if(strpos($event['project'],',')) { $temp_cats = explode(',',$event['project']); @reset($temp_cats); while(list($key,$value) = each($temp_cats)) { $check_cats[] = (int)$value; } } elseif($event['project']) { $check_cats[] = (int)$event['project']; } else { $check_cats[] = 0; } $var['project'] = Array( 'field' => lang('project'), 'data' => '' );*/ // Display tarea // Location // /* if(strpos($event['tarea'],',')) { $temp_cats = explode(',',$event['tarea']); @reset($temp_cats); while(list($key,$value) = each($temp_cats)) { $check_cats[] = (int)$value; } } elseif($event['tarea']) { $check_cats[] = (int)$event['tarea']; } else { $check_cats[] = 0; } $var['tarea'] = Array( 'field' => lang('tarea'), 'data' => '' );*/ // asunto $var['title'] = Array( 'field' => lang('title'), 'data' => '' ); // Full Description $var['description'] = Array( 'field' => lang('Description'), 'data' => '' ); $valorfechainicio=$this->bo->time2array($event['fechainicio'],$alarm = 0); $start=$valorfechainicio['mday']."/".$valorfechainicio['month']."/".$valorfechainicio['year']; $var['startdate'] = Array( 'field' => lang('Start Date'), 'data' => $jscal->input('start[str]',$start) ); // Time if ($this->bo->prefs['common']['timeformat'] == '12') { $stra .= '= 12?'':' checked').'>am'."\n" . '= 12?' checked':'').'>pm'."\n"; } $var['starttime'] = Array( 'field' => lang('Start Time'), 'data' => ':'."\n".$stra ); // End Date //$end = $this->bo->maketime($event['fechafin']) - $GLOBALS['phpgw']->datetime->tz_offset; $eee=$this->bo->maketime($GLOBALS['phpgw']->datetime->users_localtime); $valorfechaend=$this->bo->time2array($eee,$alarm = 0); //echo $valorfechaend['month']."rrr ".$event['fechafin']." ".$eee; $valorfechaend=$this->bo->time2array($event['fechafin'],$alarm = 0); $end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year']; $var['enddate'] = Array( 'field' => lang('End Date'), 'data' => $jscal->input('end[str]',$end) ); // End Time if ($this->bo->prefs['common']['timeformat'] == '12') { $strb = '= 12?'':' checked').'>am'."\n" . '= 12?' checked':'').'>pm'."\n"; } $var['endtime'] = Array( 'field' => lang('End Time'), 'data' => ':'."\n".$strb ); /*********************************************************************/ // $this->output_template_array($p,'row','list',Array('data' => '')); if (!isset($this->fields)) { $this->custom_fields = CreateObject('timesheet.bocustom_fields'); $this->fields = &$this->custom_fields->fields; $this->stock_fields = &$this->custom_fields->stock_fields; } // $this->output_template_array($p,'row','list',$var['access']); unset($var['access']); $preserved = False; foreach($this->fields as $field => $data) { if (!$data['disabled']) { if (isset($var[$field])) { switch($field) { case 'startdate': $this->output_template_array($p,'row','list',$var['startdate']); $this->output_template_array($p,'row','list',$var['starttime']); break; case 'enddate': $this->output_template_array($p,'row','list',$var['enddate']); $this->output_template_array($p,'row','list',$var['endtime']); break; case 'recure_type': $p->set_var('tr_color',$this->theme['th_bg']); $p->set_var('hr_text','
'.lang('Repeating Event Information').'
'); $p->parse('row','hr',True); $this->output_template_array($p,'row','list',$var['recure_type']); $this->output_template_array($p,'row','list',$var['recure_enddate']); $this->output_template_array($p,'row','list',$var['recure_day']); $this->output_template_array($p,'row','list',$var['recure_interval']); break; default: $this->output_template_array($p,'row','list',$var[$field]); } } elseif (!isset($this->stock_fields[$field])) // Custom field { $lang = lang($name = substr($field,1)); $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); $v = array( 'field' => $lang == $name.'*' ? $name : $lang, 'data' => '' ); if ($data['title']) { $v['tr_color'] = $this->theme['th_bg']; } if (!$data['length'] && $data['title']) { $p->set_var('tr_color',$this->theme['th_bg']); $p->set_var('hr_text','
'.$v['field'].'
'); $p->parse('row','hr',True); } else { $this->output_template_array($p,'row','list',$v); } } } else // preserve disabled fields { switch ($field) { case 'owner': $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; break; case 'recure_type': foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) { $preserved[$field] = $event[$field]; } break; case 'startdate': case 'enddate': $field = substr($field,0,-4); default: $preserved[$field] = $event[$field]; } } } unset($var); if (is_array($preserved)) { //echo "preserving
"; print_r($preserved); echo "
\n"; $p->set_var('common_hidden',$p->get_var('common_hidden').''."\n"); } $p->set_var('submit_button',lang('Save')); $delete_button = $cancel_button = ''; if ($event['id'] > 0) { $var = Array( 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), 'action_text_button' => lang('Delete'), 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", 'action_extra_field' => '', 'button_id' => 'delete_button' ); $p->set_var($var); $delete_button = $p->fp('out','form_button'); } $p->set_var('delete_button',$delete_button); $p->set_var('alert_msg',lang('Required field (category) is empty')); if ($this->bo->return_to) { $var = Array( 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), 'action_text_button' => lang('Cancel'), 'action_confirm_button' => '', 'action_extra_field' => '', 'button_id' => 'cancel_button' ); $p->set_var($var); $cancel_button = $p->fp('out','form_button'); } $p->set_var('cancel_button',$cancel_button); $p->pparse('out','edit_entry'); } function output_template_array(&$p,$row,$list,$var) { if (!isset($var['hidden_vars'])) { $var['hidden_vars'] = ''; } if (!isset($var['tr_color'])) { $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); } $p->set_var($var); $p->parse($row,$list,True); } function get_organizations($context, $selected='', $recursive = false) { $s = CreateObject('phpgwapi.sector_search_ldap'); return ($recursive ? $s->get_organizations($context, $selected, false ,true) : $s->get_sectors($selected, false, false)); } /**********************************************/ function _debug_sqsof() { $data = array( 'filter' => $this->bo->filter, 'cat_id' => $this->bo->cat_id, 'owner' => $this->bo->owner, 'year' => $this->bo->year, 'month' => $this->bo->month, 'day' => $this->bo->day, 'sortby' => $this->bo->sortby, 'num_months' => $this->bo->num_months ); Return _debug_array($data,False); } /***********************************/ function search() { //print_r($_REQUEST); unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['timesheet']['title'].' - '.lang('Search Results'); $GLOBALS['phpgw']->common->phpgw_header(); $error = ''; $matches = 0; //$event = $this->bo->read_entry($ts_id); $event = $this->get_event_ids($adicional); //$event_ids = $this->bo->search_keywords($_POST['keywords']); $matches = count($event); //echo "matches" . $matches; if ($matches == 1) { $quantity = lang('1 match found').'.'; } elseif ($matches > 0) { $quantity = lang('%1 matches found',$matches).'.'; } else { echo ''.lang('Error').':'.lang('no matches found'); return; } $p = $GLOBALS['phpgw']->template; $p->set_file( Array( 'search_form' => 'search.tpl' ) ); $p->set_block('search_form','search','search'); $p->set_block('search_form','search_list_header','search_list_header'); $p->set_block('search_form','search_list','search_list'); $p->set_block('search_form','search_list_footer','search_list_footer'); $script=''; if($matches > 0) { $p->parse('rows','search_list_header',True); } //if($info){ foreach($event as $id => $data) { $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; $info = array( 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), 'date' => $GLOBALS['phpgw']->common->show_date($datetime), 'id' => $data['id'], 'proyecto' => $data['proyecto'], 'title' => $data['title'], 'descripcion' => $data['descripcion'], 'fechainicio' => $data['fechainicio'], 'fechafin' => $data['fechafin'], 'fechamodif' => $data['fechamodif'], 'category' =>$data['category'], 'actualizo' => $data['actualizo'], 'owner' => $data['owner'], 'ownername' => $data['ownername'], 'infolog' => $data['infolog'], 'tracker' => $data['tracker'], 'accionagregar' =>'index.php?menuaction=timesheet.uitimesheet.edit&parent='. $data['id'], 'accionmodificar' =>'index.php?menuaction=timesheet.uitimesheet.edit&id='. $data['id'], 'accioneditar' =>'', 'accionagregartimet'=>'', 'accionborrar' => $data['id'] ); //'accionagregar' =>'index.php?menuaction=timesheet.uitimesheet.edit&parent='. $data['id'] $p->set_var($info); $p->set_var($data); $p->parse('rows','search_list',True); } // } if($matches > 0) { $p->parse('rows','search_list_footer',True); } $p->pparse('out','search'); } function get_event_ids($search) { //echo "tamannn".count($search)." ".$search[0]; $from =""; //if (isset($_REQUEST['id'])){ // $from = ' and t1.ts_id='.$_REQUEST['id']; // } $sql = 'select t1.* from phpgw_timesheet t1 where ts_owner='.$this->bo->owner . $from; //.$search; //. 'WHERE (phpgw_cal_user.ts_id = phpgw_cal.ts_id) ' //. $where . $extra; //echo "FULL SQL : ".$sql."
\n"; if($this->debug) { echo "FULL SQL : ".$sql."
\n"; } //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar"); $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); while( $GLOBALS['phpgw']->db->next_record() ) { // $valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('ts_start'),$alarm = 0); $ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year']; $valorfechaend=$this->bo->time2array($GLOBALS['phpgw']->db->f('ts_end'),$alarm = 0); $end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year']; $valorfechaend2=$this->bo->time2array($GLOBALS['phpgw']->db->f('ts_modified'),$alarm = 0); $end2=$valorfechaend2['mday']."/".$valorfechaend2['month']."/".$valorfechaend2['year']; $retval[] = array( 'id' => $GLOBALS['phpgw']->db->f('ts_id'), 'proyecto' => $GLOBALS['phpgw']->db->f('list_project'), 'title' => $GLOBALS['phpgw']->db->f('ts_title'), 'descripcion' => $GLOBALS['phpgw']->db->f('ts_description'), 'fechainicio' => $ini, 'fechafin' => $end, 'fechamodif' => $end2, 'category' =>$GLOBALS['phpgw']->db->f('ts_cat'), 'actualizo' => $GLOBALS['phpgw']->db->f('ts_modifier'), 'owner' => $GLOBALS['phpgw']->db->f('ts_owner'), 'infolog' => $GLOBALS['phpgw']->db->f('list_infolog'), 'tracker' => $GLOBALS['phpgw']->db->f('list_tracker') ); } return $retval; } function update() { # $vars = get_defined_vars(); # print_r($vars); /*foreach($_POST as $k=>$v){ $$k=$v; echo $$k."
"; } foreach($_POST as $nombre_campo => $valor){ $asignacion = "\$" . $nombre_campo . "='" . $valor . "';"; echo $asignacion."
"; } */ unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['timesheet']['title'].' - '.lang('Search Results'); $GLOBALS['phpgw']->common->phpgw_header(); $error = ''; $matches = 0; list($dia,$mes,$ano)=split("/",$_POST['start']['str']); $starttime = $this->bo->maketime2($_POST['start']['hour'],$_POST['start']['min'],0,$dia,$mes,$ano,$_POST['start']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset; //echo $starttime; list($dia2,$mes2,$ano2)=split("/",$_POST['end']['str']); $endtime = $this->bo->maketime2($_POST['end']['hour'],$_POST['end']['min'],0,$dia2,$mes2,$ano2,$_POST['end']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset; //echo "gggg".$_POST['end2']['month']; if($_POST['end2']['str']['month']>0){ list($dia3,$mes3,$ano3)=split("/",$_POST['end2']['str']); $endtime2 = $this->bo->maketime2($_POST['end2']['hour'],$_POST['end2']['min'],0,$dia3,$mes3,$ano3,$_POST['end2']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset; }else{ $endtime2=0; } //$starttime = $this->bo->maketime2($starthora,$startmin,0,$startfecha) - $GLOBALS['phpgw']->datetime->tz_offset; //echo "kkkk3".$_POST['exec']['accesso']; if($_REQUEST['timesheet']['parent']==""){ $parent=0; }else{ $parent=$_REQUEST['timesheet']['parent']; } $valores="&title=".$_POST['timesheet']['title']."&description=".$_POST['timesheet']['description']."&category=".$_POST['timesheet']['category']."&project=".$_POST['project']."&infolog=".$_POST['infolog']."&tracker=".$_POST['tracker']; //$GLOBALS['phpgw']->redirect($this->page($valores,'')); if($_POST['timesheet']['title']==""){ $GLOBALS['phpgw']->redirect($this->page('edit&error=40'.$valores,'')); } if($_POST['timesheet']['description']==""){ $GLOBALS['phpgw']->redirect($this->page('edit&error=48'.$valores,'')); } // $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; if(isset($_POST['timesheet']['id'])&&$_POST['timesheet']['id']>0){ $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']."'"; }else{ $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) 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")."')"; } $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); ExecMethod('timesheet.uitimesheet.index',$parms); $GLOBALS['phpgw']->common->phpgw_exit(); return ""; } function get_account_name($account_id,$valor) { $acct_type = $this->get_type($account_id); /* jakjr: using justthese with ldap_search */ //$justthese = array("cn","uid","givenname","sn","gecos"); /* search the dn for the given uid */ $justthese = array("uidnumber", "cn", "mail","gecos","dn"); // $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese); if(($acct_type == 'g') && $this->group_context) { $sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese); } else { $sri = @ldap_search($this->ds, $this->user_context, '(uidnumber=' . (int)$account_id . ')', $justthese); } //echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese; if(!$sri) return False; $allValues = ldap_get_entries($this->ds, $sri); $retorna=""; if($acct_type =='g') { if($valor=='gecos') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8'); } if($valor=='uidnumber') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8'); } if($valor=='cn') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); } if($valor=='mail') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8'); } if($valor=='dn') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8'); } } else { if($valor=='gecos') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8'); } if($valor=='uidnumber') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8'); } if($valor=='cn') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); } if($valor=='mail') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8'); } if($valor=='dn') { $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8'); } } return $retorna; } function get_type($account_id) { $allValues = array(); /* jakjr: using justthese with ldap_search */ $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype")); if(!$sri) return False; $allValues = ldap_get_entries($this->ds, $sri); if ($allValues[0]['phpgwaccounttype'][0]) { return $allValues[0]['phpgwaccounttype'][0]; } $allValues = array(); /* jakjr: using justthese with ldap_search */ $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype")); if(!$sri) return False; $allValues = ldap_get_entries($this->ds, $sri); if ($allValues[0]['phpgwaccounttype'][0]) { return $allValues[0]['phpgwaccounttype'][0]; } return False; } function select($id) { $sql = "select * from phpgw_timesheet where ts_id='".$id."'"; $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); if( $GLOBALS['phpgw']->db->next_record() ) { $retval = array( 'id' => $GLOBALS['phpgw']->db->f('ts_id'), 'proyecto' => $GLOBALS['phpgw']->db->f('ts_project'), 'title' => $GLOBALS['phpgw']->db->f('ts_title'), 'descripcion' => $GLOBALS['phpgw']->db->f('ts_description'), 'fechainicio' => $GLOBALS['phpgw']->db->f('ts_start'), 'fechafin' => $GLOBALS['phpgw']->db->f('ts_end'), 'fechamodif' => $GLOBALS['phpgw']->db->f('ts_modified'), 'category' =>$GLOBALS['phpgw']->db->f('ts_cat'), 'actualizo' => $GLOBALS['phpgw']->db->f('ts_modifier'), 'owner' => $GLOBALS['phpgw']->db->f('ts_owner'), 'ownername' => $GLOBALS['phpgw']->db->f('ts_owner_name'), 'infolog' => $GLOBALS['phpgw']->db->f('ts_infolog'), 'tracker' => $GLOBALS['phpgw']->db->f('ts_tracker') ); } //echo "iddd".$id." 56666 ".$retval['id']; return $retval; } function select_init() { $name=""; if(isset($_REQUEST['title'])){ $name=$_REQUEST['title']; } $description=""; if(isset($_REQUEST['description'])){ $description=$_REQUEST['description']; } $retval = array( 'id' => 0, 'proyecto' => $_REQUEST['project'], 'asunto' => $name, 'title' => $name, 'descripcion' => $description, 'fechainicio' => $GLOBALS['phpgw']->datetime->users_localtime, 'fechafin' => $GLOBALS['phpgw']->datetime->users_localtime, 'fechamodif' => $GLOBALS['phpgw']->datetime->users_localtime, 'category' =>0, 'ownername'=>$this->get_account_name($this->bo->owner,"gecos"), 'actualizo' => $this->bo->owner, 'owner' => $this->bo->owner, 'infolog' => $_REQUEST['infolog'], 'tracker' => $_REQUEST['tracker'] ); return $retval; } function delete() { # $vars = get_defined_vars(); # print_r($vars); /*foreach($_POST as $k=>$v){ $$k=$v; echo $$k."
"; } foreach($_POST as $nombre_campo => $valor){ $asignacion = "\$" . $nombre_campo . "='" . $valor . "';"; echo $asignacion."
"; } */ unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['infolog']['title'].' - '.lang('Search Results'); $GLOBALS['phpgw']->common->phpgw_header(); $error = ''; $matches = 0; // $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; $sql = "delete from phpgw_timesheet where ts_id='".$_GET['id']."'"; $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); ExecMethod('timesheet.uitimesheet.index',$parms); $GLOBALS['phpgw']->common->phpgw_exit(); return ""; } } ?>