/** * Get a static reference to the storage object associated with this model object * * @return rental_soparty the storage object */ public static function get_instance() { if (self::$so == null) { self::$so = CreateObject('activitycalendar.sogroup'); } return self::$so; }
public function serialize_for_export() { $so_org = activitycalendar_soorganization::get_instance(); $date_format = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']; if (isset($this->group_id) && $this->get_group_id() > 0) { if ($this->get_new_group()) { $group_name = activitycalendar_sogroup::get_instance()->get_group_name_local($this->get_group_id()); $this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_local_contact_persons($this->get_group_id(), true)); $contact_1 = activitycalendar_socontactperson::get_instance()->get_group_contact_name_local($this->get_contact_person_1()->get_id()); if ($this->get_contact_person_2()) { $contact_2 = activitycalendar_socontactperson::get_instance()->get_group_contact_name_local($this->get_contact_person_2()->get_id()); } else { $contact_2 = null; } $desc = activitycalendar_sogroup::get_instance()->get_description_local($this->get_group_id()); } else { $group_name = activitycalendar_sogroup::get_instance()->get_group_name($this->get_group_id()); $this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($this->get_group_id(), true)); $contact_1 = activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_1()->get_id()); if ($this->get_contact_person_2()) { $contact_2 = activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_2()->get_id()); } else { $contact_2 = null; } $desc = activitycalendar_sogroup::get_instance()->get_description($this->get_group_id()); } $o_id = $this->get_organization_id(); if ($this->get_new_org()) { $org_name = $so_org->get_organization_name_local($o_id); $org_homepage = $so_org->get_organization_homepage_local($o_id); } else { $org_name = $so_org->get_organization_name($o_id); $org_homepage = $so_org->get_organization_homepage($o_id); } } else { if (isset($this->organization_id) && $this->get_organization_id() > 0) { if ($this->get_new_org()) { $org_name = activitycalendar_soorganization::get_instance()->get_organization_name_local($this->get_organization_id()); $org_homepage = $so_org->get_organization_homepage_local($this->get_organization_id()); $this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_local_contact_persons($this->get_organization_id())); $contact_1 = activitycalendar_socontactperson::get_instance()->get_org_contact_name_local($this->get_contact_person_1()->get_id()); if ($this->get_contact_person_2()) { $contact_2 = activitycalendar_socontactperson::get_instance()->get_org_contact_name_local($this->get_contact_person_2()->get_id()); } else { $contact_2 = null; } $desc = activitycalendar_soorganization::get_instance()->get_description_local($this->get_organization_id()); } else { $org_name = activitycalendar_soorganization::get_instance()->get_organization_name($this->get_organization_id()); $org_homepage = $so_org->get_organization_homepage($this->get_organization_id()); $this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($this->get_organization_id())); $contact_1 = activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_1()->get_id()); if ($this->get_contact_person_2()) { $contact_2 = activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_2()->get_id()); } else { $contact_2 = null; } $desc = activitycalendar_soorganization::get_instance()->get_description($this->get_organization_id()); } } else { $contact_1 = ""; $contact_2 = ""; } } if ($this->get_internal_arena() && $this->get_internal_arena() > 0) { $arena_name = activitycalendar_soarena::get_instance()->get_building_name($this->get_internal_arena()); } else { $arena_name = activitycalendar_soarena::get_instance()->get_arena_name($this->get_arena()); } $activity_district = $this->get_so()->get_district_name($this->get_district()); $contact_person_1_name = $this->get_contact_person_1() ? $this->get_contact_person_1()->get_name() : ''; $contact_person_1_phone = $this->get_contact_person_1() ? $this->get_contact_person_1()->get_phone() : ''; $contact_person_1_mail = $this->get_contact_person_1() ? $this->get_contact_person_1()->get_email() : ''; $contact_person_2_name = $this->get_contact_person_2() ? $this->get_contact_person_2()->get_name() : ''; $contact_person_2_phone = $this->get_contact_person_2() ? $this->get_contact_person_2()->get_phone() : ''; $contact_person_2_mail = $this->get_contact_person_2() ? $this->get_contact_person_2()->get_email() : ''; return array('id' => $this->get_id(), 'title' => $this->get_title(), 'organization_id' => $org_name, 'organization_homepage' => $org_homepage, 'group_id' => $group_name, 'district' => $activity_district, 'office' => activitycalendar_soactivity::get_instance()->get_office_name($this->get_office()), 'category' => $this->get_so()->get_category_name($this->get_category()), 'state' => lang('state_' . $this->get_state()), 'description' => $desc, 'arena' => $arena_name, 'time' => $this->get_time(), 'contact_person_1_name' => $contact_person_1_name, 'contact_person_1_phone' => $contact_person_1_phone, 'contact_person_1_mail' => $contact_person_1_mail, 'contact_person_2_name' => $contact_person_2_name, 'contact_person_2_phone' => $contact_person_2_phone, 'contact_person_2_mail' => $contact_person_2_mail, 'special_adaptation' => $this->get_special_adaptation(), 'last_change_date' => $this->get_last_change_date() != NULL ? date($date_format, $this->get_last_change_date()) : '', 'frontend' => $this->get_frontend()); }
public function get_organization_groups() { $GLOBALS['phpgw_info']['flags']['noheader'] = true; $GLOBALS['phpgw_info']['flags']['nofooter'] = true; $GLOBALS['phpgw_info']['flags']['xslt_app'] = false; $org_id = phpgw::get_var('orgid'); $group_id = phpgw::get_var('groupid'); $returnHTML = "<option value='0'>Ingen gruppe valgt</option>"; if ($org_id) { $groups = activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, null, array('org_id' => $org_id)); foreach ($groups as $group) { if (isset($group)) { //$res_g = $group->serialize(); $selected = ""; if ($group_id && $group_id > 0) { $gr_id = (int) $group_id; if ($gr_id == (int) $group->get_id()) { $selected_group = " selected"; } } $group_html[] = "<option value='" . $group->get_id() . "'" . $selected_group . ">" . $group->get_name() . "</option>"; } } $html = implode(' ', $group_html); $returnHTML = $returnHTML . ' ' . $html; } return $returnHTML; //return "<option>Ingen gruppe valgt</option>"; }
echo lang('edit_contact_info_group'); ?> </a> <?php } } ?> <?php ?> <?php } else { if ($activity->get_group_id()) { if ($activity->get_new_group()) { echo activitycalendar_sogroup::get_instance()->get_group_name_local($activity->get_group_id()); } else { echo activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id()); } } } ?> </dd> <dt> <label><?php echo lang('contact_info'); ?> </label> <br/><?php echo lang('contact_info_helptext'); ?> </dt> <?php
protected function populate(int $activity_id, &$activity) { if ($activity == null) { $activity = new activitycalendar_activity((int) $activity_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'), 'string')); $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'))); $activity->set_new_group($this->unmarshal($this->db->f('new_group', 'bool'))); if ($activity->get_group_id() && $activity->get_group_id() > 0) { if ($activity->get_new_group()) { $contacts = activitycalendar_sogroup::get_instance()->get_contacts_local($activity->get_group_id()); $activity->set_contact_persons($contacts); //$org_tmp = activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id()); //$activity->set_organization_id($org_tmp); } else { $contacts = activitycalendar_sogroup::get_instance()->get_contacts($activity->get_group_id()); $activity->set_contact_persons($contacts); $org_tmp = activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id()); $activity->set_organization_id($org_tmp); } } else { if ($activity->get_organization_id() && $activity->get_organization_id() > 0) { if ($activity->get_new_org()) { $contacts = activitycalendar_soorganization::get_instance()->get_contacts_local($activity->get_organization_id()); $activity->set_contact_persons($contacts); } else { $contacts = activitycalendar_soorganization::get_instance()->get_contacts($activity->get_organization_id()); $activity->set_contact_persons($contacts); } } } } return $activity; }
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; } }