1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/*
* This file is part of the xTuple ERP: PostBooks Edition, a free and
* open source Enterprise Resource Planning software suite,
* Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
* It is licensed to you under the Common Public Attribution License
* version 1.0, the full text of which (including xTuple-specific Exhibits)
* is available at www.xtuple.com/CPAL. By using this software, you agree
* to be bound by its terms.
*/
#include "configurePO.h"
#include <QValidator>
#include <QVariant>
configurePO::configurePO(QWidget* parent, const char* name, bool /*modal*/, Qt::WindowFlags fl)
: XAbstractConfigure(parent, fl)
{
setupUi(this);
if (name)
setObjectName(name);
XSqlQuery configq;
if (_metrics->value("Application") == "PostBooks")
{
_enableDropShip->hide();
_billDropShip->hide();
}
else
{
configq.prepare("SELECT pohead_id FROM pohead "
"WHERE ( (pohead_dropship = 'true') "
" AND (pohead_status = 'O') )");
configq.exec();
if (configq.first())
{
_enableDropShip->setChecked(true);
_enableDropShip->setEnabled(false);
_billDropShip->setChecked(_metrics->boolean("BillDropShip"));
_billDropShip->setEnabled(false);
}
else
{
_enableDropShip->setChecked(_metrics->boolean("EnableDropShipments"));
_billDropShip->setChecked(_metrics->boolean("BillDropShip"));
}
}
if (_metrics->value("PONumberGeneration") == "M")
_orderNumGeneration->setCurrentIndex(0);
else if (_metrics->value("PONumberGeneration") == "A")
_orderNumGeneration->setCurrentIndex(1);
else if (_metrics->value("PONumberGeneration") == "O")
_orderNumGeneration->setCurrentIndex(2);
#if 0
if (_metrics->value("VoucherNumberGeneration") == "M")
_voucherNumGeneration->setCurrentIndex(0);
else if (_metrics->value("VoucherNumberGeneration") == "A")
_voucherNumGeneration->setCurrentIndex(1);
else if (_metrics->value("VoucherNumberGeneration") == "O")
_voucherNumGeneration->setCurrentIndex(2);
#endif
// ToDo
if (_metrics->value("PrNumberGeneration") == "M")
_prNumberGeneration->setCurrentIndex(0);
else if (_metrics->value("PrNumberGeneration") == "A")
_prNumberGeneration->setCurrentIndex(1);
else if (_metrics->value("PrNumberGeneration") == "O")
_prNumberGeneration->setCurrentIndex(2);
_nextPoNumber->setValidator(omfgThis->orderVal());
_nextVcNumber->setValidator(omfgThis->orderVal());
_nextPrNumber->setValidator(omfgThis->orderVal());
configq.exec( "SELECT ponumber.orderseq_number AS ponumber,"
" vcnumber.orderseq_number AS vcnumber,"
" prnumber.orderseq_number AS prnumber "
"FROM orderseq AS ponumber,"
" orderseq AS vcnumber,"
" orderseq AS prnumber "
"WHERE ( (ponumber.orderseq_name='PoNumber')"
" AND (vcnumber.orderseq_name='VcNumber')"
" AND (prnumber.orderseq_name='PrNumber') );" );
if (configq.first())
{
_nextPoNumber->setText(configq.value("ponumber").toString());
_nextVcNumber->setText(configq.value("vcnumber").toString());
_nextPrNumber->setText(configq.value("prnumber").toString());
}
_poChangeLog->setChecked(_metrics->boolean("POChangeLog"));
_vendorChangeLog->setChecked(_metrics->boolean("VendorChangeLog"));
_earliestPO->setChecked(_metrics->boolean("UseEarliestAvailDateOnPOItem"));
_printPO->setChecked(_metrics->boolean("DefaultPrintPOOnSave"));
_requirePoitemStdCost->setChecked(_metrics->boolean("RequireStdCostForPOItem"));
_requirePOTax->setChecked(_metrics->boolean("RequirePOTax"));
_notes->setChecked(_metrics->boolean("CopyPRtoPOItem"));
_defaultShipVia->setText(_metrics->value("DefaultPOShipVia"));
this->setWindowTitle("Purchase Configuration");
}
configurePO::~configurePO()
{
// no need to delete child widgets, Qt does it all for us
}
void configurePO::languageChange()
{
retranslateUi(this);
}
bool configurePO::sSave()
{
emit saving();
if (! _poCopies->save())
return false;
if (_orderNumGeneration->currentIndex() == 0)
_metrics->set("PONumberGeneration", QString("M"));
else if (_orderNumGeneration->currentIndex() == 1)
_metrics->set("PONumberGeneration", QString("A"));
else if (_orderNumGeneration->currentIndex() == 2)
_metrics->set("PONumberGeneration", QString("O"));
_metrics->set("VoucherNumberGeneration", QString("A"));
if (_prNumberGeneration->currentIndex() == 0)
_metrics->set("PrNumberGeneration", QString("M"));
if (_prNumberGeneration->currentIndex() == 1)
_metrics->set("PrNumberGeneration", QString("A"));
if (_prNumberGeneration->currentIndex() == 2)
_metrics->set("PrNumberGeneration", QString("O"));
_metrics->set("POChangeLog", _poChangeLog->isChecked());
_metrics->set("VendorChangeLog", _vendorChangeLog->isChecked());
_metrics->set("UseEarliestAvailDateOnPOItem", _earliestPO->isChecked());
_metrics->set("DefaultPrintPOOnSave", _printPO->isChecked());
_metrics->set("EnableDropShipments", _enableDropShip->isChecked());
_metrics->set("BillDropShip", _billDropShip->isChecked());
_metrics->set("RequireStdCostForPOItem", _requirePoitemStdCost->isChecked());
_metrics->set("RequirePOTax", _requirePOTax->isChecked());
_metrics->set("CopyPRtoPOItem", _notes->isChecked());
_metrics->set("DefaultPOShipVia", _defaultShipVia->text().trimmed());
XSqlQuery configq;
configq.prepare("SELECT setNextPoNumber(:poNumber), setNextVcNumber(:vcNumber), setNextPrNumber(:prNumber);");
configq.bindValue(":poNumber", _nextPoNumber->text().toInt());
configq.bindValue(":vcNumber", _nextVcNumber->text().toInt());
configq.bindValue(":prNumber", _nextPrNumber->text().toInt());
configq.exec();
return true;
}
|