phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/class.sodocument.php, 1.1.1.3


From: nomail
Subject: [Phpgroupware-cvs] property/class.sodocument.php, 1.1.1.3
Date: Fri, 21 May 2004 15:57:15 -0000

Update of /property
Modified Files:
        Branch: 
          class.sodocument.php

date: 2004/04/23 21:26:33;  author: sigurdne;  state: Exp;  lines: +657 -657

Log Message:
no message
=====================================================================
Index: property/class.sodocument.php
diff -u property/class.sodocument.php:1.1.1.2 
property/class.sodocument.php:1.1.1.3
--- property/class.sodocument.php:1.1.1.2       Fri Apr 23 20:25:42 2004
+++ property/class.sodocument.php       Fri Apr 23 21:26:33 2004
@@ -1,657 +1,657 @@
-<?php
-       
/**************************************************************************\
-       * phpGroupWare - property                                               
   *
-       * http://www.phpgroupware.org                                           
   *
-       *                                                                       
   *
-       * Facilities Management                                                 
   *
-       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
-       * 
------------------------------------------------------------------------ *
-       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
-       * This program is part of the GNU project, see http://www.gnu.org/      
   *
-       * 
------------------------------------------------------------------------ *
-       * This program is free software; you can redistribute it and/or modify 
it  *
-       * under the terms of the GNU General Public License as published by the 
   *
-       * Free Software Foundation; either version 2 of the License, or (at 
your   *
-       * option) any later version.                                            
   *
-       
\**************************************************************************/
-
-       class property_sodocument
-       {
-
-               function property_sodocument()
-               {
-                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->db                       = $GLOBALS['phpgw']->db;
-                       $this->db2                      = $this->db;
-                       $this->account          = 
$GLOBALS['phpgw_data']['user']['id'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon',True);
-                       $this->historylog       = 
CreateObject($this->currentapp.'_historylog','document');
-                       $this->vfs                      = 
CreateObject('phpgwapi_vfs');
-                       $this->rootdir          = $this->vfs->basedir;
-                       $this->fakebase         = $this->vfs->fakebase;
-
-                       $this->socommon         = 
CreateObject($this->currentapp.'_socommon');
-
-                       $this->join                     = $this->socommon->join;
-               }
-
-               function select_doc_type_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_document_category  ORDER BY descr ");
-
-                       $i = 0;
-                       while (!$dbresult->EOF)
-                       {
-                               $categories[$i]['id']                           
= $dbresult->fields['id'];
-                               $categories[$i]['name']                         
= stripslashes($dbresult->fields['descr']);
-                               $i++;
-                               $dbresult->MoveNext();
-                       }
-                       return $categories;
-               }
-
-               function read_single_category($id='')
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
descr FROM fm_document_category where id='$id' ");
-
-                       return $dbresult->fields['descr'];
-               }
-
-               function select_status_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_document_status ORDER BY id ");
-
-                       $i = 0;
-                       while (!$dbresult->EOF)
-                       {
-                               $status_entries[$i]['id']                       
        = $dbresult->fields['id'];
-                               $status_entries[$i]['name']                     
        = stripslashes($dbresult->fields['descr']);
-                               $i++;
-                               $dbresult->MoveNext();
-                       }
-                       return $status_entries;
-               }
-
-               function select_branch_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_branch ORDER BY id ");
-
-                       $i = 0;
-                       while (!$dbresult->EOF)
-                       {
-                               $branch_entries[$i]['id']                       
        = $dbresult->fields['id'];
-                               $branch_entries[$i]['name']                     
        = stripslashes($dbresult->fields['descr']);
-                               $i++;
-                               $dbresult->MoveNext();
-                       }
-                       return $branch_entries;
-               }
-
-               function read($data)
-               {
-                       if(is_array($data))
-                       {
-                               if ($data['start'])
-                               {
-                                       $start=$data['start'];
-                               }
-                               else
-                               {
-                                       $start=0;
-                               }
-                               $filter = 
(isset($data['filter'])?$data['filter']:'');
-                               $query = 
(isset($data['query'])?$data['query']:'');
-                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order = 
(isset($data['order'])?$data['order']:'');
-                               $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
-                               $entity_id = 
(isset($data['entity_id'])?$data['entity_id']:'');
-                       }
-
-                       $sql = $this->bocommon->fm_cache('sql_document_' . 
$entity_id);
-
-                       if(!$sql)
-                       {
-
-                       $document_table = 'fm_document';
-
-                       $cols .= $document_table . '.location_code';
-                       $cols_return[] = 'location_code';
-
-//                     $cols .= ",$document_table.id as document_id";
-//                     $cols_return[]                          = 'document_id';
-
-                       $groupmethod= " GROUP BY 
fm_document.location_code,fm_document.address  ";
-
-                       if ($entity_id)
-                       {
-                               $cols .= ",$document_table.p_num as p_num";
-                               $cols_return[]                          = 
'p_num';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]                       = 
'p_num';
-                               $uicols['descr'][]                      = 
lang('ID');
-                               $uicols['statustext'][]         = lang('ID');
-
-                               $cols .= ',fm_entity_category.name as category';
-                               $cols_return[]                          = 
'category';
-                               $uicols['input_type'][]         = 'text';
-                               $uicols['name'][]                       = 
'category';
-                               $uicols['descr'][]                      = 
lang('Type');
-                               $uicols['statustext'][]         = lang('Type');
-
-                               $cols .= ",$document_table.p_entity_id";
-                               $cols_return[]                          = 
'p_entity_id';
-                               $cols .= ",$document_table.p_cat_id";
-                               $cols_return[]                          = 
'p_cat_id';
-
-                               $joinmethod .= " $this->join  
fm_entity_category ON (fm_entity_category.entity_id 
=$document_table.p_entity_id AND fm_entity_category.id = 
$document_table.p_cat_id))";
-                               $paranthesis .='(';
-
-
-                               $groupmethod.= " 
,fm_document.p_entity_id,fm_entity_category.name,$document_table.p_num,fm_document.p_cat_id";
-                       }
-
-
-                       $sql    = 
$this->bocommon->generate_sql(array('entity_table'=>$document_table,'cols'=>$cols,'cols_return'=>$cols_return,
-                                                                               
                                
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
-
-
-                       $this->bocommon->fm_cache('sql_document_' . 
$entity_id,$sql);
-
-                       $this->uicols           = $this->bocommon->uicols;
-                       $cols_return            = $this->bocommon->cols_return;
-                       $type_id                        = 
$this->bocommon->type_id;
-                       $this->cols_extra       = $this->bocommon->cols_extra;
-
-                               $this->bocommon->fm_cache('uicols_document_' . 
$entity_id,$this->uicols);
-                               
$this->bocommon->fm_cache('cols_return_document_' . $entity_id,$cols_return);
-                               $this->bocommon->fm_cache('type_id_document_' . 
$entity_id,$type_id);
-                               
$this->bocommon->fm_cache('cols_extra_document_' . 
$entity_id,$this->cols_extra);
-
-                       }
-                       else
-                       {
-                               $this->uicols           = 
$this->bocommon->fm_cache('uicols_document_' . $entity_id);
-                               $cols_return            = 
$this->bocommon->fm_cache('cols_return_document_' . $entity_id);
-                               $type_id                        = 
$this->bocommon->fm_cache('type_id_document_' . $entity_id);
-                               $this->cols_extra       = 
$this->bocommon->fm_cache('cols_extra_document_' . $entity_id);
-                       }
-
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by fm_document.$order 
$sort";
-                       }
-                       else
-                       {
-                               $ordermethod = ' order by 
fm_document.location_code ASC';
-                       }
-
-                       $where= 'WHERE';
-
-                       if(!$entity_id)
-                       {
-                               $filtermethod .= " $where ( fm_document.p_num 
is NULL OR fm_document.p_num='') ";
-                               $where= 'AND';
-                       }
-
-                       if ($cat_id)
-                       {
-                               $filtermethod .= " $where 
fm_document.p_cat_id=$cat_id ";
-                               $where= 'AND';
-                       }
-
-                       if ($filter!='all' && $filter)
-                       {
-                               $filtermethod .= " $where 
fm_document.user_id='$filter' ";
-                       }
-
-                       if($query)
-                       {
-                               $query = ereg_replace("'",'',$query);
-                               $query = ereg_replace('"','',$query);
-
-                               $querymethod = " $where (fm_document.address 
LIKE '%$query%' or fm_document.location_code LIKE '%$query%')";
-                       }
-
-
-                       $sql .= " $filtermethod $querymethod $groupmethod";
-
-//echo $sql;
-
-                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
-                       $this->total_records = $dbresult2->_numOfRows;
-                       $maxmatchs = 15;
-
-                       if(!$allrows)
-                       {
-                               $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
-                       }
-                       else
-                       {
-                               $dbresult = $GLOBALS['phpgw']->db->Execute($sql 
. $ordermethod);
-                       }
-
-                       $j=0;
-                       while (!$dbresult->EOF)
-                       {
-                               for ($i=0;$i<count($cols_return);$i++)
-                               {
-                                       $document_list[$j][$cols_return[$i]] = 
$this->db->f($cols_return[$i]);
-                               }
-
-                               $location_code= 
$dbresult->fields['location_code'];
-                               $location = split('-',$location_code);
-                               for ($m=0;$m<count($location);$m++)
-                               {
-                                       $document_list[$j]['loc' . ($m+1)] = 
$location[$m];
-                                       
$document_list[$j]['query_location']['loc' . ($m+1)]=implode("-", 
array_slice($location, 0, ($m+1)));
-                               }
-
-                               $j++;
-                               $dbresult->MoveNext();
-                       }
-
-
-//html_print_r($document_list);
-                       return $document_list;
-               }
-
-               function read_at_location($data)
-               {
-                       if(is_array($data))
-                       {
-                               if ($data['start'])
-                               {
-                                       $start=$data['start'];
-                               }
-                               else
-                               {
-                                       $start=0;
-                               }
-                               $filter = 
(isset($data['filter'])?$data['filter']:'');
-                               $query = 
(isset($data['query'])?$data['query']:'');
-                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order = 
(isset($data['order'])?$data['order']:'');
-                               $entity_id = 
(isset($data['entity_id'])?$data['entity_id']:0);
-                               $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
-                               $doc_type = 
(isset($data['doc_type'])?$data['doc_type']:0);
-                               $location_code = 
(isset($data['location_code'])?$data['location_code']:'');
-                       }
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by $order $sort";
-                       }
-                       else
-                       {
-                               $ordermethod = ' order by location_code ASC';
-                       }
-
-                       $filtermethod = " 
fm_document.location_code='$location_code'";
-
-                       if ($doc_type > 0)
-                       {
-                               $filtermethod .= " AND 
fm_document.category='$doc_type' ";
-                       }
-                       if ($cat_id > 0)
-                       {
-                               $filtermethod .= " AND 
fm_document.p_cat_id=$cat_id AND fm_document.p_entity_id=$entity_id ";
-                       }
-
-
-                       if ($filter)
-                       {
-                               $filtermethod .= " AND 
fm_document.user_id='$filter' ";
-                       }
-
-                       if($query)
-                       {
-                               $query = ereg_replace("'",'',$query);
-                               $query = ereg_replace('"','',$query);
-
-                               $querymethod = " AND fm_document.title LIKE 
'%$query%' or fm_document.document_name LIKE '%$query%'";
-                       }
-
-                       $sql = "SELECT fm_document.*, 
fm_document_category.descr as category FROM fm_document $this->join 
fm_document_category on fm_document.category = fm_document_category.id WHERE  
$filtermethod $querymethod ";
-
-                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
-                       $this->total_records = $dbresult2->_numOfRows;
-                       $maxmatchs = 15;
-
-                       if(!$allrows)
-                       {
-                               $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
-                       }
-                       else
-                       {
-                               $dbresult = $GLOBALS['phpgw']->db->Execute($sql 
. $ordermethod);
-                       }
-
-                       while (!$dbresult->EOF)
-                       {
-                               $document_list[] = array
-                               (
-                                       'document_id'           => 
$dbresult->fields['id'],
-                                       'document_name'         => 
$dbresult->fields['document_name'],
-                                       'link'                          => 
$dbresult->fields['link'],
-                                       'title'                         => 
$dbresult->fields['title'],
-                                       'doc_type'                      => 
$dbresult->fields['category'],
-                                       'user_id'                       => 
$dbresult->fields['user_id']
-                                       );
-                               $dbresult->MoveNext();
-                       }
-//html_print_r($document_list);
-                       return $document_list;
-               }
-
-               function read_single($document_id)
-               {
-                       $sql = "SELECT * from fm_document where 
id='$document_id'";
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-
-                       if (!$dbresult->EOF)
-                       {
-                               $document['document_id']                = 
$dbresult->fields['id'];
-                               $document['title']                              
= $dbresult->fields['title'];
-                               $document['document_name']              = 
$dbresult->fields['document_name'];
-                               $document['link']                               
= $dbresult->fields['link'];
-                               $document['location_code']              = 
$dbresult->fields['location_code'];
-                               $document['branch_id']                  = 
$dbresult->fields['branch_id'];
-                               $document['version']                    = 
$dbresult->fields['version'];
-                               $document['vendor_id']                  = 
$dbresult->fields['vendor_id'];
-                               $document['floor_id']                   = 
$dbresult->fields['floor_id'];
-                               $document['descr']                              
= $dbresult->fields['descr'];
-                               $document['status']                             
= $dbresult->fields['status'];
-                               $document['user_id']                    = 
$dbresult->fields['user_id'];
-                               $document['coordinator']                = 
$dbresult->fields['coordinator'];
-                               $document['access']                             
= $dbresult->fields['access'];
-                               $document['document_date']              = 
$dbresult->fields['document_date'];
-                               $document['doc_type']                   = 
$dbresult->fields['category'];
-                               $document['p_num']                              
= $dbresult->fields['p_num'];
-                               $document['p_entity_id']                = 
$dbresult->fields['p_entity_id'];
-                               $document['p_cat_id']                   = 
$dbresult->fields['p_cat_id'];
-                       }
-
-//html_print_r($document);
-                               return $document;
-               }
-
-               function add($document)
-               {
-                       while (is_array($document['location']) && 
list($input_name,$value) = each($document['location']))
-                       {
-                               if($value)
-                               {
-                                       $cols[] = $input_name;
-                                       $vals[] = $value;
-                               }
-                       }
-
-                       while (is_array($document['extra']) && 
list($input_name,$value) = each($document['extra']))
-                       {
-                               if($value)
-                               {
-                                       $cols[] = $input_name;
-                                       $vals[] = $value;
-                               }
-                       }
-
-                       if($cols)
-                       {
-                               $cols   = "," . implode(",", $cols);
-                               $vals   = ",'" . implode("','", $vals) . "'";
-                       }
-
-                       if($document['street_name'])
-                       {
-                               $address[]= $document['street_name'];
-                               $address[]= $document['street_number'];
-                               $address        = implode(" ", $address);
-                       }
-
-                       if(!$address)
-                       {
-                               $address = $document['location_name'];
-                       }
-
-                       $document['descr'] = 
$this->db->db_addslashes($document['descr']);
-                       $document['name'] = 
$this->db->db_addslashes($document['name']);
-                       $document['title'] = 
$this->db->db_addslashes($document['title']);
-//html_print_r($document);
-
-                       $values= array(
-                               $document['document_name'],
-                               $document['link'],
-                               $document['title'],
-                               'public',
-                               $document['doc_type'],
-                               time(),
-                               $document['document_date'],
-                               $document['version'],
-                               $document['coordinator'],
-                               $document['status'],
-                               $document['descr'],
-                               $document['location_code'],
-                               $address,
-                               $document['branch_id'],
-                               $document['vendor_id'],
-                               $this->account);
-
-                       $values = $this->bocommon->validate_db_insert($values);
-
-                       $GLOBALS['phpgw']->db->Execute("INSERT INTO fm_document 
(document_name,link,title,access,category,entry_date,document_date,version,coordinator,status,"
-                               . 
"descr,location_code,address,branch_id,vendor_id,user_id $cols) "
-                               . "VALUES ($values $vals )");
-
-                       $receipt['document_id'] = 
$this->db->get_last_insert_id('fm_document','id');
-
-                       
$this->historylog->add('SO',$receipt['document_id'],$document['status']);
-                       
$this->historylog->add('TO',$receipt['document_id'],$document['doc_type']);
-                       if($document['coordinator'])
-                       {
-                               
$this->historylog->add('CO',$receipt['document_id'],$document['coordinator']);
-                       }
-                       if($document['document_name'])
-                       {
-                               
$this->historylog->add('FO',$receipt['document_id'],$document['coodocument_name']);
-                       }
-                       if($document['link'])
-                       {
-                               
$this->historylog->add('LO',$receipt['document_id'],$document['link']);
-                       }
-
-                       $receipt['message'][] = array('msg'=>lang('document %1 
has been saved',"'".$document['document_name']."'"));
-                       return $receipt;
-               }
-
-               function edit($document)
-               {
-                       while (is_array($document['location']) && 
list($input_name,$value) = each($document['location']))
-                       {
-                               $vals[] = "$input_name = '$value'";
-                       }
-
-                       while (is_array($document['extra']) && 
list($input_name,$value) = each($document['extra']))
-                       {
-                               $vals[] = "$input_name = '$value'";
-                       }
-
-                       if($vals)
-                       {
-                               $vals   = "," . implode(",",$vals);
-                       }
-
-                       if($document['street_name'])
-                       {
-                               $address[]= $document['street_name'];
-                               $address[]= $document['street_number'];
-                               $address        = implode(" ", $address);
-                       }
-
-                       if(!$address)
-                       {
-                               $address = $document['location_name'];
-                       }
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
status,category,coordinator,document_name,loc1,link,p_num FROM fm_document 
where id='" .$document['document_id']."'");
-
-
-                       $old_status = $dbresult->fields['status'];
-                       $old_doc_type = $dbresult->fields['category'];
-                       $old_coordinator = $dbresult->fields['coordinator'];
-                       $old_document_name = $dbresult->fields['document_name'];
-                       $old_loc1 = $dbresult->fields['loc1'];
-                       $old_link = $dbresult->fields['link'];
-                       $old_p_num = $dbresult->fields['p_num'];
-
-                       if ($old_status != $document['status'])
-                       {
-                               
$this->historylog->add('S',$document['document_id'],$document['status']);
-                       }
-                       if ($old_doc_type != $document['doc_type'])
-                       {
-                               
$this->historylog->add('T',$document['document_id'],$document['doc_type']);
-                       }
-                       if ((int)$old_coordinator != 
(int)$document['coordinator'])
-                       {
-                               
$this->historylog->add('C',$document['document_id'],$document['coordinator']);
-                       }
-
-                       if($document['document_name_orig'] && 
!$document['document_name'] )
-                       {
-                               $document['document_name'] = 
$document['document_name_orig'];
-                       }
-
-                       if($old_link !=$document['link'] )
-                       {
-                                       
$this->historylog->add('L',$document['document_id'],$document['link']);
-                                       $alter_link=True;
-                       }
-
-//html_print_r($document);
-                       if ($old_document_name && ($old_document_name != 
$document['document_name']))
-                       {
-                               if($document['link'] && !$alter_link)
-                               {
-                                       
$this->historylog->add('L',$document['document_id'],$document['link']);
-                               }
-                               else
-                               {
-                                       
$this->historylog->add('F',$document['document_id'],$document['document_name']);
-                               }
-
-                               if($old_p_num)
-                               {
-                                       $file = $this->fakebase. SEP . 
'document' . SEP . $old_loc1 . SEP . $document['entity_name'] . SEP . 
$document['category_name'] . SEP . $p_num . SEP . $old_document_name;
-                               }
-                               else
-                               {
-                                       $file = $this->fakebase. SEP . 
'document' . SEP . $old_loc1 . SEP . $old_document_name;
-                               }
-
-                               $receipt= $this->delete_file($file);
-                       }
-
-                       if($document['link'])
-                       {
-                               unset($document['document_name']);
-                       }
-
-                       $document['descr'] = 
$this->db->db_addslashes($document['descr']);
-                       $document['name'] = 
$this->db->db_addslashes($document['name']);
-                       $document['title'] = 
$this->db->db_addslashes($document['title']);
-
-                       $value_set=array(
-                               'document_name' =>$document['document_name'],
-                               'link'                  =>$document['link'],
-                               'title'                 =>$document['title'],
-                               'branch_id'             
=>$document['branch_id'],
-                               'status'                =>$document['status'],
-                               'category'              =>$document['doc_type'],
-                               'document_date' =>$document['document_date'],
-                               'coordinator'   =>$document['coordinator'],
-                               'descr'                 =>$document['descr'],
-                               'version'               =>$document['version'],
-                               'location_code' =>$document['location_code'],
-                               'vendor_id'             
=>$document['vendor_id'],
-                               'address'               =>$address
-                               );
-
-                       $value_set      = 
$this->bocommon->validate_db_update($value_set);
-
-                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_document set 
$value_set $vals WHERE id= '" . $document['document_id'] ."'");
-
-                       $receipt['document_id'] = $document['document_id'];
-                       $receipt['message'][] = array('msg'=>lang('document %1 
has been edited',"'".$document['title']."'"));
-                       return $receipt;
-
-               }
-
-               function delete_file($file)
-               {
-                       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 . 'document'. SEP . $document_name);
-                               }
-                               else
-                               {
-                                       
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'. 
$this->fakebase. SEP . 'document'. SEP . $document_name);
-                               }
-                               $this->vfs->override_acl = 0;
-                       }
-
-               }
-
-               function delete($document_id )
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
document_name,location_code,p_num,p_entity_id,p_cat_id FROM fm_document where 
id='$document_id'");
-
-                       $document_name  = $dbresult->fields['document_name'];
-                       $location_code  = $dbresult->fields['location_code'];
-                       $p_num                  = $dbresult->fields['p_num'];
-                       $p_entity_id    = $dbresult->fields['p_entity_id'];
-                       $p_cat_id               = $dbresult->fields['p_cat_id'];
-
-                       $location               = split("-", $location_code);
-                       $loc1   = $location[0];
-                       if($p_cat_id)
-                       {
-                               $boadmin_entity         = 
CreateObject($this->currentapp.'_boadmin_entity');
-                               $entity = 
$boadmin_entity->read_single($p_entity_id,false);
-                               $category = 
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
-                       }
-
-                       if($document_name)
-                       {
-                               if($p_num)
-                               {
-                                       $file = $this->fakebase. SEP . 
'document' . SEP . $loc1 . SEP . $entity['name'] . SEP . $category['name'] . 
SEP . $p_num . SEP . $document_name;
-                               }
-                               else
-                               {
-                                       $file = $this->fakebase. SEP . 
'document' . SEP . $loc1 . SEP . $document_name;
-                               }
-
-                               $receipt= $this->delete_file($file);
-                       }
-
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_document 
WHERE id='$document_id'");
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_document_history  WHERE  history_record_id='$document_id'");
-               }
-       }
-?>
+<?php
+       
/**************************************************************************\
+       * phpGroupWare - property                                               
   *
+       * http://www.phpgroupware.org                                           
   *
+       *                                                                       
   *
+       * Facilities Management                                                 
   *
+       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
+       * 
------------------------------------------------------------------------ *
+       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
+       * This program is part of the GNU project, see http://www.gnu.org/      
   *
+       * 
------------------------------------------------------------------------ *
+       * This program is free software; you can redistribute it and/or modify 
it  *
+       * under the terms of the GNU General Public License as published by the 
   *
+       * Free Software Foundation; either version 2 of the License, or (at 
your   *
+       * option) any later version.                                            
   *
+       
\**************************************************************************/
+
+       class property_sodocument
+       {
+
+               function property_sodocument()
+               {
+                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->db                       = $GLOBALS['phpgw']->db;
+                       $this->db2                      = $this->db;
+                       $this->account          = 
$GLOBALS['phpgw_data']['user']['id'];
+                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon',True);
+                       $this->historylog       = 
CreateObject($this->currentapp.'_historylog','document');
+                       $this->vfs                      = 
CreateObject('phpgwapi_vfs');
+                       $this->rootdir          = $this->vfs->basedir;
+                       $this->fakebase         = $this->vfs->fakebase;
+
+                       $this->socommon         = 
CreateObject($this->currentapp.'_socommon');
+
+                       $this->join                     = $this->socommon->join;
+               }
+
+               function select_doc_type_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_document_category  ORDER BY descr ");
+
+                       $i = 0;
+                       while (!$dbresult->EOF)
+                       {
+                               $categories[$i]['id']                           
= $dbresult->fields['id'];
+                               $categories[$i]['name']                         
= stripslashes($dbresult->fields['descr']);
+                               $i++;
+                               $dbresult->MoveNext();
+                       }
+                       return $categories;
+               }
+
+               function read_single_category($id='')
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
descr FROM fm_document_category where id='$id' ");
+
+                       return $dbresult->fields['descr'];
+               }
+
+               function select_status_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_document_status ORDER BY id ");
+
+                       $i = 0;
+                       while (!$dbresult->EOF)
+                       {
+                               $status_entries[$i]['id']                       
        = $dbresult->fields['id'];
+                               $status_entries[$i]['name']                     
        = stripslashes($dbresult->fields['descr']);
+                               $i++;
+                               $dbresult->MoveNext();
+                       }
+                       return $status_entries;
+               }
+
+               function select_branch_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT id, 
descr FROM fm_branch ORDER BY id ");
+
+                       $i = 0;
+                       while (!$dbresult->EOF)
+                       {
+                               $branch_entries[$i]['id']                       
        = $dbresult->fields['id'];
+                               $branch_entries[$i]['name']                     
        = stripslashes($dbresult->fields['descr']);
+                               $i++;
+                               $dbresult->MoveNext();
+                       }
+                       return $branch_entries;
+               }
+
+               function read($data)
+               {
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $filter = 
(isset($data['filter'])?$data['filter']:'');
+                               $query = 
(isset($data['query'])?$data['query']:'');
+                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order = 
(isset($data['order'])?$data['order']:'');
+                               $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
+                               $entity_id = 
(isset($data['entity_id'])?$data['entity_id']:'');
+                       }
+
+                       $sql = $this->bocommon->fm_cache('sql_document_' . 
$entity_id);
+
+                       if(!$sql)
+                       {
+
+                       $document_table = 'fm_document';
+
+                       $cols .= $document_table . '.location_code';
+                       $cols_return[] = 'location_code';
+
+//                     $cols .= ",$document_table.id as document_id";
+//                     $cols_return[]                          = 'document_id';
+
+                       $groupmethod= " GROUP BY 
fm_document.location_code,fm_document.address  ";
+
+                       if ($entity_id)
+                       {
+                               $cols .= ",$document_table.p_num as p_num";
+                               $cols_return[]                          = 
'p_num';
+                               $uicols['input_type'][]         = 'text';
+                               $uicols['name'][]                       = 
'p_num';
+                               $uicols['descr'][]                      = 
lang('ID');
+                               $uicols['statustext'][]         = lang('ID');
+
+                               $cols .= ',fm_entity_category.name as category';
+                               $cols_return[]                          = 
'category';
+                               $uicols['input_type'][]         = 'text';
+                               $uicols['name'][]                       = 
'category';
+                               $uicols['descr'][]                      = 
lang('Type');
+                               $uicols['statustext'][]         = lang('Type');
+
+                               $cols .= ",$document_table.p_entity_id";
+                               $cols_return[]                          = 
'p_entity_id';
+                               $cols .= ",$document_table.p_cat_id";
+                               $cols_return[]                          = 
'p_cat_id';
+
+                               $joinmethod .= " $this->join  
fm_entity_category ON (fm_entity_category.entity_id 
=$document_table.p_entity_id AND fm_entity_category.id = 
$document_table.p_cat_id))";
+                               $paranthesis .='(';
+
+
+                               $groupmethod.= " 
,fm_document.p_entity_id,fm_entity_category.name,$document_table.p_num,fm_document.p_cat_id";
+                       }
+
+
+                       $sql    = 
$this->bocommon->generate_sql(array('entity_table'=>$document_table,'cols'=>$cols,'cols_return'=>$cols_return,
+                                                                               
                                
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query));
+
+
+                       $this->bocommon->fm_cache('sql_document_' . 
$entity_id,$sql);
+
+                       $this->uicols           = $this->bocommon->uicols;
+                       $cols_return            = $this->bocommon->cols_return;
+                       $type_id                        = 
$this->bocommon->type_id;
+                       $this->cols_extra       = $this->bocommon->cols_extra;
+
+                               $this->bocommon->fm_cache('uicols_document_' . 
$entity_id,$this->uicols);
+                               
$this->bocommon->fm_cache('cols_return_document_' . $entity_id,$cols_return);
+                               $this->bocommon->fm_cache('type_id_document_' . 
$entity_id,$type_id);
+                               
$this->bocommon->fm_cache('cols_extra_document_' . 
$entity_id,$this->cols_extra);
+
+                       }
+                       else
+                       {
+                               $this->uicols           = 
$this->bocommon->fm_cache('uicols_document_' . $entity_id);
+                               $cols_return            = 
$this->bocommon->fm_cache('cols_return_document_' . $entity_id);
+                               $type_id                        = 
$this->bocommon->fm_cache('type_id_document_' . $entity_id);
+                               $this->cols_extra       = 
$this->bocommon->fm_cache('cols_extra_document_' . $entity_id);
+                       }
+
+
+                       if ($order)
+                       {
+                               $ordermethod = " order by fm_document.$order 
$sort";
+                       }
+                       else
+                       {
+                               $ordermethod = ' order by 
fm_document.location_code ASC';
+                       }
+
+                       $where= 'WHERE';
+
+                       if(!$entity_id)
+                       {
+                               $filtermethod .= " $where ( fm_document.p_num 
is NULL OR fm_document.p_num='') ";
+                               $where= 'AND';
+                       }
+
+                       if ($cat_id)
+                       {
+                               $filtermethod .= " $where 
fm_document.p_cat_id=$cat_id ";
+                               $where= 'AND';
+                       }
+
+                       if ($filter!='all' && $filter)
+                       {
+                               $filtermethod .= " $where 
fm_document.user_id='$filter' ";
+                       }
+
+                       if($query)
+                       {
+                               $query = ereg_replace("'",'',$query);
+                               $query = ereg_replace('"','',$query);
+
+                               $querymethod = " $where (fm_document.address 
LIKE '%$query%' or fm_document.location_code LIKE '%$query%')";
+                       }
+
+
+                       $sql .= " $filtermethod $querymethod $groupmethod";
+
+//echo $sql;
+
+                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+                       $this->total_records = $dbresult2->_numOfRows;
+                       $maxmatchs = 15;
+
+                       if(!$allrows)
+                       {
+                               $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+                       }
+                       else
+                       {
+                               $dbresult = $GLOBALS['phpgw']->db->Execute($sql 
. $ordermethod);
+                       }
+
+                       $j=0;
+                       while (!$dbresult->EOF)
+                       {
+                               for ($i=0;$i<count($cols_return);$i++)
+                               {
+                                       $document_list[$j][$cols_return[$i]] = 
$this->db->f($cols_return[$i]);
+                               }
+
+                               $location_code= 
$dbresult->fields['location_code'];
+                               $location = split('-',$location_code);
+                               for ($m=0;$m<count($location);$m++)
+                               {
+                                       $document_list[$j]['loc' . ($m+1)] = 
$location[$m];
+                                       
$document_list[$j]['query_location']['loc' . ($m+1)]=implode("-", 
array_slice($location, 0, ($m+1)));
+                               }
+
+                               $j++;
+                               $dbresult->MoveNext();
+                       }
+
+
+//html_print_r($document_list);
+                       return $document_list;
+               }
+
+               function read_at_location($data)
+               {
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $filter = 
(isset($data['filter'])?$data['filter']:'');
+                               $query = 
(isset($data['query'])?$data['query']:'');
+                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order = 
(isset($data['order'])?$data['order']:'');
+                               $entity_id = 
(isset($data['entity_id'])?$data['entity_id']:0);
+                               $cat_id = 
(isset($data['cat_id'])?$data['cat_id']:0);
+                               $doc_type = 
(isset($data['doc_type'])?$data['doc_type']:0);
+                               $location_code = 
(isset($data['location_code'])?$data['location_code']:'');
+                       }
+
+                       if ($order)
+                       {
+                               $ordermethod = " order by $order $sort";
+                       }
+                       else
+                       {
+                               $ordermethod = ' order by location_code ASC';
+                       }
+
+                       $filtermethod = " 
fm_document.location_code='$location_code'";
+
+                       if ($doc_type > 0)
+                       {
+                               $filtermethod .= " AND 
fm_document.category='$doc_type' ";
+                       }
+                       if ($cat_id > 0)
+                       {
+                               $filtermethod .= " AND 
fm_document.p_cat_id=$cat_id AND fm_document.p_entity_id=$entity_id ";
+                       }
+
+
+                       if ($filter)
+                       {
+                               $filtermethod .= " AND 
fm_document.user_id='$filter' ";
+                       }
+
+                       if($query)
+                       {
+                               $query = ereg_replace("'",'',$query);
+                               $query = ereg_replace('"','',$query);
+
+                               $querymethod = " AND fm_document.title LIKE 
'%$query%' or fm_document.document_name LIKE '%$query%'";
+                       }
+
+                       $sql = "SELECT fm_document.*, 
fm_document_category.descr as category FROM fm_document $this->join 
fm_document_category on fm_document.category = fm_document_category.id WHERE  
$filtermethod $querymethod ";
+
+                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+                       $this->total_records = $dbresult2->_numOfRows;
+                       $maxmatchs = 15;
+
+                       if(!$allrows)
+                       {
+                               $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+                       }
+                       else
+                       {
+                               $dbresult = $GLOBALS['phpgw']->db->Execute($sql 
. $ordermethod);
+                       }
+
+                       while (!$dbresult->EOF)
+                       {
+                               $document_list[] = array
+                               (
+                                       'document_id'           => 
$dbresult->fields['id'],
+                                       'document_name'         => 
$dbresult->fields['document_name'],
+                                       'link'                          => 
$dbresult->fields['link'],
+                                       'title'                         => 
$dbresult->fields['title'],
+                                       'doc_type'                      => 
$dbresult->fields['category'],
+                                       'user_id'                       => 
$dbresult->fields['user_id']
+                                       );
+                               $dbresult->MoveNext();
+                       }
+//html_print_r($document_list);
+                       return $document_list;
+               }
+
+               function read_single($document_id)
+               {
+                       $sql = "SELECT * from fm_document where 
id='$document_id'";
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+
+                       if (!$dbresult->EOF)
+                       {
+                               $document['document_id']                = 
$dbresult->fields['id'];
+                               $document['title']                              
= $dbresult->fields['title'];
+                               $document['document_name']              = 
$dbresult->fields['document_name'];
+                               $document['link']                               
= $dbresult->fields['link'];
+                               $document['location_code']              = 
$dbresult->fields['location_code'];
+                               $document['branch_id']                  = 
$dbresult->fields['branch_id'];
+                               $document['version']                    = 
$dbresult->fields['version'];
+                               $document['vendor_id']                  = 
$dbresult->fields['vendor_id'];
+                               $document['floor_id']                   = 
$dbresult->fields['floor_id'];
+                               $document['descr']                              
= $dbresult->fields['descr'];
+                               $document['status']                             
= $dbresult->fields['status'];
+                               $document['user_id']                    = 
$dbresult->fields['user_id'];
+                               $document['coordinator']                = 
$dbresult->fields['coordinator'];
+                               $document['access']                             
= $dbresult->fields['access'];
+                               $document['document_date']              = 
$dbresult->fields['document_date'];
+                               $document['doc_type']                   = 
$dbresult->fields['category'];
+                               $document['p_num']                              
= $dbresult->fields['p_num'];
+                               $document['p_entity_id']                = 
$dbresult->fields['p_entity_id'];
+                               $document['p_cat_id']                   = 
$dbresult->fields['p_cat_id'];
+                       }
+
+//html_print_r($document);
+                               return $document;
+               }
+
+               function add($document)
+               {
+                       while (is_array($document['location']) && 
list($input_name,$value) = each($document['location']))
+                       {
+                               if($value)
+                               {
+                                       $cols[] = $input_name;
+                                       $vals[] = $value;
+                               }
+                       }
+
+                       while (is_array($document['extra']) && 
list($input_name,$value) = each($document['extra']))
+                       {
+                               if($value)
+                               {
+                                       $cols[] = $input_name;
+                                       $vals[] = $value;
+                               }
+                       }
+
+                       if($cols)
+                       {
+                               $cols   = "," . implode(",", $cols);
+                               $vals   = ",'" . implode("','", $vals) . "'";
+                       }
+
+                       if($document['street_name'])
+                       {
+                               $address[]= $document['street_name'];
+                               $address[]= $document['street_number'];
+                               $address        = implode(" ", $address);
+                       }
+
+                       if(!$address)
+                       {
+                               $address = $document['location_name'];
+                       }
+
+                       $document['descr'] = 
$this->db->db_addslashes($document['descr']);
+                       $document['name'] = 
$this->db->db_addslashes($document['name']);
+                       $document['title'] = 
$this->db->db_addslashes($document['title']);
+//html_print_r($document);
+
+                       $values= array(
+                               $document['document_name'],
+                               $document['link'],
+                               $document['title'],
+                               'public',
+                               $document['doc_type'],
+                               time(),
+                               $document['document_date'],
+                               $document['version'],
+                               $document['coordinator'],
+                               $document['status'],
+                               $document['descr'],
+                               $document['location_code'],
+                               $address,
+                               $document['branch_id'],
+                               $document['vendor_id'],
+                               $this->account);
+
+                       $values = $this->bocommon->validate_db_insert($values);
+
+                       $GLOBALS['phpgw']->db->Execute("INSERT INTO fm_document 
(document_name,link,title,access,category,entry_date,document_date,version,coordinator,status,"
+                               . 
"descr,location_code,address,branch_id,vendor_id,user_id $cols) "
+                               . "VALUES ($values $vals )");
+
+                       $receipt['document_id'] = 
$this->db->get_last_insert_id('fm_document','id');
+
+                       
$this->historylog->add('SO',$receipt['document_id'],$document['status']);
+                       
$this->historylog->add('TO',$receipt['document_id'],$document['doc_type']);
+                       if($document['coordinator'])
+                       {
+                               
$this->historylog->add('CO',$receipt['document_id'],$document['coordinator']);
+                       }
+                       if($document['document_name'])
+                       {
+                               
$this->historylog->add('FO',$receipt['document_id'],$document['coodocument_name']);
+                       }
+                       if($document['link'])
+                       {
+                               
$this->historylog->add('LO',$receipt['document_id'],$document['link']);
+                       }
+
+                       $receipt['message'][] = array('msg'=>lang('document %1 
has been saved',"'".$document['document_name']."'"));
+                       return $receipt;
+               }
+
+               function edit($document)
+               {
+                       while (is_array($document['location']) && 
list($input_name,$value) = each($document['location']))
+                       {
+                               $vals[] = "$input_name = '$value'";
+                       }
+
+                       while (is_array($document['extra']) && 
list($input_name,$value) = each($document['extra']))
+                       {
+                               $vals[] = "$input_name = '$value'";
+                       }
+
+                       if($vals)
+                       {
+                               $vals   = "," . implode(",",$vals);
+                       }
+
+                       if($document['street_name'])
+                       {
+                               $address[]= $document['street_name'];
+                               $address[]= $document['street_number'];
+                               $address        = implode(" ", $address);
+                       }
+
+                       if(!$address)
+                       {
+                               $address = $document['location_name'];
+                       }
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
status,category,coordinator,document_name,loc1,link,p_num FROM fm_document 
where id='" .$document['document_id']."'");
+
+
+                       $old_status = $dbresult->fields['status'];
+                       $old_doc_type = $dbresult->fields['category'];
+                       $old_coordinator = $dbresult->fields['coordinator'];
+                       $old_document_name = $dbresult->fields['document_name'];
+                       $old_loc1 = $dbresult->fields['loc1'];
+                       $old_link = $dbresult->fields['link'];
+                       $old_p_num = $dbresult->fields['p_num'];
+
+                       if ($old_status != $document['status'])
+                       {
+                               
$this->historylog->add('S',$document['document_id'],$document['status']);
+                       }
+                       if ($old_doc_type != $document['doc_type'])
+                       {
+                               
$this->historylog->add('T',$document['document_id'],$document['doc_type']);
+                       }
+                       if ((int)$old_coordinator != 
(int)$document['coordinator'])
+                       {
+                               
$this->historylog->add('C',$document['document_id'],$document['coordinator']);
+                       }
+
+                       if($document['document_name_orig'] && 
!$document['document_name'] )
+                       {
+                               $document['document_name'] = 
$document['document_name_orig'];
+                       }
+
+                       if($old_link !=$document['link'] )
+                       {
+                                       
$this->historylog->add('L',$document['document_id'],$document['link']);
+                                       $alter_link=True;
+                       }
+
+//html_print_r($document);
+                       if ($old_document_name && ($old_document_name != 
$document['document_name']))
+                       {
+                               if($document['link'] && !$alter_link)
+                               {
+                                       
$this->historylog->add('L',$document['document_id'],$document['link']);
+                               }
+                               else
+                               {
+                                       
$this->historylog->add('F',$document['document_id'],$document['document_name']);
+                               }
+
+                               if($old_p_num)
+                               {
+                                       $file = $this->fakebase. SEP . 
'document' . SEP . $old_loc1 . SEP . $document['entity_name'] . SEP . 
$document['category_name'] . SEP . $p_num . SEP . $old_document_name;
+                               }
+                               else
+                               {
+                                       $file = $this->fakebase. SEP . 
'document' . SEP . $old_loc1 . SEP . $old_document_name;
+                               }
+
+                               $receipt= $this->delete_file($file);
+                       }
+
+                       if($document['link'])
+                       {
+                               unset($document['document_name']);
+                       }
+
+                       $document['descr'] = 
$this->db->db_addslashes($document['descr']);
+                       $document['name'] = 
$this->db->db_addslashes($document['name']);
+                       $document['title'] = 
$this->db->db_addslashes($document['title']);
+
+                       $value_set=array(
+                               'document_name' =>$document['document_name'],
+                               'link'                  =>$document['link'],
+                               'title'                 =>$document['title'],
+                               'branch_id'             
=>$document['branch_id'],
+                               'status'                =>$document['status'],
+                               'category'              =>$document['doc_type'],
+                               'document_date' =>$document['document_date'],
+                               'coordinator'   =>$document['coordinator'],
+                               'descr'                 =>$document['descr'],
+                               'version'               =>$document['version'],
+                               'location_code' =>$document['location_code'],
+                               'vendor_id'             
=>$document['vendor_id'],
+                               'address'               =>$address
+                               );
+
+                       $value_set      = 
$this->bocommon->validate_db_update($value_set);
+
+                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_document set 
$value_set $vals WHERE id= '" . $document['document_id'] ."'");
+
+                       $receipt['document_id'] = $document['document_id'];
+                       $receipt['message'][] = array('msg'=>lang('document %1 
has been edited',"'".$document['title']."'"));
+                       return $receipt;
+
+               }
+
+               function delete_file($file)
+               {
+                       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 . 'document'. SEP . $document_name);
+                               }
+                               else
+                               {
+                                       
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'. 
$this->fakebase. SEP . 'document'. SEP . $document_name);
+                               }
+                               $this->vfs->override_acl = 0;
+                       }
+
+               }
+
+               function delete($document_id )
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
document_name,location_code,p_num,p_entity_id,p_cat_id FROM fm_document where 
id='$document_id'");
+
+                       $document_name  = $dbresult->fields['document_name'];
+                       $location_code  = $dbresult->fields['location_code'];
+                       $p_num                  = $dbresult->fields['p_num'];
+                       $p_entity_id    = $dbresult->fields['p_entity_id'];
+                       $p_cat_id               = $dbresult->fields['p_cat_id'];
+
+                       $location               = split("-", $location_code);
+                       $loc1   = $location[0];
+                       if($p_cat_id)
+                       {
+                               $boadmin_entity         = 
CreateObject($this->currentapp.'_boadmin_entity');
+                               $entity = 
$boadmin_entity->read_single($p_entity_id,false);
+                               $category = 
$boadmin_entity->read_single_category($p_entity_id,$p_cat_id);
+                       }
+
+                       if($document_name)
+                       {
+                               if($p_num)
+                               {
+                                       $file = $this->fakebase. SEP . 
'document' . SEP . $loc1 . SEP . $entity['name'] . SEP . $category['name'] . 
SEP . $p_num . SEP . $document_name;
+                               }
+                               else
+                               {
+                                       $file = $this->fakebase. SEP . 
'document' . SEP . $loc1 . SEP . $document_name;
+                               }
+
+                               $receipt= $this->delete_file($file);
+                       }
+
+                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_document 
WHERE id='$document_id'");
+                       $GLOBALS['phpgw']->db->Execute("DELETE FROM 
fm_document_history  WHERE  history_record_id='$document_id'");
+               }
+       }
+?>




reply via email to

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