fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8370] Added upload of procedure documents


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [8370] Added upload of procedure documents
Date: Mon, 19 Dec 2011 13:41:29 +0000

Revision: 8370
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8370
Author:   erikhl
Date:     2011-12-19 13:41:28 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
Added upload of procedure documents
added table for documents and document types

Modified Paths:
--------------
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.sodocument.inc.php
    trunk/controller/inc/class.uidocument.inc.php
    trunk/controller/inc/class.uiprocedure.inc.php
    trunk/controller/setup/phpgw_no.lang
    trunk/controller/setup/setup.inc.php
    trunk/controller/setup/tables_current.inc.php
    trunk/controller/setup/tables_update.inc.php
    trunk/controller/templates/base/procedure_item.xsl

Added Paths:
-----------
    trunk/controller/templates/base/procedure_documents.xsl
    trunk/controller/templates/base/procedure_tabs.xsl

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/inc/class.socontrol.inc.php        2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -2,7 +2,7 @@
        /**
        * phpGroupWare - controller: a part of a Facilities Management System.
        *
-       * @author Erink Holm-Larsen <address@hidden>
+       * @author Erik Holm-Larsen <address@hidden>
        * @author Torstein Vadla <address@hidden>
        * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
        * This file is part of phpGroupWare.

Modified: trunk/controller/inc/class.sodocument.inc.php
===================================================================
--- trunk/controller/inc/class.sodocument.inc.php       2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/inc/class.sodocument.inc.php       2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -133,7 +133,7 @@
                }
                else
                {
-                       $cols = 'controller_document.id as document_id, 
controller_document.title as document_title, description, name, contract_id, 
party_id, controller_document_types.title as type_title';
+                       $cols = 'controller_document.id as document_id, 
controller_document.title as document_title, description, name, procedure_id, 
controller_document_types.title as type_title';
                }
                
                $dir = $ascending ? 'ASC' : 'DESC';
@@ -160,7 +160,7 @@
                        
$document->set_description($this->unmarshal($this->db->f('description',true),'string'));
                        
$document->set_name($this->unmarshal($this->db->f('name',true),'string'));
                        
$document->set_type($this->unmarshal($this->db->f('type_title',true),'string'));
-                       
$document->set_contract_id($this->unmarshal($this->db->f('contract_id',true),'int'));
+                       
$document->set_procedure_id($this->unmarshal($this->db->f('procedure_id',true),'int'));
                }
                return $document;
        }
@@ -176,7 +176,7 @@
                );
                
                $procedure_id = 
$this->marshal($document->get_procedure_id(),'int');
-               $contract_id = $contract_id > 0 ? $contract_id : 'NULL';
+               $procedure_id = $procedure_id > 0 ? $procedure_id : 'NULL';
                
                
                $values = array(

Modified: trunk/controller/inc/class.uidocument.inc.php
===================================================================
--- trunk/controller/inc/class.uidocument.inc.php       2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/inc/class.uidocument.inc.php       2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -43,7 +43,8 @@
                                'query'         => true,
                                'add'           => true,
                                'view'          => true,
-                               'delete'        => true
+                               'delete'        => true,
+                               'show'          => true
                        );
                
                public function __construct()
@@ -158,16 +159,16 @@
                        {
                                //Load contract
                                $procedure = 
$this->so_procedure->get_single($procedure_id);
-                               if(!$procedure->has_permission(PHPGW_ACL_EDIT))
+/*                             if(!$procedure->has_permission(PHPGW_ACL_EDIT))
                                {
                                        $data['error'] = 
lang('permission_denied_add_document');
                                        $this->render('permission_denied.php', 
$data);
                                        return;
-                               }
+                               }*/
                        }
                        
                        // If no contract or party is loaded
-                       if(!isset($contract))
+                       if(!isset($procedure))
                        {
                                $data['error'] = lang('error_no_procedure');
                                $this->render('permission_denied.php', $data);
@@ -182,7 +183,7 @@
                                
$document->set_title(phpgw::get_var('document_title'));
                                
$document->set_name($_FILES["file_path"]["name"]);
                                
$document->set_type_id(phpgw::get_var('document_type'));
-                               $document->set_contract_id($procedure_id);
+                               $document->set_procedure_id($procedure_id);
                                
                                //Retrieve the document properties
                                $document_properties = 
$this->get_type_and_id($document);
@@ -202,7 +203,7 @@
                                        {
                                                if(isset($procedure))
                                                {
-                                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uiprocedure.edit', 'id' => $procedure->get_id(), 'tab' => 'documents'));
+                                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uidocument.show', 'procedure_id' => $procedure->get_id(), 'tab' => 
'documents'));
                                                }
                                        }
                                        else
@@ -355,4 +356,76 @@
                                'id' => $id
                        );
                }
+               
+               public function show()
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= 
'::'.lang('view');
+                       $procedure_id = (int)phpgw::get_var('procedure_id');
+                       $document_type = phpgw::get_var('type');
+                       if(isset($_POST['edit_procedure']))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uiprocedure.edit', 'id' => $procedure_id));
+                       }
+                       else
+                       {
+                               if(isset($procedure_id) && $procedure_id > 0)
+                               {
+                                       $procedure = 
$this->so_procedure->get_single($procedure_id);
+                               }
+                               else
+                               {
+                                       
$this->render('permission_denied.php',array('error' => 
lang('invalid_request')));
+                                       return;
+                               }
+
+                               if($this->flash_msgs)
+                               {
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               }
+                               
+                               $documents = 
$this->so->get(null,null,null,null,null,null,array('procedure_id' => 
$procedure_id, 'type' => $document_type));
+                               //$document_array = array();
+                               //var_dump($documents);
+                                       
+                               //$document_array[] = array('document' => 
$document->toArray());
+                               $table_header[] = array('header' => 
lang('Document title'));
+                               $table_header[] = array('header' => 
lang('Document name'));
+                               
+                               foreach($documents as $document)
+                               {
+                                       $doc_array = $document->toArray();
+                                       $doc_array['link'] = 
self::link(array('menuaction' => 'controller.uidocument.view', 'id' => 
$doc_array['id']));
+                                       $table_values[] = array('document' => 
$doc_array);
+                               }
+                               //var_dump($table_values);
+
+                               $procedure_array = $procedure->toArray();
+                               
+                               $tabs = array( array(
+                                                       'label' => 
lang('Procedure'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uiprocedure.view', 'id' => $procedure->get_id()))
+
+                                               ), array(
+                                                       'label' => 
lang('View_documents_for_procedure')
+                                               ));
+
+                               $data = array
+                               (
+                                       'tabs'                                  
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                                       'view'                                  
=> "view_documents_for_procedure",
+                                       'procedure_id'                  => 
!empty($procedure) ? $procedure->get_id() : 0,
+                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'procedure'                             
=> $procedure_array,
+                                       'dateformat'                    => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
+                                       'values'                                
=> $table_values,
+                                       'table_header'                  => 
$table_header,
+                               );
+
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Procedure');
+
+                               //self::render_template_xsl('procedure_item', 
$data);
+                               
self::render_template_xsl(array('procedure_tabs', 'common', 
'procedure_documents'), $data);
+                       }
+               }
        }
\ No newline at end of file

Modified: trunk/controller/inc/class.uiprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.uiprocedure.inc.php      2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/inc/class.uiprocedure.inc.php      2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -390,9 +390,19 @@
                                                $table_values[] = array('row' 
=> $rev);
                                        }
                                }
+                               
+                               $tabs = array( array(
+                                                       'label' => 
lang('Procedure')
 
+                                               ), array(
+                                                       'label' => 
lang('View_documents_for_procedure'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uidocument.show', 'procedure_id' => $procedure->get_id(), 'type' => 
'procedure'))
+                                               ));
+
                                $data = array
                                (
+                                       'tabs'                                  
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 0),
+                                       'view'                                  
=> "view_procedure",
                                        'value_id'                              
=> !empty($procedure) ? $procedure->get_id() : 0,
                                        'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
                                        'procedure'                             
=> $procedure_array,
@@ -409,7 +419,8 @@
 
                                $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Procedure');
 
-                               self::render_template_xsl('procedure_item', 
$data);
+                               //self::render_template_xsl('procedure_item', 
$data);
+                               
self::render_template_xsl(array('procedure_tabs', 'common', 'procedure_item'), 
$data);
                        }
                }
 

Modified: trunk/controller/setup/phpgw_no.lang
===================================================================
--- trunk/controller/setup/phpgw_no.lang        2011-12-19 11:59:11 UTC (rev 
8369)
+++ trunk/controller/setup/phpgw_no.lang        2011-12-19 13:41:28 UTC (rev 
8370)
@@ -302,3 +302,7 @@
 Bim_name       controller      no      Utstyrsnavn
 Bim_type       controller      no      Utstyrstype
 GUID   controller      no      GUID
+View_procedure controller      Prosedyre
+View_documents_for_procedure   controller      no      Tilknyttede dokumenter
+Document title controller      no      Dokumentets tittel:
+Document name  controller      no      Filnavn:
\ No newline at end of file

Modified: trunk/controller/setup/setup.inc.php
===================================================================
--- trunk/controller/setup/setup.inc.php        2011-12-19 11:59:11 UTC (rev 
8369)
+++ trunk/controller/setup/setup.inc.php        2011-12-19 13:41:28 UTC (rev 
8370)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['controller']['name'] = 'controller';
-       $setup_info['controller']['version'] = '0.1.12';
+       $setup_info['controller']['version'] = '0.1.13';
        $setup_info['controller']['app_order'] = 100;
        $setup_info['controller']['enable'] = 1;
        $setup_info['controller']['app_group']  = 'office';

Modified: trunk/controller/setup/tables_current.inc.php
===================================================================
--- trunk/controller/setup/tables_current.inc.php       2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/setup/tables_current.inc.php       2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -158,5 +158,32 @@
                        'fk' => array(),
                        'ix' => array(),
                        'uc' => array()
-               )
+               ),
+               'controller_document_types' => array(
+                       'fd' => array(
+                               'id' => array('type' => 'auto', 'nullable' => 
false),
+                               'title' => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false)
+                       ),
+                       'pk' => array('id'),
+                       'fk' => array(),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
+               'controller_document' => array(
+                       'fd' => array(
+                               'id'            => array('type' => 'auto', 
'nullable' => false),
+                               'name'          => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false),
+                               'procedure_id'   => array('type' => 'int', 
'precision' => '4', 'nullable' => true),
+                               'title'         => array('type' => 'varchar', 
'precision' => '255', 'nullable' => true),
+                               'description'   => array('type' => 'text', 
'nullable' => true),
+                               'type_id'       => array('type' => 'int', 
'precision' => '4', 'nullable' => false)
+                       ),
+                       'pk' => array('id'),
+                       'fk' => array(
+                               'controller_procedure'   => 
array('procedure_id' => 'id'),
+                               'controller_document_types' => array('type_id' 
=> 'id')
+                       ),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
        );

Modified: trunk/controller/setup/tables_update.inc.php
===================================================================
--- trunk/controller/setup/tables_update.inc.php        2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/setup/tables_update.inc.php        2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -242,3 +242,43 @@
                $GLOBALS['setup_info']['controller']['currentver'] = '0.1.12';
                return $GLOBALS['setup_info']['controller']['currentver'];
        }
+       
+       $test[] = '0.1.12';
+       function controller_upgrade0_1_12()
+       {
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'controller_document_types', array(
+                               'fd' => array(
+                                       'id' => array('type' => 'auto', 
'nullable' => false),
+                                       'title' => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false)
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+               
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'controller_document', array(
+                               'fd' => array(
+                                       'id'            => array('type' => 
'auto', 'nullable' => false),
+                                       'name'          => array('type' => 
'varchar', 'precision' => '255', 'nullable' => false),
+                                       'procedure_id'   => array('type' => 
'int', 'precision' => '4', 'nullable' => true),
+                                       'title'         => array('type' => 
'varchar', 'precision' => '255', 'nullable' => true),
+                                       'description'   => array('type' => 
'text', 'nullable' => true),
+                                       'type_id'       => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(
+                                       'controller_procedure'   => 
array('procedure_id' => 'id'),
+                                       'controller_document_types' => 
array('type_id' => 'id')
+                               ),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+
+               $GLOBALS['setup_info']['controller']['currentver'] = '0.1.13';
+               return $GLOBALS['setup_info']['controller']['currentver'];
+       }

Added: trunk/controller/templates/base/procedure_documents.xsl
===================================================================
--- trunk/controller/templates/base/procedure_documents.xsl                     
        (rev 0)
+++ trunk/controller/templates/base/procedure_documents.xsl     2011-12-19 
13:41:28 UTC (rev 8370)
@@ -0,0 +1,56 @@
+<!-- $Id$ -->
+<!-- document  -->
+
+<xsl:template name="view_procedure_documents" xmlns:php="http://php.net/xsl";>
+
+<xsl:variable name="dateformat"><xsl:value-of select="dateformat" 
/></xsl:variable>
+
+<div class="yui-content">
+               <div id="details">
+                       <form enctype="multipart/form-data" 
action="?menuaction=controller.uidocument.add" method="POST">
+                               <xsl:variable name="lang_upload"><xsl:value-of 
select="php:function('lang', 'upload')" /></xsl:variable>
+                               <input type="hidden" name="procedure_id" value 
= "{procedure_id}" />
+                               <input type="hidden" name="document_type" 
value="1" />
+                               <fieldset>
+                                       <h3><xsl:value-of 
select="php:function('lang','upload')" /></h3>
+                                       <input type="file" id="file_path" 
name="file_path" />
+                                       <xsl:value-of 
select="php:function('lang','title')" />:
+                                       <input type="text" id="document_title" 
name="document_title" />
+                                       <input type="submit" id="upload_button" 
value="{$lang_upload}" />
+                               </fieldset>
+                       </form>
+               </div>
+               <div id="details">
+                       <table cellpadding="10" cellspacing="10" align="left" 
style="margin-left: 1em;">
+                               <xsl:call-template 
name="table_header_documents"/>
+                               <xsl:call-template name="values_documents"/>
+                       </table>
+               </div>
+       </div>
+</xsl:template>
+
+<xsl:template name="table_header_documents">
+       <tr class="th">
+               <xsl:for-each select="table_header" >
+                       <td class="th_text" style="padding-right: 10px;">
+                               <xsl:value-of select="header"/>
+                       </td>
+               </xsl:for-each>
+       </tr>
+</xsl:template>
+
+<xsl:template name="values_documents">
+       <xsl:for-each select="values" >
+               <tr>
+                       <xsl:for-each select="document" >
+                               <xsl:variable name="doc_link"><xsl:value-of 
select='link'/></xsl:variable>
+                               <td align="left" style="padding-right: 10px;">
+                                       <a href="{$doc_link}"><xsl:value-of 
select="title"/></a>
+                               </td>
+                               <td align="left" style="padding-right: 10px;">
+                                       <xsl:value-of select="name"/>
+                               </td>
+                       </xsl:for-each>
+               </tr>
+       </xsl:for-each>
+</xsl:template>
\ No newline at end of file


Property changes on: trunk/controller/templates/base/procedure_documents.xsl
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/controller/templates/base/procedure_item.xsl
===================================================================
--- trunk/controller/templates/base/procedure_item.xsl  2011-12-19 11:59:11 UTC 
(rev 8369)
+++ trunk/controller/templates/base/procedure_item.xsl  2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -1,15 +1,10 @@
 <!-- $Id$ -->
 <!-- item  -->
 
-<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+<xsl:template name="view_procedure" xmlns:php="http://php.net/xsl";>
 
 <xsl:call-template name="yui_booking_i18n"/>
 <xsl:variable name="dateformat"><xsl:value-of select="dateformat" 
/></xsl:variable>
-<div class="identifier-header">
-<h1><img src="{img_go_home}" /> 
-               <xsl:value-of select="php:function('lang', 'Procedure')" />
-</h1>
-</div>
 
 <div class="yui-content">
                <div id="details">

Added: trunk/controller/templates/base/procedure_tabs.xsl
===================================================================
--- trunk/controller/templates/base/procedure_tabs.xsl                          
(rev 0)
+++ trunk/controller/templates/base/procedure_tabs.xsl  2011-12-19 13:41:28 UTC 
(rev 8370)
@@ -0,0 +1,32 @@
+<!-- $Id$ -->
+<!-- separate tabs and  inline tables-->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+<xsl:call-template name="yui_booking_i18n"/>
+<div class="yui-navset yui-navset-top" id="procedure_tabview">
+       <xsl:choose>
+               <xsl:when test="view = 'view_procedure'">
+                       <div class="identifier-header">
+                               <h1><img src="{img_go_home}" /> 
+                                               <xsl:value-of 
select="php:function('lang', 'Procedure')" />
+                               </h1>
+                       </div>
+                       <!-- Prints tabs array -->
+                       <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
+                        
+                       <xsl:call-template name="view_procedure" />
+               </xsl:when>
+               <xsl:when test="view = 'view_documents_for_procedure'">
+                       <div class="identifier-header">
+                               <h1><img src="{img_go_home}" /> 
+                                               <xsl:value-of 
select="php:function('lang', 'Procedure')" />
+                               </h1>
+                       </div>
+                       <!-- Prints tabs array -->
+                       <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
+                       <xsl:call-template name="view_procedure_documents" />
+               </xsl:when>
+       </xsl:choose>
+</div>
+       
+</xsl:template>
\ No newline at end of file


Property changes on: trunk/controller/templates/base/procedure_tabs.xsl
___________________________________________________________________
Added: svn:mime-type
   + text/plain




reply via email to

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