fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [14652] more on bookingfrontend


From: Sigurd Nes
Subject: [Fmsystem-commits] [14652] more on bookingfrontend
Date: Sat, 16 Jan 2016 16:40:48 +0000

Revision: 14652
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14652
Author:   sigurdne
Date:     2016-01-16 16:40:47 +0000 (Sat, 16 Jan 2016)
Log Message:
-----------
more on bookingfrontend

Modified Paths:
--------------
    branches/dev-syncromind/booking/inc/class.sodocument.inc.php
    branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
    branches/dev-syncromind/booking/inc/class.uicommon.inc.php
    branches/dev-syncromind/booking/setup/setup.inc.php
    branches/dev-syncromind/booking/setup/tables_current.inc.php
    branches/dev-syncromind/booking/setup/tables_update.inc.php
    branches/dev-syncromind/booking/templates/base/application.xsl
    branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
    branches/dev-syncromind/bookingfrontend/templates/base/application.xsl
    branches/dev-syncromind/bookingfrontend/templates/base/application_new.xsl

Added Paths:
-----------
    branches/dev-syncromind/booking/inc/class.bodocument_application.inc.php
    
branches/dev-syncromind/booking/inc/class.bopermission_document_application.inc.php
    branches/dev-syncromind/booking/inc/class.sodocument_application.inc.php
    
branches/dev-syncromind/booking/inc/class.sopermission_document_application.inc.php
    
branches/dev-syncromind/booking/inc/class.sopermission_permission_document_application.inc.php
    branches/dev-syncromind/booking/inc/class.uidocument_application.inc.php
    
branches/dev-syncromind/bookingfrontend/inc/class.uidocument_application.inc.php

Added: branches/dev-syncromind/booking/inc/class.bodocument_application.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.bodocument_application.inc.php    
                        (rev 0)
+++ branches/dev-syncromind/booking/inc/class.bodocument_application.inc.php    
2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,7 @@
+<?php
+       phpgw::import_class('booking.bodocument');
+
+       class booking_bodocument_application extends booking_bodocument
+       {
+               
+       }
\ No newline at end of file

Added: 
branches/dev-syncromind/booking/inc/class.bopermission_document_application.inc.php
===================================================================
--- 
branches/dev-syncromind/booking/inc/class.bopermission_document_application.inc.php
                         (rev 0)
+++ 
branches/dev-syncromind/booking/inc/class.bopermission_document_application.inc.php
 2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,7 @@
+<?php
+       phpgw::import_class('booking.bopermission');
+
+       class booking_bopermission_document_application extends 
booking_bopermission
+       {
+               
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/booking/inc/class.sodocument.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sodocument.inc.php        
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/booking/inc/class.sodocument.inc.php        
2016-01-16 16:40:47 UTC (rev 14652)
@@ -26,19 +26,24 @@
                $document_owners = array(
                        'building',
                        'resource',
+                       'application'
                );
 
                function __construct()
                {
                        $this->ownerType = substr(get_class($this), 19);
 
-                       parent::__construct(sprintf('bb_document_%s', 
$this->get_owner_type()), array(
+                       $fields = array(
                                'id' => array('type' => 'int'),
                                'name' => array('type' => 'string', 'query' => 
true),
                                'owner_id' => array('type' => 'int', 'required' 
=> true),
                                'category' => array('type' => 'string', 
'required' => true),
                                'description' => array('type' => 'string', 
'required' => false),
-                               'owner_name' => array(
+                       );
+
+                       if($this->get_owner_type()!='application')
+                       {
+                               $fields['owner_name'] = array(
                                        'type' => 'string',
                                        'query' => true,
                                        'join' => array(
@@ -47,9 +52,9 @@
                                                'key' => 'id',
                                                'column' => 'name'
                                        )
-                               )
-                       )
-                       );
+                               );
+                       }
+                       parent::__construct(sprintf('bb_document_%s', 
$this->get_owner_type()), $fields );
                        $this->account = 
$GLOBALS['phpgw_info']['user']['account_id'];
 
                        $server_files_dir = 
$this->_chomp_dir_sep($GLOBALS['phpgw_info']['server']['files_dir']);

Added: branches/dev-syncromind/booking/inc/class.sodocument_application.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.sodocument_application.inc.php    
                        (rev 0)
+++ branches/dev-syncromind/booking/inc/class.sodocument_application.inc.php    
2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,7 @@
+<?php
+       phpgw::import_class('booking.sodocument');
+
+       class booking_sodocument_application extends booking_sodocument
+       {
+               
+       }
\ No newline at end of file

Added: 
branches/dev-syncromind/booking/inc/class.sopermission_document_application.inc.php
===================================================================
--- 
branches/dev-syncromind/booking/inc/class.sopermission_document_application.inc.php
                         (rev 0)
+++ 
branches/dev-syncromind/booking/inc/class.sopermission_document_application.inc.php
 2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,7 @@
+<?php
+       phpgw::import_class('booking.sopermission');
+
+       class booking_sopermission_document_application extends 
booking_sopermission
+       {
+               
+       }
\ No newline at end of file

Added: 
branches/dev-syncromind/booking/inc/class.sopermission_permission_document_application.inc.php
===================================================================
--- 
branches/dev-syncromind/booking/inc/class.sopermission_permission_document_application.inc.php
                              (rev 0)
+++ 
branches/dev-syncromind/booking/inc/class.sopermission_permission_document_application.inc.php
      2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,7 @@
+<?php
+       phpgw::import_class('booking.sopermission_permission');
+
+       class booking_sopermission_permission_document_application extends 
booking_sopermission_permission
+       {
+               
+       }

Modified: branches/dev-syncromind/booking/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uiapplication.inc.php     
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/booking/inc/class.uiapplication.inc.php     
2016-01-16 16:40:47 UTC (rev 14652)
@@ -725,6 +725,7 @@
                                $application['owner_id'] = 
$GLOBALS['phpgw_info']['user']['account_id'];
 
                                $errors = $this->validate($application);
+
                                if($_POST['contact_email'] != 
$_POST['contact_email2'])
                                {
                                        $errors['email']                        
         = lang('The e-mail addresses you entered do not match');
@@ -747,6 +748,7 @@
                                        $errors['application_deactivated'] = 
lang('Application on this building is not possible.');
                                }
 
+
                                if(!$errors)
                                {
                                        $comment_text = 
$this->create_accepted_documents_comment_text($application);
@@ -757,6 +759,33 @@
 
                                        $receipt                         = 
$this->bo->add($application);
                                        $application['id']       = 
$receipt['id'];
+
+
+                                       /** Start attachment **/
+                                       $document_application = 
createObject('booking.uidocument_application');
+
+                                       $document = array(
+                                               'category'      => 'other',
+                                               'owner_id' => 
$application['id'],
+                                               'files' => $this->get_files()
+                                       );
+                                       $document_errors = 
$document_application->bo->validate($document);
+
+                                       if(!$document_errors)
+                                       {
+                                               try
+                                               {
+                                                       
booking_bocommon_authorized::disable_authorization();
+                                                       $document_receipt = 
$document_application->bo->add($document);
+                                               }
+                                               
catch(booking_unauthorized_exception $e)
+                                               {
+                                                       
phpgwapi_cache::message_set(lang('Could not add object due to insufficient 
permissions'));
+                                               }
+                                       }
+
+                                       /** End attachment **/
+
                                        
$this->bo->send_notification($application, true);
                                        $this->bo->so->update_id_string();
                                        phpgwapi_cache::message_set(lang("Your 
application has now been registered and a confirmation email has been sent to 
you.") . "<br />" .
@@ -1140,7 +1169,51 @@
                                        $update  = true;
                                        $notify  = true;
                                }
+                               else if($_FILES)
+                               {
+                               /** Start attachment **/
+                                       $document_application = 
createObject('booking.uidocument_application');
 
+                                       $oldfiles = 
$document_application->bo->so->read(array('filters'=> array('owner_id' => 
$application['id'])));
+                                       $files = $this->get_files();
+                                       $file_exist = false;
+
+                                       if($oldfiles['results'])
+                                       {
+                                               foreach($oldfiles['results'] as 
$old_file)
+                                               {
+                                                       if($old_file['name'] == 
$files['name']['name'])
+                                                       {
+                                                               $file_exist = 
true;
+                                                               
phpgwapi_cache::message_set(lang('file exists'));
+                                                               break;
+                                                       }
+                                               }
+                                       }
+
+                                       $document = array(
+                                               'category'      => 'other',
+                                               'owner_id' => 
$application['id'],
+                                               'files' => $this->get_files()
+                                       );
+                                       $document_errors = 
$document_application->bo->validate($document);
+
+                                       if(!$document_errors && !$file_exist)
+                                       {
+                                               try
+                                               {
+                                                       
booking_bocommon_authorized::disable_authorization();
+                                                       $document_receipt = 
$document_application->bo->add($document);
+                                               }
+                                               
catch(booking_unauthorized_exception $e)
+                                               {
+                                                       
phpgwapi_cache::message_set(lang('Could not add object due to insufficient 
permissions'));
+                                               }
+                                       }
+
+                                       /** End attachment **/
+                               }
+
                                $update AND $receipt = 
$this->bo->update($application);
                                $notify AND 
$this->bo->send_notification($application);
 
@@ -1211,24 +1284,15 @@
                        }
                        $collision_dates         = array("data" => implode(',', 
$collision_dates));
                        self::check_date_availability($application);
-//            echo '<pre>';print_r($application); echo '</pre>';
-//            echo '<pre>';print_r($audience); echo '</pre>';
-//            echo '<pre>';print_r($agegroups); echo '</pre>';
-//            echo '<pre>';print_r($num_associations); echo '</pre>';
-//            echo '<pre>';print_r($from); echo '</pre>';
-//            echo '<pre>';print_r($collision_dates); echo '</pre>';
-//            echo '<pre>';print_r($comments); echo '</pre>';
-//            echo '<pre>';print_r($application_text); echo '</pre>';
                        $application['tabs'] = 
phpgwapi_jquery::tabview_generate($tabs, $active_tab);
+                       phpgwapi_jquery::formvalidator_generate(array('file'), 
'file_form');
 
+
                        self::render_template_xsl('application', 
array('application'             => $application,
                                'audience'                       => $audience, 
'agegroups'                       => $agegroups,
                                'num_associations'       => $num_associations, 
'assoc'                           => $from, 'collision'                   => 
$collision_dates,
                                'comments'                       => $comments, 
'config'                  => $application_text));
-//            self::render_template_xsl('application', array('application' => 
$application));
-//        var_dump($application);
-//        var_dump($application);
-//        exit();
+
                }
 
                function get_activity_data()

Modified: branches/dev-syncromind/booking/inc/class.uicommon.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uicommon.inc.php  2016-01-15 
12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/booking/inc/class.uicommon.inc.php  2016-01-16 
16:40:47 UTC (rev 14652)
@@ -339,6 +339,7 @@
                                case 'pqi': return 'application/cprplayer';
                                case 'tsp': return 'application/dsptype';
                                case 'xls': return 'application/x-msexcel';
+                               case 'xlsx': return 
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
                                case 'pfr': return 'application/font-tdpfr';
                                case 'spl': return 'application/x-futuresplash';
                                case 'stk': return 'application/hyperstudio';
@@ -348,6 +349,7 @@
                                case 'mbd': return 'application/mbed';
                                case 'mfp': return 'application/mirage';
                                case 'doc': return 'application/x-msword';
+                               case 'docx': return 
'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
                                case 'orq': return 'application/ocsp-request';
                                case 'ors': return 'application/ocsp-response';
                                case 'bin': return 'application/octet-stream';

Added: branches/dev-syncromind/booking/inc/class.uidocument_application.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uidocument_application.inc.php    
                        (rev 0)
+++ branches/dev-syncromind/booking/inc/class.uidocument_application.inc.php    
2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,20 @@
+<?php
+       phpgw::import_class('booking.uidocument');
+
+       class booking_uidocument_application extends booking_uidocument
+       {
+
+               public function __construct()
+               {
+                       parent::__construct();
+                       
self::set_active_menu('booking::application::documents');
+               }
+
+               protected function get_owner_pathway(array $forDocumentData)
+               {
+                       return array(
+                               array('text' => 'objects_plural_name', 'href' 
=> 'objects_plural_href'),
+                               array('text' => 'object_singular_name', 'href' 
=> 'object_singular_name'),
+                       );
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/booking/setup/setup.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/setup.inc.php 2016-01-15 12:16:55 UTC 
(rev 14651)
+++ branches/dev-syncromind/booking/setup/setup.inc.php 2016-01-16 16:40:47 UTC 
(rev 14652)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['booking']['name'] = 'booking';
-       $setup_info['booking']['version'] = '0.2.24';
+       $setup_info['booking']['version'] = '0.2.25';
        $setup_info['booking']['app_order'] = 9;
        $setup_info['booking']['enable'] = 1;
        $setup_info['booking']['app_group'] = 'office';
@@ -37,6 +37,7 @@
                'bb_booking_agegroup',
                'bb_document_building',
                'bb_document_resource',
+               'bb_document_application',
                'bb_permission',
                'bb_permission_root',
                'bb_organization_contact',

Modified: branches/dev-syncromind/booking/setup/tables_current.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/tables_current.inc.php        
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/booking/setup/tables_current.inc.php        
2016-01-16 16:40:47 UTC (rev 14652)
@@ -499,6 +499,21 @@
                        'ix' => array(),
                        'uc' => array()
                ),
+               'bb_document_application' => array(
+                       'fd' => array(
+                               'id' => array('type' => 'auto', 'nullable' => 
false),
+                               'name' => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false),
+                               'owner_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => false),
+                               'category' => array('type' => 'varchar', 
'precision' => '150', 'nullable' => false),
+                               'description' => array('type' => 'text', 
'nullable' => true),
+                       ),
+                       'pk' => array('id'),
+                       'fk' => array(
+                               "bb_application" => array('owner_id' => 'id'),
+                       ),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
                'bb_permission' => array(
                        'fd' => array(
                                'id' => array('type' => 'auto', 'nullable' => 
false),

Modified: branches/dev-syncromind/booking/setup/tables_update.inc.php
===================================================================
--- branches/dev-syncromind/booking/setup/tables_update.inc.php 2016-01-15 
12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/booking/setup/tables_update.inc.php 2016-01-16 
16:40:47 UTC (rev 14652)
@@ -3341,7 +3341,7 @@
                                'nullable' => true
                        )
                );
-               
+
                $GLOBALS['phpgw_setup']->oProc->query('CREATE OPERATOR ~@ 
(LEFTARG = jsonb, RIGHTARG = text, PROCEDURE = 
jsonb_exists)',__LINE__,__FILE__);
                $GLOBALS['phpgw_setup']->oProc->query('CREATE OPERATOR ~@| 
(LEFTARG = jsonb, RIGHTARG = text[], PROCEDURE = 
jsonb_exists_any)',__LINE__,__FILE__);
                $GLOBALS['phpgw_setup']->oProc->query('CREATE OPERATOR ~@& 
(LEFTARG = jsonb, RIGHTARG = text[], PROCEDURE = 
jsonb_exists_all)',__LINE__,__FILE__);
@@ -3352,3 +3352,38 @@
                        return $GLOBALS['setup_info']['booking']['currentver'];
                }
        }
+
+       $test[] = '0.2.24';
+       /**
+        * Update booking version from 0.2.24 to 0.2.25
+        *
+        */
+       function booking_upgrade0_2_24()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'bb_document_application',  array(
+                               'fd' => array(
+                                       'id' => array('type' => 'auto', 
'nullable' => false),
+                                       'name' => array('type' => 'varchar', 
'precision' => '255', 'nullable' => false),
+                                       'owner_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => false),
+                                       'category' => array('type' => 
'varchar', 'precision' => '150', 'nullable' => false),
+                                       'description' => array('type' => 
'text', 'nullable' => true),
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(
+                                       "bb_application" => array('owner_id' => 
'id'),
+                               ),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['booking']['currentver'] = 
'0.2.25';
+                       return $GLOBALS['setup_info']['booking']['currentver'];
+               }
+       }
+

Modified: branches/dev-syncromind/booking/templates/base/application.xsl
===================================================================
--- branches/dev-syncromind/booking/templates/base/application.xsl      
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/booking/templates/base/application.xsl      
2016-01-16 16:40:47 UTC (rev 14652)
@@ -148,7 +148,41 @@
                                                        </xsl:for-each>
                                                </div>
                                        </div>
+
                                        <div class="pure-g">
+                                               <div class="pure-u-1">
+                                                       <div class="heading">
+                                                               <legend>
+                                                                       <h3>1.1 
<xsl:value-of select="php:function('lang', 'attachments')" /></h3>
+                                                               </legend>
+                                                       </div>
+                                                       <div 
id="attachments_container"/>
+                                               <form method="POST" 
enctype='multipart/form-data' id='file_form'>
+                                                       <input name="name" 
id='field_name' type='file' >
+                                                               <xsl:attribute 
name='title'>
+                                                                       
<xsl:value-of select="document/name"/>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>mime size</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-allowing">
+                                                                       
<xsl:text>jpg, png, gif, xls, xlsx, doc, docx, txt, pdf, odt, ods</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-max-size">
+                                                                       
<xsl:text>2M</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-error-msg">
+                                                                       
<xsl:text>Max 2M:: jpg, png, gif, xls, xlsx, doc, docx, txt , pdf, odt, 
ods</xsl:text>
+                                                               </xsl:attribute>
+                                                       </input>
+                                                       <br/>
+                                                       <input type="submit" 
value="{php:function('lang', 'Add attachment')}" />
+                                               </form>
+
+                                               </div>
+                                       </div>
+
+                                       <div class="pure-g">
                                                <div class="pure-u-1 
pure-u-md-1-2 pure-u-lg-1-3">
                                                        <div class="heading">
                                                                <legend>
@@ -541,7 +575,7 @@
                if (!resourceIds || resourceIds == "") {
                resourceIds = false;
                }
-               var lang = <xsl:value-of select="php:function('js_lang', 
'Resources', 'Resource Type', 'No records found', 'ID', 'Type', 'From', 'To', 
'Document', 'Active' ,'Delete', 'del')"/>;
+               var lang = <xsl:value-of select="php:function('js_lang', 
'Resources', 'Resource Type', 'No records found', 'ID', 'Type', 'From', 'To', 
'Document', 'Active' ,'Delete', 'del', 'Name')"/>;
                var app_id = <xsl:value-of select="application/id"/>;
                var building_id = <xsl:value-of 
select="application/building_id"/>;
                var resources = <xsl:value-of select="application/resources"/>;
@@ -551,6 +585,7 @@
         var associatedURL = 
'index.php?menuaction=booking.uiapplication.associated&sort=from_&dir=asc&phpgw_return_as=json&filter_application_id='+app_id;
         var documentsURL = 
'index.php?menuaction=booking.uidocument_view.regulations&sort=name&phpgw_return_as=json&owner[]=building::'
 + building_id;
             documentsURL += 
'index.php?menuaction=booking.uidocument_view.regulations&sort=name&phpgw_return_as=json&owner[]=resource::'+
 resources;
+               var attachmentsResourceURL = 
'index.php?menuaction=booking.uidocument_application.index&sort=name&no_images=1&filter_owner_id='
 + app_id + '&phpgw_return_as=json&';
         ]]>
 
                var colDefsResources = [{key: 'name', label: lang['Resources'], 
formatter: genericLink}, {key: 'type', label: lang['Resource Type']}];
@@ -577,5 +612,9 @@
                
createTable('resources_container',resourcesURL,colDefsResources);
                
createTable('associated_container',associatedURL,colDefsAssociated,'results');
                
createTable('regulation_documents',documentsURL,colDefsDocuments);
+
+               var colDefsAttachmentsResource = [{key: 'name', label: 
lang['Name'], formatter: genericLink}];
+               createTable('attachments_container', attachmentsResourceURL, 
colDefsAttachmentsResource);
+
        </script>
 </xsl:template>

Modified: 
branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php     
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/bookingfrontend/inc/class.uiapplication.inc.php     
2016-01-16 16:40:47 UTC (rev 14652)
@@ -38,8 +38,50 @@
                                $this->redirect(array('menuaction' => 
$this->url_prefix . '.show', 'id' => $application['id'],
                                        'secret' => $application['secret']));
                        }
+                       /** Start attachment **/
+                       if($_FILES)
+                       {
+                               $document_application = 
createObject('booking.uidocument_application');
 
+                               $oldfiles = 
$document_application->bo->so->read(array('filters'=> array('owner_id' => 
$application['id'])));
+                               $files = $this->get_files();
+                               $file_exist = false;
 
+                               if($oldfiles['results'])
+                               {
+                                       foreach($oldfiles['results'] as 
$old_file)
+                                       {
+                                               if($old_file['name'] == 
$files['name']['name'])
+                                               {
+                                                       $file_exist = true;
+                                                       
phpgwapi_cache::message_set(lang('file exists'));
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               $document = array(
+                                       'category'      => 'other',
+                                       'owner_id' => $application['id'],
+                                       'files' => $this->get_files()
+                               );
+                               $document_errors = 
$document_application->bo->validate($document);
+
+                               if(!$document_errors && !$file_exist)
+                               {
+                                       try
+                                       {
+                                               
booking_bocommon_authorized::disable_authorization();
+                                               $document_receipt = 
$document_application->bo->add($document);
+                                       }
+                                       catch(booking_unauthorized_exception $e)
+                                       {
+                                               
phpgwapi_cache::message_set(lang('Could not add object due to insufficient 
permissions'));
+                                       }
+                               }
+                       }
+                       /** End attachment **/
+
                        $building_info                                   = 
$this->bo->so->get_building_info($id);
                        $application['building_id']              = 
$building_info['id'];
                        $application['building_name']    = 
$building_info['name'];
@@ -83,6 +125,9 @@
                        $agegroups                                       = 
$agegroups['results'];
                        $audience                                        = 
$this->audience_bo->fetch_target_audience($top_level_activity);
                        $audience                                        = 
$audience['results'];
+
+                       phpgwapi_jquery::formvalidator_generate(array('file'), 
'file_form');
+
                        self::render_template_xsl('application', 
array('application' => $application,
                                'audience' => $audience, 'agegroups' => 
$agegroups, 'frontend' => 'true'));
                }

Added: 
branches/dev-syncromind/bookingfrontend/inc/class.uidocument_application.inc.php
===================================================================
--- 
branches/dev-syncromind/bookingfrontend/inc/class.uidocument_application.inc.php
                            (rev 0)
+++ 
branches/dev-syncromind/bookingfrontend/inc/class.uidocument_application.inc.php
    2016-01-16 16:40:47 UTC (rev 14652)
@@ -0,0 +1,20 @@
+<?php
+       phpgw::import_class('booking.uidocument_application');
+
+       class bookingfrontend_uidocument_application extends 
booking_uidocument_application
+       {
+
+               public $public_functions = array
+                       (
+                       'download'               => true,
+                       'index'                  => true,
+                       'index_images'   => true,
+               );
+               protected $module;
+
+               public function __construct()
+               {
+                       parent::__construct();
+                       $this->module = "bookingfrontend";
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/bookingfrontend/templates/base/application.xsl
===================================================================
--- branches/dev-syncromind/bookingfrontend/templates/base/application.xsl      
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/bookingfrontend/templates/base/application.xsl      
2016-01-16 16:40:47 UTC (rev 14652)
@@ -119,6 +119,37 @@
                                                </form>
                                        </dd>
                                </dl>
+                               <dl class="proplist">
+                                       <dt class="heading">
+                                               <xsl:value-of 
select="php:function('lang', 'attachments')" />
+                                       </dt>
+                                       <dd>
+                                               <div 
id="attachments_container"/>
+                                       </dd>
+                                       <dd>
+                                               <form method="POST" 
enctype='multipart/form-data' id='file_form'>
+                                                       <input name="name" 
id='field_name' type='file' >
+                                                               <xsl:attribute 
name='title'>
+                                                                       
<xsl:value-of select="document/name"/>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>mime size</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-allowing">
+                                                                       
<xsl:text>jpg, png, gif, xls, xlsx, doc, docx, txt, pdf, odt, ods</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-max-size">
+                                                                       
<xsl:text>2M</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-error-msg">
+                                                                       
<xsl:text>Max 2M:: jpg, png, gif, xls, xlsx, doc, docx, txt, pdf, odt, 
ods</xsl:text>
+                                                               </xsl:attribute>
+                                                       </input>
+                                                       <br/>
+                                                       <input type="submit" 
value="{php:function('lang', 'Add attachment')}" />
+                                               </form>
+                                       </dd>
+                               </dl>
                        </div>
                </div>
 
@@ -178,7 +209,7 @@
                                        <dd>
                                                <xsl:value-of 
select="application/building_name"/>
                                                (<a href="javascript: void(0)"
-                                               
onclick="window.open('{application/schedule_link}',
+                                                       
onclick="window.open('{application/schedule_link}',
                                  '', 
                                    'width=1048, height=600, scrollbars=yes');
                                       return false;">
@@ -477,7 +508,7 @@
                if (!resourceIds || resourceIds == "") {
                resourceIds = false;
                }
-               var lang = <xsl:value-of select="php:function('js_lang', 
'Resources', 'Resources Type', 'ID', 'Type', 'From', 'To', 'Document')" />;
+               var lang = <xsl:value-of select="php:function('js_lang', 
'Resources', 'Resources Type', 'ID', 'Type', 'From', 'To', 'Document', 'Name')" 
/>;
                var app_id = <xsl:value-of select="application/id" />;
                var building_id = <xsl:value-of 
select="application/building_id" />;
                var resources = <xsl:value-of select="application/resources" />;
@@ -487,6 +518,7 @@
             var applicationURL = 
'index.php?menuaction=bookingfrontend.uiapplication.associated&phpgw_return_as=json&filter_application_id='
 + app_id;
             var documentURL = 
'index.php?menuaction=booking.uidocument_view.regulations&sort=name&phpgw_return_as=json&owner[]=building::'
 + building_id;
                 documentURL += 
'index.php?menuaction=booking.uidocument_view.regulations&sort=name&phpgw_return_as=json&owner[]=resource::'+
 resources;
+                       var attachmentsResourceURL = 
'index.php?menuaction=bookingfrontend.uidocument_application.index&sort=name&no_images=1&filter_owner_id='
 + app_id + '&phpgw_return_as=json&';
 
         ]]>
 
@@ -504,5 +536,9 @@
 
                var colDefsDocument = [{key: 'name', label: lang['Document'], 
formatter: genericLink}];
                createTable('regulation_documents', documentURL, 
colDefsDocument);
+
+               var colDefsAttachmentsResource = [{key: 'name', label: 
lang['Name'], formatter: genericLink}];
+               createTable('attachments_container', attachmentsResourceURL, 
colDefsAttachmentsResource);
+
        </script>
 </xsl:template>

Modified: 
branches/dev-syncromind/bookingfrontend/templates/base/application_new.xsl
===================================================================
--- branches/dev-syncromind/bookingfrontend/templates/base/application_new.xsl  
2016-01-15 12:16:55 UTC (rev 14651)
+++ branches/dev-syncromind/bookingfrontend/templates/base/application_new.xsl  
2016-01-16 16:40:47 UTC (rev 14652)
@@ -6,7 +6,7 @@
                </h3>
                <xsl:call-template name="msgbox"/>
 
-               <form action="" method="POST" id='application_form' name="form">
+               <form action="" method="POST" id='application_form' 
enctype='multipart/form-data' name="form">
                        <xsl:if test="config/application_new_application">
                                <p style="width: 750px;">
                                        <xsl:value-of 
select="config/application_new_application"/>
@@ -456,6 +456,37 @@
                                                </xsl:if>
                                        </dl>
                                </div>
+                               <div class="pure-u-1 pure-u-md-1-2 
pure-u-lg-1-3">
+                                       <dl class="form-col">
+                                               <div class="heading">9. 
<xsl:value-of select="php:function('lang', 'Attachment')" /></div>
+
+                                               <dt>
+                                               <label for="field_name">
+                                                       <xsl:value-of 
select="php:function('lang', 'Document')" />
+                                               </label>
+                                               </dt>
+                                               <dd>
+                                               <input name="name" 
id='field_name' type='file' >
+                                                       <xsl:attribute 
name='title'>
+                                                               <xsl:value-of 
select="document/name"/>
+                                                       </xsl:attribute>
+                                                       <xsl:attribute 
name="data-validation">
+                                                               <xsl:text>mime 
size</xsl:text>
+                                                       </xsl:attribute>
+                                                       <xsl:attribute 
name="data-validation-allowing">
+                                                               <xsl:text>jpg, 
png, gif, xls, xlsx, doc, docx, txt, pdf, odt, ods</xsl:text>
+                                                       </xsl:attribute>
+                                                       <xsl:attribute 
name="data-validation-max-size">
+                                                               
<xsl:text>2M</xsl:text>
+                                                       </xsl:attribute>
+                                                       <xsl:attribute 
name="data-validation-error-msg">
+                                                               <xsl:text>Max 
2M:: jpg, png, gif, xls, xlsx, doc, docx, txt, pdf, odt, ods</xsl:text>
+                                                       </xsl:attribute>
+                                               </input>
+                                               </dd>
+                                       </dl>
+                               </div>
+
                        </div>
 
                        <div class="form-buttons">




reply via email to

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