[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7274] Merge 7265:7273 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7274] Merge 7265:7273 from trunk |
Date: |
Mon, 09 May 2011 10:54:07 +0000 |
Revision: 7274
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7274
Author: sigurdne
Date: 2011-05-09 10:54:07 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Merge 7265:7273 from trunk
Modified Paths:
--------------
branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php
branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php
branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
branches/Version-1_0-branch/property/setup/setup.inc.php
branches/Version-1_0-branch/property/setup/tables_update.inc.php
Added Paths:
-----------
branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php
Property Changed:
----------------
branches/Version-1_0-branch/
Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
-
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264
+
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273
Modified:
branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -12,6 +12,16 @@
{
protected static $so;
+ public $xmlrpc_methods = array
+ (
+ array
+ (
+ 'name' => 'get_activities',
+ 'decription' => 'Get list of activities'
+ )
+ );
+
+
/**
* Get a static reference to the storage object associated with this
model object
*
@@ -210,7 +220,7 @@
'district = ' .
$this->marshal($activity->get_district(), 'int'),
'category = ' .
$this->marshal($activity->get_category(), 'int'),
'state = ' .
$this->marshal($activity->get_state(), 'int'),
- 'target = ' . $this->marshal($activity->get_target(),
'int'),
+ 'target = ' . $this->marshal($activity->get_target(),
'string'),
'description = ' .
$this->marshal($activity->get_description(), 'string'),
'arena = ' .
$this->marshal($activity->get_arena(), 'int'),
'time = ' . $this->marshal($activity->get_time(),
'string'),
@@ -255,7 +265,7 @@
$activity->set_district($this->unmarshal($this->db->f('district'), 'int'));
$activity->set_category($this->unmarshal($this->db->f('category'), 'int'));
$activity->set_state($this->unmarshal($this->db->f('state'), 'int'));
-
$activity->set_target($this->unmarshal($this->db->f('target'), 'int'));
+
$activity->set_target($this->unmarshal($this->db->f('target'), 'string'));
$activity->set_description($this->unmarshal($this->db->f('description'),
'string'));
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
@@ -342,7 +352,7 @@
function get_targets()
{
$targets = array();
- $sql = "SELECT * FROM bb_agegroup where active=1";
+ $sql = "SELECT * FROM bb_agegroup where active=1 ORDER BY sort";
$this->db->query($sql, __LINE__, __FILE__);
while($this->db->next_record()){
$target = new
activitycalendar_target($this->db->f('id'));
@@ -392,4 +402,30 @@
return $result;
}
+ function get_activities()
+ {
+ $sql = "SELECT * FROM activity_activity";
+ $this->db->query($sql, __LINE__, __FILE__);
+ while ($this->db->next_record())
+ {
+ $activities[]= array
+ (
+ 'id' =>
(int) $this->db->f('id'),
+ 'title' =>
$this->db->f('title',true),
+ 'organization_id' =>
$this->db->f('organization_id',true),
+ 'group_id' =>
$this->db->f('group_id'),
+ 'district' =>
$this->db->f('district',true),
+ 'category' =>
$this->db->f('category'),
+ 'state' =>
$this->db->f('state',true),
+ 'target' =>
$this->db->f('target'),
+ 'description' =>
$this->db->f('description'),
+ 'time' =>
$this->db->f('time'),
+ 'contact_person_1' =>
$this->db->f('contact_person_1'),
+ 'contact_person_2' =>
$this->db->f('contact_person_2'),
+ 'special_adaptation'=>
$this->db->f('special_adaptation'),
+ );
+ }
+ return $activities;
+ }
+
}
\ No newline at end of file
Modified:
branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -110,7 +110,8 @@
$activity->set_district(phpgw::get_var('district'));
$activity->set_state(phpgw::get_var('state'));
$activity->set_category(phpgw::get_var('category'));
- $activity->set_target(phpgw::get_var('target'));
+ $target_array = phpgw::get_var('target');
+ $activity->set_target(implode(",",
$target_array));
$activity->set_description(phpgw::get_var('description'));
$activity->set_time(phpgw::get_var('time'));
$activity->set_contact_persons($persons);
Modified:
branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -1,31 +1,11 @@
<?php
-/* phpgw::import_class('rental.uicommon');
- phpgw::import_class('rental.soparty');
- phpgw::import_class('rental.socomposite');
- phpgw::import_class('rental.socontract');
- phpgw::import_class('rental.sounit');
- phpgw::import_class('rental.soprice_item');
- phpgw::import_class('rental.socontract_price_item');
- phpgw::import_class('rental.sonotification');
- phpgw::import_class('rental.soadjustment');
-*/
phpgw::import_class('activitycalendar.uicommon');
phpgw::import_class('activitycalendar.soarena');
phpgw::import_class('activitycalendar.soactivity');
include_class('activitycalendar', 'arena', 'inc/model/');
include_class('activitycalendar', 'activity', 'inc/model/');
-/*
- include_class('rental', 'contract', 'inc/model/');
- include_class('rental', 'party', 'inc/model/');
- include_class('rental', 'composite', 'inc/model/');
- include_class('rental', 'property_location', 'inc/model/');
- include_class('rental', 'price_item', 'inc/model/');
- include_class('rental', 'contract_price_item', 'inc/model/');
- include_class('rental', 'property_location', 'inc/model/');
- include_class('rental', 'notification', 'inc/model/');
- include_class('rental', 'adjustment', 'inc/model/');
-*/
+
class activitycalendar_uiimport extends activitycalendar_uicommon
{
const DELIMITER = ";";
@@ -38,7 +18,7 @@
// File system path to import folder on server
protected $path;
- protected $location_id;
+ protected $district;
// Label on the import button. Changes as we step through the
import process.
protected $import_button_label;
@@ -47,8 +27,7 @@
public $public_functions = array
(
- 'index' => true,
- 'import_regulations' => true
+ 'index' => true
);
public function __construct()
@@ -67,47 +46,55 @@
// Do nothing
}
- public function import_regulations()
+
+ /**
+ * Public method.
+ *
+ * @return unknown_type
+ */
+ public function index()
{
setlocale(LC_ALL, 'no_NO');
-
// Set the submit button label to its initial state
$this->import_button_label = "Start import";
-
- var_dump(phpgw::get_var("importstep"));
+// var_dump(phpgw::get_var("importstep"));
// If the parameter 'importsubmit' exist (submit button
in import form), set path
if (phpgw::get_var("importsubmit"))
{
// Get the path for user input or use a default
path
- $this->path = phpgw::get_var("facilit_path") ?
phpgw::get_var("facilit_path") : '/home/notroot/FacilitExport';
- phpgwapi_cache::session_set('rental',
'import_path', $this->path);
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'rental.uiimport.import_regulations', 'importstep' =>
'true'));
+ $this->path = phpgw::get_var("import_path") ?
phpgw::get_var("import_path") : '/home/notroot/FacilitExport';
+ $this->district = phpgw::get_var("district") ?
phpgw::get_var("district") : '1';
+ phpgwapi_cache::session_set('activitycalendar',
'import_path', $this->path);
+ phpgwapi_cache::session_set('activitycalendar',
'import_district', $this->district);
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'activitycalendar.uiimport.index', 'importstep' =>
'true'));
}
else if(phpgw::get_var("importstep"))
{
- $this->messages = array();
- $this->warnings = array();
- $this->errors = array();
-
$start_time = time(); // Start time of import
$start = date("G:i:s",$start_time);
echo "<h3>Import started at: {$start}</h3>";
echo "<ul>";
- $this->path =
phpgwapi_cache::session_get('rental', 'import_path') . '/Intern';
+ $this->path =
phpgwapi_cache::session_get('activitycalendar', 'import_path') . '/aktiviteter';
+ $this->district =
phpgwapi_cache::session_get('activitycalendar', 'import_district');
+ //$this->path =
'/home/notroot/FacilitExport/aktiviteter';
- $result =
$this->import_adjustment_information(); // Do import step, result determines if
finished for this area
- echo '<li class="info">Finished importing
adjustment information</li>';
-
+ $result = $this->import(); // Do import step,
result determines if finished for this area
+ echo '<li class="info">Aktiviteter: finished
step ' .$result. '</li>';
+ while($result != '1')
+ {
+ $result = $this->import();
+ echo '<li class="info">Aktiviteter:
finished step ' .$result. '</li>';
+ flush();
+ }
+
echo "</ul>";
$end_time = time();
$difference = ($end_time - $start_time) / 60;
$end = date("G:i:s",$end_time);
- echo "<h3>Import ended at: {$end}. Import
lasted {$difference} minutes.</h3>";
+ echo "<h3>Import ended at: {$end}. Import
lasted {$difference} minutes.";
- $this->log_messages("adjustments");
-
if ($this->errors) {
echo "<ul>";
foreach ($this->errors as $error) {
@@ -136,97 +123,15 @@
}
else
{
- $this->render('facilit_import_adjustment.php',
array(
+ $this->render('activity_import.php', array(
'messages' => $this->messages,
'warnings' => $this->warnings,
'errors' => $this->errors,
'button_label' => $this->import_button_label,
- 'facilit_path' => $path,
- 'location_id' => $this->location_id)
+ 'import_path' => $path)
);
}
}
-
- /**
- * Public method.
- *
- * @return unknown_type
- */
- public function index()
- {
- setlocale(LC_ALL, 'no_NO');
-
- // Set the submit button label to its initial state
- $this->import_button_label = "Start import";
-// var_dump(phpgw::get_var("importstep"));
-
- // If the parameter 'importsubmit' exist (submit button
in import form), set path
- if (phpgw::get_var("importsubmit"))
- {
- // Get the path for user input or use a default
path
- $this->path = phpgw::get_var("facilit_path") ?
phpgw::get_var("facilit_path") : '/home/notroot/FacilitExport';
- phpgwapi_cache::session_set('rental',
'import_path', $this->path);
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'rental.uiimport.index', 'importstep' => 'true'));
- }
- else if(phpgw::get_var("importstep"))
- {
- $start_time = time(); // Start time of import
- $start = date("G:i:s",$start_time);
- echo "<h3>Import started at: {$start}</h3>";
- echo "<ul>";
- $this->path =
'/home/notroot/FacilitExport/aktiviteter';
-
- $result = $this->import(); // Do import step,
result determines if finished for this area
- echo '<li class="info">Internleie: finished
step ' .$result. '</li>';
- while($result != '1')
- {
- $result = $this->import();
- echo '<li class="info">Aktiviteter:
finished step ' .$result. '</li>';
- flush();
- }
-/*
- $this->location_id =
array_search('contract_type_eksternleie', $types);
- $this->path =
phpgwapi_cache::session_get('rental', 'import_path') . '/Ekstern';
-
- $result = $this->import(); // Do import step,
result determines if finished for this area
- echo '<li class="info">Eksternleie: finished
step ' .$result. '</li>';
- while($result != '7')
- {
- $result = $this->import();
- echo '<li class="info">Eksternleie:
finished step ' .$result. '</li>';
- flush();
- }
-
- $this->location_id =
array_search('contract_type_innleie', $types);
- $this->path =
phpgwapi_cache::session_get('rental', 'import_path') . '/Innleie';
-
- $result = $this->import(); // Do import step,
result determines if finished for this area
- echo '<li class="info">Innleie: finished step '
.$result. '</li>';
- while($result != '6')
- {
- $result = $this->import();
- echo '<li class="info">Innleie:
finished step ' .$result. '</li>';
- flush();
- }
-*/
- echo "</ul>";
- $end_time = time();
- $difference = ($end_time - $start_time) / 60;
- $end = date("G:i:s",$end_time);
- echo "<h3>Import ended at: {$end}. Import
lasted {$difference} minutes.";
- }
- else
- {
- $this->render('facilit_import.php', array(
- 'messages' => $this->messages,
- 'warnings' => $this->warnings,
- 'errors' => $this->errors,
- 'button_label' => $this->import_button_label,
- 'facilit_path' => $path,
- 'location_id' => $this->location_id)
- );
- }
- }
/**
* Import Facilit data to Portico Estate's rental module
@@ -262,82 +167,15 @@
return '1';
$this->clean_up();
}
-/*
- // Import activities if not done before and put them on
the users session
- if (!phpgwapi_cache::session_get('activitycalendar',
'activities')) {
- phpgwapi_cache::session_set('activitycalendar',
'activities', $this->import_activities());
- $this->log_messages(2);
- return '2';
- $this->clean_up();
- }
-*/
-/*
- // Load composite to contract link table if not done
before and put them on the users session
- if (!phpgwapi_cache::session_get('rental',
'facilit_rentalobject_to_contract')) {
- phpgwapi_cache::session_set('rental',
'facilit_rentalobject_to_contract', $this->import_rentalobject_to_contract());
- $this->log_messages(3);
- return '3';
- }
-
- // Import contracts if not done before and put them on
the users session
- // Prerequisites: Composites, parties, contract to
composite bindings, and default values for accounts/project number for
- if (!phpgwapi_cache::session_get('rental',
'facilit_contracts')) {
- $composites =
phpgwapi_cache::session_get('rental', 'facilit_composites');
- $rentalobject_to_contract =
phpgwapi_cache::session_get('rental', 'facilit_rentalobject_to_contract');
- $parties =
phpgwapi_cache::session_get('rental', 'facilit_parties');
- $location_id = $this->location_id;
- $defalt_values['account_in'] =
rental_socontract::get_instance()->get_default_account($location_id, true); //IN
- $defalt_values['account_out'] =
rental_socontract::get_instance()->get_default_account($location_id, false);
//OUT
- $defalt_values['project_number'] =
rental_socontract::get_instance()->get_default_project_number($location_id);
//PROJECTNUMBER
- phpgwapi_cache::session_set('rental',
'facilit_contracts', $this->import_contracts($composites,
$rentalobject_to_contract, $parties, $defalt_values));
- $this->log_messages(4);
- return '4';
- }
-
- // Import price items if not done before and put them
on the users session
- // Prerequisites: Contracts
- if (!phpgwapi_cache::session_get('rental',
'facilit_contract_price_items')) {
- $contracts =
phpgwapi_cache::session_get('rental', 'facilit_contracts');
- phpgwapi_cache::session_set('rental',
'facilit_contract_price_items', $this->import_contract_price_items($contracts));
- $this->log_messages(5);
- return '5';
- }
-
- // Import events if not done before and put them on the
users session
- // Prerequistes: Contracts
- if (!phpgwapi_cache::session_get('rental',
'facilit_events')) {
- $contracts =
phpgwapi_cache::session_get('rental', 'facilit_contracts');
- $event_data =
phpgwapi_cache::session_get('rental', 'facilit_events');
- $regulation_id_location_id = isset($event_data)
? $event_data : array();
- phpgwapi_cache::session_set('rental',
'facilit_events', $this->import_events($contracts, $regulation_id_location_id));
- $this->log_messages(6);
- return '6';
- }
-
- // Import adjustments
- // Prerequistes: Contracts
- if (!phpgwapi_cache::session_get('rental',
'facilit_adjustments')) {
- $contracts =
phpgwapi_cache::session_get('rental', 'facilit_contracts');
- $event_data =
phpgwapi_cache::session_get('rental', 'facilit_events');
- $regulation_id_location_id = isset($event_data)
? $event_data : array();
- $this->import_adjustments($contracts,
$regulation_id_location_id);
- $this->log_messages(7);
- $this->clean_up();
- }
-*/
+
// We're done with the import, so clear all session
variables so we're ready for a new one
// We do not clear parties (same for all responsibility
areas)
// We do not clear event data, the array is just added
for each
phpgwapi_cache::session_clear('activitycalendar',
'arenas');
- phpgwapi_cache::session_clear('activitycalendar',
'activities');
-/* phpgwapi_cache::session_clear('rental',
'facilit_contracts');
- phpgwapi_cache::session_clear('rental',
'facilit_contract_price_items');
- phpgwapi_cache::session_clear('rental',
'facilit_events');
- phpgwapi_cache::session_clear('rental',
'facilit_adjustments');*/
return '1';
}
- protected function import_arenas()
+ protected function import_arenas($office)
{
$start_time = time();
@@ -345,6 +183,8 @@
$soactivity =
activitycalendar_soactivity::get_instance();
$datalines = $this->getcsvdata($this->path .
"/import_all.csv");
+ //$activity_district = $this->district;
+ //var_dump($this->district);
$this->messages[] = "Read 'import_all.csv' file in " .
(time() - $start_time) . " seconds";
$this->messages[] = "'importfile.csv' contained " .
count($datalines) . " lines";
@@ -403,15 +243,32 @@
}
}
$activity_target = $this->decode($data[6]);
+ //var_dump($activity_target);
if($activity_target)
{
- $act_target =
split(',',$activity_target);
- //var_dump($activity_target);
- //var_dump($act_target[0]);
- $activity_target =
$soactivity->get_target_from_sort_id($act_target[0]);
+ $act_target_array = explode(",",
$activity_target);
+ foreach($act_target_array as $at)
+ {
+ $act_targets[] =
$soactivity->get_target_from_sort_id($at);
+ }
+ $activity_target = implode(",",
$act_targets);
}
+ unset($act_targets);
$activity_day = $this->decode($data[9]);
$activity_time = $this->decode($data[10]);
+ $activity_update_date =
$this->decode($data[20]);
+ if($activity_update_date)
+ {
+ $act_update_array = explode(".",
$activity_update_date);
+ if(count($act_update_array) == 3)
+ {
+ $y = $act_update_array[2];
+ $m = $act_update_array[1];
+ $d = $act_update_array[0];
+ $activity_updated_date =
strtotime($y."-".$m."-".$d);
+ }
+ }
+ //$activity_district = $this->decode($data[21]);
if($activity_title){
$activity->set_title($activity_title);
@@ -425,6 +282,8 @@
{
$activity->set_special_adaptation(true);
}
+
$activity->set_district($this->district);
+
$activity->set_last_change_date($activity_updated_date);
//var_dump($activity);
// All is good, store activity
if ($soactivity->store($activity)) {
@@ -439,1284 +298,6 @@
return true;
}
- protected function import_parties()
- {
- $start_time = time();
- $soparty = rental_soparty::get_instance();
- $parties = array();
-
- //Check to see if there is any parties in the database.
If so, do not store these
- //... double checking to ensure that the user has not
logged out and in again during import
- $alreay_imported_parties = false;
- $number_of_parties = $soparty->get_number_of_parties();
- if($number_of_parties > 0)
- {
- return;
- }
-
- $datalines = $this->getcsvdata($this->path .
"/u_PersonForetak.csv", true);
- $this->messages[] = "Read 'u_PersonForetak.csv' file in
" . (time() - $start_time) . " seconds";
- $this->messages[] = "'u_PersonForetak.csv' contained "
. count($datalines) . " lines";
- $counter = 1;
-
- // Loop through each line of the file, parsing CSV data
to a php array
- foreach ($datalines as $data) {
- if(count($data) <= 30)
- {
- continue;
- }
-
- // Create a new rental party we can fill with
info from this line from the file
- $party = new rental_party();
-
- $identifier = $this->decode($data[24]);
//cPersonForetaknr
- //Removed whitespace characters
- $identifier = str_replace('
','',''.$identifier);
-
-
-
- // Default information
- $party->set_address_1($this->decode($data[3]));
//cAdresse1
- $party->set_address_2($this->decode($data[4]));
//cAdresse2
-
$party->set_postal_code($this->decode($data[5])); //cPostnr
-
$party->set_mobile_phone($this->decode($data[7])); //cMobil
- $party->set_phone($this->decode($data[8]));
//cTelefon
- $party->set_fax($this->decode($data[9]));
//cTelefaks
- $party->set_title($this->decode($data[12]));
//cArbeidstittel
- $party->set_email($this->decode($data[25]));
//cEpost
-
$party->set_company_name($this->decode($data[10])); //cArbeidsgiver
-
$party->set_department($this->decode($data[11])); //cAvdeling
-
$party->set_account_number($this->decode($data[14])); //cBankkontonr
-
$party->set_reskontro($this->decode($data[23])); //cReskontronr
- $party->set_comment($this->decode($data[26]));
//cMerknad
-
- // Insert contract person in comment if present
- $contact_person = $this->decode($data[6]);
- if(isset($contact_person)) {
-
$party->set_comment($party->get_comment()."\n\nKontaktperson:
".$contact_person); //cKontaktPerson
- }
-
- $valid_identifier = false;
- switch(strlen(''.$identifier)) {
- case 4: // Intern organisasjonstilknytning
- //Should be four number or on the form
'KFxx'
- if(
- is_numeric($identifier)
- ||
- ((substr($identifier,0,2) == 'KF') &&
is_numeric(substr($identifier,2,2)))
- )
- {
-
$party->set_company_name($this->decode($data[2])); //cForetaksnavn
- $party->set_first_name(null);
- $party->set_last_name(null);
-
- // Get location ID
- $locations = $GLOBALS['phpgw']->locations;
- $subs =
$locations->get_subs_from_pattern('rental', '.ORG.BK.__.'.$identifier);
//cPersonForetaknr
- if(count($subs) > 0)
- {
-
$party->set_location_id($subs[0]['location_id']);
- }
- else
- {
- $this->warnings[] = "Party with valid
identifier ({$identifier}) not found in internal organisation tree. Company
name({$party->get_company_name()})";
- }
- $valid_identifier = true;
- }
- break;
- case 5: //Internal, Should be a result unit on the form
'Rxxxx'
- if((substr($identifier,0,1) == 'R') &&
is_numeric(substr($identifier,1,4)))
- {
- $identifier = substr($identifier,1,4);
-
-
$party->set_company_name($this->decode($data[2])); //cForetaksnavn
- $party->set_first_name(null);
- $party->set_last_name(null);
-
- // Get location ID
- $locations = $GLOBALS['phpgw']->locations;
- $subs =
$locations->get_subs_from_pattern('rental', '.ORG.BK.__.'.$identifier);
//cPersonForetaknr
- if(count($subs) > 0)
- {
-
$party->set_location_id($subs[0]['location_id']);
- }
- else
- {
- $this->warnings[] = "Party with valid
identifier ({$identifier}- original R{$identifier}) not found in internal
organisation tree. Company name({$party->get_company_name()})";
- }
- $valid_identifier = true;
- }
- break;
- case 6: // Foretak (agresso-id)
- case 9: // Foretak (org.nr)
- if(is_numeric($identifier))
- {
-
$party->set_company_name($this->decode($data[2])); //cForetaksnavn
- $party->set_first_name(null);
- $party->set_last_name(null);
-
- $valid_identifier = true;
- }
- break;
- case 11: // Personnr
- if(is_numeric($identifier))
- {
- if (!$this->is_null($data[0])) {
-
$party->set_first_name($this->decode($data[0])); //cFornavn
-
$party->set_last_name($this->decode($data[1])); //cEtternavn
- } else {
- $company_name = explode(' ',
$this->decode($data[2]), 2); //cForetaksnavn
- $party->set_first_name($company_name[0]);
//cFornavn
- $party->set_last_name($company_name[1]);
//cEtternavn
- }
- $valid_identifier = true;
-
- }
- break;
- }
-
- if(!$valid_identifier)
- {
- $party->set_first_name($this->decode($data[0]));
//cFornavn
- $party->set_last_name($this->decode($data[1]));
//cEtternavn
- $party->set_company_name($this->decode($data[2]));
//cForetaksnavn
- $party->set_is_inactive(true);
- $this->warnings[] = "Party with unknown 'cPersonForetaknr'
format ({$identifier}). First name ({$party->get_first_name()}). Last
name({$party->get_last_name()}). Company name({$party->get_company_name()})
Setting as inactive.";
- }
-
- // Fødselsnr/Foretaksnr/AgressoID
- $party->set_identifier($identifier);
-
- // Store party and log message
- if ($soparty->store($party))
- {
- // Add party to collection of parties
keyed by its facilit ID so we can refer to it later.
- $facilit_id = $data[17];
//nPersonForetakId
- $parties[$facilit_id] =
$party->get_id();
- $this->messages[] = "Successfully added
party " . $party->get_name() . " (" . $party->get_id() . ")";
- }
- else
- {
- $this->errors[] = "Failed to store
party " . $party->get_name();
- }
- }
-
- $this->messages[] = "Successfully imported " .
count($parties) . " contract parties. (" . (time() - $start_time) . "
seconds).";
-
- //Clean up
- //unset();
-
- return $parties;
- }
-
- protected function import_composites()
- {
- $start_time = time();
-
- // Storage objects
- $socomposite = rental_socomposite::get_instance();
- $socontract = rental_socontract::get_instance();
- $sounit = rental_sounit::get_instance();
-
- // Array for mapping the composite ids to the facilit
ids
- $composites = array();
-
- //Read source data
- $datalines = $this->getcsvdata($this->path .
"/u_Leieobjekt.csv");
- $this->messages[] = "Read 'u_Leieobjekt.csv' file in "
. (time() - $start_time) . " seconds";
- $this->messages[] = "'u_Leieobjekt.csv' contained " .
count($datalines) . " lines";
-
- foreach ($datalines as $data) {
-
- if(count($data) <= 34)
- {
- continue;
- }
-
- //If the composite differs in terms of object
number the custom address should be set (default false)
- $set_custom_address = false;
-
- //Retrieve the title for the responsibility
area we are importing (to hande the respoonsibility areas differently)
- $title =
$socontract->get_responsibility_title($this->location_id);
-
- // Variable for the location code (objektnummer)
- $loc1 = null;
-
- //Three columns for detemining the correct
object number
- $object_identifier =
trim($this->decode($data[1])); //cLeieobjektnr
- $property_identifier =
trim($this->decode($data[4])); //cInstNr
- $building_identifier =
trim($this->decode($data[5])); //cByggNr
-
-
- if($title == 'contract_type_internleie')
- {
- $property_ok = false;
-
- //Priority 1: The property identifier
(most up to date)
- if(isset($property_identifier))
- {
- $correct_length_property =
strlen($property_identifier) == 4 ? true : false;
- $integer_value_property =
((int) $property_identifier) > 0 ? true : false;
- if($correct_length_property &&
$integer_value_property)
- {
- $loc1 =
$property_identifier;
- $property_ok = true;
- }
- }
-
- //Priority 2: Use the object identifier
- if(isset($object_identifier))
- {
- $correct_length =
strlen($object_identifier) == 6 ? true : false;
- $integer_value = ((int)
$object_identifier) > 0 ? true : false;
-
- if($correct_length &&
$integer_value)
- {
- if($property_ok)
- {
- // ... add
only the building number if the property number is ok
- $loc1 = $loc1 .
"-" . substr($object_identifier, 4, 2);
- }
- else
- {
- // ... just use
the object identifier if not
- $loc1 =
substr_replace($object_identifier,"-",4,0);
- }
- }
- else
- {
- // Using non-conforming
object identifier. Gives a warning.
- $loc1 =
$object_identifier;
- $set_custom_address =
true;
- $this->warnings[] =
"Composite (internal contract) has wrong object-number ({$loc1}). Should
consist of 6 numbers. Setting custom address.";
- }
- }
- else if($property_ok)
- {
- //If no object number, only
property number
- $set_custom_address = true;
- $this->warnings[] = "Composite
(internal contract) has no object-number ({$object_identifier}). Using property
identifier. Setting custom address.";
- }
-
- if(!isset($loc1))
- {
- // No data exist to determine
the object number
- $this->warnings[] = "No data
exist to determine the object number. Setting custom address.";
- $set_custom_address = true;
- }
- }
- else if($title == 'contract_type_eksternleie')
- {
- // Two forms for object number
(xxxx.xxxx) AND (xxxx.xxxxxx.xxxx)
- $parts =
explode('.',$object_identifier);
-
- for( $i = 0; $i < count($parts); $i++)
- {
- $parts[$i] = trim($parts[$i]);
- }
-
- if(count($parts) == 2) // (xxxx.xxxx)
- {
- //Checking parts for correct
length
- $correct_length1 =
strlen($parts[0]) == 4 ? true : false;
- $correct_length2 =
strlen($parts[1]) == 4 ? true : false;
-
- if($correct_length1 &&
$correct_length2)
- {
- //If the first part
contains any characters from the alphabet
-
if(!is_numeric($parts[0]))
- {
- // ... relace
the punctuation with an '-'
- $loc1 =
$parts[0] . "-" . $parts[1];
- }
- }
- }
- else if(count($parts) == 3) //
(xxxx.xxxxxx.xxxx)
- {
- $correct_length =
strlen($parts[1]) == 6 ? true : false;
- $correct_length_property =
strlen($property_identifier) == 4 ? true : false;
-
- if($correct_length &&
is_numeric($parts[1]))
- {
-
if(isset($property_identifier) && $correct_length_property)
- {
- // ... add
only the building number if the property number is ok
- $loc1 =
$property_identifier . "-" . substr($parts[1], 4, 2);
- }
- else
- {
- // ... insert a
'-' at position 4 if not
- $loc1 =
substr_replace($parts[1],"-",4,0);
- }
- }
- }
-
- // If the object identifier is
non-conforming
-
- // Alernative 1: Try to use the buiding
identifier
- if(!isset($loc1) &&
isset($building_identifier))
- {
- $correct_length =
strlen($building_identifier) == 6 ? true : false;
- if($correct_length &&
is_numeric($building_identifier))
- {
- $loc1 =
substr_replace($building_identifier,"-",4,0);
- $set_custom_address =
true;
- $this->warnings[] =
"Composite (external) lacks conforming object number ({$object_identifier}).
Using building identifier ({$loc1}). Setting custom address.";
- }
- }
-
- // Alternative 2: Try to use the
property identifier
- if(!isset($loc1) &&
isset($property_identifier))
- {
- $correct_length =
strlen($property_identifier) == 4 ? true : false;
- if($correct_length)
- {
- //Give a warning
- $loc1 =
$property_identifier;
- $set_custom_address =
true;
- $this->warnings[] =
"Composite (external) lacks conforming object number ({$object_identifier}).
Using property identifier ({$loc1}). Setting custom address.";
- }
- }
-
- // Alternative 3: Use the
non-conforming object number
- if(!isset($loc1))
- {
- $loc1 = $object_identifier;
- $set_custom_address = true;
- $this->warnings[] = "Composite
(external) lacks data to create an object number. Using non-conforming object
number ({$loc1}) Setting custom address.";
- }
- }
- else if($title == 'contract_type_innleie')
- {
- $correct_length =
strlen($building_identifier) == 6 ? true : false;
- $integer_value = ((int)
$building_identifier) > 0 ? true : false;
- $correct_length_property =
strlen($property_identifier) == 4 ? true : false;
- if($correct_length && $integer_value)
- {
- if(isset($property_identifier)
&& $correct_length_property)
- {
- // ... add only the
building number if the property number is ok
- $loc1 =
$property_identifier . "-" . substr($building_identifier, 4, 2);
- }
- else
- {
- $loc1 =
substr_replace($building_identifier,"-",4,0);
-
- }
- }
- else if(isset($property_identifier) &&
$correct_length_property)
- {
- // ... add only the building
number if the property number is ok
- $loc1 = $property_identifier;
- $set_custom_address = true;
- $this->warnings[] = "Composite
(innleie) has non-conforming building identifier ({$building_identifier}).
Using property identifier instead ({$loc1}). Setting custom address.";
- }
-
- if(!isset($loc1))
- {
- $loc1 = $object_identifier;
- $set_custom_address = true;
- $this->warnings[] = "Composite
(innleie) lacks building identifier/property identifier
({$building_identifier}/{$property_identifier}). Using object identifier
instead ({$loc1}). Setting custom address.";
- }
- }
- else
- {
- $this->errors[] = "The type of import
({$title}) is invalid";
- }
-
- $composite = new rental_composite();
-
- // Use the first address line as name if no name
- $name = $this->decode($data[26]);
//cLeieobjektnavn
- $address1 = $this->decode($data[6]);
//cAdresse1
- if(!isset($name)){
- $name = $address1;
- }
-
- if($set_custom_address)
- {
- // Set address
-
$composite->set_custom_address_1($address1);
-
$composite->set_custom_address_2($this->decode($data[7]));
-
$composite->set_custom_postcode($this->decode($data[8]));
-
$composite->set_has_custom_address(true);
- }
-
- $composite->set_name($name);
-
$composite->set_description($this->decode($data[3]));
//cLeieobjektBeskrivelse
- $composite->set_object_type_id($this->decode($data[25]));
//nLeieobjektTypeId
- $composite->set_area($this->decode($data[2]));
//nMengde
- $composite->set_is_active($data[19] == "-1");
//bTilgjengelig
-
- // Store composite
- if ($socomposite->store($composite)) {
- // Add composite to collection of
composite so we can refer to it later.
- $composites[$data[0]] =
$composite->get_id();
-
- // Add units only if composite stored
ok.
- $res = $sounit->store(new
rental_unit(null, $composite->get_id(), new rental_property_location($loc1,
null)));
- $this->messages[] = "Successfully added
composite " . $composite->get_name() . " (" . $composite->get_id() . ")";
- if($res)
- {
- $this->messages[] =
"Successfully added unit " . $loc1 . " to composite (" . $composite->get_id() .
")";
- }
- } else {
- $this->errors[] = "Failed to store
composite " . $composite->get_name();
- }
- }
-
- $this->messages[] = "Successfully imported " .
count($composites) . " composites (" . (time() - $start_time) . " seconds)";
-
- return $composites;
- }
-
- protected function import_rentalobject_to_contract()
- {
- $start_time = time();
- $rentalobject_to_contract = array();
- $datalines = $this->getcsvdata($this->path .
"/u_Leieobjekt_Kontrakt.csv");
- $this->messages[] = "Read 'u_Leieobjekt_Kontrakt.csv'
file in " . (time() - $start_time) . " seconds";
- $this->messages[] = "'u_Leieobjekt_Kontrakt.csv'
contained " . count($datalines) . " lines";
-
- foreach ($datalines as $data) {
- // Array with Facilit Contract ID => Facilit
composite ID
- $rentalobject_to_contract[$data[1]] = $data[0];
- }
-
- $this->messages[] = "Successfully imported " .
count($rentalobject_to_contract) . " contract to composite relations";
-
- return $rentalobject_to_contract;
- }
-
- /**
- * Step 4: import the contracts from the file 'u_Kontrakt.csv'
- * @param $composites array mapping facilit ids and protico
ids for composites
- * @param $rentalobject_to_contract array mapping
composites and contracts
- * @param $parties array mapping party ids
- * @param $default_values the default accounts and
project numbers
- * @return array of contracts
- */
- protected function import_contracts($composites,
$rentalobject_to_contract, $parties, $default_values)
- {
- $start_time = time();
- $socontract = rental_socontract::get_instance();
- $contracts = array();
- $datalines = $this->getcsvdata($this->path .
"/u_Kontrakt.csv");
-
- $this->messages[] = "Read 'u_Kontrakt.csv' file in " .
(time() - $start_time) . " seconds";
- $this->messages[] = "'u_Kontrakt.csv' contained " .
count($datalines) . " lines";
-
- // Old->new ID mapping
- $contract_types = array(
- 2 => 2, // "Internleie - innleid" -> Innleie
- 3 => 1, // "Internleie - egne" -> Egne
- 4 => 8, // "Tidsbegrenset" -> Annen (ekstern)
- 5 => 4, // "Internleie - KF" -> KF
- 12=> 6, // "Eksten Feste" -> Feste
- 13=> 7, // "Ekstern Leilighet" -> Leilighet
- 14=> 8, // "Ekstern Annen" -> Annen
- 15=> 3, // "Intern - I-kontrakt" -> Inversteringskontrakt
- 17=> NULL, // "Innleie" -> null
- 18=> 8, // "Ekstern KF" -> Annen
- 19=> 8 // "Ekstern I-kontrakt" -> Annen
- );
-
- foreach ($datalines as $data) {
- // Skip this contract if its data is incomplete
- if(count($data) <= 27)
- {
- continue;
- }
-
- // Create a new contract object
- $contract = new rental_contract();
-
- //Set the contract dates
- $date_start =
is_numeric(strtotime($this->decode($data[3]))) ?
strtotime($this->decode($data[3])) : null;
- $date_end =
is_numeric(strtotime($this->decode($data[4]))) ?
strtotime($this->decode($data[4])) : null;
- $contract->set_contract_date(new
rental_contract_date($date_start,$date_end));
-
- // Set the old contract identifier
-
$contract->set_old_contract_id($this->decode($data[5])); //cKontraktnr
-
- // Set the contract biling term
- $term = $data[10];
//nTermin
- switch ($term) {
- case 1: // Monthly
- $contract->set_term_id(1);
- break;
- case 2: // Quarterly
- $contract->set_term_id(4);
- break;
- case 4: // Half-year
- $contract->set_term_id(3);
- break;
- case 5: // Yearly
- $contract->set_term_id(2);
- break;
- }
-
- // Report non-conforming price periods
- $price_period = $data[14];
//nPrisPeriode
(4=month, 8=year)
- if ($price_period == 4) {
- // The price period is month. We
ignore this but print a warning.
- $this->warnings[] = "Price period of
contract " . $contract->get_old_contract_id() . " is month. Ignored.";
- //echo "<br/>Price period of contract "
. $contract->get_old_contract_id() . " is month. Ignored.";
- }
- elseif($price_period == 5) {
- // The price period is 5, which is unknown. We ignore
this but print a warning.
- $this->warnings[] = "Price period of
contract " . $contract->get_old_contract_id() . " is unknown (value: 5).
Ignored.";
- //echo "<br/>Price period of contract "
. $contract->get_old_contract_id() . " is unknown (value: 5). Ignored.";
- }
-
- $contract_status = $data[6];
- if($contract_status == 3) { // Report contracts under
dismissal. Send warning if contract status is '3' (Under avslutning)
- $this->warnings[] = "Status of contract " .
$contract->get_old_contract_id() . " is '".lang('contract_under_dismissal')."'";
- }
- else if($contract_status == 1) { // Report
contracts under plannning. Send warning if contract status is '1' (Under
planlegging)
- $this->warnings[] = "Status of contract " .
$contract->get_old_contract_id() . " is 'Under planlegging'";
- }
- else if($contract_status == 2) { //Test: if
the contract is running; is import date within the contract period
- if($date_start != null && time() <
$date_start)
- {
- $this->warnings[] = "Status of
contract " . $contract->get_old_contract_id() . " is 'Løpende' but the start
date is in the future.";
- }
- else if($date_end != null && time() >
$date_end)
- {
- $this->warnings[] = "Status of
contract " . $contract->get_old_contract_id() . " is 'Løpende' but the end date
is in the past.";
- }
- }
- //Test that the contracts end date is in the past if the
contract has status Ended
- else if($contract_status == 4){
- if($date_end == null || time() < $date_end)
- {
- $this->warnings[] = "Status of
contract " . $contract->get_old_contract_id() . " is 'Avsluttet' but the end
date not set or in the future.";
- }
- }
-
-
- // Set the billing start date for the contract
- $billing_start_date =
is_numeric(strtotime($this->decode($data[16]))) ?
strtotime($this->decode($data[16])) : null;
- $contract->set_billing_start_date($billing_start_date);
-
- // Deres ref.
-
$contract->set_invoice_header($this->decode($data[17]));
//cFakturaRef
-
$contract->set_comment($this->decode($data[18]));
//cMerknad
-
$contract->set_contract_type_id($contract_types[$this->decode($data[1])]);
//
-
- // Set the location identifier (responsibiity
area)
- $contract->set_location_id($this->location_id);
-
- // Get the composite identifier for the
composite included in this contract
- $composite_id =
$composites[$rentalobject_to_contract[$data[0]]];
-
- // Retrieve the title for the responsibility area we are
importing (to hande the respoonsibility areas differently)
- $title =
$socontract->get_responsibility_title($this->location_id);
-
- // For external contract types the rented area resides on the
composite ...
- if($title == 'contract_type_eksternleie') {
- if($composite_id)
- {
- $socomposite = rental_socomposite::get_instance();
-
$contract->set_rented_area($socomposite->get_area($composite_id));
- }
- }
- else if($title == 'contract_type_innleie')
- {
- $rented_area_on_contract = $this->decode($data[21]);
- if(isset($rented_area_on_contract) &&
$rented_area_on_contract > 0)
- {
-
$contract->set_rented_area($rented_area_on_contract);
- }
- else
- {
- if($composite_id)
- {
- $socomposite =
rental_socomposite::get_instance();
-
$contract->set_rented_area($socomposite->get_area($composite_id));
- }
- }
- }
- else
- {
- // ... and for others contract types the rented area
resides on the contract
- $contract->set_rented_area($this->decode($data[21]));
- }
-
-
- // Retrieve default values for accounts and project numbers
- if($title == 'contract_type_eksternleie')
- {
- $type_id =
$contract->get_contract_type_id();
- if(!in_array($type_id, array(6,7,8)))
- {
-
$contract->set_contract_type_id(8);
- }
- }
- else if($title == 'contract_type_internleie')
- {
- //Set default account in/out and
project numbers for internal contracts
-
$contract->set_account_in($default_values['account_in']);
-
$contract->set_account_out($default_values['account_out']);
-
$contract->set_project_id($default_values['project_number']);
-
- // Ansvar/Tjenestested: F.eks:
080400.13000
- $ansvar_tjeneste =
$this->decode($data[26]);
//cSikkerhetsTekst
- $ansvar_tjeneste_components =
explode(".", $ansvar_tjeneste);
- if(count($ansvar_tjeneste_components)
== 2)
- {
-
$contract->set_responsibility_id($ansvar_tjeneste_components[0]);
-
$contract->set_service_id($ansvar_tjeneste_components[1]);
- }
- else
- {
- $this->warnings[] = "The
contract (internal) " . $contract->get_old_contract_id() . " lacks service and
responsibility ids";
- }
- }
-
- // Store contract
- if ($socontract->store($contract)) {
- // Map contract ids in Facilit and PE
contract id (should be the same)
- $contracts[$data[0]] =
$contract->get_id();
-
- // Check if this contract has a
composite and if so add rental composite to contract
- if
(!$this->is_null($rentalobject_to_contract[$data[0]]) &&
!$this->is_null($composite_id)) {
-
$socontract->add_composite($contract->get_id(), $composite_id);
- }
-
- // Check if this contract has a
contract part and if so add party to contract
- if (!$this->is_null($data[2])) {
//nPersonForetakId
- $party_id =
$parties[$this->decode($data[2])];
-
$socontract->add_party($contract->get_id(), $party_id);
- // Set this party to be the
contract invoice recipient
-
$socontract->set_payer($contract->get_id(), $party_id);
- }
-
- $this->messages[] = "Successfully added
contract (" . $contract->get_id() . "/". $contract->get_old_contract_id() .")";
- } else {
- $this->errors[] = "Failed to store
contract " . $this->decode($data[5]);
- }
- }
-
- $this->messages[] = "Successfully imported " .
count($contracts) . " contracts. (" . (time() - $start_time) . " seconds)";
- return $contracts;
- }
-
- protected function import_contract_price_items($contracts)
- {
- $start_time = time();
- $soprice_item = rental_soprice_item::get_instance();
- $socontract_price_item =
rental_socontract_price_item::get_instance();
- $socontract = rental_socontract::get_instance();
-
- // Read priselementdetaljkontrakt list first so we can
create our complete price items in the next loop
- // This is an array keyed by the main price item ID
- $detail_price_items = array();
- $datalines = $this->getcsvdata($this->path .
"/u_PrisElementDetaljKontrakt.csv");
-
- $this->messages[] = "Read
'u_PrisElementDetaljKontrakt.csv' file in " . (time() - $start_time) . "
seconds";
- $this->messages[] = "'u_PrisElementDetaljKontrakt.csv'
contained " . count($datalines) . " lines";
-
- foreach ($datalines as $data) { //Felt
fra 'PrisElementDetaljKontrakt'
- if(count($data) <= 10)
- {
- continue;
- }
-
-
- if(isset($detail_price_items[$data[1]]))
- {
- // Update existing detail only start
date is later than existing start date detail
- if (!$this->is_null($data[4])) {
- $detail_date =
strtotime($this->decode($data[4]));
- if($detail_date >
$detail_price_items[$data[1]]['date_start'])
- {
-
$detail_price_items[$data[1]]['date_start'] = $detail_date;
-
$detail_price_items[$data[1]]['amount'] = str_replace(',','.',$data[3]);
-
$detail_price_items[$data[1]]['price'] = str_replace(',','.',$data[2]);
- }
- }
- }
- else
- {
- //Create a row in the array holding the
details (price, amount, dates) for the price item
- $detail_price_items[$data[1]] =
//nPrisElementId
- array(
- 'price' =>
str_replace(',','.',$data[2]), //nPris
- 'amount' =>
str_replace(',','.',$data[3]), //nMengde
- 'date_start' => null,
//dGjelderFra
- 'date_end' => null
//dGjelderTil
- );
-
- if (!$this->is_null($data[4])) {
-
$detail_price_items[$data[1]]['date_start'] =
strtotime($this->decode($data[4]));
- }
- if (!$this->is_null($data[5])) {
-
$detail_price_items[$data[1]]['date_end'] = strtotime($this->decode($data[5]));
- }
- }
- }
-
- $datalines = $this->getcsvdata($this->path .
"/u_PrisElementKontrakt.csv");
-
- $this->messages[] = "Read 'u_PrisElementKontrakt.csv'
file in " . (time() - $start_time) . " seconds";
- $this->messages[] = "'u_PrisElementKontrakt.csv'
contained " . count($datalines) . " lines";
-
- //Retrieve the title for the responsibility area we are
importing (to hande the respoonsibility areas differently)
- $title =
$socontract->get_responsibility_title($this->location_id);
- //If we are importing price items for 'Innleie', we
have a default price item in the 'Prisbok' with agresso-id 'INNLEIE'
- if($title == 'contract_type_innleie'){
- $admin_price_item =
$soprice_item->get_single_with_id('INNLEIE');
- }
-
- foreach ($datalines as $data) {
- if(count($data) <= 24)
- {
- continue;
- }
-
- /* If we are importing contract price items for
external or internal:
- * - see if a pricebook element exist
- */
- if($title != 'contract_type_innleie')
- {
- // The Agresso-ID is unique for price
items
- $id = $this->decode($data[12]);
//cVarenr
- $admin_price_item = null;
- if(isset($id) && $id != '')
- {
- $admin_price_item =
$soprice_item->get_single_with_id($id);
- }
- else
- {
- $admin_price_item =
$soprice_item->get_single_with_id('UNKNOWN');
- }
- }
-
- // Get the facilit price item id so that we can
retrieve the price item details
- $facilit_id = $this->decode($data[0]);
//nPrisElementId
-
- /* Create a new pricebook price item if one
does not exist in the pricebook; store it if it has a new unique agresso-id.
- * Note: First price item with unique
agresso-id determines title, area or "nr of items", and the price (from the
price item details) */
- if ($admin_price_item == null) {
- $admin_price_item = new
rental_price_item();
-
$admin_price_item->set_title($this->decode($data[3]));
//cPrisElementNavn
- $admin_price_item->set_agresso_id($id);
//cVareNr
- // This assumes 1 for AREA, and
anything else for count, even blanks
-
$admin_price_item->set_is_area($this->decode($data[4]) == '1' ? true : false);
//nMengdeTypeId
- // This assumes -1 for adjustable, and
anything else for not adjustable, even blanks
-
$admin_price_item->set_is_adjustable($this->decode($data[17]) == '-1' ? true :
false); //bRegulerbar
- // Get the price for this price item
-
$admin_price_item->set_price($detail_price_items[$facilit_id]['price']);
-
$admin_price_item->set_responsibility_id($this->location_id);
-
- if(isset($id))
- {
-
$soprice_item->store($admin_price_item);
- $this->messages[] = "Stored
price item ({$id}) with title " . $admin_price_item->get_title() . " in
'Prisbok'";
- }
- }
- else{
- //check type on price item (not is_area
and data[4]=1, or is_area and data[4] != 1)
- if($admin_price_item->is_area() &&
$this->decode($data[4] != '1')){
- $this->warnings[] = "Price item
({$admin_price_item->get_agresso_id()}) - " . $admin_price_item->get_title() .
" - on contract {$contracts[$this->decode($data[1])]} is stored as area price
item, but has record indicating it is not an area price item!";
- }
- else if(!$admin_price_item->is_area()
&& $this->decode($data[4] == '1')){
- $this->warnings[] = "Price item
({$admin_price_item->get_agresso_id()}) - " . $admin_price_item->get_title() .
" - on contract {$contracts[$this->decode($data[1])]} is stored as non-area
price item, but has record indicating it is an area price item!";
- }
- }
-
- $contract_id =
$contracts[$this->decode($data[1])]; //nKontraktId
-
- if ($contract_id) {
- // Create a new contract price item
that we can tie to our contract
- $price_item = new
rental_contract_price_item();
-
- // Retrieve the contract
- $contract =
$socontract->get_single($contract_id);
-
- // Set cLonnsArt for price item as
contract reference
-
$contract->set_reference($this->decode($data[13]));
-
- // The contract price item title should
be the same as in the price book for internal
- if($title == 'contract_type_internleie')
- {
-
$price_item->set_title($admin_price_item->get_title());
- }
- else
- {
- // ... and overridden by the
price item for innleie and external
-
$price_item->set_title($data[3]);
- }
-
- // Set the price book element's
agresso-id and type (area/piece)
-
$price_item->set_agresso_id($admin_price_item->get_agresso_id());
-
- // If the price item is unknown do not
use the 'is_area' from the price book
- if($admin_price_item->get_agresso_id()
!= 'UNKNOWN')
- {
-
$price_item->set_is_area($admin_price_item->is_area());
- }
- else
- {
-
$price_item->set_is_area($this->decode($data[4]) == '1' ? true : false);
- }
-
- // Get the price for the price item
details
-
$price_item->set_price($detail_price_items[$facilit_id]['price']);
-
- // Give a warning if a contract has a price element of
type area with are like 1
- if($price_item->is_area() &&
($detail_price_items[$facilit_id]['amount'] == '1'))
- {
- $this->warnings[] = "Contract " .
$contract->get_old_contract_id() . " has a price item of type area with amount
like 1";
- }
-
- // Tie this price item to its parent
admin price item
-
$price_item->set_price_item_id($admin_price_item->get_id());
-
- if ($admin_price_item->is_area()) {
-
- $rented_area = $contract->get_rented_area();
- if(isset($rented_area))
- {
- if($detail_price_items[$facilit_id]['amount']
!= $rented_area)
- {
- if($rented_area == 0)
- {
-
$contract->set_rented_area($detail_price_items[$facilit_id]['amount']);
- $this->warnings[] = "Price item
{$id} - (Facilit ID {$facilit_id}) has area " .
$detail_price_items[$facilit_id]['amount']
- . " while contract {$contract_id}
already has rented area set to 0. Using rented area from price item.";
- }
- else
- {
- $this->warnings[] = "Price item
{$id} - (Facilit ID {$facilit_id}) has area " .
$detail_price_items[$facilit_id]['amount']
- . " while contract {$contract_id}
already has rented area {$rented_area}. Using rented area on contract.";
- }
- }
- }
- else
- {
- //Store price item area on contract if the
contract has no area (not from contract)
-
$contract->set_rented_area($detail_price_items[$facilit_id]['amount']);
- $this->message[] = "Price item {$id} - (Facilit
ID {$facilit_id}) has area " . $detail_price_items[$facilit_id]['amount']
- . " while contract {$contract_id}
already no area {$rented_area}. Using rented area on price item.";
-
- //Store the contract
- $socontract->store($contract);
- }
-
-
- // Set the the contract area on the price item
-
$price_item->set_area($contract->get_rented_area());
-
- //Calculate the total price for the price item
- $item_area = $price_item->get_area();
- $item_price = $price_item->get_price();
- $price_item->set_total_price($item_area *
$item_price);
-
- }
- else
- {
-
$price_item->set_count($detail_price_items[$facilit_id]['amount']);
- $item_count =
$price_item->get_count();
- $item_price = $price_item->get_price();
-
$price_item->set_total_price($item_count * $item_price);
- }
-
-
-
$price_item->set_date_start($detail_price_items[$facilit_id]['date_start']);
-
$price_item->set_date_end($detail_price_items[$facilit_id]['date_end']);
-
- // Tie the price item to the contract
it belongs to
-
$price_item->set_contract_id($contract_id);
-
- // Tie this price item to its parent
admin price item
-
$price_item->set_price_item_id($admin_price_item->get_id());
-
- //update contract with adjustment share
- $adjustment_share =
$this->decode($data[18]); //nReguleringsandel
- if($adjustment_share != null &&
$adjustment_share > 0){
-
$socontract->update_adjustment_share($contract_id, $adjustment_share);
- }
-
- // .. and save
-
if($socontract_price_item->import($price_item)) {
- $this->messages[] = "Successfully imported price item
({$id}) for contract {$contract_id}";
- }
- else {
- $this->warnings[] = "Could not store price item
({$id}) - " . $price_item->get_title();
- }
- } else {
- $this->warnings[] = "Skipped price item
with no contract attached: " . join(", ", $data);
- }
- }
- $this->messages[] = "Imported contract price items. ("
. (time() - $start_time) . " seconds)";
- return true;
- }
-
- protected function import_events($contracts,
$regulation_id_location_id)
- {
- $start_time = time();
-
- $sonotification = rental_sonotification::get_instance();
- $socontract = rental_socontract::get_instance();
-
- $datalines = $this->getcsvdata($this->path .
"/u_Hendelse.csv");
-
- $this->messages[] = "Read 'u_Hendelse.csv' file in " .
(time() - $start_time) . " seconds";
- $this->messages[] = "'u_Hendelse.csv' contained " .
count($datalines) . " lines";
-
- foreach ($datalines as $data) {
- $type_id = $data[2];
-
- $date_array =
explode(".",$this->decode($data[7]));
- if(count($date_array) == 3)
- {
- $y = $date_array[2];
- $m = $date_array[1];
- $d = $date_array[0];
- $date = strtotime($y."-".$m."-".$d);
- }
-
- //Which contract the event is linked to
- $contract_id =
$contracts[$this->decode($data[1])];
-
- if(!isset($contract_id) || $contract_id <= 0)
- {
- //This event is not bound to a contract
that is part of the currently importing respensibiliry area
- continue;
- }
-
- $location_id = $this->location_id;
-
- // Add event description to title
- $title = $this->decode($data[3]);
- if (!$this->is_null($data[4])) {
- $title .= " " . $this->decode($data[4]);
- }
-
- //Contract ending event
- if($type_id == '3')
- {
- if(isset($date) && is_numeric($date) &&
$contract_id > 0)
- {
- $con =
$socontract->get_single($contract_id);
-
if($con->get_contract_date()->has_end_date())
- {
- $old_end_date =
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
$con->get_contract_date()->get_end_date());
- $this->errors[] =
"Contract ({$con->get_old_contract_id()}) will be updated with 'contract end'
event (DATE: {$this->decode($data[7])}) event though it already had an end date
{$old_end_date} ";
- }
-
-
- //Set date as contract date
-
$socontract->update_contract_end_date($contract_id, $date);
- $this->messages[] =
"Successfully updated contract end date to '" . $this->decode($data[7]) . "'
for contract {$contract_id} (originaly had end date
({$con->get_contract_date()->get_end_date()}))";
- if(isset($title) && $title !=
'')
- {
- $this->warnings[] =
"Contract event of type end date (" . $this->decode($data[7]) . ") for contract
{$contract_id} has a title {$title} which is not imported";
- }
- }
- else
- {
- $this->warnings[] = "Skipped
contract end event with either no date ({$this->decode($data[7])}) or not valid
contract identifier ({$contract_id}/{$this->decode($data[1])})";
- }
-
- }
- else if($type_id == '4')// Event of type
notification
- {
- if(isset($title) && $title != '' &&
$contract_id > 0)
- {
- // All is good, store
notification
- $notification = new
rental_notification(null, null, $location_id, $contract_id, $date, $title);
- if
($sonotification->store($notification)) {
- $this->messages[] =
"Successfully imported notification '" . $notification->get_message() . "' for
contract {$contract_id}";
- } else {
- $this->errors[] =
"Error importing notification " . $notification->get_message() . " for contract
{$contract_id}";
- }
- }
- else
- {
- $this->warnings[] = "Skipped
notification with no valid contract identifer ({$contract_id} or no title
({$title})";
- }
- }
- else if($type_id == '1') { //price
adjustment
- $adjusted = $this->decode($data[8]);
-
- //$reg_id_generated =
$this->decode($data[9]);
- $reg_id_regulated =
$this->decode($data[10]);
-
- /*if(isset($reg_id_generated) &&
$reg_id_generated != '')
- {
-
$regulation_id_location_id[$reg_id_generated] = $location_id;
- }*/
-
- if(isset($reg_id_regulated) &&
$reg_id_regulated != '')
- {
-
$regulation_id_location_id[$reg_id_regulated] = $location_id;
- }
-
-
- if($adjusted == 0 || $adjusted == '0'){
- $current_year = date('Y');
- $date_tmp = explode(".",
$this->decode($data[7]));
- if(count($date_tmp) == 3){
- $year = $date_tmp[2];
- $interval =
$this->decode($data[6]);
- $last_adjusted_year =
$year - $interval;
- }else{
- $last_adjusted_year = 0;
- }
-
- $contract_id =
$contracts[$data[1]];
- if($last_adjusted_year <=
$current_year){
- //update last adjusted
on contract.
- if($contract_id > 0 &&
$last_adjusted_year > 0){
- //$result =
$socontract->update_adjustment_year_interval($contract_id, $last_adjusted_year,
$interval);
- if($result)
- {
-
$this->messages[] = "Successfully imported regulation. Set last regulation year
'" . $last_adjusted_year . "' for contract {$contract_id} with interval
'{$interval}'";
- }
- }
- }
- else{
- $this->warnings[] =
"Skipping adjustment on contract ({$contract_id}) because the contract's last
adjusted year ({$last_adjusted_year}) is after current year '{$current_year}'.";
- }
- }
- }
- else // Unknown event type
- {
- $this->warnings[] = "Unknow event type
" . $type_id . " for contract {$contract_id} with title/description {$title}";
- }
- unset($date);
- }
-
- //loop through events once more to update previous
adjustments
- foreach ($datalines as $data) {
- $type_id = $data[2];
-
- if($type_id == 1 || $type_id == '1') { //price
adjustment
- $adjusted = $this->decode($data[8]);
- if($adjusted == -1 || $adjusted ==
'-1'){
- $current_year = date('Y');
- $date_tmp = explode(".",
$this->decode($data[7]));
- if(count($date_tmp) == 3){
- $year = $date_tmp[2];
- }else{
- $year = 0;
- }
-
- //update last adjusted and
interval on contract.
- $contract_id =
$contracts[$data[1]];
- if($year <= $current_year){
- if($contract_id > 0 &&
$year > 0){
- //$result =
$socontract->update_adjustment_year($contract_id, $year);
- if($result)
- {
-
$this->messages[] = "Successfully updated regulation information. Set last
regulation year '" . $year . "' for contract {$contract_id}";
- }
- }
- }
- else{
- $this->warnings[] =
"Skipping adjustment-year update on contract {$contract_id} because last
adjusted year is after {$current_year}.";
- }
- }
- }
- }
-
- $this->messages[] = "Imported events. (" . (time() -
$start_time) . " seconds)";
- return $regulation_id_location_id;
- }
-
- protected function import_adjustment_information()
- {
- $start_time = time();
-
- $sonotification = rental_sonotification::get_instance();
- $socontract = rental_socontract::get_instance();
-
- $datalines = $this->getcsvdata($this->path .
"/u_Hendelse.csv");
-
- $this->messages[] = "Read 'u_Hendelse.csv' file in " .
(time() - $start_time) . " seconds";
- $this->messages[] = "'u_Hendelse.csv' contained " .
count($datalines) . " lines";
-
- foreach ($datalines as $data) {
- $type_id = $data[2];
-
- $date_array =
explode(".",$this->decode($data[7]));
- if(count($date_array) == 3)
- {
- $y = $date_array[2];
- $m = $date_array[1];
- $d = $date_array[0];
- $date = strtotime($y."-".$m."-".$d);
- }
-
- //Which contract the event is linked to
- $contract_id = $this->decode($data[1]);
-
- if(!isset($contract_id) || $contract_id <= 0)
- {
- //This event is not bound to a contract
that is part of the currently importing respensibiliry area
- continue;
- }
-
- $location_id = $this->location_id;
-
- // Add event description to title
- $title = $this->decode($data[3]);
- if (!$this->is_null($data[4])) {
- $title .= " " . $this->decode($data[4]);
- }
-
- if($type_id == '1') { //price adjustment
- $adjusted = $this->decode($data[8]);
-
- if($adjusted == 0 || $adjusted == '0'){
- $current_year = date('Y');
- $date_tmp = explode(".",
$this->decode($data[7]));
- if(count($date_tmp) == 3){
- $year = $date_tmp[2];
- $interval =
$this->decode($data[6]);
- $last_adjusted_year =
$year - $interval;
- }else{
- $last_adjusted_year = 0;
- }
-
-
- if($last_adjusted_year <=
$current_year){
- ;
- //update last adjusted
on contract.
- if($contract_id > 0 &&
$last_adjusted_year > 0){
-
//$this->messages[] = "Should set year {$last_adjusted_year} and interval
{$interval} on contract {$contract_id}";
- $result =
$socontract->update_adjustment_year_interval($contract_id, $last_adjusted_year,
$interval);
- if($result)
- {
-
$this->messages[] = "Successfully imported regulation. Set last regulation year
'" . $last_adjusted_year . "' for contract {$contract_id} with interval
'{$interval}'";
- }
- else
- {
-
$this->errors[] = "Error importing regulation. Tried to set last regulation
year '" . $last_adjusted_year . "' for contract {$contract_id} with interval
'{$interval}'";
- }
- }
- }
- else{
- $this->warnings[] =
"Skipping adjustment on contract ({$contract_id}) because the contract's last
adjusted year ({$last_adjusted_year}) is after current year '{$current_year}'.";
- }
- }
- }
- }
-
- //loop through events once more to update previous
adjustments
- foreach ($datalines as $data) {
- $type_id = $data[2];
-
- if($type_id == 1 || $type_id == '1') { //price
adjustment
- $adjusted = $this->decode($data[8]);
- if($adjusted == -1 || $adjusted ==
'-1'){
-
- $current_year = date('Y');
- $date_tmp = explode(".",
$this->decode($data[7]));
- if(count($date_tmp) == 3){
- $year = $date_tmp[2];
- }else{
- $year = 0;
- }
- //update last adjusted and
interval on contract.
- if($year <= $current_year){
-
- $contract_id =
$this->decode($data[1]);
-
- if(isset($contract_id)
&& $contract_id > 0 && $year > 0){
- $result =
$socontract->update_adjustment_year($contract_id, $year);
- if($result)
- {
-
$this->messages[] = "Successfully updated regulation information. Set last
regulation year '" . $year . "' for contract {$contract_id}";
- }
- else
- {
-
$this->errors[] = "Error updating regulation information. Tried to set last
regulation year '" . $last_adjusted_year . "' for contract {$contract_id} with
interval '{$interval}'";
- }
- }
- }
- else{
- $this->warnings[] =
"Skipping adjustment-year update on contract {$contract_id} because last
adjusted year is after {$current_year}.";
- }
- }
- }
- }
- }
-
- protected function import_adjustments($contracts,
$regulation_id_location_id)
- {
- $start_time = time();
-
- $soadjustment = rental_soadjustment::get_instance();
-
- $datalines = $this->getcsvdata($this->path .
"/u_Regulering.csv");
-
- $this->messages[] = "Read 'u_Regulering.csv' file in "
. (time() - $start_time) . " seconds";
- $this->messages[] = "'u_Regulering.csv' contained " .
count($datalines) . " lines";
-
- foreach ($datalines as $data) {
- if(count($data) <= 8)
- {
- continue;
- }
-
- $adjustment = new rental_adjustment();
- $regulation_id = $this->decode($data[0]);
//nReguleringId
- $loc_id =
$regulation_id_location_id[$regulation_id];
-
- if(isset($loc_id) && $loc_id != '')
- {
-
$adjustment->set_responsibility_id($loc_id);
- }
- else
- {
- $this->messages[] = "This adjustment '"
. $regulation_id . "' could not be linked to this responsibility area. Date
({$this->decode($data[1])}), Text ({$this->decode($data[4])}), Interval
({$this->decode($data[2])})";
- continue;
- }
-
- $date_array =
explode(".",$this->decode($data[1])); //dAktuellDato
- if(count($date_array) == 3)
- {
- $y = $date_array[2];
- $m = $date_array[1];
- $d = $date_array[0];
- $date = strtotime($y."-".$m."-".$d);
- }
- $adjustment->set_adjustment_date($date);
-
- $description_array = explode(" ",
$this->decode($data[4])); //cBeskrivelse
- $number = end($description_array);
- $percent = substr($number, 0,strlen($number)-2);
- $percent = str_replace(',', '.', $percent);
- $adjustment->set_percent($percent);
-
-
$adjustment->set_interval($this->decode($data[2]));
-
- $adjustment->set_new_price(0);
- $adjustment->set_price_item_id(0);
-
-
if(!$soadjustment->adjustment_exist($adjustment))
- {
- // All is good, store notification
- if ($soadjustment->store($adjustment)) {
- $this->messages[] =
"Successfully imported adjustment: Date ({$this->decode($data[1])}), Percent
({$adjustment->get_percent()}), Interval ({$adjustment->get_interval()})";
- } else {
- $this->errors[] = "Error
importing adjustment: Date ({$this->decode($data[1])}), Percent
({$adjustment->get_percent()}), Interval ({$adjustment->get_interval()})";
- }
- }
- else
- {
- $this->messages[] = "Adjustment already
exist: Date ({$this->decode($data[1])}), Percent
({$adjustment->get_percent()}), Interval ({$adjustment->get_interval()})";
- }
- }
-
- $this->messages[] = "Imported adjustments. (" . (time()
- $start_time) . " seconds)";
- return true;
- }
-
protected function getcsvdata($path, $skipfirstline = true)
{
// Open the csv file
Modified: branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
2011-05-09 10:54:07 UTC (rev 7274)
@@ -368,4 +368,5 @@
state_2 activitycalendar no Endring
state_3 activitycalendar no Akseptert
state_4 activitycalendar no Behandlet
-state_5 activitycalendar no Avvist
\ No newline at end of file
+state_5 activitycalendar no Avvist
+activity_import activitycalendar no Importer aktiviteter
\ No newline at end of file
Modified: branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/setup/setup.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -1,6 +1,6 @@
<?php
$setup_info['activitycalendar']['name'] = 'activitycalendar';
- $setup_info['activitycalendar']['version'] = '0.1';
+ $setup_info['activitycalendar']['version'] = '0.1.1';
$setup_info['activitycalendar']['app_order'] = 60;
$setup_info['activitycalendar']['enable'] = 1;
$setup_info['activitycalendar']['app_group'] = 'office';
Modified:
branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/setup/tables_current.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -8,7 +8,7 @@
'group_id' => array('type' => 'int',
'precision' => 4, 'nullable' => True),
'district' => array('type' =>
'varchar','precision' => '255'),
'category' => array('type' => 'int',
'precision' => 4, 'nullable' => True),
- 'target' => array('type' => 'int', 'precision'
=> 4, 'nullable' => True),
+ 'target' => array('type' => 'varchar',
'precision' => '255'),
'office' => array('type' => 'int', 'precision'
=> 4, 'nullable' => True),
'state' => array('type' => 'int', 'precision'
=> 4, 'nullable' => True),
'description' => array('type' =>
'varchar','precision' => '255'),
Copied:
branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php (from
rev 7273, trunk/activitycalendar/setup/tables_update.inc.php)
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php
(rev 0)
+++ branches/Version-1_0-branch/activitycalendar/setup/tables_update.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -0,0 +1,18 @@
+<?php
+
+ /**
+ * Update Activitycalendar from v 0.1 to 0.1.1
+ */
+
+ $test[] = '0.1';
+ function activitycalendar_upgrade0_1()
+ {
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('activity_activity','target',array(
+ 'type' => 'varchar',
+ 'precision' => '255'
+ ));
+
+ $GLOBALS['setup_info']['activitycalendar']['currentver'] =
'0.1.1';
+ return $GLOBALS['setup_info']['activitycalendar']['currentver'];
+ }
+?>
\ No newline at end of file
Modified:
branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -190,16 +190,19 @@
</dt>
<dd>
<?php
- $current_target_id =
$activity->get_target();
+ $current_target_ids =
$activity->get_target();
+ $current_target_id_array=explode(",",
$current_target_ids);
+ //echo
$current_target_id_array[0]."*".$current_target_id_array[1];
if ($editable)
{
?>
- <select name="target">
+ <select name="target[]"
size="<?php echo count($targets)?>" multiple="multiple">
<option value="0">Ingen
målgruppe valgt</option>
<?php
- foreach($targets as
$target)
+ foreach($targets as $t)
{
- echo "<option
".($current_target_id == $target->get_id() ? 'selected="selected"' : "")."
value=\"{$target->get_id()}\">".$target->get_name()."</option>";
+ //echo
in_array($target->get_id(), $current_target_id_array);
+ echo "<option
value=\"{$t->get_id()}\" ".(in_array($t->get_id(), $current_target_id_array) ?
'selected' : "").">".$t->get_name()."</option>";
}
?>
</select>
@@ -208,7 +211,12 @@
else
{
if($activity->get_target()){
- echo
$act_so->get_target_name($activity->get_target());
+ $current_target_ids =
$activity->get_target();
+
$current_target_id_array=explode(",", $current_target_ids);
+
foreach($current_target_id_array as $curr_target)
+ {
+ echo
$act_so->get_target_name($curr_target).'<br/>';
+ }
}
}
?>
Copied:
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php
(from rev 7273, trunk/activitycalendar/templates/base/activity_import.php)
===================================================================
---
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php
(rev 0)
+++
branches/Version-1_0-branch/activitycalendar/templates/base/activity_import.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -0,0 +1,69 @@
+<?php
+ include("common.php");
+?>
+<script>
+
+</script>
+<?php echo activitycalendar_uicommon::get_page_error($error) ?>
+<?php echo activitycalendar_uicommon::get_page_message($message) ?>
+
+<h1><img src="<?php echo ACTIVITYCALENDAR_IMAGE_PATH
?>images/32x32/actions/document-save.png" /> <?php echo lang('activity_import')
?></h1>
+
+<div id="messageHolder"></div>
+
+<form action="index.php?menuaction=activitycalendar.uiimport.index"
method="post">
+ <fieldset>
+ <label for="path">Path to activities file:</label> <input
type="text" name="import_path" id="import_path" value="<?php echo $import_path
?>" size="60"/>
+ <label for="district">Location for the imported
activities:</label>
+ <select name="district" id="district">
+ <?php
+ $districts =
activitycalendar_soactivity::get_instance()->select_district_list();
+ foreach($districts as $district)
+ {
+ echo "<option
value=\"{$district['id']}\">".$district['name']."</option>";
+ }
+ ?>
+ </select>
+ <input type="submit" name="importsubmit" value="<?php echo
$button_label; ?>" <?php if ($button_label == "Import done") { echo '
disabled="disabled"'; } ?> />
+
+ </fieldset>
+ <!-- <fieldset>
+ <input type="submit" name="cancelsubmit" value="<?php echo
lang('import_reset'); ?>" />
+ </fieldset>
+ -->
+
+ <?php if ($messages || $warnings || $errors) { ?>
+ <h2><?php echo lang('import_log_messages') ?></h2>
+
+ <?php if ($errors) { ?>
+ <ul>
+ <?php
+ foreach ($errors as $error) {
+ echo '<li class="error">Error: ' . $error .
'</li>';
+ }
+ ?>
+ </ul>
+ <?php } ?>
+
+ <?php if ($warnings) { ?>
+ <ul>
+ <?php
+ foreach ($warnings as $warning) {
+ echo '<li class="warning">Warning: ' . $warning
. '</li>';
+ }
+ ?>
+ </ul>
+ <?php } ?>
+
+ <?php if ($messages) { ?>
+ <ul>
+ <?php
+ foreach ($messages as $message) {
+ echo '<li class="info">' . $message . '</li>';
+ }
+ ?>
+ </ul>
+ <?php } ?>
+
+ <?php } ?>
+</form>
\ No newline at end of file
Modified: branches/Version-1_0-branch/property/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/setup.inc.php 2011-05-09
10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/property/setup/setup.inc.php 2011-05-09
10:54:07 UTC (rev 7274)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.617';
+ $setup_info['property']['version'] = '0.9.17.618';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php
2011-05-09 10:51:38 UTC (rev 7273)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php
2011-05-09 10:54:07 UTC (rev 7274)
@@ -5244,6 +5244,45 @@
/**
+ * Update property version from 0.9.17.616 to 0.9.17.617
+ * Sync fm_locations with fm_locationX
+ *
+ */
+
+ $test[] = '0.9.17.617';
+ function property_upgrade0_9_17_617()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT max(level) as
level FROM fm_locations",__LINE__,__FILE__);
+ $GLOBALS['phpgw_setup']->oProc->next_record();
+ $level = $GLOBALS['phpgw_setup']->oProc->f('level');
+ $ids = array();
+ for($i=1;$i<($level+1);$i++)
+ {
+ $sql = "SELECT id FROM fm_locations LEFT JOIN
fm_location{$i} ON fm_locations.location_code = fm_location{$i}.location_code"
+ . " WHERE fm_location{$i}.location_code
IS NULL AND LEVEL = {$i}";
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ while($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $ids[] =
$GLOBALS['phpgw_setup']->oProc->f('id');
+ }
+ }
+
+ if($ids)
+ {
+ $sql = 'DELETE FROM fm_locations WHERE id IN(' .
implode(',', $ids) . ')';
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.618';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
+ /**
* Update property version from 0.9.17.607 to 0.9.17.608
* Add more room for address at tickets
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7274] Merge 7265:7273 from trunk,
Sigurd Nes <=