protected function populate(int $billing_info_id, &$billing_info) { if ($billing_info == null) { $billing_info = new rental_billing_info($this->unmarshal($this->db->f('id'), 'int')); $billing_info->set_billing_id($this->unmarshal($this->db->f('billing_id'), 'int')); $billing_info->set_location_id($this->unmarshal($this->db->f('location_id'), 'int')); $billing_info->set_term_id($this->unmarshal($this->db->f('term_id'), 'int')); $billing_info->set_year($this->unmarshal($this->db->f('year'), 'int')); $billing_info->set_month($this->unmarshal($this->db->f('month'), 'int')); if ($billing_info->get_term_id() == 2) { // yearly $billing_info->set_term_label(lang('annually')); } else { if ($billing_info->get_term_id() == 3) { // half year if ($billing_info->get_month() == 6) { $billing_info->set_term_label(lang('first_half')); } else { $billing_info->set_term_label(lang('second_half')); } } else { if ($billing_info->get_term_id() == 4) { // quarterly if ($billing_info->get_month() == 3) { $billing_info->set_term_label(lang('first_quarter')); } else { if ($billing_info->get_month() == 6) { $billing_info->set_term_label(lang('second_quarter')); } else { if ($billing_info->get_month() == 9) { $billing_info->set_term_label(lang('third_quarter')); } else { $billing_info->set_term_label(lang('fourth_quarter')); } } } } } } } return $billing_info; }
protected function populate(int $billing_id, &$billing) { if ($billing == null) { $billing = new rental_billing($this->db->f('id', true), $this->db->f('location_id', true), $this->db->f('title', true), $this->db->f('created_by', true)); $billing->set_success($this->db->f('success', true)); $billing->set_total_sum($this->db->f('total_sum', true)); $billing->set_timestamp_start($this->db->f('timestamp_start', true)); $billing->set_timestamp_stop($this->db->f('timestamp_stop', true)); $billing->set_timestamp_commit($this->db->f('timestamp_commit', true)); $billing->set_export_format($this->db->f('export_format', true)); $billing->set_responsibility_title(lang($this->unmarshal($this->db->f('responsibility_title'), 'string'))); $id = $this->db->f('id', true); $export_exist = $this->vfs->file_exists(array('string' => "/rental/billings/{$id}", RELATIVE_NONE)); if ($export_exist) { $billing->set_generated_export(true); } /* if($this->db->f('export_data', true) != null) { $billing->set_generated_export(true); } */ } $billing_info_id = $this->unmarshal($this->db->f('billing_info_id', true), 'int'); if ($billing_info_id) { $billing_info = new rental_billing_info($billing_info_id); $billing_info->set_term_id($this->unmarshal($this->db->f('term_id', true), 'int')); $billing_info->set_month($this->unmarshal($this->db->f('month', true), 'int')); $billing_info->set_year($this->unmarshal($this->db->f('year', true), 'int')); if ($billing_info->get_term_id() == 2) { // yearly $billing_info->set_term_label(lang('annually')); } else { if ($billing_info->get_term_id() == 3) { // half year if ($billing_info->get_month() == 6) { $billing_info->set_term_label(lang('first_half')); } else { $billing_info->set_term_label(lang('second_half')); } } else { if ($billing_info->get_term_id() == 4) { // quarterly if ($billing_info->get_month() == 3) { $billing_info->set_term_label(lang('first_quarter')); } else { if ($billing_info->get_month() == 6) { $billing_info->set_term_label(lang('second_quarter')); } else { if ($billing_info->get_month() == 9) { $billing_info->set_term_label(lang('third_quarter')); } else { $billing_info->set_term_label(lang('fourth_quarter')); } } } } } } $billing->add_billing_info($billing_info); } return $billing; }