phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.uis_agreement.inc.php, 1.3


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.uis_agreement.inc.php, 1.3
Date: Mon, 14 Jun 2004 21:58:29 +0200

Update of /property/inc
Modified Files:
        Branch: 
          class.uis_agreement.inc.php

date: 2004/06/14 19:58:29;  author: sigurdne;  state: Exp;  lines: +156 -36

Log Message:
no message
=====================================================================
Index: property/inc/class.uis_agreement.inc.php
diff -u property/inc/class.uis_agreement.inc.php:1.2 
property/inc/class.uis_agreement.inc.php:1.3
--- property/inc/class.uis_agreement.inc.php:1.2        Fri Jun 11 18:45:50 2004
+++ property/inc/class.uis_agreement.inc.php    Mon Jun 14 19:58:29 2004
@@ -36,7 +36,8 @@
                        'edit_attrib'   => True,
                        'columns'               => True,
                        'edit_item'             => True,
-                       'view_item'             => True
+                       'view_item'             => True,
+                       'view_file'             =>True
                );
 
                function uis_agreement()
@@ -72,6 +73,7 @@
                        $this->cat_id           = $this->bo->cat_id;
                        $this->allrows          = $this->bo->allrows;
                        $this->member_id        = $this->bo->member_id;
+                       $this->fakebase         = $this->bo->fakebase;
 
                }
 
@@ -137,6 +139,49 @@
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
                }
 
+               function view_file()
+               {
+                       if(!$this->acl_read)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
 . $this->acl2_location);
+                       }
+
+                       $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+                       $file_name      = 
urldecode(get_var('file_name',array('POST','GET')));
+                       $id             = get_var('id',array('POST','GET'));
+
+                       $file = $this->fakebase. SEP . 'service_agreement' . 
SEP . $id . SEP . $file_name;
+
+//echo 'file: ' . $file . '<br>';
+                       if($this->bo->vfs->file_exists(array(
+                               'string' => $file,
+                               'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               $filename       = current(explode('.', 
basename($file_name)));
+
+                               $filetype       = 
$this->bo->vfs->file_type(array(
+                                                       'string' => $file,
+                                                       'relatives' => 
Array(RELATIVE_NONE)));
+
+                               $size           = 
$this->bo->vfs->get_size(array(
+                                                       'string' => $file,
+                                                       'relatives' => 
Array(RELATIVE_NONE),
+                                                       'checksubdirs' => 
True));
+
+                               $browser = CreateObject('phpgwapi.browser');
+                               
$browser->content_header($filename,$filetype,$size);
+
+                               $document= $this->bo->vfs->read(array(
+                                       'string' => $file,
+                                       'relatives' => Array(RELATIVE_NONE)));
+
+                               echo $document;
+
+//                             flush();
+                       }
+               }
+
                function index()
                {
                        $this->menu->sub        = 'project';
@@ -388,24 +433,6 @@
                                        $table_header[$i]['header']     = 
$uicols['descr'][$i];
                                        $table_header[$i]['width']              
= '5%';
                                        $table_header[$i]['align']              
= 'center';
-                                       if($uicols['datatype'][$i]!='T' && 
$uicols['datatype'][$i]!='CH')
-                                       {
-                                               $table_header[$i]['sort_link']  
=true;
-                                               $table_header[$i]['sort']       
        = $this->nextmatchs->show_sort_order(array
-                                                       (
-                                                               'sort'  => 
$this->sort,
-                                                               'var'   =>      
$uicols['name'][$i],
-                                                               'order' =>      
$this->order,
-                                                               'extra'         
=> array('menuaction'   => $this->currentapp.'.uis_agreement.index',
-                                                                               
                        'query'         =>$this->query,
-                                                                               
                        'lookup'        =>$lookup,
-                                                                               
                        'district_id'   => $this->district_id,
-                                                                               
                        'start_date'    => $start_date,
-                                                                               
                        'role'                  => $this->role,
-                                                                               
                        'member_id'             => $this->member_id,
-                                                                               
                        'end_date'=>$end_date)
-                                                       ));
-                                       }
                                }
                        }
 
@@ -444,14 +471,16 @@
 
                function edit()
                {
-                       $s_agreement_id = get_var('id',array('POST','GET'));
+                       $id     = get_var('id',array('POST','GET'));
                        $values         = get_var('values',array('POST'));
                        $delete_item    = get_var('delete_item',array('GET'));
                        $item_id        = get_var('item_id',array('GET'));
 
-                       if($delete_item && $s_agreement_id && $item_id)
+                       $config         = 
CreateObject('phpgwapi.config',$this->currentapp);
+
+                       if($delete_item && $id && $item_id)
                        {
-                               
$this->bo->delete_item($s_agreement_id,$item_id);
+                               $this->bo->delete_item($id,$item_id);
                        }
 
                        $values_attribute  = 
get_var('values_attribute',array('POST'));
@@ -498,13 +527,53 @@
 //                                             
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
                                        }
 
+
+                                       if($id)
+                                       {
+                                               $values['s_agreement_id']=$id;
+                                               $action='edit';
+                                       }
+                                       else
+                                       {
+                                               
$values['s_agreement_id']=$this->bo->request_next_id();
+                                       }
+
+                                       
$values['file_name']=$_FILES['file']['name'];
+                                       $to_file = $this->fakebase. SEP . 
'service_agreement' . SEP . $values['s_agreement_id'] . SEP . 
$values['file_name'];
+
+                                       if(!$values['document_name_orig'] && 
$this->bo->vfs->file_exists(array(
+                                                       'string' => $to_file,
+                                                       'relatives' => 
Array(RELATIVE_NONE)
+                                               )))
+                                       {
+                                               
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+                                       }
+
+
                                        if(!$receipt['error'])
                                        {
-                                               $values['s_agreement_id']       
= $s_agreement_id;
-                                               $receipt = 
$this->bo->save($values,$values_attribute);
-                                               $s_agreement_id = 
$receipt['s_agreement_id'];
+//                                             $values['s_agreement_id']       
= $id;
+                                               $receipt        = 
$this->bo->create_home_dir($receipt);
+                                               $receipt = 
$this->bo->save($values,$values_attribute,$action);
+                                               $id = 
$receipt['s_agreement_id'];
                                                $this->cat_id = 
($values['cat_id']?$values['cat_id']:$this->cat_id);
 
+                                               if($values['file_name'])
+                                               {
+                                                       
$this->bo->create_document_dir($id);
+                                                       
$this->bo->vfs->override_acl = 1;
+
+                                                       if(!$this->bo->vfs->cp 
(array (
+                                                               'from'  => 
$_FILES['file']['tmp_name'],
+                                                               'to'    => 
$to_file,
+                                                               'relatives'     
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+                                                       {
+                                                               
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+                                                       }
+                                                       
$this->bo->vfs->override_acl = 0;
+                                               }
+
+
                                                if ($values['save'])
                                                {
                                                        
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement_receipt',$receipt);
@@ -539,16 +608,16 @@
                        }
 
 
-                       $s_agreement = 
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
+                       $s_agreement = 
$this->bo->read_single(array('s_agreement_id'=>$id));
 
                        $cal_info       = $this->bocommon->jscalendar();
                        $jsDateFormat=$cal_info['jsDateFormat'];
 
-                       if ($s_agreement_id)
+                       if ($id)
                        {
                                $this->cat_id = 
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
                                $this->member_id = 
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
-                               $list = 
$this->bo->read_details($s_agreement_id);
+                               $list = $this->bo->read_details($id);
 
                                $uicols         = $this->bo->uicols;
                                $list           = 
$this->list_content($list,$uicols);
@@ -581,7 +650,7 @@
                        $link_data = array
                        (
                                'menuaction'            => 
$this->currentapp.'.uis_agreement.edit',
-                               's_agreement_id'        => $s_agreement_id,
+                               'id'    => $id,
                                'role'                          => $this->role
                        );
 
@@ -634,19 +703,45 @@
                        (
                                'lang_add'                              => 
lang('add detail'),
                                'lang_add_standardtext' => lang('add an item to 
the details'),
-                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
 . $s_agreement_id)
+                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
 . $id)
                        );
 
 
-//_debug_array($content);
+                       $link_file_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uis_agreement.view_file',
+                                               'id'                    =>$id
+                                               );
+
+                       $config->read_repository();
+                       $link_to_files = $config->config_data['files_url'];
+
+                       $j      = count($s_agreement['files']);
+                       for ($i=0;$i<$j;$i++)
+                       {
+                               
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
+                       }
 
 
                        $data = array
                        (
+
+                               'fileupload'                                    
=> True,
+                               'link_view_file'                                
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+                               'link_to_files'                                 
=> $link_to_files,
+                               'files'                                         
        => $s_agreement['files'],
+                               'lang_files'                                    
=> lang('files'),
+                               'lang_filename'                                 
=> lang('Filename'),
+                               'lang_delete_file'                              
=> lang('Delete file'),
+                               'lang_view_file_statustext'             => 
lang('Klick to view file'),
+                               'lang_delete_file_statustext'   => lang('Check 
to delete file'),
+                               'lang_upload_file'                              
=> lang('Upload file'),
+                               'lang_file_statustext'                  => 
lang('Select file to upload'),
+
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'edit_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'lang_id'                                       
        => lang('ID'),
-                               'value_s_agreement_id'                  => 
$s_agreement_id,
+                               'value_s_agreement_id'                  => $id,
                                'lang_category'                                 
=> lang('category'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_cancel'                                   
=> lang('cancel'),
@@ -702,7 +797,7 @@
                                'table_header'                                  
=> $table_header,
                                'acl_manage'                                    
=> $this->acl_manage,
                                'table_update'                                  
=> $table_update,
-                               'update_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&s_agreement_id='
 . $s_agreement_id),
+                               'update_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uis_agreement.edit&id='
 . $id),
                                'lang_select_all'                               
=> lang('Select All'),
                                'img_check'                                     
        => 
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
                                'check_source'                                  
=> './'.$this->currentapp.'/inc/check.js',
@@ -711,7 +806,7 @@
 
                        );
 
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('service agreement') . ': ' . ($s_agreement_id?lang('edit') . ' ' . 
lang($this->role):lang('add') . ' ' . lang($this->role));
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('service agreement') . ': ' . ($id?lang('edit') . ' ' . 
lang($this->role):lang('add') . ' ' . lang($this->role));
 
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }
@@ -1137,6 +1232,7 @@
                function view()
                {
                        $s_agreement_id = get_var('id',array('POST','GET'));
+                       $config         = 
CreateObject('phpgwapi.config',$this->currentapp);
 
                        
$GLOBALS['phpgw']->xslttpl->add_file(array('s_agreement','attributes_view'));
 
@@ -1151,7 +1247,7 @@
                                $list = 
$this->bo->read_details($s_agreement_id);
 
                                $uicols         = $this->bo->uicols;
-                               $list           = 
$this->list_content($list,$uicols,$view_only=True);
+                               $list           = 
$this->list_content($list,$uicols,$edit_item=False,$view_only=True);
                                $content        = $list['content'];
                                $table_header=$list['table_header'];
                        }
@@ -1183,9 +1279,33 @@
 
                        $member_of_data = 
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals' 
=> True));
 
+                       $link_file_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uis_agreement.view_file',
+                                               'id'                    
=>$s_agreement_id
+                                               );
+
+
+                       $config->read_repository();
+                       $link_to_files = $config->config_data['files_url'];
+
+                       $j      = count($s_agreement['files']);
+                       for ($i=0;$i<$j;$i++)
+                       {
+                               
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
+                       }
+
 
                        $data = array
                        (
+
+                               'link_view_file'                                
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+                               'link_to_files'                                 
=> $link_to_files,
+                               'files'                                         
        => $s_agreement['files'],
+                               'lang_files'                                    
=> lang('files'),
+                               'lang_filename'                                 
=> lang('Filename'),
+                               'lang_view_file_statustext'             => 
lang('Klick to view file'),
+
                                'edit_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'lang_id'                                       
        => lang('ID'),
                                'value_s_agreement_id'                  => 
$s_agreement_id,




reply via email to

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