[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7515] property: more on import
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7515] property: more on import |
Date: |
Fri, 19 Aug 2011 12:57:35 +0000 |
Revision: 7515
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7515
Author: sigurdne
Date: 2011-08-19 12:57:35 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
property: more on import
Modified Paths:
--------------
trunk/property/inc/import/default/cvs_import_vedlikeholdsplan_bkb
Modified: trunk/property/inc/import/default/cvs_import_vedlikeholdsplan_bkb
===================================================================
--- trunk/property/inc/import/default/cvs_import_vedlikeholdsplan_bkb
2011-08-19 08:10:56 UTC (rev 7514)
+++ trunk/property/inc/import/default/cvs_import_vedlikeholdsplan_bkb
2011-08-19 12:57:35 UTC (rev 7515)
@@ -11,6 +11,8 @@
set_time_limit(10000); //Set the time limit for this
request oto 3000 seconds
$this->account =
(int)$GLOBALS['phpgw_info']['user']['account_id'];
$this->db = & $GLOBALS['phpgw']->db;
+ $this->custom =
createObject('property.custom_fields');
+ $this->attrib_data =
$this->custom->find('property', '.project.request', 0, '', 'ASC',
'attrib_sort', true, true);
}
public function add($data)
@@ -81,7 +83,6 @@
$entry_date = time();
}
-//$category = ????;
//$authorities_demands
//$building_part
//$coordinator
@@ -111,7 +112,32 @@
$value_set['closed_date']
= strtotime("{$data[9]}/06/24");
}
}
+
+/*
+ $value_set['in_progress_date'] = time();
+ $value_set['delivered_date'] = time();
+*/
+
+ switch ($data[4])
+ {
+ case 'D':
+ $category = 13;
+ break;
+ case 'V':
+ $category = 12;
+ break;
+ case 'U':
+ $category = 14;
+ break;
+ case 'Kombinasjon':
+ $category = 201;
+ break;
+ default:
+ $category = 201;
+ break;
+
+ }
$value_set['id']
= $id;
$value_set['title']
= $this->db->db_addslashes("{$data[0]}::{$data[6]}::{$data[20]}");
@@ -123,14 +149,45 @@
$value_set['entry_date'] =
$entry_date;
$value_set['budget'] =
(int)str_replace(',', '', $data[21]);
$value_set['status'] =
$status;
- // $value_set['branch_id'] =
$data['branch_id'];
// $value_set['coordinator'] =
$coordinator;
$value_set['authorities_demands'] =
$authorities_demands;
$value_set['building_part'] =
$data[5];
- // $value_set['start_date'] =
$data['start_date'];
- // $value_set['end_date'] =
$data['end_date'];
- // $value_set['regulations'] =
$data['regulations'] ? ',' . implode(',',$data['regulations']) . ',' : '';
+ $value_set['vurderingskriterie'] =
(int)$data[10];
+ reset($this->attrib_data);
+ foreach ( $this->attrib_data as $attrib )
+ {
+ if($attrib['datatype'] == 'LB' &&
$attrib['column_name'] == 'lovhjemmel')
+ {
+ foreach($attrib['choice'] as $choice)
+ {
+
if(preg_match("/{$choice['value']}/i", $data[11]))
+ {
+
$value_set['lovhjemmel'] = $choice['id'];
+ break 2;
+ }
+ }
+ }
+ }
+
+ reset($this->attrib_data);
+ foreach ( $this->attrib_data as $attrib )
+ {
+ if($attrib['datatype'] == 'LB' &&
$attrib['column_name'] == 'forskriftshjemmel')
+ {
+ foreach($attrib['choice'] as $choice)
+ {
+
if(preg_match("/{$choice['value']}/i", $data[12]))
+ {
+
$value_set['forskriftshjemmel'] = $choice['id'];
+ break 2;
+ }
+ }
+ }
+ }
+
+
+
$cols = implode(',', array_keys($value_set));
$values =
$this->db->validate_insert(array_values($value_set));
@@ -142,18 +199,23 @@
}
else
{
-// $request_ok =
$this->db->query($sql,__LINE__,__FILE__);
+ $request_ok =
$this->db->query($sql,__LINE__,__FILE__);
+ if($request_ok)
+ {
+ $this->db->query("UPDATE fm_idgenerator
set value = value + 1 where name = 'request'");
+ }
}
$condition = array();
+ $condition_type = (int) substr($data[14], 0, 1);
- if($data[8] || $data[9])
+ if($data[13] || $data[15])
{
- $condition[1] = array
+ $condition[$condition_type] = array
(
- 'degree' =>
(int)$data[8],
- 'probability' => 2,
- 'consequence' => (int)$data[9]
+ 'degree' =>
(int)$data[13],
+ 'probability' => $data[16] ?
(int)$data[16] : 1,
+ 'consequence' => (int)$data[15]
);
}
@@ -176,141 +238,29 @@
}
else
{
-//
$this->db->query($sql,__LINE__,__FILE__);
+
$this->db->query($sql,__LINE__,__FILE__);
}
}
-/*
- $value_set['in_progress_date'] = time();
- $value_set['closed_date'] = time();
- $value_set['delivered_date'] = time();
-*/
+ $consume_data = array();
- for ($i=13; $i<27; $i++)
+ $j = 0;
+ for ($i=22; $i<36; $i++)
{
$data[$i] = str_replace(',', '', $data[$i]);
- }
- $consume_data = array();
- if($data[13] && ctype_digit($data[13]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[13],
- 'date' => strtotime("2012/06/24")
- );
+ $year = 2012 - $j;
+ $j++;
+ if($data[$i] && ctype_digit($data[$i]))
+ {
+ $consume_data[] = array
+ (
+ 'value' => (int)$data[$i],
+ 'date' =>
strtotime("{$year}/06/24")
+ );
+ }
}
- if($data[14] && ctype_digit($data[14]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[14],
- 'date' => strtotime("2011/06/24")
- );
- }
- if($data[15] && ctype_digit($data[15]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[15],
- 'date' => strtotime("2010/06/24")
- );
- }
- if($data[16] && ctype_digit($data[16]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[16],
- 'date' => strtotime("2009/06/24")
- );
- }
- if($data[17] && ctype_digit($data[17]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[17],
- 'date' => strtotime("2008/06/24")
- );
- }
-
- if($data[18] && ctype_digit($data[18]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[18],
- 'date' => strtotime("2007/06/24")
- );
- }
- if($data[19] && ctype_digit($data[19]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[19],
- 'date' => strtotime("2006/06/24")
- );
- }
- if($data[20] && ctype_digit($data[20]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[20],
- 'date' => strtotime("2005/06/24")
- );
- }
- if($data[21] && ctype_digit($data[21]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[21],
- 'date' => strtotime("2004/06/24")
- );
- }
-
- if($data[22] && ctype_digit($data[22]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[22],
- 'date' => strtotime("2003/06/24")
- );
- }
- if($data[23] && ctype_digit($data[23]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[23],
- 'date' => strtotime("2002/06/24")
- );
- }
- if($data[24] && ctype_digit($data[24]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[24],
- 'date' => strtotime("2001/06/24")
- );
- }
-
- if($data[25] && ctype_digit($data[25]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[25],
- 'date' => strtotime("2000/06/24")
- );
- }
-
- if($data[26] && ctype_digit($data[26]))
- {
- $consume_data[] = array
- (
- 'value' => (int)$data[26],
- 'date' => strtotime("1999/06/24")
- );
- }
-
-
foreach ($consume_data as $consume)
{
$sql = "INSERT INTO fm_request_consume
(request_id,amount,date,user_id,entry_date) "
@@ -320,28 +270,26 @@
. (int)$consume['date'] . ","
. $this->account . ","
. time() . ")";
+
if($debug)
{
_debug_array($sql);
}
else
{
-//
$this->db->query($sql,__LINE__,__FILE__);
+
$this->db->query($sql,__LINE__,__FILE__);
}
}
-// $this->db->query("UPDATE fm_idgenerator set value =
value + 1 where name = 'request'");
-
-
if(!$error)
{
- $this->messages[] = "Successfully imported
location: Title ({$data[1]})";
+ $this->messages[] = "Successfully imported
location: Title ({$data[20]})";
$ok = true;
}
else
{
- $this->errors[] = "Error importing location:
Title ({$data[1]})";
+ $this->errors[] = "Error importing location:
Title ({$data[20]})";
$ok = false;
}
return $ok;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7515] property: more on import,
Sigurd Nes <=