Location: PHPKode > projects > PhpRechnung > phpRechnung/config/edit_company.php
<?php
/*
	edit_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($_REQUEST['settingID']))
{
	$settingID = $_REQUEST['settingID'];
	$smarty->assign("settingID","$settingID");
}
if(isset($_REQUEST['page']))
{
	$page = $_REQUEST['page'];
	$smarty->assign("page","$page");
}
if(isset($_REQUEST['Order']))
{
	$Order = $_REQUEST['Order'];
	$smarty->assign("Order","$Order");
}
if(isset($_REQUEST['Sort']))
{
	$Sort = $_REQUEST['Sort'];
	$smarty->assign("Sort","$Sort");
}
if(isset($_REQUEST['Mark']))
{
	$Mark = $_REQUEST['Mark'];
	$smarty->assign("Mark","$Mark");
}
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'];
}

$smarty->assign("Title","$a[settings] - $a[edit] - $a[company_settings]");
$smarty->assign("Basic_Settings","$a[basic_settings]");
$smarty->assign("Company_Settings","$a[company_settings]");
$smarty->assign("PDF_Settings","$a[pdf_settings]");
$smarty->assign("Company_Name","$a[company_name]");
$smarty->assign("Company_Address","$a[company_address]");
$smarty->assign("Company_Postal","$a[company_postal]");
$smarty->assign("Company_City","$a[company_city]");
$smarty->assign("Company_Country","$a[company_country]");
$smarty->assign("Company_Phone","$a[company_phone]");
$smarty->assign("Company_Fax","$a[company_fax]");
$smarty->assign("Company_Email","$a[company_email]");
$smarty->assign("Company_URL","$a[company_url]");
$smarty->assign("Company_WAP","$a[company_wap]");
$smarty->assign("Company_Currency","$a[company_currency]");
$smarty->assign("Company_Tax_Free","$a[company_tax_free]");
$smarty->assign("Sales_Prices","$a[sales_prices]");
$smarty->assign("Company_Taxnr","$a[company_taxnr]");
$smarty->assign("Business_Taxnr","$a[business_taxnr]");
$smarty->assign("Bank_Name","$a[bank_name]");
$smarty->assign("Bank_Account","$a[bank_account]");
$smarty->assign("Bank_Number","$a[bank_number]");
$smarty->assign("Bank_IBAN","$a[bank_iban]");
$smarty->assign("Bank_BIC","$a[bank_bic]");

// Database connection
//
DBConnect();

// Get company related entrys from setting table
//
$query = $db->GetAll("SELECT DATE_FORMAT(COMPANY_DATE,'%d.%m.%Y') AS COMPANY_DATE, COMPANY_NAME, COMPANY_ADDRESS, COMPANY_POSTAL, COMPANY_CITY, COMPANY_COUNTRY, COMPANY_PHONE,
		COMPANY_FAX, COMPANY_EMAIL, COMPANY_URL, COMPANY_WAP, COMPANY_TAXNR, COMPANY_BUSINESS_TAXNR, COMPANY_BANKNAME, COMPANY_BANKACCOUNT, COMPANY_BANKNUMBER, COMPANY_BANKIBAN, COMPANY_BANKBIC, COMPANY_CURRENCY,
		COMPANY_SALESPRICE, TAX_FREE, SETTINGID FROM {$TBLName}setting WHERE SETTINGID=$settingID");

// If an error has occurred, display the error message
//
if (!$query)
	print($db->ErrorMsg());
else
	foreach($query as $f)
	{
		$sp = $f['COMPANY_SALESPRICE'];
		if (empty($CompanyDate))
		{
			$smarty->assign("CompanyDate",$f['COMPANY_DATE']);
		}
		else
		{
			$smarty->assign("CompanyDate","$CompanyDate");
		}
		if (empty($CompanyName))
		{
			$smarty->assign("CompanyName",$f['COMPANY_NAME']);
		}
		else
		{
			$smarty->assign("CompanyName","$CompanyName");
		}
		if (empty($CompanyAddress))
		{
			$smarty->assign("CompanyAddress",$f['COMPANY_ADDRESS']);
		}
		else
		{
			$smarty->assign("CompanyAddress","$CompanyAddress");
		}
		if (empty($CompanyPostal))
		{
			$smarty->assign("CompanyPostal",$f['COMPANY_POSTAL']);
		}
		else
		{
			$smarty->assign("CompanyPostal","$CompanyPostal");
		}
		if (empty($CompanyCity))
		{
			$smarty->assign("CompanyCity",$f['COMPANY_CITY']);
		}
		else
		{
			$smarty->assign("CompanyCity","$CompanyCity");
		}
		if (empty($CompanyCountry))
		{
			$smarty->assign("CompanyCountry",$f['COMPANY_COUNTRY']);
		}
		else
		{
			$smarty->assign("CompanyCountry","$CompanyCountry");
		}
		if (empty($CompanyPhone))
		{
			$smarty->assign("CompanyPhone",$f['COMPANY_PHONE']);
		}
		else
		{
			$smarty->assign("CompanyPhone","$CompanyPhone");
		}
		if (empty($CompanyFax))
		{
			$smarty->assign("CompanyFax",$f['COMPANY_FAX']);
		}
		else
		{
			$smarty->assign("CompanyFax","$CompanyFax");
		}
		if (empty($CompanyEmail))
		{
			$smarty->assign("CompanyEmail",$f['COMPANY_EMAIL']);
		}
		else
		{
			$smarty->assign("CompanyEmail","$CompanyEmail");
		}
		if (empty($CompanyURL))
		{
			$smarty->assign("CompanyURL",$f['COMPANY_URL']);
		}
		else
		{
			$smarty->assign("CompanyURL","$CompanyURL");
		}
		if (empty($CompanyWAP))
		{
			$smarty->assign("CompanyWAP",$f['COMPANY_WAP']);
		}
		else
		{
			$smarty->assign("CompanyWAP","$CompanyWAP");
		}
		if (empty($CompanyCurrency))
		{
			$smarty->assign("CompanyCurrency",$f['COMPANY_CURRENCY']);
		}
		else
		{
			$smarty->assign("CompanyCurrency","$CompanyCurrency");
		}
		if (empty($CompanyTaxFree))
		{
			$smarty->assign("CompanyTaxFree",$f['TAX_FREE']);
		}
		else
		{
			$smarty->assign("CompanyTaxFree","$CompanyTaxFree");
		}
		if ($SalesPrices == "")
		{
			$smarty->assign("SalesPrices",$f['COMPANY_SALESPRICE']);
		}
		else
		{
			$smarty->assign("SalesPrices","$SalesPrices");
		}
		if (empty($CompanyTaxnr))
		{
			$smarty->assign("CompanyTaxnr",$f['COMPANY_TAXNR']);
		}
		else
		{
			$smarty->assign("CompanyTaxnr","$CompanyTaxnr");
		}
		if (empty($BusinessTaxnr))
		{
			$smarty->assign("BusinessTaxnr",$f['COMPANY_BUSINESS_TAXNR']);
		}
		else
		{
			$smarty->assign("BusinessTaxnr","$BusinessTaxnr");
		}
		if (empty($BankName))
		{
			$smarty->assign("BankName",$f['COMPANY_BANKNAME']);
		}
		else
		{
			$smarty->assign("BankName","$BankName");
		}
		if (empty($BankAccount))
		{
			$smarty->assign("BankAccount",$f['COMPANY_BANKACCOUNT']);
		}
		else
		{
			$smarty->assign("BankAccount","$BankAccount");
		}
		if (empty($BankNumber))
		{
			$smarty->assign("BankNumber",$f['COMPANY_BANKNUMBER']);
		}
		else
		{
			$smarty->assign("BankNumber","$BankNumber");
		}
		if (empty($BankIBAN))
		{
			$smarty->assign("BankIBAN",$f['COMPANY_BANKIBAN']);
		}
		else
		{
			$smarty->assign("BankIBAN","$BankIBAN");
		}
		if (empty($BankBIC))
		{
			$smarty->assign("BankBIC",$f['COMPANY_BANKBIC']);
		}
		else
		{
			$smarty->assign("BankBIC","$BankBIC");
		}
	}

// Check if there are any saved invoices
//
$query1 = $db->Execute("SELECT INVOICEID FROM {$TBLName}invoice");
$numrows1 = $query1->RowCount();
if ($numrows1)
{
	$smarty->assign("InvoiceAvailable","1");
	$smarty->assign("DisplaySalesPrice","$sales_price[$sp]");
}

// Save options in $net_gross_values
//
$smarty->assign("sales_price_values",array($sales_price));

$smarty->assign("choice_yes_no",array($choice_yes_no));

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