[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/class.bos_agreement.inc.php, 1.1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/class.bos_agreement.inc.php, 1.1 |
Date: |
Fri, 11 Jun 2004 19:08:51 +0200 |
Update of /property/inc
Added Files:
Branch:
class.bos_agreement.inc.php
date: 2004/06/11 17:08:51; author: sigurdne; state: Exp;
Log Message:
*** empty log message ***
=====================================================================
<?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.bos_agreement.inc.php,v 1.1 2004/06/11 17:08:51 sigurdne
Exp $ */
class bos_agreement
{
var $start;
var $query;
var $filter;
var $sort;
var $order;
var $cat_id;
var $role;
var $member_id;
var $public_functions = array
(
'read' => True,
'read_single' => True,
'save' => True,
'delete' => True,
'check_perms' => True
);
function bos_agreement($session=False)
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->so =
CreateObject($this->currentapp.'.sos_agreement');
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
if ($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
$start = get_var('start',array('POST','GET'));
$query = get_var('query',array('POST','GET'));
$sort = get_var('sort',array('POST','GET'));
$order = get_var('order',array('POST','GET'));
$filter = get_var('filter',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$allrows =
get_var('allrows',array('POST','GET'));
$role = get_var('role',array('POST','GET'));
$member_id =
get_var('member_id',array('POST','GET'));
$this->role = $role;
$this->so->role = $role;
if ($start)
{
$this->start=$start;
}
else
{
$this->start=0;
}
if(isset($query))
{
$this->query = $query;
}
if(!empty($filter))
{
$this->filter = $filter;
}
if(isset($sort))
{
$this->sort = $sort;
}
if(isset($order))
{
$this->order = $order;
}
if(isset($cat_id) && !empty($cat_id))
{
$this->cat_id = $cat_id;
}
else
{
unset($this->cat_id);
}
if(isset($allrows))
{
$this->allrows = $allrows;
}
if(isset($member_id))
{
$this->member_id = $member_id;
}
}
function save_sessiondata($data)
{
if ($this->use_session)
{
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement',$data);
}
}
function read_sessiondata()
{
$data =
$GLOBALS['phpgw']->session->appsession('session_data','s_agreement');
//_debug_array($data);
$this->start = $data['start'];
$this->query = $data['query'];
$this->filter = $data['filter'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->cat_id = $data['cat_id'];
$this->member_id= $data['member_id'];
$this->allrows = $data['allrows'];
}
function check_perms($has, $needed)
{
return (!!($has & $needed) == True);
}
function select_category_list($format='',$selected='')
{
switch($format)
{
case 'select':
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
break;
case 'filter':
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
break;
}
$categories= $this->so->select_category_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 read()
{
$s_agreement = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id));
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
for ($i=0; $i<count($s_agreement); $i++)
{
$s_agreement[$i]['entry_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement[$i]['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
}
return $s_agreement;
}
function read_details($id)
{
$list = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'filter' => $this->filter,'cat_id' =>
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
's_agreement_id'=>$id,'detail'=>True));
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
for ($i=0; $i<count($list); $i++)
{
$list[$i]['date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
}
return $list;
}
function read_prizing($data)
{
$list = $this->so->read_prizing($data);
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
for ($i=0; $i<count($list); $i++)
{
$list[$i]['date'] =
$GLOBALS['phpgw']->common->show_date($list[$i]['date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
}
return $list;
}
function read_single($data)
{
$s_agreement = $this->so->read_single($data);
$dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$s_agreement['start_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement['start_date'],$dateformat);
$s_agreement['end_date'] =
$GLOBALS['phpgw']->common->show_date($s_agreement['end_date'],$dateformat);
return $this->convert_attribute($s_agreement);
}
function read_single_item($data)
{
$item = $this->so->read_single_item($data);
//_debug_array($item);
$item = $this->convert_attribute($item,True);
if($item['location_code'])
{
$solocation =
CreateObject($this->currentapp.'.solocation');
$item['location_data']
=$solocation->read_single($item['location_code']);
}
if($item['p_num'])
{
$soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
$category =
$soadmin_entity->read_single_category($item['p_entity_id'],$item['p_cat_id']);
$item['p'][$item['p_entity_id']]['p_num']=$item['p_num'];
$item['p'][$item['p_entity_id']]['p_entity_id']=$item['p_entity_id'];
$item['p'][$item['p_entity_id']]['p_cat_id']=$item['p_cat_id'];
$item['p'][$item['p_entity_id']]['p_cat_name']
= $category['name'];
}
return $item;
}
function convert_attribute($list,$detail='')
{
if($detail)
{
$this->so->role = 'detail';
}
$contacts =
CreateObject('phpgwapi.contacts');
$dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$input_type_array = array(
'R' => 'radio',
'CH' => 'checkbox',
'LB' => 'listbox'
);
$sep = '/';
$dlarr[strpos($dateformat,'Y')] = 'Y';
$dlarr[strpos($dateformat,'m')] = 'm';
$dlarr[strpos($dateformat,'d')] = 'd';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
//html_print_r($list);
$m=0;
for ($i=0;$i<count($list['attributes']);$i++)
{
if($list['attributes'][$i]['datatype']=='D' &&
$list['attributes'][$i]['value'])
{
$timestamp_date=
mktime(0,0,0,date(m,strtotime($list['attributes'][$i]['value'])),date(d,strtotime($list['attributes'][$i]['value'])),date(y,strtotime($list['attributes'][$i]['value'])));
$list['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
}
if($list['attributes'][$i]['datatype']=='AB')
{
if($list['attributes'][$i]['value'])
{
$contact_data =
$contacts->read_single_entry($list['attributes'][$i]['value'],array('org_name'=>'org_name','email'=>'email'));
$list['attributes'][$i]['org_name'] = $contact_data[0]['org_name'];
}
$insert_record_list[] =
$list['attributes'][$i]['name'];
$lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $list['attributes'][$i]['name']);
$lookup_functions[$m]['name'] =
'lookup_'. $list['attributes'][$i]['name'] .'()';
$lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
$m++;
}
if($list['attributes'][$i]['datatype']=='R' ||
$list['attributes'][$i]['datatype']=='CH' ||
$list['attributes'][$i]['datatype']=='LB')
{
$list['attributes'][$i]['choice']
= $this->so->read_attrib_choice($list['attributes'][$i]['attrib_id']);
$input_type=$input_type_array[$list['attributes'][$i]['datatype']];
if($list['attributes'][$i]['datatype']=='CH')
{
$list['attributes'][$i]['value']=unserialize($list['attributes'][$i]['value']);
$list['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($list['attributes'][$i]['value'],$list['attributes'][$i]['choice'],$input_type);
}
else
{
for
($j=0;$j<count($list['attributes'][$i]['choice']);$j++)
{
$list['attributes'][$i]['choice'][$j]['input_type']=$input_type;
if($list['attributes'][$i]['choice'][$j]['id']==$list['attributes'][$i]['value'])
{
$list['attributes'][$i]['choice'][$j]['checked']='checked';
}
}
}
}
$list['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($list['attributes'][$i]['datatype']);
$list['attributes'][$i]['counter'] = $i;
$list['attributes'][$i]['type_id'] =
$data['type_id'];
}
for ($j=0;$j<count($lookup_functions);$j++)
{
$list['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
$list['lookup_functions'] .= '{'."\r\n";
$list['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
$list['lookup_functions'] .= '}'."\r\n";
}
$GLOBALS['phpgw']->session->appsession('insert_record_s_agreement' .
!!$detail,$this->currentapp,$insert_record_list);
//html_print_r($list);
return $list;
}
function convert_attribute_save($values_attribute='')
{
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'])
{
$values_attribute[$i]['value'] =
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
}
}
return $values_attribute;
}
function save($s_agreement,$values_attribute='')
{
$s_agreement['start_date'] =
$this->bocommon->date_to_timestamp($s_agreement['start_date']);
$s_agreement['end_date'] =
$this->bocommon->date_to_timestamp($s_agreement['end_date']);
$values_attribute =
$this->convert_attribute_save($values_attribute);
if ($s_agreement['s_agreement_id'])
{
if ($s_agreement['s_agreement_id'] != 0)
{
$s_agreement_id =
$s_agreement['s_agreement_id'];
$receipt=$this->so->edit($s_agreement,$values_attribute);
}
}
else
{
$receipt =
$this->so->add($s_agreement,$values_attribute);
}
return $receipt;
}
function save_item($values,$values_attribute='')
{
while (is_array($values['location']) && list(,$value) =
each($values['location']))
{
if($value)
{
$location[] = $value;
}
}
$values['location_code'address@hidden("-", $location);
$values_attribute =
$this->convert_attribute_save($values_attribute);
if ($values['id'])
{
if ($values['id'] != 0)
{
$receipt=$this->so->edit_item($values,$values_attribute);
}
}
else
{
$receipt =
$this->so->add_item($values,$values_attribute);
}
return $receipt;
}
function update($values)
{
$values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
return $this->so->update($values);
}
function delete_last_index($s_agreement_id,$id)
{
$this->so->delete_last_index($s_agreement_id,$id);
}
function delete_item($s_agreement_id,$item_id)
{
$this->so->delete_item($s_agreement_id,$item_id);
}
function delete($s_agreement_id='',$id='',$attrib='')
{
if ($attrib)
{
$this->so->delete_attrib($id);
}
else
{
$this->so->delete($s_agreement_id);
}
}
function read_attrib($type_id='')
{
$attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'allrows'=>$this->allrows));
for ($i=0; $i<count($attrib); $i++)
{
$attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
}
$this->total_records = $this->so->total_records;
return $attrib;
}
function read_single_attrib($id)
{
return $this->so->read_single_attrib($id);
}
function resort_attrib($data)
{
$this->so->resort_attrib($data);
}
function save_attrib($attrib,$action='')
{
if ($action=='edit')
{
if ($attrib['id'] != '')
{
$receipt =
$this->so->edit_attrib($attrib);
}
}
else
{
$receipt = $this->so->add_attrib($attrib);
}
return $receipt;
}
function column_list($selected='',$allrows='')
{
if(!$selected)
{
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["s_agreement_columns"];
}
$columns =
$this->so->read_attrib(array('allrows'=>$allrows,'column_list'=>True));
$column_list=$this->bocommon->select_multi_list($selected,$columns);
return $column_list;
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc/class.bos_agreement.inc.php, 1.1,
nomail <=