void dspAPOpenItemsByVendor::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *selected, int) { QString status(selected->text(1)); QAction *menuItem; if (list()->currentItem()->text("f_doctype") == tr("Voucher")) { menuItem = pMenu->addAction(tr("View Voucher..."), this, SLOT(sViewVoucher())); menuItem->setEnabled(_privileges->check("ViewVouchers") || _privileges->check("MaintainVouchers")); } menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sEdit())); if (!_privileges->check("EditAPOpenItem")) menuItem->setEnabled(false); menuItem = pMenu->addAction(tr("View..."), this, SLOT(sView())); XSqlQuery menu; menu.prepare("SELECT apopen_status FROM apopen WHERE apopen_id=:apopen_id;"); menu.bindValue(":apopen_id", list()->id()); menu.exec(); if (menu.first()) { if(menu.value("apopen_status").toString() == "O") { menuItem = pMenu->addAction(tr("On Hold"), this, SLOT(sOnHold())); menuItem->setEnabled(_privileges->check("EditAPOpenItem")); } if(menu.value("apopen_status").toString() == "H") { menuItem = pMenu->addAction(tr("Open"), this, SLOT(sOpen())); menuItem->setEnabled(_privileges->check("EditAPOpenItem")); } } menuItem = pMenu->addAction(tr("Print..."), this, SLOT(sPrintItem())); if (!_privileges->check("EditAPOpenItem")) menuItem->setEnabled(false); if (list()->currentItem()->text("f_doctype") == tr("Credit Memo")) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("Apply Credit Memo..."), this, SLOT(sApplyAPOpenCM())); menuItem->setEnabled(_privileges->check("ApplyAPMemos")); } }
void dspAROpenItems::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pItem, int) { QAction *menuItem = 0; if (((XTreeWidgetItem *)pItem)->altId() < 4) { menuItem = pMenu->addAction(tr("Print..."), this, SLOT(sPrintItem())); if (((XTreeWidgetItem *)pItem)->altId() == 0) // Invoice menuItem->setEnabled(_privileges->check("ViewMiscInvoices") || _privileges->check("MaintainMiscInvoices")); else if (((XTreeWidgetItem *)pItem)->altId() == 1 && ((XTreeWidgetItem *)pItem)->id("docnumber") > -1) // Credit Memo menuItem->setEnabled(_privileges->check("ViewCreditMemos") || _privileges->check("MaintainCreditMemos")); else // Open Item menuItem->setEnabled(_privileges->check("ViewAROpenItems") || _privileges->check("EditAROpenItem")); } pMenu->addSeparator(); if (((XTreeWidgetItem *)pItem)->altId() == 0 && ((XTreeWidgetItem *)pItem)->rawValue("posted") == 0) // Invoice { menuItem = pMenu->addAction(tr("Edit Invoice..."), this, SLOT(sEdit())); menuItem->setEnabled(_privileges->check("MaintainMiscInvoices")); } else if (((XTreeWidgetItem *)pItem)->altId() == 1 && ((XTreeWidgetItem *)pItem)->id("docnumber") > -1) // Credit Memo { menuItem = pMenu->addAction(tr("Edit Credit Memo..."), this, SLOT(sEdit())); menuItem->setEnabled(_privileges->check("MaintainCreditMemos")); } else if (((XTreeWidgetItem *)pItem)->id() > 0) // Open Item { menuItem = pMenu->addAction(tr("Edit Receivable Item..."), this, SLOT(sEdit())); menuItem->setEnabled(_privileges->check("EditAROpenItem")); } else // Incident { menuItem = pMenu->addAction(tr("Edit Incident..."), this, SLOT(sEdit())); menuItem->setEnabled(_privileges->check("MaintainAllIncidents")); } if (((XTreeWidgetItem *)pItem)->id() > 0) // Open Item { menuItem = pMenu->addAction(tr("View Receivable Item..."), this, SLOT(sView())); menuItem->setEnabled(_privileges->check("EditAROpenItem") || _privileges->check("ViewAROpenItems")); } if (((XTreeWidgetItem *)pItem)->altId() == 0) // Invoice { if(((XTreeWidgetItem *)pItem)->rawValue("posted") != 0) { menuItem = pMenu->addAction(tr("Void Posted Invoice..."), this, SLOT(sVoidInvoiceDetails())); menuItem->setEnabled(_privileges->check("VoidPostedInvoices")); menuItem = pMenu->addAction(tr("Edit Posted Invoice..."), this, SLOT(sEditInvoiceDetails())); menuItem->setEnabled(_privileges->check("MaintainMiscInvoices")); } menuItem = pMenu->addAction(tr("View Invoice..."), this, SLOT(sViewInvoiceDetails())); menuItem->setEnabled(_privileges->check("ViewMiscInvoices")); menuItem = pMenu->addAction(tr("View Invoice Information..."), this, SLOT(sViewInvoice())); menuItem->setEnabled(_privileges->check("ViewMiscInvoices")); } else if (((XTreeWidgetItem *)pItem)->altId() == 1 && ((XTreeWidgetItem *)pItem)->id("docnumber") > -1) // Credit Memo { if(((XTreeWidgetItem *)pItem)->rawValue("posted") != 0) { menuItem = pMenu->addAction(tr("Void Posted Credit Memo..."), this, SLOT(sVoidCreditMemo())); menuItem->setEnabled(_privileges->check("VoidPostedARCreditMemos")); } menuItem = pMenu->addAction(tr("View Credit Memo..."), this, SLOT(sViewCreditMemo())); menuItem->setEnabled(_privileges->check("MaintainCreditMemos") || _privileges->check("ViewCreditMemos")); } else if (((XTreeWidgetItem *)pItem)->altId() == 4) // Incident { menuItem = pMenu->addAction(tr("View Incident..."), this, SLOT(sViewIncident())); menuItem->setEnabled(_privileges->check("ViewAllIncidents") || _privileges->check("MaintainAllIncidents")); } if (((XTreeWidgetItem *)pItem)->altId() < 2 && ((XTreeWidgetItem *)pItem)->id() == -1 && !((XTreeWidgetItem *)pItem)->rawValue("posted").toBool()) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("Post..."), this, SLOT(sPost())); menuItem->setEnabled(_privileges->check("PostARDocuments")); if (((XTreeWidgetItem *)pItem)->altId() == 0) { menuItem = pMenu->addAction(tr("Delete..."), this, SLOT(sDeleteInvoice())); menuItem->setEnabled(_privileges->check("MaintainMiscInvoices")); } else { menuItem = pMenu->addAction(tr("Delete..."), this, SLOT(sDeleteCreditMemo())); menuItem->setEnabled(_privileges->check("MaintainCreditMemos")); } } if ((((XTreeWidgetItem *)pItem)->altId() == 1 || ((XTreeWidgetItem *)pItem)->altId() == 3) && ((XTreeWidgetItem *)pItem)->rawValue("posted").toBool() && ((XTreeWidgetItem *)pItem)->rawValue("open").toBool() ) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("Apply Credit Memo..."), this, SLOT(sApplyAropenCM())); menuItem->setEnabled(_privileges->check("ApplyARMemos")); } if ((((XTreeWidgetItem *)pItem)->id("ordernumber") > 0 && ((XTreeWidgetItem *)pItem)->altId() == 0) ) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("Edit Sales Order..."), this, SLOT(sEditSalesOrder())); menuItem->setEnabled(_privileges->check("MaintainSalesOrders") || _privileges->check("ViewSalesOrders")); menuItem = pMenu->addAction(tr("View Sales Order..."), this, SLOT(sViewSalesOrder())); menuItem->setEnabled(_privileges->check("ViewSalesOrders")); menuItem = pMenu->addAction(tr("Shipment Status..."), this, SLOT(sDspShipmentStatus())); menuItem->setEnabled(_privileges->check("MaintainSalesOrders") || _privileges->check("ViewSalesOrders")); menuItem = pMenu->addAction(tr("Shipments..."), this, SLOT(sShipment())); menuItem->setEnabled(_privileges->check("MaintainSalesOrders") || _privileges->check("ViewSalesOrders")); } if ((((XTreeWidgetItem *)pItem)->altId() == 0 || ((XTreeWidgetItem *)pItem)->altId() == 2) && ((XTreeWidgetItem *)pItem)->rawValue("posted").toBool() && ((XTreeWidgetItem *)pItem)->rawValue("open").toBool() ) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("New Cash Receipt..."), this, SLOT(sNewCashrcpt())); menuItem->setEnabled(_privileges->check("MaintainCashReceipts")); } if ((_metrics->boolean("CCAccept") && ((XTreeWidgetItem *)pItem)->id("ccard_number") > 0) ) { menuItem = pMenu->addAction(tr("Refund"), this, SLOT(sCCRefundCM())); menuItem->setEnabled( _privileges->check("ProcessCreditCards") && ((XTreeWidgetItem *)pItem)->rawValue("balance").toDouble() < 0); } if (((XTreeWidgetItem *)pItem)->id() > -1 && ((XTreeWidgetItem *)pItem)->rawValue("posted").toBool() && ((XTreeWidgetItem *)pItem)->rawValue("open").toBool() ) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("New Incident..."), this, SLOT(sIncident())); if (!_privileges->check("MaintainAllIncidents")) menuItem->setEnabled(false); } }