Completed
Push — 16.1 ( dbf1e5...2e57ee )
by Nathan
26:49 queued 11:22
created
timesheet/inc/class.timesheet_ui.inc.php 1 patch
Spacing   +180 added lines, -183 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 	function view()
57 57
 	{
58
-		$this->edit(null,true);
58
+		$this->edit(null, true);
59 59
 	}
60 60
 
61
-	function edit($content = null,$view = false)
61
+	function edit($content = null, $view = false)
62 62
 	{
63 63
 		$etpl = new Etemplate('timesheet.edit');
64 64
 		if (!is_array($content))
@@ -80,35 +80,34 @@  discard block
 block discarded – undo
80 80
 			{
81 81
 				$this->data = array(
82 82
 					'ts_start' => $this->today,
83
-					'start_time' => '',	// force empty start-time
84
-					'end_time' => Api\DateTime::to($this->now,'H:i'),
83
+					'start_time' => '', // force empty start-time
84
+					'end_time' => Api\DateTime::to($this->now, 'H:i'),
85 85
 					'ts_owner' => $GLOBALS['egw_info']['user']['account_id'],
86
-					'cat_id'   => (int) $_REQUEST['cat_id'],
86
+					'cat_id'   => (int)$_REQUEST['cat_id'],
87 87
 					'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'],
88 88
 					'ts_project' => $_REQUEST['ts_project'],
89 89
 					'ts_title_blur' => $_REQUEST['ts_project'],
90 90
 				);
91
-				if(!is_numeric($_REQUEST['ts_project']))
91
+				if (!is_numeric($_REQUEST['ts_project']))
92 92
 				{
93 93
 					$this->data['pm_id'] = $this->find_pm_id($_REQUEST['ts_project']);
94 94
 				}
95 95
 			}
96 96
 			$matches = null;
97
-			$referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] :
98
-				(strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
97
+			$referer = preg_match('/menuaction=([^&]+)/', $_SERVER['HTTP_REFERER'], $matches) ? $matches[1] : (strpos($_SERVER['HTTP_REFERER'], '/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
99 98
 
100
-			if($_GET['action'] == 'copy')
99
+			if ($_GET['action'] == 'copy')
101 100
 			{
102 101
 				$this->create_copy();
103
-				$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry(TIMESHEET_APP,'entry')));
102
+				$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry(TIMESHEET_APP, 'entry')));
104 103
 			}
105 104
 			if (!$this->check_statusForEditRights($this->data))
106 105
 			{
107
-				$view = true;  //only admin can edit with this status
106
+				$view = true; //only admin can edit with this status
108 107
 				$only_admin_edit = true;
109 108
 				$msg = lang('only Admin can edit this status');
110 109
 			}
111
-			if(!$this->data['ts_project_blur'])
110
+			if (!$this->data['ts_project_blur'])
112 111
 			{
113 112
 				$this->data['ts_project_blur'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : '';
114 113
 			}
@@ -120,7 +119,7 @@  discard block
 block discarded – undo
120 119
 			{
121 120
 				if ($this->status_labels_config[$content['ts_status']]['admin'])
122 121
 				{
123
-					$view = true;  //only admin can edit with this status
122
+					$view = true; //only admin can edit with this status
124 123
 					$only_admin_edit = true;
125 124
 					$msg = lang('only Admin can edit this status');
126 125
 				}
@@ -134,29 +133,29 @@  discard block
 block discarded – undo
134 133
 			{
135 134
 				//$content['ts_start'] += $content['start_time'];
136 135
 				$start = new Api\DateTime($content['ts_start']);
137
-				$start_time = explode(':',$content['start_time']);
138
-				$start->setTime($start_time[0],$start_time[1]);
136
+				$start_time = explode(':', $content['start_time']);
137
+				$start->setTime($start_time[0], $start_time[1]);
139 138
 				$content['ts_start'] = $start->format('ts');
140 139
 			}
141 140
 			if (isset($content['end_time']))		// end-time specified
142 141
 			{
143 142
 				$end = new Api\DateTime($content['ts_start']);
144
-				$end_time = explode(':',$content['end_time']);
145
-				$end->setTime($end_time[0],$end_time[1]);
143
+				$end_time = explode(':', $content['end_time']);
144
+				$end->setTime($end_time[0], $end_time[1]);
146 145
 			}
147 146
 			if ($end && $start)	// start- & end-time --> calculate the duration
148 147
 			{
149 148
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
150 149
 				// check if negative duration is caused by wrap over midnight
151
-				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
150
+				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24 * 60)
152 151
 				{
153
-					$content['ts_duration'] += 24*60;
152
+					$content['ts_duration'] += 24 * 60;
154 153
 				}
155 154
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
156 155
 			}
157 156
 			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
158 157
 			{
159
-				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
158
+				$content['ts_start'] = $end->format('ts') - 60 * $content['ts_duration'];
160 159
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
161 160
 			}
162 161
 			if ($content['ts_duration'] > 0) unset($content['end_time']);
@@ -166,18 +165,18 @@  discard block
 block discarded – undo
166 165
 			$referer = $content['referer'];
167 166
 			$content['ts_project_blur'] = $content['pm_id'] ? Link::title('projectmanager', $content['pm_id']) : '';
168 167
 			$this->data = $content;
169
-			foreach(array('button','view','referer','tabs','start_time') as $key)
168
+			foreach (array('button', 'view', 'referer', 'tabs', 'start_time') as $key)
170 169
 			{
171 170
 				unset($this->data[$key]);
172 171
 			}
173
-			switch($button)
172
+			switch ($button)
174 173
 			{
175 174
 				case 'edit':
176 175
 					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
177 176
 					break;
178 177
 
179 178
 				case 'undelete':
180
-					if($content['ts_status'] == self::DELETED_STATUS)
179
+					if ($content['ts_status'] == self::DELETED_STATUS)
181 180
 					{
182 181
 						unset($content['ts_status']);
183 182
 						$this->data['ts_status'] = '';
@@ -195,18 +194,17 @@  discard block
 block discarded – undo
195 194
 					}
196 195
 					if (!$this->data['ts_quantity'])
197 196
 					{
198
-						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
197
+						$etpl->set_validation_error('ts_quantity', lang('Field must not be empty !!!'));
199 198
 					}
200 199
 					if ($this->data['ts_duration'] < 0)
201 200
 					{
202
-						$etpl->set_validation_error('start_time',lang('Starttime has to be before endtime !!!'));
201
+						$etpl->set_validation_error('start_time', lang('Starttime has to be before endtime !!!'));
203 202
 					}
204 203
 					// set ts_title to ts_project if short viewtype (title is not editable)
205
-					if($this->ts_viewtype == 'short')
204
+					if ($this->ts_viewtype == 'short')
206 205
 					{
207 206
 						$this->data['ts_title'] = $this->data['ts_project'] = $this->data['pm_id'] ?
208
-								Link::title('projectmanager', $this->data['pm_id']) :
209
-								$this->data['ts_project'];
207
+								Link::title('projectmanager', $this->data['pm_id']) : $this->data['ts_project'];
210 208
 					}
211 209
 					if (!$this->data['ts_title'])
212 210
 					{
@@ -215,9 +213,9 @@  discard block
 block discarded – undo
215 213
 
216 214
 						if (!$this->data['ts_title'])
217 215
 						{
218
-							$etpl->set_validation_error('ts_title',lang('Field must not be empty !!!'));
216
+							$etpl->set_validation_error('ts_title', lang('Field must not be empty !!!'));
219 217
 						}
220
-						elseif($button != 'save_new')
218
+						elseif ($button != 'save_new')
221 219
 						{
222 220
 							// remove title-blur for same behavior after apply, as for opening the saved entry again
223 221
 							unset($this->data['ts_title_blur']);
@@ -226,26 +224,26 @@  discard block
 block discarded – undo
226 224
 							unset($content['ts_project_blur']);
227 225
 						}
228 226
 					}
229
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
227
+					if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry
230 228
 
231 229
 					// account for changed project --> remove old one from links and add new one
232
-					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
230
+					if ((int)$this->data['pm_id'] != (int)$this->data['old_pm_id'])
233 231
 					{
234 232
 						// update links accordingly
235 233
 						if ($this->data['pm_id'])
236 234
 						{
237
-							Link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
235
+							Link::link(TIMESHEET_APP, $content['link_to']['to_id'], 'projectmanager', $this->data['pm_id']);
238 236
 						}
239 237
 						if ($this->data['old_pm_id'])
240 238
 						{
241
-							Link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
239
+							Link::unlink2(0, TIMESHEET_APP, $content['link_to']['to_id'], 0, 'projectmanager', $this->data['old_pm_id']);
242 240
 							unset($this->data['old_pm_id']);
243 241
 						}
244 242
 					}
245 243
 					// check if we are linked to a project, but that is NOT set as project
246 244
 					if (!$this->data['pm_id'] && is_array($content['link_to']['to_id']))
247 245
 					{
248
-						foreach($content['link_to']['to_id'] as $data)
246
+						foreach ($content['link_to']['to_id'] as $data)
249 247
 						{
250 248
 							if ($data['app'] == 'projectmanager')
251 249
 							{
@@ -266,32 +264,32 @@  discard block
 block discarded – undo
266 264
 						$msg = lang('Entry saved');
267 265
 						if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
268 266
 						{
269
-							Link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
267
+							Link::link(TIMESHEET_APP, $this->data['ts_id'], $content['link_to']['to_id']);
270 268
 						}
271 269
 					}
272 270
 					Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
273 271
 					if ($button == 'apply') break;
274 272
 					if ($button == 'save_new')
275 273
 					{
276
-						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
274
+						$msg .= ', '.lang('creating new entry'); // giving some feedback to the user
277 275
 
278 276
 						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
279 277
 						{
280 278
 							$content['link_to']['to_id'] = 0;
281
-							foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
279
+							foreach (Link::get_links(TIMESHEET_APP, $this->data['ts_id'], '!'.Link::VFS_APPNAME) as $link)
282 280
 							{
283
-								Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
281
+								Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
284 282
 							}
285 283
 						}
286 284
 						// create a new entry
287 285
 						$this->data['ts_start'] += 60 * $this->data['ts_duration'];
288
-						foreach(array('ts_id','ts_title','ts_description','ts_duration','ts_quantity','ts_modified','ts_modifier','link_to') as $name)
286
+						foreach (array('ts_id', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_modified', 'ts_modifier', 'link_to') as $name)
289 287
 						{
290 288
 							unset($this->data[$name]);
291 289
 						}
292 290
 						// save the selected project, to delete the project-link, if the user changes the project
293 291
 						$this->data['old_pm_id'] = $this->data['pm_id'];
294
-						if($this->pm_integration == 'none')
292
+						if ($this->pm_integration == 'none')
295 293
 						{
296 294
 							unset($this->data['pm_id']);
297 295
 						}
@@ -309,7 +307,7 @@  discard block
 block discarded – undo
309 307
 						else
310 308
 						{
311 309
 							$msg = lang('Error deleting the entry!!!');
312
-							break;	// dont close window
310
+							break; // dont close window
313 311
 						}
314 312
 					}
315 313
 					// fall-through for save
@@ -322,17 +320,16 @@  discard block
 block discarded – undo
322 320
 			'referer' => $referer,
323 321
 			'ts_title_blur' => $content['ts_title_blur'],
324 322
 		);
325
-		$content = array_merge($this->data,array(
323
+		$content = array_merge($this->data, array(
326 324
 			'msg'  => $msg,
327 325
 			'view' => $view,
328 326
 			'tabs'  => $content['tabs'],
329 327
 			'link_to' => array(
330
-				'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] :
331
-					($this->data['link_to']['to_id'] ? $this->data['link_to']['to_id'] : $content['link_to']['to_id']),
328
+				'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] : ($this->data['link_to']['to_id'] ? $this->data['link_to']['to_id'] : $content['link_to']['to_id']),
332 329
 				'to_app' => TIMESHEET_APP,
333 330
 			),
334
-			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '',
335
-			'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
331
+			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0, 3) : '',
332
+			'ts_quantity' => $this->data['ts_duration'] / 60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
336 333
 			'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'],
337 334
 			'pm_integration' => $this->pm_integration,
338 335
 			'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS),
@@ -342,10 +339,10 @@  discard block
 block discarded – undo
342 339
 		if (!$this->data['ts_id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
343 340
 		{
344 341
 			$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
345
-			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
342
+			foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
346 343
 			{
347 344
 				$link_id = $link_ids[$n];
348
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
345
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// gard against XSS
349 346
 				{
350 347
 					switch ($link_app)
351 348
 					{
@@ -353,33 +350,33 @@  discard block
 block discarded – undo
353 350
 							$links[] = $link_id;
354 351
 							// fall-through;
355 352
 						default:
356
-							if(!$n)
353
+							if (!$n)
357 354
 							{
358 355
 								// get title from first linked app
359
-								$preserv['ts_title_blur'] = Link::title($link_app,$link_id);
356
+								$preserv['ts_title_blur'] = Link::title($link_app, $link_id);
360 357
 								// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
361
-								if (($set = Api\Hooks::single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
358
+								if (($set = Api\Hooks::single(array('location'=>'timesheet_set', 'id'=>$link_id), $link_app)))
362 359
 								{
363
-									foreach((array)$set['link_app'] as $i => $l_app)
360
+									foreach ((array)$set['link_app'] as $i => $l_app)
364 361
 									{
365
-										if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
362
+										if (($l_id = $set['link_id'][$i])) Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $l_app, $l_id);
366 363
 										if ($l_app == 'projectmanager') $links[] = $l_id;
367 364
 									}
368 365
 									unset($set['link_app']);
369 366
 									unset($set['link_id']);
370 367
 
371
-									$content = array_merge($content,$set);
368
+									$content = array_merge($content, $set);
372 369
 								}
373 370
 							}
374 371
 							break;
375 372
 					}
376
-					Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
373
+					Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link_app, $link_id);
377 374
 				}
378 375
 			}
379 376
 		}
380 377
 		elseif ($this->data['ts_id'])
381 378
 		{
382
-			$links = Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
379
+			$links = Link::get_links(TIMESHEET_APP, $this->data['ts_id'], 'projectmanager');
383 380
 		}
384 381
 		// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
385 382
 		$content['all_pm_ids'] = array_values($links);
@@ -422,7 +419,7 @@  discard block
 block discarded – undo
422 419
 
423 420
 		if ($view)
424 421
 		{
425
-			foreach(array_merge(array_keys($this->data),array('pm_id','pl_id','link_to')) as $key)
422
+			foreach (array_merge(array_keys($this->data), array('pm_id', 'pl_id', 'link_to')) as $key)
426 423
 			{
427 424
 				$readonlys[$key] = true;
428 425
 			}
@@ -438,9 +435,9 @@  discard block
 block discarded – undo
438 435
 		{
439 436
 			$edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']);
440 437
 		}
441
-		$sel_options['ts_owner']  = $edit_grants;
442
-		$sel_options['ts_status']  = $this->status_labels;
443
-		if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
438
+		$sel_options['ts_owner'] = $edit_grants;
439
+		$sel_options['ts_status'] = $this->status_labels;
440
+		if ($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
444 441
 		{
445 442
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
446 443
 		}
@@ -450,23 +447,23 @@  discard block
 block discarded – undo
450 447
 		// supress unknow widget 'projectmanager-*', if projectmanager is not installed or old
451 448
 		if (!@file_exists(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.projectmanager_widget.inc.php'))
452 449
 		{
453
-			$etpl->set_cell_attribute('pm_id','disabled',true);
454
-			$etpl->set_cell_attribute('pl_id','disabled',true);
450
+			$etpl->set_cell_attribute('pm_id', 'disabled', true);
451
+			$etpl->set_cell_attribute('pl_id', 'disabled', true);
455 452
 		}
456 453
 
457
-		if($this->ts_viewtype == 'short')
454
+		if ($this->ts_viewtype == 'short')
458 455
 		{
459 456
 			$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
460 457
 			$content['ts_description_short'] = $content['ts_description'];
461
-			if(!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
458
+			if (!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
462 459
 			{
463
-				$etpl->setElementAttribute('pm_id','blur',$content['ts_project']);
460
+				$etpl->setElementAttribute('pm_id', 'blur', $content['ts_project']);
464 461
 			}
465 462
 		}
466
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
467
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
463
+		if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields
464
+		if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID
468 465
 
469
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
466
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit', $content, $sel_options, $readonlys, $preserv, 2);
470 467
 	}
471 468
 
472 469
 	/**
@@ -479,7 +476,7 @@  discard block
 block discarded – undo
479 476
 	{
480 477
 		if (!$datetime) return 0;
481 478
 
482
-		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
479
+		return $datetime - mktime(0, 0, 0, date('m', $datetime), date('d', $datetime), date('Y', $datetime));
483 480
 	}
484 481
 
485 482
 	/**
@@ -493,23 +490,23 @@  discard block
 block discarded – undo
493 490
 	 * @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session
494 491
 	 * @return int total number of contacts matching the selection
495 492
 	 */
496
-	function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false)
493
+	function get_rows(&$query_in, &$rows, &$readonlys, $id_only = false)
497 494
 	{
498 495
 		$this->show_sums = false;
499 496
 		$end_date = false;
500 497
 
501 498
 		// Date filter
502
-		if($query_in['filter'] === 'custom')
499
+		if ($query_in['filter'] === 'custom')
503 500
 		{
504 501
 			$end_date = $query_in['enddate'] ? $query_in['enddate'] : false;
505 502
 			$query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1;
506 503
 		}
507
-		$date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date);
504
+		$date_filter = $this->date_filter($query_in['filter'], $query_in['startdate'], $end_date);
508 505
 
509 506
 		if ($query_in['startdate'])
510 507
 		{
511
-			$start = explode('-',date('Y-m-d',$query_in['startdate']+12*60*60));
512
-			$end   = explode('-',date('Y-m-d',$end_date ? $end_date : $query_in['startdate']+7.5*24*60*60));
508
+			$start = explode('-', date('Y-m-d', $query_in['startdate'] + 12 * 60 * 60));
509
+			$end   = explode('-', date('Y-m-d', $end_date ? $end_date : $query_in['startdate'] + 7.5 * 24 * 60 * 60));
513 510
 
514 511
 			// show year-sums, if we are year-aligned (show full years)?
515 512
 			if ((int)$start[2] == 1 && (int)$start[1] == 1 && (int)$end[2] == 31 && (int)$end[1] == 12)
@@ -517,28 +514,28 @@  discard block
 block discarded – undo
517 514
 				$this->show_sums[] = 'year';
518 515
 			}
519 516
 			// show month-sums, if we are month-aligned (show full monthes)?
520
-			if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d',mktime(12,0,0,$end[1]+1,0,$end[0])))
517
+			if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d', mktime(12, 0, 0, $end[1] + 1, 0, $end[0])))
521 518
 			{
522 519
 				$this->show_sums[] = 'month';
523 520
 			}
524 521
 			// show week-sums, if we are week-aligned (show full weeks)?
525 522
 			$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
526 523
 			if (!$week_start_day) $week_start_day = 'Sunday';
527
-			switch($week_start_day)
524
+			switch ($week_start_day)
528 525
 			{
529 526
 				case 'Sunday': $week_end_day = 'Saturday'; break;
530 527
 				case 'Monday': $week_end_day = 'Sunday'; break;
531 528
 				case 'Saturday': $week_end_day = 'Friday'; break;
532 529
 			}
533
-			$filter_start_day = date('l',$query_in['startdate']+12*60*60);
534
-			$filter_end_day   = $end_date ? date('l',$end_date+12*60*60) : false;
530
+			$filter_start_day = date('l', $query_in['startdate'] + 12 * 60 * 60);
531
+			$filter_end_day   = $end_date ? date('l', $end_date + 12 * 60 * 60) : false;
535 532
 			//echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n";
536 533
 			if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day))
537 534
 			{
538 535
 				$this->show_sums[] = 'week';
539 536
 			}
540 537
 			// show day-sums, if range <= 5 weeks
541
-			if (!$end_date || $end_date - $query_in['startdate'] < 36*24*60*60)
538
+			if (!$end_date || $end_date - $query_in['startdate'] < 36 * 24 * 60 * 60)
542 539
 			{
543 540
 				$this->show_sums[] = 'day';
544 541
 			}
@@ -549,10 +546,10 @@  discard block
 block discarded – undo
549 546
 		// Refresh actions (undelete needs this)
550 547
 		$query_in['actions'] = $this->get_actions($query_in);
551 548
 
552
-		$query = $query_in;	// keep the original query
549
+		$query = $query_in; // keep the original query
553 550
 		$query['enddate'] = $end_date;
554 551
 
555
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
552
+		if ($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false, 'ts_unitprice'=>false, 'ts_total'=>false);
556 553
 		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
557 554
 
558 555
 		//_debug_array($query['col_filter']);
@@ -579,18 +576,18 @@  discard block
 block discarded – undo
579 576
 		// handle linked filter (show only entries linked to a certain other entry)
580 577
 		if ($query['col_filter']['linked'])
581 578
 		{
582
-			if(!is_array($query['col_filter']['linked']))
579
+			if (!is_array($query['col_filter']['linked']))
583 580
 			{
584
-				list($app,$id) = explode(':',$query['col_filter']['linked']);
581
+				list($app, $id) = explode(':', $query['col_filter']['linked']);
585 582
 			}
586 583
 			else
587 584
 			{
588 585
 				$app = $query['col_filter']['linked']['app'];
589 586
 				$id = $query['col_filter']['linked']['id'];
590 587
 			}
591
-			if (!($links = Link::get_links($app,$id,'timesheet')))
588
+			if (!($links = Link::get_links($app, $id, 'timesheet')))
592 589
 			{
593
-				$rows = array();	// no infologs linked to project --> no rows to return
590
+				$rows = array(); // no infologs linked to project --> no rows to return
594 591
 				return 0;
595 592
 			}
596 593
 			if (!$query['col_filter']['ts_id'])
@@ -598,9 +595,9 @@  discard block
 block discarded – undo
598 595
 				$query['col_filter']['ts_id'] = array_values(array_unique($links));
599 596
 			}
600 597
 			// allow to combine with other filters using ts_id --> intersect ids
601
-			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'],array_values(array_unique($links)))))
598
+			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'], array_values(array_unique($links)))))
602 599
 			{
603
-				$rows = array();	// no infologs linked to project --> no rows to return
600
+				$rows = array(); // no infologs linked to project --> no rows to return
604 601
 				return 0;
605 602
 			}
606 603
 		}
@@ -624,13 +621,13 @@  discard block
 block discarded – undo
624 621
 			{
625 622
 				if (isset($this->status_labels_substatus['2level'][$status_id]))
626 623
 				{
627
-					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'],$this->status_labels_substatus[$status_id]);
624
+					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'], $this->status_labels_substatus[$status_id]);
628 625
 				}
629 626
 			}
630 627
 		}
631 628
 		if ((int)$query['filter2'] != (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'])
632 629
 		{
633
-			$GLOBALS['egw']->preferences->add(TIMESHEET_APP,'show_details',(int)$query['filter2']);
630
+			$GLOBALS['egw']->preferences->add(TIMESHEET_APP, 'show_details', (int)$query['filter2']);
634 631
 			$GLOBALS['egw']->preferences->save_repository(true);
635 632
 		}
636 633
 		// category filter: cat_id or ''=All cats or 0=No cat
@@ -653,7 +650,7 @@  discard block
 block discarded – undo
653 650
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
654 651
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
655 652
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
656
-			if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
653
+			if ($query['col_filter']['ts_owner'] < 0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']), $GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'], true));
657 654
 		}
658 655
 		else
659 656
 		{
@@ -666,60 +663,60 @@  discard block
 block discarded – undo
666 663
 			// generate a meaningful app-header / report title
667 664
 			if ($this->show_sums['month'])
668 665
 			{
669
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
666
+				if ((int)$start[1] == 1 && (int)$end[1] == 12)		// whole year(s)
670 667
 				{
671
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
668
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$start[0].($start[0] != $end[0] ? ' - '.$end[0] : '');
672 669
 				}
673 670
 				else
674 671
 				{
675
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
672
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(date('F', $query['startdate'] + 12 * 60 * 60)).' '.$start[0];
676 673
 					if ($start[0] != $end[0] || $start[1] != $end[1])
677 674
 					{
678
-						$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . lang(date('F',$query['enddate']+12*60*60)) . ' ' . $end[0];
675
+						$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang(date('F', $query['enddate'] + 12 * 60 * 60)).' '.$end[0];
679 676
 					}
680 677
 				}
681 678
 			}
682 679
 			elseif ($this->show_sums['week'])
683 680
 			{
684
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang('week') . ' ' . date('W',$query['startdate']+36*60*60) . '/' . $start[0];
685
-				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10*24*60*60)
681
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('week').' '.date('W', $query['startdate'] + 36 * 60 * 60).'/'.$start[0];
682
+				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10 * 24 * 60 * 60)
686 683
 				{
687
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . date('W',$query['enddate']-36*60*60) . '/' . $end[0];
684
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.date('W', $query['enddate'] - 36 * 60 * 60).'/'.$end[0];
688 685
 				}
689 686
 			}
690 687
 			elseif ($query['startdate'])
691 688
 			{
692 689
 				$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
693
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . Api\DateTime::to($query['startdate']+12*60*60, $df);
690
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\DateTime::to($query['startdate'] + 12 * 60 * 60, $df);
694 691
 				if ($start != $end)
695 692
 				{
696
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate']+12*60*60:'now', $df);
693
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate'] + 12 * 60 * 60 : 'now', $df);
697 694
 				}
698 695
 			}
699 696
 		}
700 697
 		// Update start / end dates for custom
701
-		if($query_in['filter'] != 'custom')
698
+		if ($query_in['filter'] != 'custom')
702 699
 		{
703 700
 			Api\Json\Response::get()->call(
704 701
 				'app.timesheet.update_timespan',
705
-				Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now' , Api\DateTime::ET2),
702
+				Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now', Api\DateTime::ET2),
706 703
 				$query['filter'] ? Api\DateTime::to($query['enddate'], Api\DateTime::ET2) : null
707 704
 			);
708 705
 		}
709
-		$total = parent::get_rows($query,$rows,$readonlys);
706
+		$total = parent::get_rows($query, $rows, $readonlys);
710 707
 
711 708
 		$ids = array();
712
-		foreach($rows as &$row)
709
+		foreach ($rows as &$row)
713 710
 		{
714 711
 			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
715 712
 		}
716 713
 		if ($id_only)
717 714
 		{
718 715
 			$rows = $ids;
719
-			return $this->total;	// no need to set other fields or $readonlys
716
+			return $this->total; // no need to set other fields or $readonlys
720 717
 		}
721 718
 		$links = array();
722
-		$links3 = Link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager');	// only check for pm links!
719
+		$links3 = Link::get_links_multiple(TIMESHEET_APP, $ids, true, 'projectmanager'); // only check for pm links!
723 720
 		//as the full array is expected, we must supply the missing but needed (since expected further down) information
724 721
 		if (is_array($links3))
725 722
 		{
@@ -739,14 +736,14 @@  discard block
 block discarded – undo
739 736
 
740 737
 		$readonlys = array();
741 738
 		$have_cats = false;
742
-		foreach($rows as &$row)
739
+		foreach ($rows as &$row)
743 740
 		{
744 741
 			if ($row['cat_id']) $have_cats = true;
745 742
 
746 743
 			$row['class'] = 'row';
747 744
 			if ($row['ts_id'] <= 0)	// sums
748 745
 			{
749
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
746
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change
750 747
 
751 748
 				// Remove fake modified date, it breaks nextmatch checks
752 749
 				unset($row['ts_modified']);
@@ -754,22 +751,22 @@  discard block
 block discarded – undo
754 751
 				// Set flag to avoid actions on these rows
755 752
 				$row['no_actions'] = true;
756 753
 
757
-				switch($row['ts_id'])
754
+				switch ($row['ts_id'])
758 755
 				{
759 756
 					case 0:	// day-sum
760
-						$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
757
+						$row['ts_title'] = lang('Sum %1:', lang(date('l', $row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
761 758
 						$row['ts_id'] = 'sum-day-'.$row['ts_start'];
762 759
 						break;
763 760
 					case -1:	// week-sum
764
-						$row['ts_title'] = lang('Sum %1:',lang('week').' '.substr($row['ts_week'],4).'/'.substr($row['ts_week'],0,4));
761
+						$row['ts_title'] = lang('Sum %1:', lang('week').' '.substr($row['ts_week'], 4).'/'.substr($row['ts_week'], 0, 4));
765 762
 						$row['ts_id'] = 'sum-week-'.$row['ts_week'];
766 763
 						break;
767 764
 					case -2:	// month-sum
768
-						$row['ts_title'] = lang('Sum %1:',lang(date('F',$row['ts_start'])).' '.substr($row['ts_month'],0,4));
765
+						$row['ts_title'] = lang('Sum %1:', lang(date('F', $row['ts_start'])).' '.substr($row['ts_month'], 0, 4));
769 766
 						$row['ts_id'] = 'sum-month-'.$row['ts_month'];
770 767
 						break;
771 768
 					case -3:	// year-sum
772
-						$row['ts_title'] = lang('Sum %1:',$row['ts_year']);
769
+						$row['ts_title'] = lang('Sum %1:', $row['ts_year']);
773 770
 						$row['ts_id'] = 'sum-year-'.$row['ts_year'];
774 771
 						break;
775 772
 				}
@@ -779,11 +776,11 @@  discard block
 block discarded – undo
779 776
 				$row['titleClass'] = 'timesheet_titleSum';
780 777
 				continue;
781 778
 			}
782
-			if($row['ts_quantity'])
779
+			if ($row['ts_quantity'])
783 780
 			{
784 781
 				$row['ts_quantity'] = round($row['ts_quantity'], 2);
785 782
 			}
786
-			if (!$this->check_acl(Acl::EDIT,$row))
783
+			if (!$this->check_acl(Acl::EDIT, $row))
787 784
 			{
788 785
 				$row['class'] .= ' rowNoEdit ';
789 786
 			}
@@ -791,21 +788,21 @@  discard block
 block discarded – undo
791 788
 			{
792 789
 				$row['class'] .= ' rowNoEdit ';
793 790
 			}
794
-			if (!$this->check_acl(Acl::DELETE,$row))
791
+			if (!$this->check_acl(Acl::DELETE, $row))
795 792
 			{
796 793
 				$row['class'] .= ' rowNoDelete ';
797 794
 			}
798
-			if($row['ts_status'] != self::DELETED_STATUS)
795
+			if ($row['ts_status'] != self::DELETED_STATUS)
799 796
 			{
800 797
 				$row['class'] .= ' rowNoUndelete ';
801 798
 			}
802 799
 			if ($query['col_filter']['ts_project'])
803 800
 			{
804
-				unset($row['ts_project']);	// dont need or want to show it
801
+				unset($row['ts_project']); // dont need or want to show it
805 802
 			}
806 803
 			elseif ($links[$row['ts_id']])
807 804
 			{
808
-				foreach($links[$row['ts_id']] as $link)
805
+				foreach ($links[$row['ts_id']] as $link)
809 806
 				{
810 807
 					if ($link['app'] == 'projectmanager')
811 808
 					{
@@ -816,28 +813,28 @@  discard block
 block discarded – undo
816 813
 				}
817 814
 			}
818 815
 
819
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
816
+			if (!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
820 817
 
821 818
 		}
822 819
 		$rows['no_cat_id'] = (!$have_cats || $query['cat_id']);
823 820
 		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
824 821
 		$rows['no_owner_col'] = $query['no_owner_col'];
825
-		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1;
822
+		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'], 'ts_owner')) $rows['no_owner_col'] = 1;
826 823
 
827 824
 		$rows += $this->summary;
828 825
 
829 826
 		$rows['pm_integration'] = $this->pm_integration;
830
-		$rows['ts_viewtype'] =  $rows['no_ts_quantity'] =  $rows['no_ts_unitprice'] =  $rows['no_ts_total'] = $this->ts_viewtype == 'short';
827
+		$rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short';
831 828
 		if (!$rows['ts_viewtype'])
832 829
 		{
833 830
 			#_debug_array($query['selectcols']);
834
-			if(!is_array($query['selectcols'])){
835
-				$query['selectcols'] = explode(',',$query['selectcols']);
831
+			if (!is_array($query['selectcols'])) {
832
+				$query['selectcols'] = explode(',', $query['selectcols']);
836 833
 			}
837 834
 			#ts_quantity,ts_unitprice,ts_total
838
-			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1;
839
-			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1;
840
-			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1;
835
+			if ($query['selectcols'] && in_array('ts_quantity_quantity', $query['selectcols']) === false) $rows['no_ts_quantity'] = 1;
836
+			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols']) === false) $rows['no_ts_unitprice'] = 1;
837
+			if ($query['selectcols'] && in_array('ts_total_price', $query['selectcols']) === false) $rows['no_ts_total'] = 1;
841 838
 		}
842 839
 		$rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] ||
843 840
 			$query['no_status'];
@@ -856,7 +853,7 @@  discard block
 block discarded – undo
856 853
 	 * @param array $content
857 854
 	 * @param string $msg
858 855
 	 */
859
-	function index($content = null,$msg='')
856
+	function index($content = null, $msg = '')
860 857
 	{
861 858
 		$etpl = new Etemplate('timesheet.index');
862 859
 
@@ -893,14 +890,14 @@  discard block
 block discarded – undo
893 890
 			else
894 891
 			{
895 892
 				$success = $failed = $action_msg = null;
896
-				if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
897
-					$success,$failed,$action_msg,'index',$msg))
893
+				if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
894
+					$success, $failed, $action_msg, 'index', $msg))
898 895
 				{
899
-					$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
896
+					$msg .= lang('%1 timesheets(s) %2', $success, $action_msg);
900 897
 				}
901
-				elseif(empty($msg))
898
+				elseif (empty($msg))
902 899
 				{
903
-					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
900
+					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
904 901
 				}
905 902
 			}
906 903
 		}
@@ -912,7 +909,7 @@  discard block
 block discarded – undo
912 909
 		if (!is_array($content['nm']))
913 910
 		{
914 911
 			$date_filters = array('All');
915
-			foreach(array_keys($this->date_filters) as $name)
912
+			foreach (array_keys($this->date_filters) as $name)
916 913
 			{
917 914
 				$date_filters[$name] = $name;
918 915
 			}
@@ -921,26 +918,26 @@  discard block
 block discarded – undo
921 918
 			$content['nm'] = array(
922 919
 				'get_rows'       =>	TIMESHEET_APP.'.timesheet_ui.get_rows',
923 920
 				'options-filter' => $date_filters,
924
-				'options-filter2' => array('No details','Details'),
925
-				'order'          =>	'ts_start',// IO name of the column to sort after (optional for the sortheaders)
926
-				'sort'           =>	'DESC',// IO direction of the sort: 'ASC' or 'DESC'
921
+				'options-filter2' => array('No details', 'Details'),
922
+				'order'          =>	'ts_start', // IO name of the column to sort after (optional for the sortheaders)
923
+				'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
927 924
 				'filter_onchange' => "app.timesheet.filter_change();",
928 925
 				'filter2_onchange' => "app.timesheet.filter2_change();",
929 926
 				'filter2'        => (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'],
930 927
 				'row_id'         => 'ts_id',
931 928
 				'row_modified'   => 'ts_modified',
932 929
 				//'actions'        => $this->get_actions(),
933
-				'default_cols'   => '!legacy_actions',	// switch legacy actions column and row off by default
930
+				'default_cols'   => '!legacy_actions', // switch legacy actions column and row off by default
934 931
 				'pm_integration' => $this->pm_integration,
935 932
 				'placeholder_actions' => array('add')
936 933
 			);
937 934
 		}
938 935
 
939
-		if($_GET['search'])
936
+		if ($_GET['search'])
940 937
 		{
941 938
 			$content['nm']['search'] = $_GET['search'];
942 939
 		}
943
-		if($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
940
+		if ($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
944 941
 		{
945 942
 			$content['nm']['col_filter']['linked'] = array(
946 943
 				'app' => $_GET['link_app'],
@@ -954,25 +951,25 @@  discard block
 block discarded – undo
954 951
 			'ts_owner'   => $read_grants,
955 952
 			'pm_id'      => array(lang('No project')),
956 953
 			'cat_id'     => array(array('value' => '', 'label' => lang('all categories')), array('value' => 0, 'label'=>lang('None'))),
957
-			'ts_status'  => $this->status_labels+array(lang('No status')),
954
+			'ts_status'  => $this->status_labels + array(lang('No status')),
958 955
 		);
959
-		if($this->config_data['history'])
956
+		if ($this->config_data['history'])
960 957
 		{
961 958
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
962 959
 		}
963
-		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1;	// 1 because of 'No status'
964
-		$content['nm']['favorites'] = true;		//Enable favorite
960
+		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status'
961
+		$content['nm']['favorites'] = true; //Enable favorite
965 962
 
966 963
 		if ($this->pm_integration != 'full')
967 964
 		{
968
-			$projects =& $this->query_list('ts_project');
965
+			$projects = & $this->query_list('ts_project');
969 966
 			if (!is_array($projects)) $projects = array();
970 967
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
971 968
 		}
972 969
 
973 970
 		// dont show [Export] button if app is not availible to the user or we are on php4
974
-		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int) phpversion() < 5;
975
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index',$content,$sel_options,$readonlys);
971
+		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int)phpversion() < 5;
972
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index', $content, $sel_options, $readonlys);
976 973
 	}
977 974
 
978 975
 	/**
@@ -991,9 +988,9 @@  discard block
 block discarded – undo
991 988
 				'allowOnMultiple' => false,
992 989
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
993 990
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
994
-				'group' => $group=1,
991
+				'group' => $group = 1,
995 992
 				'disableClass' => 'th',
996
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.timesheet.viewEntry':'',
993
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.timesheet.viewEntry' : '',
997 994
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/timesheet/templates/mobile/view.xet'))
998 995
 			),
999 996
 /*
@@ -1033,7 +1030,7 @@  discard block
 block discarded – undo
1033 1030
 				)
1034 1031
 			),
1035 1032
 			'cat' => Etemplate\Widget\Nextmatch::category_action(
1036
-				'timesheet',++$group,'Change category','cat_'
1033
+				'timesheet', ++$group, 'Change category', 'cat_'
1037 1034
 			),
1038 1035
 			'status' => array(
1039 1036
 				'icon' => 'apply',
@@ -1085,7 +1082,7 @@  discard block
 block discarded – undo
1085 1082
 			);
1086 1083
 		}
1087 1084
 		// enable additonal edit check for following actions, if they are generally available
1088
-		foreach(array('cat','status') as $action)
1085
+		foreach (array('cat', 'status') as $action)
1089 1086
 		{
1090 1087
 			if ($actions[$action]['enabled'])
1091 1088
 			{
@@ -1108,7 +1105,7 @@  discard block
 block discarded – undo
1108 1105
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1109 1106
 	 * @return boolean true if all actions succeded, false otherwise
1110 1107
 	 */
1111
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
1108
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg)
1112 1109
 	{
1113 1110
 		$success = $failed = 0;
1114 1111
 		if ($use_all)
@@ -1118,17 +1115,17 @@  discard block
 block discarded – undo
1118 1115
 
1119 1116
 			if ($use_all)
1120 1117
 			{
1121
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
1122
-				$query['num_rows'] = -1;	// all
1118
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1119
+				$query['num_rows'] = -1; // all
1123 1120
 				$readonlys = null;
1124
-				$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
1121
+				$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
1125 1122
 			}
1126 1123
 		}
1127 1124
 		//error_log(__METHOD__."('$action', ".array2string($checked).', '.array2string($use_all).",,, '$session_name')");
1128 1125
 
1129
-		if (substr($action,0,9) == 'to_status')
1126
+		if (substr($action, 0, 9) == 'to_status')
1130 1127
 		{
1131
-			$to_status = (int)substr($action,10);
1128
+			$to_status = (int)substr($action, 10);
1132 1129
 			$action = 'to_status';
1133 1130
 		}
1134 1131
 		else
@@ -1137,11 +1134,11 @@  discard block
 block discarded – undo
1137 1134
 			list($action, $settings) = explode('_', $action, 2);
1138 1135
 		}
1139 1136
 
1140
-		switch($action)
1137
+		switch ($action)
1141 1138
 		{
1142 1139
 			case 'delete':
1143 1140
 				$action_msg = lang('deleted');
1144
-				foreach((array)$checked as $n => $id)
1141
+				foreach ((array)$checked as $n => $id)
1145 1142
 				{
1146 1143
 					if ($this->delete($id))
1147 1144
 					{
@@ -1154,10 +1151,10 @@  discard block
 block discarded – undo
1154 1151
 				}
1155 1152
 				break;
1156 1153
 			case 'undelete':
1157
-				$action_msg =lang('recovered');
1158
-				foreach((array)$checked as $n => $id)
1154
+				$action_msg = lang('recovered');
1155
+				foreach ((array)$checked as $n => $id)
1159 1156
 				{
1160
-					if ($this->set_status($id,''))
1157
+					if ($this->set_status($id, ''))
1161 1158
 					{
1162 1159
 						$success++;
1163 1160
 					}
@@ -1168,10 +1165,10 @@  discard block
 block discarded – undo
1168 1165
 				}
1169 1166
 				break;
1170 1167
 			case 'to_status':
1171
-				$action_msg =lang('changed status');
1172
-				foreach((array)$checked as $n => $id)
1168
+				$action_msg = lang('changed status');
1169
+				foreach ((array)$checked as $n => $id)
1173 1170
 				{
1174
-					if ($this->set_status($id,$to_status))
1171
+					if ($this->set_status($id, $to_status))
1175 1172
 					{
1176 1173
 						$success++;
1177 1174
 					}
@@ -1184,7 +1181,7 @@  discard block
 block discarded – undo
1184 1181
 			case 'cat':
1185 1182
 				$cat_name = Api\Categories::id2name($settings);
1186 1183
 				$action_msg = lang('changed category to %1', $cat_name);
1187
-				foreach((array)$checked as $n => $id) {
1184
+				foreach ((array)$checked as $n => $id) {
1188 1185
 					if (($entry = $this->read($id)) &&
1189 1186
 						($entry['cat_id'] = $settings) &&
1190 1187
 						$this->save($entry) == 0)
@@ -1215,7 +1212,7 @@  discard block
 block discarded – undo
1215 1212
 	 * @param conetnt
1216 1213
 	 * @param view
1217 1214
 	 */
1218
-	function editstatus($content = null,$msg='')
1215
+	function editstatus($content = null, $msg = '')
1219 1216
 	{
1220 1217
 		// this function requires admin rights
1221 1218
 		$GLOBALS['egw_info']['flags']['admin_only'] = true;
@@ -1226,13 +1223,13 @@  discard block
 block discarded – undo
1226 1223
 			list($button) = @each($content['button']);
1227 1224
 			unset ($content['button']);
1228 1225
 
1229
-			switch($button)
1226
+			switch ($button)
1230 1227
 			{
1231 1228
 				case 'delete':
1232 1229
 					break;
1233 1230
 				case 'apply':
1234 1231
 				case 'save':
1235
-					foreach($content['statis'] as &$cat)
1232
+					foreach ($content['statis'] as &$cat)
1236 1233
 					{
1237 1234
 						$id = $cat['id'];
1238 1235
 						if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== ''))
@@ -1246,7 +1243,7 @@  discard block
 block discarded – undo
1246 1243
 					}
1247 1244
 					if ($need_update)
1248 1245
 					{
1249
-						Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1246
+						Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1250 1247
 						$this->config_data = Api\Config::read(TIMESHEET_APP);
1251 1248
 						$this->load_statuses();
1252 1249
 						$msg .= lang('Status updated.');
@@ -1263,7 +1260,7 @@  discard block
 block discarded – undo
1263 1260
 			if (isset($this->status_labels_config[$id]))
1264 1261
 			{
1265 1262
 				unset($this->status_labels_config[$id]);
1266
-				Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1263
+				Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1267 1264
 				unset($this->status_labels[$id]);
1268 1265
 				$msg .= lang('Status deleted.');
1269 1266
 			}
@@ -1272,12 +1269,12 @@  discard block
 block discarded – undo
1272 1269
 		$i = 1;
1273 1270
 		$max_id = 0;
1274 1271
 		unset($content['statis']);
1275
-		foreach($this->status_labels_config as $id => $label)
1272
+		foreach ($this->status_labels_config as $id => $label)
1276 1273
 		{
1277
-			$content['statis'][$i]['name']= $label['name'];
1278
-			$content['statis'][$i]['id']= $id;
1279
-			$content['statis'][$i]['parent']= $label['parent'];
1280
-			$content['statis'][$i]['admin']= $label['admin'];
1274
+			$content['statis'][$i]['name'] = $label['name'];
1275
+			$content['statis'][$i]['id'] = $id;
1276
+			$content['statis'][$i]['parent'] = $label['parent'];
1277
+			$content['statis'][$i]['admin'] = $label['admin'];
1281 1278
 			$i++;
1282 1279
 			$max_id = max($id, $max_id);
1283 1280
 		}
@@ -1289,7 +1286,7 @@  discard block
 block discarded – undo
1289 1286
 		$preserv = $content;
1290 1287
 		$sel_options['parent'] = $this->status_labels;
1291 1288
 		$etpl = new Etemplate('timesheet.editstatus');
1292
-		$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv);
1289
+		$etpl->exec('timesheet.timesheet_ui.editstatus', $content, $sel_options, array(), $preserv);
1293 1290
 	}
1294 1291
 
1295 1292
 	/**
@@ -1300,14 +1297,14 @@  discard block
 block discarded – undo
1300 1297
 	protected function find_pm_id($project)
1301 1298
 	{
1302 1299
 		list($pm_number, $pm_title) = explode(': ', $project, 2);
1303
-		if(!$pm_number || !$pm_title)
1300
+		if (!$pm_number || !$pm_title)
1304 1301
 		{
1305 1302
 			return false;
1306 1303
 		}
1307 1304
 
1308 1305
 		$pm = new projectmanager_bo();
1309 1306
 		$pm_ids = $pm->search(array('pm_number' => $pm_number, 'pm_title' => $pm_title));
1310
-		if($pm_ids && count($pm_ids) >= 1)
1307
+		if ($pm_ids && count($pm_ids) >= 1)
1311 1308
 		{
1312 1309
 			return $pm_ids[0]['pm_id'];
1313 1310
 		}
@@ -1323,17 +1320,17 @@  discard block
 block discarded – undo
1323 1320
 		$original_id = $this->data['ts_id'];
1324 1321
 		unset($this->data['ts_id']);
1325 1322
 
1326
-		$this->data['ts_title'] = lang('Copy of:') . ' ' .$this->data['ts_title'];
1323
+		$this->data['ts_title'] = lang('Copy of:').' '.$this->data['ts_title'];
1327 1324
 		unset($this->data['ts_modified']);
1328 1325
 		unset($this->data['ts_modifier']);
1329
-		$this->data['ts_owner'] = !(int)$this->data['ts_owner'] || !$this->check_acl(Acl::ADD,NULL,$this->data['ts_owner']) ? $this->user : $this->data['ts_owner'];
1326
+		$this->data['ts_owner'] = !(int)$this->data['ts_owner'] || !$this->check_acl(Acl::ADD, NULL, $this->data['ts_owner']) ? $this->user : $this->data['ts_owner'];
1330 1327
 
1331 1328
 		// Copy links
1332
-		if(!is_array($this->data['link_to'])) $this->data['link_to'] = array();
1329
+		if (!is_array($this->data['link_to'])) $this->data['link_to'] = array();
1333 1330
 		$this->data['link_to']['to_app'] = 'timesheet';
1334 1331
 		$this->data['link_to']['to_id'] = 0;
1335 1332
 
1336
-		foreach(Link::get_links($this->data['link_to']['to_app'], $original_id) as $link)
1333
+		foreach (Link::get_links($this->data['link_to']['to_app'], $original_id) as $link)
1337 1334
 		{
1338 1335
 			if ($link['app'] != Link::VFS_APPNAME)
1339 1336
 			{
Please login to merge, or discard this patch.