/** * Public method. Add new activity. */ public function add() { //$GLOBALS['phpgw']->redirect_link('/activitycalendarfrontend/index.php', array('menuaction' => 'activitycalendarfrontend.uiactivity.edit', 'action' => 'new_activity')); $GLOBALS['phpgw']->js->validate_file('json', 'json', 'phpgwapi'); $c = createobject('phpgwapi.config', 'activitycalendarfrontend'); $c->read(); $config = $c->config_data; $ajaxUrl = $c->config_data['AJAXURL']; $categories = $this->so_activity->get_categories(); $targets = $this->so_activity->get_targets(); $offices = $this->so_activity->select_district_list(); $districts = $this->so_activity->get_districts(); $buildings = $this->so_arena->get_buildings(); $arenas = $this->so_arena->get(null, null, 'arena.arena_name', true, null, null, null); $organizations = $this->so_organization->get(null, null, 'org.name', true, null, null, null); $activity = new activitycalendar_activity(); $o_id = phpgw::get_var('organization_id'); $o_id_new = phpgw::get_var('organization_id_hidden'); if (isset($_POST['step_1'])) { //activity shall be registred on a new organization if ($o_id_new == "new_org") { //add new organization to internal activitycalendar organization register $org_homepage = phpgw::get_var('homepage'); if ($org_homepage == 'http://') { $org_homepage = ""; } $org_info['name'] = phpgw::get_var('orgname'); $org_info['orgnr'] = phpgw::get_var('orgno'); $org_info['homepage'] = $org_homepage; $org_info['street'] = phpgw::get_var('address'); $org_info['streetnumber'] = phpgw::get_var('number'); $org_info['zip'] = phpgw::get_var('postzip'); $org_info['postaddress'] = phpgw::get_var('postaddress'); $org_info['status'] = "new"; $o_id = $this->so_activity->add_organization_local($org_info); //add contact persons $contact1 = array(); $contact1['name'] = phpgw::get_var('org_contact1_name'); $contact1['phone'] = phpgw::get_var('org_contact1_phone'); $contact1['mail'] = phpgw::get_var('org_contact1_mail'); $contact1['org_id'] = $o_id; $contact1['group_id'] = 0; $this->so_activity->add_contact_person_local($contact1); $person_arr = $this->so_contact->get_local_contact_persons($o_id); foreach ($person_arr as $p) { $persons[] = $p; } $person_ids = $this->so_organization->get_contacts_local($o_id); $desc = phpgw::get_var('org_description'); $organization = $this->so_organization->get_organization_local($o_id); $new_org = true; $organization = $this->so_organization->get_organization_local($o_id); $person_arr = $this->so_organization->get_contacts_local_as_objects($o_id); foreach ($person_arr as $p) { //var_dump($p); $persons[] = $p; } $message = lang('organization_saved_form'); $this->render('activity_new.php', array('activity' => $activity, 'new_organization' => true, 'organization' => $organization, 'contact1' => $persons[0], 'arenas' => $arenas, 'buildings' => $buildings, 'categories' => $categories, 'targets' => $targets, 'districts' => $districts, 'offices' => $offices, 'editable' => true, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'), 'ajaxURL' => $ajaxUrl)); } else { $new_org = false; $organization = $this->so_organization->get_single($o_id); $person_arr = $this->so_contact->get(null, null, null, null, null, null, array('organization_id' => $o_id)); foreach ($person_arr as $p) { //var_dump($p); $persons[] = $p; } $activity->set_organization_id($o_id); $activity->set_description($organization->get_description()); $activity->set_contact_persons($pers); $this->render('activity_new.php', array('activity' => $activity, 'new_organization' => false, 'organization' => $organization, 'contact1' => $persons[0], 'arenas' => $arenas, 'buildings' => $buildings, 'categories' => $categories, 'targets' => $targets, 'districts' => $districts, 'offices' => $offices, 'editable' => true, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'), 'ajaxURL' => $ajaxUrl)); } } else { if (isset($_POST['save_activity'])) { $get_org_from_local = false; $new_org_group = false; $new_org = phpgw::get_var('new_organization'); if ($new_org != null && $new_org == 'yes') { $get_org_from_local = true; } if ($get_org_from_local) { $activity->set_new_org(true); //$person_arr = $this->so_contact->get_local_contact_persons($o_id); //foreach($person_arr as $p) //{ //$persons[] = $p; //} //$person_ids = $this->so_organization->get_contacts_local($o_id); //$desc = $this->so_organization->get_description_local($o_id); $organization = $this->so_organization->get_organization_local($o_id); $new_org = true; //$new_org_group = true; //Add new group for the activity $group_info['name'] = phpgw::get_var('title'); $group_info['organization_id'] = $o_id; $group_info['description'] = phpgw::get_var('description'); $group_info['status'] = "new"; $g_id = $this->so_activity->add_group_local($group_info); //add contact persons $contact1 = array(); $contact1['name'] = phpgw::get_var('contact_name'); $contact1['phone'] = phpgw::get_var('contact_phone'); $contact1['mail'] = phpgw::get_var('contact_mail'); $contact1['org_id'] = $o_id; $contact1['group_id'] = $g_id; $this->so_activity->add_contact_person_local($contact1); $person_arr = $this->so_contact->get_local_contact_persons($g_id, true); foreach ($person_arr as $p) { $persons[] = $p; } $desc = phpgw::get_var('description'); $group = $this->so_group->get_group_local($g_id); $person_ids = $this->so_group->get_contacts_local($g_id); $new_group = true; } else { if (is_numeric($o_id) && $o_id > 0) { $group_info['name'] = phpgw::get_var('title'); $group_info['organization_id'] = $o_id; $group_info['description'] = phpgw::get_var('description'); $group_info['status'] = "new"; $g_id = $this->so_activity->add_group_local($group_info); //add contact persons $contact1 = array(); $contact1['name'] = phpgw::get_var('contact_name'); $contact1['phone'] = phpgw::get_var('contact_phone'); $contact1['mail'] = phpgw::get_var('contact_mail'); $contact1['org_id'] = 0; $contact1['group_id'] = $g_id; $this->so_activity->add_contact_person_local($contact1); $person_arr = $this->so_contact->get_local_contact_persons($g_id, true); foreach ($person_arr as $p) { $persons[] = $p; } $desc = phpgw::get_var('description'); $group = $this->so_group->get_group_local($g_id); $person_ids = $this->so_group->get_contacts_local($g_id); $organization = $this->so_organization->get_single($o_id); $new_group = true; } } if (strlen($desc) > 254) { $desc = substr($desc, 0, 254); } $arena_id = phpgw::get_var('internal_arena_id'); $new_arena = phpgw::get_var('new_arena_hidden'); if ($new_arena != null && $new_arena == 'new_arena') { $arena = new activitycalendar_arena(); $arena_name = phpgw::get_var('arena_name'); $arena_address = phpgw::get_var('arena_address'); $arena_addressnumber = phpgw::get_var('arena_number'); $arena_zip_code = phpgw::get_var('arena_zip_code'); $arena_city = phpgw::get_var('arena_city'); $arena->set_arena_name($arena_name); $arena->set_address($arena_address); $arena->set_addressnumber($arena_addressnumber); $arena->set_zip_code($arena_zip_code); $arena->set_city($arena_city); $arena->set_active(true); // All is good, store arena if ($this->so_arena->store($arena)) { $arena_id = $arena->get_id(); $activity->set_arena($arena_id); } } else { $arena_arr = explode("_", $arena_id); if ($arena_arr[0] == 'i') { $activity->set_internal_arena($arena_arr[1]); } else { $activity->set_arena($arena_arr[1]); } } //... set all parameters $activity->set_title(phpgw::get_var('title')); $activity->set_organization_id($o_id); $activity->set_group_id($g_id); $activity->set_district(phpgw::get_var('district')); $activity->set_office(phpgw::get_var('office')); $activity->set_state(1); $activity->set_category(phpgw::get_var('category')); $target_array = phpgw::get_var('target'); $activity->set_target(implode(",", $target_array)); $activity->set_description($desc); $activity->set_time(phpgw::get_var('time')); $activity->set_contact_persons($persons); $activity->set_special_adaptation(phpgw::get_var('special_adaptation')); $activity->set_contact_person_2_address(phpgw::get_var('contact2_address') . ", " . phpgw::get_var('contact2_number')); $activity->set_contact_person_2_zip(phpgw::get_var('contact2_postaddress')); $activity->set_frontend(true); $activity->set_new_org($new_org); $activity->set_new_group($new_group); $target_ok = false; $district_ok = false; if ($get_org_from_local) { //update new organization with district-id from activity. $this->so_organization->update_org_district_local($organization->get_id(), $activity->get_district()); } if ($activity->get_target() && $activity->get_target() != '') { $target_ok = true; } if ($activity->get_district() && $activity->get_district() != '') { $district_ok = true; } if ($target_ok && $district_ok) { if ($this->so_activity->store($activity)) { // ... and then try to store the object $message = lang('messages_saved_form'); } else { $error = lang('messages_form_error'); } //$org_info_edit_url = self::link('/index.php' ,array('menuaction' => 'activitycalendarfrontend.uiactivity.edit_organization_values')); $GLOBALS['phpgw_info']['flags']['noframework'] = true; $this->render('activity.php', array('activity' => $activity, 'organization' => $organization, 'group' => $group, 'contact1' => $persons[0], 'arenas' => $arenas, 'buildings' => $buildings, 'categories' => $categories, 'targets' => $targets, 'districts' => $districts, 'offices' => $offices, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'), 'ajaxURL' => $ajaxUrl)); } else { if (!$target_ok) { $error .= "<br/>" . lang('target_not_selected'); } if (!$district_ok) { $error .= "<br/>" . lang('district_not_selected'); } return $this->render('activity_new.php', array('activity' => $activity, 'organizations' => $organizations, 'organization' => $organization, 'contact1' => $persons[0], 'contact2' => $persons[1], 'org_name' => $org_name, 'new_org' => $new_org, 'groups' => $groups, 'arenas' => $arenas, 'buildings' => $buildings, 'categories' => $categories, 'targets' => $targets, 'districts' => $districts, 'offices' => $offices, 'editable' => true, 'cancel_link' => $cancel_link, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'), 'ajaxURL' => $ajaxUrl)); } } else { return $this->render('activity_new_step_1.php', array('organizations' => $organizations, 'ajaxURL' => $ajaxUrl)); } } }
public function edit() { $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . lang('edit'); // Get the contract part id $activity_id = (int) phpgw::get_var('id'); $cancel_link = self::link(array('menuaction' => 'activitycalendar.uiactivities.index')); $categories = $this->so_activity->get_categories(); $targets = $this->so_activity->get_targets(); $offices = $this->so_activity->select_district_list(); $districts = $this->so_activity->get_districts(); $buildings = $this->so_arena->get_buildings(); // Retrieve the activity object or create a new one if (isset($activity_id) && $activity_id > 0) { $activity = $this->so_activity->get_single($activity_id); } else { $activity = new activitycalendar_activity(); } $new_group = $activity->get_new_group(); $g_id = phpgw::get_var('group_id'); $o_id = phpgw::get_var('organization_id'); if ($new_group) { $persons = $this->so_group->get_contacts_local($activity->get_group_id()); $desc = $this->so_group->get_description_local($activity->get_group_id()); } else { if (isset($g_id) && $g_id > 0) { $persons = $this->so_group->get_contacts($g_id); $desc = $this->so_group->get_description($g_id); } else { if (isset($o_id) && $o_id > 0) { $persons = $this->so_org->get_contacts($o_id); $desc = $this->so_org->get_description($o_id); } } } if (strlen($desc) > 254) { $desc = substr($desc, 0, 254); } $arenas = $this->so_arena->get(null, null, 'arena.arena_name', true, null, null, null); if ($activity->get_new_org()) { $org_name = $this->so_org->get_organization_name_local($activity->get_organization_id()); } else { $organizations = $this->so_org->get(null, null, 'org.name', true, null, null, null); } if ($new_group) { $group_array = $this->so_group->get(null, null, null, null, null, null, array('group_id' => $activity->get_group_id(), 'new_groups' => 'true')); //var_dump($group_array); if (count($group_array) > 0) { $keys = array_keys($group_array); $local_group = $group_array[$keys[0]]; //$group_name = $local_group->get_name(); } } else { $groups = $this->so_group->get(null, null, null, null, null, null, null); } if (isset($_POST['save_activity'])) { if (isset($activity)) { $old_state = $activity->get_state(); $new_state = phpgw::get_var('state'); // ... set all parameters $activity->set_title(phpgw::get_var('title')); $activity->set_organization_id(phpgw::get_var('organization_id')); $activity->set_group_id(phpgw::get_var('group_id')); $internal_arena = phpgw::get_var('internal_arena_id'); if (isset($internal_arena) && $internal_arena > 0) { $activity->set_arena(0); $activity->set_internal_arena($internal_arena); } else { $activity->set_arena(phpgw::get_var('arena_id')); $activity->set_internal_arena(0); } $district_array = phpgw::get_var('district'); $activity->set_district(implode(",", $district_array)); $activity->set_office(phpgw::get_var('office')); $activity->set_state($new_state); $activity->set_category(phpgw::get_var('category')); $target_array = phpgw::get_var('target'); $activity->set_target(implode(",", $target_array)); $activity->set_description($desc); $activity->set_time(phpgw::get_var('time')); $activity->set_contact_persons($persons); $activity->set_contact_person_2_address(phpgw::get_var('contact_person_2_address')); $activity->set_contact_person_2_zip(phpgw::get_var('contact_person_2_zip')); $activity->set_special_adaptation(phpgw::get_var('special_adaptation')); $target_ok = false; $district_ok = false; if ($new_state != 5) { $target_ok = true; $district_ok = true; } else { if ($activity->get_target() && $activity->get_target() != '') { $target_ok = true; } if ($activity->get_district() && $activity->get_district() != '') { $district_ok = true; } } if ($target_ok && $district_ok) { if ($this->so_activity->store($activity)) { if ($new_group) { //transfer group to booking $group_array = $this->so_group->get(null, null, null, null, null, null, array('group_id' => $activity->get_group_id(), 'new_groups' => 'true')); if (count($group_array) > 0) { $keys = array_keys($group_array); $group = $group_array[$keys[0]]; } $group_info = array(); $group_info['name'] = $group->get_name(); //new $group_info['organization_id'] = $activity->get_organization_id(); $group_info['description'] = $group->get_description(); $contacts = $this->so_contact->get_local_contact_persons($group->get_id(), true); $contact_1 = $contacts[0]; $new_group_id = $this->so_group->transfer_group($group_info); if ($new_group_id) { //update activity with new org id //add contact persons to booking $contact1 = array(); $contact1['name'] = $contact_1->get_name(); $contact1['phone'] = $contact_1->get_phone(); $contact1['mail'] = $contact_1->get_email(); $contact1['group_id'] = $new_group_id; $this->so_activity->add_contact_person_group($contact1); $message = lang('messages_saved_form'); //get organization_id for the group: $group_org_id = $this->so_group->get_orgid_from_group($new_group_id); //get affected activities and update with new org id $update_activities = $this->so_activity->get_activities_for_update($group->get_id(), true); foreach ($update_activities as $act_id) { $act = $this->so_activity->get_single($act_id); $act->set_organization_id($group_org_id); $act->set_group_id($new_group_id); $act->set_new_org(false); $act->set_new_group(false); $this->so_activity->store($act); } //set local group as stored $group->set_change_type('added'); $group->set_transferred(true); $this->so_group->update_local($group); $message = lang('messages_saved_form'); //var_dump($new_group_id); $contact_persons = $this->so_contact->get_booking_contact_persons($new_group_id, true); //var_dump(2); $cp1 = $contact_persons[0]; } } $message = lang('messages_saved_form'); } else { $error = lang('messages_form_error'); } if (isset($activity_id) && $activity_id > 0) { $activity = $this->so_activity->get_single($activity_id); } if ($old_state != $new_state && ($new_state == 3 || $new_state == 5)) { $kontor = $this->so_activity->get_office_name($activity->get_office()); $subject = lang('mail_subject_update'); $body = lang('mail_body_state_' . $new_state, $activity->get_title(), $kontor); if ($activity->get_group_id() && $activity->get_group_id() > 0) { $activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_group_id(), true)); activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_1(), $subject, $body); } else { if ($activity->get_organization_id() && $activity->get_organization_id() > 0) { $activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_organization_id())); activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_1(), $subject, $body); } } } $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'activitycalendar.uiactivities.view', 'id' => $activity->get_id(), 'saved_ok' => 'yes')); } else { if (!$target_ok) { $error .= "<br/>" . lang('target_not_selected'); } if (!$district_ok) { $error .= "<br/>" . lang('district_not_selected'); } return $this->render('activity.php', array('activity' => $activity, 'organizations' => $organizations, 'org_name' => $org_name, 'groups' => $groups, 'local_group' => $local_group, 'arenas' => $arenas, 'buildings' => $buildings, 'categories' => $categories, 'targets' => $targets, 'districts' => $districts, 'offices' => $offices, 'editable' => true, 'cancel_link' => $cancel_link, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'))); } } } $editable = true; if ($activity->get_new_org()) { $error = lang('org_not_transferred'); $editable = false; } //var_dump($local_group); return $this->render('activity.php', array('activity' => $activity, 'organizations' => $organizations, 'org_name' => $org_name, 'groups' => $groups, 'local_group' => $local_group, 'arenas' => $arenas, 'buildings' => $buildings, 'categories' => $categories, 'targets' => $targets, 'districts' => $districts, 'offices' => $offices, 'editable' => $editable, 'cancel_link' => $cancel_link, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'))); }
function get_connected_activities($org_id) { $activities = array(); $sql = "SELECT * FROM activity_activity WHERE organization_id={$org_id}"; $this->db->query($sql, __LINE__, __FILE__); while ($this->db->next_record()) { $activity = new activitycalendar_activity((int) $this->db->f('id')); $activity->set_title($this->unmarshal($this->db->f('title'), 'string')); $activity->set_organization_id($this->unmarshal($this->db->f('organization_id'), 'int')); $activity->set_group_id($this->unmarshal($this->db->f('group_id'), 'int')); $activity->set_district($this->unmarshal($this->db->f('district'), 'int')); $activity->set_office($this->unmarshal($this->db->f('office'), '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'), 'string')); $activity->set_description($this->unmarshal($this->db->f('description'), 'string')); $activity->set_arena($this->unmarshal($this->db->f('arena'), 'string')); $activity->set_internal_arena($this->unmarshal($this->db->f('internal_arena'), 'string')); $activity->set_time($this->unmarshal($this->db->f('time'), 'string')); $activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'), 'int')); $activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation', 'bool'))); $activity->set_secret($this->unmarshal($this->db->f('secret'), 'string')); $activity->set_contact_person_2_address($this->unmarshal($this->db->f('contact_person_2_address'), 'string')); $activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'), 'string')); $activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool'))); $activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool'))); $activities[] = $activity; } return $activities; }
protected function import_arenas() { $start_time = time(); $soarena = activitycalendar_soarena::get_instance(); $soactivity = activitycalendar_soactivity::get_instance(); //var_dump($_FILES['file']['name']); //var_dump($this->file); //$datalines = $this->getcsvdata($_FILES['file']['tmp_name']);; $datalines = $this->csvdata; //$datalines = $this->getcsvdata($this->file); //$activity_district = $this->district; $this->messages[] = "Read 'import_all.csv' file in " . (time() - $start_time) . " seconds"; $this->messages[] = "'importfile.csv' contained " . count($datalines) . " lines"; //$so_arena = rental_socontract::get_instance(); $db_activity = $soactivity->get_db(); $db_activity->transaction_begin(); foreach ($datalines as $data) { $arenaOK = true; $activityOK = true; unset($act_targets); unset($activity_persons); unset($activity_description); unset($org_info); unset($group_info); unset($contact_person); unset($contact1); unset($contact2); unset($contact3); unset($contact4); unset($new_group_id); $internal_arena = $this->decode($data[9]); if ($internal_arena) { $internal_arena_id = $internal_arena; $curr_arena_id = ""; } else { $arena = new activitycalendar_arena(); //8: sted, 10:adresse $arena_name = $this->decode($data[8]); $arena_address = $this->decode($data[10]); $curr_arena_id = 0; $existing_arena_id = 0; $internal_arena_id = ""; if ($arena_name) { $existing_arena_id = $soarena->get_arena_id_by_name($arena_name); if ($existing_arena_id > 0) { $curr_arena_id = $existing_arena_id; } else { $arena->set_arena_name($arena_name); $arena->set_address($arena_address); $arena->set_active(true); // All is good, store notification if ($soarena->store($arena)) { $this->messages[] = "Successfully imported arena: Name ({$arena_name})"; $curr_arena_id = $arena->get_id(); } else { $this->errors[] = "Error importing arena: Name ({$arena_name})"; $curr_arena_id = 0; $arenaOK = false; } } } else { $this->errors[] = "Error importing arena: Name not supplied"; $curr_arena_id = 0; } } $activity = new activitycalendar_activity(); $activity_title = $this->decode($data[1]); $activity_group = $this->decode($data[2]); $activity_org = $this->decode($data[3]); $activity_category = $this->decode($data[5]); $org_name_tmp = $this->decode($data[1]); if (strlen($org_name_tmp) > 50) { $org_name_tmp = substr($org_name_tmp, 0, 49); } $org_email = $this->decode($data[15]); if (strlen($org_email) > 50) { $org_email = substr($org_email, 0, 49); } $org_phone = $this->decode($data[14]); if (strlen($org_phone) > 50) { $org_phone = substr($org_phone, 0, 49); } $contact_mail_2 = $this->decode($data[21]); if (strlen($contact_mail_2) > 50) { $contact_mail_2 = substr($contact_mail_2, 0, 49); } if ($activity_category) { $activity_category = $soactivity->get_category_from_name($activity_category); } $contact1_name = $this->decode($data[13]); if (strlen($contact1_name) > 50) { $contact1_name = substr($contact1_name, 0, 49); } $contact1_phone = $this->decode($data[14]); if (strlen($contact1_phone) > 50) { $contact1_phone = substr($contact1_phone, 0, 49); } $contact2_name = $this->decode($data[17]); if (strlen($contact2_name) > 50) { $contact2_name = substr($contact2_name, 0, 49); } $contact2_phone = $this->decode($data[20]); if (strlen($contact2_phone) > 50) { $contact2_phone = substr($contact2_phone, 0, 49); } if ($activity_org) { $activity_org = $soactivity->get_orgid_from_orgno($activity_org); if ($activity_org) { //update the organization found $org_info = array(); $org_info['orgid'] = $activity_org; $org_info['name'] = $org_name_tmp; //new $org_info['homepage'] = $this->decode($data[16]); $org_info['phone'] = $org_phone; $org_info['email'] = $org_email; $org_info['description'] = $this->decode($data[6]); $org_info['street'] = $this->decode($data[10]); $org_info['zip'] = $this->decode($data[19]); $org_info['activity_id'] = $activity_category; $org_info['district'] = $this->decode($data[23]); $soactivity->update_organization($org_info); //$new_org_id = $activity_org; $soactivity->delete_contact_persons($activity_org); $contact1 = array(); $contact1['name'] = $contact1_name; $contact1['phone'] = $contact1_phone; $contact1['mail'] = $org_email; $contact1['org_id'] = $this->decode($activity_org); $soactivity->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($activity_org); $soactivity->add_contact_person_org($contact2); //group-stuff: if ($activity_group) { $group_info = array(); $group_info['organization_id'] = $activity_org; $group_info['description'] = $this->decode($data[6]); $group_info['name'] = $this->decode($data[1]); $group_info['activity_id'] = $activity_category; $new_group_id = $soactivity->add_group($group_info); $contact3 = array(); $contact3['name'] = $contact1_name; $contact3['phone'] = $contact1_phone; $contact3['mail'] = $org_email; $contact3['group_id'] = $this->decode($new_group_id); $soactivity->add_contact_person_group($contact3); $contact4 = array(); $contact4['name'] = $contact2_name; $contact4['phone'] = $contact2_phone; $contact4['mail'] = $contact_mail_2; $contact4['group_id'] = $this->decode($new_group_id); $soactivity->add_contact_person_group($contact4); $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) { unset($contact_person); $contact_person['id'] = $pers; $contact_person['name'] = $this->decode($data[11]); $contact_person['phone'] = $this->decode($data[12]); $contact_person['mail'] = $this->decode($data[13]); $contact_person['org_id'] = $this->decode($new_org_id); $soactivity->update_contact_person_org($contact_person); } */ /* $soactivity->set_org_active($activity_org); $activity_description = $this->decode($data[5]); if($activity_description) { //update description on organization $soactivity->update_org_description($activity_org, $activity_description); //var_dump(strlen($activity_description)); //if(strlen($activity_description) > 255) //{ //$activity_description = substr($activity_description,0,254); //} } */ //$activity_persons = activitycalendar_soorganization::get_instance()->get_contacts($activity_org); } else { $org_info = array(); $org_info['name'] = $org_name_tmp; //new $orgno_tmp = $this->decode($data[3]); if (strlen($orgno_tmp) > 9) { $orgno_tmp = NULL; } $org_info['orgnr'] = $orgno_tmp; $org_info['homepage'] = $this->decode($data[16]); $org_info['phone'] = $org_phone; $org_info['email'] = $org_email; $org_info['description'] = $this->decode($data[6]); $org_info['street'] = $this->decode($data[10]); $org_info['zip'] = $this->decode($data[19]); $org_info['activity_id'] = $activity_category; $org_info['district'] = $this->decode($data[23]); $new_org_id = $soactivity->add_organization($org_info); $contact1 = array(); $contact1['name'] = $contact1_name; $contact1['phone'] = $contact1_phone; $contact1['mail'] = $org_email; $contact1['org_id'] = $this->decode($new_org_id); $soactivity->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); $soactivity->add_contact_person_org($contact2); //group-stuff: if ($activity_group) { $group_info = array(); $group_info['organization_id'] = $new_org_id; $group_info['description'] = $this->decode($data[6]); $group_info['name'] = $this->decode($data[1]); $group_info['activity_id'] = $activity_category; $new_group_id = $soactivity->add_group($group_info); $contact3 = array(); $contact3['name'] = $contact1_name; $contact3['phone'] = $contact1_phone; $contact3['mail'] = $org_email; $contact3['group_id'] = $this->decode($new_group_id); $soactivity->add_contact_person_group($contact3); $contact4 = array(); $contact4['name'] = $contact2_name; $contact4['phone'] = $contact2_phone; $contact4['mail'] = $contact_mail_2; $contact4['group_id'] = $this->decode($new_group_id); $soactivity->add_contact_person_group($contact4); $activity_persons = activitycalendar_sogroup::get_instance()->get_contacts($new_group_id); } else { $activity_persons = activitycalendar_soorganization::get_instance()->get_contacts($new_org_id); } } } else { $org_info = array(); if ($activity_group && !$activity_group == '') { $org_info['name'] = $activity_group; } else { $org_info['name'] = $org_name_tmp; } //$org_info['orgnr'] = $this->decode($data[2]); $org_info['homepage'] = $this->decode($data[16]); $org_info['phone'] = $org_phone; $org_info['email'] = $org_email; $org_info['description'] = $this->decode($data[6]); $org_info['street'] = $this->decode($data[10]); $org_info['zip'] = $this->decode($data[19]); $org_info['activity_id'] = $activity_category; $org_info['district'] = $this->decode($data[23]); $new_org_id = $soactivity->add_organization($org_info); $contact1 = array(); $contact1['name'] = $contact1_name; $contact1['phone'] = $contact1_phone; $contact1['mail'] = $org_email; $contact1['org_id'] = $this->decode($new_org_id); $soactivity->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); $soactivity->add_contact_person_org($contact2); //group-stuff: if ($activity_group) { $group_info = array(); $group_info['organization_id'] = $new_org_id; $group_info['description'] = $this->decode($data[6]); $group_info['name'] = $this->decode($data[1]); $group_info['activity_id'] = $activity_category; $new_group_id = $soactivity->add_group($group_info); $contact3 = array(); $contact3['name'] = $contact1_name; $contact3['phone'] = $contact1_phone; $contact3['mail'] = $org_email; $contact3['group_id'] = $this->decode($new_group_id); $soactivity->add_contact_person_group($contact3); $contact4 = array(); $contact4['name'] = $contact2_name; $contact4['phone'] = $contact2_phone; $contact4['mail'] = $contact_mail_2; $contact4['group_id'] = $this->decode($new_group_id); $soactivity->add_contact_person_group($contact4); $activity_persons = activitycalendar_sogroup::get_instance()->get_contacts($new_group_id); } else { $activity_persons = activitycalendar_soorganization::get_instance()->get_contacts($new_org_id); } } $activity_adapted = $this->decode($data[4]); $activity_target = $this->decode($data[7]); //var_dump($activity_target); if ($activity_target) { $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); } $activity_day = $this->decode($data[11]); $activity_time = $this->decode($data[12]); $activity_update_date = $this->decode($data[22]); 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); //var_dump($activity_updated_date); } } $activity_district = $this->decode($data[23]); if ($activity_district) { $activity_district = $soactivity->get_district_from_name($activity_district); } $activity_contact_person_2_address = $this->decode($data[18]); $activity_contact_person_2_zip = $this->decode($data[19]); if ($activity_title) { $activity->set_title($activity_title); $activity->set_organization_id($activity_org); $activity->set_group_id($new_group_id); $activity->set_category($activity_category); $activity->set_target($activity_target); $activity->set_description($activity_description); $activity->set_arena($curr_arena_id); $activity->set_internal_arena($internal_arena_id); $activity->set_state(3); $activity->set_time($activity_day . ' ' . $activity_time); if ($activity_adapted) { $activity->set_special_adaptation(true); } $activity->set_office($this->office); $activity->set_district($activity_district); $activity->set_contact_person_2_address($activity_contact_person_2_address); $activity->set_contact_person_2_zip($activity_contact_person_2_zip); $activity->set_last_change_date($activity_updated_date); if ($activity_persons) { //set contact persons $activity->set_contact_persons($activity_persons); } //var_dump($activity); // All is good, store activity if ($soactivity->import_activity($activity)) { $this->messages[] = "Successfully imported activity: Title ({$this->decode($data[1])})"; } else { $this->errors[] = "Error importing activity: Title ({$this->decode($data[1])})"; $activityOK = false; } } } if ($arenaOK && $activityOK) { $this->messages[] = "Imported activities. (" . (time() - $start_time) . " seconds)"; $db_activity->transaction_commit(); return true; } else { if (!$arenaOK) { $this->messages[] = "Import of arenas failed. (" . (time() - $start_time) . " seconds)"; } else { if (!$activityOK) { $this->messages[] = "Import of activities failed. (" . (time() - $start_time) . " seconds)"; } else { $this->messages[] = "Import of activities/arenas failed. (" . (time() - $start_time) . " seconds)"; } } $db_activity->transaction_abort(); return false; } }