Location: PHPKode > projects > PhpRechnung > phpRechnung/offer/customerlist.php
<?php
/*
	customerlist.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();
CheckSession();

if(isset($_REQUEST['myID']))
{
	$myID = $_REQUEST['myID'];
	$smarty->assign("myID","$myID");
}
if(isset($_REQUEST['infoID']))
{
	$infoID = $_REQUEST['infoID'];
	$smarty->assign("infoID","$infoID");
}
if(isset($_REQUEST['page']))
{
	$page = $_REQUEST['page'];
	$smarty->assign("page","$page");
}
if(isset($_REQUEST['offerID']))
{
	$offerID = $_REQUEST['offerID'];
	$smarty->assign("offerID","$offerID");
}
if(isset($_REQUEST['messageID']))
{
	$messageID = $_REQUEST['messageID'];
	$smarty->assign("messageID","$messageID");
}
if(isset($_REQUEST['OfferDate']))
{
	$OfferDate = $_REQUEST['OfferDate'];
	$smarty->assign("OfferDate","$OfferDate");
}
if(isset($_REQUEST['OfferStatus']))
{
	$OfferStatus = $_REQUEST['OfferStatus'];
	$smarty->assign("OfferStatus","$OfferStatus");
}
if(isset($_REQUEST['MethodOfPaymentDate']))
{
	$MethodOfPaymentDate = $_REQUEST['MethodOfPaymentDate'];
	$smarty->assign("MethodOfPaymentDate","$MethodOfPaymentDate");
}
if(isset($_REQUEST['MethodOfPayment']))
{
	$MethodOfPayment = $_REQUEST['MethodOfPayment'];
	$smarty->assign("NR_METHOD_OF_PAYMENT","$MethodOfPayment");
}
if(isset($_REQUEST['Note']))
{
	$Note = $_REQUEST['Note'];
	$smarty->assign("Note","$Note");
}
if(!empty($_REQUEST['CustPage']))
{
	$intCurrentPage = $_REQUEST['CustPage'];
} else {
	$intCurrentPage = 1;
}
if(isset($_REQUEST['Customer']))
{
	$Customer = $_REQUEST['Customer'];
	$smarty->assign("Customer","$Customer");
}
if(isset($_REQUEST['OfferID1']))
{
	$OfferID1 = $_REQUEST['OfferID1'];
}
if(isset($_REQUEST['CustomerID1']))
{
	$CustomerID1 = $_REQUEST['CustomerID1'];
}
if(isset($_REQUEST['DateFrom1']))
{
	$DateFrom1 = $_REQUEST['DateFrom1'];
}
if(isset($_REQUEST['DateTill1']))
{
	$DateTill1 = $_REQUEST['DateTill1'];
}
if(isset($_REQUEST['Total1']))
{
	$Total1 = $_REQUEST['Total1'];
	$smarty->assign("Total1","$Total1");
}
if(isset($_REQUEST['Customer1']))
{
	$Customer1 = $_REQUEST['Customer1'];
}
if(!empty($_REQUEST['CustOrder']))
{
	$CustOrder = $_REQUEST['CustOrder'];
	$smarty->assign("CustOrder","$CustOrder");
} else {
	$CustOrder = "LASTNAME,FIRSTNAME,COMPANY";
	$smarty->assign("CustOrder","$CustOrder");
}
if(isset($_REQUEST['CustSort']))
{
	$CustSort = $_REQUEST['CustSort'];
	$smarty->assign("CustSort","$CustSort");
}
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['Canceled']))
{
	$Canceled = $_REQUEST['Canceled'];
	$smarty->assign("Canceled","$Canceled");
}

$Requestedstring = "page=$page&amp;offerID=$offerID&amp;infoID=$infoID&amp;messageID=$messageID&amp;OfferDate=$OfferDate&amp;OfferStatus=$OfferStatus&amp;MethodOfPayment=$MethodOfPayment&amp;MethodOfPaymentDate=$MethodOfPaymentDate&amp;Pos_Quantity=$Pos_Quantity&amp;Note=$Note&amp;Order=$Order&amp;Sort=$Sort&amp;tmpID=1&amp;Canceled=$Canceled";
$smarty->assign("Requestedstring","$Requestedstring");

$Searchstring = "OfferID1=$OfferID1&amp;CustomerID1=$CustomerID1&amp;DateFrom1=$DateFrom1&amp;DateTill1=$DateTill1&amp;Total1=$Total1&amp;Customer1=$Customer1";
$smarty->assign("Searchstring","$Searchstring");

$smarty->assign("Title","$a[addressbook] - $a[searchresult]");
$smarty->assign("First_Name","$a[firstname]");
$smarty->assign("Last_Name","$a[lastname]");
$smarty->assign("Company_Name","$a[company]");
$smarty->assign("Issue_Offer","$a[issue_offer]");
$smarty->assign("Customer_No","$a[customer_no]");

// Database connection
//
DBConnect();

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

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

// Get Customer Information
//
$query = $db->GetAll("SELECT LASTNAME, FIRSTNAME, COMPANY, MYID FROM {$TBLName}addressbook
		WHERE FIRSTNAME LIKE '%$Customer%' OR LASTNAME LIKE '%$Customer%' OR COMPANY LIKE '%$Customer%'
		ORDER BY $CustOrder $CustSort LIMIT $intCursor, $EntrysPerPage");

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

	// Count search result
	//
	$query1 = $db->Execute("SELECT LASTNAME, FIRSTNAME, COMPANY, MYID FROM {$TBLName}addressbook
		WHERE FIRSTNAME LIKE '%$Customer%' OR LASTNAME LIKE '%$Customer%' OR COMPANY LIKE '%$Customer%'");

	foreach($query1 as $result1)
	{
		$numrows += count($query1);
	}

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

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

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

// 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', "CustPage=$intCurrentPage&amp;");

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

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

$smarty->display('offer/customerlist.tpl');

?>
Return current item: PhpRechnung