[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11569] property: use parent class for cron-jobs
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11569] property: use parent class for cron-jobs |
Date: |
Thu, 26 Dec 2013 22:17:09 +0000 |
Revision: 11569
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11569
Author: sigurdne
Date: 2013-12-26 22:17:08 +0000 (Thu, 26 Dec 2013)
Log Message:
-----------
property: use parent class for cron-jobs
Modified Paths:
--------------
trunk/property/inc/cron/class.cron_parent.inc.php
trunk/property/inc/cron/default/Import_fra_agresso_X205.php
trunk/property/inc/cron/default/catch_ppc.php
trunk/property/inc/cron/default/forward_mail_as_sms.php
trunk/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
trunk/property/inc/cron/default/reset_workorder_cached_budget.php
trunk/property/inc/cron/default/synkroniser_med_boei.php
trunk/property/inc/cron/default/update_phpgw.php
Modified: trunk/property/inc/cron/class.cron_parent.inc.php
===================================================================
--- trunk/property/inc/cron/class.cron_parent.inc.php 2013-12-26 11:39:00 UTC
(rev 11568)
+++ trunk/property/inc/cron/class.cron_parent.inc.php 2013-12-26 22:17:08 UTC
(rev 11569)
@@ -3,7 +3,7 @@
* 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/
+ * @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
@@ -28,7 +28,7 @@
*/
/**
- * Filteret importerer rapporter fra Agresso som grunnlag for
oppdatering av øknomi og status på meldings_bestilling.
+ * Generic parent class for cron-jobs, with and without UI
* @package property
*/
@@ -40,10 +40,14 @@
protected $receipt = array();
protected $sub_location = 'sub_location';
protected $function_msg = 'function_msg';
+ protected $cron = false
function __construct()
{
- $this->db = & $GLOBALS['phpgw']->db;
+ $this->db = &
$GLOBALS['phpgw']->db;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+ $this->like = & $this->db->like;
}
function pre_run($data = array())
@@ -52,6 +56,7 @@
{
$confirm = true;
$cron = true;
+ $this->cron = true;
}
else
{
Modified: trunk/property/inc/cron/default/Import_fra_agresso_X205.php
===================================================================
--- trunk/property/inc/cron/default/Import_fra_agresso_X205.php 2013-12-26
11:39:00 UTC (rev 11568)
+++ trunk/property/inc/cron/default/Import_fra_agresso_X205.php 2013-12-26
22:17:08 UTC (rev 11569)
@@ -33,34 +33,35 @@
* @package property
*/
+ include_class('property', 'cron_parent', 'inc/cron/');
- class Import_fra_agresso_X205
+ class Import_fra_agresso_X205 extends property_cron_parent
{
- var $function_name = 'Import_fra_agresso_X205';
- var $auto_tax = true;
- var $mvakode=0;
- var $kildeid=1;
- var $splitt=0;
- var $soXport;
- var $invoice;
- var $default_kostra_id = 9999; //dummy
- var $debug = false;
- var $skip_import = false;
- var $skip_email = false;
+ protected $auto_tax = true;
+ protected $mvakode=0;
+ protected $kildeid=1;
+ protected $splitt=0;
+ protected $soXport;
+ protected $invoice;
+ protected $default_kostra_id = 9999; //dummy
+ protected $debug = false;
+ protected $skip_import = false;
+ protected $skip_email = false;
protected $export;
- protected $receipt = array();
-
function __construct()
{
+ parent::__construct();
+
+ $this->function_name = 'Import_fra_agresso_X205';
+ $this->sub_location = lang('invoice');
+ $this->function_msg = 'Importer faktura fra
Agresso';
+
$this->soXport =
CreateObject('property.soXport');
$this->invoice =
CreateObject('property.soinvoice');
$this->responsible =
CreateObject('property.soresponsible');
$this->bocommon =
CreateObject('property.bocommon');
- $this->db = &
$GLOBALS['phpgw']->db;
- $this->join = &
$this->db->join;
- $this->left_join = &
$this->db->left_join;
- $this->like = &
$this->db->like;
+
$this->dateformat =
$this->db->date_format();
$this->datetimeformat = $this->db->datetime_format();
$this->config =
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property',
'.invoice'));
@@ -82,80 +83,87 @@
}
- function pre_run($data = array())
+ public function execute()
{
- if(isset($data['enabled']) && $data['enabled']==1)
+
if(isset($this->config->config_data['import']['check_archive']) &&
$this->config->config_data['import']['check_archive'])
{
- $confirm = true;
- $cron = true;
+ $this->check_archive();
}
- else
+
+ $this->get_files();
+ $dirname =
$this->config->config_data['import']['local_path'];
+ // prevent path traversal
+ if ( preg_match('/\./', $dirname)
+ || !is_dir($dirname) )
{
- $confirm = phpgw::get_var('confirm',
'bool', 'POST');
- $execute = phpgw::get_var('execute',
'bool', 'GET');
+ return array();
}
- if( isset($data['debug']) && $data['debug'] )
+ $file_list = array();
+ $dir = new DirectoryIterator($dirname);
+ if ( is_object($dir) )
{
- $this->debug = true;
+ foreach ( $dir as $file )
+ {
+ if ( $file->isDot()
+ || !$file->isFile()
+ || !$file->isReadable()
+ || strcasecmp( end( explode(
".", $file->getPathname() ) ), 'xml' ) != 0 )
+ {
+ continue;
+ }
+
+ $file_list[] = (string)
"{$dirname}/{$file}";
+ }
}
- else
- {
- $this->debug = phpgw::get_var('debug',
'bool');
- }
- if ($confirm)
+ if(is_writable("{$dirname}/archive"))
{
- $this->execute($cron);
- }
- else
- {
- $this->confirm($execute=false);
- }
- }
+ foreach($file_list as $file)
+ {
+ $this->db->transaction_begin();
+ $bilagsnr = $this->import($file);
+ if($this->debug)
+ {
+ _debug_array("Behandler fil:
{$file}");
+ _debug_array("Bilagsnr:
{$bilagsnr}");
+ }
- function confirm($execute='')
- {
- $link_data = array
- (
- 'menuaction' =>
'property.custom_functions.index',
- 'function' => $this->function_name,
- 'execute' => $execute,
- 'debug' => $this->debug
- );
+ if ($bilagsnr)
+ {
+ // move file
+ $_file = basename($file);
+ $movefrom =
"{$dirname}/{$_file}";
+ $moveto =
"{$dirname}/archive/{$_file}";
+ if( is_file($moveto) )
+ {
+ @unlink($moveto);//in
case of duplicates
+ }
- if(!$execute)
+ $ok = @rename($movefrom,
$moveto);
+ if(!$ok) // Should never happen.
+ {
+
$this->db->transaction_abort();
+
$this->receipt['error'][] = array('msg' => "Kunne ikke flytte importfil til
arkiv, Bilag {$bilagsnr} er slettet");
+ }
+ else
+ {
+
$this->db->transaction_commit();
+ }
+ }
+ else
+ {
+ $this->db->transaction_abort();
+ }
+ }
+ }
+ else
{
- $lang_confirm_msg = lang('do you want to
perform this action');
+ $this->receipt['error'][] = array('msg' =>
"Arkiv katalog '{$dirname}/archive/' ikke er ikke skrivbar - kontakt
systemadminstrator for å korrigere");
}
- $lang_yes = lang('yes');
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',
array('menuaction'=>'property.uiasync.index')),
- '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' => 'Importer faktura
fra Agresso',
- 'lang_no_statustext' => 'tilbake',
- 'lang_no' =>
lang('no'),
- 'lang_done' =>
'Avbryt',
- 'lang_done_statustext' => 'tilbake'
- );
-
- $appname = lang('location');
- $function_msg = 'Importer faktura fra Agresso';
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
- $GLOBALS['phpgw']->xslttpl->pp();
+ $this->remind();
}
@@ -281,111 +289,7 @@
}
}
- public function execute($cron='')
- {
-
if(isset($this->config->config_data['import']['check_archive']) &&
$this->config->config_data['import']['check_archive'])
- {
- $this->check_archive();
- }
- $this->get_files();
- $dirname =
$this->config->config_data['import']['local_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()
- || strcasecmp( end( explode(
".", $file->getPathname() ) ), 'xml' ) != 0 )
- {
- continue;
- }
-
- $file_list[] = (string)
"{$dirname}/{$file}";
- }
- }
-
- if(is_writable("{$dirname}/archive"))
- {
- foreach($file_list as $file)
- {
- $this->db->transaction_begin();
- $bilagsnr = $this->import($file);
- if($this->debug)
- {
- _debug_array("Behandler fil:
{$file}");
- _debug_array("Bilagsnr:
{$bilagsnr}");
- }
-
- if ($bilagsnr)
- {
- // move file
- $_file = basename($file);
- $movefrom =
"{$dirname}/{$_file}";
- $moveto =
"{$dirname}/archive/{$_file}";
-
- if( is_file($moveto) )
- {
- @unlink($moveto);//in
case of duplicates
- }
-
- $ok = @rename($movefrom,
$moveto);
- if(!$ok) // Should never happen.
- {
-
$this->db->transaction_abort();
-
$this->receipt['error'][] = array('msg' => "Kunne ikke flytte importfil til
arkiv, Bilag {$bilagsnr} er slettet");
- }
- else
- {
-
$this->db->transaction_commit();
- }
- }
- else
- {
- $this->db->transaction_abort();
- }
- }
- }
- else
- {
- $this->receipt['error'][] = array('msg' =>
"Arkiv katalog '{$dirname}/archive/' ikke er ikke skrivbar - kontakt
systemadminstrator for å korrigere");
- }
-
- $this->remind();
-
- if(!$cron)
- {
- $this->confirm($execute=false);
- }
-
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
-
- $insert_values= array
- (
- $cron,
- date($this->db->datetime_format()),
- $this->function_name,
-
$this->db->db_addslashes(implode(',',(array_keys($msgbox_data))))
- );
-
- $insert_values =
$this->db->validate_insert($insert_values);
-
- $sql = "INSERT INTO fm_cron_log
(cron,cron_date,process,message) "
- . "VALUES ($insert_values)";
- $this->db->query($sql,__LINE__,__FILE__);
-
- }
-
protected function get_files()
{
$server =
$this->config->config_data['common']['host'];
Modified: trunk/property/inc/cron/default/catch_ppc.php
===================================================================
--- trunk/property/inc/cron/default/catch_ppc.php 2013-12-26 11:39:00 UTC
(rev 11568)
+++ trunk/property/inc/cron/default/catch_ppc.php 2013-12-26 22:17:08 UTC
(rev 11569)
@@ -33,91 +33,24 @@
* @package property
*/
- class catch_ppc
- {
- var $function_name = 'catch_ppc';
+ include_class('property', 'cron_parent', 'inc/cron/');
+ class catch_ppc extends property_cron_parent
+ {
public function __construct()
{
- $this->db = & $GLOBALS['phpgw']->db;
- $this->join = & $this->db->join;
- $this->like = & $this->db->like;
- set_time_limit(1000);
- }
+ parent::__construct();
- function pre_run($data = array())
- {
- phpgwapi_cache::session_set('catch', 'data', $data);
+ $this->function_name = 'catch_ppc';
+ $this->sub_location = lang('catch');
+ $this->function_msg = 'Import info from files';
- if(isset($data['enabled']) && $data['enabled']==1)
- {
- $confirm = true;
- $cron = true;
- }
- else
- {
- $confirm = phpgw::get_var('confirm',
'bool', 'POST');
- $execute = phpgw::get_var('execute',
'bool', 'GET');
- $cron = false;
- }
-
- if ($confirm)
- {
- $this->execute($cron);
- }
- else
- {
- $this->confirm($execute=false);
- }
+ set_time_limit(1000);
}
- function confirm($execute='')
+ function execute()
{
- $data = phpgwapi_cache::session_get('catch', 'data');
- $link_data = array
- (
- 'menuaction' =>
'property.custom_functions.index',
- 'data' => urlencode(serialize($data)),
- 'execute' => $execute,
- );
-
- if(!$execute)
- {
- $lang_confirm_msg = lang('do you want to
perform this action');
- }
-
- $lang_yes = lang('yes');
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
-
- $msgbox_data =
$GLOBALS['phpgw']->common->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('Export info as
files'),
- 'lang_no_statustext' => 'tilbake',
- 'lang_no' =>
lang('no'),
- 'lang_done' =>
'Avbryt',
- 'lang_done_statustext' => 'tilbake'
- );
-
- $appname = lang('location');
- $function_msg = lang('Export info as files');
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
- $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function execute($cron='')
- {
try
{
$this->import_ppc();
@@ -126,26 +59,6 @@
{
$this->receipt['error'][]=array('msg'=>$e->getMessage());
}
-
- if(!$cron)
- {
- $this->confirm($execute=false);
- }
-
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
-
- $insert_values= array(
- $cron,
- date($this->db->datetime_format()),
- $this->function_name,
- implode(',',(array_keys($msgbox_data)))
- );
-
- $insert_values =
$this->db->validate_insert($insert_values);
-
- $sql = "INSERT INTO fm_cron_log
(cron,cron_date,process,message) "
- . "VALUES ($insert_values)";
- $this->db->query($sql,__LINE__,__FILE__);
}
function import_ppc()
Modified: trunk/property/inc/cron/default/forward_mail_as_sms.php
===================================================================
--- trunk/property/inc/cron/default/forward_mail_as_sms.php 2013-12-26
11:39:00 UTC (rev 11568)
+++ trunk/property/inc/cron/default/forward_mail_as_sms.php 2013-12-26
22:17:08 UTC (rev 11569)
@@ -17,118 +17,26 @@
* @package property
*/
- class forward_mail_as_sms
- {
- var $function_name = 'forward_mail_as_sms';
+ include_class('property', 'cron_parent', 'inc/cron/');
- function forward_mail_as_sms()
+ class forward_mail_as_sms extends property_cron_parent
+ {
+ function __construct()
{
- $this->bocommon =
CreateObject('property.bocommon');
- $this->db = &
$GLOBALS['phpgw']->db;
- }
+ parent::__construct();
- function pre_run($data = array())
- {
- if(isset($data['enabled']) && $data['enabled']==1)
- {
- $confirm = true;
- $cron = true;
- $data['account_id'] =
$GLOBALS['phpgw']->accounts->name2id($data['user']);
- $GLOBALS['phpgw_info']['user']['account_id'] =
$data['account_id'];
- $GLOBALS['phpgw']->session->account_id =
$data['account_id'];
-
$GLOBALS['phpgw']->session->appsession('session_data','mail2sms',$data);
- }
- else
- {
- $confirm = phpgw::get_var('confirm',
'bool', 'POST');
- $execute = phpgw::get_var('execute',
'bool', 'GET');
- $cron = false;
- }
+ $this->function_name = 'forward_mail_as_sms';
+ $this->sub_location = lang('Async service');
+ $this->function_msg = 'Forward email as SMS';
- 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);
- }
+ $this->bocommon =
CreateObject('property.bocommon');
}
- function confirm($execute='')
+ function execute()
{
- $link_data = array
- (
- 'menuaction' =>
'property.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('property') . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
- $GLOBALS['phpgw']->xslttpl->pp();
+ $this->check_for_new_mail();
}
- function execute($cron='')
- {
- $receipt = $this->check_for_new_mail();
- if($receipt)
- {
- $this->cron_log($receipt,$cron);
- }
-
- if(!$cron)
- {
- $this->confirm($execute=false);
- }
- }
-
- function cron_log($receipt='',$cron='')
- {
- $insert_values= array(
- $cron,
- date($this->db->datetime_format()),
- $this->function_name,
- $receipt
- );
-
- $insert_values =
$this->db->validate_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');
@@ -186,9 +94,10 @@
$bosms->send_sms(array('p_num_text'=>$data['cellphone'], 'message'
=>$entry['message']));
}
- $msg = $j . ' meldinger er sendt';
- $this->receipt['message'][]=array('msg'=> $msg);
-
- return $j ? $msg : false;
+ if($j)
+ {
+ $msg = $j . ' meldinger er sendt';
+ $this->receipt['message'][]=array('msg'=> $msg);
+ }
}
}
Modified:
trunk/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
===================================================================
---
trunk/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
2013-12-26 11:39:00 UTC (rev 11568)
+++
trunk/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
2013-12-26 22:17:08 UTC (rev 11569)
@@ -32,143 +32,30 @@
* @package property
*/
+ include_class('property', 'cron_parent', 'inc/cron/');
- class import_oppdatering_av_bestilling_fra_agresso_bkb
+ class import_oppdatering_av_bestilling_fra_agresso_bkb extends
property_cron_parent
{
var $function_name =
'import_oppdatering_av_bestilling_fra_agresso_bkb';
var $debug = true;
protected $updated_tickects = array();
protected $receipt = array();
-
function __construct()
{
- $this->sotts =
CreateObject('property.sotts');
- $this->db = &
$GLOBALS['phpgw']->db;
- $this->join = &
$this->db->join;
- $this->left_join = &
$this->db->left_join;
- $this->like = &
$this->db->like;
+ parent::__construct();
+ $this->function_name =
'import_oppdatering_av_bestilling_fra_agresso_bkb';
+ $this->sub_location = lang('ticket');
+ $this->function_msg = 'Importer rapport fra Agresso
for oppdatering av meldinger';
+
+ $this->sotts =
CreateObject('property.sotts');
$this->config =
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property',
'.invoice'));
$this->send =
CreateObject('phpgwapi.send');
}
- function pre_run($data = array())
+ public function execute()
{
- if(isset($data['enabled']) && $data['enabled']==1)
- {
- $confirm = true;
- $cron = true;
- }
- else
- {
- $confirm = phpgw::get_var('confirm',
'bool', 'POST');
- $execute = phpgw::get_var('execute',
'bool', 'GET');
- }
-
- if( isset($data['debug']) && $data['debug'] )
- {
- $this->debug = true;
- }
- else
- {
- $this->debug = phpgw::get_var('debug',
'bool');
- }
-
- if ($confirm)
- {
- $this->execute($cron);
- }
- else
- {
- $this->confirm($execute=false);
- }
- }
-
- function confirm($execute='')
- {
- $link_data = array
- (
- 'menuaction' =>
'property.custom_functions.index',
- 'function' => $this->function_name,
- 'execute' => $execute,
- 'debug' => $this->debug
- );
-
-
- if(!$execute)
- {
- $lang_confirm_msg = lang('do you want to
perform this action');
- }
-
- $lang_yes = lang('yes');
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('confirm_custom'));
-
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
-
- $data = array
- (
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',
array('menuaction'=>'property.uiasync.index')),
- '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' => 'Importer rapport
fra Agresso for oppdatering av meldinger',
- 'lang_no_statustext' => 'tilbake',
- 'lang_no' =>
lang('no'),
- 'lang_done' =>
'Avbryt',
- 'lang_done_statustext' => 'tilbake'
- );
-
- $appname = lang('location');
- $function_msg = 'Importer rapport fra Agresso for
oppdatering av meldinger';
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
- $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- private function alert_assigned()
- {
-
- $updated_tickects = array_keys($this->updated_tickects);
-
- foreach ($updated_tickects as $id)
- {
- $this->db->query("SELECT assignedto FROM
fm_tts_tickets WHERE id= '{$id}'",__LINE__,__FILE__);
- $this->db->next_record();
- $assignedto = $this->db->f('assignedto');
- $this->send_notification($assignedto, $id);
- }
- }
-
- private function send_notification($assignedto = 0, $id = 0)
- {
- if
(!isset($GLOBALS['phpgw_info']['server']['smtp_server']) ||
!$GLOBALS['phpgw_info']['server']['smtp_server'])
- {
- return;
- }
-
- $subject = 'Melding er oppdatert fra Agresso';
- $from = "Ikke svar<address@hidden>";
- $prefs =
$this->bocommon->create_preferences('property', $assignedto);
- if(isset($prefs['email']) && $prefs['email'])
- {
- $body = '<a href ="' .
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uitts.view', 'id' => $id),false,true).'">' . lang('Ticket').' #' .$id
.'</a>'."\n";
- try
- {
- $rc =
$this->send->msg('email',$prefs['email'], $subject, stripslashes($body), '',
'', '',$from,'','html');
- }
- catch (phpmailerException $e)
- {
- $this->receipt['error'][] = array('msg'
=> $e->getMessage());
- }
- }
- }
-
- public function execute($cron='')
- {
$this->get_files();
$dirname =
$this->config->config_data['import']['local_path'];
@@ -241,28 +128,6 @@
{
$this->receipt['error'][] = array('msg' =>
"Arkiv katalog '{$dirname}/archive/' ikke er ikke skrivbar - kontakt
systemadminstrator for å korrigere");
}
-
- if(!$cron)
- {
- $this->confirm($execute=false);
- }
-
- $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
-
- $insert_values= array
- (
- $cron,
- date($this->db->datetime_format()),
- $this->function_name,
-
$this->db->db_addslashes(implode(',',(array_keys($msgbox_data))))
- );
-
- $insert_values =
$this->db->validate_insert($insert_values);
-
- $sql = "INSERT INTO fm_cron_log
(cron,cron_date,process,message) "
- . "VALUES ($insert_values)";
- $this->db->query($sql,__LINE__,__FILE__);
-
}
protected function get_files()
@@ -443,4 +308,41 @@
return $ok;
}
+ private function alert_assigned()
+ {
+
+ $updated_tickects = array_keys($this->updated_tickects);
+
+ foreach ($updated_tickects as $id)
+ {
+ $this->db->query("SELECT assignedto FROM
fm_tts_tickets WHERE id= '{$id}'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $assignedto = $this->db->f('assignedto');
+ $this->send_notification($assignedto, $id);
+ }
+ }
+
+ private function send_notification($assignedto = 0, $id = 0)
+ {
+ if
(!isset($GLOBALS['phpgw_info']['server']['smtp_server']) ||
!$GLOBALS['phpgw_info']['server']['smtp_server'])
+ {
+ return;
+ }
+
+ $subject = 'Melding er oppdatert fra Agresso';
+ $from = "Ikke svar<address@hidden>";
+ $prefs =
$this->bocommon->create_preferences('property', $assignedto);
+ if(isset($prefs['email']) && $prefs['email'])
+ {
+ $body = '<a href ="' .
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uitts.view', 'id' => $id),false,true).'">' . lang('Ticket').' #' .$id
.'</a>'."\n";
+ try
+ {
+ $rc =
$this->send->msg('email',$prefs['email'], $subject, stripslashes($body), '',
'', '',$from,'','html');
+ }
+ catch (phpmailerException $e)
+ {
+ $this->receipt['error'][] = array('msg'
=> $e->getMessage());
+ }
+ }
+ }
}
Modified: trunk/property/inc/cron/default/reset_workorder_cached_budget.php
===================================================================
--- trunk/property/inc/cron/default/reset_workorder_cached_budget.php
2013-12-26 11:39:00 UTC (rev 11568)
+++ trunk/property/inc/cron/default/reset_workorder_cached_budget.php
2013-12-26 22:17:08 UTC (rev 11569)
@@ -3,7 +3,7 @@
* 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/
+ * @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
@@ -28,7 +28,6 @@
*/
/**
- * Filteret importerer rapporter fra Agresso som grunnlag for
oppdatering av øknomi og status på meldings_bestilling.
* @package property
*/
@@ -44,13 +43,8 @@
$this->function_name = 'reset_workorder_cached_budget';
$this->sub_location = lang('workorder');
$this->function_msg = 'reset workorder cached
budget';
-
- $this->join = &
$this->db->join;
- $this->left_join = &
$this->db->left_join;
- $this->like = &
$this->db->like;
}
-
public function execute()
{
$orders = array();
@@ -76,6 +70,5 @@
$count_orders = count($orders);
$this->receipt['message'][] = array('msg' =>
"Rekalkulert budsjett for {$count_orders} løpende bestillinger");
-
}
}
Modified: trunk/property/inc/cron/default/synkroniser_med_boei.php
===================================================================
--- trunk/property/inc/cron/default/synkroniser_med_boei.php 2013-12-26
11:39:00 UTC (rev 11568)
+++ trunk/property/inc/cron/default/synkroniser_med_boei.php 2013-12-26
22:17:08 UTC (rev 11569)
@@ -32,13 +32,19 @@
* @package property
*/
- class synkroniser_med_boei
+ include_class('property', 'cron_parent', 'inc/cron/');
+
+ class synkroniser_med_boei extends property_cron_parent
{
- var $function_name = 'synkroniser_med_boei';
- function synkroniser_med_boei()
+ function __construct()
{
- // $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ parent::__construct();
+
+ $this->function_name = 'synkroniser_med_boei';
+ $this->sub_location = lang('location');
+ $this->function_msg = 'Synkroniser_med_boei';
+
$this->bocommon =
CreateObject('property.bocommon');
$this->db = $this->bocommon->new_db();
$this->join =
$this->db->join;
@@ -70,76 +76,9 @@
$this->db_boei2 = clone($this->db_boei);
}
- function pre_run($data='')
- {
- if($data['enabled']==1)
- {
- $confirm = true;
- $cron = true;
- }
- else
- {
- $confirm = phpgw::get_var('confirm',
'bool', 'POST');
- $execute = phpgw::get_var('execute',
'bool', 'GET');
- }
- if ($confirm)
- {
- $this->execute($cron);
- }
- else
- {
- $this->confirm($execute=false);
- }
- }
-
-
- function confirm($execute='')
+ function execute()
{
- $link_data = array
- (
- 'menuaction' =>
'property.custom_functions.index',
- 'function' =>$this->function_name,
- 'execute' => $execute,
- );
-
-
- if(!$execute)
- {
- $lang_confirm_msg = lang('do you want to
perform this action');
- }
-
- $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('property') . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
- $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function execute($cron='')
- {
set_time_limit(500);
$receipt = $this->legg_til_eier_phpgw();
$this->cron_log($receipt,$cron);
@@ -170,17 +109,13 @@
$receipt = $this->update_tenant_name();
$this->cron_log($receipt,$cron);
- if(!$cron)
- {
- $this->confirm($execute=false);
- }
}
- function cron_log($receipt='',$cron='')
+ function cron_log($receipt='')
{
$insert_values= array(
- $cron,
+ $this->cron,
date($this->db->datetime_format()),
$this->function_name,
$receipt
@@ -989,4 +924,3 @@
return $msg;
}
}
-
Modified: trunk/property/inc/cron/default/update_phpgw.php
===================================================================
--- trunk/property/inc/cron/default/update_phpgw.php 2013-12-26 11:39:00 UTC
(rev 11568)
+++ trunk/property/inc/cron/default/update_phpgw.php 2013-12-26 22:17:08 UTC
(rev 11569)
@@ -17,115 +17,26 @@
* @package property
*/
- class update_phpgw
- {
- var $function_name = 'update_phpgw';
+ include_class('property', 'cron_parent', 'inc/cron/');
+ class update_phpgw extends property_cron_parent
+ {
function update_phpgw()
{
- // $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->bocommon =
CreateObject('property.bocommon');
- $this->db = &
$GLOBALS['phpgw']->db;
- }
+ parent::__construct();
- function pre_run($data='')
- {
- if(isset($data['enabled']) && $data['enabled']==1)
- {
- $confirm = true;
- $cron = true;
- }
- else
- {
- $confirm = phpgw::get_var('confirm',
'bool', 'POST');
- $execute = phpgw::get_var('execute',
'bool', 'GET');
- $cron = false;
- }
+ $this->function_name = 'update_phpgw';
+ $this->sub_location = lang('Async service');
+ $this->function_msg = 'Update all installed apps of
phpgw';
-
- if (isset($confirm) && $confirm)
- {
- $this->execute($cron);
- }
- else
- {
- $this->confirm($execute=false);
- }
+ $this->bocommon =
CreateObject('property.bocommon');
}
- function confirm($execute='')
+ function execute()
{
- $link_data = array
- (
- 'menuaction' =>
'property.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' =>
isset($this->receipt['message'])?$this->receipt['message']:'',
- 'lang_confirm_msg' =>
$lang_confirm_msg,
- 'lang_yes' =>
$lang_yes,
- 'lang_yes_statustext' => lang('Update
database for all applications'),
- '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('property') . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('confirm' => $data));
- $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function execute($cron='')
- {
$this->perform_update_db();
-
- if(isset($this->receipt) && $this->receipt)
- {
- $this->cron_log($this->receipt,$cron);
- }
-
- if(!$cron)
- {
- $this->confirm($execute=false);
- }
}
- function cron_log($receipt='',$cron='')
- {
- $insert_values= array(
- $cron,
- date($this->db->datetime_format()),
- $this->function_name,
- $receipt
- );
-
- $insert_values =
$this->db->validate_insert($insert_values);
-
- $sql = "INSERT INTO fm_cron_log
(cron,cron_date,process,message) "
- . "VALUES ($insert_values)";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
function perform_update_db()
{
$GLOBALS['phpgw_setup'] =
CreateObject('phpgwapi.setup', true, true);
@@ -158,4 +69,3 @@
}
}
}
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11569] property: use parent class for cron-jobs,
Sigurd Nes <=