Skip to content

Commit

Permalink
add login report template
Browse files Browse the repository at this point in the history
  • Loading branch information
WajdyEssam committed Aug 10, 2012
1 parent b785a37 commit abbcb5a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 40 deletions.
Binary file added Mango/reports/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Mango/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,7 @@
<file>images/refresh.png</file>
<file>images/save.png</file>
<file>images/cancel.png</file>
<file>reports/logo.png</file>
<file>reports/LogginReport.html</file>
</qresource>
</RCC>
50 changes: 23 additions & 27 deletions Mango/ui/invoiceveiwerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ InvoiceVeiwerWidget::InvoiceVeiwerWidget(QWidget *parent) :
this->connect(ui->printButton, SIGNAL(clicked()), this, SLOT(printReportSlot()));

this->setWindowTitle("شاشة معاينة");
this->renderReport();
}

InvoiceVeiwerWidget::~InvoiceVeiwerWidget()
Expand All @@ -34,40 +35,35 @@ InvoiceVeiwerWidget::~InvoiceVeiwerWidget()


void InvoiceVeiwerWidget::renderReport() {
ui->webView->setHtml("testing");

// **********************************debug: save html
QFile file("testing.html");
file.open(QIODevice::WriteOnly|QIODevice::Text);

QTextStream out(&file);
out.setCodec(QTextCodec::codecForCStrings());
out << htmlCode;

file.close();
this->htmlCode = getHtmlCode();
ui->webView->setHtml(htmlCode);
}

QString InvoiceVeiwerWidget:: getSellHTMLCode () {
// QFile *reportFile = new QFile(":/reports/sellReport.html");
QString InvoiceVeiwerWidget:: getHtmlCode () {
QFile *reportFile = new QFile(":/reports/LogginReport.html");

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

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

// QString price = "100";
QString price = "100";

// QString reportCode = originalCode.replace("%TITLE%", TITLE).replace("%COMPANY_NAME%",COMPANY_NAME_EN)
// .replace("%OWNER_NAME%", OWNER_NAME).replace("%COMPANY_ADDRESS%", COMPANY_ADDRESS)
// .replace("%COMPANY_MOBILE%", COMPANY_MOBILE).replace("%COMPANY_EMAIL%", COMPANY_EMAIL)
// .replace("%CLIENT_NAME%", sell.to)
// .replace("%DATE%", sell.date)
// .replace("%SUCC_NUM%", price).replace("%ADD_TABLE%", getSellTable());
QString TITLE = "Mango Talaat";
QString COMPANY_NAME_EN = "Mango Talaat";
QString OWNER_NAME = "Mohmmaed Allhowh";
QString COMPANY_ADDRESS = "Riyadh, KSA";
QString COMPANY_MOBILE = "0656444654";
QString COMPANY_EMAIL = "test@gmail.com";

// return (reportCode);
return "";
QString reportCode = originalCode.replace("%TITLE%", TITLE).replace("%COMPANY_NAME%",COMPANY_NAME_EN)
.replace("%OWNER_NAME%", OWNER_NAME).replace("%COMPANY_ADDRESS%", COMPANY_ADDRESS)
.replace("%COMPANY_MOBILE%", COMPANY_MOBILE).replace("%COMPANY_EMAIL%", COMPANY_EMAIL)
.replace("%SUCC_NUM%", price).replace("%ADD_TABLE%", getSellTable());

return (reportCode);
}

QString InvoiceVeiwerWidget::getSellTable () {
Expand Down
2 changes: 1 addition & 1 deletion Mango/ui/invoiceveiwerwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InvoiceVeiwerWidget : public QWidget
void renderReport();
QString generateHTML();

QString getSellHTMLCode();
QString getHtmlCode();
QString getSellTable();

QString getBillHTMLCode();
Expand Down
10 changes: 5 additions & 5 deletions Mango/ui/invoiceveiwerwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<string>حفظ السند </string>
</property>
<property name="icon">
<iconset resource="BatteryManagement.qrc">
<iconset resource="../resources.qrc">
<normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
</property>
</widget>
Expand All @@ -72,7 +72,7 @@
<string>طباعة السند</string>
</property>
<property name="icon">
<iconset resource="BatteryManagement.qrc">
<iconset resource="../resources.qrc">
<normaloff>:/images/find.png</normaloff>:/images/find.png</iconset>
</property>
<property name="default">
Expand All @@ -83,10 +83,10 @@
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>إلغاء الأمر</string>
<string>اغلاق</string>
</property>
<property name="icon">
<iconset resource="BatteryManagement.qrc">
<iconset resource="../resources.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
</widget>
Expand Down Expand Up @@ -118,7 +118,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="BatteryManagement.qrc"/>
<include location="../resources.qrc"/>
</resources>
<connections/>
</ui>
22 changes: 15 additions & 7 deletions Mango/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "orderwidget.h"
#include "SlidingStackedWidget.h"
#include "aboutdialog.h"
#include "invoiceveiwerwidget.h"

#include <vector>
#include <QDebug>
Expand Down Expand Up @@ -125,25 +126,32 @@ void MainWindow::ShowHomePage()

void MainWindow::todayReportClickedSlot()
{
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
// Database::DatabaseManager database;
// QList<QDateTime> times = database.getCheckoutTimes();

// QList<Login> logins = database.getLoginReport(times.first(), QDateTime::currentDateTime());

// foreach(Login login, logins) {
// qDebug() << login.getId() << " , " << login.getUser().userName() << " , " << login.getEventTime() << " , "
// << login.getEventType();
// }


// QList<Order> orderReports = database.getOrderReport(times.first(), QDateTime::currentDateTime());
// foreach(Order order, orderReports) {
// qDebug() << order.id() << " , " << order.cash() << " , " << order.createdDateTime() ;
// }

// from points to points
// from last point to current time
}

void MainWindow::generalReportClickedSlot() {
Expand Down

0 comments on commit abbcb5a

Please sign in to comment.