[795] | 1 | <?php |
---|
| 2 | require_once(dirname(__FILE__) . SEP . 'class.WorkflowUtils.inc.php'); |
---|
| 3 | /** |
---|
| 4 | * @package Workflow |
---|
| 5 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 6 | */ |
---|
| 7 | class bo_workflow_forms extends WorkflowUtils |
---|
| 8 | { |
---|
| 9 | /** |
---|
| 10 | * @var int $nextrows nextmatchs (max number of rows per page) and associated vars |
---|
| 11 | * @access public |
---|
| 12 | */ |
---|
| 13 | var $nextmatchs; |
---|
| 14 | /** |
---|
| 15 | * @var int $start actual starting row number |
---|
| 16 | * @access public |
---|
| 17 | */ |
---|
| 18 | var $start; |
---|
| 19 | /** |
---|
| 20 | * @var int $total_records total number of rows |
---|
| 21 | * @access public |
---|
| 22 | */ |
---|
| 23 | var $total_records; |
---|
| 24 | /** |
---|
| 25 | * @var string $order column used for order |
---|
| 26 | * @access public |
---|
| 27 | */ |
---|
| 28 | var $order; |
---|
| 29 | /** |
---|
| 30 | * @var string $sort ASC or DESC |
---|
| 31 | * @access public |
---|
| 32 | */ |
---|
| 33 | var $sort; |
---|
| 34 | /** |
---|
| 35 | * @var int $sort_mode combination of order and sort |
---|
| 36 | * @access public |
---|
| 37 | */ |
---|
| 38 | var $sort_mode; |
---|
| 39 | /** |
---|
| 40 | * @var int $offset the number of authorized lines |
---|
| 41 | * @access public |
---|
| 42 | */ |
---|
| 43 | var $offset; |
---|
| 44 | /** |
---|
| 45 | * @var string $search_str searched string |
---|
| 46 | * @access public |
---|
| 47 | */ |
---|
| 48 | var $search_str; |
---|
| 49 | /** |
---|
| 50 | * @var array $link_data associative array of input and values used for get links and/or hidden fields |
---|
| 51 | * @access public |
---|
| 52 | */ |
---|
| 53 | var $link_data = array(); |
---|
| 54 | /** |
---|
| 55 | * @var string $template_name name of the template associated with this form, used to set the form_action as well |
---|
| 56 | * for example a template named monitor_processes must be linked with a class.ui_monitor_processes.inc.php |
---|
| 57 | * @access public |
---|
| 58 | */ |
---|
| 59 | var $template_name; |
---|
| 60 | /** |
---|
| 61 | * @var string $form_action form destination |
---|
| 62 | * @access public |
---|
| 63 | */ |
---|
| 64 | var $form_action; |
---|
| 65 | /** |
---|
| 66 | * @var string $class_name related to template_name, name of the child class |
---|
| 67 | * @access public |
---|
| 68 | */ |
---|
| 69 | var $class_name; |
---|
| 70 | /** |
---|
| 71 | * @var array $message message shown in red in top of forms |
---|
| 72 | * @access public |
---|
| 73 | */ |
---|
| 74 | var $message=Array(); |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | * Construtor |
---|
| 78 | * |
---|
| 79 | * @access public |
---|
| 80 | * @return object |
---|
| 81 | */ |
---|
| 82 | function bo_workflow_forms($template_name) |
---|
| 83 | { |
---|
| 84 | parent::WorkflowUtils(); |
---|
| 85 | |
---|
| 86 | //retrieve common form POST or GET values |
---|
| 87 | $this->start = (int)get_var('start', 'any', 0); |
---|
| 88 | $this->order = get_var('order','any','wf_procname'); |
---|
| 89 | $this->sort = get_var('sort','any','ASC'); |
---|
| 90 | $this->sort_mode = $this->order . '__' . $this->sort; |
---|
| 91 | $this->search_str = get_var('find', 'any', ''); |
---|
[3167] | 92 | $this->nextmatchs = Factory::getInstance('nextmatchs'); |
---|
[795] | 93 | |
---|
| 94 | // number of rows allowed |
---|
| 95 | if ($GLOBALS['phpgw_info']['user']['preferences']['workflow']['ui_items_per_page'] > 0) |
---|
| 96 | { |
---|
| 97 | $this->offset = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['ui_items_per_page']; |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | $this->offset = 15; |
---|
| 102 | } |
---|
| 103 | $this->nextmatchs->maxmatches = $this->offset; |
---|
| 104 | |
---|
| 105 | $this->template_name = $template_name; |
---|
| 106 | $this->class_name = explode('_', $this->template_name); |
---|
| 107 | $this->class_name = implode('', $this->class_name); |
---|
| 108 | $this->form_action = $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_'. $this->class_name .'.form'); |
---|
| 109 | |
---|
| 110 | $title = explode('_', $this->template_name); |
---|
| 111 | $title[0] = ucfirst($title[0]); |
---|
| 112 | $title[1] = ucfirst($title[1]); |
---|
| 113 | $title = implode(' ', $title); |
---|
| 114 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang($title); |
---|
| 115 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 116 | echo parse_navbar(); |
---|
| 117 | |
---|
| 118 | $this->t->set_file($this->template_name, $this->template_name . '.tpl'); |
---|
| 119 | |
---|
| 120 | //common css |
---|
| 121 | $this->t->set_var('processes_css', '<LINK href="'.$this->get_css_link('processes').'" type="text/css" rel="StyleSheet">'); |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | } |
---|
| 125 | /** |
---|
| 126 | * Fill the nextmatchs fields, arrows, and counter |
---|
| 127 | * |
---|
| 128 | * @param array $header_array is an array with header_names => header_text_shown |
---|
| 129 | * @param int $total_number total records |
---|
| 130 | * warning header names are header_[name or alias of the column in the query without a dot] |
---|
| 131 | * this is necessary for sorting |
---|
| 132 | * You need some fields on the template: |
---|
| 133 | * <table style="border: 0px;width:100%; margin:0 auto"> |
---|
| 134 | * <tr class="th" style="font-weight:bold"> |
---|
| 135 | * {left} |
---|
| 136 | * * * * <td><div align="center">{lang_showing}</div></td> |
---|
| 137 | * * * * {right} |
---|
| 138 | * </tr> |
---|
| 139 | * </table> |
---|
| 140 | * @return void |
---|
| 141 | * @access public |
---|
| 142 | */ |
---|
| 143 | function fill_nextmatchs(&$header_array, $total_number) |
---|
| 144 | { |
---|
| 145 | $this->total_records = $total_number; |
---|
| 146 | // left and right nextmatchs arrows |
---|
| 147 | $this->t->set_var('left',$this->nextmatchs->left( |
---|
| 148 | $this->form_action,$this->start,$this->total_records,$this->link_data)); |
---|
| 149 | $this->t->set_var('right',$this->nextmatchs->right( |
---|
| 150 | $this->form_action,$this->start,$this->total_records,$this->link_data)); |
---|
| 151 | //show table headers with sort |
---|
| 152 | foreach($header_array as $col => $translation) |
---|
| 153 | { |
---|
| 154 | $this->t->set_var('header_'.$col,$this->nextmatchs->show_sort_order( |
---|
| 155 | $this->sort,$col,$this->order,'/index.php',$translation,$this->link_data)); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | // info about number of rows |
---|
| 159 | if (($this->total_records) > $this->offset) |
---|
| 160 | { |
---|
| 161 | $this->t->set_var('lang_showing',lang('showing %1 - %2 of %3', |
---|
| 162 | 1+$this->start, |
---|
| 163 | (($this->start+$this->offset) > ($this->total_records))? $this->total_records : $this->start+$this->offset, |
---|
| 164 | $this->total_records)); |
---|
| 165 | } |
---|
| 166 | else |
---|
| 167 | { |
---|
| 168 | $this->t->set_var('lang_showing', lang('showing %1',$this->total_records)); |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | /** |
---|
| 172 | * Fill general datas of workflow forms |
---|
| 173 | * |
---|
| 174 | * theses datas are: |
---|
| 175 | * $message : one or more ui message |
---|
| 176 | * $search_str : search string for research |
---|
| 177 | * $start : nextmatch: number of the first row |
---|
| 178 | * $sort : nextmatch: current sort header |
---|
| 179 | * $order : nextmatch: asc or desc |
---|
| 180 | * $form_action : link to the monitor subclass |
---|
| 181 | * |
---|
| 182 | * @return void |
---|
| 183 | * @access public |
---|
| 184 | */ |
---|
| 185 | function fill_form_variables() |
---|
| 186 | { |
---|
| 187 | $this->t->set_var(array( |
---|
| 188 | 'message' => implode('<br />', array_filter($this->message)), |
---|
| 189 | 'start' => $this->start, |
---|
| 190 | 'search_str' => $this->search_str, |
---|
| 191 | 'sort' => $this->sort, |
---|
| 192 | 'order' => $this->order, |
---|
| 193 | 'form_action' => $this->form_action, |
---|
| 194 | )); |
---|
| 195 | } |
---|
| 196 | /** |
---|
| 197 | * Finish the form process by translating the template, outputing it and showing the footer |
---|
| 198 | * @return void |
---|
| 199 | * @access public |
---|
| 200 | */ |
---|
| 201 | function finish() |
---|
| 202 | { |
---|
| 203 | $this->translate_template($this->template_name); |
---|
| 204 | $this->t->pparse('output', $this->template_name); |
---|
| 205 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | } |
---|
| 209 | ?> |
---|