[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7262] bkbooking: updated revervation export
From: |
Kjell Arne Espedal |
Subject: |
[Fmsystem-commits] [7262] bkbooking: updated revervation export |
Date: |
Fri, 06 May 2011 11:09:29 +0000 |
Revision: 7262
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7262
Author: kjell
Date: 2011-05-06 11:09:28 +0000 (Fri, 06 May 2011)
Log Message:
-----------
bkbooking: updated revervation export
Modified Paths:
--------------
trunk/booking/inc/class.customer_identifier.inc.php
trunk/booking/inc/class.socompleted_reservation.inc.php
trunk/booking/inc/class.socompleted_reservation_export.inc.php
trunk/booking/inc/class.socompleted_reservation_export_file.inc.php
trunk/booking/inc/class.uicompleted_reservation_export.inc.php
trunk/booking/setup/phpgw_no.lang
trunk/booking/templates/base/account_code_dimension.xsl
Modified: trunk/booking/inc/class.customer_identifier.inc.php
===================================================================
--- trunk/booking/inc/class.customer_identifier.inc.php 2011-05-06 10:09:21 UTC
(rev 7261)
+++ trunk/booking/inc/class.customer_identifier.inc.php 2011-05-06 11:09:28 UTC
(rev 7262)
@@ -25,7 +25,22 @@
if ($from_entity_customer_identifier =
$this->get_current_identifier_type($from_entity))
{
$to_entity[$this->identifier_type_field] =
$from_entity_customer_identifier;
-
$to_entity[$this->field_prefix.$from_entity_customer_identifier] =
$this->get_current_identifier_value($from_entity);
+ if(intval($from_entity['customer_internal']) == 1)
+ {
+ if (strlen($from_entity['customer_number']) == 5)
+ {
+
$to_entity[$this->field_prefix.$from_entity_customer_identifier] =
$from_entity['customer_number'];
+ }
+ else
+ {
+
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = '';
+ }
+ }
+ else
+ {
+
$to_entity[$this->field_prefix.$from_entity_customer_identifier] =
$this->get_current_identifier_value($from_entity);
+ }
+
}
}
@@ -95,7 +110,7 @@
$identifier_field =
$this->field_prefix.$identifier_field;
$identifier_value = isset($data[$identifier_field]) ?
trim($data[$identifier_field]) : null;
-
+
return (empty($identifier_value) ? null :
$identifier_value);
}
Modified: trunk/booking/inc/class.socompleted_reservation.inc.php
===================================================================
--- trunk/booking/inc/class.socompleted_reservation.inc.php 2011-05-06
10:09:21 UTC (rev 7261)
+++ trunk/booking/inc/class.socompleted_reservation.inc.php 2011-05-06
11:09:28 UTC (rev 7262)
@@ -140,10 +140,10 @@
}
$entity = array(
- 'reservation_type' => $type,
+ 'reservation_type' => $type,
'reservation_id' =>
$reservation['id'],
'cost' =>
$reservation['cost'],
- 'from_'
=> $reservation['from_'],
+ 'from_' =>
$reservation['from_'],
'to_' =>
$reservation['to_'],
'customer_type' => 'external',
'resources' =>
$reservation['resources'],
@@ -262,7 +262,15 @@
protected function set_organization(&$entity, &$organization) {
$entity['organization_id'] = $organization['id'];
- $entity['customer_organization_number'] =
$organization['organization_number'];
+ if (intval($organization['customer_internal']) == 1) {
+ if (strlen($organization['customer_number']) == 5) {
+ $entity['customer_organization_number'] =
$organization['customer_number'];
+ } else {
+ $entity['customer_organization_number'] = '';
+ }
+ } else {
+ $entity['customer_organization_number'] =
$organization['organization_number'];
+ }
}
protected function initialize_completed_booking(&$booking,
&$entity) {
@@ -279,10 +287,10 @@
$org =
$soorg->read_single($group['organization_id']);
$cache[$booking['group_id']] = $org;
}
-
+
$this->set_organization($entity, $org);
- $this->set_customer_type($entity, $org);
- $this->copy_customer_identifier($org, $entity);
+ $this->set_customer_type($entity, $org);
+ $this->copy_customer_identifier($org, $entity);
}
protected function
initialize_completed_allocation(&$allocation, &$entity) {
Modified: trunk/booking/inc/class.socompleted_reservation_export.inc.php
===================================================================
--- trunk/booking/inc/class.socompleted_reservation_export.inc.php
2011-05-06 10:09:21 UTC (rev 7261)
+++ trunk/booking/inc/class.socompleted_reservation_export.inc.php
2011-05-06 11:09:28 UTC (rev 7262)
@@ -98,7 +98,15 @@
* Normalizes data on entity.
*/
public function initialize_entity(&$entity) {
- if (isset($entity['__initialized__']) &&
$entity['__initialized__'] === true) { return $entity; }
+ ob_start();
+ $myFile = "/tmp/debug2.txt";
+ $fh = fopen($myFile, 'w') or die("can't open file");
+ echo '<pre>';print_r($entity);
+ $op = ob_get_contents();
+ fwrite($fh, $op);
+ fclose($fh);
+ ob_end_clean();
+ if (isset($entity['__initialized__']) &&
$entity['__initialized__'] === true) { return $entity; }
$entity['__initialized__'] = true;
//re-index export configurations on their types
@@ -278,7 +286,7 @@
$export_format,
count(array_filter($external_reservations, array($this, 'not_free'))),
$this->calculate_total_cost($external_reservations),
-
$this->format_agresso($external_reservations, $account_codes, $number_generator)
+
$this->format_agresso($external_reservations, $account_codes,
$number_generator,'external')
);
}
}
@@ -289,7 +297,17 @@
* @return array with three elements where index 0: total_rows,
index 1: total_cost, index 2: formatted data
*/
public function export_internal(array &$reservations, array
$account_codes) {
- $export_format = 'csv';
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+
+ if ($config->config_data['internal_format'] == 'CSV')
+ {
+ $export_format = 'csv';
+ }
+ elseif ($config->config_data['internal_format'] == 'AGGRESSO')
+ {
+ $export_format = 'agresso';
+ }
if (is_array($reservations)) {
if (count($internal_reservations =
array_filter($reservations, array($this, 'select_internal'))) > 0) {
@@ -297,12 +315,24 @@
if (!($number_generator =
$this->sequential_number_generator_so->get_generator_instance('internal'))) {
throw new
UnexpectedValueException("Unable to find sequential number generator for
internal export");
}
- return $this->build_export_result(
- $export_format,
-
count(array_filter($internal_reservations, array($this, 'not_free'))),
-
$this->calculate_total_cost($internal_reservations),
-
$this->format_csv($internal_reservations, $account_codes, $number_generator)
- );
+ if ($config->config_data['internal_format'] == 'CSV')
+ {
+ return
$this->build_export_result(
+ $export_format,
+
count(array_filter($internal_reservations, array($this, 'not_free'))),
+
$this->calculate_total_cost($internal_reservations),
+
$this->format_csv($internal_reservations, $account_codes, $number_generator)
+ );
+ }
+ elseif ($config->config_data['internal_format'] ==
'AGGRESSO')
+ {
+ return
$this->build_export_result(
+ $export_format,
+
count(array_filter($internal_reservations, array($this, 'not_free'))),
+
$this->calculate_total_cost($internal_reservations),
+
$this->format_agresso($internal_reservations, $account_codes,
$number_generator,'internal')
+ );
+ }
}
}
return $this->build_export_result($export_format, 0,
0.0);
@@ -558,7 +588,7 @@
}
}
- public function format_agresso(array &$reservations, array
$account_codes, $sequential_number_generator) {
+ public function format_agresso(array &$reservations, array
$account_codes, $sequential_number_generator,$type) {
//$orders = array();
$export_info = array();
$output = array();
@@ -603,6 +633,8 @@
$trans_type = str_pad(substr(strtoupper('42'), 0, 2),
2, ' ');
$voucher_type = str_pad(substr(strtoupper('FK'), 0, 2),
2, ' ');
+// echo "<pre>";print_r($reservations);exit;
+
foreach($reservations as &$reservation) {
if ($this->get_cost_value($reservation['cost'])
<= 0) {
continue; //Don't export costless rows
@@ -642,7 +674,12 @@
}
//Nøkkelfelt, kundens personnr/orgnr.
- $header['tekst2'] =
str_pad(substr($this->get_customer_identifier_value_for($reservation), 0, 12),
12, ' ');
+ if ($type == 'internal') {
+ $header['tekst2'] =
str_pad(substr($config->config_data['organization_value'], 0, 12), 12, ' ');
+ $header['ext_ord_ref'] =
str_pad(substr($this->get_customer_identifier_value_for($reservation), 0, 15),
15, ' ');
+ } else {
+ $header['tekst2'] =
str_pad(substr($this->get_customer_identifier_value_for($reservation), 0, 12),
12, ' ');
+ }
$header['line_no'] = '0000'; //Nothing here
according to example file but spec. says so
//Topptekst til faktura, knyttet mot fagavdeling
Modified: trunk/booking/inc/class.socompleted_reservation_export_file.inc.php
===================================================================
--- trunk/booking/inc/class.socompleted_reservation_export_file.inc.php
2011-05-06 10:09:21 UTC (rev 7261)
+++ trunk/booking/inc/class.socompleted_reservation_export_file.inc.php
2011-05-06 11:09:28 UTC (rev 7262)
@@ -9,7 +9,7 @@
$so_completed_reservation_export;
protected static $export_type_to_file_type_map = array(
- 'internal' => 'csv',
+ 'internal' => 'csv',
'external' => 'txt',
);
@@ -34,9 +34,26 @@
}
protected function file_type_for_export_type($export_type) {
- return
isset(self::$export_type_to_file_type_map[$export_type]) ?
-
self::$export_type_to_file_type_map[$export_type] :
- 'txt';
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+
+ if ($export_type === 'internal') {
+ if ($config->config_data['internal_format'] == 'CSV')
+ {
+ return 'csv';
+ }
+ elseif ($config->config_data['internal_format'] == 'AGGRESSO')
+ {
+ return 'txt';
+ }
+ } elseif ($export_type === 'external'){
+ return 'txt';
+ } else {
+ return 'txt';
+ }
+# return
isset(self::$export_type_to_file_type_map[$export_type]) ?
+#
self::$export_type_to_file_type_map[$export_type] :
+# 'txt';
}
protected function get_available_export_types() {
@@ -193,4 +210,4 @@
}
} catch (booking_unattached_storage_object $e) { }
}
- }
\ No newline at end of file
+ }
Modified: trunk/booking/inc/class.uicompleted_reservation_export.inc.php
===================================================================
--- trunk/booking/inc/class.uicompleted_reservation_export.inc.php
2011-05-06 10:09:21 UTC (rev 7261)
+++ trunk/booking/inc/class.uicompleted_reservation_export.inc.php
2011-05-06 11:09:28 UTC (rev 7262)
@@ -186,8 +186,8 @@
)
);
}
- $data['filters'] = extract_values($_GET,
array("filter_to"));
-
+ $data['filters'] = extract_values($_GET, array("filter_to"));
+
$this->render_template('datatable', $data);
}
@@ -236,8 +236,9 @@
$this->db = $GLOBALS['phpgw']->db;
$exports = $this->bo->read();
array_walk($exports["results"], array($this,
"_add_links"), $this->module.".uicompleted_reservation_export.show");
+
foreach($exports["results"] as &$export) {
- $export = $this->bo->initialize_entity($export);
+ $export =
$this->bo->so->initialize_entity($export);
$this->add_default_display_data($export);
$sql = "SELECT account_lastname,
account_firstname FROM phpgw_accounts WHERE account_lid =
'".$export['created_by_name']."'";
@@ -246,7 +247,6 @@
$export['created_by_name'] =
$record['account_firstname']." ".$record['account_lastname'];
}
}
-
$results = $this->yui_results($exports);
return $results;
}
Modified: trunk/booking/setup/phpgw_no.lang
===================================================================
--- trunk/booking/setup/phpgw_no.lang 2011-05-06 10:09:21 UTC (rev 7261)
+++ trunk/booking/setup/phpgw_no.lang 2011-05-06 11:09:28 UTC (rev 7262)
@@ -511,3 +511,6 @@
To cancel allocation use this link booking no For å slette
tildelingen bruk lenken
Show applications booking no Vis søknader
Show messages booking no Vis beskjeder
+Internal account booking no Intern kontering
+Internal customer output format booking no Intern kunde eksport
format
+Internal_account_helptext booking no Data som brukes for faktura
eksport av interne kunder
Modified: trunk/booking/templates/base/account_code_dimension.xsl
===================================================================
--- trunk/booking/templates/base/account_code_dimension.xsl 2011-05-06
10:09:21 UTC (rev 7261)
+++ trunk/booking/templates/base/account_code_dimension.xsl 2011-05-06
11:09:28 UTC (rev 7262)
@@ -69,6 +69,38 @@
</input>
</dd>
</dl>
+ <div class="clr"/>
+ <dl class="form">
+ <dt class="heading"><xsl:value-of select="php:function('lang',
'Internal account')"/></dt>
+ </dl>
+
+ <p><xsl:value-of select="php:function('lang',
'Internal_account_helptext')"/></p>
+
+ <dl class="form-col">
+ <dt><label for="field_organization_value"><xsl:value-of
select="php:function('lang', 'Organization number')"/></label></dt>
+ <dd>
+ <input id="field_organization_value"
name="organization_value" type="text">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/organization_value"/></xsl:attribute>
+ </input>
+ </dd>
+ <dt><label for="field_internal_format"><xsl:value-of
select="php:function('lang', 'Internal customer output format')"/></label></dt>
+ <dd>
+ <select id="field_internal_format"
name="internal_format">
+ <option value="AGGRESSO">
+ <xsl:if test="config_data/internal_format='AGGRESSO'">
+ <xsl:attribute
name="selected">checked</xsl:attribute>
+ </xsl:if>
+ AGGRESSO
+ </option>
+ <option value="CSV">
+ <xsl:if test="config_data/internal_format='CSV'">
+ <xsl:attribute
name="selected">checked</xsl:attribute>
+ </xsl:if>
+ CSV
+ </option>
+ </select>
+ </dd>
+ </dl>
<div class="form-buttons">
<input type="submit">
<xsl:attribute name="value"><xsl:value-of
select="php:function('lang', 'Save')"/></xsl:attribute>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7262] bkbooking: updated revervation export,
Kjell Arne Espedal <=