From 1bb99df01b9458e162347c4984c8000afcced399 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 18 Dec 2016 20:32:53 +0100 Subject: [PATCH] configuration for print@home, partially functional Change-Id: Ib738eaa2c11f68671704c29a018cecf09ed917db --- iface/templates/templates.h | 6 +- iface/wext/MOKeyValuePair | 1 + iface/wext/keyvalue.h | 69 ++++++++++++++++ iface/wext/wext.pri | 3 +- printathome/client.cpp | 168 -------------------------------------- printathome/client.h | 51 ------------ printathome/clientcfg.cpp | 168 ++++++++++++++++++++++++++++++++++++++ printathome/clientcfg.h | 51 ++++++++++++ printathome/pah.cpp | 10 ++- printathome/pah.h | 3 +- printathome/printathome.pro | 4 +- printathome/servercfg.cpp | 186 +++++++++++++++++++++++++++++++++++++++++++ printathome/servercfg.h | 52 ++++++++++++ wob/classes/basics.wolf | 1 + wob/transact/order.wolf | 4 +- www/inc/wext/order.php | 29 +++++++ 16 files changed, 575 insertions(+), 231 deletions(-) create mode 100644 iface/wext/MOKeyValuePair create mode 100644 iface/wext/keyvalue.h delete mode 100644 printathome/client.cpp delete mode 100644 printathome/client.h create mode 100644 printathome/clientcfg.cpp create mode 100644 printathome/clientcfg.h create mode 100644 printathome/servercfg.cpp create mode 100644 printathome/servercfg.h diff --git a/iface/templates/templates.h b/iface/templates/templates.h index b9c0a7b..9e3f410 100644 --- a/iface/templates/templates.h +++ b/iface/templates/templates.h @@ -167,9 +167,6 @@ class MSIFACE_EXPORT MTemplateStore /**updates the template directory, does not do anything if force==false and the last update was less than 5min ago*/ void updateTemplates(bool force); - /**returns all templates (for MTemplateEditor)*/ - QList allTemplates(); - private: /**unused, just here to remove it from accessability*/ MTemplateStore()=delete; @@ -187,7 +184,8 @@ class MSIFACE_EXPORT MTemplateStore \param full the base name of the template to retrieve (eg. "ticket.xtt,1")*/ MTemplate getTemplateByFile(QString full); - + /**returns all templates (for MTemplateEditor)*/ + QList allTemplates(); private: QString profileid; diff --git a/iface/wext/MOKeyValuePair b/iface/wext/MOKeyValuePair new file mode 100644 index 0000000..a7ca73b --- /dev/null +++ b/iface/wext/MOKeyValuePair @@ -0,0 +1 @@ +#include"keyvalue.h" diff --git a/iface/wext/keyvalue.h b/iface/wext/keyvalue.h new file mode 100644 index 0000000..f294ff2 --- /dev/null +++ b/iface/wext/keyvalue.h @@ -0,0 +1,69 @@ +// +// C++ Interface: unabstract +// +// Description: removes abstract flag from classes that only need to be abstract in PHP +// +// +// Author: Konrad Rosenbaum , (C) 2009-2011 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOORDER_H +#define MAGICSMOKE_MOORDER_H + +#include "MOKeyValuePairAbstract" +#include "misc.h" + +#include + +#ifndef MSIFACE_EXPORT +#define MSIFACE_EXPORT Q_DECL_IMPORT +#endif + + +/**this class represents a key value pair or part of a map/dictionary.*/ +class MSIFACE_EXPORT MOKeyValuePair:public MOKeyValuePairAbstract +{ + Q_GADGET + WOBJECT(MOKeyValuePair) +public: + MOKeyValuePair(QString k,QString v){setkey(k);setvalue(v);setisnull(false);} + MOKeyValuePair(QString k,nullptr_t){setkey(k);setisnull(true);} + + inline operator QPair () + { + return QPair(key(),value()); + } + +}; + + + +Q_DECLARE_METATYPE(MOKeyValuePair) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(Nullable) + +#include +#include + +inline +QMap& mergeToMap(QMap&map, const QListpl) +{ + for(auto p:pl) + if(p.isnull()) + map.remove(p.key()); + else + map.insert(p.key(),p.value()); + return map; +} + +inline +QMap toMap(const QListpl) +{ + QMapmap; + return mergeToMap(map,pl); +} + +#endif diff --git a/iface/wext/wext.pri b/iface/wext/wext.pri index f9f30b6..fc013be 100644 --- a/iface/wext/wext.pri +++ b/iface/wext/wext.pri @@ -9,7 +9,8 @@ HEADERS += \ wext/address.h \ wext/event.h \ wext/customer.h \ - wext/transaction.h + wext/transaction.h \ + wext/keyvalue.h SOURCES += \ wext/customerinfo.cpp \ diff --git a/printathome/client.cpp b/printathome/client.cpp deleted file mode 100644 index d1f4a38..0000000 --- a/printathome/client.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// -// C++ Implementation: print @ home -// -// Description: Client Settings -// -// -// Author: Konrad Rosenbaum , (C) 2016 -// -// Copyright: See README/COPYING.GPL files that come with this distribution -// -// - -#include "client.h" - -#include "scli.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#define GROUP "PrintAtHome/Client" -#define TIMER GROUP "/timermin" -#define SETPROFILE GROUP "/setprofile" -#define PROFILE GROUP "/profile" -#define SETUSER GROUP "/setuser" -#define USERNAME GROUP "/username" -#define AUTOLOGIN GROUP "/autologin" -#define PASSWD GROUP "/passwd" - - -MPClientConfig::MPClientConfig(QWidget* parent) -:QDialog(parent) -{ - setWindowTitle(tr("Print@Home Client Configuration")); - QVBoxLayout*vl; - setLayout(vl=new QVBoxLayout); - QFormLayout*fl; - vl->addLayout(fl=new QFormLayout); - //check Interval - fl->addRow(tr("Check Interval in Minutes:"),mtimer=new QSpinBox); - mtimer->setRange(1,10080); - mtimer->setValue(timerInMinutes()); - //profile - fl->addRow("",msetprofile=new QCheckBox(tr("Preselect Profile"))); - fl->addRow(tr("Profile:"),mprofile=new QComboBox); - connect(msetprofile,SIGNAL(clicked(bool)),mprofile,SLOT(setEnabled(bool))); - msetprofile->setChecked(preselectProfile()); - //get profile names - auto prfs=MSessionClient::instance()->profiles(); - const QString cprf=preselectedProfileId(); - int cprfn=-1; - for(auto prf:prfs){ - if(prf.first==cprf)cprfn=mprofile->count(); - mprofile->addItem(prf.second,prf.first); - } - mprofile->setCurrentIndex(cprfn); - //user - fl->addRow("",msetuser=new QCheckBox(tr("Set User Name"))); - fl->addRow(tr("User Name:"),musername=new QLineEdit); - musername->setText(preselectedUserName()); - connect(msetuser,SIGNAL(clicked(bool)),musername,SLOT(setEnabled(bool))); - msetuser->setChecked(preselectUser()); - //password - fl->addRow("",mautologin=new QCheckBox(tr("Auto-Login"))); - fl->addRow(tr("Password:"),mpassword=new QLineEdit); - connect(mautologin,SIGNAL(clicked(bool)),mpassword,SLOT(setEnabled(bool))); - mautologin->setChecked(autoLogin()); - mpassword->setEchoMode(QLineEdit::Password); - mpassword->setText(password()); - - vl->addSpacing(15); - QHBoxLayout*hl; - vl->addLayout(hl=new QHBoxLayout); - hl->addStretch(1); - QPushButton*p; - hl->addWidget(p=new QPushButton(tr("&OK"))); - connect(p,SIGNAL(clicked()),this,SLOT(save()),Qt::DirectConnection); - connect(p,SIGNAL(clicked()),this,SLOT(accept()),Qt::QueuedConnection); - hl->addWidget(p=new QPushButton(tr("&Cancel"))); - connect(p,SIGNAL(clicked()),this,SLOT(reject())); - -} - -//note: this is NOT an encryption algorithm - it merely masks against accidental reading, it is trivial to reverse -static inline QByteArray maskPwd(QString pwd) -{ - QByteArray r=pwd.toUtf8(); - int m=0x58; - for(int i=0;iisChecked()); - set.setValue(TIMER,mtimer->value()); - set.setValue(PROFILE,mprofile->currentData()); - set.setValue(SETUSER,msetuser->isChecked()); - set.setValue(USERNAME,musername->text()); - set.setValue(AUTOLOGIN,mautologin->isChecked()); - set.setValue(PASSWD,maskPwd(mpassword->text())); -} - -bool MPClientConfig::preselectProfile() -{ - return QSettings().value(SETPROFILE,false).toBool(); -} - -int MPClientConfig::timerInMinutes() -{ - return QSettings().value(TIMER,60).toInt(); -} - -QString MPClientConfig::preselectedProfileId() -{ - return QSettings().value(PROFILE).toString(); -} - -bool MPClientConfig::preselectUser() -{ - return QSettings().value(SETUSER,false).toBool(); -} - -QString MPClientConfig::preselectedUserName() -{ - return QSettings().value(USERNAME).toString(); -} - -bool MPClientConfig::autoLogin() -{ - return QSettings().value(AUTOLOGIN,false).toBool(); -} - -QString MPClientConfig::password() -{ - return unmaskPwd(QSettings().value(PASSWD).toByteArray()); -} - -void MPClientConfig::performAutoLogin(MSessionClient&sc) -{ - sc.waitForReady(); - if(preselectProfile()) - sc.setProfile(preselectedProfileId()); - if(preselectUser()) - sc.login(preselectedUserName(),password(),autoLogin()); -} diff --git a/printathome/client.h b/printathome/client.h deleted file mode 100644 index 4ab0a92..0000000 --- a/printathome/client.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// C++ Interface: print @ home, client config -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2016 -// -// Copyright: See README/COPYING.GPL files that come with this distribution -// -// - -#ifndef MSMOKE_PAH_CLIENT_H -#define MSMOKE_PAH_CLIENT_H - -#include - -class QCheckBox; -class QLineEdit; -class QComboBox; -class QSpinBox; -class MSessionClient; - -class MPClientConfig:public QDialog -{ - Q_OBJECT -public: - MPClientConfig(QWidget*parent=nullptr); - - static int timerInMinutes(); - static bool preselectProfile(); - static QString preselectedProfileId(); - static bool preselectUser(); - static QString preselectedUserName(); - static bool autoLogin(); - static QString password(); - - static void performAutoLogin(MSessionClient&); - -public slots: - void save(); - -private: - QSpinBox*mtimer; - QCheckBox*msetprofile,*msetuser,*mautologin; - QLineEdit*musername,*mpassword; - QComboBox*mprofile; - -}; - -#endif diff --git a/printathome/clientcfg.cpp b/printathome/clientcfg.cpp new file mode 100644 index 0000000..5ade69e --- /dev/null +++ b/printathome/clientcfg.cpp @@ -0,0 +1,168 @@ +// +// C++ Implementation: print @ home +// +// Description: Client Settings +// +// +// Author: Konrad Rosenbaum , (C) 2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#include "clientcfg.h" + +#include "scli.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#define GROUP "PrintAtHome/Client" +#define TIMER GROUP "/timermin" +#define SETPROFILE GROUP "/setprofile" +#define PROFILE GROUP "/profile" +#define SETUSER GROUP "/setuser" +#define USERNAME GROUP "/username" +#define AUTOLOGIN GROUP "/autologin" +#define PASSWD GROUP "/passwd" + + +MPClientConfig::MPClientConfig(QWidget* parent) +:QDialog(parent) +{ + setWindowTitle(tr("Print@Home Client Configuration")); + QVBoxLayout*vl; + setLayout(vl=new QVBoxLayout); + QFormLayout*fl; + vl->addLayout(fl=new QFormLayout); + //check Interval + fl->addRow(tr("Check Interval in Minutes:"),mtimer=new QSpinBox); + mtimer->setRange(1,10080); + mtimer->setValue(timerInMinutes()); + //profile + fl->addRow("",msetprofile=new QCheckBox(tr("Preselect Profile"))); + fl->addRow(tr("Profile:"),mprofile=new QComboBox); + connect(msetprofile,SIGNAL(clicked(bool)),mprofile,SLOT(setEnabled(bool))); + msetprofile->setChecked(preselectProfile()); + //get profile names + auto prfs=MSessionClient::instance()->profiles(); + const QString cprf=preselectedProfileId(); + int cprfn=-1; + for(auto prf:prfs){ + if(prf.first==cprf)cprfn=mprofile->count(); + mprofile->addItem(prf.second,prf.first); + } + mprofile->setCurrentIndex(cprfn); + //user + fl->addRow("",msetuser=new QCheckBox(tr("Set User Name"))); + fl->addRow(tr("User Name:"),musername=new QLineEdit); + musername->setText(preselectedUserName()); + connect(msetuser,SIGNAL(clicked(bool)),musername,SLOT(setEnabled(bool))); + msetuser->setChecked(preselectUser()); + //password + fl->addRow("",mautologin=new QCheckBox(tr("Auto-Login"))); + fl->addRow(tr("Password:"),mpassword=new QLineEdit); + connect(mautologin,SIGNAL(clicked(bool)),mpassword,SLOT(setEnabled(bool))); + mautologin->setChecked(autoLogin()); + mpassword->setEchoMode(QLineEdit::Password); + mpassword->setText(password()); + + vl->addSpacing(15); + QHBoxLayout*hl; + vl->addLayout(hl=new QHBoxLayout); + hl->addStretch(1); + QPushButton*p; + hl->addWidget(p=new QPushButton(tr("&OK"))); + connect(p,SIGNAL(clicked()),this,SLOT(save()),Qt::DirectConnection); + connect(p,SIGNAL(clicked()),this,SLOT(accept()),Qt::QueuedConnection); + hl->addWidget(p=new QPushButton(tr("&Cancel"))); + connect(p,SIGNAL(clicked()),this,SLOT(reject())); + +} + +//note: this is NOT an encryption algorithm - it merely masks against accidental reading, it is trivial to reverse +static inline QByteArray maskPwd(QString pwd) +{ + QByteArray r=pwd.toUtf8(); + int m=0x58; + for(int i=0;iisChecked()); + set.setValue(TIMER,mtimer->value()); + set.setValue(PROFILE,mprofile->currentData()); + set.setValue(SETUSER,msetuser->isChecked()); + set.setValue(USERNAME,musername->text()); + set.setValue(AUTOLOGIN,mautologin->isChecked()); + set.setValue(PASSWD,maskPwd(mpassword->text())); +} + +bool MPClientConfig::preselectProfile() +{ + return QSettings().value(SETPROFILE,false).toBool(); +} + +int MPClientConfig::timerInMinutes() +{ + return QSettings().value(TIMER,60).toInt(); +} + +QString MPClientConfig::preselectedProfileId() +{ + return QSettings().value(PROFILE).toString(); +} + +bool MPClientConfig::preselectUser() +{ + return QSettings().value(SETUSER,false).toBool(); +} + +QString MPClientConfig::preselectedUserName() +{ + return QSettings().value(USERNAME).toString(); +} + +bool MPClientConfig::autoLogin() +{ + return QSettings().value(AUTOLOGIN,false).toBool(); +} + +QString MPClientConfig::password() +{ + return unmaskPwd(QSettings().value(PASSWD).toByteArray()); +} + +void MPClientConfig::performAutoLogin(MSessionClient&sc) +{ + sc.waitForReady(); + if(preselectProfile()) + sc.setProfile(preselectedProfileId()); + if(preselectUser()) + sc.login(preselectedUserName(),password(),autoLogin()); +} diff --git a/printathome/clientcfg.h b/printathome/clientcfg.h new file mode 100644 index 0000000..4ab0a92 --- /dev/null +++ b/printathome/clientcfg.h @@ -0,0 +1,51 @@ +// +// C++ Interface: print @ home, client config +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MSMOKE_PAH_CLIENT_H +#define MSMOKE_PAH_CLIENT_H + +#include + +class QCheckBox; +class QLineEdit; +class QComboBox; +class QSpinBox; +class MSessionClient; + +class MPClientConfig:public QDialog +{ + Q_OBJECT +public: + MPClientConfig(QWidget*parent=nullptr); + + static int timerInMinutes(); + static bool preselectProfile(); + static QString preselectedProfileId(); + static bool preselectUser(); + static QString preselectedUserName(); + static bool autoLogin(); + static QString password(); + + static void performAutoLogin(MSessionClient&); + +public slots: + void save(); + +private: + QSpinBox*mtimer; + QCheckBox*msetprofile,*msetuser,*mautologin; + QLineEdit*musername,*mpassword; + QComboBox*mprofile; + +}; + +#endif diff --git a/printathome/pah.cpp b/printathome/pah.cpp index 0874a3b..04cc513 100644 --- a/printathome/pah.cpp +++ b/printathome/pah.cpp @@ -16,7 +16,8 @@ #include #include "pah.h" -#include "client.h" +#include "clientcfg.h" +#include "servercfg.h" #include #include @@ -30,7 +31,7 @@ PrintIcon::PrintIcon() ctx->addAction(tr("Start &Printing now")); ctx->addSeparator(); ctx->addAction(tr("&Client Configuration..."),this,SLOT(clientConfig())); - ctx->addAction(tr("&Server Configuration...")); + ctx->addAction(tr("&Server Configuration..."),this,SLOT(serverConfig())); ctx->addSeparator(); ctx->addAction(tr("&Quit"),qApp,SLOT(quit())); setContextMenu(ctx); @@ -69,6 +70,11 @@ void PrintIcon::clientConfig() cc.exec(); } +void PrintIcon::serverConfig() +{ + MPServerConfig sc; + sc.exec(); +} int main(int argc,char**argv) diff --git a/printathome/pah.h b/printathome/pah.h index f1faadf..e47ce53 100644 --- a/printathome/pah.h +++ b/printathome/pah.h @@ -32,6 +32,7 @@ public: public slots: void setPrintMode(PrintMode); void clientConfig(); + void serverConfig(); }; -#endif \ No newline at end of file +#endif diff --git a/printathome/printathome.pro b/printathome/printathome.pro index 68806e3..e55a7ca 100644 --- a/printathome/printathome.pro +++ b/printathome/printathome.pro @@ -7,8 +7,8 @@ include(../iface/iface.pri) include(../commonlib/commonlib.pri) #sources -SOURCES += pah.cpp client.cpp -HEADERS += pah.h client.h +SOURCES += pah.cpp clientcfg.cpp servercfg.cpp +HEADERS += pah.h clientcfg.h servercfg.h RESOURCES += files.qrc diff --git a/printathome/servercfg.cpp b/printathome/servercfg.cpp new file mode 100644 index 0000000..bf92f50 --- /dev/null +++ b/printathome/servercfg.cpp @@ -0,0 +1,186 @@ +// +// C++ Implementation: print @ home +// +// Description: Client Settings +// +// +// Author: Konrad Rosenbaum , (C) 2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#include "servercfg.h" + +#include "msinterface.h" +#include "templates.h" + +#include "MTGetAllContactTypes" +#include "MTGetPrintAtHomeSettings" +#include "MTSetPrintAtHomeSettings" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TICKETCS "TicketChecksum" +#define VOUCHERCS "VoucherChecksum" +#define INVOICECS "InvoiceChecksum" +#define MAILCONTACTS "MailContactTypes" + +//seconds between forced re-inits +#define INIT_TIMER 5*60 + +QList MPServerConfig::mcontacttypes; +QDateTime MPServerConfig::mlastinit; +QMap MPServerConfig::msettings; + + +MPServerConfig::MPServerConfig(QWidget* parent) +:QDialog(parent) +{ + setWindowTitle(tr("Print@Home Server Configuration")); + QVBoxLayout*vl,*vl2; + setLayout(vl=new QVBoxLayout); + QFormLayout*fl; + vl->addLayout(fl=new QFormLayout); + //template for tickets + fl->addRow(tr("Ticket Template:"),mticket=new QComboBox); + //template for vouchers + fl->addRow(tr("Voucher Template:"),mvoucher=new QComboBox); + //template for invoice + fl->addRow(tr("Invoice Template:"),minvoice=new QComboBox); + //contacts + fl->addRow(tr("eMail Contacts:"),vl2=new QVBoxLayout); + //get settings + init(); + //update templates + QListtpl=req->templateStore()->allTemplates(); + int tp=-1,vp=-1,ip=-1; + const QString tc=ticketTemplateCS(),vc=voucherTemplateCS(),ic=invoiceTemplateCS(); + qDebug()<<"DEFAULTS tick"<addItem(tmp.description(),tmp.checksum()); + if(tc==tmp.checksum())tp=mticket->count()-1; + } + if(tmp.baseName()=="voucher"){ + mvoucher->addItem(tmp.description(),tmp.checksum()); + if(vc==tmp.checksum())vp=mvoucher->count()-1; + } + if(tmp.baseName()=="bill"){ + minvoice->addItem(tmp.description(),tmp.checksum()); + if(ic==tmp.checksum())ip=minvoice->count()-1; + } + } + mticket->setCurrentIndex(tp); + mvoucher->setCurrentIndex(vp); + minvoice->setCurrentIndex(ip); + //update contacts + QList mcont=mailContactTypeIds(); + qDebug()<<"DEFAULT contacts"<setChecked(mcont.contains(ctc.contacttypeid())); + vl2->addWidget(cb); + mcontacts.insert(ctc.contacttypeid(),cb); + } + + vl->addSpacing(15); + QHBoxLayout*hl; + vl->addLayout(hl=new QHBoxLayout); + hl->addStretch(1); + QPushButton*p; + hl->addWidget(p=new QPushButton(tr("&OK"))); + connect(p,SIGNAL(clicked()),this,SLOT(save()),Qt::DirectConnection); + connect(p,SIGNAL(clicked()),this,SLOT(accept()),Qt::QueuedConnection); + hl->addWidget(p=new QPushButton(tr("&Cancel"))); + connect(p,SIGNAL(clicked()),this,SLOT(reject())); + +} + +void MPServerConfig::init(bool force) +{ + if(!force && mlastinit>=QDateTime::currentDateTime().addSecs(-(INIT_TIMER)))return; + + auto getsettings=req->queryGetPrintAtHomeSettings(); + if(getsettings.hasError()) + QMessageBox::warning(nullptr,tr("Warning"),tr("Unable to retrieve Print@Home Settings: %1").arg(getsettings.errorString())); + else + msettings=toMap(getsettings.getsettings()); + qDebug()<<"NEW-SETTINGS"<queryGetAllContactTypes().gettypes(); + + mlastinit=QDateTime::currentDateTime(); +} + +void MPServerConfig::save() +{ + //gather data + QList settings; + settings.append(MOKeyValuePair(TICKETCS,mticket->currentData().toString())); + settings.append(MOKeyValuePair(VOUCHERCS,mvoucher->currentData().toString())); + settings.append(MOKeyValuePair(INVOICECS,minvoice->currentData().toString())); + QString mct; + for(int cid:mcontacts.keys()) + if(mcontacts[cid]->isChecked()) + mct+=QString("%1 ").arg(cid); + settings.append(MOKeyValuePair(MAILCONTACTS,mct)); + qDebug()<<"SAVING"<querySetPrintAtHomeSettings(settings); + if(setsettings.hasError()) + QMessageBox::warning(nullptr,tr("Warning"),tr("Unable to store Print@Home Settings: %1").arg(setsettings.errorString())); + + //force re-init + init(true); +} + +// TODO: THIS SHOULD REALLY BE STORED ON THE SERVER AS CONFIG VALUE!!!!!! +QString MPServerConfig::ticketTemplateCS() +{ + init(); + return msettings.value(TICKETCS); +} + +QString MPServerConfig::voucherTemplateCS() +{ + init(); + return msettings.value(VOUCHERCS); +} + +QString MPServerConfig::invoiceTemplateCS() +{ + init(); + return msettings.value(INVOICECS); +} + +QStringList MPServerConfig::mailContactTypes() +{ + QStringList ret; + for(int id:mailContactTypeIds()) + for(auto ct:mcontacttypes) + if(ct.contacttypeid()==id) + ret.append(ct.contacttype()); + return ret; +} + +QList MPServerConfig::mailContactTypeIds() +{ + init(); + QListret; + for(auto s:msettings.value(MAILCONTACTS).split(' ',QString::SkipEmptyParts)) + ret.append(s.toInt()); + return ret; +} diff --git a/printathome/servercfg.h b/printathome/servercfg.h new file mode 100644 index 0000000..da31ad7 --- /dev/null +++ b/printathome/servercfg.h @@ -0,0 +1,52 @@ +// +// C++ Interface: print @ home, client config +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MSMOKE_PAH_SERVER_H +#define MSMOKE_PAH_SERVER_H + +#include +#include +#include +#include + +#include "MOContactType" + +class QCheckBox; +class QLineEdit; +class QComboBox; +class QSpinBox; + +class MPServerConfig:public QDialog +{ + Q_OBJECT +public: + MPServerConfig(QWidget*parent=nullptr); + + static QStringList mailContactTypes(); + static QList mailContactTypeIds(); +public slots: + void save(); + +private: + QComboBox*mticket,*mvoucher,*minvoice; + QMapmcontacts; + static QMapmsettings; + static QListmcontacttypes; + static QDateTime mlastinit; + + static QString ticketTemplateCS(); + static QString voucherTemplateCS(); + static QString invoiceTemplateCS(); + static void init(bool force=false); +}; + +#endif diff --git a/wob/classes/basics.wolf b/wob/classes/basics.wolf index 47ba998..4d62b18 100644 --- a/wob/classes/basics.wolf +++ b/wob/classes/basics.wolf @@ -60,6 +60,7 @@ + diff --git a/wob/transact/order.wolf b/wob/transact/order.wolf index d55d46d..ab555c6 100644 --- a/wob/transact/order.wolf +++ b/wob/transact/order.wolf @@ -538,7 +538,7 @@ Gets all settings pertaining to Print@Home - + @@ -548,7 +548,7 @@ - + diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 4c0e669..cfcb061 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -1001,6 +1001,35 @@ class WOOrder extends WOOrderAbstract //get items $trans->setitems(WOItemAudit::fromTableArrayitem_audit(WTitem_audit::selectFromDB("audituname=".$db->escapeString($uname)." AND audittime>=".$db->escapeInt($oldest),"ORDER BY auditid"))); } + + static public function getPrintAtHomeSettings($trans) + { + $res=array(); + $cfg=WTconfig::selectFromDB(); + foreach($cfg as $c) { + if(strncmp($c->ckey,"printathome:",12)==0) + $r=new WOKeyValuePair(); + $r->setkey(substr($c->ckey,12)); + $r->setvalue($c->cval); + $res[]=$r; + } + $trans->setsettings($res); + + } + + static public function setPrintAtHomeSettings($trans) + { + foreach($trans->getsettings() as $cfg) { + if($cfg->getisnull()){ + $ct=WTconfig::getFromDB("printathome:".$cfg->getkey()); + $ct->deleteFromDb(); + }else{ + $ct=WTconfig::newRow(array("ckey"=> ("printathome:".$cfg->getkey()), "cval"=>$cfg->getvalue())); + $ct->insertOrUpdate(); + } + } + + } }; -- 1.7.2.5