<?php
/*
copy_invoice.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/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['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");
}
$Searchstring = "InvoiceID1=$InvoiceID1&CustomerID1=$CustomerID1&DateFrom1=$DateFrom1&DateTill1=$DateTill1&Total1=$Total1&Customer1=$Customer1";
$smarty->assign("Searchstring","$Searchstring");
// Assign needed text from selected language file
//
$smarty->assign("Title","$a[invoice] - $a[copy_invoice]");
$smarty->assign("Invoice_No","$a[invoice_number]");
$smarty->assign("InvoiceInitials","$a[invoice_initials]");
$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("Copy_Invoice","$a[copy_invoice]");
// Database connection
//
DBConnect();
// Get Invoice Information
//
$query = $db->GetAll("SELECT A.FIRSTNAME, A.LASTNAME, A.COMPANY, A.MYID, I.INVOICEID, I.MYID, DATE_FORMAT(I.INVOICE_DATE,'%d.%m.%Y') AS INVOICE_DATE,
I.CREATEDBY FROM {$TBLName}addressbook AS A, {$TBLName}invoice AS I WHERE A.MYID=I.MYID AND I.INVOICEID=$invoiceID");
// If an error has occurred, display the error message
//
if (!$query)
print($db->ErrorMsg());
else
foreach($query as $f)
{
$InvoiceDate = $f['INVOICE_DATE'];
$InvoiceID = $f['INVOICEID'];
$CreatedBy = $f['CREATEDBY'];
$smarty->assign("MYID",$f['MYID']);
$smarty->assign("FIRSTNAME",$f['FIRSTNAME']);
$smarty->assign("LASTNAME",$f['LASTNAME']);
$smarty->assign("COMPANY",$f['COMPANY']);
$smarty->assign("INVOICEID",$InvoiceID);
$smarty->assign("CREATED",$Created);
}
$PrintD = Print_Date($InvoiceDate);
$smarty->assign("PrintDate",$PrintD.'-'.$InvoiceID);
if(isset($_SESSION['Username']) && $_SESSION['Username'] != $root && $_SESSION['Usergroup1'] != $admingroup_1 && $_SESSION['Usergroup2'] != $admingroup_2 && $_SESSION['Username'] != $CreatedBy)
{
$_SESSION['LastSite'] = $_SERVER['PHP_SELF'].'?'.$_SERVER['argv'][0];
$_SESSION['logoutid'] = "5";
Header("Location: $web/login/sustart.php?$sessname=$sessid");
}
else
{
// Save last page visited by user
//
UserSite();
$smarty->display('invoice/copy_invoice.tpl');
}
?>