* * 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 uiinfolog { 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 boinfolog */ 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' => 'InfoLog - Edit', 'add' => 'InfoLog - New', 'add_sub' => 'InfoLog - New Subproject', 'sp' => '- Subprojects from', 're' => 'Re:' ); var $optionldap; /** * Constructor * * @return uiinfolog */ function uiinfolog() { //print_r($GLOBALS); $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); $this->bo = CreateObject('infolog.boinfolog',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->priority = &$this->bo->priority; print_debug('BO Owner',$this->bo->owner); $this->template = $GLOBALS['phpgw']->template; $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('infolog'); $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['infolog']['defaultinfolog']); $_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('infolog','defaultinfolog','month'); $GLOBALS['phpgw']->preferences->save_repository(); } } if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... { $page_app = 'infolog'; } 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['infolog']['category'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); $_SESSION['infolog']['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['infolog']['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']['infolog']['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 . '/infolog/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['infolog']['workdaystarts'])); $startmin = (int)(get_var('minute',array('GET'),0)); $endmin = $startmin + (int)$this->bo->prefs['infolog']['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['infolog']['default_private']) { $this->bo->set_class(False); } else { $this->bo->set_class(True); } $event = $this->bo->restore_from_appsession; } $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']); $justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail","telephonenumber","gecos","dn"); $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese); if(!$sri) return null; $allValues = ldap_get_entries($this->ds, $sri); //echo $event['propietario']." ".(( $event['propietario'] == "1003")?'SELECTED':''); $ttt=count($allValues); for($i=0;$i<$ttt;$i++){ if(isset($allValues[$i]['mail'][0])) { $option = ' '."\n"; $optionldap .= $option; $option2 = ' '."\n"; $optionldap2 .= $option2; } } 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 event'); 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'=>'infolog.uiinfolog.update')), 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=infolog.uiinfolog.accounts_popup'), 'common_hidden' => ''."\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); // info_type //echo $event['type']; $var['title'] = Array( 'tr_color' => $this->theme['th_bg'], 'field' => lang('Type'), 'data' => '' ); //event['public'] // 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 location // Location // if(strpos($event['location'],',')) { $temp_cats = explode(',',$event['location']); @reset($temp_cats); while(list($key,$value) = each($temp_cats)) { $check_cats[] = (int)$value; } } elseif($event['location']) { $check_cats[] = (int)$event['location']; } else { $check_cats[] = 0; } $var['location'] = Array( 'field' => lang('Location'), 'data' => '' ); // Participants if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) { $str = utf8_decode($optionldap); $var['participants'] = array ( 'field' => lang('Contacto'), 'data' => " " ); } // asunto $var['description1'] = Array( 'field' => lang('Asunto'), 'data' => '' ); // Full Description $var['description'] = Array( 'field' => lang('Description'), 'data' => '' ); //echo "quuuue".$GLOBALS['phpgw']->datetime->tz_offset." "; // Date //echo $event['fechainicio']; //$start = $this->bo->maketime( $event['fechainicio']) - $GLOBALS['phpgw']->datetime->tz_offset; //$starttime = $this->bo->maketime2(5,23,0,22,10,2010) - $GLOBALS['phpgw']->datetime->tz_offset; $valorfechainicio=$this->bo->time2array($event['fechainicio'],$alarm = 0); $start=$valorfechainicio['mday']."/".$valorfechainicio['month']."/".$valorfechainicio['year']; //echo "ddddd".$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') { $str .= '= 12?'':' checked').'>am'."\n" . '= 12?' checked':'').'>pm'."\n"; } $var['starttime'] = Array( 'field' => lang('Start Time'), 'data' => ':'."\n" ); // 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') { $str = '= 12?'':' checked').'>am'."\n" . '= 12?' checked':'').'>pm'."\n"; } $var['endtime'] = Array( 'field' => lang('End Time'), 'data' => ':'."\n".$str ); // estado $var['status'] = Array( 'field' => lang('Status'), 'data' => '' ); // prioridad if(strpos($event['priority'],',')) { $temp_cats = explode(',',$event['priority']); @reset($temp_cats); while(list($key,$value) = each($temp_cats)) { $check_cats[] = (int)$value; } } elseif($event['priority']) { $check_cats[] = (int)$event['priority']; } else { $check_cats[] = 0; } $var['priority'] = Array( 'field' => lang('Priority'), 'data' => '' ); // accesso $var['accesso'] = Array( 'field' => lang('access'), 'data' => '' ); //porcentaje $var['percent'] = Array( 'field' => lang('Completado'), 'data' => '' ); /****************************************************/ //responsable if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) { $str2 = utf8_decode($optionldap2); $var['participants1'] = array ( 'field' => lang('Responsable'), 'data' => " " ); } /*********************************************************************/ // End Date2 //$end2 = $this->bo->maketime($event['fechacompletada']) - $GLOBALS['phpgw']->datetime->tz_offset; $valorfechaend2=$this->bo->time2array($event['fechacompletada'],$alarm = 0); if(isset($event['fechacompletada'])&&$event['fechacompletada']>0){ $end2=$valorfechaend2['mday']."/".$valorfechaend2['month']."/".$valorfechaend2['year']; }else{ $end2=""; } $var['enddate2'] = Array( 'field' => lang('Fecha completada'), 'data' => $jscal->input('end2[str]',$end2) ); $i = 0; $boxes = ''; foreach ($this->bo->rpt_day as $mask => $name) { $boxes .= ' '.lang($name)."\n"; if (++$i == 5) $boxes .= '
'; } $var['recure_day'] = Array( 'field' => lang('Repeat Day').'
'.lang('(required for weekly recursivity)'), 'data' => $boxes ); $var['recure_interval'] = Array( 'field' => lang('Interval'), 'data' => '' ); // $this->output_template_array($p,'row','list',Array('data' => '')); if (!isset($this->fields)) { $this->custom_fields = CreateObject('infolog.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); $ordenar=$_REQUEST['ordenar']; echo $ordenar."fff"; $adicional=""; switch($ordenar) { case '2':$adicional= " and t1.info_type='".$_REQUEST['valor']."'";break; case '3':$adicional= " and t1.info_from='".$_REQUEST['valor']."'";break; case '4':$adicional= " and t1.info_type='".$_REQUEST['valor']."'";break; case '7':$adicional= " and t1.info_owner='".$_REQUEST['valor']."'";break; case '8':$adicional= " and t1.info_responsible='".$_REQUEST['valor']."'";break; case '9':$adicional= " and t1.info_access='".$_REQUEST['valor']."'";break; default:$adicional= " "; } 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; //$event = $this->bo->read_entry($info_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=''; $typo=''; $estatus=''; $var = Array( 'th_bg' => $this->theme['th_bg'], 'search_text' => lang('Search Results'), 'quantity' => $quantity, 'title' => 'Registro de notas y tareas', 'typo' => $typo, 'script'=>$script, 'estatus' => $estatus ); $p->set_var($var); 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), 'tipo' => $data['tipo'], 'id' => $data['id'], 'estado' => $data['estado'], 'asunto' => $data['asunto'], 'descripcion' => $data['descripcion'], 'fechainicio' => $data['fechainicio'], 'fechafin' => $data['fechafin'], 'fechacompletada' => $data['fechacompletada'], 'propietario' => $data['propietario'], 'responsable' => $data['responsable'], 'padre' => $data['padre'], 'priority'=>$data['priority'], 'accionagregar' =>'index.php?menuaction=infolog.uiinfolog.edit&parent='. $data['id'], 'accionmodificar' =>'index.php?menuaction=infolog.uiinfolog.edit&id='. $data['id'], 'accioneditar' =>'', 'accionagregartimet'=>'', 'accionborrar' =>'index.php?menuaction=infolog.uiinfolog.borrar&id='. $data['id'] ); //'accionagregar' =>'index.php?menuaction=infolog.uiinfolog.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.info_id='.$_REQUEST['id']; } $sql = 'select t1.*,t2.list_descripcion from phpgw_infolog t1, phpgw_listas t2 where t1.info_priority=t2.list_id ' . $from .$search; //. 'WHERE (phpgw_cal_user.info_id = phpgw_cal.info_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('info_startdate'),$alarm = 0); $ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year']; $valorfechaend=$this->bo->time2array($GLOBALS['phpgw']->db->f('info_enddate'),$alarm = 0); $end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year']; if($GLOBALS['phpgw']->db->f('info_datecompleted')==0){ $comp=""; }else{ $valorfechacom=$this->bo->time2array($GLOBALS['phpgw']->db->f('info_datecompleted'),$alarm = 0); $comp=$valorfechacom['mday']."/".$valorfechacom['month']."/".$valorfechacom['year']; } $retval[] = array( 'id' => $GLOBALS['phpgw']->db->f('info_id'), 'type' => 'db->f('info_type').'.png>', 'asunto' => $GLOBALS['phpgw']->db->f('info_subject'), 'descripcion' => $GLOBALS['phpgw']->db->f('info_des'), 'fechainicio' => $ini, 'fechafin' => $end, 'status' => lang($GLOBALS['phpgw']->db->f('info_status')), 'fechacompletada' => $comp, 'propietario' => $this->get_account_name($GLOBALS['phpgw']->db->f('info_owner'),'gecos'), 'responsable' => $this->get_account_name($GLOBALS['phpgw']->db->f('info_responsible'),'gecos'), 'owner' => $GLOBALS['phpgw']->db->f('info_uid'), 'percent' => $GLOBALS['phpgw']->db->f('info_percent'), 'access' => $GLOBALS['phpgw']->db->f('info_access'), 'location' =>$GLOBALS['phpgw']->db->f('info_location'), 'category' =>$GLOBALS['phpgw']->db->f('info_cat'), 'priority' => $GLOBALS['phpgw']->db->f('list_descripcion'), 'padre' => $GLOBALS['phpgw']->db->f('info_id_parent') ); } 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']['infolog']['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) - $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) - $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) - $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['infolog']['parent']==""){ $parent=0; }else{ $parent=$_REQUEST['infolog']['parent']; } // $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; if(isset($_POST['info']['id'])&&$_POST['info']['id']>0){ $sql = "update phpgw_infolog set info_type='".$_POST['exec']['info_type']."',info_cat='".$_POST['infolog']['category']."',info_from='".$_POST['participants'][0]."',info_subject='".$_POST['cal']['description1']."',info_des='".$_POST['cal']['description']."',info_status='".$_POST['status']."',info_percent=".$_POST['percent'].",info_responsible='".$_POST['participants1'][0]."',info_startdate=".$starttime.",info_enddate=".$endtime.",info_datecompleted=".$endtime2.",info_datemodified=".$GLOBALS['phpgw']->datetime->users_localtime.",info_owner=".$_POST['info']['owner'].",info_priority=".$_POST['priority'].",info_location='".$_POST['infolog']['location']."',info_id_parent=".$parent.",info_access='".$_POST['exec']['accesso']."' where info_id='".$_POST['info']['id']."'"; }else{ $sql = "insert into phpgw_infolog (info_type,info_cat,info_from,info_subject,info_des,info_status,info_percent,info_responsible,info_startdate,info_enddate,info_datecompleted,info_datemodified,info_owner,info_priority,info_location,info_id_parent,info_access) values ('".$_POST['exec']['info_type']."',".$_POST['infolog']['category'].",'".$_POST['participants'][0]."','".$_POST['cal']['description1']."','".$_POST['cal']['description']."','".$_POST['status']."',".$_POST['percent'].",'".$_POST['participants1'][0]."',".$starttime.",".$endtime.",".$endtime2.",".$GLOBALS['phpgw']->datetime->users_localtime.",".$_POST['info']['owner'].",".$_POST['priority'].",'".$_POST['infolog']['location']."',".$parent.",'".$_POST['exec']['accesso']."')"; } $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); 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_infolog where info_id='".$id."'"; $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__); if( $GLOBALS['phpgw']->db->next_record() ) { $retval = array( 'id' => $GLOBALS['phpgw']->db->f('info_id'), 'type' => $GLOBALS['phpgw']->db->f('info_type'), 'asunto' => $GLOBALS['phpgw']->db->f('info_subject'), 'descripcion' => $GLOBALS['phpgw']->db->f('info_des'), 'fechainicio' => $GLOBALS['phpgw']->db->f('info_startdate'), 'fechafin' => $GLOBALS['phpgw']->db->f('info_enddate'), 'status' => $GLOBALS['phpgw']->db->f('info_status'), 'fechacompletada' => $GLOBALS['phpgw']->db->f('info_datecompleted'), 'propietario' => $GLOBALS['phpgw']->db->f('info_from'), 'responsable' => $GLOBALS['phpgw']->db->f('info_responsible'), 'owner' => $GLOBALS['phpgw']->db->f('info_owner'), 'percent' => $GLOBALS['phpgw']->db->f('info_percent'), 'access' => $GLOBALS['phpgw']->db->f('info_access'), 'location' =>$GLOBALS['phpgw']->db->f('info_location'), 'category' =>$GLOBALS['phpgw']->db->f('info_cat'), 'priority' => $GLOBALS['phpgw']->db->f('info_priority'), 'padre' => $GLOBALS['phpgw']->db->f('info_id_parent') ); } //echo "iddd".$id." 56666 ".$retval['id']; return $retval; } function select_init() { $retval = array( 'id' => 0, 'type' => '', 'asunto' => '', 'descripcion' => '', 'fechainicio' => $GLOBALS['phpgw']->datetime->users_localtime, 'fechafin' =>$GLOBALS['phpgw']->datetime->users_localtime, 'status' => '', 'fechacompletada' => 0, 'propietario' => '', 'responsable' => '', 'owner' => $this->bo->owner, 'percent' => '', 'access' => 'public', 'location' =>'', 'category' =>0, 'priority' => 1, 'padre' => 0 ); return $retval; } } ?>