<?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: addstatus.php,v 1.12 2001/05/10 22:08:56 bettina Exp $ */

    if ($submit)
    {
        $phpgw_info['flags'] = array('noheader' => True,    
                                     'nonavbar' => True);
    }

    $phpgw_info['flags']['currentapp'] = 'inv';
    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("insert into phpgw_inv_statuslist (status_name) values ('$status_name')");
    	    Header('Location: ' . $phpgw->link('/inv/liststatus.php','lm=statusadded'));
    	    $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','');
    }

    $t->set_var('lang_action',lang('Add product status'));
    $t->set_var('form_action',$phpgw->link('/inv/addstatus.php'));
    $t->set_var('lang_name',lang('Name'));
    $t->set_var('status_name',$status_name);
    $t->set_var('lang_submit',lang('Add'));

    $t->pparse('out','form');
    $phpgw->common->phpgw_footer();
?>
