/**
  * 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.soorganization');
     }
     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());
 }
 /**
  * (non-PHPdoc)
  * @see rental/inc/rental_uicommon#query()
  */
 public function query()
 {
     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', 'string', 'GET', 'identifier');
     $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;
     //Create an empty result set
     $parties = array();
     $exp_param = phpgw::get_var('export');
     $export = false;
     if (isset($exp_param)) {
         $export = true;
         $num_of_objects = null;
     }
     //Retrieve the type of query and perform type specific logic
     $type = phpgw::get_var('type');
     $changed_org = false;
     $changed_group = false;
     switch ($type) {
         case 'changed_organizations':
             $filters = array('changed_orgs' => 'true');
             $changed_org = true;
             break;
         case 'changed_groups':
             $filters = array('changed_groups' => 'true');
             $changed_group = true;
             break;
         default:
             // ... get all parties of a given type
             //$filters = array('party_type' => phpgw::get_var('party_type'), 'active' => phpgw::get_var('active'));
             break;
     }
     if ($changed_group) {
         $result_objects = activitycalendar_sogroup::get_instance()->get($start_index, $num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, $filters);
         $result_count = activitycalendar_sogroup::get_instance()->get_count($search_for, $search_type, $filters);
     } else {
         $result_objects = activitycalendar_soorganization::get_instance()->get($start_index, $num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, $filters);
         $result_count = activitycalendar_soorganization::get_instance()->get_count($search_for, $search_type, $filters);
     }
     //var_dump($result_objects);
     // Create an empty row set
     $rows = array();
     foreach ($result_objects as $result) {
         if (isset($result)) {
             $res = $result->serialize();
             $org_id = $result->get_id();
             //$rows[] = $result->serialize();
             $rows[] = $res;
             if (!$changed_group && !$changed_org) {
                 $filter_group = array('org_id' => $org_id);
                 $result_groups = activitycalendar_sogroup::get_instance()->get(null, null, $sort_field, $sort_ascending, $search_for, $search_type, $filter_group);
                 foreach ($result_groups as $result_group) {
                     if (isset($result_group)) {
                         $res_g = $result_group->serialize();
                         $rows[] = $res_g;
                     }
                 }
             }
         }
     }
     // ... add result data
     $organization_data = array('results' => $rows, 'total_records' => $result_count);
     $editable = phpgw::get_var('editable') == 'true' ? true : false;
     if (!$export) {
         array_walk($organization_data['results'], array($this, 'add_actions'), array($type));
     }
     return $this->yui_results($organization_data, 'total_records', 'results');
 }
 public function __construct()
 {
     parent::__construct();
     $this->so_organization = activitycalendar_soorganization::get_instance();
 }
 public function serialize()
 {
     $so_org = activitycalendar_soorganization::get_instance();
     $so_act = activitycalendar_soactivity::get_instance();
     return array('id' => $this->get_id(), 'name' => $this->get_name(), 'organization_number' => $this->get_organization_number(), 'district' => ($this->get_change_type() == "new" || $this->get_change_type() == "change") && $this->get_district() && is_numeric($this->get_district()) ? $so_act->get_district_from_id($this->get_district()) : $this->get_district(), 'description' => $this->get_description(), 'homepage' => $this->get_homepage(), 'email' => $this->get_email(), 'phone' => $this->get_phone(), 'address' => $this->get_address(), 'addressnumber' => $this->get_addressnumber(), 'zip_code' => $this->get_zip_code(), 'city' => $this->get_city(), 'show_in_portal' => $this->get_show_in_portal(), 'change_type' => lang($this->get_change_type()), 'transferred' => $this->get_transferred(), 'office' => $so_org->get_office_from_district($so_org->get_district_from_name($this->get_district())));
 }
Exemple #7
0
            echo lang('edit_contact_info_org');
            ?>
</a>
						<?php 
        }
        ?>
						<?php 
    }
    ?>
					<?php 
} else {
    if ($activity->get_organization_id()) {
        if ($activity->get_new_org()) {
            echo activitycalendar_soorganization::get_instance()->get_organization_name_local($activity->get_organization_id());
        } else {
            echo activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
        }
    }
}
?>
				</dd>
				<dt>
					<?php 
if ($activity->get_group_id() || $editable) {
    ?>
					<label for="group_id"><?php 
    echo lang('group');
    ?>
</label>
					<?php 
    if ($editable) {
 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_organizations()
 {
     $soactivity = activitycalendar_soactivity::get_instance();
     $datalines = $this->csvdata;
     $this->messages[] = "Read 'import_all.csv' file in " . (time() - $start_time) . " seconds";
     $this->messages[] = "'importfile.csv' contained " . count($datalines) . " lines";
     $db_activity = $soactivity->get_db();
     $db_activity->transaction_begin();
     foreach ($datalines as $data) {
         $activityOK = true;
         unset($activity_persons);
         unset($activity_description);
         unset($org_info);
         unset($contact_person);
         unset($contact1);
         unset($contact2);
         unset($contact3);
         unset($contact4);
         unset($new_org_id);
         $activity_id = $this->decode($data[0]);
         $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[5]);
         if (strlen($org_email) > 50) {
             $org_email = substr($org_email, 0, 49);
         }
         $org_phone = $this->decode($data[4]);
         if (strlen($org_phone) > 50) {
             $org_phone = substr($org_phone, 0, 49);
         }
         $contact_mail_2 = $this->decode($data[11]);
         if (strlen($contact_mail_2) > 50) {
             $contact_mail_2 = substr($contact_mail_2, 0, 49);
         }
         $contact1_name = $this->decode($data[3]);
         if (strlen($contact1_name) > 50) {
             $contact1_name = substr($contact1_name, 0, 49);
         }
         $contact1_phone = $this->decode($data[4]);
         if (strlen($contact1_phone) > 50) {
             $contact1_phone = substr($contact1_phone, 0, 49);
         }
         $contact2_name = $this->decode($data[7]);
         if (strlen($contact2_name) > 50) {
             $contact2_name = substr($contact2_name, 0, 49);
         }
         $contact2_phone = $this->decode($data[10]);
         if (strlen($contact2_phone) > 50) {
             $contact2_phone = substr($contact2_phone, 0, 49);
         }
         $activity = $soactivity->get_single($activity_id);
         $org_info = array();
         $org_info['name'] = $org_name_tmp;
         $org_info['homepage'] = $this->decode($data[6]);
         $org_info['phone'] = $org_phone;
         $org_info['email'] = $org_email;
         $org_info['description'] = $this->decode($data[2]);
         $org_info['street'] = $this->decode($data[8]);
         $org_info['zip'] = $this->decode($data[9]);
         $org_info['activity_id'] = "";
         $org_info['district'] = $this->decode($data[12]);
         $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'] = $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'] = $new_org_id;
         $soactivity->add_contact_person_org($contact2);
         $activity_persons = activitycalendar_soorganization::get_instance()->get_contacts($new_org_id);
         $activity_contact_person_2_address = $this->decode($data[8]);
         $activity_contact_person_2_zip = $this->decode($data[9]);
         if ($activity) {
             $activity->set_organization_id($new_org_id);
             //$activity->set_description($activity_description);
             $activity->set_contact_person_2_address($activity_contact_person_2_address);
             $activity->set_contact_person_2_zip($activity_contact_person_2_zip);
             if ($activity_persons) {
                 //set contact persons
                 $activity->set_contact_persons($activity_persons);
             }
             if ($soactivity->store($activity)) {
                 $this->messages[] = "Successfully updated activity: Title ({$activity->get_title()})";
             } else {
                 $this->errors[] = "Error updating activity: Title ({$activity->get_title()})";
                 $activityOK = false;
             }
         }
     }
     if ($activityOK) {
         $this->messages[] = "Imported activities. (" . (time() - $start_time) . " seconds)";
         $db_activity->transaction_commit();
         return true;
     } 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;
     }
 }