[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7545] Fixed import
From: |
Erik Holm-Larsen |
Subject: |
[Fmsystem-commits] [7545] Fixed import |
Date: |
Thu, 01 Sep 2011 06:53:58 +0000 |
Revision: 7545
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7545
Author: erikhl
Date: 2011-09-01 06:53:57 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
Fixed import
Modified Paths:
--------------
trunk/activitycalendar/inc/class.soorganization.inc.php
trunk/activitycalendar/inc/class.uiimport.inc.php
trunk/activitycalendar/inc/class.uiorganization.inc.php
Modified: trunk/activitycalendar/inc/class.soorganization.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.soorganization.inc.php 2011-09-01
06:35:54 UTC (rev 7544)
+++ trunk/activitycalendar/inc/class.soorganization.inc.php 2011-09-01
06:53:57 UTC (rev 7545)
@@ -317,5 +317,116 @@
}
return $organization;
}
+
+ function add_organization_local($organization)
+ {
+ $name = $organization->get_name();
+ $orgnr = $organization->get_organization_number();
+ $homepage = $organization->get_homepage();
+ $phone = $organization->get_phone();
+ $email = $organization->get_email();
+ $description = $organization->get_description();
+ $street = $organization->get_address();
+/* $zip = $organization->get_();
+ if($zip && strlen($zip) > 5)
+ {
+ $zip_code = substr($zip,0,4);
+ $city = substr($zip, 5);
+ }
+ else
+ {
+ $zip_code = '';
+ $city = '';
+ }*/
+ $district = $organization->get_district();
+
+ $values[] = "NAME='{$name}'";
+ $values[] = "HOMEPAGE='{$homepage}'";
+ $values[] = "PHONE='{$phone}'";
+ $values[] = "EMAIL='{$email}'";
+ $values[] = "DESCRIPTION='{$description}'";
+ $values[] = "STREET='{$street}'";
+ //$values[] = "'{$zip_code}'";
+ //$values[] = "'{$city}'";
+ $values[] = "ORGNO='{$orgnr}'";
+ $values[] = "DISTRICT='{$district}'";
+ $vals = implode(',',$values);
+
+ //var_dump("INSERT INTO activity_organization ({$cols}) VALUES
({$vals})");
+ $sql = "UPDATE activity_organization SET {$vals} WHERE
ID={$organization->get_id()}";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if(isset($result))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function transfer_organization($org_info)
+ {
+ $name = $org_info['name'];
+ $orgnr = $org_info['orgnr'];
+ $homepage = $org_info['homepage'];
+ $phone = $org_info['phone'];
+ $email = $org_info['email'];
+ $description = $org_info['description'];
+ $street = $org_info['street'];
+ $zip = $org_info['zip'];
+ if($zip && strlen($zip) > 5)
+ {
+ $zip_code = substr($zip,0,4);
+ $city = substr($zip, 5);
+ }
+ else
+ {
+ $zip_code = '';
+ $city = '';
+ }
+ $district = $org_info['district'];
+ $activity_id = $org_info['activity_id'];
+ $show_in_portal = 1;
+
+ $columns[] = 'name';
+ $columns[] = 'homepage';
+ $columns[] = 'phone';
+ $columns[] = 'email';
+ $columns[] = 'description';
+ $columns[] = 'street';
+ $columns[] = 'zip_code';
+ $columns[] = 'city';
+ $columns[] = 'district';
+ $columns[] = 'organization_number';
+ $columns[] = 'activity_id';
+ $columns[] = 'show_in_portal';
+ $cols = implode(',',$columns);
+
+ $values[] = "'{$name}'";
+ $values[] = "'{$homepage}'";
+ $values[] = "'{$phone}'";
+ $values[] = "'{$email}'";
+ $values[] = "'{$description}'";
+ $values[] = "'{$street}'";
+ $values[] = "'{$zip_code}'";
+ $values[] = "'{$city}'";
+ $values[] = "'{$district}'";
+ $values[] = "'{$orgnr}'";
+ $values[] = $this->marshal($activity_id, 'int');
+ $values[] = $show_in_portal;
+ $vals = implode(',',$values);
+
+ $sql = "INSERT INTO bb_organization ({$cols}) VALUES ({$vals})";
+ $result = $this->db->query($sql, __LINE__, __FILE__);
+ if(isset($result))
+ {
+ return $this->db->get_last_insert_id('bb_organization',
'id');
+ }
+ else
+ {
+ return 0;
+ }
+ }
}
?>
Modified: trunk/activitycalendar/inc/class.uiimport.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiimport.inc.php 2011-09-01 06:35:54 UTC
(rev 7544)
+++ trunk/activitycalendar/inc/class.uiimport.inc.php 2011-09-01 06:53:57 UTC
(rev 7545)
@@ -341,7 +341,7 @@
$contact2['mail'] =
$contact_mail_2;
$contact2['org_id'] =
$this->decode($activity_org);
$soactivity->add_contact_person_org($contact2);
-
+/*
//group-stuff:
if($activity_group)
{
@@ -369,9 +369,9 @@
$activity_persons =
activitycalendar_sogroup::get_instance()->get_contacts($new_group_id);
}
else
- {
+ {*/
$activity_persons =
activitycalendar_soorganization::get_instance()->get_contacts($activity_org);
- }
+ /*}*/
/*
foreach($activity_persons as
$pers)
{
@@ -400,7 +400,7 @@
*/
//$activity_persons =
activitycalendar_soorganization::get_instance()->get_contacts($activity_org);
}
- else //add org unit
+/* else //add org unit
{
$org_info = array();
$org_info['name'] =
$org_name_tmp; //new
@@ -465,9 +465,9 @@
{
$activity_persons =
activitycalendar_soorganization::get_instance()->get_contacts($new_org_id);
}
- }
+ }*/
}
- else //add org unit without org no
+/* else //add org unit without org no
{
$org_info = array();
if($activity_group && !$activity_group
== '')
@@ -535,6 +535,7 @@
$activity_persons =
activitycalendar_soorganization::get_instance()->get_contacts($new_org_id);
}
}
+ */
$activity_adapted = $this->decode($data[4]);
$activity_target = $this->decode($data[7]);
Modified: trunk/activitycalendar/inc/class.uiorganization.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiorganization.inc.php 2011-09-01
06:35:54 UTC (rev 7544)
+++ trunk/activitycalendar/inc/class.uiorganization.inc.php 2011-09-01
06:53:57 UTC (rev 7545)
@@ -68,6 +68,9 @@
$GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('edit');
$id = (int)phpgw::get_var('id');
$type = phpgw::get_var('type');
+ unset($org_info);
+ unset($contact1);
+ unset($contact2);
if($type)
{
//var_dump($type);
@@ -77,7 +80,7 @@
$keys = array_keys($group_array);
$group = $group_array[$keys[0]];
}
- if(isset($_POST['save_organization'])) // The user has
pressed the save button
+ if(isset($_POST['save_group'])) // The user has pressed
the save button
{
$orgno = phpgw::get_var('orgno');
$district = phpgw::get_var('org_district');
@@ -87,7 +90,7 @@
$address = phpgw::get_var('address');
$desc = phpgw::get_var('org_description');
}
- else if(isset($_POST['store_organization'])) // The
user has pressed the store button
+ else if(isset($_POST['store_group'])) // The user has
pressed the store button
{
$orgno = phpgw::get_var('orgno');
$district = phpgw::get_var('org_district');
@@ -112,6 +115,7 @@
//var_dump('org');
$so = activitycalendar_soorganization::get_instance();
$so_activity =
activitycalendar_soactivity::get_instance();
+ $so_contact =
activitycalendar_socontactperson::get_instance();
$org_array = $so->get(null, null, null, null, null,
null, array('id' => $id, 'changed_orgs' => 'true'));
if(count($org_array)>0){
$keys = array_keys($org_array);
@@ -130,7 +134,7 @@
$org->set_address(phpgw::get_var('address'));
$org->set_description(phpgw::get_var('org_description'));
- if($so->store($org))
+ if($so->update_local_org($org))
{
$message = lang('messages_saved_form');
}
@@ -138,9 +142,6 @@
{
$error = lang('messages_form_error');
}
-
-
-
}
else if(isset($_POST['store_organization'])) // The
user has pressed the store button
{
@@ -149,8 +150,54 @@
$homepage = phpgw::get_var('homepage');
$email = phpgw::get_var('email');
$phone = phpgw::get_var('phone');
- $address = phpgw::get_var('address');
+ $address_tmp = phpgw::get_var('address');
+ //phpgw::get_var('address') . ' ' .
phpgw::get_var('number') . ', ' . phpgw::get_var('postaddress');
+ $address_array = explode(",",$address_tmp);
$desc = phpgw::get_var('org_description');
+
+ $org_info = array();
+ $org_info['name'] = $org->get_name(); //new
+ $orgno_tmp = $orgno;
+ if(strlen($orgno_tmp) > 9)
+ {
+ $orgno_tmp = NULL;
+ }
+ $org_info['orgnr'] = $orgno_tmp;
+
+ $org_info['homepage'] = $homepage;
+ $org_info['phone'] = $phone;
+ $org_info['email'] = $email;
+ $org_info['description'] = $description;
+ $org_info['street'] = $address_array[0];
+ $org_info['zip'] = $address_array[1];
+ $org_info['activity_id'] = '';
+ $org_info['district'] = $district;
+
+ $new_org_id =
$so->transfer_organization($org_info);
+ if($new_org_id)
+ {
+ //update activity with new org id
+ //add contact persons to booking
+ $contact1 = array();
+ $contact1['name'] = $contact1_name;
+ $contact1['phone'] = $contact1_phone;
+ $contact1['mail'] = $contact1_email;
+ $contact1['org_id'] =
$this->decode($new_org_id);
+
$so_contact->add_contact_person_org($contact1);
+
+ $contact2 = array();
+ $contact2['name'] = $contact2_name;
+ $contact2['phone'] = $contact2_phone;
+ $contact2['mail'] = $contact_mail_2;
+ $contact2['org_id'] =
$this->decode($new_org_id);
+
$so_contact->add_contact_person_org($contact2);
+ $message = lang('messages_saved_form');
+ }
+ else
+ {
+ $error = lang('messages_form_error');
+ }
+
}
$data = array
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7545] Fixed import,
Erik Holm-Larsen <=