[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10571] property: more on condition survey
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10571] property: more on condition survey |
Date: |
Wed, 05 Dec 2012 14:52:24 +0000 |
Revision: 10571
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10571
Author: sigurdne
Date: 2012-12-05 14:52:23 +0000 (Wed, 05 Dec 2012)
Log Message:
-----------
property: more on condition survey
Modified Paths:
--------------
trunk/property/inc/class.bocondition_survey.inc.php
trunk/property/inc/class.socondition_survey.inc.php
trunk/property/inc/class.sorequest.inc.php
trunk/property/inc/class.uicondition_survey.inc.php
Modified: trunk/property/inc/class.bocondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.bocondition_survey.inc.php 2012-12-04 14:22:03 UTC
(rev 10570)
+++ trunk/property/inc/class.bocondition_survey.inc.php 2012-12-05 14:52:23 UTC
(rev 10571)
@@ -284,8 +284,35 @@
}
+ public function import($survey, $import_data)
+ {
+ try
+ {
+ $this->so->import($survey, $import_data);
+ }
+
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
+ }
+
public function delete($id)
{
- $this->so->delete($id);
+ try
+ {
+ $this->so->delete($id);
+ }
+
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
}
}
Modified: trunk/property/inc/class.socondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.socondition_survey.inc.php 2012-12-04 14:22:03 UTC
(rev 10570)
+++ trunk/property/inc/class.socondition_survey.inc.php 2012-12-05 14:52:23 UTC
(rev 10571)
@@ -226,7 +226,7 @@
{
if ( $e )
{
- throw $e;
+ throw $e;
}
return 0;
}
@@ -257,7 +257,7 @@
{
if ( $e )
{
- throw $e;
+ throw $e;
}
}
@@ -282,7 +282,7 @@
{
if ( $e )
{
- throw $e;
+ throw $e;
}
}
@@ -311,7 +311,7 @@
{
if ( $e )
{
- throw $e;
+ throw $e;
}
}
@@ -414,10 +414,91 @@
return $value_set;
}
- function delete($id)
+ public function import($survey, $import_data = array())
{
+ if(!isset($survey['id']) || !$survey['id'])
+ {
+ throw new
Exception('property_socondition_survey::import - missing id');
+ }
+
+ $location_data =
execMethod('property.solocation.read_single', $survey['location_code']);
+
+ $_locations = explode('-', $survey['location_code']);
+ $i=1;
+ foreach ($_locations as $_location)
+ {
+ $location["loc{$i}"] = $_location;
+ $i++;
+ }
+
+ $sorequest = CreateObject('property.sorequest');
+
+_debug_array($survey);
+
+ $this->_db->transaction_begin();
+
+ foreach ($import_data as $entry)
+ {
+ if( $entry['condition_degree'] )
+ {
+ $request = array();
+ $request['street_name'] =
$location_data['street_name'];
+ $request['street_number'] =
$location_data['street_number'];
+ $request['location'] = $location;
+ $request['origin'] =
array(array('location' => '.project.condition_survey', 'id' =>
(int)$survey['id']));
+
+ $request['title'] = $entry['title'];
+ $request['descr'] = $entry['descr'];
+ $request['cat_id'] = 13; //???? FIXME
+ $request['building_part'] =
$entry['building_part'];
+ $request['coordinator'] =
$survey['coordinator_id'];
+ $request['status'] =
'registrert';//???? FIXME
+ $request['budget'] = $entry['amount'];
+ $request['planning_date'] =
mktime(13,0,0,7,1, $entry['due_year']?$entry['due_year']:date('Y'));
+ $request['planning_value'] =
$entry['amount'];
+ $request['condition'] = array
+ (
+ array
+ (
+ 'degree' =>
$entry['condition_degree'],
+ 'condition_type' =>
$entry['condition_type'],
+ 'consequence' =>
$entry['consequence'],
+ 'probability' =>
$entry['probability']
+ )
+ );
+ }
+
+_debug_array($request);
+ // $sorequest->add($request, $values_attribute =
array())
+
+ }
+ die();
+
+
+ $this->_db->transaction_commit();
+ }
+
+ public function delete($id)
+ {
$id = (int) $id;
- $table = 'fm_condition_survey';
- $this->_db->query("DELETE FROM $table WHERE
id={$id}",__LINE__,__FILE__);
+ $this->_db->transaction_begin();
+
+ try
+ {
+ $this->_db->Exception_On_Error = true;
+ $this->_db->query("DELETE FROM
fm_condition_survey WHERE id={$id}",__LINE__,__FILE__);
+ $this->_db->query("DELETE FROM fm_request WHERE
condition_survey_id={$id}",__LINE__,__FILE__);
+ $this->_db->Exception_On_Error = false;
+ }
+
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
+
+ $this->_db->transaction_commit();
}
}
Modified: trunk/property/inc/class.sorequest.inc.php
===================================================================
--- trunk/property/inc/class.sorequest.inc.php 2012-12-04 14:22:03 UTC (rev
10570)
+++ trunk/property/inc/class.sorequest.inc.php 2012-12-05 14:52:23 UTC (rev
10571)
@@ -38,6 +38,7 @@
{
public $sum_budget = 0;
public $sum_consume = 0;
+ protected $global_lock = false;
function __construct()
{
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
@@ -780,7 +781,7 @@
function add($request, $values_attribute = array())
{
- //_debug_array($request);
+// _debug_array($request);die();
$receipt = array();
$value_set = array();
@@ -825,8 +826,17 @@
$address =
$this->db->db_addslashes($request['location_name']);
}
- $this->db->transaction_begin();
+ if ( $this->db->get_transaction() )
+ {
+ $this->global_lock = true;
+ }
+ else
+ {
+ $this->db->transaction_begin();
+ }
+
+
$id = $this->next_id();
$value_set['id']
= $id;
@@ -946,18 +956,20 @@
. time() . ")",__LINE__,__FILE__);
}
- if($this->db->transaction_commit())
+ $this->increment_request_id();
+ $this->historylog->add('SO',$id,$request['status']);
+ $this->historylog->add('TO',$id,$request['cat_id']);
+
$this->historylog->add('CO',$id,$request['coordinator']);
+ $receipt['message'][] = array('msg'=>lang('request %1
has been saved',$id));
+
+
+ if ( !$this->global_lock )
{
- $this->increment_request_id();
-
$this->historylog->add('SO',$id,$request['status']);
-
$this->historylog->add('TO',$id,$request['cat_id']);
-
$this->historylog->add('CO',$id,$request['coordinator']);
- $receipt['message'][] =
array('msg'=>lang('request %1 has been saved',$id));
+ $this->db->transaction_commit();
}
- else
- {
- $receipt['error'][] =
array('msg'=>lang('request %1 has not been saved',$id));
- }
+
+// $receipt['error'][] =
array('msg'=>lang('request %1 has not been saved',$id));
+
$receipt['id'] = $id;
return $receipt;
}
Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2012-12-04 14:22:03 UTC
(rev 10570)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2012-12-05 14:52:23 UTC
(rev 10571)
@@ -66,6 +66,7 @@
$this->acl_manage =
$this->acl->check($this->acl_location, 16, 'property');
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
"property::project::condition_survey";
+ //
$GLOBALS['phpgw']->css->add_external_file('logistic/templates/base/css/base.css');
}
@@ -668,17 +669,19 @@
$tabs['step_3'] = array('label' =>
lang('choose start line'), 'link' => self::link(array('menuaction' =>
'property.uicondition_survey.import', 'id' =>$id, 'step' => 2, 'sheet_id' =>
$sheet_id, 'start_line' => $start_line )));
$tabs['step_4'] = array('label' =>
lang('choose columns'), 'link' => '#step_4');
break;
+/*
case 4://temporary
phpgwapi_cache::session_clear('property', 'condition_survey_import_file');
unlink($cached_file);
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction' =>
'property.uicondition_survey.import', 'id' =>$id, 'step' => 0));
break;
+*/
}
//-----------
$data = array();
- if(!$step || $step == 4)
+ if(!$step )
{
phpgwapi_cache::session_clear('property',
'condition_survey_import_file');
unlink($cached_file);
@@ -718,6 +721,7 @@
}
}
+ $survey = $this->bo->read_single( array('id' => $id,
'view' => $mode == 'view') );
$html_table = '<table border="1">';
if($data && $step == 2)
@@ -771,79 +775,90 @@
$html_table .= "<tr><td>[{$_column}]
{$_value}</td><td>{$_listbox}</td><tr>";
}
}
+ else if($data && $step == 4)
+ {
+// _debug_array($columns);
+ $rows = count($data)+1;
+
+ $import_data = array();
+
+ for ($i=$start_line; $i<$rows; $i++ )
+ {
+ $_result = array();
+
+ foreach ($columns as $_row_key =>
$_value_key)
+ {
+ if($_value_key !=
'_skip_import_')
+ {
+ $_result[$_value_key]
=trim($data[$i][$_row_key]);
+ }
+
+ }
+ $import_data[] = $_result;
+ }
+ if($import_data)
+ {
+ try
+ {
+ $this->bo->import($survey,
$import_data);
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+
phpgwapi_cache::message_set($e->getMessage(), 'error');
+ }
+ }
+ }
+
+// $msg = "'{$cached_file}' contained " .
count($import_data) . " lines";
+// phpgwapi_cache::message_set($msg, 'message');
+
+// _debug_array($import_data);die();
+ }
+
+
+
$html_table .= '</table>';
-//
- $values = $this->bo->read_single( array('id' => $id,
'view' => $mode == 'view') );
- if(isset($values['location_code']) &&
$values['location_code'])
+
+
+ if(isset($survey['location_code']) &&
$survey['location_code'])
{
- $values['location_data'] =
execMethod('property.solocation.read_single', $values['location_code']);
+ $survey['location_data'] =
execMethod('property.solocation.read_single', $survey['location_code']);
}
$bolocation = CreateObject('property.bolocation');
$location_data = $bolocation->initiate_ui_location(array
(
- 'values' =>
$values['location_data'],
+ 'values' =>
$survey['location_data'],
'type_id' => 2,
'lookup_type' => 'view2',
'tenant' => false,
'lookup_entity' => array(),
- 'entity_data' =>
isset($values['p'])?$values['p']:''
+ 'entity_data' =>
isset($survey['p'])?$survey['p']:''
));
-//
$data = array
(
'lang_submit'
=> $lang_submit,
- 'survey'
=> $values,
+ 'survey'
=> $survey,
'location_data2'
=> $location_data,
'step'
=> $step +1,
'sheet_id'
=> $sheet_id,
'start_line'
=> $start_line,
'html_table'
=> $html_table,
'sheets'
=> array('options' => $sheets),
- // 'tabs'
=> phpgwapi_yui::tabview_generate($tabs, $active_tab),
'tabs'
=>$GLOBALS['phpgw']->common->create_tabs($tabs, $active_tab),
);
-//_debug_array($data);die();
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . '::' . lang('condition survey import');
self::render_template_xsl(array('condition_survey_import'), $data);
-//_debug_array($html_table);
-
-return;
-
-
- $start = 1; // Where to start
-
- $fields = array_values($data[($start-1)]);
-
- $rows = count($data)+1;
-
- $result = array();
-
- for ($i=$start; $i<$rows; $i++ )
- {
- $_result = array();
- $j=0;
- foreach($data[$i] as $key => $value)
- {
- $_result[$j] = trim($value);
- $j++;
- }
- $result[] = $_result;
- }
-
- $msg = "'{$path}' contained " . count($result) . "
lines";
-
-_debug_array($msg);
-_debug_array($result);die();
-
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10571] property: more on condition survey,
Sigurd Nes <=