[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7148]
From: |
Erik Holm-Larsen |
Subject: |
[Fmsystem-commits] [7148] |
Date: |
Wed, 30 Mar 2011 06:43:54 +0000 |
Revision: 7148
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7148
Author: erikhl
Date: 2011-03-30 06:43:52 +0000 (Wed, 30 Mar 2011)
Log Message:
-----------
Added Paths:
-----------
trunk/activitycalendar/
trunk/activitycalendar/inc/
trunk/activitycalendar/inc/class.socommon.inc.php
trunk/activitycalendar/inc/class.soorganization.inc.php
trunk/activitycalendar/inc/class.uiactivities.inc.php
trunk/activitycalendar/inc/class.uiarena.inc.php
trunk/activitycalendar/inc/class.uicommon.inc.php
trunk/activitycalendar/inc/class.uiorganizationlist.inc.php
trunk/activitycalendar/index.php
trunk/activitycalendar/js/
trunk/activitycalendar/js/activitycalendar/
trunk/activitycalendar/js/activitycalendar/common.js
trunk/activitycalendar/setup/
trunk/activitycalendar/setup/default_records.inc.php
trunk/activitycalendar/setup/phpgw_no.lang
trunk/activitycalendar/setup/setup.inc.php
trunk/activitycalendar/setup/tables_current.inc.php
trunk/activitycalendar/templates/
trunk/activitycalendar/templates/base/
trunk/activitycalendar/templates/base/activities.php
trunk/activitycalendar/templates/base/arena.php
trunk/activitycalendar/templates/base/common.php
trunk/activitycalendar/templates/base/organization_list.php
trunk/activitycalendar/templates/base/organization_list_partial.php
Added: trunk/activitycalendar/inc/class.socommon.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.socommon.inc.php
(rev 0)
+++ trunk/activitycalendar/inc/class.socommon.inc.php 2011-03-30 06:43:52 UTC
(rev 7148)
@@ -0,0 +1,318 @@
+<?php
+abstract class activitycalendar_socommon
+{
+ protected $db;
+ protected $like;
+ protected $join;
+ protected $left_join;
+
+ public function __construct()
+ {
+ $this->db = clone $GLOBALS['phpgw']->db;
+ $this->like = & $this->db->like;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+ }
+
+ /**
+ * Marshal values according to type
+ * @param $value the value
+ * @param $type the type of value
+ * @return database value
+ */
+ protected function marshal($value, $type)
+ {
+ if($value === null)
+ {
+ return 'NULL';
+ }
+ else if($type == 'int')
+ {
+ if($value == '')
+ {
+ return 'NULL';
+ }
+ return intval($value);
+ }
+ else if($type == 'float')
+ {
+ return str_replace(',', '.', $value);
+ }
+ else if($type == 'field')
+ {
+ return $this->db->db_addslashes($value);
+ }
+ return "'" . $this->db->db_addslashes($value) . "'";
+ }
+
+ /**
+ * Unmarchal database values according to type
+ * @param $value the field value
+ * @param $type a string dictating value type
+ * @return the php value
+ */
+ protected function unmarshal($value, $type)
+ {
+ if($type == 'bool')
+ {
+ return (boolean)$value;
+ }
+ elseif($value === null || $value == 'NULL')
+ {
+ return null;
+ }
+ elseif($type == 'int')
+ {
+ return intval($value);
+ }
+ elseif($type == 'float')
+ {
+ return floatval($value);
+ }
+ return $value;
+ }
+
+ /**
+ * Get the count of the specified query. Query must return a signel
column
+ * called count.
+ *
+ * @param $sql the sql query
+ * @return the count value
+ */
+ protected function get_query_count($sql)
+ {
+ $result = $this->db->query($sql);
+ if($result && $this->db->next_record())
+ {
+ return $this->unmarshal($this->db->f('count', true),
'int');
+ }
+ }
+
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public abstract static function get_instance();
+
+ /**
+ * Convenience method for getting one single object. Calls get() with
the
+ * specified id as a filter.
+ *
+ * @param $id int with id of object to return.
+ * @return object with the specified id, null if not found.
+ */
+ public function get_single(int $id)
+ {
+ $objects = $this->get(null, null, null, null, null, null,
array($this->get_id_field_name() => $id));
+ if(count($objects) > 0)
+ {
+ $keys = array_keys($objects);
+ return $objects[$keys[0]];
+ }
+ return null;
+ }
+
+ /**
+ * Method for retrieving the db-object (security "forgotten")
+ */
+ public function get_db(){
+ return $this->db;
+ }
+
+ /**
+ * Method for retreiving objects.
+ *
+ * @param $start_index int with index of first object.
+ * @param $num_of_objects int with max number of objects to return.
+ * @param $sort_field string representing the object field to sort on.
+ * @param $ascending boolean true for ascending sort on sort field,
false
+ * for descending.
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @return array of objects. May return an empty
+ * array, never null. The array keys are the respective index numbers.
+ */
+ public function get(int $start_index, int $num_of_objects, string
$sort_field, boolean $ascending, string $search_for, string $search_type, array
$filters)
+ {
+ $results = array(); // Array to store
result objects
+ $map = array(); // Array to hold number
of records per target object
+ $check_map = array(); // Array to hold the actual
number of record read per target object
+ $object_ids = array(); // All of the object ids
encountered
+ $added_object_ids = array();// All of the added objects ids
+
+ // Retrieve information about the table name and the name and
alias of id column
+ // $break_on_limit - flag indicating whether to break the
loop when the number of records
+ // for all the
result objects are traversed
+ $id_field_name_info = $this->get_id_field_name(true);
+ if(is_array($id_field_name_info))
+ {
+ $break_on_limit = true;
+ $id_field_name = $id_field_name_info['translated'];
+ }
+ else
+ {
+ $break_on_limit = false;
+ $id_field_name = $id_field_name_info;
+ }
+
+ // Special case: Sort on id field. Always changed to the id
field name.
+ // $break_when_num_of_objects_reached - flag indicating to
break the loop when the number of
+ // results are reached and we are sure that the
records are ordered by the id
+ if($sort_field == null || $sort_field == 'id' || $sort_field ==
'')
+ {
+ $sort_field = $id_field_name;
+ $break_when_num_of_objects_reached = true;
+ }
+ else
+ {
+ $break_when_num_of_objects_reached = false;
+ }
+
+ // Only allow positive start index
+ if($start_index < 0)
+ {
+ $start_index = 0;
+ }
+
+
+ // test-input for break on ordered queries
+ $db2 = clone($this->db);
+
+ $sql = $this->get_query($sort_field, $ascending, $search_for,
$search_type, $filters, false);
+ $sql_parts = explode('1=1',$sql); // Split the query to insert
extra condition on test for break
+ $this->db->query($sql,__LINE__, __FILE__, false, true);
+
+ while ($this->db->next_record()) // Runs through all of the
results
+ {
+ $should_populate_object = false; // Default value - we
won't populate object
+ $result_id =
$this->unmarshal($this->db->f($id_field_name), 'int'); // The id of object
+ if(in_array($result_id, $added_object_ids)) // Object
with this id already added
+ {
+ $should_populate_object = true; // We should
populate this object as we already have it in our result array
+ }
+ else // Object isn't already added to array
+ {
+ if(!in_array($result_id, $object_ids)) //
Haven't already added this id
+ {
+ $object_ids[] = $result_id; // We have
to add the new id
+ }
+ // We have to check if we should populate this
object
+ if(count($object_ids) > $start_index) // We're
at index above start index
+ {
+ if($num_of_objects == null ||
count($results) < $num_of_objects) // We haven't found all the objects we're
looking for
+ {
+ $should_populate_object = true;
// We should populate this object
+ $added_object_ids[] =
$result_id; // We keep the id
+ }
+ }
+ }
+ if($should_populate_object)
+ {
+ $result = &$results[$result_id];
+ $results[$result_id] =
$this->populate($result_id,$result);
+ $last_result_id = $result_id;
+ $map[$result_id] = (int)$map[$result_id] +1;
+ }
+
+ //Stop looping when array not sorted on other then id
and wanted number of results is reached
+ if(count($results) == $num_of_objects &&
$last_result_id != $result_id && $break_when_num_of_objects_reached)
+ {
+ break;
+ }
+ // else stop looping when wanted number of results is
reached all records for result objects are read
+ else if($break_on_limit && (count($results) ==
$num_of_objects) && $last_result_id != $result_id)
+ {
+ $id_ok = 0;
+ foreach ($map as $_result_id => $_count)
+ {
+ if(!isset($check_map[$_result_id]))
+ {
+ // Query the number of records
for the specific object in question
+ $sql2 = "{$sql_parts[0]} 1=1
AND {$id_field_name_info['table']}.{$id_field_name_info['field']} =
{$_result_id} {$sql_parts[1]}";
+ $db2->query($sql2,__LINE__,
__FILE__);
+ $db2->next_record();
+ $check_map[$_result_id] =
$db2->num_rows();
+ }
+ if( $check_map[$_result_id] ==
$_count )
+ {
+ $id_ok++;
+ }
+ }
+ if($id_ok == $num_of_objects)
+ {
+ break;
+ }
+ }
+ }
+ return $results;
+ }
+
+ /**
+ * Returns count of matching objects.
+ *
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @return int with object count.
+ */
+ public function get_count(string $search_for, string $search_type,
array $filters)
+ {
+ return $this->get_query_count($this->get_query(null, null,
$search_for, $search_type, $filters, true));
+ }
+
+ /**
+ * Implementing classes must return the name of the field used in the
query
+ * returned from get_query().
+ *
+ * @return string with name of id field.
+ */
+ protected abstract function get_id_field_name();
+
+ /**
+ * Returns SQL for retrieving matching objects or object count.
+ *
+ * @param $start_index int with index of first object.
+ * @param $num_of_objects int with max number of objects to return.
+ * @param $sort_field string representing the object field to sort on.
+ * @param $ascending boolean true for ascending sort on sort field,
false
+ * for descending.
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @param $return_count boolean telling to return only the count of the
+ * matching objects, or the objects themself.
+ * @return string with SQL.
+ */
+ protected abstract function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count);
+
+ protected abstract function populate(int $object_id, &$object);
+
+ protected abstract function add(&$object);
+
+ protected abstract function update($object);
+
+ /**
+ * Store the object in the database. If the object has no ID it is
assumed to be new and
+ * inserted for the first time. The object is then updated with the new
insert id.
+ */
+ public function store(&$object)
+ {
+ if ($object->validates()) {
+ if ($object->get_id() > 0) {
+ // We can assume this composite came from the
database since it has an ID. Update the existing row
+ return $this->update($object);
+ }
+ else
+ {
+ // This object does not have an ID, so will be
saved as a new DB row
+ return $this->add($object);
+ }
+ }
+
+ // The object did not validate
+ return false;
+ }
+}
+?>
\ No newline at end of file
Added: trunk/activitycalendar/inc/class.soorganization.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.soorganization.inc.php
(rev 0)
+++ trunk/activitycalendar/inc/class.soorganization.inc.php 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,320 @@
+<?php
+
+phpgw::import_class('activitycalendar.socommon');
+
+
+class activitycalendar_soorganization extends activitycalendar_socommon
+{
+ protected static $so;
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Generate SQL query
+ *
+ * @todo Add support for filter "party_type", meaning what type of
contracts
+ * the party is involved in.
+ *
+ * @param string $sort_field
+ * @param boolean $ascending
+ * @param string $search_for
+ * @param string $search_type
+ * @param array $filters
+ * @param boolean $return_count
+ * @return string SQL
+ */
+ protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
+ {
+ $clauses = array('1=1');
+
+ //Add columns to this array to include them in the query
+ $columns = array();
+
+ if($sort_field != null) {
+ $dir = $ascending ? 'ASC' : 'DESC';
+ /*if($sort_field == 'name')
+ {
+ $order = "ORDER BY organization.last_name
{$dir}, party.first_name {$dir}";
+ }
+ else
+ {
+ if($sort_field == 'address')
+ {
+ $sort_field = 'party.address_1';
+ }*/
+ $order = "ORDER BY
{$this->marshal($sort_field,'field')} $dir";
+ //}
+ }
+/* if($search_for)
+ {
+ $query = $this->marshal($search_for,'string');
+ $like_pattern = "'%".$search_for."%'";
+ $like_clauses = array();
+ switch($search_type){
+ case "name":
+ $like_clauses[] = "party.first_name
$this->like $like_pattern";
+ $like_clauses[] = "party.last_name
$this->like $like_pattern";
+ $like_clauses[] = "party.company_name
$this->like $like_pattern";
+ break;
+ case "address":
+ $like_clauses[] = "party.address_1
$this->like $like_pattern";
+ $like_clauses[] = "party.address_2
$this->like $like_pattern";
+ $like_clauses[] = "party.postal_code
$this->like $like_pattern";
+ $like_clauses[] = "party.place
$this->like $like_pattern";
+ break;
+ case "identifier":
+ $like_clauses[] = "party.identifier
$this->like $like_pattern";
+ break;
+ case "reskontro":
+ $like_clauses[] = "party.reskontro
$this->like $like_pattern";
+ break;
+ case "result_unit_number":
+ $like_clauses[] =
"party.result_unit_number $this->like $like_pattern";
+ break;
+ case "all":
+ $like_clauses[] = "party.first_name
$this->like $like_pattern";
+ $like_clauses[] = "party.last_name
$this->like $like_pattern";
+ $like_clauses[] = "party.company_name
$this->like $like_pattern";
+ $like_clauses[] = "party.address_1
$this->like $like_pattern";
+ $like_clauses[] = "party.address_2
$this->like $like_pattern";
+ $like_clauses[] = "party.postal_code
$this->like $like_pattern";
+ $like_clauses[] = "party.place
$this->like $like_pattern";
+ $like_clauses[] = "party.identifier
$this->like $like_pattern";
+ $like_clauses[] = "party.comment
$this->like $like_pattern";
+ $like_clauses[] = "party.reskontro
$this->like $like_pattern";
+ break;
+ }
+
+
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
+ }
+ }*/
+
+ $filter_clauses = array();
+ $filter_clauses[] = "show_in_portal";
+/*
+ // All parties with contracts of type X
+ if(isset($filters['party_type']))
+ {
+ $party_type =
$this->marshal($filters['party_type'],'int');
+ if(isset($party_type) && $party_type > 0)
+ {
+ $filter_clauses[] = "contract.location_id =
{$party_type}";
+ }
+ }
+*/
+
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+ $condition = join(' AND ', $clauses);
+
+ if($return_count) // We should only return a count
+ {
+ $cols = 'COUNT(DISTINCT(org.id)) AS count';
+ }
+ else
+ {
+ $columns[] = 'org.id AS org_id';
+ $columns[] = 'org.name';
+ $columns[] = 'org.homepage';
+ $columns[] = 'org.phone';
+ $columns[] = 'org.email';
+ $columns[] = 'org.description';
+ $columns[] = 'org.active';
+ $columns[] = 'org.street';
+ $columns[] = 'org.zip_code';
+ $columns[] = 'org.city';
+ $columns[] = 'org.district';
+ $columns[] = 'org.organization_number';
+ $columns[] = 'org.activity_id';
+ $columns[] = 'org.customer_number';
+ $columns[] = 'org.customer_identifier_type';
+ $columns[] = 'org.customer_organization_number';
+ $columns[] = 'org.customer_ssn';
+ $columns[] = 'org.customer_internal';
+ $columns[] = 'org.shortname';
+ $columns[] = 'org.show_in_portal';
+
+ $cols = implode(',',$columns);
+ }
+
+ $tables = "bb_organization org";
+
+ //$join_contracts = " {$this->left_join}
rental_contract_party c_p ON (c_p.party_id = party.id)
+ //{$this->left_join} rental_contract contract ON (contract.id =
c_p.contract_id)";
+
+ $joins = $join_contracts;
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
+ }
+
+
+
+ /**
+ * Function for adding a new party to the database. Updates the party
object.
+ *
+ * @param rental_party $party the party to be added
+ * @return bool true if successful, false otherwise
+ */
+ function add(&$party)
+ {
+ // Insert a new party
+ $q ="INSERT INTO rental_party (is_inactive) VALUES (false)";
+ $result = $this->db->query($q);
+
+ if(isset($result)) {
+ // Set the new party ID
+
$party->set_id($this->db->get_last_insert_id('rental_party', 'id'));
+ // Forward this request to the update method
+ return $this->update($party);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Update the database values for an existing party object.
+ *
+ * @param $party the party to be updated
+ * @return boolean true if successful, false otherwise
+ */
+ function update($party)
+ {
+ $id = intval($party->get_id());
+
+
+ $location_id = $this->marshal($party->get_location_id(), 'int');
+
+ if($location_id)
+ {
+ $loc =
$GLOBALS['phpgw']->locations->get_name($location_id);
+ $name = $loc['location'];
+ $level_identifier =
result_unit::get_identifier_from_name($name);
+ }
+
+ $result_unit_number = $this->marshal($level_identifier,
'string');
+
+ $values = array(
+ 'identifier = ' .
$this->marshal($party->get_identifier(), 'string'),
+ 'first_name = ' .
$this->marshal($party->get_first_name(), 'string'),
+ 'last_name = ' .
$this->marshal($party->get_last_name(), 'string'),
+ 'title = ' .
$this->marshal($party->get_title(), 'string'),
+ 'company_name = ' .
$this->marshal($party->get_company_name(), 'string'),
+ 'department = ' .
$this->marshal($party->get_department(), 'string'),
+ 'address_1 = ' .
$this->marshal($party->get_address_1(), 'string'),
+ 'address_2 = ' .
$this->marshal($party->get_address_2(), 'string'),
+ 'postal_code = ' .
$this->marshal($party->get_postal_code(), 'string'),
+ 'place = ' .
$this->marshal($party->get_place(), 'string'),
+ 'phone = ' .
$this->marshal($party->get_phone(), 'string'),
+ 'mobile_phone = ' .
$this->marshal($party->get_mobile_phone(), 'string'),
+ 'fax = ' . $this->marshal($party->get_fax(),
'string'),
+ 'email = ' .
$this->marshal($party->get_email(), 'string'),
+ 'url = ' . $this->marshal($party->get_url(),
'string'),
+ 'account_number = ' .
$this->marshal($party->get_account_number(), 'string'),
+ 'reskontro = ' .
$this->marshal($party->get_reskontro(), 'string'),
+ 'is_inactive = ' .
$this->marshal(($party->is_inactive() ? 'true' : 'false'), 'bool'),
+ 'comment = ' .
$this->marshal($party->get_comment(), 'string'),
+ 'org_enhet_id = ' .
$this->marshal($party->get_org_enhet_id(), 'int'),
+ 'location_id = ' . $location_id,
+ 'result_unit_number = ' . $result_unit_number
+ );
+
+ $result = $this->db->query('UPDATE rental_party SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
+
+ return isset($result);
+ }
+
+ public function get_id_field_name($extended_info = false)
+ {
+ if(!$extended_info)
+ {
+ $ret = 'party_id';
+ }
+ else
+ {
+ $ret = array
+ (
+ 'table' => 'party', // alias
+ 'field' => 'id',
+ 'translated' => 'party_id'
+ );
+ }
+ return $ret;
+ }
+
+ protected function populate(int $party_id, &$party)
+ {
+
+ if($party == null) {
+ $party = new rental_party((int) $party_id);
+
+ $party->set_account_number(
$this->unmarshal($this->db->f('account_number'), 'string'));
+ $party->set_address_1(
$this->unmarshal($this->db->f('address_1'), 'string'));
+ $party->set_address_2(
$this->unmarshal($this->db->f('address_2'), 'string'));
+ $party->set_comment(
$this->unmarshal($this->db->f('comment'), 'string'));
+ $party->set_company_name(
$this->unmarshal($this->db->f('company_name'), 'string'));
+ $party->set_department(
$this->unmarshal($this->db->f('department'), 'string'));
+ $party->set_email(
$this->unmarshal($this->db->f('email'), 'string'));
+ $party->set_fax(
$this->unmarshal($this->db->f('fax'), 'string'));
+ $party->set_first_name(
$this->unmarshal($this->db->f('first_name'), 'string'));
+ $party->set_is_inactive(
$this->unmarshal($this->db->f('is_inactive'), 'bool'));
+ $party->set_last_name(
$this->unmarshal($this->db->f('last_name'), 'string'));
+ $party->set_location_id(
$this->unmarshal($this->db->f('org_location_id'), 'int'));
+ $party->set_identifier(
$this->unmarshal($this->db->f('identifier'), 'string'));
+ $party->set_mobile_phone(
$this->unmarshal($this->db->f('mobile_phone'), 'string'));
+ $party->set_place(
$this->unmarshal($this->db->f('place'), 'string'));
+ $party->set_postal_code(
$this->unmarshal($this->db->f('postal_code'), 'string'));
+ $party->set_reskontro(
$this->unmarshal($this->db->f('reskontro'), 'string'));
+ $party->set_title(
$this->unmarshal($this->db->f('title'), 'string'));
+ $party->set_url(
$this->unmarshal($this->db->f('url'), 'string'));
+ $party->set_org_enhet_id(
$this->unmarshal($this->db->f('org_enhet_id'), 'string'));
+ $sync_message = $party->set_sync_data(
+ array(
+ 'responsibility_id' =>
$this->unmarshal($this->db->f('responsibility_id'), 'string'),
+ 'org_enhet_id' =>
$this->unmarshal($this->db->f('org_enhet_id'), 'string'),
+ 'result_unit_number' =>
$this->unmarshal($this->db->f('result_unit_number'), 'string'),
+ )
+ );
+ if(isset($sync_message) && $sync_message != '')
+ {
+ $party->add_sync_problem($sync_message);
+ }
+ }
+ return $party;
+ }
+
+ public function get_export_data()
+ {
+ $parties = rental_soparty::get_instance()->get(null, null,
null, null, null, null, null);
+ $exportable = new rental_agresso_cs15($parties);
+ return $exportable->get_contents();
+ }
+
+ public function get_number_of_parties()
+ {
+ $q ="SELECT COUNT(id) FROM rental_party";
+ $result = $this->db->query($q);
+ $this->db->query($q, __LINE__, __FILE__);
+ $this->db->next_record();
+ return (int) $this->db->f('count',true);
+ }
+
+}
+?>
Added: trunk/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiactivities.inc.php
(rev 0)
+++ trunk/activitycalendar/inc/class.uiactivities.inc.php 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,409 @@
+<?php
+phpgw::import_class('activitycalendar.uicommon');
+
+class activitycalendar_uiactivities extends activitycalendar_uicommon
+{
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'query' => true,
+ 'view' => true,
+ 'delete' => true,
+ 'commit' => true,
+ 'download' => true,
+ 'download_export' => true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+ self::set_active_menu('booking::activities');
+ $config = CreateObject('phpgwapi.config','activitycalendar');
+ $config->read();
+ }
+
+ public function index()
+ {
+ // No messages so far
+ $errorMsgs = array();
+ $warningMsgs = array();
+ $infoMsgs = array();
+
+
+ $data = array
+ (
+ 'contract_type' => phpgw::get_var('contract_type'),
+ 'billing_term' => phpgw::get_var('billing_term'),
+ 'year' => phpgw::get_var('year'),
+ 'month' => phpgw::get_var('month'),
+ 'errorMsgs' => $errorMsgs,
+ 'warningMsgs' => $warningMsgs,
+ 'infoMsgs' => $infoMsgs
+ );
+ $this->render('activities.php', $data);
+ }
+ /*public function index()
+ {
+ if(phpgw::get_var('phpgw_return_as') == 'json') {
+ return $this->index_json();
+ }
+ //$GLOBALS['phpgw_info']['apps']['manual']['section'] =
'booking_manual';
+ //self::add_javascript('booking', 'booking',
'datatable.js');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('paginator');
+ $data = array(
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' => 'booking.uidashboard.index', 'phpgw_return_as'
=> 'json')),
+ 'field' => array(
+ array(
+ 'key' => 'id',
+ 'label' => lang('ID'),
+ 'formatter' =>
'YAHOO.booking.formatLink'
+ ),
+ array(
+ 'key' => 'status',
+ 'label' =>
lang('Status')
+ ),
+ array(
+ 'key' => 'type',
+ 'label' => lang('Type')
+ ),
+ array(
+ 'key' => 'created',
+ 'label' =>
lang('Created')
+ ),
+ array(
+ 'key' => 'modified',
+ 'label' => lang('Last
modified')
+ ),
+ array(
+ 'key' => 'what',
+ 'label' => lang('What')
+ ),
+ array(
+ 'key' =>
'activity_name',
+ 'label' =>
lang('Activity')
+ ),
+ array(
+ 'key' => 'contact_name',
+ 'label' =>
lang('Contact')
+ ),
+ array(
+ 'key' =>
'case_officer_name',
+ 'label' => lang('Case
Officer')
+ ),
+ array(
+ 'key' => 'link',
+ 'hidden' => true
+ )
+ )
+ )
+ );
+ self::render_template('datatable', $data);
+ }*/
+
+ /**
+ * Displays info about one single billing job.
+ */
+ public function view()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('invoice_run');
+
+ $errorMsgs = array();
+ $infoMsgs = array();
+ $billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+ $billing_info_array =
rental_sobilling_info::get_instance()->get(null, null, null, null, null, null,
array('billing_id' => phpgw::get_var('id')));
+
+ if($billing_job == null) // Not found
+ {
+ $errorMsgs[] = lang('Could not find specified billing
job.');
+ }
+ else if(phpgw::get_var('generate_export') != null) // User
wants to generate export
+ {
+
+ $open_and_exported =
rental_soinvoice::get_instance()->number_of_open_and_exported_rental_billings($billing_job->get_location_id());
+
+ if($open_and_exported == 0)
+ {
+ //Loop through billing info array to find the
first month
+ $month = 12;
+ foreach($billing_info_array as $billing_info)
+ {
+ $year = $billing_info->get_year();
+ if($month > $billing_info->get_month())
+ {
+ $month =
$billing_info->get_month();
+ }
+ }
+
+ $billing_job->set_year($year);
+ $billing_job->set_month($month);
+
+
if(rental_sobilling::get_instance()->generate_export($billing_job))
+ {
+ $infoMsgs[] = lang('Export generated.');
+
$billing_job->set_generated_export(true); // The template need to know that
we've genereated the export
+ }
+ else
+ {
+ $errorMsgs = lang('Export failed.');
+ }
+ }
+ else
+ {
+ $errorMsgs[] = lang('open_and_exported_exist');
+ }
+ }
+ else if(phpgw::get_var('commit') != null) // User wants to
commit/close billing so that it cannot be deleted
+ {
+ $billing_job->set_timestamp_commit(time());
+ rental_sobilling::get_instance()->store($billing_job);
+ }
+ $data = array
+ (
+ 'billing_job' => $billing_job,
+ 'billing_info_array' => $billing_info_array,
+ 'errorMsgs' => $errorMsgs,
+ 'infoMsgs' => $infoMsgs,
+ 'back_link' =>
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.index'))),
+ 'download_link' =>
html_entity_decode(self::link(array('menuaction' =>
'rental.uibilling.download_export', 'id' => (($billing_job != null) ?
$billing_job->get_id() : ''), 'date' => $billing_job->get_timestamp_stop(),
'export_format' => $billing_job->get_export_format())))
+ );
+ $this->render('billing.php', $data);
+ }
+
+ /**
+ * Deletes an uncommited billing job.
+ */
+ public function delete()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+ $billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+ $billing_job->set_deleted(true);
+ rental_sobilling::get_instance()->store($billing_job);
+
+ //set deleted=true on billing_info
+ $billing_infos =
rental_sobilling_info::get_instance()->get(null, null, null, null, null, null,
array('billing_id' => phpgw::get_var('id')));
+ foreach($billing_infos as $billing_info){
+ $billing_info->set_deleted(true);
+
rental_sobilling_info::get_instance()->store($billing_info);
+ }
+
+ //set is_billed on invoice price items to false
+ $billing_job_invoices =
rental_soinvoice::get_instance()->get(null, null, null, null, null, null,
array('billing_id' => phpgw::get_var('id')));
+ foreach($billing_job_invoices as $invoice){
+ $price_items =
rental_socontract_price_item::get_instance()->get(null, null, null, null, null,
null, array('contract_id' => $invoice->get_contract_id(), 'one_time' => true));
+ foreach($price_items as $price_item){
+ if($price_item->get_date_start() >=
$invoice->get_timestamp_start() && $price_item->get_date_start() <=
$invoice->get_timestamp_end()){
+ $price_item->set_is_billed(false);
+
rental_socontract_price_item::get_instance()->store($price_item);
+ }
+ }
+ $invoice->set_serial_number(null);
+ rental_soinvoice::get_instance()->store($invoice);
+ }
+ }
+
+ /**
+ * Commits a billing job. After it's commited it cannot be deleted.
+ */
+ public function commit()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+ $billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+ $billing_job->set_timestamp_commit(time());
+ rental_sobilling::get_instance()->store($billing_job);
+ }
+
+ 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;
+ }
+
+ switch($query_type)
+ {
+ case 'all_billings':
+ $filters = array();
+ if($sort_field == 'responsibility_title'){
+ $sort_field = 'location_id';
+ }
+ $result_objects =
rental_sobilling::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $object_count =
rental_sobilling::get_instance()->get_count($search_for, $search_type,
$filters);
+ break;
+ case 'invoices':
+ if($sort_field == 'term_label'){
+ $sort_field = 'term_id';
+ }
+ $filters = array('billing_id' =>
phpgw::get_var('billing_id'));
+ $result_objects =
rental_soinvoice::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $object_count =
rental_soinvoice::get_instance()->get_count($search_for, $search_type,
$filters);
+ break;
+ }
+
+ //Create an empty row set
+ $rows = array();
+ foreach($result_objects as $result) {
+ if(isset($result))
+ {
+ if($result->has_permission(PHPGW_ACL_READ))
+ {
+ // ... 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');
+ }
+
+ /**
+ * Add action links and labels for the context menu of the list items
+ *
+ * @param $value pointer to
+ * @param $key ?
+ * @param $params [composite_id, type of query, editable]
+ */
+ public function add_actions(&$value, $key, $params)
+ {
+ //Defining new columns
+ $value['ajax'] = array();
+ $value['actions'] = array();
+ $value['labels'] = array();
+
+ $query_type = $params[0];
+
+ switch($query_type)
+ {
+ case 'all_billings':
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.view',
'id' => $value['id'])));
+ $value['labels'][] = lang('show');
+ if($value['timestamp_commit'] == null ||
$value['timestamp_commit'] == '')
+ {
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.delete',
'id' => $value['id'])));
+ $value['labels'][] = lang('delete');
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.commit',
'id' => $value['id'])));
+ $value['labels'][] = lang('commit');
+ }
+ break;
+ case 'invoices':
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['contract_id']))) . '#price';
+ $value['labels'][] = lang('show');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
'id' => $value['contract_id']))) . '#price';
+ $value['labels'][] = lang('edit');
+ break;
+ }
+ }
+
+ public function download_export()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+ //$browser = CreateObject('phpgwapi.browser');
+ //$browser->content_header('export.txt','text/plain');
+
+ $stop = phpgw::get_var('date');
+
+ $cs15 = phpgw::get_var('generate_cs15');
+ if($cs15 == null){
+ $export_format =
explode('_',phpgw::get_var('export_format'));
+ $file_ending = $export_format[1];
+ if($file_ending == 'gl07')
+ {
+ $type = 'intern';
+ }
+ else if($file_ending == 'lg04')
+ {
+ $type = 'faktura';
+ }
+ $date = date('Ymd', $stop);
+ header('Content-type: text/plain');
+ header("Content-Disposition: attachment;
filename=PE_{$type}_{$date}.{$file_ending}");
+
+ $id = phpgw::get_var('id');
+ $path = "/rental/billings/{$id}";
+
+ $vfs = CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+
+ print $vfs->read
+ (
+ array
+ (
+ 'string' => $path,
+ RELATIVE_NONE
+ )
+ );
+
+ //print
rental_sobilling::get_instance()->get_export_data((int)phpgw::get_var('id'));
+ }
+ else{
+ $file_ending = 'cs15';
+ $type = 'kundefil';
+ $date = date('Ymd', $stop);
+ header('Content-type: text/plain');
+ header("Content-Disposition: attachment;
filename=PE_{$type}_{$date}.{$file_ending}");
+ print
rental_sobilling::get_instance()->generate_customer_export((int)phpgw::get_var('id'));
+ }
+ }
+
+}
+?>
Added: trunk/activitycalendar/inc/class.uiarena.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiarena.inc.php
(rev 0)
+++ trunk/activitycalendar/inc/class.uiarena.inc.php 2011-03-30 06:43:52 UTC
(rev 7148)
@@ -0,0 +1,350 @@
+<?php
+phpgw::import_class('activitycalendar.uicommon');
+
+class activitycalendar_uiarena extends activitycalendar_uicommon
+{
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'query' => true,
+ 'view' => true,
+ 'delete' => true,
+ 'commit' => true,
+ 'download' => true,
+ 'download_export' => true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+ self::set_active_menu('booking::activities::arena');
+ $config = CreateObject('phpgwapi.config','activitycalendar');
+ $config->read();
+ }
+
+ public function index()
+ {
+ // No messages so far
+ $errorMsgs = array();
+ $warningMsgs = array();
+ $infoMsgs = array();
+
+
+ $data = array
+ (
+ 'contract_type' => phpgw::get_var('contract_type'),
+ 'billing_term' => phpgw::get_var('billing_term'),
+ 'year' => phpgw::get_var('year'),
+ 'month' => phpgw::get_var('month'),
+ 'errorMsgs' => $errorMsgs,
+ 'warningMsgs' => $warningMsgs,
+ 'infoMsgs' => $infoMsgs
+ );
+ $this->render('arena.php', $data);
+ }
+
+ /**
+ * Displays info about one single billing job.
+ */
+ public function view()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('invoice_run');
+
+ $errorMsgs = array();
+ $infoMsgs = array();
+ $billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+ $billing_info_array =
rental_sobilling_info::get_instance()->get(null, null, null, null, null, null,
array('billing_id' => phpgw::get_var('id')));
+
+ if($billing_job == null) // Not found
+ {
+ $errorMsgs[] = lang('Could not find specified billing
job.');
+ }
+ else if(phpgw::get_var('generate_export') != null) // User
wants to generate export
+ {
+
+ $open_and_exported =
rental_soinvoice::get_instance()->number_of_open_and_exported_rental_billings($billing_job->get_location_id());
+
+ if($open_and_exported == 0)
+ {
+ //Loop through billing info array to find the
first month
+ $month = 12;
+ foreach($billing_info_array as $billing_info)
+ {
+ $year = $billing_info->get_year();
+ if($month > $billing_info->get_month())
+ {
+ $month =
$billing_info->get_month();
+ }
+ }
+
+ $billing_job->set_year($year);
+ $billing_job->set_month($month);
+
+
if(rental_sobilling::get_instance()->generate_export($billing_job))
+ {
+ $infoMsgs[] = lang('Export generated.');
+
$billing_job->set_generated_export(true); // The template need to know that
we've genereated the export
+ }
+ else
+ {
+ $errorMsgs = lang('Export failed.');
+ }
+ }
+ else
+ {
+ $errorMsgs[] = lang('open_and_exported_exist');
+ }
+ }
+ else if(phpgw::get_var('commit') != null) // User wants to
commit/close billing so that it cannot be deleted
+ {
+ $billing_job->set_timestamp_commit(time());
+ rental_sobilling::get_instance()->store($billing_job);
+ }
+ $data = array
+ (
+ 'billing_job' => $billing_job,
+ 'billing_info_array' => $billing_info_array,
+ 'errorMsgs' => $errorMsgs,
+ 'infoMsgs' => $infoMsgs,
+ 'back_link' =>
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.index'))),
+ 'download_link' =>
html_entity_decode(self::link(array('menuaction' =>
'rental.uibilling.download_export', 'id' => (($billing_job != null) ?
$billing_job->get_id() : ''), 'date' => $billing_job->get_timestamp_stop(),
'export_format' => $billing_job->get_export_format())))
+ );
+ $this->render('billing.php', $data);
+ }
+
+ /**
+ * Deletes an uncommited billing job.
+ */
+ public function delete()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+ $billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+ $billing_job->set_deleted(true);
+ rental_sobilling::get_instance()->store($billing_job);
+
+ //set deleted=true on billing_info
+ $billing_infos =
rental_sobilling_info::get_instance()->get(null, null, null, null, null, null,
array('billing_id' => phpgw::get_var('id')));
+ foreach($billing_infos as $billing_info){
+ $billing_info->set_deleted(true);
+
rental_sobilling_info::get_instance()->store($billing_info);
+ }
+
+ //set is_billed on invoice price items to false
+ $billing_job_invoices =
rental_soinvoice::get_instance()->get(null, null, null, null, null, null,
array('billing_id' => phpgw::get_var('id')));
+ foreach($billing_job_invoices as $invoice){
+ $price_items =
rental_socontract_price_item::get_instance()->get(null, null, null, null, null,
null, array('contract_id' => $invoice->get_contract_id(), 'one_time' => true));
+ foreach($price_items as $price_item){
+ if($price_item->get_date_start() >=
$invoice->get_timestamp_start() && $price_item->get_date_start() <=
$invoice->get_timestamp_end()){
+ $price_item->set_is_billed(false);
+
rental_socontract_price_item::get_instance()->store($price_item);
+ }
+ }
+ $invoice->set_serial_number(null);
+ rental_soinvoice::get_instance()->store($invoice);
+ }
+ }
+
+ /**
+ * Commits a billing job. After it's commited it cannot be deleted.
+ */
+ public function commit()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+ $billing_job =
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+ $billing_job->set_timestamp_commit(time());
+ rental_sobilling::get_instance()->store($billing_job);
+ }
+
+ 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;
+ }
+
+ switch($query_type)
+ {
+ case 'all_billings':
+ $filters = array();
+ if($sort_field == 'responsibility_title'){
+ $sort_field = 'location_id';
+ }
+ $result_objects =
rental_sobilling::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $object_count =
rental_sobilling::get_instance()->get_count($search_for, $search_type,
$filters);
+ break;
+ case 'invoices':
+ if($sort_field == 'term_label'){
+ $sort_field = 'term_id';
+ }
+ $filters = array('billing_id' =>
phpgw::get_var('billing_id'));
+ $result_objects =
rental_soinvoice::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $object_count =
rental_soinvoice::get_instance()->get_count($search_for, $search_type,
$filters);
+ break;
+ }
+
+ //Create an empty row set
+ $rows = array();
+ foreach($result_objects as $result) {
+ if(isset($result))
+ {
+ if($result->has_permission(PHPGW_ACL_READ))
+ {
+ // ... 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');
+ }
+
+ /**
+ * Add action links and labels for the context menu of the list items
+ *
+ * @param $value pointer to
+ * @param $key ?
+ * @param $params [composite_id, type of query, editable]
+ */
+ public function add_actions(&$value, $key, $params)
+ {
+ //Defining new columns
+ $value['ajax'] = array();
+ $value['actions'] = array();
+ $value['labels'] = array();
+
+ $query_type = $params[0];
+
+ switch($query_type)
+ {
+ case 'all_billings':
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.view',
'id' => $value['id'])));
+ $value['labels'][] = lang('show');
+ if($value['timestamp_commit'] == null ||
$value['timestamp_commit'] == '')
+ {
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.delete',
'id' => $value['id'])));
+ $value['labels'][] = lang('delete');
+ $value['ajax'][] = true;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uibilling.commit',
'id' => $value['id'])));
+ $value['labels'][] = lang('commit');
+ }
+ break;
+ case 'invoices':
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['contract_id']))) . '#price';
+ $value['labels'][] = lang('show');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
'id' => $value['contract_id']))) . '#price';
+ $value['labels'][] = lang('edit');
+ break;
+ }
+ }
+
+ public function download_export()
+ {
+ if(!$this->isExecutiveOfficer())
+ {
+ $this->render('permission_denied.php');
+ return;
+ }
+ //$browser = CreateObject('phpgwapi.browser');
+ //$browser->content_header('export.txt','text/plain');
+
+ $stop = phpgw::get_var('date');
+
+ $cs15 = phpgw::get_var('generate_cs15');
+ if($cs15 == null){
+ $export_format =
explode('_',phpgw::get_var('export_format'));
+ $file_ending = $export_format[1];
+ if($file_ending == 'gl07')
+ {
+ $type = 'intern';
+ }
+ else if($file_ending == 'lg04')
+ {
+ $type = 'faktura';
+ }
+ $date = date('Ymd', $stop);
+ header('Content-type: text/plain');
+ header("Content-Disposition: attachment;
filename=PE_{$type}_{$date}.{$file_ending}");
+
+ $id = phpgw::get_var('id');
+ $path = "/rental/billings/{$id}";
+
+ $vfs = CreateObject('phpgwapi.vfs');
+ $vfs->override_acl = 1;
+
+ print $vfs->read
+ (
+ array
+ (
+ 'string' => $path,
+ RELATIVE_NONE
+ )
+ );
+
+ //print
rental_sobilling::get_instance()->get_export_data((int)phpgw::get_var('id'));
+ }
+ else{
+ $file_ending = 'cs15';
+ $type = 'kundefil';
+ $date = date('Ymd', $stop);
+ header('Content-type: text/plain');
+ header("Content-Disposition: attachment;
filename=PE_{$type}_{$date}.{$file_ending}");
+ print
rental_sobilling::get_instance()->generate_customer_export((int)phpgw::get_var('id'));
+ }
+ }
+
+}
+?>
Added: trunk/activitycalendar/inc/class.uicommon.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uicommon.inc.php
(rev 0)
+++ trunk/activitycalendar/inc/class.uicommon.inc.php 2011-03-30 06:43:52 UTC
(rev 7148)
@@ -0,0 +1,488 @@
+<?php
+ phpgw::import_class('phpgwapi.yui');
+
+ define("ACTIVITYCALENDAR_TEMPLATE_PATH",
"activitycalendar/templates/base/");
+
+
+ /**
+ * Cherry pick selected values into a new array
+ *
+ * @param array $array input array
+ * @param array $keys array of keys to pick
+ *
+ * @return array containg values from $array for the keys in $keys.
+ */
+
+
+ function extract_values($array, $keys)
+ {
+ $result = array();
+ foreach($keys as $key)
+ {
+ if(in_array($key, array_keys($array)))
+ {
+ $result[$key] = $array[$key];
+ }
+ }
+ return $result;
+ }
+
+ function array_set_default(&$array, $key, $value)
+ {
+ if(!isset($array[$key])) $array[$key] = $value;
+ }
+
+ define('MANAGER','MANAGER');
+ define('EXECUTIVE_OFFICER','EXECUTIVE_OFFICER');
+ define('ADMINISTRATOR','ADMINISTRATOR');
+
+ abstract class activitycalendar_uicommon
+ {
+ protected static $old_exception_handler;
+
+ const LOCATION_ROOT = '.';
+ const LOCATION_IN = '.RESPONSIBILITY.INTO';
+ const LOCATION_OUT = '.RESPONSIBILITY.OUT';
+ const LOCATION_INTERNAL = '.RESPONSIBILITY.INTERNAL';
+
+ public $dateFormat;
+
+ public $type_of_user;
+
+ public $flash_msgs;
+
+ public function __construct()
+ {
+ self::set_active_menu('booking');
+
self::add_stylesheet('phpgwapi/js/yahoo/calendar/assets/skins/sam/calendar.css');
+
self::add_stylesheet('phpgwapi/js/yahoo/autocomplete/assets/skins/sam/autocomplete.css');
+
self::add_stylesheet('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+
self::add_stylesheet('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+
self::add_stylesheet('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
self::add_stylesheet('phpgwapi/js/yahoo/treeview/assets/skins/sam/treeview.css');
+
//self::add_stylesheet('rental/templates/base/css/base.css');
+ self::add_javascript('activitycalendar',
'activitycalendar', 'common.js');
+ $this->tmpl_search_path = array();
+ array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT .
'/phpgwapi/templates/base');
+ array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT .
'/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set']);
+ array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT .
'/' . $GLOBALS['phpgw_info']['flags']['currentapp'] . '/templates/base');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('paginator');
+ phpgwapi_yui::load_widget('menu');
+ phpgwapi_yui::load_widget('calendar');
+ phpgwapi_yui::load_widget('autocomplete');
+ phpgwapi_yui::load_widget('animation');
+
+ $dateFormat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $this->acl = & $GLOBALS['phpgw']->acl;
+ $this->locations = & $GLOBALS['phpgw']->locations;
+
+/* $this->type_of_user = array(
+ MANAGER => $this->isManager(),
+ EXECUTIVE_OFFICER =>
$this->isExecutiveOfficer(),
+ ADMINISTRATOR => $this->isAdministrator()
+ );*/
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($GLOBALS['phpgw_info']['flags']['currentapp']);
+ }
+
+ /**
+ * Permission check. Proxy method for method check in
phpgwapi->acl
+ *
+ * @param $location
+ * @param $permission
+ * @return true if check is ok, false othewise
+ */
+ protected function hasPermissionOn($location =
activitycalendar_uicommon::LOCATION_ROOT, $permission = PHPGW_ACL_PRIVATE){
+ return
$this->acl->check($location,$permission,'bkbooking');
+ }
+
+
+ /**
+ * Check to see if this user is an administrator
+ *
+ * @return true if private permission on root, false otherwise
+ */
+ protected function isAdministrator(){
+ return
$this->acl->check(activitycalendar_uicommon::LOCATION_ROOT,PHPGW_ACL_PRIVATE,'activitycalendar');
+ }
+
+ /**
+ * Check to see if the user is an executive officer
+ *
+ * @return true if at least add permission on fields of
responsibilities (locations: .RESPONSIBIITY.*)
+ */
+ protected function isExecutiveOfficer(){
+ return (
+
$this->acl->check(activitycalendar_uicommon::LOCATION_IN,PHPGW_ACL_ADD,'activitycalendar')
||
+
$this->acl->check(activitycalendar_uicommon::LOCATION_OUT,PHPGW_ACL_ADD,'activitycalendar')
||
+
$this->acl->check(activitycalendar_uicommon::LOCATION_INTERNAL,PHPGW_ACL_ADD,'activitycalendar')
+ );
+ }
+
+ /**
+ * Check to see if the user is a manager
+ *
+ * @return true if no read,add,delete,edit permission on fields
of responsibilities (locations: .RESPONSIBILITY.*)
+ */
+ protected function isManager(){
+ return !$this->isExecutiveOfficer();
+ }
+
+ public static function process_rental_unauthorized_exceptions()
+ {
+ self::$old_exception_handler =
set_exception_handler(array(__CLASS__, 'handle_rental_unauthorized_exception'));
+ }
+
+ public static function
handle_rental_unauthorized_exception(Exception $e)
+ {
+ if ($e instanceof rental_unauthorized_exception)
+ {
+ $message = htmlentities('HTTP/1.0 401
Unauthorized - '.$e->getMessage(), null, self::encoding());
+ header($message);
+ echo
"<html><head><title>$message</title></head><body><strong>$message</strong></body></html>";
+ } else {
+ call_user_func(self::$old_exception_handler,
$e);
+ }
+ }
+
+ public function link($data)
+ {
+ return $GLOBALS['phpgw']->link('/index.php', $data);
+ }
+
+ public function redirect($link_data)
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
$link_data);
+ }
+
+ public function flash($msg, $type='success')
+ {
+ $this->flash_msgs[$msg] = $type == 'success';
+ }
+
+ public function flash_form_errors($errors)
+ {
+ foreach($errors as $field => $msg)
+ {
+ $this->flash_msgs[$msg] = false;
+ }
+ }
+
+ public function add_stylesheet($path)
+ {
+ $GLOBALS['phpgw']->css->add_external_file($path);
+ }
+
+ public function add_javascript($app, $pkg, $name)
+ {
+ return $GLOBALS['phpgw']->js->validate_file($pkg,
str_replace('.js', '', $name), $app);
+ }
+
+ public function set_active_menu($item)
+ {
+ $GLOBALS['phpgw_info']['flags']['menu_selection'] = $item;
+ }
+
+ /**
+ * A more flexible version of xslttemplate.add_file
+ */
+ public function add_template_file($tmpl)
+ {
+ if(is_array($tmpl))
+ {
+ foreach($tmpl as $t)
+ {
+ $this->add_template_file($t);
+ }
+ return;
+ }
+ foreach(array_reverse($this->tmpl_search_path) as $path)
+ {
+ $filename = $path . '/' . $tmpl . '.xsl';
+ if (file_exists($filename))
+ {
+
$GLOBALS['phpgw']->xslttpl->xslfiles[$tmpl] = $filename;
+ return;
+ }
+ }
+ echo "Template $tmpl not found in search path: ";
+ print_r($this->tmpl_search_path);
+ die;
+ }
+
+ public function render_template($output)
+ {
+ $GLOBALS['phpgw']->common->phpgw_header(true);
+ if($this->flash_msgs)
+ {
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+ foreach($msgbox_data as & $message)
+ {
+ echo "<div
class='{$message['msgbox_class']}'>";
+ echo $message['msgbox_text'];
+ echo '</div>';
+ }
+ }
+ echo htmlspecialchars_decode($output);
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
+
+ public function check_active($url)
+ {
+ if($_SERVER['REQUEST_METHOD'] == 'POST')
+ {
+ $activate = extract_values($_POST,
array("status", "activate_id"));
+
$this->bo->set_active(intval($activate['activate_id']),
intval($activate['status']));
+ $this->redirect(array('menuaction' => $url,
'id' => $activate['activate_id']));
+ }
+ }
+
+ /**
+ * Build a YUI result of the data
+ *
+ * @param $data the data
+ * @return YUI result { ResultSet => { totalRecords => ?,
Result => ?}
+ */
+ public function yui_results($data,$field_total =
'total_records', $field_results = 'results')
+ {
+ return array
+ (
+ 'ResultSet' => array(
+ 'totalRecords' => $data[$field_total],
+ 'Result' => $data[$field_results]
+ )
+ );
+ }
+
+ /**
+ * Returns formatted version of gab id. The format of the
string returned
+ * is '[Cadastral unit number] / [Property unit number] /
[Leasehold unit number] / [Section unit number]'.
+ *
+ * @param $gab_id string with id to to format.
+ * @return string formatted version of the string passed to the
method,
+ * or the same string if the one passed is of an incorrect
format.
+ */
+ public static function get_nicely_formatted_gab_id(string
$gab_id)
+ {
+ if(strlen($gab_id) == 20)
+ {
+ $gab_id = substr($gab_id,4,5).' /
'.substr($gab_id,9,4).' / '.substr($gab_id,13,4).' / '.substr($gab_id,17,3);
+ }
+ return $gab_id;
+ }
+
+ public function render($template,$local_variables = array())
+ {
+ foreach($local_variables as $name => $value)
+ {
+ $$name = $value;
+
+ }
+
+ ob_start();
+ foreach(array_reverse($this->tmpl_search_path) as $path)
+ {
+ $filename = $path . '/' . $template;
+ if (file_exists($filename))
+ {
+ include($filename);
+ break;
+ }
+ }
+ $output = ob_get_contents();
+ ob_end_clean();
+ self::render_template($output);
+ }
+
+ /**
+ * Method for JSON queries.
+ *
+ * @return YUI result
+ */
+ public abstract function query();
+
+ /**
+ * Generate javascript for the extra column definitions for a
partial list
+ *
+ * @param $array_name the name of the javascript variable that
contains the column definitions
+ * @param $extra_cols the list of extra columns to set
+ * @return string javascript
+ */
+ public static function get_extra_column_defs($array_name,
$extra_cols = array())
+ {
+ $result = "";
+
+ foreach($extra_cols as $col){
+ $literal = '{';
+ $literal .= 'key: "' . $col['key'] . '",';
+ $literal .= 'label: "' . $col['label'] . '"';
+ if (isset($col['formatter'])) {
+ $literal .= ',formatter: ' .
$col['formatter'];
+ }
+ if (isset($col['parser'])) {
+ $literal .= ',parser: ' .
$col['parser'];
+ }
+ $literal .= '}';
+
+ if($col["index"]){
+ $result .=
"{$array_name}.splice(".$col["index"].", 0,".$literal.");";
+ } else {
+ $result .=
"{$array_name}.push($literal);";
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Generate javascript definitions for any editor widgets set
on columns for
+ * a partial list.
+ *
+ * @param $array_name the name of the javascript variable that
contains the column definitions
+ * @param $editors the list of editors, keyed by column key
+ * @return string javascript
+ */
+ public static function get_column_editors($array_name, $editors
= array())
+ {
+ $result = "for (var i in {$array_name}) {\n";
+ $result .= " switch ({$array_name}[i].key) {\n";
+ foreach ($editors as $field => $editor) {
+ $result .= " case '{$field}':\n";
+ $result .= "
{$array_name}[i].editor = {$editor};\n";
+ $result .= " break;\n";
+ }
+ $result .= " }\n";
+ $result .= "}";
+
+ return $result;
+ }
+
+ /**
+ * Returns a html-formatted error message if one is defined in
the
+ * list of validation errors on the object we're given. If no
+ * error is defined, an empty string is returned.
+ *
+ * @param $object the object to display errors for
+ * @param $field the name of the attribute to display errors for
+ * @return string a html formatted error message
+ */
+ public static function get_field_error($object, $field)
+ {
+ if(isset($object))
+ {
+ $errors = $object->get_validation_errors();
+
+ if ($errors[$field]) {
+ return '<label class="error" for="' .
$field . '">' . $errors[$field] . '</label>';
+ }
+ return '';
+ }
+ }
+
+ public static function get_messages($messages, $message_type)
+ {
+ $output = '';
+ if(is_array($messages) && count($messages) > 0) //
Array of messages
+ {
+ $output = "<div class=\"{$message_type}\">";
+ foreach($messages as $message)
+ {
+ $output .= "<p
class=\"message\">{$message}</p>";
+ }
+ $output .= "</div>";
+ }
+ else if($messages) {
+ $output = "<div class=\"{$message_type}\"><p
class=\"message\">{$messages}</p></div>";
+ }
+ return $output;
+ }
+ /**
+ * Returns a html-formatted error message to display on top of
the page. If
+ * no error is defined, an empty string is returned.
+ *
+ * @param $error the error to display
+ * @return string a html formatted error message
+ */
+ public static function get_page_error($errors)
+ {
+ return self::get_messages($errors, 'error');
+ }
+
+ /**
+ * Returns a html-formatted error message to display on top of
the page. If
+ * no error is defined, an empty string is returned.
+ *
+ * @param $error the error to display
+ * @return string a html formatted error message
+ */
+ public static function get_page_warning($warnings)
+ {
+ return self::get_messages($warnings, 'warning');
+ }
+
+ /**
+ * Returns a html-formatted info message to display on top of
the page. If
+ * no message is defined, an empty string is returned.
+ *
+ * @param $message the message to display
+ * @return string a html formatted info message
+ */
+ public static function get_page_message($messages)
+ {
+ return self::get_messages($messages, 'info');
+ }
+
+ /**
+ * Download xls, csv or similar file representation of a data
table
+ */
+ public function download()
+ {
+ $list = $this->query();
+ $list = $list['ResultSet']['Result'];
+
+ $keys = array();
+
+ if(count($list[0]) > 0) {
+ foreach($list[0] as $key => $value) {
+ if(!is_array($value)) {
+ array_push($keys, $key);
+ }
+ }
+ }
+
+ // Remove newlines from output
+ $count = count($list);
+ for($i = 0; $i < $count; $i++)
+ {
+ foreach ($list[$i] as $key => &$data)
+ {
+ $data = str_replace(array("\n","\r\n",
"<br>"),'',$data);
+ }
+ }
+
+ // Use keys as headings
+ $headings = array();
+ $count_keys = count($keys);
+ for($j=0;$j<$count_keys;$j++)
+ {
+ array_push($headings, lang($keys[$j]));
+ }
+
+ $property_common = CreateObject('property.bocommon');
+ $property_common->download($list, $keys, $headings);
+ }
+
+ /**
+ * Added because error reporting facilities in phpgw tries to
serialize the PDO
+ * instance in $this->db which causes an error. This method
removes $this->db from the
+ * serialized values to avoid this problem.
+ */
+ public function __sleep()
+ {
+ return array('table_name', 'fields');
+ }
+
+ }
+?>
Added: trunk/activitycalendar/inc/class.uiorganizationlist.inc.php
===================================================================
--- trunk/activitycalendar/inc/class.uiorganizationlist.inc.php
(rev 0)
+++ trunk/activitycalendar/inc/class.uiorganizationlist.inc.php 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,167 @@
+<?php
+phpgw::import_class('activitycalendar.uicommon');
+
+class activitycalendar_uiorganizationlist extends activitycalendar_uicommon
+{
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'query' => true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+ self::set_active_menu('booking::activities::organizationList');
+ $config = CreateObject('phpgwapi.config','activitycalendar');
+ $config->read();
+ }
+
+ public function index()
+ {
+ $this->render('organization_list.php', $data);
+ }
+
+
+ /**
+ * (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');
+
+ $config = CreateObject('phpgwapi.config','activitycalendar');
+ $config->read();
+ switch($type)
+ {
+ case 'included_parties': // ... get all parties
incolved in the contract
+ $filters = array('contract_id' => $contract_id);
+ break;
+ case 'not_included_parties': // ... get all parties not
included in the contract
+ $filters = array('not_contract_id' =>
$contract_id, 'party_type' => phpgw::get_var('party_type'));
+ break;
+ case 'sync_parties':
+ case 'sync_parties_res_unit':
+ case 'sync_parties_identifier':
+ case 'sync_parties_org_unit':
+ $filters = array('sync' => $type, 'party_type'
=> phpgw::get_var('party_type'), 'active' => phpgw::get_var('active'));
+ if($use_fellesdata)
+ {
+ $bofelles =
rental_bofellesdata::get_instance();
+ }
+ break;
+ default: // ... get all parties of a given type
+ //$filters = array('party_type' =>
phpgw::get_var('party_type'), 'active' => phpgw::get_var('active'));
+ break;
+ }
+
+ $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 $organization) {
+ if(isset($organization))
+ {
+ //$serialized = $party->serialize($contract);
+ $rows[] = $organization;
+ }
+ }
+ // ... add result data
+ $organization_data = array('results' => $rows, 'total_records'
=> $result_count);
+
+ $editable = phpgw::get_var('editable') == 'true' ? true : false;
+
+ if(!$export){
+ array_walk(
+ $party_data['results'],
+ array($this, 'add_actions'),
+ array(
// Parameters
(non-object pointers)
+ $contract_id,
// [1] The contract id
+ $type,
// [2] The type of query
+ //isset($contract) ?
$contract->serialize() : null, // [3] Serialized contract
+ $editable,
// [4] Editable flag
+ $this->type_of_user
// [5] User role
+ )
+ );
+ }
+
+
+ return $this->yui_results($organization_data, 'total_records',
'results');
+ }
+
+ /**
+ * Public method. Called when a user wants to view information about a
party.
+ * @param HTTP::id the party ID
+ */
+ public function view()
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('view');
+ // Get the contract part id
+ $party_id = (int)phpgw::get_var('id');
+ if(isset($party_id) && $party_id > 0)
+ {
+ $party =
rental_soparty::get_instance()->get_single($party_id);
+ }
+ else
+ {
+ $this->render('permission_denied.php',array('error' =>
lang('invalid_request')));
+ return;
+ }
+
+ if(isset($party) && $party->has_permission(PHPGW_ACL_READ))
+ {
+ return $this->render(
+ 'party.php',
+ array (
+ 'party' => $party,
+ 'editable' => false,
+ 'cancel_link' =>
self::link(array('menuaction' => 'rental.uiparty.index', 'populate_form' =>
'yes')),
+ )
+ );
+ }
+ else
+ {
+ $this->render('permission_denied.php',array('error' =>
lang('permission_denied_view_party')));
+ }
+ }
+
+ public function download_agresso(){
+ $browser = CreateObject('phpgwapi.browser');
+ $browser->content_header('export.txt','text/plain');
+ print rental_soparty::get_instance()->get_export_data();
+ }
+}
+?>
\ No newline at end of file
Added: trunk/activitycalendar/index.php
===================================================================
--- trunk/activitycalendar/index.php (rev 0)
+++ trunk/activitycalendar/index.php 2011-03-30 06:43:52 UTC (rev 7148)
@@ -0,0 +1,25 @@
+<?php
+ DEFINE('APP_NAME', 'activitycalendar');
+
+ $GLOBALS['phpgw_info']['flags'] = array
+ (
+ 'noheader' => true,
+ 'nonavbar' => true,
+ 'currentapp' => APP_NAME,
+ 'enable_vfs_class' => True,
+ );
+
+ include('../header.inc.php');
+
+ // Start page is set
+
if(isset($GLOBALS['phpgw_info']['user']['preferences'][APP_NAME]['default_start_page']))
+ {
+ $start_page = array('menuaction'=>
APP_NAME.'.ui'.$GLOBALS['phpgw_info']['user']['preferences'][APP_NAME]['default_start_page'].'.index');
+ }
+ else
+ {
+ $start_page = array('menuaction'=>
APP_NAME.'.uifrontpage.index');
+ }
+ $GLOBALS['phpgw']->redirect_link('/index.php',$start_page);
+
+?>
Added: trunk/activitycalendar/js/activitycalendar/common.js
===================================================================
--- trunk/activitycalendar/js/activitycalendar/common.js
(rev 0)
+++ trunk/activitycalendar/js/activitycalendar/common.js 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,259 @@
+YAHOO.namespace('activitycalendar');
+
+parseISO8601 = function (string) {
+ var regexp = "(([0-9]{4})(-([0-9]{1,2})(-([0-9]{1,2}))))?(
)?(([0-9]{1,2}):([0-9]{1,2}))?";
+ var d = string.match(new RegExp(regexp));
+ var year = d[2] ? (d[2] * 1 - 1900) : 0;
+ date = new Date(year, (d[4]||1)-1, d[6]||0);
+ if(d[9])
+ date.setHours(d[9]);
+ if(d[10])
+ date.setMinutes(d[10]);
+ return date;
+}
+
+
+YAHOO.activitycalendar.serializeForm = function(formID) {
+ var form = YAHOO.util.Dom.get(formID);
+ var values = [];
+ for(var i=0; i < form.elements.length; i++) {
+
+ var e = form.elements[i];
+
+ if(e.type=='checkbox' || e.type=='radio') {
+ if(e.checked) {
+ values.push(e.name + '=' +
encodeURIComponent(e.value));
+ }
+ }
+ else if(e.name) {
+ values.push(e.name + '=' + encodeURIComponent(e.value));
+ }
+ }
+ return values.join('&');
+}
+
+YAHOO.activitycalendar.formatLink = function(elCell, oRecord, oColumn, oData)
{
+ var name = oRecord.getData(oColumn.key);
+ var link = oRecord.getData('link');
+ elCell.innerHTML = '<a href="' + link + '">' + name + '</a>';
+};
+
+YAHOO.activitycalendar.formatGenericLink = function() {
+ links = [];
+ nOfLinks = arguments.length;
+
+ for (var i=0; i < nOfLinks; i++) { links[i] = arguments[i]; }
+
+ return function(elCell, oRecord, oColumn, oData)
+ {
+ nOfLinks = links.length;
+ data = oRecord.getData(oColumn.key);
+
+ linksHtml = '';
+ for (var i=0; i < nOfLinks; i++) {
+ linksHtml += '<div><a href="' + data[i] + '">' +
links[i] + '</a></div>';
+ }
+
+ elCell.innerHTML = linksHtml;
+ }
+};
+
+YAHOO.activitycalendar.autocompleteHelper = function(url, field, hidden,
container) {
+ var myDataSource = new YAHOO.util.DataSource(url);
+ myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+ myDataSource.connXhrMode = "queueRequests";
+ myDataSource.responseSchema = {
+ resultsList: "ResultSet.Result",
+ fields: ['name', 'id']
+ };
+ myDataSource.maxCacheEntries = 5;
+ var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
+ ac.queryQuestionMark = false;
+ ac.resultTypeList = false;
+ ac.forceSelection = true;
+ ac.itemSelectEvent.subscribe(function(sType, aArgs) {
+ YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
+ });
+ return ac;
+}
+
+YAHOO.activitycalendar.inlineTableHelper = function(container, url, colDefs,
options) {
+ options = options || {};
+ var myDataSource = new YAHOO.util.DataSource(url);
+ myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+ myDataSource.connXhrMode = "queueRequests";
+ myDataSource.responseSchema = {
+ resultsList: "ResultSet.Result",
+ metaFields : { totalResultsAvailable: "totalRecords" }
+ };
+ var myDataTable = new YAHOO.widget.DataTable(container, colDefs,
myDataSource, options);
+}
+
+YAHOO.activitycalendar.radioTableHelper = function(container, url, name,
selection) {
+ return YAHOO.activitycalendar.checkboxTableHelper(container, url, name,
selection, 'radio')
+}
+
+YAHOO.activitycalendar.checkboxTableHelper = function(container, url, name,
selection, type) {
+ type = type || 'checkbox';
+ selection = selection || [];
+ var myDataSource = new YAHOO.util.DataSource(url);
+ myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+ myDataSource.connXhrMode = "queueRequests";
+ myDataSource.responseSchema = {
+ resultsList: "ResultSet.Result",
+ metaFields : { totalResultsAvailable: "totalRecords" }
+ };
+ var checkboxFormatter = function(elCell, oRecord, oColumn, oData) {
+ var checked = '';
+ for(var i =0; i< selection.length; i++) {
+ if((selection[i] * 1) == (oData * 1)) {
+ var checked = 'checked="checked"';
+ }
+ }
+ // alert(selection.length);
+ // var checked = (selection.indexOf(oData * 1) != -1) ?
'checked="checked"' : '';
+ elCell.innerHTML = '<input type="' + type + '" name="' + name +
'" value="' + oData + '" ' + checked + '/>';
+ };
+ var colDefs = [
+ {key: "id", label: "", formatter: checkboxFormatter},
+ {key: "name", label: "Name", sortable: true}
+ ];
+ var myDataTable = new YAHOO.widget.DataTable(container, colDefs,
myDataSource, {
+ sortedBy: {key: 'name', dir: YAHOO.widget.DataTable.CLASS_ASC}
+ });
+}
+
+YAHOO.activitycalendar.setupDatePickers = function() {
+ YAHOO.util.Dom.getElementsByClassName('date-picker', null, null,
YAHOO.activitycalendar.setupDatePickerHelper, [true, false]);
+ YAHOO.util.Dom.getElementsByClassName('time-picker', null, null,
YAHOO.activitycalendar.setupDatePickerHelper, [false, true]);
+ YAHOO.util.Dom.getElementsByClassName('datetime-picker', null, null,
YAHOO.activitycalendar.setupDatePickerHelper, [true, true]);
+}
+
+YAHOO.activitycalendar.setupDatePickerHelper = function(field, args) {
+ if(field._converted)
+ return;
+ field._converted = true;
+ var date = args[0];
+ var time = args[1];
+ var Dom = YAHOO.util.Dom;
+ var Event = YAHOO.util.Event;
+ var oCalendarMenu = new YAHOO.widget.Overlay(Dom.generateId(), {
visible: false});
+ var oButton = new YAHOO.widget.Button({type: "menu", id:
Dom.generateId(), menu: oCalendarMenu, container: field});
+ oButton._calendarMenu = oCalendarMenu;
+ oButton._input = field._input = Dom.getElementsBy(function(){return
true;}, 'input', field)[0];
+ oButton.on("appendTo", function () {
+ this._calendarMenu.setBody(" ");
+ this._calendarMenu.body.id = Dom.generateId();
+ });
+ if(!date)
+ oButton.setStyle('display', 'none');
+ //oButton._input.setAttribute('type', 'hidden');
+ oButton._input.style.display = 'none';
+ if(oButton._input.value) {
+ oButton._date = parseISO8601(oButton._input.value);
+ }
+ else
+ oButton._date = new Date(-1, 4, 18);
+// oButton._date = new Date(109, 4, 18);
+ oButton._input._update = function() {
+ oButton._date = parseISO8601(oButton._input.value);
+ oButton._update();
+ }
+ oButton._update = function() {
+ var year = this._date.getYear() + 1900;
+ var month = this._date.getMonth() + 1;
+ var day = this._date.getDate();
+ var hours = this._date.getHours();
+ var minutes = this._date.getMinutes();
+ var month = month < 10 ? '0' + month : '' + month;
+ var day = day < 10 ? '0' + day : '' + day;
+ var hours = hours < 10 ? '0' + hours : '' + hours;
+ var minutes = minutes < 10 ? '0' + minutes : '' + minutes;
+ var dateValue = year + '-' + month + '-' + day;
+ var timeValue = hours + ':' + minutes;
+ if(year == 1899 || year == -1) {
+ this.set('label', 'Choose a date');
+ } else {
+ this.set('label', dateValue);
+ }
+ if(time) {
+ this._hours.set('label', hours);
+ this._minutes.set('label', minutes);
+ }
+ if(year != 1899 && date && time)
+ this._input.value = dateValue + ' ' + timeValue;
+ else if (year != 1899 && date)
+ this._input.value = dateValue;
+ else if(!date && time)
+ this._input.value = timeValue;
+ }
+
+ oButton.on("click", function () {
+ var oCalendar = new YAHOO.widget.Calendar(Dom.generateId(),
this._calendarMenu.body.id);
+ oCalendar._button = this;
+ if(this._date.getYear() == -1) {
+ var d = new Date();
+ oCalendar.cfg.setProperty("pagedate", (d.getMonth()+1)
+ "/" + d.getFullYear());
+ } else {
+ oCalendar.select(this._date);
+ oCalendar.cfg.setProperty("pagedate",
(this._date.getMonth()+1) + "/" + this._date.getFullYear());
+ }
+ oCalendar.render();
+ // Hide date picker on ESC
+ Event.on(this._calendarMenu.element, "keydown", function
(p_oEvent) {
+ if (Event.getCharCode(p_oEvent) === 27) {
+ this._calendarMenu.hide();
+ this.focus();
+ }
+ }, null, this);
+ oCalendar.selectEvent.subscribe(function (p_sType, p_aArgs) {
+ if (p_aArgs) {
+ var aDate = p_aArgs[0][0];
+// var year = aDate[0] > 100 ? aDate[0] - 1900 :
aDate[0];
+ this._date.setYear(aDate[0] - 1900);
+ this._date.setMonth(aDate[1]-1);
+ this._date.setDate(aDate[2]);
+ this._update();
+ //this._input.value = value;
+ }
+ this._calendarMenu.hide();
+ }, this, true);
+ });
+ if(time) {
+ var hourMenu = [{text: '00', value: 0}, {text: '01', value: 1},
{text: '02', value: 2}, {text: '03', value: 3}, {text: '04', value: 4}, {text:
'05', value: 5}, {text: '06', value: 6}, {text: '07', value: 7}, {text: '08',
value: 8}, {text: '09', value: 9}, {text: '10', value: 10}, {text: '11', value:
11}, {text: '12', value: 12}, {text: '13', value: 13}, {text: '14', value: 14},
{text: '15', value: 15}, {text: '16', value: 16}, {text: '17', value: 17},
{text: '18', value: 18}, {text: '19', value: 19}, {text: '20', value: 20},
{text: '21', value: 21}, {text: '22', value: 22}, {text: '23', value: 23}];
+ oButton._hours = new YAHOO.widget.Button({
+ type:
"menu",
+ id:
Dom.generateId(),
+ menu:
hourMenu,
+
container: field});
+ var minuteMenu = [{text: '00', value: 0}, {text: '15', value:
15}, {text: '30', value: 30}, {text: '45', value: 45}];
+ oButton._minutes = new YAHOO.widget.Button({
+ type:
"menu",
+ id:
Dom.generateId(),
+ menu:
minuteMenu,
+
container: field});
+ oButton._hours.getMenu().subscribe('click', function(p_sType,
p_aArgs) {
+ oMenuItem = p_aArgs[1];
+ this._date.setHours(oMenuItem.value);
+ this._update();
+ }, oButton, true);
+ oButton._minutes.getMenu().subscribe('click', function(p_sType,
p_aArgs) {
+ oMenuItem = p_aArgs[1];
+ this._date.setMinutes(oMenuItem.value);
+ this._update();
+ }, oButton, true);
+ }
+ oButton._update.apply(oButton);
+}
+
+// Executed on all activitycalendar.uicommon-based pages
+YAHOO.util.Event.addListener(window, "load", function() {
+ YAHOO.activitycalendar.setupDatePickers();
+});
+var showIfNotEmpty = function(event, fieldname) {
+ if (document.getElementById(fieldname).value.length > 1) {
+ YAHOO.util.Dom.replaceClass(fieldname + "_edit", "hideit", "showit");
+ } else {
+ YAHOO.util.Dom.replaceClass(fieldname + "_edit", "showit", "hideit");
+ }
+}
Property changes on: trunk/activitycalendar/js/activitycalendar/common.js
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/activitycalendar/setup/default_records.inc.php
===================================================================
--- trunk/activitycalendar/setup/default_records.inc.php
(rev 0)
+++ trunk/activitycalendar/setup/default_records.inc.php 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,31 @@
+<?php
+
+// Default user
+$GLOBALS['phpgw']->accounts = createObject('phpgwapi.accounts');
+$GLOBALS['phpgw']->acl = CreateObject('phpgwapi.acl');
+
+$modules = array
+(
+ 'activitycalendar',
+// 'preferences'
+);
+
+$aclobj =& $GLOBALS['phpgw']->acl;
+/*
+if (!$GLOBALS['phpgw']->accounts->exists('bookingguest') ) // no guest account
already exists
+{
+ $GLOBALS['phpgw_info']['server']['password_level'] = '8CHAR';
+ $account = new phpgwapi_user();
+ $account->lid = 'bookingguest';
+ $account->firstname = 'booking';
+ $account->lastname = 'Guest';
+ $account->passwd = 'bkbooking';
+ $account->enabled = true;
+ $account->expires = -1;
+ $bookingguest = $GLOBALS['phpgw']->accounts->create($account,
array(), array(), $modules);
+
+ $preferences = createObject('phpgwapi.preferences');
+ $preferences->set_account_id($bookingguest);
+ $preferences->add('activitycalendar','template_set','bkbooking');
+ $preferences->save_repository(true,$GLOBALS['type']);
+}*/
Added: trunk/activitycalendar/setup/phpgw_no.lang
===================================================================
--- trunk/activitycalendar/setup/phpgw_no.lang (rev 0)
+++ trunk/activitycalendar/setup/phpgw_no.lang 2011-03-30 06:43:52 UTC (rev
7148)
@@ -0,0 +1,326 @@
+current activities activitycalendar no Aktiviteter
+-- select an activity -- activitycalendar no Velg en
aktivitet
+why? activitycalendar no Hvorfor?
+where? activitycalendar no Hvor?
+when? activitycalendar no NÃ¥r?
+who? activitycalendar no Hvem?
+how many? activitycalendar no Hvor mange?
+accept application activitycalendar no Godta søknaden
+accepted activitycalendar no Akseptert
+account activitycalendar no Bruker
+actions activitycalendar no Handling
+active activitycalendar no Aktiv
+active applications activitycalendar no Aktive søknader
+activity activitycalendar no Aktivitet
+add a comment activitycalendar no Legg til en kommentar
+add another date activitycalendar no Legg til dato
+add boundary activitycalendar no Legg til rammetid
+add comment activitycalendar no Legg til kommentar
+add document activitycalendar no Legg til dokument
+add new event activitycalendar no Legg til arrangement
+add permission activitycalendar no Legg til rettighet
+address activitycalendar no Besøksadresse
+admin 1 activitycalendar no Bookingansvarlig 1
+admin 2 activitycalendar no Bookingansvarlig 2
+admins activitycalendar no Bookingansvarlige
+age group activitycalendar no Aldersgruppe
+agegroup activitycalendar no Aldersgruppe
+allocation activitycalendar no Tildeling
+allocations activitycalendar no Tildelinger
+allocations colliding with existing bookings or allocations (%1)
activitycalendar no Dobbel-booking som IKKE lagres
+allocations that can be created (%1) activitycalendar no
Tildelinger som kan lages
+application activitycalendar no Søknad
+applications activitycalendar no Søknader
+apr activitycalendar no april
+archived activitycalendar no Arkivert
+audience activitycalendar no MÃ¥lgruppe
+aug activitycalendar no august
+bookable resources activitycalendar no Bookbare ressurser
+booking activitycalendar no Booking
+booking district activitycalendar no Bydel
+booking name activitycalendar no Navn på booking
+bookings activitycalendar no Bookinger
+boundaries activitycalendar no Rammetid
+building activitycalendar no Bygg/anlegg
+building name activitycalendar no Bygg/anlegg
+building schedule activitycalendar no Kalender
+buildings activitycalendar no Bygg/anlegg
+bygning activitycalendar no Bygg/anlegg
+cancel activitycalendar no Avbryt
+cancelled activitycalendar no Avbestilt
+case officer activitycalendar no Saksbehandler
+category activitycalendar no Kategori
+choose a date activitycalendar no Velg dato
+choose a date activitycalendar no Velg en dato
+choose file activitycalendar no Velg dokument
+city activitycalendar no Poststed
+click to sort ascending activitycalendar no Klikk for å
sortere stigende
+click to sort descending activitycalendar no Klikk for å
sortere synkende
+contact activitycalendar no Kontakt
+contact 1 activitycalendar no Kontakt 1
+contact 2 activitycalendar no Kontakt 2
+contact person activitycalendar no Kontaktperson
+contact information activitycalendar no Kontaktinformasjon
+cost activitycalendar no Pris
+create activitycalendar no Lagre
+created activitycalendar no Opprettet
+dashboard activitycalendar no Skrivebord
+day of the week activitycalendar no Ukedag
+dec activitycalendar no desember
+description activitycalendar no Beskrivelse
+district activitycalendar no Bydel
+document activitycalendar no Dokument
+documents activitycalendar no Dokumenter
+document name activitycalendar no Dokumentnavn
+drawing activitycalendar no Tegning
+edit activitycalendar no Rediger
+edit agegroup group activitycalendar no Rediger aldersgruppe
+edit allocation activitycalendar no Rediger tildeling
+edit Audience group activitycalendar no Rediger målgruppe
+edit booking activitycalendar no Rediger booking
+edit event activitycalendar no Rediger arrangement
+edit organization activitycalendar no Rediger organisasjon
+editer activitycalendar no Rediger
+equipment activitycalendar no Utstyr
+equipment name activitycalendar no Utstyr
+event activitycalendar no Arrangement
+events activitycalendar no Arrangementer
+feb activitycalendar no februar
+female activitycalendar no Kvinne
+filnavn activitycalendar no Dokument
+found %1 results activitycalendar no %1 treff
+fr activitycalendar no fr.
+from activitycalendar no Fra
+generate allocations activitycalendar no Lag tildelning
+generate allocations from week template activitycalendar no
Lag tildelningar fra ukeplan
+go back to the template week activitycalendar no GÃ¥ tilbake til
ukeplan
+group activitycalendar no Gruppe/Lag
+history and comments (%1) activitycalendar no Historikk (%1)
+hms document activitycalendar no HMS dokument
+homepage activitycalendar no Hjemmeside
+id activitycalendar no ID
+inactivate activitycalendar no Inaktivert
+inactive activitycalendar no Inaktiv
+invoice information activitycalendar no Fakturainformasjon
+responsible applicant activitycalendar no Ansvarlig søker
+jan activitycalendar no januar
+jul activitycalendar no juli
+jun activitycalendar no juni
+last modified activitycalendar no Sist endret
+location activitycalendar no Lokale
+log on activitycalendar no Logg inn
+log off activitycalendar no Logg ut
+male activitycalendar no Mann
+mar activitycalendar no mars
+may activitycalendar no mai
+mo activitycalendar no ma.
+modified activitycalendar no Endret
+more info activitycalendar no Mer informasjon
+name activitycalendar no Navn
+new activitycalendar no Ny
+new activity activitycalendar no Ny aktivitet
+new age group activitycalendar no Ny aldersgruppe
+new allocation activitycalendar no Ny tildeling
+new application activitycalendar no Ny søknad
+new audience group activitycalendar no Ny målgruppe
+new booking activitycalendar no Ny booking
+new booking application activitycalendar no Ny søknad
+new building activitycalendar no Nytt bygg/anlegg
+new building permission activitycalendar no Nye rettigheter
bygg/anlegg
+new contact activitycalendar no Ny kontakt
+new document activitycalendar no Nye dokumenter
+new equipment activitycalendar no Nytt utstyr
+new event activitycalendar no Ny arrangement
+new group activitycalendar no Ny gruppe
+new organization activitycalendar no Ny organisajon
+new resource activitycalendar no Ny ressurs
+new root permission activitycalendar no Nye systemrettigheter
+new season activitycalendar no Ny sesong
+new season permission activitycalendar no Nye rettigheter sesong
+next activitycalendar no Neste
+next week activitycalendar no Neste uke
+no Data. activitycalendar no Ingen treff.
+no description yet activitycalendar no Beskrivelse mangler
+no parents activitycalendar no Ingen overordnet
+no records found. activitycalendar no Ingen treff.
+no records found. activitycalendar no Ingen funnet!
+nov activitycalendar no november
+number of participants activitycalendar no Antall deltakere
+estimated number of participants activitycalendar no
Estimert antall deltakere
+oct activitycalendar no oktober
+of activitycalendar no av
+officer activitycalendar no Saksbehandler
+organization activitycalendar no Organisasjon
+organization number activitycalendar no Organisasjonnummer
+organizations activitycalendar no Organisasjoner
+organization index activitycalendar no Organisasjonsoversikt
+other activitycalendar no Annet
+parent activity activitycalendar no Overordnet kategori
+parent id activitycalendar no Overordnet id
+permissions activitycalendar no Rettigheter
+phone activitycalendar no Telefon
+picture activitycalendar no Bilde
+planning activitycalendar no Planlegging
+prev activitycalendar no Forrige
+preview activitycalendar no Forhåndsvisning
+previous week activitycalendar no Forrige uke
+price list activitycalendar no Prisliste
+primary admin activitycalendar no Kontaktperson 1
+primary contact activitycalendar no Kontaktperson 1
+published activitycalendar no Publisert
+reject application activitycalendar no Avslå søknad
+rejected activitycalendar no Avvist
+resource activitycalendar no Ressurs
+resource name activitycalendar no Ressurs
+resource schedule activitycalendar no Ressurskalender
+resource type activitycalendar no Type
+resources activitycalendar no Ressurser
+role activitycalendar no Rolle
+root permissions activitycalendar no Systemrettigheter
+Sa activitycalendar no lø.
+schedule activitycalendar no Ukeplan
+season activitycalendar no Sesong
+season name activitycalendar no Sesong
+seasons activitycalendar no Sesonger
+secondary admin activitycalendar no Kontaktperson 2
+select a building first activitycalendar no Velg
bygg/anlegg først
+select a grooup activitycalendar no Velg en Gruppe
+select category... activitycalendar no Velg en kategori...
+select role... activitycalendar no Velg rolle...
+sep activitycalendar no september
+settings activitycalendar no Innstillinger
+show only active activitycalendar no Skjul
+showing items activitycalendar no Viser
+showing items {startRecord} - {endRecord} of {totalRecords}
activitycalendar no Viser {startRecord} - {endRecord} av
{totalRecords}
+social security number activitycalendar no Fødselsnummer (11
siffer)
+status activitycalendar no Status
+street activitycalendar no Gate
+su activitycalendar no sø
+submit activitycalendar no Lagre
+successfully created (%1) allocations: activitycalendar no (%1)
tildelinger lagret
+surname activitycalendar no Etternavn
+target audience activitycalendar no MÃ¥lgruppe
+telephone activitycalendar no Telefon
+terms and conditions activitycalendar no Juridiske betingelser
+th activitycalendar no to.
+to activitycalendar no Til
+tu activitycalendar no ti.
+upload document activitycalendar no Last opp dokument
+user activitycalendar no Bruker
+we activitycalendar no on.
+week activitycalendar no Uke
+week day activitycalendar no Ukedag
+week template activitycalendar no Ukeplan
+when activitycalendar no NÃ¥r
+when? activitycalendar no NÃ¥r?
+where activitycalendar no Hvor
+where? activitycalendar no Hvor?
+who activitycalendar no Hvem
+who? activitycalendar no Hvem?
+why activitycalendar no Hvorfor
+why? activitycalendar no Hvorfor?
+zip code activitycalendar no Postnummer
+postal city activitycalendar no Poststed
+team leaders activitycalendar no Ansvarlige gruppeledere
+team leader 1 activitycalendar no Ansvarlig gruppeleder 1
+team leader 2 activitycalendar no Ansvarlig gruppeleder 2
+regulation activitycalendar no Reglement
+Object No. activitycalendar no Objektnr.
+Article activitycalendar no Artikkel
+Unit No. activitycalendar no Fagavdelningsnr.
+Unit Prefix activitycalendar no Fagavdelnings kode (for
buntnummeret)
+Invoice Instruction activitycalendar no Topptekst til faktura
+Responsible Code activitycalendar no Ansvarssted
+Service activitycalendar no Tjeneste
+Project No. activitycalendar no Prosjektnr.
+Account Codes activitycalendar no Konteringsstrenger
+Account Codes activitycalendar no Konteringsstreng
+Field %1 is required activitycalendar no Feltet '%1' må fylles ut
+Field %1: Invalid format activitycalendar no Feltet '%1':
ugyldig format
+Building users activitycalendar no Brukere av bygg/anlegg
+Ssn activitycalendar no Fødselsnummer (11 siffer)
+Date of birth or SSN activitycalendar no Fødselsdato eller
fødselsnummer
+Interval activitycalendar no Interval
+Recurring booking activitycalendar no Gjenta booking
+Repeat until activitycalendar no Gjenta til
+1 week activitycalendar no 1 uke
+2 weeks activitycalendar no 2 uker
+3 weeks activitycalendar no 3 uker
+4 weeks activitycalendar no 4 uker
+Select a group activitycalendar no Velg Gruppe/Lag
+Bookings that can be created activitycalendar no Bookinger som
kan lages
+Please enter correct numbers for the event activitycalendar no
Vennlist oppgi korrekt deltakertall
+Report numbers activitycalendar no Rapporter deltakertall
+Thank you activitycalendar no Takk
+The data was successfully updated activitycalendar no Dataene
ble oppdatert uten feil
+Close activitycalendar no Lukke
+Create new booking activitycalendar no Lag ny booking
+You must accept to follow all terms and conditions of lease first.
activitycalendar no Du må akseptere alle juridiske betingelser
først.
+Invalid from date activitycalendar no Ugyldig fradato
+The user has accepted the following documents activitycalendar no
Brukeren har akseptert følgende dokument
+Send activitycalendar no Send
+Go back activitycalendar no Tilbake
+Your application has now been registered and a confirmation email has been
sent to you. activitycalendar no Søknaden har blitt sendt
inn, og en bekreftelse har blitt sendt til deg på e-post.
+A Case officer will review your application as soon as possible.
activitycalendar no En saksbehandler vil behandle søknaden så fort
som mulig.
+Loading... activitycalendar no Laster...
+customer_ssn contains an invalid Norwegian social security number (6 or 11
digits) activitycalendar no Fødselsdato/fødselsnummer er ikke
gyldig. Nummeret må bestå av 6 eller 11 siffer
+customer_organization_number is invalid activitycalendar no
Organisasjonsnummer er ugyldig
+Used buildings activitycalendar no Bygg/anlegg som brukes
+Add group activitycalendar no Ny gruppe
+Internal Customer activitycalendar no Intern kunde
+Customer number activitycalendar no Ressursnummer
+activity_id activitycalendar no Aktivitet
+contact_email activitycalendar no E-post
+contact_name activitycalendar no Navn
+customer_identifier_type activitycalendar no
Fakturainformasjon
+group_id activitycalendar no Gruppe/Lag
+dates activitycalendar no Fra/Til
+Information about the event activitycalendar no Informasjon om
arrangementet
+Short description. For public events, activities and training under the
direction of organizations and clubs, this information will be displayed on the
internet activitycalendar no Gi en kort beskrivelse av
arrangementet. For åpne arrangement, aktiviteter og trening i regi av
organisasjoner og klubber vises denne informasjonen på internett
+To borrow premises you must verify that you have read terms and conditions
activitycalendar no For å låne lokaler må du bekrefte at du har
lest juridiske betingelser
+In order to send the invoice we need information about either customer
organization number or norwegian social security number activitycalendar
no For å kunne sende faktura trenger vi opplysninger om organisasjonsnr.
eller fødselsnr.
+Private event activitycalendar no Privat arrangement
+Mass update activitycalendar no Masseoppdatering
+You are now about to update all bookings from this date and to the end of the
season. activitycalendar no Du er nå i ferd med å oppdatere alle
bookinger fra dagens dato og ut sesongen.
+Please update the data and click the Next-button. activitycalendar
no Vennligst oppdater dataene og klikk på Neste-knappen.
+When clicking the Next-button you will be presented to a list of bookings that
will be updated. activitycalendar no Etter at du har klikket
på Neste-knappen vil du få oversikt over hvilke bookinger som kommer til å bli
oppdatert.
+Update activitycalendar no Oppdater
+%1 bookings will be updated. activitycalendar no %1 bookinger
vil bli oppdatert.
+%1 bookings were updated. activitycalendar no %1 bookinger
ble oppdatert.
+Access denied activitycalendar no Ingen tilgang
+Print as PDF activitycalendar no Skriv ut som PDF
+Out season activitycalendar no Ut sesong
+Can not repeat from a date in the past activitycalendar no Du kan
ikke repetere fra en dato i fortiden.
+Can not create a booking in the past activitycalendar no Du kan
ikke opprette en booking i fortiden.
+Overlaps with existing event activitycalendar no Overlapper med
eksisterende arrangement
+Overlaps with existing allocation activitycalendar no
Overlapper med eksisterende tildeling
+Overlaps with existing booking activitycalendar no Overlapper med
eksisterende booking
+Overlaps other organizations allocation activitycalendar no
Overlapper med en annen organisasjons tildeling
+The booking uses resources not in the containing allocation
activitycalendar no Bookingen bruker ressurser som ikke finnes i
gitt tildeling
+CONFIRMED activitycalendar no BEKREFTET
+Pending activitycalendar no Under behandling
+This booking is not connected to a season activitycalendar no
Denne bookingen er ikke koblet mot en sesong
+The user has accepted the document under point 8. activitycalendar
no Brukeren har akseptert dokumentene under punkt 8.
+Organization shortname activitycalendar no Kortnavn
+Group shortname activitycalendar no Kortnavn
+Edit Group activitycalendar no Rediger gruppe
+contacts[0][email] contains an invalid email activitycalendar no
Ugyldig epost under ansvarlig gruppeleder 1
+contacts[1][email] contains an invalid email activitycalendar no
Ugyldig epost under ansvarlig gruppeleder 2
+This booking is outside the organization's allocated time
activitycalendar no Denne bookingen ligger utenfor organisasjonens
tildelte tid
+Time is set wrong activitycalendar no Et av klokkeslettene er
feil
+title activitycalendar no Tittel
+Message activitycalendar no Beskjed
+New system message activitycalendar no Ny system beskjed
+New message activitycalendar no Ny beskjed
+System message activitycalendar no System beskjed
+System messages activitycalendar no System beskjeder
+Edit System Message activitycalendar no Rediger system beskjed
+Send message activitycalendar no Send beskjed
+E-mail address activitycalendar no E-postadresse
+Confirm e-mail address activitycalendar no Bekreft e-postadressen
+The e-mail addresses you entered do not match activitycalendar no
E-postadressene er ikke like
+Lengt of shortname is to long, max 11 characters long activitycalendar
no Kortnavn er for langt, maks 11 tegn
+Go back to calendar activitycalendar no Tilbake til kalender
+Agegroups kan not be larger than 9999 peoples activitycalendar no
Estimert antall deltakere kan ikke være større en 9999 personer
+Contact information name is to long. max 50 characters activitycalendar
no Navn i kontakt informasjon er for langt. Maks 50 tegn
+Unable to fill report activitycalendar no Greide ikke å fylle ut
rapport
Added: trunk/activitycalendar/setup/setup.inc.php
===================================================================
--- trunk/activitycalendar/setup/setup.inc.php (rev 0)
+++ trunk/activitycalendar/setup/setup.inc.php 2011-03-30 06:43:52 UTC (rev
7148)
@@ -0,0 +1,44 @@
+<?php
+ $setup_info['activitycalendar']['name'] = 'activitycalendar';
+ $setup_info['activitycalendar']['version'] = '0.1';
+ $setup_info['activitycalendar']['app_order'] = 60;
+ $setup_info['activitycalendar']['enable'] = 1;
+ $setup_info['activitycalendar']['app_group'] = 'office';
+
+ $setup_info['activitycalendar']['tables'] = array
+ (
+ 'activity_activity',
+ 'activity_arena'
+ );
+
+ $setup_info['activitycalendar']['description'] = 'Bergen kommune
activitycalendar';
+
+ $setup_info['activitycalendar']['author'][] = array
+ (
+ 'name' => 'Bouvet ASA',
+ 'email' => 'address@hidden'
+ );
+
+ /* Dependencies for this app to work */
+ $setup_info['activitycalendar']['depends'][] = array(
+ 'appname' => 'phpgwapi',
+ 'versions' => Array('0.9.17', '0.9.18')
+ );
+
+ $setup_info['activitycalendar']['depends'][] = array(
+ 'appname' => 'booking',
+ 'versions' => Array('0.2.00',
'0.2.01','0.2.02','0.2.03','0.2.04','0.2.05')
+ );
+
+ $setup_info['activitycalendar']['depends'][] = array(
+ 'appname' => 'property',
+ 'versions' => Array('0.9.17')
+ );
+
+ /* The hooks this app includes, needed for hooks registration */
+/* $setup_info['activitycalendar']['hooks'] = array
+ (
+ 'menu' => 'activitycalendar.menu.get_menu',
+ 'config'
+ );*/
+?>
Added: trunk/activitycalendar/setup/tables_current.inc.php
===================================================================
--- trunk/activitycalendar/setup/tables_current.inc.php
(rev 0)
+++ trunk/activitycalendar/setup/tables_current.inc.php 2011-03-30 06:43:52 UTC
(rev 7148)
@@ -0,0 +1,36 @@
+<?php
+ $phpgw_baseline = array(
+ 'activity_activity' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'nullable' =>
FALSE),
+ 'organization_id' => array('type' => 'int',
'nullable' => True),
+ 'group_id' => array('type' => 'int', 'nullable'
=> True),
+ 'district' => array('type' =>
'varchar','precision' => '255'),
+ 'category' => array('type' => 'int', 'nullable'
=> True),
+ 'target' => array('type' => 'int', 'nullable'
=> True),
+ 'description' => array('type' =>
'varchar','precision' => '255'),
+ 'arena' => array('type' => 'int', 'nullable' =>
True),
+ 'date_start' => array('type' => 'int',
'precision' => '8', 'nullable' => true),
+ 'date_end' => array('type' => 'int',
'precision' => '8', 'nullable' => true),
+ 'contact_person_1' => array('type' =>
'varchar','precision' => '255'),
+ 'contact_person_2' => array('type' =>
'varchar','precision' => '255')
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'activity_arena' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'nullable' =>
FALSE),
+ 'internal_arena_id' => array('type' => 'int',
'nullable' => True),
+ 'arena_name' => array('type' =>
'varchar','precision' => '255','nullable' => false),
+ 'address' => array('type' =>
'varchar','precision' => '255')
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+?>
Added: trunk/activitycalendar/templates/base/activities.php
===================================================================
--- trunk/activitycalendar/templates/base/activities.php
(rev 0)
+++ trunk/activitycalendar/templates/base/activities.php 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,136 @@
+<?php
+?>
+<table>
+ <tr>
+
<th>Navn</th><th>bydel</th><th>kategori</th><th>målgruppe</th><th>arena</th><th>kontor</th><th>epost</th><th>dato
oppdatert</th>
+ </tr>
+ <tr>
+ <td>test</td><td>Fana</td><td>idrett</td><td>alle</td><td>Fana
bydelshus</td><td>Fana</td><td>address@hidden</td><td>2011-03-24</td>
+ </tr>
+</table>
+<hr/>
+
+<div class="toolbar-container"><div class="toolbar"><form method="POST"
action="/pe/index.php?menuaction=property.uilocation.index&type_id=1&district_id=&part_of_town_id=&cat_id=&click_history=ed9d0b13fdf51556bfabd136e6d73aee">
+<div style="float:left" class="field"><input id="btn_cat_id" type="button"
name="cat_id" value="Kategori" class="button" tabindex="1"></div>
+<div style="float:left" class="field"><input id="btn_district_id"
type="button" name="district_id" value="Område" class="button"
tabindex="2"></div>
+
+<div style="float:left" class="field"><input id="btn_part_of_town_id"
type="button" name="part_of_town_id" value="Bydel" class="button"
tabindex="3"></div>
+<div style="float:left" class="field"><input id="btn_owner_id" type="button"
name="owner_id" value="Filter" class="button" tabindex="4"></div>
+<div style="float:right" class="field"><a id="btn_columns" href="#"
onclick="Javascript:window.open('/pe/index.php?menuaction=property.uilocation.columns&type_id=1&click_history=ed9d0b13fdf51556bfabd136e6d73aee','','width=300,height=600,scrollbars=1')"
tabindex="9">kolonner</a></div>
+<div style="float:right" class="field"><input id="btn_export" type="button"
name="" value="Last ned" class="button" tabindex="8"></div>
+<div style="float:right" class="field"><input id="type_id" type="hidden"
name="" value="1" class="hidden"></div>
+<div style="float:right" class="field"><input id="btn_search" type="button"
name="search" value="Søk" class="button" tabindex="6"></div>
+<div style="float:right" class="field"><input id="txt_query" type="text"
name="query" value="" class="text" size="28" tabindex="5" onkeypress="return
pulsar(event)"></div>
+<div style="float:right" class="field"><input id="btn_new" type="button"
name="" value="Legg til" class="button" tabindex="7"></div>
+</form></div></div><script type="text/javascript">
+ function Exchange_values(data)
+ {
+
+ }
+ </script><br><div id="message"></div><div
id="paging"></div><div class="datatable-container"></div><div
id="datatable-detail"
style="background-color:#000000;color:#FFFFFF;display:none">
+<div class="hd" style="background-color:#000000;color:#000000; border:0;
text-align:center"> Record Detail </div>
+<div class="bd" style="text-align:center;"></div>
+</div><div id="footer"></div>
+<script type="text/javascript">
+ var allow_allrows = "1";
+
+ var property_js = "/pe/property/js/yahoo/property.js";
+
+ var base_java_url =
"{menuaction:'property.uilocation.index',type_id:'1',query:'',district_id:
'',part_of_town_id:'',lookup:'',second_display:1,lookup_tenant:'',lookup_name:'',cat_id:'',status:'',location_code:'',block_query:''}";
+
+
+ var json_data =
{"recordsReturned":"10","totalRecords":626,"startIndex":0,"sort":"loc1","dir":"asc","records":[],"integrationurl":"","hidden":{"dependent":[{"id":"","value":"#!no
part of address@hidden address@hidden address@hidden address@hidden
address@hidden address@hidden address@hidden address@hidden@6#YTREBYGDA
BYDEL@"}]},"rights":[{"my_name":"view","text":"Kontrakter","action":"\/pe\/index.php?menuaction=rental.uicontract.index&search_type=location_id&contract_status=all&populate_form=yes&click_history=ed9d0b13fdf51556bfabd136e6d73aee","parameters":{"parameter":[{"name":"search_for","source":"location_code"}]}},{"my_name":"view","text":"Vis","action":"\/pe\/index.php?menuaction=property.uilocation.view&click_history=ed9d0b13fdf51556bfabd136e6d73aee","parameters":{"parameter":[{"name":"location_code","source":"location_code"}]}},{"my_name":"view","text":"\u00c5pne
visning i nytt
vindu","action":"\/pe\/index.php?menuaction=property.uilocation.view&target=_blank&click_history=ed9d0b13fdf51556bfabd136e6d73aee","parameters":{"parameter":[{"name":"location_code","source":"location_code"}]}}]};
+
+
+ var myColumnDefs = [
+
+ {
+ key: "location_code",
+ label: "dummy",
+ resizeable:true,
+ sortable: false,
+ visible: false,
+ format: "hidden",
+ formatter: "",
+ source: "",
+ className: ""
+ },
+ {
+ key: "loc1",
+ label: "Eiendom",
+ resizeable:true,
+ sortable: true,
+ visible: true,
+ format: "number",
+ formatter: "",
+ source: "fm_location1.loc1",
+ className: ""
+ },
+ {
+ key: "loc1_name",
+ label: "Eiendom Navn",
+ resizeable:true,
+ sortable: false,
+ visible: true,
+ format: "varchar",
+ formatter: "",
+ source: "",
+ className: ""
+ },
+ {
+ key: "adresse1",
+ label: "Adresse1",
+ resizeable:true,
+ sortable: true,
+ visible: true,
+ format: "varchar",
+ formatter: "",
+ source: "adresse1",
+ className: ""
+ },
+ {
+ key: "postnummer",
+ label: "Postnummer",
+ resizeable:true,
+ sortable: true,
+ visible: true,
+ format: "number",
+ formatter: "",
+ source: "postnummer",
+ className: ""
+ },
+ {
+ key: "poststed",
+ label: "Poststed",
+ resizeable:true,
+ sortable: true,
+ visible: true,
+ format: "varchar",
+ formatter: "",
+ source: "poststed",
+ className: ""
+ }
+ ];
+
+ var values_combo_box = [
+
+ {
+ id: "values_combo_box_0",
+ value: "#Kategori ikke
address@hidden@11#AN01 - ANDRE address@hidden - ANDRE address@hidden EIENDOM
@address@hidden - FESTET address@hidden@14#BY01- address@hidden@15#FR01 -
address@hidden - address@hidden@address@hidden@address@hidden address@hidden -
address@hidden - address@hidden - address@hidden@99#SOLGT/address@hidden -
address@hidden - TRANSFORMATORKIOSK @21#VE01 - VEIGRUNN@"
+ },
+ {
+ id: "values_combo_box_1",
+ value: "#Distrikt ikke
address@hidden/address@hidden/address@hidden/address@hidden/address@hidden@"
+ },
+ {
+ id: "values_combo_box_2",
+ value: "#Bydel ikke address@hidden
address@hidden address@hidden address@hidden address@hidden address@hidden
address@hidden address@hidden@6#YTREBYGDA BYDEL@"
+ },
+ {
+ id: "values_combo_box_3",
+ value: "#vis address@hidden@2#Ekstern@"
+ }
+ ];
+
+
+ </script>
\ No newline at end of file
Added: trunk/activitycalendar/templates/base/arena.php
===================================================================
--- trunk/activitycalendar/templates/base/arena.php
(rev 0)
+++ trunk/activitycalendar/templates/base/arena.php 2011-03-30 06:43:52 UTC
(rev 7148)
@@ -0,0 +1,3 @@
+<?php
+?>
+<h1>Dette er en test</h1>
\ No newline at end of file
Added: trunk/activitycalendar/templates/base/common.php
===================================================================
--- trunk/activitycalendar/templates/base/common.php
(rev 0)
+++ trunk/activitycalendar/templates/base/common.php 2011-03-30 06:43:52 UTC
(rev 7148)
@@ -0,0 +1,960 @@
+<script type="text/javascript">
+
+/**
+ * Javascript for the activitycalendar module. Holds datasource init
functions and form helpers.
+ *
+ * Functions and objects within this file are kept in the
YAHOO.activitycalendar namespace.
+ */
+
+ // Holds data source setup funtions
+ YAHOO.activitycalendar.setupDatasource = new Array();
+
+ //Holds all data sources
+ YAHOO.activitycalendar.datatables = new Array();
+
+ counter = 0;
+ // Adds data source setup funtions
+ function setDataSource(source_url, column_defs, form_id, filter_ids,
container_id, paginator_id, datatable_id,rel_id, editor_action,
disable_left_click) {
+ YAHOO.activitycalendar.setupDatasource.push(
+ function() {
+ this.url = source_url;
+ this.columns = column_defs;
+ this.form = form_id;
+ this.filters = filter_ids;
+ this.container = container_id;
+ this.paginator = paginator_id;
+ this.tid = datatable_id;
+ this.related_datatable = rel_id;
+ this.editor_action = editor_action;
+ if(disable_left_click) {
+ this.disable_left_click = true;
+ } else {
+ this.disable_left_click = false;
+ }
+ }
+ );
+ }
+
+ YAHOO.activitycalendar.formatDate = function(elCell, oRecord, oColumn,
oData) {
+ //alert("oDate: " + oData);
+ if (oData && oData != "Invalid Date" && oData != "NaN") {
+ var my_date = Math.round(Date.parse(oData) / 1000);
+ elCell.innerHTML = formatDate('<?php echo
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] ?>',
my_date);
+ } else {
+ elCell.innerHTML = "";
+ }
+ };
+
+ // Override the built-in formatter
+ YAHOO.widget.DataTable.formatCurrency = function(elCell, oRecord,
oColumn, oData) {
+ if (oData != undefined) {
+ elCell.innerHTML = YAHOO.util.Number.format( oData,
+ {
+ prefix: "<?php echo
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'].' ' ?>",
+ thousandsSeparator: ",",
+ decimalPlaces: 2
+ });
+ }
+ //if (oData != undefined) {
+ // elCell.innerHTML = '<?php echo
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'].' ' ?>' +
parseFloat(oData).toFixed(2);
+ //}
+ };
+
+ // Reloads all data sources that are necessary based on the selected
related datatable
+ function reloadDataSources(selected_datatable){
+
+ //... hooks into the regular callback function
(onDataReturnInitializeTable) call to set empty payload array
+ var loaded = function ( sRequest , oResponse , oPayload ) {
+ var payload = new Array();
+ this.onDataReturnInitializeTable( sRequest , oResponse
, payload );
+ }
+
+ //... refresh the selected data tables
+
selected_datatable.getDataSource().sendRequest('',{success:loaded,
scope:selected_datatable});
+
+ //... traverse all datatables and refresh related (to the
selected) data tables
+ for(var i=0; i<YAHOO.activitycalendar.datatables.length; i++){
+ var datatable = YAHOO.activitycalendar.datatables[i];
+
+ for(var j=0;j<selected_datatable.related.length;j++){
+ var curr_related =
selected_datatable.related[j];
+ if(datatable.tid == curr_related){
+
datatable.getDataSource().sendRequest('',{success:loaded,scope: datatable});
+ }
+ }
+ }
+ }
+
+ var highlightEditableCell = function(oArgs) {
+ var elCell = oArgs.target;
+ if(YAHOO.util.Dom.hasClass(elCell, "yui-dt-editable")) {
+ this.highlightCell(elCell);
+ }
+ };
+
+ // Wraps data sources setup logic
+ function dataSourceWrapper(source_properties,pag) {
+
+ this.properties = source_properties;
+ this.paginator = pag;
+
+ //... prepare base url
+ this.url = this.properties.url;
+ if(this.url[length-1] != '&') {
+ this.url += '&';
+ }
+
+ //... set up a new data source
+ this.source = new YAHOO.util.DataSource(this.url);
+
+ this.source.responseType = YAHOO.util.DataSource.TYPE_JSON;
+ this.source.connXhrMode = "queueRequests";
+
+ this.source.responseSchema = {
+ resultsList: "ResultSet.Result",
+ fields: this.properties.columns,
+ metaFields : {
+ totalRecords: "ResultSet.totalRecords"
+ }
+ };
+
+ //... set up a new data table
+ if(this.properties.tid == 'total_price')
+ {
+ //if the datatable is display of total price on
contract, always initialize
+ this.table = new YAHOO.widget.DataTable(
+ this.properties.container,
+ this.properties.columns,
+ this.source,
+ {
+ paginator: this.paginator,
+ dynamicData: true,
+ MSG_EMPTY: '<?php echo
lang("DATATABLE_MSG_EMPTY")?>',
+ MSG_ERROR: '<?php echo
lang("DATATABLE_MSG_ERROR")?>',
+ MSG_LOADING: '<?php echo
lang("DATATABLE_MSG_LOADING")?>'
+ }
+ );
+ }
+ else
+ {
+ this.table = new YAHOO.widget.DataTable(
+ this.properties.container,
+ this.properties.columns,
+ this.source,
+ {
+ paginator: this.paginator,
+ dynamicData: true,
+ <?php
+ $populate =
phpgw::get_var('populate_form');
+ echo isset($populate)?
'initialLoad: false,':''
+ ?>
+ <?php
+ $initLoad =
phpgw::get_var('initial_load');
+ echo ($initLoad == 'no')?
'initialLoad: false,':''
+ ?>
+ MSG_EMPTY: '<?php echo
lang("DATATABLE_MSG_EMPTY")?>',
+ MSG_ERROR: '<?php echo
lang("DATATABLE_MSG_ERROR")?>',
+ MSG_LOADING: '<?php echo
lang("DATATABLE_MSG_LOADING")?>'
+ }
+ );
+ }
+
+ //... set table properties
+ this.table.related = this.properties.related_datatable;
+ this.table.tid = this.properties.tid;
+ this.table.container_id = this.properties.container;
+ this.table.editor_action = this.properties.editor_action;
+
+ //... push the data table on a stack
+ YAHOO.activitycalendar.datatables.push(this.table);
+
+ //... ?
+ this.table.handleDataReturnPayload = function(oRequest,
oResponse, oPayload) {
+ if(oPayload){
+ oPayload.totalRecords =
oResponse.meta.totalRecords;
+ return oPayload;
+ }
+ }
+
+ //... create context menu for each record after the table has
loaded the data
+ this.table.doAfterLoadData = function() {
+ onContextMenuBeforeShow = function(p_sType, p_aArgs)
+ {
+ var oTarget = this.contextEventTarget;
+ if (this.getRoot() == this)
+ {
+ if(oTarget.tagName != "TD")
+ {
+ oTarget =
YAHOO.util.Dom.getAncestorByTagName(oTarget, "td");
+ }
+ oSelectedTR =
YAHOO.util.Dom.getAncestorByTagName(oTarget, "tr");
+ oSelectedTR.style.backgroundColor =
'#AAC1D8' ;
+ oSelectedTR.style.color = "black";
+ YAHOO.util.Dom.addClass(oSelectedTR,
prefixSelected);
+ }
+ }
+
+ onContextMenuHide = function(p_sType, p_aArgs)
+ {
+ if (this.getRoot() == this && oSelectedTR)
+ {
+ oSelectedTR.style.backgroundColor = ""
;
+ oSelectedTR.style.color = "";
+ YAHOO.util.Dom.removeClass(oSelectedTR,
prefixSelected);
+ }
+ }
+
+ var records = this.getRecordSet();
+ var validRecords = 0;
+ for(var i=0; i<records.getLength(); i++) {
+ var record = records.getRecord(i);
+ if(record == null)
+ {
+ continue;
+ }
+ else
+ {
+ validRecords++;
+ }
+
+ // use a global counter to create unique names
(even for the same datatable) for all context menues on the page
+ var menuName = this.container_id + "_cm_" +
counter;
+ counter++;
+
+ //... add menu items with label and handler
function for click events
+ var labels = record.getData().labels;
+ //create a context menu that triggers on the
HTML row element
+ record.menu = new
YAHOO.widget.ContextMenu(menuName,{trigger:this.getTrEl(validRecords -1
),itemdata: labels, lazyload: true});
+
+ //... subscribe handler for click events
+
record.menu.clickEvent.subscribe(onContextMenuClick, this);
+ record.menu.subscribe("beforeShow",
onContextMenuBeforeShow);
+ record.menu.subscribe("hide",
onContextMenuHide);
+
+ //... render the menu on the related table row
+
record.menu.render(this.getTrEl(validRecords-1));
+ }
+
+
+ }
+
+ //... calback methods for handling ajax calls
+ var ajaxResponseSuccess = function(o){
+ reloadDataSources(this.args);
+ };
+
+ var ajaxResponseFailure = function(o){
+ reloadDataSources(this.args);
+ };
+
+ //...create a handler for context menu clicks
+ var onContextMenuClick = function(eventString, args, table) {
+ //... the argument holds the selected index number in
the context menu
+ var task = args[1];
+ //... only act on a data table
+ if(table instanceof YAHOO.widget.DataTable) {
+ //... retrieve the record based on the selected
table row
+ var row =
table.getTrEl(this.contextEventTarget);
+ var record = table.getRecord(row);
+
+ //... check whether this action should be an
AJAX call
+ if(record.getData().ajax[task.index]) {
+ var request =
YAHOO.util.Connect.asyncRequest(
+ 'GET',
+ record.getData().actions[
task.index ],
+ {
+ success:
ajaxResponseSuccess,
+ success:
ajaxResponseFailure,
+ args:table
+ });
+ } else {
+ window.location =
record.getData().actions[task.index];
+ }
+ }
+ };
+
+ // Handle mouseover and click events for inline editing
+ this.table.subscribe("cellMouseoverEvent",
highlightEditableCell);
+ this.table.subscribe("cellMouseoutEvent",
this.table.onEventUnhighlightCell);
+ this.table.subscribe("cellClickEvent",
this.table.onEventShowCellEditor);
+
+ this.table.subscribe("editorSaveEvent", function(oArgs) {
+ var field = oArgs.editor.getColumn().field;
+ var value = oArgs.newData;
+ var id = oArgs.editor.getRecord().getData().id;
+ var action = oArgs.editor.getDataTable().editor_action;
+
+ // Translate to unix time if the editor is a calendar.
+ if (oArgs.editor._sType == 'date') {
+ var selectedDate =
oArgs.editor.calendar.getSelectedDates()[0];
+ //alert("selDate1: " + selectedDate);
+ // Make sure we're at midnight GMT
+ selectedDate = selectedDate.toString().split("
");
+ //for(var e=0;e<selectedDate.length;e++){
+ // alert("element " + e + ": " +
selectedDate[e]);
+ //}
+ if(selectedDate[3] == "00:00:00"){
+ // alert("seldate skal byttes!");
+ selectedDate =
selectedDate.slice(0,3).join(" ") + " " + selectedDate[5] + " 00:00:00 GMT";
+ }
+ else{
+ selectedDate =
selectedDate.slice(0,4).join(" ") + " 00:00:00 GMT";
+ }
+ //selectedDate =
selectedDate.toString().split(" ").slice(0, 4).join(" ") + " 00:00:00 GMT";
+ //alert("selDate2: " + selectedDate);
+ var value = Math.round(Date.parse(selectedDate)
/ 1000);
+ //alert("selDate3 value: " + value);
+ }
+
+ var request = YAHOO.util.Connect.asyncRequest(
+ 'GET',
+ 'index.php?menuaction=' + action +
"&field=" + field + "&value=" + value + "&id=" + id,
+ {
+ success: ajaxResponseSuccess,
+ failure: ajaxResponseFailure,
+ args:oArgs.editor.getDataTable()
+ }
+ );
+ });
+
+ // Don't set the row to be left-clickable if the table is
editable by inline editors.
+ // In that case we use cellClickEvents instead
+ var table_should_be_clickable = true;
+ for (i in this.properties.columns) {
+ if (this.properties.columns[i].editor) {
+ table_should_be_clickable = false;
+ }
+ }
+
+ if (table_should_be_clickable &&
!this.properties.disable_left_click) {
+ //... create a handler for regular clicks on a table row
+ this.table.subscribe("rowClickEvent", function(e,obj) {
+ YAHOO.util.Event.stopEvent(e);
+
+ //... trigger first action on row click
+ var row = obj.table.getTrEl(e.target);
+ if(row) {
+ var record = obj.table.getRecord(row);
+
+ //... check whether this action should
be an AJAX call
+ if(record.getData().ajax[0]) {
+ var request =
YAHOO.util.Connect.asyncRequest(
+ 'GET',
+ //... execute first
action
+
record.getData().actions[0],
+ {
+ success:
ajaxResponseSuccess,
+ failure:
ajaxResponseFailure,
+ args:obj.table
+ }
+ );
+ } else {
+ //... execute first action
+ window.location =
record.getData().actions[0];
+ }
+ }
+ },this);
+
+ //... highlight rows on mouseover. This too only
happens if the table is
+ // not editable.
+ this.table.subscribe("rowMouseoverEvent",
this.table.onEventHighlightRow);
+ this.table.subscribe("rowMouseoutEvent",
this.table.onEventUnhighlightRow);
+ }
+
+
+ //... create context menues when the table renders
+ this.table.subscribe("renderEvent",this.table.doAfterLoadData);
+
+ //... listen for form submits and filter changes
+
YAHOO.util.Event.addListener(this.properties.form,'submit',formListener,this,true);
+ YAHOO.util.Event.addListener(this.properties.filters,
'change',formListener,this,true);
+ }
+
+
+ // Set up data sources when the document has loaded
+ YAHOO.util.Event.addListener(window, "load", function() {
+ var i = 0;
+ while(YAHOO.activitycalendar.setupDatasource.length > 0){
+ //... create a variable name, assign set up function to
that variable and instantiate properties
+ variableName = "YAHOO.activitycalendar.datasource" + i;
+ eval(variableName + " =
YAHOO.activitycalendar.setupDatasource.shift()");
+ var source_properties = eval("new " + variableName +
"()");
+
+<?php
+ 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;
+ }
+?>
+
+ // ... create a paginator for this datasource
+ var pag = new YAHOO.widget.Paginator({
+ rowsPerPage: <?php echo $user_rows_per_page ?>,
+ alwaysVisible: true,
+ rowsPerPageOptions: [5, 10, 25, 50, 100, 200],
+ firstPageLinkLabel: "<< <?php echo
lang('first') ?>",
+ previousPageLinkLabel: "< <?php echo
lang('previous') ?>",
+ nextPageLinkLabel: "<?php echo lang('next') ?>
>",
+ lastPageLinkLabel: "<?php echo lang('last') ?>
>>",
+ template :
"{RowsPerPageDropdown}<?php echo lang('elements_pr_page')
?>.{CurrentPageReport}<br/> {FirstPageLink} {PreviousPageLink} {PageLinks}
{NextPageLink} {LastPageLink}",
+ pageReportTemplate : "<?php echo
lang('shows_from') ?> {startRecord} <?php echo lang('to') ?> {endRecord} <?php
echo lang('of_total') ?> {totalRecords}.",
+ containers: [source_properties.paginator]
+ });
+
+ pag.render();
+
+ //... send data source properties and paginator to
wrapper function
+ this.wrapper = new dataSourceWrapper(source_properties,
pag);
+ i+=1;
+
+ <?php
+ $populate = phpgw::get_var('populate_form');
+ if(isset($populate)){?>
+ var qs =
YAHOO.activitycalendar.serializeForm(source_properties.form);
+ this.wrapper.source.liveData =
this.wrapper.url + qs + '&';
+ this.wrapper.source.sendRequest('',
{success: function(sRequest, oResponse, oPayload) {
+
this.wrapper.table.onDataReturnInitializeTable(sRequest, oResponse,
this.wrapper.paginator);
+ }, scope: this});
+ <?php }
+ ?>
+
+ // XXX: Create generic column picker for all datasources
+
+ // Shows dialog, creating one when necessary
+ var newCols = true;
+ var showDlg = function(e) {
+ YAHOO.util.Event.stopEvent(e);
+
+ if(newCols) {
+ // Populate Dialog
+ // Using a template to create elements
for the SimpleDialog
+ var allColumns =
this.wrapper.table.getColumnSet().keys;
+ var elPicker =
YAHOO.util.Dom.get("dt-dlg-picker");
+ var elTemplateCol =
document.createElement("div");
+ YAHOO.util.Dom.addClass(elTemplateCol,
"dt-dlg-pickercol");
+ var elTemplateKey =
elTemplateCol.appendChild(document.createElement("span"));
+ YAHOO.util.Dom.addClass(elTemplateKey,
"dt-dlg-pickerkey");
+ var elTemplateBtns =
elTemplateCol.appendChild(document.createElement("span"));
+ YAHOO.util.Dom.addClass(elTemplateBtns,
"dt-dlg-pickerbtns");
+ var onclickObj = {fn:handleButtonClick,
obj:this, scope:false };
+
+ // Create one section in the
SimpleDialog for each Column
+ var elColumn, elKey, elButton,
oButtonGrp;
+
+ for(var
i=0,l=allColumns.length;i<l;i++) {
+ var oColumn = allColumns[i];
+ if(oColumn.label !=
'unselectable') { // We haven't marked the column as unselectable for the user
+ // Use the template
+ elColumn =
elTemplateCol.cloneNode(true);
+
+ // Write the Column key
+ elKey =
elColumn.firstChild;
+ elKey.innerHTML =
oColumn.label;
+
+ // Create a ButtonGroup
+ oButtonGrp = new
YAHOO.widget.ButtonGroup({
+ id:
"buttongrp"+i,
+ name:
oColumn.getKey(),
+ container:
elKey.nextSibling
+ });
+ oButtonGrp.addButtons([
+ { label: "Vis",
value: "Vis", checked: ((!oColumn.hidden)), onclick: onclickObj},
+ { label:
"Skjul", value: "Skjul", checked: ((oColumn.hidden)), onclick: onclickObj}
+ ]);
+
+
elPicker.appendChild(elColumn);
+ }
+ }
+
+ newCols = false;
+ }
+
+ myDlg.show();
+ };
+
+ var storeColumnsUrl =
YAHOO.activitycalendar.storeColumnsUrl;
+ var hideDlg = function(e) {
+ this.hide();
+ // After we've hidden the dialog we send a post
call to store the columns the user has selected
+ var postData = 'values[save]=1';
+ var allColumns =
wrapper.table.getColumnSet().keys;
+ for(var i=0; i < allColumns.length; i++) {
+ if(!allColumns[i].hidden){
+ postData +=
'&values[columns][]=' + allColumns[i].getKey();
+ }
+ }
+
+ YAHOO.util.Connect.asyncRequest('POST',
storeColumnsUrl, null, postData);
+ };
+
+ var handleButtonClick = function(e, oSelf) {
+ var sKey = this.get("name");
+ if(this.get("value") === "Skjul") {
+ // Hides a Column
+ wrapper.table.hideColumn(sKey);
+ } else {
+ // Shows a Column
+ wrapper.table.showColumn(sKey);
+ }
+ };
+
+ // Create the SimpleDialog
+ YAHOO.util.Dom.removeClass("dt-dlg", "inprogress");
+ var myDlg = new YAHOO.widget.SimpleDialog("dt-dlg", {
+ width: "30em",
+ visible: false,
+ modal: false, // modal: true doesn't work for
some reason - the dialog becomes unclickable
+ buttons: [
+ {text:"Lukk", handler:hideDlg}
+ ],
+ fixedcenter: true,
+ constrainToViewport: true
+ });
+ myDlg.render();
+
+ // Nulls out myDlg to force a new one to be created
+ wrapper.table.subscribe("columnReorderEvent",
function(){
+ newCols = true;
+ YAHOO.util.Event.purgeElement("dt-dlg-picker",
true);
+ YAHOO.util.Dom.get("dt-dlg-picker").innerHTML =
"";
+ }, this, true);
+
+ // Hook up the SimpleDialog to the link
+ YAHOO.util.Event.addListener("dt-options-link",
"click", showDlg, this, true);
+ }
+ });
+
+ /*
+ * Listen for events in form. Serialize all form elements. Stop
+ * the original request and send new request.
+ */
+ function formListener(event){
+ YAHOO.util.Event.stopEvent(event);
+ var qs =
YAHOO.activitycalendar.serializeForm(this.properties.form);
+ this.source.liveData = this.url + qs + '&';
+ this.source.sendRequest('', {success: function(sRequest, oResponse,
oPayload) {
+ this.table.onDataReturnInitializeTable(sRequest, oResponse,
this.paginator);
+ }, scope: this});
+ }
+
+
+
+// TODO: All the calendar data must be removed when the 'old' calender is no
longer used.
+
+// CALENDAR LOGIC
+
+function onClickOnInput(event)
+{
+ this.align();
+ this.show();
+}
+
+function closeCalender(event)
+{
+ YAHOO.util.Event.stopEvent(event);
+ this.hide();
+}
+
+function clearCalendar(event)
+{
+ YAHOO.util.Event.stopEvent(event);
+ this.clear();
+ document.getElementById(this.inputFieldID).value = '';
+ document.getElementById(this.hiddenField).value = '';
+}
+
+function initCalendar(inputFieldID, divContainerID, calendarBodyId,
calendarTitle, closeButton,clearButton,hiddenField,noPostOnSelect)
+{
+ var overlay = new YAHOO.widget.Dialog(
+ divContainerID,
+ { visible: false,
+ close: true
+ }
+ );
+
+ var navConfig = {
+ strings: {
+ month:"<?php echo lang('month') ?>",
+ year:"<?php echo lang('year') ?>",
+ submit: "<?php echo lang('ok') ?>",
+ cancel: "<?php echo lang('cancel') ?>",
+ invalidYear: "<?php echo
lang('select_date_valid_year') ?>"
+ },
+ initialFocus: "month"
+ }
+
+ var cal = new YAHOO.widget.Calendar(
+ calendarBodyId,
+ { navigator:navConfig,
+ title: '<?php echo lang('select_date') ?>',
+ start_weekday:1,
+ LOCALE_WEEKDAYS:"short"}
+ );
+
+ cal.cfg.setProperty("MONTHS_LONG",<?php echo lang('calendar_months')
?>);
+ cal.cfg.setProperty("WEEKDAYS_SHORT",<?php echo
lang('calendar_weekdays') ?>);
+ cal.render();
+
+
cal.selectEvent.subscribe(onCalendarSelect,[inputFieldID,overlay,hiddenField,noPostOnSelect],false);
+ cal.inputFieldID = inputFieldID;
+ cal.hiddenField = hiddenField;
+
+
YAHOO.util.Event.addListener(closeButton,'click',closeCalender,overlay,true);
+
YAHOO.util.Event.addListener(clearButton,'click',clearCalendar,cal,true);
+
YAHOO.util.Event.addListener(inputFieldID,'click',onClickOnInput,overlay,true);
+
+ return cal;
+}
+
+function onCalendarSelect(type,args,array){
+ var firstDate = args[0][0];
+ var month = firstDate[1] + "";
+ var day = firstDate[2] + "";
+ var year = firstDate[0] + "";
+ var date = month + "/" + day + "/" + year;
+ var hiddenDateField = document.getElementById(array[2]);
+ if(hiddenDateField != null)
+ {
+ if(month < 10)
+ {
+ month = '0' + month;
+ }
+ if(day < 10)
+ {
+ day = '0' + day;
+ }
+ hiddenDateField.value = year + '-' + month + '-' + day;
+ }
+ document.getElementById(array[0]).value = formatDate('<?php echo
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
?>',Math.round(Date.parse(date)/1000));
+ array[1].hide();
+ if (cal_postOnChange || (array[3] != undefined && !array[3])) {
+ document.getElementById('ctrl_search_button').click();
+ }
+
+}
+
+/**
+ * Update the selected calendar date with a date from an input field
+ * Input field value must be of the format YYYY-MM-DD
+ */
+function updateCalFromInput(cal, inputId) {
+ var txtDate1 = document.getElementById(inputId);
+
+ if (txtDate1.value != "") {
+
+ var date_elements = txtDate1.value.split('-');
+ var year = date_elements[0];
+ var month = date_elements[1];
+ var day = date_elements[2];
+
+ cal.select(month + "/" + day + "/" + year);
+ var selectedDates = cal.getSelectedDates();
+ if (selectedDates.length > 0) {
+ var firstDate = selectedDates[0];
+ cal.cfg.setProperty("pagedate",
(firstDate.getMonth()+1) + "/" + firstDate.getFullYear());
+ cal.render();
+ }
+
+ }
+}
+
+function formatDate ( format, timestamp ) {
+ // http://kevin.vanzonneveld.net
+ // + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
+ // + parts by: Peter-Paul Koch
(http://www.quirksmode.org/js/beat.html)
+ // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: MeEtc (http://yass.meetcweb.com)
+ // + improved by: Brad Touesnard
+ // + improved by: Tim Wiel
+ // + improved by: Bryan Elliott
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: David Randall
+ // + input by: Brett Zamir (http://brett-zamir.me)
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + derived from: gettimeofday
+ // % note 1: Uses global: php_js to store the default timezone
+ // * example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);
+ // * returns 1: '09:09:40 m is month'
+ // * example 2: date('F j, Y, g:i a', 1062462400);
+ // * returns 2: 'September 2, 2003, 2:26 am'
+ // * example 3: date('Y W o', 1062462400);
+ // * returns 3: '2003 36 2003'
+ // * example 4: x = date('Y m d', (new Date()).getTime()/1000); //
2009 01 09
+ // * example 4: (x+'').length == 10
+ // * returns 4: true
+
+ var jsdate=(
+ (typeof(timestamp) == 'undefined') ? new Date() : // Not provided
+ (typeof(timestamp) == 'number') ? new Date(timestamp*1000) : // UNIX
timestamp
+ new Date(timestamp) // Javascript Date()
+ ); // , tal=[]
+ var pad = function(n, c){
+ if( (n = n + "").length < c ) {
+ return new Array(++c - n.length).join("0") + n;
+ } else {
+ return n;
+ }
+ };
+ var _dst = function (t) {
+ // Calculate Daylight Saving Time (derived from gettimeofday() code)
+ var dst=0;
+ var jan1 = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0); // jan 1st
+ var june1 = new Date(t.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st
+ var temp = jan1.toUTCString();
+ var jan2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1));
+ temp = june1.toUTCString();
+ var june2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1));
+ var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
+ var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
+
+ if (std_time_offset === daylight_time_offset) {
+ dst = 0; // daylight savings time is NOT observed
+ }
+ else {
+ // positive is southern, negative is northern hemisphere
+ var hemisphere = std_time_offset - daylight_time_offset;
+ if (hemisphere >= 0) {
+ std_time_offset = daylight_time_offset;
+ }
+ dst = 1; // daylight savings time is observed
+ }
+ return dst;
+ };
+ var ret = '';
+ var txt_weekdays = ["Sunday","Monday","Tuesday","Wednesday",
+ "Thursday","Friday","Saturday"];
+ var txt_ordin = {1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"};
+ var txt_months = ["", "January", "February", "March", "April",
+ "May", "June", "July", "August", "September", "October", "November",
+ "December"];
+
+ var f = {
+ // Day
+ d: function(){
+ return pad(f.j(), 2);
+ },
+ D: function(){
+ var t = f.l();
+ return t.substr(0,3);
+ },
+ j: function(){
+ return jsdate.getDate();
+ },
+ l: function(){
+ return txt_weekdays[f.w()];
+ },
+ N: function(){
+ return f.w() + 1;
+ },
+ S: function(){
+ return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th';
+ },
+ w: function(){
+ return jsdate.getDay();
+ },
+ z: function(){
+ return (jsdate - new Date(jsdate.getFullYear() + "/1/1")) /
864e5 >> 0;
+ },
+
+ // Week
+ W: function(){
+ var a = f.z(), b = 364 + f.L() - a;
+ var nd2, nd = (new Date(jsdate.getFullYear() +
"/1/1").getDay() || 7) - 1;
+
+ if(b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b){
+ return 1;
+ }
+ if(a <= 2 && nd >= 4 && a >= (6 - nd)){
+ nd2 = new Date(jsdate.getFullYear() - 1 + "/12/31");
+ return date("W", Math.round(nd2.getTime()/1000));
+ }
+ return (1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >>
0);
+ },
+
+ // Month
+ F: function(){
+ return txt_months[f.n()];
+ },
+ m: function(){
+ return pad(f.n(), 2);
+ },
+ M: function(){
+ var t = f.F();
+ return t.substr(0,3);
+ },
+ n: function(){
+ return jsdate.getMonth() + 1;
+ },
+ t: function(){
+ var n;
+ if( (n = jsdate.getMonth() + 1) == 2 ){
+ return 28 + f.L();
+ }
+ if( n & 1 && n < 8 || !(n & 1) && n > 7 ){
+ return 31;
+ }
+ return 30;
+ },
+
+ // Year
+ L: function(){
+ var y = f.Y();
+ return (!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0;
+ },
+ o: function(){
+ if (f.n() === 12 && f.W() === 1) {
+ return jsdate.getFullYear()+1;
+ }
+ if (f.n() === 1 && f.W() >= 52) {
+ return jsdate.getFullYear()-1;
+ }
+ return jsdate.getFullYear();
+ },
+ Y: function(){
+ return jsdate.getFullYear();
+ },
+ y: function(){
+ return (jsdate.getFullYear() + "").slice(2);
+ },
+
+ // Time
+ a: function(){
+ return jsdate.getHours() > 11 ? "pm" : "am";
+ },
+ A: function(){
+ return f.a().toUpperCase();
+ },
+ B: function(){
+ // peter paul koch:
+ var off = (jsdate.getTimezoneOffset() + 60)*60;
+ var theSeconds = (jsdate.getHours() * 3600) +
+ (jsdate.getMinutes() * 60) +
+ jsdate.getSeconds() + off;
+ var beat = Math.floor(theSeconds/86.4);
+ if (beat > 1000) {
+ beat -= 1000;
+ }
+ if (beat < 0) {
+ beat += 1000;
+ }
+ if ((String(beat)).length == 1) {
+ beat = "00"+beat;
+ }
+ if ((String(beat)).length == 2) {
+ beat = "0"+beat;
+ }
+ return beat;
+ },
+ g: function(){
+ return jsdate.getHours() % 12 || 12;
+ },
+ G: function(){
+ return jsdate.getHours();
+ },
+ h: function(){
+ return pad(f.g(), 2);
+ },
+ H: function(){
+ return pad(jsdate.getHours(), 2);
+ },
+ i: function(){
+ return pad(jsdate.getMinutes(), 2);
+ },
+ s: function(){
+ return pad(jsdate.getSeconds(), 2);
+ },
+ u: function(){
+ return pad(jsdate.getMilliseconds()*1000, 6);
+ },
+
+ // Timezone
+ e: function () {
+/* var abbr='', i=0;
+ if (this.php_js && this.php_js.default_timezone) {
+ return this.php_js.default_timezone;
+ }
+ if (!tal.length) {
+ tal = timezone_abbreviations_list();
+ }
+ for (abbr in tal) {
+ for (i=0; i < tal[abbr].length; i++) {
+ if (tal[abbr][i].offset ===
-jsdate.getTimezoneOffset()*60) {
+ return tal[abbr][i].timezone_id;
+ }
+ }
+ }
+*/
+ return 'UTC';
+ },
+ I: function(){
+ return _dst(jsdate);
+ },
+ O: function(){
+ var t = pad(Math.abs(jsdate.getTimezoneOffset()/60*100), 4);
+ t = (jsdate.getTimezoneOffset() > 0) ? "-"+t : "+"+t;
+ return t;
+ },
+ P: function(){
+ var O = f.O();
+ return (O.substr(0, 3) + ":" + O.substr(3, 2));
+ },
+ T: function () {
+/* var abbr='', i=0;
+ if (!tal.length) {
+ tal = timezone_abbreviations_list();
+ }
+ if (this.php_js && this.php_js.default_timezone) {
+ for (abbr in tal) {
+ for (i=0; i < tal[abbr].length; i++) {
+ if (tal[abbr][i].timezone_id ===
this.php_js.default_timezone) {
+ return abbr.toUpperCase();
+ }
+ }
+ }
+ }
+ for (abbr in tal) {
+ for (i=0; i < tal[abbr].length; i++) {
+ if (tal[abbr][i].offset ===
-jsdate.getTimezoneOffset()*60) {
+ return abbr.toUpperCase();
+ }
+ }
+ }
+*/
+ return 'UTC';
+ },
+ Z: function(){
+ return -jsdate.getTimezoneOffset()*60;
+ },
+
+ // Full Date/Time
+ c: function(){
+ return f.Y() + "-" + f.m() + "-" + f.d() + "T" + f.h() + ":" +
f.i() + ":" + f.s() + f.P();
+ },
+ r: function(){
+ return f.D()+', '+f.d()+' '+f.M()+' '+f.Y()+'
'+f.H()+':'+f.i()+':'+f.s()+' '+f.O();
+ },
+ U: function(){
+ return Math.round(jsdate.getTime()/1000);
+ }
+ };
+
+ return format.replace(/[\\]?([a-zA-Z])/g, function(t, s){
+ if( t!=s ){
+ // escaped
+ ret = s;
+ } else if( f[s] ){
+ // a date function exists
+ ret = f[s]();
+ } else{
+ // nothing special
+ ret = s;
+ }
+ return ret;
+ });
+}
+</script>
Added: trunk/activitycalendar/templates/base/organization_list.php
===================================================================
--- trunk/activitycalendar/templates/base/organization_list.php
(rev 0)
+++ trunk/activitycalendar/templates/base/organization_list.php 2011-03-30
06:43:52 UTC (rev 7148)
@@ -0,0 +1,16 @@
+<?php
+ include("common.php");
+?>
+
+<?php //echo activitycalendar_uicommon::get_page_error($error) ?>
+<?php //echo activitycalendar_uicommon::get_page_message($message) ?>
+
+<h1><img src="<?php echo RENTAL_TEMPLATE_PATH
?>images/32x32/x-office-address-book.png" /> <?php echo lang('organizations')
?></h1>
+
+
+<?php
+ $list_form = true;
+ $list_id = 'all_organizations';
+ $url_add_on = '&type=all_organizations';
+ include('organization_list_partial.php');
+?>
\ No newline at end of file
Added: trunk/activitycalendar/templates/base/organization_list_partial.php
===================================================================
--- trunk/activitycalendar/templates/base/organization_list_partial.php
(rev 0)
+++ trunk/activitycalendar/templates/base/organization_list_partial.php
2011-03-30 06:43:52 UTC (rev 7148)
@@ -0,0 +1,166 @@
+<script type="text/javascript">
+ //Add listener resetting form: redirects browser to call index again
+/* YAHOO.util.Event.addListener(
+ 'ctrl_reset_button',
+ 'click',
+ function(e)
+ {
+ YAHOO.util.Event.stopEvent(e);
+ window.location =
'index.php?menuaction=activitycalendar.uiorganizationlist.index';
+ }
+ );
+*/
+ // Defining columns for datatable
+ var columnDefs = [{
+ key: "identifier",
+ label: "<?php echo lang('identifier') ?>",
+ sortable: true
+ },
+ {
+ key: "name",
+ label: "<?php echo lang('name') ?>",
+ sortable: true
+ },
+ {
+ key: "address",
+ label: "<?php echo lang('address') ?>",
+ sortable: true
+ },
+ {
+ key: "actions",
+ hidden: true
+ },
+ {
+ key: "labels",
+ hidden: true
+ },
+ {
+ key: "ajax",
+ hidden: true
+ }
+ ];
+
+ <?php
+ if(isset($extra_cols)){
+ foreach($extra_cols as $col){
+ $literal = "{key: \"".$col["key"]."\",
+ label: \"".$col["label"]."\"}";
+ if($col["index"]){
+ echo
"columnDefs.splice(".$col["index"].", 0,".$literal.");";
+ } else {
+ echo "columnDefs.push($literal);";
+ }
+ }
+ }
+ ?>
+
+ // Initiating the data source
+ setDataSource(
+
'index.php?menuaction=activitycalendar.uiorganizationlist.query&phpgw_return_as=json<?php
echo $url_add_on; ?>&editable=<?php echo $editable ? "true" : "false"; ?>',
+ columnDefs,
+ '<?php echo $list_id ?>_form',
+ ['<?php echo $list_id ?>_ctrl_toggle_active','<?php echo
$list_id ?>_ctrl_toggle_party_type','<?php echo $list_id
?>_ctrl_toggle_party_fields','<?php echo $list_id ?>_ctrl_search_query'],
+ '<?php echo $list_id ?>_container',
+ '<?php echo $list_id ?>_paginator',
+ '<?php echo $list_id ?>',
+ new Array(<?php
+ if(isset($related)){
+ foreach($related as $r){
+ echo "\"".$r."\"";
+ }
+ }
+ ?>)
+ );
+
+ function party_export(ptype) {
+ var select = document.getElementById('<?php echo $list_id
?>_ctrl_toggle_organization_type');
+ var pType = select.options[select.selectedIndex].value;
+
+ var sSelect = document.getElementById('<?php echo $list_id
?>_ctrl_toggle_organization_fields');
+ var sOption = sSelect.options[sSelect.selectedIndex].value;
+
+ var statusSelect = document.getElementById('<?php echo $list_id
?>_ctrl_toggle_active');
+ var pStatus = statusSelect.options[statusSelect.selectedIndex].value;
+
+ var query = document.getElementById('<?php echo $list_id
?>_ctrl_search_query').value;
+ <?php
+ /* FIXME Search queries will affect ALL data tables listed on one page
(of that type) when exporting
+ * even though the search only affects one of the data tables.
+ * F.ex on /index.php?menuaction=rental.uicontract.edit&id=1 -> Parties
+ */
+ ?>
+
+ window.location =
'index.php?menuaction=activitycalendar.uiorganizationlist.download'+
+ '&organization_type='+pType+
+ '<?php echo $url_add_on; ?>'+
+ '&active='+pStatus+
+ '&query='+query+
+ '&search_option='+sOption+
+ '&export=true';
+ }
+
+</script>
+<?php
+ if($list_form)
+ {
+?>
+
+<form id="<?php echo $list_id ?>_form" method="GET">
+ <fieldset>
+ <!-- Search -->
+ <label for="ctrl_search_query"><?php echo lang('search_for')
?></label>
+ <input id="<?php echo $list_id ?>_ctrl_search_query"
type="text" name="query" autocomplete="off" value="<?php echo isset($q) ? $q :
''?>"/>
+ <label class="toolbar_element_label"
for="ctrl_toggle_organizationlist_fields"><?php echo lang('search_where')
?>&nbsp;
+ <select name="search_option" id="<?php echo $list_id
?>_ctrl_toggle_organizationlist_fields">
+ <option value="all" <?php echo ($s_type ==
'all') ? 'selected' : ''?>><?php echo lang('all') ?></option>
+ <option value="name" <?php echo ($s_type ==
'name') ? 'selected' : ''?>><?php echo lang('name') ?></option>
+ <option value="address" <?php echo ($s_type ==
'address') ? 'selected' : ''?>><?php echo lang('address') ?></option>
+ <option value="identifier" <?php echo ($s_type
== 'identifier') ? 'selected' : ''?>><?php echo lang('Identifier') ?></option>
+ <option value="reskontro" <?php echo ($s_type
== 'reskontro') ? 'selected' : ''?>><?php echo lang('reskontro') ?></option>
+ <option value="result_unit_number" <?php echo
($s_type == 'result_unit_number') ? 'selected' : ''?>><?php echo
lang('result_unit_number') ?></option>
+ </select>
+ </label>
+ <input type="submit" id="ctrl_search_button" value="<?php echo
lang('search') ?>" />
+ <input type="button" id="ctrl_reset_button" value="<?php echo
lang('reset') ?>" />
+ </fieldset>
+
+ <fieldset>
+ <!-- Filters -->
+ <label class="toolbar_element_label"
for="ctrl_toggle_organizationlist_type"><?php echo lang('part_of_contract')
?></label>
+ <select name="party_type" id="<?php echo $list_id
?>_ctrl_toggle_party_type">
+ <option value="all"><?php echo lang('all') ?></option>
+ <?php
+ $types =
rental_socontract::get_instance()->get_fields_of_responsibility();
+ foreach($types as $id => $label)
+ {
+ ?><option value="<?php echo $id ?>" <?php echo
($p_type == $id) ? 'selected' : ''?>><?php echo lang($label) ?></option><?php
+ }
+ ?>
+ </select>
+ <label class="toolbar_element_label" for="<?php echo $list_id
?>_ctrl_toggle_active"><?php echo lang('marked_as') ?></label>
+ <select name="active" id="<?php echo $list_id
?>_ctrl_toggle_active">
+ <option value="all" <?php echo ($status == 'all') ?
'selected' : ''?>><?php echo lang('not_available_nor_hidden') ?></option>
+ <option value="active" <?php echo ($status == 'active')
? 'selected' : ''?>><?php echo lang('available_for_pick') ?></option>
+ <option value="inactive" <?php echo ($status ==
'inactive') ? 'selected' : ''?>><?php echo lang('hidden_for_pick') ?></option>
+ </select>
+ </fieldset>
+
+
+</form>
+<?php
+ }
+?>
+<fieldset>
+ <h3><?php echo lang('export_to') ?></h3>
+ <?php
+ $export_format =
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['export_format'])
&& $GLOBALS['phpgw_info']['user']['preferences']['property']['export_format']
? $GLOBALS['phpgw_info']['user']['preferences']['property']['export_format'] :
'csv';
+ ?>
+ <div id="export">
+ <a href="javascript:party_export('<?php echo $list_id ?>')"
title="<?php echo lang('Download as %1', $export_format) ?>"><img src="<?php
echo RENTAL_TEMPLATE_PATH
?>images/16x16/mimetypes/x-office-spreadsheet.png"/></a>
+ &nbsp;&nbsp;
+ <a href="index.php?menuaction=rental.uiparty.download_agresso"
title="<?php echo lang('Download Agresso import file') ?>"><img src="<?php echo
RENTAL_TEMPLATE_PATH ?>images/16x16/mimetypes/x-office-document.png"/></a>
+ </div>
+</fieldset>
+
+<div id="<?php echo $list_id ?>_paginator" class="paginator"></div>
+<div id="<?php echo $list_id ?>_container" class="datatable_container"></div>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7148],
Erik Holm-Larsen <=