<?php
  /**************************************************************************\
  * phpGroupWare - Inventory                                                 *
  * http://www.phpgroupware.org                                              *
  * This file written by Joseph Engo <jengo@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: editstatus.php,v 1.14 2001/05/10 22:08:57 bettina Exp $ */
  
    $phpgw_info['flags']['currentapp'] = 'inv';
  
    if ($submit)
    {
	$phpgw_info['flags']['nonavbar'] = True;
	$phpgw_info['flags']['noheader'] = True;
    }

    include('../header.inc.php');
    $t = new Template(PHPGW_APP_TPL);
    $t->set_file(array('form' => 'status_form.tpl'));
  
    if ($submit)
    {
	$status_name = addslashes($status_name);

	$phpgw->db->query("select count(*) from phpgw_inv_statuslist where status_name='$status_name'");
	$phpgw->db->next_record();

	if ($phpgw->db->f(0) != 0)
	{
    	    $error = lang('This status name already exsists !');
        }
	else
	{
    	    $phpgw->db->query("update phpgw_inv_statuslist set status_name='$status_name' where status_id='$status_id'");
    	    Header('Location: ' . $phpgw->link('/inv/liststatus.php','lm=statusupdated'));
    	    $phpgw->common->phpgw_exit();
        }
    }
  
    if ($error)
    {
	$phpgw->common->phpgw_header();
        echo parse_navbar();
        $t->set_var('message',$error);
        $t->set_var('status_name',$status_name);
    }
    else 
    {
	$t->set_var('message','');
    }

    $phpgw->db->query("select status_name from phpgw_inv_statuslist where status_id='$status_id'");
    $phpgw->db->next_record();

    $t->set_var('status_name',$phpgw->db->f('status_name'));
    $t->set_var('lang_action','Edit product status');
    $t->set_var('form_action',$phpgw->link('/inv/editstatus.php',"status_id=$status_id"));
    $t->set_var('lang_name',lang('Name'));
    $t->set_var('lang_submit',lang('Edit'));
  
    $t->pparse('out','form');

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