phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.uialarm.inc.php, 1.1


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.uialarm.inc.php, 1.1
Date: Wed, 21 Jul 2004 21:00:12 +0200

Update of /property/inc
Added Files:
        Branch: 
          class.uialarm.inc.php

date: 2004/07/21 19:00:12;  author: sigurdne;  state: Exp;

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.                                            
   *
        
\**************************************************************************/

        class uialarm
        {
                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
                );

                function uialarm()
                {
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->nextmatchs       = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];

                        $this->bo                       = 
CreateObject($this->currentapp.'.boalarm',True);
                        $this->boasync          = 
CreateObject($this->currentapp.'.boasync');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->menu                                     = 
CreateObject($this->currentapp.'.menu');

                        $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->method_id        = $this->bo->method_id;
                        $this->allrows          = $this->bo->allrows;
                }

                function save_sessiondata()
                {
                        $data = array
                        (
                                'start'                 => $this->start,
                                'query'                 => $this->query,
                                'sort'                  => $this->sort,
                                'order'                 => $this->order,
                                'filter'                => $this->filter,
                                'method_id'             => $this->method_id,
                                'this->allrows' => $this->allrows
                        );
                        $this->bo->save_sessiondata($data);
                }

                function index()
                {
                        $GLOBALS['phpgw']->xslttpl->add_file(array('alarm',
                                                                                
'menu',
                                                                                
'receipt',
                                                                                
'search_field',
                                                                                
'nextmatchs'));

                        $links = $this->menu->links();

                        $receipt = 
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt');
                        
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt','');
                        $values         = get_var('values',array('POST'));
                        if($values['delete_alarm'] && count($values['alarm'])):
                        {
                                $receipt = 
$this->bo->delete_alarm('fm_async',$values['alarm']);
                        }
                        elseif(($values['enable_alarm'] || 
$values['disable_alarm']) && count($values['alarm'])):
                        {
                                $receipt = 
$this->bo->enable_alarm('fm_async',$values['alarm'],$values['enable_alarm']);
                        }
                        endif;

                        $list = $this->bo->read();
//_debug_array($list);

                        while (is_array($list) && list(,$alarm) = each($list))
                        {
                                if(is_array($alarm['times']))
                                {
                                        while (is_array($alarm['times']) && 
list($key,$value) = each($alarm['times']))
                                        {
                                                $times .=$key . ' => ' .$value. 
' ';
                                        }

                                }
                                else
                                {
                                        $times = 
$GLOBALS['phpgw']->common->show_date($alarm['times']);
                                }
                                if(is_array($alarm['data']))
                                {
                                        while (is_array($alarm['data']) && 
list($key,$value) = each($alarm['data']))
                                        {
                                                $data .=$key . ' => ' .$value . 
' ';
                                        }

                                }

                                $content[] = array
                                (
                                        'id'                                    
        => $alarm['id'],
                                        'next_run'                              
        => $GLOBALS['phpgw']->common->show_date($alarm['next']),
                                        'method'                                
        => $alarm['method'],
                                        'times'                                 
        => $times,
                                        'data'                                  
        => $data,
                                        'enabled'                               
        => $alarm['enabled'],
                                        'user'                                  
        => $GLOBALS['phpgw']->accounts->id2name($alarm[account_id]),
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit&async_id='
 . urlencode($alarm['id'])),
                                        'lang_view_statustext'          => 
lang('view the alarm'),
                                        'lang_edit_statustext'          => 
lang('edit the alarm'),
                                        'lang_delete_statustext'        => 
lang('delete the alarm'),
                                        'text_view'                             
        => lang('view'),
                                        'text_edit'                             
        => lang('edit'),
                                        'text_delete'                           
=> lang('delete')
                                );
                                unset($alarm);
                                unset($data);
                                unset($times);
                        }

                        $table_header = array
                        (
                                'lang_next_run'         => lang('Next run'),
                                'lang_times'            => lang('Times'),
                                'lang_method'           => lang('Method'),
                                'lang_user'                     => lang('User'),
                                'lang_data'                     => lang('Data'),
                                'lang_select'           => lang('select'),
                                'lang_edit'                     => lang('edit'),
                                'lang_alarm_id'         => lang('alarm id'),
                                'lang_enabled'          => lang('enabled'),
                                'sort_next_run'         => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   => 'next',
                                                                                
        'order' => $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uialarm.index',
                                                                                
                                                        'cat_id'        => 
$this->cat_id,
                                                                                
                                                        'query'         
=>$this->query,
                                                                                
                                                        'allrows'       
=>$this->allrows)
                                                                                
)),
                                'sort_alarm_id'         => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   => 'alarm_id',
                                                                                
        'order' => $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uialarm.index',
                                                                                
                                                        'cat_id'        => 
$this->cat_id,
                                                                                
                                                        'query'         
=>$this->query,
                                                                                
                                                        'allrows'       
=>$this->allrows)
                                                                                
))
                        );

                        $alter_alarm = array
                        (
                                'lang_enable'           => lang('Enable'),
                                'lang_disable'          => lang('Disable'),
                                'lang_delete'           => lang('Delete')
                                );

                        $table_add = array
                        (
                                'lang_add'                              => 
lang('add'),
                                'lang_add_statustext'   => lang('add a alarm'),
                                'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uialarm.edit')
                        );

                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uialarm.index',
                                                'sort'                  
=>$this->sort,
                                                'order'                 
=>$this->order,
                                                'cat_id'                
=>$this->cat_id,
                                                'filter'                
=>$this->filter,
                                                'query'                 
=>$this->query
                        );

                        if(!$this->allrows)
                        {
                                $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
                        }
                        else
                        {
                                $record_limit   = $this->bo->total_records;
                        }

                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

                        $data = array
                        (
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'links'                                         
        => $links,
                                'allow_allrows'                                 
=> true,
                                'allrows'                                       
        => $this->allrows,
                                'start_record'                                  
=> $this->start,
                                'record_limit'                                  
=> $record_limit,
                                'num_records'                                   
=> count($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_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the alarm 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'                                 
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'filter_list'                                   
=> $this->nextmatchs->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,
                                'alter_alarm'                                   
=> $alter_alarm,
                        );
                        $this->save_sessiondata();
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('alarm') . ': ' . lang('list alarm');
//_debug_array($data);

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                }

                function initiate_ui_addr_lookup($data)
                {
//_debug_array($data);

                        if($data['type']=='view')
                        {
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('abook_view'));
                        }
                        else
                        {
                                
$GLOBALS['phpgw']->xslttpl->add_file(array('abook_form'));
                        }

                        $owner['value_abid']                            = 
$data['abid'];
                        $owner['value_org_name']                        = 
$data['org_name'];

                        if($data['abid'] && !$data['org_name'])
                        {
                                $abook_data                                     
        = 
$this->contacts->read_single_entry($data['abid'],array('org_name'=>'org_name','email'=>'email'));
                                $owner['value_org_name']                = 
$abook_data[0]['org_name'];
                        }

                        $owner['abook_link']                                    
= 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook');
                        $owner['lang_contact']                                  
= lang('contact');
                        $owner['lang_select_contact_help']              = 
lang('Klick this link to select owner from the addressbook');
                        $owner['lang_org_name']                         = 
lang('Name');

//_debug_array($owner);
                        return $owner;
                }


                function edit()
                {
                        $async_id       = 
urldecode(get_var('async_id',array('POST','GET')));
                        $values         = get_var('values',array('POST'));

                        $GLOBALS['phpgw']->xslttpl->add_file(array('alarm'));


                        if ($values['save'] || $values['apply'])
                        {

                                $units = array(
                                        'year',
                                        'month',
                                        'day',
                                        'dow',
                                        'hour',
                                        'min');

                                $times = array();
                                foreach($units as $u)
                                {
                                        if ($values[$u] !== '')
                                        {
                                                $times[$u] = $values[$u];
                                        }
                                }

                                if(!$receipt['error'])
                                {
                                        $this->method_id = 
($values['method_id']?$values['method_id']:$this->method_id);

                                        $values['alarm_id']     = $alarm_id;

                                        
$async=$this->boasync->read_single($this->method_id);
                                        $data_set = unserialize($async['data']);
                                        $data_set['enabled']    = True;
                                        $data_set['time']               = 
$times;
                                        $data_set['owner']              = 
$this->account;
                                        $data_set['event_id']           = 
$this->method_id;


                                        $receipt = 
$this->bo->save_alarm($alarm_type='fm_async',$entity_id=$this->method_id,$alarm=$data_set,$async['num']);
                        //              $alarm_id = $alarm['id'];

                                        if ($values['save'])
                                        {
                                                
$GLOBALS['phpgw']->session->appsession('session_data','alarm_receipt',$receipt);
                                                
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uialarm.index');
                                        }
                                }
                        }

                        if ($values['cancel'])
                        {
                                
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uialarm.index');
                        }

                        if ($alarm_id)
                        {
                                $alarm = $this->bo->read_single($alarm_id);
                                $this->cat_id = 
($alarm['cat_id']?$alarm['cat_id']:$this->cat_id);
                        }

                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uialarm.edit',
                                'alarm_id'              => $alarm_id
                        );

                        $msgbox_data = $this->bocommon->msgbox_data($receipt);

                        $data = array
                        (
                                'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'abook_data'                                    
=> $abook_data,
                                'edit_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'lang_alarm_id'                                 
=> lang('ID'),
                                'value_alarm_id'                                
=> $alarm_id,
                                'lang_remark'                                   
=> lang('remark'),
                                'lang_method'                                   
=> lang('method'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_cancel'                                   
=> lang('cancel'),
                                'lang_apply'                                    
=> lang('apply'),
                                'value_remark'                                  
=> $alarm['remark'],
                                'value_cat'                                     
        => $alarm['cat'],
                                'lang_apply_statustext'                 => 
lang('Apply the values'),
                                'lang_cancel_statustext'                => 
lang('Leave the owner untouched and return back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the owner and return back to the list'),
                                'lang_no_method'                                
=> lang('no method'),
                                'lang_method_statustext'                => 
lang('Select the method for this times service'),
                                'method_list'                                   
=> $this->bo->select_method_list($this->method_id),
                                'lang_timing'                                   
=> lang('timing'),
                                'lang_year'                                     
        => lang('year'),
                                'lang_month'                                    
=> lang('month'),
                                'lang_day'                                      
        => lang('day'),
                                'lang_dow'                                      
        => lang('Day of week (0-6, 0=Sun)'),
                                'lang_hour'                                     
        => lang('hour'),
                                'lang_minute'                                   
=> lang('minute'),
                                'lang_data'                                     
        => lang('data'),
                                'lang_data_statustext'                  => 
lang('inputdata for the method'),



                        );
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('owner') . ': ' . ($owner_id?lang('edit owner'):lang('add owner'));

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }


                function delete()
                {
                        $owner_id       = 
get_var('owner_id',array('POST','GET'));
                        $delete         = get_var('delete',array('POST'));
                        $confirm        = get_var('confirm',array('POST'));

                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.uiowner.index'
                        );

                        if (get_var('confirm',array('POST')))
                        {
                                $this->bo->delete($owner_id);
//                              Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                                
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
                        }

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));

                        $data = array
                        (
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiowner.delete&owner_id='
 . $owner_id),
                                '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('owner');
                        $function_msg                                   = 
lang('delete owner');

                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }



                function view()
                {
                        $owner_id       = get_var('owner_id',array('GET'));
                        $action         = get_var('action',array('GET'));

                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('owner') . ': ' . lang('view owner');

                        $GLOBALS['phpgw']->xslttpl->add_file('owner');

                        $owner = $this->bo->read_single($owner_id);

                        $data = array
                        (
                                'done_action'           => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiowner.index'),
                                'lang_name'                     => lang('name'),
                                'lang_category'         => lang('category'),
                                'lang_time_created'     => lang('time created'),
                                'lang_done'                     => lang('done'),
                                'value_name'            => $owner['name'],
                                'value_cat'                     => 
$this->bo->read_category_name($owner['cat_id']),
                                'value_date'            => 
$GLOBALS['phpgw']->common->show_date($owner['entry_date'])
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }
        }
?>




reply via email to

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