[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11607] proprty: more on cron and integration
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11607] proprty: more on cron and integration |
Date: |
Sat, 18 Jan 2014 15:27:26 +0000 |
Revision: 11607
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11607
Author: sigurdne
Date: 2014-01-18 15:27:25 +0000 (Sat, 18 Jan 2014)
Log Message:
-----------
proprty: more on cron and integration
Modified Paths:
--------------
trunk/property/inc/cron/class.cron_parent.inc.php
trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
trunk/property/templates/base/confirm_custom.xsl
Modified: trunk/property/inc/cron/class.cron_parent.inc.php
===================================================================
--- trunk/property/inc/cron/class.cron_parent.inc.php 2014-01-17 19:49:18 UTC
(rev 11606)
+++ trunk/property/inc/cron/class.cron_parent.inc.php 2014-01-18 15:27:25 UTC
(rev 11607)
@@ -36,7 +36,7 @@
abstract class property_cron_parent
{
protected $function_name;
- protected $debug = true;
+ protected $debug = false;
protected $receipt = array();
protected $sub_location = 'sub_location';
protected $function_msg = 'function_msg';
@@ -95,8 +95,7 @@
(
'menuaction' =>
'property.custom_functions.index',
'function' => $this->function_name,
- 'execute' => $execute,
- 'debug' => $this->debug
+ 'execute' => $execute
);
@@ -123,7 +122,8 @@
'lang_no_statustext' => 'tilbake',
'lang_no' =>
lang('no'),
'lang_done' =>
'Avbryt',
- 'lang_done_statustext' => 'tilbake'
+ 'lang_done_statustext' => 'tilbake',
+ 'debug' =>
$this->debug
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $this->sub_location . ': ' . $this->function_msg;
@@ -137,12 +137,16 @@
private function cron_log($cron)
{
-
if(!$this->receipt)
{
return;
}
+ if($this->debug)
+ {
+ return;
+ }
+
$msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
$insert_values= array
Modified:
trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
===================================================================
--- trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
2014-01-17 19:49:18 UTC (rev 11606)
+++ trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
2014-01-18 15:27:25 UTC (rev 11607)
@@ -44,57 +44,57 @@
$this->function_name = get_class($this);
$this->sub_location = lang('catch');
$this->function_msg = 'Import info from files';
-
- set_time_limit(1000);
}
-
function execute()
{
$fellesdata = new property_fellesdata();
+
+ $fellesdata->set_debug($this->debug);
+
+
$fellesdata->get_org_unit_ids_from_top();
if($this->debug)
{
- _debug_array($fellesdata->unit_ids);
+// _debug_array($fellesdata->unit_ids);
}
try
{
$fellesdata->insert_values();
+
+
if(isset($GLOBALS['phpgw_info']['user']['apps']['rental']))
+ {
+ $this->update_rental_party();
+ }
}
catch(Exception $e)
{
$this->receipt['error'][]=array('msg'=>$e->getMessage());
}
-
-
if(isset($GLOBALS['phpgw_info']['user']['apps']['rental']))
- {
- $this->update_rental_party();
- }
-
$messages = $fellesdata->messages;
foreach ($messages as $message)
{
- $this->receipt['message'][] = $message;
+ $this->receipt['message'][] = array('msg'=>
$message);
}
}
private function update_rental_party()
{
$sogeneric = CreateObject('property.sogeneric');
- $sql = "SELECT DISTINCT org_enhet_id FROM rental_party
WHERE org_enhet_id IS NOT NULL";
+ $sql = "SELECT DISTINCT org_enhet_id FROM rental_party
WHERE org_enhet_id IS NOT NULL";
$this->db->query($sql,__LINE__,__FILE__);
$parties = array();
while($this->db->next_record())
{
- $parties[] = $this->db->f('org_enhet_id');
+ $parties[] = $this->db->f('org_enhet_id');
}
-
+
foreach ($parties as $party)
{
- $sql = "SELECT name, parent_id FROM
fm_department WHERE id = {$party}";
+ $sql = "SELECT name, parent_id FROM
fm_department WHERE id = {$party}";
$this->db->query($sql,__LINE__,__FILE__);
if($this->db->next_record())
{
@@ -106,12 +106,17 @@
$value_set = array
(
'company_name' => $name,
- 'department' => $parent_name
+ 'department' =>
$this->db->db_addslashes($parent_name)
);
$value_set =
$this->db->validate_update($value_set);
- $sql = "UPDATE {$table} SET
{$value_set} WHERE org_enhet_id ={$parent_id}";
+ $sql = "UPDATE rental_party SET
{$value_set} WHERE org_enhet_id ={$party}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ if($this->debug)
+ {
+ $this->receipt['message'][] =
array('msg' => $sql);
+ }
}
}
}
@@ -127,6 +132,7 @@
protected $unit_ids = array();
protected $names = array();
protected $messages = array();
+ protected $debug = false;
function __construct()
{
@@ -137,7 +143,12 @@
$this->initiate_config();
}
}
-
+
+ public function set_debug($debug)
+ {
+ $this->debug = $debug;
+ }
+
private function initiate_config()
{
$receipt_section = $this->config->add_section(array
@@ -231,12 +242,9 @@
return $this->db;
}
- $config = CreateObject('phpgwapi.config','rental');
- $config->read();
-
- if(! $config->config_data['external_db_host'] ||
!$this->ping($config->config_data['external_db_host']))
+ if(! $this->config->config_data['fellesdata']['host']
|| !$this->ping($this->config->config_data['fellesdata']['host']))
{
- $message ="Database server
{$config->config_data['external_db_host']} is not accessible";
+ $message ="Database server
{$this->config->config_data['fellesdata']['host']} is not accessible";
phpgwapi_cache::message_set($message, 'error');
return false;
}
@@ -244,12 +252,12 @@
$db = createObject('phpgwapi.db', null, null, true);
$db->debug = false;
- $db->Host =
$config->config_data['fellesdata']['host'];
- $db->Port =
$config->config_data['fellesdata']['port'];
+ $db->Host =
$this->config->config_data['fellesdata']['host'];
+ $db->Port =
$this->config->config_data['fellesdata']['port'];
$db->Type = 'oracle';
- $db->Database =
$config->config_data['fellesdata']['db_name'];
- $db->User =
$config->config_data['fellesdata']['user'];
- $db->Password =
$config->config_data['fellesdata']['password'];
+ $db->Database =
$this->config->config_data['fellesdata']['db_name'];
+ $db->User =
$this->config->config_data['fellesdata']['user'];
+ $db->Password =
$this->config->config_data['fellesdata']['password'];
try
{
@@ -273,14 +281,14 @@
$db->transaction_begin();
$units = $this->unit_ids;
-
+
foreach ($units as $unit)
{
$value_set = array
(
'id' => $unit['id'],
'parent_id' =>
$unit['parent'],
- 'name' =>
$unit['name'],
+ 'name' =>
$db->db_addslashes($unit['name']),
'created_on' => time(),
'created_by' =>
$GLOBALS['phpgw_info']['user']['account_id'],
'modified_by' =>
$GLOBALS['phpgw_info']['user']['account_id'],
@@ -333,8 +341,8 @@
while($db->next_record())
{
$org_unit_id = $db->f('ORG_ENHET_ID');
- $name = $db->f('ORG_NAVN');
-
+ $name = $db->f('ORG_NAVN', true);
+
$this->names[$org_unit_id] = $name;
}
@@ -364,7 +372,7 @@
{
$org_unit_id = (int)$org_unit_id;
$db = clone($this->db);
-
+
$q = "SELECT V_ORG_KNYTNING.*,
ANT_ENHETER_UNDER,V_ORG_ENHET.ORG_NAVN,ORG_NIVAA FROM V_ORG_KNYTNING"
. " JOIN V_ORG_ENHET ON (V_ORG_ENHET.ORG_ENHET_ID =
V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING ) WHERE
V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING=$org_unit_id";
Modified: trunk/property/templates/base/confirm_custom.xsl
===================================================================
--- trunk/property/templates/base/confirm_custom.xsl 2014-01-17 19:49:18 UTC
(rev 11606)
+++ trunk/property/templates/base/confirm_custom.xsl 2014-01-18 15:27:25 UTC
(rev 11607)
@@ -8,7 +8,7 @@
</xsl:template>
<!-- update_cat -->
- <xsl:template match="confirm">
+ <xsl:template match="confirm" xmlns:php="http://php.net/xsl">
<table cellpadding="2" cellspacing="2" align="center">
<xsl:choose>
<xsl:when test="msgbox_data != ''">
@@ -40,6 +40,16 @@
<xsl:value-of select="lang_yes_statustext"/>
</xsl:attribute>
</input>
+ <input
type="checkbox" name="debug" value="1">
+
<xsl:attribute name="title">
+
<xsl:value-of select="php:function('lang', 'debug')"/>
+
</xsl:attribute>
+ <xsl:if
test="debug = '1'">
+
<xsl:attribute name="checked">
+
<xsl:text>checked</xsl:text>
+
</xsl:attribute>
+
</xsl:if>
+ </input>
</form>
</td>
<td align="right">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11607] proprty: more on cron and integration,
Sigurd Nes <=