[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/class.bocommon.php, 1.1.1.3
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/class.bocommon.php, 1.1.1.3 |
Date: |
Fri, 21 May 2004 15:44:35 -0000 |
Update of /property
Modified Files:
Branch:
class.bocommon.php
date: 2004/04/23 21:26:33; author: sigurdne; state: Exp; lines: +1487 -1487
Log Message:
no message
=====================================================================
Index: property/class.bocommon.php
diff -u property/class.bocommon.php:1.1.1.2 property/class.bocommon.php:1.1.1.3
--- property/class.bocommon.php:1.1.1.2 Fri Apr 23 20:25:22 2004
+++ property/class.bocommon.php Fri Apr 23 21:26:33 2004
@@ -1,1487 +1,1487 @@
-<?php
-
/**************************************************************************\
- * phpGroupWare - property
*
- * http://www.phpgroupware.org
*
- *
*
- * Facilities Management
*
- * Written by Sigurd Nes [sigurdne at online.no]
*
- *
------------------------------------------------------------------------ *
- * Copyright 2000 - 2003 Free Software Foundation, Inc
*
- * This program is part of the GNU project, see http://www.gnu.org/
*
- *
------------------------------------------------------------------------ *
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by the
*
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
- /* $Id$ */
-
- class property_bocommon
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $district_id;
- var $action;
-
-
- var $public_functions = array
- (
- 'select_part_of_town' => True,
- 'menu' => True,
- );
-
- var $soap_functions = array(
- 'list' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'save' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'delete' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- function property_bocommon()
- {
-
- $this->currentapp = 'property';
//$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->socommon =
CreateObject($this->currentapp.'_socommon');
-
- $this->join = $this->socommon->join;
- $this->left_join = $this->socommon->left_join;
-
- switch($GLOBALS['phpgw_info']['server']['db_type'])
- {
- case 'mssql':
- $this->dateformat = "M d
Y";
- $this->datetimeformat = "M d Y g:iA";
- break;
- case 'mysql':
- $this->dateformat =
"Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
- break;
- case 'pgsql':
- $this->dateformat =
"Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
-// $this->dateformat = "F j,
Y";
-// $this->datetimeformat = "F j, Y g:iA";
- break;
- }
-
- /* if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
- {
- $this->dateformat = "M d Y";
- $this->datetimeformat = "M d Y g:iA";
- }
- else
- {
- $this->dateformat = "Y-m-d";
- $this->datetimeformat = "Y-m-d G:i:s";
- }
- */
-
- }
-
- function jscalendar()
- {
- $phpgw_js_url =
$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'].'/phpgwapi/js';
- $img = $phpgw_js_url.'/jscalendar/img.gif';
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $jsDateFormat = str_replace(array('d', 'm', 'M', 'Y'),
array('%d', '%m', '%b', '%Y'), $dateformat);
-
- $GLOBALS['phpgw_info']['flags']['java_script']
.='</script>
- <link rel="stylesheet" type="text/css" media="all"
href="'.$phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css"
title="win2k-cold-1" >
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar.js"></script>
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar-setup.js"></script>
- <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js"></script>
- ';
-
-
-// <script type="text/javascript"
src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',$this->link('/phpgwapi/js/jscalendar/jscalendar-setup.php')).'"></script>
-
- $cal_info=array(
-// 'stylesheet'
=> $phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css',
-// 'calendar_source'
=> $phpgw_js_url.'/jscalendar/calendar.js',
-// 'calendar_setup_source' =>
$phpgw_js_url.'/jscalendar/calendar-setup.js',
-// 'calendar_lang'
=>
$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js',
- 'jsDateFormat'
=> $jsDateFormat,
- 'img'
=> $img,
- );
- return $cal_info;
- }
-
- function check_perms($rights, $required)
- {
- // return (!!($rights & $required) == True);
- return ($rights & $required);
- }
-
- function create_preferences($app='',$user_id='')
- {
- return
$this->socommon->create_preferences($app,$user_id);
- }
-
- function get_lookup_entity($location='')
- {
- return $this->socommon->get_lookup_entity($location);
- }
-
- function get_start_entity($location='')
- {
- return $this->socommon->get_start_entity($location);
- }
-
- function msgbox_data($receipt)
- {
- $msgbox_data_error=array();
- if (isSet($receipt['error']) AND
is_array($receipt['error']))
- {
- foreach($receipt['error'] as $errors)
- {
- $msgbox_data_error +=
array($errors['msg']=> False);
- }
- }
-
- $msgbox_data_message=array();
-
- if (isSet($receipt['message']) AND
is_array($receipt['message']))
- {
- foreach($receipt['message'] as $messages)
- {
- $msgbox_data_message +=
array($messages['msg']=> True);
- }
- }
-
- $msgbox_data = $msgbox_data_error +
$msgbox_data_message;
-
- return $msgbox_data;
- }
-
- function moneyformat($amount)
- {
- if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
- {
- $moneyformat =
"CONVERT(MONEY,"."'$amount'".",0)";
- }
- else
- {
- $moneyformat = "'" . $amount . "'";
- }
-
- return $moneyformat;
- }
-
-
- function date_array($date)
- {
- $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- $dateformat = str_replace(".","",$dateformat);
- $dateformat = str_replace("-","",$dateformat);
- $dateformat = str_replace("/","",$dateformat);
- $y=strpos($dateformat,'y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/', $date);
- $date_array['day'] = $dateparts[$d];
- $date_array['month'] = $dateparts[$m];
- $date_array['year'] = $dateparts[$y];
-
- return $date_array;
- }
-
- function date_to_timestamp($date)
- {
- if($date)
- {
- $date_array = $this->date_array($date);
- $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
- }
- return $date;
- }
-
-
- function
column_list($selected='',$entity_type='',$cat_id,$allrows='')
- {
- $bostandard_entity =
CreateObject($this->currentapp.'_bostandard_entity',True);
-
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$entity_type.'_columns_'.$cat_id];
- }
-
- $columns =
$bostandard_entity->read_attrib($entity_type,$cat_id,$allrows);
-//html_print_r($columns);
-
-
$column_list=$this->select_multi_list($selected,$columns);
-
- return $column_list;
-
- }
-
- function select_multi_list($selected='',$input_list)
- {
- $j=0;
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $output_list[$j]['id'] = $entry['id'];
- $output_list[$j]['name'] =
$entry['name'];
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i] ==
$entry['id'])
- {
-
$output_list[$j]['selected'] = 'selected';
- }
- }
- $j++;
- }
- }
-
- for ($i=0;$i<count($output_list);$i++)
- {
- if ($output_list[$i]['selected'] != 'selected')
- {
- unset($output_list[$i]['selected']);
- }
- }
-
- return $output_list;
- }
-
-
-
- function select_list($selected='',$input_list='')
- {
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $sel_entry = '';
- if ($entry['id']==$selected)
- {
- $sel_entry = 'selected';
- }
- $entry_list[] = array
- (
- 'id' => $entry['id'],
- 'name' =>
$entry['name'],
- 'selected' => $sel_entry
- );
- }
- for ($i=0;$i<count($entry_list);$i++)
- {
- if ($entry_list[$i]['selected'] !=
'selected')
- {
-
unset($entry_list[$i]['selected']);
- }
- }
- }
- return $entry_list;
- }
-
-
- function
get_user_list($format='',$selected='',$extra='',$default='')
- {
- switch($format)
- {
- case 'select':
-
$this->xsl_add_file(array('user_id_select'));
- break;
- case 'filter':
-
$this->xsl_add_file(array('user_id_filter'));
- break;
- }
-
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- if (is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_id' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
- $accounts = CreateObject('phpgwapi_accounts');
- $users = $accounts->get_list('accounts', $start, $sort,
$order, $query);
- unset($accounts);
- if (is_array($users_extra) && is_array($users))
- {
- $users = $users_extra + $users;
- }
-
- if (isSet($users) AND is_array($users))
- {
- foreach($users as $user)
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_id' =>
$user['account_id'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
- }
-
- $user_count= count($user_list);
- for ($i=0;$i<$user_count;$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//html_print_r($user_list);
- return $user_list;
- }
-
- function get_group_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$this->xsl_add_file(array('group_select'));
- break;
- case 'filter':
-
$this->xsl_add_file(array('group_filter'));
- break;
- }
-
- $accounts = CreateObject('phpgwapi_accounts');
- $users = $accounts->get_list('groups', $start, $sort,
$order, $query);
- unset($accounts);
- if (isSet($users) AND is_array($users))
- {
- foreach($users as $user)
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'id' => $user['account_id'],
- 'name' =>
$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
- }
-
- $user_count= count($user_list);
- for ($i=0;$i<$user_count;$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
-//html_print_r($user_list);
- return $user_list;
- }
-
-
- function
get_user_list_right($right='',$selected='',$acl_location='')
- {
-
$employees=$this->socommon->get_user_list_right($right,$acl_location);
- while (is_array($employees) && list(,$user) =
each($employees))
- {
- $sel_user = '';
- if ($user['account_lid']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'lid' =>
$user['account_lid'],
- 'firstname' =>
$user['account_firstname'],
- 'lastname' =>
$user['account_lastname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
- return $user_list;
- }
-
- function
get_user_list_right2($format='',$right='',$selected='',$acl_location='',$extra='',$default='')
- {
- switch($format)
- {
- case 'select':
-
$this->xsl_add_file(array('user_id_select'));
- break;
- case 'filter':
-
$this->xsl_add_file(array('user_id_filter'));
- break;
- }
-
- if(!$selected && $default)
- {
- $selected = $default;
- }
-
- if (isset($extra) AND is_array($extra))
- {
- foreach($extra as $extra_user)
- {
- $users_extra[]=array
- (
- 'account_id' => $extra_user,
- 'account_firstname' =>
lang($extra_user)
- );
- }
- }
-
-
$users=$this->socommon->get_user_list_right($right,$acl_location);
-
- if (is_array($users_extra) && is_array($users))
- {
- $users = $users_extra + $users;
- }
-
- while (is_array($users) && list(,$user) = each($users))
- {
- $sel_user = '';
- if ($user['account_id']==$selected)
- {
- $sel_user = 'selected';
- }
-
- $user_list[] = array
- (
- 'user_id' =>
$user['account_id'],
- 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
- 'selected' => $sel_user
- );
- }
-
- for ($i=0;$i<count($user_list);$i++)
- {
- if ($user_list[$i]['selected'] != 'selected')
- {
- unset($user_list[$i]['selected']);
- }
- }
-
- return $user_list;
- }
-
-
- function initiate_ui_vendorlookup($data)
- {
-//html_print_r($data);
- $contacts =
CreateObject('phpgwapi_contacts');
-
- if($data['type']=='view')
- {
- $this->xsl_add_file(array('vendor_view'));
- }
- else
- {
- $this->xsl_add_file(array('vendor_form'));
- }
-
- $vendor['value_vendor_id']
= $data['vendor_id'];
- $vendor['value_vendor_name'] =
$data['vendor_name'];
-
- if($data['vendor_id'] && !$data['vendor_name'])
- {
- $vendor_data
=
$contacts->read_single_entry($data['vendor_id'],array('org_name'=>'org_name','email'=>'email'));
- $vendor['value_vendor_name'] =
$vendor_data[0]['org_name'];
- }
-
- $vendor['vendor_link']
=
$this->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilookup.addressbook');
- $vendor['lang_vendor']
= lang('Vendor');
- $vendor['lang_select_vendor_help'] =
lang('Klick this link to select vendor');
- $vendor['lang_vendor_name']
= lang('Vendor Name');
-
- unset($contacts);
-//html_print_r($vendor);
- return $vendor;
- }
-
-
- function initiate_ui_budget_account_lookup($data)
- {
-//html_print_r($data);
-
- $this->xsl_add_file(array('b_account_form'));
- $b_account['value_b_account_id']
= $data['b_account_id'];
- $b_account['value_b_account_name']
= $data['b_account_name'];
- $b_account['b_account_link']
=
$this->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilookup.b_account');
- $b_account['lang_b_account']
= lang('b_account');
- $b_account['lang_select_b_account_help'] =
lang('Klick this link to select budget account');
- $b_account['lang_b_account']
= lang('Budget account');
-
-//html_print_r($b_account);
- return $b_account;
- }
-
- function
select_multi_list_2($selected='',$input_list,$input_type='')
- {
- $j=0;
- if (isset($input_list) AND is_array($input_list))
- {
- foreach($input_list as $entry)
- {
- $output_list[$j]['id'] = $entry['id'];
- $output_list[$j]['value'] =
$entry['value'];
- $output_list[$j]['input_type'] =
$input_type;
-
- for ($i=0;$i<count($selected);$i++)
- {
- if($selected[$i] ==
$entry['id'])
- {
-
$output_list[$j]['checked'] = 'checked';
- }
- }
- $j++;
- }
- }
-
- for ($i=0;$i<count($output_list);$i++)
- {
- if ($output_list[$i]['checked'] != 'checked')
- {
- unset($output_list[$i]['checked']);
- }
- }
-
- return $output_list;
- }
-
- function translate_datatype($datatype)
- {
- $datatype_text = array(
- 'V' => 'Varchar',
- 'I' => 'Integer',
- 'C' => 'char',
- 'N' => 'Float',
- 'D' => 'Date',
- 'T' => 'Memo',
- 'R' => 'Muliple radio',
- 'CH' => 'Muliple checkbox',
- 'LB' => 'Listbox',
- 'AB' => 'Contact'
- );
-
- $datatype = lang($datatype_text[$datatype]);
-
- return $datatype;
- }
-
- function translate_datatype_insert($datatype)
- {
- $datatype_text = array(
- 'V' => 'varchar',
- 'I' => 'int',
- 'C' => 'char',
- 'N' => 'decimal',
- 'D' => 'timestamp',
- 'T' => 'text',
- 'R' => 'int',
- 'CH' => 'text',
- 'LB' => 'int',
- 'AB' => 'int'
- );
-
- return $datatype_text[$datatype];
- }
-
-
- function save_attributes($values_attribute,$type)
- {
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
- }
- if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
- }
-
- if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
- {
- $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
- }
-
- if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
- {
- $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $dateformat =
str_replace(".","",$dateformat);
- $dateformat =
str_replace("-","",$dateformat);
- $dateformat =
str_replace("/","",$dateformat);
- $y=strpos($dateformat,'Y');
- $d=strpos($dateformat,'d');
- $m=strpos($dateformat,'m');
-
- $dateparts = explode('/',
$values_attribute[$i]['value']);
- $day = $dateparts[$d];
- $month = $dateparts[$m];
- $year = $dateparts[$y];
- $values_attribute[$i]['value'] =
date($this->dateformat,mktime(2,0,0,$month,$day,$year));
- }
- }
-
-
$this->socommon->save_attributes($values_attribute,$type);
- }
-
- function list_methods($_type='xmlrpc')
- {
- /*
- This handles introspection or discovery by the logged
in client,
- in which case the input might be an array. The
server always calls
- this function to fill the server dispatch map using a
string.
- */
- if (is_array($_type))
- {
- $_type = $_type['type'] ? $_type['type'] :
$_type[0];
- }
- switch($_type)
- {
- case 'xmlrpc':
- $xml_functions = array(
- 'read' => array(
- 'function' => 'read',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
- ),
- 'save' => array(
- 'function' => 'save',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Update a single entry by passing the fields.')
- ),
- 'delete' => array(
- 'function' => 'delete',
- 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
- 'docstring' =>
lang('Delete a single entry by passing the id.')
- ),
- 'list' => array(
- 'function' => '_list',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read a list of entries.')
- ),
- 'list_methods' => array(
- 'function' =>
'list_methods',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
- 'docstring' =>
lang('Read this list of methods.')
- )
- );
- return $xml_functions;
- break;
- case 'soap':
- return $this->soap_functions;
- break;
- default:
- return array();
- break;
- }
- }
-
- function add_leading_zero($num)
- {
-
- if ($id_type == "hex")
- {
- $num = hexdec($num);
- $num++;
- $num = dechex($num);
- }
- else
- {
- $num++;
- }
-
- if (strlen($num) == 4)
- $return = $num;
- if (strlen($num) == 3)
- $return = "0$num";
- if (strlen($num) == 2)
- $return = "00$num";
- if (strlen($num) == 1)
- $return = "000$num";
- if (strlen($num) == 0)
- $return = "0001";
-
- return strtoupper($return);
- }
-
-
- function read_location_data($location_code)
- {
- $soadmin_location =
CreateObject($this->currentapp.'_soadmin_location');
-
- $location_types =
$soadmin_location->select_location_type();
- unset($soadmin_location);
-
- return
$this->socommon->read_location_data($location_code,$location_types);
- }
-
- function read_single_tenant($tenant_id)
- {
- return $this->socommon->read_single_tenant($tenant_id);
- }
-
- function check_location($location_code='',$type_id='')
- {
- return
$this->socommon->check_location($location_code,$type_id);
- }
-
- function generate_sql($data)
- {
-//html_print_r($data);
-
- $cols =
(isset($data['cols'])?$data['cols']:'');
- $entity_table =
(isset($data['entity_table'])?$data['entity_table']:'');
- $cols_return =
(isset($data['cols_return'])?$data['cols_return']:'');
- $uicols =
(isset($data['uicols'])?$data['uicols']:'');
- $joinmethod =
(isset($data['joinmethod'])?$data['joinmethod']:'');
- $paranthesis =
(isset($data['paranthesis'])?$data['paranthesis']:'');
- $lookup =
(isset($data['lookup'])?$data['lookup']:'');
- $location_level =
(isset($data['location_level'])?$data['location_level']:'');
-
- $this->join = $this->socommon->join;
-
- $joinmethod .= " $this->join fm_location1 ON
($entity_table.loc1 = fm_location1.loc1))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id))";
- $paranthesis .='(';
- $joinmethod .= " $this->join fm_owner ON
(fm_location1.owner_id = fm_owner.owner_id))";
- $paranthesis .='(';
-
- $soadmin_location =
CreateObject($this->currentapp.'_soadmin_location');
- $location_types =
$soadmin_location->select_location_type();
- $config = $soadmin_location->read_config();
-
- if($location_level)
- {
- $type_id=$location_level;
- }
- else
- {
- $type_id = count($location_types);
- }
- $this->type_id = $type_id;
-
- for ($i=0; $i<$type_id; $i++)
- {
-
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
- $uicols['descr'][] =
$location_types[$i]['name'];
- $uicols['statustext'][] =
$location_types[$i]['descr'];
- }
-/*
- $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
- $location_cols_count = count($fm_location_cols);
-
- for ($i=0;$i<$location_cols_count;$i++)
- {
- if($fm_location_cols[$i]['list']==1)
- {
- $cols_extra[]
= $fm_location_cols[$i]['column_name']; // only for lookup
- $cols_return[]
= $fm_location_cols[$i]['column_name'];
- $uicols['input_type'][] =
'text';
- $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
- $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
- $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
- }
- }
-
-*/
- unset($soadmin_location);
-
- for ($i=0; $i< $this->type_id; $i++)
- {
- $cols_return[] = 'loc' .
$location_types[$i]['id'];
- }
-
- if($lookup)
- {
- $cols_return[] =
'loc1_name';
- $cols_extra[] =
'loc1_name';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] =
'loc1_name';
- $uicols['descr'][] =
lang('Property Name');
- $uicols['statustext'][] =
lang('Property Name');
-
- for ($i=2;$i<($type_id+1);$i++)
- {
- $cols_return_lookup[] = 'loc'
. $i . '_name';
- $uicols['input_type'][] =
'hidden';
- $uicols['name'][]
= 'loc' . $i . '_name';
- $uicols['descr'][]
= '';
- $uicols['statustext'][] = '';
- }
- }
-
- $cols.= ",$entity_table.address";
- $cols_return[] = 'address';
- $uicols['input_type'][] = 'text';
- $uicols['name'][] = 'address';
- $uicols['descr'][] =
lang('address');
- $uicols['statustext'][] = lang('address');
-
-//html_print_r($config);
- $config_count = count($config);
- for ($i=0;$i<$config_count;$i++)
- {
-
- if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['query_value'] ==1))
- {
-
-
if($config[$i]['column_name']=='street_id')
- {
-
- $cols_return[]
= 'street_name';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'street_name';
- $uicols['descr'][]
= lang('street name');
- $uicols['statustext'][]
= lang('street name');
-
- $cols_return[]
= 'street_number';
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= 'street_number';
- $uicols['descr'][]
= lang('street number');
- $uicols['statustext'][]
= lang('street number');
-
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'hidden';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= lang($config[$i]['input_text']);
- $uicols['statustext'][]
= lang($config[$i]['input_text']);
- if($lookup)
- {
- $cols_extra[]
= 'street_name';
- $cols_extra[]
= 'street_number';
- $cols_extra[]
= $config[$i]['column_name'];
- }
-
- }
- else
- {
- $cols_return[]
= $config[$i]['column_name'];
- $uicols['input_type'][]
= 'text';
- $uicols['name'][]
= $config[$i]['column_name'];
- $uicols['descr'][]
= $config[$i]['input_text'];
- $uicols['statustext'][]
= $config[$i]['input_text'];
-
- if($lookup)
- {
- $cols_extra[]
= $config[$i]['column_name'];
- }
- }
- }
- }
-
- $this->uicols = $uicols;
- $this->cols_return = $cols_return;
- $this->cols_extra = $cols_extra;
- $this->cols_return_lookup = $cols_return_lookup;
-
- $from .= " FROM $paranthesis $entity_table ";
-
- $sql = "SELECT $cols $from $joinmethod";
-
- return $sql;
-
- }
-
- function select_part_of_town($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$this->xsl_add_file(array('select_part_of_town'));
- break;
- case 'filter':
-
$this->xsl_add_file(array('filter_part_of_town'));
- break;
- }
-
- $parts= $this->socommon->select_part_of_town();
-
- while (is_array($parts) && list(,$part) = each($parts))
- {
- $sel_part = '';
- if ($part['id']==$selected)
- {
- $sel_part = 'selected';
- }
-
- $part_of_town_list[] = array
- (
- 'id' => $part['id'],
- 'name' => $part['name'],
- 'selected' => $sel_part
- );
- }
-
- for ($i=0;$i<count($part_of_town_list);$i++)
- {
- if ($part_of_town_list[$i]['selected'] !=
'selected')
- {
-
unset($part_of_town_list[$i]['selected']);
- }
- }
-
- return $part_of_town_list;
- }
-
- function select_category_property_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$this->xsl_add_file(array('cat_select'));
- break;
- case 'filter':
-
$this->xsl_add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->socommon->select_category_property_list();
-
- while (is_array($categories) && list(,$category) =
each($categories))
- {
- $sel_category = '';
- if ($category['id']==$selected)
- {
- $sel_category = 'selected';
- }
-
- $category_list[] = array
- (
- 'cat_id' => $category['id'],
- 'name' => $category['name'],
- 'selected' => $sel_category
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
- function select_district_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->add_xsl('property.select_district');
- break;
- case 'filter':
-
$GLOBALS['phpgw']->add_xsl('property.filter_district');
- break;
- }
-
- $districts= $this->socommon->select_district_list();
-
- while (is_array($districts) && list(,$district) =
each($districts))
- {
- $sel_district = '';
- if ($district['id']==$selected)
- {
- $sel_district = 'selected';
- }
-
- $district_list[] = array
- (
- 'id' => $district['id'],
- 'name' => $district['name'],
- 'selected' => $sel_district
- );
- }
-
- for ($i=0;$i<count($district_list);$i++)
- {
- if ($district_list[$i]['selected'] !=
'selected')
- {
- unset($district_list[$i]['selected']);
- }
- }
-//html_print_r($district_list);
-
- return $district_list;
- }
-
-
- function validate_db_insert($values)
- {
- foreach($values as $value)
- {
- if($value)
- {
- $insert_value[] = "'".$value."'";
- }
- else
- {
- $insert_value[] = 'NULL';
- }
- }
-
- $values = implode(",", $insert_value);
- return $values;
- }
-
- function validate_db_update($value_set)
- {
- while (is_array($value_set) && list($field,$value) =
each($value_set))
- {
- if($value)
- {
- $value_entry[]= "$field='$value'";
- }
- else
- {
- $value_entry[]= "$field=NULL";
- }
- }
-
- $value_set = implode(",", $value_entry);
- return $value_set;
- }
-
- function fm_cache($name='',$value='')
- {
- return $this->socommon->fm_cache($name,$value);
- }
-
- function next_id($table,$key='')
- {
- return $this->socommon->next_id($table,$key);
- }
-
- function select_datatype($selected='')
- {
- $datatypes[0]['id']= 'V';
- $datatypes[0]['name']= lang('varchar');
- $datatypes[1]['id']= 'C';
- $datatypes[1]['name']= lang('Character');
- $datatypes[2]['id']= 'I';
- $datatypes[2]['name']= lang('Integer');
- $datatypes[3]['id']= 'N';
- $datatypes[3]['name']= lang('Decimal');
- $datatypes[4]['id']= 'D';
- $datatypes[4]['name']= lang('Date');
- $datatypes[5]['id']= 'T';
- $datatypes[5]['name']= lang('Memo');
- $datatypes[6]['id']= 'R';
- $datatypes[6]['name']= lang('Multiple radio');
- $datatypes[7]['id']= 'CH';
- $datatypes[7]['name']= lang('Multiple Checkbox');
- $datatypes[8]['id']= 'LB';
- $datatypes[8]['name']= lang('ListBox');
- $datatypes[9]['id']= 'AB';
- $datatypes[9]['name']= lang('Contact');
-
- return $this->select_list($selected,$datatypes);
-
- }
-
- function select_nullable($selected='')
- {
- $nullable[0]['id']= 'True';
- $nullable[0]['name']= lang('True');
- $nullable[1]['id']= 'False';
- $nullable[1]['name']= lang('False');
-
- return $this->select_list($selected,$nullable);
- }
-
-
- function excel($list,$name,$descr)
- {
- $GLOBALS['phpgw_info']['flags']['noframework'] = True;
- require('PEAR.php');
- $xls =
CreateObject($this->currentapp.'_excel');
-
- $count_uicols_name=count($name);
-
- $j=0;
- if (isset($list) AND is_array($list))
- {
- $str=$xls->Begin();
- foreach($list as $entry)
- {
- $m=0;
- for ($k=0;$k<$count_uicols_name;$k++)
- {
-
if($uicols['input_type'][$k]!='hidden')
- {
- $content[$j][$m]
= str_replace("\r\n"," ",$entry[$name[$k]]);
-
$str.=$xls->WriteLabel(0,$m,$descr[$k]);
- $m++;
- }
- }
-
- $j++;
- }
-
- foreach($content as $row)
- {
- $line++;
- for ($i=0; $i<count($row); $i++)
- {
-
$str.=$xls->WriteLabel($line,$i,$row[$i]);
- }
- }
-
- $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
-
- $str.=$xls->EOF();
- $size=strlen($str);
-
- $browser = CreateObject('phpgwapi_browser');
-
$browser->content_header($filename,'application/vnd.ms-excel',$size);
-
- echo $str;
- }
-
- }
-
- /*!
- @function show_sort_order
- @abstract ?
- @param $sort ?
- @param $var ?
- @param $order ?
- @param $program ?
- @param $text ?
- @param $extra default ''
- @param $build_an_href default True
- */
- function show_sort_order($sort, $var = '', $order = '',
$program = '', $text = '', $extra='', $build_an_href = True)
- {
-// if(MENUACTION)
- {
- $this->action = $GLOBALS['_GET']['op'];
- }
-
- if(is_array($sort))
- {
- $temp_format = $sort['sort'];
- $var =
(isset($sort['var'])?$sort['var']:'');
- $order =
(isset($sort['order'])?$sort['order']:'');
- $program =
(isset($sort['program'])?$sort['program']:'/index.php');
- $text =
(isset($sort['text'])?$sort['text']:'xslt');
- $extra =
(isset($sort['extra'])?$sort['extra']:'');
- $build_an_href =
(isset($sort['build_an_href'])?$sort['build_an_href']:True);
- settype($sort,'string');
- $sort = $temp_format;
- unset($temp_format);
- }
-
- list($filter,$qfield,$start,$NULL1,$NULL) =
$this->get_var();
-
- if(($order == $var) && ($sort == 'ASC'))
- {
- $sort = 'DESC';
- }
- elseif(($order == $var) && ($sort == 'DESC'))
- {
- $sort = 'ASC';
- }
- else
- {
- $sort = 'ASC';
- }
-
- if(is_array($extra))
- {
- $extra = $this->extras_to_string($extra);
- }
-
- $extravar =
'order='.$var.'&sort='.$sort.'&filter='.$filter.'&qfield='.$qfield.'&start='.$start.'&query='.urlencode(stripslashes($GLOBALS['query'])).$extra;
-
- $link =
($this->action?$this->page($extravar):$this->link($program,$extravar));
-
- if ($text == 'xslt')
- {
- return $link;
- }
- elseif($build_an_href)
- {
- return '<a href="' . $link . '">' . $text .
'</a>';
- }
- else
- {
- return $link;
- }
- }
- /*!
- @function get_var
- @abstract Fetch commonly-used GP(C) vars
- @discussion This calls get_var() from functions.inc.php
- */
- function get_var()
- {
- return array(
- get_var('filter',array('GLOBAL','POST','GET')),
- get_var('qfield',array('GLOBAL','POST','GET')),
- get_var('start',array('GLOBAL','POST','GET')),
- get_var('order',array('GLOBAL','POST','GET')),
- get_var('sort',array('GLOBAL','POST','GET'))
- );
- }
-
- function extras_to_string($extra)
- {
- if(is_array($extra))
- {
- @reset($extra);
- while(list($var,$value) = each($extra))
- {
- $t_extras[] = $var . '=' . $value;
- }
- $extra_s = '&' . implode('&',$t_extras);
- }
- return $extra_s;
- }
-
- function page($extravars='')
- {
- if($extravars && is_string($extravars) &&
substr($extravars,0,1)!='&')
- {
- $extras = '&'.$extravars;
- }
- elseif($extravars && is_array($extravars))
- {
- @reset($extravars);
- while(list($var,$value) = each($extravars))
- {
- if($var != 'sid=cookie&op')
- {
- $t_extras[] = $var.'='.$value;
- }
- }
- $extras = implode($t_extras,'&');
- }
-
- return
$this->link('/index.php','sid=cookie&op='.$this->action.$extras);
- }
-
- function link($url, $extravars = '')
- {
- /* first we process the $url to build the full
scriptname */
- $full_scriptname = True;
-
- $url_firstchar = substr($url ,0,1);
- if ($url_firstchar == '/' &&
$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] == '/')
- {
- $full_scriptname = False;
- }
-
- if ($url_firstchar != '/')
- {
- $app =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- if ($app != 'home' && $app != 'login' && $app
!= 'logout')
- {
- $url = $app.'/'.$url;
- }
- }
-
- if($full_scriptname)
- {
- $webserver_url_count =
strlen($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'])-1;
-
if(substr($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] ,$webserver_url_count,1) !=
'/' && $url_firstchar != '/')
- {
- $url =
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) .'/'. $url;
- }
- else
- {
- $url =
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) . $url;
- }
- }
-
-
if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) &&
$GLOBALS['phpgw_info']['server']['enforce_ssl'] && !$_SERVER['HTTPS'])
- {
- if(substr($url ,0,4) != 'http')
- {
- $url =
'https://'.$GLOBALS['HTTP_HOST'].$url;
- }
- else
- {
- $url = str_replace ( 'http:', 'https:',
$url);
- }
- }
-
- /* Now we process the extravars into a proper url
format */
- /* if its not an array, then we turn it into one */
- /* We do this to help prevent any duplicates from being
sent. */
- if (!is_array($extravars) && $extravars != '')
- {
- $a = explode('&', $extravars);
- $i = 0;
- while ($i < count($a))
- {
- $b = split('=', $a[$i]);
- $new_extravars[$b[0]] = $b[1];
- $i++;
- }
- $extravars = $new_extravars;
- unset($new_extravars);
- }
-
-//html_print_r($extravars);
- /* if using frames we make sure there is a framepart */
- if(@defined('PHPGW_USE_FRAMES') && PHPGW_USE_FRAMES)
- {
- if (!isset($extravars['framepart']))
- {
- $extravars['framepart']='body';
- }
- }
-
- /* add session params if not using cookies */
-/* if (@!$GLOBALS['phpgw_info']['server']['usecookies'])
- {
- $extravars['sessionid'] = $this->sessionid;
- $extravars['kp3'] = $this->kp3;
- $extravars['domain'] = $this->account_domain;
- }
-*/
- /* if we end up with any extravars then we generate the
url friendly string */
- /* and return the result */
- if (is_array($extravars))
- {
- $new_extravars = '';
- reset($extravars);
- while(list($key,$value) = each($extravars))
- {
- if (!empty($new_extravars))
- {
- $new_extravars .= '&';
- }
- $new_extravars .=
$key.'='.htmlentities(urlencode($value));
- }
- return $url .= '?' . $new_extravars;
- }
- /* if no extravars then we return the cleaned up
url/scriptname */
- return $url;
- }
-
- function redirect_link($url, $extravars = '')
- {
- $link = $this->link($url, $extravars);
- header('Location: '.$link);
- }
-
- function xsl_add_file($filename)
- {
- reset($filename);
- while(list(,$file) = each($filename))
- {
- $GLOBALS['phpgw']->add_xsl($this->currentapp .
'.' .$file);
- }
- }
-
- function xslt_filter($data=0)
- {
-
- $this->xsl_add_file(array('filter_select'));
-
- if(is_array($data))
- {
- $filter =
(isset($data['filter'])?$data['filter']:'');
- $format =
(isset($data['format'])?$data['format']:'all');
- $link_data =
(isset($data['link_data'])?$data['link_data']:'');
- }
- else
- {
- return False;
- }
-
- switch($format)
- {
- case 'yours':
- $filter_obj = array
- (
- array('key' => 'none','lang' =>
lang('show all')),
- array('key' => 'yours','lang'
=> lang('only yours'))
- );
- break;
- case 'private':
- $filter_obj = array
- (
- array('key' => 'none','lang' =>
lang('show all')),
- array('key' => 'private','lang'
=> lang('only private'))
- );
- break;
- default:
- $filter_obj = array
- (
- array('key' => 'none','lang' =>
lang('show all')),
- array('key' => 'yours','lang'
=> lang('only yours')),
- array('key' => 'private','lang'
=> lang('only private'))
- );
- }
-
- for($i=0;$i<count($filter_obj);$i++)
- {
- if($filter_obj[$i]['key'] == $filter)
- {
- $filter_obj[$i]['selected'] = 'yes';
- }
- }
-
- $filter_data = array
- (
- 'filter_list' =>
$filter_obj,
- 'lang_filter_statustext' => lang('Select
the filter. To show all entries select SHOW ALL'),
- 'lang_submit' =>
lang('submit'),
- 'select_url' =>
$this->link('/index.php',$link_data)
- );
- return $filter_data;
- }
- }
-?>
+<?php
+
/**************************************************************************\
+ * phpGroupWare - property
*
+ * http://www.phpgroupware.org
*
+ *
*
+ * Facilities Management
*
+ * Written by Sigurd Nes [sigurdne at online.no]
*
+ *
------------------------------------------------------------------------ *
+ * Copyright 2000 - 2003 Free Software Foundation, Inc
*
+ * This program is part of the GNU project, see http://www.gnu.org/
*
+ *
------------------------------------------------------------------------ *
+ * This program is free software; you can redistribute it and/or modify
it *
+ * under the terms of the GNU General Public License as published by the
*
+ * Free Software Foundation; either version 2 of the License, or (at
your *
+ * option) any later version.
*
+
\**************************************************************************/
+ /* $Id$ */
+
+ class property_bocommon
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $district_id;
+ var $action;
+
+
+ var $public_functions = array
+ (
+ 'select_part_of_town' => True,
+ 'menu' => True,
+ );
+
+ var $soap_functions = array(
+ 'list' => array(
+ 'in' =>
array('int','int','struct','string','int'),
+ 'out' => array('array')
+ ),
+ 'read' => array(
+ 'in' => array('int','struct'),
+ 'out' => array('array')
+ ),
+ 'save' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ ),
+ 'delete' => array(
+ 'in' => array('int','struct'),
+ 'out' => array()
+ )
+ );
+
+ function property_bocommon()
+ {
+
+ $this->currentapp = 'property';
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->socommon =
CreateObject($this->currentapp.'_socommon');
+
+ $this->join = $this->socommon->join;
+ $this->left_join = $this->socommon->left_join;
+
+ switch($GLOBALS['phpgw_info']['server']['db_type'])
+ {
+ case 'mssql':
+ $this->dateformat = "M d
Y";
+ $this->datetimeformat = "M d Y g:iA";
+ break;
+ case 'mysql':
+ $this->dateformat =
"Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+ break;
+ case 'pgsql':
+ $this->dateformat =
"Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+// $this->dateformat = "F j,
Y";
+// $this->datetimeformat = "F j, Y g:iA";
+ break;
+ }
+
+ /* if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+ {
+ $this->dateformat = "M d Y";
+ $this->datetimeformat = "M d Y g:iA";
+ }
+ else
+ {
+ $this->dateformat = "Y-m-d";
+ $this->datetimeformat = "Y-m-d G:i:s";
+ }
+ */
+
+ }
+
+ function jscalendar()
+ {
+ $phpgw_js_url =
$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'].'/phpgwapi/js';
+ $img = $phpgw_js_url.'/jscalendar/img.gif';
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $jsDateFormat = str_replace(array('d', 'm', 'M', 'Y'),
array('%d', '%m', '%b', '%Y'), $dateformat);
+
+ $GLOBALS['phpgw_info']['flags']['java_script']
.='</script>
+ <link rel="stylesheet" type="text/css" media="all"
href="'.$phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css"
title="win2k-cold-1" >
+ <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar.js"></script>
+ <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/calendar-setup.js"></script>
+ <script type="text/javascript"
src="'.$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js"></script>
+ ';
+
+
+// <script type="text/javascript"
src="'.ereg_replace('[?&]*click_history=[0-9a-f]*','',$this->link('/phpgwapi/js/jscalendar/jscalendar-setup.php')).'"></script>
+
+ $cal_info=array(
+// 'stylesheet'
=> $phpgw_js_url.'/jscalendar/calendar-win2k-cold-1.css',
+// 'calendar_source'
=> $phpgw_js_url.'/jscalendar/calendar.js',
+// 'calendar_setup_source' =>
$phpgw_js_url.'/jscalendar/calendar-setup.js',
+// 'calendar_lang'
=>
$phpgw_js_url.'/jscalendar/lang/calendar-'.substr($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],0,2)
.'.js',
+ 'jsDateFormat'
=> $jsDateFormat,
+ 'img'
=> $img,
+ );
+ return $cal_info;
+ }
+
+ function check_perms($rights, $required)
+ {
+ // return (!!($rights & $required) == True);
+ return ($rights & $required);
+ }
+
+ function create_preferences($app='',$user_id='')
+ {
+ return
$this->socommon->create_preferences($app,$user_id);
+ }
+
+ function get_lookup_entity($location='')
+ {
+ return $this->socommon->get_lookup_entity($location);
+ }
+
+ function get_start_entity($location='')
+ {
+ return $this->socommon->get_start_entity($location);
+ }
+
+ function msgbox_data($receipt)
+ {
+ $msgbox_data_error=array();
+ if (isSet($receipt['error']) AND
is_array($receipt['error']))
+ {
+ foreach($receipt['error'] as $errors)
+ {
+ $msgbox_data_error +=
array($errors['msg']=> False);
+ }
+ }
+
+ $msgbox_data_message=array();
+
+ if (isSet($receipt['message']) AND
is_array($receipt['message']))
+ {
+ foreach($receipt['message'] as $messages)
+ {
+ $msgbox_data_message +=
array($messages['msg']=> True);
+ }
+ }
+
+ $msgbox_data = $msgbox_data_error +
$msgbox_data_message;
+
+ return $msgbox_data;
+ }
+
+ function moneyformat($amount)
+ {
+ if
($GLOBALS['phpgw_info']['server']['db_type']=='mssql')
+ {
+ $moneyformat =
"CONVERT(MONEY,"."'$amount'".",0)";
+ }
+ else
+ {
+ $moneyformat = "'" . $amount . "'";
+ }
+
+ return $moneyformat;
+ }
+
+
+ function date_array($date)
+ {
+ $dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $dateformat = str_replace(".","",$dateformat);
+ $dateformat = str_replace("-","",$dateformat);
+ $dateformat = str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/', $date);
+ $date_array['day'] = $dateparts[$d];
+ $date_array['month'] = $dateparts[$m];
+ $date_array['year'] = $dateparts[$y];
+
+ return $date_array;
+ }
+
+ function date_to_timestamp($date)
+ {
+ if($date)
+ {
+ $date_array = $this->date_array($date);
+ $date = mktime
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+ }
+ return $date;
+ }
+
+
+ function
column_list($selected='',$entity_type='',$cat_id,$allrows='')
+ {
+ $bostandard_entity =
CreateObject($this->currentapp.'_bostandard_entity',True);
+
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp][$entity_type.'_columns_'.$cat_id];
+ }
+
+ $columns =
$bostandard_entity->read_attrib($entity_type,$cat_id,$allrows);
+//html_print_r($columns);
+
+
$column_list=$this->select_multi_list($selected,$columns);
+
+ return $column_list;
+
+ }
+
+ function select_multi_list($selected='',$input_list)
+ {
+ $j=0;
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $output_list[$j]['id'] = $entry['id'];
+ $output_list[$j]['name'] =
$entry['name'];
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i] ==
$entry['id'])
+ {
+
$output_list[$j]['selected'] = 'selected';
+ }
+ }
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($output_list);$i++)
+ {
+ if ($output_list[$i]['selected'] != 'selected')
+ {
+ unset($output_list[$i]['selected']);
+ }
+ }
+
+ return $output_list;
+ }
+
+
+
+ function select_list($selected='',$input_list='')
+ {
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $sel_entry = '';
+ if ($entry['id']==$selected)
+ {
+ $sel_entry = 'selected';
+ }
+ $entry_list[] = array
+ (
+ 'id' => $entry['id'],
+ 'name' =>
$entry['name'],
+ 'selected' => $sel_entry
+ );
+ }
+ for ($i=0;$i<count($entry_list);$i++)
+ {
+ if ($entry_list[$i]['selected'] !=
'selected')
+ {
+
unset($entry_list[$i]['selected']);
+ }
+ }
+ }
+ return $entry_list;
+ }
+
+
+ function
get_user_list($format='',$selected='',$extra='',$default='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$this->xsl_add_file(array('user_id_select'));
+ break;
+ case 'filter':
+
$this->xsl_add_file(array('user_id_filter'));
+ break;
+ }
+
+ if(!$selected && $default)
+ {
+ $selected = $default;
+ }
+
+ if (is_array($extra))
+ {
+ foreach($extra as $extra_user)
+ {
+ $users_extra[]=array
+ (
+ 'account_id' => $extra_user,
+ 'account_firstname' =>
lang($extra_user)
+ );
+ }
+ }
+
+ $accounts = CreateObject('phpgwapi_accounts');
+ $users = $accounts->get_list('accounts', $start, $sort,
$order, $query);
+ unset($accounts);
+ if (is_array($users_extra) && is_array($users))
+ {
+ $users = $users_extra + $users;
+ }
+
+ if (isSet($users) AND is_array($users))
+ {
+ foreach($users as $user)
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'user_id' =>
$user['account_id'],
+ 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+ }
+
+ $user_count= count($user_list);
+ for ($i=0;$i<$user_count;$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//html_print_r($user_list);
+ return $user_list;
+ }
+
+ function get_group_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$this->xsl_add_file(array('group_select'));
+ break;
+ case 'filter':
+
$this->xsl_add_file(array('group_filter'));
+ break;
+ }
+
+ $accounts = CreateObject('phpgwapi_accounts');
+ $users = $accounts->get_list('groups', $start, $sort,
$order, $query);
+ unset($accounts);
+ if (isSet($users) AND is_array($users))
+ {
+ foreach($users as $user)
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'id' => $user['account_id'],
+ 'name' =>
$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+ }
+
+ $user_count= count($user_list);
+ for ($i=0;$i<$user_count;$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+//html_print_r($user_list);
+ return $user_list;
+ }
+
+
+ function
get_user_list_right($right='',$selected='',$acl_location='')
+ {
+
$employees=$this->socommon->get_user_list_right($right,$acl_location);
+ while (is_array($employees) && list(,$user) =
each($employees))
+ {
+ $sel_user = '';
+ if ($user['account_lid']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'lid' =>
$user['account_lid'],
+ 'firstname' =>
$user['account_firstname'],
+ 'lastname' =>
$user['account_lastname'],
+ 'selected' => $sel_user
+ );
+ }
+
+ for ($i=0;$i<count($user_list);$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+ return $user_list;
+ }
+
+ function
get_user_list_right2($format='',$right='',$selected='',$acl_location='',$extra='',$default='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$this->xsl_add_file(array('user_id_select'));
+ break;
+ case 'filter':
+
$this->xsl_add_file(array('user_id_filter'));
+ break;
+ }
+
+ if(!$selected && $default)
+ {
+ $selected = $default;
+ }
+
+ if (isset($extra) AND is_array($extra))
+ {
+ foreach($extra as $extra_user)
+ {
+ $users_extra[]=array
+ (
+ 'account_id' => $extra_user,
+ 'account_firstname' =>
lang($extra_user)
+ );
+ }
+ }
+
+
$users=$this->socommon->get_user_list_right($right,$acl_location);
+
+ if (is_array($users_extra) && is_array($users))
+ {
+ $users = $users_extra + $users;
+ }
+
+ while (is_array($users) && list(,$user) = each($users))
+ {
+ $sel_user = '';
+ if ($user['account_id']==$selected)
+ {
+ $sel_user = 'selected';
+ }
+
+ $user_list[] = array
+ (
+ 'user_id' =>
$user['account_id'],
+ 'name' =>
$user['account_lastname'].' '.$user['account_firstname'],
+ 'selected' => $sel_user
+ );
+ }
+
+ for ($i=0;$i<count($user_list);$i++)
+ {
+ if ($user_list[$i]['selected'] != 'selected')
+ {
+ unset($user_list[$i]['selected']);
+ }
+ }
+
+ return $user_list;
+ }
+
+
+ function initiate_ui_vendorlookup($data)
+ {
+//html_print_r($data);
+ $contacts =
CreateObject('phpgwapi_contacts');
+
+ if($data['type']=='view')
+ {
+ $this->xsl_add_file(array('vendor_view'));
+ }
+ else
+ {
+ $this->xsl_add_file(array('vendor_form'));
+ }
+
+ $vendor['value_vendor_id']
= $data['vendor_id'];
+ $vendor['value_vendor_name'] =
$data['vendor_name'];
+
+ if($data['vendor_id'] && !$data['vendor_name'])
+ {
+ $vendor_data
=
$contacts->read_single_entry($data['vendor_id'],array('org_name'=>'org_name','email'=>'email'));
+ $vendor['value_vendor_name'] =
$vendor_data[0]['org_name'];
+ }
+
+ $vendor['vendor_link']
=
$this->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilookup.addressbook');
+ $vendor['lang_vendor']
= lang('Vendor');
+ $vendor['lang_select_vendor_help'] =
lang('Klick this link to select vendor');
+ $vendor['lang_vendor_name']
= lang('Vendor Name');
+
+ unset($contacts);
+//html_print_r($vendor);
+ return $vendor;
+ }
+
+
+ function initiate_ui_budget_account_lookup($data)
+ {
+//html_print_r($data);
+
+ $this->xsl_add_file(array('b_account_form'));
+ $b_account['value_b_account_id']
= $data['b_account_id'];
+ $b_account['value_b_account_name']
= $data['b_account_name'];
+ $b_account['b_account_link']
=
$this->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilookup.b_account');
+ $b_account['lang_b_account']
= lang('b_account');
+ $b_account['lang_select_b_account_help'] =
lang('Klick this link to select budget account');
+ $b_account['lang_b_account']
= lang('Budget account');
+
+//html_print_r($b_account);
+ return $b_account;
+ }
+
+ function
select_multi_list_2($selected='',$input_list,$input_type='')
+ {
+ $j=0;
+ if (isset($input_list) AND is_array($input_list))
+ {
+ foreach($input_list as $entry)
+ {
+ $output_list[$j]['id'] = $entry['id'];
+ $output_list[$j]['value'] =
$entry['value'];
+ $output_list[$j]['input_type'] =
$input_type;
+
+ for ($i=0;$i<count($selected);$i++)
+ {
+ if($selected[$i] ==
$entry['id'])
+ {
+
$output_list[$j]['checked'] = 'checked';
+ }
+ }
+ $j++;
+ }
+ }
+
+ for ($i=0;$i<count($output_list);$i++)
+ {
+ if ($output_list[$i]['checked'] != 'checked')
+ {
+ unset($output_list[$i]['checked']);
+ }
+ }
+
+ return $output_list;
+ }
+
+ function translate_datatype($datatype)
+ {
+ $datatype_text = array(
+ 'V' => 'Varchar',
+ 'I' => 'Integer',
+ 'C' => 'char',
+ 'N' => 'Float',
+ 'D' => 'Date',
+ 'T' => 'Memo',
+ 'R' => 'Muliple radio',
+ 'CH' => 'Muliple checkbox',
+ 'LB' => 'Listbox',
+ 'AB' => 'Contact'
+ );
+
+ $datatype = lang($datatype_text[$datatype]);
+
+ return $datatype;
+ }
+
+ function translate_datatype_insert($datatype)
+ {
+ $datatype_text = array(
+ 'V' => 'varchar',
+ 'I' => 'int',
+ 'C' => 'char',
+ 'N' => 'decimal',
+ 'D' => 'timestamp',
+ 'T' => 'text',
+ 'R' => 'int',
+ 'CH' => 'text',
+ 'LB' => 'int',
+ 'AB' => 'int'
+ );
+
+ return $datatype_text[$datatype];
+ }
+
+
+ function save_attributes($values_attribute,$type)
+ {
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ }
+ if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
$values_attribute[$i]['value'][0];
+ }
+
+ if($values_attribute[$i]['datatype']=='N' &&
$values_attribute[$i]['value'])
+ {
+ $values_attribute[$i]['value'] =
str_replace(",",".",$values_attribute[$i]['value']);
+ }
+
+ if($values_attribute[$i]['datatype']=='D' &&
$values_attribute[$i]['value'])
+ {
+ $dateformat=
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $dateformat =
str_replace(".","",$dateformat);
+ $dateformat =
str_replace("-","",$dateformat);
+ $dateformat =
str_replace("/","",$dateformat);
+ $y=strpos($dateformat,'Y');
+ $d=strpos($dateformat,'d');
+ $m=strpos($dateformat,'m');
+
+ $dateparts = explode('/',
$values_attribute[$i]['value']);
+ $day = $dateparts[$d];
+ $month = $dateparts[$m];
+ $year = $dateparts[$y];
+ $values_attribute[$i]['value'] =
date($this->dateformat,mktime(2,0,0,$month,$day,$year));
+ }
+ }
+
+
$this->socommon->save_attributes($values_attribute,$type);
+ }
+
+ function list_methods($_type='xmlrpc')
+ {
+ /*
+ This handles introspection or discovery by the logged
in client,
+ in which case the input might be an array. The
server always calls
+ this function to fill the server dispatch map using a
string.
+ */
+ if (is_array($_type))
+ {
+ $_type = $_type['type'] ? $_type['type'] :
$_type[0];
+ }
+ switch($_type)
+ {
+ case 'xmlrpc':
+ $xml_functions = array(
+ 'read' => array(
+ 'function' => 'read',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
+ ),
+ 'save' => array(
+ 'function' => 'save',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Update a single entry by passing the fields.')
+ ),
+ 'delete' => array(
+ 'function' => 'delete',
+ 'signature' =>
array(array(xmlrpcBoolean,xmlrpcInt)),
+ 'docstring' =>
lang('Delete a single entry by passing the id.')
+ ),
+ 'list' => array(
+ 'function' => '_list',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Read a list of entries.')
+ ),
+ 'list_methods' => array(
+ 'function' =>
'list_methods',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
+ 'docstring' =>
lang('Read this list of methods.')
+ )
+ );
+ return $xml_functions;
+ break;
+ case 'soap':
+ return $this->soap_functions;
+ break;
+ default:
+ return array();
+ break;
+ }
+ }
+
+ function add_leading_zero($num)
+ {
+
+ if ($id_type == "hex")
+ {
+ $num = hexdec($num);
+ $num++;
+ $num = dechex($num);
+ }
+ else
+ {
+ $num++;
+ }
+
+ if (strlen($num) == 4)
+ $return = $num;
+ if (strlen($num) == 3)
+ $return = "0$num";
+ if (strlen($num) == 2)
+ $return = "00$num";
+ if (strlen($num) == 1)
+ $return = "000$num";
+ if (strlen($num) == 0)
+ $return = "0001";
+
+ return strtoupper($return);
+ }
+
+
+ function read_location_data($location_code)
+ {
+ $soadmin_location =
CreateObject($this->currentapp.'_soadmin_location');
+
+ $location_types =
$soadmin_location->select_location_type();
+ unset($soadmin_location);
+
+ return
$this->socommon->read_location_data($location_code,$location_types);
+ }
+
+ function read_single_tenant($tenant_id)
+ {
+ return $this->socommon->read_single_tenant($tenant_id);
+ }
+
+ function check_location($location_code='',$type_id='')
+ {
+ return
$this->socommon->check_location($location_code,$type_id);
+ }
+
+ function generate_sql($data)
+ {
+//html_print_r($data);
+
+ $cols =
(isset($data['cols'])?$data['cols']:'');
+ $entity_table =
(isset($data['entity_table'])?$data['entity_table']:'');
+ $cols_return =
(isset($data['cols_return'])?$data['cols_return']:'');
+ $uicols =
(isset($data['uicols'])?$data['uicols']:'');
+ $joinmethod =
(isset($data['joinmethod'])?$data['joinmethod']:'');
+ $paranthesis =
(isset($data['paranthesis'])?$data['paranthesis']:'');
+ $lookup =
(isset($data['lookup'])?$data['lookup']:'');
+ $location_level =
(isset($data['location_level'])?$data['location_level']:'');
+
+ $this->join = $this->socommon->join;
+
+ $joinmethod .= " $this->join fm_location1 ON
($entity_table.loc1 = fm_location1.loc1))";
+ $paranthesis .='(';
+ $joinmethod .= " $this->join fm_part_of_town ON
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id))";
+ $paranthesis .='(';
+ $joinmethod .= " $this->join fm_owner ON
(fm_location1.owner_id = fm_owner.owner_id))";
+ $paranthesis .='(';
+
+ $soadmin_location =
CreateObject($this->currentapp.'_soadmin_location');
+ $location_types =
$soadmin_location->select_location_type();
+ $config = $soadmin_location->read_config();
+
+ if($location_level)
+ {
+ $type_id=$location_level;
+ }
+ else
+ {
+ $type_id = count($location_types);
+ }
+ $this->type_id = $type_id;
+
+ for ($i=0; $i<$type_id; $i++)
+ {
+
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'loc'
. $location_types[$i]['id'];
+ $uicols['descr'][] =
$location_types[$i]['name'];
+ $uicols['statustext'][] =
$location_types[$i]['descr'];
+ }
+/*
+ $fm_location_cols =
$soadmin_location->read_attrib(array('type_id'=>$type_id,'lookup_type'=>$type_id));
+ $location_cols_count = count($fm_location_cols);
+
+ for ($i=0;$i<$location_cols_count;$i++)
+ {
+ if($fm_location_cols[$i]['list']==1)
+ {
+ $cols_extra[]
= $fm_location_cols[$i]['column_name']; // only for lookup
+ $cols_return[]
= $fm_location_cols[$i]['column_name'];
+ $uicols['input_type'][] =
'text';
+ $uicols['name'][]
= $fm_location_cols[$i]['column_name'];
+ $uicols['descr'][]
= $fm_location_cols[$i]['input_text'];
+ $uicols['statustext'][] =
$fm_location_cols[$i]['statustext'];
+ }
+ }
+
+*/
+ unset($soadmin_location);
+
+ for ($i=0; $i< $this->type_id; $i++)
+ {
+ $cols_return[] = 'loc' .
$location_types[$i]['id'];
+ }
+
+ if($lookup)
+ {
+ $cols_return[] =
'loc1_name';
+ $cols_extra[] =
'loc1_name';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] =
'loc1_name';
+ $uicols['descr'][] =
lang('Property Name');
+ $uicols['statustext'][] =
lang('Property Name');
+
+ for ($i=2;$i<($type_id+1);$i++)
+ {
+ $cols_return_lookup[] = 'loc'
. $i . '_name';
+ $uicols['input_type'][] =
'hidden';
+ $uicols['name'][]
= 'loc' . $i . '_name';
+ $uicols['descr'][]
= '';
+ $uicols['statustext'][] = '';
+ }
+ }
+
+ $cols.= ",$entity_table.address";
+ $cols_return[] = 'address';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'address';
+ $uicols['descr'][] =
lang('address');
+ $uicols['statustext'][] = lang('address');
+
+//html_print_r($config);
+ $config_count = count($config);
+ for ($i=0;$i<$config_count;$i++)
+ {
+
+ if (($config[$i]['location_type'] <= $type_id)
&& ($config[$i]['query_value'] ==1))
+ {
+
+
if($config[$i]['column_name']=='street_id')
+ {
+
+ $cols_return[]
= 'street_name';
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= 'street_name';
+ $uicols['descr'][]
= lang('street name');
+ $uicols['statustext'][]
= lang('street name');
+
+ $cols_return[]
= 'street_number';
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= 'street_number';
+ $uicols['descr'][]
= lang('street number');
+ $uicols['statustext'][]
= lang('street number');
+
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'hidden';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= lang($config[$i]['input_text']);
+ $uicols['statustext'][]
= lang($config[$i]['input_text']);
+ if($lookup)
+ {
+ $cols_extra[]
= 'street_name';
+ $cols_extra[]
= 'street_number';
+ $cols_extra[]
= $config[$i]['column_name'];
+ }
+
+ }
+ else
+ {
+ $cols_return[]
= $config[$i]['column_name'];
+ $uicols['input_type'][]
= 'text';
+ $uicols['name'][]
= $config[$i]['column_name'];
+ $uicols['descr'][]
= $config[$i]['input_text'];
+ $uicols['statustext'][]
= $config[$i]['input_text'];
+
+ if($lookup)
+ {
+ $cols_extra[]
= $config[$i]['column_name'];
+ }
+ }
+ }
+ }
+
+ $this->uicols = $uicols;
+ $this->cols_return = $cols_return;
+ $this->cols_extra = $cols_extra;
+ $this->cols_return_lookup = $cols_return_lookup;
+
+ $from .= " FROM $paranthesis $entity_table ";
+
+ $sql = "SELECT $cols $from $joinmethod";
+
+ return $sql;
+
+ }
+
+ function select_part_of_town($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$this->xsl_add_file(array('select_part_of_town'));
+ break;
+ case 'filter':
+
$this->xsl_add_file(array('filter_part_of_town'));
+ break;
+ }
+
+ $parts= $this->socommon->select_part_of_town();
+
+ while (is_array($parts) && list(,$part) = each($parts))
+ {
+ $sel_part = '';
+ if ($part['id']==$selected)
+ {
+ $sel_part = 'selected';
+ }
+
+ $part_of_town_list[] = array
+ (
+ 'id' => $part['id'],
+ 'name' => $part['name'],
+ 'selected' => $sel_part
+ );
+ }
+
+ for ($i=0;$i<count($part_of_town_list);$i++)
+ {
+ if ($part_of_town_list[$i]['selected'] !=
'selected')
+ {
+
unset($part_of_town_list[$i]['selected']);
+ }
+ }
+
+ return $part_of_town_list;
+ }
+
+ function select_category_property_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$this->xsl_add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$this->xsl_add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->socommon->select_category_property_list();
+
+ while (is_array($categories) && list(,$category) =
each($categories))
+ {
+ $sel_category = '';
+ if ($category['id']==$selected)
+ {
+ $sel_category = 'selected';
+ }
+
+ $category_list[] = array
+ (
+ 'cat_id' => $category['id'],
+ 'name' => $category['name'],
+ 'selected' => $sel_category
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+ function select_district_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->add_xsl('property.select_district');
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->add_xsl('property.filter_district');
+ break;
+ }
+
+ $districts= $this->socommon->select_district_list();
+
+ while (is_array($districts) && list(,$district) =
each($districts))
+ {
+ $sel_district = '';
+ if ($district['id']==$selected)
+ {
+ $sel_district = 'selected';
+ }
+
+ $district_list[] = array
+ (
+ 'id' => $district['id'],
+ 'name' => $district['name'],
+ 'selected' => $sel_district
+ );
+ }
+
+ for ($i=0;$i<count($district_list);$i++)
+ {
+ if ($district_list[$i]['selected'] !=
'selected')
+ {
+ unset($district_list[$i]['selected']);
+ }
+ }
+//html_print_r($district_list);
+
+ return $district_list;
+ }
+
+
+ function validate_db_insert($values)
+ {
+ foreach($values as $value)
+ {
+ if($value)
+ {
+ $insert_value[] = "'".$value."'";
+ }
+ else
+ {
+ $insert_value[] = 'NULL';
+ }
+ }
+
+ $values = implode(",", $insert_value);
+ return $values;
+ }
+
+ function validate_db_update($value_set)
+ {
+ while (is_array($value_set) && list($field,$value) =
each($value_set))
+ {
+ if($value)
+ {
+ $value_entry[]= "$field='$value'";
+ }
+ else
+ {
+ $value_entry[]= "$field=NULL";
+ }
+ }
+
+ $value_set = implode(",", $value_entry);
+ return $value_set;
+ }
+
+ function fm_cache($name='',$value='')
+ {
+ return $this->socommon->fm_cache($name,$value);
+ }
+
+ function next_id($table,$key='')
+ {
+ return $this->socommon->next_id($table,$key);
+ }
+
+ function select_datatype($selected='')
+ {
+ $datatypes[0]['id']= 'V';
+ $datatypes[0]['name']= lang('varchar');
+ $datatypes[1]['id']= 'C';
+ $datatypes[1]['name']= lang('Character');
+ $datatypes[2]['id']= 'I';
+ $datatypes[2]['name']= lang('Integer');
+ $datatypes[3]['id']= 'N';
+ $datatypes[3]['name']= lang('Decimal');
+ $datatypes[4]['id']= 'D';
+ $datatypes[4]['name']= lang('Date');
+ $datatypes[5]['id']= 'T';
+ $datatypes[5]['name']= lang('Memo');
+ $datatypes[6]['id']= 'R';
+ $datatypes[6]['name']= lang('Multiple radio');
+ $datatypes[7]['id']= 'CH';
+ $datatypes[7]['name']= lang('Multiple Checkbox');
+ $datatypes[8]['id']= 'LB';
+ $datatypes[8]['name']= lang('ListBox');
+ $datatypes[9]['id']= 'AB';
+ $datatypes[9]['name']= lang('Contact');
+
+ return $this->select_list($selected,$datatypes);
+
+ }
+
+ function select_nullable($selected='')
+ {
+ $nullable[0]['id']= 'True';
+ $nullable[0]['name']= lang('True');
+ $nullable[1]['id']= 'False';
+ $nullable[1]['name']= lang('False');
+
+ return $this->select_list($selected,$nullable);
+ }
+
+
+ function excel($list,$name,$descr)
+ {
+ $GLOBALS['phpgw_info']['flags']['noframework'] = True;
+ require('PEAR.php');
+ $xls =
CreateObject($this->currentapp.'_excel');
+
+ $count_uicols_name=count($name);
+
+ $j=0;
+ if (isset($list) AND is_array($list))
+ {
+ $str=$xls->Begin();
+ foreach($list as $entry)
+ {
+ $m=0;
+ for ($k=0;$k<$count_uicols_name;$k++)
+ {
+
if($uicols['input_type'][$k]!='hidden')
+ {
+ $content[$j][$m]
= str_replace("\r\n"," ",$entry[$name[$k]]);
+
$str.=$xls->WriteLabel(0,$m,$descr[$k]);
+ $m++;
+ }
+ }
+
+ $j++;
+ }
+
+ foreach($content as $row)
+ {
+ $line++;
+ for ($i=0; $i<count($row); $i++)
+ {
+
$str.=$xls->WriteLabel($line,$i,$row[$i]);
+ }
+ }
+
+ $filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
+
+ $str.=$xls->EOF();
+ $size=strlen($str);
+
+ $browser = CreateObject('phpgwapi_browser');
+
$browser->content_header($filename,'application/vnd.ms-excel',$size);
+
+ echo $str;
+ }
+
+ }
+
+ /*!
+ @function show_sort_order
+ @abstract ?
+ @param $sort ?
+ @param $var ?
+ @param $order ?
+ @param $program ?
+ @param $text ?
+ @param $extra default ''
+ @param $build_an_href default True
+ */
+ function show_sort_order($sort, $var = '', $order = '',
$program = '', $text = '', $extra='', $build_an_href = True)
+ {
+// if(MENUACTION)
+ {
+ $this->action = $GLOBALS['_GET']['op'];
+ }
+
+ if(is_array($sort))
+ {
+ $temp_format = $sort['sort'];
+ $var =
(isset($sort['var'])?$sort['var']:'');
+ $order =
(isset($sort['order'])?$sort['order']:'');
+ $program =
(isset($sort['program'])?$sort['program']:'/index.php');
+ $text =
(isset($sort['text'])?$sort['text']:'xslt');
+ $extra =
(isset($sort['extra'])?$sort['extra']:'');
+ $build_an_href =
(isset($sort['build_an_href'])?$sort['build_an_href']:True);
+ settype($sort,'string');
+ $sort = $temp_format;
+ unset($temp_format);
+ }
+
+ list($filter,$qfield,$start,$NULL1,$NULL) =
$this->get_var();
+
+ if(($order == $var) && ($sort == 'ASC'))
+ {
+ $sort = 'DESC';
+ }
+ elseif(($order == $var) && ($sort == 'DESC'))
+ {
+ $sort = 'ASC';
+ }
+ else
+ {
+ $sort = 'ASC';
+ }
+
+ if(is_array($extra))
+ {
+ $extra = $this->extras_to_string($extra);
+ }
+
+ $extravar =
'order='.$var.'&sort='.$sort.'&filter='.$filter.'&qfield='.$qfield.'&start='.$start.'&query='.urlencode(stripslashes($GLOBALS['query'])).$extra;
+
+ $link =
($this->action?$this->page($extravar):$this->link($program,$extravar));
+
+ if ($text == 'xslt')
+ {
+ return $link;
+ }
+ elseif($build_an_href)
+ {
+ return '<a href="' . $link . '">' . $text .
'</a>';
+ }
+ else
+ {
+ return $link;
+ }
+ }
+ /*!
+ @function get_var
+ @abstract Fetch commonly-used GP(C) vars
+ @discussion This calls get_var() from functions.inc.php
+ */
+ function get_var()
+ {
+ return array(
+ get_var('filter',array('GLOBAL','POST','GET')),
+ get_var('qfield',array('GLOBAL','POST','GET')),
+ get_var('start',array('GLOBAL','POST','GET')),
+ get_var('order',array('GLOBAL','POST','GET')),
+ get_var('sort',array('GLOBAL','POST','GET'))
+ );
+ }
+
+ function extras_to_string($extra)
+ {
+ if(is_array($extra))
+ {
+ @reset($extra);
+ while(list($var,$value) = each($extra))
+ {
+ $t_extras[] = $var . '=' . $value;
+ }
+ $extra_s = '&' . implode('&',$t_extras);
+ }
+ return $extra_s;
+ }
+
+ function page($extravars='')
+ {
+ if($extravars && is_string($extravars) &&
substr($extravars,0,1)!='&')
+ {
+ $extras = '&'.$extravars;
+ }
+ elseif($extravars && is_array($extravars))
+ {
+ @reset($extravars);
+ while(list($var,$value) = each($extravars))
+ {
+ if($var != 'sid=cookie&op')
+ {
+ $t_extras[] = $var.'='.$value;
+ }
+ }
+ $extras = implode($t_extras,'&');
+ }
+
+ return
$this->link('/index.php','sid=cookie&op='.$this->action.$extras);
+ }
+
+ function link($url, $extravars = '')
+ {
+ /* first we process the $url to build the full
scriptname */
+ $full_scriptname = True;
+
+ $url_firstchar = substr($url ,0,1);
+ if ($url_firstchar == '/' &&
$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] == '/')
+ {
+ $full_scriptname = False;
+ }
+
+ if ($url_firstchar != '/')
+ {
+ $app =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ if ($app != 'home' && $app != 'login' && $app
!= 'logout')
+ {
+ $url = $app.'/'.$url;
+ }
+ }
+
+ if($full_scriptname)
+ {
+ $webserver_url_count =
strlen($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'])-1;
+
if(substr($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] ,$webserver_url_count,1) !=
'/' && $url_firstchar != '/')
+ {
+ $url =
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) .'/'. $url;
+ }
+ else
+ {
+ $url =
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) . $url;
+ }
+ }
+
+
if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) &&
$GLOBALS['phpgw_info']['server']['enforce_ssl'] && !$_SERVER['HTTPS'])
+ {
+ if(substr($url ,0,4) != 'http')
+ {
+ $url =
'https://'.$GLOBALS['HTTP_HOST'].$url;
+ }
+ else
+ {
+ $url = str_replace ( 'http:', 'https:',
$url);
+ }
+ }
+
+ /* Now we process the extravars into a proper url
format */
+ /* if its not an array, then we turn it into one */
+ /* We do this to help prevent any duplicates from being
sent. */
+ if (!is_array($extravars) && $extravars != '')
+ {
+ $a = explode('&', $extravars);
+ $i = 0;
+ while ($i < count($a))
+ {
+ $b = split('=', $a[$i]);
+ $new_extravars[$b[0]] = $b[1];
+ $i++;
+ }
+ $extravars = $new_extravars;
+ unset($new_extravars);
+ }
+
+//html_print_r($extravars);
+ /* if using frames we make sure there is a framepart */
+ if(@defined('PHPGW_USE_FRAMES') && PHPGW_USE_FRAMES)
+ {
+ if (!isset($extravars['framepart']))
+ {
+ $extravars['framepart']='body';
+ }
+ }
+
+ /* add session params if not using cookies */
+/* if (@!$GLOBALS['phpgw_info']['server']['usecookies'])
+ {
+ $extravars['sessionid'] = $this->sessionid;
+ $extravars['kp3'] = $this->kp3;
+ $extravars['domain'] = $this->account_domain;
+ }
+*/
+ /* if we end up with any extravars then we generate the
url friendly string */
+ /* and return the result */
+ if (is_array($extravars))
+ {
+ $new_extravars = '';
+ reset($extravars);
+ while(list($key,$value) = each($extravars))
+ {
+ if (!empty($new_extravars))
+ {
+ $new_extravars .= '&';
+ }
+ $new_extravars .=
$key.'='.htmlentities(urlencode($value));
+ }
+ return $url .= '?' . $new_extravars;
+ }
+ /* if no extravars then we return the cleaned up
url/scriptname */
+ return $url;
+ }
+
+ function redirect_link($url, $extravars = '')
+ {
+ $link = $this->link($url, $extravars);
+ header('Location: '.$link);
+ }
+
+ function xsl_add_file($filename)
+ {
+ reset($filename);
+ while(list(,$file) = each($filename))
+ {
+ $GLOBALS['phpgw']->add_xsl($this->currentapp .
'.' .$file);
+ }
+ }
+
+ function xslt_filter($data=0)
+ {
+
+ $this->xsl_add_file(array('filter_select'));
+
+ if(is_array($data))
+ {
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $format =
(isset($data['format'])?$data['format']:'all');
+ $link_data =
(isset($data['link_data'])?$data['link_data']:'');
+ }
+ else
+ {
+ return False;
+ }
+
+ switch($format)
+ {
+ case 'yours':
+ $filter_obj = array
+ (
+ array('key' => 'none','lang' =>
lang('show all')),
+ array('key' => 'yours','lang'
=> lang('only yours'))
+ );
+ break;
+ case 'private':
+ $filter_obj = array
+ (
+ array('key' => 'none','lang' =>
lang('show all')),
+ array('key' => 'private','lang'
=> lang('only private'))
+ );
+ break;
+ default:
+ $filter_obj = array
+ (
+ array('key' => 'none','lang' =>
lang('show all')),
+ array('key' => 'yours','lang'
=> lang('only yours')),
+ array('key' => 'private','lang'
=> lang('only private'))
+ );
+ }
+
+ for($i=0;$i<count($filter_obj);$i++)
+ {
+ if($filter_obj[$i]['key'] == $filter)
+ {
+ $filter_obj[$i]['selected'] = 'yes';
+ }
+ }
+
+ $filter_data = array
+ (
+ 'filter_list' =>
$filter_obj,
+ 'lang_filter_statustext' => lang('Select
the filter. To show all entries select SHOW ALL'),
+ 'lang_submit' =>
lang('submit'),
+ 'select_url' =>
$this->link('/index.php',$link_data)
+ );
+ return $filter_data;
+ }
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/class.bocommon.php, 1.1.1.3,
nomail <=