[20936] improvement and fixes: property module updated from upstream
Sigurd Nes <[email protected]> Tue, 05 Jan 2010 21:40:00 +0000
| Newsgroups | gmane.comp.web.phpgroupware.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 20936
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20936
Author: sigurdne
Date: 2010-01-05 21:40:00 +0000 (Tue, 05 Jan 2010)
Log Message:
-----------
improvement and fixes: property module updated from upstream
Modified Paths:
--------------
people/sigurdne/modules/property/trunk/inc/class.boalarm.inc.php
people/sigurdne/modules/property/trunk/inc/class.bocommon.inc.php
people/sigurdne/modules/property/trunk/inc/class.boevent.inc.php
people/sigurdne/modules/property/trunk/inc/class.bogab.inc.php
people/sigurdne/modules/property/trunk/inc/class.boinvoice.inc.php
people/sigurdne/modules/property/trunk/inc/class.bolocation.inc.php
people/sigurdne/modules/property/trunk/inc/class.bolookup.inc.php
people/sigurdne/modules/property/trunk/inc/class.botts.inc.php
people/sigurdne/modules/property/trunk/inc/class.sogab.inc.php
people/sigurdne/modules/property/trunk/inc/class.soinvoice.inc.php
people/sigurdne/modules/property/trunk/inc/class.uigab.inc.php
people/sigurdne/modules/property/trunk/inc/class.uiinvoice.inc.php
people/sigurdne/modules/property/trunk/inc/class.uilookup.inc.php
people/sigurdne/modules/property/trunk/inc/class.uirequest.inc.php
people/sigurdne/modules/property/trunk/inc/class.uitts.inc.php
people/sigurdne/modules/property/trunk/inc/class.uiwo_hour.inc.php
people/sigurdne/modules/property/trunk/inc/class.uiworkorder.inc.php
people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_BKK_csv
people/sigurdne/modules/property/trunk/inc/ods/ods.php
people/sigurdne/modules/property/trunk/js/yahoo/invoice.list_sub.js
people/sigurdne/modules/property/trunk/templates/base/config.tpl
Added Paths:
-----------
people/sigurdne/modules/property/trunk/inc/cron/default/Import_fra_basware_X205.php
Removed Paths:
-------------
people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_basware_X205
Modified: people/sigurdne/modules/property/trunk/inc/class.boalarm.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.boalarm.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.boalarm.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -395,20 +395,18 @@
$current_prefs_user = $this->bocommon->create_preferences('property',$alarm['owner']);
$current_user_address=$current_prefs_user['email'];
- $headers = "Return-Path: <". $current_user_address .">\r\n";
- $headers .= "From: " . $current_user_name . "<" . $current_user_address .">\r\n";
-// $headers .= "Bcc: " . $current_user_name . "<" . $current_user_address .">\r\n";
- $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
-
//-----------from--------
// build body
- $body = '';
- $body .= lang('Alarm').' #'.$alarm['event_id']."\n";
+
+ $info = explode(':', $alarm['id']);
+
+ $body = lang('Alarm').' #'.$alarm['event_id']."\n";
$body .= lang('Name').': '.$alarm['event_name']."\n";
+ $body .= '<a href ="http://' . $GLOBALS['phpgw_info']['server']['hostname'] . $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> "property.ui{$info[0]}.edit", 'id'=> $info[1])).'">' . $alarm['event_name'] ."</a>\n";
if(!is_array($alarm['time']))
{
- $body .= lang('Deadline').': '. $GLOBALS['phpgw']->common->show_date(($alarm['time']+$alarm['offset'])) ."\n";
+ $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $body .= lang('Deadline').': '. $GLOBALS['phpgw']->common->show_date(($alarm['time']+$alarm['offset']),$dateformat) ."\n";
}
$body .= lang('Assigned To').': '.$GLOBALS['phpgw']->accounts->id2name($alarm['owner'])."\n";
@@ -446,7 +444,8 @@
if (isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server'])
{
- $rc = $this->send->msg('email', $to, $subject, stripslashes($body), '', $cc, $bcc,$current_user_address,$current_user_name,'txt');
+ $body = nl2br($body);
+ $rc = $this->send->msg('email', $to, $subject, $body, '', $cc, $bcc,$current_user_address,$current_user_name,'html');
}
else
{
Modified: people/sigurdne/modules/property/trunk/inc/class.bocommon.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.bocommon.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.bocommon.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -436,11 +436,11 @@
foreach ($users_gross as $entry => $user)
{
- if( !array_search($user['account_id'], $accounts ) )
+ if( !isset($accounts[$user['account_id']]) )
{
$users[] = $user;
}
- $accounts[] = $user['account_id'];
+ $accounts[$user['account_id']] = true;
}
unset($users_gross);
unset($accounts);
@@ -2012,6 +2012,12 @@
{
$values['location_name'] = phpgw::get_var('loc' . (count($values['location'])).'_name', 'string', 'POST'); // if not address - get the parent name as address
}
+
+ if(isset($values['location']) && $values['location'])
+ {
+ phpgwapi_cache::session_set('property', 'filter_location', implode('-', $values['location']));
+ }
+
return $values;
}
Modified: people/sigurdne/modules/property/trunk/inc/class.boevent.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.boevent.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.boevent.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -370,7 +370,7 @@
$this->so->cron_log(array
(
'cron' => true, // or false for manual...
- 'action' => $data['action'],
+ 'action' => isset($data['action']) && $data['action'] ? $data['action'] : 'dummy',
'message' => $message
)
);
Modified: people/sigurdne/modules/property/trunk/inc/class.bogab.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.bogab.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.bogab.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -40,6 +40,7 @@
var $sort;
var $order;
var $cat_id;
+ var $gab_insert_level;
var $public_functions = array
(
@@ -50,11 +51,11 @@
'check_perms' => true
);
- function property_bogab($session=false)
+ function __construct($session=false)
{
$this->solocation = CreateObject('property.solocation');
$this->so = CreateObject('property.sogab');
-
+ $this->gab_insert_level = $this->so->gab_insert_level;
if ($session)
{
$this->read_sessiondata();
Modified: people/sigurdne/modules/property/trunk/inc/class.boinvoice.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.boinvoice.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.boinvoice.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -459,12 +459,24 @@
$contacts = CreateObject('property.soactor');
$contacts->role='vendor';
- $vendor_data = $contacts->read_single(array('actor_id'=>$vendor_id));
+ $criteria = array
+ (
+ 'attributes' => array
+ (
+ array
+ (
+ 'column_name' => 'org_name'
+ )
+ )
+ );
+
+ $vendor_data = $contacts->read_single($vendor_id, $criteria);
+
if(is_array($vendor_data))
{
foreach($vendor_data['attributes'] as $attribute)
{
- if($attribute['name']=='org_name')
+ if($attribute['column_name']=='org_name')
{
return $attribute['value'];
}
@@ -474,26 +486,53 @@
function set_responsible($values,$user_id='',$b_account_id='')
{
+ $responsible = CreateObject('property.soresponsible');
if (!$values['budget_responsible'])
{
+// var $bestiller = 85; //cat_id for rolle
+// var $attestant = 83; //cat_id for rolle
+// var $budsjettansvarlig = 82; //cat_id for rolle
+
+ $criteria_budget_responsible = array('ecodimb' => $values['dimb'], 'cat_id' => 82);//$this->budsjettansvarlig); //anviser
+ $budget_responsible_contact_id = $responsible->get_responsible($criteria_budget_responsible);
+ $budget_responsible_user_id = $responsible->get_contact_user_id($budget_responsible_contact_id);
+ $values['budget_responsible'] = $GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
+ $values['budsjettansvarligid'] = $values['budget_responsible'];
+ }
+
+ if (!$values['budget_responsible'])
+ {
$values['budget_responsible'] = $this->soXport->get_responsible($b_account_id);
$values['budsjettansvarligid'] = $values['budget_responsible'];
}
+
+ if(!$values['supervisor'])
+ {
+ $criteria_supervisor = array('ecodimb' => $values['dimb'], 'cat_id' => 83);//$this->attestant); // attestere
+ $supervisor_contact_id = $responsible->get_responsible($criteria_supervisor);
+ $supervisor_user_id = $responsible->get_contact_user_id($supervisor_contact_id);
+ $values['supervisor'] = $GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
+ $values['saksbehandlerid'] = $values['supervisor'];
+ }
+
+ $values['janitor'] = $GLOBALS['phpgw']->accounts->get($user_id)->lid;
+ $values['oppsynsmannid'] = $values['janitor'];
+
+ if(!$values['supervisor'])
+ {
$acl = CreateObject('phpgwapi.acl',$user_id);
- if($acl->check('.invoice', 32, 'property') && !$acl->check('.invoice', 64, 'property')):
+ if($acl->check('.invoice', 32, 'property') && !$acl->check('.invoice', 64, 'property'))
{
- $values['janitor'] = $GLOBALS['phpgw']->accounts->id2name($user_id);
+ $values['janitor'] = $GLOBALS['phpgw']->accounts->get($user_id)->lid;
$values['oppsynsmannid'] = $values['janitor'];
}
- // elseif((!$acl->check('.invoice', 32, 'property') && $acl->check('.invoice', 64, 'property')) || ($acl->check('.invoice', 32, 'property') && $acl->check('.invoice', 64, 'property'))):
- elseif($acl->check('.invoice', 64, 'property')):
+ else if($acl->check('.invoice', 64, 'property'))
{
- $values['supervisor'] = $GLOBALS['phpgw']->accounts->id2name($user_id);
+ $values['supervisor'] = $GLOBALS['phpgw']->accounts->get($user_id)->lid;
$values['saksbehandlerid'] = $values['supervisor'];
}
- endif;
-
+ }
return $values;
}
}
Modified: people/sigurdne/modules/property/trunk/inc/class.bolocation.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.bolocation.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.bolocation.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -280,6 +280,11 @@
}
$filter_location = isset($data['filter_location']) ? $data['filter_location'] : '';
+ if(!$filter_location)
+ {
+ $filter_location = phpgwapi_cache::session_get('property', 'filter_location');
+ phpgwapi_cache::session_clear('property', 'filter_location');
+ }
$block_query = !!$filter_location;
$location_link = "menuaction:'property.uilocation.index',lookup:1,location_code:'{$filter_location}',block_query:'{$block_query}'";
Modified: people/sigurdne/modules/property/trunk/inc/class.bolookup.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.bolookup.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.bolookup.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -138,9 +138,27 @@
$criteria = $addressbook->criteria_contacts(1, $category_filter, 'person', $this->query, $fields_search);
$this->total_records = $addressbook->get_count_persons($criteria);
- $entries = $addressbook->get_persons($fields, $this->limit, $this->start, $this->order, $this->sort, '', $criteria);
+ $contacts = $addressbook->get_persons($fields, $this->limit, $this->start, $this->order, $this->sort, '', $criteria);
- return $entries;
+ $accounts = $GLOBALS['phpgw']->accounts->get_list();
+ $user_contacts = array();
+
+ foreach($accounts as $account)
+ {
+ if(isset($account->person_id) && $account->person_id)
+ {
+ $user_contacts[] = $account->person_id;
+ }
+ }
+ foreach($contacts as &$contact)
+ {
+ if (in_array($contact['contact_id'], $user_contacts) )
+ {
+ $contact['is_user'] = 'X';
+ }
+ }
+
+ return $contacts;
}
Modified: people/sigurdne/modules/property/trunk/inc/class.botts.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.botts.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.botts.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -832,6 +832,7 @@
if ($this->config->config_data['ownernotification'] && $ticket['user_id'])
{
+
// add owner to recipients
$members[] = array('account_id' => $ticket['user_id'], 'account_name' => $GLOBALS['phpgw']->accounts->id2name($ticket['user_id']));
}
@@ -872,15 +873,26 @@
$to = current($toarray);
}
- $body = str_replace("\n" ,"</br>",$body);
+ $body = nl2br($body);
+
+ if($to)
+ {
if (isset($GLOBALS['phpgw_info']['server']['smtp_server']) && $GLOBALS['phpgw_info']['server']['smtp_server'])
{
+ try
+ {
$rc = $this->send->msg('email', $to, $subject, stripslashes($body), '', $cc, $bcc,$current_user_address,$current_user_name,'html');
}
+ catch (phpmailerException $e)
+ {
+ $receipt['error'][] = array('msg' => $e->getMessage());
+ }
+ }
else
{
$receipt['error'][] = array('msg'=>lang('SMTP server is not set! (admin section)'));
}
+ }
if (!$rc && ($this->config->config_data['groupnotification'] || $this->config->config_data['ownernotification'] || $this->config->config_data['groupnotification']))
{
Modified: people/sigurdne/modules/property/trunk/inc/class.sogab.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.sogab.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.sogab.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -35,7 +35,7 @@
class property_sogab
{
var $gab_insert_level;
- var $payment_date;
+ var $payment_date = array();
function __construct()
{
@@ -44,6 +44,7 @@
$this->db = & $GLOBALS['phpgw']->db;
$this->db2 = clone($this->db);
$this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
$this->like = & $this->db->like;
$this->config = CreateObject('phpgwapi.config','property');
@@ -141,7 +142,26 @@
if($check_payments)
{
- $sql = "SELECT gab_id,count(gab_id) as hits, address ,fm_gab_location.loc1 as location_code, fm_gab_location.owner as owner FROM fm_gab_location $joinmethod $filtermethod GROUP BY gab_id,fm_gab_location.loc1,address,owner ";
+// $sql = "SELECT gab_id,count(gab_id) as hits, address ,fm_gab_location.loc1 as location_code, fm_gab_location.owner as owner FROM fm_gab_location $joinmethod $filtermethod GROUP BY gab_id,fm_gab_location.loc1,address,owner ";
+// $sql = "SELECT DISTINCT gab_id, fm_gab_location.loc1 as location_code, fm_gab_location.owner as owner FROM fm_gab_location $joinmethod $filtermethod GROUP BY gab_id,fm_gab_location.loc1,address,owner ";
+// $sql = "SELECT gab_id, fm_gab_location.loc1 as location_code, fm_gab_location.owner as owner FROM fm_gab_location $joinmethod $filtermethod GROUP BY gab_id,fm_gab_location.loc1,address,owner ";
+
+ $spvend_code = 9901;
+ $spbudact_code = '11954111';
+ switch($GLOBALS['phpgw_info']['server']['db_type'])
+ {
+ case 'postgres':
+ $due_date = "to_char(forfallsdato,'MM/YYYY') as due_date";
+ break;
+ default:
+ $due_date = "to_char(forfallsdato,'MM/YYYY') as due_date";
+ }
+
+ $sql = "SELECT sum(belop) as paid, count(fm_ecobilagoverf.loc1) as hits, {$due_date}, fm_ecobilagoverf.loc1, owner"
+ . " FROM fm_ecobilagoverf {$this->left_join} fm_gab_location ON fm_ecobilagoverf.loc1 = fm_gab_location.loc1"
+ . " WHERE spvend_code = '{$spvend_code}' AND spbudact_code = '{$spbudact_code}'"
+ . " GROUP BY owner, forfallsdato,spbudact_code, fm_ecobilagoverf.loc1 ORDER BY forfallsdato ASC";
+
}
else
{
@@ -161,19 +181,21 @@
}
$gab_list = array();
+ if(!$check_payments)
+ {
while ($this->db->next_record())
{
$gab_list[] = array
(
'gab_id' => $this->db->f('gab_id'),
'location_code' => $this->db->f('location_code'),
- 'address' => stripslashes($this->db->f('address')),
+ 'address' => $this->db->f('address',true),
'hits' => $this->db->f('hits'),
'owner' => $this->db->f('owner')
);
}
-
- if($check_payments)
+ }
+ else
{
if($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
{
@@ -184,26 +206,75 @@
$dateformat = 'd-m-Y';
}
- for ($i=0;$i<count($gab_list);$i++)
+ $gross_list = array();
+ $dates = array();
+ while ($this->db->next_record())
{
- $sql = "SELECT * FROM fm_ecobilagoverf WHERE item_id = '" . $gab_list[$i]['gab_id'] . "'";
+ $gross_list[] = array
+ (
+ 'gab_id' => '00000000000000000000',//$this->db->f('gab_id'),
+ 'location_code' => $this->db->f('loc1'),
+ 'address' => $this->db->f('address',true),
+ 'hits' => $this->db->f('hits'),
+ 'owner' => $this->db->f('owner'),
+ 'paid' => $this->db->f('paid'),
+ 'due_date' => $this->db->f('due_date'),
+ );
+ $dates[$this->db->f('due_date')] = true;
+ }
+
+ $dates = array_keys($dates);
+ $payment_date = array();
+ $location_buffer = array();
+ $i=0;
+ foreach ($gross_list as $entry)
+ {
+ if(!isset($location_buffer[$entry['location_code']]))
+ {
+ $gab_list[$i] = array
+ (
+ 'location_code' => $entry['location_code'],
+ 'gab_id' => $entry['gab_id'],
+ 'address' => $entry['address'],
+ 'hits' => $entry['hits'],
+ 'owner' => $entry['owner']
+ );
+ $location_buffer[$entry['location_code']] = true;
+ $j = $i;
+ $i++;
+ }
+ foreach ( $dates as $date )
+ {
+ $gab_list[$i]['payment'][$date] = $entry['paid'];
+ }
+ }
+
+ reset($dates);
+ foreach ( $dates as $date )
+ {
+ $payment_date[$date] = $date;
+ }
+
+/* foreach ($gab_list as &$entry)
+ {
+ $sql = "SELECT forfallsdato, belop FROM fm_ecobilagoverf WHERE item_id = '{$entry['gab_id']}' ORDER BY forfallsdato ASC";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
- $gab_list[$i]['payment'][date($dateformat,strtotime($this->db->f('forfallsdato')))] = $this->db->f('belop');
+ $entry['payment'][date($dateformat,strtotime($this->db->f('forfallsdato')))] = $this->db->f('belop');
$payment_date[strtotime($this->db->f('forfallsdato'))] = date($dateformat,strtotime($this->db->f('forfallsdato')));
}
- $sql = "SELECT * FROM fm_ecobilag WHERE item_id = '" . $gab_list[$i]['gab_id'] . "'";
+ $sql = "SELECT forfallsdato, belop FROM fm_ecobilag WHERE item_id = '{$entry['gab_id']}'";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
- $gab_list[$i]['payment'][date($dateformat,strtotime($this->db->f('forfallsdato')))] = $this->db->f('belop');
+ $entry['payment'][date($dateformat,strtotime($this->db->f('forfallsdato')))] = $this->db->f('belop');
$payment_date[strtotime($this->db->f('forfallsdato'))] = date($dateformat,strtotime($this->db->f('forfallsdato')));
}
}
-
+*/
$this->payment_date=$payment_date;
}
Modified: people/sigurdne/modules/property/trunk/inc/class.soinvoice.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.soinvoice.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.soinvoice.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -36,8 +36,9 @@
{
var $total_records = 0;
var $role = array();
+ protected $invoice_approval = 2;
- function property_soinvoice()
+ function __construct()
{
$this->account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$this->acl = & $GLOBALS['phpgw']->acl;
@@ -45,6 +46,9 @@
$this->join = & $this->db->join;
$this->left_join = & $this->db->left_join;
$this->like = & $this->db->like;
+ $this->config = CreateObject('phpgwapi.config','property');
+ $this->config->read();
+ $this->invoice_approval = isset($this->config->config_data['invoice_approval']) && $this->config->config_data['invoice_approval'] ? $this->config->config_data['invoice_approval'] : 2;
}
function read_invoice($data)
@@ -1109,7 +1113,6 @@
$receipt['error'][] = array('msg'=>'Dette bilaget er ikkje godkjent: ' . " ".$voucher_id);
$local_error= true;
}
-
}
if ($values['kreditnota'][$n])
@@ -1124,19 +1127,23 @@
if (! $local_error)
{
- $sql= "UPDATE fm_ecobilag set $blank_date $kommma_blank $sign_field $sign_id $kommma $sign_date_field $sign_date $kommma $transfer_sign_field $transfer_id $transfer_date_field $transfer_date ,kreditnota=$wait_for_kreditnota where bilagsnr='$voucher_id'";
+ $sql= "UPDATE fm_ecobilag SET $blank_date $kommma_blank $sign_field $sign_id $kommma $sign_date_field $sign_date $kommma $transfer_sign_field $transfer_id $transfer_date_field $transfer_date ,kreditnota=$wait_for_kreditnota where bilagsnr='$voucher_id'";
$GLOBALS['phpgw']->db->transaction_begin();
$GLOBALS['phpgw']->db->query($sql);
- $GLOBALS['phpgw']->db->transaction_commit();
-
+ if($GLOBALS['phpgw']->db->transaction_commit())
+ {
$receipt['message'][] = array('msg'=> lang('voucher is updated: ') . $voucher_id);
}
}
}
}
+ }
$GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set utbetalingid = NULL, utbetalingsigndato = NULL WHERE budsjettsigndato IS NULL");
+ if($this->invoice_approval == 2)
+ {
$GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set utbetalingid = NULL, utbetalingsigndato = NULL WHERE oppsynsigndato IS NULL AND saksigndato IS NULL");
+ }
return $receipt;
}
@@ -1150,10 +1157,20 @@
$this->db->next_record();
+ if($this->invoice_approval == 1)
+ {
+ if ($this->db->f('budsjettsigndato'))
+ {
+ $allow_transfer=true;
+ }
+ }
+ else
+ {
if ($this->db->f('budsjettsigndato') && ($this->db->f('oppsynsigndato') || $this->db->f('saksigndato')))
{
$allow_transfer=true;
}
+ }
return $allow_transfer;
}
Modified: people/sigurdne/modules/property/trunk/inc/class.uigab.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uigab.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uigab.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -56,7 +56,7 @@
'download' => true
);
- function property_uigab()
+ function __construct()
{
$GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
$GLOBALS['phpgw_info']['flags']['menu_selection'] = 'property::location::gabnr';
@@ -654,7 +654,7 @@
'sort' => $datatable['sorting']['order'],
'dir' => $datatable['sorting']['sort'],
'records' => array(),
- // 'headers' => $uicols_add['name'],
+ 'headers' => $uicols_add['name'],
'headers_all' => $uicols['name']
);
Modified: people/sigurdne/modules/property/trunk/inc/class.uiinvoice.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uiinvoice.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uiinvoice.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -606,34 +606,34 @@
$content = $this->bo->read_invoice($paid,$start_date,$end_date,$vendor_id,$loc1,$workorder_id,$voucher_id);
//_debug_array($content);
$uicols = array (
- 'input_type' => array(hidden,hidden ,hidden ,hidden ,hidden,hidden,hidden,hidden,hidden ,link,link ,hidden,hidden,hidden,$paid?varchar:input,varchar,link ,hidden,varchar,varchar,varchar,$paid?hidden:input,$paid?hidden:input,special,special,special,special2),
- 'type' => array(number,'' ,'' ,'' ,number,number,'' ,number,'' ,url ,msg_box ,'' ,'' ,'' ,$paid?'':text ,'' ,msg_box,'' ,'' ,'' ,'' ,$paid?'':checkbox ,$paid?'':radio ,'' ,'' ,'' ,'' ),
+ 'input_type' => array('hidden','hidden' ,'hidden' ,'hidden' ,'hidden','hidden','hidden','hidden','hidden' ,'link','link' ,'hidden','hidden','hidden',$paid?'varchar':'input','varchar','link' ,'hidden','varchar','varchar','varchar',$paid?'hidden':'input',$paid?'hidden':'input','special','special','special','special2'),
+ 'type' => array('number','' ,'' ,'' ,'number','number','' ,'number','' ,'url' ,'msg_box' ,'' ,'' ,'' ,$paid?'':'text' ,'' ,'msg_box','' ,'' ,'' ,'' ,$paid?'':'checkbox' ,$paid?'':'radio' ,'' ,'' ,'' ,'' ),
- 'col_name' => array(payment_date,transfer,kreditnota,sign,vendor_name,counter_num,counter,voucher_id_num,voucher_id,voucher_id_lnk,voucher_date_lnk,sign_orig ,num_days_orig,timestamp_voucher_date,num_days,amount_lnk,vendor_id_lnk,invoice_count,invoice_count_lnk,type_lnk,period,kreditnota_tmp,sign_tmp ,janitor_lnk,supervisor_lnk,budget_responsible_lnk,transfer_lnk),
- 'name' => array(payment_date,dummy,dummy,dummy,vendor,counter,counter,voucher_id ,voucher_id,voucher_id ,voucher_date ,sign_orig,num_days ,timestamp_voucher_date,num_days,amount ,vendor_id ,invoice_count,invoice_count ,type ,period,kreditnota,empty_fild,janitor ,supervisor ,budget_responsible ,transfer_id),
+ 'col_name' => array('payment_date','transfer','kreditnota','sign','vendor_name','counter_num','counter','voucher_id_num','voucher_id','voucher_id_lnk','voucher_date_lnk','sign_orig' ,'num_days_orig','timestamp_voucher_date','num_days','amount_lnk','vendor_id_lnk','invoice_count','invoice_count_lnk','type_lnk','period','kreditnota_tmp','sign_tmp' ,'janitor_lnk','supervisor_lnk','budget_responsible_lnk','transfer_lnk'),
+ 'name' => array('payment_date','dummy','dummy','dummy','vendor','counter','counter','voucher_id' ,'voucher_id','voucher_id' ,'voucher_date' ,'sign_orig','num_days' ,'timestamp_voucher_date','num_days','amount' ,'vendor_id' ,'invoice_count','invoice_count' ,'type' ,'period','kreditnota','empty_fild','janitor' ,'supervisor' ,'budget_responsible' ,'transfer_id'),
- 'formatter' => array('','','','','','','','','','','','','','','',myFormatDate,'','','','',$paid?'':myPeriodDropDown,'','','','','',''),
+ 'formatter' => array('','','','','','','','','','','','','','','','myFormatDate','','','','',$paid?'':'myPeriodDropDown','','','','','',''),
- 'descr' => array(dummy,dummy,dummy,dummy,dummy,dummy,dummy,dummy,dummy,lang('voucher'),lang('Voucher Date'),dummy,dummy,dummy,lang('Days'),lang('Sum'),lang('Vendor'),dummy,lang('Count'),lang('Type'),lang('Period'),lang('KreditNota'),lang('None'),lang('Janitor'),lang('Supervisor'),lang('Budget Responsible'),lang('Transfer')),
+ 'descr' => array('dummy','dummy','dummy','dummy','dummy','dummy','dummy','dummy','dummy',lang('voucher'),lang('Voucher Date'),'dummy','dummy','dummy',lang('Days'),lang('Sum'),lang('Vendor'),'dummy',lang('Count'),lang('Type'),lang('Period'),lang('KreditNota'),lang('None'),lang('Janitor'),lang('Supervisor'),lang('Budget Responsible'),lang('Transfer')),
'className' => array('','','','','','','','','','','centerClasss','','','',$paid?'rightClasss':'','rightClasss','rightClasss','','rightClasss','',$paid?'centerClasss':'comboClasss','centerClasss','centerClasss','','','centerClasss','centerClasss')
);
//url to detail of voucher
$link_sub = $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 'property.uiinvoice.list_sub','user_lid'=>$this->user_lid));
-
if($paid)
{
$link_sub.="&paid=true";
}
$j=0;
+ $count_uicols = count($uicols['name']);
//---- llena DATATABLE-ROWS con los valores del READ
if (isset($content) && is_array($content))
{
foreach($content as $invoices)
{
- for ($i=0;$i<count($uicols['name']);$i++)
+ for ($i=0;$i<$count_uicols;$i++)
{
//values column kreditnota
if($uicols['type'][$i]=='checkbox' && $uicols['col_name'][$i]=='kreditnota_tmp')
@@ -687,7 +687,7 @@
{
if( ($invoices['is_janitor']== 1 && $type_sign == 'janitor') || ($invoices['is_supervisor']== 1 && $type_sign == 'supervisor') || ($invoices['is_budget_responsible']== 1 && $type_sign == 'budget_responsible'))
{
- if( ( ($invoices['jan_date'] == '') && $type_sign == 'janitor') || (($invoices['super_date'] == '') && $type_sign == 'supervisor') || (($invoices['budget_date'] == '') && $type_sign == 'budget_responsible'))
+ if( ( (!$invoices['jan_date']) && $type_sign == 'janitor') || ((!$invoices['super_date']) && $type_sign == 'supervisor') || ((!$invoices['budget_date']) && $type_sign == 'budget_responsible'))
{
$datatable['rows']['row'][$j]['column'][$i]['name'] = 'sign_tmp';
$datatable['rows']['row'][$j]['column'][$i]['type'] = 'radio';
@@ -695,7 +695,7 @@
$datatable['rows']['row'][$j]['column'][$i]['extra_param'] = "";
}
- elseif( (($invoices['janitor'] == $invoices['current_user']) && $type_sign == 'janitor') || (($invoices['supervisor'] == $invoices['current_user']) && $type_sign == 'supervisor') || (($invoices['budget_responsible'] == $invoices['current_user']) && $type_sign == 'budget_responsible'))
+ else if( (($invoices['janitor'] == $invoices['current_user']) && $type_sign == 'janitor') || (($invoices['supervisor'] == $invoices['current_user']) && $type_sign == 'supervisor') || (($invoices['budget_responsible'] == $invoices['current_user']) && $type_sign == 'budget_responsible'))
{
$datatable['rows']['row'][$j]['column'][$i]['name'] = 'sign_tmp';
$datatable['rows']['row'][$j]['column'][$i]['type'] = 'radio';
@@ -714,7 +714,7 @@
}
else
{
- if( ($invoices['jan_date']=='' && $type_sign == 'janitor') || ($invoices['super_date']=='' && $type_sign == 'supervisor') || ($invoices['budget_date']=='' && $type_sign == 'budget_responsible') )
+ if( (!$invoices['jan_date'] && $type_sign == 'janitor') || (!$invoices['super_date'] && $type_sign == 'supervisor') || (!$invoices['budget_date'] && $type_sign == 'budget_responsible') )
{
}
else
@@ -725,8 +725,8 @@
$datatable['rows']['row'][$j]['column'][$i]['extra_param'] = " disabled=\"disabled\" checked ";
}
}
- $datatable['rows']['row'][$j]['column'][$i]['value2'] = ($type_sign == 'janitor'? $invoices['janitor']: ($type_sign == 'supervisor'? $invoices['supervisor'] : $invoices['budget_responsible']));
- $datatable['rows']['row'][$j]['column'][$i]['value0'] = ($type_sign == 'supervisor'? $invoices['super_date']: "");
+ $datatable['rows']['row'][$j]['column'][$i]['value2'] = $type_sign == 'janitor'? $invoices['janitor']: ($type_sign == 'supervisor'? $invoices['supervisor'] : $invoices['budget_responsible']);
+ $datatable['rows']['row'][$j]['column'][$i]['value0'] = $type_sign == 'janitor'? $invoices['jan_date']: ($type_sign == 'supervisor'? $invoices['super_date'] : $invoices['budget_date']);
}
else //if($paid)
{
@@ -736,7 +736,6 @@
//---- speciual2----
elseif($uicols['input_type'][$i]=='special2')
{
-
// the same name of columns
$type_sign = $datatable['rows']['row'][$j]['column'][$i]['format'] = $uicols['name'][$i];
$datatable['rows']['row'][$j]['column'][$i]['for_json'] = $uicols['col_name'][$i];
@@ -746,7 +745,7 @@
{
if( ($invoices['is_transfer']==1))
{
- if( ($invoices['transfer_date']==''))
+ if(!$invoices['transfer_date'])
{
$datatable['rows']['row'][$j]['column'][$i]['name'] = 'transfer_tmp';
$datatable['rows']['row'][$j]['column'][$i]['type'] = 'checkbox';
@@ -1237,35 +1236,43 @@
$uicols = array (
array(
- 'col_name'=>workorder ,'label'=>lang('Workorder'), 'className'=>'centerClasss', 'sortable'=>true, 'sort_field'=>'pmwrkord_code', 'visible'=>true),
+ 'col_name'=>'workorder' ,'label'=>lang('Workorder'), 'className'=>'centerClasss', 'sortable'=>true, 'sort_field'=>'pmwrkord_code', 'visible'=>true),
array(
'col_name'=>'project_group','label'=>lang('project group'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>close_order, 'label'=>lang('Close order'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'close_order', 'label'=>lang('Close order'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>paid_percent, 'label'=>lang('paid percent'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'paid_percent', 'label'=>lang('paid percent'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>change_tenant, 'label'=>lang('Charge tenant'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'change_tenant', 'label'=>lang('Charge tenant'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>invoice_id, 'label'=>lang('Invoice Id'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'invoice_id', 'label'=>lang('Invoice Id'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>budget_Account, 'label'=>lang('Budget account'),'className'=>'centerClasss', 'sortable'=>true, 'sort_field'=>'spbudact_code', 'visible'=>true),
+ 'col_name'=>'budget_Account', 'label'=>lang('Budget account'),'className'=>'centerClasss', 'sortable'=>true, 'sort_field'=>'spbudact_code', 'visible'=>true),
array(
- 'col_name'=>sum, 'label'=>lang('Sum'), 'className'=>'rightClasss', 'sortable'=>true, 'sort_field'=>'belop', 'visible'=>true),
+ 'col_name'=>'sum', 'label'=>lang('Sum'), 'className'=>'rightClasss', 'sortable'=>true, 'sort_field'=>'belop', 'visible'=>true),
array(
- 'col_name'=>dim_A, 'label'=>lang('Dim A'), 'className'=>'centerClasss', 'sortable'=>true, 'sort_field'=>'dima', 'visible'=>true),
+ 'col_name'=>'dim_A', 'label'=>lang('Dim A'), 'className'=>'centerClasss', 'sortable'=>true, 'sort_field'=>'dima', 'visible'=>true),
array(
- 'col_name'=>dim_B, 'label'=>lang('Dim B'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'dim_B', 'label'=>lang('Dim B'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>dim_D, 'label'=>lang('Dim D'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'dim_D', 'label'=>lang('Dim D'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>Tax_code, 'label'=>lang('Tax code'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'Tax_code', 'label'=>lang('Tax code'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>Remark, 'label'=>lang('Remark'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ 'col_name'=>'Remark', 'label'=>lang('Remark'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
array(
- 'col_name'=>counter, 'visible'=>false)
+ 'col_name'=>'external_ref' ,'label'=>lang('external_ref'), 'className'=>'centerClasss', 'sortable'=>false, 'sort_field'=>'', 'visible'=>true),
+ array(
+ 'col_name'=>'counter', 'visible'=>false)
);
+
+ $config = CreateObject('phpgwapi.config','property');
+ $config->read();
+ $baseurl_invoice = isset($config->config_data['baseurl_invoice']) && $config->config_data['baseurl_invoice'] ? $config->config_data['baseurl_invoice'] : '';
+ $lang_picture = lang('picture');
+
$j=0;
//---- llena DATATABLE-ROWS con los valores del READ
if (isset($content) && is_array($content))
@@ -1465,8 +1472,20 @@
$json_row[$uicols[$i]['col_name']] .= "<b>-</b>";
}
}
- elseif($i == 13)
+ elseif(($i == 13))
{
+ if(isset($invoices['external_ref']) && $invoices['external_ref'])
+ {
+ // $json_row[$uicols[$i]['col_name']] = " <a target='_blank' href='".$baseurl_invoice. $invoices['external_ref']."'>{$lang_picture}</a>";
+ $json_row[$uicols[$i]['col_name']] = " <a href=\"javascript:openwindow('".$baseurl_invoice. $invoices['external_ref']. "','640','800')\" >{$lang_picture}</a>";
+ }
+ else
+ {
+ $json_row[$uicols[$i]['col_name']] .= "<b>-</b>";
+ }
+ }
+ elseif($i == 14)
+ {
$json_row[$uicols[$i]['col_name']] = $invoices['counter'];
}
}
@@ -2332,16 +2351,15 @@
if($add_invoice && is_array($values))
{
- if($values['order_id'] && !ctype_digit($values['order_id'])):
+ if($values['order_id'] && !ctype_digit($values['order_id']))
{
$receipt['error'][]=array('msg'=>lang('Please enter an integer for order!'));
unset($values['order_id']);
}
- elseif($values['order_id']):
+ else if($values['order_id'])
{
$order=true;
}
- endif;
if (!$values['amount'])
{
Modified: people/sigurdne/modules/property/trunk/inc/class.uilookup.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uilookup.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uilookup.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -214,11 +214,11 @@
}
$uicols = array (
- 'input_type' => array(text,text),
- 'name' => array(contact_id,contact_name),
- 'sort_field' => array(person_id,last_name),
- 'formatter' => array('',''),
- 'descr' => array(lang('ID'),lang('Name'))
+ 'input_type' => array('text','text'),
+ 'name' => array('contact_id','contact_name','is_user'),
+ 'sort_field' => array('person_id','last_name'),
+ 'formatter' => array('','',''),
+ 'descr' => array(lang('ID'),lang('Name'), lang('is user'))
);
$addressbook_list = array();
@@ -232,10 +232,12 @@
{
for ($i=0;$i<count($uicols['name']);$i++)
{
- if ($uicols['name'][$i] == 'contact_name'){
+ if ($uicols['name'][$i] == 'contact_name')
+ {
$datatable['rows']['row'][$j]['column'][$i]['value'] = $addressbook_entry['per_last_name'] . ', ' . $addressbook_entry['per_first_name'];
}
- else {
+ else
+ {
$datatable['rows']['row'][$j]['column'][$i]['value'] = $addressbook_entry[$uicols['name'][$i]];
}
$datatable['rows']['row'][$j]['column'][$i]['name'] = $uicols['name'][$i];
Modified: people/sigurdne/modules/property/trunk/inc/class.uirequest.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uirequest.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uirequest.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -916,6 +916,7 @@
if($values['location'])
{
$location_code=implode("-", $values['location']);
+ $values['extra']['view'] = true;
$values['location_data'] = $this->bolocation->read_single($location_code,$values['extra']);
}
Modified: people/sigurdne/modules/property/trunk/inc/class.uitts.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uitts.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uitts.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -1773,7 +1773,8 @@
$values['assignedto'] = $this->account;
}
$receipt = $this->bo->update_ticket($values,$id);
- if (isset($this->bo->config->config_data['mailnotification']) && $this->bo->config->config_data['mailnotification'])
+
+ if ( isset($values['send_mail']) && $values['send_mail'])
{
$receipt = $this->bo->mail_ticket($id, $this->bo->fields_updated, $receipt);
}
Modified: people/sigurdne/modules/property/trunk/inc/class.uiwo_hour.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uiwo_hour.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uiwo_hour.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -1377,6 +1377,7 @@
$this->create_html->add_file(array(PHPGW_SERVER_ROOT . '/property/templates/base/wo_hour'));
$this->create_html->add_file(array(PHPGW_SERVER_ROOT . '/property/templates/base/location_view'));
+ $this->create_html->add_file(array(PHPGW_SERVER_ROOT . '/property/templates/base/contact_view'));
$this->create_html->set_var('phpgw',array('email_data' => $email_data));
Modified: people/sigurdne/modules/property/trunk/inc/class.uiworkorder.inc.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/class.uiworkorder.inc.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/class.uiworkorder.inc.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -999,7 +999,7 @@
}
if (isset($receipt['notice_owner']) && is_array($receipt['notice_owner'])
&& $config->config_data['mailnotification']
- && isset($GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner'] == 1)
+ && isset($GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner']) && $GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner'])
{
if($this->account!=$project['coordinator'] && $config->config_data['workorder_approval'])
{
Added: people/sigurdne/modules/property/trunk/inc/cron/default/Import_fra_basware_X205.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/cron/default/Import_fra_basware_X205.php (rev 0)
+++ people/sigurdne/modules/property/trunk/inc/cron/default/Import_fra_basware_X205.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -0,0 +1,430 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <[email protected]>
+ * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc. http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
+ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage import
+ * @version $Id: Import_fra_basware_X205.php 4418 2009-12-25 19:30:58Z sigurd $
+ */
+
+ /**
+ * Filteret benytter format X205 for integrasjon mellom Contempus Invoice og ClockWork Logistics.
+ * Formatet sender innskannede fakturaer fra Contempus til ClockWork - og Portico Estate
+ * @package property
+ */
+
+
+ class Import_fra_basware_X205
+ {
+ var $function_name = 'Import_fra_basware_X205';
+ var $auto_tax = true;
+ var $mvakode=0;
+ var $kildeid=1;
+ var $splitt=0;
+ var $soXport;
+ var $invoice;
+ var $bestiller = 85; //cat_id for rolle
+ var $attestant = 83; //cat_id for rolle
+ var $budsjettansvarlig = 82; //cat_id for rolle
+ var $default_kostra_id = 9999; //dummy
+
+ var $import = array(
+ 'Bilagsnr' => 'bilagsnr',
+ 'Fakturanr' => 'fakturanr',
+ 'Konto' => 'spbudact_code',
+ 'Objekt' => 'dima', //objectclass: organizationalPerson
+ 'DimB' => 'dimb',
+ 'KID' => 'kidnr',
+ 'MVA' => 'mvakode',
+ 'Tjeneste'=> 'kostra_id',
+ 'Belop [kr]' => 'belop',
+ 'Referanse' => 'referanse',
+ 'BOEI Gateadresse' => 'boei_gateadresse',
+ );
+
+ var $header = array('Bilagsnr','Fakturanr','Konto','Objekt','DimB','KID','MVA','Tjeneste','Belop [kr]','Referanse');
+
+ function __construct()
+ {
+ $this->soXport = CreateObject('property.soXport');
+ $this->invoice = CreateObject('property.soinvoice');
+ $this->responsible = CreateObject('property.soresponsible');
+ $this->bocommon = CreateObject('property.bocommon');
+ $this->db = & $GLOBALS['phpgw']->db;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+ $this->like = & $this->db->like;
+ $this->dateformat = $this->db->date_format();
+ $this->datetimeformat = $this->db->datetime_format();
+ }
+
+ function pre_run($data='')
+ {
+ if($data['enabled']==1)
+ {
+ $confirm = true;
+ $cron = true;
+ }
+ else
+ {
+ $confirm = phpgw::get_var('confirm', 'bool', 'POST');
+ $execute = phpgw::get_var('execute', 'bool', 'GET');
+ }
+
+ if ($confirm)
+ {
+ $this->execute($cron);
+ }
+ else
+ {
+ $this->confirm($execute=false);
+ }
+ }
+
+ function confirm($execute='')
+ {
+ $link_data = array
+ (
+ 'menuaction' => 'property.custom_functions.index',
+ 'function' =>$this->function_name,
+ 'execute' => $execute,
+ );
+
+
+ if(!$execute)
+ {
+ $lang_confirm_msg = lang('do you want to perform this action');
+ }
+
+ $lang_yes = lang('yes');
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+
+ $msgbox_data = $this->bocommon->msgbox_data($this->receipt);
+
+ $data = array
+ (
+ 'msgbox_data' => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'done_action' => $GLOBALS['phpgw']->link('/index.php', array('menuaction'=>'property.uiasync.index')),
+ 'run_action' => $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'message' => $this->receipt['message'],
+ 'lang_confirm_msg' => $lang_confirm_msg,
+ 'lang_yes' => $lang_yes,
+ 'lang_yes_statustext' => 'Importer faktura fra Basware',
+ 'lang_no_statustext' => 'tilbake',
+ 'lang_no' => lang('no'),
+ 'lang_done' => 'Avbryt',
+ 'lang_done_statustext' => 'tilbake'
+ );
+
+ $appname = lang('location');
+ $function_msg = 'Importer faktura fra Basware';
+ $GLOBALS['phpgw_info']['flags']['app_header'] = lang('property') . ' - ' . $appname . ': ' . $function_msg;
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+ $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ public function execute($cron='')
+ {
+ $config = CreateObject('phpgwapi.config','property');
+ $config->read();
+ $dirname = $config->config_data['import_path'];
+ // prevent path traversal
+ if ( preg_match('/\./', $dirname)
+ || !is_dir($dirname) )
+ {
+ return array();
+ }
+
+ $file_list = array();
+ $dir = new DirectoryIterator($dirname);
+ if ( is_object($dir) )
+ {
+ foreach ( $dir as $file )
+ {
+ if ( $file->isDot()
+ || !$file->isFile()
+ || !$file->isReadable()
+ || strcasecmp( end( explode( ".", $file->getPathname() ) ), 'xml' ) != 0 )
+ {
+ continue;
+ }
+
+ $file_list[] = (string) "{$dirname}/{$file}";
+ }
+ }
+
+ if(is_writable("{$dirname}/archive"))
+ {
+ foreach($file_list as $file)
+ {
+ $bilagsnr = $this->import($file);
+ if ($bilagsnr)
+ {
+ // move file
+ $_file = basename($file);
+ $movefrom = "{$dirname}/{$_file}";
+ $moveto = "{$dirname}/archive/{$_file}";
+
+ $ok = @rename($movefrom, $moveto);
+ if(!$ok) // Should never happen.
+ {
+ $this->invoice->delete($bilagsnr);
+ $this->receipt['error'][] = array('msg' => "Kunne ikke flytte importfil til arkiv, Bilag {$bilagsnr} er slettet");
+ }
+ }
+ }
+ }
+ else
+ {
+ $this->receipt['error'][] = array('msg' => "Arkiv katalog '{$dirname}/archive/' ikke er ikke skrivbar - kontakt systemadminstrator for å korrigere");
+ }
+
+ if(!$cron)
+ {
+ $this->confirm($execute=false);
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($this->receipt);
+
+ $insert_values= array
+ (
+ $cron,
+ date($this->bocommon->datetimeformat),
+ $this->function_name,
+ $this->db->db_addslashes(implode(',',(array_keys($msgbox_data))))
+ );
+
+ $insert_values = $this->db->validate_insert($insert_values);
+
+ $sql = "INSERT INTO fm_cron_log (cron,cron_date,process,message) "
+ . "VALUES ($insert_values)";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ }
+
+ function import($file)
+ {
+ $valid_data= False;
+ $bilagsnr = $this->invoice->next_bilagsnr();
+
+ $buffer = array();
+
+ $xmlparse = CreateObject('property.XmlToArray');
+ $xmlparse->setEncoding('UTF-8');
+ $var_result = $xmlparse->parseFile($file);
+
+ set_time_limit(300);
+
+ if (isset($var_result['INVOICES']) AND is_array($var_result['INVOICES']))
+ {
+ $transferdate = str_replace('.', '-', $var_result['TRANSACTIONINFORMATION'][0]['TRANSFERDATE']);// 2009.05.28
+ $transfertime = $var_result['TRANSACTIONINFORMATION'][0]['TRANSFERTIME'];// 13:10:28
+ $regtid = date($this->datetimeformat,strtotime("{$transferdate} {$transfertime}"));
+
+ $i = 0;
+ foreach ($var_result['INVOICES'] as $dummy => $entry)
+ {
+ $_data = $entry['INVOICE'][0]['INVOICEHEADER'][0];
+
+//_debug_array($_data);
+//die();
+
+ $_data['KEY']; // => 1400050146
+// $_data['SCANNINGNO']; // => 11E28NJINL3VR6
+// $_data['AMOUNT']; // => 312500
+ $_data['ARRIVAL']; // => 2009.05.28
+ $_data['CLIENT.CODE']; // => 14
+ $_data['CURRENCY.CURRENCYID']; // => NOK
+ $_data['EXCHANGERATE']; // => 1
+// $_data['INVOICEDATE']; // => 2009.05.28
+ $_data['LOCALAMOUNT']; // => 312500
+ $_data['LOCALVATAMOUNT']; // => 62500
+// $_data['MATURITY']; // => 2009.06.30
+ $_data['PAYAMOUNT']; // => 0
+ $_data['POSTATUSUPDATED']; // => 0
+// $_data['PURCHASEORDERNO']; // => 1409220008
+ $_data['PURCHASEORDERSTATUS.CODE']; // => WaitForMatch
+ $_data['SUPPLIER.BANKGIRO']; // => 70580621110
+// $_data['SUPPLIER.CODE']; // => 100644
+// $_data['SUPPLIERREF']; // => 7869
+ $_data['VATAMOUNT']; // => 62500
+
+
+ $order_id = $_data['PURCHASEORDERNO'];
+ $fakturanr = $_data['KEY'];
+ $fakturadato = date($this->dateformat,strtotime(str_replace('.', '-', $_data['INVOICEDATE'])));
+ $forfallsdato = date($this->dateformat,strtotime(str_replace('.', '-', $_data['MATURITY'])));
+ $periode = date('n',strtotime(str_replace('.', '-', $_data['INVOICEDATE'])));
+ $belop = $_data['AMOUNT']/100;
+
+ if( $belop < 0 )
+ {
+ $buffer[$i]['artid'] = 2;
+ }
+ else
+ {
+ $buffer[$i]['artid'] = 1;
+ }
+
+ $kidnr = $_data['KIDNO'];
+
+ $buffer[$i]['external_ref'] = $_data['SCANNINGNO'];
+ $buffer[$i]['pmwrkord_code'] = $order_id;
+ $buffer[$i]['fakturanr'] = $fakturanr;
+ $buffer[$i]['periode'] = $periode;
+ $buffer[$i]['forfallsdato'] = $forfallsdato;
+ $buffer[$i]['fakturadato'] = $fakturadato;
+ $buffer[$i]['belop'] = $belop;
+ $buffer[$i]['godkjentbelop'] = $belop;
+
+ $buffer[$i]['kidnr'] = $kidnr;
+ $buffer[$i]['bilagsnr'] = $bilagsnr;
+ $buffer[$i]['referanse'] = "ordre: {$order_id}";
+
+ $order_info = $this->get_order_info($order_id);
+
+ $buffer[$i]['dimb'] = $order_info['dimb'];
+ $buffer[$i]['dima'] = $order_info['dima'];
+ $buffer[$i]['loc1'] = $order_info['loc1'];
+
+ $buffer[$i]['mvakode'] = $this->mvakode;
+
+ if($buffer[$i]['dima'] && $this->auto_tax)
+ {
+ $mvakode = $this->soXport->auto_tax($buffer[$i]['dima']);
+
+ if($mvakode)
+ {
+ $buffer[$i]['mvakode'] = $mvakode;
+ }
+ }
+
+ if ($order_info['vendor_id'] != $_data['SUPPLIER.CODE'])
+ {
+ $this->receipt['error'][] = array('msg' => 'Manglende eller ikke treff på ordreNr');
+ }
+
+ $vendor_id = $order_info['vendor_id'];
+
+
+ if($this->auto_tax)
+ {
+ $buffer[$i]['mvakode'] = $this->soXport->tax_b_account_override($buffer[$i]['mvakode'], $order_info['spbudact_code']);
+ $buffer[$i]['mvakode'] = $this->soXport->tax_vendor_override($buffer[$i]['mvakode'], $vendor_id);
+ }
+
+ $buffer[$i]['kostra_id'] = $this->default_kostra_id;//$this->soXport->get_kostra_id($buffer[$i]['loc1']);
+
+ $merknad = "lag meg ein link til bilde av faktura - ref: {$_data['SCANNINGNO']}";
+
+ $buffer[$i]['merknad'] = $merknad;
+ $buffer[$i]['splitt'] = $this->splitt;
+ $buffer[$i]['kildeid'] = $this->kildeid;
+ $buffer[$i]['spbudact_code'] = $order_info['spbudact_code'];
+ $buffer[$i]['typeid'] = isset($invoice_common['type']) && $invoice_common['type'] ? $invoice_common['type'] : 1;
+ $buffer[$i]['regtid'] = $regtid;
+
+ $buffer[$i]['spvend_code'] = $vendor_id;
+
+ if(isset($order_info['janitor']) && $order_info['janitor'])
+ {
+ $buffer[$i]['oppsynsmannid'] = $order_info['janitor'];
+ }
+
+ if(isset($order_info['supervisor']) && $order_info['supervisor'])
+ {
+ $buffer[$i]['saksbehandlerid'] = $order_info['supervisor'];
+ }
+
+ if(isset($order_info['budget_responsible']) && $order_info['budget_responsible'])
+ {
+ $buffer[$i]['budsjettansvarligid'] = $order_info['budget_responsible'];
+ }
+
+ $i++;
+ }
+ }
+
+//_debug_array($buffer);
+//_debug_array($this->receipt);
+
+ if(!isset($this->receipt['error']) || !$this->receipt['error'])
+ {
+ return $this->import_end_file($buffer);
+ }
+ return false;
+ }
+
+ function get_order_info($order_id = '')
+ {
+ $order_info = array();
+ $order_id = (int) $order_id;
+ $sql = "SELECT fm_workorder.location_code,fm_workorder.vendor_id,fm_workorder.account_id,fm_workorder.ecodimb, fm_workorder.user_id"
+ . " FROM fm_workorder {$this->join} fm_project ON fm_workorder.project_id = fm_project.id WHERE fm_workorder.id = $order_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ if ($this->db->f('location_code'))
+ {
+ $parts = explode('-',$this->db->f('location_code'));
+ $order_info['dima'] = implode('', $parts);
+ $order_info['loc1'] = $parts[0];
+ }
+
+ $order_info['vendor_id'] = $this->db->f('vendor_id');
+ $order_info['spbudact_code'] = $this->db->f('account_id');
+ $order_info['dimb'] = $this->db->f('ecodimb');
+
+// $criteria_janitor = array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->bestiller ); //bestiller
+// $janitor_contact_id = $this->responsible->get_responsible($criteria_janitor);
+// $janitor_user_id = $this->responsible->get_contact_user_id($janitor_contact_id);
+ $janitor_user_id = $this->db->f('user_id');
+ $order_info['janitor'] = $GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
+
+ $criteria_supervisor = array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->attestant); // attestere
+ $supervisor_contact_id = $this->responsible->get_responsible($criteria_supervisor);
+ $supervisor_user_id = $this->responsible->get_contact_user_id($supervisor_contact_id);
+
+ $order_info['supervisor'] = $GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
+
+ $criteria_budget_responsible = array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->budsjettansvarlig); //anviser
+ $budget_responsible_contact_id = $this->responsible->get_responsible($criteria_budget_responsible);
+ $budget_responsible_user_id = $this->responsible->get_contact_user_id($budget_responsible_contact_id);
+ $order_info['budget_responsible'] = $GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
+
+ return $order_info;
+ }
+
+
+ function import_end_file($buffer)
+ {
+ $num = $this->soXport->add($buffer);
+ if($num > 0)
+ {
+ $this->receipt['message'][]= array('msg' => lang('Successfully imported %1 records into your invoice register.',$num).' '.lang('ID').': '. $buffer[0]['bilagsnr']);
+ return $buffer[0]['bilagsnr'];
+ }
+ return false;
+ }
+ }
Modified: people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_BKK_csv
===================================================================
--- people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_BKK_csv 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_BKK_csv 2010-01-05 21:40:00 UTC (rev 20936)
@@ -45,6 +45,9 @@
var $soXport;
var $invoice;
var $meter_table;
+ var $bilagsnr_0 = 0;
+ var $bilagsnr_1 = 0;
+ var $bilagsnr_2 = 0;
var $import = array(
'Bestilling' => 'pmwrkord_code',
@@ -79,23 +82,17 @@
function import_conv()
{
-
- $this->currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->soXport = CreateObject($this->currentapp.'.soXport');
- $this->invoice = CreateObject($this->currentapp.'.boinvoice');
- $this->bocommon = CreateObject($this->currentapp.'.bocommon');
+ $this->soXport = CreateObject('property.soXport');
+ $this->invoice = CreateObject('property.boinvoice');
+ $this->bocommon = CreateObject('property.bocommon');
$this->dateformat = $this->bocommon->dateformat;
$this->datetimeformat = $this->bocommon->datetimeformat;
- $this->next_bilagsnr = $this->invoice->next_bilagsnr();
$this->config = CreateObject('phpgwapi.config','property');
$this->config->read_repository();
$this->meter_table = $this->config->config_data['meter_table'];
- // $this->db = $GLOBALS['phpgw']->db;
$this->db = $this->bocommon->new_db();
$this->join = $this->bocommon->join;
-
-
}
function import($invoice_common,$download)
@@ -154,7 +151,7 @@
if(!$download)
{
- $buffer = $this->import_end_file($buffer,$invoice_common['bilagsnr']);
+ $buffer = $this->import_end_file($buffer);
}
$this->header = array('Fakt. Nr','Måler nr','Konto','Objekt','MVA','Tjeneste','Belop [kr]','Omr','Adresse');
@@ -194,6 +191,18 @@
$value = str_replace(' ','',$value);
$value = str_replace(',','.',$value);
+
+ if($value < 0)
+ {
+ $buffer[$this->id]['artid'] = 2;
+ $buffer[$this->id]['bilagsnr'] = $this->next_bilagsnr_2();
+ }
+ else
+ {
+ $buffer[$this->id]['artid'] = $invoice_common['art'];
+ $buffer[$this->id]['bilagsnr'] = $this->next_bilagsnr_1();
+ }
+
if( $invoice_common['art'] == 2 ) // kreditnota
{
$value = -1 * abs($value);
@@ -252,7 +261,6 @@
}
$buffer[$this->id][$name] = $value;
- $buffer[$this->id]['bilagsnr'] = $this->next_bilagsnr;
$buffer[$this->id]['fakturanr'] = $invoice_common['invoice_num'];
$buffer[$this->id]['dima'] = $dima;
$buffer[$this->id]['loc1'] = $loc1;
@@ -266,7 +274,7 @@
$buffer[$this->id]['forfallsdato'] = $payment_date;
$buffer[$this->id]['periode'] = $invoice_common['smonth'];
$buffer[$this->id]['regtid'] = date($this->datetimeformat);
- $buffer[$this->id]['artid'] = $invoice_common['art'];
+
$buffer[$this->id]['godkjentbelop'] = $godkjentbelop;
$buffer[$this->id]['spvend_code'] = $invoice_common['vendor_id'];
$buffer[$this->id]['dimb'] = $invoice_common['dim_b'];
@@ -304,11 +312,69 @@
return $maalerinfo;
}
- function import_end_file($buffer,$bilagsnr)
+ function import_end_file($buffer)
{
$num = $this->soXport->add($buffer);
- $receipt['message'][]= array('msg' => lang('Successfully imported %1 records into your invoice register.',$num).' '.lang('ID').': '. $bilagsnr);
+
+ $_bilagsnr = array();
+ if($this->bilagsnr_1)
+ {
+ $_bilagsnr[] = $this->bilagsnr_1;
+ }
+ if($this->bilagsnr_2)
+ {
+ $_bilagsnr[] = $this->bilagsnr_2;
+ }
+
+ $bilagsnr = max($_bilagsnr);
+ $this->db->query("UPDATE fm_idgenerator SET VALUE ={$bilagsnr} WHERE name = 'Bilagsnummer'");
+
+ $receipt['message'][]= array('msg' => lang('Successfully imported %1 records into your invoice register.',$num).' '.lang('ID').': '. implode(',', $_bilagsnr));
return $receipt;
}
+
+ protected function next_bilagsnr_1()
+ {
+ if ($this->bilagsnr_1)
+ {
+ return $this->bilagsnr_1;
+ }
+ else
+ {
+ if(!$this->bilagsnr_0)
+ {
+ $this->bilagsnr_0 = $this->invoice->next_bilagsnr();
+ $this->bilagsnr_1 = $this->bilagsnr_0;
+ }
+ else
+ {
+ $this->bilagsnr_1 = $this->bilagsnr_0 + 1;
+ }
+
+ return $this->bilagsnr_1;
+ }
+ }
+
+ protected function next_bilagsnr_2()
+ {
+ if ($this->bilagsnr_2)
+ {
+ return $this->bilagsnr_2;
+ }
+ else
+ {
+ if(!$this->bilagsnr_0)
+ {
+ $this->bilagsnr_0 = $this->invoice->next_bilagsnr();
+ $this->bilagsnr_2 = $this->bilagsnr_0;
+ }
+ else
+ {
+ $this->bilagsnr_2 = $this->bilagsnr_0 + 1;
+ }
+
+ return $this->bilagsnr_2;
+ }
+ }
}
?>
Deleted: people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_basware_X205
===================================================================
--- people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_basware_X205 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/import/default/Import_fra_basware_X205 2010-01-05 21:40:00 UTC (rev 20936)
@@ -1,307 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <[email protected]>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc. http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
- * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage import
- * @version $Id: Import_fra_basware_xml,v 1.13 2007/03/18 16:33:16 sigurdne Exp $
- */
-
- /**
- * Filteret benytter format X205 for integrasjon mellom Contempus Invoice og ClockWork Logistics.
- * Formatet sender innskannede fakturaer fra Contempus til ClockWork - og Portico Estate
- * @package property
- */
-
-
- class import_conv
- {
- var $mvakode=0;
- var $kildeid=1;
- var $splitt=0;
- var $soXport;
- var $invoice;
- var $bestiller = 85; //cat_id for rolle
- var $attestant = 84; //cat_id for rolle
- var $budsjettansvarlig = 83; //cat_id for rolle
-
- var $import = array(
- 'Bilagsnr' => 'bilagsnr',
- 'Fakturanr' => 'fakturanr',
- 'Konto' => 'spbudact_code',
- 'Objekt' => 'dima', //objectclass: organizationalPerson
- 'DimB' => 'dimb',
- 'KID' => 'kidnr',
- 'MVA' => 'mvakode',
- 'Tjeneste'=> 'kostra_id',
- 'Belop [kr]' => 'belop',
- 'Referanse' => 'referanse',
- 'BOEI Gateadresse' => 'boei_gateadresse',
- );
-
- var $header = array('Bilagsnr','Fakturanr','Konto','Objekt','DimB','KID','MVA','Tjeneste','Belop [kr]','Referanse');
-
- function import_conv()
- {
- $this->soXport = CreateObject('property.soXport');
- $this->invoice = CreateObject('property.soinvoice');
- $this->responsible = CreateObject('property.soresponsible');
- $this->db = & $GLOBALS['phpgw']->db;
- $this->join = & $this->db->join;
- $this->left_join = & $this->db->left_join;
- $this->like = & $this->db->like;
- $this->dateformat = $this->db->date_format();
- $this->datetimeformat = $this->db->datetime_format();
- }
-
- function import($invoice_common,$download)
- {
- $tsvfile = $invoice_common['tsvfile'];
- $valid_data= False;
- $bilagsnr = $this->invoice->next_bilagsnr();
-
- $buffer = array();
-
- $xmlparse = CreateObject('property.XmlToArray');
- $xmlparse->setEncoding('UTF-8');
- $var_result = $xmlparse->parseFile($tsvfile);
-
- set_time_limit(300);
-
- if (isset($var_result['INVOICES']) AND is_array($var_result['INVOICES']))
- {
- $transferdate = str_replace('.', '-', $var_result['TRANSACTIONINFORMATION'][0]['TRANSFERDATE']);// 2009.05.28
- $transfertime = $var_result['TRANSACTIONINFORMATION'][0]['TRANSFERTIME'];// 13:10:28
- $regtid = date($this->datetimeformat,strtotime("{$transferdate} {$transfertime}"));
-
- $i = 0;
- foreach ($var_result['INVOICES'] as $dummy => $entry)
- {
- $_data = $entry['INVOICE'][0]['INVOICEHEADER'][0];
-
-//_debug_array($_data);
-//die();
-
- $_data['KEY']; // => 1400050146
-// $_data['SCANNINGNO']; // => 11E28NJINL3VR6
-// $_data['AMOUNT']; // => 312500
- $_data['ARRIVAL']; // => 2009.05.28
- $_data['CLIENT.CODE']; // => 14
- $_data['CURRENCY.CURRENCYID']; // => NOK
- $_data['EXCHANGERATE']; // => 1
-// $_data['INVOICEDATE']; // => 2009.05.28
- $_data['LOCALAMOUNT']; // => 312500
- $_data['LOCALVATAMOUNT']; // => 62500
-// $_data['MATURITY']; // => 2009.06.30
- $_data['PAYAMOUNT']; // => 0
- $_data['POSTATUSUPDATED']; // => 0
-// $_data['PURCHASEORDERNO']; // => 1409220008
- $_data['PURCHASEORDERSTATUS.CODE']; // => WaitForMatch
- $_data['SUPPLIER.BANKGIRO']; // => 70580621110
-// $_data['SUPPLIER.CODE']; // => 100644
-// $_data['SUPPLIERREF']; // => 7869
- $_data['VATAMOUNT']; // => 62500
-
-
- $order_id = $_data['PURCHASEORDERNO'];
- $fakturanr = $_data['KEY'];
- $fakturadato = date($this->dateformat,strtotime(str_replace('.', '-', $_data['INVOICEDATE'])));
- $forfallsdato = date($this->dateformat,strtotime(str_replace('.', '-', $_data['MATURITY'])));
- $periode = date('n',strtotime(str_replace('.', '-', $_data['INVOICEDATE'])));
- $belop = $_data['AMOUNT']/100;
-
- if( $belop < 0 )
- {
- $invoice_common['art'] = 2;
- }
- if( $invoice_common['art'] == 2 ) // kreditnota
- {
- $belop = -1 * abs($belop);
- }
-
- $kidnr = $_data['KIDNO'];
-
- $buffer[$i]['external_ref'] = $_data['SCANNINGNO'];
- $buffer[$i]['pmwrkord_code'] = $order_id;
- $buffer[$i]['fakturanr'] = $fakturanr;
- $buffer[$i]['periode'] = $periode;
- $buffer[$i]['forfallsdato'] = $forfallsdato;
- $buffer[$i]['fakturadato'] = $fakturadato;
- $buffer[$i]['belop'] = $belop;
- $buffer[$i]['godkjentbelop'] = $belop;
-
- $buffer[$i]['kidnr'] = $kidnr;
- $buffer[$i]['bilagsnr'] = $bilagsnr;
- $buffer[$i]['referanse'] = "ordre: {$order_id}";
-
- $order_info = $this->get_order_info($order_id);
-
- if(isset($invoice_common['dim_b']) && $invoice_common['dim_b'])
- {
- $buffer[$i]['dimb'] = $invoice_common['dim_b'];
- }
- else
- {
- $buffer[$i]['dimb'] = $order_info['dimb'];
- }
-
- $buffer[$i]['dima'] = $order_info['dima'];
- $buffer[$i]['loc1'] = $order_info['loc1'];
-
- $buffer[$i]['mvakode'] = $this->mvakode;
-
- if($buffer[$i]['dima'] && (isset($invoice_common['auto_tax']) && $invoice_common['auto_tax']))
- {
- $mvakode = $this->soXport->auto_tax($buffer[$i]['dima']);
-
- if($mvakode)
- {
- $buffer[$i]['mvakode'] = $mvakode;
- }
- }
-
- if(isset($invoice_common['vendor_id']) && $invoice_common['vendor_id'])
- {
- $vendor_id = $invoice_common['vendor_id'];
- }
- else if ($order_id)
- {
- $vendor_id = $order_info['vendor_id'];
- }
- else
- {
- $vendor_id = $_data['SUPPLIER.CODE'];
- }
-
-
- if(isset($invoice_common['auto_tax']) && $invoice_common['auto_tax'])
- {
- $buffer[$i]['mvakode'] = $this->soXport->tax_b_account_override($buffer[$i]['mvakode'], $order_info['spbudact_code']);
- $buffer[$i]['mvakode'] = $this->soXport->tax_vendor_override($buffer[$i]['mvakode'], $vendor_id);
- }
-
- $buffer[$i]['kostra_id'] = $this->soXport->get_kostra_id($buffer[$i]['loc1']);
-
- $merknad = "lag meg ein link til bilde av faktura - ref: {$_data['SCANNINGNO']}";
-
- $buffer[$i]['merknad'] = $merknad;
- $buffer[$i]['splitt'] = $this->splitt;
- $buffer[$i]['kildeid'] = $this->kildeid;
- $buffer[$i]['spbudact_code'] = $order_info['spbudact_code'];
- $buffer[$i]['typeid'] = isset($invoice_common['type']) && $invoice_common['type'] ? $invoice_common['type'] : 1;
- $buffer[$i]['regtid'] = $regtid;
- $buffer[$i]['artid'] = $invoice_common['art'];
- $buffer[$i]['spvend_code'] = $vendor_id;
-
- $oppsynsmannid = '';
- if(isset($invoice_common['janitor']) && $invoice_common['janitor'])
- {
- $oppsynsmannid = $invoice_common['janitor'];
- }
- else if($order_info['janitor'])
- {
- $oppsynsmannid = $order_info['janitor'];
- }
-
- $saksbehandlerid = '';
- if(isset($invoice_common['supervisor']) && $invoice_common['supervisor'])
- {
- $saksbehandlerid = $invoice_common['supervisor'];
- }
- else if($order_info['supervisor'])
- {
- $saksbehandlerid = $order_info['supervisor'];
- }
-
- $budsjettansvarligid = '';
- if(isset($invoice_common['budget_responsible']) && $invoice_common['budget_responsible'])
- {
- $budsjettansvarligid = $invoice_common['budget_responsible'];
- }
- else if($order_info['budget_responsible'])
- {
- $budsjettansvarligid = $order_info['budget_responsible'];
- }
-
- $buffer[$i]['oppsynsmannid'] = $oppsynsmannid;
- $buffer[$i]['saksbehandlerid'] = $saksbehandlerid;
- $buffer[$i]['budsjettansvarligid'] = $budsjettansvarligid;
-
- $bilagsnr++;
- $i++;
- }
- }
-
- if(!$download)
- {
- $buffer = $this->import_end_file($buffer,$invoice_common['bilagsnr']);
- }
-
- return $buffer;
- }
-
- function get_order_info($order_id = '')
- {
- $order_info = array();
- $order_id = (int) $order_id;
- $sql = "SELECT fm_workorder.location_code,fm_workorder.vendor_id,fm_workorder.account_id,fm_workorder.ecodimb, fm_workorder.user_id"
- . " FROM fm_workorder {$this->join} fm_project ON fm_workorder.project_id = fm_project.id WHERE fm_workorder.id = $order_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- if ($this->db->f('location_code'))
- {
- $parts = explode('-',$this->db->f('location_code'));
- $order_info['dima'] = implode('', $parts);
- $order_info['loc1'] = $parts[0];
- }
-
- $order_info['vendor_id'] = $this->db->f('vendor_id');
- $order_info['spbudact_code'] = $this->db->f('account_id');
- $order_info['dimb'] = $this->db->f('ecodimb');
-
- $criteria_janitor = array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->bestiller ); //bestiller
- $janitor_contact_id = $this->responsible->get_responsible($criteria_janitor);
- $janitor_user_id = $this->responsible->get_contact_user_id($janitor_contact_id);
- $order_info['janitor'] = $GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
-
- $criteria_supervisor = array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->attestant); // attestere
- $supervisor_contact_id = $this->responsible->get_responsible($criteria_supervisor);
- $supervisor_user_id = $this->responsible->get_contact_user_id($supervisor_contact_id);
- $order_info['supervisor'] = $GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
-
- $criteria_budget_responsible = array('ecodimb' => $order_info['dimb'], 'cat_id' => $this->budsjettansvarlig); //anviser
- $budget_responsible_contact_id = $this->responsible->get_responsible($criteria_budget_responsible);
- $budget_responsible_user_id = $this->responsible->get_contact_user_id($budget_responsible_contact_id);
- $order_info['budget_responsible'] = $GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
-
- return $order_info;
- }
-
-
- function import_end_file($buffer,$bilagsnr)
- {
- $num = $this->soXport->add($buffer);
- $receipt['message'][]= array('msg' => lang('Successfully imported %1 records into your invoice register.',$num).' '.lang('ID').': '. $bilagsnr);
- return $receipt;
- }
- }
Modified: people/sigurdne/modules/property/trunk/inc/ods/ods.php
===================================================================
--- people/sigurdne/modules/property/trunk/inc/ods/ods.php 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/inc/ods/ods.php 2010-01-05 21:40:00 UTC (rev 20936)
@@ -10,7 +10,7 @@
Copyright: Juan Lao Tebar ([email protected]) and Jose Carlos Norte ([email protected]) - 2008
https://sourceforge.net/projects/ods-php/
-@version $Id$
+@version $Id: ods.php 4237 2009-11-27 23:17:21Z sigurd $
*/
class ods {
Modified: people/sigurdne/modules/property/trunk/js/yahoo/invoice.list_sub.js
===================================================================
--- people/sigurdne/modules/property/trunk/js/yahoo/invoice.list_sub.js 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/js/yahoo/invoice.list_sub.js 2010-01-05 21:40:00 UTC (rev 20936)
@@ -236,7 +236,7 @@
CreateRowChecked("transfer_idClass");
td_empty(4);
td_sum(values_ds.sum);
- td_empty(5);
+ td_empty(6);
//Add to Table
myfoot = tableYUI.createTFoot();
myfoot.setAttribute("id","myfoot");
Modified: people/sigurdne/modules/property/trunk/templates/base/config.tpl
===================================================================
--- people/sigurdne/modules/property/trunk/templates/base/config.tpl 2010-01-05 21:38:51 UTC (rev 20935)
+++ people/sigurdne/modules/property/trunk/templates/base/config.tpl 2010-01-05 21:40:00 UTC (rev 20936)
@@ -16,9 +16,24 @@
<td>{lang_organisation}:</td>
<td><input name="newsettings[org_name]" value="{value_org_name}"></td>
</tr>
+ <tr class="row_off">
+ <td>{lang_needed_for_invoice_approval}:</td>
+ <td>
+ <select name="newsettings[invoice_approval]">
+ <option value="" {selected_invoice_approval_}>2</option>
+ <option value="1" {selected_invoice_approval_1}>1</option>
+ </select>
+ </td>
+ </tr>
+
<tr class="row_on">
- <td>{lang_Path_to_Invoice_Export_file}: ({lang_mandatory})<br>
+ <td>{lang_Path_to_Invoice_import_files}:<br>
{lang_On_windows_use}: "//computername/share" {lang_or} "\\\\computername\share"</td>
+ <td><input name="newsettings[import_path]" value="{value_import_path}"></td>
+ </tr>
+ <tr class="row_on">
+ <td>{lang_Path_to_Invoice_Export_files}: ({lang_mandatory})<br>
+ {lang_On_windows_use}: "//computername/share" {lang_or} "\\\\computername\share"</td>
<td><input name="newsettings[export_path]" value="{value_export_path}"></td>
</tr>
<tr class="row_off">
@@ -26,6 +41,10 @@
{lang_On_windows_use}: "//computername/share" {lang_or} "\\\\computername\share"</td>
<td><input name="newsettings[export_pre_path]" value="{value_export_pre_path}"></td>
</tr>
+ <tr class="row_off">
+ <td>{lang_baseurl_to_invoice_image}:</td>
+ <td><input name="newsettings[baseurl_invoice]" value="{value_baseurl_invoice}"></td>
+ </tr>
<tr class="row_on">
<td>{lang_invoice_export_method}:</td>
<td>
@@ -101,17 +120,8 @@
</table>
</td>
</tr>
- <tr class="row_off">
- <td>{lang_TTS_file_upload}:</td>
- <td>
- <select name="newsettings[fmttsfileupload]">
- <option value="" {selected_fmttsfileupload_}>NO</option>
- <option value="1" {selected_fmttsfileupload_1}>YES</option>
- </select>
- </td>
- </tr>
<tr class="row_on">
- <td>{lang_Mail_Notification_(TTS)}:</td>
+ <td>{lang_Mail_Notification}:</td>
<td>
<select name="newsettings[mailnotification]">
<option value="" {selected_mailnotification_}>NO</option>
@@ -120,8 +130,17 @@
</td>
</tr>
<tr class="row_off">
- <td>{lang_Owner_Notification_(TTS)}.</td>
+ <td>{lang_Owner_Notification_Project}.</td>
<td>
+ <select name="newsettings[notify_project_owner]">
+ <option value="" {selected_notify_project_owner_}>NO</option>
+ <option value="1" {selected_notify_project_owner_1}>YES</option>
+ </select>
+ </td>
+ </tr>
+ <tr class="row_off">
+ <td>{lang_Owner_Notification_TTS}.</td>
+ <td>
<select name="newsettings[ownernotification]">
<option value="" {selected_ownernotification_}>NO</option>
<option value="1" {selected_ownernotification_1}>YES</option>
@@ -129,7 +148,7 @@
</td>
</tr>
<tr class="row_on">
- <td>{lang_Assigned_Notification_(TTS)}.</td>
+ <td>{lang_Assigned_Notification_TTS}.</td>
<td>
<select name="newsettings[assignednotification]">
<option value="" {selected_assignednotification_}>NO</option>
@@ -138,7 +157,7 @@
</td>
</tr>
<tr class="row_off">
- <td>{lang_Group_Notification_(TTS)}.</td>
+ <td>{lang_Group_Notification_TTS}.</td>
<td>
<select name="newsettings[groupnotification]">
<option value="" {selected_groupnotification_}>NO</option>
@@ -146,8 +165,17 @@
</select>
</td>
</tr>
+ <tr class="row_off">
+ <td>{lang_TTS_file_upload}:</td>
+ <td>
+ <select name="newsettings[fmttsfileupload]">
+ <option value="" {selected_fmttsfileupload_}>NO</option>
+ <option value="1" {selected_fmttsfileupload_1}>YES</option>
+ </select>
+ </td>
+ </tr>
<tr class="row_on">
- <td>{lang_priority_levels_(TTS)}.</td>
+ <td>{lang_priority_levels_TTS}.</td>
<td>
<select name="newsettings[prioritylevels]">
<option value="" {selected_prioritylevels_}>3</option>
@@ -157,7 +185,7 @@
</td>
</tr>
<tr class="row_off">
- <td>{lang_mandatory_title_(TTS)}.</td>
+ <td>{lang_mandatory_title_TTS}.</td>
<td>
<select name="newsettings[tts_mandatory_title]">
<option value="" {selected_tts_mandatory_title_}>NO</option>