Location: PHPKode > projects > PhpRechnung > phpRechnung/reports/customer_booking_details.php
<?php
/*
	customer_booking_details.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/company_settings.inc.php");
require_once("../include/smarty.inc.php");
CheckUser();
CheckAdminGroup3();
CheckSession();

if(isset($_REQUEST['myID'])) {
	$myID = $_REQUEST['myID'];
	$smarty->assign("myID","$myID");
}
if(isset($_REQUEST['invoiceID'])) {
	$invoiceID = $_REQUEST['invoiceID'];
	$smarty->assign("invoiceID","$invoiceID");
}
if(isset($_REQUEST['paymentID'])) {
	$paymentID = $_REQUEST['paymentID'];
	$smarty->assign("paymentID","$paymentID");
}
if(isset($_REQUEST['offerID'])) {
	$offerID = $_REQUEST['offerID'];
	$smarty->assign("offerID","$offerID");
}
if(!empty($_REQUEST['page']))
{
	$intCurrentPage = $_REQUEST['page'];
} else {
	$intCurrentPage = 1;
}
if(isset($_REQUEST['infoID'])) {
	$infoID = $_REQUEST['infoID'];
	$smarty->assign("infoID","$infoID");
}
if(isset($_REQUEST['Customer'])) {
	$Customer = $_REQUEST['Customer'];
	$smarty->assign("Customer","$Customer");
}
if(isset($_REQUEST['messageID'])) {
	$messageID = $_REQUEST['messageID'];
	$smarty->assign("messageID","$messageID");
}
if(isset($_REQUEST['new_offerID'])) {
	$new_offerID = $_REQUEST['new_offerID'];
	$smarty->assign("new_offerID","$new_offerID");
}

if(isset($_REQUEST['PrintName1'])) {
	$PrintName1 = $_REQUEST['PrintName1'];
	$smarty->assign("PrintName1","$PrintName1");
}
if(isset($_REQUEST['DateFrom'])) {
	$DateFrom = $_REQUEST['DateFrom'];
	$smarty->assign("DateFrom","$DateFrom");
}
if(isset($_REQUEST['DateTill'])) {
	$DateTill = $_REQUEST['DateTill'];
	$smarty->assign("DateTill","$DateTill");
}
if(isset($_REQUEST['Date_From1'])) {
	$Date_From1 = $_REQUEST['Date_From1'];
	$smarty->assign("Date_From1","$Date_From1");
}
if(isset($_REQUEST['Date_Till1'])) {
	$Date_Till1 = $_REQUEST['Date_Till1'];
	$smarty->assign("Date_Till1","$Date_Till1");
}
if(isset($_REQUEST['CustomerID'])) {
	$CustomerID = $_REQUEST['CustomerID'];
	$smarty->assign("CustomerID","$CustomerID");
}
if(isset($_REQUEST['Prefix1'])) {
	$Prefix1 = $_REQUEST['Prefix1'];
	$smarty->assign("Prefix1","$Prefix1");
}
if(isset($_REQUEST['Firstname1'])) {
	$Firstname1 = $_REQUEST['Firstname1'];
	$smarty->assign("Firstname1","$Firstname1");
}
if(isset($_REQUEST['Lastname1'])) {
	$Lastname1 = $_REQUEST['Lastname1'];
	$smarty->assign("Lastname1","$Lastname1");
}
if(isset($_REQUEST['Title11'])) {
	$Title11 = $_REQUEST['Title11'];
	$smarty->assign("Title11","$Title11");
}
if(isset($_REQUEST['Company1'])) {
	$Company1 = $_REQUEST['Company1'];
	$smarty->assign("Company1","$Company1");
}
if(isset($_REQUEST['Department1'])) {
	$Department1 = $_REQUEST['Department1'];
	$smarty->assign("Department1","$Department1");
}
if(isset($_REQUEST['Address1'])) {
	$Address1 = $_REQUEST['Address1'];
	$smarty->assign("Address1","$Address1");
}
if(isset($_REQUEST['Country1'])) {
	$Country1 = $_REQUEST['Country1'];
	$smarty->assign("Country1","$Country1");
}
if(isset($_REQUEST['Postalcode1'])) {
	$Postalcode1 = $_REQUEST['Postalcode1'];
	$smarty->assign("Postalcode1","$Postalcode1");
}
if(isset($_REQUEST['City1'])) {
	$City1 = $_REQUEST['City1'];
	$smarty->assign("City1","$City1");
}
if(isset($_REQUEST['Stateprov1'])) {
	$Stateprov1 = $_REQUEST['Stateprov1'];
	$smarty->assign("Stateprov1","$Stateprov1");
}
if(isset($_REQUEST['Position11'])) {
	$Position11 = $_REQUEST['Position11'];
	$smarty->assign("Position1","$Position1");
}
if(isset($_REQUEST['Initials1'])) {
	$Initials1 = $_REQUEST['Initials1'];
	$smarty->assign("Initials1","$Initials1");
}
if(isset($_REQUEST['Salutation1'])) {
	$Salutation1 = $_REQUEST['Salutation1'];
	$smarty->assign("Salutation1","$Salutation1");
}
if(isset($_REQUEST['Phonehome1'])) {
	$Phonehome1 = $_REQUEST['Phonehome1'];
	$smarty->assign("Phonehome1","$Phonehome1");
}
if(isset($_REQUEST['Phoneoffi1'])) {
	$Phoneoffi1 = $_REQUEST['Phoneoffi1'];
	$smarty->assign("Phoneoffi1","$Phoneoffi1");
}
if(isset($_REQUEST['Phoneothe1'])) {
	$Phoneothe1 = $_REQUEST['Phoneothe1'];
	$smarty->assign("Phoneothe1","$Phoneothe1");
}
if(isset($_REQUEST['Phonework1'])) {
	$Phonework1 = $_REQUEST['Phonework1'];
	$smarty->assign("Phonework1","$Phonework1");
}
if(isset($_REQUEST['Mobile1'])) {
	$Mobile1 = $_REQUEST['Mobile1'];
	$smarty->assign("Mobile1","$Mobile1");
}
if(isset($_REQUEST['Pager1'])) {
	$Pager1 = $_REQUEST['Pager1'];
	$smarty->assign("Pager1","$Pager1");
}
if(isset($_REQUEST['Fax1'])) {
	$Fax1 = $_REQUEST['Fax1'];
	$smarty->assign("Fax1","$Fax1");
}
if(isset($_REQUEST['Email1'])) {
	$Email1 = $_REQUEST['Email1'];
	$smarty->assign("Email1","$Email1");
}
if(isset($_REQUEST['Url1'])) {
	$Url1 = $_REQUEST['Url1'];
	$smarty->assign("Url1","$Url1");
}
if(isset($_REQUEST['Note1'])) {
	$Note1 = $_REQUEST['Note1'];
	$smarty->assign("Note1","$Note1");
}
if(isset($_REQUEST['AltField11'])) {
	$AltField11 = $_REQUEST['AltField11'];
	$smarty->assign("AltField11","$AltField11");
}
if(isset($_REQUEST['AltField21'])) {
	$AltField21 = $_REQUEST['AltField21'];
	$smarty->assign("AltField21","$AltField21");
}
if(isset($_REQUEST['AltField31'])) {
	$AltField31 = $_REQUEST['AltField31'];
	$smarty->assign("AltField31","$AltField31");
}
if(isset($_REQUEST['AltField41'])) {
	$AltField41 = $_REQUEST['AltField41'];
	$smarty->assign("AltField41","$AltField41");
}
if(isset($_REQUEST['Category1'])) {
	$Category1 = $_REQUEST['Category1'];
	$smarty->assign("Category1","$Category1");
}
if(isset($_REQUEST['MethodOfPayment1'])) {
	$MethodOfPayment1 = $_REQUEST['MethodOfPayment1'];
	$smarty->assign("MethodOfPayment1","$MethodOfPayment1");
}
if(isset($_REQUEST['Birthday1'])) {
	$Birthday1 = $_REQUEST['Birthday1'];
	$smarty->assign("Birthday1","$Birthday1");
}
if(!empty($_REQUEST['Order']))
{
	$Order = $_REQUEST['Order'];
	$smarty->assign("Order","$Order");
} else {
	$Order = "P.PAYMENT_DATE DESC";
	$smarty->assign("Order","$Order");
}
if(isset($_REQUEST['Sort']))
{
	$Sort = $_REQUEST['Sort'];
	$smarty->assign("Sort","$Sort");
}
if(isset($_REQUEST['Report']))
{
	$Report = $_REQUEST['Report'];
	$smarty->assign("Report","$Report");
}
if(isset($_REQUEST['Canceled']))
{
	$Canceled = $_REQUEST['Canceled'];
	$smarty->assign("Canceled","$Canceled");
}

$Searchstring = "myID=$myID&amp;DateFrom=$DateFrom&amp;DateTill=$DateTill&amp;Report=$Report&amp;CustomerID=$CustomerID&amp;Prefix1=$Prefix1&amp;Title11=$Title11&amp;Firstname1=$Firstname1&amp;Initials1=$Initials1&amp;Lastname1=$Lastname1&amp;Phonehome1=$Phonehome1&amp;Salutation1=$Salutation1&amp;Mobile1=$Mobile1&amp;Address1=$Address1&amp;Fax1=$Fax1&amp;Stateprov1=$Stateprov1&amp;Email1=$Email1&amp;Postalcode1=$Postalcode1&amp;City1=$City1&amp;Url1=$Url1&amp;Company1=$Company1&amp;Phonework1=$Phonework1&amp;Department1=$Department1&amp;Phoneoffi1=$Phoneoffi1&amp;Position11=$Position11&amp;Phoneothe1=$Phoneothe1&amp;Pager1=$Pager1&amp;Note1=$Note1&amp;Altfield11=$AltField11&amp;Altfield21=$AltField21&amp;Altfield31=$AltField31&amp;Altfield41=$AltField41&amp;Country1=$Country1&amp;Date_From1=$Date_From1&amp;Date_Till1=$Date_Till1&amp;Birthday1=$Birthday1&amp;Category1=$Category1&amp;MethodOfPayment1=$MethodOfPayment1&amp;PrintName1=$PrintName1";
$smarty->assign("Searchstring","$Searchstring");

$smarty->assign("Title","$a[reports] - $a[booking_details]");
$smarty->assign("SearchResult","$a[booking_details]");
$smarty->assign("First_Name","$a[firstname]");
$smarty->assign("Last_Name","$a[lastname]");
$smarty->assign("Company_Name","$a[company]");
$smarty->assign("Customer_No","$a[customer_no]");
$smarty->assign("Customer","$a[customer]");
$smarty->assign("EntryCanceled","$a[entry_canceled]");
$smarty->assign("NewEntry","$a[new_entry]");
$smarty->assign("Payment_No","$a[payment_number]");
$smarty->assign("Payment_Sum","$a[payment_sum]");
$smarty->assign("Total_Payment","$a[total_payment]");
$smarty->assign("Open_Account","$a[open_account]");
$smarty->assign("Method_Of_Payment","$a[method_of_payment]");
$smarty->assign("Date_From","$a[date_from]");
$smarty->assign("Date_Till","$a[date_till]");

// Database connection
//
DBConnect();

// Get data from company_settings.inc.php
//
$smarty->assign("Payment_Currency",$CompanyCurrency);

$intCursor = ($intCurrentPage - 1) * $EntrysPerPage;

$DateFrom = German_Mysql_Date($DateFrom);
$DateTill = German_Mysql_Date($DateTill);

if($Canceled == 1)
{
	$query = $db->GetAll("SELECT A.MYID, A.FIRSTNAME, A.LASTNAME, A.COMPANY,  P.CREATEDBY, P.PAYMENTID, P.INVOICEID, P.MYID, DATE_FORMAT(P.PAYMENT_DATE,'%d.%m.%Y') AS PAYMENT_DATE, P.SUM_PAID, P.METHOD_OF_PAY, P.CANCELED FROM {$TBLName}payment AS P, {$TBLName}addressbook AS A
		WHERE P.CANCELED=1 AND A.MYID=$myID AND P.MYID=$myID AND P.PAYMENT_DATE >= '$DateFrom' AND P.PAYMENT_DATE <= '$DateTill' ORDER BY $Order $Sort LIMIT $intCursor, $EntrysPerPage");
}
else if($Canceled == 3)
{
	$query = $db->GetAll("SELECT A.MYID, A.FIRSTNAME, A.LASTNAME, A.COMPANY,  P.CREATEDBY, P.PAYMENTID, P.INVOICEID, P.MYID, DATE_FORMAT(P.PAYMENT_DATE,'%d.%m.%Y') AS PAYMENT_DATE, P.SUM_PAID, P.METHOD_OF_PAY, P.CANCELED FROM {$TBLName}payment AS P, {$TBLName}addressbook AS A
		WHERE AND A.MYID=$myID AND P.MYID=$myID AND P.PAYMENT_DATE >= '$DateFrom' AND P.PAYMENT_DATE <= '$DateTill' ORDER BY $Order $Sort LIMIT $intCursor, $EntrysPerPage");
}
else
{
	$query = $db->GetAll("SELECT A.MYID, A.FIRSTNAME, A.LASTNAME, A.COMPANY,  P.CREATEDBY, P.PAYMENTID, P.INVOICEID, P.MYID, DATE_FORMAT(P.PAYMENT_DATE,'%d.%m.%Y') AS PAYMENT_DATE, P.SUM_PAID, P.METHOD_OF_PAY, P.CANCELED FROM {$TBLName}payment AS P, {$TBLName}addressbook AS A
		WHERE P.CANCELED=2 AND A.MYID=$myID AND P.MYID=$myID AND P.PAYMENT_DATE >= '$DateFrom' AND P.PAYMENT_DATE <= '$DateTill' ORDER BY $Order $Sort LIMIT $intCursor, $EntrysPerPage");
}

// If an error has occurred, display the error message
//
if (!$query)
	print($db->ErrorMsg());
else
	// Count PageRows
	//
	$pagenumrows = count($query);

	// Count MaxRows
	//

	if($Canceled == 1)
	{
		$query1 = $db->Execute("SELECT A.MYID, A.FIRSTNAME, A.LASTNAME, A.COMPANY,  P.CREATEDBY, P.PAYMENTID, P.INVOICEID, P.MYID, DATE_FORMAT(P.PAYMENT_DATE,'%d.%m.%Y') AS PAYMENT_DATE, P.SUM_PAID, P.METHOD_OF_PAY, P.CANCELED FROM {$TBLName}payment AS P, {$TBLName}addressbook AS A
			WHERE P.CANCELED=1 AND A.MYID=$myID AND P.MYID=$myID AND P.PAYMENT_DATE >= '$DateFrom' AND P.PAYMENT_DATE <= '$DateTill'");
	}
	else if($Canceled == 3)
	{
		$query1 = $db->Execute("SELECT A.MYID, A.FIRSTNAME, A.LASTNAME, A.COMPANY,  P.CREATEDBY, P.PAYMENTID, P.INVOICEID, P.MYID, DATE_FORMAT(P.PAYMENT_DATE,'%d.%m.%Y') AS PAYMENT_DATE, P.SUM_PAID, P.METHOD_OF_PAY, P.CANCELED FROM {$TBLName}payment AS P, {$TBLName}addressbook AS A
			WHERE A.MYID=$myID AND P.MYID=$myID AND P.PAYMENT_DATE >= '$DateFrom' AND P.PAYMENT_DATE <= '$DateTill'");
	}
	else
	{
		$query1 = $db->Execute("SELECT A.MYID, A.FIRSTNAME, A.LASTNAME, A.COMPANY,  P.CREATEDBY, P.PAYMENTID, P.INVOICEID, P.MYID, DATE_FORMAT(P.PAYMENT_DATE,'%d.%m.%Y') AS PAYMENT_DATE, P.SUM_PAID, P.METHOD_OF_PAY, P.CANCELED FROM {$TBLName}payment AS P, {$TBLName}addressbook AS A
			WHERE P.CANCELED=2 AND A.MYID=$myID AND P.MYID=$myID AND P.PAYMENT_DATE >= '$DateFrom' AND P.PAYMENT_DATE <= '$DateTill'");
	}

	if (!$query1)
		print($db->ErrorMsg());
	else
		foreach($query1 as $result1)
		{
			$numrows += count($query1);

			// Save Total Searchresult Sum Paid
			//
			$TotalSearchresult += $result1['SUM_PAID'];
			$smarty->assign("TOTAL_SEARCHRESULT",$TotalSearchresult);
		}

	// Save MaxPages
	//
	$intPages = ceil($numrows/$EntrysPerPage);

	// Save all entrys in $PaymentData array
	//
	foreach($query as $result)
	{
		$PaymentData[] = $result;

		// Save Total Page Sum Paid
		//
		$TotalPage += $result['SUM_PAID'];
		$smarty->assign("TOTAL_PAGE",$TotalPage);
	}

	$smarty->assign("PageRows","$pagenumrows");
	$smarty->assign("MaxRows","$numrows");
	$smarty->assign('PaymentData', $PaymentData);

// Display pager only if $numrows > $EntrysPerPage ( lines per page )
// from settings menu
//
if ($numrows > $EntrysPerPage)
{
	$smarty->assign('CurrentPage', "$intCurrentPage");
	$smarty->assign('MaxPages', "$intPages");
	$smarty->assign('AddCurrentPage', "page=$intCurrentPage&amp;");

	// If we are not on first page then display
	// first page, previous page link
	//
	if ($intCurrentPage > 1)
	{
		$Page = $intCurrentPage - 1;
		$smarty->assign('PrevPage', "$Page");
	}

	// If we are not on the last page then display
	// next page, last page link
	//
	if ($intCurrentPage < $intPages)
	{
		$Page = $intCurrentPage + 1;
		$smarty->assign('NextPage', "$Page");
	}
}

$smarty->display('reports/customer_booking_details.tpl');

?>
Return current item: PhpRechnung