phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: inv/inc class.boinventory.inc.php,1.2,1.3 class.


From: Bettina gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: inv/inc class.boinventory.inc.php,1.2,1.3 class.soinventory.inc.php,1.1,1.2 class.uiinventory.inc.php,1.2,1.3
Date: Tue, 15 Jan 2002 20:32:08 -0500

Update of /cvsroot/phpgroupware/inv/inc
In directory subversions:/tmp/cvs-serv3586/inc

Modified Files:
        class.boinventory.inc.php class.soinventory.inc.php 
        class.uiinventory.inc.php 
Log Message:
update

Index: class.boinventory.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/inv/inc/class.boinventory.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.boinventory.inc.php   15 Jan 2002 03:32:00 -0000      1.2
--- class.boinventory.inc.php   16 Jan 2002 01:32:05 -0000      1.3
***************
*** 35,47 ****
                var $sort;
                var $cat_id;
  
                var $public_functions = array
                (
!                       'cached_accounts'       => True,
!                       'read_products'         => True,
!                       'check_perms'           => True,
!                       'check_values'          => True,
!                       'return_single_cat'     => True,
!                       'return_value'          => True
                );
  
--- 35,49 ----
                var $sort;
                var $cat_id;
+               var $product_id;
  
                var $public_functions = array
                (
!                       'cached_accounts'               => True,
!                       'read_products'                 => True,
!                       'check_perms'                   => True,
!                       'check_values'                  => True,
!                       'return_value'                  => True,
!                       'select_status_list'    => True,
!                       'select_dist_list'              => True
                );
  
***************
*** 51,54 ****
--- 53,57 ----
                        $this->cats             = 
CreateObject('phpgwapi.categories');
                        $this->contacts = CreateObject('phpgwapi.contacts');
+                       $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
  
                        if ($session)
***************
*** 64,67 ****
--- 67,71 ----
                        $cat_id = $GLOBALS['HTTP_POST_VARS']['cat_id'] ? 
$GLOBALS['HTTP_POST_VARS']['cat_id'] : $GLOBALS['HTTP_GET_VARS']['cat_id'];
                        $action = $GLOBALS['HTTP_POST_VARS']['action'] ? 
$GLOBALS['HTTP_POST_VARS']['action'] : $GLOBALS['HTTP_GET_VARS']['action'];
+                       $product_id = $GLOBALS['HTTP_POST_VARS']['product_id'] 
? $GLOBALS['HTTP_POST_VARS']['product_id'] : 
$GLOBALS['HTTP_GET_VARS']['product_id'];
  
                        if(!empty($start) || $start == '0' || $start == 0)
***************
*** 73,77 ****
                                $this->query = $query;
                        }
- 
                        if(isset($cat_id))
                        {
--- 77,80 ----
***************
*** 82,85 ****
--- 85,96 ----
                                unset($this->cat_id);
                        }
+                       if(isset($product_id))
+                       {
+                               $this->product_id = $product_id;
+                       }
+                       if($product_id == '')
+                       {
+                               unset($this->product_id);
+                       }
                        if(isset($sort) && !empty($sort))
                        {
***************
*** 114,117 ****
--- 125,132 ----
                                $this->cat_id = $data['cat_id'];
                        }
+                       if(isset($data['product_id']))
+                       {
+                               $this->product_id = $data['product_id'];
+                       }
                }
  
***************
*** 129,137 ****
                }
  
-               function return_single_cat($cat_id)
-               {
-                       return $this->cats->return_single($this->cat_id);
-               }
- 
                function check_perms($has, $needed)
                {
--- 144,147 ----
***************
*** 182,185 ****
--- 192,228 ----
                }
  
+               function select_status_list($selected = '') 
+               {
+                       $sl = $this->status_list();
+ 
+                       while ($status = each($sl)) 
+                       {
+                               $html_status_list .= '<option value="' . 
$status[0] . '"';
+                               if ($status[0] == $selected)
+                               {
+                                       $html_status_list .= ' selected';
+                               }
+                               $html_status_list .= '>' . $status[1] . 
'</option>';
+                       }
+                       return $html_status_list;
+               }
+ 
+               function select_dist_list($dist = '') 
+               {
+                       $cols = array('org_name' => 'org_name');
+ 
+                       $entries = $this->contacts->read($start = '',$offset = 
'',$cols,$query = '','tid=n',$sort = '',$order = '',$this->account);
+                       for ($i=0;$i<count($entries);$i++) 
+                       {
+                               $html_dist_list .= '<option value="' . 
$entries[$i]['id'] . '"';
+                               if ($entries[$i]['id'] == $dist)
+                               {
+                                       $html_dist_list .= ' selected';
+                               }
+                               $html_dist_list .= '>'  . 
$entries[$i]['org_name'] . '</option>';
+                       }
+                       return $html_dist_list;
+               }
+ 
                function return_value($item)
                {
***************
*** 198,299 ****
                }
  
!               function read_products($limit,$object,$status)
!               {
!                       $pro = 
$this->soinv->read_products($this->start,$limit,$this->query,$object,$this->cat_id,$this->sort,$this->order,$status);
!                       $this->total_records = $this->soinv->total_records;
!                       return $pro;
!               }
! 
!               function read_rooms($start, $limit = True, $query = '', $filter 
= '', $sort = '', $order = '')
                {
!                       global $phpgw,$phpgw_info;
! 
!                       if (!$sort)
!                       {
!                               $sort = "ASC";
!                       }
  
!                       if ($order)
                        {
!                               $ordermethod = " order by $order $sort";
                        }
                        else
                        {
!                               $ordermethod = "order by room_name asc";
                        }
  
!                       if (! $filter)
!                       {
!                               $filter = 'none';
!                       }
  
!                       if ($filter != 'private')
                        {
!                               if ($filter != 'none')
!                               {
!                                       $filtermethod = " room_access like 
'%,$filter,%' ";
!                               }
!                               else
!                               {
!                                       $filtermethod = " ( room_owner=" . 
$phpgw_info['user']['account_id'];
!                                       if (is_array($this->grants))
!                                       {
!                                               $grants = $this->grants;
!                                               while (list($user) = 
each($grants))
!                                               {
!                                                       $public_user_list[] = 
$user;
!                                               }
!                                               reset($public_user_list);
!                                               $filtermethod .= " OR 
(room_access='public' AND room_owner in(" . implode(',',$public_user_list) . 
")))";
!                                       }
!                                       else
!                                       {
!                                               $filtermethod .= ' )';
!                                       }
!                               }
                        }
                        else
                        {
!                               $filtermethod = ' room_owner=' . 
$phpgw_info['user']['account_id'] . ' ';
                        }
  
!                       if ($query)
!                       {
!                               $querymethod = " AND (room_name like '%$query%' 
OR room_note like '%$query%')";
!                       }
! 
!                       $sql = "select * from phpgw_inv_stockrooms WHERE 
$filtermethod $querymethod";
  
!                       $this->db2->query($sql,__LINE__,__FILE__);
! 
!                       $this->total_records = $this->db2->num_rows();
  
!                       if ($limit)
                        {
!                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
                        else
                        {
!                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
                        }
  
!                       $i = 0;
! 
!                       while ($this->db->next_record())
!                       {
!                               $rooms[$i]['id']                = 
$this->db->f('id');
!                               $rooms[$i]['owner']             = 
$this->db->f('room_owner');
!                               $rooms[$i]['access']    = 
$this->db->f('room_access');
!                               $rooms[$i]['name']              = 
$this->db->f('room_name');
!                               $rooms[$i]['note']              = 
$this->db->f('room_note');
!                               $i++;
!                       }
!                       return $rooms;
                }
  
                function select_room_list($selected = '')
                {
-                       global $phpgw;
- 
                        $rooms = 
$this->read_rooms($start,False,$query,$filter,$sort,$order);
  
--- 241,321 ----
                }
  
!               function select_number($cat_id)
                {
!                       $cat_data = $this->cats->id2name($this->cat_id,'data');
!                       $data = unserialize($cat_data);
  
!                       if ($data['number'])
                        {
!                               return $data['number'];
                        }
                        else
                        {
!                               return False;
                        }
+               }
  
!               function read_products($limit,$object,$cat_id,$status)
!               {
!                       $pro = 
$this->soinv->read_products($this->start,$limit,$this->query,$object,$cat_id,$this->sort,$this->order,$status);
!                       $this->total_records = $this->soinv->total_records;
!                       return $pro;
!               }
! 
!               function read_single_product()
!               {
!                       return 
$this->soinv->read_single_product($this->product_id);
!               }
  
!               function add_leading_zero($num,$idtype = 'hex') 
!               {
!                       if ($idtype == "hex") 
                        {
!                               $num = hexdec($num);
!                               $num++;
!                               $num = dechex($num);
                        }
                        else
                        {
!                               $num++; 
                        }
  
!                       if (strlen($num) == 4)
!                               $return = $num;
!                       if (strlen($num) == 3)
!                               $return = "0$num";
!                       if (strlen($num) == 2)
!                               $return = "00$num";
!                       if (strlen($num) == 1)
!                               $return = "000$num";
!                       if (strlen($num) == 0)
!                               $return = "0001";
  
!                       return strtoupper($return);
!               }
  
!               function create_productid($cat_id) 
!               {
!                       if ($this->select_number($cat_id))
                        {
!                               $number = $this->select_number($cat_id);
!                               $maxnum = 
$this->soinv->max_product_number($number);
!                               $sub = strlen($number);
!                               $max = add_leading_zero(substr($maxnum,$sub));
!                               return $number . $max;
                        }
                        else
                        {
!                               return False;
                        }
+               }
  
!               function read_rooms($start, $limit = True, $query = '', $filter 
= '', $sort = '', $order = '')
!               {
!                       return 
$this->soinv->read_rooms($start,$limit,$query,$filter,$sort,$order);
                }
  
                function select_room_list($selected = '')
                {
                        $rooms = 
$this->read_rooms($start,False,$query,$filter,$sort,$order);
  
***************
*** 305,309 ****
                                        $s .= ' selected';
                                }
!                               $s .= '>' . 
$phpgw->strip_html($rooms[$i]['name']);
                                $s .= '</option>' . "\n";
                        }
--- 327,331 ----
                                        $s .= ' selected';
                                }
!                               $s .= '>' . 
$GLOBALS['phpgw']->strip_html($rooms[$i]['name']);
                                $s .= '</option>' . "\n";
                        }
***************
*** 313,326 ****
                function one_room($id = '')
                {
-                       $this->db->query("select * from phpgw_inv_stockrooms 
where id='$id'",__LINE__,__FILE__);
- 
-                       if ($this->db->next_record())
-                       {
-                               $room[0]['id']          = $this->db->f('id');
-                               $room[0]['owner']       = 
$this->db->f('room_owner');
-                               $room[0]['access']      = 
$this->db->f('room_access');
-                               $room[0]['name']        = 
$this->db->f('room_name');
-                               $room[0]['note']        = 
$this->db->f('room_note');
-                       }
                        return $room;
                }
--- 335,338 ----
***************
*** 328,334 ****
                function get_stock($product_id = '')
                {
-                       $this->db->query("select stock from phpgw_inv_products 
where con='$product_id'",__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $stock = $this->db->f('stock');
                        return $stock;
                }
--- 340,343 ----
***************
*** 362,365 ****
--- 371,474 ----
  
                        $this->db->query("update phpgw_inv_products set 
stock='$newstock' where con='$product_id'",__LINE__,__FILE__);
+               }
+ 
+               function exists($values)
+               {
+                       return $this->soinv->exists($values);
+               }
+ 
+               function check_values($values)
+               {
+                       if (!$values['cat_id'])
+                       {
+               $error[] = lang('Please select a category for that product !');
+                       }
+ 
+                       if (!$values['choose'])
+                       {
+                               if (!$values['num'])
+                               {
+                                       $error[] = lang('Please enter an ID !');
+                               }
+                               else
+                               {
+                                       $exists = $this->exists(array('action' 
=> 'num','num' => $values['num'],'cat_id' => $values['cat_id'],
+                                                                               
                        'product_id' => $values['product_id']));
+ 
+                                       if ($exists)
+                                       {
+                                               $error[] = lang('That ID has 
been used already !');
+                                       }
+ 
+                                       if (strlen($values['num']) > 20)
+                                       {
+                                               $error[] = lang('ID can not 
exceed 20 characters in length !');
+                                       }
+                               }
+                       }
+ 
+                       if (!$values['serial'])
+                       {
+                               if ($values['name'])
+                               {
+                                       $exists = $this->exists(array('action' 
=> 'name','name' => $values['name'],'cat_id' => $values['cat_id'],
+                                                                               
                        'product_id' => $values['product_id']));
+ 
+                                       if ($exists)
+                                       {
+                                               $error[] = lang('That name has 
been used already !');
+                                       }
+ 
+                                       if (strlen($values['name']) > 255)
+                                       {
+                                               $error[] = lang('name can not 
exceed 255 characters in length !');
+                                       }
+                               }
+                       }
+ 
+                       if (! 
checkdate($values['pmonth'],$values['pday'],$values['pyear']))
+                       {
+                               $error[] = lang('You have entered an invalid 
purchase date !');
+                       }
+ 
+                       if (! 
checkdate($values['smonth'],$values['sday'],$values['syear']))
+                       {
+                               $error[] = lang('You have entered an invalid 
selling date !');
+                       }
+ 
+                       if (is_array($error))
+                       {
+                               return $error;
+                       }
+               }
+ 
+               function save_product($values)
+               {
+                       if ($values['choose'])
+                       {
+                               $values['num'] = 
$this->create_productid($values['cat_id']);
+                       }
+ 
+                       if ($values['url'] == 'http://')
+                       {
+                               $values['url'] = '';
+                       }
+ 
+                       if ($values['ftp'] == 'ftp://')
+                       {
+                               $values['ftp'] = '';
+                       }
+ 
+                       $taxpercent = $this->select_tax($values['cat_id']);
+                       $values['retail'] = 
round($values['price']*(1+$taxpercent),2);
+ 
+                       if ($values['product_id'] && $values['product_id'] != 0)
+                       {
+                               $this->soinv->edit_product($values);
+                       }
+                       else
+                       {
+                               $this->soinv->add_product($values);
+                       }
                }
        }

Index: class.soinventory.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/inv/inc/class.soinventory.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.soinventory.inc.php   15 Jan 2002 02:57:17 -0000      1.1
--- class.soinventory.inc.php   16 Jan 2002 01:32:05 -0000      1.2
***************
*** 173,177 ****
                        {
                                $products[$i]['con']            = 
$this->db->f('con');
!                               $products[$i]['id']                     = 
$this->db->f('id');
                                $products[$i]['serial']         = 
$this->db->f('serial');
                                $products[$i]['name']           = 
$this->db->f('name');
--- 173,177 ----
                        {
                                $products[$i]['con']            = 
$this->db->f('con');
!                               $products[$i]['num']            = 
$this->db->f('id');
                                $products[$i]['serial']         = 
$this->db->f('serial');
                                $products[$i]['name']           = 
$this->db->f('name');
***************
*** 197,200 ****
--- 197,231 ----
                }
  
+               function read_single_product($con)
+               {
+                       $this->db->query("SELECT * from phpgw_inv_products 
WHERE con='$con'",__LINE__,__FILE__);
+ 
+                       if ($this->db->next_record())
+                       {
+                               $product['con']         = $this->db->f('con');
+                               $product['num']         = $this->db->f('id');
+                               $product['serial']      = 
$this->db->f('serial');
+                               $product['name']        = $this->db->f('name');
+                               $product['descr']       = $this->db->f('descr');
+                               $product['cat_id']      = 
$this->db->f('category');
+                               $product['status']      = 
$this->db->f('status');
+                               $product['weight']      = 
$this->db->f('weight');
+                               $product['cost']        = $this->db->f('cost');
+                               $product['price']       = $this->db->f('price');
+                               $product['retail']      = 
$this->db->f('retail');
+                               $product['stock']       = $this->db->f('stock');
+                               $product['mstock']      = 
$this->db->f('mstock');
+                               $product['url']         = $this->db->f('url');
+                               $product['ftp']         = $this->db->f('ftp');
+                               $product['dist']        = $this->db->f('dist');
+                               $product['pdate']       = $this->db->f('pdate');
+                               $product['sdate']       = $this->db->f('sdate');
+                               $product['bin']         = $this->db->f('bin');
+                               $product['note']        = 
$this->db->f('product_note');
+                       }
+                       return $product;
+               }
+ 
+ 
                function read_rooms($start, $limit = True, $query = '', $filter 
= '', $sort = '', $order = '')
                {
***************
*** 363,366 ****
--- 394,450 ----
                                return $this->db->f('status_name');
                        }
+               }
+ 
+               function exists($values)
+               {
+                       if (!$values['cat_id'])
+                       {
+                               $values['cat_id'] = 0;
+                       }
+ 
+                       switch($values['action'])
+                       {
+                               case 'num':             $column = 'id'; $item = 
$values['num']; break;
+                               case 'name':    $column = 'name'; $item = 
$values['name']; break;
+                       }
+ 
+                       if ($values['id'] && ($values['id'] != 0))
+                       {
+                               $editexists = " and con !='" . $values['id'] . 
"'";
+                       }
+ 
+                       $this->db->query("select count(*) from 
phpgw_inv_products where $column ='" . $item . "' AND category='"
+                                                       . $values['cat_id'] . 
"'" . $editexists,__LINE__,__FILE__);
+ 
+                       if ($this->db->f(0))
+                       {
+                               return True;
+                       }
+                       else
+                       {
+                               return False;
+                       }
+               }
+ 
+               function add_product($values)
+               {
+                       $values['name']         = 
$this->db_addslashes($values['name']);
+                       $values['descr']        = 
$this->db_addslashes($values['descr']);
+                       $values['note']         = 
$this->db_addslashes($values['note']);
+                       $values['url']          = 
$this->db_addslashes($values['url']);
+                       $values['ftp']          = 
$this->db_addslashes($values['ftp']);
+ 
+                       $this->db->query("insert into phpgw_inv_products 
(id,serial,name,descr,category,status,cost,price,retail,stock,mstock,url,ftp,dist,"
+                                                       . 
"pdate,sdate,bin,product_note) values ('" . $values['num'] . "','" . 
$values['serial'] . "','" . $values['name']
+                                                       . "','" . 
$values['descr'] . "','" . $values['cat_id'] . "','" . $values['status'] . 
"','" . $values['cost']
+                                                       . "','" . 
$values['price'] . "','" . $values['retail'] . "','" . $values['stock'] . "','" 
. $values['mstock'] . "','"
+                                                       . $values['url'] . 
"','" . $values['ftp'] . "','" . $values['dist'] . "','" . $values['pdate'] . 
"','" . $values['sdate']
+                                                       . "','" . 
$values['bin'] . "','" . $values['product_note'] . "')",__LINE__,__FILE__);
+               }
+ 
+ 
+               function max_product_number($number) 
+               {
+                       return $this->db->query("select max(id) from 
phpgw_inv_products where id like ('$number%')");
                }
        }

Index: class.uiinventory.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/inv/inc/class.uiinventory.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.uiinventory.inc.php   15 Jan 2002 03:32:00 -0000      1.2
--- class.uiinventory.inc.php   16 Jan 2002 01:32:05 -0000      1.3
***************
*** 33,37 ****
                var $public_functions = array
                (
!                       'list_products' => True
                );
  
--- 33,38 ----
                var $public_functions = array
                (
!                       'list_products' => True,
!                       'edit_product'  => true
                );
  
***************
*** 53,56 ****
--- 54,58 ----
                        $this->cat_id                                   = 
$this->boinv->cat_id;
                        $this->action                                   = 
$this->boinv->action;
+                       $this->product_id                               = 
$this->boinv->product_id;
                }
  
***************
*** 59,69 ****
                        $data = array
                        (
!                               'start'         => $this->start,
!                               'query'         => $this->query,
!                               'filter'        => $this->filter,
!                               'order'         => $this->order,
!                               'sort'          => $this->sort,
!                               'cat_id'        => $this->cat_id,
!                               'action'        => $this->action
                        );
                        $this->boinv->save_sessiondata($data);
--- 61,72 ----
                        $data = array
                        (
!                               'start'                 => $this->start,
!                               'query'                 => $this->query,
!                               'filter'                => $this->filter,
!                               'order'                 => $this->order,
!                               'sort'                  => $this->sort,
!                               'cat_id'                => $this->cat_id,
!                               'action'                => $this->action,
!                               'product_id'    => $this->product_id
                        );
                        $this->boinv->save_sessiondata($data);
***************
*** 86,89 ****
--- 89,117 ----
                $this->t->set_var('lang_archive',lang('Archive'));
                $this->t->set_var('lang_rooms',lang('Stock rooms'));
+                       $this->t->set_var('lang_num',lang('Product ID'));
+                       $this->t->set_var('lang_name',lang('Short Name'));
+                       $this->t->set_var('lang_url',lang('WWW'));
+                       $this->t->set_var('lang_ftp',lang('FTP'));
+                       $this->t->set_var('lang_purchase_date',lang('Purchase 
date'));
+                       $this->t->set_var('lang_selling_date',lang('Selling 
date'));
+                       
$this->t->set_var('lang_description',lang('Description'));
+                       $this->t->set_var('lang_category',lang('Category'));
+                       $this->t->set_var('lang_in_stock',lang('in Stock'));
+                       $this->t->set_var('lang_min_stock',lang('min Stock'));
+                       $this->t->set_var('lang_cost',lang('Purchase price'));
+                       $this->t->set_var('lang_price',lang('Selling price'));
+                       $this->t->set_var('lang_retail',lang('Retail'));
+                       $this->t->set_var('lang_status',lang('Status'));
+                       $this->t->set_var('lang_serial',lang('Serial number'));
+                       $this->t->set_var('lang_select_dist',lang('Select 
distributor'));
+                       $this->t->set_var('lang_select_room',lang('Select Stock 
room'));
+                       $this->t->set_var('lang_select_cat',lang('Select 
category'));
+                       
$this->t->set_var('lang_distributor',lang('Distributor'));
+                       $this->t->set_var('lang_note',lang('Note'));
+                       $this->t->set_var('lang_room',lang('Stock room'));
+                       $this->t->set_var('lang_add',lang('Add'));
+                       $this->t->set_var('lang_reset',lang('Clear Form'));
+                       $this->t->set_var('lang_done',lang('Done'));
+                       $this->t->set_var('lang_save',lang('Save'));
                }
  
***************
*** 141,148 ****
                function list_products()
                {
                        $link_data = array
                        (
                                'menuaction'    => 
'inv.uiinventory.list_products',
!                               'cat_id'                => $this->cat_id,
                                'action'                => $this->action
                        );
--- 169,178 ----
                function list_products()
                {
+                       global $cat_id;
+ 
                        $link_data = array
                        (
                                'menuaction'    => 
'inv.uiinventory.list_products',
!                               'cat_id'                => $cat_id,
                                'action'                => $this->action
                        );
***************
*** 171,184 ****
                        }
  
!                       if (! $this->cat_id)
                        {
!                               $this->cat_id = '999';
                        }
                        else
                        {
!                               $category = 
$this->boinv->return_single_cat($cat_id);
                        }
  
!                       $products = 
$this->boinv->read_products(True,'category','active');
  
  //--------------------------------- nextmatch 
--------------------------------------------
--- 201,214 ----
                        }
  
!                       if (! $cat_id)
                        {
!                               $cat_id = '999';
                        }
                        else
                        {
!                               $category = 
$this->boinv->cats->return_single($cat_id);
                        }
  
!                       $products = 
$this->boinv->read_products(True,'category',$cat_id,'active');
  
  //--------------------------------- nextmatch 
--------------------------------------------
***************
*** 195,199 ****
  //---------------------------- list variable template-declarations 
-------------------------
  
!                       
$this->t->set_var('sort_id',$this->nextmatchs->show_sort_order($this->sort,'id',$this->order,'/index.php',lang('Product
 ID'),$link_data));
                        
$this->t->set_var('sort_serial',$this->nextmatchs->show_sort_order($this->sort,'serial',$this->order,'/index.php',lang('Serial
 number'),$link_data));
                        
$this->t->set_var('sort_name',$this->nextmatchs->show_sort_order($this->sort,'name',$this->order,'/index.php',lang('Name'),$link_data));
--- 225,229 ----
  //---------------------------- list variable template-declarations 
-------------------------
  
!                       
$this->t->set_var('sort_num',$this->nextmatchs->show_sort_order($this->sort,'id',$this->order,'/index.php',lang('Product
 ID'),$link_data));
                        
$this->t->set_var('sort_serial',$this->nextmatchs->show_sort_order($this->sort,'serial',$this->order,'/index.php',lang('Serial
 number'),$link_data));
                        
$this->t->set_var('sort_name',$this->nextmatchs->show_sort_order($this->sort,'name',$this->order,'/index.php',lang('Name'),$link_data));
***************
*** 209,213 ****
                        
$this->t->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
  
!                       
$this->t->set_var('category_list',$this->boinv->formatted_list(array('format' 
=> 'select','type' => 'all','selected' => $this->cat_id)));
  
  // -------------------------------- end declaration 
-----------------------------------------
--- 239,243 ----
                        
$this->t->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
  
!                       
$this->t->set_var('category_list',$this->boinv->formatted_list(array('format' 
=> 'select','type' => 'all','selected' => $cat_id)));
  
  // -------------------------------- end declaration 
-----------------------------------------
***************
*** 224,228 ****
                                if (! $name) $name = '&nbsp;';
  
!                               $id = 
$GLOBALS['phpgw']->strip_html($products[$i]['id']);
                                $abid = $products[$i]['dist'];
  
--- 254,258 ----
                                if (! $name) $name = '&nbsp;';
  
!                               $num = 
$GLOBALS['phpgw']->strip_html($products[$i]['num']);
                                $abid = $products[$i]['dist'];
  
***************
*** 243,257 ****
  //---------------------------------- list records 
-------------------------------------
  
!                               $this->t->set_var(array('id' => $id,
!                                                               'name' => $name,
!                                                               'dist' => $dist,
!                                                               'status' => 
lang($this->boinv->return_value($products[$i]['status'])),
!                                                               'cost' => $cost,
!                                                               'price' => 
$price,
!                                                               'retail' => 
sprintf("%01.2f",$retail),
!                                                               'stock' => 
$stock,
!                                                               'serial' => 
$serial));
  
!                               $link_data['con'] = $products[$i]['con'];
                                if 
($this->boinv->check_perms($grants[$category[0]['owner']],PHPGW_ACL_EDIT) || 
$category[0]['owner'] == $this->account)
                                {
--- 273,287 ----
  //---------------------------------- list records 
-------------------------------------
  
!                               $this->t->set_var(array('num' => $num,
!                                                                               
'name' => $name,
!                                                                               
'dist' => $dist,
!                                                                               
'status' => lang($this->boinv->return_value($products[$i]['status'])),
!                                                                               
'cost' => $cost,
!                                                                               
'price' => $price,
!                                                                               
'retail' => sprintf("%01.2f",$retail),
!                                                                               
'stock' => $stock,
!                                                                               
'serial' => $serial));
  
!                               $link_data['product_id'] = $products[$i]['con'];
                                if 
($this->boinv->check_perms($grants[$category[0]['owner']],PHPGW_ACL_EDIT) || 
$category[0]['owner'] == $this->account)
                                {
***************
*** 269,273 ****
                        if 
($this->boinv->check_perms($grants[$category[0]['owner']],PHPGW_ACL_ADD) || 
$category[0]['owner'] == $this->account)
                        {
!                               $link_data['menuaction'] = 
'inv.uiinventory.add_product';
                                $this->t->set_var('action','<form method="POST" 
action="' . $GLOBALS['phpgw']->link('/index.php',$link_data)
                                                        . '"><input 
type="submit" value="' . lang('Add') .'"></form>');
--- 299,304 ----
                        if 
($this->boinv->check_perms($grants[$category[0]['owner']],PHPGW_ACL_ADD) || 
$category[0]['owner'] == $this->account)
                        {
!                               $link_data['menuaction'] = 
'inv.uiinventory.edit_product';
!                               $link_data['product_id'] = '';
                                $this->t->set_var('action','<form method="POST" 
action="' . $GLOBALS['phpgw']->link('/index.php',$link_data)
                                                        . '"><input 
type="submit" value="' . lang('Add') .'"></form>');
***************
*** 279,282 ****
--- 310,479 ----
                        $this->save_sessiondata();
                        $this->t->pfp('out','listproducts_t',True);
+               }
+ 
+ 
+               function edit_product()
+               {
+                       global $cat_id;
+ 
+                       $values         = $GLOBALS['HTTP_POST_VARS']['values'];
+                       $submit         = $GLOBALS['HTTP_POST_VARS']['submit'];
+ 
+                       if (!$submit)
+                       {
+                               $referer = 
$GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] ? 
$GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] : $GLOBALS['HTTP_REFERER'];
+                       }
+ 
+                       $this->t->set_file(array('form' => 'product_form.tpl'));
+ 
+                       if ($this->product_id)
+                       {
+                               $this->t->set_block('form','add','addhandle');
+                               $this->t->set_block('form','edit','edithandle');
+                               $this->t->set_var('lang_action',lang('Edit 
product'));
+                               $hidden_vars = '<input type="hidden" 
name="product_id" value="' . $this->product_id . '">' . "\n";
+                               $values = $this->boinv->read_single_product();
+                               $cat_id = $values['cat_id'];
+                       }
+                       else
+                       {
+                               $this->t->set_block('form','add','addhandle');
+                               $this->t->set_block('form','edit','edithandle');
+                               $this->t->set_var('lang_action',lang('Add 
product'));
+                               $this->t->set_var('lang_choose',lang('Generate 
Product ID ?'));
+                               $this->t->set_var('choose','<input 
type="checkbox" name="values[choose]" value="True"' . ($values['choose'] == 
True?' checked':'') . '>');
+                       }
+ 
+                       if ($submit)
+                       {
+                               if ($product_id)
+                               {
+                                       $values['product_id']   = $product_id;
+                                       $this->product_id               = 
$product_id;
+                               }
+ 
+                               $values['cat_id'] = $cat_id;
+                               $error = $this->boinv->check_values($values);
+                               if (is_array($error))
+                               {
+                                       
$this->t->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
+                               }
+                               else
+                               {
+                                       $this->boinv->save_product($values);
+                                       
$this->t->set_var('message',lang('Product x x has been added !', 
$values['num'],$values['name']));
+                               }
+                       }
+ 
+                       $link_data = array
+                       (
+                               'menuaction'    => 
'inv.uiinventory.edit_product',
+                               'action'                => $this->action,
+                               'product_id'    => $this->product_id,
+                               'cat_id'                => $cat_id
+                       );
+ 
+                       if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']))
+                       {
+                               $currency = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'];
+                       }
+                       else
+                       {
+                               $this->t->set_var('error',lang('Please set your 
preferences for this application !'));
+                       }
+ 
+                       $this->display_app_header();
+                       $hidden_vars .= '<input type="hidden" name="referer" 
value="' . $referer . '">' . "\n";
+                       $owner = $this->boinv->cats->id2name($cat_id,'owner');
+                       
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
+                       $this->t->set_var('hidden_vars',$hidden_vars);
+                       $this->t->set_var('num',$values['num']);
+                       $this->t->set_var('short_name',$values['name']);
+                       $this->t->set_var('product_note',$values['note']);
+                       $this->t->set_var('serial',$values['serial']);
+                       $this->t->set_var('descr',$values['descr']);
+ 
+                       if (! ereg('http://',$values['url']))
+                       {
+                               $url = 'http://'. $values['url'];
+                       }
+                       $this->t->set_var('url',$url);
+ 
+                       if (! ereg('ftp://',$values['ftp']))
+                       {
+                               $ftp = 'ftp://'. $values['ftp'];
+                       }
+                       $this->t->set_var('ftp',$ftp);
+ 
+                       $this->t->set_var('cost',$values['cost']);
+                       $this->t->set_var('price',$values['price']);
+                       $this->t->set_var('retail',$values['retail']);
+                       $this->t->set_var('stock',$values['stock']);
+                       $this->t->set_var('mstock',$values['mstock']);
+ 
+                       
$this->t->set_var('category_list',$this->boinv->cats->formated_list(array('format'
 => 'select','type' => 'all','selected' => $cat_id)));
+                       
$this->t->set_var('status_list',$this->boinv->select_status_list($values['status']));
+ 
+                       
$this->t->set_var('dist_list',$this->boinv->select_dist_list($values['dist']));
+ 
+                       
$this->t->set_var('room_list',$this->boinv->select_room_list($values['bin']));
+ 
+                       $this->t->set_var('currency',$currency);
+ 
+                       if (!$values['pdate'])
+                       {
+                               $pmonth = date('m',time());
+                               $pday   = date('d',time());
+                               $pyear  = date('Y',time());
+                       }
+                       else
+                       {
+                               $pmonth = date('m',$values['pdate']);
+                               $pday   = date('d',$values['pdate']);
+                               $pyear  = date('Y',$values['pdate']);
+                       }
+ 
+                       
$this->t->set_var('purchase_date_select',$GLOBALS['phpgw']->common->dateformatorder($this->sbox->getYears('values[pyear]',$pyear),
+                                                                               
                                                                                
                $this->sbox->getMonthText('values[pmonth]',$pmonth),
+                                                                               
                                                                                
                $this->sbox->getDays('values[pday]',$pday)));
+ 
+                       if (!$values['sdate'])
+                       {
+                               $smonth = 0;
+                               $sday = 0;
+                               $syear = 0;
+                       }
+                       else
+                       {
+                               $smonth = date('m',$values['sdate']);
+                               $sday = date('d',$values['sdate']);
+                               $syear = date('Y',$values['sdate']);
+                       }
+ 
+                       
$this->t->set_var('selling_date_select',$GLOBALS['phpgw']->common->dateformatorder($this->sbox->getYears('values[syear]',$syear),
+                                                                               
                                                                                
                $this->sbox->getMonthText('values[smonth]',$smonth),
+                                                                               
                                                                                
                $this->sbox->getDays('values[sday]',$sday)));
+ 
+                       $this->t->set_var('done_action',$referer);
+ 
+                       $this->t->set_var('edithandle','');
+                       $this->t->set_var('addhandle','');
+ 
+                       $this->t->pfp('out','form');
+ 
+                       if ($this->product_id)
+                       {
+                               if 
($this->boinv->check_perms($grants[$owner],PHPGW_ACL_DELETE) || $owner == 
$this->account)
+                               {
+                                       $link_data['menuaction'] = 
'inv.uiinventory.delete';
+                                       $t->set_var('delete','<form 
method="POST" action="' . $phpgw->link('/index.php',$link_data)
+                                                                               
. '"><input type="submit" value="' . lang('Delete') .'"></form>');
+                               }
+                               $this->t->pfp('edithandle','edit');
+                       }
+                       else
+                       {
+                               $this->t->pfp('addhandle','add');
+                       }
                }
        }




reply via email to

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