Location: PHPKode > projects > PhpRechnung > phpRechnung/config/editf_company.php
<?php
/*
	editf_company.php

	phpRechnung - is easy-to-use Web-based multilingual accounting software.
	Copyright (C) 2001 - 2008 Edy Corak < phprechnung at ecorak dot net >

	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.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

require_once("../include/phprechnung.inc.php");
require_once("../include/smarty.inc.php");
CheckUser();
CheckAdminGroup1();
CheckSession();

if(isset($_POST['settingID']))
{
	$settingID = $_POST['settingID'];
}
if(isset($_POST['page']))
{
	$page = $_POST['page'];
}
if(isset($_POST['Order']))
{
	$Order = $_POST['Order'];
}
if(isset($_POST['Sort']))
{
	$Sort = $_POST['Sort'];
}
if(isset($_POST['CompanyDate']))
{
	$CompanyDate = $_POST['CompanyDate'];
}
if(isset($_POST['CompanyName']))
{
	$CompanyName = $_POST['CompanyName'];
}
if(isset($_POST['CompanyAddress']))
{
	$CompanyAddress = $_POST['CompanyAddress'];
}
if(isset($_POST['CompanyPostal']))
{
	$CompanyPostal = $_POST['CompanyPostal'];
}
if(isset($_POST['CompanyCity']))
{
	$CompanyCity = $_POST['CompanyCity'];
}
if(isset($_POST['CompanyCountry']))
{
	$CompanyCountry = $_POST['CompanyCountry'];
}
if(isset($_POST['CompanyPhone']))
{
	$CompanyPhone = $_POST['CompanyPhone'];
}
if(isset($_POST['CompanyFax']))
{
	$CompanyFax = $_POST['CompanyFax'];
}
if(isset($_POST['CompanyEmail']))
{
	$CompanyEmail = $_POST['CompanyEmail'];
}
if(isset($_POST['CompanyURL']))
{
	$CompanyURL = $_POST['CompanyURL'];
}
if(isset($_POST['CompanyWAP']))
{
	$CompanyWAP = $_POST['CompanyWAP'];
}
if(isset($_POST['CompanyCurrency']))
{
	$CompanyCurrency = $_POST['CompanyCurrency'];
}
if(isset($_POST['CompanyTaxFree']))
{
	$CompanyTaxFree = $_POST['CompanyTaxFree'];
}
if(isset($_POST['SalesPrices']))
{
	$SalesPrices = $_POST['SalesPrices'];
}
if(isset($_POST['CompanyTaxnr']))
{
	$CompanyTaxnr = $_POST['CompanyTaxnr'];
}
if(isset($_POST['BusinessTaxnr']))
{
	$BusinessTaxnr = $_POST['BusinessTaxnr'];
}
if(isset($_POST['BankName']))
{
	$BankName = $_POST['BankName'];
}
if(isset($_POST['BankAccount']))
{
	$BankAccount = $_POST['BankAccount'];
}
if(isset($_POST['BankNumber']))
{
	$BankNumber = $_POST['BankNumber'];
}
if(isset($_POST['BankIBAN']))
{
	$BankIBAN = $_POST['BankIBAN'];
}
if(isset($_POST['BankBIC']))
{
	$BankBIC = $_POST['BankBIC'];
}

// Database connection
//
DBConnect();

function UserInput($mark)
{
	global $smarty, $settingID, $page, $CompanyDate, $CompanyName, $CompanyAddress, $CompanyPostal,
	$CompanyCity, $CompanyCountry, $CompanyPhone, $CompanyFax, $CompanyEmail, $CompanyURL, $CompanyWAP,
	$CompanyCurrency, $CompanyTaxFree, $SalesPrices, $CompanyTaxnr, $BusinessTaxnr, $BankName, $BankAccount, $BankNumber,
	$BankIBAN, $BankBIC, $Order, $Sort;
	$smarty->assign("settingID","$settingID");
	$smarty->assign("page","$page");
	$smarty->assign("CompanyDate","$CompanyDate");
	$smarty->assign("CompanyName","$CompanyName");
	$smarty->assign("CompanyAddress","$CompanyAddress");
	$smarty->assign("CompanyPostal","$CompanyPostal");
	$smarty->assign("CompanyCity","$CompanyCity");
	$smarty->assign("CompanyCountry","$CompanyCountry");
	$smarty->assign("CompanyPhone","$CompanyPhone");
	$smarty->assign("CompanyFax","$CompanyFax");
	$smarty->assign("CompanyEmail","$CompanyEmail");
	$smarty->assign("CompanyURL","$CompanyURL");
	$smarty->assign("CompanyWAP","$CompanyWAP");
	$smarty->assign("CompanyCurrency","$CompanyCurrency");
	$smarty->assign("CompanyTaxFree","$CompanyTaxFree");
	$smarty->assign("SalesPrices","$SalesPrices");
	$smarty->assign("CompanyTaxnr","$CompanyTaxnr");
	$smarty->assign("BusinessTaxnr","$BusinessTaxnr");
	$smarty->assign("BankName","$BankName");
	$smarty->assign("BankAccount","$BankAccount");
	$smarty->assign("BankNumber","$BankNumber");
	$smarty->assign("BankIBAN","$BankIBAN");
	$smarty->assign("BankBIC","$BankBIC");
	$smarty->assign("Order","$Order");
	$smarty->assign("Sort","$Sort");
	$smarty->assign("Mark","$mark");
}

list($day, $month, $year) = explode(".", $CompanyDate);

if(empty($CompanyDate))
{
	$smarty->assign("FieldError","$a[date_text] - $a[field_error]");
	UserInput("CompanyDate");
}
else if (!checkdate($month, $day, $year))
{
	$smarty->assign("FieldError","$a[date_text] - $a[field_error]");
	UserInput("CompanyDate");
}
else if (empty($CompanyName))
{
	$smarty->assign("FieldError","$a[company_name] - $a[field_error]");
	UserInput("CompanyName");
}
else if (empty($CompanyAddress))
{
	$smarty->assign("FieldError","$a[company_address] - $a[field_error]");
	UserInput("CompanyAddress");
}
else if (empty($CompanyPostal))
{
	$smarty->assign("FieldError","$a[company_postal] - $a[field_error]");
	UserInput("CompanyPostal");
}
else if (empty($CompanyCity))
{
	$smarty->assign("FieldError","$a[company_city] - $a[field_error]");
	UserInput("CompanyCity");
}
else if (empty($CompanyCountry))
{
	$smarty->assign("FieldError","$a[company_country] - $a[field_error]");
	UserInput("CompanyCountry");
}
else if (empty($CompanyCurrency))
{
	$smarty->assign("FieldError","$a[company_currency] - $a[field_error]");
	UserInput("CompanyCurrency");
}
else
{
	$CompanyDate = German_Mysql_Date($CompanyDate);
	if(empty($SalesPrices))
	{
		$query = $db->Execute("UPDATE {$TBLName}setting SET COMPANY_DATE='$CompanyDate', COMPANY_NAME='$CompanyName', COMPANY_ADDRESS='$CompanyAddress', COMPANY_POSTAL='$CompanyPostal', COMPANY_CITY='$CompanyCity', COMPANY_COUNTRY='$CompanyCountry', COMPANY_PHONE='$CompanyPhone', COMPANY_FAX='$CompanyFax', COMPANY_EMAIL='$CompanyEmail', COMPANY_URL='$CompanyURL', COMPANY_WAP='$CompanyWAP', COMPANY_CURRENCY='$CompanyCurrency', TAX_FREE='$CompanyTaxFree', COMPANY_TAXNR='$CompanyTaxnr', COMPANY_BUSINESS_TAXNR='$BusinessTaxnr', COMPANY_BANKNAME='$BankName', COMPANY_BANKACCOUNT='$BankAccount', COMPANY_BANKNUMBER='$BankNumber', COMPANY_BANKIBAN='$BankIBAN', COMPANY_BANKBIC='$BankBIC', MODIFIEDBY='$_SESSION[Username]' WHERE SETTINGID=$settingID");
	}
	else
	{
		$query = $db->Execute("UPDATE {$TBLName}setting SET COMPANY_DATE='$CompanyDate', COMPANY_NAME='$CompanyName', COMPANY_ADDRESS='$CompanyAddress', COMPANY_POSTAL='$CompanyPostal', COMPANY_CITY='$CompanyCity', COMPANY_COUNTRY='$CompanyCountry', COMPANY_PHONE='$CompanyPhone', COMPANY_FAX='$CompanyFax', COMPANY_EMAIL='$CompanyEmail', COMPANY_URL='$CompanyURL', COMPANY_WAP='$CompanyWAP', COMPANY_CURRENCY='$CompanyCurrency', COMPANY_SALESPRICE='$SalesPrices', TAX_FREE='$CompanyTaxFree', COMPANY_TAXNR='$CompanyTaxnr', COMPANY_BUSINESS_TAXNR='$BusinessTaxnr', COMPANY_BANKNAME='$BankName', COMPANY_BANKACCOUNT='$BankAccount', COMPANY_BANKNUMBER='$BankNumber', COMPANY_BANKIBAN='$BankIBAN', COMPANY_BANKBIC='$BankBIC', MODIFIEDBY='$_SESSION[Username]' WHERE SETTINGID=$settingID");
	}
	Header("Location: $web/config/list.php?page=$page&Order=$Order&Sort=$Sort&$sessname=$sessid#$settingID");
}

$smarty->display('config/editf_company.tpl');
?>
Return current item: PhpRechnung