--- /dev/null
+//
+// C++ Implementation: moneylog
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "moneylog.h"
+#include "webrequest.h"
+#include "misc.h"
+
+#include <QBoxLayout>
+#include <QPushButton>
+#include <QTextEdit>
+
+MMoneyLog::MMoneyLog(QWidget*pa,MWebRequest*req,QString q)
+ :QDialog(pa)
+{
+ //set title
+ QStringList sl=q.split("\n");
+ sl[0][0]=sl[0][0].toUpper();
+ setWindowTitle(tr("Money Log of %1 %2").arg(sl[0]).arg(sl[1]));
+
+ //layout
+ QVBoxLayout*vl;
+ QHBoxLayout*hl;
+ QTextEdit*text;
+ QPushButton*p;
+ setLayout(vl=new QVBoxLayout);
+ vl->addWidget(text=new QTextEdit,10);
+ text->setReadOnly(true);
+ vl->addSpacing(15);
+ vl->addLayout(hl=new QHBoxLayout,0);
+ hl->addStretch(10);
+ hl->addWidget(p=new QPushButton(tr("Close")));
+ connect(p,SIGNAL(clicked()),this,SLOT(accept()));
+
+ //query
+ if(req->request("moneylog",q.toAscii())){
+ if(req->responseStatus()==MWebRequest::Ok){
+ text->setPlainText(QString::fromUtf8(req->responseBody()));
+ }else{
+ text->setHtml("<h1>Error</h1>"+htmlize(QString::fromUtf8(req->responseBody())));
+ }
+ }else{
+ text->setHtml("<h1>Low Level Error</h1>Request failed.");
+ }
+}
\ No newline at end of file
--- /dev/null
+//
+// C++ Interface: moneylog
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_MONEYLOG_H
+#define MAGICSMOKE_MONEYLOG_H
+
+#include <QDialog>
+
+class MWebRequest;
+
+class MMoneyLog:public QDialog
+{
+ Q_OBJECT
+ public:
+ MMoneyLog(QWidget*,MWebRequest*req,QString);
+};
+
+
+#endif
#include "event.h"
#include "labeldlg.h"
#include "misc.h"
+#include "moneylog.h"
#include "odtrender.h"
#include "orderwin.h"
#include "ticketrender.h"
m->addAction(tr("Change Sh&ipping Method..."),this,SLOT(changeShipping()))
->setEnabled(req->hasRole("changeordershipping"));
m->addSeparator();
+ m->addAction(tr("MoneyLog for Order..."),this,SLOT(moneyLogOrder()))
+ ->setEnabled(req->hasRole("moneylog"));
+ m->addAction(tr("MoneyLog for selected Voucher..."),this,SLOT(moneyLogVoucher()))
+ ->setEnabled(req->hasRole("moneylog"));
+ m->addSeparator();
m->addAction(tr("&Close"),this,SLOT(close()));
m=mb->addMenu(tr("&Payment"));
m_total->setText(m_order.totalPriceString());
}
+void MOrderWindow::moneyLogOrder()
+{
+ if(m_order.orderID()<0)return;
+ MMoneyLog ml(this,req,"order\n"+QString::number(m_order.orderID()));
+ ml.exec();
+}
+
+void MOrderWindow::moneyLogVoucher()
+{
+ if(m_order.orderID()<0)return;
+ //get selection
+ if(!m_order.isValid())return;
+ //get ticket selection
+ QModelIndexList lst=m_table->selectionModel()->selectedIndexes();
+ if(lst.size()<1)return;
+ QModelIndex idx=m_model->index(lst[0].row(),0);
+ QString id=m_model->data(idx).toString();
+ if(id=="")return;
+ int type=m_model->data(idx,Qt::UserRole).toInt();
+ if(type==ITEM_VOUCHER){
+ MMoneyLog ml(this,req,"voucher\n"+id);
+ ml.exec();
+ }else
+ QMessageBox::warning(this,tr("Warning"),tr("This is not a voucher, cannot show the money log."));
+}
+
+
/*************************************************************************************/
MOrderItemView::MOrderItemView(QWidget*w,MWebRequest*r,QList<MTicket>t,QList<MVoucher>v)
/**prune and recheck the order*/
void recheckOrder();
+
+ /**money log for the order*/
+ void moneyLogOrder();
+ /**money log for a voucher*/
+ void moneyLogVoucher();
private:
MWebRequest*req;
#include "eventedit.h"
#include "eventsummary.h"
#include "misc.h"
+#include "moneylog.h"
#include "orderwin.h"
#include "overview.h"
#include "webrequest.h"
m->addAction(tr("Edit &Shipping Options..."),this,SLOT(editShipping()));
m->addSeparator();
m->addAction(tr("&Deduct from voucher..."),this,SLOT(deductVoucher()));
+ m->addSeparator();
+ m->addAction(tr("&Money Log for voucher..."),this,SLOT(moneylogVoucher()));
+ m->addAction(tr("Money Log for &user..."),this,SLOT(moneylogUser()));
m=mb->addMenu(tr("C&onfigure"));
m->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh()));
}
}
+void MOverview::moneylogVoucher()
+{
+ QString vid=QInputDialog::getText(this,tr("Voucher ID"),tr("Please enter voucher ID to show log:"));
+ if(vid!="")
+ MMoneyLog(this,req,"voucher\n"+vid).exec();
+}
+
+void MOverview::moneylogUser()
+{
+ QString vid=QInputDialog::getText(this,tr("User"),tr("Please enter login name of user to show log:"));
+ if(vid!="")
+ MMoneyLog(this,req,"user\n"+vid).exec();
+}
+
+
/**********************************************/
MBackupDialog::MBackupDialog(QWidget*par,QString pk,MWebRequest*req)
/**deduct some money from a voucher (to pay outside the system)*/
void deductVoucher();
+ /**money log for voucher*/
+ void moneylogVoucher();
+ /**money log for user*/
+ void moneylogUser();
+
/**refresh data that we can refresh*/
void refreshData();
/**set refresh timeout*/
templates.cpp \
templatedlg.cpp \
office.cpp \
- centbox.cpp
+ centbox.cpp \
+ moneylog.cpp
HEADERS = \
keygen.h \
templates.h \
templatedlg.h \
office.h \
- centbox.h
+ centbox.h \
+ moneylog.h
#some PHP files are listed in this file to scan them for translatable items
#use genphpscan.sh to regenerate it.
}
}
+
+function cent2str($c)
+{
+ $r=floor($c/100).".";
+ $c="".$c%100;
+ if(strlen($c)<2)$c="0".$c;
+ return $r.$c;
+}
+
+function moneylogXml($data)
+{
+ //split/validate data
+ $splt=explode("\n",$data);
+ if(count($splt)<2){
+ header("X-MagicSmoke-Status: Error");
+ echo tr("Expected 2 arguments: query type and ID.");
+ return;
+ }
+ //formulate query
+ global $db;
+ $query="";
+ switch(trim($splt[0])){
+ case "order":
+ $query="orderid=".$db->escapeInt(trim($splt[1]));
+ break;
+ case "voucher":
+ $query="voucherid=".$db->escapeString(trim($splt[1]));
+ break;
+ case "user":
+ $query="uname=".$db->escapeString(trim($splt[1]));
+ break;
+ }
+ if($query==""){
+ header("X-MagicSmoke-Status: Error");
+ echo tr("Invalid Query Type.");
+ return;
+ }
+ //query and print
+ header("X-MagicSmoke-Status: Ok");
+ $res=$db->select("moneylog","*",$query);
+ foreach($res as $row){
+ print(date(DATE_W3C,$row["logtime"])." ".$row["log"]." by ".$row["uname"]);
+ if(!$db->isNull($row["orderid"]))
+ print(", order ".$row["orderid"]);
+ if(!$db->isNull($row["voucherid"]))
+ print(", voucher ".$row["voucherid"]);
+ if(!$db->isNull($row["moved"]))
+ print(", money moved ".cent2str($row["moved"]));
+ if(!$db->isNull($row["orderpaid"]))
+ print(", now paid for order ".cent2str($row["orderpaid"]));
+ if(!$db->isNull($row["orderdue"]))
+ print(", total price of order ".cent2str($row["orderdue"]));
+ if(!$db->isNull($row["vouchervalue"]))
+ print(", remaining value of voucher ".cent2str($row["vouchervalue"]));
+ print("\n");
+ }
+}
+
?>
\ No newline at end of file
$db->rollbackTransaction();
return false;
}
- $db->mkLog(array("voucherid"=>$vid, "vouchervalue"=>value, "orderid"=>$orderid),tr("create voucher"));
+ $db->mkLog(array("voucherid"=>$vid, "vouchervalue"=>$value, "orderid"=>$orderid),tr("create voucher"));
$db->commitTransaction();
$this->voucherid=$vid;
$this->orderid=$orderid;
tr("gettemplatelist"),tr("gettemplate"),tr("settemplate"),tr("settemplatedescription"),
tr("deletetemplate"),
//backup
- tr("backup")
+ tr("backup"),
+ //money trail
+ tr("moneylog")
);
/**special roles begin with _ and are listed here (in lower case and wrapped in tr())*/
$SPECIALROLES=array(
}
+//get info about a voucher
+if($SMOKEREQUEST=="moneylog"){
+ moneylogXml(trim($REQUESTDATA));
+ exit();
+}
+
+
//retrieve backup
if($SMOKEREQUEST=="backup"){
header("X-MagicSmoke-Status: Ok");