[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11344] property: add status to lookup
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11344] property: add status to lookup |
Date: |
Mon, 30 Sep 2013 13:42:33 +0000 |
Revision: 11344
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11344
Author: sigurdne
Date: 2013-09-30 13:42:32 +0000 (Mon, 30 Sep 2013)
Log Message:
-----------
property: add status to lookup
Modified Paths:
--------------
trunk/property/inc/class.bogeneric.inc.php
trunk/property/inc/class.bolookup.inc.php
trunk/property/inc/class.historylog.inc.php
trunk/property/inc/class.solookup.inc.php
trunk/property/inc/class.uientity.inc.php
trunk/property/inc/class.uigeneric.inc.php
trunk/property/inc/class.uilookup.inc.php
trunk/property/templates/base/attributes_form.xsl
Modified: trunk/property/inc/class.bogeneric.inc.php
===================================================================
--- trunk/property/inc/class.bogeneric.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.bogeneric.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -249,4 +249,57 @@
{
return $this->so->get_children2($id, $level, $reset);
}
+
+ public function read_attrib_history($data)
+ {
+ $attrib_data = $this->custom->get($data['app'],
$data['acl_location'], $data['attrib_id'], $inc_choices = true);
+ $history_type =
$this->get_history_type_for_location($data['acl_location']);
+ $historylog =
CreateObject('property.historylog',$history_type);
+ $history_values =
$historylog->return_array(array(),array('SO'),'history_timestamp','DESC',$data['id'],$data['attrib_id'],
$data['detail_id']);
+
+ if($attrib_data['column_info']['type'] == 'LB')
+ {
+ foreach($history_values as &$value_set)
+ {
+ foreach ($attrib_data['choice'] as
$choice)
+ {
+ if ($choice['id'] ==
$value_set['new_value'])
+ {
+
$value_set['new_value'] = $choice['value'];
+ }
+ }
+ }
+ }
+
+
+ if($attrib_data['column_info']['type'] == 'D')
+ {
+ foreach($history_values as &$value_set)
+ {
+ $value_set['new_value'] =
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
strtotime( $value_set['new_value']));
+ }
+ }
+
+ reset($history_values);
+ $this->total_records = count($history_values);
+ return $history_values;
+ }
+
+ function get_history_type_for_location($acl_location)
+ {
+ switch($acl_location)
+ {
+ case '.vendor':
+ $history_type ='vendor';
+ break;
+ default:
+ $history_type =
str_replace('.','_',substr($acl_location,-strlen($acl_location)+1));
+ }
+ if(!$history_type)
+ {
+ throw new Exception(lang('Unknown history type
for acl_location: %1', $acl_location));
+ }
+ return $history_type;
+ }
+
}
Modified: trunk/property/inc/class.bolookup.inc.php
===================================================================
--- trunk/property/inc/class.bolookup.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.bolookup.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -268,13 +268,38 @@
return $persons;
}
- function read_vendor()
+ function read_vendor($filter = array())
{
- $vendor = $this->so->read_vendor(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
- 'filter' => $this->filter,'cat_id' =>
$this->cat_id, 'allrows' => $this->allrows));
- $this->total_records = $this->so->total_records;
+ $sogeneric = CreateObject('property.sogeneric');
- return $vendor;
+ $location_info =
$sogeneric->get_location_info('vendor');
+
+
+ if (! $filter )
+ {
+ foreach ( $location_info['fields'] as $field )
+ {
+ if (isset($field['filter']) &&
$field['filter'])
+ {
+ if($field['name'] == 'category')
+ {
+ $field_name = 'cat_id';
+ }
+ else
+ {
+ $field_name =
$field['name'];
+ }
+ $filter[$field['name']] =
phpgw::get_var($field_name);
+ }
+ }
+ }
+
+ $values = $sogeneric->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+ 'allrows'=>$this->allrows),$filter);
+
+ $this->total_records = $sogeneric->total_records;
+
+ return $values;
}
function read_b_account($data)
Modified: trunk/property/inc/class.historylog.inc.php
===================================================================
--- trunk/property/inc/class.historylog.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.historylog.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -102,6 +102,8 @@
case 'tenant_claim':
$this->table='fm_tenant_claim_history';
break;
+ default:
+ throw new Exception(lang('Unknown
history register for acl_location: %1', $selector));
}
Modified: trunk/property/inc/class.solookup.inc.php
===================================================================
--- trunk/property/inc/class.solookup.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.solookup.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -110,72 +110,7 @@
return $contact;
}
- function read_vendor($data)
- {
- if(is_array($data))
- {
- $start = isset($data['start']) &&
$data['start'] ? $data['start'] : 0;
- $filter =
isset($data['filter'])?$data['filter']:'none';
- $query =
isset($data['query'])?$data['query']:'';
- $sort = isset($data['sort']) &&
$data['sort'] ? $data['sort']:'ASC';
- $order =
isset($data['order'])?$data['order']:'';
- $cat_id =
isset($data['cat_id'])?$data['cat_id']:0;
- $allrows =
isset($data['allrows'])?$data['allrows']:'';
- }
- if ($order)
- {
- $ordermethod = " ORDER BY $order $sort";
- }
- else
- {
- $ordermethod = ' ORDER BY org_name ASC';
- }
-
-
- $where= 'WHERE';
-
- if ($cat_id > 0)
- {
- $filtermethod .= " $where member_of $this->like
'%,$cat_id,%' ";
- $where= 'AND';
- }
-
- if($query)
- {
- $query = $this->db->db_addslashes($query);
-
- $querymethod = " $where (id = ". (int)$query .
"OR org_name $this->like '%$query%')";
- }
-
- $sql = "SELECT id,org_name FROM fm_vendor $filtermethod
$querymethod";
-
- $this->db->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- $vendor = array();
- while ($this->db->next_record())
- {
- $vendor[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'org_name' =>
$this->db->f('org_name',true),
- );
- }
- //_debug_array($vendor);
-
- return $vendor;
- }
-
-
function read_b_account($data)
{
$start = isset($data['start']) &&
$data['start'] ? (int)$data['start'] : 0;
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.uientity.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -2602,7 +2602,7 @@
{
$link_delete_history_data = array
(
- 'menuaction' =>
'property.uientity.attrib_history',
+ 'menuaction' =>
'property.uigeneric.attrib_history',
'acl_location' =>
$acl_location,
'id' =>
$data_lookup['id'],
'attrib_id' =>
$data_lookup['attrib_id'],
Modified: trunk/property/inc/class.uigeneric.inc.php
===================================================================
--- trunk/property/inc/class.uigeneric.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.uigeneric.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -47,11 +47,12 @@
var $public_functions = array
(
- 'index' => true,
- 'edit' => true,
- 'delete' => true,
- 'download' => true,
- 'columns' => true,
+ 'index' => true,
+ 'edit' => true,
+ 'delete' => true,
+ 'download' => true,
+ 'columns' => true,
+ 'attrib_history' => true
);
function __construct()
@@ -781,6 +782,7 @@
'attrib_id'
=> $attribute['id'],
'actor_id'
=> $actor_id,
'role'
=> $this->role,
+ 'acl_location'
=> $this->acl_location,
'edit'
=> true
);
@@ -899,6 +901,242 @@
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
}
+ function attrib_history()
+ {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('attrib_history','nextmatchs'));
+ $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+ $acl_location = phpgw::get_var('acl_location',
'string');
+ $id = phpgw::get_var('id',
'int');
+ $attrib_id = phpgw::get_var('attrib_id',
'int');
+ $detail_id = phpgw::get_var('detail_id',
'int');
+
+ $data_lookup= array
+ (
+ 'app' => 'property',
+ 'acl_location' => $acl_location,
+ 'id' => $id,
+ 'attrib_id' => $attrib_id,
+ 'detail_id' => $detail_id,
+ );
+
+ $delete = phpgw::get_var('delete', 'bool');
+ $edit = phpgw::get_var('edit', 'bool');
+
+ if ($delete)
+ {
+ $data_lookup['history_id'] =
phpgw::get_var('history_id', 'int');
+ // $this->bo->delete_history_item($data_lookup);
+ }
+
+ $values = $this->bo->read_attrib_history($data_lookup);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ while (is_array($values) && list(,$entry) =
each($values))
+ {
+ $link_delete_history_data = array
+ (
+ 'menuaction' =>
'property.uientity.attrib_history',
+ 'acl_location' =>
$acl_location,
+ 'id' =>
$data_lookup['id'],
+ 'attrib_id' =>
$data_lookup['attrib_id'],
+ 'detail_id' =>
$data_lookup['detail_id'],
+ 'history_id' => $entry['id'],
+ 'delete' => true,
+ 'edit' => true,
+ 'type' =>
$this->type
+ );
+ if($edit)
+ {
+ $text_delete = lang('delete');
+ $link_delete =
$GLOBALS['phpgw']->link('/index.php',$link_delete_history_data);
+ }
+
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'value'
=> $entry['new_value'],
+ 'user'
=> $entry['owner'],
+ 'time_created'
=> $GLOBALS['phpgw']->common->show_date($entry['datetime'],$dateformat),
+ 'link_delete'
=> $link_delete,
+ 'lang_delete_statustext'
=> lang('delete the item'),
+ 'text_delete'
=> $text_delete,
+ );
+ }
+
+
+ $table_header = array
+ (
+ 'lang_value' =>
lang('value'),
+ 'lang_user' =>
lang('user'),
+ 'lang_time_created' => lang('time
created'),
+ 'lang_delete' =>
lang('delete')
+ );
+
+ $link_data = array
+ (
+ 'menuaction' =>
'property.uientity.attrib_history',
+ 'acl_location' => $acl_location,
+ 'id' => $id,
+ 'detail_id' =>
$data_lookup['detail_id'],
+ 'edit' => $edit,
+ 'type' => $this->type
+ );
+
+
+ //--- asynchronous response
--------------------------------------------
+
+ if( phpgw::get_var('phpgw_return_as') == 'json')
+ {
+ if(count($content))
+ {
+ return json_encode($content);
+ }
+ else
+ {
+ return "";
+ }
+ }
+ //---datatable
settings---------------------------------------------------
+ $parameters['delete'] = array
+ (
+ 'parameter' => array
+ (
+ array
+ (
+ 'name' =>
'acl_location',
+ 'source' =>
$data_lookup['acl_location'],
+ 'ready' => 1
+ ),
+ array
+ (
+ 'name' => 'id',
+ 'source' =>
$data_lookup['id'],
+ 'ready' => 1
+ ),
+ array
+ (
+ 'name' => 'attrib_id',
+ 'source' =>
$data_lookup['attrib_id'],
+ 'ready' => 1
+ ),
+ array
+ (
+ 'name' => 'detail_id',
+ 'source' =>
$data_lookup['detail_id'],
+ 'ready' => 1
+ ),
+ array
+ (
+ 'name' => 'history_id',
+ 'source' => 'id',
+ ),
+ array
+ (
+ 'name' => 'delete',
+ 'source' => true,
+ 'ready' => 1
+ ),
+ array
+ (
+ 'name' => 'edit',
+ 'source' => true,
+ 'ready' => 1
+ ),
+ array
+ (
+ 'name' => 'type',
+ 'source' => $this->type,
+ 'ready' => 1
+ )
+ )
+ );
+
+ if($edit && $this->acl->check($acl_location,
PHPGW_ACL_DELETE, $this->type_app[$this->type]))
+ {
+ $permissions['rowactions'][] = array
+ (
+ 'text' =>
lang('delete'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'property.uigeneric.attrib_history' )),
+ 'confirm_msg'=> lang('do you
really want to delete this entry'),
+ 'parameters'=>
$parameters['delete']
+ );
+ }
+
+ $datavalues[0] = array
+ (
+ 'name' => "0",
+ 'values' =>
json_encode($content),
+ 'total_records' => count($content),
+ 'permission' =>
json_encode($permissions['rowactions']),
+ 'is_paginator' => 1,
+ 'footer' => 0
+ );
+
+ $myColumnDefs[0] = array
+ (
+ 'name' => "0",
+ 'values' =>
json_encode(array( array('key' => 'id', 'hidden'=>true),
+
array('key' => 'value',
'label'=>lang('value'), 'sortable'=>true,'resizeable'=>true),
+
array('key' => 'time_created', 'label'=>lang('time
created'),'sortable'=>true,'resizeable'=>true),
+
array('key' => 'user',
'label'=>lang('user'), 'sortable'=>true,'resizeable'=>true)
+ ))
+ );
+
+
//----------------------------------------------datatable settings--------
+ $property_js = "/property/js/yahoo/property2.js";
+
+ if
(!isset($GLOBALS['phpgw_info']['server']['no_jscombine']) ||
!$GLOBALS['phpgw_info']['server']['no_jscombine'])
+ {
+ $cachedir =
urlencode($GLOBALS['phpgw_info']['server']['temp_dir']);
+ $property_js =
"/phpgwapi/inc/combine.php?cachedir={$cachedir}&type=javascript&files=" .
str_replace('/', '--', ltrim($property_js,'/'));
+ }
+
+ $data = array
+ (
+ 'property_js' =>
json_encode($GLOBALS['phpgw_info']['server']['webserver_url'] . $property_js),
+ 'base_java_url' =>
json_encode(array(menuaction => "property.uigeneric.attrib_history")),
+ 'datatable' => $datavalues,
+ 'myColumnDefs' => $myColumnDefs,
+ 'allow_allrows' => false,
+ 'start_record' => $this->start,
+ 'record_limit' =>
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
+ 'num_records' => count($values),
+ 'all_records' =>
$this->bo->total_records,
+ 'link_url' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path' =>
$GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'values' => $content,
+ 'table_header' => $table_header,
+ );
+ //---datatable settings--------------------
+ phpgwapi_yui::load_widget('dragdrop');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('menu');
+ phpgwapi_yui::load_widget('connection');
+ phpgwapi_yui::load_widget('loader');
+ phpgwapi_yui::load_widget('tabview');
+ phpgwapi_yui::load_widget('paginator');
+ phpgwapi_yui::load_widget('animation');
+
+ $GLOBALS['phpgw']->css->validate_file('datatable');
+ $GLOBALS['phpgw']->css->validate_file('property');
+
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+ $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'entity.attrib_history', 'property' );
+ //-----------------------datatable settings---
+
+ //_debug_array($data);die();
+ $custom =
createObject('phpgwapi.custom_fields');
+ $attrib_data = $custom->get('property',
$acl_location, $attrib_id);
+ $appname = $attrib_data['input_text'];
+ $function_msg = lang('history');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('attrib_history' => $data));
+ }
+
function delete()
{
if(!$this->acl_delete)
Modified: trunk/property/inc/class.uilookup.inc.php
===================================================================
--- trunk/property/inc/class.uilookup.inc.php 2013-09-30 07:13:29 UTC (rev
11343)
+++ trunk/property/inc/class.uilookup.inc.php 2013-09-30 13:42:32 UTC (rev
11344)
@@ -757,7 +757,7 @@
array
( //boton
CATEGORY
'id' =>
'btn_cat_id',
- 'name'
=> 'cat_id',
+ 'name'
=> 'category',
'value'
=> lang('Category'),
'type'
=> 'button',
'style'
=> 'filter',
@@ -796,10 +796,10 @@
}
$uicols = array (
- 'input_type' => array('text','text'),
- 'name' =>
array('id','org_name'),
- 'formatter' => array('',''),
- 'descr' =>
array(lang('ID'),lang('Name'))
+ 'input_type' =>
array('text','text','text'),
+ 'name' =>
array('id','org_name','status'),
+ 'formatter' => array('','',''),
+ 'descr' =>
array(lang('ID'),lang('Name'), lang('status'))
);
$vendor_list = array();
Modified: trunk/property/templates/base/attributes_form.xsl
===================================================================
--- trunk/property/templates/base/attributes_form.xsl 2013-09-30 07:13:29 UTC
(rev 11343)
+++ trunk/property/templates/base/attributes_form.xsl 2013-09-30 13:42:32 UTC
(rev 11344)
@@ -637,10 +637,10 @@
<xsl:value-of select="//lang_history_help"/>
</xsl:variable>
<xsl:variable
name="lang_history">
-
<xsl:value-of select="//lang_history"/>
+
<xsl:value-of select="php:function('lang', 'history')" />
</xsl:variable>
- <a
href="javascript:var
w=window.open('{$link_history}','','left=50,top=100,width=550,height=400,scrollbars')"
title="{$lang_history_help}">
-
<xsl:value-of select="//lang_history"/>
+ <a
href="javascript:var
w=window.open('{$link_history}','','left=50,top=100,width=550,height=400,scrollbars')"
title="{$lang_history}">
+
<xsl:value-of select="$lang_history"/>
</a>
</xsl:when>
</xsl:choose>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11344] property: add status to lookup,
Sigurd Nes <=