Exemple #1
0
 /**
  * Function to list invoiceable and uninvoicable hours
  */
 private function _list_work_hours()
 {
     $hours_mc = org_openpsa_projects_hour_report_dba::new_collector('person', midcom_connection::get_user());
     $hours_mc->add_value_property('task');
     $hours_mc->add_value_property('invoiceable');
     $hours_mc->add_value_property('hours');
     $hours_mc->add_constraint('date', '>=', $this->_request_data['week_start']);
     $hours_mc->add_constraint('date', '<=', $this->_request_data['week_end']);
     $hours_mc->execute();
     $hours = $hours_mc->list_keys();
     $this->_request_data['customers'] = array();
     $this->_request_data['hours'] = array('invoiceable' => array(), 'uninvoiceable' => array(), 'total_invoiceable' => 0, 'total_uninvoiceable' => 0);
     foreach ($hours as $guid => $values) {
         $this->_add_hour_data($hours_mc->get($guid));
     }
     return true;
 }
Exemple #2
0
 /**
  * The handler for the index view.
  *
  * @param mixed $handler_id the array key from the request array
  * @param array $args the arguments given to the handler
  * @param Array &$data The local request data.
  */
 public function _handler_index($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     if (isset($args[0])) {
         $data['requested_time'] = $args[0];
     } else {
         $data['requested_time'] = date('Y-m-d');
     }
     $date = new DateTime($data['requested_time']);
     $offset = $date->format('N') - 1;
     $date->modify('-' . $offset . ' days');
     $data['week_start'] = (int) $date->format('U');
     $date->modify('+7 days -1 second');
     $data['week_end'] = (int) $date->format('U');
     $date->modify('+1 day');
     $next_week = $date->format('Y-m-d');
     $date->modify('-14 days');
     $previous_week = $date->format('Y-m-d');
     $hours_mc = org_openpsa_projects_hour_report_dba::new_collector('metadata.deleted', false);
     $hours_mc->add_value_property('task');
     $hours_mc->add_value_property('hours');
     $hours_mc->add_value_property('date');
     $hours_mc->add_value_property('person');
     $this->_master->add_list_filter($hours_mc);
     $hours_mc->add_constraint('date', '>=', $data['week_start']);
     $hours_mc->add_constraint('date', '<=', $data['week_end']);
     $hours_mc->add_order('task');
     $hours_mc->add_order('date');
     $hours_mc->execute();
     $data['rows'] = $this->_get_sorted_reports($hours_mc);
     $this->_populate_toolbar($previous_week, $next_week);
     org_openpsa_widgets_grid::add_head_elements();
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.expenses/expenses.css");
     $this->add_breadcrumb('', sprintf($this->_l10n->get("expenses in week %s"), strftime("%V %G", $this->_request_data['week_start'])));
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n->get("expenses in week %s"), strftime("%V %G", $this->_request_data['week_start'])));
 }
Exemple #3
0
 function list_hours()
 {
     $hours = array('reported' => 0, 'approved' => 0, 'invoiced' => 0, 'invoiceable' => 0);
     // Check agreement for invoiceability rules
     $invoice_approved = false;
     try {
         $agreement = new org_openpsa_sales_salesproject_deliverable_dba($this->agreement);
         if ($agreement->invoiceApprovedOnly) {
             $invoice_approved = true;
         }
     } catch (midcom_error $e) {
     }
     $report_mc = org_openpsa_projects_hour_report_dba::new_collector('task', $this->id);
     $report_mc->add_value_property('hours');
     $report_mc->add_value_property('invoice');
     $report_mc->add_value_property('invoiceable');
     $report_mc->add_value_property('metadata.isapproved');
     $report_mc->execute();
     $reports = $report_mc->list_keys();
     foreach ($reports as $guid => $empty) {
         $report_data = $report_mc->get($guid);
         $report_hours = $report_data['hours'];
         $is_approved = $report_data['isapproved'];
         $hours['reported'] += $report_hours;
         if ($is_approved) {
             $hours['approved'] += $report_hours;
         }
         if ($report_data['invoice']) {
             $hours['invoiced'] += $report_hours;
         } else {
             if ($report_data['invoiceable']) {
                 // Check agreement for invoiceability rules
                 if ($invoice_approved) {
                     // Count only uninvoiced approved hours as invoiceable
                     if ($is_approved) {
                         $hours['invoiceable'] += $report_hours;
                     }
                 } else {
                     // Count all uninvoiced invoiceable hours as invoiceable regardless of approval status
                     $hours['invoiceable'] += $report_hours;
                 }
             }
         }
     }
     return $hours;
 }