| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 require_once(dirname(__FILE__) . SEP . 'class.bo_user_forms.inc.php'); 3 4 class ui_useractivities extends bo_user_forms 5 { 6 var $public_functions = array( 7 'form' => true 8 ); 9 10 // true or false, decide if the form is the 'show global activities form' or 'show avaible acvtivities with instances form' 11 var $show_globals; 12 13 //communication with the workflow engine 14 var $GUI; 15 16 var $filter_process; 17 18 var $filter_activity; 19 20 21 function ui_useractivities() 22 { 23 parent::bo_user_forms('user_activities'); 24 $this->GUI =& CreateObject('workflow.workflow_gui'); 25 } 26 27 function form($force_show_globals=false) 28 { 29 // when show_globals is on we show only standalone activities 30 // else we only show activities with instances avaible 31 // force_show_globals can be true when called with ExecMethod, for example by ../index.php 32 if ($force_show_globals) 33 { 34 $this->show_globals = true; 35 } 36 else 37 { 38 $this->show_globals = get_var('show_globals', 'any', 0); 39 } 40 //echo '<br>show_globals:'.$this->show_globals; 41 $this->filter_process = get_var('filter_process', 'any', ''); 42 //echo '<br>filter_process:'.$this->filter_process; 43 $this->filter_activity = get_var('filter_activity', 'any', ''); 44 //echo '<br>filter_activity:'.$this->filter_activity; 45 46 if ($this->filter_process) $this->wheres[] = 'gp.wf_p_id=' . (int)$this->filter_process; 47 if ($this->filter_activity) $this->wheres[] = "ga.wf_name='" . $this->GUI->security_cleanup($this->filter_activity, false, true)."'"; 48 $remove_non_pseudo = false; //remove 'classical' activities, other are pseudo-activities because not related to instances 49 $select_standalone = false; //add standalone activities, not a classical one becaus no instance is associated to it 50 $select_start = false; //idem with start 51 $select_view = false; //idem no real activity-instance association 52 if ($this->show_globals) 53 { 54 //we want only standalone activities 55 //this will filter the activities select list 56 $remove_non_pseudo = true; 57 $select_standalone = true; 58 //we need activities without instances 59 $remove_zero = false; 60 } 61 else 62 { 63 //we do not need activities without instances 64 $remove_zero = true; 65 } 66 $this->wheres = implode(' and ', $this->wheres); 67 //echo "<br>wheres:".$this->wheres; 68 $this->link_data = array( 69 'show_globals' => $this->show_globals, 70 'find' => $this->search_str, 71 'filter_process' => $this->filter_process, 72 'filter_activity' => $this->filter_activity, 73 ); 74 75 $all_processes =& $this->GUI->gui_list_user_processes($GLOBALS['egw_info']['user']['account_id'], 0, -1, 'wf_procname__asc', '', ''); 76 $all_activities =& $this->GUI->gui_list_user_activities_by_unique_name($GLOBALS['egw_info']['user']['account_id'], 0, -1, 'ga.wf_name__asc', '', '',$remove_non_pseudo, $select_start, $select_standalone, $select_view); 77 $activities =& $this->GUI->gui_list_user_activities($GLOBALS['egw_info']['user']['account_id'], $this->start, $this->offset, $this->sort_mode, $this->search_str, $this->wheres, $remove_zero, $remove_non_pseudo, $select_start, $select_standalone, $select_view); 78 79 // show process select box 80 $this->show_process_select_box($all_processes['data']); 81 //show activities select box 82 $this->show_select_activities($all_activities['data']); 83 84 // show activities list 85 $this->show_activities_list($activities['data'], $activities['cant']); 86 87 $this->t->set_var(array( 88 'show_globals' => $this->show_globals, 89 'filter_activity' => $this->filter_activity, 90 'filter_process' => $this->filter_process, 91 )); 92 93 //for the tabs this form can be viewed as two different forms 94 if ($this->show_globals) 95 { 96 $this->show_user_tabs('userglobalactivities'); 97 } 98 else 99 { 100 $this->show_user_tabs($this->class_name); 101 } 102 103 //collect error messages 104 $this->message[] = $this->GUI->get_error(false, _DEBUG); 105 106 $this->fill_form_variables(); 107 $this->finish(); 108 } 109 110 function show_activities_list(&$activities_data, $total_number) 111 { 112 //_debug_array($activities_data); 113 //warning header names are header_[name or alias of the column in the query without a dot] 114 //this is necessary for sorting 115 $header_array = array( 116 'wf_procname' => lang('Process'), 117 'wf_name' => lang('Activity'), 118 ); 119 $this->fill_nextmatchs($header_array,$total_number); 120 121 $this->t->set_block('user_activities', 'block_activities_list', 'activities_list'); 122 foreach ($activities_data as $activity) 123 { 124 // for standalone or start activities we make arrows to execute the activity 125 if ($activity['wf_is_interactive'] == 'y' && ($activity['wf_type'] == 'start' || $activity['wf_type'] == 'standalone')) 126 { 127 $arrow = '<a href="'. $GLOBALS['egw']->link('/index.php', array( 128 'menuaction' => 'workflow.run_activity.go', 129 'activity_id' => $activity['wf_activity_id'], 130 )) .'"><img src="'. $GLOBALS['egw']->common->image('workflow', 'runform') .'" alt="'. lang('run activity') .'" title="'. lang('run activity') .'" /></a>'; 131 } 132 else 133 { 134 //we use the normally empty arrow to show number of instances 135 $arrow = '('.$activity['wf_instances'].')'; 136 } 137 //create the activity name with a link if there are some instances to see 138 $act_name = ''; 139 if ($activity['wf_instances'] > 0) $act_name = '<a href="'. $GLOBALS['egw']->link('/index.php', array( 140 'menuaction' => 'workflow.ui_userinstances.form', 141 'filter_process' => $activity['wf_p_id'], 142 'filter_activity' => $activity['wf_activity_id'], 143 )) .'">'; 144 $act_name .= $activity['wf_name']; 145 if ($activity['wf_instances'] > 0) $act_name .= '</a>'; 146 147 $this->t->set_var(array( 148 'act_wf_procname' => $activity['wf_procname'], 149 'act_proc_version' => $activity['wf_version'], 150 'act_icon' => $this->act_icon($activity['wf_type'],$activity['wf_is_interactive']), 151 'act_name' => $act_name, 152 'run_act' => $arrow, 153 'color_line' => $this->nextmatchs->alternate_row_color($tr_color, true), 154 )); 155 $this->t->parse('activities_list', 'block_activities_list', true); 156 } 157 if (!($total_number)) $this->t->set_var('activities_list', '<tr><td colspan="3" align="center">'. lang('There are no user activites available') .'</td></tr>'); 158 } 159 160 function show_process_select_box(&$processes_data) 161 { 162 if (!$this->filter_process) 163 { 164 $this->t->set_var('filter_process_all_selected', 'selected="selected"'); 165 } 166 else 167 { 168 $this->t->set_var('filter_process_all_selected', ''); 169 } 170 171 $this->t->set_block('user_activities', 'block_select_process', 'select_process'); 172 //echo "processes_data: <pre>";print_r($processes_data);echo "</pre>"; 173 foreach ($processes_data as $process_data) 174 { 175 //echo "process_data: <pre>";print_r($process_data);echo "</pre>"; 176 $this->t->set_var(array( 177 'filter_process_selected' => ($process_data['wf_p_id'] == $this->filter_process)? 'selected="selected"' : '', 178 'filter_process_value' => $process_data['wf_p_id'], 179 'filter_process_name' => $process_data['wf_procname'], 180 'filter_process_version' => $process_data['wf_version'], 181 )); 182 $this->t->parse('select_process', 'block_select_process', true); 183 } 184 if (!count($processes_data)) $this->t->set_var('select_process', ''); 185 } 186 187 function show_select_activities(&$all_activities_data) 188 { 189 $this->t->set_block('user_activities', 'block_filter_activity', 'select_activity'); 190 $this->t->set_var('filter_activity_selected_all', ($this->filter_activity=='')? 'selected="selected"' : ''); 191 192 foreach ($all_activities_data as $activity_data) 193 { 194 $this->t->set_var(array( 195 'filter_activity_selected' => ($this->filter_activity == $activity_data['wf_name'])? 'selected="selected"' : '', 196 'filter_activity_name' => $activity_data['wf_name'] 197 )); 198 $this->t->parse('select_activity', 'block_filter_activity', true); 199 } 200 } 201 202 } 203 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |