<?php
/* searchlist_e.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(!empty($_REQUEST['page']))
{
$intCurrentPage = $_REQUEST['page'];
}
else
{
$intCurrentPage = 1;
}
if(!empty($_REQUEST['Order']))
{
$Order = $_REQUEST['Order'];
$smarty->assign("Order","$Order");
}
else
{
$Order = "LASTNAME,FIRSTNAME,COMPANY";
$smarty->assign("Order","$Order");
}
if(isset($_REQUEST['Sort']))
{
$Sort = $_REQUEST['Sort'];
$smarty->assign("Sort","$Sort");
}
if(isset($_REQUEST['Customer']))
{
$Customer = $_REQUEST['Customer'];
$smarty->assign("Customer","$Customer");
}
if(isset($_REQUEST['PrintName1']))
{
$PrintName1 = $_REQUEST['PrintName1'];
}
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'];
}
if(isset($_REQUEST['Prefix1']))
{
$Prefix1 = $_REQUEST['Prefix1'];
}
if(isset($_REQUEST['Firstname1']))
{
$Firstname1 = $_REQUEST['Firstname1'];
}
if(isset($_REQUEST['Lastname1']))
{
$Lastname1 = $_REQUEST['Lastname1'];
}
if(isset($_REQUEST['Title11']))
{
$Title11 = $_REQUEST['Title11'];
}
if(isset($_REQUEST['Company1']))
{
$Company1 = $_REQUEST['Company1'];
}
if(isset($_REQUEST['Department1']))
{
$Department1 = $_REQUEST['Department1'];
}
if(isset($_REQUEST['Address1']))
{
$Address1 = $_REQUEST['Address1'];
}
if(isset($_REQUEST['Country1']))
{
$Country1 = $_REQUEST['Country1'];
}
if(isset($_REQUEST['Postalcode1']))
{
$Postalcode1 = $_REQUEST['Postalcode1'];
}
if(isset($_REQUEST['City1']))
{
$City1 = $_REQUEST['City1'];
}
if(isset($_REQUEST['Stateprov1']))
{
$Stateprov1 = $_REQUEST['Stateprov1'];
}
if(isset($_REQUEST['Position11']))
{
$Position11 = $_REQUEST['Position11'];
}
if(isset($_REQUEST['Initials1']))
{
$Initials1 = $_REQUEST['Initials1'];
}
if(isset($_REQUEST['Salutation1']))
{
$Salutation1 = $_REQUEST['Salutation1'];
}
if(isset($_REQUEST['Phonehome1']))
{
$Phonehome1 = $_REQUEST['Phonehome1'];
}
if(isset($_REQUEST['Phoneoffi1']))
{
$Phoneoffi1 = $_REQUEST['Phoneoffi1'];
}
if(isset($_REQUEST['Phoneothe1']))
{
$Phoneothe1 = $_REQUEST['Phoneothe1'];
}
if(isset($_REQUEST['Phonework1']))
{
$Phonework1 = $_REQUEST['Phonework1'];
}
if(isset($_REQUEST['Mobile1']))
{
$Mobile1 = $_REQUEST['Mobile1'];
}
if(isset($_REQUEST['Pager1']))
{
$Pager1 = $_REQUEST['Pager1'];
}
if(isset($_REQUEST['Fax1']))
{
$Fax1 = $_REQUEST['Fax1'];
}
if(isset($_REQUEST['Email1']))
{
$Email1 = $_REQUEST['Email1'];
}
if(isset($_REQUEST['Url1']))
{
$Url1 = $_REQUEST['Url1'];
}
if(isset($_REQUEST['Note1']))
{
$Note1 = $_REQUEST['Note1'];
}
if(isset($_REQUEST['Category1']))
{
$Category1 = $_REQUEST['Category1'];
}
if(isset($_REQUEST['MethodOfPayment1']))
{
$MethodOfPayment1 = $_REQUEST['MethodOfPayment1'];
}
if(isset($_REQUEST['Birthday1']))
{
$Birthday1 = $_REQUEST['Birthday1'];
}
$Searchstring = "CustomerID=$CustomerID&Prefix1=$Prefix1&Title11=$Title11&Firstname1=$Firstname1&Initials1=$Initials1&Lastname1=$Lastname1&Phonehome1=$Phonehome1&Salutation1=$Salutation1&Mobile1=$Mobile1&Address1=$Address1&Fax1=$Fax1&Stateprov1=$Stateprov1&Email1=$Email1&Postalcode1=$Postalcode1&City1=$City1&Url1=$Url1&Company1=$Company1&Phonework1=$Phonework1&Department1=$Department1&Phoneoffi1=$Phoneoffi1&Position11=$Position11&Phoneothe1=$Phoneothe1&Pager1=$Pager1&Note1=$Note1&Country1=$Country1&Date_From1=$Date_From1&Date_Till1=$Date_Till1&Birthday1=$Birthday1&Category1=$Category1&MethodOfPayment1=$MethodOfPayment1&PrintName1=$PrintName1";
$smarty->assign("Searchstring","$Searchstring");
$smarty->assign("Order","$Order");
$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("Phone_Work","$a[phonework]");
$smarty->assign("Issue_Invoice","$a[issue_invoice]");
$smarty->assign("Issue_Offer","$a[issue_offer]");
$smarty->assign("Customer_No","$a[customer_no]");
$smarty->assign("EntryChanged","$a[entry_changed]");
$smarty->assign("EntryDeleted","$a[entry_deleted]");
$smarty->assign("Email_OK","$a[email_ok]");
$smarty->assign("Email_Error","$a[email_error]");
$smarty->assign("DateFrom","$a[date_from]");
$smarty->assign("DateTill","$a[date_till]");
// Database connection
//
DBConnect();
$intCursor = ($intCurrentPage - 1) * $EntrysPerPage;
if (!empty($PrintName1))
{
$PrintName1 = "AND PRINT_NAME=$PrintName1";
}
if (!empty($Category1))
{
$Category1 = "AND CATEGORY=$Category1";
}
if (!empty($MethodOfPayment1))
{
$MethodOfPayment1 = "AND METHODOFPAY=$MethodOfPayment1";
}
$Date_From1 = German_Mysql_Date($Date_From1);
$Date_Till1 = German_Mysql_Date($Date_Till1);
$Birthday1 = German_Mysql_Date($Birthday1);
// Get Customer Information
//
$query = $db->GetAll("SELECT FIRSTNAME, LASTNAME, COMPANY, PHONEWORK, CREATED, MYID FROM {$TBLName}addressbook
WHERE MYID LIKE '%$CustomerID%' AND PREFIX LIKE '%$Prefix1%' AND FIRSTNAME LIKE '%$Firstname1%'
AND LASTNAME LIKE '%$Lastname1%' AND TITLE LIKE '%$Title11%' AND COMPANY LIKE '%$Company1%'
AND DEPARTMENT LIKE '%$Department1%' AND ADDRESS LIKE '%$Address1%' AND CITY LIKE '%$City1%'
AND STATEPROV LIKE '%$Stateprov1%' AND POSTALCODE LIKE '%$Postalcode1%' AND COUNTRY LIKE '%$Country1%'
AND POSITION LIKE '%$Position11%' AND INITIALS LIKE '%$Initials1%' AND SALUTATION LIKE '%$Salutation1%'
AND PHONEHOME LIKE '%$Phonehome1%' AND PHONEOFFI LIKE '%$Phoneoffi1%' AND PHONEOTHE LIKE '%$Phoneothe1%'
AND PHONEWORK LIKE '%$Phonework1%' AND MOBILE LIKE '%$Mobile1%' AND PAGER LIKE '%$Pager1%'
AND FAX LIKE '%$Fax1%' AND EMAIL LIKE '%$Email1%' AND URL LIKE '%$Url1%' AND NOTE LIKE '%$Note1%'
AND BIRTHDAY LIKE '%$Birthday1%' AND CREATED >= '$Date_From1' AND CREATED <= '$Date_Till1'
$Category1 $MethodOfPayment1 $PrintName1 ORDER BY $Order $Sort 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 FIRSTNAME, LASTNAME, COMPANY, PHONEWORK, CREATED, MYID FROM {$TBLName}addressbook
WHERE MYID LIKE '%$CustomerID%' AND PREFIX LIKE '%$Prefix1%' AND FIRSTNAME LIKE '%$Firstname1%'
AND LASTNAME LIKE '%$Lastname1%' AND TITLE LIKE '%$Title11%' AND COMPANY LIKE '%$Company1%'
AND DEPARTMENT LIKE '%$Department1%' AND ADDRESS LIKE '%$Address1%' AND CITY LIKE '%$City1%'
AND STATEPROV LIKE '%$Stateprov1%' AND POSTALCODE LIKE '%$Postalcode1%' AND COUNTRY LIKE '%$Country1%'
AND POSITION LIKE '%$Position11%' AND INITIALS LIKE '%$Initials1%' AND SALUTATION LIKE '%$Salutation1%'
AND PHONEHOME LIKE '%$Phonehome1%' AND PHONEOFFI LIKE '%$Phoneoffi1%' AND PHONEOTHE LIKE '%$Phoneothe1%'
AND PHONEWORK LIKE '%$Phonework1%' AND MOBILE LIKE '%$Mobile1%' AND PAGER LIKE '%$Pager1%'
AND FAX LIKE '%$Fax1%' AND EMAIL LIKE '%$Email1%' AND URL LIKE '%$Url1%' AND NOTE LIKE '%$Note1%'
AND BIRTHDAY LIKE '%$Birthday1%' AND CREATED >= '$Date_From1' AND CREATED <= '$Date_Till1'
$Category1 $MethodOfPayment1 $PrintName1 ORDER BY $Order $Sort");
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);
// Get information from selected customer
//
$query3 = $db->Execute("SELECT LASTNAME, FIRSTNAME, COMPANY, MYID FROM {$TBLName}addressbook WHERE MYID='$myID'");
// If an error has occurred, display the error message
//
if (!$query3)
print $db->ErrorMsg();
else
foreach($query3 as $result3)
{
$smarty->assign("FIRSTNAME","$result3[FIRSTNAME]");
$smarty->assign("LASTNAME","$result3[LASTNAME]");
$smarty->assign("COMPANY","$result3[COMPANY]");
$smarty->assign("MYID","$result3[MYID]");
}
// 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&");
// 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('addressbook/searchlist_e.tpl');
unset($_SESSION['EditID']);
unset($_SESSION['DeleteID']);
unset ($_SESSION['emailID']);
?>