phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc class.custom_functions.inc.php cro...


From: Sigurd Nes
Subject: [Phpgroupware-cvs] property/inc class.custom_functions.inc.php cro...
Date: Tue, 27 Feb 2007 10:11:29 +0000

CVSROOT:        /sources/phpgroupware
Module name:    property
Changes by:     Sigurd Nes <sigurdne>   07/02/27 10:11:29

Modified files:
        inc            : class.custom_functions.inc.php 
Added files:
        inc/cron       : cron.php forward_mail_as_sms.php 
                         lag_lang_filer.php 
                         oppdater_antall_leieobjekt.php 
                         oppdater_namssakstatus_pr_leietaker.php 
                         oppdater_utgaatt_objekt.php 
                         organize_drawing.php synkroniser_med_boei.php 
Removed files:
        inc/custom     : cron.php forward_mail_as_sms.php 
                         lag_lang_filer.php 
                         oppdater_antall_leieobjekt.php 
                         oppdater_namssakstatus_pr_leietaker.php 
                         oppdater_utgaatt_objekt.php 
                         organize_drawing.php synkroniser_med_boei.php 

Log message:
        Organize cron and custom add-in-funksjons

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/property/inc/class.custom_functions.inc.php?cvsroot=phpgroupware&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/cron.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/forward_mail_as_sms.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/lag_lang_filer.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/oppdater_antall_leieobjekt.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/oppdater_namssakstatus_pr_leietaker.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/oppdater_utgaatt_objekt.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/organize_drawing.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/cron/synkroniser_med_boei.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/cron.php?cvsroot=phpgroupware&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/forward_mail_as_sms.php?cvsroot=phpgroupware&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/lag_lang_filer.php?cvsroot=phpgroupware&r1=1.7&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/oppdater_antall_leieobjekt.php?cvsroot=phpgroupware&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/oppdater_namssakstatus_pr_leietaker.php?cvsroot=phpgroupware&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/oppdater_utgaatt_objekt.php?cvsroot=phpgroupware&r1=1.10&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/organize_drawing.php?cvsroot=phpgroupware&r1=1.7&r2=0
http://cvs.savannah.gnu.org/viewcvs/property/inc/custom/synkroniser_med_boei.php?cvsroot=phpgroupware&r1=1.10&r2=0

Patches:
Index: class.custom_functions.inc.php
===================================================================
RCS file: /sources/phpgroupware/property/inc/class.custom_functions.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- class.custom_functions.inc.php      26 Feb 2007 13:45:00 -0000      1.9
+++ class.custom_functions.inc.php      27 Feb 2007 10:11:29 -0000      1.10
@@ -24,12 +24,13 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package property
        * @subpackage core
-       * @version $Id: class.custom_functions.inc.php,v 1.9 2007/02/26 
13:45:00 sigurdne Exp $
+       * @version $Id: class.custom_functions.inc.php,v 1.10 2007/02/27 
10:11:29 sigurdne Exp $
        */
 
        /**
-        * This is a class used to gain access to custom classes stored in 
/inc/custom to be run as cron jobs
+        * This is a class used to gain access to custom classes stored in 
/inc/cron to be run as cron jobs
         * or from the admin interface.
+        * usage (example): /usr/local/bin/php -q 
/var/www/html/phpgroupware/property/inc/cron/cron.php default 
forward_mail_as_sms user=<username> cellphone=<phonenumber>
         * @package property
         */
 
@@ -74,7 +75,7 @@
                                }
                        }
 
-                       
include_once(PHPGW_SERVER_ROOT.'/'.'property'.'/inc/custom/' . 
$data['function'] . '.php');
+                       
include_once(PHPGW_SERVER_ROOT.'/'.'property'.'/inc/cron/' . $data['function'] 
. '.php');
                        $custom = new $data['function'];
                        $custom->pre_run($data);
                }

Index: cron/cron.php
===================================================================
RCS file: cron/cron.php
diff -N cron/cron.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/cron.php       27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,74 @@
+#!/usr/bin/php -q
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage admin
+       * @version $Id: cron.php,v 1.1 2007/02/27 10:11:29 sigurdne Exp $
+       */
+
+       /**
+        * Description
+        * example cron : /usr/local/bin/php -q 
/var/www/html/phpgroupware/property/inc/cron/cron.php default 
forward_mail_as_sms user=<username> cellphone=<phonenumber>
+        */
+
+       $path_to_phpgroupware = dirname(__FILE__) . '/../../..';        // need 
to be adapted if this script is moved somewhere else
+       $_GET['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 
'default';
+
+
+       if(!$function = $_SERVER['argv'][2])
+
+       {
+               echo date('Y/m/d H:i:s ') . " Nothing to execute\n";
+               return;
+       }
+
+//     echo $function;
+
+       $GLOBALS['phpgw_info']['flags'] = array(
+               'currentapp' => 'login',
+               'noapi'      => True            // this stops header.inc.php to 
include phpgwapi/inc/function.inc.php
+       );
+       include($path_to_phpgroupware.'/header.inc.php');
+       unset($GLOBALS['phpgw_info']['flags']['noapi']);
+
+       $db_type = $GLOBALS['phpgw_domain'][$_GET['domain']]['db_type'];
+
+       $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db';
+
+       include(PHPGW_API_INC.'/functions.inc.php');
+
+       $data = array('function' => $function,'enabled'=>1);
+       while ($argc > 3)
+       {
+               list($key,$value) = explode('=',$argv[3]);
+               $data[$key] = $value;
+               array_shift($argv);
+               --$argc;
+       }
+
+       $num = ExecMethod('property.custom_functions.index',$data);
+       // echo date('Y/m/d H:i:s ').$_GET['domain'].': '.($num ? "$num job(s) 
executed" : 'Nothing to execute')."\n";
+
+       $GLOBALS['phpgw']->common->phpgw_exit();

Index: cron/forward_mail_as_sms.php
===================================================================
RCS file: cron/forward_mail_as_sms.php
diff -N cron/forward_mail_as_sms.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/forward_mail_as_sms.php        27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,178 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: forward_mail_as_sms.php,v 1.1 2007/02/27 10:11:29 
sigurdne Exp $
+       */
+
+       /**
+        * Description
+        * usage: 
+        * @package property
+        */
+
+       class forward_mail_as_sms
+       {
+               var     $function_name = 'forward_mail_as_sms';
+
+               function forward_mail_as_sms()
+               {
+                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->db                       = 
$this->bocommon->new_db();
+               }
+
+               function pre_run($data='')
+               {
+                       if(isset($data['enabled']) && $data['enabled']==1)
+                       {
+                               $confirm        = True;
+                               $cron           = True;
+                               $data['account_id'] = 
$GLOBALS['phpgw']->accounts->name2id($data['user']);
+                               
$GLOBALS['phpgw']->session->appsession('session_data','mail2sms',$data);
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                               $cron = false;
+                       }
+
+
+                       if (isset($confirm) && $confirm)
+                       {
+                               $this->execute($cron);
+                       }
+                       else
+                       {
+                               $this->confirm($execute=False);
+                               $data['account_id'] = 
$GLOBALS['phpgw']->accounts->name2id($data['user']);
+                               
$GLOBALS['phpgw']->session->appsession('session_data','mail2sms',$data);
+                       }
+               }
+
+               function confirm($execute='')
+               {
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
+                               'function'      => $this->function_name,
+                               'execute'       => $execute,
+                       );
+
+                       if(!$execute)
+                       {
+                               $lang_confirm_msg       = lang('Do you want to 
execute this action?');
+                       }
+
+                       $lang_yes                       = lang('yes');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+                       $msgbox_data = 
isset($this->receipt)?$this->bocommon->msgbox_data($this->receipt):'';
+
+                       $data = array
+                       (
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'message'                               => 
$this->receipt['message'],
+                               'lang_confirm_msg'              => 
$lang_confirm_msg,
+                               'lang_yes'                              => 
$lang_yes,
+                               'lang_yes_statustext'   => lang('Check for new 
mail - and forward as sms'),
+                               'lang_no_statustext'    => 'tilbake',
+                               'lang_no'                               => 
lang('no'),
+                               'lang_done'                             => 
lang('cancel'),
+                               'lang_done_statustext'  => 'tilbake'
+                       );
+
+                       $appname                = lang('Async service');
+                       $function_msg   = 'Forward email as SMS';
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+                       $GLOBALS['phpgw']->xslttpl->pp();
+               }
+
+               function execute($cron='')
+               {
+                       $receipt = $this->check_for_new_mail();
+                       $this->cron_log($receipt,$cron);
+
+                       if(!$cron)
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+               function cron_log($receipt='',$cron='')
+               {
+                       $insert_values= array(
+                               $cron,
+                               date($this->bocommon->datetimeformat),
+                               $this->function_name,
+                               $receipt
+                               );
+
+                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
+                                       . "VALUES ($insert_values)";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function check_for_new_mail()
+               {
+                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','mail2sms');
+
+                       $GLOBALS['phpgw_info']['user']['account_id'] = 
$data['account_id'];
+                       $GLOBALS['phpgw']->preferences->account_id = 
$data['account_id'];
+                       $pref = 
$GLOBALS['phpgw']->preferences->read_repository();
+                       
$GLOBALS['phpgw_info']['user']['preferences']['felamimail'] = 
isset($pref['felamimail']) ? $pref['felamimail'] : '';
+
+                       $bofelamimail   = 
CreateObject('felamimail.bofelamimail');
+                       $connectionStatus = $bofelamimail->openConnection();
+                       $headers = $bofelamimail->getHeaders(0, $maxMessages = 
15, $sort = 6);
+
+                       $j = 0;
+                       foreach ($headers['header'] as $header)
+                       {
+                               if($header['seen'] == 0)
+                               {
+                                       $sms[$j]['message'] = 
$header['subject'];
+                                       $bodyParts = 
$bofelamimail->getMessageBody($header['uid']);
+                                       $sms[$j]['message'] .= "\n";
+                                       for($i=0; $i<count($bodyParts); $i++ )
+                                       {
+                                               $sms[$j]['message'] .= 
$bodyParts[$i]['body'];
+                                       }
+
+                                       $sms[$j]['message'] = 
substr($sms[$j]['message'],0,160);
+                                       $j++;
+                               }
+                       }
+                       if($connectionStatus == 'True')
+                       {
+                               $bofelamimail->closeConnection();
+                       }
+
+                       $bosms  = CreateObject('sms.bosms',False);
+                       if(isset($sms) && is_array($sms))
+                       {
+                               foreach ($sms as $entry)
+                               {
+                                       
$bosms->send_sms(array('p_num_text'=>$data['cellphone'], 'message' 
=>$entry['message']));
+                               }
+                       }
+
+                       $msg = $j . ' messages er sendt';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+               }
+       }
+?>

Index: cron/lag_lang_filer.php
===================================================================
RCS file: cron/lag_lang_filer.php
diff -N cron/lag_lang_filer.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/lag_lang_filer.php     27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,67 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: lag_lang_filer.php,v 1.1 2007/02/27 10:11:29 sigurdne 
Exp $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class lag_lang_filer
+       {
+               var     $function_name = 'lag_lang_filer';
+
+               function lag_lang_filer()
+               {
+                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->db               = $this->bocommon->new_db();
+               }
+               
+               function pre_run($data='')
+               {
+                       if($data['enabled']==1)
+                       {
+                               $confirm        = True;
+                               $cron           = True;
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                       }
+                       if ($confirm)
+                       {
+                               $this->execute($cron);
+                       }
+                       else
+                       {
                                $this->confirm($execute=False);
                        }
                }


                function confirm($execute='')
                {
                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.custom_functions.index',
                                'function'      =>$this->function_name,
                                'execute'       => $execute,
                        );

                        if(!$execute)
                        {
                                $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
                        }
+                       $lang_yes                       = lang('yes');
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+                       $data = array
                        (
                                'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
                                'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'message'                               => 
$this->receipt['message'],
                                'lang_confirm_msg'              => 
$lang_confirm_msg,
                                'lang_yes'                              => 
$lang_yes,
                                'lang_yes_statustext'   => 'lag_lang_filer fra 
database',
                                'lang_no_statustext'    => 'tilbake',
                                'lang_no'                               => 
lang('no'),
                                'lang_done'                             => 
'Avbryt',
                                'lang_done_statustext'  => 'tilbake'
                        );

                        $appname                = lang('location');
                        $function_msg   = 'lag_lang_filer';
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
                        $GLOBALS['phpgw']->xslttpl->pp();
                }

                function execute($cron='')
                {

                        $sql = "SELECT * from phpgw_lang WHERE app_name = 
'property' AND lang='no' ORDER BY message_id ASC";

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

                        $i=0;
                        while ($this->db->next_record())
                        {
                                        $str.=$this->db->f('message_id') ."\t";
                                        $str.=$this->db->f('app_name') ."\t";
                                        $str.=$this->db->f('lang') ."\t";
                                        $str.=$this->db->f('content') ."\n";
                                        $i++;
                        }

_debug_array($str);
/*                         $filename= 'phpgw_no_lang';

                                $size=strlen($str);

                                $browser = CreateObject('phpgwapi.browser');
                                
$browser->content_header($filename,'application/txt',$size);

                                echo $str;
*/

                        $this->receipt['message'][]=array('msg'=> $i . ' 
tekster lagt til');

                        if(!$cron)
                        {
                                $this->confirm($execute=False);
                        }
                }
        }
?>

Index: cron/oppdater_antall_leieobjekt.php
===================================================================
RCS file: cron/oppdater_antall_leieobjekt.php
diff -N cron/oppdater_antall_leieobjekt.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/oppdater_antall_leieobjekt.php 27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,177 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: oppdater_antall_leieobjekt.php,v 1.1 2007/02/27 
10:11:29 sigurdne Exp $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class oppdater_antall_leieobjekt
+       {
+               var     $function_name = 'oppdater_antall_leieobjekt';
+
+               function oppdater_antall_leieobjekt()
+               {
+                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->db                       = 
$this->bocommon->new_db();
+                       $this->db2                      = 
$this->bocommon->new_db();
+                       $this->soadmin_location = 
CreateObject($this->currentapp.'.soadmin_location');
+
+                       $this->join                     = $this->bocommon->join;
+                       $this->left_join                = 
$this->bocommon->left_join;
+               }
+
+               function pre_run($data='')
+               {
+                       if($data['enabled']==1)
+                       {
+                               $confirm        = True;
+                               $cron           = True;
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                       }
+
+                       if ($confirm)
+                       {
+                               $this->execute($cron);
+                       }
+                       else
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+
+               function confirm($execute='')
+               {
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
+                               'function'      =>$this->function_name,
+                               'execute'       => $execute,
+                       );
+
+
+                       if(!$execute)
+                       {
+                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
+                       }
+
+                       $lang_yes                       = lang('yes');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $data = array
+                       (
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'message'                               => 
$this->receipt['message'],
+                               'lang_confirm_msg'              => 
$lang_confirm_msg,
+                               'lang_yes'                              => 
$lang_yes,
+                               'lang_yes_statustext'   => 'Oppdater antall 
leieobjekter for tv-anlegg',
+                               'lang_no_statustext'    => 'tilbake',
+                               'lang_no'                               => 
lang('no'),
+                               'lang_done'                             => 
'Avbryt',
+                               'lang_done_statustext'  => 'tilbake'
+                       );
+
+                       $appname                = lang('location');
+                       $function_msg   = 'Oppdater antall leieobjekter for 
tv-anlegg';
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+                       $GLOBALS['phpgw']->xslttpl->pp();
+               }
+
+               function execute($cron='')
+               {
+
+                       $this->db->transaction_begin();
+
+
+                       $sql = "SELECT kunde_nr_lev, fm_entity_1_3.loc1, 
fm_entity_1_3.loc2, Count(fm_location4.location_code) AS antall_leieobjekt, 
fm_entity_1_3.location_code
+                                       FROM fm_entity_1_3 INNER JOIN 
fm_location4 ON (fm_entity_1_3.loc1 = fm_location4.loc1) AND 
(fm_entity_1_3.loc2 = fm_location4.loc2)
+                                       WHERE fm_location4.category IN 
(1,2,3,4,6,10,14,15,17,22,23,24,25)
+                                       GROUP BY kunde_nr_lev, 
fm_entity_1_3.loc1, fm_entity_1_3.loc2, fm_entity_1_3.location_code";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       while ($this->db->next_record())
+                       {
+                               if($this->db->f('kunde_nr_lev'))
+                               {
+                                       $update[]= array(
+                                       'kunde_nr_lev'  
=>$this->db->f('kunde_nr_lev'),
+                                       'antall_leieobjekt'     
=>$this->db->f('antall_leieobjekt'),
+                                       );
+                               }
+                       }
+
+//_debug_array($update);
+
+                       for ($i=0; $i<count($update); $i++)
+                       {
+                               $this->db->query("UPDATE fm_entity_1_3 set 
ant_leil_pt =" . $update[$i]['antall_leieobjekt'] . " WHERE kunde_nr_lev= '" . 
$update[$i]['kunde_nr_lev'] . "'" ,__LINE__,__FILE__);
+                       }
+
+                       $this->receipt['message'][]=array('msg'=>'antall 
leieobjekter er oppdatert for tv-anlegg');
+
+                       unset($update);
+
+                       $this->db->transaction_commit();
+
+                       if(!$cron)
+                       {
+                               $this->confirm($execute=False);
+                       }
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $insert_values= array(
+                               $cron,
+                               date($this->bocommon->datetimeformat),
+                               $this->function_name,
+                               implode(',',(array_keys($msgbox_data)))
+                               );
+
+                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
+                                       . "VALUES ($insert_values)";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+       }
+?>

Index: cron/oppdater_namssakstatus_pr_leietaker.php
===================================================================
RCS file: cron/oppdater_namssakstatus_pr_leietaker.php
diff -N cron/oppdater_namssakstatus_pr_leietaker.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/oppdater_namssakstatus_pr_leietaker.php        27 Feb 2007 10:11:29 
-0000      1.1
@@ -0,0 +1,214 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: oppdater_namssakstatus_pr_leietaker.php,v 1.1 
2007/02/27 10:11:29 sigurdne Exp $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class oppdater_namssakstatus_pr_leietaker
+       {
+               var     $function_name = 'oppdater_namssakstatus_pr_leietaker';
+
+               function oppdater_namssakstatus_pr_leietaker()
+               {
+                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->db                       = 
$this->bocommon->new_db();
+                       $this->db2                      = 
$this->bocommon->new_db();
+
+                       $this->join                     = $this->bocommon->join;
+                       $this->left_join                = 
$this->bocommon->left_join;
+                       $this->like                     = $this->bocommon->like;
+
+                       $this->db_boei                  = 
CreateObject($this->currentapp.'.db_mssql');
+                       $this->db_boei->Host            = 
$GLOBALS['external_db']['boei']['db_host'];
+                       $this->db_boei->Type            = 
$GLOBALS['external_db']['boei']['db_type'];
+                       $this->db_boei->Database        = 
$GLOBALS['external_db']['boei']['db_name'];
+                       $this->db_boei->User            = 
$GLOBALS['external_db']['boei']['db_user'];
+                       $this->db_boei->Password        = 
$GLOBALS['external_db']['boei']['db_pass'];
+                       $this->db_boei->Halt_On_Error   = 'yes';
+               }
+
+               function pre_run($data='')
+               {
+                       if($data['enabled']==1)
+                       {
+                               $confirm        = True;
+                               $cron           = True;
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                       }
+
+                       if ($confirm)
+                       {
+                               $this->execute($cron);
+                       }
+                       else
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+
+               function confirm($execute='')
+               {
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
+                               'function'      =>$this->function_name,
+                               'execute'       => $execute,
+                       );
+
+
+                       if(!$execute)
+                       {
+                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
+                       }
+
+                       $lang_yes                       = lang('yes');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $data = array
+                       (
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'message'                               => 
$this->receipt['message'],
+                               'lang_confirm_msg'              => 
$lang_confirm_msg,
+                               'lang_yes'                              => 
$lang_yes,
+                               'lang_yes_statustext'   => lang('Update the 
category to not active based on if there is only nonactive apartments'),
+                               'lang_no_statustext'    => 'tilbake',
+                               'lang_no'                               => 
lang('no'),
+                               'lang_done'                             => 
'Avbryt',
+                               'lang_done_statustext'  => 'tilbake'
+                       );
+
+                       $appname                = lang('location');
+                       $function_msg   = 'Oppdatere namssaksstatus pr 
leietater';
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+                       $GLOBALS['phpgw']->xslttpl->pp();
+               }
+
+               function execute($cron='')
+               {
+
+                       $receipt = $this->oppdater_namssakstatus();
+                       $this->cron_log($receipt,$cron);
+
+                       if(!$cron)
+                       {
+                               $this->confirm($execute=False);
+                       }
+
+               }
+
+               function cron_log($receipt='',$cron='')
+               {
+
+                       $insert_values= array(
+                               $cron,
+                               date($this->bocommon->datetimeformat),
+                               $this->function_name,
+                               $receipt
+                               );
+
+                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
+                                       . "VALUES ($insert_values)";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function oppdater_namssakstatus()
+               {
+
+                       $sql = "SELECT TOP 100 PERCENT fm_tenant.id"
+                                       . " FROM  fm_tenant LEFT OUTER JOIN"
+                    . " v_Leietaker ON fm_tenant.id = v_Leietaker.leietaker_id 
AND "
+                    . " fm_tenant.status_drift = 
v_Leietaker.namssakstatusdrift_id AND "
+                    . " fm_tenant.status_eco = 
v_Leietaker.namssakstatusokonomi_id"
+                                       . " WHERE (v_Leietaker.leietaker_id IS 
NULL)";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       while ($this->db_boei->next_record())
+                       {
+                               $leietaker[]= $this->db_boei->f('id');
+                       }
+
+                       for ($i=0; $i<count($leietaker); $i++)
+                       {
+                               $sql = "SELECT namssakstatusokonomi_id, 
namssakstatusdrift_id"
+                                       . " FROM  v_Leietaker"
+                                       . " WHERE (v_Leietaker.leietaker_id = 
'" . $leietaker[$i] . "')";
+
+                               $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                               $this->db_boei->next_record();
+                               $leietaker_oppdatert[]= array (
+                                'id'                           => 
$leietaker[$i],
+                                'status_drift'         => 
$this->db_boei->f('namssakstatusdrift_id'),
+                                'status_eco'           => 
$this->db_boei->f('namssakstatusokonomi_id')
+                                );
+
+                       }
+
+                       for ($i=0; $i<count($leietaker_oppdatert); $i++)
+                       {
+                               $sql = " UPDATE fm_tenant SET "
+                               . " status_eco = '" . 
$leietaker_oppdatert[$i]['status_eco'] . "',"
+                               . " status_drift = '" . 
$leietaker_oppdatert[$i]['status_drift'] . "'"
+                               . " WHERE  id = '" . 
$leietaker_oppdatert[$i]['id'] . "'";
+
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db_boei->query($sql,__LINE__,__FILE__);
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = $i . ' namssakstatus er oppdatert';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+
+               }
+       }
+?>

Index: cron/oppdater_utgaatt_objekt.php
===================================================================
RCS file: cron/oppdater_utgaatt_objekt.php
diff -N cron/oppdater_utgaatt_objekt.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/oppdater_utgaatt_objekt.php    27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,254 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: oppdater_utgaatt_objekt.php,v 1.1 2007/02/27 10:11:29 
sigurdne Exp $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class oppdater_utgaatt_objekt
+       {
+               var     $function_name = 'oppdater_utgaatt_objekt';
+
+               function oppdater_utgaatt_objekt()
+               {
+                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->db                       = 
$this->bocommon->new_db();
+                       $this->db2                      = 
$this->bocommon->new_db();
+                       $this->soadmin_location = 
CreateObject($this->currentapp.'.soadmin_location');
+
+                       $this->join                     = $this->bocommon->join;
+                       $this->left_join                = 
$this->bocommon->left_join;
+               }
+
+               function pre_run($data='')
+               {
+                       if($data['enabled']==1)
+                       {
+                               $confirm        = True;
+                               $cron           = True;
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                       }
+
+                       if ($confirm)
+                       {
+                               $this->execute($cron);
+                       }
+                       else
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+
+               function confirm($execute='')
+               {
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
+                               'function'      =>$this->function_name,
+                               'execute'       => $execute,
+                       );
+
+
+                       if(!$execute)
+                       {
+                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
+                       }
+
+                       $lang_yes                       = lang('yes');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $data = array
+                       (
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'message'                               => 
$this->receipt['message'],
+                               'lang_confirm_msg'              => 
$lang_confirm_msg,
+                               'lang_yes'                              => 
$lang_yes,
+                               'lang_yes_statustext'   => lang('Update the 
category to not active based on if there is only nonactive apartments'),
+                               'lang_no_statustext'    => 'tilbake',
+                               'lang_no'                               => 
lang('no'),
+                               'lang_done'                             => 
'Avbryt',
+                               'lang_done_statustext'  => 'tilbake'
+                       );
+
+                       $appname                = lang('location');
+                       $function_msg   = lang('Update the not active category 
for locations');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+                       $GLOBALS['phpgw']->xslttpl->pp();
+               }
+
+               function execute($cron='')
+               {
+                       $location_types = 
$this->soadmin_location->select_location_type();
+
+                       $m= count($location_types);
+
+
+                       $this->db->query("UPDATE fm_location" . $m. " set       
status= 2  WHERE category=99",__LINE__,__FILE__);
+
+                       for ($type_id=$m; $type_id>1; $type_id--)
+                       {
+                               $parent_table = 'fm_location' . ($type_id-1);
+
+                               $joinmethod .= " $this->join $parent_table";
+
+                               $paranthesis .='(';
+
+                               $on = 'ON';
+                               for ($i=($type_id-1); $i>0; $i--)
+                               {
+                                       $joinmethod .= " $on (fm_location" . 
($type_id) .".loc" . ($i). ' = '.$parent_table . ".loc" . ($i) . ")";
+                                       $on = 'AND';
+                                       if($i==1)
+                                       {
+                                               $joinmethod .= ")";
+                                       }
+                               }
+
+                               $sql = "SELECT $parent_table.location_code 
,count(*) as count_99  FROM $paranthesis fm_location$type_id $joinmethod where 
fm_location$type_id.status=2 group by $parent_table.location_code ";
+                               $this->db->query($sql,__LINE__,__FILE__);
+
+                               while ($this->db->next_record())
+                               {
+                                       
$outdated[$this->db->f('location_code')]['count_99']=$this->db->f('count_99');
+                               }
+
+                               $sql = "SELECT $parent_table.location_code 
,count(*) as count_all  FROM $paranthesis fm_location$type_id $joinmethod group 
by $parent_table.location_code ";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               while ($this->db->next_record())
+                               {
+                                       if( 
$outdated[$this->db->f('location_code')]['count_99']==$this->db->f('count_all'))
+                                       {
+                                               $update[]=array('location_code' 
=> $this->db->f('location_code'));
+                                       }
+                               }
+
+                               $metadata = 
$this->db->metadata('fm_location'.($type_id-1));
+
+                               if(isset($this->db->adodb))
+                               {
+                                       $i = 0;
+                                       foreach($metadata as $key => $val)
+                                       {
+                                               $metadata_temp[$i]['name'] = 
$key;
+                                               $i++;
+                                       }
+                                       $metadata = $metadata_temp;
+                                       unset ($metadata_temp);
+                               }
+
+                               $j=0;
+                               for ($i=0; $i<count($update); $i++)
+                               {
+                                       $this->db->transaction_begin();
+
+                                       $sql = "SELECT category FROM 
$parent_table WHERE location_code= '" . $update[$i]['location_code'] ."'";
+
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+                                       $this->db->next_record();
+
+                                       if($this->db->f('category')!=99)
+                                       {
+                                               $sql = "SELECT * from 
$parent_table WHERE location_code ='" . $update[$i]['location_code'] . "'";
+                                               
$this->db->query($sql,__LINE__,__FILE__);
+                                               $this->db->next_record();
+
+                                               for ($k=0; $k<count($metadata); 
$k++)
+                                               {
+                                                       $cols[] = 
$metadata[$k]['name'];
+                                                       $vals[] = 
$this->db->f($metadata[$k]['name']);
+                                               }
+
+                                               $cols[] = 'exp_date';
+                                               $vals[] = 
date($this->bocommon->datetimeformat,time());
+
+                                               $cols   =implode(",", $cols);
+                                               $vals = 
$this->bocommon->validate_db_insert($vals);
+
+                                               $sql = "INSERT INTO 
fm_location" . ($type_id-1) ."_history ($cols) VALUES ($vals)";
+                                               
$this->db->query($sql,__LINE__,__FILE__);
+                                               unset($cols);
+                                               unset($vals);
+
+                                               $j++;
+                                               $this->db->query("UPDATE 
fm_location" . ($type_id-1). " set     status= 2, category=99, change_type=2  
WHERE location_code= '" . $update[$i]['location_code'] ."'",__LINE__,__FILE__);
+                                               if($type_id == 2)
+                                               {
+                                                       
$this->db->query("UPDATE fm_location1 set kostra_id = NULL  WHERE 
location_code= '" . $update[$i]['location_code'] ."'",__LINE__,__FILE__);
+                                               }
+                                       }
+                               }
+
+                               
$this->receipt['message'][]=array('msg'=>lang('%1 location %2 has been updated 
to not active of %3 already not 
active',$j,$location_types[($type_id-2)]['descr'],count($update)));
+
+                               $log_msg .= lang('%1 location %2 has been 
updated to not active of %3 already not 
active',$j,$location_types[($type_id-2)]['descr'],count($update));
+                               unset($outdated);
+                               unset($update);
+                               unset($joinmethod);
+                               unset($paranthesis);
+                               unset($metadata);
+                               $this->db->transaction_commit();
+                       }
+
+
+                       if(!$cron)
+                       {
+                               $this->confirm($execute=False);
+                       }
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $insert_values= array(
+                               $cron,
+                               date($this->bocommon->datetimeformat),
+                               $this->function_name,
+                               implode(',',(array_keys($msgbox_data)))
+                               );
+
+                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
+                                       . "VALUES ($insert_values)";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+       }
+?>

Index: cron/organize_drawing.php
===================================================================
RCS file: cron/organize_drawing.php
diff -N cron/organize_drawing.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/organize_drawing.php   27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,456 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: organize_drawing.php,v 1.1 2007/02/27 10:11:29 sigurdne 
Exp $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class organize_drawing
+       {
+               /* In Admin->Property->Async servises:
+               *  Name: property.custom_functions.index
+               *  Data: function=organize_drawing,dir=C:/path/to/drawings
+               */
+
+               var     $dir = '/mnt/filer2/Tegninger';
+               var     $suffix = 'dwg';
+               var     $bypass = False; // bypass location check (only for 
debugging)
+               var     $function_name = 'organize_drawing';
+
+               function organize_drawing()
+               {
+                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->vfs              = CreateObject('phpgwapi.vfs');
+                       $this->rootdir          = $this->vfs->basedir;
+                       $this->fakebase         = $this->vfs->fakebase;
+                       $this->db               = $this->bocommon->new_db();
+
+               }
+
+               function pre_run($data='')
+               {
+
+                       if($data['enabled']==1)
+                       {
+                               $confirm                = True;
+                               $execute                = True;
+                               $cron                   = True;
+                               if($data['suffix'])
+                               {
+                                       $this->suffix = $data['suffix'];
+                               }
+                               if($data['dir'])
+                               {
+                                       $this->dir = $data['dir'];
+                               }
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                               if(get_var('dir',array('GET')))
+                               {
+                                       $this->dir = urldecode 
(get_var('dir',array('GET')));
+                               }
+                               if(get_var('suffix',array('GET')))
+                               {
+                                       $this->suffix = 
get_var('suffix',array('GET'));
+                               }
+                       }
+
+                       if(!$execute)
+                       {
+                               $dry_run=True;
+                       }
+
+                       if ($confirm)
+                       {
+                               $this->execute($dry_run,$cron);
+                       }
+                       else
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+               function confirm($execute='',$done='')
+               {
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
+                               'function'      => $this->function_name,
+                               'execute'       => $execute,
+                               'dir'           => $this->dir,
+                               'suffix'        => $this->suffix,
+                       );
+
+                       if(!$done)
+                       {
+                               if(!$execute)
+                               {
+                                       $lang_confirm_msg       = 'Gå videre 
for å se hva som blir lagt til';
+                               }
+                               else
+                               {
+                                       $lang_confirm_msg       = 'Vil du 
virkelig utføre denne operasjonen';
+                               }
+                       }
+                       $lang_yes                       = lang('yes');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $data = array
+                       (
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'message'                               => 
$this->receipt['message'],
+                               'lang_confirm_msg'              => 
$lang_confirm_msg,
+                               'lang_yes'                              => 
$lang_yes,
+                               'lang_yes_statustext'   => 'Organisere 
tegninger i register og på disk',
+                               'lang_no_statustext'    => 'tilbake',
+                               'lang_no'                               => 
lang('no'),
+                               'lang_done'                             => 
'Avbryt',
+                               'lang_done_statustext'  => 'tilbake'
+                       );
+
+                       $appname                = 'Organisere tegninger';
+                       $function_msg   = 'Organisere tegninger i register og 
på disk';
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+                       $GLOBALS['phpgw']->xslttpl->pp();
+               }
+
+               function execute($dry_run='',$cron='')
+               {
+
+                       $file_list = $this->get_files();
+
+                       if($dry_run)
+                       {
+                               $this->confirm($execute=True);
+                               _debug_array($file_list);
+                       }
+                       else
+                       {
+                               if (isSet($file_list) AND is_array($file_list))
+                               {
+                                       foreach($file_list as $file_entry)
+                                       {
+                                               $loc1_list[$file_entry['loc1']] 
= True;
+                                       }
+
+                                       $loc1_list = array_keys($loc1_list);
+
+                                       for ($i=0;$i<count($loc1_list);$i++)
+                                       {
+                                               
$this->create_loc1_dir($loc1_list[$i]);
+                                       }
+
+                                       for ($i=0;$i<count($file_list);$i++)
+                                       {
+                                               
$this->copy_files($file_list[$i]);
+                                       }
+                               }
+                               if(!$cron)
+                               {
+                                       
$this->confirm($execute=false,$done=True);
+                               }
+
+                               $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                               $insert_values= array(
+                                       $cron,
+                                       date($this->bocommon->datetimeformat),
+                                       $this->function_name,
+                                       implode(',',(array_keys($msgbox_data)))
+                                       );
+
+                               $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                               $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
+                                               . "VALUES ($insert_values)";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                       }
+               }
+
+               function get_files()
+               {
+                       $drawing_branch=array(
+                       'a' => 'arkitekt'
+                       );
+
+                       $category=array(
+                       'plan' => 2,
+                       'snitt' => 3,
+                       'fasade' => 4
+                       );
+
+                       $branch_id_array=array(
+                       'arkitekt' => 13
+                       );
+
+                       $dir_handle = @opendir($this->dir);
+
+                       $i=0; $myfilearray = '';
+                       while ($file = @readdir($dir_handle))
+                       {
+                               if ((strtolower(substr($file, -3, 3)) == 
$this->suffix) && is_file($this->dir . SEP . $file) )
+                               {
+                                       $myfilearray[$i] = $file;
+                                       $i++;
+                               }
+                       }
+                       @closedir($dir_handle);
+                       @sort($myfilearray);
+
+                       for ($i=0;$i<count($myfilearray);$i++)
+                       {
+                               $fname = $myfilearray[$i];
+                               $loc1 = substr($myfilearray[$i],4,4);
+                               $loc2 = substr($myfilearray[$i],8,2);
+                               $etasje = '';
+                               $loc3 = '';
+                               $nr = '';
+                               $direction = '';
+
+                               $type = $this->get_type($myfilearray[$i]);
+                               switch($type)
+                               {
+                                       case 'plan':
+                                               $etasje = 
substr($myfilearray[$i],13,2);
+                                               $loc3 = 
substr($myfilearray[$i],10,2);
+                                               $location_code = $loc1 . '-' . 
$loc2 . '-' . $loc3;
+                                               break;
+                                       case 'snitt':
+                                               $location_code = $loc1 . '-' . 
$loc2;
+                                               $nr = 
substr($myfilearray[$i],-8,3);
+                                               break;
+                                       case 'fasade':
+                                               $location_code = $loc1 . '-' . 
$loc2;
+                                               $direction = 
substr($myfilearray[$i],11,2);
+                                               $nr = 
substr($myfilearray[$i],-8,3);
+                                               break;
+                               }
+
+
+                               $branch = 
$drawing_branch[strtolower(substr($myfilearray[$i],-5,1))];
+
+                               if ($this->check_building($loc1,$loc2) && $type 
&& $branch)
+                               {
+                                       $file_list[] = array
+                                       (
+                                               'file_name'     => $fname,
+                                               'loc1'          => $loc1,
+                                               'loc2'          => $loc2,
+                                               'loc3'          => $loc3,
+                                               'type'          => $type,
+                                               'nr'            => $nr,
+                                               'etasje'        => $etasje,
+                                               'branch'        => $branch,
+                                               'branch_id' => 
$branch_id_array[$branch],
+                                               'category_id'   => 
$category[$type],
+                                               'direction'     => $direction,
+                                               'location_code' => 
$location_code,
+                                       );
+                               }
+                       }
+
+                       return $file_list;
+               }
+
+
+               function get_type($filename='')
+               {
+                       $drawing_type=array(
+                       'p' => 'plan',
+                       'f' => 'fasade',
+                       's' => 'snitt'
+                       );
+
+                       for ($i=10;$i<strlen($filename);$i++)
+                       {
+                               $type = 
$drawing_type[strtolower(substr($filename,$i,1))];
+                               if($type)
+                               {
+                                       return $type;
+                               }
+                       }
+               }
+
+               function check_building($loc1='',$loc2='')
+               {
+                       $sql = "SELECT count(*)  FROM fm_location2 WHERE loc1= 
'$loc1' AND loc2= '$loc2'";
+
+//_debug_array($sql);
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+                       if($this->db->f(0))
+                       {
+                               return True;
+                       }
+
+                       if($this->bypass)
+                       {
+                               return True;
+                       }
+
+               }
+
+               function create_loc1_dir($loc1='')
+               {
+                       if(!$this->vfs->file_exists(array(
+                                       'string' => $this->fakebase . SEP . 
'document' . SEP . $loc1,
+                                       'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               $this->vfs->override_acl = 1;
+
+                               if(!$this->vfs->mkdir (array(
+                                    'string' => $this->fakebase. SEP . 
'document' . SEP . $loc1,
+                                    'relatives' => array(
+                                         RELATIVE_NONE
+                                    )
+                               )))
+                               {
+                                       
$this->receipt['error'][]=array('msg'=>lang('failed to create directory') . ' 
:'. $this->fakebase. SEP . 'document' . SEP . $loc1);
+                               }
+                               else
+                               {
+                                       
$this->receipt['message'][]=array('msg'=>lang('directory created') . ' :'. 
$this->fakebase. SEP . 'document' . SEP . $loc1);
+                               }
+                               $this->vfs->override_acl = 0;
+                       }
+
+//                     return $this->receipt;
+               }
+
+               function copy_files($values)
+               {
+                       $to_file = $this->fakebase . SEP . 'document' . SEP . 
$values['loc1'] . SEP . $values['file_name'];
+                       $from_file = $this->dir . SEP . $values['file_name'];
+                       $this->vfs->override_acl = 1;
+
+
+//_debug_array($to_file);
+                       if($this->vfs->file_exists(array(
+                                       'string' => $to_file,
+                                       'relatives' => Array(RELATIVE_NONE)
+                               )))
+                       {
+                               
$this->receipt['error'][]=array('msg'=>lang('File %1 already 
exists!',$values['file_name']));
+                       }
+                       else
+                       {
+
+                               if(!$this->vfs->cp (array (
+                                       'from'  => $from_file,
+                                       'to'    => $to_file,
+                                       'relatives'     => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+                               {
+                                       
$this->receipt['error'][]=array('msg'=>lang('Failed to copy file !') . 
$values['file_name']);
+                               }
+                               else
+                               {
+                                       $address = 
$this->get_address($values['loc1'],$values['loc2'],$values['loc3']);
+
+                                       switch($values['type'])
+                                       {
+                                               case 'plan':
+                                                       $values['title'] = 
$this->db->db_addslashes($values['branch'] . ', ' .$values['type'] . ', etasje: 
' . $values['etasje']);
+                                                       break;
+                                               case 'snitt':
+                                                       $values['title'] = 
$this->db->db_addslashes($values['branch'] . ', ' . $values['type'] . ' nr: ' . 
$values['nr']);
+                                                       break;
+                                               case 'fasade':
+                                                       $values['title'] = 
$this->db->db_addslashes($values['branch'] . ', ' . $values['type'] . ' nr: ' . 
$values['nr'] . ' retning: ' . $values['direction']);
+                                                       break;
+                                       }
+
+                                       $insert_values= array(
+                                               $values['file_name'],
+                                               $values['title'],
+                                               'public',
+                                               $values['category_id'],
+                                               time(),
+                                               $values['values_date'],
+                                               $values['version'],
+                                               $values['coordinator'],
+                                               $values['status'],
+                                               $values['location_code'],
+                                               $address,
+                                               $values['branch_id'],
+                                               $values['vendor_id'],
+                                               $this->account,
+                                               $values['loc1'],
+                                               $values['loc2'],
+                                               $values['loc3'],
+                                               );
+
+                                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                                       $sql = "INSERT INTO fm_document 
(document_name,title,access,category,entry_date,document_date,version,coordinator,status,"
+                                               . 
"location_code,address,branch_id,vendor_id,user_id,loc1,loc2,loc3) "
+                                               . "VALUES ($insert_values)";
+
+                                       
$this->db->query($sql,__LINE__,__FILE__);
+
+                                       unlink($from_file);
+
+                                       
$this->receipt['message'][]=array('msg'=>lang('File %1 
copied!',$values['file_name']));
+                                       
$this->receipt['message'][]=array('msg'=>lang('File %1 deleted!',$from_file));
+                               }
+                       }
+
+                       $this->vfs->override_acl = 0;
+//                     return $this->receipt;
+               }
+
+               function get_address($loc1='',$loc2='',$loc3='')
+               {
+                       if ($loc3)
+                       {
+                               $sql = "SELECT loc3_name as address FROM 
fm_location3 WHERE loc1='$loc1' AND loc2='$loc2' AND loc3='$loc3'";
+                       }
+                       else
+                       {
+                               $sql = "SELECT loc2_name as address FROM 
fm_location2 WHERE loc1='$loc1' AND loc2='$loc2'";
+                       }
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+                       return $this->db->f('address');
+               }
+       }
+?>

Index: cron/synkroniser_med_boei.php
===================================================================
RCS file: cron/synkroniser_med_boei.php
diff -N cron/synkroniser_med_boei.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cron/synkroniser_med_boei.php       27 Feb 2007 10:11:29 -0000      1.1
@@ -0,0 +1,794 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+       * @package property
+       * @subpackage custom
+       * @version $Id: synkroniser_med_boei.php,v 1.1 2007/02/27 10:11:29 
sigurdne Exp $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class synkroniser_med_boei
+       {
+               var     $function_name = 'synkroniser_med_boei';
+
+               function synkroniser_med_boei()
+               {
+                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->db                               = 
$this->bocommon->new_db();
+
+                       $this->join                             = 
$this->bocommon->join;
+                       $this->left_join                = 
$this->bocommon->left_join;
+                       $this->like                             = 
$this->bocommon->like;
+
+                       $this->db_boei                  = 
CreateObject($this->currentapp.'.db_mssql');
+                       $this->db_boei->Host            = 
$GLOBALS['external_db']['boei']['db_host'];
+                       $this->db_boei->Type            = 
$GLOBALS['external_db']['boei']['db_type'];
+                       $this->db_boei->Database        = 
$GLOBALS['external_db']['boei']['db_name'];
+                       $this->db_boei->User            = 
$GLOBALS['external_db']['boei']['db_user'];
+                       $this->db_boei->Password        = 
$GLOBALS['external_db']['boei']['db_pass'];
+                       $this->db_boei->Halt_On_Error   = 'yes';
+
+                       $this->db_boei2                 = 
CreateObject($this->currentapp.'.db_mssql');
+                       $this->db_boei2->Host           = 
$GLOBALS['external_db']['boei']['db_host'];
+                       $this->db_boei2->Type           = 
$GLOBALS['external_db']['boei']['db_type'];
+                       $this->db_boei2->Database       = 
$GLOBALS['external_db']['boei']['db_name'];
+                       $this->db_boei2->User           = 
$GLOBALS['external_db']['boei']['db_user'];
+                       $this->db_boei2->Password       = 
$GLOBALS['external_db']['boei']['db_pass'];
+                       $this->db_boei2->Halt_On_Error  = 'yes';
+               }
+
+               function pre_run($data='')
+               {
+                       if($data['enabled']==1)
+                       {
+                               $confirm        = True;
+                               $cron           = True;
+                       }
+                       else
+                       {
+                               $confirm        = 
get_var('confirm',array('POST'));
+                               $execute        = 
get_var('execute',array('GET'));
+                       }
+
+                       if ($confirm)
+                       {
+                               $this->execute($cron);
+                       }
+                       else
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+
+               function confirm($execute='')
+               {
+                       $link_data = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
+                               'function'      =>$this->function_name,
+                               'execute'       => $execute,
+                       );
+
+
+                       if(!$execute)
+                       {
+                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
+                       }
+
+                       $lang_yes                       = lang('yes');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
+
+
+                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
+
+                       $data = array
+                       (
+                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'message'                               => 
$this->receipt['message'],
+                               'lang_confirm_msg'              => 
$lang_confirm_msg,
+                               'lang_yes'                              => 
$lang_yes,
+                               'lang_yes_statustext'   => lang('Update the 
category to not active based on if there is only nonactive apartments'),
+                               'lang_no_statustext'    => 'tilbake',
+                               'lang_no'                               => 
lang('no'),
+                               'lang_done'                             => 
'Avbryt',
+                               'lang_done_statustext'  => 'tilbake'
+                       );
+
+                       $appname                = lang('location');
+                       $function_msg   = 'synkroniser med BOEI';
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
+                       $GLOBALS['phpgw']->xslttpl->pp();
+               }
+
+               function execute($cron='')
+               {
+                       $receipt = $this->legg_til_eier_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->legg_til_gateadresse_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->legg_til_objekt_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->legg_til_bygg_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->legg_til_seksjon_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->legg_til_leieobjekt_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->legg_til_leietaker_phpgw();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->oppdater_leieobjekt();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->oppdater_boa_objekt();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->oppdater_boa_bygg();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->oppdater_boa_del();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->oppdater_oppsagtdato();
+                       $this->cron_log($receipt,$cron);
+                       $receipt = $this->slett_feil_telefon();
+                       $this->cron_log($receipt,$cron);
+
+                       if(!$cron)
+                       {
+                               $this->confirm($execute=False);
+                       }
+               }
+
+               function cron_log($receipt='',$cron='')
+               {
+
+                       $insert_values= array(
+                               $cron,
+                               date($this->bocommon->datetimeformat),
+                               $this->function_name,
+                               $receipt
+                               );
+
+                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
+
+                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
+                                       . "VALUES ($insert_values)";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function legg_til_eier_phpgw()
+               {
+                       $sql = " SELECT TOP 100 PERCENT v_Eier.id, 
v_Eier.category"
+                               . " FROM  v_Eier";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+                       while ($this->db_boei->next_record())
+                       {
+                               if($this->db_boei->f('category')==0)
+                               {
+                                       $category = 4;
+                               }
+                               else
+                               {
+                                       $category = 
$this->db_boei->f('category');
+                               }
+                               $owner[]= array (
+                                'id'           => $this->db_boei->f('id'),
+                                'category'     => $category,
+                                );                     
+                       }
+                       
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($owner); $i++)
+                       {
+                               $sql2 = "UPDATE fm_owner set category = 
'{$owner[$i]['category']}' WHERE id = '{$owner[$i]['id']}'";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+                       }
+
+                       unset($owner);
+
+                       $sql = "SELECT v_Eier.id, 
v_Eier.org_name,v_Eier.category FROM  fm_owner RIGHT OUTER JOIN "
+                               . " v_Eier ON fm_owner.id = v_Eier.id"
+                                       . " WHERE (fm_owner.id IS NULL)";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+                       while ($this->db_boei->next_record())
+                       {
+                               if($this->db_boei->f('category')==0)
+                               {
+                                       $category = 4;
+                               }
+                               else
+                               {
+                                       $category = 
$this->db_boei->f('category');
+                               }
+                               $owner[]= array (
+                                'id'           => $this->db_boei->f('id'),
+                                'org_name'     => 
$this->db->db_addslashes($this->db_boei->f('org_name')),
+                                'remark'       => 
$this->db->db_addslashes($this->db_boei->f('org_name')),
+                                'category'     => $category,
+                                'entry_date'   => time(),
+                                'owner_id'             => 6
+                                );
+                       }
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($owner); $i++)
+                       {
+                               $sql2 = "INSERT INTO fm_owner 
(id,org_name,remark,category,entry_date,owner_id)"
+                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($owner[$i]) . ")";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               $owner_msg[]=$owner[$i]['org_name'];
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($owner) . ' eier er lagt til: ' . 
@implode(",", $owner_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($owner);
+                       unset ($owner_msg);
+                       return $msg;
+
+               }
+
+
+
+               function legg_til_gateadresse_phpgw()
+               {
+                       $sql = "SELECT v_Gateadresse.gateadresse_id, 
v_Gateadresse.gatenavn FROM  fm_streetaddress RIGHT OUTER JOIN "
+                               . " v_Gateadresse ON fm_streetaddress.id = 
v_Gateadresse.gateadresse_id"
+                                       . " WHERE (fm_streetaddress.id IS 
NULL)";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+                       while ($this->db_boei->next_record())
+                       {
+                               $gate[]= array (
+                                'id'           => 
$this->db_boei->f('gateadresse_id'),
+                                'descr'        => $this->db_boei->f('gatenavn')
+                                );
+
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($gate); $i++)
+                       {
+
+                               $sql2 = "INSERT INTO fm_streetaddress 
(id,descr)"
+                                       . " VALUES (" . $gate[$i]['id'] . ", 
'". $gate[$i]['descr']. "')";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               $gate_msg[]=$gate[$i]['descr'];
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($gate) . ' gateadresser er lagt til: ' . 
@implode(",", $gate_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($gate);
+                       unset ($gate_msg);
+                       return $msg;
+
+               }
+
+               function legg_til_objekt_phpgw()
+               {
+                       $sql = "SELECT v_Objekt.objekt_id, v_Objekt.navn, 
v_Objekt.bydel_id, v_Objekt.eier_id,v_Objekt.tjenestested"
+                                       . " FROM fm_location1 RIGHT OUTER JOIN "
+                               . " v_Objekt ON fm_location1.loc1 = 
v_Objekt.objekt_id"
+                                       . " WHERE fm_location1.loc1 IS NULL";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+                       while ($this->db_boei->next_record())
+                       {
+                               $objekt[]= array (
+                                'location_code'        => 
$this->db_boei->f('objekt_id'),
+                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
+                                'loc1_name'            => 
$this->db_boei->f('navn'),
+                                'part_of_town_id'      => 
$this->db_boei->f('bydel_id'),
+                                'owner_id'             => 
$this->db_boei->f('eier_id'),
+                                'kostra_id'            => 
$this->db_boei->f('tjenestested')
+                                );
+
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($objekt); $i++)
+                       {
+
+                               $sql2 = "INSERT INTO fm_location1 
(location_code, loc1, loc1_name, part_of_town_id, owner_id, kostra_id) "
+                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($objekt[$i]) . ")";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               $obj_msg[]=$objekt[$i]['loc1'];
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($objekt) . ' Objekt er lagt til: ' . 
@implode(",", $obj_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($objekt);
+                       unset ($obj_msg);
+                       return $msg;
+               }
+
+               function legg_til_bygg_phpgw()
+               {
+                       $sql = "SELECT v_Bygg.objekt_id + '-' + v_Bygg.bygg_id 
AS location_code, v_Bygg.objekt_id, v_Bygg.bygg_id, 
v_Bygg.byggnavn,v_Bygg.driftstatus"
+                               . " FROM v_Bygg LEFT OUTER JOIN"
+                       . " fm_location2 ON v_Bygg.objekt_id = 
fm_location2.loc1 AND v_Bygg.bygg_id = fm_location2.loc2"
+                       . " WHERE fm_location2.loc1 IS NULL";
+
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+                       while ($this->db_boei->next_record())
+                       {
+
+                               $bygg[]= array (
+                                'location_code'        => 
$this->db_boei->f('location_code'),
+                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
+                                'loc2'                         => 
$this->db_boei->f('bygg_id'),
+                                'loc2_name'            => 
$this->db_boei->f('byggnavn'),
+                                );
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($bygg); $i++)
+                       {
+
+                               $sql2 = "INSERT INTO fm_location2 
(location_code, loc1, loc2, loc2_name) "
+                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($bygg[$i]) . ")";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               $bygg_msg[]=$bygg[$i]['location_code'];
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($bygg) . ' Bygg er lagt til: ' . 
@implode(",", $bygg_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($bygg);
+                       unset ($bygg_msg);
+                       return $msg;
+
+               }
+
+               function legg_til_seksjon_phpgw()
+               {
+
+                       $sql = "SELECT v_Seksjon.objekt_id + '-' + 
v_Seksjon.bygg_id + '-' + v_Seksjon.seksjons_id AS location_code, 
v_Seksjon.objekt_id, v_Seksjon.bygg_id,"
+                               . " v_Seksjon.seksjons_id, 
v_Seksjon.beskrivelse, v_Seksjon.totalt_fellesareal"
+                               . " FROM v_Seksjon LEFT OUTER JOIN"
+                               . " fm_location3 ON v_Seksjon.objekt_id = 
fm_location3.loc1 AND v_Seksjon.bygg_id = fm_location3.loc2 AND "
+                               . " v_Seksjon.seksjons_id = fm_location3.loc3"
+                               . " WHERE fm_location3.loc1 IS NULL";
+
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+                       while ($this->db_boei->next_record())
+                       {
+
+                               $seksjon[]= array (
+                                'location_code'        => 
$this->db_boei->f('location_code'),
+                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
+                                'loc2'                         => 
$this->db_boei->f('bygg_id'),
+                                'loc3'                         => 
$this->db_boei->f('seksjons_id'),
+                                'loc3_name'            => 
$this->db_boei->f('beskrivelse'),
+                                'fellesareal'  => 
$this->db_boei->f('totalt_fellesareal')
+                                );
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($seksjon); $i++)
+                       {
+
+                               $sql2 = "INSERT INTO fm_location3 
(location_code, loc1, loc2, loc3, loc3_name, fellesareal) "
+                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($seksjon[$i]) . ")";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               $seksjon_msg[]=$seksjon[$i]['location_code'];
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($seksjon) . ' Seksjon er lagt til: ' . 
@implode(",", $seksjon_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($seksjon);
+                       unset ($seksjon_msg);
+                       return $msg;
+               }
+
+               function legg_til_leieobjekt_phpgw()
+               {
+
+                       $sql = "SELECT v_Leieobjekt.objekt_id + '-' + 
v_Leieobjekt.bygg_id + '-' + v_Leieobjekt.seksjons_id + '-' + 
v_Leieobjekt.leie_id AS location_code,"
+                  . " v_Leieobjekt.objekt_id, v_Leieobjekt.leie_id, 
v_Leieobjekt.leieobjekttype_id, v_Leieobjekt.bygg_id, v_Leieobjekt.seksjons_id,"
+                  . " v_Leieobjekt.formaal_id, v_Leieobjekt.gateadresse_id, 
v_Leieobjekt.gatenr, v_Leieobjekt.etasje, v_Leieobjekt.antallrom,"
+                  . " v_Leieobjekt.boareal, v_Leieobjekt.livslopsstd, 
v_Leieobjekt.heis, v_Leieobjekt.driftsstatus_id, v_Leieobjekt.leietaker_id,"
+                  . " v_Leieobjekt.beregnet_boa"
+                  . " FROM v_Leieobjekt LEFT OUTER JOIN"
+                  . " fm_location4 ON v_Leieobjekt.objekt_id = 
fm_location4.loc1 AND v_Leieobjekt.leie_id = fm_location4.loc4"
+                  . " WHERE fm_location4.loc1 IS NULL";
+
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       while ($this->db_boei->next_record())
+                       {
+
+                               $leieobjekt[]= array (
+                                'location_code'        => 
$this->db_boei->f('location_code'),
+                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
+                                'loc4'                         => 
$this->db_boei->f('leie_id'),
+                                'leieobjekttype_id'=> 
$this->db_boei->f('leieobjekttype_id'),
+                                'loc2'                         => 
$this->db_boei->f('bygg_id'),
+                                'loc3'                         => 
$this->db_boei->f('seksjons_id'),
+                                'category'             => 
$this->db_boei->f('formaal_id'),
+                                'street_id'            => 
$this->db_boei->f('gateadresse_id'),
+                                'street_number'        => 
$this->db_boei->f('gatenr'),
+                                'etasje'                       => 
$this->db_boei->f('etasje'),
+                                'antallrom'            => 
$this->db_boei->f('antallrom'),
+                                'boareal'                      => 
$this->db_boei->f('boareal'),
+                                'livslopsstd'          => 
$this->db_boei->f('livslopsstd'),
+                                'heis'                         => 
$this->db_boei->f('heis'),
+                                'driftsstatus_id'      => 
$this->db_boei->f('driftsstatus_id'),
+                                'tenant_id'            => 
$this->db_boei->f('leietaker_id'),
+                                'beregnet_boa'         => 
$this->db_boei->f('beregnet_boa')
+                                );
+
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($leieobjekt); $i++)
+                       {
+
+                               $sql2 = "INSERT INTO fm_location4 
(location_code, loc1, loc4, leieobjekttype_id, loc2, loc3, category, street_id, 
street_number, etasje, antallrom, boareal, livslopsstd, heis, driftsstatus_id,
+                      tenant_id, beregnet_boa)"
+                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($leieobjekt[$i]) . ")";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               
$leieobjekt_msg[]=$leieobjekt[$i]['location_code'];
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($leieobjekt) . ' Leieobjekt er lagt til: ' 
. @implode(",", $leieobjekt_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($leieobjekt);
+                       unset ($leieobjekt_msg);
+                       return $msg;
+               }
+
+               function legg_til_leietaker_phpgw()
+               {
+                       $sql = " SELECT v_Leietaker.leietaker_id, 
v_Leietaker.fornavn, v_Leietaker.etternavn, v_Leietaker.kjonn_juridisk,"
+                               . " v_Leietaker.namssakstatusokonomi_id, 
v_Leietaker.namssakstatusdrift_id"
+                               . " FROM fm_tenant RIGHT OUTER JOIN"
+                               . " v_Leietaker ON fm_tenant.id = 
v_Leietaker.leietaker_id"
+                               . " WHERE fm_tenant.id IS NULL";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       while ($this->db_boei->next_record())
+                       {
+                               $leietaker[]= array (
+                                'id'                           => 
$this->db_boei->f('leietaker_id'),
+                                'first_name'           => 
$this->db_boei->f('fornavn'),
+                                'last_name'            => 
$this->db_boei->f('etternavn'),
+                                'category'                     => 
$this->db_boei->f('kjonn_juridisk') + 1,
+                                'status_eco'           => 
$this->db_boei->f('namssakstatusokonomi_id'),
+                                'status_drift'         => 
$this->db_boei->f('namssakstatusdrift_id'),
+                                'entry_date'           => time(),
+                                'owner_id'                     => 6
+                                );
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       for ($i=0; $i<count($leietaker); $i++)
+                       {
+                               $sql2 = "INSERT INTO fm_tenant (id, first_name, 
last_name, category, status_eco, status_drift,entry_date,owner_id)"
+                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($leietaker[$i]) . ")";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei->query($sql2,__LINE__,__FILE__);
+
+                               $leietaker_msg[]= '[' 
.$leietaker[$i]['last_name'] . ', ' . $leietaker[$i]['first_name'] . ']';
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = count($leietaker) . ' Leietaker er lagt til: ' . 
@implode(",", $leietaker_msg);
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       unset ($leietaker);
+                       unset ($leietaker_msg);
+                       return $msg;
+
+               }
+
+               function oppdater_leieobjekt()
+               {
+
+                       $sql = " SELECT TOP 100 PERCENT 
objekt_id,leie_id,leietaker_id, boareal, formaal_id, gateadresse_id, gatenr, 
etasje,driftsstatus_id"
+                               . " FROM  v_Leieobjekt"; // WHERE 
v_Leieobjekt.formaal_id NOT IN (99)";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $i=0;
+                       while ($this->db_boei->next_record())
+                       {
+                               $sql2 = " UPDATE  fm_location4 SET "
+                               . " tenant_id = '" . 
$this->db_boei->f('leietaker_id') . "',"
+                               . " category = '" . 
$this->db_boei->f('formaal_id') . "',"
+                               . " etasje = '" . $this->db_boei->f('etasje') . 
"',"
+                               . " street_id = '" . 
$this->db_boei->f('gateadresse_id') . "',"
+                               . " street_number = '" . 
$this->db_boei->f('gatenr') . "',"
+                               . " driftsstatus_id = '" . 
$this->db_boei->f('driftsstatus_id') . "',"
+                               . " boareal = '" . $this->db_boei->f('boareal') 
. "'"
+                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'  AND  loc4= '" . 
$this->db_boei->f('leie_id') . "'";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
+                               $i++;
+                       }
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $msg = $i . ' Leieobjekt er oppdatert';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+
+               }
+
+               function oppdater_boa_objekt()
+               {
+
+                       $sql = " SELECT TOP 100 PERCENT 
sum(v_Leieobjekt.boareal) as sum_boa, count(leie_id) as ant_leieobjekt,"
+                                       . " 
v_Objekt.objekt_id,bydel_id,tjenestested,navn,v_Objekt.eier_id FROM  v_Objekt 
$this->join v_Leieobjekt ON v_Objekt.objekt_id = v_Leieobjekt.objekt_id"
+                                       . " WHERE v_Leieobjekt.formaal_id NOT 
IN (99)"
+                                       . " GROUP BY 
bydel_id,v_Objekt.objekt_id,navn,tjenestested,eier_id";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $i=0;
+                       while ($this->db_boei->next_record())
+                       {
+                               $sql2 = " UPDATE fm_location1 SET "
+                               . " loc1_name = '" . $this->db_boei->f('navn') 
. "',"
+                               . " sum_boa = '" . $this->db_boei->f('sum_boa') 
. "',"
+                               . " ant_leieobjekt = '" . 
$this->db_boei->f('ant_leieobjekt') . "',"
+                               . " part_of_town_id = '" . 
$this->db_boei->f('bydel_id') . "',"
+                               . " owner_id = '" . 
$this->db_boei->f('eier_id') . "',"
+                               . " kostra_id = '" . 
$this->db_boei->f('tjenestested') . "'"
+                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
+                               $i++;
+                       }
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $msg = $i . ' Objekt er oppdatert';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+
+
+               }
+
+               function oppdater_boa_bygg()
+               {
+                       $sql = " SELECT TOP 100 PERCENT 
sum(v_Leieobjekt.boareal) as sum_boa, count(leie_id) as ant_leieobjekt,"
+                                       . " v_Bygg.objekt_id,v_Bygg.bygg_id , 
byggnavn  FROM  v_Bygg $this->join v_Leieobjekt "
+                                       . " ON v_Bygg.objekt_id = 
v_Leieobjekt.objekt_id AND v_Bygg.bygg_id = v_Leieobjekt.bygg_id"
+                                       . " WHERE v_Leieobjekt.formaal_id NOT 
IN (99)"
+                                       . " GROUP BY 
v_Bygg.objekt_id,v_Bygg.bygg_id ,byggnavn";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $i=0;
+                       while ($this->db_boei->next_record())
+                       {
+                               $sql2 = " UPDATE fm_location2 SET "
+                               . " loc2_name = '" . 
$this->db_boei->f('byggnavn') . "',"
+                               . " sum_boa = '" . $this->db_boei->f('sum_boa') 
. "',"
+                               . " ant_leieobjekt = '" . 
$this->db_boei->f('ant_leieobjekt') . "'"
+                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'  AND  loc2= '" . 
$this->db_boei->f('bygg_id') . "'";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
+                               $i++;
+                       }
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $msg = $i . ' Bygg er oppdatert';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+               }
+
+               function oppdater_boa_del()
+               {
+
+                       $sql = " SELECT TOP 100 PERCENT 
sum(v_Leieobjekt.boareal) as sum_boa, count(leie_id) as ant_leieobjekt,"
+                                       . " 
v_Seksjon.objekt_id,v_Seksjon.bygg_id,v_Seksjon.seksjons_id , beskrivelse   
FROM  v_Seksjon $this->join v_Leieobjekt "
+                                       . " ON v_Seksjon.objekt_id = 
v_Leieobjekt.objekt_id"
+                                       . " AND v_Seksjon.bygg_id = 
v_Leieobjekt.bygg_id"
+                                       . " AND v_Seksjon.seksjons_id = 
v_Leieobjekt.seksjons_id"
+                                       . " WHERE v_Leieobjekt.formaal_id NOT 
IN (99)"
+                                       . " GROUP BY 
v_Seksjon.objekt_id,v_Seksjon.bygg_id,v_Seksjon.seksjons_id,beskrivelse";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       $i=0;
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       while ($this->db_boei->next_record())
+                       {
+                               $sql2 = " UPDATE fm_location3 SET "
+                               . " loc3_name = '" . 
$this->db_boei->f('beskrivelse') . "',"
+                               . " sum_boa = '" . $this->db_boei->f('sum_boa') 
. "',"
+                               . " ant_leieobjekt = '" . 
$this->db_boei->f('ant_leieobjekt') . "'"
+                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'  AND  loc2= '" . 
$this->db_boei->f('bygg_id') . "'  AND  loc3= '" . 
$this->db_boei->f('seksjons_id') . "'";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
+                               $i++;
+                       }
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       $msg = $i . ' Seksjoner er oppdatert';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+               }
+
+               function oppdater_oppsagtdato()
+               {
+
+                       $sql = "SELECT TOP 100 PERCENT fm_tenant.id"
+                                       . " FROM  fm_tenant LEFT OUTER JOIN"
+                    . " v_Leietaker ON fm_tenant.id = v_Leietaker.leietaker_id 
AND "
+                    . " fm_tenant.oppsagtdato = v_Leietaker.oppsagtdato"
+                                       . " WHERE (v_Leietaker.leietaker_id IS 
NULL)";
+
+                       $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                       $this->db->transaction_begin();
+                       $this->db_boei->transaction_begin();
+
+                       while ($this->db_boei->next_record())
+                       {
+                               $leietaker[]= $this->db_boei->f('id');
+                       }
+
+                       for ($i=0; $i<count($leietaker); $i++)
+                       {
+                               $sql = "SELECT oppsagtdato"
+                                       . " FROM  v_Leietaker"
+                                       . " WHERE (v_Leietaker.leietaker_id = 
'" . $leietaker[$i] . "')";
+
+                               $this->db_boei->query($sql,__LINE__,__FILE__);
+
+                               $this->db_boei->next_record();
+                               $leietaker_oppdatert[]= array (
+                                'id'                           => 
$leietaker[$i],
+                                'oppsagtdato'          => 
$this->db_boei->f('oppsagtdato')
+                                );
+
+                       }
+
+                       for ($i=0; $i<count($leietaker_oppdatert); $i++)
+                       {
+                               $sql = " UPDATE fm_tenant SET "
+                               . " oppsagtdato = '" . 
$leietaker_oppdatert[$i]['oppsagtdato'] . "'"
+                               . " WHERE  id = '" . 
$leietaker_oppdatert[$i]['id'] . "'";
+
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db_boei->query($sql,__LINE__,__FILE__);
+                       }
+
+                       $this->db->transaction_commit();
+                       $this->db_boei->transaction_commit();
+
+                       $msg = $i . ' oppsagtdato er oppdatert';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+
+               }
+
+
+               function slett_feil_telefon()
+               {
+                       $sql = "SELECT count(contact_phone) as ant_tlf from 
fm_tenant WHERE id > 99999 OR id = 0";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $this->db->next_record();
+
+                       $ant_tlf = $this->db->f('ant_tlf');
+
+                       $sql = "UPDATE fm_tenant SET contact_phone = NULL WHERE 
id > 99999 OR id = 0";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $msg = $ant_tlf . ' Telefon nr er slettet';
+                       $this->receipt['message'][]=array('msg'=> $msg);
+                       return $msg;
+               }
+       }
+?>

Index: custom/cron.php
===================================================================
RCS file: custom/cron.php
diff -N custom/cron.php
--- custom/cron.php     26 Jan 2007 14:54:04 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-#!/usr/bin/php -q
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage admin
-       * @version $Id: cron.php,v 1.8 2007/01/26 14:54:04 sigurdne Exp $
-       */
-
-       /**
-        * Description
-        * example cron : /usr/local/bin/php -q 
/var/www/html/phpgroupware/property/inc/custom/cron.php default 
oppdater_namssakstatus_pr_leietaker
-        */
-
-       $path_to_phpgroupware = dirname(__FILE__) . '/../../..';        // need 
to be adapted if this script is moved somewhere else
-       $_GET['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 
'default';
-
-
-       if(!$function = $_SERVER['argv'][2])
-
-       {
-               echo date('Y/m/d H:i:s ') . " Nothing to execute\n";
-               return;
-       }
-
-//     echo $function;
-
-       $GLOBALS['phpgw_info']['flags'] = array(
-               'currentapp' => 'login',
-               'noapi'      => True            // this stops header.inc.php to 
include phpgwapi/inc/function.inc.php
-       );
-       include($path_to_phpgroupware.'/header.inc.php');
-       unset($GLOBALS['phpgw_info']['flags']['noapi']);
-
-       $db_type = $GLOBALS['phpgw_domain'][$_GET['domain']]['db_type'];
-
-       $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db';
-
-       include(PHPGW_API_INC.'/functions.inc.php');
-
-       $num = ExecMethod('property.custom_functions.index',array('function' => 
$function,'enabled'=>1));
-       // echo date('Y/m/d H:i:s ').$_GET['domain'].': '.($num ? "$num job(s) 
executed" : 'Nothing to execute')."\n";
-
-       $GLOBALS['phpgw']->common->phpgw_exit();

Index: custom/forward_mail_as_sms.php
===================================================================
RCS file: custom/forward_mail_as_sms.php
diff -N custom/forward_mail_as_sms.php
--- custom/forward_mail_as_sms.php      26 Feb 2007 22:20:07 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,174 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: forward_mail_as_sms.php,v 1.2 2007/02/26 22:20:07 
sigurdne Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class forward_mail_as_sms
-       {
-               var     $function_name = 'forward_mail_as_sms';
-
-               function forward_mail_as_sms()
-               {
-                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->db                       = 
$this->bocommon->new_db();
-               }
-
-               function pre_run($data='')
-               {
-                       if(isset($data['enabled']) && $data['enabled']==1)
-                       {
-                               $confirm        = True;
-                               $cron           = True;
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                               $cron = false;
-                       }
-
-
-                       if (isset($confirm) && $confirm)
-                       {
-                               $this->execute($cron);
-                       }
-                       else
-                       {
-                               $this->confirm($execute=False);
-                               $data['account_id'] = 
$GLOBALS['phpgw']->accounts->name2id($data['user']);
-                               
$GLOBALS['phpgw']->session->appsession('session_data','mail2sms',$data);
-                       }
-               }
-
-               function confirm($execute='')
-               {
-                       $link_data = array
-                       (
-                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
-                               'function'      => $this->function_name,
-                               'execute'       => $execute,
-                       );
-
-                       if(!$execute)
-                       {
-                               $lang_confirm_msg       = lang('Do you want to 
execute this action?');
-                       }
-
-                       $lang_yes                       = lang('yes');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-                       $msgbox_data = 
isset($this->receipt)?$this->bocommon->msgbox_data($this->receipt):'';
-
-                       $data = array
-                       (
-                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
-                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'message'                               => 
$this->receipt['message'],
-                               'lang_confirm_msg'              => 
$lang_confirm_msg,
-                               'lang_yes'                              => 
$lang_yes,
-                               'lang_yes_statustext'   => lang('Check for new 
mail - and forward as sms'),
-                               'lang_no_statustext'    => 'tilbake',
-                               'lang_no'                               => 
lang('no'),
-                               'lang_done'                             => 
lang('cancel'),
-                               'lang_done_statustext'  => 'tilbake'
-                       );
-
-                       $appname                = lang('Async service');
-                       $function_msg   = 'Forward email as SMS';
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
-                       $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function execute($cron='')
-               {
-                       $receipt = $this->check_for_new_mail();
-                       $this->cron_log($receipt,$cron);
-
-                       if(!$cron)
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-               function cron_log($receipt='',$cron='')
-               {
-                       $insert_values= array(
-                               $cron,
-                               date($this->bocommon->datetimeformat),
-                               $this->function_name,
-                               $receipt
-                               );
-
-                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
-                                       . "VALUES ($insert_values)";
-                       $this->db->query($sql,__LINE__,__FILE__);
-               }
-
-               function check_for_new_mail()
-               {
-                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','mail2sms');
-                       $GLOBALS['phpgw_info']['user']['account_id'] = 
$data['account_id'];
-                       $GLOBALS['phpgw']->preferences->account_id = 
$data['account_id'];
-                       $pref = 
$GLOBALS['phpgw']->preferences->read_repository();
-                       
$GLOBALS['phpgw_info']['user']['preferences']['felamimail'] = 
isset($pref['felamimail']) ? $pref['felamimail'] : '';
-
-                       $bofelamimail   = 
CreateObject('felamimail.bofelamimail');
-                       $connectionStatus = $bofelamimail->openConnection();
-                       $headers = $bofelamimail->getHeaders(0, $maxMessages = 
15, $sort = 6);
-
-                       $j = 0;
-                       foreach ($headers['header'] as $header)
-                       {
-                               if($header['seen'] == 0)
-                               {
-                                       $sms[$j]['message'] = 
$header['subject'];
-                                       $bodyParts = 
$bofelamimail->getMessageBody($header['uid']);
-                                       $sms[$j]['message'] .= "\n";
-                                       for($i=0; $i<count($bodyParts); $i++ )
-                                       {
-                                               $sms[$j]['message'] .= 
$bodyParts[$i]['body'];
-                                       }
-
-                                       $sms[$j]['message'] = 
substr($sms[$j]['message'],0,160);
-                                       $j++;
-                               }
-                       }
-                       if($connectionStatus == 'True')
-                       {
-                               $bofelamimail->closeConnection();
-                       }
-
-                       $bosms  = CreateObject('sms.bosms',False);
-                       if(isset($sms) && is_array($sms))
-                       {
-                               foreach ($sms as $entry)
-                               {
-                                       
$bosms->send_sms(array('p_num_text'=>$data['cellphone'], 'message' 
=>$entry['message']));
-                               }
-                       }
-
-                       $msg = $j . ' messages er sendt';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-               }
-       }
-?>

Index: custom/lag_lang_filer.php
===================================================================
RCS file: custom/lag_lang_filer.php
diff -N custom/lag_lang_filer.php
--- custom/lag_lang_filer.php   26 Jan 2007 14:54:04 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: lag_lang_filer.php,v 1.7 2007/01/26 14:54:04 sigurdne 
Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class lag_lang_filer
-       {
-               var     $function_name = 'lag_lang_filer';
-
-               function lag_lang_filer()
-               {
-                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->db               = $this->bocommon->new_db();
-               }
-               
-               function pre_run($data='')
-               {
-                       if($data['enabled']==1)
-                       {
-                               $confirm        = True;
-                               $cron           = True;
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                       }
-                       if ($confirm)
-                       {
-                               $this->execute($cron);
-                       }
-                       else
-                       {
                                $this->confirm($execute=False);
                        }
                }


                function confirm($execute='')
                {
                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.custom_functions.index',
                                'function'      =>$this->function_name,
                                'execute'       => $execute,
                        );

                        if(!$execute)
                        {
                                $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
                        }
-                       $lang_yes                       = lang('yes');
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-                       $data = array
                        (
                                'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
                                'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'message'                               => 
$this->receipt['message'],
                                'lang_confirm_msg'              => 
$lang_confirm_msg,
                                'lang_yes'                              => 
$lang_yes,
                                'lang_yes_statustext'   => 'lag_lang_filer fra 
database',
                                'lang_no_statustext'    => 'tilbake',
                                'lang_no'                               => 
lang('no'),
                                'lang_done'                             => 
'Avbryt',
                                'lang_done_statustext'  => 'tilbake'
                        );

                        $appname                = lang('location');
                        $function_msg   = 'lag_lang_filer';
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
                        $GLOBALS['phpgw']->xslttpl->pp();
                }

                function execute($cron='')
                {

                        $sql = "SELECT * from phpgw_lang WHERE app_name = 
'property' AND lang='no' ORDER BY message_id ASC";

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

                        $i=0;
                        while ($this->db->next_record())
                        {
                                        $str.=$this->db->f('message_id') ."\t";
                                        $str.=$this->db->f('app_name') ."\t";
                                        $str.=$this->db->f('lang') ."\t";
                                        $str.=$this->db->f('content') ."\n";
                                        $i++;
                        }

_debug_array($str);
/*                         $filename= 'phpgw_no_lang';

                                $size=strlen($str);

                                $browser = CreateObject('phpgwapi.browser');
                                
$browser->content_header($filename,'application/txt',$size);

                                echo $str;
*/

                        $this->receipt['message'][]=array('msg'=> $i . ' 
tekster lagt til');

                        if(!$cron)
                        {
                                $this->confirm($execute=False);
                        }
                }
        }
?>

Index: custom/oppdater_antall_leieobjekt.php
===================================================================
RCS file: custom/oppdater_antall_leieobjekt.php
diff -N custom/oppdater_antall_leieobjekt.php
--- custom/oppdater_antall_leieobjekt.php       26 Jan 2007 14:54:04 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,177 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: oppdater_antall_leieobjekt.php,v 1.2 2007/01/26 
14:54:04 sigurdne Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class oppdater_antall_leieobjekt
-       {
-               var     $function_name = 'oppdater_antall_leieobjekt';
-
-               function oppdater_antall_leieobjekt()
-               {
-                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->db                       = 
$this->bocommon->new_db();
-                       $this->db2                      = 
$this->bocommon->new_db();
-                       $this->soadmin_location = 
CreateObject($this->currentapp.'.soadmin_location');
-
-                       $this->join                     = $this->bocommon->join;
-                       $this->left_join                = 
$this->bocommon->left_join;
-               }
-
-               function pre_run($data='')
-               {
-                       if($data['enabled']==1)
-                       {
-                               $confirm        = True;
-                               $cron           = True;
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                       }
-
-                       if ($confirm)
-                       {
-                               $this->execute($cron);
-                       }
-                       else
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-
-               function confirm($execute='')
-               {
-                       $link_data = array
-                       (
-                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
-                               'function'      =>$this->function_name,
-                               'execute'       => $execute,
-                       );
-
-
-                       if(!$execute)
-                       {
-                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
-                       }
-
-                       $lang_yes                       = lang('yes');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
-                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'message'                               => 
$this->receipt['message'],
-                               'lang_confirm_msg'              => 
$lang_confirm_msg,
-                               'lang_yes'                              => 
$lang_yes,
-                               'lang_yes_statustext'   => 'Oppdater antall 
leieobjekter for tv-anlegg',
-                               'lang_no_statustext'    => 'tilbake',
-                               'lang_no'                               => 
lang('no'),
-                               'lang_done'                             => 
'Avbryt',
-                               'lang_done_statustext'  => 'tilbake'
-                       );
-
-                       $appname                = lang('location');
-                       $function_msg   = 'Oppdater antall leieobjekter for 
tv-anlegg';
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
-                       $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function execute($cron='')
-               {
-
-                       $this->db->transaction_begin();
-
-
-                       $sql = "SELECT kunde_nr_lev, fm_entity_1_3.loc1, 
fm_entity_1_3.loc2, Count(fm_location4.location_code) AS antall_leieobjekt, 
fm_entity_1_3.location_code
-                                       FROM fm_entity_1_3 INNER JOIN 
fm_location4 ON (fm_entity_1_3.loc1 = fm_location4.loc1) AND 
(fm_entity_1_3.loc2 = fm_location4.loc2)
-                                       WHERE fm_location4.category IN 
(1,2,3,4,6,10,14,15,17,22,23,24,25)
-                                       GROUP BY kunde_nr_lev, 
fm_entity_1_3.loc1, fm_entity_1_3.loc2, fm_entity_1_3.location_code";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       while ($this->db->next_record())
-                       {
-                               if($this->db->f('kunde_nr_lev'))
-                               {
-                                       $update[]= array(
-                                       'kunde_nr_lev'  
=>$this->db->f('kunde_nr_lev'),
-                                       'antall_leieobjekt'     
=>$this->db->f('antall_leieobjekt'),
-                                       );
-                               }
-                       }
-
-//_debug_array($update);
-
-                       for ($i=0; $i<count($update); $i++)
-                       {
-                               $this->db->query("UPDATE fm_entity_1_3 set 
ant_leil_pt =" . $update[$i]['antall_leieobjekt'] . " WHERE kunde_nr_lev= '" . 
$update[$i]['kunde_nr_lev'] . "'" ,__LINE__,__FILE__);
-                       }
-
-                       $this->receipt['message'][]=array('msg'=>'antall 
leieobjekter er oppdatert for tv-anlegg');
-
-                       unset($update);
-
-                       $this->db->transaction_commit();
-
-                       if(!$cron)
-                       {
-                               $this->confirm($execute=False);
-                       }
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $insert_values= array(
-                               $cron,
-                               date($this->bocommon->datetimeformat),
-                               $this->function_name,
-                               implode(',',(array_keys($msgbox_data)))
-                               );
-
-                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
-                                       . "VALUES ($insert_values)";
-                       $this->db->query($sql,__LINE__,__FILE__);
-               }
-       }
-?>

Index: custom/oppdater_namssakstatus_pr_leietaker.php
===================================================================
RCS file: custom/oppdater_namssakstatus_pr_leietaker.php
diff -N custom/oppdater_namssakstatus_pr_leietaker.php
--- custom/oppdater_namssakstatus_pr_leietaker.php      26 Jan 2007 14:54:04 
-0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,214 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: oppdater_namssakstatus_pr_leietaker.php,v 1.2 
2007/01/26 14:54:04 sigurdne Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class oppdater_namssakstatus_pr_leietaker
-       {
-               var     $function_name = 'oppdater_namssakstatus_pr_leietaker';
-
-               function oppdater_namssakstatus_pr_leietaker()
-               {
-                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->db                       = 
$this->bocommon->new_db();
-                       $this->db2                      = 
$this->bocommon->new_db();
-
-                       $this->join                     = $this->bocommon->join;
-                       $this->left_join                = 
$this->bocommon->left_join;
-                       $this->like                     = $this->bocommon->like;
-
-                       $this->db_boei                  = 
CreateObject($this->currentapp.'.db_mssql');
-                       $this->db_boei->Host            = 
$GLOBALS['external_db']['boei']['db_host'];
-                       $this->db_boei->Type            = 
$GLOBALS['external_db']['boei']['db_type'];
-                       $this->db_boei->Database        = 
$GLOBALS['external_db']['boei']['db_name'];
-                       $this->db_boei->User            = 
$GLOBALS['external_db']['boei']['db_user'];
-                       $this->db_boei->Password        = 
$GLOBALS['external_db']['boei']['db_pass'];
-                       $this->db_boei->Halt_On_Error   = 'yes';
-               }
-
-               function pre_run($data='')
-               {
-                       if($data['enabled']==1)
-                       {
-                               $confirm        = True;
-                               $cron           = True;
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                       }
-
-                       if ($confirm)
-                       {
-                               $this->execute($cron);
-                       }
-                       else
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-
-               function confirm($execute='')
-               {
-                       $link_data = array
-                       (
-                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
-                               'function'      =>$this->function_name,
-                               'execute'       => $execute,
-                       );
-
-
-                       if(!$execute)
-                       {
-                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
-                       }
-
-                       $lang_yes                       = lang('yes');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
-                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'message'                               => 
$this->receipt['message'],
-                               'lang_confirm_msg'              => 
$lang_confirm_msg,
-                               'lang_yes'                              => 
$lang_yes,
-                               'lang_yes_statustext'   => lang('Update the 
category to not active based on if there is only nonactive apartments'),
-                               'lang_no_statustext'    => 'tilbake',
-                               'lang_no'                               => 
lang('no'),
-                               'lang_done'                             => 
'Avbryt',
-                               'lang_done_statustext'  => 'tilbake'
-                       );
-
-                       $appname                = lang('location');
-                       $function_msg   = 'Oppdatere namssaksstatus pr 
leietater';
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
-                       $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function execute($cron='')
-               {
-
-                       $receipt = $this->oppdater_namssakstatus();
-                       $this->cron_log($receipt,$cron);
-
-                       if(!$cron)
-                       {
-                               $this->confirm($execute=False);
-                       }
-
-               }
-
-               function cron_log($receipt='',$cron='')
-               {
-
-                       $insert_values= array(
-                               $cron,
-                               date($this->bocommon->datetimeformat),
-                               $this->function_name,
-                               $receipt
-                               );
-
-                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
-                                       . "VALUES ($insert_values)";
-                       $this->db->query($sql,__LINE__,__FILE__);
-               }
-
-               function oppdater_namssakstatus()
-               {
-
-                       $sql = "SELECT TOP 100 PERCENT fm_tenant.id"
-                                       . " FROM  fm_tenant LEFT OUTER JOIN"
-                    . " v_Leietaker ON fm_tenant.id = v_Leietaker.leietaker_id 
AND "
-                    . " fm_tenant.status_drift = 
v_Leietaker.namssakstatusdrift_id AND "
-                    . " fm_tenant.status_eco = 
v_Leietaker.namssakstatusokonomi_id"
-                                       . " WHERE (v_Leietaker.leietaker_id IS 
NULL)";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       while ($this->db_boei->next_record())
-                       {
-                               $leietaker[]= $this->db_boei->f('id');
-                       }
-
-                       for ($i=0; $i<count($leietaker); $i++)
-                       {
-                               $sql = "SELECT namssakstatusokonomi_id, 
namssakstatusdrift_id"
-                                       . " FROM  v_Leietaker"
-                                       . " WHERE (v_Leietaker.leietaker_id = 
'" . $leietaker[$i] . "')";
-
-                               $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                               $this->db_boei->next_record();
-                               $leietaker_oppdatert[]= array (
-                                'id'                           => 
$leietaker[$i],
-                                'status_drift'         => 
$this->db_boei->f('namssakstatusdrift_id'),
-                                'status_eco'           => 
$this->db_boei->f('namssakstatusokonomi_id')
-                                );
-
-                       }
-
-                       for ($i=0; $i<count($leietaker_oppdatert); $i++)
-                       {
-                               $sql = " UPDATE fm_tenant SET "
-                               . " status_eco = '" . 
$leietaker_oppdatert[$i]['status_eco'] . "',"
-                               . " status_drift = '" . 
$leietaker_oppdatert[$i]['status_drift'] . "'"
-                               . " WHERE  id = '" . 
$leietaker_oppdatert[$i]['id'] . "'";
-
-                               $this->db->query($sql,__LINE__,__FILE__);
-                               $this->db_boei->query($sql,__LINE__,__FILE__);
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = $i . ' namssakstatus er oppdatert';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-
-               }
-       }
-?>

Index: custom/oppdater_utgaatt_objekt.php
===================================================================
RCS file: custom/oppdater_utgaatt_objekt.php
diff -N custom/oppdater_utgaatt_objekt.php
--- custom/oppdater_utgaatt_objekt.php  26 Jan 2007 14:54:04 -0000      1.10
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,254 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: oppdater_utgaatt_objekt.php,v 1.10 2007/01/26 14:54:04 
sigurdne Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class oppdater_utgaatt_objekt
-       {
-               var     $function_name = 'oppdater_utgaatt_objekt';
-
-               function oppdater_utgaatt_objekt()
-               {
-                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->db                       = 
$this->bocommon->new_db();
-                       $this->db2                      = 
$this->bocommon->new_db();
-                       $this->soadmin_location = 
CreateObject($this->currentapp.'.soadmin_location');
-
-                       $this->join                     = $this->bocommon->join;
-                       $this->left_join                = 
$this->bocommon->left_join;
-               }
-
-               function pre_run($data='')
-               {
-                       if($data['enabled']==1)
-                       {
-                               $confirm        = True;
-                               $cron           = True;
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                       }
-
-                       if ($confirm)
-                       {
-                               $this->execute($cron);
-                       }
-                       else
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-
-               function confirm($execute='')
-               {
-                       $link_data = array
-                       (
-                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
-                               'function'      =>$this->function_name,
-                               'execute'       => $execute,
-                       );
-
-
-                       if(!$execute)
-                       {
-                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
-                       }
-
-                       $lang_yes                       = lang('yes');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
-                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'message'                               => 
$this->receipt['message'],
-                               'lang_confirm_msg'              => 
$lang_confirm_msg,
-                               'lang_yes'                              => 
$lang_yes,
-                               'lang_yes_statustext'   => lang('Update the 
category to not active based on if there is only nonactive apartments'),
-                               'lang_no_statustext'    => 'tilbake',
-                               'lang_no'                               => 
lang('no'),
-                               'lang_done'                             => 
'Avbryt',
-                               'lang_done_statustext'  => 'tilbake'
-                       );
-
-                       $appname                = lang('location');
-                       $function_msg   = lang('Update the not active category 
for locations');
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
-                       $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function execute($cron='')
-               {
-                       $location_types = 
$this->soadmin_location->select_location_type();
-
-                       $m= count($location_types);
-
-
-                       $this->db->query("UPDATE fm_location" . $m. " set       
status= 2  WHERE category=99",__LINE__,__FILE__);
-
-                       for ($type_id=$m; $type_id>1; $type_id--)
-                       {
-                               $parent_table = 'fm_location' . ($type_id-1);
-
-                               $joinmethod .= " $this->join $parent_table";
-
-                               $paranthesis .='(';
-
-                               $on = 'ON';
-                               for ($i=($type_id-1); $i>0; $i--)
-                               {
-                                       $joinmethod .= " $on (fm_location" . 
($type_id) .".loc" . ($i). ' = '.$parent_table . ".loc" . ($i) . ")";
-                                       $on = 'AND';
-                                       if($i==1)
-                                       {
-                                               $joinmethod .= ")";
-                                       }
-                               }
-
-                               $sql = "SELECT $parent_table.location_code 
,count(*) as count_99  FROM $paranthesis fm_location$type_id $joinmethod where 
fm_location$type_id.status=2 group by $parent_table.location_code ";
-                               $this->db->query($sql,__LINE__,__FILE__);
-
-                               while ($this->db->next_record())
-                               {
-                                       
$outdated[$this->db->f('location_code')]['count_99']=$this->db->f('count_99');
-                               }
-
-                               $sql = "SELECT $parent_table.location_code 
,count(*) as count_all  FROM $paranthesis fm_location$type_id $joinmethod group 
by $parent_table.location_code ";
-                               $this->db->query($sql,__LINE__,__FILE__);
-                               while ($this->db->next_record())
-                               {
-                                       if( 
$outdated[$this->db->f('location_code')]['count_99']==$this->db->f('count_all'))
-                                       {
-                                               $update[]=array('location_code' 
=> $this->db->f('location_code'));
-                                       }
-                               }
-
-                               $metadata = 
$this->db->metadata('fm_location'.($type_id-1));
-
-                               if(isset($this->db->adodb))
-                               {
-                                       $i = 0;
-                                       foreach($metadata as $key => $val)
-                                       {
-                                               $metadata_temp[$i]['name'] = 
$key;
-                                               $i++;
-                                       }
-                                       $metadata = $metadata_temp;
-                                       unset ($metadata_temp);
-                               }
-
-                               $j=0;
-                               for ($i=0; $i<count($update); $i++)
-                               {
-                                       $this->db->transaction_begin();
-
-                                       $sql = "SELECT category FROM 
$parent_table WHERE location_code= '" . $update[$i]['location_code'] ."'";
-
-                                       
$this->db->query($sql,__LINE__,__FILE__);
-                                       $this->db->next_record();
-
-                                       if($this->db->f('category')!=99)
-                                       {
-                                               $sql = "SELECT * from 
$parent_table WHERE location_code ='" . $update[$i]['location_code'] . "'";
-                                               
$this->db->query($sql,__LINE__,__FILE__);
-                                               $this->db->next_record();
-
-                                               for ($k=0; $k<count($metadata); 
$k++)
-                                               {
-                                                       $cols[] = 
$metadata[$k]['name'];
-                                                       $vals[] = 
$this->db->f($metadata[$k]['name']);
-                                               }
-
-                                               $cols[] = 'exp_date';
-                                               $vals[] = 
date($this->bocommon->datetimeformat,time());
-
-                                               $cols   =implode(",", $cols);
-                                               $vals = 
$this->bocommon->validate_db_insert($vals);
-
-                                               $sql = "INSERT INTO 
fm_location" . ($type_id-1) ."_history ($cols) VALUES ($vals)";
-                                               
$this->db->query($sql,__LINE__,__FILE__);
-                                               unset($cols);
-                                               unset($vals);
-
-                                               $j++;
-                                               $this->db->query("UPDATE 
fm_location" . ($type_id-1). " set     status= 2, category=99, change_type=2  
WHERE location_code= '" . $update[$i]['location_code'] ."'",__LINE__,__FILE__);
-                                               if($type_id == 2)
-                                               {
-                                                       
$this->db->query("UPDATE fm_location1 set kostra_id = NULL  WHERE 
location_code= '" . $update[$i]['location_code'] ."'",__LINE__,__FILE__);
-                                               }
-                                       }
-                               }
-
-                               
$this->receipt['message'][]=array('msg'=>lang('%1 location %2 has been updated 
to not active of %3 already not 
active',$j,$location_types[($type_id-2)]['descr'],count($update)));
-
-                               $log_msg .= lang('%1 location %2 has been 
updated to not active of %3 already not 
active',$j,$location_types[($type_id-2)]['descr'],count($update));
-                               unset($outdated);
-                               unset($update);
-                               unset($joinmethod);
-                               unset($paranthesis);
-                               unset($metadata);
-                               $this->db->transaction_commit();
-                       }
-
-
-                       if(!$cron)
-                       {
-                               $this->confirm($execute=False);
-                       }
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $insert_values= array(
-                               $cron,
-                               date($this->bocommon->datetimeformat),
-                               $this->function_name,
-                               implode(',',(array_keys($msgbox_data)))
-                               );
-
-                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
-                                       . "VALUES ($insert_values)";
-                       $this->db->query($sql,__LINE__,__FILE__);
-               }
-       }
-?>

Index: custom/organize_drawing.php
===================================================================
RCS file: custom/organize_drawing.php
diff -N custom/organize_drawing.php
--- custom/organize_drawing.php 26 Jan 2007 14:54:04 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,456 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: organize_drawing.php,v 1.7 2007/01/26 14:54:04 sigurdne 
Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class organize_drawing
-       {
-               /* In Admin->Property->Async servises:
-               *  Name: property.custom_functions.index
-               *  Data: function=organize_drawing,dir=C:/path/to/drawings
-               */
-
-               var     $dir = '/mnt/filer2/Tegninger';
-               var     $suffix = 'dwg';
-               var     $bypass = False; // bypass location check (only for 
debugging)
-               var     $function_name = 'organize_drawing';
-
-               function organize_drawing()
-               {
-                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->vfs              = CreateObject('phpgwapi.vfs');
-                       $this->rootdir          = $this->vfs->basedir;
-                       $this->fakebase         = $this->vfs->fakebase;
-                       $this->db               = $this->bocommon->new_db();
-
-               }
-
-               function pre_run($data='')
-               {
-
-                       if($data['enabled']==1)
-                       {
-                               $confirm                = True;
-                               $execute                = True;
-                               $cron                   = True;
-                               if($data['suffix'])
-                               {
-                                       $this->suffix = $data['suffix'];
-                               }
-                               if($data['dir'])
-                               {
-                                       $this->dir = $data['dir'];
-                               }
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                               if(get_var('dir',array('GET')))
-                               {
-                                       $this->dir = urldecode 
(get_var('dir',array('GET')));
-                               }
-                               if(get_var('suffix',array('GET')))
-                               {
-                                       $this->suffix = 
get_var('suffix',array('GET'));
-                               }
-                       }
-
-                       if(!$execute)
-                       {
-                               $dry_run=True;
-                       }
-
-                       if ($confirm)
-                       {
-                               $this->execute($dry_run,$cron);
-                       }
-                       else
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-               function confirm($execute='',$done='')
-               {
-                       $link_data = array
-                       (
-                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
-                               'function'      => $this->function_name,
-                               'execute'       => $execute,
-                               'dir'           => $this->dir,
-                               'suffix'        => $this->suffix,
-                       );
-
-                       if(!$done)
-                       {
-                               if(!$execute)
-                               {
-                                       $lang_confirm_msg       = 'Gå videre 
for å se hva som blir lagt til';
-                               }
-                               else
-                               {
-                                       $lang_confirm_msg       = 'Vil du 
virkelig utføre denne operasjonen';
-                               }
-                       }
-                       $lang_yes                       = lang('yes');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
-                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'message'                               => 
$this->receipt['message'],
-                               'lang_confirm_msg'              => 
$lang_confirm_msg,
-                               'lang_yes'                              => 
$lang_yes,
-                               'lang_yes_statustext'   => 'Organisere 
tegninger i register og på disk',
-                               'lang_no_statustext'    => 'tilbake',
-                               'lang_no'                               => 
lang('no'),
-                               'lang_done'                             => 
'Avbryt',
-                               'lang_done_statustext'  => 'tilbake'
-                       );
-
-                       $appname                = 'Organisere tegninger';
-                       $function_msg   = 'Organisere tegninger i register og 
på disk';
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
-                       $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function execute($dry_run='',$cron='')
-               {
-
-                       $file_list = $this->get_files();
-
-                       if($dry_run)
-                       {
-                               $this->confirm($execute=True);
-                               _debug_array($file_list);
-                       }
-                       else
-                       {
-                               if (isSet($file_list) AND is_array($file_list))
-                               {
-                                       foreach($file_list as $file_entry)
-                                       {
-                                               $loc1_list[$file_entry['loc1']] 
= True;
-                                       }
-
-                                       $loc1_list = array_keys($loc1_list);
-
-                                       for ($i=0;$i<count($loc1_list);$i++)
-                                       {
-                                               
$this->create_loc1_dir($loc1_list[$i]);
-                                       }
-
-                                       for ($i=0;$i<count($file_list);$i++)
-                                       {
-                                               
$this->copy_files($file_list[$i]);
-                                       }
-                               }
-                               if(!$cron)
-                               {
-                                       
$this->confirm($execute=false,$done=True);
-                               }
-
-                               $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                               $insert_values= array(
-                                       $cron,
-                                       date($this->bocommon->datetimeformat),
-                                       $this->function_name,
-                                       implode(',',(array_keys($msgbox_data)))
-                                       );
-
-                               $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                               $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
-                                               . "VALUES ($insert_values)";
-                               $this->db->query($sql,__LINE__,__FILE__);
-                       }
-               }
-
-               function get_files()
-               {
-                       $drawing_branch=array(
-                       'a' => 'arkitekt'
-                       );
-
-                       $category=array(
-                       'plan' => 2,
-                       'snitt' => 3,
-                       'fasade' => 4
-                       );
-
-                       $branch_id_array=array(
-                       'arkitekt' => 13
-                       );
-
-                       $dir_handle = @opendir($this->dir);
-
-                       $i=0; $myfilearray = '';
-                       while ($file = @readdir($dir_handle))
-                       {
-                               if ((strtolower(substr($file, -3, 3)) == 
$this->suffix) && is_file($this->dir . SEP . $file) )
-                               {
-                                       $myfilearray[$i] = $file;
-                                       $i++;
-                               }
-                       }
-                       @closedir($dir_handle);
-                       @sort($myfilearray);
-
-                       for ($i=0;$i<count($myfilearray);$i++)
-                       {
-                               $fname = $myfilearray[$i];
-                               $loc1 = substr($myfilearray[$i],4,4);
-                               $loc2 = substr($myfilearray[$i],8,2);
-                               $etasje = '';
-                               $loc3 = '';
-                               $nr = '';
-                               $direction = '';
-
-                               $type = $this->get_type($myfilearray[$i]);
-                               switch($type)
-                               {
-                                       case 'plan':
-                                               $etasje = 
substr($myfilearray[$i],13,2);
-                                               $loc3 = 
substr($myfilearray[$i],10,2);
-                                               $location_code = $loc1 . '-' . 
$loc2 . '-' . $loc3;
-                                               break;
-                                       case 'snitt':
-                                               $location_code = $loc1 . '-' . 
$loc2;
-                                               $nr = 
substr($myfilearray[$i],-8,3);
-                                               break;
-                                       case 'fasade':
-                                               $location_code = $loc1 . '-' . 
$loc2;
-                                               $direction = 
substr($myfilearray[$i],11,2);
-                                               $nr = 
substr($myfilearray[$i],-8,3);
-                                               break;
-                               }
-
-
-                               $branch = 
$drawing_branch[strtolower(substr($myfilearray[$i],-5,1))];
-
-                               if ($this->check_building($loc1,$loc2) && $type 
&& $branch)
-                               {
-                                       $file_list[] = array
-                                       (
-                                               'file_name'     => $fname,
-                                               'loc1'          => $loc1,
-                                               'loc2'          => $loc2,
-                                               'loc3'          => $loc3,
-                                               'type'          => $type,
-                                               'nr'            => $nr,
-                                               'etasje'        => $etasje,
-                                               'branch'        => $branch,
-                                               'branch_id' => 
$branch_id_array[$branch],
-                                               'category_id'   => 
$category[$type],
-                                               'direction'     => $direction,
-                                               'location_code' => 
$location_code,
-                                       );
-                               }
-                       }
-
-                       return $file_list;
-               }
-
-
-               function get_type($filename='')
-               {
-                       $drawing_type=array(
-                       'p' => 'plan',
-                       'f' => 'fasade',
-                       's' => 'snitt'
-                       );
-
-                       for ($i=10;$i<strlen($filename);$i++)
-                       {
-                               $type = 
$drawing_type[strtolower(substr($filename,$i,1))];
-                               if($type)
-                               {
-                                       return $type;
-                               }
-                       }
-               }
-
-               function check_building($loc1='',$loc2='')
-               {
-                       $sql = "SELECT count(*)  FROM fm_location2 WHERE loc1= 
'$loc1' AND loc2= '$loc2'";
-
-//_debug_array($sql);
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       $this->db->next_record();
-                       if($this->db->f(0))
-                       {
-                               return True;
-                       }
-
-                       if($this->bypass)
-                       {
-                               return True;
-                       }
-
-               }
-
-               function create_loc1_dir($loc1='')
-               {
-                       if(!$this->vfs->file_exists(array(
-                                       'string' => $this->fakebase . SEP . 
'document' . SEP . $loc1,
-                                       'relatives' => Array(RELATIVE_NONE)
-                               )))
-                       {
-                               $this->vfs->override_acl = 1;
-
-                               if(!$this->vfs->mkdir (array(
-                                    'string' => $this->fakebase. SEP . 
'document' . SEP . $loc1,
-                                    'relatives' => array(
-                                         RELATIVE_NONE
-                                    )
-                               )))
-                               {
-                                       
$this->receipt['error'][]=array('msg'=>lang('failed to create directory') . ' 
:'. $this->fakebase. SEP . 'document' . SEP . $loc1);
-                               }
-                               else
-                               {
-                                       
$this->receipt['message'][]=array('msg'=>lang('directory created') . ' :'. 
$this->fakebase. SEP . 'document' . SEP . $loc1);
-                               }
-                               $this->vfs->override_acl = 0;
-                       }
-
-//                     return $this->receipt;
-               }
-
-               function copy_files($values)
-               {
-                       $to_file = $this->fakebase . SEP . 'document' . SEP . 
$values['loc1'] . SEP . $values['file_name'];
-                       $from_file = $this->dir . SEP . $values['file_name'];
-                       $this->vfs->override_acl = 1;
-
-
-//_debug_array($to_file);
-                       if($this->vfs->file_exists(array(
-                                       'string' => $to_file,
-                                       'relatives' => Array(RELATIVE_NONE)
-                               )))
-                       {
-                               
$this->receipt['error'][]=array('msg'=>lang('File %1 already 
exists!',$values['file_name']));
-                       }
-                       else
-                       {
-
-                               if(!$this->vfs->cp (array (
-                                       'from'  => $from_file,
-                                       'to'    => $to_file,
-                                       'relatives'     => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
-                               {
-                                       
$this->receipt['error'][]=array('msg'=>lang('Failed to copy file !') . 
$values['file_name']);
-                               }
-                               else
-                               {
-                                       $address = 
$this->get_address($values['loc1'],$values['loc2'],$values['loc3']);
-
-                                       switch($values['type'])
-                                       {
-                                               case 'plan':
-                                                       $values['title'] = 
$this->db->db_addslashes($values['branch'] . ', ' .$values['type'] . ', etasje: 
' . $values['etasje']);
-                                                       break;
-                                               case 'snitt':
-                                                       $values['title'] = 
$this->db->db_addslashes($values['branch'] . ', ' . $values['type'] . ' nr: ' . 
$values['nr']);
-                                                       break;
-                                               case 'fasade':
-                                                       $values['title'] = 
$this->db->db_addslashes($values['branch'] . ', ' . $values['type'] . ' nr: ' . 
$values['nr'] . ' retning: ' . $values['direction']);
-                                                       break;
-                                       }
-
-                                       $insert_values= array(
-                                               $values['file_name'],
-                                               $values['title'],
-                                               'public',
-                                               $values['category_id'],
-                                               time(),
-                                               $values['values_date'],
-                                               $values['version'],
-                                               $values['coordinator'],
-                                               $values['status'],
-                                               $values['location_code'],
-                                               $address,
-                                               $values['branch_id'],
-                                               $values['vendor_id'],
-                                               $this->account,
-                                               $values['loc1'],
-                                               $values['loc2'],
-                                               $values['loc3'],
-                                               );
-
-                                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                                       $sql = "INSERT INTO fm_document 
(document_name,title,access,category,entry_date,document_date,version,coordinator,status,"
-                                               . 
"location_code,address,branch_id,vendor_id,user_id,loc1,loc2,loc3) "
-                                               . "VALUES ($insert_values)";
-
-                                       
$this->db->query($sql,__LINE__,__FILE__);
-
-                                       unlink($from_file);
-
-                                       
$this->receipt['message'][]=array('msg'=>lang('File %1 
copied!',$values['file_name']));
-                                       
$this->receipt['message'][]=array('msg'=>lang('File %1 deleted!',$from_file));
-                               }
-                       }
-
-                       $this->vfs->override_acl = 0;
-//                     return $this->receipt;
-               }
-
-               function get_address($loc1='',$loc2='',$loc3='')
-               {
-                       if ($loc3)
-                       {
-                               $sql = "SELECT loc3_name as address FROM 
fm_location3 WHERE loc1='$loc1' AND loc2='$loc2' AND loc3='$loc3'";
-                       }
-                       else
-                       {
-                               $sql = "SELECT loc2_name as address FROM 
fm_location2 WHERE loc1='$loc1' AND loc2='$loc2'";
-                       }
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       $this->db->next_record();
-                       return $this->db->f('address');
-               }
-       }
-?>

Index: custom/synkroniser_med_boei.php
===================================================================
RCS file: custom/synkroniser_med_boei.php
diff -N custom/synkroniser_med_boei.php
--- custom/synkroniser_med_boei.php     26 Jan 2007 14:54:05 -0000      1.10
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,794 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare 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.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage custom
-       * @version $Id: synkroniser_med_boei.php,v 1.10 2007/01/26 14:54:05 
sigurdne Exp $
-       */
-
-       /**
-        * Description
-        * @package property
-        */
-
-       class synkroniser_med_boei
-       {
-               var     $function_name = 'synkroniser_med_boei';
-
-               function synkroniser_med_boei()
-               {
-                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon                 = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->db                               = 
$this->bocommon->new_db();
-
-                       $this->join                             = 
$this->bocommon->join;
-                       $this->left_join                = 
$this->bocommon->left_join;
-                       $this->like                             = 
$this->bocommon->like;
-
-                       $this->db_boei                  = 
CreateObject($this->currentapp.'.db_mssql');
-                       $this->db_boei->Host            = 
$GLOBALS['external_db']['boei']['db_host'];
-                       $this->db_boei->Type            = 
$GLOBALS['external_db']['boei']['db_type'];
-                       $this->db_boei->Database        = 
$GLOBALS['external_db']['boei']['db_name'];
-                       $this->db_boei->User            = 
$GLOBALS['external_db']['boei']['db_user'];
-                       $this->db_boei->Password        = 
$GLOBALS['external_db']['boei']['db_pass'];
-                       $this->db_boei->Halt_On_Error   = 'yes';
-
-                       $this->db_boei2                 = 
CreateObject($this->currentapp.'.db_mssql');
-                       $this->db_boei2->Host           = 
$GLOBALS['external_db']['boei']['db_host'];
-                       $this->db_boei2->Type           = 
$GLOBALS['external_db']['boei']['db_type'];
-                       $this->db_boei2->Database       = 
$GLOBALS['external_db']['boei']['db_name'];
-                       $this->db_boei2->User           = 
$GLOBALS['external_db']['boei']['db_user'];
-                       $this->db_boei2->Password       = 
$GLOBALS['external_db']['boei']['db_pass'];
-                       $this->db_boei2->Halt_On_Error  = 'yes';
-               }
-
-               function pre_run($data='')
-               {
-                       if($data['enabled']==1)
-                       {
-                               $confirm        = True;
-                               $cron           = True;
-                       }
-                       else
-                       {
-                               $confirm        = 
get_var('confirm',array('POST'));
-                               $execute        = 
get_var('execute',array('GET'));
-                       }
-
-                       if ($confirm)
-                       {
-                               $this->execute($cron);
-                       }
-                       else
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-
-               function confirm($execute='')
-               {
-                       $link_data = array
-                       (
-                               'menuaction' => 
$this->currentapp.'.custom_functions.index',
-                               'function'      =>$this->function_name,
-                               'execute'       => $execute,
-                       );
-
-
-                       if(!$execute)
-                       {
-                               $lang_confirm_msg       = 'Vil du virkelig 
utføre denne operasjonen';
-                       }
-
-                       $lang_yes                       = lang('yes');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-
-                       $msgbox_data = 
$this->bocommon->msgbox_data($this->receipt);
-
-                       $data = array
-                       (
-                               'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
-                               'run_action'                    => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'message'                               => 
$this->receipt['message'],
-                               'lang_confirm_msg'              => 
$lang_confirm_msg,
-                               'lang_yes'                              => 
$lang_yes,
-                               'lang_yes_statustext'   => lang('Update the 
category to not active based on if there is only nonactive apartments'),
-                               'lang_no_statustext'    => 'tilbake',
-                               'lang_no'                               => 
lang('no'),
-                               'lang_done'                             => 
'Avbryt',
-                               'lang_done_statustext'  => 'tilbake'
-                       );
-
-                       $appname                = lang('location');
-                       $function_msg   = 'synkroniser med BOEI';
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
-                       $GLOBALS['phpgw']->xslttpl->pp();
-               }
-
-               function execute($cron='')
-               {
-                       $receipt = $this->legg_til_eier_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->legg_til_gateadresse_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->legg_til_objekt_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->legg_til_bygg_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->legg_til_seksjon_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->legg_til_leieobjekt_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->legg_til_leietaker_phpgw();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->oppdater_leieobjekt();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->oppdater_boa_objekt();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->oppdater_boa_bygg();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->oppdater_boa_del();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->oppdater_oppsagtdato();
-                       $this->cron_log($receipt,$cron);
-                       $receipt = $this->slett_feil_telefon();
-                       $this->cron_log($receipt,$cron);
-
-                       if(!$cron)
-                       {
-                               $this->confirm($execute=False);
-                       }
-               }
-
-               function cron_log($receipt='',$cron='')
-               {
-
-                       $insert_values= array(
-                               $cron,
-                               date($this->bocommon->datetimeformat),
-                               $this->function_name,
-                               $receipt
-                               );
-
-                       $insert_values  = 
$this->bocommon->validate_db_insert($insert_values);
-
-                       $sql = "INSERT INTO fm_cron_log 
(cron,cron_date,process,message) "
-                                       . "VALUES ($insert_values)";
-                       $this->db->query($sql,__LINE__,__FILE__);
-               }
-
-               function legg_til_eier_phpgw()
-               {
-                       $sql = " SELECT TOP 100 PERCENT v_Eier.id, 
v_Eier.category"
-                               . " FROM  v_Eier";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-                       while ($this->db_boei->next_record())
-                       {
-                               if($this->db_boei->f('category')==0)
-                               {
-                                       $category = 4;
-                               }
-                               else
-                               {
-                                       $category = 
$this->db_boei->f('category');
-                               }
-                               $owner[]= array (
-                                'id'           => $this->db_boei->f('id'),
-                                'category'     => $category,
-                                );                     
-                       }
-                       
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($owner); $i++)
-                       {
-                               $sql2 = "UPDATE fm_owner set category = 
'{$owner[$i]['category']}' WHERE id = '{$owner[$i]['id']}'";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-                       }
-
-                       unset($owner);
-
-                       $sql = "SELECT v_Eier.id, 
v_Eier.org_name,v_Eier.category FROM  fm_owner RIGHT OUTER JOIN "
-                               . " v_Eier ON fm_owner.id = v_Eier.id"
-                                       . " WHERE (fm_owner.id IS NULL)";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-                       while ($this->db_boei->next_record())
-                       {
-                               if($this->db_boei->f('category')==0)
-                               {
-                                       $category = 4;
-                               }
-                               else
-                               {
-                                       $category = 
$this->db_boei->f('category');
-                               }
-                               $owner[]= array (
-                                'id'           => $this->db_boei->f('id'),
-                                'org_name'     => 
$this->db->db_addslashes($this->db_boei->f('org_name')),
-                                'remark'       => 
$this->db->db_addslashes($this->db_boei->f('org_name')),
-                                'category'     => $category,
-                                'entry_date'   => time(),
-                                'owner_id'             => 6
-                                );
-                       }
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($owner); $i++)
-                       {
-                               $sql2 = "INSERT INTO fm_owner 
(id,org_name,remark,category,entry_date,owner_id)"
-                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($owner[$i]) . ")";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               $owner_msg[]=$owner[$i]['org_name'];
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($owner) . ' eier er lagt til: ' . 
@implode(",", $owner_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($owner);
-                       unset ($owner_msg);
-                       return $msg;
-
-               }
-
-
-
-               function legg_til_gateadresse_phpgw()
-               {
-                       $sql = "SELECT v_Gateadresse.gateadresse_id, 
v_Gateadresse.gatenavn FROM  fm_streetaddress RIGHT OUTER JOIN "
-                               . " v_Gateadresse ON fm_streetaddress.id = 
v_Gateadresse.gateadresse_id"
-                                       . " WHERE (fm_streetaddress.id IS 
NULL)";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-                       while ($this->db_boei->next_record())
-                       {
-                               $gate[]= array (
-                                'id'           => 
$this->db_boei->f('gateadresse_id'),
-                                'descr'        => $this->db_boei->f('gatenavn')
-                                );
-
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($gate); $i++)
-                       {
-
-                               $sql2 = "INSERT INTO fm_streetaddress 
(id,descr)"
-                                       . " VALUES (" . $gate[$i]['id'] . ", 
'". $gate[$i]['descr']. "')";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               $gate_msg[]=$gate[$i]['descr'];
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($gate) . ' gateadresser er lagt til: ' . 
@implode(",", $gate_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($gate);
-                       unset ($gate_msg);
-                       return $msg;
-
-               }
-
-               function legg_til_objekt_phpgw()
-               {
-                       $sql = "SELECT v_Objekt.objekt_id, v_Objekt.navn, 
v_Objekt.bydel_id, v_Objekt.eier_id,v_Objekt.tjenestested"
-                                       . " FROM fm_location1 RIGHT OUTER JOIN "
-                               . " v_Objekt ON fm_location1.loc1 = 
v_Objekt.objekt_id"
-                                       . " WHERE fm_location1.loc1 IS NULL";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-                       while ($this->db_boei->next_record())
-                       {
-                               $objekt[]= array (
-                                'location_code'        => 
$this->db_boei->f('objekt_id'),
-                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
-                                'loc1_name'            => 
$this->db_boei->f('navn'),
-                                'part_of_town_id'      => 
$this->db_boei->f('bydel_id'),
-                                'owner_id'             => 
$this->db_boei->f('eier_id'),
-                                'kostra_id'            => 
$this->db_boei->f('tjenestested')
-                                );
-
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($objekt); $i++)
-                       {
-
-                               $sql2 = "INSERT INTO fm_location1 
(location_code, loc1, loc1_name, part_of_town_id, owner_id, kostra_id) "
-                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($objekt[$i]) . ")";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               $obj_msg[]=$objekt[$i]['loc1'];
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($objekt) . ' Objekt er lagt til: ' . 
@implode(",", $obj_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($objekt);
-                       unset ($obj_msg);
-                       return $msg;
-               }
-
-               function legg_til_bygg_phpgw()
-               {
-                       $sql = "SELECT v_Bygg.objekt_id + '-' + v_Bygg.bygg_id 
AS location_code, v_Bygg.objekt_id, v_Bygg.bygg_id, 
v_Bygg.byggnavn,v_Bygg.driftstatus"
-                               . " FROM v_Bygg LEFT OUTER JOIN"
-                       . " fm_location2 ON v_Bygg.objekt_id = 
fm_location2.loc1 AND v_Bygg.bygg_id = fm_location2.loc2"
-                       . " WHERE fm_location2.loc1 IS NULL";
-
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-                       while ($this->db_boei->next_record())
-                       {
-
-                               $bygg[]= array (
-                                'location_code'        => 
$this->db_boei->f('location_code'),
-                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
-                                'loc2'                         => 
$this->db_boei->f('bygg_id'),
-                                'loc2_name'            => 
$this->db_boei->f('byggnavn'),
-                                );
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($bygg); $i++)
-                       {
-
-                               $sql2 = "INSERT INTO fm_location2 
(location_code, loc1, loc2, loc2_name) "
-                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($bygg[$i]) . ")";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               $bygg_msg[]=$bygg[$i]['location_code'];
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($bygg) . ' Bygg er lagt til: ' . 
@implode(",", $bygg_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($bygg);
-                       unset ($bygg_msg);
-                       return $msg;
-
-               }
-
-               function legg_til_seksjon_phpgw()
-               {
-
-                       $sql = "SELECT v_Seksjon.objekt_id + '-' + 
v_Seksjon.bygg_id + '-' + v_Seksjon.seksjons_id AS location_code, 
v_Seksjon.objekt_id, v_Seksjon.bygg_id,"
-                               . " v_Seksjon.seksjons_id, 
v_Seksjon.beskrivelse, v_Seksjon.totalt_fellesareal"
-                               . " FROM v_Seksjon LEFT OUTER JOIN"
-                               . " fm_location3 ON v_Seksjon.objekt_id = 
fm_location3.loc1 AND v_Seksjon.bygg_id = fm_location3.loc2 AND "
-                               . " v_Seksjon.seksjons_id = fm_location3.loc3"
-                               . " WHERE fm_location3.loc1 IS NULL";
-
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-                       while ($this->db_boei->next_record())
-                       {
-
-                               $seksjon[]= array (
-                                'location_code'        => 
$this->db_boei->f('location_code'),
-                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
-                                'loc2'                         => 
$this->db_boei->f('bygg_id'),
-                                'loc3'                         => 
$this->db_boei->f('seksjons_id'),
-                                'loc3_name'            => 
$this->db_boei->f('beskrivelse'),
-                                'fellesareal'  => 
$this->db_boei->f('totalt_fellesareal')
-                                );
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($seksjon); $i++)
-                       {
-
-                               $sql2 = "INSERT INTO fm_location3 
(location_code, loc1, loc2, loc3, loc3_name, fellesareal) "
-                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($seksjon[$i]) . ")";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               $seksjon_msg[]=$seksjon[$i]['location_code'];
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($seksjon) . ' Seksjon er lagt til: ' . 
@implode(",", $seksjon_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($seksjon);
-                       unset ($seksjon_msg);
-                       return $msg;
-               }
-
-               function legg_til_leieobjekt_phpgw()
-               {
-
-                       $sql = "SELECT v_Leieobjekt.objekt_id + '-' + 
v_Leieobjekt.bygg_id + '-' + v_Leieobjekt.seksjons_id + '-' + 
v_Leieobjekt.leie_id AS location_code,"
-                  . " v_Leieobjekt.objekt_id, v_Leieobjekt.leie_id, 
v_Leieobjekt.leieobjekttype_id, v_Leieobjekt.bygg_id, v_Leieobjekt.seksjons_id,"
-                  . " v_Leieobjekt.formaal_id, v_Leieobjekt.gateadresse_id, 
v_Leieobjekt.gatenr, v_Leieobjekt.etasje, v_Leieobjekt.antallrom,"
-                  . " v_Leieobjekt.boareal, v_Leieobjekt.livslopsstd, 
v_Leieobjekt.heis, v_Leieobjekt.driftsstatus_id, v_Leieobjekt.leietaker_id,"
-                  . " v_Leieobjekt.beregnet_boa"
-                  . " FROM v_Leieobjekt LEFT OUTER JOIN"
-                  . " fm_location4 ON v_Leieobjekt.objekt_id = 
fm_location4.loc1 AND v_Leieobjekt.leie_id = fm_location4.loc4"
-                  . " WHERE fm_location4.loc1 IS NULL";
-
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       while ($this->db_boei->next_record())
-                       {
-
-                               $leieobjekt[]= array (
-                                'location_code'        => 
$this->db_boei->f('location_code'),
-                                'loc1'                         => 
$this->db_boei->f('objekt_id'),
-                                'loc4'                         => 
$this->db_boei->f('leie_id'),
-                                'leieobjekttype_id'=> 
$this->db_boei->f('leieobjekttype_id'),
-                                'loc2'                         => 
$this->db_boei->f('bygg_id'),
-                                'loc3'                         => 
$this->db_boei->f('seksjons_id'),
-                                'category'             => 
$this->db_boei->f('formaal_id'),
-                                'street_id'            => 
$this->db_boei->f('gateadresse_id'),
-                                'street_number'        => 
$this->db_boei->f('gatenr'),
-                                'etasje'                       => 
$this->db_boei->f('etasje'),
-                                'antallrom'            => 
$this->db_boei->f('antallrom'),
-                                'boareal'                      => 
$this->db_boei->f('boareal'),
-                                'livslopsstd'          => 
$this->db_boei->f('livslopsstd'),
-                                'heis'                         => 
$this->db_boei->f('heis'),
-                                'driftsstatus_id'      => 
$this->db_boei->f('driftsstatus_id'),
-                                'tenant_id'            => 
$this->db_boei->f('leietaker_id'),
-                                'beregnet_boa'         => 
$this->db_boei->f('beregnet_boa')
-                                );
-
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($leieobjekt); $i++)
-                       {
-
-                               $sql2 = "INSERT INTO fm_location4 
(location_code, loc1, loc4, leieobjekttype_id, loc2, loc3, category, street_id, 
street_number, etasje, antallrom, boareal, livslopsstd, heis, driftsstatus_id,
-                      tenant_id, beregnet_boa)"
-                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($leieobjekt[$i]) . ")";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               
$leieobjekt_msg[]=$leieobjekt[$i]['location_code'];
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($leieobjekt) . ' Leieobjekt er lagt til: ' 
. @implode(",", $leieobjekt_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($leieobjekt);
-                       unset ($leieobjekt_msg);
-                       return $msg;
-               }
-
-               function legg_til_leietaker_phpgw()
-               {
-                       $sql = " SELECT v_Leietaker.leietaker_id, 
v_Leietaker.fornavn, v_Leietaker.etternavn, v_Leietaker.kjonn_juridisk,"
-                               . " v_Leietaker.namssakstatusokonomi_id, 
v_Leietaker.namssakstatusdrift_id"
-                               . " FROM fm_tenant RIGHT OUTER JOIN"
-                               . " v_Leietaker ON fm_tenant.id = 
v_Leietaker.leietaker_id"
-                               . " WHERE fm_tenant.id IS NULL";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       while ($this->db_boei->next_record())
-                       {
-                               $leietaker[]= array (
-                                'id'                           => 
$this->db_boei->f('leietaker_id'),
-                                'first_name'           => 
$this->db_boei->f('fornavn'),
-                                'last_name'            => 
$this->db_boei->f('etternavn'),
-                                'category'                     => 
$this->db_boei->f('kjonn_juridisk') + 1,
-                                'status_eco'           => 
$this->db_boei->f('namssakstatusokonomi_id'),
-                                'status_drift'         => 
$this->db_boei->f('namssakstatusdrift_id'),
-                                'entry_date'           => time(),
-                                'owner_id'                     => 6
-                                );
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       for ($i=0; $i<count($leietaker); $i++)
-                       {
-                               $sql2 = "INSERT INTO fm_tenant (id, first_name, 
last_name, category, status_eco, status_drift,entry_date,owner_id)"
-                                       . "VALUES (" . 
$this->bocommon->validate_db_insert($leietaker[$i]) . ")";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei->query($sql2,__LINE__,__FILE__);
-
-                               $leietaker_msg[]= '[' 
.$leietaker[$i]['last_name'] . ', ' . $leietaker[$i]['first_name'] . ']';
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = count($leietaker) . ' Leietaker er lagt til: ' . 
@implode(",", $leietaker_msg);
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       unset ($leietaker);
-                       unset ($leietaker_msg);
-                       return $msg;
-
-               }
-
-               function oppdater_leieobjekt()
-               {
-
-                       $sql = " SELECT TOP 100 PERCENT 
objekt_id,leie_id,leietaker_id, boareal, formaal_id, gateadresse_id, gatenr, 
etasje,driftsstatus_id"
-                               . " FROM  v_Leieobjekt"; // WHERE 
v_Leieobjekt.formaal_id NOT IN (99)";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $i=0;
-                       while ($this->db_boei->next_record())
-                       {
-                               $sql2 = " UPDATE  fm_location4 SET "
-                               . " tenant_id = '" . 
$this->db_boei->f('leietaker_id') . "',"
-                               . " category = '" . 
$this->db_boei->f('formaal_id') . "',"
-                               . " etasje = '" . $this->db_boei->f('etasje') . 
"',"
-                               . " street_id = '" . 
$this->db_boei->f('gateadresse_id') . "',"
-                               . " street_number = '" . 
$this->db_boei->f('gatenr') . "',"
-                               . " driftsstatus_id = '" . 
$this->db_boei->f('driftsstatus_id') . "',"
-                               . " boareal = '" . $this->db_boei->f('boareal') 
. "'"
-                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'  AND  loc4= '" . 
$this->db_boei->f('leie_id') . "'";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
-                               $i++;
-                       }
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $msg = $i . ' Leieobjekt er oppdatert';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-
-               }
-
-               function oppdater_boa_objekt()
-               {
-
-                       $sql = " SELECT TOP 100 PERCENT 
sum(v_Leieobjekt.boareal) as sum_boa, count(leie_id) as ant_leieobjekt,"
-                                       . " 
v_Objekt.objekt_id,bydel_id,tjenestested,navn,v_Objekt.eier_id FROM  v_Objekt 
$this->join v_Leieobjekt ON v_Objekt.objekt_id = v_Leieobjekt.objekt_id"
-                                       . " WHERE v_Leieobjekt.formaal_id NOT 
IN (99)"
-                                       . " GROUP BY 
bydel_id,v_Objekt.objekt_id,navn,tjenestested,eier_id";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $i=0;
-                       while ($this->db_boei->next_record())
-                       {
-                               $sql2 = " UPDATE fm_location1 SET "
-                               . " loc1_name = '" . $this->db_boei->f('navn') 
. "',"
-                               . " sum_boa = '" . $this->db_boei->f('sum_boa') 
. "',"
-                               . " ant_leieobjekt = '" . 
$this->db_boei->f('ant_leieobjekt') . "',"
-                               . " part_of_town_id = '" . 
$this->db_boei->f('bydel_id') . "',"
-                               . " owner_id = '" . 
$this->db_boei->f('eier_id') . "',"
-                               . " kostra_id = '" . 
$this->db_boei->f('tjenestested') . "'"
-                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
-                               $i++;
-                       }
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $msg = $i . ' Objekt er oppdatert';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-
-
-               }
-
-               function oppdater_boa_bygg()
-               {
-                       $sql = " SELECT TOP 100 PERCENT 
sum(v_Leieobjekt.boareal) as sum_boa, count(leie_id) as ant_leieobjekt,"
-                                       . " v_Bygg.objekt_id,v_Bygg.bygg_id , 
byggnavn  FROM  v_Bygg $this->join v_Leieobjekt "
-                                       . " ON v_Bygg.objekt_id = 
v_Leieobjekt.objekt_id AND v_Bygg.bygg_id = v_Leieobjekt.bygg_id"
-                                       . " WHERE v_Leieobjekt.formaal_id NOT 
IN (99)"
-                                       . " GROUP BY 
v_Bygg.objekt_id,v_Bygg.bygg_id ,byggnavn";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $i=0;
-                       while ($this->db_boei->next_record())
-                       {
-                               $sql2 = " UPDATE fm_location2 SET "
-                               . " loc2_name = '" . 
$this->db_boei->f('byggnavn') . "',"
-                               . " sum_boa = '" . $this->db_boei->f('sum_boa') 
. "',"
-                               . " ant_leieobjekt = '" . 
$this->db_boei->f('ant_leieobjekt') . "'"
-                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'  AND  loc2= '" . 
$this->db_boei->f('bygg_id') . "'";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
-                               $i++;
-                       }
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $msg = $i . ' Bygg er oppdatert';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-               }
-
-               function oppdater_boa_del()
-               {
-
-                       $sql = " SELECT TOP 100 PERCENT 
sum(v_Leieobjekt.boareal) as sum_boa, count(leie_id) as ant_leieobjekt,"
-                                       . " 
v_Seksjon.objekt_id,v_Seksjon.bygg_id,v_Seksjon.seksjons_id , beskrivelse   
FROM  v_Seksjon $this->join v_Leieobjekt "
-                                       . " ON v_Seksjon.objekt_id = 
v_Leieobjekt.objekt_id"
-                                       . " AND v_Seksjon.bygg_id = 
v_Leieobjekt.bygg_id"
-                                       . " AND v_Seksjon.seksjons_id = 
v_Leieobjekt.seksjons_id"
-                                       . " WHERE v_Leieobjekt.formaal_id NOT 
IN (99)"
-                                       . " GROUP BY 
v_Seksjon.objekt_id,v_Seksjon.bygg_id,v_Seksjon.seksjons_id,beskrivelse";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       $i=0;
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       while ($this->db_boei->next_record())
-                       {
-                               $sql2 = " UPDATE fm_location3 SET "
-                               . " loc3_name = '" . 
$this->db_boei->f('beskrivelse') . "',"
-                               . " sum_boa = '" . $this->db_boei->f('sum_boa') 
. "',"
-                               . " ant_leieobjekt = '" . 
$this->db_boei->f('ant_leieobjekt') . "'"
-                               . " WHERE  loc1 = '" . 
$this->db_boei->f('objekt_id') . "'  AND  loc2= '" . 
$this->db_boei->f('bygg_id') . "'  AND  loc3= '" . 
$this->db_boei->f('seksjons_id') . "'";
-
-                               $this->db->query($sql2,__LINE__,__FILE__);
-                               $this->db_boei2->query($sql2,__LINE__,__FILE__);
-                               $i++;
-                       }
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       $msg = $i . ' Seksjoner er oppdatert';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-               }
-
-               function oppdater_oppsagtdato()
-               {
-
-                       $sql = "SELECT TOP 100 PERCENT fm_tenant.id"
-                                       . " FROM  fm_tenant LEFT OUTER JOIN"
-                    . " v_Leietaker ON fm_tenant.id = v_Leietaker.leietaker_id 
AND "
-                    . " fm_tenant.oppsagtdato = v_Leietaker.oppsagtdato"
-                                       . " WHERE (v_Leietaker.leietaker_id IS 
NULL)";
-
-                       $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                       $this->db->transaction_begin();
-                       $this->db_boei->transaction_begin();
-
-                       while ($this->db_boei->next_record())
-                       {
-                               $leietaker[]= $this->db_boei->f('id');
-                       }
-
-                       for ($i=0; $i<count($leietaker); $i++)
-                       {
-                               $sql = "SELECT oppsagtdato"
-                                       . " FROM  v_Leietaker"
-                                       . " WHERE (v_Leietaker.leietaker_id = 
'" . $leietaker[$i] . "')";
-
-                               $this->db_boei->query($sql,__LINE__,__FILE__);
-
-                               $this->db_boei->next_record();
-                               $leietaker_oppdatert[]= array (
-                                'id'                           => 
$leietaker[$i],
-                                'oppsagtdato'          => 
$this->db_boei->f('oppsagtdato')
-                                );
-
-                       }
-
-                       for ($i=0; $i<count($leietaker_oppdatert); $i++)
-                       {
-                               $sql = " UPDATE fm_tenant SET "
-                               . " oppsagtdato = '" . 
$leietaker_oppdatert[$i]['oppsagtdato'] . "'"
-                               . " WHERE  id = '" . 
$leietaker_oppdatert[$i]['id'] . "'";
-
-                               $this->db->query($sql,__LINE__,__FILE__);
-                               $this->db_boei->query($sql,__LINE__,__FILE__);
-                       }
-
-                       $this->db->transaction_commit();
-                       $this->db_boei->transaction_commit();
-
-                       $msg = $i . ' oppsagtdato er oppdatert';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-
-               }
-
-
-               function slett_feil_telefon()
-               {
-                       $sql = "SELECT count(contact_phone) as ant_tlf from 
fm_tenant WHERE id > 99999 OR id = 0";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $this->db->next_record();
-
-                       $ant_tlf = $this->db->f('ant_tlf');
-
-                       $sql = "UPDATE fm_tenant SET contact_phone = NULL WHERE 
id > 99999 OR id = 0";
-
-                       $this->db->query($sql,__LINE__,__FILE__);
-
-                       $msg = $ant_tlf . ' Telefon nr er slettet';
-                       $this->receipt['message'][]=array('msg'=> $msg);
-                       return $msg;
-               }
-       }
-?>




reply via email to

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