[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15216] Merge 14936:15027 and 15164:15215 from Syncro
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15216] Merge 14936:15027 and 15164:15215 from Syncromind to trunk |
Date: |
Mon, 30 May 2016 07:58:10 +0000 (UTC) |
Revision: 15216
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15216
Author: sigurdne
Date: 2016-05-30 07:58:10 +0000 (Mon, 30 May 2016)
Log Message:
-----------
Merge 14936:15027 and 15164:15215 from Syncromind to trunk
Modified Paths:
--------------
trunk/controller/inc/class.uicheck_list.inc.php
trunk/phpgwapi/inc/class.vfs_sql.inc.php
trunk/property/inc/class.uientity.inc.php
trunk/property/inc/class.uigeneric_document.inc.php
trunk/property/inc/class.uilocation.inc.php
trunk/property/js/portico/entity.edit.js
trunk/property/js/portico/location.edit.js
trunk/property/templates/base/entity.xsl
trunk/property/templates/base/generic_document.xsl
trunk/property/templates/base/location.xsl
Added Paths:
-----------
trunk/property/inc/class.bogeneric_document.inc.php
trunk/property/inc/class.sogeneric_document.inc.php
trunk/property/js/portico/generic_document.edit.js
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
+ /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14937-15027,15165-15215
/branches/stavangerkommune:12743-12875,12986
Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php 2016-05-29 17:20:13 UTC
(rev 15215)
+++ trunk/controller/inc/class.uicheck_list.inc.php 2016-05-30 07:58:10 UTC
(rev 15216)
@@ -930,36 +930,62 @@
// $valid_types =
isset($config->config_data['document_valid_types']) &&
$config->config_data['document_valid_types'] ? str_replace ( ',' , '|' ,
$config->config_data['document_valid_types'] ) : '.pdf';
$values = array();
-// if($valid_types)
+
+ $lang_view = lang('click to view file');
+ foreach ($document_list as $entry)
{
- $lang_view = lang('click to view file');
- foreach ($document_list as $entry)
+ $link_file_data = array
+ (
+ 'menuaction' =>
'property.uidocument.view_file',
+ 'id' => $entry['document_id'],
+ 'p_num' => $data['id'],
+ 'cat_id' => $cat_id,
+ 'entity_id' => $entity_id,
+ );
+
+ $values[] = array
+ (
+ 'document_id' => $entry['document_id'],
+ 'file_name' => $entry['document_name'],
+ 'file_name' => '<a href="' .
$GLOBALS['phpgw']->link('/index.php', $link_file_data) . "\" target='_blank'
title='{$lang_view}'>{$entry['document_name']}</a>",
+ 'link' => $entry['link'],
+ 'title' => $entry['title'],
+ 'doc_type' => $entry['doc_type'],
+ 'document_date' =>
$GLOBALS['phpgw']->common->show_date($entry['document_date'],
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
+ );
+ }
+
+ $generic_document =
CreateObject('property.sogeneric_document');
+ $params['location_id'] = $location_id;
+ $params['order'] = 'name';
+ $params['allrows'] = true;
+ $generic_document_list = array();
+ foreach ($doc_types as $doc_type)
+ {
+ if ($doc_type)
{
-// if (
!preg_match("/({$valid_types})$/i", $entry['document_name']) )
-// {
-// continue;
-// }
- $link_file_data = array
- (
- 'menuaction' =>
'property.uidocument.view_file',
- 'id' => $entry['document_id'],
- 'p_num' => $data['id'],
- 'cat_id' => $cat_id,
- 'entity_id' => $entity_id,
- );
-
- $values[] = array
- (
- 'document_id' =>
$entry['document_id'],
- 'file_name' =>
$entry['document_name'],
- 'file_name' => '<a href="' .
$GLOBALS['phpgw']->link('/index.php', $link_file_data) . "\" target='_blank'
title='{$lang_view}'>{$entry['document_name']}</a>",
- 'link' => $entry['link'],
- 'title' => $entry['title'],
- 'doc_type' =>
$entry['doc_type'],
- 'document_date' =>
$GLOBALS['phpgw']->common->show_date($entry['document_date'],
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
- );
+ $params['cat_id'] = $doc_type;
+ $generic_document_list =
array_merge($generic_document_list, $generic_document->read($params));
}
}
+
+ foreach ($generic_document_list as $entry)
+ {
+ $link_file_data = array
+ (
+ 'menuaction' =>
'property.uigeneric_document.view_file',
+ 'file_id' => $entry['id']
+ );
+
+ $values[] = array
+ (
+ 'document_id' => $entry['id'],
+ 'file_name' => $entry['name'],
+ 'file_name' => '<a href="' .
$GLOBALS['phpgw']->link('/index.php', $link_file_data) . "\" target='_blank'
title='{$lang_view}'>{$entry['name']}</a>"
+ );
+ }
+
+
return $values;
}
Modified: trunk/phpgwapi/inc/class.vfs_sql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.vfs_sql.inc.php 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/phpgwapi/inc/class.vfs_sql.inc.php 2016-05-30 07:58:10 UTC (rev
15216)
@@ -1115,6 +1115,94 @@
}
}
+ function touch2($data,$p = array())
+ {
+ if(!is_array($data))
+ {
+ $data = array();
+ }
+
+ $default_values = array
+ (
+ 'relatives' => array(RELATIVE_CURRENT)
+ );
+
+ $data = array_merge($this->default_values($data,
$default_values), $data);
+
+ $account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+
+ if(!$p)
+ {
+ $p = $this->path_parts(array(
+ 'string' =>
$data['string'],
+ 'relatives' =>
array($data['relatives'][0])
+ )
+ );
+ }
+
+ umask(000);
+
+ if(!$this->acl_check(array(
+ 'string' => $p->fake_full_path,
+ 'relatives' => array($p->mask),
+ 'operation' => PHPGW_ACL_ADD
+ ))
+ )
+ {
+ return false;
+ }
+
+ $value_set = array
+ (
+ 'owner_id' => $this->working_id,
+ 'directory' => $p->fake_leading_dirs_clean,
+ 'name' => $p->fake_name_clean
+ );
+
+ $cols = implode(',', array_keys($value_set));
+ $values =
$GLOBALS['phpgw']->db->validate_insert(array_values($value_set));
+ $sql = "INSERT INTO phpgw_vfs ({$cols}) VALUES
({$values})";
+
+ $query = $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
+
+ $last_insert_id =
$GLOBALS['phpgw']->db->get_last_insert_id('phpgw_vfs', 'file_id');
+
+ $this->set_attributes(array(
+ 'string' => $p->fake_full_path,
+ 'relatives' => array($p->mask),
+ 'attributes' => array(
+ 'createdby_id' =>
$account_id,
+ 'created'
=> $this->now,
+ 'size'
=> 0,
+ 'deleteable' => 'Y',
+ 'app'
=> $currentapp
+ )
+ )
+ );
+ $this->correct_attributes(array(
+ 'string' => $p->fake_full_path,
+ 'relatives' => array($p->mask)
+ )
+ );
+
+ $this->add_journal(array(
+ 'string' => $p->fake_full_path,
+ 'relatives' => array($p->mask),
+ 'operation' => VFS_OPERATION_CREATED
+ )
+ );
+
+ if($query)
+ {
+ return $last_insert_id;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
/*
* See vfs_shared
*/
@@ -1302,7 +1390,7 @@
'relatives' =>
array($t->mask)
)
);
-
+
$set_attributes_array = array
(
'createdby_id' => $account_id,
@@ -1684,6 +1772,367 @@
return true;
}
+
+
+ function cp3($data)
+ {
+ if(!$data['from'])
+ {
+ throw new Exception('nothing to copy from');
+ }
+
+ if(!is_array($data))
+ {
+ $data = array();
+ }
+
+ $default_values = array
+ (
+ 'relatives' => array(RELATIVE_CURRENT,
RELATIVE_CURRENT)
+ );
+
+ $data = array_merge($this->default_values($data,
$default_values), $data);
+
+ $account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $f = $this->path_parts(array(
+ 'string' => $data['from'],
+ 'relatives' =>
array($data['relatives'][0])
+ )
+ );
+
+ $t = $this->path_parts(array(
+ 'string' => $data['to'],
+ 'relatives' =>
array($data['relatives'][1])
+ )
+ );
+
+ if(!$this->fileoperation->check_target_directory($t))
+ {
+ $GLOBALS['phpgw']->log->error(array(
+ 'text' => 'vfs::cp() : missing target
directory %1',
+ 'p1' => $t->real_leading_dirs,
+ 'p2' => '',
+ 'line' => __LINE__,
+ 'file' => __FILE__
+ ));
+
+ return false;
+ }
+
+ if(!$this->acl_check(array(
+ 'string' => $f->fake_full_path,
+ 'relatives' => array($f->mask),
+ 'operation' => PHPGW_ACL_READ
+ ))
+ )
+ {
+ return false;
+ }
+
+ if($this->file_exists(array(
+ 'string' => $t->fake_full_path,
+ 'relatives' => array($t->mask)
+ ))
+ )
+ {
+ if(!$this->acl_check(array(
+ 'string' =>
$t->fake_full_path,
+ 'relatives' =>
array($t->mask),
+ 'operation' =>
PHPGW_ACL_EDIT
+ ))
+ )
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if(!$this->acl_check(array(
+ 'string' =>
$t->fake_full_path,
+ 'relatives' =>
array($t->mask),
+ 'operation' => PHPGW_ACL_ADD
+ ))
+ )
+ {
+ return false;
+ }
+
+ }
+
+ umask(000);
+
+ if($this->file_type(array(
+ 'string' => $f->fake_full_path,
+ 'relatives' => array($f->mask)
+ )) != 'Directory'
+ )
+ {
+ if($this->file_actions)
+ {
+// if(!$this->fileoperation->touch($data,
$t) && !$this->fileoperation->copy($f, $t))
+
if(isset($this->fileoperation->external_ref) &&
$this->fileoperation->external_ref)
+ {
+ $_document_id =
$this->fileoperation->touch($data, $t);
+ }
+
+ if(!$this->fileoperation->copy($f, $t,
$_document_id))
+ {
+ return false;
+ }
+
+ $size =
$this->fileoperation->filesize($f);
+ }
+ else
+ {
+ $content = $this->read(array(
+ 'string' =>
$f->fake_full_path,
+ 'relatives' =>
array($f->mask)
+ )
+ );
+
+ $size = strlen($content);
+ }
+
+ if($t->outside)
+ {
+ return true;
+ }
+
+ $ls_array = $this->ls(array(
+ 'string' =>
$f->real_full_path, // Sigurd: seems to work better with real - old: 'string'
=> $f->fake_full_path,
+ 'relatives' =>
array($f->mask),
+ 'checksubdirs' => false,
+ 'mime_type' => false,
+ 'nofiles' => true
+ )
+ );
+ $record = $ls_array[0];
+
+ if($data['id'])
+ {
+ $file_info =
$this->get_info($data['id']);
+ $old_file =
"{$file_info['directory']}/{$file_info['name']}";
+
+ $p = $this->path_parts(array(
+ 'string' =>
$old_file,
+ 'relatives' =>
array($data['relatives'][0])
+ )
+ );
+
+ if(!$this->acl_check(array(
+ 'string' =>
$p->fake_full_path,
+ 'relatives' =>
array($p->mask),
+ 'operation' =>
PHPGW_ACL_DELETE
+ ))
+ )
+ {
+ return false;
+ }
+
+ if(!$this->file_exists(array(
+ 'string' =>
$old_file,
+ 'relatives' =>
array($data['relatives'][0])
+ ))
+ )
+ {
+ if($this->file_actions)
+ {
+
$this->fileoperation->unlink($p);
+ }
+ }
+
+ $file_name = $t->fake_leading_dirs
.'/'.$data['id'].'_#' .$t->fake_name_clean;
+ $t2 = $this->path_parts(array(
+ 'string' =>
$file_name,
+ 'relatives' =>
array($data['relatives'][1])
+ )
+ );
+
+ $query =
$GLOBALS['phpgw']->db->query("UPDATE phpgw_vfs SET
owner_id='{$this->working_id}',"
+ . "
directory='{$t2->fake_leading_dirs_clean}',"
+ . " name='{$t2->fake_name_clean}'"
+ . " WHERE
owner_id='{$this->working_id}' AND file_id='{$data['id']}'" .
$this->extra_sql(VFS_SQL_UPDATE), __LINE__, __FILE__);
+
+ $t = $t2;
+
+ $set_attributes_array = array
+ (
+ 'createdby_id' => $account_id,
+ 'created' =>
$this->now,
+ 'size' =>
$size,
+ 'mime_type' =>
$record['mime_type'],
+ 'deleteable' =>
$record['deleteable'],
+ 'comment' =>
$record['comment'],
+ 'app' =>
$record['app']
+ );
+
+ if(!$this->file_actions)
+ {
+
$set_attributes_array['content'] = $content;
+ }
+
+ $this->set_attributes(array(
+ 'string' =>
$t->fake_full_path,
+ 'relatives' =>
array($t->mask),
+ 'attributes' =>
$set_attributes_array
+ )
+ );
+
+ $this->add_journal(array(
+ 'string' =>
$t->fake_full_path,
+ 'relatives' =>
array($t->mask),
+ 'operation' =>
VFS_OPERATION_EDITED
+ )
+ );
+ $file_id = $data['id'];
+ }
+ else
+ {
+ $file_id = $this->touch2(array(
+ 'string' =>
$t->fake_full_path,
+ 'relatives' =>
array($t->mask)
+ )
+ );
+
+ if ($file_id)
+ {
+ if($this->file_actions)
+ {
+ $new_name =
$t->fake_leading_dirs .'/'.$file_id.'_#' .$t->fake_name_clean;
+
+ $t2 =
$this->path_parts(array(
+
'string' => $new_name,
+
'relatives' => array($data['relatives'][1])
+ )
+ );
+
+ $rr =
$this->fileoperation->rename($t, $t2);
+
+ if ($rr)
+ {
+ $query =
$GLOBALS['phpgw']->db->query("UPDATE phpgw_vfs SET
owner_id='{$this->working_id}',"
+ . "
directory='{$t2->fake_leading_dirs_clean}',"
+ . "
name='{$t2->fake_name_clean}'"
+ . " WHERE
owner_id='{$this->working_id}' AND directory='{$t->fake_leading_dirs_clean}'"
+ . " AND
name='{$t->fake_name_clean}'", __LINE__, __FILE__);
+
+ $t = $t2;
+ }
+ }
+
+ $set_attributes_array = array
+ (
+ 'createdby_id' =>
$account_id,
+ 'created'
=> $this->now,
+ 'size'
=> $size,
+ 'mime_type'
=> $record['mime_type'],
+ 'deleteable' =>
$record['deleteable'],
+ 'comment'
=> $record['comment'],
+ 'app'
=> $record['app']
+ );
+
+ if(!$this->file_actions)
+ {
+
$set_attributes_array['content'] = $content;
+ }
+
+ $this->set_attributes(array(
+ 'string'
=> $t->fake_full_path,
+ 'relatives'
=> array($t->mask),
+ 'attributes'
=> $set_attributes_array
+ )
+ );
+ }
+ }
+ $this->correct_attributes(array(
+ 'string' =>
$t->fake_full_path,
+ 'relatives' =>
array($t->mask)
+ )
+ );
+
+ if ($file_id)
+ {
+ return $file_id;
+ }
+ else {
+ return false;
+ }
+ }
+ else /* It's a directory */
+ {
+ /* First, make the initial directory */
+ if($this->mkdir(array(
+ 'string' => $data['to'],
+ 'relatives' =>
array($data['relatives'][1])
+ )) === false
+ )
+ {
+ return false;
+ }
+
+ /* Next, we create all the directories below
the initial directory */
+ $ls = $this->ls(array(
+ 'string' =>
$f->fake_full_path,
+ 'relatives' =>
array($f->mask),
+ 'checksubdirs' => true,
+ 'mime_type' => 'Directory'
+ )
+ );
+
+ while(list($num, $entry) = each($ls))
+ {
+ $newdir = preg_replace("/^" .
str_replace('/', '\/', $f->fake_full_path). "/", $t->fake_full_path,
$entry['directory']);
+
+ if($this->mkdir(array(
+ 'string' =>
"{$newdir}/{$entry['name']}",
+ 'relatives' =>
array($t->mask)
+ )) === false
+ )
+ {
+ return false;
+ }
+ }
+
+ /* Lastly, we copy the files over */
+ $ls = $this->ls(array(
+ 'string' =>
$f->fake_full_path,
+ 'relatives' =>
array($f->mask)
+ )
+ );
+
+ while(list($num, $entry) = each($ls))
+ {
+ if($entry['mime_type'] == 'Directory')
+ {
+ continue;
+ }
+
+ $newdir = preg_replace("/^" .
str_replace('/', '\/', $f->fake_full_path). "/", $t->fake_full_path,
$entry['directory']);
+ $this->cp(array(
+ 'from' =>
"{$entry[directory]}/{$entry[name]}",
+ 'to' =>
"{$newdir}/{$entry[name]}",
+ 'relatives' =>
array($f->mask, $t->mask)
+ )
+ );
+ }
+ }
+
+ if(!$f->outside)
+ {
+ $this->add_journal(array(
+ 'string' =>
$f->fake_full_path,
+ 'relatives' =>
array($f->mask),
+ 'operation' =>
VFS_OPERATION_COPIED,
+ 'state_one' => NULL,
+ 'state_two' =>
$t->fake_full_path
+ )
+ );
+ }
+
+ return true;
+ }
+
/*
* See vfs_shared
*/
Copied: trunk/property/inc/class.bogeneric_document.inc.php (from rev 15027,
branches/dev-syncromind-2/property/inc/class.bogeneric_document.inc.php)
===================================================================
--- trunk/property/inc/class.bogeneric_document.inc.php
(rev 0)
+++ trunk/property/inc/class.bogeneric_document.inc.php 2016-05-30 07:58:10 UTC
(rev 15216)
@@ -0,0 +1,105 @@
+<?php
+ /**
+ * phpGroupWare - property: a part of a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @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
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage logistic
+ * @version $Id: class.bogeneric_document.inc.php 14913 2016-04-27
12:27:37Z sigurdne $
+ */
+
+ class property_bogeneric_document
+ {
+ private $so;
+ var $public_functions = array
+ (
+ 'read' => true,
+ 'read_single' => true,
+ 'save' => true,
+ 'delete' => true,
+ 'get_file_relations' => true
+ );
+
+ public function __construct()
+ {
+ $this->so = CreateObject('property.sogeneric_document');
+ $this->bocommon = CreateObject('property.bocommon');
+ }
+
+ public function read($data = array())
+ {
+
+ $values = $this->so->read($data);
+ $this->total_records = $this->so->total_records;
+
+ return $values;
+ }
+
+ public function read_single( $file_id )
+ {
+ $values = $this->so->read_single($file_id);
+
+ return json_decode($values);
+ }
+
+ function get_file_relations( $location_id, $file_id )
+ {
+ $values = $this->so->get_file_relations($location_id,
$file_id);
+
+ return $values;
+ }
+
+ function save( $values = array(), $file_id )
+ {
+ $report_date =
phpgwapi_datetime::date_array($values['report_date']);
+ $values['report_date'] = mktime(2, 0, 0,
$report_date['month'], $report_date['day'], $report_date['year']);
+
+ $result = $this->so->read_single( $file_id );
+
+ if (count($result))
+ {
+ $receipt = $this->so->update($values, $file_id);
+ }
+ else
+ {
+ $receipt = $this->so->add($values, $file_id);
+ }
+
+ return $receipt;
+ }
+
+ function save_file_relations( $items = array(), $location_id,
$file_id )
+ {
+
+ $receipt = $this->so->save_file_relations( $items,
$location_id, $file_id );
+
+ return $receipt;
+ }
+
+ function delete( $file_id )
+ {
+ $receipt = $this->so->delete( $file_id );
+
+ return $receipt;
+ }
+
+ }
\ No newline at end of file
Copied: trunk/property/inc/class.sogeneric_document.inc.php (from rev 15027,
branches/dev-syncromind-2/property/inc/class.sogeneric_document.inc.php)
===================================================================
--- trunk/property/inc/class.sogeneric_document.inc.php
(rev 0)
+++ trunk/property/inc/class.sogeneric_document.inc.php 2016-05-30 07:58:10 UTC
(rev 15216)
@@ -0,0 +1,336 @@
+<?php
+ /**
+ * phpGroupWare - property: a part of a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @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
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage logistic
+ * @version $Id: class.sogeneric_document.inc.php 14913 2016-04-27
12:27:37Z sigurdne $
+ */
+
+ class property_sogeneric_document
+ {
+
+ function __construct()
+ {
+ $this->vfs = CreateObject('phpgwapi.vfs');
+ $this->vfs->fakebase = '/property';
+
+ $this->db = & $GLOBALS['phpgw']->db;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+ $this->like = & $this->db->like;
+ $this->total_records = 0;
+ }
+
+ public function read($data)
+ {
+ $start = isset($data['start']) && $data['start'] ?
$data['start'] : 0;
+ $sort = isset($data['sort']) && $data['sort'] ?
$data['sort'] : 'ASC';
+ $order = isset($data['order']) ? $data['order'] : '';
+ $allrows = isset($data['allrows']) ? $data['allrows'] :
'';
+ $dry_run = isset($data['dry_run']) ? $data['dry_run'] :
'';
+ $user_id = isset($data['user_id']) && $data['user_id']
? (int)$data['user_id'] : 0;
+ $cat_id = isset($data['cat_id']) && $data['cat_id'] ?
(int)$data['cat_id'] : 0;
+ $location_id = isset($data['location_id']) &&
$data['location_id'] ? (int)$data['location_id'] : 0;
+ $mime_type = isset($data['mime_type']) ?
$data['mime_type'] : '';
+ $start_date = isset($data['start_date']) ?
$data['start_date'] : 0;
+ $end_date = isset($data['end_date']) ?
$data['end_date'] : 0;
+ $location = !empty($data['location']) ?
$data['location'] : '';
+ $results = (isset($data['results']) ? $data['results']
: 0);
+
+ if ($order)
+ {
+ switch ($order)
+ {
+ case 'id':
+ $_order = 'file_id';
+ break;
+ case 'date':
+ $_order = 'created';
+ break;
+ default:
+ $_order = $order;
+ }
+
+ $ordermethod = " ORDER BY a.{$_order} {$sort}";
+ }
+ else
+ {
+ $ordermethod = ' ORDER BY a.file_id ASC';
+ }
+
+ $filtermethod = "WHERE a.mime_type != 'Directory' AND
a.mime_type != 'journal' AND a.mime_type != 'journal-deleted'";
+
+ if ($cat_id)
+ {
+ $joinmethod .= " {$this->join}
phpgw_vfs_filedata b ON ( a.file_id = b.file_id )";
+ $filtermethod .= " AND b.metadata @>
'{\"cat_id\":\"{$cat_id}\"}'";
+ }
+
+ if ($location_id)
+ {
+ $joinmethod .= " {$this->join}
phpgw_vfs_file_relation c ON ( a.file_id = c.file_id )";
+ $filtermethod .= " AND c.location_id =
{$location_id}";
+ }
+
+ if ($user_id)
+ {
+ $filtermethod .= " AND a.createdby_id =
{$user_id}";
+ }
+
+ if ($mime_type)
+ {
+ $filtermethod .= " AND a.mime_type =
'{$mime_type}'";
+ }
+
+ if ($start_date)
+ {
+ $date_format = $this->db->date_format();
+ $start_date = date($date_format, $start_date);
+ $end_date = date($date_format, $end_date);
+ $filtermethod .= " AND a.created >=
'$start_date' AND a.created <= '$end_date'";
+ }
+
+ if ($location)
+ {
+ $filtermethod .= " AND a.directory
{$this->like} '%{$location}%'";
+ }
+
+ $sql = "SELECT DISTINCT a.file_id, a.* FROM phpgw_vfs a
" ." {$joinmethod} "." {$filtermethod} ";
+
+ $this->db->query($sql, __LINE__, __FILE__);
+ $this->total_records = $this->db->num_rows();
+
+ $values = array();
+ if (!$dry_run)
+ {
+ if (!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod, $start, __LINE__, __FILE__, $results);
+ }
+ else
+ {
+ $this->db->query($sql . $ordermethod,
__LINE__, __FILE__);
+ }
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ while ($this->db->next_record())
+ {
+ $values[] = array
+ (
+ 'id' => $this->db->f('file_id'),
+ 'owner_id' =>
$this->db->f('owner_id'),
+ 'createdby_id' =>
$this->db->f('createdby_id'),
+ 'modifiedby_id' =>
$this->db->f('modifiedby_id'),
+ 'created' =>
$GLOBALS['phpgw']->common->show_date(strtotime($this->db->f('created')),
$dateformat),
+ 'modified' =>
$GLOBALS['phpgw']->common->show_date(strtotime($this->db->f('modified')),
$dateformat),
+ 'size' => $this->db->f('size'),
+ 'mime_type' =>
$this->db->f('mime_type', true),
+ 'app' => $this->db->f('app'),
+ 'directory' =>
$this->db->f('directory', true),
+ 'name' => $this->db->f('name'),
+ 'link_directory' =>
$this->db->f('link_directory', true),
+ 'link_name' =>
$this->db->f('link_name', true),
+ 'version' =>
$this->db->f('version')
+ );
+ }
+ }
+
+ return $values;
+ }
+
+ public function get_file_relations($location_id, $file_id)
+ {
+ $filtermethod = "WHERE location_id = {$location_id} AND
file_id = {$file_id}";
+
+ $sql = "SELECT * FROM phpgw_vfs_file_relation " ."
{$filtermethod} ";
+ $this->db->query($sql, __LINE__, __FILE__);
+
+ $values = array();
+
+ while ($this->db->next_record())
+ {
+ $values[] = array
+ (
+ 'id' => $this->db->f('relation_id'),
+ 'location_item_id' =>
$this->db->f('location_item_id')
+ );
+ }
+
+ return $values;
+ }
+
+ function save_file_relations( $items = array(), $location_id,
$file_id )
+ {
+ $this->db->transaction_begin();
+
+ $this->db->query("DELETE FROM phpgw_vfs_file_relation
WHERE file_id = {$file_id} AND location_id = {$location_id}", __LINE__,
__FILE__);
+
+ $date_format =
phpgwapi_datetime::date_array(date('Y-m-d'));
+ $date = mktime(2, 0, 0, $date_format['month'],
$date_format['day'], $date_format['year']);
+
+ if (count($items))
+ {
+ foreach($items as $item)
+ {
+ $values_insert = array
+ (
+ 'file_id' => (int)$file_id,
+ 'location_id' =>
(int)$location_id,
+ 'location_item_id' =>
(int)$item,
+ 'is_private' => 0,
+ 'account_id' =>
$GLOBALS['phpgw_info']['user']['account_id'],
+ 'entry_date' => $date,
+ 'start_date' => $date,
+ 'end_date' => $date
+ );
+
+ $this->db->query("INSERT INTO
phpgw_vfs_file_relation (" . implode(',', array_keys($values_insert)) . ')
VALUES ('
+ .
$this->db->validate_insert(array_values($values_insert)) . ')', __LINE__,
__FILE__);
+ }
+ }
+
+ if ($this->db->transaction_commit())
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ public function add( $data = array(), $file_id )
+ {
+ $receipt = array();
+ $values_insert = array
+ (
+ 'file_id' => $file_id,
+ 'metadata' => json_encode($data)
+ );
+
+ $result = $this->db->query("INSERT INTO
phpgw_vfs_filedata (" . implode(',', array_keys($values_insert)) . ') VALUES ('
+ .
$this->db->validate_insert(array_values($values_insert)) . ')', __LINE__,
__FILE__);
+
+ if ($result)
+ {
+ $receipt['message'] = lang('filedata has been
saved');
+ }
+ else {
+ $receipt['error'] = lang('filedata has not been
saved');
+ }
+ return $receipt;
+ }
+
+ public function update( $data = array(), $file_id)
+ {
+ $receipt = array();
+ $value_set = array
+ (
+ 'metadata' => json_encode($data)
+ );
+
+ $value_set = $this->db->validate_update($value_set);
+
+ $result = $this->db->query("UPDATE phpgw_vfs_filedata
SET $value_set WHERE file_id = {$file_id}", __LINE__, __FILE__);
+
+ if ($result)
+ {
+ $receipt['message'] = lang('filedata has been
edited');
+ }
+ else {
+ $receipt['error'] = lang('filedata has not been
edited');
+ }
+ return $receipt;
+ }
+
+ public function read_single( $id )
+ {
+ $id = (int)$id;
+
+ $this->db->query("SELECT * FROM phpgw_vfs_filedata
WHERE file_id = {$id}");
+
+ $values = array();
+ if ($this->db->next_record())
+ {
+ $values['id'] = $id;
+ $values['metadata'] = $this->db->f('metadata');
+ }
+
+ return $values['metadata'];
+ }
+
+ public function delete( $file_id )
+ {
+ $file_info = $this->vfs->get_info($file_id);
+ $file =
"{$file_info['directory']}/{$file_info['name']}";
+
+ if ($file)
+ {
+ $this->db->transaction_begin();
+
+ $this->db->query("DELETE FROM
phpgw_vfs_file_relation WHERE file_id = {$file_id}", __LINE__, __FILE__);
+ $this->db->query("DELETE FROM
phpgw_vfs_filedata WHERE file_id = {$file_id}", __LINE__, __FILE__);
+
+ $result = $this->delete_file($file);
+
+ if ($result)
+ {
+ $this->db->transaction_commit();
+ $receipt = lang('file deleted') . ' : '
. $file_info['name'];
+ } else {
+ $receipt = lang('failed to delete
file') . ' : ' . $file_info['name'];
+ }
+ }
+
+ return $receipt;
+ }
+
+ function delete_file( $file )
+ {
+ $result = false;
+ if ($this->vfs->file_exists(array(
+ 'string' => $file,
+ 'relatives' => array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if ($this->vfs->rm(array(
+ 'string' => $file,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+ $result = true;
+ }
+
+ $this->vfs->override_acl = 0;
+ }
+
+ return $result;
+ }
+
+ }
\ No newline at end of file
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/property/inc/class.uientity.inc.php 2016-05-30 07:58:10 UTC (rev
15216)
@@ -465,15 +465,63 @@
public function get_documents()
{
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+ $doc_type = phpgw::get_var('doc_type', 'int');
$entity_id = phpgw::get_var('entity_id', 'int');
$cat_id = phpgw::get_var('cat_id', 'int');
$num = phpgw::get_var('num');
+ $location_id = phpgw::get_var('location_id', 'int');
+ $export = phpgw::get_var('export', 'bool');
+ $values = array();
+ $params = array(
+ 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'dir' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1 || $export,
+ 'doc_type' => $doc_type,
+ 'entity_id' => $entity_id,
+ 'cat_id' => $cat_id,
+ 'num' => $num
+ );
+
$document = CreateObject('property.sodocument');
- $documents =
$document->get_files_at_location(array('entity_id' => $entity_id,
- 'cat_id' => $cat_id, 'num' => $num));
+ $documents = $document->read_at_location($params);
+
+ foreach ($documents as $item)
+ {
+ $document_name = '<a
href="'.self::link(array('menuaction'=>'property.uidocument.edit',
'document_id'=>$item['document_id'])).'">'.$item['document_name'].'</a>';
+ $values[] = array('document_name' =>
$document_name, 'title'=> $item['title']);
+ }
- return $documents;
+ //$location_id =
$GLOBALS['phpgw']->locations->get_id('property', '.location.' .
count(explode('-', $location_code)));
+ $generic_document =
CreateObject('property.sogeneric_document');
+ if (empty($location_id))
+ {
+ $location_id =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$this->entity_id}.{$this->cat_id}");
+ }
+ $params['location_id'] = $location_id;
+ $params['order'] = 'name';
+ $params['cat_id'] = $doc_type;
+ $documents2 = $generic_document->read($params);
+ foreach ($documents2 as $item)
+ {
+ $document_name = '<a
href="'.self::link(array('menuaction'=>'property.uigeneric_document.edit',
'id'=>$item['id'])).'">'.$item['name'].'</a>';
+ $values[] = array('document_name' =>
$document_name, 'title'=> $item['title']);
+ }
+
+ $result_data = array('results' => $values);
+
+ $result_data['total_records'] = count($values);
+ $result_data['draw'] = $draw;
+
+ return $this->jquery_results($result_data);
}
public function query()
@@ -1972,27 +2020,6 @@
if ($id)
{
- $get_docs = false;
- $check_doc =
$this->bocommon->get_lookup_entity('document');
- foreach ($check_doc as $_check)
- {
- if ($_check['id'] == $this->entity_id)
- {
- $get_docs = true;
- break;
- }
- }
-
- if ($get_docs)
- {
- $tabs['document'] = array('label' =>
lang('document'), 'link' => '#document',
- 'disable' => 0);
- $requestUrlDoc =
json_encode(self::link(array('menuaction' => 'property.uientity.get_documents',
- 'entity_id' =>
$this->entity_id, 'cat_id' => $this->cat_id, 'num' => $values['num'],
- 'phpgw_return_as' =>
'json')));
- $documents = 1;
- }
-
if (!$category['enable_bulk'])
{
$tabs['related'] = array('label' =>
lang('log'), 'link' => '#related', 'disable' => 0);
@@ -2038,8 +2065,8 @@
)
);
- if ($category['enable_bulk'])
- {
+ //if ($category['enable_bulk'])
+ //{
$tabs['inventory'] = array('label' =>
lang('inventory'), 'link' => '#inventory',
'disable' => 0);
@@ -2076,7 +2103,7 @@
array('disablePagination' => true)
)
);
- }
+ //}
if ($_enable_controller)
{
$location_id =
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
@@ -2210,6 +2237,54 @@
)
);
}
+
+ $get_docs = false;
+ $check_doc =
$this->bocommon->get_lookup_entity('document');
+ foreach ($check_doc as $_check)
+ {
+ if ($_check['id'] == $this->entity_id)
+ {
+ $get_docs = true;
+ break;
+ }
+ }
+
+ //if ($get_docs)
+ //{
+ $tabs['document'] = array('label' =>
lang('document'), 'link' => '#document', 'disable' => 0);
+
+ $cats =
CreateObject('phpgwapi.categories', -1, 'property', '.document');
+ $cats->supress_info = true;
+ $categories =
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' => '',
+ 'globals' => true, 'use_acl' =>
true));
+ $default_value = array('cat_id' => '',
'name' => lang('no document type'), 'selected' => 'selected');
+ array_unshift($categories['cat_list'],
$default_value);
+
+ foreach ($categories['cat_list'] as &
$_category)
+ {
+ $_category['id'] =
$_category['cat_id'];
+ }
+ $doc_type_filter =
$categories['cat_list'];
+
+ $documents_def = array
+ (
+ array('key' => 'document_name',
'label' => lang('name'), 'sortable' => false, 'resizeable' => true),
+ array('key' => 'title', 'label'
=> lang('title'), 'sortable' => false, 'resizeable' => true)
+ );
+
+ $datatable_def[] = array
+ (
+ 'container' =>
'datatable-container_7',
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' => 'property.uientity.get_documents',
+ 'location_id' =>
$location_id, 'entity_id' => $this->entity_id, 'cat_id' => $this->cat_id, 'num'
=> $values['num'], 'phpgw_return_as' => 'json'))),
+ 'data' => "",
+ 'ColumnDefs' => $documents_def,
+ 'config' => array(
+ array('disableFilter'
=> true)
+ )
+ );
+ //}
+
}
//$category['org_unit'] =1;
@@ -2319,8 +2394,9 @@
'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
'active_tab' => $active_tab,
'integration' => $integration,
- 'documents' => $documents,
- 'requestUrlDoc' => $requestUrlDoc ?
$requestUrlDoc : '',
+ 'doc_type_filter' => array('options' =>
$doc_type_filter),
+ /*'documents' => $documents,
+ 'requestUrlDoc' => $requestUrlDoc ?
$requestUrlDoc : '',*/
'lean' => $_lean ? 1 : 0,
'entity_group_list' => array('options' =>
$entity_group_list),
'entity_group_name' => $entity_group_name,
@@ -2339,7 +2415,7 @@
self::render_template_xsl(array('entity',
'datatable_inline', 'attributes_form',
'files'), array('edit' => $data));
- phpgwapi_jquery::load_widget('treeview');
+ //phpgwapi_jquery::load_widget('treeview');
$criteria = array
(
Modified: trunk/property/inc/class.uigeneric_document.inc.php
===================================================================
--- trunk/property/inc/class.uigeneric_document.inc.php 2016-05-29 17:20:13 UTC
(rev 15215)
+++ trunk/property/inc/class.uigeneric_document.inc.php 2016-05-30 07:58:10 UTC
(rev 15216)
@@ -45,7 +45,12 @@
'get_vendors' => true,
'get_users' => true,
'edit_title' => true,
- 'get_relations' => true,
+ 'get_componentes' => true,
+ 'save_file_relations' => true,
+ 'get_location_filter' => true,
+ 'get_part_of_town' => true,
+ 'get_locations_for_type' => true,
+ 'get_categories_for_type' => true,
'view_file' => true,
'download' => true,
);
@@ -54,7 +59,7 @@
{
parent::__construct();
-// $this->bo =
CreateObject('property.bogeneric_document');∕∕create me...
+ $this->bo = CreateObject('property.bogeneric_document');
$this->bocommon = & $this->bo->bocommon;
$this->acl = & $GLOBALS['phpgw']->acl;
$this->acl_location =
'.document';//$this->bo->acl_location;
@@ -114,7 +119,7 @@
self::add_javascript('phpgwapi', 'jquery',
'editable/jquery.dataTables.editable.js');
$categories = $this->_get_categories();
-
+
$data = array(
'datatable_name' => lang('generic document'),
'form' => array(
@@ -144,8 +149,8 @@
'formatter' =>
'JqueryPortico.formatLink'
),
array(
- 'key' => 'title',
- 'label' =>
lang('title'),
+ 'key' => 'name',
+ 'label' => lang('Name'),
'sortable' => true,
'editor' => true
),
@@ -155,38 +160,20 @@
'sortable' => false,
), */
array(
- 'key' => 'address',
- 'label' =>
lang('buildingname'),
+ 'key' => 'app',
+ 'label' => lang('app'),
'sortable' => true
),
array(
- 'key' => 'vendor',
- 'label' =>
lang('vendor'),
+ 'key' => 'version',
+ 'label' =>
lang('version'),
'sortable' => true
),
array(
- 'key' => 'year',
- 'label' => lang('year'),
+ 'key' => 'created',
+ 'label' =>
lang('created'),
'sortable' => true,
'className' => 'center'
- ),
- array(
- 'key' => 'multiplier',
- 'label' =>
lang('multiplier'),
- 'sortable' => false,
- 'className' => 'right'
- ),
- array(
- 'key' => 'cnt',
- 'label' =>
lang('count'),
- 'sortable' => false,
- 'className' => 'center'
- ),
- array(
- 'key' => 'link',
- 'label' => 'dummy',
- 'sortable' => false,
- 'hidden' => true,
)
)
),
@@ -241,7 +228,7 @@
'parameters' => json_encode($parameters)
);
}
-
+
self::render_template_xsl('datatable_jquery', $data);
}
@@ -254,23 +241,20 @@
$search = phpgw::get_var('search');
$order = phpgw::get_var('order');
$draw = phpgw::get_var('draw', 'int');
- $export = phpgw::get_var('export', 'bool');
+ $columns = phpgw::get_var('columns');
-
$params = array(
'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
'query' => $search['value'],
- 'sort' => phpgw::get_var('sort'),
- 'dir' => phpgw::get_var('dir'),
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
'cat_id' => phpgw::get_var('cat_id', 'int',
'REQUEST', 0),
- 'allrows' => phpgw::get_var('length', 'int') ==
-1 || $export
+ 'location' => 'generic_document',
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1
);
- $result_objects = array();
- $result_count = 0;
-
- $values = array(); //$this->bo->read($params);
+ $values = $this->bo->read($params);
if ($export)
{
return $values;
@@ -286,6 +270,71 @@
return $this->jquery_results($result_data);
}
+ public function get_locations_for_type()
+ {
+ $type_id = phpgw::get_var('type_id', 'int');
+ $file_id = phpgw::get_var('id', 'int');
+
+ if (!$type_id)
+ {
+ $type_id = 1;
+ }
+
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
+ $params = array(
+ 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'cat_id' => phpgw::get_var('cat_id', 'int',
'REQUEST', 0),
+ 'type_id' => $type_id,
+ 'district_id' => phpgw::get_var('district_id',
'int', 'REQUEST', 0),
+ 'part_of_town_id' =>
phpgw::get_var('part_of_town_id', 'int', 'REQUEST', 0),
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1
+ );
+
+ $solocation = CreateObject('property.solocation');
+ $locations = $solocation->read($params);
+
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");
+ if ($file_id)
+ {
+ $relation_values =
$this->bo->get_file_relations($location_id, $file_id);
+ }
+ $values_location_item_id = array();
+ if (count($relation_values))
+ {
+ foreach($relation_values as $item)
+ {
+ $values_location_item_id[] =
$item['location_item_id'];
+ }
+ }
+
+ $values = array();
+ foreach($locations as $item)
+ {
+ $checked = in_array($item['id'],
$values_location_item_id) ? 'checked="checked"' : '';
+
+ $values[] = array(
+ 'location_code' =>
$item['location_code'],
+ 'loc1_name' => $item['loc1_name'],
+ 'relate' => '<input
value="'.$item['id'].'" class="locations mychecks" type="checkbox"
'.$checked.'>'
+ );
+ }
+
+ $result_data = array('results' => $values);
+
+ $result_data['total_records'] =
$solocation->total_records;
+ $result_data['draw'] = $draw;
+
+ return $this->jquery_results($result_data);
+ }
+
public function view()
{
if (!$this->acl_read)
@@ -313,7 +362,7 @@
public function edit( $values = array(), $mode = 'edit' )
{
$id = isset($values['id']) && $values['id'] ?
$values['id'] : phpgw::get_var('id', 'int');
-
+
if (!$this->acl_add && !$this->acl_edit)
{
$GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'property.uigeneric_document.view',
@@ -340,47 +389,105 @@
$tabs = array();
$tabs['generic'] = array('label' => lang('generic'),
'link' => '#generic');
$active_tab = 'generic';
- $tabs['relations'] = array('label' =>
lang('relations'), 'link' => "#relations",
- 'disable' => 0);
if ($id)
{
- $tabs['relations']['link'] = '#relations';
- $tabs['relations']['disable'] = 0;
-
if (!$values)
{
- $values =
array();//$this->bo->read_single(array('id' => $id, 'view' => $mode == 'view'));
+ $values = (array)
$this->bo->read_single($id);
+ $values['report_date'] =
($values['report_date']) ? date($this->dateFormat, $values['report_date']) :
'';
}
+ $values['id'] = $id;
}
-
+
$categories = $this->_get_categories($values['cat_id']);
self::message_set($this->receipt);
+
+ $datatable_def = array();
+
+ if ($id)
+ {
+ $tabs['relations'] = array('label' =>
lang('Components'), 'link' => '#relations');
+ $tabs['locations'] = array('label' =>
lang('Locations'), 'link' => '#locations');
+
+ $related_def = array
+ (
+ array('key' => 'name', 'label' =>
lang('name'), 'sortable' => false, 'resizeable' => true),
+ array('key' => 'relate', 'label' =>
lang('related'), 'sortable' => false, 'resizeable' => true),
+ );
- $related_def = array
- (
- array('key' => 'name', 'label' => lang('name'),
'sortable' => false,
- 'resizeable' => true),
- array('key' => 'relate', 'label' =>
lang('related'), 'sortable' => false,
- 'resizeable' => true),
- );
+ $values_location = $this->get_location_filter();
+ $entity_group =
execMethod('property.bogeneric.get_list', array('type' => 'entity_group',
'add_empty' => true));
+ $type_filter =
execMethod('property.soadmin_location.read', array());
+ $category_filter =
$this->get_categories_for_type();
+
+ $district_filter =
$this->bocommon->select_district_list('filter');
+ array_unshift($district_filter, array('id' =>
'', 'name' => lang('no district')));
+
+ $part_of_town_filter =
$this->get_part_of_town();
+
+ $tabletools[] = array
+ (
+ 'my_name' => 'relate',
+ 'text' => lang('Relate'),
+ 'className' => 'relate',
+ 'type' => 'custom',
+ 'custom_code' => "
+ var oArgs = " .
json_encode(array(
+ 'menuaction' =>
'property.uigeneric_document.save_file_relations',
+ 'phpgw_return_as' => 'json'
+ )) . ";
+ var parameters = " .
json_encode(array('parameter' => array(array('name' => 'id',
+ 'source' =>
'id')))) . ";
+ setRelationsComponents(oArgs,
parameters);
+ "
+ );
-
- $datatable_def = array();
- $datatable_def[] = array
+ $datatable_def[] = array
(
- 'container' => 'datatable-container_0',
- 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uigeneric_document.get_relations',
- 'id' => $id, 'phpgw_return_as'
=> 'json'))),
- 'ColumnDefs' => $related_def,
- 'config' => array(
- array('disableFilter' => true)
- )
- );
-
+ 'container' => 'datatable-container_0',
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uigeneric_document.get_componentes',
+ 'id' => $id,
'location_id' => $values_location[0]['id'], 'phpgw_return_as' => 'json'))),
+ 'ColumnDefs' => $related_def,
+ 'tabletools' => ($mode == 'edit') ?
$tabletools : array(),
+ 'config' => array(array('disableFilter'
=> true))
+ );
+
+ $related_def2 = array
+ (
+ array('key' => 'location_code', 'label'
=> lang('name'), 'sortable' => false, 'resizeable' => true),
+ array('key' => 'loc1_name', 'label' =>
lang('eiendom name'), 'sortable' => false, 'resizeable' => true),
+ //array('key' => 'location_id', 'label'
=> lang('location id'), 'sortable' => false, 'resizeable' => true, 'hidden' =>
true),
+ array('key' => 'relate', 'label' =>
lang('related'), 'sortable' => false, 'resizeable' => true),
+ );
+
+ $tabletools2[] = array
+ (
+ 'my_name' => 'relate_locations',
+ 'text' => lang('Relate'),
+ 'className' => 'relate',
+ 'type' => 'custom',
+ 'custom_code' => "
+ var oArgs = " .
json_encode(array(
+ 'menuaction' =>
'property.uigeneric_document.save_file_relations',
+ 'phpgw_return_as' => 'json'
+ )) . ";
+ setRelationsLocations(oArgs);
+ "
+ );
+
+ $datatable_def[] = array
+ (
+ 'container' => 'datatable-container_1',
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uigeneric_document.get_locations_for_type', 'id' => $id,
'phpgw_return_as' => 'json'))),
+ 'ColumnDefs' => $related_def2,
+ 'tabletools' => ($mode == 'edit') ?
$tabletools2 : array()
+ );
+ }
+
$data = array
- (
+ (
'datatable_def' => $datatable_def,
'document' => $values,
'lang_coordinator' => lang('coordinator'),
@@ -388,24 +495,28 @@
'status_list' => array('options' => array('id'
=> 1, 'name' => 'status_1')),
'editable' => $mode == 'edit',
'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
- 'location_filter' => array('options' =>
$this->get_location_filter()),
+ 'location_filter' => array('options' =>
$values_location),
+ 'entity_group_filter' => array('options' =>
$entity_group),
+
+ 'type_filter' => array('options' =>
$type_filter),
+ 'category_filter' => array('options' =>
$category_filter),
+ 'district_filter' => array('options' =>
$district_filter),
+ 'part_of_town_filter' => array('options' =>
$part_of_town_filter),
+
'link_controller_example' =>
self::link(array('menuaction' => 'controller.uicomponent.index'))
);
- //print_r($data['tabs']); die;
-
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . '::' . lang('generic document');
if ($mode == 'edit')
{
$GLOBALS['phpgw']->jqcal->add_listener('report_date');
phpgwapi_jquery::load_widget('core');
- self::add_javascript('property', 'portico',
'generic_document_edit.js');
phpgwapi_jquery::formvalidator_generate(array('date', 'security','file'));
}
phpgwapi_jquery::load_widget('numberformat');
- self::add_javascript('property', 'portico',
'generic_document.js');
+ self::add_javascript('property', 'portico',
'generic_document.edit.js');
self::add_javascript('phpgwapi', 'tinybox2',
'packed.js');
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
@@ -413,23 +524,65 @@
self::render_template_xsl(array('generic_document',
'datatable_inline'), $data);
}
+ public function get_categories_for_type()
+ {
+ $type_id = phpgw::get_var('type_id', 'int');
- private function get_location_filter()
+ if (!$type_id)
+ {
+ $type_id = 1;
+ }
+
+ $categories =
$this->bocommon->select_category_list(array
+ ('format' => 'filter',
+ 'selected' => '',
+ 'type' => 'location',
+ 'type_id' => $type_id,
+ 'order' => 'descr')
+ );
+ array_unshift($categories, array('id' => '', 'name' =>
lang('no category')));
+
+ return $categories;
+ }
+
+ public function get_part_of_town()
{
- $this->soadmin_entity =
CreateObject('property.soadmin_entity');
- $entity_list =
$this->soadmin_entity->read(array('allrows' => true));
- $location_filter = array();
- foreach ($entity_list as $entry)
+ $district_id = phpgw::get_var('district_id', 'int');
+ $values =
$this->bocommon->select_part_of_town('filter', '', $district_id);
+ array_unshift($values, array('id' => '', 'name' =>
lang('no part of town')));
+
+ return $values;
+ }
+
+ public function get_location_filter()
+ {
+ $entity_group_id = phpgw::get_var('entity_group_id',
'int');
+
+ $location_filter =
phpgwapi_cache::session_get('property', "location_filter_{$entity_group_id}");
+
+ if (!$location_filter)
{
- $categories =
$this->soadmin_entity->read_category(array('entity_id' => $entry['id'],
- 'order' => 'name', 'sort' => 'asc',
'enable_controller' => true, 'allrows' => true));
- foreach ($categories as $category)
+ $this->soadmin_entity =
CreateObject('property.soadmin_entity');
+ $entity_list =
$this->soadmin_entity->read(array('allrows' => true));
+
+ $location_filter = array();
+ foreach ($entity_list as $entry)
{
- $location_filter[] = array(
- 'id' =>
$category['location_id'],
- 'name' =>
"{$entry['name']}::{$category['name']}",
- );
+ $categories =
$this->soadmin_entity->read_category(array('entity_id' => $entry['id'],
+ 'order' => 'name', 'sort' =>
'asc', 'enable_controller' => true, 'allrows' => true));
+ foreach ($categories as $category)
+ {
+ if ($entity_group_id &&
$category['entity_group_id'] != $entity_group_id)
+ {
+ continue;
+ }
+ $location_filter[] = array(
+ 'id' =>
$category['location_id'],
+ 'name' =>
"{$entry['name']}::{$category['name']}",
+ );
+ }
}
+ phpgwapi_cache::session_set('property',
"location_filter_{$entity_group_id}", $location_filter);
}
foreach ($location_filter as &$location)
@@ -458,7 +611,7 @@
if ($id)
{
- $values =
array();//$this->bo->read_single(array('id' => $id, 'view' => true));
+ $values = (array)$this->bo->read_single($id);
}
else
{
@@ -476,10 +629,10 @@
}
else
{
-
try
{
- $id = $this->bo->save($values);
+ $id = $this->_handle_files($id);
+ $receipt = $this->bo->save($values,
$id);
}
catch (Exception $e)
{
@@ -490,18 +643,15 @@
return;
}
}
-
- $this->_handle_files($id);
- if ($_FILES['import_file']['tmp_name'])
+
+ if ($receipt['message'])
{
- $this->_handle_import($id);
+
phpgwapi_cache::message_set($receipt['message'], 'message');
+ } else {
+
phpgwapi_cache::message_set($receipt['message'], 'error');
}
- else
- {
- phpgwapi_cache::message_set('ok!',
'message');
- self::redirect(array('menuaction' =>
'property.uigeneric_document.edit',
- 'id' => $id));
- }
+
+ self::redirect(array('menuaction' =>
'property.uigeneric_document.edit', 'id' => $id));
}
}
@@ -512,32 +662,90 @@
*
* @return array $ResultSet json resultset
*/
- public function get_relations()
+ public function get_componentes()
{
if (!$this->acl_read)
{
return;
}
+
+ $file_id = phpgw::get_var('id', 'int');
+ $location_id = phpgw::get_var('location_id', 'int');
+ $search = phpgw::get_var('search');
+ $draw = phpgw::get_var('draw', 'int');
+
+ $soentity = CreateObject('property.soentity');
+ $_components = $soentity->read( array(
+ 'start' => phpgw::get_var('start', 'int', 'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int', 'REQUEST', 0),
+ 'query' => $search['value'],
+ 'allrows' => phpgw::get_var('length', 'int') == -1,
+ 'filter_entity_group' => 0,
+ 'location_id' => $location_id,
+ 'filter_item' => array()
+ ));
+
+ if ($file_id)
+ {
+ $relation_values =
$this->bo->get_file_relations($location_id, $file_id);
+ }
+ $values_location_item_id = array();
+ if (count($relation_values))
+ {
+ foreach($relation_values as $item)
+ {
+ $values_location_item_id[] =
$item['location_item_id'];
+ }
+ }
+
+ $values = array();
+ foreach($_components as $item)
+ {
+ $checked = in_array($item['id'],
$values_location_item_id) ? 'checked="checked"' : '';
+ $values[] = array(
+ 'name' => $item['benevnelse'],
+ 'relate' => '<input
value="'.$item['id'].'" class="components mychecks" type="checkbox"
'.$checked.'>',
+ );
+ }
+
+ $result_data = array('results' => $values);
- $values = array();
- $values[] = array(
- 'name' => 'Item 1',
- 'relate' => '<input type="checkbox"
checked="checked">',
- );
- $values[] = array(
- 'name' => 'Item 2',
- 'relate' => '<input type="checkbox">',
- );
+ $result_data['total_records'] =
$soentity->total_records;
+ $result_data['draw'] = $draw;
- return array(
- 'recordsTotal' => count($values),
- 'recordsFiltered' => count($values),
- 'draw' => phpgw::get_var('draw', 'int'),
- 'data' => $values,
- );
+ return $this->jquery_results($result_data);
}
+
+ public function save_file_relations()
+ {
+ $receipt = array();
+
+ $type_id = phpgw::get_var('type_id', 'int');
+ $location_id = phpgw::get_var('location_id', 'int');
+ $file_id = phpgw::get_var('file_id', 'int');
+ $items = phpgw::get_var('items');
+
+ if (empty($location_id))
+ {
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");
+ }
+
+ $result = $this->bo->save_file_relations( $items,
$location_id, $file_id );
+
+ if ($result)
+ {
+ $receipt['message'][] = array('msg' =>
lang('Records has been added'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('Nothing changed'));
+ }
+
+ return $receipt;
+ }
+
/**
* Dowloads a single file to the browser
@@ -565,48 +773,56 @@
private function _handle_files( $id )
{
$id = (int)$id;
- if (!$id)
+
+ if (empty($id))
{
- throw new
Exception('uigeneric_document::_handle_files() - missing id');
+ if (!is_file($_FILES['file']['tmp_name']))
+ {
+
//phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
+ throw new Exception('Failed to upload
file !');
+ }
}
+
$bofiles = CreateObject('property.bofiles');
-
- if (isset($_POST['file_action']) &&
is_array($_POST['file_action']))
- {
-
$bofiles->delete_file("/generic_document/{$id}/",array('file_action' =>
$_POST['file_action']));
- }
+
$file_name = str_replace(' ', '_',
$_FILES['file']['name']);
if ($file_name)
{
- if (!is_file($_FILES['file']['tmp_name']))
- {
-
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
- return;
- }
-
- $to_file = $bofiles->fakebase .
'/generic_document/' . $id . '/' . $file_name;
- if ($bofiles->vfs->file_exists(array(
+ $to_file = $bofiles->fakebase .
'/generic_document/' .$file_name;
+ /*if ($bofiles->vfs->file_exists(array(
'string' => $to_file,
- 'relatives' =>
Array(RELATIVE_NONE)
+ 'relatives' =>
array(RELATIVE_NONE)
)))
{
- phpgwapi_cache::message_set(lang('This
file already exists !'), 'error');
+
//phpgwapi_cache::message_set(lang('This file already exists !'), 'error');
+ throw new Exception('This file already
exists !');
}
else
- {
-
$bofiles->create_document_dir("generic_document/{$id}");
+ {*/
+ $receipt =
$bofiles->create_document_dir("generic_document");
+ if (count($receipt['error']))
+ {
+ throw new Exception('failed to
create directory');
+ }
$bofiles->vfs->override_acl = 1;
-
- if (!$bofiles->vfs->cp(array(
+
+ $file_id = $bofiles->vfs->cp3(array(
'from' =>
$_FILES['file']['tmp_name'],
'to' => $to_file,
- 'relatives' =>
array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL))))
- {
-
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
- }
+ 'id' => $id,
+ 'relatives' =>
array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL)));
$bofiles->vfs->override_acl = 0;
- }
+
+ if (empty($file_id))
+ {
+ throw new Exception('Failed to
upload file !');
+ }
+
+ return $file_id;
+ //}
+ } else {
+ return $id;
}
}
@@ -723,11 +939,12 @@
{
return 'No access';
}
+
$id = phpgw::get_var('id', 'int', 'GET');
try
{
- $this->bo->delete($id);
+ $result = $this->bo->delete($id);
}
catch (Exception $e)
{
@@ -736,13 +953,12 @@
return $e->getMessage();
}
}
- return 'Deleted';
+ return $result;
}
- /*
+ /*
* Overrides with incoming data from POST
*/
-
private function _populate( $data = array() )
{
Modified: trunk/property/inc/class.uilocation.inc.php
===================================================================
--- trunk/property/inc/class.uilocation.inc.php 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/property/inc/class.uilocation.inc.php 2016-05-30 07:58:10 UTC (rev
15216)
@@ -54,6 +54,7 @@
'responsiblility_role_save' => true,
'get_part_of_town' => true,
'get_history_data' => true,
+ 'get_documents' => true,
'download' => true,
'index' => true,
'view' => true,
@@ -1606,15 +1607,54 @@
public function get_documents()
{
- $entity_id = phpgw::get_var('entity_id', 'int');
- $cat_id = phpgw::get_var('cat_id', 'int');
- $num = phpgw::get_var('num');
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+ $doc_type = phpgw::get_var('doc_type', 'int');
+ $location_code = phpgw::get_var('location_code');
+ $export = phpgw::get_var('export', 'bool');
+ $values = array();
+ $params = array(
+ 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'dir' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length', 'int') ==
-1 || $export,
+ 'doc_type' => $doc_type,
+ 'location_code' => $location_code
+ );
+
$document = CreateObject('property.sodocument');
- $documents =
$document->get_files_at_location(array('entity_id' => $entity_id,
- 'cat_id' => $cat_id, 'num' => $num));
+ $documents = $document->read_at_location($params);
+
+ foreach ($documents as $item)
+ {
+ $document_name = '<a
href="'.self::link(array('menuaction'=>'property.uidocument.edit',
'document_id'=>$item['document_id'])).'">'.$item['document_name'].'</a>';
+ $values[] = array('document_name' =>
$document_name, 'title'=> $item['title']);
+ }
- return $documents;
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('property', '.location.' .
count(explode('-', $location_code)));
+ $generic_document =
CreateObject('property.sogeneric_document');
+ $params['location_id'] = $location_id;
+ $params['order'] = 'name';
+ $params['cat_id'] = $doc_type;
+ $documents2 = $generic_document->read($params);
+ foreach ($documents2 as $item)
+ {
+ $document_name = '<a
href="'.self::link(array('menuaction'=>'property.uigeneric_document.edit',
'id'=>$item['id'])).'">'.$item['name'].'</a>';
+ $values[] = array('document_name' =>
$document_name, 'title'=> $item['title']);
+ }
+
+ $result_data = array('results' => $values);
+
+ $result_data['total_records'] = count($values);
+ $result_data['draw'] = $draw;
+
+ return $this->jquery_results($result_data);
}
public function add()
@@ -1935,8 +1975,8 @@
unset($attributes_groups);
}
- $documents = array();
- $file_tree = array();
+ /*$documents = array();
+ $file_tree = array();*/
$integration = array();
if ($location_code)
{
@@ -1981,20 +2021,51 @@
$location_type_info =
$this->soadmin_location->read_single($type_id);
$documents = array();
- if ($location_type_info['list_documents'])
+ /*if ($location_type_info['list_documents'])
{
$objDocument =
CreateObject('property.sodocument');
$documents =
$objDocument->get_files_at_location(array('location_code' => $location_code));
- }
+ }*/
- if (count($documents))
+ $cats = CreateObject('phpgwapi.categories', -1,
'property', '.document');
+ $cats->supress_info = true;
+ $categories =
$cats->formatted_xslt_list(array('format' => 'filter', 'selected' => 0,
+ 'globals' => true, 'use_acl' => true));
+ $default_value = array('cat_id' => '', 'name'
=> lang('no document type'));
+ array_unshift($categories['cat_list'],
$default_value);
+
+ foreach ($categories['cat_list'] as &
$_category)
{
- $tabs['document'] = array('label' =>
lang('document'), 'link' => '#document');
- $documents = json_encode($documents);
+ $_category['id'] = $_category['cat_id'];
}
- $_dirname = '';
+ $doc_type_filter = $categories['cat_list'];
+
+ //if (count($documents))
+ //{
+ $tabs['document'] = array('label' =>
lang('document'), 'link' => '#document');
+ //$documents = json_encode($documents);
+
+ $documents_def = array
+ (
+ array('key' => 'document_name',
'label' => lang('name'), 'sortable' => false, 'resizeable' => true),
+ array('key' => 'title', 'label'
=> lang('title'), 'sortable' => false, 'resizeable' => true)
+ );
+ $datatable_def[] = array
+ (
+ 'container' =>
'datatable-container_0',
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
'property.uilocation.get_documents', 'location_code' => $location_code,
'phpgw_return_as' => 'json'))),
+ 'data' => "",
+ 'ColumnDefs' => $documents_def,
+ 'config' => array(
+ array('disableFilter'
=> true)
+ )
+ );
+ //}
+
+ /*$_dirname = '';
+
$_files_maxlevel = 0;
if
(isset($_config->config_data['external_files_maxlevel']) &&
$_config->config_data['external_files_maxlevel'])
{
@@ -2018,7 +2089,7 @@
{
$tabs['file_tree'] = array('label' =>
lang('Files'), 'link' => '#file_tree');
$file_tree = json_encode($file_tree);
- }
+ }*/
$_related = array();
foreach ($related as $_location_level =>
$related_info)
@@ -2066,7 +2137,7 @@
$datatable_def[] = array
(
- 'container' => 'datatable-container_0',
+ 'container' => 'datatable-container_1',
'requestUrl' => "''",
'data' => json_encode($_related),
'ColumnDefs' => $related_def,
@@ -2096,7 +2167,7 @@
$datatable_def[] = array
(
- 'container' =>
'datatable-container_1',
+ 'container' =>
'datatable-container_2',
'requestUrl' => "''",
'data' => json_encode(array()),
'ColumnDefs' => $history_def,
@@ -2344,18 +2415,19 @@
'cat_list' =>
$this->bocommon->select_category_list(array('format' => 'select',
'selected' => $values['cat_id'], 'type'
=> 'location', 'type_id' => $type_id,
'order' => 'descr')),
+ 'doc_type_filter' => array('options' =>
$doc_type_filter),
'textareacols' =>
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'])
&& $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] ?
$GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] : 40,
'textarearows' =>
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'])
&& $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ?
$GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 6,
'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, 'general'),
- 'documents' => $documents,
- 'file_tree' => $file_tree,
+ //'documents' => $documents,
+ //'file_tree' => $file_tree,
'lang_expand_all' => lang('expand all'),
'lang_collapse_all' => lang('collapse all'),
'validator' =>
phpgwapi_jquery::formvalidator_generate(array('location',
'date', 'security', 'file'))
);
- phpgwapi_jquery::load_widget('treeview');
+ //phpgwapi_jquery::load_widget('treeview');
$appname = lang('location');
Modified: trunk/property/js/portico/entity.edit.js
===================================================================
--- trunk/property/js/portico/entity.edit.js 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/property/js/portico/entity.edit.js 2016-05-30 07:58:10 UTC (rev
15216)
@@ -223,43 +223,12 @@
$(document).ready(function ()
{
- if (requestUrlDoc)
+ $('#doc_type').change( function()
{
- $("#treeDiv1").jstree({
- "core": {
- "multiple": false,
- "themes": {"stripes": true},
- "data": {
- "url": requestUrlDoc
- }
- },
- "plugins": ["themes", "html_data", "ui", "state"]
- });
+ oTable7.dataTableSettings[7]['ajax']['data']['doc_type'] =
$(this).val();
+ oTable7.fnDraw();
+ });
- var count = 0;
- $("#treeDiv1").bind("select_node.jstree", function (event, data)
- {
- count += 1;
- var divd =
data.instance.get_node(data.selected[0]).original['link'];
- if (count > 1)
- {
- window.location.href = divd;
- }
- });
-
- $('#collapse').on('click', function ()
- {
- $(this).attr('href', 'javascript:;');
- $('#treeDiv1').jstree('close_all');
- })
-
- $('#expand').on('click', function ()
- {
- $(this).attr('href', 'javascript:;');
- $('#treeDiv1').jstree('open_all');
- });
- }
-
$("#workorder_cancel").on("submit", function (e)
{
if ($("#lean").val() == 0)
Copied: trunk/property/js/portico/generic_document.edit.js (from rev 15027,
branches/dev-syncromind-2/property/js/portico/generic_document.edit.js)
===================================================================
--- trunk/property/js/portico/generic_document.edit.js
(rev 0)
+++ trunk/property/js/portico/generic_document.edit.js 2016-05-30 07:58:10 UTC
(rev 15216)
@@ -0,0 +1,145 @@
+
+$(document).ready(function ()
+{
+ $('#entity_group_id').change(function ()
+ {
+ var oArgs1 = {menuaction:
'property.uigeneric_document.get_location_filter'};
+ var requestUrl = phpGWLink('index.php', oArgs1, true);
+ var data = {"entity_group_id": $(this).val()};
+ JqueryPortico.execute_ajax(requestUrl,
+ function(result){
+ var $el = $("#location_id");
+ $el.empty();
+ $.each(result, function(key, value) {
+
$el.append($("<option></option>").attr("value", value.id).text(value.name));
+ });
+ $( "#location_id" ).change();
+ }, data, "GET", "json"
+ );
+ });
+
+ $('#location_id').change(function ()
+ {
+ var oArgs1 = {menuaction:
'property.uigeneric_document.get_componentes', location_id:
$('#location_id').val(), id: $('#id').val()};
+ var requestUrl = phpGWLink('index.php', oArgs1, true);
+ JqueryPortico.updateinlineTableHelper(oTable0, requestUrl);
+ });
+
+ $('select#type_id').change( function()
+ {
+ filterData({'type_id': $(this).val(), 'cat_id': ''});
+
+ var oArgs1 = {menuaction:
'property.uigeneric_document.get_categories_for_type'};
+ var requestUrl = phpGWLink('index.php', oArgs1, true);
+ var data = {"type_id": $(this).val()};
+ JqueryPortico.execute_ajax(requestUrl,
+ function(result){
+ var $el = $("#cat_location_id");
+ $el.empty();
+ $.each(result, function(key, value) {
+
$el.append($("<option></option>").attr("value", value.id).text(value.name));
+ });
+ }, data, "GET", "json"
+ );
+ });
+
+ $('select#cat_location_id').change( function()
+ {
+ filterData({'cat_id': $(this).val()});
+ });
+
+ $('select#district_id').change( function()
+ {
+ filterData({'district_id': $(this).val(), 'part_of_town_id':
''});
+
+ var oArgs1 = {menuaction:
'property.uigeneric_document.get_part_of_town'};
+ var requestUrl = phpGWLink('index.php', oArgs1, true);
+ var data = {"district_id": $(this).val()};
+ JqueryPortico.execute_ajax(requestUrl,
+ function(result){
+ var $el = $("#part_of_town_id");
+ $el.empty();
+ $.each(result, function(key, value) {
+
$el.append($("<option></option>").attr("value", value.id).text(value.name));
+ });
+ }, data, "GET", "json"
+ );
+ });
+
+ $('select#part_of_town_id').change( function()
+ {
+ filterData({'part_of_town_id': $(this).val()});
+ });
+
+ $('select#part_of_town_id').prop('selectedIndex', 0);
+});
+
+function filterData(objParams)
+{
+ $.each(objParams, function(key, value) {
+ oTable1.dataTableSettings[1]['ajax']['data'][key] = value;
+ });
+
+ oTable1.fnDraw();
+}
+
+function setRelationsComponents(oArgs)
+{
+ var values = {};
+
+ var select_check = $('.components');
+ select_check.each(function (i, obj)
+ {
+ if (obj.checked)
+ {
+ values[obj.value] = obj.value;
+ }
+ });
+
+ oArgs['location_id'] = $('#location_id').val();
+ oArgs['file_id'] = $('#id').val();
+ var requestUrl = phpGWLink('index.php', oArgs);
+
+ var data = {"items": values};
+ JqueryPortico.execute_ajax(requestUrl, function (result)
+ {
+ JqueryPortico.show_message(0, result);
+ oTable0.fnDraw();
+
+ }, data, "POST", "JSON");
+}
+
+function setRelationsLocations(oArgs)
+{
+ var values = {};
+
+ var select_check = $('.locations');
+ select_check.each(function (i, obj)
+ {
+ if (obj.checked)
+ {
+ values[obj.value] = obj.value;
+ }
+ });
+
+ oArgs['type_id'] = $('#type_id').val();
+ oArgs['file_id'] = $('#id').val();
+ var requestUrl = phpGWLink('index.php', oArgs);
+
+ var data = {"items": values};
+ JqueryPortico.execute_ajax(requestUrl, function (result)
+ {
+ JqueryPortico.show_message(1, result);
+ oTable1.fnDraw();
+
+ }, data, "POST", "JSON");
+}
+
+// call to AutoCompleteHelper JQUERY
+var oArgs = {menuaction: 'property.uigeneric_document.get_users'};
+var strURL = phpGWLink('index.php', oArgs, true);
+JqueryPortico.autocompleteHelper(strURL, 'coordinator_name', 'coordinator_id',
'coordinator_container');
+
+var oArgs = {menuaction: 'property.uigeneric_document.get_vendors'};
+var strURL = phpGWLink('index.php', oArgs, true);
+JqueryPortico.autocompleteHelper(strURL, 'vendor_name', 'vendor_id',
'vendor_container');
\ No newline at end of file
Modified: trunk/property/js/portico/location.edit.js
===================================================================
--- trunk/property/js/portico/location.edit.js 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/property/js/portico/location.edit.js 2016-05-30 07:58:10 UTC (rev
15216)
@@ -1,78 +1,15 @@
-var documents = null;
-var documents2 = null;
+
var link_history = null;
var set_history_data = 0;
$(document).ready(function ()
{
-
- $("#treeDiv1").jstree({
- "core": {
- "multiple": false,
- "themes": {"stripes": true},
- "data": documents
- },
- "plugins": ["themes", "html_data", "ui", "state"]
- });
-
- var count1 = 0;
- $("#treeDiv1").bind("select_node.jstree", function (event, data)
+ $('#doc_type').change( function()
{
- count1 += 1;
- var divd =
data.instance.get_node(data.selected[0]).original['link'];
- if (count1 > 1)
- {
- window.location.href = divd;
- }
+ oTable0.dataTableSettings[0]['ajax']['data']['doc_type'] =
$(this).val();
+ oTable0.fnDraw();
});
- $('#collapse1').on('click', function ()
- {
- $(this).attr('href', 'javascript:;');
- $('#treeDiv1').jstree('close_all');
- })
-
- $('#expand1').on('click', function ()
- {
- $(this).attr('href', 'javascript:;');
- $('#treeDiv1').jstree('open_all');
- });
-
- if (documents2)
- {
- $("#treeDiv2").jstree({
- "core": {
- "multiple": false,
- "themes": {"stripes": true},
- "data": documents2
- },
- "plugins": ["themes", "html_data", "ui", "state"]
- });
-
- var count2 = 0;
- $("#treeDiv2").bind("select_node.jstree", function (event, data)
- {
- count2 += 1;
- var divd =
data.instance.get_node(data.selected[0]).original['link'];
- if (count2 > 1)
- {
- window.location.href = divd;
- }
- });
-
- $('#collapse2').on('click', function ()
- {
- $(this).attr('href', 'javascript:;');
- $('#treeDiv2').jstree('close_all');
- })
-
- $('#expand2').on('click', function ()
- {
- $(this).attr('href', 'javascript:;');
- $('#treeDiv2').jstree('open_all');
- });
- }
-
get_history_data = function ()
{
if (set_history_data === 0)
Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/property/templates/base/entity.xsl 2016-05-30 07:58:10 UTC (rev
15216)
@@ -300,8 +300,8 @@
<xsl:template match="options">
<option value="{id}">
- <xsl:if test="selected != 0">
- <xsl:attribute name="selected" value="selected"/>
+ <xsl:if test="selected = 'selected' or selected = 1">
+ <xsl:attribute name="selected" value="selected" />
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="name"/>
</option>
@@ -741,34 +741,31 @@
</div>
</xsl:for-each>
- <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">
- documents =
<xsl:value-of select="documents"/>;
- requestUrlDoc =
<xsl:value-of select="requestUrlDoc"/>;
- </script>
- <fieldset>
- <!-- markup for
expand/contract links -->
- <div
id="treecontrol">
- <a
id="collapse" title="Collapse the entire tree below" href="#">
-
<xsl:value-of select="php:function('lang', 'collapse all')"/>
- </a>
-
<xsl:text> | </xsl:text>
- <a
id="expand" title="Expand the entire tree below" href="#">
-
<xsl:value-of select="php:function('lang', 'expand all')"/>
- </a>
- </div>
- <div
id="treeDiv1"></div>
- </fieldset>
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Doc type')" />
+ </label>
+ <select
id="doc_type" name="doc_type">
+
<xsl:apply-templates select="doc_type_filter/options"/>
+ </select>
+ </div>
+
+ <xsl:for-each
select="datatable_def">
+ <xsl:if
test="container = 'datatable-container_7'">
+
<xsl:call-template name="table_setup">
+
<xsl:with-param name="container" select ='container'/>
+
<xsl:with-param name="requestUrl" select ='requestUrl' />
+
<xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+
<xsl:with-param name="tabletools" select ='tabletools' />
+
<xsl:with-param name="data" select ='data' />
+
<xsl:with-param name="config" select ='config' />
+
</xsl:call-template>
+
</xsl:if>
+ </xsl:for-each>
</div>
- </xsl:when>
- </xsl:choose>
+
<xsl:choose>
<xsl:when test="value_id !='' and
enable_bulk = 0">
@@ -805,8 +802,7 @@
</xsl:when>
</xsl:choose>
- <xsl:choose>
- <xsl:when test="enable_bulk = 1">
+
<div id="inventory">
<fieldset>
<div
class="pure-control-group">
@@ -835,8 +831,7 @@
</xsl:choose>
</fieldset>
</div>
- </xsl:when>
- </xsl:choose>
+
</div>
<xsl:choose>
Modified: trunk/property/templates/base/generic_document.xsl
===================================================================
--- trunk/property/templates/base/generic_document.xsl 2016-05-29 17:20:13 UTC
(rev 15215)
+++ trunk/property/templates/base/generic_document.xsl 2016-05-30 07:58:10 UTC
(rev 15216)
@@ -23,12 +23,6 @@
<xsl:value-of disable-output-escaping="yes"
select="tabs"/>
<div id="generic">
-
- <h3>Generic document
information::metadata <br/>
- the metadata might be stored as
XML (or JSONB) in "phpgw_vfs_filedata"
-
- </h3>
- <fieldset>
<xsl:choose>
<xsl:when
test="document/id!=''">
<div
class="pure-control-group">
@@ -36,7 +30,7 @@
<xsl:value-of select="php:function('lang', 'id')" />
</label>
<xsl:value-of select="document/id"/>
- <input
type="hidden" name="id" value="{document/id}"/>
+ <input
type="hidden" name="id" id="id" value="{document/id}"/>
</div>
</xsl:when>
@@ -218,51 +212,89 @@
</div>
</xsl:when>
</xsl:choose>
-
- </fieldset>
</div>
- <div id="relations">
+ <xsl:choose>
+ <xsl:when test="document/id!=''">
+ <div id="relations">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'entity group')" />
+ </label>
+ <select
id="entity_group_id" name="entity_group_id">
+
<xsl:apply-templates select="entity_group_filter/options"/>
+ </select>
+ </div>
+ <div
class="pure-control-group">
+ <label
for="vendor">
+
<xsl:value-of select="php:function('lang', 'item types')" />
+ </label>
+ <select
id="location_id" name="location_id">
+
<xsl:apply-templates select="location_filter/options"/>
+ </select>
+ </div>
- <h3>Implement how to find and link
documents to items - using "location_id", "item_id" and the
"phpgw_vfs_file_relation"</h3>
-
- <div class="pure-control-group">
- <label for="vendor">
- <xsl:value-of
select="php:function('lang', 'item types')" />
- </label>
- <select id="location_id"
name="location_id">
- <xsl:apply-templates
select="location_filter/options"/>
- </select>
- </div>
-
- <h3> Should be able to get items from
the following (have a look at <a
href="{link_controller_example}">controller</a>) for how it is used</h3>
-
- <xsl:text>
- $_components =
execMethod('property.soentity.read', array(
- 'filter_entity_group' =>
$entity_group_id,
- 'location_id' => $_location_id,
- 'district_id' => $district_id,
- 'allrows' => true,
- 'filter_item' => $component_list
- )
- );
- </xsl:text>
-
- <div class="pure-control-group">
-
- <xsl:for-each
select="datatable_def">
- <xsl:if test="container
= 'datatable-container_0'">
-
<xsl:call-template name="table_setup">
-
<xsl:with-param name="container" select ='container'/>
-
<xsl:with-param name="requestUrl" select ='requestUrl' />
-
<xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
-
<xsl:with-param name="tabletools" select ='tabletools' />
-
<xsl:with-param name="config" select ='config' />
-
</xsl:call-template>
- </xsl:if>
- </xsl:for-each>
- </div>
- </div>
+ <xsl:for-each
select="datatable_def">
+ <xsl:if
test="container = 'datatable-container_0'">
+
<xsl:call-template name="table_setup">
+
<xsl:with-param name="container" select ='container'/>
+
<xsl:with-param name="requestUrl" select ='requestUrl' />
+
<xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+
<xsl:with-param name="tabletools" select ='tabletools' />
+
<xsl:with-param name="config" select ='config' />
+
</xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
+ </div>
+
+ <div id="locations">
+ <div
class="pure-control-group">
+ <label
for="vendor">
+
<xsl:value-of select="php:function('lang', 'type')" />
+ </label>
+ <select
id="type_id" name="type_id">
+
<xsl:apply-templates select="type_filter/options"/>
+ </select>
+ </div>
+ <div
class="pure-control-group">
+ <label
for="vendor">
+
<xsl:value-of select="php:function('lang', 'category')" />
+ </label>
+ <select
id="cat_location_id" name="cat_location_id">
+
<xsl:apply-templates select="category_filter/options"/>
+ </select>
+ </div>
+ <div
class="pure-control-group">
+ <label
for="vendor">
+
<xsl:value-of select="php:function('lang', 'district')" />
+ </label>
+ <select
id="district_id" name="district_id">
+
<xsl:apply-templates select="district_filter/options"/>
+ </select>
+ </div>
+ <div
class="pure-control-group">
+ <label
for="vendor">
+
<xsl:value-of select="php:function('lang', 'part of town')" />
+ </label>
+ <select
id="part_of_town_id" name="part_of_town_id">
+
<xsl:apply-templates select="part_of_town_filter/options"/>
+ </select>
+ </div>
+
+ <xsl:for-each
select="datatable_def">
+ <xsl:if
test="container = 'datatable-container_1'">
+
<xsl:call-template name="table_setup">
+
<xsl:with-param name="container" select ='container'/>
+
<xsl:with-param name="requestUrl" select ='requestUrl' />
+
<xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+
<xsl:with-param name="tabletools" select ='tabletools' />
+
<xsl:with-param name="config" select ='config' />
+
</xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
+ </div>
+ </xsl:when>
+ </xsl:choose>
</div>
<div class="proplist-col">
<xsl:variable name="lang_cancel">
@@ -321,7 +353,7 @@
<xsl:template match="options">
<option value="{id}">
- <xsl:if test="selected = 1">
+ <xsl:if test="selected = 'selected' or selected = 1">
<xsl:attribute name="selected" value="selected" />
</xsl:if>
<xsl:attribute name="title" value="description" />
Modified: trunk/property/templates/base/location.xsl
===================================================================
--- trunk/property/templates/base/location.xsl 2016-05-29 17:20:13 UTC (rev
15215)
+++ trunk/property/templates/base/location.xsl 2016-05-30 07:58:10 UTC (rev
15216)
@@ -506,63 +506,34 @@
</div>
</xsl:when>
</xsl:choose>
- <xsl:choose>
- <xsl:when test="documents !=
''">
+
<div id="document">
- <fieldset>
- <!-- 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">
-
documents = <xsl:value-of select="documents"/>;
- </script>
- <!-- markup for
expand/contract links -->
- <div
id="treecontrol">
- <a
id="collapse1" title="Collapse the entire tree below" href="#">
-
<xsl:value-of select="php:function('lang', 'collapse all')"/>
- </a>
-
<xsl:text> | </xsl:text>
- <a
id="expand1" title="Expand the entire tree below" href="#">
-
<xsl:value-of select="php:function('lang', 'expand all')"/>
- </a>
- </div>
- <div
id="treeDiv1"></div>
- </fieldset>
+
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Doc type')" />
+ </label>
+ <select
id="doc_type" name="doc_type">
+
<xsl:apply-templates select="doc_type_filter/options"/>
+ </select>
</div>
- </xsl:when>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="file_tree !=
''">
- <div id="file_tree">
- <fieldset>
- <!-- Some style
for the expand/contract section-->
- <style>
-
#expandcontractdiv2 {border:1px dotted #dedede; margin:0 0 .5em 0;
padding:0.4em;}
-
#treeDiv2 { background: #fff; padding:1em; margin-top:1em; }
- </style>
- <script
type="text/javascript">
-
documents2 = <xsl:value-of select="file_tree"/>;
- </script>
- <!-- markup for
expand/contract links -->
- <div
id="treecontrol">
- <a
id="collapse2" title="Collapse the entire tree below" href="#">
-
<xsl:value-of select="php:function('lang', 'collapse all')"/>
- </a>
-
<xsl:text> | </xsl:text>
- <a
id="expand2" title="Expand the entire tree below" href="#">
-
<xsl:value-of select="php:function('lang', 'expand all')"/>
- </a>
- </div>
- <div
id="treeDiv2"></div>
- </fieldset>
+
+ <xsl:for-each
select="datatable_def">
+ <xsl:if
test="container = 'datatable-container_0'">
+
<xsl:call-template name="table_setup">
+
<xsl:with-param name="container" select ='container'/>
+
<xsl:with-param name="requestUrl" select ='requestUrl' />
+
<xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+
<xsl:with-param name="tabletools" select ='tabletools' />
+
<xsl:with-param name="data" select ='data' />
+
<xsl:with-param name="config" select ='config' />
+
</xsl:call-template>
+
</xsl:if>
+ </xsl:for-each>
</div>
- </xsl:when>
- </xsl:choose>
<div id="related">
<xsl:for-each select="datatable_def">
- <xsl:if test="container =
'datatable-container_0'">
+ <xsl:if test="container =
'datatable-container_1'">
<xsl:call-template
name="table_setup">
<xsl:with-param
name="container" select ='container'/>
<xsl:with-param
name="requestUrl" select ='requestUrl' />
@@ -581,7 +552,7 @@
</script>
<div id="history">
<xsl:for-each
select="datatable_def">
- <xsl:if
test="container = 'datatable-container_1'">
+ <xsl:if
test="container = 'datatable-container_2'">
<xsl:call-template name="table_setup">
<xsl:with-param name="container" select ='container'/>
<xsl:with-param name="requestUrl" select ='requestUrl' />
@@ -834,3 +805,13 @@
];
</script>
</xsl:template>
+
+<xsl:template match="options">
+ <option value="{id}">
+ <xsl:if test="selected = 'selected' or selected = 1">
+ <xsl:attribute name="selected" value="selected" />
+ </xsl:if>
+ <xsl:attribute name="title" value="description" />
+ <xsl:value-of disable-output-escaping="yes" select="name"/>
+ </option>
+</xsl:template>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15216] Merge 14936:15027 and 15164:15215 from Syncromind to trunk,
sigurdne <=