|
|
|
@ -5,6 +5,11 @@
|
|
|
|
|
#include <QTextCodec>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <winspool.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
const QString ReceiptGenerator::DIACRITIC = "ÂâÁáÄäĂ㥹ĆćČčÇçĎďĐđÉéËëĚěĘęÍíÎîĹ弾ŁłŃńŇňÓóÖöÔôŐőŔŕŘřŚśŠšŞşŤťŢţÚúÜüŮůŰűÝýŹźŽžŻż";
|
|
|
|
|
const QString ReceiptGenerator::NON_DIACRITIC = "AaAaAaAaAaCcCcCcDdDdEeEeEeEeIiIiLlLlLlNnNnOoOoOoOoRrRrSsSsSsTtTtUuUuUuUuYyZzZzZz";
|
|
|
|
|
|
|
|
|
@ -43,7 +48,48 @@ void ReceiptGenerator::save()
|
|
|
|
|
|
|
|
|
|
void ReceiptGenerator::print()
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
SettingsService srvShopSettings("SHOP");
|
|
|
|
|
ShopSettingsPtr shopSettings = srvShopSettings.loadSettings<ShopSettings>();
|
|
|
|
|
QString printer = shopSettings->output();
|
|
|
|
|
|
|
|
|
|
HANDLE hPrinter;
|
|
|
|
|
DOC_INFO_1 docInfo;
|
|
|
|
|
DWORD dwJob;
|
|
|
|
|
DWORD dwBytes;
|
|
|
|
|
BOOL bStatus = FALSE;
|
|
|
|
|
|
|
|
|
|
if (OpenPrinter((LPWSTR)printer.toStdWString().c_str(), &hPrinter, NULL))
|
|
|
|
|
{
|
|
|
|
|
docInfo.pDocName = L"Uctenka";
|
|
|
|
|
docInfo.pOutputFile = NULL;
|
|
|
|
|
docInfo.pDatatype = L"RAW";
|
|
|
|
|
|
|
|
|
|
dwJob = StartDocPrinter(hPrinter, 1, (LPBYTE)&docInfo);
|
|
|
|
|
if (dwJob > 0)
|
|
|
|
|
{
|
|
|
|
|
if (!StartPagePrinter(hPrinter))
|
|
|
|
|
{
|
|
|
|
|
ClosePrinter(hPrinter);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QByteArray data = generate();
|
|
|
|
|
BOOL bPrinted = WritePrinter(hPrinter, (LPBYTE)data.data(), data.length(), &dwBytes);
|
|
|
|
|
EndPagePrinter(hPrinter);
|
|
|
|
|
EndDocPrinter(hPrinter);
|
|
|
|
|
|
|
|
|
|
if (!bPrinted)
|
|
|
|
|
{
|
|
|
|
|
DWORD dwErr = GetLastError();
|
|
|
|
|
int i = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClosePrinter(hPrinter);
|
|
|
|
|
#else
|
|
|
|
|
save();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ReceiptGenerator::outputFile() const
|
|
|
|
|