/*------------------------------------------------------------------*/ void AzTaskTools::dumpWeights(const AzOut &out, const AzDvect *v_w, const char *name, const AzSvFeatInfo *feat, int print_max, bool changeLine) { if (out.isNull()) return; AzPrint o(out); o.write(name); o.writeln(" -----"); AzIFarr ifa_ex_weight; v_w->nonZero(&ifa_ex_weight); int num = ifa_ex_weight.size(); ifa_ex_weight.sort_Float(false); /* descending order */ /*----- print largest weights -----*/ int ix; for (ix = 0; ix < num; ++ix) { if (ix >= print_max) break; int ex; double val = ifa_ex_weight.get(ix, &ex); AzBytArr str_weight; formatWeight(feat, ex, val, &str_weight); o.write(str_weight); if (changeLine) { o.newLine(); } } o.newLine(); o.newLine(); if (num > print_max) { /*----- print smallest weights -----*/ for (ix = num - 1; ix >= 0; --ix) { if (num - ix > print_max) break; int ex; double val = ifa_ex_weight.get(ix, &ex); AzBytArr str_weight; formatWeight(feat, ex, val, &str_weight); o.write(str_weight); if (changeLine) { o.newLine(); } } o.newLine(); o.newLine(); } o.flush(); }
void shippingInformation::sFillList() { // Clear any old data _item->clear(); QString shs( "SELECT shiphead_notes, shiphead_shipvia," " shiphead_shipchrg_id, shiphead_shipform_id," " shiphead_freight, shiphead_freight_curr_id," " shiphead_shipdate," " CASE WHEN (shiphead_shipdate IS NULL) THEN FALSE" " ELSE TRUE" " END AS validdata " "FROM shiphead " "WHERE ((NOT shiphead_shipped)" " AND (shiphead_order_type=<? value(\"ordertype\") ?>)" " AND (shiphead_order_id=<? value(\"orderid\") ?>) );" ) ; ParameterList shp; if (_salesOrder->isValid()) { shp.append("ordertype", "SO"); shp.append("orderid", _salesOrder->id()); } else if (_to->isValid()) { shp.append("ordertype", "TO"); shp.append("orderid", _to->id()); } else { _salesOrder->setId(-1); _orderDate->setNull(); _poNumber->clear(); _custName->clear(); _custPhone->clear(); _shipDate->setNull(); _shipVia->setNull(); _freight->reset(); _totalNetWeight->clear(); _totalTareWeight->clear(); _totalGrossWeight->clear(); return; } MetaSQLQuery shm(shs); q = shm.toQuery(shp); bool fetchFromHead = TRUE; if (q.first()) { if (q.value("validdata").toBool()) { fetchFromHead = FALSE; _shipDate->setDate(q.value("shiphead_shipdate").toDate()); _shipVia->setText(q.value("shiphead_shipvia").toString()); _shippingCharges->setId(q.value("shiphead_shipchrg_id").toInt()); _shippingForm->setId(q.value("shiphead_shipform_id").toInt()); _freight->setId(q.value("shiphead_freight_curr_id").toInt()); _freight->setLocalValue(q.value("shiphead_freight").toDouble()); _notes->setText(q.value("shiphead_notes").toString()); } } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } if (_salesOrder->isValid()) { q.prepare( "SELECT cohead_orderdate AS orderdate," " cohead_holdtype AS holdtype," " cohead_custponumber AS ponumber," " cust_name AS name, cust_phone AS phone," " cohead_shipcomments AS shipcomments," " cohead_shipvia AS shipvia," " cohead_shipchrg_id AS shipchrg_id," " cohead_shipform_id AS shipform_id " "FROM cohead, cust " "WHERE ((cohead_cust_id=cust_id)" " AND (cohead_id=:cohead_id));" ); q.bindValue(":cohead_id", _salesOrder->id()); } else if (_to->isValid()) { q.prepare( "SELECT tohead_orderdate AS orderdate," " 'N' AS holdtype," " :to AS ponumber," " tohead_destname AS name, tohead_destphone AS phone," " tohead_shipcomments AS shipcomments," " tohead_shipvia AS shipvia," " tohead_shipchrg_id AS shipchrg_id," " tohead_shipform_id AS shipform_id " "FROM tohead " "WHERE (tohead_id=:tohead_id);" ); q.bindValue(":tohead_id", _to->id()); } q.exec(); if (q.first()) { _orderDate->setDate(q.value("orderdate").toDate()); _poNumber->setText(q.value("custponumber").toString()); _custName->setText(q.value("name").toString()); _custPhone->setText(q.value("phone").toString()); QString msg; if (q.value("head_holdtype").toString() == "C") msg = storedProcErrorLookup("issuetoshipping", -12); else if (q.value("head_holdtype").toString() == "P") msg = storedProcErrorLookup("issuetoshipping", -13); else if (q.value("head_holdtype").toString() == "R") msg = storedProcErrorLookup("issuetoshipping", -14); if (! msg.isEmpty()) { QMessageBox::warning(this, tr("Order on Hold"), msg); _salesOrder->setId(-1); _salesOrder->setFocus(); _to->setId(-1); return; } if (fetchFromHead) { _shipDate->setDate(omfgThis->dbDate()); _shippingCharges->setId(q.value("shipchrg_id").toInt()); _shippingForm->setId(q.value("shipform_id").toInt()); _notes->setText(q.value("shipcomments").toString()); _shipVia->setText(q.value("shipvia").toString()); } } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } if (_salesOrder->isValid()) { q.prepare( "SELECT coitem_id AS itemid, coitem_cohead_id AS headid," " coitem_linenumber AS linenumber, item_number," " (item_prodweight * itemuomtouom(item_id, coitem_price_uom_id, NULL, qtyAtShipping('SO', coitem_id))) AS netweight," " (item_packweight * itemuomtouom(item_id, coitem_price_uom_id, NULL, qtyAtShipping('SO', coitem_id))) AS tareweight," " qtyAtShipping('SO', coitem_id) AS qtyatshipping," " formatQty(qtyAtShipping('SO', coitem_id)) AS f_qtyatshipping " "FROM coitem, itemsite, item " "WHERE ((coitem_itemsite_id=itemsite_id)" " AND (itemsite_item_id=item_id)" " AND (coitem_cohead_id=:cohead_id) ) " "ORDER BY coitem_linenumber;" ); q.bindValue(":cohead_id", _salesOrder->id()); } else if (_to->isValid()) { q.prepare( "SELECT toitem_id AS itemid, toitem_tohead_id AS headid," " toitem_linenumber AS linenumber, item_number," " (item_prodweight * qtyAtShipping('TO', toitem_id))) AS netweight," " (item_packweight * qtyAtShipping('TO', toitem_id))) AS tareweight," " qtyAtShipping('TO', toitem_id) AS qtyatshipping," " formatQty(qtyAtShipping('TO', toitem_id)) AS f_qtyatshipping " "FROM toitem, item " "WHERE ((toitem_item_id=item_id)" " AND (toitem_tohead_id=:tohead_id) ) " "ORDER BY toitem_linenumber;" ) ; q.bindValue(":tohead_id", _to->id()); } q.exec(); double totalNetWeight = 0; double totalTareWeight = 0; XTreeWidgetItem* last = 0; while (q.next()) { totalNetWeight += q.value("netweight").toDouble(); totalTareWeight += q.value("tareweight").toDouble(); last = new XTreeWidgetItem( _item, last, q.value("itemid").toInt(), q.value("headid").toInt(), q.value("linenumber"), q.value("item_number"), q.value("f_qtyatshipping"), formatWeight(q.value("netweight").toDouble()), formatWeight(q.value("tareweight").toDouble()), formatWeight((q.value("netweight").toDouble() + q.value("tareweight").toDouble())) ); } if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } _totalNetWeight->setText(formatWeight(totalNetWeight)); _totalTareWeight->setText(formatWeight(totalTareWeight)); _totalGrossWeight->setText(formatWeight(totalNetWeight + totalTareWeight)); }