Location: PHPKode > projects > PhpRechnung > phpRechnung/offer/poslist.php
<?php
/*
	poslist.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['offerID']))
{
	$offerID = $_REQUEST['offerID'];
	$smarty->assign("offerID","$offerID");
}
if(isset($_REQUEST['page']))
{
	$page = $_REQUEST['page'];
	$smarty->assign("page","$page");
}
if(isset($_REQUEST['tmpPosID']))
{
	$tmpPosID = $_REQUEST['tmpPosID'];
	$smarty->assign("tmpPosID","$tmpPosID");
}
if(isset($_REQUEST['posID']))
{
	$posID = $_REQUEST['posID'];
	$smarty->assign("posID","$posID");
}
if(isset($_REQUEST['PosID']))
{
	$PosID = $_REQUEST['PosID'];
	$smarty->assign("PosID","$PosID");
}
if(isset($_REQUEST['TMP_OfferID']))
{
	$TMP_OfferID = $_REQUEST['TMP_OfferID'];
	$smarty->assign("TMP_OfferID","$TMP_OfferID");
}
if(!empty($_REQUEST['PosPage']))
{
	$intCurrentPage = $_REQUEST['PosPage'];
} else {
	$intCurrentPage = 1;
}
if(isset($_REQUEST['infoID']))
{
	$infoID = $_REQUEST['infoID'];
	$smarty->assign("infoID","$infoID");
}
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(isset($_REQUEST['Pos_Quantity']))
{
	$Pos_Quantity = $_REQUEST['Pos_Quantity'];
	$smarty->assign("Pos_Quantity","$Pos_Quantity");
}
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['PosOrder']))
{
	$PosOrder = $_REQUEST['PosOrder'];
	$smarty->assign("PosOrder","$PosOrder");
} else {
	$PosOrder = "POS_GROUP ASC,POS_DESC ASC";
	$smarty->assign("PosOrder","$PosOrder");
}
if(isset($_REQUEST['PosSort']))
{
	$PosSort = $_REQUEST['PosSort'];
	$smarty->assign("PosSort","$PosSort");
}
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");
}
if(isset($_REQUEST['Pos_Order']))
{
	$Pos_Order = $_REQUEST['Pos_Order'];
	$smarty->assign("Pos_Order",$Pos_Order);
}
if(isset($_REQUEST['Pos_Sort']))
{
	$Pos_Sort = $_REQUEST['Pos_Sort'];
	$smarty->assign("Pos_Sort",$Pos_Sort);
}

$Requestedstring = "tmpPosID=$tmpPosID&amp;posID=$posID&amp;page=$page&amp;myID=$myID&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;Canceled=$Canceled&amp;Pos_Order=$Pos_Order&amp;Pos_Sort=$Pos_Sort";
$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[position] - $a[searchresult]");
$smarty->assign("PositionName","$a[pos_name]");
$smarty->assign("PositionText","$a[pos_text]");
$smarty->assign("PositionPrice","$a[pos_price]");
$smarty->assign("PositionChoose","$a[pos_choose]");

// Database connection
//
DBConnect();

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

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

// Display active, inactive or all positions
// Default is to display only active positions
//
	$query = $db->GetAll("SELECT POSITIONID, POS_NAME, POS_DESC, POS_PRICE, POS_GROUP, POS_ACTIVE FROM {$TBLName}article WHERE POS_ACTIVE=1 AND (POS_NAME LIKE '%$PosID%' OR POS_DESC LIKE '%$PosID%') ORDER BY $PosOrder $PosSort LIMIT $intCursor, $EntrysPerPage");


	// Count MaxRows depend on active positions and searchstring
	//
// 	$query1 = $db->GetAll("SELECT POS_ACTIVE FROM {$TBLName}article WHERE POS_ACTIVE='1' AND POS_NAME LIKE '%$PosID%' OR POS_DESC LIKE '%$PosID%'");
// 	$numrows = count($query1);

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

	// Count MaxRows depend on active positions and searchstring
	//
	$query1 = $db->Execute("SELECT POS_ACTIVE, POS_NAME, POS_DESC FROM {$TBLName}article WHERE POS_ACTIVE=1 AND (POS_NAME LIKE '%$PosID%' OR POS_DESC LIKE '%$PosID%')");
	
	foreach($query1 as $result1)
	{
		$numrows += count($query1);
	}

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

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

	$smarty->assign('Positions', $Position);

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

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

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

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

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

unset($_SESSION['EditID']);
unset($_SESSION['DeleteID']);
?>
Return current item: PhpRechnung