<?php
  /**************************************************************************\
  * phpGroupWare - Inventory                                                 *
  * http://www.phpgroupware.org                                              *
  * This file written by Bettina Gille [ceb@phpgroupware.org]                *
  * ---------------------------------------------------------                *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/
  /* $Id: invoice_list.php,v 1.8 2001/05/10 22:08:57 bettina Exp $ */
  
    $phpgw_info["flags"] = array('currentapp' => 'inv',
		    'enable_nextmatchs_class' => True);

    include("../header.inc.php");
  
    $db2 = $phpgw->db;
  
    $t = new Template(PHPGW_APP_TPL);  
    $t->set_file(array('invoice_list_t' => 'listdelivery.tpl',                                                                                                                
			'invoice_list'  => 'listdelivery.tpl'));
    $t->set_block('invoice_list_t','invoice_list','list'); 

    if ($order) { $ordermethod = "order by $order $sort"; } 
    else { $ordermethod = "order by num asc"; }
  
    $t->set_var('lang_action',lang('Invoice list'));

  // -------------- header declaration ----------------- 

    $t->set_var('th_bg',$phpgw_info["theme"][th_bg]);                                                                                                            
    $t->set_var('sort_num',$phpgw->nextmatchs->show_sort_order($sort,'num',$order,'/inv/invoice_list.php',lang('Invoice ID')));   
    $t->set_var('sort_date',$phpgw->nextmatchs->show_sort_order($sort,'date',$order,'/inv/invoice_list.php',lang('Date')));                                                     
    $t->set_var('lang_delivery',lang('Invoice')); 

  // -------------- end header declaration -----------------

    $phpgw->db->query("select * from phpgw_inv_invoice WHERE order_id='$order_id' $ordermethod");                                                                                               
  
    while ($phpgw->db->next_record()) { 
    $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
    $t->set_var('tr_color',$tr_color);
    $num = $phpgw->strip_html($phpgw->db->f("num"));
    
    $date = $phpgw->db->f("date");                                                                                                                                                           
    $month = $phpgw->common->show_date(time(),"n");                                                                                                                                             
    $day   = $phpgw->common->show_date(time(),"d");                                                                                                                                             
    $year  = $phpgw->common->show_date(time(),"Y");                                                                                                                                             
                                                                                                                                                                                                  
    $date = $date + (60*60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"];                                                                                                            
                                                                                                                                                                                                  
    $dateout =  $phpgw->common->show_date($date,$phpgw_info["user"]["preferences"]["common"]["dateformat"]);                                                          

   
//--------- template declaration for list records--------------------                                                                                                                
                                                                                                                                                            
    $t->set_var(array('num' => $num,                                                                                                                        
                      'date' => $dateout));
    
    $t->set_var('delivery',$phpgw->link('/inv/invoice_update.php','invoice_id=' . $phpgw->db->f("id") . "&order_id=$order_id")); 
    
    $t->parse('list','invoice_list',True);                                                                                                                   
    }                                                                                                                                                          
   
// -------------------- end record declaration ------------------------

    $t->parse('out','invoice_list_t',True);                                                                                                           
    $t->p('out');

    $phpgw->common->phpgw_footer();
 ?>