[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [6934] property: documents for entities
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [6934] property: documents for entities |
Date: |
Sun, 06 Feb 2011 13:30:27 +0000 |
Revision: 6934
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6934
Author: sigurdne
Date: 2011-02-06 13:30:26 +0000 (Sun, 06 Feb 2011)
Log Message:
-----------
property: documents for entities
Modified Paths:
--------------
trunk/property/inc/class.bodocument.inc.php
trunk/property/inc/class.sodocument.inc.php
trunk/property/inc/class.soentity.inc.php
trunk/property/inc/class.uidocument.inc.php
trunk/property/inc/class.uientity.inc.php
trunk/property/inc/class.uilocation.inc.php
trunk/property/js/yahoo/entity.edit.js
trunk/property/templates/base/entity.xsl
Modified: trunk/property/inc/class.bodocument.inc.php
===================================================================
--- trunk/property/inc/class.bodocument.inc.php 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/inc/class.bodocument.inc.php 2011-02-06 13:30:26 UTC (rev
6934)
@@ -179,9 +179,9 @@
return $documents;
}
- function get_files_at_location($location_code)
+ function get_files_at_location($data)
{
- return $this->so->get_files_at_location($location_code);
+ return $this->so->get_files_at_location($data);
}
Modified: trunk/property/inc/class.sodocument.inc.php
===================================================================
--- trunk/property/inc/class.sodocument.inc.php 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/inc/class.sodocument.inc.php 2011-02-06 13:30:26 UTC (rev
6934)
@@ -646,10 +646,37 @@
* @return array parent and children
*/
- function get_files_at_location($location_code)
+ function get_files_at_location($data)
{
+ $location_code = isset($data['location_code']) ?
$data['location_code'] : '';
+ $entity_id = (int)$data['entity_id'];
+ $cat_id = (int)$data['cat_id'];
+ $num = $data['num'];
+
+ if( !$location_code )
+ {
+ if( !$entity_id || !$cat_id || !$num)
+ {
+ throw new
Exception("property_soentity::read_entity_to_link - Missing entity information
info in input");
+ }
+ }
+ else if( !$entity_id || !$cat_id || !$num)
+ {
+ if( !$location_code)
+ {
+ throw new
Exception("property_soentity::read_entity_to_link - Missing entity information
info in input");
+ }
+ }
+
$documents = array();
- $sql = "SELECT count(*) as hits FROM fm_document WHERE
location_code $this->like '$location_code%'";
+ if($location_code)
+ {
+ $sql = "SELECT count(*) as hits FROM
fm_document WHERE location_code {$this->like} '$location_code%' AND p_num IS
NULL";
+ }
+ else
+ {
+ $sql = "SELECT count(*) as hits FROM
fm_document WHERE p_entity_id = {$entity_id} AND p_cat_id = {$cat_id} AND p_num
= '{$num}'";
+ }
$this->db->query($sql,__LINE__,__FILE__);
if($this->db->next_record())
{
@@ -660,7 +687,10 @@
$cache_x_at_y[$y] = $x;
$documents[$x] = array
(
- 'link' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'property.uidocument.list_doc','location_code'=> $location_code)),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'property.uidocument.list_doc','location_code'=> $location_code,
+
'entity_id' => $entity_id,
+
'cat_id' => $cat_id,
+
'p_num' => $num)),
'text' =>
lang('documents') . ' [' . $hits . ']:',
'descr' =>
lang('Documentation'),
'level' => 0
@@ -668,16 +698,27 @@
}
else
{
- return $documents;
+// return $documents;
}
$categories = $this->cats->return_sorted_array(0,
false);
+ $location_filter = 'WHERE 1=1';
+
+ if($location_code)
+ {
+ $location_filter = "WHERE location_code
{$this->like} '{$location_code}%' AND p_num IS NULL";
+ }
+ else
+ {
+ $location_filter = "WHERE p_entity_id =
{$entity_id} AND p_cat_id = {$cat_id} AND p_num = '{$num}'";
+ }
+
foreach ($categories as $category)
{
$doc_types =
$this->get_sub_doc_types($category['id']);
- $sql = "SELECT count(*) as hits FROM
fm_document WHERE location_code $this->like '$location_code%' AND category IN
(". implode(',', $doc_types) . ')';
+ $sql = "SELECT count(*) as hits FROM
fm_document {$location_filter} AND category IN (". implode(',', $doc_types) .
')';
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$hits = (int) $this->db->f('hits');
@@ -707,15 +748,61 @@
$map .= '[]';
eval($map . ' =array('
- . "'link' => '" .
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'property.uidocument.list_doc','location_code'=> $location_code, 'doc_type'=>
$category['id'])) . "',\n"
+ . "'link' => '" .
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'property.uidocument.list_doc',
+
'location_code' => $location_code,
+
'doc_type' => $category['id'],
+
'entity_id' => $entity_id,
+
'cat_id' => $cat_id,
+
'p_num' => $num)) . "',\n"
. "'text' => '" .
$category['name'] . ' [' . $hits . ']' . "',\n"
. "'descr' => '" .
lang('Documentation') . "',\n"
. "'level' => " .
($category['level']+1) . "\n"
. ');');
$cache_x_at_y[$y] = $x;
+
+//--add node
+
+ if(count($doc_types) == 1) // node
+ {
+ $level = $level+1;
+ if($level == $y)
+ {
+ $x++;
+ }
+ else if($level < $y )
+ {
+ $x = $cache_x_at_y[$level]+1;
+ }
+ else if($level > $y )
+ {
+ $x = 0;
+ }
+ $y = $level;
+
+ $map = '$documents';
+ for ($i = 0; $i < $level ; $i++)
+ {
+ $map .= '[' . $cache_x_at_y[$i]
."]['children']";
+ }
+
+ $map .= '[]';
+
+ eval($map . ' =array('
+ . "'link' => '" .
$GLOBALS['phpgw']->link('/index.php',array('menuaction' =>
'property.uidocument.edit',
+
'location_code' => $location_code,
+
'doc_type' => $category['id'],
+
'p_entity_id' => $entity_id,
+
'p_cat_id' => $cat_id,
+
'p_num' => $num)) . "',\n"
+ . "'text'
=> '" . lang('add') . "',\n"
+ . "'descr'
=> '" . lang('Add Document') . "',\n"
+ . "'level'
=> " . $y . "\n"
+ . ');');
+
+ $cache_x_at_y[$y] = $x;
+ }
}
-
return $documents;
}
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/inc/class.soentity.inc.php 2011-02-06 13:30:26 UTC (rev
6934)
@@ -567,12 +567,22 @@
function read_single($data,$values = array())
{
- $entity_id =$data['entity_id'];
- $cat_id =$data['cat_id'];
- $id =$data['id'];
+ $entity_id = (int)$data['entity_id'];
+ $cat_id = (int)$data['cat_id'];
+ $id = (int)$data['id'];
+ $num = isset($data['num']) && $data['num'] ?
$data['num'] : '';
$table = "fm_{$this->type}_{$entity_id}_{$cat_id}";
- $this->db->query("SELECT * FROM $table WHERE id =$id");
+ if($num)
+ {
+ $filtermethod = "WHERE num = '{$num}'";
+ }
+ else
+ {
+ $filtermethod = "WHERE id = {$id}";
+ }
+
+ $this->db->query("SELECT * FROM {$table}
{$filtermethod}");
if($this->db->next_record())
{
Modified: trunk/property/inc/class.uidocument.inc.php
===================================================================
--- trunk/property/inc/class.uidocument.inc.php 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/inc/class.uidocument.inc.php 2011-02-06 13:30:26 UTC (rev
6934)
@@ -534,9 +534,6 @@
$p_num = phpgw::get_var('p_num');
- $location =
$this->bo->read_location_data($location_code);
- //_debug_array($location);
-
if($this->cat_id)
{
$entity_data[$this->entity_id]['p_num']=$p_num;
@@ -546,9 +543,15 @@
$category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
$lookup_entity =
$this->bocommon->get_lookup_entity('document');
$appname_sub = $entity['name'];
+ $_values =
execMethod('property.soentity.read_single',array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,
'num' => $p_num));
+
+ $location =
$this->bo->read_location_data($_values['location_code']);
+ $location_code = $_values['location_code'];
+ unset($_values);
}
else
{
+ $location =
$this->bo->read_location_data($location_code);
$appname_sub = lang('location');
}
@@ -1096,6 +1099,15 @@
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
}
+ if(phpgw::get_var('p_num'))
+ {
+ $_values =
execMethod('property.soentity.read_single',array('entity_id'=>$p_entity_id,'cat_id'=>$p_cat_id,
'num' => phpgw::get_var('p_num')));
+
+ $location =
$this->bo->read_location_data($_values['location_code']);
+ $location_code =
$_values['location_code'];
+ unset($_values);
+ }
+
if($location_code)
{
$values['location_data'] =
$this->bolocation->read_single($location_code,array('view' => true));
@@ -1394,12 +1406,12 @@
'lang_no_cat'
=> lang('Select category'),
'lang_cat_statustext'
=> lang('Select the category the document belongs to. To do not use a category
select NO CATEGORY'),
'value_cat_id'
=> $values['doc_type'],
- 'cat_select'
=> $this->cats->formatted_xslt_list(array('select_name' =>
'values[doc_type]','selected' => $values['doc_type'])),
+ 'cat_select'
=> $this->cats->formatted_xslt_list(array('select_name' =>
'values[doc_type]','selected' =>
$values['doc_type']?$values['doc_type']:$this->doc_type)),
'lang_coordinator'
=> lang('Coordinator'),
'lang_user_statustext'
=> lang('Select the coordinator the document belongs to. To do not use a
category select NO USER'),
'select_user_name'
=> 'values[coordinator]',
'lang_no_user'
=> lang('Select coordinator'),
- 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator'],$this->acl_location),
+ 'user_list'
=>
$this->bocommon->get_user_list_right2('select',4,$values['coordinator']?$values['coordinator']:$this->account,$this->acl_location),
'status_list'
=> $this->bo->select_status_list('select',$values['status']),
'status_name'
=> 'values[status]',
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/inc/class.uientity.inc.php 2011-02-06 13:30:26 UTC (rev
6934)
@@ -1750,6 +1750,16 @@
*/
if ($id)
{
+
+ $document = CreateObject('property.sodocument');
+ $documents =
$document->get_files_at_location(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'num'=>$values['num']));
+
+ if($documents)
+ {
+ $tabs['document'] = array('label'
=> lang('document'), 'link' => '#document');
+ $documents = json_encode($documents);
+ }
+
$related =
$this->bo->read_entity_to_link(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$values['num']));
$related_link = array();
@@ -1842,10 +1852,11 @@
'integration'
=> $integration,
'value_integration_src'
=> $integration_src,
'base_java_url'
=> "{menuaction:'property.uientity.get_files',".
- "id:'{$id}',".
- "entity_id:'{$this->entity_id}',".
- "cat_id:'{$this->cat_id}',".
- "type:'{$this->type}'}"
+
"id:'{$id}',".
+
"entity_id:'{$this->entity_id}',".
+
"cat_id:'{$this->cat_id}',".
+
"type:'{$this->type}'}",
+ 'documents'
=> $documents
);
phpgwapi_yui::load_widget('dragdrop');
@@ -1857,6 +1868,8 @@
phpgwapi_yui::load_widget('paginator');
phpgwapi_yui::load_widget('animation');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/examples/treeview/assets/css/folders/tree.css');
+ phpgwapi_yui::load_widget('treeview');
$appname = $entity['name'];
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->type_app[$this->type]) . ' - ' . $appname . ': ' . $function_msg;
Modified: trunk/property/inc/class.uilocation.inc.php
===================================================================
--- trunk/property/inc/class.uilocation.inc.php 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/inc/class.uilocation.inc.php 2011-02-06 13:30:26 UTC (rev
6934)
@@ -2094,7 +2094,7 @@
$related_link = array();
$document = CreateObject('property.sodocument');
- $documents =
$document->get_files_at_location($location_code);
+ $documents = $document->get_files_at_location(
array('location_code' => $location_code) );
if($documents)
{
@@ -2161,6 +2161,7 @@
'lang_entity_statustext' => $entry['descr'],
'text_entity' => $entry['name'],
);
+
}
}
}
Modified: trunk/property/js/yahoo/entity.edit.js
===================================================================
--- trunk/property/js/yahoo/entity.edit.js 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/js/yahoo/entity.edit.js 2011-02-06 13:30:26 UTC (rev
6934)
@@ -65,3 +65,63 @@
YAHOO.util.Dom.setStyle('lightbox-placeholder', 'display',
'block');
});
+(function() {
+ var tree;
+
+ function treeInit()
+ {
+ buildTextNodeTree();
+
+ //handler for expanding all nodes
+ YAHOO.util.Event.on("expand", "click", function(e) {
+ tree.expandAll();
+ YAHOO.util.Event.preventDefault(e);
+ });
+
+ //handler for collapsing all nodes
+ YAHOO.util.Event.on("collapse", "click", function(e) {
+ tree.collapseAll();
+ YAHOO.util.Event.preventDefault(e);
+ });
+
+ tree.subscribe('clickEvent',function(oArgs) {
+ window.open(oArgs.node.href,oArgs.node.target);
+ });
+ }
+
+ function buildTextNodeTree()
+ {
+ //instantiate the tree:
+ tree = new YAHOO.widget.TreeView("treeDiv1");
+ for (var i = 0; i < documents.length; i++)
+ {
+ var root = tree.getRoot();
+ var myobj = { label: documents[i]['text'],
href:documents[i]['link'],target:"_blank" };
+ var tmpNode = new YAHOO.widget.TextNode(myobj, root);
+
+ if(documents[i]['children'].length)
+ {
+ buildBranch(tmpNode, documents[i]['children']);
+ }
+ }
+
+ tree.draw();
+ }
+
+ function buildBranch(node, parent)
+ {
+ for (var i = 0; i < parent.length; i++)
+ {
+ var tmpNode = new
YAHOO.widget.TextNode({label:parent[i]['text'], href:parent[i]['link']}, node,
false);
+ if(parent[i]['children'])
+ {
+ buildBranch(tmpNode, parent[i]['children']);
+ }
+ }
+ }
+
+ //When the DOM is done loading, initialize TreeView instance:
+ YAHOO.util.Event.onDOMReady(treeInit);
+
+})();
+
Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl 2011-02-05 15:31:02 UTC (rev
6933)
+++ trunk/property/templates/base/entity.xsl 2011-02-06 13:30:26 UTC (rev
6934)
@@ -261,6 +261,30 @@
</xsl:choose>
<xsl:choose>
+ <xsl:when test="documents !=
''">
+ <div id="document">
+ <!-- Some style
for the expand/contract section-->
+ <style>
+
#expandcontractdiv {border:1px dotted #dedede; margin:0 0 .5em 0;
padding:0.4em;}
+
#treeDiv1 { background: #fff; padding:1em; margin-top:1em; }
+ </style>
+ <script
type="text/javascript">
+ var
documents = <xsl:value-of select="documents" />;
+ </script>
+
+ <!-- markup for
expand/contract links -->
+ <div
id="expandcontractdiv">
+ <a
id="expand" href="#"><xsl:value-of select="php:function('lang', 'expand all')"
/></a>
+
<xsl:text> </xsl:text>
+ <a
id="collapse" href="#"><xsl:value-of select="php:function('lang', 'collapse
all')" /></a>
+ </div>
+
+ <div
id="treeDiv1"></div>
+ </div>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:choose>
<xsl:when test="related_link !=
''">
<div id="related">
<table
cellpadding="2" cellspacing="2" width="80%" align="center">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [6934] property: documents for entities,
Sigurd Nes <=