phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc class.soproject.inc.php, 1.16 class.bopr


From: sigurdne
Subject: [Phpgroupware-cvs] property/inc class.soproject.inc.php, 1.16 class.boproject.inc.php, 1.8 class.soentity.inc.php, 1.6 class.uientity.inc.php, 1.8 class.borequest.inc.php, 1.4 class.sorequest.inc.php, 1.5 class.uiproject.inc.php, 1.13 class.uirequest.inc.php, 1.9 class.uitts.inc.php, 1.11 class.bocommon.inc.php, 1.9 class.sotts.inc.php, 1.5
Date: Tue, 1 Mar 2005 16:04:00 +0100

Update of property/inc

Modified Files:
     Branch: MAIN
            class.soproject.inc.php lines: +18 -59
            class.boproject.inc.php lines: +1 -6
            class.soentity.inc.php lines: +23 -14
            class.uientity.inc.php lines: +73 -30
            class.borequest.inc.php lines: +132 -2
            class.sorequest.inc.php lines: +38 -15
            class.uiproject.inc.php lines: +38 -51
            class.uirequest.inc.php lines: +209 -34
            class.uitts.inc.php lines: +31 -3
            class.bocommon.inc.php lines: +28 -1
            class.sotts.inc.php lines: +25 -67

Log Message:
no message

====================================================
Index: property/inc/class.soproject.inc.php
diff -u property/inc/class.soproject.inc.php:1.15 
property/inc/class.soproject.inc.php:1.16
--- property/inc/class.soproject.inc.php:1.15   Fri Feb 25 14:05:30 2005
+++ property/inc/class.soproject.inc.php        Tue Mar  1 15:04:27 2005
@@ -356,7 +356,7 @@
                                }
                        }

-                       $sql = "SELECT * FROM fm_project_origin WHERE 
project_id='$project_id' ORDER by origin DESC  ";
+                       $sql = "SELECT * FROM fm_origin WHERE destination = 
'project' AND destination_id='$project_id' ORDER by origin DESC  ";

                        $this->db->query($sql,__LINE__,__FILE__);

@@ -368,7 +368,7 @@
                                        $i++;
                                }
                                $project['origin'][$i]['type'] = 
$this->db->f('origin');
-                               $project['origin'][$i]['link'] = 
$this->get_origin_link($this->db->f('origin'));
+                               $project['origin'][$i]['link'] = 
$this->bocommon->get_origin_link($this->db->f('origin'));
                                $project['origin'][$i]['data'][]= array(
                                        'id'=> $this->db->f('origin_id'),
                                        'type'=> $this->db->f('origin')
@@ -377,59 +377,13 @@
                                $last_type=$this->db->f('origin');
                        }

-                       $sql = "SELECT * FROM fm_project_origin WHERE 
project_id='$project_id' and origin ='request'";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $i=0;
-                       while ($this->db->next_record())
-                       {
-                               $project['request_id'][$i]['id']        = 
$this->db->f('origin_id');
-                               $i++;
-                       }
-
-                       $sql = "SELECT * FROM fm_project_origin WHERE 
project_id='$project_id' and origin ='tts'";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       while ($this->db->next_record())
-                       {
-                               $project['ticket_id'][$i]['id'] = 
$this->db->f('origin_id');
-                               $i++;
-                       }
-
-
 //_debug_array($project);
                                return $project;
                }

-
-               function get_origin_link($type)
-               {
-                       if($type=='tts'):
-                       {
-                               $link = '.uitts.view';
-                       }
-                       elseif($type=='request'):
-                       {
-                               $link = '.uirequest.view';
-                       }
-                       elseif(substr($type,0,6)=='entity'):
-                       {
-
-                               $type           = explode("_",$type);
-                               $entity_id      = $type[1];
-                               $cat_id         = $type[2];
-                               $link = 
".uientity.view&entity_id=$entity_id&cat_id=$cat_id";
-                       }
-                       endif;
-
-                       return $link;
-               }
-
                function get_ticket($project_id = '')
                {
-                       $sql = "SELECT * FROM fm_project_origin WHERE 
project_id='$project_id' and origin ='tts'";
+                       $sql = "SELECT * FROM fm_origin WHERE origin ='tts' AND 
destination = 'project' AND destination_id='$project_id' ORDER by origin DESC  
";
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->next_record();
                        return $this->db->f('origin_id');
@@ -592,11 +546,13 @@

                        if($project['origin'][0]['data'][0]['id'])
                        {
-                               $this->db->query("INSERT INTO  
fm_project_origin (origin,origin_id,project_id,entry_date) "
+                               $this->db->query("INSERT INTO  fm_origin 
(origin,origin_id,destination,destination_id,user_id,entry_date) "
                                        . "VALUES ('"
                                        . $project['origin'][0]['type']. "','"
                                        . 
$project['origin'][0]['data'][0]['id']. "',"
+                                       . "'project',"
                                        . $project['project_id']. ","
+                                       . $this->account . ","
                                        . time() . ")",__LINE__,__FILE__);
                        }

@@ -824,7 +780,7 @@
                        for ($i=0;$i<count($request_id);$i++)
                        {
                                $this->db2->query("update fm_request set 
project_id = NULL where id='". $request_id[$i] . "'",__LINE__,__FILE__);
-                               $this->db->query("DELETE FROM fm_project_origin 
WHERE origin_id='" . $request_id[$i] . "' AND 
origin='request'",__LINE__,__FILE__);
+                               $this->db->query("DELETE FROM fm_origin WHERE 
destination ='project' AND origin_id='" . $request_id[$i] . "' AND 
origin='request'",__LINE__,__FILE__);
                                $receipt['message'][] = 
array('msg'=>lang('Request %1 has been deleted from project 
%2',$request_id[$i],$project_id));
                        }
                        return $receipt;
@@ -835,7 +791,8 @@
                {
                        $historylog_r   = 
CreateObject($this->currentapp.'.historylog','request');

-                       $sql = "SELECT origin_id FROM fm_project_origin WHERE 
project_id='$project_id' and origin ='request'";
+                       $sql = "SELECT origin_id FROM fm_origin WHERE 
destination ='project' AND destination_id='$project_id' and origin ='request'";
+//                     $sql = "SELECT origin_id FROM fm_project_origin WHERE 
project_id='$project_id' and origin ='request'";
                        $this->db->query($sql,__LINE__,__FILE__);

                        while ($this->db->next_record())
@@ -875,7 +832,7 @@

                function check_request($request_id)
                {
-                       $sql = "SELECT project_id FROM fm_project_origin WHERE 
origin_id='$request_id' and origin ='request'";
+                       $sql = "SELECT project_id FROM fm_origin WHERE 
destination ='project' AND origin_id='$request_id' and origin ='request'";
                        $this->db->query($sql,__LINE__,__FILE__);

                        $this->db->next_record();
@@ -895,10 +852,13 @@

                                if(!$project_id)
                                {
-                                       $this->db->query("INSERT INTO  
fm_project_origin (origin,origin_id,project_id) "
+                                       $this->db->query("INSERT INTO  
fm_origin (origin,origin_id,destination,destination_id,user_id,entry_date) "
                                                . "VALUES ('request','"
                                                . 
$add_request['request_id'][$i]. "','"
-                                               . $id. "')",__LINE__,__FILE__);
+                                               . "project',"
+                                               . $id . ","
+                                               . $this->account . ","
+                                               . time() . 
")",__LINE__,__FILE__);

                                        $this->db2->query("update fm_request 
set project_id='$id' where id='". $add_request['request_id'][$i] . 
"'",__LINE__,__FILE__);

@@ -916,8 +876,7 @@

                function delete($project_id )
                {
-
-                       $sql = "SELECT origin_id FROM fm_project_origin WHERE 
project_id='$project_id' and origin ='request'";
+                       $sql = "SELECT origin_id FROM fm_origin WHERE 
destination ='project' AND destination_id='$project_id' and origin ='request'";
                        $this->db->query($sql,__LINE__,__FILE__);

                        while ($this->db->next_record())
@@ -945,7 +904,7 @@
                        $this->db->query("DELETE FROM fm_project WHERE id='" . 
$project_id . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_project_history  WHERE 
 history_record_id='" . $project_id   . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_projectbranch  WHERE  
project_id='" . $project_id   . "'",__LINE__,__FILE__);
-                       $this->db->query("DELETE FROM fm_project_origin WHERE 
project_id='" . $project_id . "'",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM fm_origin WHERE 
destination ='project' AND destination_id ='" . $project_id . 
"'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_workorder WHERE 
project_id='" . $project_id . "'",__LINE__,__FILE__);

                        for ($i=0;$i<count($workorder_id);$i++)

====================================================
Index: property/inc/class.boproject.inc.php
diff -u property/inc/class.boproject.inc.php:1.7 
property/inc/class.boproject.inc.php:1.8
--- property/inc/class.boproject.inc.php:1.7    Fri Feb 25 13:19:54 2005
+++ property/inc/class.boproject.inc.php        Tue Mar  1 15:04:27 2005
@@ -573,10 +573,5 @@
                        $this->so->delete($project_id);
                }

-               function get_origin_link($origin)
-               {
-                       return $this->so->get_origin_link($origin);
-               }
-
        }
 ?>

====================================================
Index: property/inc/class.soentity.inc.php
diff -u property/inc/class.soentity.inc.php:1.5 
property/inc/class.soentity.inc.php:1.6
--- property/inc/class.soentity.inc.php:1.5     Fri Feb  4 15:14:59 2005
+++ property/inc/class.soentity.inc.php Tue Mar  1 15:04:27 2005
@@ -435,15 +435,24 @@
                                        }
                                }

-                               $sql = "SELECT * FROM fm_entity_origin WHERE 
entity_id = $entity_id AND cat_id = $cat_id AND id =$id";
-
+                               $sql = "SELECT * FROM fm_origin WHERE 
destination ='entity_" . $entity_id . '_' . $cat_id . "' AND destination_id = 
$id";
                                $this->db->query($sql,__LINE__,__FILE__);
-                               $i=0;
+
+                               $i=-1;
                                while ($this->db->next_record())
                                {
-                                       $entity['origin'][$i]['id']             
= $this->db->f('origin_id');
-                                       $entity['origin'][$i]['type']   = 
$this->db->f('origin');
-                                       $i++;
+                                       if($last_type != $this->db->f('origin'))
+                                       {
+                                               $i++;
+                                       }
+                                       $entity['origin'][$i]['type'] = 
$this->db->f('origin');
+                                       $entity['origin'][$i]['link'] = 
$this->bocommon->get_origin_link($this->db->f('origin'));
+                                       $entity['origin'][$i]['data'][]= array(
+                                               'id'=> 
$this->db->f('origin_id'),
+                                               'type'=> $this->db->f('origin')
+                                               );
+
+                                       $last_type=$this->db->f('origin');
                                }
                        }

@@ -560,15 +569,15 @@
                                . time() . ","
                                . $this->account. " $vals)",__LINE__,__FILE__);

-                       if($values['origin_type'] && $values['origin_id'])
+                       if($values['origin'][0]['data'][0]['id'])
                        {
-                               $this->db->query("INSERT INTO fm_entity_origin 
(origin,origin_id,entity_id,cat_id,id,entry_date) "
+                               $this->db->query("INSERT INTO fm_origin 
(origin,origin_id,destination,destination_id,user_id,entry_date) "
                                        . "VALUES ('"
-                                       . $values['origin_type']. "',"
-                                       . $values['origin_id']. ","
-                                       . $entity_id. ","
-                                       . $cat_id. ","
+                                       . $values['origin'][0]['type']. "',"
+                                       . 
$values['origin'][0]['data'][0]['id']. ","
+                                       . "'entity_" . $entity_id .'_' . 
$cat_id . "',"
                                        . $values['id']. ","
+                                       . $this->account. ","
                                        . time() . ")",__LINE__,__FILE__);
                        }

@@ -641,7 +650,7 @@
                        $table='fm_entity_' . $entity_id .'_' . $cat_id;
                        $this->db->transaction_begin();
                        $this->db->query("DELETE FROM $table WHERE 
id=$id",__LINE__,__FILE__);
-                       $this->db->query("DELETE FROM fm_entity_origin WHERE 
entity_id=$entity_id AND cat_id=$cat_id AND id=$id",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM fm_origin WHERE 
destination ='entity_" . $entity_id . '_' . $cat_id . "' AND 
destination_id=$id",__LINE__,__FILE__);
                        $this->db->transaction_commit();
                }
        }

====================================================
Index: property/inc/class.uientity.inc.php
diff -u property/inc/class.uientity.inc.php:1.7 
property/inc/class.uientity.inc.php:1.8
--- property/inc/class.uientity.inc.php:1.7     Thu Jan 13 16:52:48 2005
+++ property/inc/class.uientity.inc.php Tue Mar  1 15:04:27 2005
@@ -581,6 +581,11 @@
                                $values['p'][$p_entity_id]['p_cat_id']          
        = $p_cat_id;
                                $values['p'][$p_entity_id]['p_num']             
                = get_var('p_num',array('POST','GET'));

+
+                               $origin                         = 
get_var('origin',array('POST','GET'));
+                               $origin_id                      = 
get_var('origin_id',array('POST','GET'));
+
+
                                if($p_entity_id && $p_cat_id)
                                {
                                        $entity_category = 
$this->boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
@@ -595,16 +600,22 @@

                        }

-                       if($ticket_id)
+                       if($values['origin'])
                        {
-                               $values['origin'][0]['type']= 'tts';
-                               $values['origin'][0]['id']= $ticket_id;
+                               $origin         = $values['origin'];
+                               $origin_id      = $values['origin_id'];
                        }

-                       if($request_id)
+                       if($origin)
                        {
-                               $values['origin'][0]['type']= 'request';
-                               $values['origin'][0]['id']= $request_id;
+                               unset($values['origin']);
+                               unset($values['origin_id']);
+                               $values['origin'][0]['type']= $origin;
+                               
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
+                               $values['origin'][0]['data'][]= array(
+                                       'id'=> $origin_id,
+                                       'type'=> $origin
+                                       );
                        }

                        if($tenant_id)
@@ -816,15 +827,6 @@
                                        break;
                        }

-                       if(is_array($values['origin']))
-                       {
-                               for ($i=0;$i<count($values['origin']);$i++)
-                               {
-                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui'.$values['origin'][$i]['type'].'.view');
-                                       
$values['origin'][$i]['name']=lang($values['origin'][$i]['type']);
-                               }
-                       }
-
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

                        $link_file_data = array
@@ -859,6 +861,29 @@
                                'origin_id'                     => $id
                        );

+//_debug_array($values['origin']);
+                       for ($i=0;$i<count($values['origin']);$i++)
+                       {
+                               
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
+                               
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+                               {
+                                       $type           = 
explode("_",$values['origin'][$i]['type']);
+                                       $entity_id      = $type[1];
+                                       $cat_id         = $type[2];
+
+                                       if(!is_object($boadmin_entity))
+                                       {
+                                               $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                       }
+                                       $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                       $values['origin'][$i]['descr'] = 
$entity_category['name'];
+                               }
+                               else
+                               {
+                                       $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
+                               }
+                       }
+
                        $data = array
                        (
                                'start_project'                                 
=> $category['start_project'],
@@ -876,9 +901,9 @@
                                'lang_upload_file'                              
=> lang('Upload file'),
                                'lang_file_statustext'                  => 
lang('Select file to upload'),

-                               'origin_list'                                   
=> $values['origin'],
-                               'value_origin_type'                             
=> $values['origin'][0]['type'],
-                               'value_origin_id'                               
=> $values['origin'][0]['id'],
+                               'value_origin'                                  
=> $values['origin'],
+                               'value_origin_type'                             
=> $origin,
+                               'value_origin_id'                               
=> $origin_id,

                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category. To do not use a category select NO CATEGORY'),
@@ -1058,15 +1083,6 @@

                        $dateformat= (implode($sep,$dlarr));

-                       if(is_array($values['origin']))
-                       {
-                               for ($i=0;$i<count($values['origin']);$i++)
-                               {
-                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui'.$values['origin'][$i]['type'].'.view');
-                                       
$values['origin'][$i]['name']=lang($values['origin'][$i]['type']);
-                               }
-                       }
-
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

                        $link_file_data = array
@@ -1078,7 +1094,6 @@
                                                'entity_id'             
=>$this->entity_id
                                                );

-
                        $config->read_repository();
                        $link_to_files = $config->config_data['files_url'];

@@ -1088,6 +1103,31 @@
                                
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
                        }

+                       if(is_array($values['origin']))
+                       {
+                               for ($i=0;$i<count($values['origin']);$i++)
+                               {
+                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
+                                       
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+                                       {
+                                               $type           = 
explode("_",$values['origin'][$i]['type']);
+                                               $entity_id      = $type[1];
+                                               $cat_id         = $type[2];
+
+                                               if(!is_object($boadmin_entity))
+                                               {
+                                                       $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               }
+                                               $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                               $values['origin'][$i]['descr'] 
= $entity_category['name'];
+                                       }
+                                       else
+                                       {
+                                               $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
+                                       }
+                               }
+                       }
+
                        $data = array
                        (
                                'link_view_file'                                
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
@@ -1097,7 +1137,10 @@
                                'lang_filename'                                 
=> lang('Filename'),
                                'lang_view_file_statustext'             => 
lang('Klick to view file'),

-                               'origin_list'                                   
=> $values['origin'],
+                               'value_origin'                                  
=> $values['origin'],
+                               'value_origin_type'                             
=> $origin,
+                               'value_origin_id'                               
=> $origin_id,
+
                                'lang_entity'                                   
=> lang('entity'),
                                'entity_name'                                   
=> $entity['name'],
                                'lang_category'                                 
=> lang('category'),

====================================================
Index: property/inc/class.borequest.inc.php
diff -u property/inc/class.borequest.inc.php:1.3 
property/inc/class.borequest.inc.php:1.4
--- property/inc/class.borequest.inc.php:1.3    Thu Jan 13 16:52:48 2005
+++ property/inc/class.borequest.inc.php        Tue Mar  1 15:04:27 2005
@@ -50,6 +50,9 @@
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->solocation       = 
CreateObject($this->currentapp.'.solocation');
                        $this->historylog       = 
CreateObject($this->currentapp.'.historylog','request');
+                       $this->vfs                      = 
CreateObject('phpgwapi.vfs');
+                       $this->rootdir          = $this->vfs->basedir;
+                       $this->fakebase         = $this->vfs->fakebase;

                        if ($session)
                        {
@@ -121,6 +124,87 @@
                        $this->status_id        = $data['status_id'];
                }

+
+               function create_home_dir($receipt='')
+               {
+                       if(!$this->vfs->file_exists(array(
+                                       'string' => $this->fakebase. SEP . 
'request',
+                                       'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               $this->vfs->override_acl = 1;
+
+                               if(!$this->vfs->mkdir (array(
+                                    'string' => $this->fakebase. SEP . 
'request',
+                                    'relatives' => array(
+                                         RELATIVE_NONE
+                                    )
+                               )))
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'. 
$this->fakebase. SEP . 'request');
+                               }
+                               else
+                               {
+                                       
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'. 
$this->fakebase. SEP . 'request');
+                               }
+                               $this->vfs->override_acl = 0;
+                       }
+
+                       return $receipt;
+               }
+
+               function create_document_dir($location_code='',$id='')
+               {
+                       if(!$this->vfs->file_exists(array(
+                                       'string' => $this->fakebase. SEP . 
'request' .  SEP . $location_code,
+                                       'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               $this->vfs->override_acl = 1;
+                               if(!$this->vfs->mkdir (array(
+                                    'string' => $this->fakebase. SEP . 
'request' .  SEP . $location_code,
+                                    'relatives' => array(
+                                         RELATIVE_NONE
+                                    )
+                               )))
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'. 
$this->fakebase. SEP . 'request' .  SEP . $location_code);
+                               }
+                               else
+                               {
+                                       
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'. 
$this->fakebase. SEP . 'request' .  SEP . $location_code);
+                               }
+                               $this->vfs->override_acl = 0;
+                       }
+
+
+                       if(!$this->vfs->file_exists(array(
+                                       'string' => $this->fakebase. SEP . 
'request' .  SEP . $location_code .  SEP . $id,
+                                       'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               $this->vfs->override_acl = 1;
+                               if(!$this->vfs->mkdir (array(
+                                    'string' => $this->fakebase. SEP . 
'request' .  SEP . $location_code .  SEP . $id,
+                                    'relatives' => array(
+                                         RELATIVE_NONE
+                                    )
+                               )))
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'. 
$this->fakebase. SEP  . 'request'  .  SEP . $location_code .  SEP . $id);
+                               }
+                               else
+                               {
+                                       
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'. 
$this->fakebase. SEP . 'request' .  SEP . $location_code .  SEP . $id);
+                               }
+                               $this->vfs->override_acl = 0;
+                       }
+
+//_debug_array($receipt);
+                       return $receipt;
+               }
+
+
                function 
select_degree_list($degree_value='',$degreedefault_type='')
                {
                        if ($degree_value)
@@ -452,6 +536,20 @@
                                
$request['p'][$request['p_entity_id']]['p_cat_id']=$request['p_cat_id'];
                                
$request['p'][$request['p_entity_id']]['p_cat_name'] = $category['name'];
                        }
+
+                       $this->vfs->override_acl = 1;
+
+                       $request['files'] = $this->vfs->ls (array(
+                            'string' => $this->fakebase. '/' . 'request' . '/' 
. $request['location_code'] .  '/' . $request_id,
+                            'relatives' => array(RELATIVE_NONE)));
+
+                       $this->vfs->override_acl = 0;
+
+                       if(!$request['files'][0]['file_id'])
+                       {
+                               unset($request['files']);
+                       }
+
                        return $request;
                }

@@ -549,7 +647,39 @@
 //_debug_array($request);
                        if ($action=='edit')
                        {
-                                       $receipt = $this->so->edit($request);
+                               $receipt = $this->so->edit($request);
+
+                               if($values['delete_file'])
+                               {
+                                       for 
($i=0;$i<count($values['delete_file']);$i++)
+                                       {
+                                               $file = $this->fakebase. SEP . 
'request' . SEP . $request['location_code'] . SEP . $values['id'] . SEP . 
$values['delete_file'][$i];
+
+                                               
if($this->vfs->file_exists(array(
+                                                               'string' => 
$file,
+                                                               'relatives' => 
Array(RELATIVE_NONE)
+                                                       )))
+                                               {
+                                                       
$this->vfs->override_acl = 1;
+
+                                                       if(!$this->vfs->rm 
(array(
+                                                               'string' => 
$file,
+                                                            'relatives' => 
array(
+                                                                 RELATIVE_NONE
+                                                            )
+                                                       )))
+                                                       {
+                                                               
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'. 
$this->fakebase. SEP . 'request' . SEP . $request['location_code']. SEP . 
$values['id'] . SEP .$values['delete_file'][$i]);
+                                                       }
+                                                       else
+                                                       {
+                                                               
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'. 
$this->fakebase. SEP . 'request' . SEP . $request['location_code']. SEP . 
$values['id'] . SEP . $values['delete_file'][$i]);
+                                                       }
+                                                       
$this->vfs->override_acl = 0;
+                                               }
+                                       }
+                               }
+
                        }
                        else
                        {

====================================================
Index: property/inc/class.sorequest.inc.php
diff -u property/inc/class.sorequest.inc.php:1.4 
property/inc/class.sorequest.inc.php:1.5
--- property/inc/class.sorequest.inc.php:1.4    Mon Jan 24 11:41:31 2005
+++ property/inc/class.sorequest.inc.php        Tue Mar  1 15:04:27 2005
@@ -375,28 +375,48 @@
                                $request['power_meter'] = 
$this->soproject->get_power_meter($this->db->f('location_code'));
                        }

-
-                       $sql = "SELECT * FROM fm_request_origin WHERE 
request_id='$request_id'";
+                       $sql = "SELECT * FROM fm_origin WHERE destination = 
'request' AND destination_id='$request_id' ORDER by origin DESC  ";

                        $this->db->query($sql,__LINE__,__FILE__);

-                       if ($this->db->next_record())
+                       $i=-1;
+                       while ($this->db->next_record())
                        {
-                               $request['origin_id']   = 
$this->db->f('origin_id');
-                               $request['origin']              = 
$this->db->f('origin');
+                               if($last_type != $this->db->f('origin'))
+                               {
+                                       $i++;
+                               }
+                               $request['origin'][$i]['type'] = 
$this->db->f('origin');
+                               $request['origin'][$i]['link'] = 
$this->bocommon->get_origin_link($this->db->f('origin'));
+                               $request['origin'][$i]['data'][]= array(
+                                       'id'=> $this->db->f('origin_id'),
+                                       'type'=> $this->db->f('origin')
+                                       );
+
+                               $last_type=$this->db->f('origin');
                        }

-                       $sql = "SELECT * FROM fm_project_origin WHERE 
origin_id='$request_id' and origin ='request'";
+                       $sql = "SELECT * FROM fm_origin WHERE origin = 
'request' AND origin_id='$request_id' ORDER by destination DESC  ";

                        $this->db->query($sql,__LINE__,__FILE__);

                        while ($this->db->next_record())
                        {
-                               $request['project_id'][]['id']  = 
$this->db->f('project_id');
+                               if($last_type != $this->db->f('destination'))
+                               {
+                                       $i++;
+                               }
+                               $request['origin'][$i]['type'] = 
$this->db->f('destination');
+                               $request['origin'][$i]['link'] = 
$this->bocommon->get_origin_link($this->db->f('destination'));
+                               $request['origin'][$i]['data'][]= array(
+                                       'id'=> $this->db->f('destination_id'),
+                                       'type'=> $this->db->f('destination')
+                                       );
+
+                               $last_type=$this->db->f('destination');
                        }

-//_debug_array($request);
-                               return $request;
+                       return $request;
                }

                function request_workorder_data($request_id = '')
@@ -539,16 +559,19 @@
                                
$this->soproject->update_power_meter($request['power_meter'],$request['location_code'],$address);
                        }

-                       if($request['origin'] && $request['origin_id'])
+                       if($request['origin'][0]['data'][0]['id'])
                        {
-                               $this->db->query("INSERT INTO  
fm_request_origin (origin,origin_id,request_id,entry_date) "
+                               $this->db->query("INSERT INTO fm_origin 
(origin,origin_id,destination,destination_id,user_id,entry_date) "
                                        . "VALUES ('"
-                                       . $request['origin']. "','"
-                                       . $request['origin_id']. "',"
+                                       . $request['origin'][0]['type']. "','"
+                                       . 
$request['origin'][0]['data'][0]['id']. "',"
+                                       . "'request',"
                                        . $request['request_id']. ","
+                                       . $this->account . ","
                                        . time() . ")",__LINE__,__FILE__);
                        }

+
                        if($this->db->transaction_commit())
                        {
                                $this->increment_request_id();
@@ -684,7 +707,7 @@
                {
                        $this->db->query("DELETE FROM fm_request WHERE id='" . 
$request_id . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_request_history  WHERE 
 history_record_id='" . $request_id   . "'",__LINE__,__FILE__);
-                       $this->db->query("DELETE FROM fm_request_origin WHERE 
request_id='" . $request_id . "'",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM fm_origin WHERE 
destination = 'request' AND destination_id='" . $request_id . 
"'",__LINE__,__FILE__);
                }
        }
 ?>

====================================================
Index: property/inc/class.uiproject.inc.php
diff -u property/inc/class.uiproject.inc.php:1.12 
property/inc/class.uiproject.inc.php:1.13
--- property/inc/class.uiproject.inc.php:1.12   Fri Feb 25 13:19:54 2005
+++ property/inc/class.uiproject.inc.php        Tue Mar  1 15:04:27 2005
@@ -576,7 +576,6 @@
                                $location_code          = 
get_var('location_code',array('POST','GET'));
                                $tenant_id                      = 
get_var('tenant_id',array('POST','GET'));
                                $values['descr']        = 
get_var('descr',array('POST','GET'));
-                               $request_id             = 
get_var('request_id',array('POST','GET'));
                                $p_entity_id            = 
get_var('p_entity_id',array('POST','GET'));
                                $p_cat_id                       = 
get_var('p_cat_id',array('POST','GET'));
                                $values['p'][$p_entity_id]['p_entity_id']       
        = $p_entity_id;
@@ -616,7 +615,7 @@
                                unset($values['origin']);
                                unset($values['origin_id']);
                                $values['origin'][0]['type']= $origin;
-                               
$values['origin'][0]['link']=$this->bo->get_origin_link($origin);
+                               
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
                                $values['origin'][0]['data'][]= array(
                                        'id'=> $origin_id,
                                        'type'=> $origin
@@ -929,28 +928,31 @@
                        $jsDateFormat=$cal_info['jsDateFormat'];


-                       for ($i=0;$i<count($values['origin']);$i++)
+                       if (isset($values['origin']) AND 
is_array($values['origin']))
                        {
-                               
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
-                               
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+                               for ($i=0;$i<count($values['origin']);$i++)
                                {
-                                       $type           = 
explode("_",$values['origin'][$i]['type']);
-                                       $entity_id      = $type[1];
-                                       $cat_id         = $type[2];
-
-                                       if(!is_object($boadmin_entity))
+                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
+                                       
if(substr($values['origin'][$i]['type'],0,6)=='entity')
                                        {
-                                               $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               $type           = 
explode("_",$values['origin'][$i]['type']);
+                                               $entity_id      = $type[1];
+                                               $cat_id         = $type[2];
+
+                                               if(!is_object($boadmin_entity))
+                                               {
+                                                       $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               }
+                                               $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                               $values['origin'][$i]['descr'] 
= $entity_category['name'];
                                        }
-                                       $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
-                                       $values['origin'][$i]['descr'] = 
$entity_category['name'];
-                               }
-                               else
-                               {
-                                       $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
-                                       if($values['origin'][$i]['type'] == 
'request')
+                                       else
                                        {
-                                               $selected_request = True;
+                                               $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
+                                               
if($values['origin'][$i]['type'] == 'request')
+                                               {
+                                                       $selected_request = 
True;
+                                               }
                                        }
                                }
                        }
@@ -1222,29 +1224,27 @@
 //_debug_array($values);
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

-
-                       for ($i=0;$i<count($values['origin']);$i++)
+                       if (isset($values['origin']) AND 
is_array($values['origin']))
                        {
-                               
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
-                               
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+                               for ($i=0;$i<count($values['origin']);$i++)
                                {
-                                       $type           = 
explode("_",$values['origin'][$i]['type']);
-                                       $entity_id      = $type[1];
-                                       $cat_id         = $type[2];
-
-                                       if(!is_object($boadmin_entity))
+                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
+                                       
if(substr($values['origin'][$i]['type'],0,6)=='entity')
                                        {
-                                               $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               $type           = 
explode("_",$values['origin'][$i]['type']);
+                                               $entity_id      = $type[1];
+                                               $cat_id         = $type[2];
+
+                                               if(!is_object($boadmin_entity))
+                                               {
+                                                       $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               }
+                                               $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                               $values['origin'][$i]['descr'] 
= $entity_category['name'];
                                        }
-                                       $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
-                                       $values['origin'][$i]['descr'] = 
$entity_category['name'];
-                               }
-                               else
-                               {
-                                       $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
-                                       if($values['origin'][$i]['type'] == 
'request')
+                                       else
                                        {
-                                               $selected_request = True;
+                                               $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
                                        }
                                }
                        }
@@ -1253,23 +1253,10 @@
                        (
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),

-
                                'value_origin'                                  
=> $values['origin'],
                                'value_origin_type'                             
=> $origin,
                                'value_origin_id'                               
=> $origin_id,
-                               'selected_request'                              
=> $selected_request,
-

-/*                             'lang_ticket'                                   
=> lang('ticket'),
-                               'lang_ticket_statustext'                => 
lang('Link to the ticket for this project'),
-                               'link_ticket'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitts.view'),
-                               'value_ticket_id'                               
=> $values['ticket_id'],
-
-                               'lang_request'                                  
=> lang('request'),
-                               'lang_request_statustext'               => 
lang('Link to the request for this project'),
-                               'value_request_id'                              
=> $values['request_id'],
-                               'link_request'                                  
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uirequest.view'),
-*/
                                'table_header_workorder_budget' => 
$table_header_workorder_budget,
                                'lang_no_workorders'                    => 
lang('No workorder bugdet'),
                                'workorder_link'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),

====================================================
Index: property/inc/class.uirequest.inc.php
diff -u property/inc/class.uirequest.inc.php:1.8 
property/inc/class.uirequest.inc.php:1.9
--- property/inc/class.uirequest.inc.php:1.8    Fri Feb 25 13:19:54 2005
+++ property/inc/class.uirequest.inc.php        Tue Mar  1 15:04:27 2005
@@ -44,7 +44,8 @@
                        'view'                  => True,
                        'edit'                  => True,
                        'delete'                => True,
-                       'priority_key'  => True
+                       'priority_key'  => True,
+                       'view_file'             => True
                );

                function uirequest()
@@ -77,6 +78,7 @@
                        $this->status_id                        = 
$this->bo->status_id;

                        $this->menu->sub                        ='project';
+                       $this->fakebase                         = 
$this->bo->fakebase;
                }

                function save_sessiondata()
@@ -94,6 +96,47 @@
                        $this->bo->save_sessiondata($data);
                }

+               function view_file()
+               {
+                       $GLOBALS['phpgw_info']['flags'][noheader] = True;
+                       $GLOBALS['phpgw_info']['flags'][nofooter] = True;
+
+                       if(!$this->acl_read)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
 . $this->acl2_location);
+                       }
+
+                       $file_name      = 
urldecode(get_var('file_name',array('POST','GET')));
+                       $location_code          = 
get_var('location_code',array('POST','GET'));
+                       $id             = get_var('id',array('POST','GET'));
+
+                       $file = $this->fakebase. SEP . 'request' . SEP . 
$location_code . SEP . $id . SEP . $file_name;
+
+                       if($this->bo->vfs->file_exists(array(
+                               'string' => $file,
+                               'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               $size           = 
$this->bo->vfs->get_size(array(
+                                                       'string' => $file,
+                                                       'relatives' => 
Array(RELATIVE_NONE),
+                                                       'checksubdirs' => 
True));
+
+                               $document= $this->bo->vfs->read(array(
+                                       'string' => $file,
+                                       'relatives' => Array(RELATIVE_NONE)));
+
+                               $filename       = 
basename($values['document_name']);
+                               $filetype = array_pop(explode('.', 
basename($file)));
+                               $browser = CreateObject('phpgwapi.browser');
+                               
$browser->content_header($filename,$filetype,$size);
+
+                               echo $document;
+
+                       }
+               }
+
+
                function index()
                {
                        if(!$this->acl_read)
@@ -485,7 +528,6 @@
                        {
                                $location_code                          = 
get_var('location_code',array('POST','GET'));
                                $tenant_id                                      
= get_var('tenant_id',array('POST','GET'));
-                               $ticket_id                                      
= get_var('ticket_id',array('POST','GET'));

                                $p_entity_id            = 
get_var('p_entity_id',array('POST','GET'));
                                $p_cat_id                       = 
get_var('p_cat_id',array('POST','GET'));
@@ -493,6 +535,9 @@
                                $values['p'][$p_entity_id]['p_cat_id']          
        = $p_cat_id;
                                $values['p'][$p_entity_id]['p_num']             
                = get_var('p_num',array('POST','GET'));

+                               $origin                         = 
get_var('origin',array('POST','GET'));
+                               $origin_id                      = 
get_var('origin_id',array('POST','GET'));
+
                                if($p_entity_id && $p_cat_id)
                                {
                                        $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
@@ -500,11 +545,6 @@
                                        
$values['p'][$p_entity_id]['p_cat_name'] = $entity_category['name'];
                                }

-                               if($ticket_id)
-                               {
-                                       $values['origin']= 'tts';
-                                       $values['origin_id']= $ticket_id;
-                               }

                                if($location_code)
                                {
@@ -513,6 +553,24 @@

                        }

+                       if($values['origin'])
+                       {
+                               $origin         = $values['origin'];
+                               $origin_id      = $values['origin_id'];
+                       }
+
+                       if($origin)
+                       {
+                               unset($values['origin']);
+                               unset($values['origin_id']);
+                               $values['origin'][0]['type']= $origin;
+                               
$values['origin'][0]['link']=$this->bocommon->get_origin_link($origin);
+                               $values['origin'][0]['data'][]= array(
+                                       'id'=> $origin_id,
+                                       'type'=> $origin
+                                       );
+                       }
+
                        $values['start_date']           = 
get_var('start_date',array('POST'));
                        $values['end_date']                     = 
get_var('end_date',array('POST'));

@@ -549,14 +607,25 @@
                                        $values['request_id']=$id;
                                        $action='edit';
                                }
+                               else
+                               {
+                                               
$values['request_id']=$this->bo->next_id();
+                               }
+
+                               $values['file_name']=str_replace(" 
","_",$_FILES['file']['name']);
+                               $to_file = $this->fakebase. SEP . 'request' . 
SEP . $values['location']['location_code'] . SEP . $values['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'])
                                {
-                                       if(!$id)
-                                       {
-                                               
$values['request_id']=$this->bo->next_id();
-                                               $id     = $values['request_id'];
-                                       }
+                                       $receipt        = 
$this->bo->create_home_dir($receipt);

                                        if($values['copy_request'])
                                        {
@@ -565,6 +634,22 @@
                                                $id     = $values['request_id'];
                                        }
                                        $receipt = 
$this->bo->save($values,$action);
+
+                                       if($values['file_name'])
+                                       {
+                                               
$this->bo->create_document_dir($values['location']['location_code'], 
$values['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;
+                                       }
+
                                        $id = $values['request_id'];
                                        $function_msg = lang('Edit request');

@@ -672,15 +757,6 @@
                                }
                        }

-                       if($values['origin']== 'tts')
-                       {
-                               $origin_data = array
-                               (
-                                       'menuaction'    => 
$this->currentapp.'.uitts.view',
-                                       'id'                    => 
$values['origin_id']
-                               );
-                       }
-
                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uirequest.edit',
@@ -766,19 +842,71 @@

                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

+                       $link_file_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uirequest.view_file',
+                                               'location_code' 
=>$values['location_data']['location_code'],
+                                               'id'                    =>$id
+                                               );
+
+                       $link_to_files = 
$this->config->config_data['files_url'];
+
+                       $j      = count($values['files']);
+                       for ($i=0;$i<$j;$i++)
+                       {
+                               
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
+                       }
+
+                       if (isset($values['origin']) AND 
is_array($values['origin']))
+                       {
+                               for ($i=0;$i<count($values['origin']);$i++)
+                               {
+                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
+                                       
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+                                       {
+                                               $type           = 
explode("_",$values['origin'][$i]['type']);
+                                               $entity_id      = $type[1];
+                                               $cat_id         = $type[2];
+
+                                               if(!is_object($boadmin_entity))
+                                               {
+                                                       $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               }
+                                               $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                               $values['origin'][$i]['descr'] 
= $entity_category['name'];
+                                       }
+                                       else
+                                       {
+                                               $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
+                                       }
+                               }
+                       }
+
                        $data = array
                        (
+                               'fileupload'                                    
=> True,
+                               'link_view_file'                                
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+                               'link_to_files'                                 
=> $link_to_files,
+                               'files'                                         
        => $values['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),
-                               'lang_origin'                                   
=> lang('origin'),
-                               'lang_origin_statustext'                => 
lang('Link to the origin for this request'),
-                               'link_origin'                                   
=> $GLOBALS['phpgw']->link('/index.php',$origin_data),
+
                                'value_origin'                                  
=> $values['origin'],
-                               'value_origin_id'                               
=> $values['origin_id'],
+                               'value_origin_type'                             
=> $origin,
+                               'value_origin_id'                               
=> $origin_id,
+                               'lang_origin_statustext'                => 
lang('Link to the origin for this request'),

-                               'lang_project'                                  
=> lang('Project'),
-                               'lang_project_statustext'               => 
lang('Link to the project originatet from this request'),
-                               'link_project'                                  
=> $GLOBALS['phpgw']->link('/index.php',$project_lookup_data),
-                               'value_project_id'                              
=> $values['project_id'],
+//                             'lang_project'                                  
=> lang('Project'),
+//                             'lang_project_statustext'               => 
lang('Link to the project originatet from this request'),
+//                             'link_project'                                  
=> $GLOBALS['phpgw']->link('/index.php',$project_lookup_data),
+//                             'value_project_id'                              
=> $values['project_id'],

                                'generate_project_action'                       
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
                                'lang_generate_project'                         
=> lang('Generate project'),
@@ -1056,12 +1184,59 @@
                                );
                        }

+                       $link_file_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uirequest.view_file',
+                                               'location_code' 
=>$values['location_data']['location_code'],
+                                               'id'                    =>$id
+                                               );
+
+                       $this->config->read_repository();
+                       $link_to_files = 
$this->config->config_data['files_url'];
+
+                       $j      = count($values['files']);
+                       for ($i=0;$i<$j;$i++)
+                       {
+                               
$values['files'][$i]['file_name']=urlencode($values['files'][$i]['name']);
+                       }
+
+                       if (isset($values['origin']) AND 
is_array($values['origin']))
+                       {
+                               for ($i=0;$i<count($values['origin']);$i++)
+                               {
+                                       
$values['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $values['origin'][$i]['link']);
+                                       
if(substr($values['origin'][$i]['type'],0,6)=='entity')
+                                       {
+                                               $type           = 
explode("_",$values['origin'][$i]['type']);
+                                               $entity_id      = $type[1];
+                                               $cat_id         = $type[2];
+
+                                               if(!is_object($boadmin_entity))
+                                               {
+                                                       $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               }
+                                               $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                               $values['origin'][$i]['descr'] 
= $entity_category['name'];
+                                       }
+                                       else
+                                       {
+                                               $values['origin'][$i]['descr']= 
lang($values['origin'][$i]['type']);
+                                       }
+                               }
+                       }
+
                        $data = array
                        (
-                               'lang_origin'                                   
=> lang('origin'),
-                               'lang_origin_statustext'                => 
lang('Link to the origin for this request'),
-                               'link_origin'                                   
=> $GLOBALS['phpgw']->link('/index.php',$origin_data),
-                               'value_origin_id'                               
=> $values['origin_id'],
+                               'link_view_file'                                
=> $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+                               'link_to_files'                                 
=> $link_to_files,
+                               'files'                                         
        => $values['files'],
+                               'lang_files'                                    
=> lang('files'),
+                               'lang_filename'                                 
=> lang('Filename'),
+                               'lang_view_file_statustext'             => 
lang('Klick to view file'),
+
+                               'value_origin'                                  
=> $values['origin'],
+                               'value_origin_type'                             
=> $origin,
+                               'value_origin_id'                               
=> $origin_id,

                                'lang_project'                                  
=> lang('Project'),
                                'lang_project_statustext'               => 
lang('Link to the project originatet from this request'),

====================================================
Index: property/inc/class.uitts.inc.php
diff -u property/inc/class.uitts.inc.php:1.10 
property/inc/class.uitts.inc.php:1.11
--- property/inc/class.uitts.inc.php:1.10       Fri Feb 25 13:19:54 2005
+++ property/inc/class.uitts.inc.php    Tue Mar  1 15:04:27 2005
@@ -903,8 +903,38 @@

                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

+
+                       if (isset($ticket['origin']) AND 
is_array($ticket['origin']))
+                       {
+                               for ($i=0;$i<count($ticket['origin']);$i++)
+                               {
+                                       
$ticket['origin'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp
 . $ticket['origin'][$i]['link']);
+                                       
if(substr($ticket['origin'][$i]['type'],0,6)=='entity')
+                                       {
+                                               $type           = 
explode("_",$ticket['origin'][$i]['type']);
+                                               $entity_id      = $type[1];
+                                               $cat_id         = $type[2];
+
+                                               if(!is_object($boadmin_entity))
+                                               {
+                                                       $boadmin_entity = 
CreateObject($this->currentapp.'.boadmin_entity');
+                                               }
+                                               $entity_category = 
$boadmin_entity->read_single_category($entity_id,$cat_id);
+                                               $ticket['origin'][$i]['descr'] 
= $entity_category['name'];
+                                       }
+                                       else
+                                       {
+                                               $ticket['origin'][$i]['descr']= 
lang($ticket['origin'][$i]['type']);
+                                       }
+                               }
+                       }
+
                        $data = array
                        (
+                               'value_origin'                                  
=> $ticket['origin'],
+                               'value_origin_type'                             
=> $origin,
+                               'value_origin_id'                               
=> $origin_id,
+
                                'lang_dateformat'                               
=> strtolower($dateformat),
                                'dateformat_validate'                   => 
$dateformat_validate,
                                'onKeyUp'                                       
        => $onKeyUp,
@@ -916,8 +946,6 @@
                                'link_entity'                                   
=> $link_entity,
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),

-                               'entity_origin_list'                    => 
$ticket['entity'],
-
                                'lang_request'                                  
=> lang('Request'),
                                'lang_request_statustext'               => 
lang('Link to the request originatet from this ticket'),
                                'link_request'                                  
=> $GLOBALS['phpgw']->link('/index.php',$request_lookup_data),

====================================================
Index: property/inc/class.bocommon.inc.php
diff -u property/inc/class.bocommon.inc.php:1.8 
property/inc/class.bocommon.inc.php:1.9
--- property/inc/class.bocommon.inc.php:1.8     Thu Jan 13 16:52:48 2005
+++ property/inc/class.bocommon.inc.php Tue Mar  1 15:04:27 2005
@@ -1331,5 +1331,32 @@
                {
                        return $this->socommon->increment_id($name);
                }
+
+               function get_origin_link($type)
+               {
+                       if($type=='tts'):
+                       {
+                               $link = '.uitts.view';
+                       }
+                       elseif($type=='request'):
+                       {
+                               $link = '.uirequest.view';
+                       }
+                       elseif($type=='project'):
+                       {
+                               $link = '.uiproject.view';
+                       }
+                       elseif(substr($type,0,6)=='entity'):
+                       {
+
+                               $type           = explode("_",$type);
+                               $entity_id      = $type[1];
+                               $cat_id         = $type[2];
+                               $link = 
".uientity.view&entity_id=$entity_id&cat_id=$cat_id";
+                       }
+                       endif;
+
+                       return $link;
+               }
        }
 ?>

====================================================
Index: property/inc/class.sotts.inc.php
diff -u property/inc/class.sotts.inc.php:1.4 
property/inc/class.sotts.inc.php:1.5
--- property/inc/class.sotts.inc.php:1.4        Mon Jan 24 11:41:32 2005
+++ property/inc/class.sotts.inc.php    Tue Mar  1 15:04:27 2005
@@ -228,10 +228,10 @@

                function get_origin_entity_type()
                {
-                       $sql = "SELECT fm_entity_origin.entity_id, 
fm_entity_origin.cat_id,name"
-                       . " FROM fm_entity_origin $this->join 
fm_entity_category on fm_entity_origin.entity_id=fm_entity_category.entity_id"
-                       . " AND fm_entity_origin.cat_id=fm_entity_category.id "
-                       . " WHERE origin ='tts' and tracking=1 group by 
fm_entity_origin.entity_id, fm_entity_origin.cat_id,name";
+                       $sql = "SELECT entity_id, id as cat_id,name"
+                       . " FROM fm_entity_category "
+                       . " WHERE tracking=1 ORDER by entity_id,cat_id";
+

                        $this->db->query($sql,__LINE__,__FILE__);

@@ -254,13 +254,17 @@

                function get_child_date($id,$type,$entity_id='',$cat_id='')
                {
-                       $table= 'fm_' . $type . '_origin';
+                       $table= 'fm_origin';
                        if($cat_id)
                        {
-                               $and = " AND entity_id=$entity_id AND 
cat_id=$cat_id";
+                               $and = " AND destination = 'entity_" . 
$entity_id . '_' . $cat_id . "'";
+                       }
+                       else
+                       {
+                               $and = " AND destination = '$type'";
                        }

-                       $sql = "SELECT * FROM $table  WHERE origin_id='$id' and 
origin ='tts' $and";
+                       $sql = "SELECT * FROM $table WHERE origin_id='$id' and 
origin ='tts' $and";

                        $this->db->query($sql,__LINE__,__FILE__);

@@ -268,14 +272,14 @@
                        while ($this->db->next_record())
                        {
                                $date_info['date_info'][$i]['entry_date']= 
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
-                               if($this->db->f('cat_id'))
+                               if($cat_id)
                                {
-                                       
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='.$entity_id.'&cat_id='
 . $cat_id . '&id=' . $this->db->f('id'));
+                                       
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='.$entity_id.'&cat_id='
 . $cat_id . '&id=' . $this->db->f('destination_id'));
                                        
$date_info['date_info'][$i]['descr']=$this->soadmin_entity->read_category_name($entity_id,$cat_id);
                                }
                                else
                                {
-                                       
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui'
 . $type . '.view&id=' . $this->db->f($type . '_id'));
+                                       
$date_info['date_info'][$i]['link']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.ui'
 . $type . '.view&id=' . $this->db->f('destination_id'));
                                        
$date_info['date_info'][$i]['descr']=lang($type);
                                }

@@ -319,74 +323,28 @@

                        }

-                       $sql = "SELECT * FROM fm_request_origin WHERE 
origin_id='$id' and origin ='tts'";

-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $i=0;
-                       while ($this->db->next_record())
-                       {
-                               $ticket['request_id'][$i]['id'] = 
$this->db->f('request_id');
-                               $ticket['request_id'][$i]['entry_date'] = 
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
-                               $i++;
-                       }
-
-                       $sql = "SELECT * FROM fm_project_origin WHERE 
origin_id='$id' and origin ='tts'";
+                       $sql = "SELECT * FROM fm_origin WHERE origin = 'tts' 
AND origin_id='$id' ORDER by destination DESC  ";

                        $this->db->query($sql,__LINE__,__FILE__);

-                       $i=0;
+                       $i=-1;
                        while ($this->db->next_record())
                        {
-                               $ticket['project_id'][$i]['id'] = 
$this->db->f('project_id');
-                               $ticket['project_id'][$i]['entry_date'] = 
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
-                               $i++;
-                       }
-
-                       $sql = "SELECT * FROM fm_entity_origin WHERE 
origin_id='$id' and origin ='tts' ORDER BY entity_id ASC";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $i=0;
-                       $j=0;
-                       $entity_id=0;
-                       while ($this->db->next_record())
-                       {
-                               if(!$first)
-                               {
-                                       $boadmin_entity         = 
CreateObject($this->currentapp.'.boadmin_entity');
-                                       $entity         = 
$boadmin_entity->read_single($this->db->f('entity_id'),false);
-                                       $entity_id      = 
$this->db->f('entity_id');
-                               }
-
-                               if($this->db->f('entity_id')==$entity_id)
-                               {
-                                       $ticket['entity'][$i]['name']   = 
$entity['name'];
-                                       
$ticket['entity'][$i]['link_info'][$j]['id']    = $this->db->f('id');
-                                       
$ticket['entity'][$i]['link_info'][$j]['link']  = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='.$this->db->f('entity_id').'&cat_id='
 . $this->db->f('cat_id'));
-                                       
$ticket['entity'][$i]['link_info'][$j]['entry_date']    = 
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
-                                       $j++;
-                               }
-                               else
+                               if($last_type != $this->db->f('destination'))
                                {
                                        $i++;
-                                       $j=0;
-                                       $entity         = 
$boadmin_entity->read_single($this->db->f('entity_id'),false);
-                                       $entity_id      = 
$this->db->f('entity_id');
-                                       $ticket['entity'][$i]['name']   = 
$entity['name'];
-                                       
$ticket['entity'][$i]['link_info'][$j]['id']    = $this->db->f('id');
-                                       
$ticket['entity'][$i]['link_info'][$j]['link']  = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='.$this->db->f('entity_id').'&cat_id='
 . $this->db->f('cat_id'));
-                                       
$ticket['entity'][$i]['link_info'][$j]['entry_date']    = 
$GLOBALS['phpgw']->common->show_date($this->db->f('entry_date'),$this->dateformat);
-                                       $j++;
                                }
+                               $ticket['origin'][$i]['type'] = 
$this->db->f('destination');
+                               $ticket['origin'][$i]['link'] = 
$this->bocommon->get_origin_link($this->db->f('destination'));
+                               $ticket['origin'][$i]['data'][]= array(
+                                       'id'=> $this->db->f('destination_id'),
+                                       'type'=> $this->db->f('destination')
+                                       );

-                               $first=True;
+                               $last_type=$this->db->f('destination');
                        }

-
-//_debug_array($ticket);
-//_debug_array($ticket['entity']);
-
                        return $ticket;
                }







reply via email to

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