phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] property/inc/class.uitenant.inc.php, 1.1.1.2


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.uitenant.inc.php, 1.1.1.2
Date: Tue, 18 May 2004 15:45:25 +0200

Update of /property/inc
Modified Files:
        Branch: 
          class.uitenant.inc.php

date: 2004/05/18 13:45:25;  author: sigurdne;  state: Exp;  lines: +561 -87

Log Message:
no message
=====================================================================
Index: property/inc/class.uitenant.inc.php
diff -u property/inc/class.uitenant.inc.php:1.1.1.1 
property/inc/class.uitenant.inc.php:1.1.1.2
--- property/inc/class.uitenant.inc.php:1.1.1.1 Fri Apr 23 13:14:10 2004
+++ property/inc/class.uitenant.inc.php Tue May 18 13:45:25 2004
@@ -31,7 +31,10 @@
                        'index'  => True,
                        'view'   => True,
                        'edit'   => True,
-                       'delete' => True
+                       'delete' => True,
+                       'list_attribute'=> True,
+                       'edit_attrib'   => True,
+                       'columns'               => True
                );
 
                function uitenant()
@@ -45,6 +48,15 @@
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->menu                                     = 
CreateObject($this->currentapp.'.menu');
 
+
+                       $this->acl2                     = 
CreateObject($this->currentapp.'.acl2');
+                       $this->acl2_location= '.tenant';
+
+                       $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->start            = $this->bo->start;
                        $this->query            = $this->bo->query;
                        $this->sort                     = $this->bo->sort;
@@ -69,8 +81,62 @@
                        $this->bo->save_sessiondata($data);
                }
 
+               function columns()
+               {
+
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
+
+                       $GLOBALS['phpgw_info']['flags']['headonly']=true;
+
+                       $values                 = 
get_var('values',array('POST','GET'));
+
+                       if ($values['save'])
+                       {
+
+                               
$GLOBALS['phpgw']->preferences->account_id=$this->account;
+                               
$GLOBALS['phpgw']->preferences->read_repository();
+                               
$GLOBALS['phpgw']->preferences->add($this->currentapp,"tenant_columns",$values['columns'],'user');
+                               
$GLOBALS['phpgw']->preferences->save_repository();
+
+                               $receipt['message'][] = array('msg' => 
lang('columns is updated'));
+                       }
+
+                       $function_msg   = lang('Select Column');
+
+                       $link_data = array
+                       (
+                               'menuaction'         => 
$this->currentapp.'.uitenant.columns'
+                       );
+
+                       $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'   => 
$GLOBALS['phpgw']->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;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
+               }
+
+
+
                function index()
                {
+                       $this->menu->sub        ='tenant';
+
+                       if(!$this->acl_read)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
 . $this->acl2_location);
+                       }
+
                        $GLOBALS['phpgw']->xslttpl->add_file(array('tenant',
                                                                                
'menu',
                                                                                
'receipt',
@@ -84,83 +150,104 @@
 
                        $tenants_list = $this->bo->read();
 
-                       while (is_array($tenants_list) && list(,$tenant) = 
each($tenants_list))
+                       $uicols = $this->bo->uicols;
+
+                       $j=0;
+
+                       if (isset($tenants_list) AND is_array($tenants_list))
                        {
-                               $content[] = array
-                               (
-                                       'tenant_id'                             
        => $tenant['tenant_id'],
-                                       'name'                                  
        => $tenant['name'],
-                                       'entry_date'                            
=> $tenant['entry_date'],
-                                       'category'                              
        => $tenant['category'],
-                                       'link_view'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.view&tenant_id='
 . $tenant['tenant_id']),
-                                       'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.edit&tenant_id='
 . $tenant['tenant_id']),
-                                       'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.delete&tenant_id='
 . $tenant['tenant_id']),
-                                       'lang_view_statustext'          => 
lang('view the tenant'),
-                                       'lang_edit_statustext'          => 
lang('edit the tenant'),
-                                       'lang_delete_statustext'        => 
lang('delete the tenant'),
-                                       'text_view'                             
        => lang('view'),
-                                       'text_edit'                             
        => lang('edit'),
-                                       'text_delete'                           
=> lang('delete')
-                               );
+                               foreach($tenants_list as $tenant_entry)
+                               {
+                                       for 
($i=0;$i<count($uicols['name']);$i++)
+                                       {
+                                               
if($uicols['input_type'][$i]!='hidden')
+                                               {
+                                                       
$content[$j]['row'][$i]['value']                        = 
$tenant_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']                               = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.view&tenant_id='
 . $tenant_entry['tenant_id']);
+                                       }
+                                       if($this->acl_edit)
+                                       {
+                                               
$content[$j]['row'][$i]['statustext']                   = lang('edit the 
tenant');
+                                               $content[$j]['row'][$i]['text'] 
                                = lang('edit');
+                                               
$content[$j]['row'][$i++]['link']                               = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.edit&tenant_id='
 . $tenant_entry['tenant_id']);
+                                       }
+                                       if($this->acl_delete)
+                                       {
+                                               
$content[$j]['row'][$i]['statustext']                   = lang('delete the 
tenant');
+                                               $content[$j]['row'][$i]['text'] 
                                = lang('delete');
+                                               
$content[$j]['row'][$i++]['link']                               = 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.delete&tenant_id='
 . $tenant_entry['tenant_id']);
+                                       }
+
+                                       $j++;
+                               }
                        }
 
-                       $table_header = array
-                       (
-                               'lang_name'                     => lang('name'),
-                               'lang_time_created'     => lang('time created'),
-                               'lang_view'                     => lang('view'),
-                               'lang_edit'                     => lang('edit'),
-                               'lang_delete'           => lang('delete'),
-                               'lang_tenant_id'                => lang('tenant 
id'),
-                               'sort_name'             => 
$this->nextmatchs->show_sort_order(array
-                                                                               
(
-                                                                               
        'sort'  => $this->sort,
-                                                                               
        'var'   => 'last_name',
-                                                                               
        'order' => $this->order,
-                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uitenant.index',
-                                                                               
                                                        'cat_id'        => 
$this->cat_id,
-                                                                               
                                                        'query'         
=>$this->query,
-                                                                               
                                                        'allrows'       
=>$this->allrows)
-                                                                               
)),
-                               'sort_tenant_id'                => 
$this->nextmatchs->show_sort_order(array
-                                                                               
(
-                                                                               
        'sort'  => $this->sort,
-                                                                               
        'var'   => 'tenant_id',
-                                                                               
        'order' => $this->order,
-                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uitenant.index',
-                                                                               
                                                        'cat_id'        => 
$this->cat_id,
-                                                                               
                                                        'query'         
=>$this->query,
-                                                                               
                                                        'allrows'       
=>$this->allrows)
-                                                                               
)),
-                               'sort_time_created'     => 
$this->nextmatchs->show_sort_order(array
-                                                                               
(
-                                                                               
        'sort'  => $this->sort,
-                                                                               
        'var'   =>      'entry_date',
-                                                                               
        'order' =>      $this->order,
-                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uitenant.index',
-                                                                               
                                                        'cat_id'        
=>$this->cat_id,
-                                                                               
                                                        'query'         
=>$this->query,
-                                                                               
                                                        'allrows'       
=>$this->allrows)
-                                                                               
)),
-                               'sort_category' => 
$this->nextmatchs->show_sort_order(array
-                                                                               
(
-                                                                               
        'sort'  => $this->sort,
-                                                                               
        'var'   =>      'descr',
-                                                                               
        'order' =>      $this->order,
-                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uitenant.index',
-                                                                               
                                                        'cat_id'        
=>$this->cat_id,
-                                                                               
                                                        'query'         
=>$this->query,
-                                                                               
                                                        'allrows'       
=>$this->allrows)
-                                                                               
)),
-                               'lang_category'         => lang('category')
-                       );
+//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->nextmatchs->show_sort_order(array
+                                                       (
+                                                               'sort'  => 
$this->sort,
+                                                               'var'   =>      
$uicols['name'][$i],
+                                                               'order' =>      
$this->order,
+                                                               'extra'         
=> array('menuaction'   => $this->currentapp.'.uitenant.index',
+                                                                               
                        'query'         =>$this->query,
+                                                                               
                        'lookup'        =>$lookup,
+                                                                               
                        'district_id'   => $this->district_id,
+                                                                               
                        'start_date'=>$start_date,
+                                                                               
                        'end_date'=>$end_date)
+                                                       ));
+                                       }
+                               }
+                       }
 
-                       $table_add = array
-                       (
-                               'lang_add'                              => 
lang('add'),
-                               'lang_add_statustext'   => lang('add a tenant'),
-                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.edit')
-                       );
+                       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 
tenant'),
+                                       'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.edit')
+                               );
+                       }
 
                        $link_data = array
                        (
@@ -183,8 +270,17 @@
 
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);
 
+                       $link_columns = array
+                       (
+                               'menuaction' => 
$this->currentapp.'.uitenant.columns'
+                       );
+
                        $data = array
                        (
+                               'overlib_source'                                
=> './'.$this->currentapp.'/inc/overlib.js',
+                               'lang_columns'                                  
=> lang('columns'),
+                               'link_columns'                                  
=> $GLOBALS['phpgw']->link('/index.php',$link_columns),
+                               'lang_columns_help'                             
=> lang('Choose columns'),
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'links'                                         
        => $links,
                                'allow_allrows'                                 
=> false,
@@ -220,11 +316,31 @@
                {
                        $tenant_id      = 
get_var('tenant_id',array('POST','GET'));
                        $values         = get_var('values',array('POST'));
+                       $values_attribute  = 
get_var('values_attribute',array('POST'));
 
-                       $GLOBALS['phpgw']->xslttpl->add_file(array('tenant'));
+                       $insert_record_tenant = 
$GLOBALS['phpgw']->session->appsession('insert_record_tenant',$this->currentapp);
+
+//_debug_array($insert_record_tenant);
+                       for ($j=0;$j<count($insert_record_tenant);$j++)
+                       {
+                               
$insert_record['extra'][$insert_record_tenant[$j]]      = 
$insert_record_tenant[$j];
+                       }
+
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant','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];
+                                       }
+                               }
+
+//_debug_array($values);
+
                                if ($values['save'] || $values['apply'])
                                {
 
@@ -241,7 +357,7 @@
                                        if(!$receipt['error'])
                                        {
                                                $values['tenant_id']    = 
$tenant_id;
-                                               $receipt = 
$this->bo->save($values);
+                                               $receipt = 
$this->bo->save($values,$values_attribute);
                                                $tenant_id = 
$receipt['tenant_id'];
                                                $this->cat_id = 
($values['cat_id']?$values['cat_id']:$this->cat_id);
 
@@ -259,9 +375,10 @@
                        }
 
 
+                       $tenant = 
$this->bo->read_single(array('tenant_id'=>$tenant_id));
+
                        if ($tenant_id)
                        {
-                               $tenant = $this->bo->read_single($tenant_id);
                                $this->cat_id = 
($tenant['cat_id']?$tenant['cat_id']:$this->cat_id);
                        }
 
@@ -272,13 +389,41 @@
                        );
 //_debug_array($link_data);
 
+                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['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;
+                       }
+
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);
 
                        $data = array
                        (
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'edit_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'lang_tenant_id'                                
        => lang('Owner ID'),
+                               'lang_tenant_id'                                
=> lang('Tenant ID'),
                                'value_tenant_id'                               
=> $tenant_id,
                                'lang_first_name'                               
=> lang('first name'),
                                'lang_last_name'                                
=> lang('last name'),
@@ -300,7 +445,17 @@
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the tenant 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)
+                               'cat_list'                                      
        => $this->bo->select_category_list('select',$this->cat_id),
+                               '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'                             
=> $tenant['attributes'],
+                               'lookup_functions'                              
=> $tenant['lookup_functions'],
+                               'dateformat'                                    
=> $dateformat,
                        );
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('tenant') . ': ' . ($tenant_id?lang('edit tenant'):lang('add tenant'));
 
@@ -310,18 +465,29 @@
 
                function delete()
                {
+                       $attrib         = get_var('attrib',array('POST','GET'));
+                       $id             = get_var('id',array('POST','GET'));
                        $tenant_id      = 
get_var('tenant_id',array('POST','GET'));
                        $delete         = get_var('delete',array('POST'));
                        $confirm        = get_var('confirm',array('POST'));
 
+
+                       if($attrib)
+                       {
+                               $function='list_attribute';
+                       }
+                       else
+                       {
+                               $function='index';
+                       }
                        $link_data = array
                        (
-                               'menuaction' => 
$this->currentapp.'.uitenant.index'
+                               'menuaction' => 
$this->currentapp.'.uitenant.'.$function
                        );
 
                        if (get_var('confirm',array('POST')))
                        {
-                               $this->bo->delete($tenant_id);
+                               $this->bo->delete($tenant_id,$id,$attrib);
 //                             Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                                
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
                        }
@@ -331,7 +497,7 @@
                        $data = array
                        (
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.delete&tenant_id='
 . $tenant_id),
+                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.delete&tenant_id='
 . $tenant_id. '&id=' . $id . '&attrib=' . $attrib),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
                                'lang_yes_statustext'   => lang('Delete the 
entry'),
@@ -355,9 +521,20 @@
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('tenant') . ': ' . lang('view tenant');
 
-                       $GLOBALS['phpgw']->xslttpl->add_file('tenant');
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant','attributes_view'));
+
+                       $tenant = 
$this->bo->read_single(array('tenant_id'=>$tenant_id));
 
-                       $tenant = $this->bo->read_single($tenant_id);
+                       $attributes_values=$tenant['attributes'];
+
+                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                       $sep = '/';
+                       $dlarr[strpos($dateformat,'y')] = 'yyyy';
+                       $dlarr[strpos($dateformat,'m')] = 'MM';
+                       $dlarr[strpos($dateformat,'d')] = 'DD';
+                       ksort($dlarr);
+
+                       $dateformat= (implode($sep,$dlarr));
 
                        $data = array
                        (
@@ -372,10 +549,307 @@
                                'value_last_name'                       => 
$tenant['last_name'],
                                'value_contact_phone'           => 
$tenant['contact_phone'],
                                'cat_list'                                      
=> $this->bo->select_category_list('',$tenant['cat_id']),
-                               'value_date'                            => 
$GLOBALS['phpgw']->common->show_date($tenant['entry_date'])
+                               'value_date'                            => 
$GLOBALS['phpgw']->common->show_date($tenant['entry_date']),
+                               'lang_dateformat'                       => 
lang(strtolower($dateformat)),
+                               'lang_attributes'                       => 
lang('Attributes'),
+                               'attributes_view'                       => 
$attributes_values,
+                               'dateformat'                            => 
$dateformat
                        );
 
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }
+
+               function list_attribute()
+               {
+                       $id     = get_var('id',array('POST','GET'));
+                       $resort = get_var('resort',array('POST','GET'));
+
+                       $GLOBALS['phpgw']->xslttpl->add_file(array(
+                                                               'tenant',
+                                                               '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'],
+                                       'link_up'                               
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.list_attribute&resort=up&id='
 . $attrib['id'] . '&allrows=' . $this->allrows),
+                                       'link_down'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.list_attribute&resort=down&id='
 . $attrib['id'] . '&allrows=' . $this->allrows),
+                                       'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.edit_attrib&id='
 . $attrib['id']),
+                                       'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.delete&id='
 . $attrib['id'].'&attrib=true'),
+                                       '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_edit'                     => lang('edit'),
+                               'lang_delete'           => lang('delete'),
+                               'sort_sorting'  => 
$this->nextmatchs->show_sort_order(array
+                                                                               
(
+                                                                               
        'sort'  => $this->sort,
+                                                                               
        'var'   =>      'attrib_sort',
+                                                                               
        'order' =>      $this->order,
+                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uitenant.list_attribute',
+                                                                               
                                                'allrows'=>$this->allrows)
+                                                                               
)),
+
+                               'sort_name'     => 
$this->nextmatchs->show_sort_order(array
+                                                                               
(
+                                                                               
        'sort'  => $this->sort,
+                                                                               
        'var'   =>      'column_name',
+                                                                               
        'order' =>      $this->order,
+                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uitenant.list_attribute',
+                                                                               
                                                'allrows'=>$this->allrows)
+                                                                               
)),
+                               'lang_name'     => lang('Name'),
+                       );
+
+                       $table_add[] = array
+                       (
+                               'lang_add'                              => 
lang('add'),
+                               'lang_add_attribtext'   => lang('add a attrib'),
+                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.edit_attrib'),
+                               'lang_done'                             => 
lang('done'),
+                               'lang_done_attribtext'  => lang('back to 
admin'),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/admin/index.php'),
+                       );
+
+                       if(!$this->allrows)
+                       {
+                               $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       }
+                       else
+                       {
+                               $record_limit   = $this->bo->total_records;
+                       }
+
+                       $link_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uitenant.list_attribute',
+                                               'sort'                  
=>$this->sort,
+                                               'order'                 
=>$this->order,
+                                               'query'                 
=>$this->query
+                       );
+
+                       $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'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+                               '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('attribute');
+                       $function_msg                                   = 
lang('list location attribute');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       //$this->save_sessiondata();
+//_debug_array($GLOBALS['phpgw_info']['user']);
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+               }
+
+               function edit_attrib()
+               {
+                       $id                     = 
get_var('id',array('POST','GET'));
+                       $values         = get_var('values',array('POST'));
+       //              $GLOBALS['phpgw']->common->msgbox(lang('Altering 
ColumnName OR Datatype  - deletes your data in this Column'));
+       //html_print_r($values);
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('tenant','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');
+                               $action='edit';
+                       }
+                       else
+                       {
+                               $function_msg = lang('add attribute');
+                               $action='add';
+                       }
+
+                       $link_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uitenant.edit_attrib',
+                               'id'    => $id
+                       );
+       //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'                           => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'done_action'                           => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uitenant.list_attribute&type_id='.$type_id),
+                               '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 tenant 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')
+                       );
+       //html_print_r($data);
+
+                       $appname                                                
= lang('location');
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+               }
        }
-?>
+?>
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]