phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: stocks/inc class.bo.inc.php,1.11,1.12 class.ui.


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: stocks/inc class.bo.inc.php,1.11,1.12 class.ui.inc.php,1.17,1.18
Date: Sat, 26 Apr 2003 16:52:22 -0400

Update of /cvsroot/phpgroupware/stocks/inc
In directory subversions:/tmp/cvs-serv6883/inc

Modified Files:
        class.bo.inc.php class.ui.inc.php 
Log Message:
update

Index: class.bo.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/stocks/inc/class.bo.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** class.bo.inc.php    29 Apr 2002 03:09:18 -0000      1.11
--- class.bo.inc.php    26 Apr 2003 20:52:19 -0000      1.12
***************
*** 10,14 ****
        * Written by Bettina Gille address@hidden                   *
        * -----------------------------------------------                   *
!       * Copyright (C) 2001,2002 Bettina Gille                             *
        *                                                                   *
        * This program is free software; you can redistribute it and/or     *
--- 10,14 ----
        * Written by Bettina Gille address@hidden                   *
        * -----------------------------------------------                   *
!       * Copyright (C) 2001 - 2003 Bettina Gille                           *
        *                                                                   *
        * This program is free software; you can redistribute it and/or     *
***************
*** 37,48 ****
                        $this->read_sessiondata();
  
!                       $country = get_var('country',Array('GET','POST'));
  
!                       if (isset($country) && !empty($country))
                        {
                                $this->country = $country;
                        }
! 
!                       if($country == '')
                        {
                                $prefs = $this->read_prefs();
--- 37,47 ----
                        $this->read_sessiondata();
  
!                       $country = get_var('country',Array('POST','GET'));
  
!                       if ($country)
                        {
                                $this->country = $country;
                        }
!                       else
                        {
                                $prefs = $this->read_prefs();
***************
*** 80,84 ****
                        switch($this->country)
                        {
-                               case 'US':      $url = 
'http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s='; break;
                                case 'DE':      $url = 
'http://de.finance.yahoo.com/d/quotes_de.csv?f=sl1d1t1c1ohgv&e=.csv&s='; break;
                                default :       $url = 
'http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s='; break;
--- 79,82 ----

Index: class.ui.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/stocks/inc/class.ui.inc.php,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** class.ui.inc.php    31 Mar 2003 16:52:04 -0000      1.17
--- class.ui.inc.php    26 Apr 2003 20:52:20 -0000      1.18
***************
*** 10,14 ****
        * Written by Bettina Gille address@hidden                   *
        * -----------------------------------------------                   *
!       * Copyright (C) 2001,2002 Bettina Gille                             *
        *                                                                   *
        * This program is free software; you can redistribute it and/or     *
--- 10,14 ----
        * Written by Bettina Gille address@hidden                   *
        * -----------------------------------------------                   *
!       * Copyright (C) 2001 - 2003 Bettina Gille                           *
        *                                                                   *
        * This program is free software; you can redistribute it and/or     *
***************
*** 35,40 ****
                        'preferences'   => True,
                        'edit_stock'    => True,
!                       'list_stocks'   => True,
!                       'add_stock'             => True
                );
  
--- 35,39 ----
                        'preferences'   => True,
                        'edit_stock'    => True,
!                       'list_stocks'   => True
                );
  
***************
*** 42,46 ****
                {
                        $this->bo                       = 
CreateObject('stocks.bo');
-                       $this->t                        = 
$GLOBALS['phpgw']->template;
                        $this->sbox                     = 
CreateObject('phpgwapi.sbox');
                        $this->nextmatchs       = 
CreateObject('phpgwapi.nextmatchs');
--- 41,44 ----
***************
*** 52,56 ****
                        $data = array
                        (
!                               'country'       => $this->country
                        );
                        $this->bo->save_sessiondata($data);
--- 50,54 ----
                        $data = array
                        (
!                               'country' => $this->country
                        );
                        $this->bo->save_sessiondata($data);
***************
*** 59,91 ****
                function set_app_langs()
                {
!                       
$this->t->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
!                       
$this->t->set_var('tr_color1',$GLOBALS['phpgw_info']['theme']['row_on']);
!                       
$this->t->set_var('tr_color2',$GLOBALS['phpgw_info']['theme']['row_off']);
!                       $this->t->set_var('lang_company',lang('Company name'));
!                       $this->t->set_var('lang_symbol',lang('Symbol'));
!                       $this->t->set_var('lang_edit',lang('Edit'));
!                       $this->t->set_var('lang_add',lang('Add'));
!                       $this->t->set_var('lang_country',lang('Country'));
!                       $this->t->set_var('lang_add_stock',lang('Add new 
stock'));
!                       $this->t->set_var('lang_delete',lang('Delete'));
!                       $this->t->set_var('lang_save',lang('Save'));
!                       $this->t->set_var('lang_stocks',lang('Stock Quotes'));
!                       $this->t->set_var('lang_done',lang('Done'));
!                       $this->t->set_var('lang_submit',lang('Submit'));
!                       $this->t->set_var('lang_select_country',lang('Select 
country'));
                }
  
                function display_app_header()
                {
!                       $this->t->set_file(array('header' => 'header.tpl'));
!                       $this->t->set_block('header','stock_header');
  
                        $this->set_app_langs();
  
!                       
$this->t->set_var('link_stocks',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks'));
!                       $this->t->set_var('lang_select_stocks',lang('Select 
stocks to display'));
! 
!                       $this->t->fp('app_header','stock_header');
! 
                        $GLOBALS['phpgw']->common->phpgw_header();
                }
--- 57,88 ----
                function set_app_langs()
                {
!                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
!                       
$GLOBALS['phpgw']->template->set_var('tr_color1',$GLOBALS['phpgw_info']['theme']['row_on']);
!                       
$GLOBALS['phpgw']->template->set_var('tr_color2',$GLOBALS['phpgw_info']['theme']['row_off']);
!                       
$GLOBALS['phpgw']->template->set_var('lang_company',lang('Company name'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_symbol',lang('Symbol'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_add',lang('Add'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_country',lang('Country'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_add_stock',lang('Add new stock'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_delete',lang('Delete'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_save',lang('Save'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_stocks',lang('Stock Quotes'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_done',lang('Done'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_submit',lang('Submit'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_select_country',lang('Select 
country'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
                }
  
                function display_app_header()
                {
!                       $GLOBALS['phpgw']->template->set_file(array('header' => 
'header.tpl'));
!                       
$GLOBALS['phpgw']->template->set_block('header','stock_header');
  
                        $this->set_app_langs();
  
!                       
$GLOBALS['phpgw']->template->set_var('link_stocks',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks&country='
 . $this->country));
!                       
$GLOBALS['phpgw']->template->set_var('lang_select_stocks',lang('Select stocks 
to display'));
!                       
$GLOBALS['phpgw']->template->fp('app_header','stock_header');
                        $GLOBALS['phpgw']->common->phpgw_header();
                }
***************
*** 93,105 ****
                function return_html($quotes)
                {
                        for ($i=0;$i<count($quotes);$i++)
                        {
                                $data[] = array
                                (
!                                       'symbol'        => 
$quotes[$i]['symbol'],
!                                       'name'          => $quotes[$i]['name'],
!                                       'price0'        => 
$quotes[$i]['price0'],
!                                       'price1'        => 
$quotes[$i]['price1'],
!                                       'price2'        => 
$quotes[$i]['price2'],
                                        'dollarchange'  => 
$quotes[$i]['dchange'],
                                        'percentchange' => 
$quotes[$i]['pchange'],
--- 90,142 ----
                function return_html($quotes)
                {
+                       $return_html = '<table cellspacing="1" cellpadding="0" 
border="0" bgcolor="black"><tr><td>'
+                       . '<table cellspacing="1" cellpadding="2" border="0" 
bgcolor="white">'
+                       . '<tr><td><b>' . lang('Name') . '</b></td><td><b>' . 
lang('Symbol') . '</b></td><td align="right"><b>' . lang('Price') . 
'</b></td><td align="right">'
+                       . '<b>&nbsp;' . lang('Change') . '</b></td><td 
align="right"><b>' . lang('%') . '&nbsp;' . lang('Change') . '</b></td><td 
align="center"><b>' . lang('Date') . '</b></td><td align="center">'
+                                       . '<b>' . lang('Time') . 
'</b></td></tr>';
+ 
+                       for ($i=0;$i<count($quotes);$i++)
+                       {
+                               $q = $quotes[$i];
+                               $symbol = $q['symbol'];
+                               $name = $q['name'];
+                               $price0 = $q['price0']; // today's price
+                               $price1 = $q['price1'];
+                               $price2 = $q['price2'];
+                               $dollarchange = $q['dchange'];
+                               $percentchange = $q['pchange'];
+                               $date = $q['date'];
+                               $time = $q['time'];
+                               $volume = $q['volume'];
+ 
+                               if ($dollarchange < 0)
+                               {
+                                       $color = 'red';
+                               }
+                               else
+                               {
+                                       $color = 'green';
+                               }
+ 
+                               $return_html .= '<tr><td>' . $name . 
'</td><td>' . $symbol . '</td><td align="right">' . $price0 . '</td><td 
align="right"><font color="'
+                                                               . $color . '">' 
. $dollarchange . '</font></td><td align="right"><font color="' . $color . '">' 
. $percentchange
+                                                               . 
'</font></td><td align="center">' . $date . '</td><td align="center">' . $time 
. '</td></tr>';
+                       }
+ 
+                       $return_html .= '</table></td></tr></table>';
+                       return $return_html;
+               }
+ 
+               function return_values($quotes)
+               {
                        for ($i=0;$i<count($quotes);$i++)
                        {
                                $data[] = array
                                (
!                                       'symbol'                => 
$quotes[$i]['symbol'],
!                                       'name'                  => 
$quotes[$i]['name'],
!                                       'price0'                => 
$quotes[$i]['price0'],
!                                       'price1'                => 
$quotes[$i]['price1'],
!                                       'price2'                => 
$quotes[$i]['price2'],
                                        'dollarchange'  => 
$quotes[$i]['dchange'],
                                        'percentchange' => 
$quotes[$i]['pchange'],
***************
*** 126,144 ****
                }
  
!               function return_quotes()
!               {       
                        $stocklist = $this->bo->get_savedstocks();
                        $quotes = $this->bo->get_quotes($stocklist);
-                       return $this->return_html($quotes);
-               }
  
!               function selected_country($country = '')
!               {
!                       if (!$country)
                        {
!                               $country = $this->country;
                        }
  
!                       switch($country)
                        {
                                case 'US': $country_sel[0]=' selected'; break;
--- 163,181 ----
                }
  
!               function return_quotes($ui = 'home')
!               {
                        $stocklist = $this->bo->get_savedstocks();
                        $quotes = $this->bo->get_quotes($stocklist);
  
!                       switch($ui)
                        {
!                               case 'page':    return 
$this->return_html($quotes); break;
!                               default:                return 
$this->return_values($quotes); break;
                        }
+               }
  
!               function selected_country()
!               {
!                       switch($this->country)
                        {
                                case 'US': $country_sel[0]=' selected'; break;
***************
*** 156,164 ****
                {
                        $this->display_app_header();
!                       $this->t->set_file(array('quotes_list' => 'main.tpl'));
!                       
$this->t->set_var('country_list',$this->selected_country($this->country));
!                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index&country='
 . $this->country));
!                       $this->t->set_var('quotes',$this->return_quotes());
!                       $this->t->pfp('out','quotes_list');
                        $this->save_sessiondata();
                }
--- 193,203 ----
                {
                        $this->display_app_header();
!                       
$GLOBALS['phpgw']->template->set_file(array('quotes_list' => 'main.tpl'));
! 
!                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Stock Quotes') . ': ' . lang('display stock quotes');
!                       
$GLOBALS['phpgw']->template->set_var('country_list',$this->selected_country());
!                       
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index'));
!                       
$GLOBALS['phpgw']->template->set_var('quotes',$this->return_quotes('page'));
!                       $GLOBALS['phpgw']->template->pfp('out','quotes_list');
                        $this->save_sessiondata();
                }
***************
*** 166,170 ****
                function list_stocks()
                {
!                       $action         = get_var('action',Array('POST','GET'));
                        $stock_id       = get_var('stock_id',Array('GET'));
  
--- 205,209 ----
                function list_stocks()
                {
!                       $action         = get_var('action',Array('GET'));
                        $stock_id       = get_var('stock_id',Array('GET'));
  
***************
*** 184,201 ****
                        $this->display_app_header();
  
!                       $this->t->set_file(array('stock_list_t' => 'list.tpl'));
!                       $this->t->set_block('stock_list_t','stock_list','list');
  
!                       $this->t->set_var('lang_list',lang('Stock Quotes 
list'));
!                       $this->t->set_var('h_lang_edit',lang('Edit'));
!                       $this->t->set_var('h_lang_delete',lang('Delete'));
!                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
  
!                       if (!$country)
!                       {
!                               $country = '';
!                       }
  
!                       
$this->t->set_var('country_list',$this->selected_country($this->country));
  
                        $stocks = $this->bo->read_stocks();
--- 223,236 ----
                        $this->display_app_header();
  
!                       
$GLOBALS['phpgw']->template->set_file(array('stock_list_t' => 'list.tpl'));
!                       
$GLOBALS['phpgw']->template->set_block('stock_list_t','stock_list','list');
  
!                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Stock Quotes') . ': ' . lang('stock quotes to display');
  
!                       
$GLOBALS['phpgw']->template->set_var('h_lang_edit',lang('Edit'));
!                       
$GLOBALS['phpgw']->template->set_var('h_lang_delete',lang('Delete'));
!                       
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
  
!                       
$GLOBALS['phpgw']->template->set_var('country_list',$this->selected_country($this->country));
  
                        $stocks = $this->bo->read_stocks();
***************
*** 207,211 ****
                                        
$this->nextmatchs->template_alternate_row_color(&$this->t);
  
!                                       $this->t->set_var(array
                                        (
                                                'ssymbol' => 
$GLOBALS['phpgw']->strip_html($stock['symbol']),
--- 242,246 ----
                                        
$this->nextmatchs->template_alternate_row_color(&$this->t);
  
!                                       
$GLOBALS['phpgw']->template->set_var(array
                                        (
                                                'ssymbol' => 
$GLOBALS['phpgw']->strip_html($stock['symbol']),
***************
*** 214,231 ****
                                        ));
  
!                                       
$this->t->set_var('delete',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks&action=delete&stock_id='
!                                                                               
                                                                . 
$stock['id']));
! 
!                                       
$this->t->set_var('edit',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.edit_stock&stock_id='
!                                                                               
                                                        . $stock['id']));
! 
!                                       $this->t->fp('list','stock_list',True);
                                }
                        }
!                       $link_data['menuaction'] = 'stocks.ui.add_stock';
!                       
$this->t->set_var('addurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
!                       
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index'));
                        $this->save_sessiondata();
!                       $this->t->pfp('out','stock_list_t',True);
                }
  
--- 249,269 ----
                                        ));
  
!                                       $link_data['stock_id']  = $stock['id'];
!                                       $link_data['action']    = 'delete';
!                                       $link_data['menuaction'] = 
'stocks.ui.list_stocks';
!                                       
$GLOBALS['phpgw']->template->set_var('delete',$GLOBALS['phpgw']->link('/index.php',$link_data));
! 
!                                       $link_data['menuaction'] = 
'stocks.ui.edit_stock';
!                                       unset($link_data['action']);
!                                       
$GLOBALS['phpgw']->template->set_var('edit',$GLOBALS['phpgw']->link('/index.php',$link_data));
!                                       
$GLOBALS['phpgw']->template->fp('list','stock_list',True);
                                }
                        }
!                       $link_data['menuaction'] = 'stocks.ui.edit_stock';
!                       unset($link_data['stock_id']);
!                       
$GLOBALS['phpgw']->template->set_var('addurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
!                       
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.index'));
                        $this->save_sessiondata();
!                       
$GLOBALS['phpgw']->template->pfp('out','stock_list_t',True);
                }
  
***************
*** 239,339 ****
                        );
  
!                       if ($prefs['submit'])
                        {
                                $this->bo->save_prefs($prefs);
!                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
!                               $GLOBALS['phpgw']->common->phpgw_exit();
                        }
  
                        $GLOBALS['phpgw']->common->phpgw_header();
! 
!                       $this->t->set_file(array('stock_prefs' => 
'preferences.tpl'));
  
                        $this->set_app_langs();
- 
                        $prefs = $this->bo->read_prefs();
  
!                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
!                       $this->t->set_var('lang_action',lang('Stock Quote 
preferences'));
!                       $this->t->set_var('lang_def_country',lang('Default 
country'));
!                       $this->t->set_var('lang_display',lang('Display stocks 
on main screen is enabled'));
!                       $this->t->set_var('mainscreen', '<input type="checkbox" 
name="prefs[mainscreen]" value="True"'
                                                                                
. ($prefs['mainscreen'] == 'enabled'?' checked':'') . '>');
  
!                       
$this->t->set_var('country_list',$this->selected_country($prefs['country']));
  
!                       
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
!                       $this->t->pfp('out','stock_prefs',True);
!               }
! 
!               function add_stock()
!               {
!                       $submit         = get_var('submit',Array('POST'));
!                       $values         = get_var('values',Array('POST'));
! 
!                       if ($submit)
!                       {
!                               $values['symbol']       = 
strtoupper($values['symbol']);
!                               $values['access']       = 'public';
!                               $this->bo->save_stock($values);
!                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks'));
!                               $GLOBALS['phpgw']->common->phpgw_exit();
!                       }
! 
!                       $this->display_app_header();
!                       $this->t->set_file(array('edit' => 
'preferences_edit.tpl'));
!                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.add_stock'));
!                       $this->t->set_var('h_lang_edit',lang('Add stock'));
!                       
$this->t->set_var('country_list',$this->selected_country($country));
!                       $this->t->set_var('symbol',$symbol);
!                       $this->t->set_var('name',$name);
! 
!                       $this->t->pfp('out','edit');
                }
  
                function edit_stock()
                {
-                       $submit         = get_var('submit',Array('POST'));
                        $values         = get_var('values',Array('POST'));
!                       $stock_id       = get_var('stock_id',Array('POST'));
  
                        $link_data = array
                        (
!                               'menuaction'    => 'stocks.ui.list_stocks',
!                               'stock_id'              => $stock_id
                        );
  
!                       if (! $stock_id)
!                       {
!                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
!                               $GLOBALS['phpgw']->common->phpgw_exit();
!                       }
! 
!                       if ($submit)
                        {
                                $values['symbol']       = 
strtoupper($values['symbol']);
                                $values['access']       = 'public';
-                               $values['id']           = $stock_id;
  
                                $this->bo->save_stock($values);
!                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
!                               $GLOBALS['phpgw']->common->phpgw_exit();
                        }
  
                        $this->display_app_header();
  
!                       $this->t->set_file(array('edit' => 
'preferences_edit.tpl'));
!                       $link_data['menuaction'] = 'stocks.ui.edit_stock';
!                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
  
!                       $this->t->set_var('hidden_vars','<input type="hidden" 
name="stock_id" value="' . $stock_id . '">' . "\n");
!                       $this->t->set_var('h_lang_edit',lang('Edit stock'));
  
!                       $stock = $this->bo->read_single($stock_id);
!                       
$this->t->set_var('country_list',$this->selected_country($stock['country']));
!                       
$this->t->set_var('symbol',$GLOBALS['phpgw']->strip_html($stock['symbol']));
!                       
$this->t->set_var('name',$GLOBALS['phpgw']->strip_html($stock['name']));
  
!                       $this->t->pfp('out','edit');
                }
        }
--- 277,353 ----
                        );
  
!                       if ($prefs['save'])
                        {
                                $this->bo->save_prefs($prefs);
!                               
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
                        }
  
                        $GLOBALS['phpgw']->common->phpgw_header();
!                       
$GLOBALS['phpgw']->template->set_file(array('stock_prefs' => 
'preferences.tpl'));
!                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Stock Quotes') . ': ' . lang('preferences');
  
                        $this->set_app_langs();
                        $prefs = $this->bo->read_prefs();
  
!                       
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
!                       
$GLOBALS['phpgw']->template->set_var('lang_def_country',lang('Default 
country'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_display',lang('Display stocks on 
main screen is enabled'));
!                       $GLOBALS['phpgw']->template->set_var('mainscreen', 
'<input type="checkbox" name="prefs[mainscreen]" value="True"'
                                                                                
. ($prefs['mainscreen'] == 'enabled'?' checked':'') . '>');
  
!                       
$GLOBALS['phpgw']->template->set_var('country_list',$this->selected_country($prefs['country']));
  
!                       
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/preferences/index.php'));
!                       
$GLOBALS['phpgw']->template->pfp('out','stock_prefs',True);
                }
  
                function edit_stock()
                {
                        $values         = get_var('values',Array('POST'));
!                       $stock_id       = 
get_var('stock_id',Array('GET','POST'));
  
                        $link_data = array
                        (
!                               'menuaction'    => 'stocks.ui.edit_stock',
!                               'country'               => $this->country
                        );
  
!                       if ($values['save'])
                        {
+                               if($stock_id)
+                               {
+                                       $values['id']           = $stock_id;
+                               }
                                $values['symbol']       = 
strtoupper($values['symbol']);
                                $values['access']       = 'public';
  
                                $this->bo->save_stock($values);
!                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=stocks.ui.list_stocks');
                        }
  
                        $this->display_app_header();
  
!                       $GLOBALS['phpgw']->template->set_file(array('edit' => 
'preferences_edit.tpl'));
! 
!                       
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
  
!                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Stock Quotes') . ': ' . ($stock_id?lang('edit stock quote'):lang('add 
stock quote'));
  
!                       
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" 
name="stock_id" value="' . $stock_id . '">' . "\n");
  
!                       if ($stock_id)
!                       {
!                               $stock = $this->bo->read_single($stock_id);
!                               $this->country  = $stock['country'];
!                               $link_data['stock_id']  = $stock_id;
!                       }
! 
!                       
$GLOBALS['phpgw']->template->set_var('country_list',$this->selected_country($this->country));
!                       
$GLOBALS['phpgw']->template->set_var('symbol',$GLOBALS['phpgw']->strip_html($stock['symbol']));
!                       
$GLOBALS['phpgw']->template->set_var('name',$GLOBALS['phpgw']->strip_html($stock['name']));
! 
!                       
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php','menuaction=stocks.ui.list_stocks'));
!                       $this->save_sessiondata();
!                       $GLOBALS['phpgw']->template->pfp('out','edit');
                }
        }





reply via email to

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