function __construct()
 {
     $this->file_storage = CreateObject('booking.filestorage', $this);
     $this->so_completed_reservation = CreateObject('booking.socompleted_reservation');
     $this->so_completed_reservation_export = CreateObject('booking.socompleted_reservation_export');
     parent::__construct('bb_completed_reservation_export_file', array('id' => array('type' => 'int'), 'type' => array('type' => 'string', 'required' => true, 'query' => true), 'filename' => array('type' => 'string'), 'log_filename' => array('type' => 'string'), 'total_cost' => array('type' => 'decimal', 'required' => true), 'total_items' => array('type' => 'int', 'required' => true), key(booking_socommon::$AUTO_CREATED_ON) => current(booking_socommon::$AUTO_CREATED_ON), key(booking_socommon::$AUTO_CREATED_BY) => current(booking_socommon::$AUTO_CREATED_BY), 'created_by_name' => booking_socommon::$REL_CREATED_BY_NAME));
 }
 function doValidate($entity, booking_errorstack $errors)
 {
     parent::doValidate($entity, $errors);
     if (!isset($errors['type']) && !in_array($entity['type'], self::allowed_types(), true)) {
         $errors['type'] = lang('Invalid Resource Type');
     }
 }
 function validate($entity)
 {
     $errors = parent::validate($entity);
     # Detect and prevent loop creation
     $node_id = $entity['parent_id'];
     while ($entity['id'] && $node_id) {
         if ($node_id == $entity['id']) {
             $errors['parent_id'] = lang('Invalid parent activity');
             break;
         }
         $next = $this->read_single($node_id);
         $node_id = $next['parent_id'];
     }
     return $errors;
 }
 function _get_conditions($query, $filters)
 {
     //Removes season_name from filters if the season_id is already included in the filters
     if (isset($filters['season_name']) and isset($filters['season_id'])) {
         unset($filters['season_name']);
     }
     //Removes building_name from filters if the building_id is already included in the filters
     if (isset($filters['building_name']) and isset($filters['building_id'])) {
         unset($filters['building_name']);
     }
     $where_clauses = isset($filters['where']) ? (array) $filters['where'] : array();
     if (isset($filters['season_id'])) {
         $season_id = $this->marshal_field_value('season_id', $filters['season_id']);
         unset($filters['season_id']);
         $where_clauses[] = "(%%table%%.season_id = {$season_id} OR (%%table%%.reservation_type = 'event' AND %%table%%.season_id IS NULL) " . "AND %%table%%.reservation_type != 'event' OR " . "(%%table%%.reservation_type = 'event' AND %%table%%.reservation_id IN " . "(SELECT event_id FROM bb_event_resource er JOIN bb_season_resource sr ON er.resource_id = sr.resource_id AND sr.season_id = {$season_id}) " . "))";
     }
     if (count($where_clauses) > O) {
         $filters['where'][] = join($where_clauses, ' AND ');
     }
     return parent::_get_conditions($query, $filters);
 }
 function __construct()
 {
     $this->season_so = CreateObject('booking.soseason');
     $this->resource_so = CreateObject('booking.soresource');
     parent::__construct('bb_account_code_set', array('id' => array('type' => 'int'), 'name' => array('type' => 'string', 'required' => True, 'query' => True), 'object_number' => array('type' => 'string', 'required' => True, 'nullable' => False), 'responsible_code' => array('type' => 'string', 'required' => True, 'nullable' => False), 'article' => array('type' => 'string', 'required' => True, 'nullable' => False), 'service' => array('type' => 'string', 'required' => True, 'nullable' => False), 'project_number' => array('type' => 'string', 'required' => True, 'nullable' => False), 'unit_number' => array('type' => 'string', 'required' => True, 'nullable' => False), 'unit_prefix' => array('type' => 'string', 'required' => True, 'nullable' => False), 'dim_4' => array('type' => 'string', 'required' => False, 'nullable' => True), 'dim_value_4' => array('type' => 'string', 'required' => False, 'nullable' => True), 'dim_value_5' => array('type' => 'string', 'required' => False, 'nullable' => True), 'invoice_instruction' => array('type' => 'string'), 'active' => array('type' => 'int')));
 }
 function __construct()
 {
     parent::__construct('bb_organization_contact', array('id' => array('type' => 'int'), 'organization_id' => array('type' => 'int', 'required' => True), 'name' => array('type' => 'string', 'required' => True, 'query' => True), 'ssn' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorNorwegianSSN')), 'email' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% contains an invalid email'))), 'phone' => array('type' => 'string')));
     $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
 }
 function read($params)
 {
     $result = parent::read($params);
     if ($this->has_results($result)) {
         foreach ($result['results'] as &$record) {
             $record['is_image'] = $this->is_image($record);
         }
     }
     return $result;
 }
Ejemplo n.º 8
0
 function update($entity)
 {
     return parent::update($this->trim_contacts($entity));
 }
 function add($entry)
 {
     $export_reservations =& $this->get_completed_reservations_for($entry);
     if (!$export_reservations) {
         throw new LogicException('Nothing to export');
     }
     $entry['from_'] = $export_reservations[0]['to_'];
     $entry['to_'] = $export_reservations[count($export_reservations) - 1]['to_'];
     $entry['total_cost'] = $this->calculate_total_cost($export_reservations);
     $entry['total_items'] = count(array_filter($export_reservations, array($this, 'not_free')));
     $this->db->transaction_begin();
     $receipt = parent::add($entry);
     $entry['id'] = $receipt['id'];
     $this->update_completed_reservations_exported_state($entry, $export_reservations);
     if (!$this->db->transaction_commit()) {
         throw new UnexpectedValueException('Transaction failed.');
     }
     return $receipt;
 }
Ejemplo n.º 10
0
 function __construct()
 {
     parent::__construct('bb_agegroup', array('id' => array('type' => 'int'), 'name' => array('type' => 'string', 'query' => true, 'required' => true), 'sort' => array('type' => 'int', 'required' => true), 'description' => array('type' => 'string', 'query' => true, 'required' => false), 'active' => array('type' => 'int')));
     $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
 }
 function __construct()
 {
     parent::__construct('bb_allocation', array('id' => array('type' => 'int'), 'id_string' => array('type' => 'string', 'required' => false, 'default' => '0', 'query' => true), 'active' => array('type' => 'int', 'required' => true), 'application_id' => array('type' => 'int', 'required' => false), 'organization_id' => array('type' => 'int', 'required' => true), 'building_name' => array('type' => 'string', 'required' => true, 'query' => true), 'season_id' => array('type' => 'int', 'required' => 'true'), 'from_' => array('type' => 'string', 'required' => true), 'to_' => array('type' => 'string', 'required' => true), 'cost' => array('type' => 'decimal', 'required' => true), 'completed' => array('type' => 'int', 'required' => true, 'default' => '0'), 'organization_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_organization', 'fkey' => 'organization_id', 'key' => 'id', 'column' => 'name')), 'organization_shortname' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_organization', 'fkey' => 'organization_id', 'key' => 'id', 'column' => 'shortname')), 'building_id' => array('type' => 'string', 'join' => array('table' => 'bb_season', 'fkey' => 'season_id', 'key' => 'id', 'column' => 'building_id')), 'season_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_season', 'fkey' => 'season_id', 'key' => 'id', 'column' => 'name')), 'resources' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_allocation_resource', 'key' => 'allocation_id', 'column' => 'resource_id'))));
 }
 function __construct()
 {
     parent::__construct('bb_contact_person', array('id' => array('type' => 'auto', 'nullable' => false), 'ssn' => array('type' => 'varchar', 'precision' => '12', 'nullable' => True), 'name' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False, 'query' => true), 'homepage' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False), 'phone' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False, 'default' => ''), 'email' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False, 'default' => ''), 'description' => array('type' => 'varchar', 'precision' => '1000', 'nullable' => False, 'default' => '')));
     $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
 }
 function __construct()
 {
     parent::__construct('bb_organization', array('id' => array('type' => 'int'), 'organization_number' => array('type' => 'string', 'query' => true, 'sf_validator' => createObject('booking.sfValidatorNorwegianOrganizationNumber', array(), array('invalid' => '%field% is invalid'))), 'name' => array('type' => 'string', 'required' => True, 'query' => True), 'shortname' => array('type' => 'string', 'required' => False, 'query' => True), 'homepage' => array('type' => 'string', 'required' => False, 'query' => True), 'phone' => array('type' => 'string'), 'email' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% is invalid'))), 'description' => array('type' => 'string'), 'street' => array('type' => 'string'), 'zip_code' => array('type' => 'string'), 'district' => array('type' => 'string'), 'city' => array('type' => 'string'), 'active' => array('type' => 'int', 'required' => true), 'show_in_portal' => array('type' => 'int', 'required' => true), 'activity_id' => array('type' => 'int', 'required' => true), 'customer_identifier_type' => array('type' => 'string', 'required' => False), 'customer_number' => array('type' => 'string', 'required' => False), 'customer_ssn' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorNorwegianSSN'), 'required' => false), 'customer_organization_number' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorNorwegianOrganizationNumber', array(), array('invalid' => '%field% is invalid'))), 'customer_internal' => array('type' => 'int', 'required' => true), 'activity_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_activity', 'fkey' => 'activity_id', 'key' => 'id', 'column' => 'name')), 'contacts' => array('type' => 'string', 'manytomany' => array('table' => 'bb_organization_contact', 'key' => 'organization_id', 'column' => array('name', 'ssn' => array('sf_validator' => createObject('booking.sfValidatorNorwegianSSN')), 'email' => array('sf_validator' => createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% contains an invalid email'))), 'phone')))));
     $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
 }
 function __construct()
 {
     parent::__construct('bb_building', array('id' => array('type' => 'int'), 'name' => array('type' => 'string', 'query' => true, 'required' => true), 'homepage' => array('type' => 'string'), 'description' => array('type' => 'string'), 'phone' => array('type' => 'string'), 'email' => array('type' => 'string'), 'location_code' => array('type' => 'string', 'required' => false), 'street' => array('type' => 'string', 'query' => true), 'zip_code' => array('type' => 'string'), 'district' => array('type' => 'string', 'query' => true), 'city' => array('type' => 'string', 'query' => true), 'active' => array('type' => 'int')));
 }
Ejemplo n.º 15
0
 function __construct()
 {
     parent::__construct('bb_booking', array('id' => array('type' => 'int'), 'active' => array('type' => 'int', 'required' => true), 'allocation_id' => array('type' => 'int', 'required' => false), 'application_id' => array('type' => 'int', 'required' => false), 'activity_id' => array('type' => 'int', 'required' => true), 'building_name' => array('type' => 'string', 'required' => true, 'query' => true), 'group_id' => array('type' => 'int', 'required' => true), 'from_' => array('type' => 'timestamp', 'required' => true), 'to_' => array('type' => 'timestamp', 'required' => true), 'season_id' => array('type' => 'int', 'required' => true), 'cost' => array('type' => 'decimal', 'required' => true), 'sms_total' => array('type' => 'int', 'required' => false), 'completed' => array('type' => 'int', 'required' => true, 'nullable' => false, 'default' => '0'), 'reminder' => array('type' => 'int', 'required' => true, 'nullable' => false, 'default' => '1'), 'secret' => array('type' => 'string', 'required' => true), 'activity_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_activity', 'fkey' => 'activity_id', 'key' => 'id', 'column' => 'name')), 'group_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_group', 'fkey' => 'group_id', 'key' => 'id', 'column' => 'name')), 'group_shortname' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_group', 'fkey' => 'group_id', 'key' => 'id', 'column' => 'shortname')), 'building_id' => array('type' => 'string', 'join' => array('table' => 'bb_season', 'fkey' => 'season_id', 'key' => 'id', 'column' => 'building_id')), 'season_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_season', 'fkey' => 'season_id', 'key' => 'id', 'column' => 'name')), 'audience' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_booking_targetaudience', 'key' => 'booking_id', 'column' => 'targetaudience_id')), 'agegroups' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_booking_agegroup', 'key' => 'booking_id', 'column' => array('agegroup_id' => array('type' => 'int', 'required' => true), 'male' => array('type' => 'int', 'required' => true), 'female' => array('type' => 'int', 'required' => true)))), 'resources' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_booking_resource', 'key' => 'booking_id', 'column' => 'resource_id'))));
 }
 function __construct()
 {
     parent::__construct('bb_system_message_association', array('id' => array('type' => 'int'), 'building_id' => array('type' => 'int'), 'type' => array('type' => 'string', 'required' => true), 'status' => array('type' => 'string', 'required' => true)));
 }
 function read($params)
 {
     $result = parent::read($params);
     return $result;
 }
 function __construct()
 {
     parent::__construct('bb_permission_root', array('id' => array('type' => 'int'), 'subject_id' => array('type' => 'int', 'required' => true), 'role' => array('type' => 'string', 'required' => true, 'query' => true), 'subject_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'phpgw_accounts', 'fkey' => 'subject_id', 'key' => 'account_id', 'column' => 'account_lid'))));
     $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
 }
 function __construct()
 {
     //CREATE VIEW bb_document_view AS SELECT bb_document.id AS id,bb_document.name AS name,bb_document.owner_id AS owner_id,bb_document.category AS category,bb_document.description AS description,bb_document.type AS type FROM ((SELECT *, 'building' as type from bb_document_building) UNION ALL (SELECT *, 'resource' as type from bb_document_resource)) as bb_document;
     parent::__construct('bb_document_view', array('id' => array('type' => 'string', 'expression' => '%%table%%.type || \'::\' || %%table%%.id'), 'type' => array('type' => 'string'), 'name' => array('type' => 'string', 'query' => true), 'owner_id' => array('type' => 'int', 'required' => true), 'category' => array('type' => 'string', 'required' => true), 'description' => array('type' => 'string', 'required' => false)));
 }
Ejemplo n.º 20
0
 function __construct()
 {
     parent::__construct('bb_building', array('id' => array('type' => 'int'), 'name' => array('type' => 'string', 'query' => true, 'required' => true), 'homepage' => array('type' => 'string'), 'calendar_text' => array('type' => 'string'), 'description' => array('type' => 'string'), 'phone' => array('type' => 'string'), 'email' => array('type' => 'string'), 'tilsyn_name' => array('type' => 'string'), 'tilsyn_phone' => array('type' => 'string'), 'tilsyn_email' => array('type' => 'string'), 'tilsyn_name2' => array('type' => 'string'), 'tilsyn_phone2' => array('type' => 'string'), 'tilsyn_email2' => array('type' => 'string'), 'deactivate_calendar' => array('type' => 'int'), 'deactivate_application' => array('type' => 'int'), 'deactivate_sendmessage' => array('type' => 'int'), 'extra_kalendar' => array('type' => 'int'), 'location_code' => array('type' => 'string', 'required' => false), 'street' => array('type' => 'string', 'query' => true), 'zip_code' => array('type' => 'string'), 'district' => array('type' => 'string', 'query' => true), 'city' => array('type' => 'string', 'query' => true), 'active' => array('type' => 'int')));
 }
 function __construct()
 {
     parent::__construct('bb_application_association', array('id' => array('type' => 'int'), 'application_id' => array('type' => 'int'), 'type' => array('type' => 'string', 'required' => true), 'from_' => array('type' => 'timestamp', 'query' => true), 'to_' => array('type' => 'timestamp'), 'active' => array('type' => 'int')));
 }
 function update($entry)
 {
     $entry['object_type'] = $this->get_object_type();
     return parent::update($entry);
 }
Ejemplo n.º 23
0
 protected function doValidate($entity, booking_errorstack $errors)
 {
     parent::doValidate($entity, $errors);
     // Make sure the template allocation doesn't overlap with any
     // other existing template allocation
     if ($entity['to_'] <= $entity['from_']) {
         $errors['to'] = lang('TO needs to be later than FROM');
     }
     if ($entity['cost'] < 0) {
         $errors['cost'] = lang('COST needs to be non-negative');
     }
     if (!$entity['resources']) {
         return;
     }
     $id = $this->_marshal($entity['id'] ? $entity['id'] : -1, 'int');
     $from_ = $this->_marshal($entity['from_'], 'time');
     $to_ = $this->_marshal($entity['to_'], 'time');
     $wday = $this->_marshal($entity['wday'], 'int');
     $resources = $this->_marshal($entity['resources'], 'intarray');
     $season_id = intval($entity['season_id']);
     $this->db->query("SELECT 1 FROM bb_wtemplate_alloc a1, " . "bb_wtemplate_alloc_resource ar1 " . "WHERE ar1.allocation_id<>{$id} AND ar1.allocation_id=a1.id AND " . "      ar1.resource_id IN {$resources} AND " . "      a1.season_id = {$season_id} AND " . "      a1.wday = {$wday} AND " . "     ((a1.from_ >= {$from_} AND a1.from_ < {$to_}) OR " . "\t   (a1.to_ > {$from_} AND a1.to_ <= {$to_}) OR " . "\t   (a1.from_ < {$from_} AND a1.to_ > {$to_})) ", __LINE__, __FILE__);
     if ($this->db->next_record()) {
         $errors['overlaps'] = lang("This allocation overlaps another allocation");
     }
     $this->db->query("SELECT 1 FROM bb_season_boundary " . "WHERE wday = {$wday} AND from_ <= {$from_} AND to_ >= {$to_} AND season_id = {$season_id}", __LINE__, __FILE__);
     if (!$this->db->next_record()) {
         $errors['overlaps'] = lang("This allocation is outside season boundaries");
     }
 }
Ejemplo n.º 24
0
 function __construct()
 {
     parent::__construct('bb_event', array('id' => array('type' => 'int'), 'id_string' => array('type' => 'string', 'required' => false, 'default' => '0', 'query' => true), 'active' => array('type' => 'int', 'required' => true), 'activity_id' => array('type' => 'int', 'required' => true), 'application_id' => array('type' => 'int', 'required' => false), 'description' => array('type' => 'string', 'required' => true, 'query' => true), 'building_id' => array('type' => 'int', 'required' => true), 'building_name' => array('type' => 'string', 'required' => true, 'query' => true), 'from_' => array('type' => 'string', 'required' => true), 'to_' => array('type' => 'string', 'required' => true), 'cost' => array('type' => 'decimal', 'required' => true), 'contact_name' => array('type' => 'string', 'required' => true, 'query' => true), 'contact_email' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% is invalid'))), 'contact_phone' => array('type' => 'string'), 'completed' => array('type' => 'int', 'required' => true, 'nullable' => false, 'default' => '0'), 'reminder' => array('type' => 'int', 'required' => true, 'nullable' => false, 'default' => '1'), 'is_public' => array('type' => 'int', 'required' => true, 'nullable' => false, 'default' => '1'), 'secret' => array('type' => 'string', 'required' => true), 'sms_total' => array('type' => 'int', 'required' => false), 'customer_organization_name' => array('type' => 'string', 'required' => False, 'query' => true), 'customer_organization_id' => array('type' => 'int', 'required' => False), 'customer_identifier_type' => array('type' => 'string', 'required' => False), 'customer_ssn' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorNorwegianSSN'), 'required' => false), 'customer_organization_number' => array('type' => 'string', 'sf_validator' => createObject('booking.sfValidatorNorwegianOrganizationNumber', array(), array('invalid' => '%field% is invalid'))), 'customer_internal' => array('type' => 'int', 'required' => true), 'activity_name' => array('type' => 'string', 'query' => true, 'join' => array('table' => 'bb_activity', 'fkey' => 'activity_id', 'key' => 'id', 'column' => 'name')), 'audience' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_event_targetaudience', 'key' => 'event_id', 'column' => 'targetaudience_id')), 'agegroups' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_event_agegroup', 'key' => 'event_id', 'column' => array('agegroup_id' => array('type' => 'int', 'required' => true), 'male' => array('type' => 'int', 'required' => true), 'female' => array('type' => 'int', 'required' => true)))), 'comments' => array('type' => 'string', 'manytomany' => array('table' => 'bb_event_comment', 'key' => 'event_id', 'column' => array('time', 'author', 'comment', 'type'), 'order' => array('sort' => 'time', 'dir' => 'ASC'))), 'resources' => array('type' => 'int', 'required' => true, 'manytomany' => array('table' => 'bb_event_resource', 'key' => 'event_id', 'column' => 'resource_id')), 'dates' => array('type' => 'timestamp', 'manytomany' => array('table' => 'bb_event_date', 'key' => 'event_id', 'column' => array('from_', 'to_', 'id')))));
 }
 function __construct()
 {
     $this->season_so = CreateObject('booking.soseason');
     $this->resource_so = CreateObject('booking.soresource');
     parent::__construct('bb_billing_sequential_number_generator', array('id' => array('type' => 'int'), 'value' => array('type' => 'int', 'required' => true)));
 }