Skip to content

Commit

Permalink
add today loggin report
Browse files Browse the repository at this point in the history
  • Loading branch information
WajdyEssam committed Aug 11, 2012
1 parent 43d5e9a commit dc2f2f1
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 157 deletions.
6 changes: 3 additions & 3 deletions Mango/ui/headerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ void HeaderWidget::createToolButtons()
reportsButton->setFont(font);

// add menu for report button
QAction *todayReportAction = new QAction(QIcon(":/images/find.png"),tr("التقرير اليومي"), this);
connect(todayReportAction, SIGNAL(triggered()), this, SIGNAL(todayReportActionClicked()));
QAction *todayLogginReportAction = new QAction(QIcon(":/images/find.png"),tr("التقرير اليومي"), this);
connect(todayLogginReportAction, SIGNAL(triggered()), this, SIGNAL(todayLogginReportActionClicked()));

QAction *generalReportAction = new QAction(QIcon(":/images/find.png"),tr("تقرير مخصص"), this);
connect(generalReportAction, SIGNAL(triggered()), this, SIGNAL(generalReportActionClicked()));

QMenu *reportMenu = new QMenu(this);
reportMenu->addAction(todayReportAction);
reportMenu->addAction(todayLogginReportAction);
reportMenu->addAction(generalReportAction);

reportsButton->setMenu(reportMenu);
Expand Down
2 changes: 1 addition & 1 deletion Mango/ui/headerwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HeaderWidget : public QWidget
signals:
void homeClicked();
void logoutClicked();
void todayReportActionClicked();
void todayLogginReportActionClicked();
void generalReportActionClicked();
void closeSystemActionClicked();
void aboutSystemActionClicked();
Expand Down
129 changes: 1 addition & 128 deletions Mango/ui/invoiceveiwerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,114 +43,12 @@ void InvoiceVeiwerWidget::renderReport() {

QString InvoiceVeiwerWidget:: getHtmlCode () {
QDateTime from = QDateTime::currentDateTime();
QDateTime fto = QDateTime::currentDateTime();
QDateTime to = QDateTime::currentDateTime();

Report* report = new LogginReport(from, to);
return (report->getHTML());
}

QString InvoiceVeiwerWidget::getSellTable () {
// QString tableBegin = "<table width=\"100%\" cellspacing=\"1\"><tbody>"
// "<tr><th>Number of Batteries</th><th>Type of Batteries</th><th>Batteries Price</th></tr>";
// QString tableEnd = "</tbody></table>";

// QString htmlTableResult = tableBegin;

// foreach(BattaryPrice battary, sell.battariesList) {
// QString tableRaw = QString("<tr valign=\"top\"> <td align=\"center\"><font size=\"2\">%1 أمبير</font></td> <td align=\"center\"><font size=\"2\">%2</font></td> <td align=\"center\"><font size=\"2\">%3</font></td></tr>")
// .arg( battary.battaryType, battary.battaryCount, battary.battaryPrice);

// htmlTableResult += tableRaw ;
// }

// htmlTableResult += tableEnd;
// return htmlTableResult;
return "";
}



QString InvoiceVeiwerWidget:: getBillHTMLCode () {
// QFile *reportFile = new QFile(":/reports/htmlReport.html");

// if ( ! reportFile->open(QIODevice::ReadOnly | QIODevice::Text) ) {
// qDebug() << "File Openining Problem";
// return "";
// }

// QString originalCode = reportFile->readAll();

// QString price = "100";

// QString reportCode = originalCode.replace("%TITLE%", TITLE)
// .replace("%COMPANY_NAME_EN%",COMPANY_NAME_EN).replace("%COMPANY_NAME_AR%",COMPANY_NAME_AR)
// .replace("%OWNER_NAME%", OWNER_NAME).replace("%COMPANY_ADDRESS%", COMPANY_ADDRESS)
// .replace("%COMPANY_MOBILE%", COMPANY_MOBILE).replace("%COMPANY_EMAIL%", COMPANY_EMAIL)
// .replace("%CLIENT_ID%", bill.customerNo)
// .replace("%BILL_ID%", bill.invoiceNO).replace("%CLIENT_COMPANY%", bill.companyName)
// .replace("%CLIENT_NAME%", bill.customerName).replace("%CLIENT_MOBILE%", bill.mobile)
// .replace("%SUCC_NUM%", price)
// .replace("%CLIENT_ADDRESS%", bill.address).replace("%DATE%", bill.invoiceDate.toString("dd/MM/yyyy"))
// .replace("%TIME%", bill.invoiceTime.toString("HH:mm A")).replace("%ADD_TABLE%", getBillTable());

// return (reportCode);
return "";
}


QString InvoiceVeiwerWidget::getBillTable () {
// QString tableBegin = "<table width=\"100%\" cellspacing=\"1\"><tbody>"
// "<tr><th>Number of Batteries</th><th>Type of Batteries</th><th>Voucher No</th><th>Batteries Price</th></tr>";
// QString tableEnd = "</tbody></table>";

// QString htmlTableResult = tableBegin;

// foreach(BattaryPrice battary, bill.battariesList) {
// QString tableRaw = QString("<tr valign=\"top\"> <td align=\"center\"><font size=\"2\">%1 أمبير</font></td> <td align=\"center\"><font size=\"2\">%2</font></td> <td align=\"center\"><font size=\"2\">%3</font></td><td align=\"center\"><font size=\"2\">%4</font></td></tr>")
// .arg( battary.battaryType, battary.battaryCount, bill.invoiceNO, battary.battaryPrice);

// htmlTableResult += tableRaw ;
// }

// htmlTableResult += tableEnd;
// return htmlTableResult;
return "";
}

QString InvoiceVeiwerWidget::generateHTML () {
// QFile *reportFile = new QFile(":/reports/sanadReport.html");

// if ( ! reportFile->open(QIODevice::ReadOnly | QIODevice::Text) ) {
// qDebug() << "File Openining Problem";
// return "";
// }

// QString originalCode = reportFile->readAll();

// QString reportType ;

// if ( type == INSERT )
// reportType = "إدخال بطاريات";
// else
// reportType = "سحب بطاريات";

// QString reportCode = originalCode.replace("%TITLE%", TITLE)

// .replace("%COMPANY_LOGO%", "qrc:/reports/logo.png")
// .replace("%COMPANY_NAME_EN%",COMPANY_NAME_EN).replace("%COMPANY_NAME_AR%",COMPANY_NAME_AR)
// .replace("%OWNER_NAME%", OWNER_NAME).replace("%COMPANY_ADDRESS%", COMPANY_ADDRESS)
// .replace("%COMPANY_MOBILE%", COMPANY_MOBILE).replace("%COMPANY_FAX%", COMPANY_FAX)
// .replace("%COMPANY_EMAIL%", COMPANY_EMAIL)
// .replace("%BILL_TYPE%",reportType).replace("%CLIENT_ID%", invoice.customerNo)
// .replace("%BILL_ID%", invoice.invoiceNO).replace("%CLIENT_COMPANY%", invoice.companyName)
// .replace("%CLIENT_NAME%", invoice.customerName).replace("%CLIENT_MOBILE%", invoice.mobile)
// .replace("%CLIENT_ADDRESS%", invoice.address).replace("%DATE%", invoice.invoiceDate.toString("dd/MM/yyyy"))
// .replace("%TIME%", invoice.invoiceTime.toString("hh:mm:ss A")).replace("%ADD_TABLE%", getHTMLTable(type));

// return (reportCode);
return "";
}

void InvoiceVeiwerWidget::printReportSlot(){
QPrinter printer;
QPrintDialog dialog(&printer, this);
Expand All @@ -175,28 +73,3 @@ void InvoiceVeiwerWidget::saveReportSlot(){
void InvoiceVeiwerWidget::cancelReportSlot(){
this->hide();
}

void InvoiceVeiwerWidget::consolePrinting(){
/*
qDebug() << "Customer Details:";
qDebug() << "===================" ;
qDebug() << "\tcustomer no: " << invoice.customerNo ;
qDebug() << "\tcustomer name: " << invoice.customerName ;
qDebug() << "\tcustomer company: " << invoice.companyName ;
qDebug() << "\tcustomer mobile: " << invoice.mobile ;
qDebug() << "\tAddress: " << invoice.address ;
qDebug() << "Invoice Details:";
qDebug() << "===================" ;
qDebug() << "\tInvoice no: " << invoice.invoiceNO ;
qDebug() << "\tinvoice Date: " << invoice.invoiceDate ;
qDebug() << "\tinvouce time: " << invoice.invoiceTime ;
qDebug() << "Battary Details:";
qDebug() << "===================" ;
foreach(Battary battary, invoice.battariesList) {
qDebug() << "\tType: " << battary.battaryType << " Count: " << battary.battaryCount ;
}
qDebug() << "\n\n" */;
}
8 changes: 0 additions & 8 deletions Mango/ui/invoiceveiwerwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ class InvoiceVeiwerWidget : public QWidget

private:
void renderReport();
QString generateHTML();

QString getHtmlCode();
QString getSellTable();

QString getBillHTMLCode();
QString getBillTable();

void consolePrinting();

private slots:
void saveReportSlot();
Expand Down
13 changes: 2 additions & 11 deletions Mango/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void MainWindow::createHeaderDockWidget()
{
this->headerWidget = new HeaderWidget;
connect(this->headerWidget, SIGNAL(homeClicked()), SLOT(ShowHomePage()));
connect(this->headerWidget, SIGNAL(todayReportActionClicked()), SLOT(todayReportClickedSlot()));
connect(this->headerWidget, SIGNAL(todayLogginReportActionClicked()), SLOT(todayLogginReportClickedSlot()));
connect(this->headerWidget, SIGNAL(generalReportActionClicked()), SLOT(generalReportClickedSlot()));
connect(this->headerWidget, SIGNAL(closeSystemActionClicked()), SLOT(closeSystemClickedSlot()));
connect(this->headerWidget, SIGNAL(aboutSystemActionClicked()), SLOT(aboutSystemClickedSlot()));
Expand Down Expand Up @@ -124,20 +124,11 @@ void MainWindow::ShowHomePage()
this->setCurrentPage(CategoryPage);
}

void MainWindow::todayReportClickedSlot()
void MainWindow::todayLogginReportClickedSlot()
{
InvoiceVeiwerWidget *viewer = new InvoiceVeiwerWidget;
viewer->show();

QList<Model::Event> events = Services::Event::getAll();
foreach(Model::Event event, events) {
Model::Event::EventTypes type = event.eventType();
QString eventType = type == Model::Event::Login ? "Loggin" : " Logout";

qDebug() << event.id() << " " << event.user().userName() << " " << event.createdDateTime() << " "
<< eventType;
}


// show reports
// event logging table, order table, cancel table, summary table
Expand Down
2 changes: 1 addition & 1 deletion Mango/ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MainWindow : public QMainWindow
private slots:
void ShowHomePage();
void orderItemClicked(QString orderIndexId);
void todayReportClickedSlot();
void todayLogginReportClickedSlot();
void generalReportClickedSlot();
void closeSystemClickedSlot();
void aboutSystemClickedSlot();
Expand Down
4 changes: 2 additions & 2 deletions MangoReports/MangoReports.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ TEMPLATE = lib
DEFINES += MANGOREPORTS_LIBRARY

SOURCES += report.cpp \
logginreport.cpp
logginreport.cpp

HEADERS += report.h\
MangoReports_global.h \
logginreport.h
logginreport.h

unix:DESTDIR = ../bin
unix:OBJECTS_DIR = build/_obj
Expand Down
37 changes: 36 additions & 1 deletion MangoReports/logginreport.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "logginreport.h"

#include "../MangoModel/event.h"
#include "../MangoService/event.h"
#include <QDebug>

LogginReport::LogginReport(const QDateTime& from, const QDateTime& to)
:Report(from, to)
{
Expand All @@ -8,7 +12,8 @@ LogginReport::LogginReport(const QDateTime& from, const QDateTime& to)
QString LogginReport::getHTML()
{
QString orignalHTML = getTemplateFileContent();
originalHtml = orignalHTML.replace("%LOGIN_REPORT_TYPE%", "Loging Report");
orignalHTML = orignalHTML.replace("%LOGIN_REPORT_TYPE%", "Loging Report");
orignalHTML = orignalHTML.replace("%LOGIN_TABLE%", getTableData());

return orignalHTML;
}
Expand All @@ -17,3 +22,33 @@ QString LogginReport::getReportTemplateName()
{
return ":/reports/LogginReport.html";
}

QString LogginReport::getTableData()
{
QString tableBegin = "<table width=\"100%\" cellspacing=\"1\"><tbody>"
"<tr><th>Id</th><th>Username</th><th>Date</th><th>Actions</th></tr>";
QString tableEnd = "</tbody></table>";

QString htmlTableResult = tableBegin;

QList<Model::Event> events = Services::Event::getAll();
foreach(Model::Event event, events) {
Model::Event::EventTypes type = event.eventType();
QString eventType = type == Model::Event::Login ? "Loggin" : " Logout";

QString tableRaw = QString(
"<tr valign=\"top\"> "
"<td align=\"center\"><font size=\"2\">%1</font></td> "
"<td align=\"center\"><font size=\"2\">%2</font></td> "
"<td align=\"center\"><font size=\"2\">%3</font></td> "
"<td align=\"center\"><font size=\"2\">%4</font></td> "
"</tr>"
).arg( QString::number(event.id()), event.user().userName(), event.createdDateTime().toString(), eventType);

htmlTableResult += tableRaw ;
}

htmlTableResult += tableEnd;

return htmlTableResult;
}
3 changes: 3 additions & 0 deletions MangoReports/logginreport.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class MANGOREPORTSSHARED_EXPORT LogginReport: public Report

virtual QString getHTML();
virtual QString getReportTemplateName();

private:
QString getTableData();
};

#endif // LOGGINREPORT_H
2 changes: 1 addition & 1 deletion MangoReports/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ QString Report::getTemplateFileContent()
return replaceHeader(htmlContent);
}

QString Report::replaceHeader(const QString& content) {
QString Report::replaceHeader(QString& content) {
QString TITLE = "Mango Talaat";
QString COMPANY_NAME_EN = "Mango Talaat";
QString OWNER_NAME = "Mohmmaed Allhowh";
Expand Down
3 changes: 2 additions & 1 deletion MangoReports/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <QDateTime>
#include <QFile>
#include <QString>

class MANGOREPORTSSHARED_EXPORT Report {
public:
Expand All @@ -15,7 +16,7 @@ class MANGOREPORTSSHARED_EXPORT Report {
virtual QString getReportTemplateName() = 0;

private:
QString replaceHeader(const QString& content);
QString replaceHeader(QString& content);
QDateTime m_from, m_to;
};

Expand Down

0 comments on commit dc2f2f1

Please sign in to comment.