phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: property/inc class.bobuilding.inc.php,1.1,1.2 cl


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.bobuilding.inc.php,1.1,1.2 class.bocommon.inc.php,1.6,1.7 class.boinvestment.inc.php,1.3,1.4 class.socommon.inc.php,1.3,1.4 class.soinvestment.inc.php,1.3,1.4 class.uiinvestment.inc.php,1.3,1.4
Date: Sun, 26 Jan 2003 07:27:52 -0500

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

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

Index: class.bobuilding.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.bobuilding.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.bobuilding.inc.php    11 Dec 2002 19:31:22 -0000      1.1
--- class.bobuilding.inc.php    26 Jan 2003 12:27:49 -0000      1.2
***************
*** 49,52 ****
--- 49,53 ----
                        $this->so               = 
CreateObject($this->currentapp.'.sobuilding');
                        $this->socommon = 
CreateObject($this->currentapp.'.socommon');
+                       $this->bocommon = 
CreateObject($this->currentapp.'.bocommon');
  
                        $start  = get_var('start',array('POST','GET'));
***************
*** 134,141 ****
                        {
  
!                               
$building['location_code']=$this->socommon->location_code($building['property_id'],$building['building_id']);
                                $message = $this->so->add($building);
- //print_r($ids);
- //print_();
                        }
                        return $message;
--- 135,140 ----
                        {
  
!                               
$building['location_code']=$this->bocommon->location_code($building['property_id'],$building['building_id']);
                                $message = $this->so->add($building);
                        }
                        return $message;

Index: class.bocommon.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.bocommon.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.bocommon.inc.php      22 Jan 2003 11:20:46 -0000      1.6
--- class.bocommon.inc.php      26 Jan 2003 12:27:49 -0000      1.7
***************
*** 137,140 ****
--- 137,159 ----
  
  
+               function date_array($date)
+               {
+                       $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('/', $date);
+                       $date_array['day']              = $dateparts[$d];
+                       $date_array['month']    = $dateparts[$m];
+                       $date_array['year']             = $dateparts[$y];
+ 
+                       return $date_array;
+               }
+ 
+ 
                function list_methods($_type='xmlrpc')
                {
***************
*** 420,423 ****
--- 439,463 ----
                }
  
+               function 
location_code($property_id='',$building_id='',$entrance_id='',$apartment='')
+               {
+ 
+                       $location_code=$property_id;
+ 
+                       if($building_id)
+                       {
+                               $location_code.= "-".$building_id;
+                       }
+                       if($entrance_id)
+                       {
+                               $location_code.= "-".$entrance_id;
+                       }
+                       if($apartment)
+                       {
+                               $location_code.= "-".$apartment;
+                       }
+ 
+                       return $location_code;
+ 
+               }
  
                function select_part_of_town($format='',$selected='')

Index: class.boinvestment.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.boinvestment.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.boinvestment.inc.php  22 Jan 2003 20:16:36 -0000      1.3
--- class.boinvestment.inc.php  26 Jan 2003 12:27:49 -0000      1.4
***************
*** 59,62 ****
--- 59,63 ----
                        $cat_id = get_var('cat_id',array('POST','GET'));
                        $part_of_town_id        = 
get_var('part_of_town_id',array('POST','GET'));
+                       $allrows        = 
get_var('allrows',array('POST','GET'));
  
                        if ($start)
***************
*** 93,96 ****
--- 94,102 ----
                                $this->part_of_town_id = $part_of_town_id;
                        }
+                       if(isset($allrows))
+                       {
+                               $this->allrows = $allrows;
+                       }
+ 
                }
  
***************
*** 151,175 ****
                }
  
  
                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']);
  
--- 157,247 ----
                }
  
+               function write_off_period_list($selected='')
+               {
+ 
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
+ 
+ 
+                       $categories= $this->so->write_off_period_list();
+ 
+                       while (is_array($categories) && list(,$category) = 
each($categories))
+                       {
+                               $sel_category = '';
+                               if ($category['period']==$selected)
+                               {
+                                       $sel_category = 'selected';
+                               }
+ 
+                               $category_list[] = array
+                               (
+                                       'cat_id'        => $category['period'],
+                                       'name'          => $category['period'],
+                                       'selected'      => $sel_category
+                               );
+                       }
+ 
+                       for ($i=0;$i<count($category_list);$i++)
+                       {
+                               if ($category_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($category_list[$i]['selected']);
+                               }
+                       }
+ 
+                       return $category_list;
+               }
+ 
+ 
+ 
+ 
+               function save_investment($values)
+               {
+ //_debug_array($values);
+                       
$date_array=$this->bocommon->date_array($values['date']);
+ 
+                       $date = mktime 
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+                       $values['date']= 
date($this->bocommon->dateformat,$date);
+ 
+                       $values['initial_value']        = 
abs($values['initial_value']);
+ 
+                       if($values['type']=='funding')
+                       {
+                               $values['initial_value'] = 
-$values['initial_value'];
+                       }
+ 
+                       if($values['new_period'])
+                       {
+                               $values['period'] = $values['new_period'];
+                               unset($values['new_period']);
+                       }
+ 
+                       
$values['location_code']=$this->bocommon->location_code($values['property_id'],$values['building_id'],$values['entrance_id'],$values['apartment_id']);
+ 
+                       if($values['equipment_id'])
+                       {
+                               $values['entity_id']    = 
$values['equipment_id'];
+                               $values['entity_type']  ='equipment';
+                       }
+                       else
+                       {
+                               $values['entity_id']    = 
$values['location_code'];
+                               $values['entity_type']  ='property';
+                       }
+ 
+ 
+                       $receipt=$this->so->save_investment($values);
+ 
+                       return $receipt;
+               }
+ 
  
                function update_investment($values)
                {
  
+                       
$date_array=$this->bocommon->date_array($values['date']);
  
!                       $date = mktime 
(2,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
                        $date= date($this->bocommon->dateformat,$date);
  
                        $new_index=str_replace(",",".",$values['new_index']);
  
***************
*** 246,254 ****
  
  
!               function read_single($property_id,$building_id)
                {
!                       return 
$this->so->read_single($property_id,$building_id);
                }
  
                function select_part_of_town($part_of_town_id)
                {
--- 318,331 ----
  
  
!               function read_single($entity_id,$investment_id)
                {
!                       $history        = 
$this->so->read_single($entity_id,$investment_id,$this->start,$this->allrows);
! 
!                       $this->total_records = $this->so->total_records;
! 
!                       return $history;
                }
  
+ 
                function select_part_of_town($part_of_town_id)
                {
***************
*** 256,291 ****
                }
  
-               function save($building,$action='')
-               {
-                       if ($building['access'])
-                       {
-                               $building['access'] = 'private';
-                       }
-                       else
-                       {
-                               $building['access'] = 'public';
-                       }
- 
-                       if ($action=='edit')
-                       {
-                               if ($building['building_id'] != 0)
-                               {
-                                       $message = $this->so->edit($building);
-                               }
-                       }
-                       else
-                       {
- 
-                               
$building['location_code']=$this->socommon->location_code($building['property_id'],$building['building_id']);
-                               $message = $this->so->add($building);
- //print_r($ids);
- //print_();
-                       }
-                       return $message;
-               }
  
!               function delete($property_id,$building_id)
                {
!                       $this->so->delete($property_id,$building_id);
                }
        }
--- 333,340 ----
                }
  
  
!               function delete($entity_id,$investment_id,$index_count)
                {
!                       
$this->so->delete($entity_id,$investment_id,$index_count);
                }
        }

Index: class.socommon.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.socommon.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.socommon.inc.php      2 Jan 2003 22:03:57 -0000       1.3
--- class.socommon.inc.php      26 Jan 2003 12:27:49 -0000      1.4
***************
*** 94,121 ****
                }
  
- 
- 
-               function 
location_code($property_id='',$building_id='',$entrance_id='',$apartment='')
-               {
- 
-                       $location_code=$property_id;
- 
-                       if($building_id)
-                       {
-                               $location_code.= "-".$building_id;
-                       }
-                       if($entrance_id)
-                       {
-                               $location_code.= "-".$entrance_id;
-                       }
-                       if($apartment)
-                       {
-                               $location_code.= "-".$apartment;
-                       }
- 
-                       return $location_code;
- 
-               }
- 
                function next_id($table='')
                {
--- 94,97 ----

Index: class.soinvestment.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soinvestment.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.soinvestment.inc.php  22 Jan 2003 20:16:36 -0000      1.3
--- class.soinvestment.inc.php  26 Jan 2003 12:27:49 -0000      1.4
***************
*** 106,111 ****
                        if ($cat_id=='equipment')
                        {
!                               $sql = "SELECT fm_investment.entity_id, 
fm_investment.descr as descr, fm_investment_value.invest_id,initial_value,"
!                               . " fm_investment_value.value, 
fm_investment_value.date, fm_investment_value.this_index,fm_equipment.descr as 
equipment_descr, fm_equipment_type.name as equipment_name, "
                                . " fm_investment_value.index_count "
                                . " FROM fm_investment $this->join "
--- 106,111 ----
                        if ($cat_id=='equipment')
                        {
!                               $sql = "SELECT 
fm_investment.location_code,fm_investment.entity_id, fm_investment.descr as 
descr, fm_investment_value.invest_id,initial_value,"
!                               . " fm_investment_value.value, 
fm_investment_value.date, fm_investment_value.this_index,fm_equipment.descr as 
equipment_descr, fm_equipment_type.num as equipment_name, "
                                . " fm_investment_value.index_count "
                                . " FROM fm_investment $this->join "
***************
*** 117,120 ****
--- 117,123 ----
                                . " ORDER BY fm_investment.entity_id ";
  
+ 
+ 
+ 
                        }
  
***************
*** 127,130 ****
--- 130,134 ----
                        {
                                $investment[$i]['counter']                      
= $i;
+                               $investment[$i]['location_code']        = 
$this->db->f('location_code');
                                $investment[$i]['entity_id']            = 
$this->db->f('entity_id');
                                $investment[$i]['investment_id']        = 
$this->db->f('invest_id');
***************
*** 137,141 ****
                                $investment[$i]['index_count']          = 
$this->db->f('index_count');
                                $investment[$i]['date']                         
= $this->db->f('date');
-                               $investment[$i]['equipment_descr']      = 
$this->db->f('equipment_descr');
                                if ($cat_id=='property')
                                {
--- 141,144 ----
***************
*** 150,157 ****
--- 153,210 ----
                                $i++;
                        }
+ 
+                       if($investment && $cat_id=='equipment')
+                       {
+                               for ($i=0; $i<count($investment); $i++)
+                               {
+ 
+                                       $objekt_id = 
substr($investment[$i]['location_code'],0,4);
+ 
+                                       $this->db->query("select 
bydel,omraade_id from boei_objekt $this->join boei_bydel on 
boei_objekt.bydel_id=boei_bydel.bydel_id Where objekt_id= '$objekt_id'");
+                                       $this->db->next_record();
+                                       $investment[$i]['district_id'] = 
$this->db->f('omraade_id');
+                                       $investment[$i]['part_of_town'] = 
$this->db->f('bydel');
+ 
+                               }
+ 
+ 
+                       }
+ 
+ 
+ 
  //_debug_array($investment);
                        return $investment;
                }
  
+               function save_investment($values)
+               {
+ //_debug_array($values);
+ 
+                   $period                     = $values['period'];
+                   $type                       = $values['funding'];
+                   $initial_value      = $values['initial_value'];
+                   $descr                      = 
$this->db->db_addslashes($values['descr']);
+                   $date                       = $values['date'];
+                   $location_code      = $values['location_code'];
+                   $entity_id          = $values['entity_id'];
+                   $entity_type        = $values['entity_type'];
+ 
+ 
+                       $this->db->query("select max(invest_id) as 
max_invest_id from fm_investment Where entity_id= '$entity_id'");
+                       $this->db->next_record();
+                       $next_invest_id  = $this->db->f('max_invest_id')+1;
+ 
+                       $this->db->query("insert into fm_investment (entity_id, 
invest_id,entity_type,location_code,writeoff_year, descr) "
+                       . " values ('$entity_id', 
'$next_invest_id','$entity_type','$location_code','$period','$descr')");
+ 
+                       $this->db->query("insert into fm_investment_value 
(entity_id, invest_id, index_count, this_index, current_index, 
value,initial_value, date) "
+                       . " values ('$entity_id', '$next_invest_id','1', '0', 
'1','$initial_value','$initial_value','$date')");
+ 
+ 
+                       $receipt['message'][0]=array('msg' => lang('Investment 
added !'));
+                       $receipt['message'][1]=array('msg' => lang('Entity ID 
'). $entity_id);
+                       $receipt['message'][2]=array('msg' => lang('Investment 
ID:'). $next_invest_id);
+                       return $receipt;
+               }
  
                function 
update_investment($entity_id,$invest_id,$new_index,$new_value,$initial_value,$date)
***************
*** 171,197 ****
  
  
!               function read_single($property_id,$building_id)
                {
!                       $sql = "SELECT * FROM boei_bygg  where 
objekt_id='$property_id' and bygg_id='$building_id'";
  
!                       $this->db->query($sql,__LINE__,__FILE__);
  
!                       if ($this->db->next_record())
                        {
!                               $building['property_id']                = 
(int)$this->db->f('objekt_id');
!                               $building['building_id']                = 
(int)$this->db->f('bygg_id');
!                               $building['owner']                              
= $this->db->f('owner');
!                               $building['name']                               
= stripslashes($this->db->f('byggnavn'));
!                               $building['generaladdress']             = 
stripslashes($this->db->f('generelladresse'));
!                               $building['access']                             
= $this->db->f('access');
!                               $building['date']                               
= $this->db->f('entry_date');
!                               $building['cat_id']                             
= (int)$this->db->f('cat_id');
!                               $building['omraade_id']                 = 
$this->db->f('omraade_id');
!                               $building['part_of_town']               = 
$this->db->f('bydel');
!                               $building['building_type_id']   = 
$this->db->f('building_type_id');
!                               $building['location_code']              = 
$this->db->f('location_code');
  
!                               return $building;
                        }
                }
  
--- 224,281 ----
  
  
!               function read_single($entity_id,$investment_id,$start,$allrows)
                {
!                       if (!$start)
!                       {
!                               $start=0;
!                       }
! 
  
!                       $sql = "SELECT index_count, 
this_index,current_index,value, initial_value, date  "
!                       . " FROM fm_investment_value Where entity_id= 
'$entity_id' and invest_id= '$investment_id' order by index_count";
  
!                       $this->db2->query($sql,__LINE__,__FILE__);
!                       $this->total_records = $this->db2->num_rows();
! 
!                       if(!$allrows)
                        {
!                               
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
!                       }
!                       else
!                       {
!                               $this->db->query($sql,__LINE__,__FILE__);
!                       }
! 
!                       $i=0;
!                       while ($this->db->next_record())
!                       {
!                               $investment[$i]['descr']                        
= $this->db->f('descr');
!                               $investment[$i]['initial_value']        = 
$this->db->f('initial_value');
!                               $investment[$i]['value']                        
= $this->db->f('value');
!                               $investment[$i]['this_index']           = 
$this->db->f('this_index');
!                               $investment[$i]['current_index']        = 
$this->db->f('current_index');
!                               $investment[$i]['index_count']          = 
$this->db->f('index_count');
!                               $investment[$i]['date']                         
= $this->db->f('date');
!                               $investment[$i]['this_write_off']       = 
round(($this->db->f('this_index') * $this->db->f('initial_value')),2);
!                               $i++;
!                       }
! 
!                       return $investment;
!               }
! 
! 
!               function write_off_period_list()
!               {
!                       $this->db->query("SELECT writeoff_year FROM 
fm_investment GROUP BY writeoff_year ",__LINE__,__FILE__);
  
!                       while ($this->db->next_record())
!                       {
!                               $period_list[] = Array(
!                                       'period'        => 
$this->db->f('writeoff_year')
!                               );
                        }
+ 
+                       return $period_list;
+ 
                }
  
***************
*** 223,229 ****
                }
  
!               function delete($property_id,$building_id )
                {
!                       $this->db->query('DELETE FROM boei_bygg WHERE 
objekt_id=' . $property_id . ' and bygg_id=' . $building_id,__LINE__,__FILE__);
                }
        }
--- 307,326 ----
                }
  
!               function delete($entity_id,$invest_id,$index_count)
                {
!                       if ($index_count==1)
!                       {
!                               $this->db->query("update fm_investment_value 
set current_index = '0', this_index=Null, 
value=Null,initial_value=Null,date=Null  where entity_id='$entity_id' and 
invest_id= '$invest_id' and index_count= '1'");
!                       }
!                       else
!                       {
!                               $this->db->query("delete from 
fm_investment_value where entity_id='$entity_id' and invest_id= '$invest_id' 
and index_count= '$index_count'");
! 
!                               $new_current= $index_count -1;
! 
!                               $this->db->query("update fm_investment_value 
set current_index = '1' where entity_id='$entity_id' and invest_id= 
'$invest_id' and index_count= '$new_current'");
!                       }
! 
!       //              $this->db->query("DELETE FROM fm_investment_value WHERE 
entity_id= '$entity_id'  and invest_id='$invest_id' and 
index_count='$index_count'",__LINE__,__FILE__);
                }
        }

Index: class.uiinvestment.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiinvestment.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.uiinvestment.inc.php  22 Jan 2003 20:16:36 -0000      1.3
--- class.uiinvestment.inc.php  26 Jan 2003 12:27:49 -0000      1.4
***************
*** 23,27 ****
                (
                        'index'  => True,
!                       'view'   => True,
                        'add'   => True,
                        'delete' => True
--- 23,27 ----
                (
                        'index'  => True,
!                       'history'   => True,
                        'add'   => True,
                        'delete' => True
***************
*** 48,51 ****
--- 48,52 ----
                        $this->cat_id                           = 
$this->bo->cat_id;
                        $this->part_of_town_id          = 
$this->bo->part_of_town_id;
+                       $this->allrows                          = 
$this->bo->allrows;
                        $this->admin_invoice            = 
$this->bocommon->admin_invoice;
                }
***************
*** 61,65 ****
                                'filter'                        => 
$this->filter,
                                'cat_id'                        => 
$this->cat_id,
!                               'part_of_town_id'       => 
$this->part_of_town_id
                        );
                        $this->bocommon->save_sessiondata($data);
--- 62,67 ----
                                'filter'                        => 
$this->filter,
                                'cat_id'                        => 
$this->cat_id,
!                               'part_of_town_id'       => 
$this->part_of_town_id,
!                               'this->allrows'         => $this->allrows
                        );
                        $this->bocommon->save_sessiondata($data);
***************
*** 86,114 ****
                        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']);
--- 88,97 ----
                        if($values)
                        {
!                               $receipt=$this->update_investment($values);
                        }
  
                        $investment_list = $this->bo->read();
  
! //_debug_array($values);
  
                        $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
***************
*** 138,142 ****
                                        'this_index'                            
=> $investment['this_index'],
                                        'index_count'                           
=> $investment['index_count'],
-                                       'equipment_descr'                       
=> $investment['equipment_descr'],
                                        'entity_name'                           
=> $investment['entity_name'],
                                        'this_write_off'                        
=> number_format($investment['this_write_off'], 0, ',', ' '),
--- 121,124 ----
***************
*** 189,194 ****
                                'lang_date_statustext'          => lang('Select 
the date for the update'),
                                'lang_update'                           => 
lang('Update'),
!                               'lang_update_statustext'        => lang('update 
selected investments'),
!                               'update_action'                         => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.edit')
                        );
  
--- 171,175 ----
                                'lang_date_statustext'          => lang('Select 
the date for the update'),
                                'lang_update'                           => 
lang('Update'),
!                               'lang_update_statustext'        => lang('update 
selected investments')
                        );
  
***************
*** 257,364 ****
  
                                'table_update'                                  
=> $table_update,
                                'table_add'                                     
        => $table_add
                        );
  
- //print_r($data).'<br>';
- //print_($menu);
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                        $this->save_sessiondata();
                }
  
!               function edit()
                {
!                       $entity_id = get_var('entity_id',array('GET'));
!                       $investment_id = 
get_var('investment_id',array('POST','GET'));
!                       $values         = get_var('values',array('POST'));
  
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('investment',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
  
!                       if ($values['save'])
                        {
!                               if($investment_id)
!                               {
!                                       $values['entity_id']=$entity_id;
!                                       $values['investment_id']=$investment_id;
!                                       $action='edit';
!                               }
!                               else
!                               {
!                                       $entity_id =    $values['entity_id'];
!                                       $investment_id =        
$values['investment_id'];
!                               }
  
!                               $message = $this->bo->save($values,$action);
                        }
  
!                       if ($investment_id)
                        {
!                               $investment = 
$this->bo->read_single($entity_id,$investment_id);
! //print_r($investment).'<br>';
! //print_($investment).'<br>';
!                               $function_msg = lang('edit investment');
                        }
!                       else
                        {
!                               $function_msg = lang('add investment');
                        }
  
!                       if ($investment['cat_id'] > 0)
                        {
!                               $this->cat_id = $investment['cat_id'];
                        }
!                       if ($investment['part_of_town_id'] > 0)
                        {
!                               $this->part_of_town_id = 
$investment['part_of_town_id'];
                        }
  
                        $link_data = array
                        (
!                               'menuaction'    => 
$this->currentapp.'.uiinvestment.edit',
!                               'entity_id'     => $entity_id,
!                               'investment_id' => $investment_id
                        );
  
                        $data = array
                        (
                                'appname'                                       
        => lang('investment'),
!                               'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
!                               'lang_entity_id'                                
=> lang('Property ID'),
!                               'lang_investment_id'                            
=> lang('investment ID'),
                                'lang_name'                                     
        => lang('name'),
-                               'lang_generaladdress'                   => 
lang('General Address'),
-                               'lang_generellinfo'                             
=> lang('General Info'),
-                               'lang_category'                                 
=> lang('category'),
-                               'lang_access'                                   
=> lang('private'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
!                               'value_entity_id'                               
=> $entity_id,
!                               'value_investment_id'                           
=> $investment_id,
!                               'value_name'                                    
=> $investment['name'],
!                               'value_generaladdress'                  => 
$investment['generaladdress'],
!                               'value_access'                                  
=> $investment['access'],
!                               'value_cat'                                     
        => $investment['cat'],
!                               'message'                                       
        => $message,
!                               'lang_name_statustext'                  => 
lang('Enter the name of the investment'),
!                               'lang_entity_id_statustext'     => lang('Enter 
Property ID'),
!                               'lang_investment_id_statustext' => lang('Enter 
investment ID'),
!                               'lang_generaladdress_statustext'=> lang('Enter 
the general address'),
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the investment'),
!                               'lang_access_off_statustext'    => lang('The 
investment is public. If the investment should be private, check this box'),
!                               'lang_access_on_statustext'             => 
lang('The investment is private. If the investment should be public, uncheck 
this box'),
!                               'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the investment belongs to. To do not use a category 
select NO CATEGORY'),
!                               'select_name'                                   
=> 'values[cat_id]',
!                               'lang_town_statustext'                  => 
lang('Select the part of town the investment belongs to. To do not use a part 
of town -  select NO PART OF TOWN'),
!                               'lang_part_of_town'                             
=> lang('Part of town'),
!                               'lang_no_part_of_town'                  => 
lang('No part of town'),
!                               'cat_list'                                      
        => $this->cats->formatted_xslt_list(array('format' => 
'select','selected' => $this->cat_id,'globals' => True)),
!                               'part_of_town_list'                             
=> $this->bocommon->select_part_of_town('select',$this->part_of_town_id),
!                               'select_name_part_of_town'              => 
'values[part_of_town_id]',
!                               'omraade_id'                                    
=> $investment['omraade_id'],
!                               'part_of_town'                                  
=> $investment['part_of_town'],
!                               'investment_type_id'                            
=> $investment['investment_type_id'],
                                'location_code'                                 
=> $investment['location_code'],
                                'value_generellinfo'                    => 
$investment['generellinfo']
--- 238,564 ----
  
                                'table_update'                                  
=> $table_update,
+                               'update_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
                                'table_add'                                     
        => $table_add
                        );
  
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
                        $this->save_sessiondata();
                }
  
!               function update_investment($values='')
                {
! //_debug_array($values);
  
!                       $errorcount = 0;
  
!                       if(!$values['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);
                        }
+                       return $receipt;
+               }
+ 
+               function history()
+               {
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('investment',
+                                                                               
'menu',
+                                                                               
'nextmatchs',
+                                                                               
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));
  
!                       $sub                    = 
get_var('sub',array('POST','GET'));
!                       $links                  = $this->bocommon->menu($sub);
!                       $values                 = 
get_var('values',array('POST'));
!                       $date                   = 
get_var('date',array('POST','GET'));
!                       $entity_type    = 
get_var('entity_type',array('POST','GET'));
!                       $entity_id              = 
get_var('entity_id',array('POST','GET'));
!                       $investment_id  = 
get_var('investment_id',array('POST','GET'));
! 
!                       if($date)
                        {
!                               $values['date'] = $date;
                        }
! //_debug_array($values);
! 
!                       if($values)
                        {
!                               $receipt= $this->update_investment($values);
                        }
  
!                       $investment_list = 
$this->bo->read_single($entity_id,$investment_id);
! //_debug_array($investment_list);
! 
! 
!                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
!                       $sep = '/';
!                       $dlarr[strpos($dateformat,'y')]                 = 'Y';
!                       $dlarr[strpos($dateformat,'m')]                 = 'm';
!                       $dlarr[strpos($dateformat,'d')]                 = 'd';
!                       ksort($dlarr);
!                       $dateformat                                             
                = (implode($sep,$dlarr));
! 
!                       while (is_array($investment_list) && list(,$investment) 
= each($investment_list))
                        {
! 
!                               $content[] = array
!                               (
!                                       'date'                                  
        => date($dateformat,strtotime($investment['date'])),
!                                       'initial_value_ex'                      
=> $investment['initial_value'],
!                                       'initial_value'                         
=> number_format($investment['initial_value'], 0, ',', ' '),
!                                       'value_ex'                              
        => $investment['value'],
!                                       'value'                                 
        => number_format($investment['value'], 0, ',', ' '),
!                                       'this_index'                            
=> $investment['this_index'],
!                                       'current_index'                         
=> $investment['current_index'],
!                                       'index_count'                           
=> $investment['index_count'],
!                                       'this_write_off'                        
=> number_format($investment['this_write_off'], 0, ',', ' '),
!                                       'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
 . $entity_id.'&investment_id=' . $investment_id.'&index_count=' . 
$investment['index_count'].'&entity_type='.$entity_type),
!                                       'lang_delete'                           
=> lang('Delete'),
!                                       'lang_delete_statustext'        => 
lang('Delete last entry'),
!                                       'is_admin'                              
        => $this->admin_invoice
!                               );
! 
                        }
! 
! //_debug_array($content);
!                       $table_header[] = array
!                       (
!                               'lang_initial_value'    => lang('Initial 
value'),
!                               'lang_value'                    => 
lang('Value'),
!                               'lang_last_index'               => lang('Last 
index'),
!                               'lang_write_off'                => lang('Write 
off'),
!                               'lang_date'                             => 
lang('Date'),
!                               'lang_index_count'              => lang('Index 
count'),
!                               'lang_delete'                   => 
lang('Delete')
!                       );
! 
! 
!                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
!                       $dlarr[strpos($dateformat,'y')]                 = 
'yyyy';
!                       $dlarr[strpos($dateformat,'m')]                 = 'MM';
!                       $dlarr[strpos($dateformat,'d')]                 = 'DD';
!                       ksort($dlarr);
! 
! 
!                       $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'".')',
!                               'calendar_gif'                          => 
'./'.$this->currentapp.'/templates/default/images/calendar.gif',
!                               'calendar_source'                       => 
'./'.$this->currentapp.'/inc/calendar.js',
!                               'lang_popup_calendar'           => lang('Popup 
Calendar'),
!                               'lang_date_statustext'          => lang('Select 
the date for the update'),
!                               'lang_update'                           => 
lang('Update'),
!                               'lang_update_statustext'        => lang('update 
selected investments')
!                       );
! 
!                       $table_done[] = array
!                       (
!                               'lang_done'                             => 
lang('done'),
!                               'lang_done_statustext'  => lang('Back to 
investment list '),
!                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index')
!                       );
! 
!                       $link_data = array
!                       (
!                               'menuaction'            => 
$this->currentapp.'.uiinvestment.index',
!                               'order'                         => $this->order,
!                               'sort'                          => $this->sort,
!                               'cat_id'                        => 
$this->cat_id,
!                               'part_of_town_id'       => 
$this->part_of_town_id,
!                               'sub'                           => $this->sub,
!                               'query'                         => $this->query,
!                               'start'                         => $this->start,
!                               'filter'                        => 
$this->filter,
!                               'entity_type'           => $entity_type
!                       );
! 
! 
!                       if(!$this->allrows)
!                       {
!                               $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
!                       }
!                       else
!                       {
!                               $record_limit   = $this->bo->total_records;
!                       }
! 
!                       $data = array
!                       (
!                               'error'                                         
        => $receipt['error'],
!                               'message'                                       
        => $receipt['message'],
!                               'entity_id'                                     
        => $entity_id,
!                               'lang_entity_id'                                
=> lang('Entity Id'),
!                               'investment_id'                                 
=> $investment_id,
!                               'lang_investment_id'                    => 
lang('Investment Id'),
!                               'entity_type'                                   
=> lang($entity_type),
!                               'lang_entity_type'                              
=> lang('Entity Type'),
!                               'links'                                         
        => $links,
!                               'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'allow_all_rows'                                
=> true,
!                               'allrows'                                       
        => $this->allrows,
!                               'start_record'                                  
=> $this->start,
!                               'record_limit'                                  
=> $record_limit,
!                               'num_records'                                   
=> count($investment_list),
!                               'all_records'                                   
=> $this->bo->total_records,
!                               'link_url'                                      
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
 . $entity_id.'&investment_id=' . $investment_id),
!                               'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
!                               'appname'                                       
        => lang($this->currentapp),
!                               'function_msg'                                  
=> lang('investment history'),
!                               'entity_id'                                     
        => $entity_id,
!                               'investment_id'                                 
=> $investment_id,
!                               'table_header_history'                  => 
$table_header,
!                               'values_history'                                
=> $content,
!                               'table_update'                                  
=> $table_update,
!                               'update_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.history&entity_id='
 . $entity_id.'&investment_id=' . $investment_id . '&entity_type=' . 
$entity_type),
!                               'table_done'                                    
=> $table_done
!                       );
! 
!                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('history' => $data));
!                       $this->save_sessiondata();
!               }
! 
! 
!               function add()
!               {
!                       $values                                 = 
get_var('values',array('POST'));
!                       $values['date']                 = 
get_var('date',array('POST'));
!                       $values['property_id']  = 
get_var('property_id',array('POST'));
!                       $values['building_id']  = 
get_var('building_id',array('POST'));
!                       $values['entrance_id']  = 
get_var('entrance_id',array('POST'));
!                       $values['apartment_id'] = 
get_var('apartment_id',array('POST'));
!                       $values['equipment_id'] = 
get_var('equipment_id',array('POST'));
! 
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('investment',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
! 
!                       if ($values['save'])
                        {
!                               $errorcount = 0;
! 
!                               if(!$values['type'])
!                               {
!                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Please select a type !'));
!                               }
! 
!                               if(!$values['period'] && !$values['new_period'])
!                               {
!                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Please select a period for 
write off !'));
!                               }
! 
!                               if(!$values['date'])
!                               {
!                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Please select a date !'));
!                               }
! 
!                               if(!$values['initial_value'])
!                               {
!                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Please set a inital value 
!'));
!                               }
! 
!                               if(!$values['property_id'] || 
!$values['equipment_id'])
!                               {
!                                       
$receipt['error'][$errorcount++]=array('msg'=>lang('Pleace select a location - 
or an equipment !'));
!                               }
! 
! //_debug_array($values);
!                               if(!$receipt['error'])
!                               {
!                                       
$receipt=$this->bo->save_investment($values);
!                                       unset($values);
! 
!                               //      header('Location: '. 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'));
!                               }
! 
                        }
  
                        $link_data = array
                        (
!                               'menuaction'    => 
$this->currentapp.'.uiinvestment.add'
                        );
  
+ 
+                       $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
                        (
                                'appname'                                       
        => lang('investment'),
!                               'function_msg'                                  
=> lang('add investment'),
!                               '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'".')',
!                               'calendar_gif'                                  
=> './'.$this->currentapp.'/templates/default/images/calendar.gif',
!                               'calendar_source'                               
=> './'.$this->currentapp.'/inc/calendar.js',
!                               'dateformat'                                    
=> $dateformat,
!                               'lang_popup_calendar'                   => 
lang('Popup Calendar'),
!                               'lang_date_statustext'                  => 
lang('insert the date for the initial value'),
! 
!                               'lang_date'                                     
        => lang('Date'),
!                               'lang_location'                                 
=> lang('Location'),
!                               'lang_select_location_statustext'=> 
lang('select either a location or an equipment'),
! 
!                               'location_link'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.property'),
!                               'equipment_link'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.equipment'),
! 
!                               'lang_property'                                 
=> lang('Property'),
!                               'lang_building'                                 
=> lang('Building'),
!                               'lang_entrance'                                 
=> lang('Entrance'),
!                               'lang_apartment'                                
=> lang('Apartment'),
!                               'lang_equipment'                                
=> lang('Equipment'),
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.index'),
! 
!                               'lang_write_off_period'                 => 
lang('Write off period'),
!                               'lang_new'                                      
        => lang('New'),
!                               'lang_select'                                   
=> lang('Select'),
!                               'cat_list'                                      
        => $this->bo->write_off_period_list($values['period']),
!                               'lang_descr'                                    
=> lang('Description'),
!                               'lang_type'                                     
        => lang('Type'),
!                               'lang_amount'                                   
=> lang('Amount'),
!                               'lang_value_statustext'                 => 
lang('insert the value at the start-date as a positive amount'),
!                               'lang_new_period_statustext'    => lang('Enter 
a new writeoff period if it is NOT in the list'),
!                               'filter_list'                                   
=> $this->bo->filter('select',$values['type']),
!                               'filter_name'                                   
=> 'values[type]',
!                               'lang_filter_statustext'                => 
lang('Select the type of value'),
!                               'lang_show_all'                                 
=> lang('Select'),
! 
                                'lang_name'                                     
        => lang('name'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
!                               'value_property_id'                             
=> $values['property_id'],
!                               'value_building_id'                             
=> $values['building_id'],
!                               'value_entrance_id'                             
=> $values['entrance_id'],
!                               'value_apartment_id'                    => 
$values['apartment_id'],
!                               'value_equipment_id'                    => 
$values['equipment_id'],
!                               'value_new_period'                              
=> $values['new_period'],
!                               'value_inital_value'                    => 
$values['initial_value'],
!                               'value_date'                                    
=> $values['date'],
!                               'value_descr'                                   
=> $values['descr'],
!                               'error'                                         
        => $receipt['error'],
!                               'message'                                       
        => $receipt['message'],
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the investment'),
!                               'lang_no_cat'                                   
=> lang('Select'),
                                'lang_cat_statustext'                   => 
lang('Select the category the investment belongs to. To do not use a category 
select NO CATEGORY'),
!                               'select_name'                                   
=> 'values[period]',
!                               'investment_type_id'                    => 
$investment['investment_type_id'],
                                'location_code'                                 
=> $investment['location_code'],
                                'value_generellinfo'                    => 
$investment['generellinfo']
***************
*** 366,389 ****
  
                        );
- //print_r($data).'<br>';
- //print_();
  
!                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }
  
                function delete()
                {
!                       $entity_id = get_var('entity_id',array('GET'));
                        $investment_id = 
get_var('investment_id',array('POST','GET'));
                        $confirm        = get_var('confirm',array('POST'));
  
                        $link_data = array
                        (
!                               'menuaction' => 
$this->currentapp.'.uiinvestment.index'
                        );
  
                        if (get_var('confirm',array('POST')))
                        {
!                               $this->bo->delete($entity_id,$investment_id);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }
--- 566,595 ----
  
                        );
  
!                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add' 
=> $data));
                }
  
                function delete()
                {
!                       $entity_id = get_var('entity_id',array('POST','GET'));
                        $investment_id = 
get_var('investment_id',array('POST','GET'));
+                       $index_count = 
get_var('index_count',array('POST','GET'));
+                       $entity_type = 
get_var('entity_type',array('POST','GET'));
+ 
                        $confirm        = get_var('confirm',array('POST'));
  
                        $link_data = array
                        (
!                               'menuaction'    => 
$this->currentapp.'.uiinvestment.history',
!                               'entity_id'             => $entity_id,
!                               'investment_id' => $investment_id,
!                               'index_count'   => $index_count,
!                               'entity_type'   => $entity_type
                        );
  
                        if (get_var('confirm',array('POST')))
                        {
! 
!                               
$this->bo->delete($entity_id,$investment_id,$index_count);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }
***************
*** 395,401 ****
                        (
                                'appname'                               => 
lang('investment'),
!                               'function_msg'                  => lang('delete 
investment'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
 . $entity_id.'&investment_id=' . $investment_id),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
--- 601,607 ----
                        (
                                'appname'                               => 
lang('investment'),
!                               'function_msg'                  => lang('delete 
investment history element'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvestment.delete&entity_id='
 . $entity_id.'&investment_id=' . $investment_id.'&index_count=' . 
$index_count.'&entity_type='.$entity_type),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),





reply via email to

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