fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10545] property: more on condition survey


From: Sigurd Nes
Subject: [Fmsystem-commits] [10545] property: more on condition survey
Date: Tue, 27 Nov 2012 14:54:10 +0000

Revision: 10545
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10545
Author:   sigurdne
Date:     2012-11-27 14:54:08 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
property: more on condition survey

Modified Paths:
--------------
    trunk/property/inc/class.uicondition_survey.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/templates/base/condition_survey.xsl

Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2012-11-27 11:22:54 UTC 
(rev 10544)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2012-11-27 14:54:08 UTC 
(rev 10545)
@@ -45,7 +45,8 @@
                        'save'                          => true,
                        'get_vendors'           => true,
                        'get_users'                     => true,
-                       'edit_survey_title'     => true
+                       'edit_survey_title'     => true,
+                       'get_files'                     => true
                );
 
                public function __construct()
@@ -314,21 +315,64 @@
                                ));
 
                        $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+/*
 
+               var oArgs = {
+                                       
menuaction:'property.uicondition_survey.get_files',
+                                       id: '<xsl:value-of select='survey/id'/>'
+                               };
+                       
+               var requestUrl = phpGWLink('index.php', oArgs, true);
+                       
+               var myColumnDefs = [ 
+               {key:"id", label:'Id', sortable:true},
+               {key:"name", label:'Aktivitetsnavn', sortable:true},
+               {key:"start_date", label:'Startdato', sortable:true}, 
+               {key:"end_date", label:'Sluttdato', sortable:true},
+               {key:"responsible_user_name", label:'Ansvarlig', sortable:true},
+               {key:"status", label:'Status', sortable:true}
+           ]; 
+
+               YAHOO.portico.inlineTableHelper("datatable-container_0", 
requestUrl, myColumnDefs);
+               
+       });
+  </script>
+-->
+       <script>
+               <xsl:for-each select="datatable_def">
+                       YAHOO.portico.inlineTableHelper(<xsl:value-of 
select="container"/>, <xsl:value-of select="requestUrl"/>, <xsl:value-of 
select="ColumnDefs"/>);
+               </xsl:for-each>
+
+*/
+
+                       $file_def = array
+                       (
+                               array('key' => 
'file_name','label'=>lang('Filename'),'sortable'=>false,'resizeable'=>true),
+                               array('key' => 
'delete_file','label'=>lang('Delete 
file'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
+                       );
+
+
+                       $datatable_def = array();
+                       $datatable_def[] = array
+                       (
+                               'container'             => 
'datatable-container_0',
+                               'requestUrl'    => 
json_encode(self::link(array('menuaction' => 
'property.uicondition_survey.get_files', 'id' => 
$id,'phpgw_return_as'=>'json'))),
+                               'ColumnDefs'    => json_encode($file_def),
+                       
+                       );
+
                        $data = array
                        (
-                               'msgbox_data'           => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'survey'                        => $values,
-                               'location_data'         => $location_data,
-                               'categories'            => array('options' => 
$categories),
-                               'status_list'           => array('options' => 
execMethod('property.bogeneric.get_list',array('type' => 
'condition_survey_status', 'selected' => $values['status_id'], 'add_empty' => 
true))),
-                               'editable'                      => $mode == 
'edit',
-                               'tabs'                          => 
phpgwapi_yui::tabview_generate($tabs, $active_tab),
+                               'datatable_def'                                 
=> $datatable_def,
+                               'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'survey'                                        
        => $values,
+                               'location_data'                                 
=> $location_data,
+                               'categories'                                    
=> array('options' => $categories),
+                               'status_list'                                   
=> array('options' => execMethod('property.bogeneric.get_list',array('type' => 
'condition_survey_status', 'selected' => $values['status_id'], 'add_empty' => 
true))),
+                               'editable'                                      
        => $mode == 'edit',
+                               'tabs'                                          
        => phpgwapi_yui::tabview_generate($tabs, $active_tab),
                                'fileupload'                                    
=> true,
                                'multiple_uploader'                             
=> true,
-                               'fileuploader_action'                   => 
"{menuaction:'property.fileuploader.add',"
-                                                                               
                                
."upload_target:'property.bocondition_survey.addfiles',"
-                                                                               
                                ."id:'{$id}'}",
                        );
 //_debug_array($data);die();
                        $GLOBALS['phpgw']->jqcal->add_listener('report_date');
@@ -385,11 +429,130 @@
                                        }
                                }
 
+                               $this->_handle_files($id);
                                phpgwapi_cache::message_set('ok!', 'message'); 
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uicondition_survey.view', 'id' => $id));
                        }
                }
 
+
+               public function get_files()
+               {
+                       $content_files = array();
+                       $content_files[] = array
+                       (
+                               'file_name' => '<a 
href="'.$link_view_file.'&amp;file_name='.$_entry['name'].'" target="_blank" 
title="'.lang('click to view file').'">'.$_entry['name'].'</a>',
+                               'delete_file' => '<input type="checkbox" 
name="values[file_action][]" value="'.$_entry['name'].'" title="'.lang('Check 
to delete file').'">'
+                       );
+
+
+                       return json_encode($content_files);
+
+
+                       $id     = phpgw::get_var('id', 'int');
+
+                       if( !$this->acl_read)
+                       {
+                               return;
+                       }
+
+                       $link_file_data = array
+                       (
+                               'menuaction'    => 'property.uitts.view_file',
+                               'id'                    => $id
+                       );
+
+                       $link_to_files = 
isset($this->bo->config->config_data['files_url']) ? 
$this->bo->config->config_data['files_url']:'';
+
+                       $link_view_file = 
$GLOBALS['phpgw']->link('/index.php',$link_file_data);
+                       $values = $this->bo->read_single($id);
+
+                       $content_files = array();
+
+                       foreach($values['files'] as $_entry )
+                       {
+                               $content_files[] = array
+                               (
+                                       'file_name' => '<a 
href="'.$link_view_file.'&amp;file_name='.$_entry['name'].'" target="_blank" 
title="'.lang('click to view file').'">'.$_entry['name'].'</a>',
+                                       'delete_file' => '<input 
type="checkbox" name="values[file_action][]" value="'.$_entry['name'].'" 
title="'.lang('Check to delete file').'">',
+                                       'attach_file' => '<input 
type="checkbox" name="values[file_attach][]" value="'.$_entry['name'].'" 
title="'.lang('Check to attach file').'">'
+                               );
+                       }                                                       
+
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       {
+
+                               if(count($content_files))
+                               {
+                                       return json_encode($content_files);
+                               }
+                               else
+                               {
+                                       return "";
+                               }
+                       }
+                       return $content_files;
+               }
+
+
+
+               /**
+               * Store and / or delete files related to an entity
+               *
+               * @param string  $id  entity id
+               *
+               * @return void
+               */
+               private function _handle_files($id)
+               {
+                       $id = (int)$id;
+                       if(!$id)
+                       {
+                               throw new 
Exception('uicondition_survey::_handle_files() - missing id');
+                       }
+                       $bofiles        = CreateObject('property.bofiles');
+                       if(isset($_POST['file_action']) && 
is_array($_POST['file_action']))
+                       {
+                               
$bofiles->delete_file("/condition_survey/{$id}/", array('file_action' => 
$_POST['file_action']));
+                       }
+                       $file_name=str_replace(' ','_',$_FILES['file']['name']);
+
+                       if($file_name)
+                       {
+                               $to_file = $bofiles->fakebase . 
'/condition_survey/' . $id . '/' . $file_name;
+                               if($bofiles->vfs->file_exists(array(
+                                       'string' => $to_file,
+                                       'relatives' => Array(RELATIVE_NONE)
+                               )))
+                               {
+                                       phpgwapi_cache::message_set(lang('This 
file already exists !'), 'error'); 
+                               }
+                               else
+                               {
+                                       
$bofiles->create_document_dir("condition_survey/{$id}");
+                                       $bofiles->vfs->override_acl = 1;
+
+                                       if(!$bofiles->vfs->cp (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'); 
+                                       }
+                                       $bofiles->vfs->override_acl = 0;
+                               }
+                       }
+               }
+
+
+               /**
+               * Gets user candidates to be used as coordinator - called as 
ajax from edit form
+               *
+               * @param string  $query
+               *
+               * @return array 
+               */
+
                public function get_users()
                {
                        if(!$this->acl_read)
@@ -416,6 +579,14 @@
                        return array('ResultSet'=> array('Result'=>$values));
                }
 
+               /**
+               * Gets vendor canidated to be used as vendor - called as ajax 
from edit form
+               *
+               * @param string  $query
+               *
+               * @return array 
+               */
+
                public function get_vendors()
                {
                        if(!$this->acl_read)
@@ -434,6 +605,14 @@
                        return array('ResultSet'=> array('Result'=>$values));
                }
 
+               /**
+               * Edit title fo entity directly from table
+               *
+               * @param int  $id  id of entity
+               * @param string  $value new title of entity
+               *
+               * @return string text to appear in ui as receipt on action
+               */
 
                public function edit_survey_title()
                {

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2012-11-27 11:22:54 UTC (rev 
10544)
+++ trunk/property/inc/class.uitts.inc.php      2012-11-27 14:54:08 UTC (rev 
10545)
@@ -2391,7 +2391,7 @@
                                        $receipt = $this->bo->mail_ticket($id, 
$this->bo->fields_updated, $receipt,'', false, isset($values['send_mail']) && 
$values['send_mail'] ? true : false);
                                }
 
-                               //--------- files
+                       //--------- files
                                $bofiles        = 
CreateObject('property.bofiles');
                                if(isset($values['file_action']) && 
is_array($values['file_action']))
                                {
@@ -2426,9 +2426,8 @@
                                                $bofiles->vfs->override_acl = 0;
                                        }
                                }
-                               //                      
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uitts.index'));
 
-
+                       //---------end files
                                if( phpgw::get_var('notify_client_by_sms', 
'bool') 
                                        && isset($values['response_text'])
                                        && $values['response_text']
@@ -2451,7 +2450,6 @@
                                $values = 
$this->bocommon->preserve_attribute_values($values,$values_attribute);
                        }
 
-                       //---------end files
                        $ticket = $this->bo->read_single($id, $values);
 
                        if (isset($ticket['attributes']) && 
is_array($ticket['attributes']))

Modified: trunk/property/templates/base/condition_survey.xsl
===================================================================
--- trunk/property/templates/base/condition_survey.xsl  2012-11-27 11:22:54 UTC 
(rev 10544)
+++ trunk/property/templates/base/condition_survey.xsl  2012-11-27 14:54:08 UTC 
(rev 10545)
@@ -10,28 +10,6 @@
                                </script>
                        </xsl:when>
                </xsl:choose>
-               <script type="text/javascript">
-                       var property_js = <xsl:value-of select="property_js"/>;
-                       var base_java_url = <xsl:value-of 
select="base_java_url"/>;
-                       var datatable = new Array();
-                       var myColumnDefs = new Array();
-
-                       <xsl:for-each select="datatable">
-                               datatable[<xsl:value-of select="name"/>] = [
-                                       {
-                                               values:<xsl:value-of 
select="values"/>,
-                                               total_records: <xsl:value-of 
select="total_records"/>,
-                                               edit_action:  <xsl:value-of 
select="edit_action"/>,
-                                               is_paginator:  <xsl:value-of 
select="is_paginator"/>,
-                                               footer:<xsl:value-of 
select="footer"/>
-                                       }
-                               ]
-                       </xsl:for-each>
-
-                       <xsl:for-each select="myColumnDefs">
-                               myColumnDefs[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
-                       </xsl:for-each>
-               </script>
                <div class="yui-navset" id="survey_edit_tabview">
        
                <h1>
@@ -233,16 +211,23 @@
 
                        <div id="documents">
                                <script type="text/javascript">
-                                       var fileuploader_action = <xsl:value-of 
select="fileuploader_action"/>;
+                                  var fileuploader_action = {
+                                               
menuaction:'property.fileuploader.add',
+                                               
upload_target:'property.bocondition_survey.addfiles',
+                                               id: '<xsl:value-of 
select='survey/id'/>',
+                                               phpgw_return_as: 'json'
+                                       };
                                </script>
+
+                               <xsl:call-template name="datasource-definition" 
/>
+
                                <table cellpadding="2" cellspacing="2" 
width="80%" align="center">
-                                       <!-- <xsl:call-template 
name="file_list"/> -->
                                        <tr>
                                                <td align="left" valign="top">
                                                        <xsl:value-of 
select="php:function('lang', 'files')"/>
                                                </td>
                                                <td>
-                                                       <div 
id="datatable-container_0"/>
+                                                       <div 
style="clear:both;" id="datatable-container_0"></div>              
                                                </td>
                                        </tr>
                                        <xsl:call-template name="file_upload"/>
@@ -251,8 +236,6 @@
                        </div>
                        <div id="import">
                        </div>
-
-
                                        <xsl:choose>
                                                <xsl:when test="documents != 
''">
                                                        <div id="document">
@@ -368,7 +351,20 @@
 
        </xsl:template>
 
+<xsl:template name="datasource-definition">
+       <script>
+       YAHOO.util.Event.onDOMReady(function(){
 
+               <xsl:for-each select="datatable_def">
+                       YAHOO.portico.inlineTableHelper("<xsl:value-of 
select="container"/>", <xsl:value-of select="requestUrl"/>, <xsl:value-of 
select="ColumnDefs"/>);
+               </xsl:for-each>
+
+       });
+  </script>
+
+</xsl:template>
+
+
 <xsl:template match="options">
        <option value="{id}">
                <xsl:if test="selected = 'selected' or selected = 1">




reply via email to

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