[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/class.uis_agreement.php, 1.1.2.1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/class.uis_agreement.php, 1.1.2.1 |
Date: |
Sun, 20 Jun 2004 11:04:46 +0200 |
Update of /property
Added Files:
Branch: proposal-branch
class.uis_agreement.php
date: 2004/06/20 09:04:46; author: sigurdne; state: Exp; lines: +1681 -0
Log Message:
no 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.uis_agreement.php,v 1.1.2.1 2004/06/20 09:04:46 sigurdne
Exp $ */
class property_uis_agreement
{
var $grants;
var $cat_id;
var $start;
var $query;
var $sort;
var $order;
var $filter;
var $public_functions = array
(
'index' => True,
'view' => True,
'edit' => True,
'delete' => True,
'list_attribute'=> True,
'edit_attrib' => True,
'columns' => True,
'edit_item' => True,
'view_item' => True,
'view_file' => True,
'excel' => True
);
function property_uis_agreement()
{
$this->currentapp = 'property';
//$GLOBALS['phpgw_data']['flags']['req_app'];
$this->account =
$GLOBALS['phpgw_data']['user']['id'];
$this->bo =
CreateObject($this->currentapp.'_bos_agreement',True);
$this->bocommon =
CreateObject($this->currentapp.'_bocommon');
$this->menu =
CreateObject($this->currentapp.'_menu');
$this->role = $this->bo->role;
$this->cats =
CreateObject($this->currentapp.'_categories_api');
$this->cats->app_name = 'fm_vendor';
$this->fm_session =
CreateObject($this->currentapp.'_session');
$this->acl2 =
CreateObject($this->currentapp.'_acl2');
$this->acl2_location= '.s_agreement';
$this->acl_read =
$this->acl2->check($this->acl2_location,1);
$this->acl_add =
$this->acl2->check($this->acl2_location,2);
$this->acl_edit =
$this->acl2->check($this->acl2_location,4);
$this->acl_delete =
$this->acl2->check($this->acl2_location,8);
$this->acl_manage =
$this->acl2->check($this->acl2_location,16);
$this->start = $this->bo->start;
$this->query = $this->bo->query;
$this->sort = $this->bo->sort;
$this->order = $this->bo->order;
$this->filter = $this->bo->filter;
$this->cat_id = $this->bo->cat_id;
$this->allrows = $this->bo->allrows;
$this->member_id = $this->bo->member_id;
$this->fakebase = $this->bo->fakebase;
}
function save_sessiondata()
{
$data = 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->bo->save_sessiondata($data);
}
function columns()
{
$this->bocommon->xsl_add_file(array('columns'));
$GLOBALS['phpgw_info']['flags']['headonly']=true;
$values =
$this->bocommon->get_var2('values',array('POST','GET'));
if ($values['save'])
{
$GLOBALS['phpgw']->prefs->set($this->currentapp
. 's_agreement_columns',serialize($values['columns']),$this->account);
$receipt['message'][] = array('msg' =>
lang('columns is updated'));
}
$function_msg = lang('Select Column');
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.columns',
'role' => $this->role
);
$msgbox_data = $this->bocommon->msgbox_data($receipt);
$data = array
(
// 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
'column_list' =>
$this->bo->column_list($values['columns'],$allrows=True),
'function_msg' => $function_msg,
'form_action' =>
$this->bocommon->link('/index.php',$link_data),
'lang_columns' => lang('columns'),
'lang_none' => lang('None'),
'lang_save' => lang('save'),
'select_name' => 'period'
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
return array('columns' => $data);
}
function view_file()
{
if(!$this->acl_read)
{
$this->bocommon->redirect_link('/index.php','sid=cookie&op='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
}
$GLOBALS['phpgw_info']['flags']['noframework'] = True;
$file_name =
urldecode($this->bocommon->get_var2('file_name',array('POST','GET')));
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$file = $this->fakebase. '/' . 'service_agreement' .
'/' . $id . '/' . $file_name;
//echo 'file: ' . $file . '<br>';
if($this->bo->vfs->file_exists(array(
'string' => $file,
'relatives' => Array(RELATIVE_NONE)
)))
{
$filename = current(explode('.',
basename($file_name)));
$filetype =
$this->bo->vfs->file_type(array(
'string' => $file,
'relatives' =>
Array(RELATIVE_NONE)));
$size =
$this->bo->vfs->get_size(array(
'string' => $file,
'relatives' =>
Array(RELATIVE_NONE),
'checksubdirs' =>
True));
$browser = CreateObject('phpgwapi.browser');
$browser->content_header($filename,$filetype,$size);
$document= $this->bo->vfs->read(array(
'string' => $file,
'relatives' => Array(RELATIVE_NONE)));
echo $document;
// flush();
}
}
function index()
{
$this->menu->sub = 'project';
if(!$this->acl_read)
{
$this->bocommon->redirect_link('/index.php','sid=cookie&op='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
}
$this->bocommon->xsl_add_file(array('s_agreement',
'menu',
'receipt',
'search_field',
'nextmatchs',
'filter_member_of'));
$links = $this->menu->links('s_agreement');
$receipt =
$this->fm_session->appsession('session_data','s_agreement_receipt');
$this->fm_session->appsession('session_data','s_agreement_receipt','');
$list = $this->bo->read();
$uicols = $this->bo->uicols;
$j=0;
if (isset($list) AND is_array($list))
{
foreach($list as $entry)
{
for
($i=0;$i<count($uicols['name']);$i++)
{
if($uicols['input_type'][$i]!='hidden')
{
$content[$j]['row'][$i]['value'] =
$entry[$uicols['name'][$i]];
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
}
}
if($this->acl_read)
{
$content[$j]['row'][$i]['statustext'] = lang('view the
entity');
$content[$j]['row'][$i]['text']
= lang('view');
$content[$j]['row'][$i++]['link'] =
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.view&id='
. $entry['id'] .'&role=' . $this->role);
}
if($this->acl_edit)
{
$content[$j]['row'][$i]['statustext'] = lang('edit the
s_agreement');
$content[$j]['row'][$i]['text']
= lang('edit');
$content[$j]['row'][$i++]['link'] =
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit&id='
. $entry['id'] .'&role=' . $this->role);
}
if($this->acl_delete)
{
$content[$j]['row'][$i]['statustext'] = lang('delete the
s_agreement');
$content[$j]['row'][$i]['text']
= lang('delete');
$content[$j]['row'][$i++]['link'] =
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.delete&s_agreement_id='
. $entry['id'] .'&role=' . $this->role);
}
$j++;
}
}
//html_print_r($content);
for ($i=0;$i<count($uicols['descr']);$i++)
{
if($uicols['input_type'][$i]!='hidden')
{
$table_header[$i]['header'] =
$uicols['descr'][$i];
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
if($uicols['datatype'][$i]!='T' &&
$uicols['datatype'][$i]!='CH')
{
$table_header[$i]['sort_link']
=true;
$table_header[$i]['sort']
= $this->bocommon->show_sort_order(array
(
'sort' =>
$this->sort,
'var' =>
$uicols['name'][$i],
'order' =>
$this->order,
'extra'
=> array('sid=cookie&op' => $this->currentapp.'.uis_agreement.index',
'query' =>$this->query,
'lookup' =>$lookup,
'district_id' => $this->district_id,
'start_date' => $start_date,
'role' => $this->role,
'member_id' => $this->member_id,
'end_date'=>$end_date)
));
}
}
}
if($this->acl_read)
{
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
$table_header[$i]['header']
= lang('view');
$i++;
}
if($this->acl_edit)
{
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
$table_header[$i]['header']
= lang('edit');
$i++;
}
if($this->acl_delete)
{
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
$table_header[$i]['header']
= lang('delete');
$i++;
}
if($this->acl_add)
{
$table_add = array
(
'lang_add'
=> lang('add'),
'lang_add_statustext' => lang('add a
s_agreement'),
'add_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit&role='
. $this->role)
);
}
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.index',
'sort'
=>$this->sort,
'order'
=>$this->order,
'cat_id'
=>$this->cat_id,
'filter'
=>$this->filter,
'query'
=>$this->query,
'role' =>
$this->role,
'member_id' =>
$this->member_id
);
if(!$this->allrows)
{
$record_limit = 15;
//$GLOBALS['phpgw_data']['user']['preferences']['common']['maxmatchs'];
}
else
{
$record_limit = $this->bo->total_records;
}
$msgbox_data = $this->bocommon->msgbox_data($receipt);
$link_columns = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.columns',
'role' =>
$this->role
);
// $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True));
//html_print_r($member_of_data);
$data = array
(
'overlib_source'
=> './'.$this->currentapp.'/overlib.js',
'lang_columns'
=> lang('columns'),
'link_columns'
=> $this->bocommon->link('/index.php',$link_columns),
'lang_columns_help'
=> lang('Choose columns'),
// 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'links'
=> $links,
'allow_allrows'
=> false,
'allrows'
=> $this->allrows,
'start_record'
=> $this->start,
'record_limit'
=> $record_limit,
'num_records'
=> count($list),
'all_records'
=> $this->bo->total_records,
'link_url'
=> $this->bocommon->link('/index.php',$link_data),
'img_path'
=>
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']).'/api/skins/default/images',
'lang_no_cat'
=> lang('no category'),
'lang_cat_statustext' =>
lang('Select the category the s_agreement belongs to. To do not use a category
select NO CATEGORY'),
'select_name'
=> 'cat_id',
'cat_list'
=> $this->bo->select_category_list('filter',$this->cat_id),
'select_action'
=> $this->bocommon->link('/index.php',$link_data),
'lang_no_member'
=> lang('no member'),
'member_of_name'
=> 'member_id',
'member_of_list'
=> $member_of_data['cat_list'],
'filter_list'
=> $this->bocommon->xslt_filter(array('filter' => $this->filter)),
'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
'lang_searchbutton_statustext' => lang('Submit
the search string'),
'query'
=> $this->query,
'lang_search'
=> lang('search'),
'table_header'
=> $table_header,
'values'
=> $content,
'table_add'
=> $table_add
);
// $this->save_sessiondata();
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('list ' . $this->role);
return array('list' => $data);
}
function list_content($list,$uicols,$edit_item='',$view_only='')
{
$j=0;
if (isset($list) AND is_array($list))
{
foreach($list as $entry)
{
$content[$j]['id']
= $entry['id'];
$content[$j]['item_id'] =
$entry['item_id'];
$content[$j]['index_count'] =
$entry['index_count'];
$content[$j]['cost'] =
$entry['cost'];
$k=0;
for
($i=0;$i<count($uicols['name']);$i++)
{
if($uicols['input_type'][$i]!='hidden')
{
$content[$j]['row'][$k]['value'] =
$entry[$uicols['name'][$i]];
$content[$j]['row'][$k]['name'] = $uicols['name'][$i];
$k++;
}
}
if($this->acl_read && !$edit_item &&
!$view_only)
{
$content[$j]['row'][$k]['statustext'] = lang('view the
entity');
$content[$j]['row'][$k]['text']
= lang('view');
$content[$j]['row'][$k++]['link'] =
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.view_item&s_agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
}
if($this->acl_edit && !$edit_item &&
!$view_only)
{
$content[$j]['row'][$k]['statustext'] = lang('edit the
s_agreement');
$content[$j]['row'][$k]['text']
= lang('edit');
$content[$j]['row'][$k++]['link'] =
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $entry['agreement_id'] .'&id=' . $entry['id']);
}
if($this->acl_delete && !$edit_item &&
!$view_only)
{
$content[$j]['row'][$k]['statustext'] = lang('delete this
item');
$content[$j]['row'][$k]['text']
= lang('delete');
$content[$j]['row'][$k++]['link'] =
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit&delete_item=1&s_agreement_id='
. $entry['agreement_id'] .'&item_id=' . $entry['id']);
}
$j++;
}
}
//html_print_r($content);
$j=0;
for ($i=0;$i<count($uicols['descr']);$i++)
{
if($uicols['input_type'][$i]!='hidden')
{
$table_header[$j]['header'] =
$uicols['descr'][$i];
$table_header[$j]['width']
= '5%';
$table_header[$j]['align']
= 'center';
$j++;
}
}
if($this->acl_read && !$edit_item && !$view_only)
{
$table_header[$j]['width']
= '5%';
$table_header[$j]['align']
= 'center';
$table_header[$j]['header']
= lang('view');
$j++;
}
if($this->acl_edit && !$edit_item && !$view_only)
{
$table_header[$j]['width']
= '5%';
$table_header[$j]['align']
= 'center';
$table_header[$j]['header']
= lang('edit');
$j++;
}
if($this->acl_delete && !$edit_item && !$view_only)
{
$table_header[$j]['width']
= '5%';
$table_header[$j]['align']
= 'center';
$table_header[$j]['header']
= lang('delete');
$j++;
}
if($this->acl_manage && !$edit_item && !$view_only)
{
$table_header[$j]['width']
= '5%';
$table_header[$j]['align']
= 'center';
$table_header[$j]['header']
= lang('Update');
$j++;
}
return
array('content'=>$content,'table_header'=>$table_header);
}
function edit()
{
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$values =
$this->bocommon->get_var2('values',array('POST'));
$delete_item =
$this->bocommon->get_var2('delete_item',array('GET'));
$item_id =
$this->bocommon->get_var2('item_id',array('GET'));
$config =
CreateObject($this->currentapp.'_config',$this->currentapp);
if($delete_item && $id && $item_id)
{
$this->bo->delete_item($id,$item_id);
}
$values_attribute =
$this->bocommon->get_var2('values_attribute',array('POST'));
$insert_record_s_agreement =
$this->fm_session->appsession('insert_record_s_agreement',$this->currentapp);
//html_print_r($insert_record_s_agreement);
for ($j=0;$j<count($insert_record_s_agreement);$j++)
{
$insert_record['extra'][$insert_record_s_agreement[$j]] =
$insert_record_s_agreement[$j];
}
$this->bocommon->xsl_add_file(array('s_agreement','attributes_form'));
if (is_array($values))
{
while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
{
if($_POST[$key])
{
$values['extra'][$column]
= $_POST[$key];
}
}
//html_print_r($values);
if ($values['save'] || $values['apply']):
{
$values['vendor_id'] =
$this->bocommon->get_var2('vendor_id',array('POST'));
$values['vendor_name'] =
$this->bocommon->get_var2('vendor_name',array('POST'));
$values['b_account_id'] =
$this->bocommon->get_var2('b_account_id',array('POST'));
$values['b_account_name'] =
$this->bocommon->get_var2('b_account_name',array('POST'));
$values['start_date'] =
$this->bocommon->get_var2('start_date',array('POST'));
$values['end_date']
= $this->bocommon->get_var2('end_date',array('POST'));
if(!$values['cat_id'])
{
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
}
if(!$values['last_name'])
{
//
$receipt['error'][]=array('msg'=>lang('Please enter a name !'));
}
if($id)
{
$values['s_agreement_id']=$id;
$action='edit';
}
else
{
$values['s_agreement_id']=$this->bo->request_next_id();
}
$values['file_name']=$_FILES['file']['name'];
$to_file = $this->fakebase. '/' .
'service_agreement' . '/' . $values['s_agreement_id'] . '/' .
$values['file_name'];
if(!$values['document_name_orig'] &&
$this->bo->vfs->file_exists(array(
'string' => $to_file,
'relatives' =>
Array(RELATIVE_NONE)
)))
{
$receipt['error'][]=array('msg'=>lang('This file already exists !'));
}
if(!$receipt['error'])
{
// $values['s_agreement_id']
= $id;
$receipt =
$this->bo->create_home_dir($receipt);
$receipt =
$this->bo->save($values,$values_attribute,$action);
$id =
$receipt['s_agreement_id'];
$this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
if($values['file_name'])
{
$this->bo->create_document_dir($id);
$this->bo->vfs->override_acl = 1;
if(!$this->bo->vfs->cp
(array (
'from' =>
$_FILES['file']['tmp_name'],
'to' =>
$to_file,
'relatives'
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
{
$receipt['error'][]=array('msg'=>lang('Failed to upload file !'));
}
$this->bo->vfs->override_acl = 0;
}
if ($values['save'])
{
$this->fm_session->appsession('session_data','s_agreement_receipt',$receipt);
$this->bocommon->redirect_link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.index&role='
. $this->role);
}
}
}
elseif($values['update']):
{
$values['date'] =
$this->bocommon->get_var2('date',array('POST'));
if(!$values['date'])
{
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
}
if(!$values['new_index'])
{
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
}
if(!$receipt['error'])
{
$receipt =
$this->bo->update($values);
}
}
elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
{
$this->bocommon->redirect_link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.index&role='
. $this->role);
}
endif;
}
$s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$id));
$cal_info = $this->bocommon->jscalendar();
$jsDateFormat=$cal_info['jsDateFormat'];
if ($id)
{
$this->cat_id =
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
$this->member_id =
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
$list = $this->bo->read_details($id);
$uicols = $this->bo->uicols;
$list =
$this->list_content($list,$uicols);
$content = $list['content'];
$table_header=$list['table_header'];
for ($i=0;
$i<count($list['content'][0]['row']); $i++)
{
$set_column[]=True;
}
if ($content)
{
$table_update[] = array
(
'jsDateFormat'
=> $jsDateFormat,
'date_img'
=> $cal_info['img'],
'lang_datetitle'
=> lang('Select date'),
'calendar_setup'
=> "Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat
. "',button : 'date-trigger'});",
'lang_new_index'
=> lang('New index'),
'lang_new_index_statustext'
=> lang('Enter a new index'),
'lang_date_statustext'
=> lang('Select the date for the update'),
'lang_update'
=> lang('Update'),
'lang_update_statustext'
=> lang('update selected investments')
);
}
}
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.edit',
'id' => $id,
'role' => $this->role
);
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
'vendor_id' =>
$s_agreement['vendor_id'],
'vendor_name' =>
$s_agreement['vendor_name']));
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
'b_account_id' =>
$s_agreement['b_account_id'],
'b_account_name' =>
$s_agreement['b_account_name']));
$dateformat =
strtolower($GLOBALS['phpgw_data']['prefs'][$this->currentapp . '.dateformat']);
$sep = '/';
$dlarr[strpos($dateformat,'y')] = 'yyyy';
$dlarr[strpos($dateformat,'m')] = 'MM';
$dlarr[strpos($dateformat,'d')] = 'DD';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
switch(substr($dateformat,0,1))
{
case 'M':
$dateformat_validate=
"javascript:vDateType='1'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
$onBlur =
"DateFormat(this,this.value,event,true,'1')";
break;
case 'y':
$dateformat_validate="javascript:vDateType='2'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
$onBlur =
"DateFormat(this,this.value,event,true,'2')";
break;
case 'D':
$dateformat_validate="javascript:vDateType='3'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
$onBlur =
"DateFormat(this,this.value,event,true,'3')";
break;
}
$cal_info = $this->bocommon->jscalendar();
$jsDateFormat=$cal_info['jsDateFormat'];
$msgbox_data = $this->bocommon->msgbox_data($receipt);
// $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True));
$table_add[] = array
(
'lang_add' =>
lang('add detail'),
'lang_add_standardtext' => lang('add an item to
the details'),
'add_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $id)
);
$link_file_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.view_file',
'id' =>$id
);
$config->read_repository();
$link_to_files = $config->config_data['files_url'];
$j = count($s_agreement['files']);
for ($i=0;$i<$j;$i++)
{
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
}
$link_excel = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.excel',
'id'
=>$id
);
$data = array
(
'lang_excel' =>
'excel',
'link_excel' =>
$this->bocommon->link('/index.php',$link_excel),
'lang_excel_help' =>
lang('Download table to MS Excel'),
'overlib_source'
=> './'.$this->currentapp.'/overlib.js',
'fileupload'
=> True,
'link_view_file'
=> $this->bocommon->link('/index.php',$link_file_data),
'link_to_files'
=> $link_to_files,
'files'
=> $s_agreement['files'],
'lang_files'
=> lang('files'),
'lang_filename'
=> lang('Filename'),
'lang_delete_file'
=> lang('Delete file'),
'lang_view_file_statustext' =>
lang('Klick to view file'),
'lang_delete_file_statustext' => lang('Check
to delete file'),
'lang_upload_file'
=> lang('Upload file'),
'lang_file_statustext' =>
lang('Select file to upload'),
// 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'edit_url'
=> $this->bocommon->link('/index.php',$link_data),
'lang_id'
=> lang('ID'),
'value_s_agreement_id' => $id,
'lang_category'
=> lang('category'),
'lang_save'
=> lang('save'),
'lang_cancel'
=> lang('cancel'),
'lang_apply'
=> lang('apply'),
'value_cat'
=> $s_agreement['cat'],
'lang_apply_statustext' =>
lang('Apply the values'),
'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
'lang_save_statustext' =>
lang('Save the s_agreement and return back to the list'),
'lang_no_cat'
=> lang('no category'),
'lang_cat_statustext' =>
lang('Select the category the s_agreement belongs to. To do not use a category
select NO CATEGORY'),
'select_name'
=> 'values[cat_id]',
'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
'lang_member_of'
=> lang('member of'),
'member_of_name'
=> 'member_id',
'member_of_list'
=> $member_of_data['cat_list'],
'lang_dateformat'
=> lang(strtolower($dateformat)),
'dateformat_validate' =>
$dateformat_validate,
'onKeyUp'
=> $onKeyUp,
'onBlur'
=> $onBlur,
'dateformat_source'
=> './'.$this->currentapp.'/dateformat.js',
'lang_attributes'
=> lang('Attributes'),
'attributes_header'
=> $attributes_header,
'attributes_values'
=> $s_agreement['attributes'],
'lookup_functions'
=> $s_agreement['lookup_functions'],
'dateformat'
=> $dateformat,
'cal_info'
=> $cal_info,
'jsDateFormat'
=> $jsDateFormat,
'date_img'
=> $cal_info['img'],
'lang_datetitle'
=> lang('Select date'),
'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
'lang_start_date'
=> lang('start date'),
'value_start_date'
=> $s_agreement['start_date'],
'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
'lang_end_date'
=> lang('end date'),
'value_end_date'
=> $s_agreement['end_date'],
'vendor_data'
=> $vendor_data,
'b_account_data'
=> $b_account_data,
'lang_name'
=> lang('name'),
'lang_name_statustext' =>
lang('name'),
'value_name'
=> $s_agreement['name'],
'lang_descr'
=> lang('descr'),
'lang_descr_statustext' =>
lang('descr'),
'value_descr'
=> $s_agreement['descr'],
'table_add'
=> $table_add,
'values'
=> $content,
'table_header'
=> $table_header,
'acl_manage'
=> $this->acl_manage,
'table_update'
=> $table_update,
'update_action'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit&id='
. $id),
'lang_select_all'
=> lang('Select All'),
'img_check'
=>
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']).'/'.$this->currentapp.
'/skins/default/images/check.gif',
'check_source'
=> './'.$this->currentapp.'/check.js',
'check_all_script'
=> $check_all_script,
'set_column'
=> $set_column,
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . ($id?lang('edit') . ' ' .
lang($this->role):lang('add') . ' ' . lang($this->role));
return array('edit' => $data);
}
function excel()
{
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$list = $this->bo->read_details($id);
$uicols = $this->bo->uicols;
$this->bocommon->excel($list,$uicols['name'],$uicols['descr']);
}
function edit_item()
{
$s_agreement_id =
$this->bocommon->get_var2('s_agreement_id',array('POST','GET'));
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$values =
$this->bocommon->get_var2('values',array('POST'));
$delete_last =
$this->bocommon->get_var2('delete_last',array('GET'));
if($delete_last)
{
$this->bo->delete_last_index($s_agreement_id,$id);
}
$bolocation =
CreateObject($this->currentapp.'_bolocation');
$values_attribute =
$this->bocommon->get_var2('values_attribute',array('POST'));
$insert_record =
$this->fm_session->appsession('insert_record',$this->currentapp);
$insert_record_entity =
$this->fm_session->appsession('insert_record_entity',$this->currentapp);
$insert_record_s_agreement =
$this->fm_session->appsession('insert_record_s_agreement',$this->currentapp);
//html_print_r($insert_record_s_agreement);
for ($j=0;$j<count($insert_record_entity);$j++)
{
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
}
for ($j=0;$j<count($insert_record_s_agreement1);$j++)
{
$insert_record['extra'][$insert_record_s_agreement[$j]] =
$insert_record_s_agreement[$j];
}
$this->bocommon->xsl_add_file(array('s_agreement','attributes_form'));
if (is_array($values))
{
for ($i=0;
$i<count($insert_record['location']); $i++)
{
if($_POST[$insert_record['location'][$i]])
{
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
}
}
while (is_array($insert_record['extra']) &&
list($key,$column) = each($insert_record['extra']))
{
if($_POST[$key])
{
$values['extra'][$column]
= $_POST[$key];
}
}
$values['street_name'] =
$_POST['street_name'];
$values['street_number'] =
$_POST['street_number'];
$values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
//html_print_r($values);
if ($values['save'] || $values['apply']):
{
if(!$receipt['error'])
{
$values['s_agreement_id']
= $s_agreement_id;
$values['id'] = $id;
$receipt =
$this->bo->save_item($values,$values_attribute);
$s_agreement_id =
$receipt['s_agreement_id'];
$id =
$receipt['id'];
$this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
if ($values['save'])
{
$this->fm_session->appsession('session_data','s_agreement_receipt',$receipt);
$this->bocommon->redirect_link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit&id='
. $s_agreement_id);
}
}
else
{
if($values['location'])
{
$location_code=implode("-", $values['location']);
$values['location_data'] =
$bolocation->read_single($location_code,$values['extra']);
}
if($values['extra']['p_num'])
{
$values['p'][$values['extra']['p_entity_id']]['p_num']=$values['extra']['p_num'];
$values['p'][$values['extra']['p_entity_id']]['p_entity_id']=$values['extra']['p_entity_id'];
$values['p'][$values['extra']['p_entity_id']]['p_cat_id']=$values['extra']['p_cat_id'];
$values['p'][$values['extra']['p_entity_id']]['p_cat_name']=$_POST['entity_cat_name_'.$values['extra']['p_entity_id']];
}
}
}
elseif($values['update']):
{
$values['date'] =
$this->bocommon->get_var2('date',array('POST'));
if(!$values['date'])
{
$receipt['error'][]=array('msg'=>lang('Please select a date !'));
}
if(!$values['new_index'])
{
$receipt['error'][]=array('msg'=>lang('Please enter a index !'));
}
if(!$receipt['error'])
{
$receipt =
$this->bo->update($values);
}
}
elseif (!$values['save'] && !$values['apply']
&& !$values['update']):
{
$this->bocommon->redirect_link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit&id='
. $s_agreement_id);
}
endif;
}
$s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
$values =
$this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id));
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.edit_item',
's_agreement_id' => $s_agreement_id,
'id' => $id,
'role' => $this->role
);
$dateformat =
strtolower($GLOBALS['phpgw_data']['prefs'][$this->currentapp . '.dateformat']);
$sep = '/';
$dlarr[strpos($dateformat,'y')] = 'yyyy';
$dlarr[strpos($dateformat,'m')] = 'MM';
$dlarr[strpos($dateformat,'d')] = 'DD';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
switch(substr($dateformat,0,1))
{
case 'M':
$dateformat_validate=
"javascript:vDateType='1'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
$onBlur =
"DateFormat(this,this.value,event,true,'1')";
break;
case 'y':
$dateformat_validate="javascript:vDateType='2'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
$onBlur =
"DateFormat(this,this.value,event,true,'2')";
break;
case 'D':
$dateformat_validate="javascript:vDateType='3'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
$onBlur =
"DateFormat(this,this.value,event,true,'3')";
break;
}
$cal_info = $this->bocommon->jscalendar();
$jsDateFormat=$cal_info['jsDateFormat'];
$msgbox_data = $this->bocommon->msgbox_data($receipt);
// $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True));
$table_add[] = array
(
'lang_add' =>
lang('add detail'),
'lang_add_standardtext' => lang('add an item to
the details'),
'add_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $s_agreement_id)
);
if($id)
{
$list =
$this->bo->read_prizing(array('s_agreement_id'=>$s_agreement_id,'item_id'=>$id));
}
$uicols = $this->bo->uicols;
$list =
$this->list_content($list,$uicols,$edit_item=True);
$content = $list['content'];
$table_header=$list['table_header'];
for ($i=0; $i<count($list['content'][0]['row']); $i++)
{
$set_column[]=True;
}
//html_print_r($list);
$table_update[] = array
(
'jsDateFormat'
=> $jsDateFormat,
'date_img'
=> $cal_info['img'],
'lang_datetitle'
=> lang('Select date'),
'calendar_setup' =>
"Calendar.setup({inputField : 'date',ifFormat : '" . $jsDateFormat .
"',button : 'date-trigger'});",
'lang_new_index' =>
lang('New index'),
'lang_new_index_statustext' => lang('Enter
a new index'),
'lang_date_statustext' => lang('Select
the date for the update'),
'lang_update' =>
lang('Update'),
'lang_update_statustext' => lang('update
selected investments')
);
$lookup_type='form';
//html_print_r($values);
$location_data=$bolocation->initiate_ui_location(array(
'values' =>
$values['location_data'],
'type_id' => -1,
// calculated from location_types
'no_link' =>
False, // disable lookup links for location type less than type_id
'tenant' =>
False,
'lookup_type' => $lookup_type,
'lookup_entity' =>
$this->bocommon->get_lookup_entity('s_agreement'),
'entity_data' => $values['p']
));
$data = array
(
// 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'edit_url'
=> $this->bocommon->link('/index.php',$link_data),
'lang_id'
=> lang('ID'),
'value_id'
=> $values['id'],
'value_s_agreement_id' =>
$s_agreement_id,
'lang_category'
=> lang('category'),
'lang_save'
=> lang('save'),
'lang_cancel'
=> lang('cancel'),
'lang_apply'
=> lang('apply'),
'lang_apply_statustext' =>
lang('Apply the values'),
'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
'lang_save_statustext' =>
lang('Save the s_agreement and return back to the list'),
'lang_dateformat'
=> lang(strtolower($dateformat)),
'dateformat_validate' =>
$dateformat_validate,
'onKeyUp'
=> $onKeyUp,
'onBlur'
=> $onBlur,
'dateformat_source'
=> './'.$this->currentapp.'/dateformat.js',
'lang_attributes'
=> lang('Attributes'),
'attributes_header'
=> $attributes_header,
'attributes_values'
=> $values['attributes'],
'lookup_functions'
=> $values['lookup_functions'],
'dateformat'
=> $dateformat,
'cal_info'
=> $cal_info,
'jsDateFormat'
=> $jsDateFormat,
'date_img'
=> $cal_info['img'],
'lang_datetitle'
=> lang('Select date'),
'calendar_setup_start' =>
"Calendar.setup({inputField : 'start_date',ifFormat : '" . $jsDateFormat .
"',button : 'start_date-trigger'});",
'calendar_setup_end' =>
"Calendar.setup({inputField : 'end_date',ifFormat : '" . $jsDateFormat .
"',button : 'end_date-trigger'});",
'lang_agreement'
=> lang('Agreement'),
'agreement_name'
=> $s_agreement['name'],
'table_add'
=> $table_add,
'values'
=> $content,
'table_header'
=> $table_header,
'acl_manage'
=> $this->acl_manage,
'table_update'
=> $table_update,
'update_action'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_item&s_agreement_id='
. $s_agreement_id . '&id=' . $id),
'lang_select_all'
=> lang('Select All'),
'img_check'
=>
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']).'/'.$this->currentapp.
'/skins/default/images/check.gif',
'check_source'
=> './'.$this->currentapp.'/check.js',
'location_data'
=> $location_data,
'lang_cost'
=> lang('cost'),
'lang_cost_statustext' =>
lang('cost'),
'value_cost'
=> $values['cost'],
'set_column'
=> $set_column,
'lang_delete_last'
=> lang('delete last index'),
'lang_delete_last_statustext' => lang('delete
the last index'),
'delete_action'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_item&delete_last=1&s_agreement_id='
. $s_agreement_id . '&id=' . $id),
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . ($values['id']?lang('edit item') . ' ' .
$s_agreement['name']:lang('add item') . ' ' . $s_agreement['name']);
return array('edit_item' => $data);
}
function view_item()
{
$s_agreement_id =
$this->bocommon->get_var2('s_agreement_id',array('POST','GET'));
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$bolocation =
CreateObject($this->currentapp.'_bolocation');
$this->bocommon->xsl_add_file(array('s_agreement','attributes_view'));
$s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
$values =
$this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id));
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.edit',
'id' =>
$s_agreement_id
);
$dateformat =
strtolower($GLOBALS['phpgw_data']['prefs'][$this->currentapp . '.dateformat']);
$sep = '/';
$dlarr[strpos($dateformat,'y')] = 'yyyy';
$dlarr[strpos($dateformat,'m')] = 'MM';
$dlarr[strpos($dateformat,'d')] = 'DD';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
if($id)
{
$list =
$this->bo->read_prizing(array('s_agreement_id'=>$s_agreement_id,'item_id'=>$id));
}
$uicols = $this->bo->uicols;
$list =
$this->list_content($list,$uicols,$edit_item=True);
$content = $list['content'];
$table_header=$list['table_header'];
$lookup_type='view';
$location_data=$bolocation->initiate_ui_location(array(
'values' =>
$values['location_data'],
'type_id' => -1,
// calculated from location_types
'no_link' =>
False, // disable lookup links for location type less than type_id
'tenant' =>
False,
'lookup_type' => $lookup_type,
'lookup_entity' =>
$this->bocommon->get_lookup_entity('s_agreement'),
'entity_data' => $values['p']
));
$data = array
(
// 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'edit_url'
=> $this->bocommon->link('/index.php',$link_data),
'lang_id'
=> lang('ID'),
'value_id'
=> $values['id'],
'value_s_agreement_id' =>
$s_agreement_id,
'lang_category'
=> lang('category'),
'lang_cancel'
=> lang('cancel'),
'lang_cancel_statustext' =>
lang('Leave the service agreement untouched and return back to the list'),
'lang_dateformat'
=> lang(strtolower($dateformat)),
'attributes_view'
=> $values['attributes'],
'lang_agreement'
=> lang('Agreement'),
'agreement_name'
=> $s_agreement['name'],
'table_add'
=> $table_add,
'values'
=> $content,
'table_header'
=> $table_header,
'check_source'
=> './'.$this->currentapp.'/check.js',
'location_data'
=> $location_data,
'lang_cost'
=> lang('cost'),
'lang_cost_statustext' =>
lang('cost'),
'value_cost'
=> $values['cost'],
'set_column'
=> $set_column,
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('view item') . ' ' .
$s_agreement['name'];
return array('view_item' => $data);
}
function delete()
{
$attrib =
$this->bocommon->get_var2('attrib',array('POST','GET'));
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$s_agreement_id =
$this->bocommon->get_var2('s_agreement_id',array('POST','GET'));
$delete =
$this->bocommon->get_var2('delete',array('POST'));
$confirm =
$this->bocommon->get_var2('confirm',array('POST'));
if($attrib)
{
$function='list_attribute';
}
else
{
$function='index';
}
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.'.$function,
'role' => $this->role
);
if ($this->bocommon->get_var2('confirm',array('POST')))
{
$this->bo->delete($s_agreement_id,$id,$attrib);
// Header('Location: ' .
$this->bocommon->link('/index.php',$link_data));
$this->bocommon->redirect_link('/index.php',$link_data);
}
$this->bocommon->xsl_add_file(array('app_delete'));
$data = array
(
'done_action' =>
$this->bocommon->link('/index.php',$link_data),
'delete_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.delete&s_agreement_id='
. $s_agreement_id. '&id=' . $id . '&attrib=' . $attrib . '&role=' .
$this->role),
'lang_confirm_msg' => lang('do you
really want to delete this entry'),
'lang_yes' =>
lang('yes'),
'lang_yes_statustext' => lang('Delete the
entry'),
'lang_no_statustext' => lang('Back to the
list'),
'lang_no' =>
lang('no')
);
$appname
= lang('service agreement');
$function_msg =
lang('delete') . ' ' . lang($this->role);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
return array('delete' => $data);
}
function view()
{
$s_agreement_id =
$this->bocommon->get_var2('id',array('POST','GET'));
$config =
CreateObject($this->currentapp.'_config',$this->currentapp);
$this->bocommon->xsl_add_file(array('s_agreement','attributes_view'));
$s_agreement =
$this->bo->read_single(array('s_agreement_id'=>$s_agreement_id));
if ($s_agreement_id)
{
$this->cat_id =
($s_agreement['cat_id']?$s_agreement['cat_id']:$this->cat_id);
$this->member_id =
($s_agreement['member_of']?$s_agreement['member_of']:$this->member_id);
$list =
$this->bo->read_details($s_agreement_id);
$uicols = $this->bo->uicols;
$list =
$this->list_content($list,$uicols,$edit_item=False,$view_only=True);
$content = $list['content'];
$table_header=$list['table_header'];
}
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.index',
's_agreement_id' => $s_agreement_id,
);
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
'vendor_id' =>
$s_agreement['vendor_id'],
'vendor_name' =>
$s_agreement['vendor_name'],
'type' =>
'view'));
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
'b_account_id' =>
$s_agreement['b_account_id'],
'b_account_name' =>
$s_agreement['b_account_name'],
'type' =>
'view'));
$dateformat =
strtolower($GLOBALS['phpgw_data']['prefs'][$this->currentapp . '.dateformat']);
$sep = '/';
$dlarr[strpos($dateformat,'y')] = 'yyyy';
$dlarr[strpos($dateformat,'m')] = 'MM';
$dlarr[strpos($dateformat,'d')] = 'DD';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
// $member_of_data =
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals'
=> True));
$link_file_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.view_file',
'id'
=>$s_agreement_id
);
$config->read_repository();
$link_to_files = $config->config_data['files_url'];
$j = count($s_agreement['files']);
for ($i=0;$i<$j;$i++)
{
$s_agreement['files'][$i]['file_name']=urlencode($s_agreement['files'][$i]['name']);
}
$data = array
(
'link_view_file'
=> $this->bocommon->link('/index.php',$link_file_data),
'link_to_files'
=> $link_to_files,
'files'
=> $s_agreement['files'],
'lang_files'
=> lang('files'),
'lang_filename'
=> lang('Filename'),
'lang_view_file_statustext' =>
lang('Klick to view file'),
'edit_url'
=> $this->bocommon->link('/index.php',$link_data),
'lang_id'
=> lang('ID'),
'value_s_agreement_id' =>
$s_agreement_id,
'lang_category'
=> lang('category'),
'lang_save'
=> lang('save'),
'lang_cancel'
=> lang('done'),
'lang_apply'
=> lang('apply'),
'value_cat'
=> $s_agreement['cat'],
'lang_cancel_statustext' =>
lang('return back to the list'),
'cat_list'
=> $this->bo->select_category_list('select',$this->cat_id),
'lang_member_of'
=> lang('member of'),
'member_of_name'
=> 'member_id',
'member_of_list'
=> $member_of_data['cat_list'],
'lang_dateformat'
=> lang(strtolower($dateformat)),
'attributes_view'
=> $s_agreement['attributes'],
'dateformat'
=> $dateformat,
'lang_start_date'
=> lang('start date'),
'value_start_date'
=> $s_agreement['start_date'],
'lang_end_date'
=> lang('end date'),
'value_end_date'
=> $s_agreement['end_date'],
'vendor_data'
=> $vendor_data,
'b_account_data'
=> $b_account_data,
'lang_name'
=> lang('name'),
'value_name'
=> $s_agreement['name'],
'lang_descr'
=> lang('descr'),
'value_descr'
=> $s_agreement['descr'],
'table_add'
=> $table_add,
'values'
=> $content,
'table_header'
=> $table_header,
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang('service agreement') . ': ' . lang('view');
//html_print_r($data);
return array('view' => $data);
}
function list_attribute()
{
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$resort =
$this->bocommon->get_var2('resort',array('POST','GET'));
$this->bocommon->xsl_add_file(array(
's_agreement',
'nextmatchs',
'search_field'));
if($resort)
{
$this->bo->resort_attrib(array('resort'=>$resort,'id'=>$id));
}
$attrib_list = $this->bo->read_attrib();
while (is_array($attrib_list) && list(,$attrib) =
each($attrib_list))
{
$content[] = array
(
'name'
=> $attrib['name'],
'type_name'
=> $attrib['type_name'],
'datatype'
=> $attrib['datatype'],
'column_name'
=> $attrib['column_name'],
'input_text'
=> $attrib['input_text'],
'sorting'
=> $attrib['attrib_sort'],
'search'
=> $attrib['search'],
'link_up'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.list_attribute&resort=up&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
'link_down'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.list_attribute&resort=down&id='
. $attrib['id'] . '&allrows=' . $this->allrows . '&role=' . $this->role),
'link_edit'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_attrib&id='
. $attrib['id'] . '&role=' . $this->role),
'link_delete'
=>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.delete&id='
. $attrib['id'].'&attrib=true&role=' . $this->role),
'lang_view_attribtext' =>
lang('view the attrib'),
'lang_attribute_attribtext' =>
lang('attributes for the attrib'). ' ' . lang('location'),
'lang_edit_attribtext' =>
lang('edit the attrib'),
'lang_delete_attribtext' =>
lang('delete the attrib'),
'text_attribute'
=> lang('Attributes'),
'text_up'
=> lang('up'),
'text_down'
=> lang('down'),
'text_edit'
=> lang('edit'),
'text_delete'
=> lang('delete')
);
}
//html_print_r($content);
$table_header[] = array
(
'lang_descr' => lang('Descr'),
'lang_datatype' => lang('Datatype'),
'lang_sorting' => lang('sorting'),
'lang_search' => lang('search'),
'lang_edit' => lang('edit'),
'lang_delete' => lang('delete'),
'sort_sorting' =>
$this->bocommon->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'attrib_sort',
'order' => $this->order,
'extra' => array('sid=cookie&op' =>
$this->currentapp.'.uis_agreement.list_attribute',
'allrows'=>$this->allrows,
'role' => $this->role)
)),
'sort_name' =>
$this->bocommon->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'column_name',
'order' => $this->order,
'extra' => array('sid=cookie&op' =>
$this->currentapp.'.uis_agreement.list_attribute',
'allrows'=>$this->allrows,
'role' => $this->role)
)),
'lang_name' => lang('Name'),
);
$table_add[] = array
(
'lang_add' =>
lang('add'),
'lang_add_attribtext' => lang('add a attrib'),
'add_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.edit_attrib&role='
. $this->role),
'lang_done' =>
lang('done'),
'lang_done_attribtext' => lang('back to
admin'),
'done_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uiadmin.index')
);
if(!$this->allrows)
{
$record_limit = 15;
//$GLOBALS['phpgw_data']['user']['preferences']['common']['maxmatchs'];
}
else
{
$record_limit = $this->bo->total_records;
}
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.list_attribute',
'sort'
=>$this->sort,
'order'
=>$this->order,
'query'
=>$this->query,
'role' =>
$this->role
);
$data = array
(
'allow_allrows'
=> True,
'allrows'
=> $this->allrows,
'start_record'
=> $this->start,
'record_limit'
=> $record_limit,
'num_records'
=> count($attrib_list),
'all_records'
=> $this->bo->total_records,
'link_url'
=> $this->bocommon->link('/index.php',$link_data),
'img_path'
=>
dirname($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']).'/api/skins/default/images',
'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
'lang_searchbutton_attribtext' => lang('Submit
the search string'),
'query'
=> $this->query,
'lang_search'
=> lang('search'),
'table_header_attrib' =>
$table_header,
'values_attrib'
=> $content,
'table_add2'
=> $table_add
);
$appname
= lang('service agreement');
$function_msg =
lang('list attribute') . ': ' . lang($this->role);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
//$this->save_sessiondata();
return array('list_attribute' => $data);
}
function edit_attrib()
{
$id =
$this->bocommon->get_var2('id',array('POST','GET'));
$values =
$this->bocommon->get_var2('values',array('POST'));
// $GLOBALS['phpgw']->common->msgbox(lang('Altering
ColumnName OR Datatype - deletes your data in this Column'));
//html_print_r($values);
$this->bocommon->xsl_add_file(array('s_agreement','choice',));
if ($values['save'])
{
if($id)
{
$values['id']=$id;
$action='edit';
}
$type_id =
$values['type_id'];
if (!$values['column_name'])
{
$receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
}
if (!$values['input_text'])
{
$receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
}
if (!$values['statustext'])
{
$receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
}
if (!$values['column_info']['type'])
{
$receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
}
if(!ctype_digit($values['column_info']['precision']))
{
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
unset($values['column_info']['precision']);
}
if(!ctype_digit($values['column_info']['scale']))
{
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
unset($values['column_info']['scale']);
}
if (!$values['column_info']['nullable'])
{
$receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
}
if (!$receipt['error'])
{
$receipt =
$this->bo->save_attrib($values,$action);
if(!$id)
{
$id=$receipt['id'];
}
}
else
{
$receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
}
}
if ($id)
{
$values = $this->bo->read_single_attrib($id);
$function_msg = lang('edit attribute') . ': ' .
lang($this->role);
$action='edit';
}
else
{
$function_msg = lang('add attribute') . ': ' .
lang($this->role);
$action='add';
}
$link_data = array
(
'sid=cookie&op' =>
$this->currentapp.'.uis_agreement.edit_attrib',
'id' => $id,
'role' => $this->role
);
//html_print_r($values);
if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
{
$multiple_choice= True;
}
$msgbox_data = $this->bocommon->msgbox_data($receipt);
$data = array
(
'lang_choice' =>
lang('Choice'),
'lang_new_value' =>
lang('New value'),
'lang_new_value_statustext' => lang('New
value for mulitple choice'),
'multiple_choice' =>
$multiple_choice,
'value_choice' =>
$values['choice'],
'lang_delete_value' =>
lang('Delete value'),
'lang_value' =>
lang('value'),
'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
//'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
'form_action' =>
$this->bocommon->link('/index.php',$link_data),
'done_action' =>
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uis_agreement.list_attribute&type_id='.$type_id
. '&role=' . $this->role),
'lang_id'
=> lang('Attribute ID'),
'lang_save'
=> lang('save'),
'lang_done'
=> lang('done'),
'value_id'
=> $id,
'lang_column_name'
=> lang('Column name'),
'value_column_name'
=> $values['column_name'],
'lang_column_name_statustext' => lang('enter
the name for the column'),
'lang_input_text'
=> lang('input text'),
'value_input_text'
=> $values['input_text'],
'lang_input_name_statustext' => lang('enter
the input text for records'),
'lang_id_attribtext' => lang('Enter
the attribute ID'),
'lang_entity_statustext' => lang('Select
a s_agreement type'),
'lang_statustext' =>
lang('Statustext'),
'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
'value_statustext' =>
$values['statustext'],
'lang_done_attribtext' => lang('Back
to the list'),
'lang_save_attribtext' => lang('Save
the attribute'),
'lang_datatype' =>
lang('Datatype'),
'lang_datatype_statustext' => lang('Select
a datatype'),
'lang_no_datatype' =>
lang('No datatype'),
'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
'lang_precision' =>
lang('Precision'),
'lang_precision_statustext' => lang('enter
the record length'),
'value_precision' =>
$values['column_info']['precision'],
'lang_scale' =>
lang('scale'),
'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
'value_scale' =>
$values['column_info']['scale'],
'lang_default' =>
lang('default'),
'lang_default_statustext' => lang('enter
the default value'),
'value_default' =>
$values['column_info']['default'],
'lang_nullable' =>
lang('Nullable'),
'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
'lang_select_nullable' => lang('Select
nullable'),
'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
'value_list' =>
$values['list'],
'lang_list'
=> lang('show in list'),
'lang_list_statustext' => lang('check
to show this attribute in location list'),
'value_search' =>
$values['search'],
'lang_include_search' =>
lang('Include in search'),
'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
);
//html_print_r($data);
$appname
= lang('service agreement');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
return array('edit_attrib' => $data);
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/class.uis_agreement.php, 1.1.2.1,
nomail <=