Example #1
0
distributeInventory::distributeInventory(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_bcDistribute,    SIGNAL(clicked()), this, SLOT(sBcDistribute()));
  connect(_default,         SIGNAL(clicked()), this, SLOT(sDefault()));
  connect(_defaultAndPost,  SIGNAL(clicked()), this, SLOT(sDefaultAndPost()));
  connect(_distribute,      SIGNAL(clicked()), this, SLOT(sSelectLocation()));
  connect(_itemloc, SIGNAL(itemSelected(int)), this, SLOT(sSelectLocation()));
  connect(_post,            SIGNAL(clicked()), this, SLOT(sPost()));
  connect(_taggedOnly,  SIGNAL(toggled(bool)), this, SLOT(sFillList()));
  connect(_bc,   SIGNAL(textChanged(QString)), this, SLOT(sBcChanged(QString)));
  connect(_qtyOnly,     SIGNAL(toggled(bool)), this, SLOT(sFillList()));

  omfgThis->inputManager()->notify(cBCLotSerialNumber, this, this, SLOT(sCatchLotSerialNumber(QString)));

  _trapClose = TRUE;

  _item->setReadOnly(TRUE);
  _qtyToDistribute->setPrecision(omfgThis->qtyVal());
  _qtyTagged->setPrecision(omfgThis->qtyVal());
  _qtyRemaining->setPrecision(omfgThis->qtyVal());
  
  _itemloc->addColumn(tr("Location"),     _itemColumn, Qt::AlignLeft,  true, "locationname");
  _itemloc->addColumn(tr("Default"),      _ynColumn,   Qt::AlignLeft,  true, "defaultlocation");
  _itemloc->addColumn(tr("Netable"),      _ynColumn,   Qt::AlignCenter,true, "location_netable");
  _itemloc->addColumn(tr("Lot/Serial #"), -1,          Qt::AlignLeft,  true, "lotserial");
  _itemloc->addColumn(tr("Expiration"),   _dateColumn, Qt::AlignCenter,true, "f_expiration");
  _itemloc->addColumn(tr("Qty. Before"),  _qtyColumn,  Qt::AlignRight, true, "qty");
  _itemloc->addColumn(tr("Tagged Qty."),  _qtyColumn,  Qt::AlignRight, true, "qtytagged");
  _itemloc->addColumn(tr("Qty. After"),   _qtyColumn,  Qt::AlignRight, true, "balance");
  
  //If not multi-warehouse hide whs control
  if (!_metrics->boolean("MultiWhs"))
  {
    _warehouseLit->hide();
    _warehouse->hide();
  }
  
  //If not lot serial control, hide info
  if (!_metrics->boolean("LotSerialControl"))
  {
    _lotSerial->hide();
    _lotSerialLit->hide();
    _bcLit->hide();
    _bc->hide();
    _bcQtyLit->hide();
    _bcQty->hide();
    _bcDistribute->hide();
  }

  _itemlocdistid = -1;
  
  _locationDefaultLit->hide();
  _locations->hide();
}
void reserveSalesOrderItem::populate()
{
  XSqlQuery distributepopulate;
  distributepopulate.prepare("SELECT itemsite_loccntrl, itemsite_controlmethod "
                             "FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) "
                             "WHERE (coitem_id=:soitem_id);");
  
  distributepopulate.bindValue(":soitem_id", _soitemid);
  distributepopulate.exec();
  if (distributepopulate.first())
  {
    _locControl = distributepopulate.value("itemsite_loccntrl").toBool();
    _controlMethod = distributepopulate.value("itemsite_controlmethod").toString();

    if (_metrics->boolean("SOManualReservations") && (_locControl || _controlMethod == "L" || _controlMethod == "S"))
    {
      connect(_bcReserve,       SIGNAL(clicked()), this, SLOT(sBcReserve()), Qt::UniqueConnection);
      connect(_reserve,         SIGNAL(clicked()), this, SLOT(sReserveLocation()), Qt::UniqueConnection);
      connect(_unreserve,       SIGNAL(clicked()), this, SLOT(sUnreserveLocation()), Qt::UniqueConnection);
      connect(_itemloc, SIGNAL(itemSelected(int)), this, SLOT(sReserveLocation()), Qt::UniqueConnection);
      connect(_bc,   SIGNAL(textChanged(QString)), this, SLOT(sBcChanged(QString)), Qt::UniqueConnection);
      
      //If not lot serial control, hide info
      if (!_metrics->boolean("LotSerialControl"))
      {
        _bcLit->hide();
        _bc->hide();
        _bcQtyLit->hide();
        _bcQty->hide();
        _bcReserve->hide();
      }
      else
      {
        omfgThis->inputManager()->notify(cBCLotSerialNumber, this, this, SLOT(sCatchLotSerialNumber(QString)));
        
        _bc->setEnabled(_controlMethod == "L" || _controlMethod == "S");
        _bcQty->setEnabled(_controlMethod == "L");
        _bcReserve->setEnabled(_controlMethod == "L" || _controlMethod == "S");
        if (_controlMethod == "S")
          _bcQty->setText("1");
        else
          _bcQty->clear();

      }
    }
reserveSalesOrderItem::reserveSalesOrderItem(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_close, SIGNAL(clicked()), this, SLOT(reject()));

  _item->setReadOnly(true);

  _qtyToReserve->setValidator(omfgThis->qtyVal());

  _ordered->setPrecision(omfgThis->qtyVal());
  _shipped->setPrecision(omfgThis->qtyVal());
  _atShipping->setPrecision(omfgThis->qtyVal());
  _reserved->setPrecision(omfgThis->qtyVal());
  _onHand->setPrecision(omfgThis->qtyVal());
  _allocated->setPrecision(omfgThis->qtyVal());
  _unreserved->setPrecision(omfgThis->qtyVal());

  if (_metrics->boolean("SOManualReservations"))
  {
    connect(_bcReserve,       SIGNAL(clicked()), this, SLOT(sBcReserve()));
    connect(_reserve,         SIGNAL(clicked()), this, SLOT(sReserveLocation()));
    connect(_unreserve,       SIGNAL(clicked()), this, SLOT(sUnreserveLocation()));
    connect(_itemloc, SIGNAL(itemSelected(int)), this, SLOT(sReserveLocation()));
    connect(_bc,   SIGNAL(textChanged(QString)), this, SLOT(sBcChanged(QString)));
    
    omfgThis->inputManager()->notify(cBCLotSerialNumber, this, this, SLOT(sCatchLotSerialNumber(QString)));
    
    _itemloc->addColumn(tr("Location"),       _itemColumn, Qt::AlignLeft,  true, "location");
    _itemloc->addColumn(tr("Lot/Serial #"),   -1,          Qt::AlignLeft,  true, "lotserial");
    _itemloc->addColumn(tr("Expiration"),     _dateColumn, Qt::AlignCenter,true, "f_expiration");
    _itemloc->addColumn(tr("This Reserved"),  _qtyColumn,  Qt::AlignRight, true, "reserved");
    _itemloc->addColumn(tr("Total Reserved"), _qtyColumn,  Qt::AlignRight, true, "totalreserved");
    _itemloc->addColumn(tr("Unreserved"),     _qtyColumn,  Qt::AlignRight, true, "unreserved");

    //If not lot serial control, hide info
    if (!_metrics->boolean("LotSerialControl"))
    {
      _bcLit->hide();
      _bc->hide();
      _bcQtyLit->hide();
      _bcQty->hide();
      _bcReserve->hide();
    }
    else
    {
      // Add columns for lotserial characteristics
      QString column;
      QString name;
      QString sql = QString("SELECT char_id, char_name, char_type "
                            "FROM char "
                            "WHERE (char_lotserial) "
                            " AND (char_search) "
                            "ORDER BY char_name;");
      XSqlQuery chars;
      chars.exec(sql);
      while (chars.next())
      {
        characteristic::Type chartype = (characteristic::Type)chars.value("char_type").toInt();
        column = QString("char%1").arg(chars.value("char_id").toString());
        name = chars.value("char_name").toString();
        _itemloc->addColumn(name, -1, Qt::AlignLeft , true, column );
        if (chartype == characteristic::Text)
        {
          _charidstext.append(chars.value("char_id").toInt());
        }
        else if (chartype == characteristic::List)
        {
          _charidslist.append(chars.value("char_id").toInt());
        }
        else if (chartype == characteristic::Date)
        {
          _charidsdate.append(chars.value("char_id").toInt());
        }
      }
    }
  }