<?php
/*
posedit.php
phpInvoice - 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['invoiceID']))
{
$invoiceID = $_REQUEST['invoiceID'];
$smarty->assign("invoiceID","$invoiceID");
}
if(isset($_REQUEST['page']))
{
$page = $_REQUEST['page'];
$smarty->assign("page","$page");
}
if(isset($_REQUEST['infoID']))
{
$infoID = $_REQUEST['infoID'];
$smarty->assign("infoID","$infoID");
}
if(isset($_REQUEST['tmpPosID']))
{
$tmpPosID = $_REQUEST['tmpPosID'];
$smarty->assign("tmpPosID","$tmpPosID");
}
if(isset($_REQUEST['messageID']))
{
$messageID = $_REQUEST['messageID'];
$smarty->assign("messageID","$messageID");
}
if(isset($_REQUEST['InvoiceDate']))
{
$InvoiceDate = $_REQUEST['InvoiceDate'];
$smarty->assign("InvoiceDate","$InvoiceDate");
}
if(isset($_REQUEST['MethodOfPayment']))
{
$MethodOfPayment = $_REQUEST['MethodOfPayment'];
$smarty->assign("NR_METHOD_OF_PAYMENT","$MethodOfPayment");
}
if(isset($_REQUEST['MethodOfPaymentDate']))
{
$MethodOfPaymentDate = $_REQUEST['MethodOfPaymentDate'];
$smarty->assign("MethodOfPaymentDate","$MethodOfPaymentDate");
}
if(isset($_REQUEST['Note']))
{
$Note = $_REQUEST['Note'];
$smarty->assign("Note","$Note");
}
if(isset($_REQUEST['posID']))
{
$PosID = $_REQUEST['posID'];
$smarty->assign("PosID","$PosID");
}
if(isset($_REQUEST['Pos_Quantity']))
{
$Pos_Quantity = $_REQUEST['Pos_Quantity'];
$smarty->assign("Pos_Quantity","$Pos_Quantity");
}
if(isset($_REQUEST['InvoiceID1']))
{
$InvoiceID1 = $_REQUEST['InvoiceID1'];
$smarty->assign("InvoiceID1","$InvoiceID1");
}
if(isset($_REQUEST['CustomerID1']))
{
$CustomerID1 = $_REQUEST['CustomerID1'];
$smarty->assign("CustomerID1","$CustomerID1");
}
if(isset($_REQUEST['DateFrom1']))
{
$DateFrom1 = $_REQUEST['DateFrom1'];
$smarty->assign("DateFrom1","$DateFrom1");
}
if(isset($_REQUEST['DateTill1']))
{
$DateTill1 = $_REQUEST['DateTill1'];
$smarty->assign("DateTill1","$DateTill1");
}
if(isset($_REQUEST['Total1']))
{
$Total1 = $_REQUEST['Total1'];
$smarty->assign("Total1","$Total1");
}
if(isset($_REQUEST['Customer1']))
{
$Customer1 = $_REQUEST['Customer1'];
$smarty->assign("Customer1","$Customer1");
}
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 = "page=$page&invoiceID=$invoiceID&infoID=$infoID&messageID=$messageID&InvoiceDate=$InvoiceDate&MethodOfPayment=$MethodOfPayment&MethodOfPaymentDate=$MethodOfPaymentDate&Note=$Note&Order=$Order&Sort=$Sort&tmpID=1&Canceled=$Canceled&Pos_Order=$Pos_Order&Pos_Sort=$Pos_Sort";
$smarty->assign("Requestedstring","$Requestedstring");
$Searchstring = "InvoiceID1=$InvoiceID1&CustomerID1=$CustomerID1&DateFrom1=$DateFrom1&DateTill1=$DateTill1&Total1=$Total1&Customer1=$Customer1";
$smarty->assign("Searchstring","$Searchstring");
// Assign needed text from language file
//
$smarty->assign("Title","$a[position] - $a[edit]");
$smarty->assign("PositionName","$a[pos_name]");
$smarty->assign("PositionText","$a[pos_text]");
$smarty->assign("PositionQuantity","$a[pos_quantity]");
$smarty->assign("PositionPrice","$a[pos_price]");
$smarty->assign("PositionChoose","$a[pos_choose]");
$smarty->assign("PositionSearch","$a[pos_search]");
// Database connection
//
DBConnect();
// Get data from company_settings.inc.php
//
$smarty->assign("Offer_Currency",$CompanyCurrency);
if(isset($_REQUEST['PosID']))
{
$PosID = $_REQUEST['PosID'];
$smarty->assign("PosID",$PosID);
$query1 = $db->GetAll("SELECT P.POSITIONID, P.POS_NAME, P.POS_DESC, P.POS_PRICE, P.POS_TAX AS TAX, P.POS_GROUP, T.TAXID, T.TAX_MULTI, T.TAX_DIVIDE, T.TAX_DESC FROM {$TBLName}article AS P, {$TBLName}tax AS T WHERE P.POS_TAX=T.TAXID AND P.POSITIONID=$PosID");
}
else
{
$query1 = $db->GetAll("SELECT P.POSITIONID, P.POS_NAME, T.POSITIONID, T.POS_QUANTITY, T.POS_DESC, T.POS_PRICE, T.TAX, T.TAX_MULTI, T.TAX_DIVIDE, T.TAX_DESC, T.POS_GROUP, T.TMP_INVOICEID FROM {$TBLName}article AS P, {$TBLName}tmp_invoice AS T WHERE T.POSITIONID=P.POSITIONID AND TMP_INVOICEID=$tmpPosID");
}
// If an error has occurred, display the error message
//
if (!$query1)
print($db->ErrorMsg());
else
foreach($query1 as $f)
{
$smarty->assign("POSITIONID",$f['POSITIONID']);
$smarty->assign("POS_NAME",$f['POS_NAME']);
$smarty->assign("POS_DESC",$f['POS_DESC']);
$smarty->assign("POS_PRICE",$f['POS_PRICE']);
if(empty($_REQUEST['Pos_Quantity']))
{
$smarty->assign("POS_QUANTITY",$f['POS_QUANTITY']);
} else {
$smarty->assign("POS_QUANTITY",$Pos_Quantity);
}
$smarty->assign("POS_TAX",$f['TAX']);
$smarty->assign("POS_TAX_MULTI",$f['TAX_MULTI']);
$smarty->assign("POS_TAX_DIVIDE",$f['TAX_DIVIDE']);
$smarty->assign("POS_TAX_DESC",$f['TAX_DESC']);
$smarty->assign("POS_GROUP",$f['POS_GROUP']);
}
$smarty->display('invoice/posedit.tpl');
?>