phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.uiinvoice.inc.php, 1.3


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.uiinvoice.inc.php, 1.3
Date: Wed, 28 Jul 2004 22:24:16 +0200

Update of /property/inc
Modified Files:
        Branch: 
          class.uiinvoice.inc.php

date: 2004/07/28 20:24:16;  author: sigurdne;  state: Exp;  lines: +293 -2

Log Message:
no message
=====================================================================
Index: property/inc/class.uiinvoice.inc.php
diff -u property/inc/class.uiinvoice.inc.php:1.2 
property/inc/class.uiinvoice.inc.php:1.3
--- property/inc/class.uiinvoice.inc.php:1.2    Wed Jun  2 18:54:28 2004
+++ property/inc/class.uiinvoice.inc.php        Wed Jul 28 20:24:16 2004
@@ -35,7 +35,8 @@
                        'list_sub'              => True,
                        'consume'               => True,
                        'remark'                => True,
-                       'delete'                => True
+                       'delete'                => True,
+                       'add'                   => True
                );
 
                function uiinvoice()
@@ -234,6 +235,16 @@
                                'filter'                        => $this->filter
                        );
 
+                       if($this->acl_add)
+                       {
+                               $table_add[] = array
+                               (
+                                       'lang_add'                              
=> lang('add'),
+                                       'lang_add_statustext'   => lang('add a 
invoice'),
+                                       'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.add')
+                               );
+                       }
+
 
                        if(!$this->allrows)
                        {
@@ -271,7 +282,7 @@
                        $data['query']                                          
        = $this->query;
                        $data['form_action']                                    
= $GLOBALS['phpgw']->link('/index.php',$link_data);
 
-//_debug_array($data);
+//_debug_array($content);
                        $appname                                                
= lang('invoice');
                        $function_msg                                   = 
lang('list voucher');
 
@@ -335,6 +346,7 @@
                                $data['table_header_list_voucher']              
= $table_header;
                                $data['values_list_voucher']                    
= $content;
                                $data['acl_delete']                             
                = $this->acl_delete;
+                               $data['table_add_invoice']                      
        = $table_add;
 
                                
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_voucher' => $data));
                        }
@@ -807,5 +819,284 @@
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
                }
 
+               function add()
+               {
+                       if(!$this->acl_add)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
 . $this->acl2_location);
+                       }
+
+                       $bolocation                     = 
CreateObject($this->currentapp.'.bolocation');
+
+                       $values['art']                          = 
get_var('art',array('POST','GET'));
+                       $values['type']                         = 
get_var('type',array('POST','GET'));
+                       $values['dim_b']                        = 
get_var('dim_b',array('POST','GET'));
+                       $values['invoice_num']          = 
get_var('invoice_num',array('POST','GET'));
+                       $values['kid_nr']                       = 
get_var('kid_nr',array('POST','GET'));
+                       $values['vendor_id']            = 
get_var('vendor_id',array('POST','GET'));
+                       $values['vendor_name']          = 
get_var('vendor_name',array('POST','GET'));
+                       $values['janitor']                      = 
get_var('janitor',array('POST','GET'));
+                       $values['supervisor']           = 
get_var('supervisor',array('POST','GET'));
+                       $values['budget_responsible']= 
get_var('budget_responsible',array('POST','GET'));
+                       $invoice_date   = 
urldecode(get_var('invoice_date',array('POST','GET')));
+                       $values['num_days']                     = 
get_var('num_days',array('POST','GET'));
+                       $payment_date   = 
urldecode(get_var('payment_date',array('POST','GET')));
+                       $values['cancel']                       = 
get_var('cancel',array('POST','GET'));
+                       $values['convert']                      = 
get_var('convert',array('POST','GET'));
+                       $values['sday']                         = 
get_var('sday',array('POST','GET'));
+                       $values['smonth']                       = 
get_var('smonth',array('POST','GET'));
+                       $values['syear']                        = 
get_var('syear',array('POST','GET'));
+                       $values['eday']                         = 
get_var('eday',array('POST','GET'));
+                       $values['emonth']                       = 
get_var('emonth',array('POST','GET'));
+                       $values['eyear']                        = 
get_var('eyear',array('POST','GET'));
+                       $values['auto_tax']             = 
get_var('auto_tax',array('POST','GET'));
+                       $values['merknad']                      = 
get_var('merknad',array('POST','GET'));
+                       $values['b_account_id']         = 
get_var('b_account_id',array('POST'));
+                       $values['b_account_name']       = 
get_var('b_account_name',array('POST'));
+                       $values['amount']                       = 
get_var('amount',array('POST'));
+                       $add                                            = 
get_var('add',array('POST','GET'));
+
+
+                       $links = $this->menu->links('add_inv');
+
+
+                       if($add)
+                       {
+                               $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
+
+                               for ($i=0; 
$i<count($insert_record['location']); $i++)
+                               {
+                                       
if($_POST[$insert_record['location'][$i]])
+                                       {
+                                               
$values['location'][$insert_record['location'][$i]]= 
$_POST[$insert_record['location'][$i]];
+                                       }
+                               }
+
+                               while (is_array($insert_record['extra']) && 
list($key,$column) = each($insert_record['extra']))
+                               {
+                                       if($_POST[$key])
+                                       {
+                                               $values['extra'][$column]       
= $_POST[$key];
+                                       }
+                               }
+
+                               $values['street_name']          = 
$_POST['street_name'];
+                               $values['street_number']        = 
$_POST['street_number'];
+                               $values['location_name']        = $_POST['loc' 
. (count($values['location'])).'_name']; // if not address - get the parent 
name as address
+
+
+                               if (!$values['art'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select type invoice!'));
+                               }
+                               if (!$values['vendor_id'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select Vendor!'));
+                               }
+
+                               if (!$values['type'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select type order!'));
+                               }
+
+                               if (!$values['budget_responsible'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select budget responsible!'));
+                               }
+
+                               if 
(!$this->bo->check_vendor($values['vendor_id']))
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('That Vendor ID is not valid !'). ' : ' . 
$values['vendor_id']);
+                               }
+                               if (!$payment_date && !$values['num_days'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select either payment date or number of days from 
invoice date !'));
+                               }
+
+//_debug_array($values);
+                               if (!is_array($receipt['error']))
+                               {
+                                       $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');
+
+                                       if($invoice_date)
+                                       {
+                                               $dateparts = explode('/', 
$invoice_date);
+                                               $values['sday'] = 
$dateparts[$d];
+                                               $values['smonth'] = 
$dateparts[$m];
+                                               $values['syear'] = 
$dateparts[$y];
+
+                                               $dateparts = explode('/', 
$payment_date);
+                                               $values['eday'] = 
$dateparts[$d];
+                                               $values['emonth'] = 
$dateparts[$m];
+                                               $values['eyear'] = 
$dateparts[$y];
+                                       }
+
+                                       $values['bilagsnr']             = 
$this->bo->next_bilagsnr();
+                                       $values['regtid']               = 
date($this->bocommon->datetimeformat);
+
+                                       $receipt = $this->bo->add($values);
+                                       unset($values);
+                                       
$GLOBALS['phpgw']->session->appsession('session_data','add_receipt',$receipt);
+                               }
+                               else
+                               {
+                                       if($values['location'])
+                                       {
+                                               $location_code=implode("-", 
$values['location']);
+                                               $values['location_data'] = 
$bolocation->read_single($location_code,$values['extra']);
+                                       }
+                               }
+                       }
+
+                       $location_data=$bolocation->initiate_ui_location(array(
+                                               'values'                => 
$values['location_data'],
+                                               'type_id'               => -1, 
// calculated from location_types
+                                               'no_link'               => 
False, // disable lookup links for location type less than type_id
+                                               'tenant'                => 
False,
+                                               'lookup_type'   => 'form',
+                                               'lookup_entity' => False, 
//$this->bocommon->get_lookup_entity('project'),
+                                               'entity_data'   => False 
//$values['p']
+                                               ));
+
+                       
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
+                                               'b_account_id'          => 
$values['b_account_id'],
+                                               'b_account_name'        => 
$values['b_account_name']));
+
+                       $link_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uiinvoice.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));
+
+                       $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+                       $cal_info       = $this->bocommon->jscalendar();
+                       $jsDateFormat=$cal_info['jsDateFormat'];
+
+                       $data = array
+                       (
+                               'msgbox_data'                                   
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'links'                                         
        => $links,
+
+                               'jsDateFormat'                                  
=> $jsDateFormat,
+                               'date_img'                                      
        => $cal_info['img'],
+                               'lang_datetitle'                                
=> lang('Select date'),
+                               'calendar_setup_invoice'                => 
"Calendar.setup({inputField  : 'invoice_date',ifFormat  : '" . $jsDateFormat . 
"',button : 'invoice_date-trigger'});",
+                               'calendar_setup_payment'                => 
"Calendar.setup({inputField  : 'payment_date',ifFormat  : '" . $jsDateFormat . 
"',button : 'payment_date-trigger'});",
+
+                               'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'cancel_action'                                 
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiinvoice.index'),
+                               'lang_cancel'                                   
=> lang('Cancel'),
+                               'lang_cancel_statustext'                => 
lang('cancel'),
+                               'action_url'                                    
=> $GLOBALS['phpgw']->link('/index.php','menuaction='. $this->currentapp 
.'.uiinvoice.add'),
+                               'tsvfilename'                                   
=> '',
+
+                               'lang_add'                                      
=> lang('add'),
+                               'lang_add_statustext'           => lang('Klick 
this button to add a invice'),
+
+                               'lang_invoice_date'                             
=> lang('invoice date'),
+                               'lang_payment_date'                             
=> lang('Payment date'),
+                               'lang_no_of_days'                               
=> lang('Days'),
+                               'lang_invoice_number'                   => 
lang('Invoice Number'),
+                               'lang_invoice_num_statustext'   => lang('Enter 
Invoice Number'),
+
+                               'lang_select'                                   
=> lang('Select per button !'),
+                               'lang_kidnr'                                    
=> lang('KID nr'),
+                               'lang_kid_nr_statustext'                => 
lang('Enter Kid nr'),
+
+                               'lang_vendor'                                   
=> lang('Vendor'),
+                               'addressbook_link'                              
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor'),
+
+                               'lang_invoice_date_statustext'  => lang('Enter 
the invoice date'),
+                               'lang_num_days_statustext'              => 
lang('Enter the payment date or the payment delay'),
+                               'lang_payment_date_statustext'  => lang('Enter 
the payment date or the payment delay'),
+                               'lang_vendor_statustext'                        
=> lang('Select the vendor by klicking the button'),
+                               'lang_vendor_name_statustext'   => lang('Select 
the vendor by klicking the button'),
+                               'lang_select_vendor_statustext' => lang('Select 
the vendor by klicking this button'),
+
+                               'value_invoice_date'                    => 
$invoice_date,
+                               'value_payment_date'                    => 
$payment_date,
+                               'value_belop'                                   
=> $values['belop'],
+                               'value_vendor_id'                               
=> $values['vendor_id'],
+                               'value_vendor_name'                             
=> $values['vendor_name'],
+                               'value_kid_nr'                                  
=> $values['kid_nr'],
+                               'value_dim_b'                                   
=> $values['dim_b'],
+                               'value_invoice_num'                             
=> $values['invoice_num'],
+                               'value_merknad'                                 
=> $values['merknad'],
+                               'value_num_days'                                
=> $values['num_days'],
+                               'value_amount'                                  
=> $values['amount'],
+
+                               'lang_auto_tax'                                 
=> lang('Auto TAX'),
+                               'lang_auto_tax_statustext'              => 
lang('Set tax'),
+
+                               'lang_amount'                                   
=> lang('Amount'),
+                               'lang_amount_statustext'                => 
lang('Amount of the invoice'),
+
+                               'lang_art'                                      
        => lang('Art'),
+                               'art_list'                                      
        => $this->bo->get_lisfm_ecoart($art),
+                               'select_art'                                    
=> 'art',
+                               'lang_select_art'                               
=> lang('Select Invoice Type'),
+                               'lang_art_statustext'                   => 
lang('You have to select type of invoice'),
+
+                               'lang_type'                                     
        => lang('Type invoice II'),
+                               'type_list'                                     
        => $this->bo->get_type_list($type),
+                               'select_type'                                   
=> 'type',
+                               'lang_no_type'                                  
=> lang('No type'),
+                               'lang_type_statustext'                  => 
lang('Select the type  invoice. To do not use type -  select NO TYPE'),
+
+                               'lang_dimb'                                     
        => lang('Dim B'),
+                               'dimb_list'                                     
        => $this->bo->select_dimb_list($dim_b),
+                               'select_dimb'                                   
=> 'dim_b',
+                               'lang_no_dimb'                                  
=> lang('No Dim B'),
+                               'lang_dimb_statustext'                  => 
lang('Select the Dim B for this invoice. To do not use Dim B -  select NO DIM 
B'),
+
+                               'lang_janitor'                                  
=> lang('Janitor'),
+                               'janitor_list'                                  
=> $this->bocommon->get_user_list_right(32,$janitor,'.invoice'),
+                               'select_janitor'                                
=> 'janitor',
+                               'lang_no_janitor'                               
=> lang('No janitor'),
+                               'lang_janitor_statustext'               => 
lang('Select the janitor responsible for this invoice. To do not use janitor -  
select NO JANITOR'),
+
+                               'lang_supervisor'                               
=> lang('Supervisor'),
+                               'supervisor_list'                               
=> $this->bocommon->get_user_list_right(64,$supervisor,'.invoice'),
+                               'select_supervisor'                             
=> 'supervisor',
+                               'lang_no_supervisor'                    => 
lang('No supervisor'),
+                               'lang_supervisor_statustext'    => lang('Select 
the supervisor responsible for this invoice. To do not use supervisor -  select 
NO SUPERVISOR'),
+
+                               'lang_budget_responsible'               => 
lang('B - responsible'),
+                               'budget_responsible_list'               => 
$this->bocommon->get_user_list_right(128,$budget_responsible,'.invoice'),
+                               'select_budget_responsible'             => 
'budget_responsible',
+                               'lang_select_budget_responsible'=> lang('Select 
B-Responsible'),
+                               'lang_budget_responsible_statustext'            
=> lang('You have to select a budget responsible for this invoice in order to 
add the invoice'),
+                               'lang_merknad'                                  
=> lang('Descr'),
+                               'lang_merknad_statustext'               => 
lang('Descr'),
+                               'location_data'                                 
=> $location_data,
+                               'b_account_data'                                
=> $b_account_data
+                       );
+
+//_debug_array($data);
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('invoice','menu'));
+
+                       $appname                                                
= lang('Invoice');
+                       $function_msg                                   = 
lang('Add invoice');
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('add' 
=> $data));
+               }
+
        }
 ?>




reply via email to

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