printQuote::printQuote(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
    : printSinglecopyDocument(parent, name, modal, fl)
{
  setupUi(optionsWidget());
  setWindowTitle(optionsWidget()->windowTitle());
  
  setDoctype("QT");
  setReportKey("quhead_id");

  _docinfoQueryString = "SELECT quhead_id AS docid, quhead_id,"
                        "       quhead_number AS docnumber,"
                        "       false         AS printed,"
                        "<? if exists('reportname') ?>"
                        "       <? value('reportname') ?>"
                        "<? else ?>"
                        "       findCustomerForm(quhead_cust_id, 'Q')"
                        " <? endif ?> AS reportname"
                        "  FROM quhead"
                        " WHERE (quhead_id=<? value('docid') ?>);" ;

  connect(_quote,          SIGNAL(newId(int)), this, SLOT(sHandleNewQuoteId()));
  connect(_report,         SIGNAL(newID(int)), this, SLOT(sHandleButtons()));
  connect(this,     SIGNAL(finishedWithAll()), this, SLOT(sFinishedWithAll()));
  connect(this, SIGNAL(populated(XSqlQuery*)), this, SLOT(sPopulate(XSqlQuery*)));
}
示例#2
0
printPoForm::printPoForm(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
  : printSinglecopyDocument(parent, name, modal, fl)
{
  setupUi(optionsWidget());
  setWindowTitle(optionsWidget()->windowTitle());

  setDoctype("PO");
  setReportKey("pohead_id");

  _docinfoQueryString = "SELECT pohead_id      AS docid, pohead_id,"
                        "       pohead_number  AS docnumber,"
                        "       pohead_printed AS printed,"
                        "<? if exists('reportname') ?>"
                        "       (SELECT form_report_name"
                        "          FROM form"
                        "         WHERE ((form_name=<? value('reportname') ?>)"
                        "            AND (form_key='PO')))"
                        "<? else ?>"
                        "       COALESCE((SELECT MIN(form_report_name)"
                        "                   FROM form WHERE (form_key='PO')),"
                        "                'PurchaseOrder')"
                        "<? endif ?> AS reportname"
                        "  FROM pohead"
                        " WHERE (pohead_id=<? value('docid') ?>);" ;

  _report->populate( "SELECT form_id, form_name, form_name "
                     "FROM form "
                     "WHERE (form_key='PO') "
                     "ORDER BY form_name;" );

  connect(_po,    SIGNAL(newId(int, QString)), this, SLOT(sHandleNewOrderId()));
  connect(_report,         SIGNAL(newID(int)), this, SLOT(sHandleButtons()));
  connect(this,     SIGNAL(finishedWithAll()), this, SLOT(sFinishedWithAll()));
  connect(this, SIGNAL(populated(XSqlQuery*)), this, SLOT(sPopulate(XSqlQuery*)));
}
示例#3
0
printInvoices::printInvoices(QWidget *parent, const char *name, bool modal, Qt::WFlags fl)
    : printMulticopyDocument("InvoiceCopies",     "InvoiceWatermark",
                             "InvoiceShowPrices", "PostMiscInvoices",
                             parent, name, modal, fl)
{
  setupUi(optionsWidget());
  setWindowTitle(optionsWidget()->windowTitle());

  setDoctype("IN");
  setReportKey("invchead_id");
  _distributeInventory = true;

  _shipvia->populate( "SELECT MIN(invchead_id), invchead_shipvia "
                      "  FROM invchead "
                      " WHERE ( (NOT invchead_printed)"
                      "   AND   (NOT invchead_posted) )"
                      " GROUP BY invchead_shipvia"
                      " ORDER BY invchead_shipvia;" );

  QString      errmsg;
  bool         ok  = false;
  MetaSQLQuery mql = MQLUtil::mqlLoad("invoices", "print", errmsg, &ok);
  if (ok)
    _docinfoQueryString = mql.getSource();
  else
    ErrorReporter::error(QtCriticalMsg, this, tr("Getting Invoices to Print"),
                         errmsg, __FILE__, __LINE__);

  _markAllPrintedQry = "UPDATE invchead"
                       "   SET invchead_printed=TRUE "
                       " WHERE invchead_id IN ("
                       "<? foreach('printedDocs') ?>"
                       "  <? if not isfirst('printedDocs') ?>, <? endif ?>"
                       "  <? value('printedDocs') ?>"
                       "<? endforeach ?>"
                       ");" ;
              
  _postFunction = "postInvoice";
  _postQuery    = "SELECT postInvoice(<? value('docid') ?>) AS result;" ;

  _askBeforePostingQry = "SELECT invoiceTotal(<? value('docid') ?>) = 0 AS ask;" ;
  _askBeforePostingMsg = tr("<p>Invoice %1 has a total value of 0.<br/>"
                            "Would you like to post it anyway?</p>");

  _errCheckBeforePostingQry =
         "SELECT EXISTS(SELECT *"
         "                FROM curr_rate, invchead "
         "               WHERE ((curr_id=invchead_curr_id)"
         "                 AND  (invchead_invcdate BETWEEN curr_effective AND curr_expires)"
         "                 AND  (invchead_id=<? value('docid') ?>))) AS ok;" ;
  _errCheckBeforePostingMsg =
          tr("Could not post Invoice %1 because of a missing exchange rate.");

  connect(this, SIGNAL(aboutToStart(XSqlQuery*)), this, SLOT(sHandleAboutToStart(XSqlQuery*)));
  connect(this, SIGNAL(finishedWithAll()),        this, SLOT(sHandleFinishedWithAll()));
}
printCreditMemos::printCreditMemos(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : printMulticopyDocument("CreditMemoCopies",     "CreditMemoWatermark",
                             "CreditMemoShowPrices", "PostARDocuments",
                             parent, name, modal, fl)
{
  setupUi(optionsWidget());
  setWindowTitle(optionsWidget()->windowTitle());

  setDoctype("CM");
  setReportKey("cmhead_id");
  _distributeInventory = true;

  _docinfoQueryString =
             "SELECT cmhead_id      AS docid,"
             "       cmhead_number  AS docnumber,"
             "       cmhead_printed AS printed,"
             "       cmhead_posted  AS posted,"
             "       cmhead_cust_id,"
             "       findCustomerForm(cmhead_cust_id, 'C') AS reportname"
             "  FROM cmhead "
             " WHERE (NOT cmhead_hold"
             "    AND NOT COALESCE(cmhead_printed, false)"
             "    AND checkCreditMemoSitePrivs(cmhead_id));" ;

  _markAllPrintedQry = "UPDATE cmhead"
                       "   SET cmhead_printed=TRUE "
                       " WHERE cmhead_id IN ("
                       "<? foreach('printedDocs') ?>"
                       "  <? if not isfirst('printedDocs') ?>, <? endif ?>"
                       "  <? value('printedDocs') ?>"
                       "<? endforeach ?>"
                       ");" ;
              
  _postFunction = "postCreditMemo";
  _postQuery    = "SELECT postCreditMemo(<? value('docid') ?>, 0) AS result;" ;

  connect(this, SIGNAL(finishedWithAll()), this, SLOT(sHandleFinishedWithAll()));
}
void printMulticopyDocument::sPrint()
{
  if (! isOkToPrint())
    return;

  //bool mpStartedInitialized = _data->_mpIsInitialized;

  _data->_printed.clear();

  MetaSQLQuery  docinfom(_docinfoQueryString);
  ParameterList alldocsp = getParamsDocList();
  XSqlQuery     docinfoq = docinfom.toQuery(alldocsp);
  while (docinfoq.next())
  {
    message(tr("Processing %1 #%2")
              .arg(_data->_doctypefull, docinfoq.value("docnumber").toString()));

    // This indirection allows scripts to replace core behavior - 14285
    emit aboutToStart(&docinfoq);
    emit timeToPrintOneDoc(&docinfoq);
    emit timeToMarkOnePrinted(&docinfoq);
    emit timeToPostOneDoc(&docinfoq);

    message("");
  }

//  if (! mpStartedInitialized)
  if (!_data->_captive)
  {
    orReport::endMultiPrint(_data->_printer);
    _data->_mpIsInitialized = false;
  }

  if (_data->_printed.size() == 0)
    QMessageBox::information(this, tr("No Documents to Print"),
                             tr("There aren't any documents to print."));
  else if (! _markAllPrintedQry.isEmpty() &&
           QMessageBox::question(this, tr("Mark Documents as Printed?"),
                                 tr("<p>Did all of the documents print correctly?"),
                                 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
  {
    ParameterList allp;
    allp.append("printedDocs", QVariant(_data->_printed));
    MetaSQLQuery markAllPrintedm(_markAllPrintedQry);
    XSqlQuery markPrintedq = markAllPrintedm.toQuery(allp);
    ErrorReporter::error(QtCriticalMsg, this, tr("Database Error"),
                         markPrintedq, __FILE__, __LINE__); // don't return

    if (_data->_alert)
      emit docUpdated(-1);
  }

  _data->_printed.clear();
  emit finishedWithAll();

  if (_data->_captive)
    accept();
  else
    clear();

  if (ErrorReporter::error(QtCriticalMsg, this, tr("Cannot Print"),
                           docinfoq, __FILE__, __LINE__))
    return;
}