phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: property/inc class.boinvestment.inc.php,1.2,1.3


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.boinvestment.inc.php,1.2,1.3 class.soinvestment.inc.php,1.2,1.3class.uiinvestment.inc.php,1.2,1.3
Date: Wed, 22 Jan 2003 15:16:38 -0500

Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv28795/inc

Modified Files:
        class.boinvestment.inc.php class.soinvestment.inc.php 
        class.uiinvestment.inc.php 
Log Message:
no message

Index: class.boinvestment.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.boinvestment.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.boinvestment.inc.php  22 Jan 2003 11:20:46 -0000      1.2
--- class.boinvestment.inc.php  22 Jan 2003 20:16:36 -0000      1.3
***************
*** 49,52 ****
--- 49,53 ----
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so               = 
CreateObject($this->currentapp.'.soinvestment');
+                       $this->bocommon = 
CreateObject($this->currentapp.'.bocommon');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');
  
***************
*** 148,151 ****
--- 149,201 ----
  
                        return $category_list;
+               }
+ 
+ 
+               function update_investment($values)
+               {
+                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                       $dateformat = str_replace(".","",$dateformat);
+                       $dateformat = str_replace("-","",$dateformat);
+                       $dateformat = str_replace("/","",$dateformat);
+                       $y=strpos($dateformat,'y');
+                       $d=strpos($dateformat,'d');
+                       $m=strpos($dateformat,'m');
+ 
+                       $dateparts = explode('/', $values['date']);
+ 
+ 
+                       $day = $dateparts[$d];
+                       $month = $dateparts[$m];
+                       $year = $dateparts[$y];
+                       $date = mktime (2,0,0,$month,$day,$year);
+                       $date= date($this->bocommon->dateformat,$date);
+ 
+ 
+                       $new_index=str_replace(",",".",$values['new_index']);
+ 
+                       while($entry=each($values['update']))
+                       {
+                               $local_error='';
+                               $n=$entry[0];
+ 
+                               if ($values['value'][$n])
+                               {
+ 
+                                       if ((abs($values['value'][$n])- 
abs(($values['initial_value'][$n]*$new_index)))<0)
+                                       {
+                                               $new_value=0;
+                                               
$new_index=$values['value'][$n]/$values['initial_value'][$n];
+                                       }
+                                       else
+                                       {
+                                               
$new_value=$values['value'][$n]-($values['initial_value'][$n]*$new_index);
+                                       }
+ 
+                                       
$this->so->update_investment($values['entity_id'][$n],$values['investment_id'][$n],$new_index,$new_value,$values['initial_value'][$n],$date);
+ 
+                               }
+ 
+ 
+                       }
                }
  

Index: class.soinvestment.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soinvestment.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.soinvestment.inc.php  22 Jan 2003 11:20:46 -0000      1.2
--- class.soinvestment.inc.php  22 Jan 2003 20:16:36 -0000      1.3
***************
*** 147,151 ****
                                }
  
!                               $investment[$i]['this_write_off']       = 
round(($this->db->f('index_count') * $this->db->f('initial_value')),2);
                                $i++;
                        }
--- 147,151 ----
                                }
  
!                               $investment[$i]['this_write_off']       = 
round(($this->db->f('this_index') * $this->db->f('initial_value')),2);
                                $i++;
                        }
***************
*** 153,156 ****
--- 153,173 ----
                        return $investment;
                }
+ 
+ 
+               function 
update_investment($entity_id,$invest_id,$new_index,$new_value,$initial_value,$date)
+               {
+ 
+                       $this->db->query("select max(index_count) as 
max_index_count from fm_investment_value Where entity_id= '$entity_id' and 
invest_id= '$invest_id'");
+                       $this->db->next_record();
+                       $next_index_count  = $this->db->f('max_index_count')+1;
+ 
+                       $this->db->query("update fm_investment_value set 
current_index = Null"
+                       . " WHERE entity_id= '$entity_id' and invest_id= 
'$invest_id'");
+ 
+                       $this->db->query("insert into fm_investment_value 
(entity_id, invest_id, index_count, this_index, value,initial_value, 
date,current_index) "
+                       . " values ('$entity_id', 
'$invest_id','$next_index_count', '$new_index', 
'$new_value','$initial_value','$date', '1')");
+               }
+ 
+ 
  
                function read_single($property_id,$building_id)

Index: class.uiinvestment.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiinvestment.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.uiinvestment.inc.php  22 Jan 2003 11:20:46 -0000      1.2
--- class.uiinvestment.inc.php  22 Jan 2003 20:16:36 -0000      1.3
***************
*** 77,84 ****
                        $links = $this->bocommon->menu($sub);
                        $values         = get_var('values',array('POST'));
  
                        $investment_list = $this->bo->read();
  
! //_debug_array($values);
  
                        $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
--- 77,114 ----
                        $links = $this->bocommon->menu($sub);
                        $values         = get_var('values',array('POST'));
+                       $date           = get_var('date',array('POST'));
+ 
+                       if($date)
+                       {
+                               $values['date'] = $date;
+                       }
+ 
+                       if($values)
+                       {
+                               $errorcount = 0;
+ 
+                               if(!$date)
+                               {
+                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Please select a date !'));
+                               }
+                               if(!$values['new_index'])
+                               {
+                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Please set a new index !'));
+                               }
+ 
+                               if(!$values['update'])
+                               {
+                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Nothing to do... !'));
+                               }
+ 
+                               if(!$receipt['error'])
+                               {
+                                       
$receipt=$this->bo->update_investment($values);
+                               }
+                       }
  
                        $investment_list = $this->bo->read();
  
! _debug_array($values);
  
                        $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
***************
*** 150,153 ****
--- 180,185 ----
                        $table_update[] = array
                        (
+                               'lang_new_index'                        => 
lang('New index'),
+                               'lang_new_index_statustext'     => lang('Enter 
a new index'),
                                'dateformat'                            => 
(implode($sep,$dlarr)),
                                'link_calendar_date'            => 
'setDateField(document.form.date);top.newWin=window.open('."'.".'/'.$this->currentapp.'/inc/calendar.html'."'".','."'".'cal'."'".','."'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes'".')',
***************
*** 183,186 ****
--- 215,220 ----
                        $data = array
                        (
+                               'error'                                         
        => $receipt['error'],
+                               'message'                                       
        => $receipt['message'],
                                'links'                                         
        => $links,
                                'lang_search'                                   
=> lang('Search'),





reply via email to

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