fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [17267] rename


From: sigurdne
Subject: [Fmsystem-commits] [17267] rename
Date: Thu, 2 Nov 2017 14:14:32 -0400 (EDT)

Revision: 17267
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17267
Author:   sigurdne
Date:     2017-11-02 14:14:31 -0400 (Thu, 02 Nov 2017)
Log Message:
-----------
rename

Added Paths:
-----------
    thirdparty/PE_custom/NLSH/catch/
    thirdparty/PE_custom/NLSH/catch/inc/
    thirdparty/PE_custom/NLSH/catch/inc/custom/
    thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/
    
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email.php
    
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_18_1.php
    
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_3_1.php
    
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_18_1.php
    thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_3_1.php
    
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/update_location_at_record.php
    thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/
    
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/catch_ppc.php
    
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/reset_workorder_cached_budget.php
    thirdparty/PE_custom/NLSH/property/inc/custom/Nordlandssykehuset_HF/
    thirdparty/PE_custom/NLSH/property/inc/import/Nordlandssykehuset_HF/
    thirdparty/PE_custom/NLSH/rental/inc/custom/Nordlandssykehuset_HF/
    
thirdparty/PE_custom/NLSH/rental/inc/custom/Nordlandssykehuset_HF/NLSH_add_contract_from_composite.php

Removed Paths:
-------------
    thirdparty/PE_custom/NLSH/property/inc/cron/default/
    thirdparty/PE_custom/NLSH/property/inc/custom/default/
    thirdparty/PE_custom/NLSH/property/inc/import/default/
    thirdparty/PE_custom/NLSH/rental/inc/custom/default/

Copied: 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email.php
 (from rev 17264, trunk/catch/inc/custom/default/notify_by_email.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email.php
                                (rev 0)
+++ 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email.php
        2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,159 @@
+<?php
+       $validator = CreateObject('phpgwapi.EmailAddressValidator');
+
+       if(isset($config_data['notify_email']) && $config_data['notify_email'])
+       {
+               $to_array = array();
+               $_to_array = explode(',', $config_data['notify_email']);
+
+               if (isset($config_data['notify_rule']) && 
$config_data['notify_rule'])
+               {
+                       $notify_rule = explode(',', 
$config_data['notify_rule']);
+                       foreach($notify_rule as $_rule )
+                       {
+                               $__rule = explode('=&gt;', $_rule);
+                               $___rule = explode(';', trim($__rule[1]));
+                               if($__rule)
+                               {
+                                       $_condition = explode('=', $__rule[0]);
+                                       if($_condition)
+                                       {
+                                               $this->db->query("SELECT * FROM 
$target_table WHERE id = {$id} AND " . trim($_condition[0]) . "='" . 
trim($_condition[1]) . "'",__LINE__,__FILE__);
+                                               if($this->db->next_record())
+                                               {
+                                                       foreach($___rule as 
$____rule)
+                                                       {
+                                                               if(isset( 
$_to_array[($____rule-1)]))
+                                                               {
+                                                                       
$to_array[] =  $_to_array[($____rule-1)];
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               else
+               {
+                       $to_array = $_to_array;
+               }
+
+               $to_array = array_unique($to_array);
+
+               //_debug_array($to_array);
+
+               $socommon               = CreateObject('property.socommon');
+               $prefs = $socommon->create_preferences('property',$user_id);
+
+               if ($validator->check_email_address($prefs['email']))
+               {
+                       $account_name = 
$GLOBALS['phpgw']->accounts->id2name($user_id);
+                       // avoid problems with the delimiter in the send class
+                       if(strpos($account_name,','))
+                       {
+                               $_account_name = explode(',', $account_name);
+                               $account_name = ltrim($_account_name[1]) . ' ' 
. $_account_name[0];
+                       }
+                       $from_email = "{$account_name}<{$prefs['email']}>";
+
+                       $to_array[] = $from_email;
+               }
+
+               if (!is_object($GLOBALS['phpgw']->send))
+               {
+                       $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+               }
+
+               $_to = implode(';',$to_array);
+
+               $from_name = 'noreply';
+               $from_email = isset($from_email) && $from_email ? $from_email : 
"{$from_name}<address@hidden>";
+               $cc = '';
+               $bcc ='';
+               $subject = "{$schema_text}::{$id}";
+
+               // Include something in subject
+               if(isset($config_data['email_include_in_subject']) && 
$config_data['email_include_in_subject'])
+               {
+                       $params = explode('=&gt;', 
$config_data['email_include_in_subject']);
+                       $_metadata = $this->db->metadata($target_table);
+                       if ( isset( $_metadata[$params[1]] ) )
+                       {
+                               $this->db->query("SELECT {$params[1]} FROM 
$target_table WHERE id = {$id}",__LINE__,__FILE__);
+                               if($this->db->next_record())
+                               {
+                                       $subject .= "::{$params[0]} " . 
$this->db->f($params[1]);
+                               }
+                       }
+                       unset($_metadata);
+               }
+
+               unset($_link_to_item);
+
+               if(isset($config_data['email_message']) && 
$config_data['email_message'])
+               {
+                       $body = str_replace(array('[', ']'), array('<', '>'), 
$config_data['email_message']);
+               }
+               else
+               {
+                       $body ="<H2>Det er registrert ny post i 
{$schema_text}</H2>";
+               }
+
+               $jasper_id = isset($config_data['jasper_id']) && 
$config_data['jasper_id'] ? $config_data['jasper_id'] : 0;
+
+               $attachments = array();
+
+               if(!$jasper_id)
+               {
+                       
$this->receipt['error'][]=array('msg'=>lang('notify_by_email: missing 
"jasper_id" in config for catch %1 schema', $schema_text));
+               }
+               else
+               {
+                       $jasper_parameters = '';
+                       $_parameters = array();
+
+                       $_parameters[] =  "ID|{$id}";
+                       $jasper_parameters = '"' . implode(';', $_parameters) . 
'"';
+
+                       unset($_parameters);
+
+                       $output_type            = 'PDF';
+                       $values_jasper          = 
execMethod('property.bojasper.read_single', $jasper_id);
+                       $report_source          = 
"{$GLOBALS['phpgw_info']['server']['files_dir']}/property/jasper/{$jasper_id}/{$values_jasper['file_name']}";
+                       $jasper_wrapper         = 
CreateObject('phpgwapi.jasper_wrapper');
+
+                       try
+                       {
+                               $report = 
$jasper_wrapper->execute($jasper_parameters, $output_type, $report_source, 
true);
+                       }
+                       catch(Exception $e)
+                       {
+                               $error = $e->getMessage();
+                               echo "<H1>{$error}</H1>";
+                       }
+
+                       $jasper_fname = 
tempnam($GLOBALS['phpgw_info']['server']['temp_dir'], 'PDF_') . '.pdf';
+                       file_put_contents($jasper_fname, $report['content'], 
LOCK_EX);
+
+                       $attachments[] = array
+                       (
+                               'file' => $jasper_fname,
+                               'name' => $report['filename'],
+                               'type' => $report['mime']
+                       );
+
+                       if($attachments)
+                       {
+                               $body .= "</br>Se vedlegg";
+                       }
+               }
+
+               if ($_to && $GLOBALS['phpgw']->send->msg('email', $_to, 
$subject, stripslashes($body), '', $cc, $bcc, $from_email, $from_name, 'html', 
'', $attachments , true))
+               {
+                       $this->receipt['message'][]=array('msg'=> "email 
notification sent to: {$_to}");
+               }
+               if( isset($jasper_fname) && is_file($jasper_fname) )
+               {
+                       unlink($jasper_fname);
+               }
+       }

Copied: 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_18_1.php
 (from rev 17264, trunk/catch/inc/custom/default/notify_by_email_18_1.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_18_1.php
                           (rev 0)
+++ 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_18_1.php
   2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,169 @@
+<?php
+       $validator = CreateObject('phpgwapi.EmailAddressValidator');
+
+       if(isset($config_data['notify_email']) && $config_data['notify_email'])
+       {
+               $to_array        = array();
+               $_to_array       = explode(',', $config_data['notify_email']);
+
+               if(isset($config_data['notify_rule']) && 
$config_data['notify_rule'])
+               {
+                       $notify_rule = explode(',', 
$config_data['notify_rule']);
+                       foreach($notify_rule as $_rule)
+                       {
+                               $__rule  = explode('=&gt;', $_rule);
+                               $___rule = explode(';', trim($__rule[1]));
+                               if($__rule)
+                               {
+                                       $_condition = explode('=', $__rule[0]);
+                                       if($_condition)
+                                       {
+                                               $this->db->query("SELECT * FROM 
$target_table WHERE id = {$id} AND " . trim($_condition[0]) . "='" . 
trim($_condition[1]) . "'", __LINE__, __FILE__);
+                                               if($this->db->next_record())
+                                               {
+                                                       foreach($___rule as 
$____rule)
+                                                       {
+                                                               
if(isset($_to_array[($____rule - 1)]))
+                                                               {
+                                                                       
$to_array[] = $_to_array[($____rule - 1)];
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               else
+               {
+                       $to_array = $_to_array;
+               }
+
+               $to_array = array_unique($to_array);
+
+               //_debug_array($to_array);
+
+               $socommon        = CreateObject('property.socommon');
+               $prefs           = $socommon->create_preferences('property', 
$user_id);
+
+               if($validator->check_email_address($prefs['email']))
+               {
+                       $account_name = 
$GLOBALS['phpgw']->accounts->id2name($user_id);
+                       // avoid problems with the delimiter in the send class
+                       if(strpos($account_name, ','))
+                       {
+                               $_account_name   = explode(',', $account_name);
+                               $account_name    = ltrim($_account_name[1]) . ' 
' . $_account_name[0];
+                       }
+                       $from_email = "{$account_name}<{$prefs['email']}>";
+
+                       $to_array[] = $from_email;
+               }
+
+               if(!is_object($GLOBALS['phpgw']->send))
+               {
+                       $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+               }
+
+               $_to = implode(';', $to_array);
+
+               $from_name       = 'noreply';
+               $from_email      = isset($from_email) && $from_email ? 
$from_email : "{$from_name}<address@hidden>";
+               $cc                      = '';
+               $bcc             = '';
+               $subject         = "{$schema_text}::{$id}";
+
+               // Include something in subject
+               if(isset($config_data['email_include_in_subject']) && 
$config_data['email_include_in_subject'])
+               {
+                       $params          = explode('=&gt;', 
$config_data['email_include_in_subject']);
+                       $_metadata       = $this->db->metadata($target_table);
+                       if(isset($_metadata[$params[1]]))
+                       {
+                               $this->db->query("SELECT {$params[1]} FROM 
$target_table WHERE id = {$id}", __LINE__, __FILE__);
+                               if($this->db->next_record())
+                               {
+                                       $subject .= "::{$params[0]} " . 
$this->db->f($params[1]);
+                               }
+                       }
+                       unset($_metadata);
+               }
+
+               unset($_link_to_item);
+
+               if(isset($config_data['email_message']) && 
$config_data['email_message'])
+               {
+                       $body = str_replace(array('[', ']'), array('<', '>'), 
$config_data['email_message']);
+               }
+               else
+               {
+                       $body = "<H2>Det er registrert ny post i 
{$schema_text}</H2>";
+               }
+
+               $attachments = array();
+
+               require_once PHPGW_SERVER_ROOT . 
"/catch/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/pdf_18_1.php";
+
+               $pdf = new pdf_18_1();
+
+               try
+               {
+                       $report = $pdf->get_document($id);
+               }
+               catch(Exception $e)
+               {
+                       $error = $e->getMessage();
+                       echo "<H1>{$error}</H1>";
+               }
+
+
+               $report_fname = 
tempnam($GLOBALS['phpgw_info']['server']['temp_dir'], 'PDF_') . '.pdf';
+               file_put_contents($report_fname, $report, LOCK_EX);
+
+               $attachments[] = array
+               (
+                       'file' => $report_fname,
+                       'name' => "NLSH_melding_om_utflytting_{$id}.pdf",
+                       'type' => 'application/pdf'
+               );
+
+               if($attachments)
+               {
+                       $body .= "</br>Rapport vedlagt";
+               }
+
+               $this->db->query("SELECT kontraktsnummer, leie_opphore_fra_dato 
FROM $target_table WHERE id = {$id}", __LINE__, __FILE__);
+               $this->db->next_record();
+               $_kontraktsnummer        = $this->db->f('kontraktsnummer');
+               $_utflyttingsdato        = 
$this->db->f('leie_opphore_fra_dato');
+               if($_utflyttingsdato)
+               {
+                       $this->db->query("SELECT id, num, utflyttingsdato FROM 
fm_catch_3_1 WHERE kontraktsnummer ilike '{$_kontraktsnummer}'", __LINE__, 
__FILE__);
+                       if($this->db->next_record())
+                       {
+                               $_num_3_1                                = 
$this->db->f('num');
+                               $_id_3_1                                 = 
$this->db->f('id');
+                               $_old_utflyttingsdato    = 
$this->db->f('utflyttingsdato');
+
+                               $this->db->query("UPDATE fm_catch_3_1 SET 
utflyttingsdato = '{$_utflyttingsdato}' WHERE id = '{$_id_3_1}'", __LINE__, 
__FILE__);
+
+                               $body .= "</br></br>Utflyttingsdato oppdatert 
fra {$_old_utflyttingsdato} til {$_utflyttingsdato} for inneflyttemelding 
{$_num_3_1}";
+                       }
+                       else
+                       {
+                               $body .= "</br></br>Fant ikke innflyttemelding 
for kontraktsnummer {$_kontraktsnummer}";
+                       }
+               }
+               else
+               {
+                       $body .= "</br>Utflyttingsdato ikke angitt";
+               }
+
+               if($_to && $GLOBALS['phpgw']->send->msg('email', $_to, 
$subject, stripslashes($body), '', $cc, $bcc, $from_email, $from_name, 'html', 
'', $attachments, true))
+               {
+                       $this->receipt['message'][] = array('msg' => "email 
notification sent to: {$_to}");
+               }
+               if(isset($report_fname) && is_file($report_fname))
+               {
+                       unlink($report_fname);
+               }
+       }

Copied: 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_3_1.php
 (from rev 17264, trunk/catch/inc/custom/default/notify_by_email_3_1.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_3_1.php
                            (rev 0)
+++ 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/notify_by_email_3_1.php
    2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,158 @@
+<?php
+       $validator = CreateObject('phpgwapi.EmailAddressValidator');
+
+       if(isset($config_data['notify_email']) && $config_data['notify_email'])
+       {
+               $to_array        = array();
+               $_to_array       = explode(',', $config_data['notify_email']);
+
+               if(isset($config_data['notify_rule']) && 
$config_data['notify_rule'])
+               {
+                       $notify_rule = explode(',', 
$config_data['notify_rule']);
+                       foreach($notify_rule as $_rule)
+                       {
+                               $__rule  = explode('=&gt;', $_rule);
+                               $___rule = explode(';', trim($__rule[1]));
+                               if($__rule)
+                               {
+                                       $_condition = explode('=', $__rule[0]);
+                                       if($_condition)
+                                       {
+                                               $this->db->query("SELECT * FROM 
$target_table WHERE id = {$id} AND " . trim($_condition[0]) . "='" . 
trim($_condition[1]) . "'", __LINE__, __FILE__);
+                                               if($this->db->next_record())
+                                               {
+                                                       foreach($___rule as 
$____rule)
+                                                       {
+                                                               
if(isset($_to_array[($____rule - 1)]))
+                                                               {
+                                                                       
$to_array[] = $_to_array[($____rule - 1)];
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               else
+               {
+                       $to_array = $_to_array;
+               }
+
+               $to_array = array_unique($to_array);
+
+               //_debug_array($to_array);
+
+               $socommon        = CreateObject('property.socommon');
+               $prefs           = $socommon->create_preferences('property', 
$user_id);
+
+               if($validator->check_email_address($prefs['email']))
+               {
+                       $account_name = 
$GLOBALS['phpgw']->accounts->id2name($user_id);
+                       // avoid problems with the delimiter in the send class
+                       if(strpos($account_name, ','))
+                       {
+                               $_account_name   = explode(',', $account_name);
+                               $account_name    = ltrim($_account_name[1]) . ' 
' . $_account_name[0];
+                       }
+                       $from_email = "{$account_name}<{$prefs['email']}>";
+
+                       $to_array[] = $from_email;
+               }
+
+               if(!is_object($GLOBALS['phpgw']->send))
+               {
+                       $GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
+               }
+
+               $_to = implode(';', $to_array);
+
+               $from_name       = 'noreply';
+               $from_email      = isset($from_email) && $from_email ? 
$from_email : "{$from_name}<address@hidden>";
+               $cc                      = '';
+               $bcc             = '';
+               $subject         = "{$schema_text}::{$id}";
+
+               // Include something in subject
+               if(isset($config_data['email_include_in_subject']) && 
$config_data['email_include_in_subject'])
+               {
+                       $params          = explode('=&gt;', 
$config_data['email_include_in_subject']);
+                       $_metadata       = $this->db->metadata($target_table);
+                       if(isset($_metadata[$params[1]]))
+                       {
+                               $this->db->query("SELECT {$params[1]} FROM 
$target_table WHERE id = {$id}", __LINE__, __FILE__);
+                               if($this->db->next_record())
+                               {
+                                       $subject .= "::{$params[0]} " . 
$this->db->f($params[1]);
+                               }
+                       }
+                       unset($_metadata);
+               }
+
+               unset($_link_to_item);
+
+               if(isset($config_data['email_message']) && 
$config_data['email_message'])
+               {
+                       $body = str_replace(array('[', ']'), array('<', '>'), 
$config_data['email_message']);
+               }
+               else
+               {
+                       $body = "<H2>Det er registrert ny post i 
{$schema_text}</H2>";
+               }
+
+               $_duplicate_num = '';
+
+               $this->db->query("SELECT kontraktsnummer FROM $target_table 
WHERE id = {$id}", __LINE__, __FILE__);
+               if($this->db->next_record())
+               {
+                       $_kontraktsnummer        = 
$this->db->f('kontraktsnummer');
+                       $this->db->query("SELECT num FROM $target_table WHERE 
id != {$id} AND kontraktsnummer = '{$_kontraktsnummer}'", __LINE__, __FILE__);
+                       $this->db->next_record();
+                       $_duplicate_num          = $this->db->f('num');
+               }
+
+               $attachments = array();
+
+               require_once PHPGW_SERVER_ROOT . 
"/catch/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/pdf_3_1.php";
+
+               $pdf = new pdf_3_1();
+
+               try
+               {
+                       $report = $pdf->get_document($id, $_duplicate_num);
+               }
+               catch(Exception $e)
+               {
+                       $error = $e->getMessage();
+                       echo "<H1>{$error}</H1>";
+               }
+
+               if($_duplicate_num)
+               {
+                       $this->db->query("DELETE  FROM $target_table WHERE id = 
{$id}", __LINE__, __FILE__);
+               }
+
+               $report_fname = 
tempnam($GLOBALS['phpgw_info']['server']['temp_dir'], 'PDF_') . '.pdf';
+               file_put_contents($report_fname, $report, LOCK_EX);
+
+               $attachments[] = array
+               (
+                       'file' => $report_fname,
+                       'name' => "NLSH_melding_om_innflytting_{$id}.pdf",
+                       'type' => 'application/pdf'
+               );
+
+               if($attachments)
+               {
+                       $body .= "</br>Se vedlegg";
+               }
+
+
+               if($_to && $GLOBALS['phpgw']->send->msg('email', $_to, 
$subject, stripslashes($body), '', $cc, $bcc, $from_email, $from_name, 'html', 
'', $attachments, true))
+               {
+                       $this->receipt['message'][] = array('msg' => "email 
notification sent to: {$_to}");
+               }
+               if(isset($report_fname) && is_file($report_fname))
+               {
+                       unlink($report_fname);
+               }
+       }
\ No newline at end of file

Copied: 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_18_1.php 
(from rev 17264, trunk/catch/inc/custom/default/pdf_18_1.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_18_1.php   
                            (rev 0)
+++ 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_18_1.php   
    2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,231 @@
+<?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
+       * @version $Id$
+       */
+
+       /**
+        * Custom class for catch_3_1
+        *
+        */
+
+       class pdf_18_1
+       {
+               
+               var $preview = false;
+
+
+               public function __construct()
+               {
+
+
+               }
+               
+
+               /**
+                * Produce the document for a specified record
+                * @param type $id
+                * @return string document
+                */
+               public function get_document($id = 0)
+               {
+                       if(!$id)
+                       {
+                               return false;
+                       }
+
+                       $sql = "SELECT * FROM fm_catch_18_1 WHERE id ='{$id}'";
+                       $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+                       $GLOBALS['phpgw']->db->next_record();
+                       $values = $GLOBALS['phpgw']->db->Record;
+
+//_debug_array($values);
+//die();
+
+                       $config                         = 
CreateObject('phpgwapi.config','property');
+
+                       $config->read();
+
+                       $pdf = CreateObject('phpgwapi.pdf');
+                       $pdf -> ezSetMargins(50,70,50,50);
+                       $pdf->selectFont(PHPGW_API_INC . 
'/pdf/fonts/Helvetica.afm');
+
+                       // put a line top and bottom on all the pages
+                       $all = $pdf->openObject();
+                       $pdf->saveState();
+
+
+                       if(isset($config->config_data['order_logo']) && 
$config->config_data['order_logo'])
+                       {
+                               
$pdf->addJpegFromFile($config->config_data['order_logo'],
+                                       40,
+                                       800,
+                                       
isset($config->config_data['order_logo_width']) && 
$config->config_data['order_logo_width'] ? 
$config->config_data['order_logo_width'] : 80
+                               );
+                       }
+
+                       $pdf->setStrokeColor(0,0,0,1);
+                       $pdf->line(20,40,578,40);
+                       //      $pdf->line(20,820,578,820);
+                       //      $pdf->addText(50,823,6,lang('order'));
+                       $pdf->addText(50,28,6,$config->config_data['org_name']);
+                       $pdf->addText(300,28,6,$date);
+
+                       $pdf->restoreState();
+                       $pdf->closeObject();
+                       // note that object can be told to appear on just odd 
or even pages by changing 'all' to 'odd'
+                       // or 'even'.
+                       $pdf->addObject($all,'all');
+
+                       //                      $pdf->ezSetDy(-100);
+
+                       $pdf->ezStartPageNumbers(500,28,6,'right','{PAGENUM} ' 
. lang('of') . ' {TOTALPAGENUM}',1);
+
+                       $data = array
+                       (
+                               array
+                               (
+                                       
'col1'=>"{$config->config_data['org_name']}\n\nOrg.nr: 
{$config->config_data['org_unit_id']}",
+                                       'col2'=>'MELDING OM UTFLYTTING',
+                                       'col3'=> 'Melding Nr:' . "\n\n{$id}"
+                               )
+                       );              
+
+                       
$pdf->ezTable($data,array('col1'=>'','col2'=>'','col3'=>''),''
+                               ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+                               
,'xOrientation'=>'right','width'=>500,'gridlines'=> EZ_GRIDLINE_ALL
+                               ,'cols'=>array
+                               (
+                                       
'col1'=>array('justification'=>'right','width'=>200, 'justification'=>'left'),
+                                       
'col2'=>array('justification'=>'right','width'=>100, 'justification'=>'center'),
+                                       
'col3'=>array('justification'=>'right','width'=>200),
+                               )
+
+                       ));
+
+                       $pdf->ezText("Opphør av leieforhold, Kontrakt: 
{$values['kontraktsnummer']}",14);
+                       $pdf->ezSetDy(-20);
+
+                       $address = 'Tildelt Leilighet:';
+                       $address_element = 
execMethod('property.botts.get_address_element', $values['location_code']);
+                       foreach($address_element as $entry)
+                       {
+                               $address .= "\n   {$entry['text']}: 
{$entry['value']}";
+                       }
+
+                       $data = array
+                       (
+                               array
+                               (
+                                       'col1'=>"Leietaker:\n   
{$values['navn_leietaker']}\n"
+                                       . "   
Fødselsdato:{$values['foedselsdato']}\n"
+                                       . "   Tlf:{$values['telefonnummer']}\n"
+                                       . "   Avd:{$values['avdeling']}\n   
Innbetaling av leie: {$values['innbetaling_av_leie']}\n"
+                                       . "   Fakturaadresse: 
{$values['faktura_sendes_til']}",
+                                       'col2' => $address
+                               ),
+                       );
+
+                       $pdf->ezTable($data,array('col1'=>'','col2'=>''),''
+                               ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+                               
,'xOrientation'=>'right','width'=>500,'showLines'=> 0
+                               ,'cols'=>array
+                               (
+                                       'col1' =>array('justification' => 
'right', 'width' => 250, 'justification' => 'left'),
+                                       'col2' => array('justification' => 
'right', 'width' => 250, 'justification' => 'left'),
+                               )
+
+                       ));
+
+
+                       $text = <<<TXT
+1. Boligen er inspisert av oppsynsmann ved NLSH dato: 
{$values['boligen_inspisert_dato']}
+
+2. Nøkler til boligen er : "{$values['nokler_til_boligen_er']}"          
Antall nøkler: {$values['antall_nokler']}
+
+3. Leien kan opphøre fra dato: {$values['leie_opphore_fra_dato']}
+
+4. Leietaker sier opp strøm ved utflytting.
+
+5. Målerstand ved utflytting:  {$values['maalerstand_kwh']}        Målernr: 
{$values['maalernummer']}
+
+6. Leiligheten har mangler/feil iht innflyttingsprotokoll:
+  {$values['feil_mangler_innflytting']}
+
+7. Nye feil og mangler i perioden:
+  {$values['mangler_skader_leieperiode']}
+
+8. Er leietaker erstatningspliktig: {$values['leietaker_erstatningspliktig']}
+
+9. Erstatningspliktig beløp kr: {$values['erstatningspliktig_beloep']}
+10. Er det innbetalt forskudd: {$values['innbetalt_forskudd']}
+
+11. Innbetalt forskudd (kr) {$values['forskudd_beloep']}
+
+12. Forskudd tilbakebetales ? {$values['forskudd_tilbakebetales']}
+
+13. Merknader:
+{$values['merknader']}
+
+
+Dato:
+TXT;
+       
+
+                       $pdf->ezSetDy(-20);
+                       $pdf->ezText($text,10);
+                       $pdf->ezSetDy(-40);
+
+
+                       $data = array
+                               (
+                                       array('col1'=>"Sign 
leietaker:\n\n\n{$values['navn_leietaker']}",'col2' => 
"Boligforvalter:\n\n\n{$values['boligforvalter']}"),
+                               );              
+
+                       $pdf->ezTable($data,array('col1'=>'','col2'=>''),''
+                               ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+                               
,'xOrientation'=>'right','width'=>500,'gridlines'=> 0
+                               ,'cols'=>array
+                               (
+                                       'col1' =>array('justification' => 
'right', 'width' => 250, 'justification' => 'left'),
+                                       'col2' => array('justification' => 
'right', 'width' => 250, 'justification' => 'left'),
+                               )
+
+                       ));
+
+                       $document= $pdf->ezOutput();
+
+                       if($this->preview)
+                       {
+                               
$pdf->print_pdf($document,"NLSH_melding_om_utflytting_{$id}");
+                       }
+                       else
+                       {
+                               return $document;
+                       }
+
+               }
+
+       }

Copied: 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_3_1.php 
(from rev 17264, trunk/catch/inc/custom/default/pdf_3_1.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_3_1.php    
                            (rev 0)
+++ 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/pdf_3_1.php    
    2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,238 @@
+<?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
+       * @version $Id$
+       */
+
+       /**
+        * Custom class for catch_3_1
+        *
+        */
+
+       class pdf_3_1
+       {
+               
+               var $preview = false;
+
+
+               public function __construct()
+               {
+
+
+               }
+               
+
+               /**
+                * Produce the document for a specified record
+                * @param type $id
+                * @return string document
+                */
+               public function get_document($id = 0, $_duplicate='')
+               {
+                       if(!$id)
+                       {
+                               return false;
+                       }
+
+                       $sql = "SELECT * FROM fm_catch_3_1 WHERE id ='{$id}'";
+                       $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+                       $GLOBALS['phpgw']->db->next_record();
+                       $values = $GLOBALS['phpgw']->db->Record;
+
+//_debug_array($values);
+//die();
+
+                       $config                         = 
CreateObject('phpgwapi.config','property');
+
+                       $config->read();
+
+                       $pdf = CreateObject('phpgwapi.pdf');
+                       $pdf -> ezSetMargins(50,70,50,50);
+                       $pdf->selectFont(PHPGW_API_INC . 
'/pdf/fonts/Helvetica.afm');
+
+                       // put a line top and bottom on all the pages
+                       $all = $pdf->openObject();
+                       $pdf->saveState();
+
+
+                       if(isset($config->config_data['order_logo']) && 
$config->config_data['order_logo'])
+                       {
+                               
$pdf->addJpegFromFile($config->config_data['order_logo'],
+                                       40,
+                                       800,
+                                       
isset($config->config_data['order_logo_width']) && 
$config->config_data['order_logo_width'] ? 
$config->config_data['order_logo_width'] : 80
+                               );
+                       }
+
+                       $pdf->setStrokeColor(0,0,0,1);
+                       $pdf->line(20,40,578,40);
+                       //      $pdf->line(20,820,578,820);
+                       //      $pdf->addText(50,823,6,lang('order'));
+                       $pdf->addText(50,28,6,$config->config_data['org_name']);
+                       $pdf->addText(300,28,6,$date);
+
+                       if($_duplicate)
+                       {
+                               $pdf->setColor(1,0,0);
+                               $pdf->addText(50,400,30,"Dette er en duplikat 
av {$_duplicate}",-10);
+                               $pdf->addText(50,350,30," - og er 
slettet!",-10);
+                       }
+
+                       $pdf->restoreState();
+                       $pdf->closeObject();
+                       // note that object can be told to appear on just odd 
or even pages by changing 'all' to 'odd'
+                       // or 'even'.
+                       $pdf->addObject($all,'all');
+
+                       //                      $pdf->ezSetDy(-100);
+
+                       $pdf->ezStartPageNumbers(500,28,6,'right','{PAGENUM} ' 
. lang('of') . ' {TOTALPAGENUM}',1);
+
+                       $data = array
+                       (
+                               array
+                               (
+                                       
'col1'=>"{$config->config_data['org_name']}\n\nOrg.nr: 
{$config->config_data['org_unit_id']}",
+                                       'col2'=>'MELDING OM INNFLYTTING',
+                                       'col3'=> 'Melding Nr:' . "\n\n{$id}"
+                               )
+                       );              
+
+                       
$pdf->ezTable($data,array('col1'=>'','col2'=>'','col3'=>''),''
+                               ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+                               
,'xOrientation'=>'right','width'=>500,'gridlines'=> EZ_GRIDLINE_ALL
+                               ,'cols'=>array
+                               (
+                                       
'col1'=>array('justification'=>'right','width'=>200, 'justification'=>'left'),
+                                       
'col2'=>array('justification'=>'right','width'=>100, 'justification'=>'center'),
+                                       
'col3'=>array('justification'=>'right','width'=>200),
+                               )
+
+                       ));
+
+                       $address = 'Tildelt Leilighet:';
+                       $address_element = 
execMethod('property.botts.get_address_element', $values['location_code']);
+                       foreach($address_element as $entry)
+                       {
+                               $address .= "\n   {$entry['text']}: 
{$entry['value']}";
+                       }
+
+                       $text = "Kontrakt: {$values['kontraktsnummer']}";
+                       $text .= "\n\nLeietaker:";
+                       $text .= "{$values['navn_leietaker']}";
+                       $text .= "\n\n{$address}";
+                       $text .= "\n\nFødselsdato:";
+                       $text .= " {$values['foedselsdato']}";
+                       $text .= "\n\nAvd:";
+                       $text .= " {$values['avdeling']}";
+                       $text .= "\n\nTlf:";
+                       $text .= " {$values['telefonnummer']}";
+                       $text .= "\n\nInnbetaling av leie:";
+                       $text .= " {$values['innbetaling_av_leie']}";
+                       $text .= "\n\nFaktura sendes til:";
+                       $text .= " {$values['faktura_sendes_til']}";
+                       $text .= "\n\nFakturaadresse:";
+                       $text .= " {$values['fakturaadresse']}";
+                       $text .= "\n\nKostnadssted:";
+                       $text .= " {$values['kostnadssted']}";
+                       $text .= "\n\nFirmaadresse:";
+                       $text .= " {$values['firmaadresse']}\n\n";
+
+                       $text .= <<<TXT
+1. Innflyttingsdato: {$values['innflyttingsdato']}
+Boligtype: {$values['boligtype']}
+
+2. Utflyttingsdato: {$values['utflyttingsdato']}
+
+3. Utlevert antall nøkler: {$values['utlevert_ant_nokler']}
+Boligareal (m2): {$values['boligareal']}
+
+4. Langtidsleie:
+Husleien er ved kontraktsinngåelsen fastsatt til kr 
{$values['husleie_pr_mnd']} pr mnd og kan endres iht konsumprisindeksen 
tidligst et år etter at sist leiefastsetting ble satt i verk.
+
+Det innbetales forskuddsvis leie (kr): {$values['innbetaling_forskudd']}
+
+5. Kortidsleie:
+Antall leiedøgn: {$values['antall_leiedoegn']}
+Klargjøring boenheter (kr): {$values['klargjoering_av_boenhet']}
+Leie pr døgn (kr): {$values['leie_pr_doegn']}
+Sengetøy/håndduker kr/døgn: {$values['sengetoey_handduker']}
+Samlet leie ved korttidsleie er fastsatt til kr: 
{$values['samlet_korttidsleie']}
+
+6. Strømab registreres på: {$values['strommaaler_registreres_paa']}
+
+7. Innbo: {$values['innbo']}
+Målerstand: {$values['maalerstand_kwh']}
+Målernr: {$values['maalernummer']}
+Annet innbo: {$values['annet_innbo']}
+Vedlagt inventarliste: {$values['inventarliste_vedlagt_kontrakt']}
+
+8. Boligstandard ved innflytting: {$values['bolig_standard_ved_innflytting']}
+
+9. Tilstand spesielt: {$values['tilstand_spesielt']}
+
+Merknader:  {$values['merknader_tilstand']}
+
+10. Jeg er kjent med at skade på leiligheten, mangler, dårlig renhold o.l. ved 
utflytting blir belastet meg som leietaker
+
+Dato:
+TXT;
+       
+
+                       $pdf->ezSetDy(-20);
+                       $pdf->ezText($text,12);
+                       $pdf->ezSetDy(-40);
+
+
+                       $data = array
+                               (
+                                       array('col1'=>"Sign 
leietaker:\n\n\n{$values['navn_leietaker']}",'col2' => 
"Boligforvalter:\n\n\n{$values['boligforvalter']}"),
+                               );              
+
+                       $pdf->ezTable($data,array('col1'=>'','col2'=>''),''
+                               ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+                               
,'xOrientation'=>'right','width'=>500,'gridlines'=> 0
+                               ,'cols'=>array
+                               (
+                                       'col1' =>array('justification' => 
'right', 'width' => 250, 'justification' => 'left'),
+                                       'col2' => array('justification' => 
'right', 'width' => 250, 'justification' => 'left'),
+                               )
+
+                       ));
+
+                       $document= $pdf->ezOutput();
+
+                       if($this->preview)
+                       {
+                               
$pdf->print_pdf($document,"NLSH_melding_om_innflytting_{$id}");
+                       }
+                       else
+                       {
+                               return $document;
+                       }
+
+               }
+
+       }

Copied: 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/update_location_at_record.php
 (from rev 17264, trunk/catch/inc/custom/default/update_location_at_record.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/update_location_at_record.php
                              (rev 0)
+++ 
thirdparty/PE_custom/NLSH/catch/inc/custom/Nordlandssykehuset_HF/update_location_at_record.php
      2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,124 @@
+<?php
+               if(!isset($this->db) || !is_object($this->db))
+               {
+                       $this->db               = & $GLOBALS['phpgw']->db;
+                       $this->like             = & $this->db->like;            
+               }
+
+               $this->db2              = clone($this->db);
+
+               if(!isset($target_table) || !$target_table)
+               {
+                       $target_table = 
"fm_{$this->type_app[$this->type]}_{$entity_id}_{$cat_id}";
+               }
+
+               $sql = "SELECT id FROM {$target_table} WHERE (location_code is 
NULL OR location_code = '')";
+               $metadata = $this->db->metadata($target_table);
+
+               if(isset($metadata['target_id']))
+               {
+                       $sql .= 'OR (target_id IS NOT NULL AND location_id IS 
NOT NULL AND p_num IS NULL)';
+               }
+
+               $ids = array();
+               $this->db->query($sql,__LINE__,__FILE__);
+               while ($this->db->next_record())
+               {
+                       $ids[] = $this->db->f('id');
+               }
+
+               foreach ($ids as $_id)
+               {
+                       $value_set = array();
+                       $this->db->query("SELECT * FROM $target_table WHERE id 
= {$_id}",__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       $location_id = $this->db->f('location_id');
+                       $target_id = $this->db->f('target_id');
+
+                       if($location_id  && $target_id)
+                       {
+                               $origin = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+                               $origin_table =  
$GLOBALS['phpgw']->locations->get_attrib_table($origin['appname'], 
$origin['location']);
+                               $origin_arr = explode('_', $origin_table);
+                               $p_entity_id = $origin_arr[2];
+                               $p_cat_id = $origin_arr[3];
+                               if($origin_table)
+                               {
+                                       $this->db2->query("SELECT 
location_code, address, id AS target_id FROM {$origin_table} WHERE num = 
'{$target_id}'",__LINE__,__FILE__);
+                                       $this->db2->next_record();
+                                       $origin_location_code           = 
$this->db2->f('location_code');
+                                       $origin_address                         
= $this->db2->f('address');
+                                       $value_set['location_code'] = 
$origin_location_code;
+                                       $value_set['p_num']             = 
$this->db2->f('target_id');
+                                       $value_set['p_entity_id']       = 
$p_entity_id;
+                                       $value_set['p_cat_id']          = 
$p_cat_id;
+                                       $origin_location_code_arr       = 
explode('-',$origin_location_code);
+                                       if($origin_location_code_arr)
+                                       {
+                                               $j=1;
+                                               
foreach($origin_location_code_arr as $_loc)
+                                               {
+                                                       $value_set["loc{$j}"]   
= $_loc;
+                                                       $j++;
+                                               }
+                                       }
+                                       $value_set['address']   = 
$origin_address;
+                               }
+                       }
+                       else
+                       {
+                               $loc_fields = array
+                               (
+                                       'eiendomid',
+                                       'byggid',
+                                       'etasjeid',
+                                       'bruksenhetid',
+                                       'romid'
+                               );
+
+                               $location = array();
+                               $j = 1;
+                               foreach ($loc_fields as $loc)
+                               {
+                                       if($this->db->f($loc))
+                                       {
+
+// 8.April 11: 'romid' is now loc5
+/*
+                                               if($loc == 'romid')
+                                               {
+                                                       
$this->db2->query("SELECT loc5 FROM fm_location5 WHERE rom_nr_id = '" . 
$this->db->f($loc) . "' AND location_code {$this->like} '" . implode('-', 
$location) . "%'",__LINE__,__FILE__);
+       
+                                                       
$this->db2->next_record();
+                                                       
if($this->db2->f('loc5'))
+                                                       {
+                                                               $location[] = 
$this->db2->f('loc5');
+                                                               
$value_set["loc{$j}"] = $this->db2->f('loc5');
+                                                       }
+                                               }
+                                               else
+*/
+                                               {
+                                                       $location[] = 
$this->db->f($loc);
+                                                       $value_set["loc{$j}"] = 
$this->db->f($loc);
+                                               }
+                                       }
+                                       else
+                                       {
+                                               break;
+                                       }
+                                       $j++;
+                               }
+                               if($location)
+                               {
+                                       $value_set['location_code'] = 
implode('-', $location);
+                               }
+                       }
+
+                       if($value_set)
+                       {
+                               $value_set      = 
$this->db->validate_update($value_set);
+                               $this->db->query("UPDATE $target_table SET 
$value_set WHERE id={$_id}",__LINE__,__FILE__);
+                       }
+               }

Copied: 
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/catch_ppc.php 
(from rev 17264, trunk/property/inc/cron/default/catch_ppc.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/catch_ppc.php 
                            (rev 0)
+++ 
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/catch_ppc.php 
    2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,304 @@
+<?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 catch
+        * @version $Id$
+        */
+       /**
+        * Description
+        * example cron : /usr/local/bin/php -q 
/var/www/html/phpgroupware/property/inc/cron/cron.php default catch_ppc
+        * @package property
+        */
+       include_class('property', 'cron_parent', 'inc/cron/');
+
+       class catch_ppc extends property_cron_parent
+       {
+
+               public function __construct()
+               {
+                       parent::__construct();
+
+                       $this->function_name = get_class($this);
+                       $this->sub_location = lang('catch');
+                       $this->function_msg = 'Import info from files';
+
+                       set_time_limit(1000);
+               }
+
+               function execute()
+               {
+                       try
+                       {
+                               $this->import_ppc();
+                       }
+                       catch (Exception $e)
+                       {
+                               $this->receipt['error'][] = array('msg' => 
$e->getMessage());
+                       }
+               }
+
+               function import_ppc()
+               {
+
+                       //do the actual import
+                       $config = CreateObject('catch.soconfig');
+                       $config->read_repository();
+                       $entity = CreateObject('property.soentity');
+                       $entity->type = 'catch';
+                       $admin_entity = CreateObject('property.soadmin_entity');
+                       $admin_entity->type = 'catch';
+
+                       $bofiles = CreateObject('property.bofiles');
+
+                       foreach ($config->config_data as $config_data)
+                       {
+                               $this->pickup_path = 
$config_data['pickup_path'];
+                               $target = $config_data['target'];
+                               $target_table = "fm_catch_{$target}";
+                               list($entity_id, $cat_id) = preg_split('/[_]/', 
$target);
+                               $this->category_dir = 
"catch_{$entity_id}_{$cat_id}";
+                               $category = 
$admin_entity->read_single_category($entity_id, $cat_id);
+                               $schema_text = "{$target} {$category['name']}";
+
+                               $metadata = $this->db->metadata($target_table);
+                               if (!$metadata)
+                               {
+                                       throw new Exception(lang('no valid 
target'));
+                               }
+
+//                             $xmlparse = CreateObject('property.XmlToArray');
+//                             $xmlparse->setEncoding('UTF-8');
+
+                               $file_list = $this->get_files();
+
+                               $i = 0;
+                               foreach ($file_list as $file)
+                               {
+                                       $xml = new DOMDocument('1.0', 'utf-8');
+                                       $xml->load($file);
+
+                                       $var_result = array();
+
+                                       
//_debug_array($xml->getElementsByTagName('PPCC')->item(0)->getattribute('UUID'));die();
+
+                                       foreach ($metadata as $field => 
$field_info)
+                                       {
+                                               $var_result[$field] = 
$xml->getElementsByTagName($field)->item(0)->nodeValue;
+                                       }
+                                       $var_result['unitid'] = 
$xml->getElementsByTagName('UnitID')->item(0)->nodeValue;
+//                                     _debug_array($var_result);die();
+//                                     $var_result = 
$xmlparse->parseFile($file);
+//                                     $var_result = 
array_change_key_case($var_result, CASE_LOWER);
+                                       //data
+                                       $insert_values = array();
+                                       $cols = array();
+                                       $val_errors = array();
+
+                                       foreach ($metadata as $field => 
$field_info)
+                                       {
+                                               // If field is missing from 
file jump to next
+                                               if (!isset($var_result[$field]))
+                                               {
+                                                       continue;
+                                               }
+
+                                               $insert_value = 
trim($var_result[$field]);
+                                               switch ($field_info->type)
+                                               {
+                                                       case 'string':
+                                                       case 'varchar':
+                                                               $max_length = 
intval($field_info->max_length);
+                                                               $input_length = 
strlen($insert_value);
+
+                                                               if 
($input_length > $max_length)
+                                                               {
+                                                                       
$val_errors[] = lang('Input for field "%1" is %2 characters, max for field is 
%3 (%4)', $field_info->name, $input_length, $max_length, $file);
+                                                               }
+                                                               break;
+                                                       case 'int2':
+                                                       case 'int4':
+                                                               // Check if 
input starts with - (optional) and then only
+                                                               // contains 
numbers
+                                                               /*
+                                                                 if( 
preg_match('@^[-]?[0-9]+$@', $insert_value) !== 1 )
+                                                                 {
+                                                                 $val_errors[] 
= lang('Input for field "%1" is "%2", but should be int (%3)',
+                                                                 
$field_info->name, $insert_value, $file);
+                                                                 }
+                                                                */
+                                                               $insert_value = 
$insert_value ? (int)$insert_value : '';
+                                                               break;
+                                                       case 'numeric':
+                                                               $insert_value = 
str_replace(',', '.', $insert_value);
+                                                               $insert_value = 
floatval($insert_value);
+                                                               break;
+                                                       case 'timestamp':
+                                                               $insert_value = 
date($this->db->date_format(), strtotime($insert_value));
+                                                               break;
+                                               }
+                                               $insert_values[] = 
$insert_value;
+                                               $cols[] = $field;
+                                       }
+
+                                       // Raise exception if we have 
validation errors
+                                       if (count($val_errors) > 0)
+                                       {
+                                               throw new 
Exception(implode("<br>", $val_errors));
+                                       }
+
+                                       if ($cols) // something to import
+                                       {
+                                               $movefiles = array();
+
+                                               $this->db->transaction_begin();
+
+                                               $cols[] = 'entry_date';
+                                               $insert_values[] = time();
+                                               $id = 
$entity->generate_id(array('entity_id' => $entity_id, 'cat_id' => $cat_id));
+                                               $num = 
$entity->generate_num($entity_id, $cat_id, $id);
+                                               $this->db->query("SELECT * FROM 
fm_catch_1_1 WHERE unitid ='{$var_result['unitid']}'", __LINE__, __FILE__);
+                                               $this->db->next_record();
+                                               $user_id = 
$this->db->f('user_');
+                                               if (!$user_id)
+                                               {
+                                                       throw new 
Exception(lang('no valid user for this UnitID: %1', $var_result['unitid']));
+                                               }
+
+                                               
$bofiles->set_account_id($user_id);
+                                               
$GLOBALS['phpgw_info']['user']['account_id'] = $user_id; // needed for the 
vfs::mkdir()
+                                               
$GLOBALS['phpgw_info']['flags']['currentapp'] = 'property';
+
+                                               $insert_values = 
$this->db->validate_insert($insert_values);
+                                               $this->db->query("INSERT INTO 
$target_table (id, num, user_id, " . implode(',', $cols) . ')'
+                                                       . "VALUES ($id, '$num', 
$user_id, $insert_values)", __LINE__, __FILE__);
+
+                                               //attachment
+                                               foreach ($var_result as $field 
=> $data)
+                                               {
+                                                       if 
(is_file("{$this->pickup_path}/{$data}"))
+                                                       {
+                                                               $to_file = 
"{$bofiles->fakebase}/{$this->category_dir}/dummy/{$id}/{$field}_{$data}"; // 
the dummy is for being consistant with the entity-code that relies on loc1
+                                                               
$bofiles->create_document_dir("{$this->category_dir}/dummy/{$id}");
+
+                                                               
$bofiles->vfs->override_acl = 1;
+
+                                                               if 
(!$bofiles->vfs->cp(array(
+                                                                               
'from' => "{$this->pickup_path}/{$data}",
+                                                                               
'to' => $to_file,
+                                                                               
'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL))))
+                                                               {
+                                                                       
$this->receipt['error'][] = array('msg' => lang('Failed to upload file %1 on id 
%2', $data, $num));
+                                                               }
+                                                               
$bofiles->vfs->override_acl = 0;
+                                                               // move 
attachment
+                                                               
$movefiles["{$this->pickup_path}/{$data}"] = 
"{$this->pickup_path}/imported/{$data}";
+                                                       }
+                                               }
+                                               // move file
+                                               $_file = basename($file);
+                                               
$movefiles["{$this->pickup_path}/{$_file}"] = 
"{$this->pickup_path}/imported/{$_file}";
+
+                                               $i++;
+
+
+                                               $ok = false;
+                                               if 
($this->db->transaction_commit())
+                                               {
+                                                       foreach ($movefiles as 
$movefrom => $moveto)
+                                                       {
+                                                               $ok = 
@rename($movefrom, $moveto);
+                                                       }
+                                               }
+
+                                               if (!$ok)
+                                               {
+                                                       
$this->db->query("DELETE FROM $target_table WHERE id =" . (int)$id, __LINE__, 
__FILE__);
+                                                       $i--;
+                                                       
$this->receipt['error'][] = array('msg' => lang('There was a problem moving the 
file(s), imported records are reverted'));
+                                               }
+                                               else
+                                               {
+
+                                                       // finishing
+                                                       $criteria = array
+                                                               (
+                                                               'appname' => 
'catch',
+                                                               'location' => 
'.catch.' . str_replace('_', '.', $target),
+                                                               'allrows' => 
true
+                                                       );
+
+                                                       $custom_functions = 
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+                                                       foreach 
($custom_functions as $entry)
+                                                       {
+                                                               // prevent path 
traversal
+                                                               if 
(preg_match('/\.\./', $entry['file_name']))
+                                                               {
+                                                                       
continue;
+                                                               }
+
+                                                               $file = 
PHPGW_SERVER_ROOT . 
"/catch/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+                                                               if 
($entry['active'] && is_file($file))
+                                                               {
+                                                                       require 
$file;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               $this->receipt['message'][] = array('msg' => 
lang('%1 records imported to %2', $i, $schema_text));
+                       }
+               }
+
+               public function get_files()
+               {
+                       $dirname = $this->pickup_path;
+                       // prevent path traversal
+                       if (preg_match('/\./', $dirname) || !is_dir($dirname))
+                       {
+                               return array();
+                       }
+
+                       $file_list = array();
+                       $dir = new DirectoryIterator($dirname);
+                       if (is_object($dir))
+                       {
+                               foreach ($dir as $file)
+                               {
+                                       if ($file->isDot() || !$file->isFile() 
|| !$file->isReadable()
+                                               //|| 
mime_content_type($file->getPathname()) != 'text/xml')
+                                               //|| finfo_file( 
finfo_open(FILEINFO_MIME, '/usr/share/file/magic'), $file->getPathname() ) != 
'text/xml')
+                                               || strcasecmp(end(explode(".", 
$file->getPathname())), 'xml') != 0)
+                                       {
+                                               continue;
+                                       }
+
+                                       $file_list[] = 
(string)"{$dirname}/{$file}";
+                               }
+                       }
+
+                       return $file_list;
+               }
+       }
\ No newline at end of file

Copied: 
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/reset_workorder_cached_budget.php
 (from rev 17264, 
trunk/property/inc/cron/default/reset_workorder_cached_budget.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/reset_workorder_cached_budget.php
                         (rev 0)
+++ 
thirdparty/PE_custom/NLSH/property/inc/cron/Nordlandssykehuset_HF/reset_workorder_cached_budget.php
 2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,75 @@
+<?php
+       /**
+        * phpGroupWare - property: a Facilities Management System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2013,2014 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 import
+        * @version $Id$
+        */
+       /**
+        * @package property
+        */
+       include_class('property', 'cron_parent', 'inc/cron/');
+
+       class reset_workorder_cached_budget extends property_cron_parent
+       {
+
+               function __construct()
+               {
+                       parent::__construct();
+
+                       $this->function_name = get_class($this);
+                       $this->sub_location = lang('workorder');
+                       $this->function_msg = 'reset workorder cached budget';
+               }
+
+               public function execute()
+               {
+                       $orders = array();
+                       $sql = "SELECT DISTINCT fm_workorder.id as order_id"
+                               . " FROM fm_workorder "
+                               . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id"
+                               . " WHERE continuous = 1"// AND 
fm_workorder_budget.year > " . (date('Y') -1)
+                               . " ORDER BY fm_workorder.id";
+
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       $_order_budget = array();
+                       while ($this->db->next_record())
+                       {
+                               $orders[] = $this->db->f('order_id');
+                       }
+
+                       foreach ($orders as $order_id)
+                       {
+                               phpgwapi_cache::system_clear('property', 
"budget_order_{$order_id}");
+                               execMethod('property.soworkorder.get_budget', 
$order_id);
+                       }
+
+                       $sql = "UPDATE fm_project_budget SET closed = 1 WHERE 
year =" . date('Y') . ' AND ( month > 0 AND month <= ' . date('n') . ')';
+                       $this->db->query($sql, __LINE__, __FILE__);
+
+                       $count_orders = count($orders);
+
+                       $this->receipt['message'][] = array('msg' => 
"Rekalkulert budsjett for {$count_orders} løpende bestillinger");
+               }
+       }
\ No newline at end of file

Copied: 
thirdparty/PE_custom/NLSH/rental/inc/custom/Nordlandssykehuset_HF/NLSH_add_contract_from_composite.php
 (from rev 17264, 
trunk/rental/inc/custom/default/NLSH_add_contract_from_composite.php)
===================================================================
--- 
thirdparty/PE_custom/NLSH/rental/inc/custom/Nordlandssykehuset_HF/NLSH_add_contract_from_composite.php
                              (rev 0)
+++ 
thirdparty/PE_custom/NLSH/rental/inc/custom/Nordlandssykehuset_HF/NLSH_add_contract_from_composite.php
      2017-11-02 18:14:31 UTC (rev 17267)
@@ -0,0 +1,62 @@
+<?php
+       /*
+        * This file will only work for the implementation of NLSH
+        */
+
+       /**
+        * Intended for custom configuration on contracts.
+        *
+        * @author Sigurd Nes <address@hidden>
+        */
+       class rental_NLSH_add_contract_from_composite
+       {
+
+               function __construct()
+               {
+
+               }
+
+               /**
+                * Do your magic
+                * @param array $data
+                */
+               function validate( &$data )
+               {
+                       $contract = $data['contract'];
+                       $location_arr = explode('-', $data['location_code']);
+                       $loc1 = $location_arr[0];
+                       $loc2 = $location_arr[1];
+
+                       if ($loc1 > 8006 && $loc1 < 8100)
+                       {
+                               $responsibility_id = 8018;
+                       }
+                       else if($loc1 == 8534)
+                       {
+                               $responsibility_id = 4036;
+                       }
+                       else if ($loc1 > 8499 && $loc1 < 8600)
+                       {
+                               if ($loc2 == 18)
+                               {
+                                       $responsibility_id = 4036;
+                               }
+                               else
+                               {
+                                       $responsibility_id = 4034;
+                               }
+                       }
+                       else if ($loc1 > 8599 && $loc1 < 8700)
+                       {
+                               $responsibility_id = 3015;
+                       }
+
+                       $contract->set_responsibility_id($responsibility_id);
+                       return;
+               }
+       }
+       $process = new rental_NLSH_add_contract_from_composite($data);
+       if ($_error = $process->validate($data))
+       {
+               return $receipt['error'][] = array('msg' => $_error);
+       }




reply via email to

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