[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8219] bkbooking: added warning to booking when there
From: |
Kjell Arne Espedal |
Subject: |
[Fmsystem-commits] [8219] bkbooking: added warning to booking when there is a cost in allocation, added ftp export for agresso |
Date: |
Wed, 30 Nov 2011 12:18:34 +0000 |
Revision: 8219
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8219
Author: kjell
Date: 2011-11-30 12:16:12 +0000 (Wed, 30 Nov 2011)
Log Message:
-----------
bkbooking: added warning to booking when there is a cost in allocation, added
ftp export for agresso
Modified Paths:
--------------
trunk/booking/inc/class.uibooking.inc.php
trunk/booking/inc/class.uicompleted_reservation_export_file.inc.php
trunk/booking/setup/phpgw_no.lang
trunk/booking/templates/base/account_code_dimension.xsl
Added Paths:
-----------
trunk/booking/inc/class.export_agresso.inc.php
Added: trunk/booking/inc/class.export_agresso.inc.php
===================================================================
--- trunk/booking/inc/class.export_agresso.inc.php
(rev 0)
+++ trunk/booking/inc/class.export_agresso.inc.php 2011-11-30 12:16:12 UTC
(rev 8219)
@@ -0,0 +1,144 @@
+<?php
+
+ /**
+ * Hvordan overføre filer til agresseo: ekempel fra 'property'
+ * Prosedyre: 1) Lag filnavn
+ * 2) Produser filen
+ * 3) Lagre filen lokalt (for
referanse/historikk/feilbehandling)
+ * 4) Overfør filen til Agresso
+ * 5) Evnt logg til databasen hvordan
dette gikk
+ *
+ * Forutsetning:1) configurasjon for lokal lagring (katalog)
+ * 2) configurasjon for pålogging til
ftp-server (IP/Login/Passord/envt katalog)
+ *
+ */
+
+ class export_agresso
+ {
+ function __construct()
+ {
+ $this->db =
&$GLOBALS['phpgw']->db;
+ $this->config =
CreateObject('phpgwapi.config','booking');
+ $this->config->read_repository();
+ }
+
+ public function do_your_magic($buffer,$id)
+ {
+ // Viktig: må kunne rulle tilbake dersom noe feiler.
+ $this->db->transaction_begin();
+
+// $buffer = 'test';
+
+ $filnavn = $this->lagfilnavn();
+
+ $file_written = false;
+
+ $fp = fopen($filnavn, "wb");
+ fwrite($fp,$buffer);
+
+ if(fclose($fp))
+ {
+ $file_written=true;
+ }
+
+ if($file_written &&
$this->config->config_data['invoice_export_method']!='ftp')
+ {
+ $transfer_ok = true;
+ }
+ else if($file_written)
+ {
+ $transfer_ok = $this->transfer($filnavn);
+ }
+
+ if($transfer_ok)
+ {
+ $this->db->transaction_commit();
+ $this->config->config_data['invoice_last_id'] =
$id;
+ $this->config->save_repository();
+ $message = "Godkjent: periode: {$Periode}
antall bilag/underbilag overfort: {$antall} , fil: {$filnavn}";
+ }
+ else
+ {
+ $this->db->transaction_abort();
+ $message = 'Noe gikk galt med overforing av
godkjendte fakturaer!';
+ }
+ return $message;
+ }
+
+
+ protected function lagfilnavn()
+ {
+ $fil_katalog =
$this->config->config_data['invoice_export_path'];
+ $continue = true;
+ $i = 1;
+ do
+ {
+ $filnavn = $fil_katalog . '/FDB' . date("dmy")
. '_' . sprintf("%02s",$i) . '.TXT';
+
+ //Sjekk om filen eksisterer
+ If (!file_exists($filnavn))
+ {
+ return $filnavn;
+ }
+
+ $i++;
+ }
+ while ($continue);
+
+ //Ingen løpenr er ledige, gi feilmelding
+ return false;
+ }
+
+ protected function transfer($filnavn)
+ {
+
+
if($this->config->config_data['invoice_export_method']=='ftp')
+ {
+
+ $transfer_ok = false;
+ $ftp = $this->phpftp_connect();
+ $basedir =
$this->config->config_data['invoice_ftp_basedir'];
+
+
+ if($basedir)
+ {
+ $newfile = $basedir . '/' .
basename($filnavn);
+ }
+ else
+ {
+ $newfile = basename($filnavn);
+ }
+
+ if (ftp_put($ftp, $newfile,$filnavn,
FTP_BINARY))
+ {
+ //log_transaction_ok
+ $transfer_ok = True;
+ }
+ else
+ {
+ //log_transaction_feil
+ $transfer_ok = false;
+ unlink($filnavn);
+ }
+ ftp_quit($ftp);
+ }
+ return $transfer_ok;
+ }
+
+ protected function phpftp_connect()
+ {
+ $host = $this->config->config_data['invoice_ftp_host'];
+ $user = $this->config->config_data['invoice_ftp_user'];
+ $pass =
$this->config->config_data['invoice_ftp_password'];
+
+ $ftp = ftp_connect($host);
+ if($ftp)
+ {
+ if ($lres = ftp_login($ftp,$user,$pass))
+ {
+ return $ftp;
+ }
+ }
+ }
+ }
+
Modified: trunk/booking/inc/class.uibooking.inc.php
===================================================================
--- trunk/booking/inc/class.uibooking.inc.php 2011-11-29 13:57:01 UTC (rev
8218)
+++ trunk/booking/inc/class.uibooking.inc.php 2011-11-30 12:16:12 UTC (rev
8219)
@@ -431,7 +431,11 @@
}
}
}
+ if($allocation['cost'] > 0) {
+ $errors['cost'] = lang('There is a cost of %1
assosiated with the allocation you are useing',$allocation['cost']);
+ }
$this->flash_form_errors($errors);
+ unset($errors['cost']);
self::add_javascript('booking', 'booking',
'booking.js');
array_set_default($booking, 'resources', array());
$booking['resources_json'] =
json_encode(array_map('intval', $booking['resources']));
Modified: trunk/booking/inc/class.uicompleted_reservation_export_file.inc.php
===================================================================
--- trunk/booking/inc/class.uicompleted_reservation_export_file.inc.php
2011-11-29 13:57:01 UTC (rev 8218)
+++ trunk/booking/inc/class.uicompleted_reservation_export_file.inc.php
2011-11-30 12:16:12 UTC (rev 8219)
@@ -9,6 +9,7 @@
'show' => true,
'add' => true,
'download' => true,
+ 'upload' => true,
);
protected
@@ -18,8 +19,10 @@
{
parent::__construct();
$this->bo =
CreateObject('booking.bocompleted_reservation_export_file');
+ $this->export_agresso =
CreateObject('booking.export_agresso');
self::set_active_menu('booking::invoice_center::generated_files');
$this->url_prefix =
'booking.uicompleted_reservation_export_file';
+
}
public function link_to($action, $params = array())
@@ -112,6 +115,12 @@
'sortable' => false,
),
array(
+ 'key' => 'upload',
+ 'label' =>
lang('Export'),
+ 'formatter' =>
'YAHOO.booking.formatGenericLink()',
+ 'sortable' => false,
+ ),
+ array(
'key' => 'link',
'hidden' => true
),
@@ -125,6 +134,9 @@
public function index_json()
{
$this->db = $GLOBALS['phpgw']->db;
+ $config = CreateObject('phpgwapi.config','booking');
+ $config->read();
+ if ($config->config_data['output_files'] == 'single')
$export_files = $this->bo->read();
array_walk($export_files["results"], array($this,
"_add_links"), $this->module.".uicompleted_reservation_export_file.show");
foreach($export_files["results"] as &$export_file) {
@@ -135,7 +147,18 @@
'label' => lang('Download'),
'href' => $this->link_to('download',
array('id' => $export_file['id']))
);
-
+ if ($export_file['total_items'] > 0 and
$export_file['id'] > $config->config_data['invoice_last_id'])
+ {
+ $export_file['upload'] = array(
+ 'label' => lang('Upload'),
+ 'href' =>
$this->link_to('upload', array('id' => $export_file['id']))
+ );
+ } else {
+ $export_file['upload'] = array(
+ 'label' => ' ',
+ 'href' => '#'
+ );
+ }
$sql = "SELECT account_lastname,
account_firstname FROM phpgw_accounts WHERE account_lid =
'".$export_file['created_by_name']."'";
$this->db->query($sql);
while ($record =
array_shift($this->db->resultSet)) {
@@ -166,4 +189,17 @@
$this->send_file($file->get_system_identifier(),
array('filename' => $file->get_identifier()));
}
+ public function upload() {
+ $id = phpgw::get_var('id', 'GET');
+ $export_file =
$this->bo->read_single(phpgw::get_var('id', 'GET'));
+
+ if (!is_array($export_file)) {
+ $this->redirect_to('index');
+ }
+
+ $file = $this->bo->get_file($export_file);
+ $content =
file_get_contents($file->get_system_identifier(),false);
+ $this->export_agresso->do_your_magic($content,$id);
+ $this->redirect_to('index');
+ }
}
Modified: trunk/booking/setup/phpgw_no.lang
===================================================================
--- trunk/booking/setup/phpgw_no.lang 2011-11-29 13:57:01 UTC (rev 8218)
+++ trunk/booking/setup/phpgw_no.lang 2011-11-30 12:16:12 UTC (rev 8219)
@@ -537,3 +537,6 @@
All that borrow premises from Bergen Kommune must verify that they have read
the terms and conditions, this is usually fire regulations and house rules.
booking no Alle som leier lokaler hos Bergen kommune må bekrefte at de
har lest betingelsene, dette gjelder som regel brannforskrifter og husreglement.
Delete information booking no Hvis du kun skal slette tildeling på
valgt dato, velg Slett-knappen nederst og tiden blir vist som ledig i
kalenderen, og kan tildeles andre klubber/org.
Delete information2 booking no Skal du slette flere kan du velge Ut
sesong eller Slett til og velg en dato, du kan også velge intervall (f.eks.
annen hver uke).
+There is a cost of %1 assosiated with the allocation you are useing booking
no Det er en kostnad på %1kr knyttet til den tildelingen du bruker.
+Export booking no Eksport
+Upload booking no Last opp
Modified: trunk/booking/templates/base/account_code_dimension.xsl
===================================================================
--- trunk/booking/templates/base/account_code_dimension.xsl 2011-11-29
13:57:01 UTC (rev 8218)
+++ trunk/booking/templates/base/account_code_dimension.xsl 2011-11-30
12:16:12 UTC (rev 8219)
@@ -118,6 +118,72 @@
</select>
</dd>
</dl>
+
+ <div class="clr"/>
+
+ <dl class="form">
+ <dt class="heading"><xsl:value-of select="php:function('lang',
'Export aggresso')"/></dt>
+ </dl>
+
+ <p><xsl:value-of select="php:function('lang', 'export_help_text')"/></p>
+
+ <dl class="form-col">
+ <dt><label for="field_invoice_export_method"><xsl:value-of
select="php:function('lang', 'Export method')"/></label></dt>
+ <dd>
+ <select id="field_invoice_export_method"
name="invoice_export_method">
+ <option value="local">
+ <xsl:if
test="config_data/invoice_export_method='local'">
+ <xsl:attribute
name="selected">checked</xsl:attribute>
+ </xsl:if>
+ local
+ </option>
+ <option value="ftp">
+ <xsl:if test="config_data/invoice_export_method='ftp'">
+ <xsl:attribute
name="selected">checked</xsl:attribute>
+ </xsl:if>
+ ftp
+ </option>
+ </select>
+ </dd>
+ <dt><label for="field_invoice_export_path"><xsl:value-of
select="php:function('lang', 'Export path')"/></label></dt>
+ <dd>
+ <input id="field_invoice_export_path"
name="invoice_export_path" type="text">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/invoice_export_path"/></xsl:attribute>
+ </input>
+ </dd>
+ <dt><label for="field_invoice_ftp_host"><xsl:value-of
select="php:function('lang', 'Ftp host')"/></label></dt>
+ <dd>
+ <input id="field_invoice_ftp_host"
name="invoice_ftp_host" type="text">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/invoice_ftp_host"/></xsl:attribute>
+ </input>
+ </dd>
+ <dt><label for="field_invoice_ftp_basedir"><xsl:value-of
select="php:function('lang', 'Ftp basedir')"/></label></dt>
+ <dd>
+ <input id="field_invoice_ftp_basedir"
name="invoice_ftp_basedir" type="text">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/invoice_ftp_basedir"/></xsl:attribute>
+ </input>
+ </dd>
+ <dt><label for="field_invoice_ftp_user"><xsl:value-of
select="php:function('lang', 'Ftp user')"/></label></dt>
+ <dd>
+ <input id="field_invoice_ftp_user"
name="invoice_ftp_user" type="text">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/invoice_ftp_user"/></xsl:attribute>
+ </input>
+ </dd>
+ <dt><label for="field_invoice_ftp_password"><xsl:value-of
select="php:function('lang', 'Ftp password')"/></label></dt>
+ <dd>
+ <input id="field_invoice_ftp_password"
name="invoice_ftp_password" type="password">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/invoice_ftp_password"/></xsl:attribute>
+ </input>
+ </dd>
+ <dt><label for="field_invoice_last_id"><xsl:value-of
select="php:function('lang', 'last id')"/></label></dt>
+ <p><xsl:value-of select="php:function('lang', 'Do not
edit!')"/></p>
+ <dd>
+ <input id="field_invoice_last_id"
name="invoice_last_id" type="text">
+ <xsl:attribute
name="value"><xsl:value-of
select="config_data/invoice_last_id"/></xsl:attribute>
+ </input>
+ </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] [8219] bkbooking: added warning to booking when there is a cost in allocation, added ftp export for agresso,
Kjell Arne Espedal <=