fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10724] property: files at projects


From: Sigurd Nes
Subject: [Fmsystem-commits] [10724] property: files at projects
Date: Tue, 29 Jan 2013 12:20:00 +0000

Revision: 10724
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10724
Author:   sigurdne
Date:     2013-01-29 12:19:59 +0000 (Tue, 29 Jan 2013)
Log Message:
-----------
property: files at projects

Modified Paths:
--------------
    trunk/property/inc/class.boproject.inc.php
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.soworkorder.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/inc/class.uiworkorder.inc.php
    trunk/property/inc/import/default/Import_fra_BKK_csv
    trunk/property/setup/phpgw_no.lang
    trunk/property/templates/base/project.xsl
    trunk/property/templates/base/workorder.xsl

Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php  2013-01-29 11:00:46 UTC (rev 
10723)
+++ trunk/property/inc/class.boproject.inc.php  2013-01-29 12:19:59 UTC (rev 
10724)
@@ -834,7 +834,27 @@
                        return $record_history;
                }
 
+               public function get_files($id = 0)
+               {
+                       $vfs = CreateObject('phpgwapi.vfs');
+                       $vfs->override_acl = 1;
 
+                       $files = $vfs->ls(array(
+                               'string' => "/property/project/{$id}",
+                               'relatives' => array(RELATIVE_NONE)
+                       ));
+
+                       $vfs->override_acl = 0;
+
+                       $j      = count($files);
+                       for ($i=0;$i<$j;$i++)
+                       {
+                               
$files[$i]['file_name']=urlencode($files[$i]['name']);
+                       }
+                       return $files;
+               }
+
+
                function next_project_id()
                {
                        return $this->so->next_project_id();

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2013-01-29 11:00:46 UTC (rev 
10723)
+++ trunk/property/inc/class.soproject.inc.php  2013-01-29 12:19:59 UTC (rev 
10724)
@@ -710,7 +710,7 @@
 
 */
 
-                                       $_get_accounting = true;
+                                       $_get_accounting = false;
                                        if($_get_accounting)
                                        {
 

Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php        2013-01-29 11:00:46 UTC 
(rev 10723)
+++ trunk/property/inc/class.soworkorder.inc.php        2013-01-29 12:19:59 UTC 
(rev 10724)
@@ -793,7 +793,7 @@
                                        $_paid_filter = " AND (periode > 
{$filter_year}00 AND periode < {$filter_year}13 OR periode IS NULL)";
                                }
 
-                               $_get_accounting = true;
+                               $_get_accounting = false;
                                if($_get_accounting)
                                {
                                $this->db->query($sql_cost,__LINE__,__FILE__);

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2013-01-29 11:00:46 UTC (rev 
10723)
+++ trunk/property/inc/class.uiproject.inc.php  2013-01-29 12:19:59 UTC (rev 
10724)
@@ -67,6 +67,7 @@
                                'columns'                               => true,
                                'bulk_update_status'    => true,
                                'project_group'                 => true,
+                               'view_file'                             => true
                        );
 
                function property_uiproject()
@@ -132,6 +133,16 @@
                        
$this->bocommon->download($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
                }
 
+               function view_file()
+               {
+                       if(!$this->acl_read)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
+                       }
+                       $bofiles        = CreateObject('property.bofiles');
+                       $bofiles->view_file('project');
+               }
+
                function columns()
                {
                        $receipt = array();
@@ -1004,7 +1015,7 @@
                                }
                        }
 
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('project','attributes_form'));
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('project','files','attributes_form'));
                        $location_id    = 
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
                        $config                         = 
CreateObject('phpgwapi.config','property');
                        $config->read();
@@ -1279,6 +1290,44 @@
                                                        $id = $receipt['id'];
                                                }
 
+                                       //----------files
+                                               $bofiles        = 
CreateObject('property.bofiles');
+                                               
if(isset($values['file_action']) && is_array($values['file_action']))
+                                               {
+                                                       
$bofiles->delete_file("/project/{$id}/", $values);
+                                               }
+
+                                               $file_name = @str_replace(' 
','_',$_FILES['file']['name']);
+
+                                               if($file_name)
+                                               {
+                                                       $to_file = 
"{$bofiles->fakebase}/project/{$id}/{$file_name}";
+
+                                                       
if($bofiles->vfs->file_exists(array(
+                                                               'string' => 
$to_file,
+                                                               'relatives' => 
Array(RELATIVE_NONE)
+                                                       )))
+                                                       {
+                                                               
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
+                                                       }
+                                                       else
+                                                       {
+                                                               
$bofiles->create_document_dir("project/$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))))
+                                                               {
+                                                                       
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
+                                                               }
+                                                               
$bofiles->vfs->override_acl = 0;
+                                                       }
+                                               }
+                                       //-----------
+
+
                                                if ( 
isset($GLOBALS['phpgw_info']['server']['smtp_server'])
                                                        && 
$GLOBALS['phpgw_info']['server']['smtp_server'] )
        //                                              && 
$config->config_data['project_approval'] )
@@ -1956,6 +2005,57 @@
 
 
 
+//--------------files
+                       $link_file_data = array
+                       (
+                               'menuaction'    => 
'property.uiproject.view_file',
+                               'id'            => $id
+                       );
+
+                       $link_to_files 
=(isset($config->config_data['files_url'])?$config->config_data['files_url']:'');
+
+                       $link_view_file = 
$GLOBALS['phpgw']->link('/index.php',$link_file_data);
+
+                       $_files = $this->bo->get_files($id);
+                       
+                       $lang_view_file = lang('click to view file');
+                       $lang_delete_file = lang('Check to delete file');
+                       $z=0;
+                       $content_files = array();
+                       foreach( $_files as $_file )
+                       {
+                               if ($link_to_files)
+                               {
+                                       $content_files[$z]['file_name'] = "<a 
href='{$link_to_files}/{$_file['directory']}/{$_file['file_name']}' 
target=\"_blank\" title='{$lang_view_file}'>{$_file['name']}</a>";
+                               }
+                               else
+                               {
+                                       $content_files[$z]['file_name'] = "<a 
href=\"{$link_view_file}&amp;file_name={$_file['file_name']}\" 
target=\"_blank\" title=\"{$lang_view_file}\">{$_file['name']}</a>";
+                               }
+                               $content_files[$z]['delete_file'] = "<input 
type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['name']}\" 
title=\"{$lang_delete_file}\">";
+                               $z++;
+                       }                                                       
                
+
+                       $datavalues[5] = array
+                       (
+                               'name'                                  => "5",
+                               'values'                                => 
json_encode($content_files),
+                               'total_records'                 => 
count($content_files),
+                               'edit_action'                   => "''",
+                               'is_paginator'                  => 0,
+                               'footer'                                => 0
+                       );
+
+                       $myColumnDefs[5] = array
+                               (
+                                       'name'          => "5",
+                                       'values'        =>      
json_encode(array(      array('key' => 
'file_name','label'=>lang('Filename'),'sortable'=>false,'resizeable'=>true),
+                                       array('key' => 
'delete_file','label'=>lang('Delete 
file'),'sortable'=>false,'resizeable'=>true)))
+                               );
+
+//--------------files
+
+
 //     _debug_array($myButtons);die();
                        
//----------------------------------------------datatable settings--------
 
@@ -2005,7 +2105,7 @@
                                        'origin_id'             => $id
                                );
                        }
-
+                       $selected_tab = phpgw::get_var('tab', 'string', 
'REQUEST', 'general');
                        $project_type_id = isset($values['project_type_id']) && 
$values['project_type_id'] ? $values['project_type_id'] : 
$GLOBALS['phpgw_info']['user']['preferences']['property']['default_project_type'];
                        
                        $data = array
@@ -2025,7 +2125,7 @@
                                        'datatable'                             
                        => $datavalues,
                                        'myColumnDefs'                          
                => $myColumnDefs,
                                        'myButtons'                             
                        => $myButtons,
-                                       'tabs'                                  
                        => self::_generate_tabs($tabs),
+                                       'tabs'                                  
                        => self::_generate_tabs($tabs,array('documents' => 
$id?false:true, 'history' => $id?false:true),$selected_tab),
                                        'msgbox_data'                           
                => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                        'value_origin'                          
                => isset($values['origin']) ? $values['origin'] : '',
                                        'value_origin_type'                     
                => isset($origin)?$origin:'',
@@ -2191,8 +2291,6 @@
 //                     $template_vars = array();
 //                     $template_vars['datatable'] = $datatable;
 
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
-
                        $GLOBALS['phpgw']->css->validate_file('datatable');
                        $GLOBALS['phpgw']->css->validate_file('property');
                        
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
@@ -2683,15 +2781,16 @@
                        );
                }
 
-               protected function _generate_tabs($tabs_ = array(), $suppress = 
array())
+               protected function _generate_tabs($tabs_ = array(), $suppress = 
array(), $selected = 'general')
                {
                        $tabs = array
                                (
-                                       'general'               => 
array('label' => lang('general'), 'link' => '#general'),
-                                       'location'              => 
array('label' => lang('location'), 'link' => '#location'),
-                                       'budget'                => 
array('label' => lang('Time and budget'), 'link' => '#budget'),
-                                       'coordination'  => array('label' => 
lang('coordination'), 'link' => '#coordination'),
-                                       'history'               => 
array('label' => lang('history'), 'link' => '#history')
+                                       'general'               => 
array('label' => lang('general'), 'link' => '#general', 'function' => 
"set_tab('general')"),
+                                       'location'              => 
array('label' => lang('location'), 'link' => '#location', 'function' => 
"set_tab('location')"),
+                                       'budget'                => 
array('label' => lang('Time and budget'), 'link' => '#budget', 'function' => 
"set_tab('budget')"),
+                                       'coordination'  => array('label' => 
lang('coordination'), 'link' => '#coordination', 'function' => 
"set_tab('coordination')"),
+                                       'documents'             => 
array('label' => lang('documents'), 'link' => '#documents', 'function' => 
"set_tab('documents')"),
+                                       'history'               => 
array('label' => lang('history'), 'link' => '#history', 'function' => 
"set_tab('history')")
                                );
                        $tabs = array_merge($tabs, $tabs_);
                        foreach($suppress as $tab => $remove)
@@ -2703,6 +2802,6 @@
                        }
                        phpgwapi_yui::tabview_setup('project_tabview');
 
-                       return  phpgwapi_yui::tabview_generate($tabs, 
'general');
+                       return  phpgwapi_yui::tabview_generate($tabs, 
$selected);
                }
        }

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2013-01-29 11:00:46 UTC 
(rev 10723)
+++ trunk/property/inc/class.uiworkorder.inc.php        2013-01-29 12:19:59 UTC 
(rev 10724)
@@ -1055,6 +1055,11 @@
                                        
$receipt['error'][]=array('msg'=>lang('budget') . ': ' . lang('Please enter an 
integer !'));
                                }
 
+                               if(!$values['contract_sum'] && 
!$values['budget'])
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('please enter either a budget or contrakt 
sum'));
+                               }
+
                                if(isset($values['addition_rs']) && 
$values['addition_rs'] && !ctype_digit(ltrim($values['addition_rs'],'-')))
                                {
                                        
$receipt['error'][]=array('msg'=>lang('Rig addition') . ': ' . lang('Please 
enter an integer !'));
@@ -2542,11 +2547,11 @@
                {
                        $tabs = array
                                (
-                                       'general'               => 
array('label' => lang('general'), 'link' => '#general'),
-                                       'budget'                => 
array('label' => lang('Time and budget'), 'link' => '#budget'),
-                                       'coordination'  => array('label' => 
lang('coordination'), 'link' => '#coordination'),
-                                       'documents'             => 
array('label' => lang('documents'), 'link' => '#documents'),
-                                       'history'               => 
array('label' => lang('history'), 'link' => '#history')
+                                       'general'               => 
array('label' => lang('general'), 'link' => '#general', 'function' => 
"set_tab('general')"),
+                                       'budget'                => 
array('label' => lang('Time and budget'), 'link' => '#budget', 'function' => 
"set_tab('budget')"),
+                                       'coordination'  => array('label' => 
lang('coordination'), 'link' => '#coordination', 'function' => 
"set_tab('coordination')"),
+                                       'documents'             => 
array('label' => lang('documents'), 'link' => '#documents', 'function' => 
"set_tab('documents')"),
+                                       'history'               => 
array('label' => lang('history'), 'link' => '#history', 'function' => 
"set_tab('history')"),
                                );
                        $tabs = array_merge($tabs, $tabs_);
 

Modified: trunk/property/inc/import/default/Import_fra_BKK_csv
===================================================================
--- trunk/property/inc/import/default/Import_fra_BKK_csv        2013-01-29 
11:00:46 UTC (rev 10723)
+++ trunk/property/inc/import/default/Import_fra_BKK_csv        2013-01-29 
12:19:59 UTC (rev 10724)
@@ -196,7 +196,7 @@
                                        if($value < 0)
                                        {
                                                $buffer[$this->id]['artid'] = 
2;                                        
-                                               $buffer[$this->id]['bilagsnr'] 
= $this->next_bilagsnr_2();
+                                               $buffer[$this->id]['bilagsnr'] 
= $this->next_bilagsnr_2() . '_k';
                                        }
                                        else
                                        {

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2013-01-29 11:00:46 UTC (rev 10723)
+++ trunk/property/setup/phpgw_no.lang  2013-01-29 12:19:59 UTC (rev 10724)
@@ -1248,6 +1248,7 @@
 please enter a sql query !     property        no      Angi en sql-spørring
 please enter a value for either material cost, labour cost or both !   
property        no      angi enten material kostnader, arbeidskostnader eller 
begge
 please enter a workorder title !       property        no      Angi en 
bestillings tittel
+please enter either a budget or contrakt sum   property        no      Angi 
enten budsjett eller konstraktsum (eller begge)
 please enter precision as integer !    property        no      Angi heltall 
for presisjon
 please enter scale as integer !        property        no      Angi heltall 
for skalering
 please give som details !      property        no      Angi detaljer

Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl   2013-01-29 11:00:46 UTC (rev 
10723)
+++ trunk/property/templates/base/project.xsl   2013-01-29 12:19:59 UTC (rev 
10724)
@@ -41,6 +41,11 @@
                                document.add_sub_entry_form.submit();
                        }
                        var project_type_id = '<xsl:value-of 
select="project_type_id"/>';
+
+                       function set_tab(tab = '')
+                       {
+                               document.form.tab.value = tab;                  
+                       }
                </script>
                <table cellpadding="2" cellspacing="2" align="center">
                        <xsl:choose>
@@ -67,7 +72,8 @@
                                </xsl:when>
                        </xsl:choose>
                </table>
-               <form method="post" name="form" action="{form_action}">
+               <form ENCTYPE="multipart/form-data" method="post" name="form" 
action="{form_action}">
+                       <input type="hidden" name="tab" value=""/>
                        <div class="yui-navset" id="project_tabview">
                                <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
                                <div class="yui-content">
@@ -731,10 +737,28 @@
                                                        </xsl:choose>
                                                </table>
                                        </div>
-                                       <div id="history">
-                                               <div id="paging_4"> </div>
-                                               <div 
id="datatable-container_4"/>
-                                       </div>
+                                       <xsl:choose>
+                                               <xsl:when 
test="value_project_id &gt; 0">
+                                                       <div id="documents">
+                                                               <table 
cellpadding="2" cellspacing="2" width="80%" align="center">
+                                                                       <tr>
+                                                                               
<td align="left" valign="top">
+                                                                               
        <xsl:value-of select="php:function('lang', 'files')"/>
+                                                                               
</td>
+                                                                               
<td>
+                                                                               
        <div id="datatable-container_5"/>
+                                                                               
</td>
+                                                                       </tr>
+                                                                       
<xsl:call-template name="file_upload"/>
+                                                               </table>
+                                                       </div>
+                                                       <div id="history">
+                                                               <div 
id="paging_4"> </div>
+                                                               <div 
id="datatable-container_4"/>
+                                                       </div>
+                                               </xsl:when>
+                                       </xsl:choose>
+
                                        <xsl:call-template 
name="attributes_values"/>
                                </div>
                        </div>

Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2013-01-29 11:00:46 UTC (rev 
10723)
+++ trunk/property/templates/base/workorder.xsl 2013-01-29 12:19:59 UTC (rev 
10724)
@@ -88,6 +88,11 @@
                        {
                                document.send_workorder_form.submit();
                        }
+                       function set_tab(tab = '')
+                       {
+                               document.form.tab.value = tab;                  
+                       }
+
                </script>
                <table cellpadding="2" cellspacing="2" align="center">
                        <xsl:choose>
@@ -161,6 +166,7 @@
                        <xsl:value-of select="form_action"/>
                </xsl:variable>
                <form ENCTYPE="multipart/form-data" method="post" 
id='workorder_edit' name="form" action="{$form_action}">
+                       <input type="hidden" name="tab" value=""/>
                        <div class="yui-navset" id="workorder_tabview">
                                <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
                                <div class="yui-content">




reply via email to

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