fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [16301] Backport diff from Syncromind to trunk


From: sigurdne
Subject: [Fmsystem-commits] [16301] Backport diff from Syncromind to trunk
Date: Mon, 13 Feb 2017 10:36:34 -0500 (EST)

Revision: 16301
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16301
Author:   sigurdne
Date:     2017-02-13 10:36:34 -0500 (Mon, 13 Feb 2017)
Log Message:
-----------
Backport diff from Syncromind to trunk

Modified Paths:
--------------
    trunk/property/inc/class.bogeneric_document.inc.php
    trunk/property/inc/class.sogeneric_document.inc.php
    trunk/property/inc/class.uigeneric_document.inc.php
    trunk/property/inc/import/class.import_component_files.inc.php
    trunk/property/js/portico/generic_document.edit.js
    trunk/property/js/portico/import_components.js
    trunk/property/templates/base/generic_document.xsl

Property Changed:
----------------
    trunk/
    trunk/booking/
    trunk/bookingfrontend/

Index: trunk
===================================================================
--- trunk       2017-02-13 15:29:58 UTC (rev 16300)
+++ trunk       2017-02-13 15:36:34 UTC (rev 16301)

Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
 /branches/dev-syncromind:13653
-/branches/dev-syncromind-2:14933-16188
+/branches/dev-syncromind-2:14933-16300
 /branches/stavangerkommune:12743-12875,12986
\ No newline at end of property
Index: trunk/booking
===================================================================
--- trunk/booking       2017-02-13 15:29:58 UTC (rev 16300)
+++ trunk/booking       2017-02-13 15:36:34 UTC (rev 16301)

Property changes on: trunk/booking
___________________________________________________________________
Modified: svn:mergeinfo
## -1,2 +1,2 ##
-/branches/dev-syncromind-2/booking:14933-16188
+/branches/dev-syncromind-2/booking:14933-16300
 /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
\ No newline at end of property
Index: trunk/bookingfrontend
===================================================================
--- trunk/bookingfrontend       2017-02-13 15:29:58 UTC (rev 16300)
+++ trunk/bookingfrontend       2017-02-13 15:36:34 UTC (rev 16301)

Property changes on: trunk/bookingfrontend
___________________________________________________________________
Modified: svn:mergeinfo
## -1,2 +1,2 ##
-/branches/dev-syncromind-2/bookingfrontend:14933-16188
+/branches/dev-syncromind-2/bookingfrontend:14933-16300
 /branches/stavangerkommune/bookingfrontend:9468-12740,12986
\ No newline at end of property
Modified: trunk/property/inc/class.bogeneric_document.inc.php
===================================================================
--- trunk/property/inc/class.bogeneric_document.inc.php 2017-02-13 15:29:58 UTC 
(rev 16300)
+++ trunk/property/inc/class.bogeneric_document.inc.php 2017-02-13 15:36:34 UTC 
(rev 16301)
@@ -36,7 +36,8 @@
                        'read_single' => true,
                        'save' => true,
                        'delete' => true,
-                       'get_file_relations' => true
+                       'get_file_relations' => true,
+                       'get_file_relations_componentes' => true
                );
                
                public function __construct()
@@ -68,6 +69,14 @@
                        return $values;
                }
                
+               function get_file_relations_componentes( $data )
+               {
+                       $values = 
$this->so->get_file_relations_componentes($data);
+                       $this->total_records_componentes = 
$this->so->total_records_componentes;
+
+                       return $values;
+               }
+               
                function save( $values = array(), $file_id )
                {
                        $report_date = 
phpgwapi_datetime::date_array($values['report_date']);

Modified: trunk/property/inc/class.sogeneric_document.inc.php
===================================================================
--- trunk/property/inc/class.sogeneric_document.inc.php 2017-02-13 15:29:58 UTC 
(rev 16300)
+++ trunk/property/inc/class.sogeneric_document.inc.php 2017-02-13 15:36:34 UTC 
(rev 16301)
@@ -199,6 +199,72 @@
                        return $values;
                }
                
+               public function get_file_relations_componentes($data) 
+               {
+                       $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
+                       $results = isset($data['results']) && $data['results'] 
? $data['results'] : 0;
+                       $file_id = isset($data['file_id']) && $data['file_id'] 
? (int)$data['file_id'] : 0;
+                       $location_id = isset($data['location_id']) && 
$data['location_id'] ? (int)$data['location_id'] : 0;
+                       $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
+                       $entity_group_id = isset($data['entity_group_id']) ? 
$data['entity_group_id'] : '';
+                       
+                       if ($location_id)
+                       {
+                               $filtermethod = "WHERE a.location_id = 
{$location_id} AND a.file_id = {$file_id}";
+                       } else {
+                               $filtermethod = "WHERE a.file_id = {$file_id}";
+                       }
+                       
+                       if ($entity_group_id)
+                       {
+                               $filtermethod .= " AND c.entity_group_id = 
{$entity_group_id}";
+                       }
+                       
+                       $sql = "SELECT a.file_id, b.type, b.id, b.location_id, 
b.location_code, b.json_representation, c.name AS category_name, c.entity_id, 
c.entity_group_id "
+                                       . "FROM phpgw_vfs_file_relation a INNER 
JOIN fm_bim_item b ON a.location_id = b.location_id AND a.location_item_id = 
b.id "
+                                       . "INNER JOIN fm_entity_category c ON 
b.location_id = c.location_id" ." {$filtermethod} ";
+
+                       if (!$allrows)
+                       {
+                               $this->db->limit_query($sql, $start, __LINE__, 
__FILE__, $results);
+                       }
+                       else
+                       {
+                               $this->db->query($sql, __LINE__, __FILE__);
+                       }
+
+                       $values = array();
+                       $i = 0;
+                       while ($this->db->next_record())
+                       {
+                               $values[$i] = array
+                                       (
+                                       'id' => $this->db->f('id'),
+                                       'entity_id' => 
$this->db->f('entity_id'),
+                                       'entity_group_id' => 
$this->db->f('entity_group_id'),
+                                       'location_id' => 
$this->db->f('location_id'),
+                                       'category_name' => 
$this->db->f('category_name')
+                               );
+                                       
+                               $jsondata = 
json_decode($this->db->f('json_representation', true), true);
+                               foreach ($jsondata as $k => $v)
+                               {
+                                       $values[$i][$k] = $v;
+                               }
+                               $i++;
+                       }
+                                               
+                       $sql2 = "SELECT count(*) as cnt "
+                                       . "FROM phpgw_vfs_file_relation a INNER 
JOIN fm_bim_item b ON a.location_id = b.location_id AND a.location_item_id = 
b.id "
+                                       . "INNER JOIN fm_entity_category c ON 
b.location_id = c.location_id" ." {$filtermethod} ";                      
+                       $this->db->query($sql2, __LINE__, __FILE__);
+
+                       $this->db->next_record();
+                       $this->total_records_componentes = $this->db->f('cnt');
+                       
+                       return $values;
+               }
+               
                function save_file_relations( $add, $delete, $location_id, 
$file_id )
                {
                        $this->db->transaction_begin();

Modified: trunk/property/inc/class.uigeneric_document.inc.php
===================================================================
--- trunk/property/inc/class.uigeneric_document.inc.php 2017-02-13 15:29:58 UTC 
(rev 16300)
+++ trunk/property/inc/class.uigeneric_document.inc.php 2017-02-13 15:36:34 UTC 
(rev 16301)
@@ -61,6 +61,7 @@
 
                        $this->bo = CreateObject('property.bogeneric_document');
                        $this->bocommon = & $this->bo->bocommon;
+                       $this->soadmin_entity = 
CreateObject('property.soadmin_entity');
                        $this->acl = & $GLOBALS['phpgw']->acl;
                        $this->acl_location = 
'.document';//$this->bo->acl_location;
                        $this->acl_read = 
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'property');
@@ -406,7 +407,12 @@
                                if (!$values)
                                {
                                        $values = (array) 
$this->bo->read_single($id);
+                                       $paths = array();
+                                       foreach ($values['path'] as $path){
+                                               $paths[] = array('value' => 
$path);
+                                       }
                                        $values['report_date'] = 
($values['report_date']) ? date($this->dateFormat, $values['report_date']) : '';
+                                       $values['paths'] = $paths;
                                }
                                $values['id'] = $id;
                        }
@@ -426,6 +432,7 @@
                                        (
                                        array('key' => 'id', 'label' => 
lang('id'), 'sortable' => false, 'resizeable' => true),
                                        array('key' => 'name', 'label' => 
lang('Benevnelse'), 'sortable' => false, 'resizeable' => true),
+                                       array('key' => 'category', 'label' => 
lang('Category'), 'sortable' => false, 'resizeable' => true),
                                        array('key' => 'relate', 'label' => 
lang('related'), 'sortable' => false, 'resizeable' => true),
                                );
 
@@ -452,7 +459,7 @@
                                        )) . ";
                                                var parameters = " . 
json_encode(array('parameter' => array(array('name' => 'id',
                                                                'source' => 
'id')))) . ";
-                                               setRelationsComponents(oArgs, 
parameters);
+                                               setRelationsComponents(oArgs);
                                        "
                                );
 
@@ -579,7 +586,7 @@
 
                        if (!$location_filter)
                        {
-                               $this->soadmin_entity = 
CreateObject('property.soadmin_entity');
+                               //$this->soadmin_entity = 
CreateObject('property.soadmin_entity');
                                $entity_list = 
$this->soadmin_entity->read(array('allrows' => true));
 
                                $location_filter = array();
@@ -691,7 +698,44 @@
                        $search = phpgw::get_var('search');
                        $draw = phpgw::get_var('draw', 'int');
                        $only_related = phpgw::get_var('only_related', 
'boolean');
+                       $all_types = phpgw::get_var('all_types', 'boolean');
+                       $entity_group_id = phpgw::get_var('entity_group_id');
+                                               
+                       $entity_list = 
$this->soadmin_entity->read(array('allrows' => true));
+                       $e_list = array();
+                       foreach($entity_list as $entity)
+                       {
+                               $e_list[$entity['id']] = $entity['name'];
+                       }
+                               
+                       if ($all_types)
+                       {
+                               $result = 
$this->bo->get_file_relations_componentes(array(
+                                       'start' => phpgw::get_var('start', 
'int', 'REQUEST', 0),
+                                       'results' => phpgw::get_var('length', 
'int', 'REQUEST', 0),
+                                       'allrows' => phpgw::get_var('length', 
'int') == -1,
+                                       'file_id' => $file_id,
+                                       'entity_group_id' => $entity_group_id
+                                       ));
 
+                               $values = array();
+                               foreach($result as $item)
+                               {
+                                       $values[] = array(
+                                               'id' => '<a 
href="'.self::link(array('menuaction' => 'property.uientity.view', 
'location_id' => $item['location_id'], 'id' => 
$item['id'])).'">'.$item['id'].'</a>',
+                                               'name' => $item['benevnelse'],
+                                               'category' => 
$e_list[$item['entity_id']].'::'.$item['category_name'],
+                                               'relate' => '<input 
value="'.$item['id'].'_'.$item['location_id'].'" class="components mychecks" 
type="checkbox" checked="checked"><input type="hidden" 
class="components_related" value="'.$item['id'].'_'.$item['location_id'].'">',
+                                       );
+                               }
+
+                               $result_data = array('results' => $values);
+                               $result_data['total_records'] = 
$this->bo->total_records_componentes;
+                               $result_data['draw'] = $draw;
+
+                               return $this->jquery_results($result_data);
+                       }
+               
             $soentity = CreateObject('property.soentity');
             $_components = $soentity->read( array(
                 'start' => phpgw::get_var('start', 'int', 'REQUEST', 0),
@@ -702,6 +746,7 @@
                 'location_id' => $location_id,
                 'filter_item' => array()
                 ));
+                       $category = 
$this->soadmin_entity->get_single_category($location_id, true);
 
                        if ($file_id)
                        {
@@ -730,6 +775,7 @@
                                $values[] = array(
                                        'id' => '<a 
href="'.self::link(array('menuaction' => 'property.uientity.view', 
'location_id' => $location_id, 'id' => $item['id'])).'">'.$item['id'].'</a>',
                                        'name' => $item['benevnelse'],
+                                       'category' => 
$e_list[$item['entity_id']].'::'.$category['name'],
                                        'relate' => '<input 
value="'.$item['id'].'" class="components mychecks" type="checkbox" 
'.$checked.'>'.$hidden,
                                );
                        }
@@ -741,12 +787,12 @@
 
                        return $this->jquery_results($result_data);
                }
-
-
+               
                public function save_file_relations()
                {
                        $receipt = array();
 
+                       $all_types = phpgw::get_var('all_types', 'int');
                        $type_id = phpgw::get_var('type_id', 'int');
                        $location_id = phpgw::get_var('location_id', 'int');
                        $file_id = phpgw::get_var('file_id', 'int');
@@ -756,13 +802,33 @@
                        $add = array_diff($items, $related);
                        $delete = array_diff($related, $items);
 
-                       if (empty($location_id))
+                       if ($all_types) 
                        {
-                               $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");
+                               if (count($add))
+                               {
+                                       foreach ($add as $item) {
+                                               $values = explode('_', $item);
+                                               $result = 
$this->bo->save_file_relations( array($values[0]), array(), $values[1], 
$file_id );
+                                       }
+                               }
+
+                               if (count($delete))
+                               {
+                                       foreach ($delete as $item) {
+                                               $values = explode('_', $item);
+                                               $result = 
$this->bo->save_file_relations( array(), array($values[0]), $values[1], 
$file_id );
+                                       }
+                               }
+                       } 
+                       else {
+                               
+                               if (empty($location_id))
+                               {
+                                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', ".location.{$type_id}");
+                               }
+                               $result = $this->bo->save_file_relations( $add, 
$delete, $location_id, $file_id );
                        }
 
-                       $result = $this->bo->save_file_relations( $add, 
$delete, $location_id, $file_id );
-
                        if ($result)
                        {
                                $receipt['message'][] = array('msg' => 
lang('Records has been added'));

Modified: trunk/property/inc/import/class.import_component_files.inc.php
===================================================================
--- trunk/property/inc/import/class.import_component_files.inc.php      
2017-02-13 15:29:58 UTC (rev 16300)
+++ trunk/property/inc/import/class.import_component_files.inc.php      
2017-02-13 15:36:34 UTC (rev 16301)
@@ -72,7 +72,6 @@
                        return true;
                }
                
-               /*
                private function _get_files_by_component($id, $location_id)
                {
                        $sql = "SELECT a.location_id, a.location_item_id, 
b.file_id, b.name, b.md5_sum FROM phpgw_vfs_file_relation a INNER JOIN 
phpgw_vfs b "
@@ -85,25 +84,6 @@
                        
                        while ($this->db->next_record())
                        {
-                               $healthy = $this->db->f('file_id').'_#';
-                               $values[] = 
$this->db->f('md5_sum').'_'.trim(str_replace($healthy, '', 
$this->db->f('name')));
-                       }
-
-                       return $values;                 
-               }*/
-               
-               private function _get_files_by_component($id, $location_id)
-               {
-                       $sql = "SELECT a.location_id, a.location_item_id, 
b.file_id, b.name, b.md5_sum FROM phpgw_vfs_file_relation a INNER JOIN 
phpgw_vfs b "
-                                       . " ON a.file_id = b.file_id WHERE 
a.location_item_id = '{$id}' AND a.location_id = '{$location_id}'"
-                                       . " AND b.mime_type != 'Directory' AND 
b.mime_type != 'journal' AND b.mime_type != 'journal-deleted'";
-
-                       $this->db->query($sql, __LINE__, __FILE__);
-
-                       $values = array();
-                       
-                       while ($this->db->next_record())
-                       {
                                $values[] = $this->db->f('md5_sum');
                        }
 
@@ -232,6 +212,8 @@
                                $message['message'][] = array('msg' => lang('%1 
relations existing', $count_relations_existing));
                        }
                        
+                       $this->_delete_all_dir_temp();
+                       
                        return $message;
                }
                
@@ -286,17 +268,19 @@
                                        }
                                }
                        } else {
-                               foreach ($uploaded_files as $file)
+                               foreach ($uploaded_files as &$file)
                                {
                                        $md5sum = 
$this->_generate_md5sum($file['path_absolute']);
                                        if (!empty($md5sum)) 
                                        {
+                                               $file['md5sum'] = $md5sum;
+                                               $component_files[$md5sum] = 
$file;
                                                
$this->paths_from_file[$md5sum][] = $file['path_relative'];
                                        } else {
                                                $this->paths_empty[] = 
$file['path_absolute'];
                                        }                               
                                }
-                               $component_files = $uploaded_files;
+                               //$component_files = $uploaded_files;
                        }
                }
        
@@ -518,6 +502,20 @@
                        return $component_files;
                }
                
+               private function _delete_all_dir_temp()
+               {
+                       $files = glob($this->path_upload_dir . '*', GLOB_MARK);
+                       
+                       foreach ($files as $file)
+                       {
+                               $path = realpath($file);
+                               if (is_dir($path)) 
+                               {                               
+                                       exec("rm -Rf '{$path}'", $ret);         
                        
+                               }                       
+                       }
+               }
+               
                private function 
_search_relations_with_components_location($relations) 
                {
                        $count_new_relations = 0; 
@@ -790,6 +788,8 @@
                                }
                        }
                        
+                       $this->_delete_all_dir_temp();
+                       
                        return $message;
                }
                

Modified: trunk/property/js/portico/generic_document.edit.js
===================================================================
--- trunk/property/js/portico/generic_document.edit.js  2017-02-13 15:29:58 UTC 
(rev 16300)
+++ trunk/property/js/portico/generic_document.edit.js  2017-02-13 15:36:34 UTC 
(rev 16301)
@@ -90,17 +90,28 @@
 {
        paramsTable0['location_id'] = $('#location_id').val();
        paramsTable0['id'] = $('#id').val();
+       paramsTable0['entity_group_id'] = $('#entity_group_id').val();
        
        if ($('#check_components_related').is(':checked')) {
                paramsTable0['only_related'] = 1;
+               $( "#check_all_types" ).prop( "disabled", false );
        } else {
                paramsTable0['only_related'] = 0;
+               $( "#check_all_types" ).prop( "disabled", true );
        }
 
+       if ($('#check_all_types').is(':checked')) {
+               paramsTable0['all_types'] = 1;
+               $( "#location_id" ).prop( "disabled", true );
+       } else {
+               paramsTable0['all_types'] = 0;
+               $( "#location_id" ).prop( "disabled", false );
+       }
+       
        oTable0.fnDraw();
 }
 
-function setRelationsComponents(oArgs)
+/*function setRelationsComponents2(oArgs)
 {
        var values = {};
        var related = {};
@@ -120,7 +131,6 @@
                related[obj.value] = obj.value;
        });
        
-       oArgs['location_id'] = $('#location_id').val();
        oArgs['file_id'] = $('#id').val();
        var requestUrl = phpGWLink('index.php', oArgs);
 
@@ -132,7 +142,46 @@
                
        }, data, "POST", "JSON");
 }
+*/
+function setRelationsComponents(oArgs)
+{      
+       var values = {};
+       var related = {};
+       
+       var select_check = $('.components');
+       select_check.each(function (i, obj)
+       {
+               if (obj.checked)
+               {
+                       values[obj.value] = obj.value;
+               }
+       });
+       
+       var select_related = $('.components_related');
+       select_related.each(function (i, obj)
+       {
+               related[obj.value] = obj.value;
+       });
+       
+       if ($('#check_all_types').is(':checked')) 
+       {
+               oArgs['all_types'] = 1;
+       } else {
+               oArgs['location_id'] = $('#location_id').val();
+       }
+       
+       oArgs['file_id'] = $('#id').val();
+       var requestUrl = phpGWLink('index.php', oArgs);
 
+       var data = {"items":values, "related":related};
+       JqueryPortico.execute_ajax(requestUrl, function (result)
+       {
+               JqueryPortico.show_message(0, result);
+               oTable0.fnDraw();
+               
+       }, data, "POST", "JSON");
+}
+
 function setRelationsLocations(oArgs)
 {
        var values = {};
@@ -170,6 +219,10 @@
        getComponents();
 }
 
+function showAllTypes() {
+       getComponents();
+}
+
 function showRelatedLocations() {
        getLocations();
 }

Modified: trunk/property/js/portico/import_components.js
===================================================================
--- trunk/property/js/portico/import_components.js      2017-02-13 15:29:58 UTC 
(rev 16300)
+++ trunk/property/js/portico/import_components.js      2017-02-13 15:36:34 UTC 
(rev 16301)
@@ -216,6 +216,7 @@
                })
                .done(function(result) {
                        JqueryPortico.show_message(4, result);
+                       refresh_tab_files();
                        //$('#import_components_files').prop('disabled', true);
                })
                .fail(function() {
@@ -687,6 +688,23 @@
        );                      
 }
        
+function refresh_tab_files ()
+{
+       $('#multi_upload_file').addClass('fileupload-processing');
+       $.ajax({
+               // Uncomment the following to send cross-domain cookies:
+               //xhrFields: {withCredentials: true},
+               url: $('#multi_upload_file').fileupload('option', 'url'),
+               dataType: 'json',
+               context: $('#multi_upload_file')[0]
+       }).always(function () {
+               $('#multi_upload_file').removeClass('fileupload-processing');
+       }).done(function (result) {
+               $('.presentation').empty();
+               $('#multi_upload_file').fileupload('option', 
'done').call($('#multi_upload_file'), $.Event('done'), {result: result});
+       });     
+}
+
 function valid_new_attribute (code)
 {
        if ($('#name_' + code).val() == '')

Modified: trunk/property/templates/base/generic_document.xsl
===================================================================
--- trunk/property/templates/base/generic_document.xsl  2017-02-13 15:29:58 UTC 
(rev 16300)
+++ trunk/property/templates/base/generic_document.xsl  2017-02-13 15:36:34 UTC 
(rev 16301)
@@ -204,6 +204,16 @@
                                                        </label>
                                                        <a 
href="{link_file}"><xsl:value-of select="file_name" /></a>
                                                </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'Path')"/>
+                                                       </label>
+                                                       <xsl:for-each 
select="document/paths">
+                                                               <div 
class='pure-custom'>
+                                                                       
<div><xsl:value-of select="value"/></div>
+                                                               </div>          
                                                
+                                                       </xsl:for-each>
+                                               </div>
                                                <xsl:choose>
                                                        <xsl:when 
test="editable = 1">
                                                                <div 
class="pure-control-group">
@@ -234,6 +244,10 @@
                                                                        
<xsl:value-of select="php:function('lang', 'Only Related')" />
                                                                </label>
                                                                <input 
type="checkbox" id="check_components_related" name="check_components_related" 
value="1" onchange="showRelatedComponentes()"></input>
+                                                               <label>
+                                                                       
<xsl:value-of select="php:function('lang', 'all types')" />
+                                                               </label>
+                                                               <input 
type="checkbox" disabled="disabled" id="check_all_types" name="check_all_types" 
value="1" onchange="showAllTypes()"></input>
                                                        </div>                  
                                
                                                        <div 
class="pure-control-group">
                                                                <label 
for="vendor">




reply via email to

[Prev in Thread] Current Thread [Next in Thread]