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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
/*
* 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 <metasql.h>
#include <parameter.h>
#include <xsqlquery.h>
#include "widgets.h"
#include "warehouseCluster.h"
WComboBox::WComboBox(QWidget *parent, const char *name) : XComboBox(parent, name)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
setMinimumWidth(80);
setType(AllActive);
}
void WComboBox::setAllowNull(bool pAllowNull)
{
_allowNull = pAllowNull;
setType(_type);
}
WComboBox::WComboBoxTypes WComboBox::type()
{
return _type;
}
void WComboBox::setType(WComboBoxTypes pType)
{
_type = pType;
// If we're in Designer, don't populate
QObject *ancestor = this;
bool designMode;
for ( ; ancestor; ancestor = ancestor->parent())
{
designMode = ancestor->inherits("xTupleDesigner");
if (designMode)
return;
}
int warehousid = ((_x_preferences) ? _x_preferences->value("PreferredWarehouse").toInt() : -1);
QString whss("SELECT warehous_id, warehous_code, warehous_code "
"FROM site() "
"WHERE (true"
"<? if exists(\"active\") ?> AND (warehous_active) <? endif ?>"
"<? if exists(\"shipping\") ?>AND (warehous_shipping)<? endif ?>"
"<? if exists(\"transit\") ?>"
" AND (warehous_transit) "
"<? elseif exists(\"nottransit\") ?>"
" AND (NOT warehous_transit)"
"<? endif ?>"
") "
"ORDER BY warehous_code;" );
ParameterList whsp;
switch (_type)
{
case AllActive:
whsp.append("active");
break;
case Sold:
case NonTransit:
whsp.append("nottransit");
whsp.append("active");
break;
case Shipping:
whsp.append("shipping");
whsp.append("active");
break;
case Supply:
clear();
return; // yes, the previous version just had "clear(); return;"
break;
case Transit:
whsp.append("transit");
whsp.append("active");
break;
case All:
default:
break;
}
MetaSQLQuery whsm(whss);
XSqlQuery whsq = whsm.toQuery(whsp);
populate(whsq, warehousid);
}
void WComboBox::findItemsites(int pItemID)
{
if (pItemID != -1)
{
QString iss("SELECT warehous_id, warehous_code, warehous_code "
"FROM site(), itemsite "
"WHERE ((itemsite_warehous_id=warehous_id)"
" AND (itemsite_item_id=<? value(\"itemid\") ?>) "
"<? if exists(\"active\") ?> AND (warehous_active) <? endif ?>"
"<? if exists(\"shipping\") ?>AND (warehous_shipping)<? endif ?>"
"<? if exists(\"transit\") ?>"
" AND (warehous_transit) "
"<? elseif exists(\"nottransit\") ?>"
" AND (NOT warehous_transit)"
"<? endif ?>"
"<? if exists(\"active\") ?> AND (itemsite_active) <? endif ?>"
"<? if exists(\"soldIS\") ?> AND (itemsite_sold) <? endif ?>"
"<? if exists(\"supplyIS\") ?> AND ( (itemsite_wosupply) OR (itemsite_posupply) OR (itemsite_supply_itemsite_id IS NOT NULL) ) <? endif ?>"
"<? if exists(\"posupplyIS\") ?> AND (itemsite_posupply) <? endif ?>"
"<? if exists(\"wosupplyIS\") ?> AND (itemsite_wosupply) <? endif ?>"
"<? if exists(\"inventory\") ?> AND (itemsite_controlmethod<>'N') <? endif ?>"
") "
"ORDER BY warehous_code;" );
ParameterList isp;
isp.append("itemid", pItemID);
switch (_type)
{
case AllActive:
isp.append("active");
break;
case AllActiveInventory:
isp.append("active");
isp.append("inventory");
break;
case NonTransit:
isp.append("nottransit");
isp.append("active");
break;
case Sold:
isp.append("active");
isp.append("nottransit");
isp.append("soldIS");
break;
/* TODO: ? previous version of this function didn't have Shipping case
case Shipping:
isp.append("shipping");
isp.append("active");
break;
*/
case Supply:
isp.append("active");
isp.append("supplyIS");
break;
case POSupply:
isp.append("active");
isp.append("posupplyIS");
break;
case WOSupply:
isp.append("active");
isp.append("wosupplyIS");
break;
case Transit:
isp.append("transit");
isp.append("active");
break;
case All:
default:
break;
}
MetaSQLQuery ism(iss);
XSqlQuery isq = ism.toQuery(isp);
populate(isq, ((_x_preferences) ?
_x_preferences->value("PreferredWarehouse").toInt() : -1));
if (currentIndex() == -1)
setCurrentIndex(0);
}
else
clear();
}
void WComboBox::setId(int pId)
{
XComboBox::setId(pId);
}
|