[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10530] property: more on condition survey
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10530] property: more on condition survey |
Date: |
Thu, 22 Nov 2012 14:24:13 +0000 |
Revision: 10530
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10530
Author: sigurdne
Date: 2012-11-22 14:24:07 +0000 (Thu, 22 Nov 2012)
Log Message:
-----------
property: more on condition survey
Modified Paths:
--------------
trunk/property/inc/class.bocommon.inc.php
trunk/property/inc/class.bocondition_survey.inc.php
trunk/property/inc/class.bolocation.inc.php
trunk/property/inc/class.socondition_survey.inc.php
trunk/property/inc/class.uicondition_survey.inc.php
Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php 2012-11-22 13:15:58 UTC (rev
10529)
+++ trunk/property/inc/class.bocommon.inc.php 2012-11-22 14:24:07 UTC (rev
10530)
@@ -2012,11 +2012,14 @@
//_debug_array($insert_record);die();
if($insert_record)
{
- for ($i=0;
$i<count($insert_record['location']); $i++)
+ if( isset($insert_record['location']) &&
is_array($insert_record['location']) )
{
-
if(isset($_POST[$insert_record['location'][$i]]) &&
$_POST[$insert_record['location'][$i]])
+ for ($i=0;
$i<count($insert_record['location']); $i++)
{
-
$values['location'][$insert_record['location'][$i]]=
phpgw::get_var($insert_record['location'][$i], 'string', 'POST');
+
if(isset($_POST[$insert_record['location'][$i]]) &&
$_POST[$insert_record['location'][$i]])
+ {
+
$values['location'][$insert_record['location'][$i]]=
phpgw::get_var($insert_record['location'][$i], 'string', 'POST');
+ }
}
}
@@ -2034,7 +2037,10 @@
{
foreach
($insert_record['additional_info'] as $additional_info)
{
-
$values['additional_info'][$additional_info['input_text']] =
phpgw::get_var($additional_info['input_name'], 'string', 'POST');
+ if($additional_info_value =
phpgw::get_var($additional_info['input_name'], 'string', 'POST'))
+ {
+
$values['additional_info'][$additional_info['input_text']] =
$additional_info_value;
+ }
}
}
}
Modified: trunk/property/inc/class.bocondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.bocondition_survey.inc.php 2012-11-22 13:15:58 UTC
(rev 10529)
+++ trunk/property/inc/class.bocondition_survey.inc.php 2012-11-22 14:24:07 UTC
(rev 10530)
@@ -153,24 +153,31 @@
return $values;
}
- public function save($data,$action='',$values_attribute =
array())
+ public function save($data = array())
{
- if(is_array($values_attribute))
+ if(isset($data['attributes']) &&
is_array($data['attributes']))
{
- $values_attribute =
$this->custom->convert_attribute_save($values_attribute);
+ $data['attributes'] =
$this->custom->convert_attribute_save($data['attributes']);
}
- if ($action=='edit')
+ try
{
- if ($data['id'] != '')
+ if (isset($data['id']) && $data['id'])
{
-
- $receipt =
$this->so->edit($data,$values_attribute);
+ $receipt = $this->so->edit($data);
}
+ else
+ {
+ $receipt = $this->so->add($data);
+ }
}
- else
+
+ catch(Exception $e)
{
- $receipt =
$this->so->add($data,$values_attribute);
+ if ( $e )
+ {
+ throw $e;
+ }
}
return $receipt;
Modified: trunk/property/inc/class.bolocation.inc.php
===================================================================
--- trunk/property/inc/class.bolocation.inc.php 2012-11-22 13:15:58 UTC (rev
10529)
+++ trunk/property/inc/class.bolocation.inc.php 2012-11-22 14:24:07 UTC (rev
10530)
@@ -596,7 +596,9 @@
}
if(isset($insert_record))
{
-
$GLOBALS['phpgw']->session->appsession('insert_record','property',$insert_record);
+ //
$GLOBALS['phpgw']->session->appsession('insert_record','property',$insert_record);
+ phpgwapi_cache::session_set('property',
'insert_record',$insert_record);
+
}
//
$GLOBALS['phpgw']->session->appsession('input_name','property',$input_name);
Modified: trunk/property/inc/class.socondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.socondition_survey.inc.php 2012-11-22 13:15:58 UTC
(rev 10529)
+++ trunk/property/inc/class.socondition_survey.inc.php 2012-11-22 14:24:07 UTC
(rev 10530)
@@ -178,6 +178,8 @@
function add($data)
{
+ throw new Exception('Test socondition_survey::add()');
+
$table = 'fm_condition_survey';
$custom['sql_text'] =
$this->_db->db_addslashes(htmlspecialchars_decode($custom['sql_text']));
Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2012-11-22 13:15:58 UTC
(rev 10529)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2012-11-22 14:24:07 UTC
(rev 10530)
@@ -34,6 +34,7 @@
{
private $bo;
+ private $receipt = array();
public $public_functions = array(
'query' => true,
'index' => true,
@@ -332,23 +333,40 @@
if ($id )
{
- $project = $this->so->get_single($id);
+ $values = $this->bo->read_single(array('id' =>
$id));
}
else
{
- $project = new logistic_project();
+ $values = array();
}
- $project->populate();
+ /*
+ * Overrides with incoming data from POST
+ */
+ $values = $this->_populate($values);
- if( $project->validate() )
+ if( !$this->receipt['error'] )
{
- $id = $this->so->store($project);
+ try
+ {
+ $id = $this->bo->save($values);
+ }
+
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+
phpgwapi_cache::message_set($e->getMessage(), 'error');
+ $this->edit( $values );
+ return;
+ }
+ }
+
$GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'property.uicondition_survey.view', 'id' => $id));
}
else
{
- $this->edit( $project );
+ $this->edit( $values );
}
}
@@ -365,6 +383,52 @@
return array('ResultSet'=> array('Result'=>$values));
}
+
+ /*
+ * Overrides with incoming data from POST
+ */
+ private function _populate($data = array())
+ {
+ $insert_record =
phpgwapi_cache::session_get('property', 'insert_record');
+ $values =
$this->bocommon->collect_locationdata($data,$insert_record);
+
+ /*
+ * Extra data from custom fields
+ */
+ $values['attributes'] =
phpgw::get_var('values_attribute');
+
+ if(is_array($values['attributes']))
+ {
+ foreach ($values['attributes'] as $attribute )
+ {
+ if($attribute['nullable'] != 1 &&
(!$attribute['value'] && !$values['extra'][$attribute['name']]))
+ {
+
$this->receipt['error'][]=array('msg'=>lang('Please enter value for attribute
%1', $attribute['input_text']));
+ }
+ }
+ }
+
+ if(!isset($values['cat_id']) || !$values['cat_id'])
+ {
+ $receipt['error'][]=array('msg'=>lang('Please
select a category !'));
+ }
+
+ if(isset($values['title']) || !$values['title'])
+ {
+ $receipt['error'][]=array('msg'=>lang('Please
give a title !'));
+ }
+
+ if(!isset($values['report_date']) ||
!$values['report_date'])
+ {
+ $receipt['error'][]=array('msg'=>lang('Please
select a date!'));
+ }
+
+
+ phpgwapi_cache::message_set('test-message', 'error');
+
+ return $values;
+ }
+
private function _get_categories($selected = 0)
{
$cats = CreateObject('phpgwapi.categories', -1,
'property', $this->acl_location);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10530] property: more on condition survey,
Sigurd Nes <=