Esempio n. 1
0
 /**
  * executes passed action for passed reports & relocates to passed url
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_batch($handler_id, array $args, array &$data)
 {
     //get url to relocate
     $relocate = "/";
     if (isset($_POST['relocate_url'])) {
         $relocate = $_POST['relocate_url'];
     } else {
         debug_print_r('no relocate url was passed ', $_POST);
     }
     //check if reports are passed
     if (isset($_POST['entries'])) {
         //iterate through reports
         foreach ($_POST['entries'] as $report_id => $void) {
             $hour_report = new org_openpsa_projects_hour_report_dba($report_id);
             switch ($_POST['action']) {
                 case 'mark_invoiceable':
                     $hour_report->invoiceable = true;
                     break;
                 case 'mark_uninvoiceable':
                     $hour_report->invoiceable = false;
                     break;
                 case 'change_invoice':
                     $id = $this->_get_autocomplete_selection();
                     if ($id != 0) {
                         $hour_report->invoice = $id;
                     }
                     break;
                 case 'change_task':
                     $id = $this->_get_autocomplete_selection();
                     if ($id != 0) {
                         $hour_report->task = $id;
                     }
                     break;
                 default:
                     throw new midcom_error('passed action ' . $_POST['action'] . ' is unknown');
             }
             $hour_report->update();
         }
     } else {
         debug_print_r('No reports passed to action handler', $_POST);
     }
     return new midcom_response_relocate($relocate);
 }