| | 274 | |
|---|
| | 275 | /** |
|---|
| | 276 | * The delete handler. |
|---|
| | 277 | * |
|---|
| | 278 | * @param mixed $handler_id The ID of the handler. |
|---|
| | 279 | * @param Array $args The argument list. |
|---|
| | 280 | * @param Array &$data The local request data. |
|---|
| | 281 | * @return boolean Indicating success. |
|---|
| | 282 | */ |
|---|
| | 283 | function _handler_delete($handler_id, $args, &$data) |
|---|
| | 284 | { |
|---|
| | 285 | $this->_hour_report = new org_openpsa_projects_hour_report($args[0]); |
|---|
| | 286 | if (!$this->_hour_report) |
|---|
| | 287 | { |
|---|
| | 288 | return false; |
|---|
| | 289 | } |
|---|
| | 290 | |
|---|
| | 291 | $this->_hour_report->require_do('midgard:delete'); |
|---|
| | 292 | |
|---|
| | 293 | if (array_key_exists('org_openpsa_expenses_deleteok', $_REQUEST)) |
|---|
| | 294 | { |
|---|
| | 295 | // Deletion confirmed. |
|---|
| | 296 | if (! $this->_hour_report->delete()) |
|---|
| | 297 | { |
|---|
| | 298 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to delete hour report {$args[0]}, last Midgard error was: " . mgd_errstr()); |
|---|
| | 299 | // This will exit. |
|---|
| | 300 | } |
|---|
| | 301 | |
|---|
| | 302 | // Delete ok, relocating to welcome. |
|---|
| | 303 | $_MIDCOM->relocate(''); |
|---|
| | 304 | // This will exit. |
|---|
| | 305 | } |
|---|
| | 306 | |
|---|
| | 307 | if (array_key_exists('org_openpsa_expenses_deletecancel', $_REQUEST)) |
|---|
| | 308 | { |
|---|
| | 309 | // Redirect to view page. |
|---|
| | 310 | $_MIDCOM->relocate(); |
|---|
| | 311 | // This will exit() |
|---|
| | 312 | } |
|---|
| | 313 | |
|---|
| | 314 | $this->_prepare_request_data(); |
|---|
| | 315 | $this->_view_toolbar->bind_to($this->_hour_report); |
|---|
| | 316 | |
|---|
| | 317 | $_MIDCOM->set_26_request_metadata($this->_hour_report->revised, $this->_hour_report->guid); |
|---|
| | 318 | |
|---|
| | 319 | return true; |
|---|
| | 320 | } |
|---|
| | 321 | |
|---|
| | 322 | /** |
|---|
| | 323 | * Shows the delete hour_report form |
|---|
| | 324 | * |
|---|
| | 325 | * @param mixed $handler_id The ID of the handler. |
|---|
| | 326 | * @param mixed &$data The local request data. |
|---|
| | 327 | */ |
|---|
| | 328 | function _show_delete($handler_id, &$data) |
|---|
| | 329 | { |
|---|
| | 330 | midcom_show_style('hours_delete'); |
|---|
| | 331 | } |
|---|