/** * Get a static reference to the storage object associated with this model object * * @return activitycalendar_soparty the storage object */ public static function get_instance() { if (self::$so == null) { self::$so = CreateObject('activitycalendar.soarena'); } return self::$so; }
public function __construct() { parent::__construct(); $this->bo_org = CreateObject('booking.boorganization'); $this->bo_group = CreateObject('booking.bogroup'); $this->so_org = activitycalendar_soorganization::get_instance(); $this->so_group = activitycalendar_sogroup::get_instance(); $this->so_contact = activitycalendar_socontactperson::get_instance(); $this->so_activity = activitycalendar_soactivity::get_instance(); $this->so_arena = activitycalendar_soarena::get_instance(); self::set_active_menu('activitycalendar::activities'); $config = CreateObject('phpgwapi.config', 'activitycalendar'); $config->read(); $this->config_booking = CreateObject('phpgwapi.config', 'booking'); $this->config_booking->read(); $this->validator = CreateObject('phpgwapi.EmailAddressValidator'); $this->debug = false; }
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 query() { /* if(!$this->isExecutiveOfficer()) { $this->render('permission_denied.php'); return; } */ if ($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0) { $user_rows_per_page = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']; } else { $user_rows_per_page = 10; } // YUI variables for paging and sorting $start_index = phpgw::get_var('startIndex', 'int'); $num_of_objects = phpgw::get_var('results', 'int', 'GET', $user_rows_per_page); $sort_field = phpgw::get_var('sort'); $sort_ascending = phpgw::get_var('dir') == 'desc' ? false : true; // Form variables $search_for = phpgw::get_var('query'); $search_type = phpgw::get_var('search_option'); // Create an empty result set $result_objects = array(); $result_count = 0; //Retrieve the type of query and perform type specific logic $query_type = phpgw::get_var('type'); $exp_param = phpgw::get_var('export'); $export = false; if (isset($exp_param)) { $export = true; $num_of_objects = null; } //var_dump($query_type); switch ($query_type) { case 'all_arenas': $filters = array('arena_type' => phpgw::get_var('arena_type'), 'active' => phpgw::get_var('active')); $result_objects = activitycalendar_soarena::get_instance()->get($start_index, $num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, $filters); $object_count = activitycalendar_soarena::get_instance()->get_count($search_for, $search_type, $filters); break; } //var_dump($result_objects); //Create an empty row set $rows = array(); foreach ($result_objects as $result) { if (isset($result)) { // ... add a serialized result $rows[] = $result->serialize(); } } // ... add result data $result_data = array('results' => $rows, 'total_records' => $object_count); if (!$export) { //Add action column to each row in result table array_walk($result_data['results'], array($this, 'add_actions'), array($query_type)); } return $this->yui_results($result_data, 'total_records', 'results'); }
/** * Public method. */ function get_address_search() { $search_string = phpgw::get_var('search'); //var_dump($search_string); return activitycalendar_soarena::get_instance()->get_address($search_string); }
echo activitycalendar_soarena::get_instance()->get_building_name($activity->get_internal_arena()); ?> </dd> <?php } if ($activity->get_arena()) { ?> <dt> <label for="arena"><?php echo lang('arena'); ?> </label> </dt> <dd> <?php echo activitycalendar_soarena::get_instance()->get_arena_name($activity->get_arena()); ?> </dd> <?php } ?> <dt> <label for="district"><?php echo lang('district'); ?> </label> </dt> <dd> <?php if ($activity->get_district()) { $current_district_ids = $activity->get_district();
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; } }