[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10535] property: More on condition survey
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10535] property: More on condition survey |
Date: |
Sun, 25 Nov 2012 20:54:39 +0000 |
Revision: 10535
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10535
Author: sigurdne
Date: 2012-11-25 20:54:38 +0000 (Sun, 25 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.socondition_survey.inc.php
trunk/property/inc/class.uicondition_survey.inc.php
trunk/property/templates/base/condition_survey.xsl
Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php 2012-11-25 20:53:51 UTC (rev
10534)
+++ trunk/property/inc/class.bocommon.inc.php 2012-11-25 20:54:38 UTC (rev
10535)
@@ -3,7 +3,7 @@
* phpGroupWare - property: a Facilities Management System.
*
* @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
+ * @copyright Copyright (C)
2003,2004,2005,2006,2007,2008,2009,2010,2011,2012 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
@@ -2050,6 +2050,7 @@
if(isset($values['location']) &&
is_array($values['location']))
{
$values['location_name'] =
phpgw::get_var('loc' . (count($values['location'])).'_name', 'string', 'POST');
// if not address - get the parent name as address
+ $values['location_code'] = implode('-',
$values['location']);
}
return $values;
Modified: trunk/property/inc/class.bocondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.bocondition_survey.inc.php 2012-11-25 20:53:51 UTC
(rev 10534)
+++ trunk/property/inc/class.bocondition_survey.inc.php 2012-11-25 20:54:38 UTC
(rev 10535)
@@ -3,7 +3,7 @@
* phpGroupWare - property: a Facilities Management System.
*
* @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007,2008,2009 Free
Software Foundation, Inc. http://www.fsf.org/
+ * @copyright Copyright (C) 2012 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
@@ -50,6 +50,7 @@
$this->so =
CreateObject('property.socondition_survey');
$this->custom = & $this->so->custom;
$this->bocommon =
CreateObject('property.bocommon');
+ $this->dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$start =
phpgw::get_var('start', 'int', 'REQUEST', 0);
$query =
phpgw::get_var('query');
@@ -150,6 +151,9 @@
{
$values = $this->custom->prepare($values,
'property', $this->acl_location, $data['view']);
}
+
+ $values['report_date'] =
$GLOBALS['phpgw']->common->show_date($values['report_date'],$this->dateformat);
+
return $values;
}
Modified: trunk/property/inc/class.socondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.socondition_survey.inc.php 2012-11-25 20:53:51 UTC
(rev 10534)
+++ trunk/property/inc/class.socondition_survey.inc.php 2012-11-25 20:54:38 UTC
(rev 10535)
@@ -3,7 +3,7 @@
* phpGroupWare - property: a Facilities Management System.
*
* @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
+ * @copyright Copyright (C) 2012 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
@@ -27,6 +27,8 @@
* @version $Id$
*/
+ phpgw::import_class('phpgwapi.datetime');
+
/**
* Description
* @package property
@@ -64,10 +66,11 @@
public function __construct()
{
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->_db = & $GLOBALS['phpgw']->db;
- $this->_join = & $this->_db->join;
- $this->_like = & $this->_db->like;
+ $this->account =
(int)$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->_db = &
$GLOBALS['phpgw']->db;
+ $this->_join = & $this->_db->join;
+ $this->_like = & $this->_db->like;
+ $this->custom =
createObject('property.custom_fields');
}
/**
@@ -139,20 +142,23 @@
$this->_db->query($sql .
$ordermethod,__LINE__,__FILE__);
}
+ $values = array();
while ($this->_db->next_record())
{
- $customs[] = array
- (
- 'custom_id' =>
$this->_db->f('id'),
- 'name' =>
stripslashes($this->_db->f('name')),
- 'entry_date' =>
$this->_db->f('entry_date'),
- 'user' =>
$GLOBALS['phpgw']->accounts->id2name($this->_db->f('user_id'))
- );
+ $values[] = array
+ (
+ 'id' =>
$this->_db->f('id'),
+ 'title' =>
$this->_db->f('title',true),
+ 'descr' =>
$this->_db->f('descr',true),
+ 'entry_date' =>
$this->_db->f('entry_date'),
+ 'user' =>
$this->_db->f('user_id')
+ );
}
- return $customs;
+
+ return $values;
}
- function read_single($id)
+ function read_single($id, $data = array())
{
$table = 'fm_condition_survey';
@@ -164,12 +170,28 @@
{
$values = array
(
- 'id' =>
(int)$this->_db->f('id'),
- 'name' =>
$this->_db->f('name', true),
- 'sql_text' =>
$this->_db->f('sql_text', true),
- 'entry_date' =>
$this->_db->f('entry_date'),
+ 'id' => $id,
+ 'title' =>
$this->_db->f('title',true),
+ 'descr' =>
$this->_db->f('descr', true),
+ 'location_code' =>
$this->_db->f('location_code', true),
+ 'status_id' =>
(int)$this->_db->f('status_id'),
+ 'cat_id' =>
(int)$this->_db->f('category'),
+ 'vendor_id' =>
(int)$this->_db->f('vendor_id'),
+ 'coordinator' =>
(int)$this->_db->f('coordinator'),
+ 'report_date' =>
(int)$this->_db->f('report_date'),
+ 'user_id' =>
(int)$this->_db->f('user_id'),
+ 'entry_date' =>
(int)$this->_db->f('entry_date'),
+ 'modified_date' =>
(int)$this->_db->f('modified_date'),
+ );
- );
+ if ( isset($data['attributes']) &&
is_array($data['attributes']) )
+ {
+ $values['attributes'] =
$data['attributes'];
+ foreach ( $values['attributes'] as
&$attr )
+ {
+ $attr['value'] =
$this->db->f($attr['column_name']);
+ }
+ }
}
return $values;
@@ -178,10 +200,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']));
$this->_db->transaction_begin();
@@ -191,23 +211,117 @@
(
'id' => $id,
'title' =>
$this->_db->db_addslashes($data['title']),
- 'month' =>
$entry['month'],
- 'budget' =>
$entry['budget'],
- 'user_id' =>
$entry['user_id'],
- 'entry_date' => $entry['entry_date'],
- 'modified_date' =>
$entry['modified_date']
+ 'descr' =>
$this->_db->db_addslashes($data['descr']),
+ 'status_id' =>
(int)$data['status_id'],
+ 'category' =>
(int)$data['cat_id'],
+ 'vendor_id' =>
(int)$data['vendor_id'],
+ 'coordinator' => (int)$this->account,
+ 'report_date' =>
phpgwapi_datetime::date_to_timestamp($data['report_date']),
+ 'user_id' =>
$this->account,
+ 'entry_date' => time(),
+ 'modified_date' => time()
);
+
+
+ if(isset($data['location']) &&
is_array($data['location']))
+ {
+ foreach ($data['location'] as $input_name =>
$value)
+ {
+ if(isset($value) && $value)
+ {
+ $value_set[$input_name] =
$value;
+ }
+ }
+ $value_set['location_code'] = implode('-',
$data['location']);
+ }
+
+ if(isset($data['extra']) && is_array($data['extra']))
+ {
+ foreach ($data['extra'] as $input_name =>
$value)
+ {
+ if(isset($value) && $value)
+ {
+ $value_set[$input_name] =
$value;
+ }
+ }
+
+ if($data['extra']['p_num'] &&
$data['extra']['p_entity_id'] && $data['extra']['p_cat_id'])
+ {
+ $entity =
CreateObject('property.soadmin_entity');
+ $entity_category =
$entity->read_single_category($data['extra']['p_entity_id'],$data['extra']['p_cat_id']);
+ }
+ }
+
+ if(isset($values['attributes']) &&
is_array($values['attributes']))
+ {
+ $data_attribute =
$this->custom->prepare_for_db($table, $values['attributes']);
+ if(isset($data_attribute['value_set']))
+ {
+ foreach($data_attribute['value_set'] as
$input_name => $value)
+ {
+ if(isset($value) && $value)
+ {
+ $value_set[$input_name]
= $value;
+ }
+ }
+ }
+ }
+
+ $_address = array();
+ if(isset($data['street_name']) && $data['street_name'])
+ {
+ $_address[] = "{$data['street_name']}
{$data['street_number']}";
+ }
+
+ if(isset($data['location_name']) &&
$data['location_name'])
+ {
+ $_address[] = $data['location_name'];
+ }
+
+ if(isset($data['additional_info']) &&
$data['additional_info'])
+ {
+ foreach($data['additional_info'] as $key =>
$value)
+ {
+ if($value)
+ {
+ $_address[] = "{$key}|{$value}";
+ }
+ }
+ }
+
+ if(isset($entity_category) && $entity_category)
+ {
+ $_address[] =
"{$entity_category['name']}::{$data['extra']['p_num']}";
+ }
+
+ $address =
$this->_db->db_addslashes(implode('::', $_address));
+ // $value_set['address'] = $address;
+
+ unset($_address);
+
$cols = implode(',', array_keys($value_set));
$values =
$this->_db->validate_insert(array_values($value_set));
- $this->_db->query("INSERT INTO {$table} ({$cols})
VALUES ({$values})",__LINE__,__FILE__);
- $receipt['id']= $id;
+ try
+ {
+ $this->_db->Exception_On_Error = true;
+ $this->_db->query("INSERT INTO {$table}
({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+ $this->_db->Exception_On_Error = false;
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ throw $e;
+ }
+ }
+
if($this->_db->transaction_commit())
{
- $this->_receipt['message'][] =
array('msg'=>lang('survey %1 has been saved',$id));
return $id;
}
+
return 0;
}
Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2012-11-25 20:53:51 UTC
(rev 10534)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2012-11-25 20:54:38 UTC
(rev 10535)
@@ -134,22 +134,17 @@
'formatter' =>
'YAHOO.portico.formatLink'
),
array(
- 'key' => 'name',
- 'label' => lang('name'),
+ 'key' => 'title',
+ 'label' =>
lang('title'),
'sortable' => true
),
array(
- 'key' => 'description',
+ 'key' => 'descr',
'label' =>
lang('description'),
'sortable' => false,
'editor' => 'new
YAHOO.widget.TextboxCellEditor({disableBtns:true})'
),
array(
- 'key' =>
'survey_type_label',
- 'label' => lang('type'),
- 'sortable' => false
- ),
- array(
'key' => 'link',
'hidden' => true
)
@@ -175,7 +170,7 @@
'text' =>
lang('edit'),
'action' =>
$GLOBALS['phpgw']->link('/index.php',array
(
- 'menuaction' =>
'logistic.uiactivity.edit'
+ 'menuaction' =>
'property.uicondition_survey.edit'
)),
'parameters' =>
json_encode($parameters)
);
@@ -211,7 +206,7 @@
$export = phpgw::get_var('export');
$values = $this->bo->read($params);
-
+//_debug_array($values);
// ... add result data
$result_data = array('results' => $values);
@@ -248,6 +243,10 @@
public function edit($values = array(), $mode = 'edit')
{
+/*
+_debug_array($_POST);
+die();
+*/
$id = phpgw::get_var('id', 'int');
if(!$this->acl_add && !$this->acl_edit)
@@ -272,7 +271,6 @@
}
}
-//_debug_array($values);die();
phpgwapi_yui::tabview_setup('survey_edit_tabview');
$tabs = array();
$tabs['generic'] = array('label' =>
lang('generic'), 'link' => '#generic');
@@ -286,11 +284,15 @@
if ($id)
{
- $values = $this->so->read_single( array('id' =>
$id, 'view' => $mode == 'view') );
+ $values = $this->bo->read_single( array('id' =>
$id, 'view' => $mode == 'view') );
}
+ if(isset($values['location_code']) &&
$values['location_code'])
+ {
+ $values['location_data'] =
execMethod('property.solocation.read_single', $values['location_code']);
+ }
- $categories =
$this->_get_categories($survey['category']);
+ $categories = $this->_get_categories($values['cat_id']);
$bolocation = CreateObject('property.bolocation');
$location_data = $bolocation->initiate_ui_location(array
@@ -303,18 +305,18 @@
'lookup_entity' => array(),
'entity_data' =>
isset($values['p'])?$values['p']:''
));
+//_debug_array($values);die();
-
$data = array
(
'survey' => $values,
+ 'location_data' => $location_data,
'categories' => array('options' =>
$categories),
'status_list' => array('options' =>
execMethod('property.bogeneric.get_list',array('type' =>
'condition_survey_status', 'selected' => $values['status_id'], 'add_empty' =>
true))),
'editable' => $mode ==
'edit',
'tabs' =>
phpgwapi_yui::tabview_generate($tabs, $active_tab),
- 'location_data' => $location_data,
);
-
+//_debug_array($data);die();
$GLOBALS['phpgw']->jqcal->add_listener('report_date');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . '::' . lang('condition survey');
@@ -343,7 +345,8 @@
* Overrides with incoming data from POST
*/
$values = $this->_populate($values);
-
+
+//_debug_array($values);die();
if( !$this->receipt['error'] )
{
try
@@ -402,7 +405,7 @@
),
array
(
- 'name' => 'description',
+ 'name' => 'descr',
'type' => 'string',
'required' => true
),
@@ -437,12 +440,21 @@
'required' => false
),
);
+
-
foreach ($_fields as $_field)
{
- $data[$_field['name']] =
phpgw::get_var($_field['name'], 'POST', $_field['type']);
+ if($data[$_field['name']] =
$_POST['values'][$_field['name']])
+ {
+ $data[$_field['name']] =
phpgw::clean_value($data[$_field['name']], $_field['type']);
+ }
+ if($_field['required'] &&
!$data[$_field['name']])
+ {
+
$this->receipt['error'][]=array('msg'=>lang('Please enter value for attribute
%1', $_field['name']));
+ }
}
+//_debug_array($_POST);
+//_debug_array($data);
$values =
$this->bocommon->collect_locationdata($data,$insert_record);
@@ -477,9 +489,6 @@
$receipt['error'][]=array('msg'=>lang('Please
select a date!'));
}
-
- phpgwapi_cache::message_set('test-message', 'error');
-
return $values;
}
Modified: trunk/property/templates/base/condition_survey.xsl
===================================================================
--- trunk/property/templates/base/condition_survey.xsl 2012-11-25 20:53:51 UTC
(rev 10534)
+++ trunk/property/templates/base/condition_survey.xsl 2012-11-25 20:54:38 UTC
(rev 10535)
@@ -54,46 +54,25 @@
</tr>
</xsl:when>
</xsl:choose>
- <xsl:choose>
- <xsl:when test="value_id !=''">
- <tr>
- <td
class="th_text" valign="top">
- <a
href="{link_pdf}" target="_blank">PDF</a>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
</table>
- <table cellpadding="2" cellspacing="2"
width="80%" align="center">
- <tr>
- <td class="th_text">
- <xsl:value-of
select="lang_entity"/>
- </td>
- <td class="th_text">
- <xsl:value-of
select="entity_name"/>
- </td>
- </tr>
+ <xsl:value-of disable-output-escaping="yes"
select="tabs"/>
+ <div class="yui-content">
+ <div id="generic">
+ <table>
<xsl:choose>
- <xsl:when test="value_id!=''">
+ <xsl:when test="survey/id!=''">
<tr>
<td
valign="top">
-
<xsl:value-of select="lang_id"/>
+
<xsl:value-of select="php:function('lang', 'id')" />
</td>
<td>
-
<xsl:value-of select="value_num"/>
- <input
type="hidden" name="location_code" value="{location_code}"/>
- <input
type="hidden" name="lookup_tenant" value="{lookup_tenant}"/>
- <input
type="hidden" name="values[id]" value="{value_id}"/>
- <input
type="hidden" name="values[num]" value="{value_num}"/>
+
<xsl:value-of select="survey/id"/>
+ <input
type="hidden" name="values[id]" value="{survey/id}"/>
</td>
</tr>
</xsl:when>
</xsl:choose>
- </table>
- <xsl:value-of disable-output-escaping="yes"
select="tabs"/>
- <div class="yui-content">
- <div id="generic">
- <table>
+
<xsl:choose>
<xsl:when
test="location_data!=''">
<xsl:choose>
@@ -113,7 +92,7 @@
<td>
<xsl:choose>
<xsl:when
test="editable = 1">
- <input
id="title" name='title' type="text"
+ <input
id="title" name='values[title]' type="text" value="{survey/title}"
formvalidator:FormField="yes"
formvalidator:Type="TextBaseField">
</input>
@@ -126,20 +105,19 @@
</tr>
<tr>
<td>
-
- <label
for="name"><xsl:value-of select="php:function('lang', 'description')" /></label>
+ <label for="name"><xsl:value-of
select="php:function('lang', 'description')" /></label>
</td>
<td>
<xsl:choose>
<xsl:when
test="editable = 1">
- <textarea
id="description" name="values[description]" rows="5" cols="60"
+ <textarea
id="descr" name="values[descr]" rows="5" cols="60"
formvalidator:FormField="yes"
formvalidator:Type="TextBaseField">
-
<xsl:value-of select="project/description" disable-output-escaping="yes"/>
+
<xsl:value-of select="survey/descr" disable-output-escaping="yes"/>
</textarea>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of
select="project/description" disable-output-escaping="yes"/>
+ <xsl:value-of
select="survey/descr" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
</td>
@@ -170,10 +148,16 @@
<label
for="category"><xsl:value-of select="php:function('lang', 'date')" /></label>
</td>
<td>
- <input id="report_date"
name='values[report_date]' type="text"
-
formvalidator:FormField="yes"
-
formvalidator:type="TextBaseField"/>
-
+ <xsl:choose>
+ <xsl:when
test="editable = 1">
+ <input
id="report_date" name='values[report_date]' type="text"
value="{survey/report_date}"
+
formvalidator:FormField="yes"
+
formvalidator:type="TextBaseField"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="survey/report_date"/>
+ </xsl:otherwise>
+ </xsl:choose>
</td>
</tr>
<tr>
@@ -208,7 +192,7 @@
<xsl:when
test="editable = 1">
<div
class="autocomplete">
<input
type="hidden" id="vendor_id" name="values[vendor_id]"
value="{survey/vendor_id}"/>
- <input
type="text" id="vendor_name" name="vendor_name" value="{survey/vendor_name}">
+ <input
type="text" id="vendor_name" name="values[vendor_name]"
value="{survey/vendor_name}">
</input>
<div
id="vendor_container"/>
</div>
@@ -344,18 +328,19 @@
</td>
<td>
<div class="form-buttons">
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')"
/></xsl:variable>
<xsl:choose>
<xsl:when
test="editable = 1">
<xsl:variable name="lang_save"><xsl:value-of select="php:function('lang',
'save')" /></xsl:variable>
-
<xsl:variable name="lang_cancel"><xsl:value-of select="php:function('lang',
'cancel')" /></xsl:variable>
<input
type="submit" name="save_project" value="{$lang_save}" title = "{$lang_save}" />
- <input
class="submit" type="button" name="cancelButton" id ='cancelButton'
value="{$lang_cancel}" title = "{$lang_cancel}"
onClick="document.cancel_form.submit();"/>
+ <input
class="button" type="button" name="cancelButton" id ='cancelButton'
value="{$lang_cancel}" title = "{$lang_cancel}"
onClick="document.cancel_form.submit();"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="lang_edit"><xsl:value-of select="php:function('lang',
'edit')" /></xsl:variable>
-
<xsl:variable name="lang_new_activity"><xsl:value-of
select="php:function('lang', 't_new_activity')" /></xsl:variable>
- <input
type="submit" name="edit_project" value="{$lang_edit}" title = "{$lang_edit}" />
- <input
type="submit" name="new_activity" value="{$lang_new_activity}" title =
"{$lang_new_activity}" />
+
<xsl:variable name="lang_new_survey"><xsl:value-of select="php:function('lang',
'new survey')" /></xsl:variable>
+ <input
type="button" name="edit_survey" value="{$lang_edit}" title = "{$lang_edit}"
onClick="document.load_edit_form.submit();"/>
+ <input
type="button" name="new_survey" value="{$lang_new_survey}" title =
"{$lang_new_survey}" onClick="document.new_form.submit();"/>
+ <input
class="button" type="button" name="cancelButton" id ='cancelButton'
value="{$lang_cancel}" title = "{$lang_cancel}"
onClick="document.cancel_form.submit();"/>
</xsl:otherwise>
</xsl:choose>
</div>
@@ -380,14 +365,29 @@
<form name="cancel_form" id="cancel_form"
action="{$cancel_url}" method="post">
</form>
+ <xsl:variable name="new_url">
+ <xsl:value-of select="php:function('get_phpgw_link',
'/index.php', 'menuaction:property.uicondition_survey.add')" />
+ </xsl:variable>
+ <form name="new_form" id="new_form" action="{$new_url}"
method="post">
+ </form>
+ <xsl:variable name="edit_params">
+ <xsl:text>menuaction:property.uicondition_survey.edit,
id:</xsl:text>
+ <xsl:value-of select="survey/id" />
+ </xsl:variable>
+ <xsl:variable name="edit_url">
+ <xsl:value-of
select="php:function('get_phpgw_link', '/index.php', $edit_params )" />
+ </xsl:variable>
+ <form name="load_edit_form" id="load_edit_form"
action="{$edit_url}" method="post">
+ </form>
+
</xsl:template>
<xsl:template match="options">
<option value="{id}">
- <xsl:if test="selected = 'selected'">
+ <xsl:if test="selected = 'selected' or selected = 1">
<xsl:attribute name="selected" value="selected" />
</xsl:if>
<xsl:attribute name="title" value="description" />
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10535] property: More on condition survey,
Sigurd Nes <=