[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11826] rental : add transactions, formatting
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11826] rental : add transactions, formatting |
Date: |
Fri, 14 Mar 2014 16:13:01 +0000 |
Revision: 11826
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11826
Author: sigurdne
Date: 2014-03-14 16:13:01 +0000 (Fri, 14 Mar 2014)
Log Message:
-----------
rental : add transactions, formatting
Modified Paths:
--------------
trunk/rental/inc/class.sobilling.inc.php
trunk/rental/inc/class.uibilling.inc.php
trunk/rental/inc/model/class.agresso_lg04.inc.php
Modified: trunk/rental/inc/class.sobilling.inc.php
===================================================================
--- trunk/rental/inc/class.sobilling.inc.php 2014-03-14 16:09:38 UTC (rev
11825)
+++ trunk/rental/inc/class.sobilling.inc.php 2014-03-14 16:13:01 UTC (rev
11826)
@@ -1,423 +1,433 @@
<?php
-phpgw::import_class('rental.socommon');
-phpgw::import_class('rental.sobilling_info');
-include_class('rental', 'agresso_gl07', 'inc/model/');
-include_class('rental', 'agresso_lg04', 'inc/model/');
-include_class('rental', 'agresso_cs15', 'inc/model/');
-include_class('rental', 'billing_info', 'inc/model/');
-include_class('rental', 'party', 'inc/model/');
+ phpgw::import_class('rental.socommon');
+ phpgw::import_class('rental.sobilling_info');
+ include_class('rental', 'agresso_gl07', 'inc/model/');
+ include_class('rental', 'agresso_lg04', 'inc/model/');
+ include_class('rental', 'agresso_cs15', 'inc/model/');
+ include_class('rental', 'billing_info', 'inc/model/');
+ include_class('rental', 'party', 'inc/model/');
-class rental_sobilling extends rental_socommon
-{
- protected static $so;
- protected $billing_terms; // Used for caching the billing terms
- public $vfs;
-
- /**
- * Get a static reference to the storage object associated with this
model object
- *
- * @return the storage object
- */
- public static function get_instance()
+ class rental_sobilling extends rental_socommon
{
- if (self::$so == null) {
- self::$so = CreateObject('rental.sobilling');
- $virtual_file_system = CreateObject('phpgwapi.vfs');
- $virtual_file_system->override_acl = 1;
- self::$so->vfs = $virtual_file_system;
- }
- return self::$so;
- }
- protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
- $clauses = array('1=1');
- if($sort_field == 'description')
+ protected static $so;
+ protected $billing_terms; // Used for caching the billing terms
+ public $vfs;
+
+ /**
+ * Get a static reference to the storage object associated with
this model object
+ *
+ * @return the storage object
+ */
+ public static function get_instance()
{
- $sort_field = "title";
+ if(self::$so == null)
+ {
+ self::$so = CreateObject('rental.sobilling');
+ $virtual_file_system
= CreateObject('phpgwapi.vfs');
+ $virtual_file_system->override_acl = 1;
+ self::$so->vfs
= $virtual_file_system;
+ }
+ return self::$so;
}
- if(isset($filters[$this->get_id_field_name()]))
+
+ protected function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count)
{
- $filter_clauses[] =
"rb.{$this->marshal($this->get_id_field_name(),'field')} =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ $clauses = array('1=1');
+ if($sort_field == 'description')
+ {
+ $sort_field = "title";
+ }
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] =
"rb.{$this->marshal($this->get_id_field_name(), 'field')} =
{$this->marshal($filters[$this->get_id_field_name()], 'int')}";
+ }
+ if(isset($filters['location_id']))
+ {
+ $location_id =
$this->marshal($filters['location_id'], 'int');
+ $filter_clauses[] =
"rb.location_id=$location_id";
+ $filter_clauses[] = "rb.timestamp_commit
is null";
+ }
+ $filter_clauses[] = "rb.deleted = false";
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+ $condition = join(' AND ', $clauses);
+
+ $tables = "rental_billing rb";
+ $joins = $this->left_join . ' rental_billing_info rbi
ON (rb.id = rbi.billing_id)';
+ $joins .= $this->left_join . '
rental_contract_responsibility rcr ON (rcr.location_id = rb.location_id)';
+ if($return_count) // We should only return a count
+ {
+ $cols = 'COUNT(DISTINCT(rb.id)) AS count';
+ }
+ else
+ {
+ $cols = 'rb.id, rb.total_sum, rb.success,
rb.created_by, rb.timestamp_start, rb.timestamp_stop, rb.timestamp_commit,
rb.location_id, rb.title, rb.export_format, rbi.id as billing_info_id,
rbi.term_id, rbi.month, rbi.year, rcr.title as responsibility_title';
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = $sort_field ? "ORDER BY
rb.{$this->marshal($sort_field, 'field')} {$dir}" : 'ORDER BY rb.timestamp_stop
DESC';
+ }
+ //var_dump("SELECT {$cols} FROM {$tables} {$joins}
WHERE {$condition} {$order}");
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
}
- if(isset($filters['location_id']))
+
+ protected function populate(int $billing_id, &$billing)
{
- $location_id = $this->marshal($filters['location_id'],
'int');
- $filter_clauses[] = "rb.location_id=$location_id";
- $filter_clauses[] = "rb.timestamp_commit is null";
- }
- $filter_clauses[] = "rb.deleted = false";
- if(count($filter_clauses))
- {
- $clauses[] = join(' AND ', $filter_clauses);
- }
- $condition = join(' AND ', $clauses);
+ 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')));
- $tables = "rental_billing rb";
- $joins = $this->left_join.' rental_billing_info rbi ON (rb.id =
rbi.billing_id)';
- $joins .= $this->left_join.' rental_contract_responsibility rcr
ON (rcr.location_id = rb.location_id)';
- if($return_count) // We should only return a count
- {
- $cols = 'COUNT(DISTINCT(rb.id)) AS count';
- }
- else
- {
- $cols = 'rb.id, rb.total_sum, rb.success,
rb.created_by, rb.timestamp_start, rb.timestamp_stop, rb.timestamp_commit,
rb.location_id, rb.title, rb.export_format, rbi.id as billing_info_id,
rbi.term_id, rbi.month, rbi.year, rcr.title as responsibility_title';
- $dir = $ascending ? 'ASC' : 'DESC';
- $order = $sort_field ? "ORDER BY
rb.{$this->marshal($sort_field, 'field')} {$dir}": 'ORDER BY rb.timestamp_stop
DESC';
- }
- //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}");
- return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
- }
-
- 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
- (
+ $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($export_exist)
+ {
+ $billing->set_generated_export(true);
+ }
+
+ /* if($this->db->f('export_data', true) != null)
+ {
+ $billing->set_generated_export(true);
+ } */
}
-
- /*if($this->db->f('export_data', true) != null)
+
+ $billing_info_id =
$this->unmarshal($this->db->f('billing_info_id', true), 'int');
+ if($billing_info_id)
{
- $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'));
+ $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{
-
$billing_info->set_term_label(lang('second_half'));
+ 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_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'));
+ }
}
- 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);
}
- $billing->add_billing_info($billing_info);
+ return $billing;
}
- return $billing;
- }
-
- protected function get_id_field_name()
- {
- return 'id';
- }
-
- public function add(&$billing)
- {
- $values = array
- (
- $this->marshal($billing->get_total_sum(), 'float'),
- $billing->is_success() ? 'true' : 'false',
- $this->marshal($billing->get_created_by(), 'int'),
- $this->marshal($billing->get_timestamp_start(), 'int'),
- $this->marshal($billing->get_timestamp_stop(), 'int'),
- $this->marshal($billing->get_timestamp_commit(), 'int'),
- $this->marshal($billing->get_location_id(), 'int'),
- $this->marshal($billing->get_title(), 'string'),
- $billing->is_deleted() ? 'true' : 'false',
- $this->marshal($billing->get_export_format(), 'string'),
- );
- $query ="INSERT INTO rental_billing(total_sum, success,
created_by, timestamp_start, timestamp_stop, timestamp_commit, location_id,
title, deleted, export_format) VALUES (" . join(',', $values) . ")";
- $receipt = null;
- if($this->db->query($query))
+
+ protected function get_id_field_name()
{
- $receipt = array();
- $receipt['id'] =
$this->db->get_last_insert_id('rental_billing', 'id');
- $billing->set_id($receipt['id']);
+ return 'id';
}
- return $receipt;
- }
-
- public function update($billing)
- {
- $values = array(
- 'total_sum = ' .
$this->marshal($billing->get_total_sum(), 'float'),
- "success = '" . ($billing->is_success() ? 'true' :
'false') . "'",
- 'timestamp_start = ' .
$this->marshal($billing->get_timestamp_start(), 'int'),
- 'timestamp_stop = ' .
$this->marshal($billing->get_timestamp_stop(), 'int'),
- 'timestamp_commit = ' .
$this->marshal($billing->get_timestamp_commit(), 'int'),
- 'location_id = ' .
$this->marshal($billing->get_location_id(), 'int'),
- 'title = ' . $this->marshal($billing->get_title(),
'string'),
- "deleted = '" . ($billing->is_deleted() ? 'true' :
'false') . "'",
- 'export_format = ' .
$this->marshal($billing->get_export_format(), 'string'),
- );
- $result = $this->db->query("UPDATE rental_billing SET " .
join(',', $values) . " WHERE id={$billing->get_id()}", __LINE__,__FILE__);
- }
-
- /**
- * Get a key/value array of titles of billing term types keyed by their
id
- *
- * @return array
- */
- function get_billing_terms()
- {
- if($this->billing_terms == null)
+
+ public function add(&$billing)
{
- $sql = "SELECT id, title FROM rental_billing_term ORDER
BY months DESC";
- //FIXME Sigurd 21.june 2010: this query trigger
fetch_single mode for next_record()
- $this->db->query($sql, __LINE__, __FILE__,false,true);
- $results = array();
- while($this->db->next_record())
+ $values = array
+ (
+ $this->marshal($billing->get_total_sum(),
'float'),
+ $billing->is_success() ? 'true' : 'false',
+ $this->marshal($billing->get_created_by(),
'int'),
+ $this->marshal($billing->get_timestamp_start(),
'int'),
+ $this->marshal($billing->get_timestamp_stop(),
'int'),
+
$this->marshal($billing->get_timestamp_commit(), 'int'),
+ $this->marshal($billing->get_location_id(),
'int'),
+ $this->marshal($billing->get_title(), 'string'),
+ $billing->is_deleted() ? 'true' : 'false',
+ $this->marshal($billing->get_export_format(),
'string'),
+ );
+ $query = "INSERT INTO rental_billing(total_sum,
success, created_by, timestamp_start, timestamp_stop, timestamp_commit,
location_id, title, deleted, export_format) VALUES (" . join(',', $values) .
")";
+ $receipt = null;
+ if($this->db->query($query))
{
- $results[$this->db->f('id')] =
$this->db->f('title', true);
+ $receipt = array();
+ $receipt['id'] =
$this->db->get_last_insert_id('rental_billing', 'id');
+ $billing->set_id($receipt['id']);
}
- $this->billing_terms = $results;
+ return $receipt;
}
-
- return $this->billing_terms;
- }
-
- public function get_missing_billing_info(int $billing_term, int $year,
int $mont, array $contracts_to_bill, array $contracts_overriding_billing_start,
string $export_format)
- {
- $exportable = null;
- $missing_billing_info = array();
- switch($export_format)
+
+ public function update($billing)
{
- case 'agresso_gl07':
- $exportable = $export_format;
- break;
- case 'agresso_lg04':
- $exportable = $export_format;
- break;
- default:
- $missing_billing_info[] = 'Unknown export
format.';
- break;
+ $values = array
+ (
+ 'total_sum = ' .
$this->marshal($billing->get_total_sum(), 'float'),
+ "success = '" . ($billing->is_success() ?
'true' : 'false') . "'",
+ 'timestamp_start = ' .
$this->marshal($billing->get_timestamp_start(), 'int'),
+ 'timestamp_stop = ' .
$this->marshal($billing->get_timestamp_stop(), 'int'),
+ 'timestamp_commit = ' .
$this->marshal($billing->get_timestamp_commit(), 'int'),
+ 'location_id = ' .
$this->marshal($billing->get_location_id(), 'int'),
+ 'title = ' .
$this->marshal($billing->get_title(), 'string'),
+ "deleted = '" . ($billing->is_deleted() ?
'true' : 'false') . "'",
+ 'export_format = ' .
$this->marshal($billing->get_export_format(), 'string'),
+ );
+ $result = $this->db->query("UPDATE rental_billing SET
" . join(',', $values) . " WHERE id={$billing->get_id()}", __LINE__, __FILE__);
}
- foreach($contracts_to_bill as $contract_id) // Runs through all
the contracts that should be billed in this run
+
+ /**
+ * Get a key/value array of titles of billing term types keyed
by their id
+ *
+ * @return array
+ */
+ function get_billing_terms()
{
- $contract =
rental_socontract::get_instance()->get_single($contract_id);
- $info = null;
+ if($this->billing_terms == null)
+ {
+ $sql = "SELECT id, title FROM
rental_billing_term ORDER BY months DESC";
+ //FIXME Sigurd 21.june 2010: this query trigger
fetch_single mode for next_record()
+ $this->db->query($sql, __LINE__, __FILE__,
false, true);
+ $results = array();
+ while($this->db->next_record())
+ {
+ $results[$this->db->f('id')] =
$this->db->f('title', true);
+ }
+ $this->billing_terms = $results;
+ }
+
+ return $this->billing_terms;
+ }
+
+ public function get_missing_billing_info(int $billing_term, int
$year, int $mont, array $contracts_to_bill, array
$contracts_overriding_billing_start, string $export_format)
+ {
+ $exportable = null;
+ $missing_billing_info = array();
switch($export_format)
{
case 'agresso_gl07':
- $info =
rental_agresso_gl07::get_missing_billing_info($contract);
+ $exportable
= $export_format;
break;
case 'agresso_lg04':
- $info =
rental_agresso_lg04::get_missing_billing_info($contract);
+ $exportable
= $export_format;
break;
+ default:
+ $missing_billing_info[] = 'Unknown
export format.';
+ break;
}
- if($info != null && count($info) > 0)
+ foreach($contracts_to_bill as $contract_id) // Runs
through all the contracts that should be billed in this run
{
- $missing_billing_info[$contract_id] = $info;
+ $contract =
rental_socontract::get_instance()->get_single($contract_id);
+ $info = null;
+ switch($export_format)
+ {
+ case 'agresso_gl07':
+ $info =
rental_agresso_gl07::get_missing_billing_info($contract);
+ break;
+ case 'agresso_lg04':
+ $info =
rental_agresso_lg04::get_missing_billing_info($contract);
+ break;
+ }
+ if($info != null && count($info) > 0)
+ {
+ $missing_billing_info[$contract_id] =
$info;
+ }
}
+ return $missing_billing_info;
}
- return $missing_billing_info;
- }
-
- public function create_billing(int $decimals, int $contract_type, int
$billing_term, int $year, int $month, $title, int $created_by, array
$contracts_to_bill, array $contracts_overriding_billing_start, string
$export_format, int $existing_billing, array $contracts_bill_only_one_time)
- {
- if($contracts_overriding_billing_start == null){
- $contracts_overriding_billing_start = array();
- }
-
- if($contracts_bill_only_one_time == null){
- $contracts_bill_only_one_time = array();
- }
-
- // We start a transaction before running the billing
- $this->db->transaction_begin();
- if($existing_billing < 1){ //new billing
- $billing = new rental_billing(-1, $contract_type,
$title, $created_by); // The billing job itself
- $billing->set_timestamp_start(time()); // Start of run
- $billing->set_export_format($export_format);
- $billing->set_title($title);
- $this->store($billing); // Store job as it is
- $billing_end_timestamp = strtotime('-1 day',
strtotime(($month == 12 ? ($year + 1) : $year) . '-' . ($month == 12 ? '01' :
($month + 1)) . '-01')); // Last day of billing period is the last day of the
month we're billing
- $counter = 0;
- $total_sum = 0;
- }
- else{
- $billing = $this->get_single($existing_billing);
- $billing_end_timestamp = strtotime('-1 day',
strtotime(($month == 12 ? ($year + 1) : $year) . '-' . ($month == 12 ? '01' :
($month + 1)) . '-01')); // Last day of billing period is the last day of the
month we're billing
- $total_sum = $billing->get_total_sum();
- }
- $billing_info = new rental_billing_info(null,
$billing->get_id(), $contract_type, $billing_term, $year, $month);
- $res =
rental_sobilling_info::get_instance()->store($billing_info);
-
- // Get the number of months in selected term for contract
- $months =
rental_socontract::get_instance()->get_months_in_term($billing_term);
-
- // The billing should start from the first date of the periode
(term) we're billing for
- $first_day_of_selected_month = strtotime($year . '-' . $month .
'-01');
- $bill_from_timestamp = strtotime('-'.($months-1).' month',
$first_day_of_selected_month);
-
- foreach($contracts_to_bill as $contract_id) // Runs through all
the contracts that should be billed in this run
+ public function create_billing(int $decimals, int
$contract_type, int $billing_term, int $year, int $month, $title, int
$created_by, array $contracts_to_bill, array
$contracts_overriding_billing_start, string $export_format, int
$existing_billing, array $contracts_bill_only_one_time)
{
- $invoice = rental_invoice::create_invoice($decimals,
$billing->get_id(), $contract_id,
in_array($contract_id,$contracts_overriding_billing_start) ? true :
false,$bill_from_timestamp,
$billing_end_timestamp,in_array($contract_id,$contracts_bill_only_one_time) ?
true : false ); // Creates an invoice of the contract
- if($invoice != null)
+ if($contracts_overriding_billing_start == null)
{
- $total_sum += $invoice->get_total_sum();
+ $contracts_overriding_billing_start = array();
}
+
+ if($contracts_bill_only_one_time == null)
+ {
+ $contracts_bill_only_one_time = array();
+ }
+
+ // We start a transaction before running the billing
+ $this->db->transaction_begin();
+ if($existing_billing < 1)
+ { //new billing
+ $billing = new
rental_billing(-1, $contract_type, $title, $created_by); // The billing job
itself
+ $billing->set_timestamp_start(time()); // Start
of run
+ $billing->set_export_format($export_format);
+ $billing->set_title($title);
+ $this->store($billing); // Store job as it is
+ $billing_end_timestamp = strtotime('-1 day',
strtotime(($month == 12 ? ($year + 1) : $year) . '-' . ($month == 12 ? '01' :
($month + 1)) . '-01')); // Last day of billing period is the last day of the
month we're billing
+ $counter = 0;
+ $total_sum = 0;
+ }
+ else
+ {
+ $billing =
$this->get_single($existing_billing);
+ $billing_end_timestamp = strtotime('-1 day',
strtotime(($month == 12 ? ($year + 1) : $year) . '-' . ($month == 12 ? '01' :
($month + 1)) . '-01')); // Last day of billing period is the last day of the
month we're billing
+ $total_sum =
$billing->get_total_sum();
+ }
+
+ $billing_info = new rental_billing_info(null,
$billing->get_id(), $contract_type, $billing_term, $year, $month);
+ $res =
rental_sobilling_info::get_instance()->store($billing_info);
+
+ // Get the number of months in selected term for
contract
+ $months =
rental_socontract::get_instance()->get_months_in_term($billing_term);
+
+ // The billing should start from the first date of the
periode (term) we're billing for
+ $first_day_of_selected_month = strtotime($year . '-' .
$month . '-01');
+ $bill_from_timestamp = strtotime('-' .
($months - 1) . ' month', $first_day_of_selected_month);
+
+ foreach($contracts_to_bill as $contract_id) // Runs
through all the contracts that should be billed in this run
+ {
+ $invoice =
rental_invoice::create_invoice($decimals, $billing->get_id(), $contract_id,
in_array($contract_id, $contracts_overriding_billing_start) ? true : false,
$bill_from_timestamp, $billing_end_timestamp, in_array($contract_id,
$contracts_bill_only_one_time) ? true : false ); // Creates an invoice of the
contract
+ if($invoice != null)
+ {
+ $total_sum += $invoice->get_total_sum();
+ }
+ }
+ $billing->set_total_sum(round($total_sum, $decimals));
+ $billing->set_timestamp_stop(time()); // End of run
+ $billing->set_success(true); // Billing job is a success
+ $this->store($billing); // Store job now that we're done
+ // End of transaction!
+ if($this->db->transaction_commit())
+ {
+ return $billing;
+ }
+ throw new UnexpectedValueException('Transaction
failed.');
}
- $billing->set_total_sum(round($total_sum, $decimals));
- $billing->set_timestamp_stop(time()); // End of run
- $billing->set_success(true); // Billing job is a success
- $this->store($billing); // Store job now that we're done
- // End of transaction!
- if ($this->db->transaction_commit()) {
- return $billing;
- }
- throw new UnexpectedValueException('Transaction failed.');
- }
-
- /**
- * Helper method to check if a period has been billed before.
- *
- * @param $contract_type
- * @param $billing_term
- * @param $year
- * @param $month
- * @return boolean true if the period has been billed before, false if
not.
- */
- public function has_been_billed($contract_type, $billing_term, $year,
$month)
- {
- $sql = "SELECT COUNT(id) AS count FROM rental_billing_info
WHERE location_id = {$this->marshal($contract_type,'int')} AND term_id =
{$this->marshal($billing_term,'int')} AND year = {$this->marshal($year,'int')}
AND month = {$this->marshal($month,'int')} AND deleted = false";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if($result && $this->db->next_record())
+
+ /**
+ * Helper method to check if a period has been billed before.
+ *
+ * @param $contract_type
+ * @param $billing_term
+ * @param $year
+ * @param $month
+ * @return boolean true if the period has been billed before,
false if not.
+ */
+ public function has_been_billed($contract_type, $billing_term,
$year, $month)
{
- return ($this->unmarshal($this->db->f('count', true),
'int') > 0);
+ $sql = "SELECT COUNT(id) AS count FROM
rental_billing_info WHERE location_id = {$this->marshal($contract_type, 'int')}
AND term_id = {$this->marshal($billing_term, 'int')} AND year =
{$this->marshal($year, 'int')} AND month = {$this->marshal($month, 'int')} AND
deleted = false";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if($result && $this->db->next_record())
+ {
+ return ($this->unmarshal($this->db->f('count',
true), 'int') > 0);
+ }
+ return false;
}
- return false;
- }
-
- /**
- * Generates export data and stores in database.
- *
- * @param $billing_job
- */
- public function generate_export(&$billing_job, $excel_export=false)
- {
- set_time_limit(1000);
- $exportable = null;
- switch($billing_job->get_export_format())
+
+ /**
+ * Generates export data and stores in database.
+ *
+ * @param $billing_job
+ */
+ public function generate_export(&$billing_job, $excel_export =
false)
{
- case 'agresso_gl07':
- $exportable = new
rental_agresso_gl07($billing_job);
- break;
- case 'agresso_lg04':
- $exportable = new
rental_agresso_lg04($billing_job);
- break;
- /*default:
- $exportable = new
rental_default_export($billing_job);
- break;*/
- }
- if($exportable != null)
- {
- if($excel_export)
- {
- $export_data = $exportable->get_contents_excel();
- //_debug_array($export_data[1]);
- return $export_data;
- }
- else
- {
- //$sql = "UPDATE rental_billing SET export_data =
{$this->marshal(iconv("ISO-8859-1","UTF-8",$exportable->get_contents()),'string')}
WHERE id = {$this->marshal($billing_job->get_id(),'int')}";
- //$result = $this->db->query($sql, __LINE__, __FILE__);
-
- $vfs = CreateObject('phpgwapi.vfs');
- $vfs->override_acl = 1;
-
- $path = "/rental";
- $dir = array('string' => $path, RELATIVE_NONE);
- if(!$vfs->file_exists($dir)){
- if(!$vfs->mkdir($dir))
- {
- return;
- }
+ $exportable = null;
+ switch($billing_job->get_export_format())
+ {
+ case 'agresso_gl07':
+ $exportable = new
rental_agresso_gl07($billing_job);
+ break;
+ case 'agresso_lg04':
+ $exportable = new
rental_agresso_lg04($billing_job);
+ break;
+ /* default:
+ $exportable = new
rental_default_export($billing_job);
+ break; */
}
-
- $path .= "/billings";
- $dir = array('string' => $path, RELATIVE_NONE);
- if(!$vfs->file_exists($dir)){
- if(!$vfs->mkdir($dir))
+ if($exportable != null)
+ {
+ if($excel_export)
{
- return;
+ $export_data =
$exportable->get_contents_excel();
+ //_debug_array($export_data[1]);
+ return $export_data;
}
- }
-
-
- $id = $billing_job->get_id();
- $export_data = $exportable->get_contents();
- $file_path = $path."/{$id}";
- if($export_data != ""){
- $result = $vfs->write
- (
- array
- (
- 'string' => $file_path,
- RELATIVE_NONE,
- 'content' => $export_data
- )
- );
- if($result)
+ else
{
- return true;
+ //$sql = "UPDATE rental_billing SET
export_data =
{$this->marshal(iconv("ISO-8859-1","UTF-8",$exportable->get_contents()),'string')}
WHERE id = {$this->marshal($billing_job->get_id(),'int')}";
+ //$result = $this->db->query($sql,
__LINE__, __FILE__);
+
+ $vfs =
CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+
+ $path = "/rental";
+ $dir = array('string' => $path,
RELATIVE_NONE);
+ if(!$vfs->file_exists($dir))
+ {
+ if(!$vfs->mkdir($dir))
+ {
+ return;
+ }
+ }
+
+ $path .= "/billings";
+ $dir = array('string' => $path,
RELATIVE_NONE);
+ if(!$vfs->file_exists($dir))
+ {
+ if(!$vfs->mkdir($dir))
+ {
+ return;
+ }
+ }
+
+
+ $id =
$billing_job->get_id();
+ $export_data =
$exportable->get_contents();
+ $file_path = $path . "/{$id}";
+ if($export_data != "")
+ {
+ $result = $vfs->write
+ (
+ array
+ (
+ 'string'
=> $file_path,
+ RELATIVE_NONE,
+ 'content'
=> $export_data
+ )
+ );
+ if($result)
+ {
+ return true;
+ }
+ }
}
}
- }
- }
- return false;
- }
-
- public function generate_customer_export($billing_id)
- {
-
- $file = PHPGW_SERVER_ROOT .
"/rental/inc/export/{$GLOBALS['phpgw_info']['user']['domain']}/customer.php";
- if(is_file($file))
- {
- include $file;
- return $customer_export->get_contents();
+ return false;
}
- else
+
+ public function generate_customer_export($billing_id)
{
- $file = PHPGW_SERVER_ROOT .
"/rental/inc/export/default/customer.php";
+
+ $file = PHPGW_SERVER_ROOT .
"/rental/inc/export/{$GLOBALS['phpgw_info']['user']['domain']}/customer.php";
if(is_file($file))
{
include $file;
@@ -425,31 +435,39 @@
}
else
{
- return false;
+ $file = PHPGW_SERVER_ROOT .
"/rental/inc/export/default/customer.php";
+ if(is_file($file))
+ {
+ include $file;
+ return $customer_export->get_contents();
+ }
+ else
+ {
+ return false;
+ }
}
}
- }
-
- public function get_export_data(int $billing_job_id)
- {
- $sql = "SELECT export_data FROM rental_billing WHERE id =
{$this->marshal($billing_job_id,'int')}";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if($result && $this->db->next_record())
+
+ public function get_export_data(int $billing_job_id)
{
- return $this->unmarshal(iconv("UTF-8","ISO-8859-1",
$this->db->f('export_data', true)), 'string');
+ $sql = "SELECT export_data FROM rental_billing
WHERE id = {$this->marshal($billing_job_id, 'int')}";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if($result && $this->db->next_record())
+ {
+ return $this->unmarshal(iconv("UTF-8",
"ISO-8859-1", $this->db->f('export_data', true)), 'string');
+ }
+ return '';
}
- return '';
- }
-
- public function get_agresso_export_format($contract_type)
- {
- $sql = "SELECT export_format FROM
rental_contract_responsibility WHERE location_id=$contract_type";
- $result = $this->db->query($sql, __LINE__, __FILE__);
- if($result && $this->db->next_record())
+
+ public function get_agresso_export_format($contract_type)
{
- return $this->unmarshal($this->db->f('export_format',
true), 'string');
+ $sql = "SELECT export_format FROM
rental_contract_responsibility WHERE location_id=$contract_type";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if($result && $this->db->next_record())
+ {
+ return
$this->unmarshal($this->db->f('export_format', true), 'string');
+ }
+ return '';
}
- return '';
- }
-}
-?>
+
+ }
\ No newline at end of file
Modified: trunk/rental/inc/class.uibilling.inc.php
===================================================================
--- trunk/rental/inc/class.uibilling.inc.php 2014-03-14 16:09:38 UTC (rev
11825)
+++ trunk/rental/inc/class.uibilling.inc.php 2014-03-14 16:13:01 UTC (rev
11826)
@@ -25,7 +25,7 @@
self::set_active_menu('rental::contracts::invoice');
$config = CreateObject('phpgwapi.config','rental');
$config->read();
- $billing_time_limit =
$config->config_data['billing_time_limit'];
+ $billing_time_limit =
isset($config->config_data['billing_time_limit']) &&
$config->config_data['billing_time_limit'] ?
(int)$config->config_data['billing_time_limit'] : 500;
set_time_limit($billing_time_limit); // Set time limit
$GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('invoice_menu');
}
Modified: trunk/rental/inc/model/class.agresso_lg04.inc.php
===================================================================
--- trunk/rental/inc/model/class.agresso_lg04.inc.php 2014-03-14 16:09:38 UTC
(rev 11825)
+++ trunk/rental/inc/model/class.agresso_lg04.inc.php 2014-03-14 16:13:01 UTC
(rev 11826)
@@ -4,6 +4,7 @@
class rental_agresso_lg04 implements rental_exportable
{
+
protected $billing_job;
protected $date_str;
protected $orders;
@@ -150,20 +151,20 @@
$data['article_code'] =
$price_item->get_agresso_id();
$price_item_data[]
= $data;
}
- $this->orders[] = $this->get_order(
- $invoice->get_header(),
$invoice->get_party()->get_identifier(), $invoice->get_id(),
$this->billing_job->get_year(), $this->billing_job->get_month(),
$invoice->get_account_out(), $price_item_data,
$invoice->get_responsibility_id(), $invoice->get_service_id(),
$building_location_code, $invoice->get_project_id(), $composite_name,
$serial_number, $invoice->get_reference()
- );
+ $this->orders[] =
$this->get_order($invoice->get_header(),
$invoice->get_party()->get_identifier(), $invoice->get_id(),
$this->billing_job->get_year(), $this->billing_job->get_month(),
$invoice->get_account_out(), $price_item_data,
$invoice->get_responsibility_id(), $invoice->get_service_id(),
$building_location_code, $invoice->get_project_id(), $composite_name,
$serial_number, $invoice->get_reference());
$invoice->set_serial_number($serial_number);
$serial_number++;
}
$so_invoice = rental_soinvoice::get_instance();
+ $so_invoice->transaction_begin();
//Store invoices with serial numbers
foreach($invoices as $invoice) // Runs through all
invoices
{
$so_invoice->store($invoice);
}
+ return $so_invoice->transaction_commit();
}
protected function run_excel_export()
@@ -230,171 +231,171 @@
$order[] = // Header line
- '1' // 1 accept_flag
- . sprintf("%8s", '') // 2
just white space..
- . sprintf("%20s", '') // 3
accountable
- . sprintf("%160s", '') // 4 address
- . sprintf("%20s", '') // 5-7
just white space..
- . sprintf("%08s", '') // 8 apar_id
- . sprintf("%30s", '') // 9
apar_name
- . sprintf("%50s", '') // 10-11 just
white space..
- . sprintf("%2s", '') // 12
att_1_id
- . sprintf("%2s", '') // 13
att_2_id
- . sprintf("%2s", '') // 14
att_3_id
- . sprintf("%2s", '') // 15
att_4_id
- . sprintf("%2s", '') // 16
att_5_id
- . sprintf("%2s", '') // 17
att_6_id
- . sprintf("%2s", '') // 18
att_7_id
- . sprintf("%35s", '') // 19
bank_account
- . sprintf("%-12s", "BKBPE{$this->date_str}") //
20 batch_id DATA
- . 'BY' // 21 client
DATA
- . sprintf("%2s", '') // 22
client_ref
- . sprintf("%-17s", "{$this->date_str}") // 23
confirm_date DATA
- . sprintf("%1s", '') // 24
control
- . sprintf("%17s", '') // 25
just white space..
- . 'NOK' // 26
currency DATA
- . sprintf("%60s", '') // 27
del_met_descr
- . sprintf("%60s", '') // 28
del_term_descr
- . sprintf("%255s", '') // 29
deliv_addr
- . sprintf("%50s", '') // 30
deliv_attention
- . sprintf("%3s", '') // 31
deliv_countr
- . sprintf("%-17s", "{$this->date_str}") // 32
deliv_date DATA
- . sprintf("%8s", '') // 33
deliv_method
- . sprintf("%8s", '') // 34
deliv_terms
- . sprintf("%52s", '') // 35-41 just
white space..
- . sprintf("%-12.12s", $account) // 42
dim_value_1 DATA
- . sprintf("%12s", '') // 43
dim_value_2
- . sprintf("%12s", '') // 44
dim_value_3
- . sprintf("%12s", '') // 45
dim_value_4
- . sprintf("%12s", '') // 46
dim_value_5
- . sprintf("%12s", '') // 47
dim_value_6
- . sprintf("%12s", '') // 48
dim_value_7
- . sprintf("%17s", '') // 49-50 just
white space..
- . sprintf("%017s", '') // 51
exch_rate
- . sprintf("%-15.15s", $client_ref) // 52
ext_ord_ref
- . sprintf("%6s", '') // 53
intrule_id
- . sprintf("%8s", '') // 54-55 just
white space..
- . sprintf("%-120.120s", utf8_decode($header)) //
56 long_info1 DATA
- . sprintf("%120s", '') // 57
long_info2
- . sprintf("%10s", '') // 58
just white space..
- . sprintf("%08s", '') // 59
main_apar_id
- . sprintf("%50s", '') // 60
mark_attention
- . sprintf("%3s", '') // 61
mark_ctry_cd
- . sprintf("%120s", '') // 62
markings
- . sprintf("%-17s", '') // 63
obs_date
- . sprintf("%-17s", '') // 64
order_date
- . sprintf("%09.9s", $serial_number) // 65
order_id DATA
- . 'FS' // 66
order_type DATA
- . 'IP' // 67
pay_method DATA
+ '1' // 1 accept_flag
+ . sprintf("%8s", '') // 2 just
white space..
+ . sprintf("%20s", '') // 3 accountable
+ . sprintf("%160s", '') // 4 address
+ . sprintf("%20s", '') // 5-7 just
white space..
+ . sprintf("%08s", '') // 8 apar_id
+ . sprintf("%30s", '') // 9 apar_name
+ . sprintf("%50s", '') // 10-11 just white
space..
+ . sprintf("%2s", '') // 12 att_1_id
+ . sprintf("%2s", '') // 13 att_2_id
+ . sprintf("%2s", '') // 14 att_3_id
+ . sprintf("%2s", '') // 15 att_4_id
+ . sprintf("%2s", '') // 16 att_5_id
+ . sprintf("%2s", '') // 17 att_6_id
+ . sprintf("%2s", '') // 18 att_7_id
+ . sprintf("%35s", '') // 19
bank_account
+ . sprintf("%-12s", "BKBPE{$this->date_str}") //
20 batch_id DATA
+ . 'BY' // 21 client
DATA
+ . sprintf("%2s", '') // 22
client_ref
+ . sprintf("%-17s", "{$this->date_str}") // 23
confirm_date DATA
+ . sprintf("%1s", '') // 24 control
+ . sprintf("%17s", '') // 25 just
white space..
+ . 'NOK' // 26 currency
DATA
+ . sprintf("%60s", '') // 27
del_met_descr
+ . sprintf("%60s", '') // 28
del_term_descr
+ . sprintf("%255s", '') // 29
deliv_addr
+ . sprintf("%50s", '') // 30
deliv_attention
+ . sprintf("%3s", '') // 31
deliv_countr
+ . sprintf("%-17s", "{$this->date_str}") // 32
deliv_date DATA
+ . sprintf("%8s", '') // 33
deliv_method
+ . sprintf("%8s", '') // 34
deliv_terms
+ . sprintf("%52s", '') // 35-41 just white
space..
+ . sprintf("%-12.12s", $account) // 42
dim_value_1 DATA
+ . sprintf("%12s", '') // 43
dim_value_2
+ . sprintf("%12s", '') // 44
dim_value_3
+ . sprintf("%12s", '') // 45
dim_value_4
+ . sprintf("%12s", '') // 46
dim_value_5
+ . sprintf("%12s", '') // 47
dim_value_6
+ . sprintf("%12s", '') // 48
dim_value_7
+ . sprintf("%17s", '') // 49-50 just white
space..
+ . sprintf("%017s", '') // 51
exch_rate
+ . sprintf("%-15.15s", $client_ref) // 52
ext_ord_ref
+ . sprintf("%6s", '') // 53
intrule_id
+ . sprintf("%8s", '') // 54-55 just white
space..
+ . sprintf("%-120.120s", utf8_decode($header)) //
56 long_info1 DATA
+ . sprintf("%120s", '') // 57
long_info2
+ . sprintf("%10s", '') // 58 just
white space..
+ . sprintf("%08s", '') // 59
main_apar_id
+ . sprintf("%50s", '') // 60
mark_attention
+ . sprintf("%3s", '') // 61
mark_ctry_cd
+ . sprintf("%120s", '') // 62 markings
+ . sprintf("%-17s", '') // 63 obs_date
+ . sprintf("%-17s", '') // 64
order_date
+ . sprintf("%09.9s", $serial_number) // 65
order_id DATA
+ . 'FS' // 66 order_type
DATA
+ . 'IP' // 67 pay_method
DATA
// (68)
. sprintf("%02s", '')
. sprintf("%04.4s", $bill_year)
- . sprintf("%02.2s", $bill_month) //
69 period DATA
- . sprintf("%30s", '') // 70
place
- . sprintf("%40s", '') // 71
province
- . sprintf("%12s", '') // 72
just white space..
- . sprintf("%-8s", 'BKBPE') // 73
responsible DATA
- . sprintf("%-8s", 'BKBPE') // 74
responsible2 DATA
- . sprintf("%8s", '') // 75
just white space..
- . sprintf("%-08s", '') // 76
sequence_ref
- . sprintf("%80s", '') // 77-78 just
white space..
- . 'N' // 79 status
DATA
- . sprintf("%4s", '') // 80-82 just
white space..
- . sprintf("%08s", '') // 83
template_id
- . sprintf("%2s", '') // 84
terms_id
- . sprintf("%12s", '') // 85
tekx1
- . sprintf("%-12s", $party_id) // 86
tekst2 DATA
- . sprintf("%12s", '') // 87
tekst3
- . sprintf("%12s", '') // 88
text4
- . '42' // 89
trans_type DATA
- . sprintf("%70s", '') // 90-92 just
white space..
- . sprintf("%09s", '') // 93
voucher_ref
- . 'FU' // 94
voucher_type DATA
- . sprintf("%4s", '') // 95
just white space..
- . sprintf("%15s", '') // 96
zip_code
+ . sprintf("%02.2s", $bill_month) // 69
period DATA
+ . sprintf("%30s", '') // 70 place
+ . sprintf("%40s", '') // 71 province
+ . sprintf("%12s", '') // 72 just
white space..
+ . sprintf("%-8s", 'BKBPE') // 73
responsible DATA
+ . sprintf("%-8s", 'BKBPE') // 74
responsible2 DATA
+ . sprintf("%8s", '') // 75 just
white space..
+ . sprintf("%-08s", '') // 76
sequence_ref
+ . sprintf("%80s", '') // 77-78 just white
space..
+ . 'N' // 79 status
DATA
+ . sprintf("%4s", '') // 80-82 just white
space..
+ . sprintf("%08s", '') // 83
template_id
+ . sprintf("%2s", '') // 84 terms_id
+ . sprintf("%12s", '') // 85 tekx1
+ . sprintf("%-12s", $party_id) // 86
tekst2 DATA
+ . sprintf("%12s", '') // 87 tekst3
+ . sprintf("%12s", '') // 88 text4
+ . '42' // 89 trans_type
DATA
+ . sprintf("%70s", '') // 90-92 just white
space..
+ . sprintf("%09s", '') // 93
voucher_ref
+ . 'FU' // 94 voucher_type
DATA
+ . sprintf("%4s", '') // 95 just
white space..
+ . sprintf("%15s", '') // 96 zip_code
;
$item_counter = 0;
foreach($product_items as $item) // All products
(=price items)
{
$order[] = // Product line
- '0' // 1
0 for påfølgende linjer etter ordrehde
- . sprintf("%8s", '') // 2
account
- . sprintf("%180s", '') // 3-4
just white space..
- . sprintf("%2s", '') // 5
allocation_key
+ '0' // 1 0 for
påfølgende linjer etter ordrehde
+ . sprintf("%8s", '') // 2 account
+ . sprintf("%180s", '') // 3-4
just white space..
+ . sprintf("%2s", '') // 5
allocation_key
. $this->get_formatted_amount($item['amount'])
// 6 amount DATA
- . '1' // 7
amount_set
- . sprintf("%38s", '') // 8-9
just white space..
+ . '1' // 7 amount_set
+ . sprintf("%38s", '') // 8-9
just white space..
. sprintf("%-35.35s",
utf8_decode($item['article_description'])) // 10 art_descr
DATA
- . sprintf("%-15.15s", $item['article_code'])
// 11 article DATA
- . sprintf("%49s", '') // 12-19
just white space..
- . sprintf("%-12s", "BKBPE{$this->date_str}")
// 20 batch_id DATA
- . 'BY' // 21
client DATA
- . sprintf("%20s", '') // 22-24
just white space..
- . sprintf("%017s", '') // 25
cur_amount
- . sprintf("%464s", '') // 26-34
just white space..
- . sprintf("%-8.8s", $responsibility) //
35 dim_1 DATA
- . sprintf("%-8.8s", $service) // 36
dim_2 DATA
- . sprintf("%8s", '') // 37
dim_3
- . sprintf("%8s", '') // 38
dim_4
- . sprintf("%-12.12s", $project) // 39
dim_5 DATA
- . sprintf("%4s", '') // 40
dim_6
- . sprintf("%4s", '') // 41
dim_7
- . sprintf("%84s", '') // 42-48
just white space..
- . sprintf("%017s", '') // 49
disc_percent
+ . sprintf("%-15.15s", $item['article_code']) //
11 article DATA
+ . sprintf("%49s", '') // 12-19 just
white space..
+ . sprintf("%-12s", "BKBPE{$this->date_str}") //
20 batch_id DATA
+ . 'BY' // 21 client
DATA
+ . sprintf("%20s", '') // 22-24 just
white space..
+ . sprintf("%017s", '') // 25
cur_amount
+ . sprintf("%464s", '') // 26-34 just
white space..
+ . sprintf("%-8.8s", $responsibility) //
35 dim_1 DATA
+ . sprintf("%-8.8s", $service) // 36
dim_2 DATA
+ . sprintf("%8s", '') // 37
dim_3
+ . sprintf("%8s", '') // 38
dim_4
+ . sprintf("%-12.12s", $project) // 39
dim_5 DATA
+ . sprintf("%4s", '') // 40
dim_6
+ . sprintf("%4s", '') // 41
dim_7
+ . sprintf("%84s", '') // 42-48 just
white space..
+ . sprintf("%017s", '') // 49
disc_percent
// (50)
- . sprintf("%017s", '') // 51
exch_rate
- . sprintf("%21s", '') // 52-53
just white space..
- . sprintf("%04.4s", ++$item_counter) //
54 line_no DATA
- . sprintf("%4s", '') // 55
location
- . sprintf("%240s", '') // 56-57
just white space..
- . sprintf("%10s", '') // 58
lot
- . sprintf("%215s", '') // 59-64
just white space..
- . sprintf("%09.9s", $serial_number) //
65 order_id DATA
- . sprintf("%4s", '') // 66-67
just white space..
+ . sprintf("%017s", '') // 51
exch_rate
+ . sprintf("%21s", '') // 52-53 just
white space..
+ . sprintf("%04.4s", ++$item_counter) //
54 line_no DATA
+ . sprintf("%4s", '') // 55
location
+ . sprintf("%240s", '') // 56-57 just
white space..
+ . sprintf("%10s", '') // 58
lot
+ . sprintf("%215s", '') // 59-64 just
white space..
+ . sprintf("%09.9s", $serial_number) //
65 order_id DATA
+ . sprintf("%4s", '') // 66-67 just
white space..
// (68)
. sprintf("%02s", '')
. sprintf("%04.4s", $bill_year)
- . sprintf("%02.2s", $bill_month) //
69 period DATA
- . sprintf("%70s", '') // 70-71
just white space..
- . sprintf("%12s", '') // 72
rel_value
- . sprintf("%16s", '') // 73-74
just white space..
- . sprintf("%08s", '') // 75
sequence_no
- . sprintf("%8s", '') // 76
just white space..
- . sprintf("%20s", '') // 77
serial_no
- . sprintf("%60s", '') // 78
just white space..
- . 'N' // 79
status DATA
+ . sprintf("%02.2s", $bill_month) //
69 period DATA
+ . sprintf("%70s", '') // 70-71 just
white space..
+ . sprintf("%12s", '') // 72
rel_value
+ . sprintf("%16s", '') // 73-74 just
white space..
+ . sprintf("%08s", '') // 75
sequence_no
+ . sprintf("%8s", '') // 76
just white space..
+ . sprintf("%20s", '') // 77
serial_no
+ . sprintf("%60s", '') // 78
just white space..
+ . 'N' // 79 status
DATA
// (80)
- . sprintf("%2s", '') // 81
tax_code
- . sprintf("%2s", '') // 82
tax_system
- . sprintf("%-08s", '') // 83
template_id
- . sprintf("%50s", '') // 84-88
just white space..
- . '42' // 89
trans_type
- . sprintf("%3s", '') // 90
unit_code
- . sprintf("%50s", '') // 91
unit_descr
- . sprintf("%017s", 1 * 100) //
92 value_1 DATA
- . sprintf("%9s", '') // 93
just white space..
- . 'FU' // 94
voucher_type DATA
- . sprintf("%4s", '') // 95
warehouse
- . sprintf("%15s", '') // 96
just white space..
+ . sprintf("%2s", '') // 81
tax_code
+ . sprintf("%2s", '') // 82
tax_system
+ . sprintf("%-08s", '') // 83
template_id
+ . sprintf("%50s", '') // 84-88 just
white space..
+ . '42' // 89 trans_type
+ . sprintf("%3s", '') // 90
unit_code
+ . sprintf("%50s", '') // 91
unit_descr
+ . sprintf("%017s", 1 * 100) // 92
value_1 DATA
+ . sprintf("%9s", '') // 93
just white space..
+ . 'FU' // 94 voucher_type
DATA
+ . sprintf("%4s", '') // 95
warehouse
+ . sprintf("%15s", '') // 96
just white space..
;
$order[] = // Text line
'0' . // 1
- sprintf("%345s", '') // 2-19
just white space.. DATA
- . sprintf("%-12s", "BKBPE{$this->date_str}")
// 20 batch_id DATA
- . 'BY' // 21
client DATA
- . sprintf("%692s", '') // 22-53
just white space..
- . sprintf("%04.4s", $item_counter) //
54 line_no DATA
- . sprintf("%469s", '') // 55-64
just white space..
- . sprintf("%09.9s", $serial_number) //
65 order_id DATA
- . sprintf("%110s", '') // 66-74
just white space..
- . sprintf("%08s", 1) // 75
sequence_no DATA
- . sprintf("%28s", '') // 76-77
just white space..
- . sprintf("%-60.60s", utf8_decode($text))
// 78 shot_info DATA
- . sprintf("%63s", '') // 79-88
just white space..
- . '42' // 89
trans_type DATA
- . sprintf("%79s", '') // 90-93
just white space..
- . 'FU' // 94
voucher_type DATA
- . sprintf("%19s", '') // 95-96
just white space..
+ sprintf("%345s", '') // 2-19 just
white space.. DATA
+ . sprintf("%-12s", "BKBPE{$this->date_str}") //
20 batch_id DATA
+ . 'BY' // 21 client
DATA
+ . sprintf("%692s", '') // 22-53 just
white space..
+ . sprintf("%04.4s", $item_counter) //
54 line_no DATA
+ . sprintf("%469s", '') // 55-64 just
white space..
+ . sprintf("%09.9s", $serial_number) //
65 order_id DATA
+ . sprintf("%110s", '') // 66-74 just
white space..
+ . sprintf("%08s", 1) // 75
sequence_no DATA
+ . sprintf("%28s", '') // 76-77 just
white space..
+ . sprintf("%-60.60s", utf8_decode($text)) //
78 shot_info DATA
+ . sprintf("%63s", '') // 79-88 just
white space..
+ . '42' // 89 trans_type
DATA
+ . sprintf("%79s", '') // 90-93 just
white space..
+ . 'FU' // 94 voucher_type
DATA
+ . sprintf("%19s", '') // 95-96 just
white space..
;
}
return str_replace(array("\n", "\r"), '', $order);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11826] rental : add transactions, formatting,
Sigurd Nes <=