/** * CustomLoginFlagEditor::saveClicked() * * Walks through the flagTable and saves the values. */ void CustomLoginFlagEditor::saveClicked() { ADB db; if (flagTable->numRows()) { // Create a LoginService object to setup our flags. LoginService svc; svc.setServiceID(QString(myLoginID)); if (!svc.loginExists()) { QMessageBox::warning(this, "BRASS Error", svc.lastStatus()); return; } if (!svc.loadFlags()) { QMessageBox::warning(this, "BRASS Error", svc.lastStatus()); return; } // Loop through the rows, grabbing the key/value pairs for (int i = 0; i < flagTable->numRows(); i++) { long result; QString flag, val; flag = flagTable->text(i-1,0); val = flagTable->text(i-1,1); if (flag.length()) { svc.addFlag(flag, val, true); result = db.dbcmd("replace into LoginFlagValues values ('%s', '%s', '%s')", myLoginID, flag.ascii(), val.ascii()); if (result < 0) { QMessageBox::warning(this, "Database Error", "Unable to save flag."); } } } svc.provision(); } // Let our parent know that something has changed emit(customerUpdated(myCustID)); delete this; }
void Tab_Logins::updateDBForWipe(const char * LoginID) { char tmpLogin[64]; char newLogin[64]; char tmpstr[1024]; LoginsDB LDB; ADB DB; NotesDB NDB; int wasActive = 0; QDate tmpDate; char today[64]; strcpy(tmpLogin, LoginID); tmpDate = QDate::currentDate(); sprintf(today, "%04d-%02d-%02d", tmpDate.year(), tmpDate.month(), tmpDate.day()); LDB.get(myCustID, LoginID); DB.dbcmd("update Subscriptions set Active = 0 where LoginID = '%s' and CustomerID = %ld", tmpLogin, myCustID); // Remove any custom flags. DB.dbcmd("delete from LoginFlagValues where LoginID = '%s'", tmpLogin); wasActive = LDB.getInt("Active"); LDB.setValue("Active", (int) 0); LDB.setValue("Wiped", today); LDB.upd(); // Now, just if they were open, update the AR. // If not, don't make an adjusting entry because // the lock routines should have already done that. if (wasActive && isManager()) { QApplication::restoreOverrideCursor(); if (QMessageBox::warning(this, "Prorate Charges", "Do you wish to prorate the charges for this login?", "&Yes", "&No", 0, 1) == 0) { QApplication::setOverrideCursor(WaitCursor); updateARForLock(tmpLogin); QApplication::restoreOverrideCursor(); } QApplication::setOverrideCursor(WaitCursor); } NDB.setValue("LoginID", tmpLogin); NDB.setValue("CustomerID", myCustID); NDB.setValue("NoteType", "Operator"); NDB.setValue("NoteText", "Login Wiped."); NDB.ins(); // Now that they're wiped, rename this login // to show that it has been wiped. // Wiped logins should preface with "Wnn-" where // 'nn' is between 00 and 99. The "W" should be // capitalized, that way it will appear at the // end of the sort list. int StartingNo = 0; int FoundOne = 0; while (!FoundOne) { sprintf(tmpstr, "W%02d-%s", StartingNo, tmpLogin); DB.query("select * from Logins where CustomerID = %ld and LoginID = '%s'", myCustID, tmpstr); if (!DB.rowCount) { FoundOne = 1; strcpy(newLogin, tmpstr); } else { StartingNo++; } } // Now that we've got the newLogin, update // _ALL_ of the tables with it... // Not fun, but necessary. LDB.get(myCustID, tmpLogin); LDB.changeLoginID(newLogin); emit(customerUpdated(myCustID)); refreshLoginList(myCustID); }
int createSalesTicket(ConnectNotice &cn) { char noteText[4096]; char summary[4096]; Ticket newTick; sprintf(summary, "Qwest DSL - %s %s", cn.connType, cn.custCirc); newTick.setName(cn.custName); newTick.setSummary(summary); newTick.setOpened(); newTick.setModified(); newTick.setStatus(Ticket::Unexamined); newTick.setType(Ticket::Sales); newTick.create(); strcpy(noteText, "The following Qwest connect notice has been recieved and no matching phone numbers could be found for it.<P>\n"); strcat(noteText, "Action "); strcat(noteText, cn.connType); strcat(noteText, "<BR>\n"); strcat(noteText, "Notice Date "); strcat(noteText, cn.noticeDate); strcat(noteText, "<BR>\n"); strcat(noteText, "Name "); strcat(noteText, cn.custName); strcat(noteText, "<BR>\n"); strcat(noteText, "Addr1 "); strcat(noteText, cn.addr1); strcat(noteText, "<BR>\n"); strcat(noteText, "Addr2 "); strcat(noteText, cn.addr2); strcat(noteText, "<BR>\n"); strcat(noteText, "Addr3 "); strcat(noteText, cn.addr3); strcat(noteText, "<BR>\n"); strcat(noteText, "Select "); strcat(noteText, cn.isSelect); strcat(noteText, "<BR>\n"); strcat(noteText, "CBR Number "); strcat(noteText, cn.cbr); strcat(noteText, "<BR>\n"); strcat(noteText, "DSL Phone "); strcat(noteText, cn.custCirc); strcat(noteText, "<BR>\n"); strcat(noteText, "Blarg Circuit "); strcat(noteText, cn.hostCirc); strcat(noteText, "<BR>\n"); strcat(noteText, "Due Date "); strcat(noteText, cn.dueDate); strcat(noteText, "<BR>\n"); strcat(noteText, "Speed "); strcat(noteText, cn.speed); strcat(noteText, "<BR>\n"); strcat(noteText, "VPI "); strcat(noteText, cn.vpi); strcat(noteText, "<BR>\n"); strcat(noteText, "VCI "); strcat(noteText, cn.vci); strcat(noteText, "<BR>\n"); newTick.addLogEntry(Ticket::Normal, "%s", noteText); ADB tmpDB; cn.ticketNo = newTick.ticketNo(); tmpDB.dbcmd("update QwestDSLNotices set TicketNo = %ld where NoticeID = %ld", cn.ticketNo, cn.noticeID); return 1; }
void scanOrphans() { ADB connDB; ADB phoneDB; ADB workDB; char tmpPhone[1024]; string workStr; long custID; char noteText[4096]; connDB.query("select * from QwestDSLNotices where CustomerID = 0"); if (!connDB.rowCount) return; while (connDB.getrow()) { strcpy(tmpPhone, ""); workStr = connDB.curRow["DSLNumber"]; strcat(tmpPhone, workStr.substr(0, 3).c_str()); strcat(tmpPhone, "%%"); strcat(tmpPhone, workStr.substr(3, 3).c_str()); strcat(tmpPhone, "%%"); strcat(tmpPhone, workStr.substr(6, 4).c_str()); strcat(tmpPhone, "%%"); //printf("select * from PhoneNumbers where PhoneNumber LIKE '%s'\n", tmpPhone); phoneDB.query("select * from PhoneNumbers where PhoneNumber LIKE '%s'", tmpPhone); if (phoneDB.rowCount) { // Found a matching phone number phoneDB.getrow(); custID = atol(phoneDB.curRow["RefID"]); workDB.dbcmd("update QwestDSLNotices set CustomerID = %ld where NoticeID = %ld", custID, atol(connDB.curRow["NoticeID"])); // Now, add the notice into the customer notes. ADBTable notesDB("Notes"); notesDB.setValue("AutoNote", 1); notesDB.setValue("AddedBy", "Auto"); notesDB.setValue("NoteDate", connDB.curRow["NoticeDate"]); notesDB.setValue("CustomerID", custID); notesDB.setValue("NoteType", "Qwest DSL"); notesDB.setValue("Category", connDB.curRow["Action"]); notesDB.setValue("SubCategory", "Connect Notice"); notesDB.setValue("Subject", connDB.curRow["Action"]); strcpy(noteText, ""); strcat(noteText, "Action "); strcat(noteText, connDB.curRow["Action"]); strcat(noteText, "\n"); strcat(noteText, "Name "); strcat(noteText, connDB.curRow["Name"]); strcat(noteText, "\n"); strcat(noteText, "Addr1 "); strcat(noteText, connDB.curRow["Addr1"]); strcat(noteText, "\n"); strcat(noteText, "Addr2 "); strcat(noteText, connDB.curRow["Addr2"]); strcat(noteText, "\n"); strcat(noteText, "Addr3 "); strcat(noteText, connDB.curRow["Addr3"]); strcat(noteText, "\n"); strcat(noteText, "Select "); strcat(noteText, connDB.curRow["Select256"]); strcat(noteText, "\n"); strcat(noteText, "CBR Number "); strcat(noteText, connDB.curRow["CBR"]); strcat(noteText, "\n"); strcat(noteText, "DSL Phone "); strcat(noteText, connDB.curRow["DSLNumber"]); strcat(noteText, "\n"); strcat(noteText, "Blarg Circuit "); strcat(noteText, connDB.curRow["BlargCircuit"]); strcat(noteText, "\n"); strcat(noteText, "Due Date "); strcat(noteText, connDB.curRow["DueDate"]); strcat(noteText, "\n"); strcat(noteText, "Speed "); strcat(noteText, connDB.curRow["LineSpeed"]); strcat(noteText, "\n"); strcat(noteText, "VPI "); strcat(noteText, connDB.curRow["VPI"]); strcat(noteText, "\n"); strcat(noteText, "VCI "); strcat(noteText, connDB.curRow["VCI"]); strcat(noteText, "\n"); notesDB.setValue("NoteText", noteText); notesDB.ins(); // Now that the note has been inserted, check for any // tickets that may be opened on this line still. if (atol(connDB.curRow["TicketNo"])) { // We have a ticket. Load it up. Ticket tmpTick; tmpTick.setTicketNo(atol(connDB.curRow["TicketNo"])); if (tmpTick.status() != Ticket::Closed) { // The ticket is open. Set the customer ID and // close it. tmpTick.setCustomerID(custID); tmpTick.setStatus(Ticket::Closed); tmpTick.addLogEntry(Ticket::Normal, "DSL Number %s found for Customer ID %ld. Auto-closing ticket.", connDB.curRow["DSLNumber"], custID); } } } } }
void MakeDeposits::processSelections() { if (selTotal <= 0.00) return; GenLedger *GL = new GenLedger(); int srcAcct, dstAcct = 0; ADB DB; QDate selDate = transDate->date(); char tDate[1024]; strcpy(tDate, selDate.toString("yyyy-MM-dd").ascii()); // Setup the base GL transaction GL->BaseDesc = "Deposit"; // Get the source and destination accounts. // The source will be our Undeposited Funds account. srcAcct = atol(cfgVal("UndepositedFundsAcct")); dstAcct = accountIDX[targetAccountList->currentItem()]; // Now, setup the transaction. // Start by walking through each of the undeposited items and // then adding a split item for it. Q3ListViewItem *curItem; //int nameCol = 2; //int numCol = 3; int amtCol = 4; int intIDCol = 5; char tmpStr[1024]; selTotal = 0.00; curItem = paymentList->firstChild(); while (curItem != NULL) { if (curItem->isSelected()) { selTotal += atof(curItem->key(amtCol,0)); } curItem = curItem->itemBelow(); } // Add the first half of our split GL->AddSplit(); GL->CurrentSplit->IntAccountNo.setNum(srcAcct); GL->CurrentSplit->Amount.setNum(selTotal * -1.0); GL->CurrentSplit->TransType.setNum(TRANSTYPE_DEPOSIT); GL->CurrentSplit->TransTypeLink.setNum(0); GL->CurrentSplit->TransDate = selDate.toString("yyyy-MM-dd"); GL->CurrentSplit->BilledDate = selDate.toString("yyyy-MM-dd"); GL->CurrentSplit->DueDate = selDate.toString("yyyy-MM-dd"); GL->CurrentSplit->Cleared.setNum(0); GL->CurrentSplit->Number.setNum(0); GL->CurrentSplit->NumberStr = ""; GL->CurrentSplit->ItemID.setNum(0); GL->CurrentSplit->Quantity.setNum(1); GL->CurrentSplit->Price.setNum(selTotal); sprintf(tmpStr, "Deposit of $%.2f on %s", selTotal, selDate.toString("yyyy-MM-dd").ascii()); GL->CurrentSplit->Memo = tmpStr; // Now, setup the other "half" of our transaction. GL->AddSplit(); GL->CurrentSplit->IntAccountNo.setNum(dstAcct); GL->CurrentSplit->Amount.setNum(selTotal); GL->CurrentSplit->TransType.setNum(TRANSTYPE_DEPOSIT); GL->CurrentSplit->TransTypeLink.setNum(0); GL->CurrentSplit->TransDate = selDate.toString("yyyy-MM-dd").ascii(); GL->CurrentSplit->BilledDate = selDate.toString("yyyy-MM-dd").ascii(); GL->CurrentSplit->DueDate = selDate.toString("yyyy-MM-dd").ascii(); GL->CurrentSplit->Cleared.setNum(0); GL->CurrentSplit->Number.setNum(0); GL->CurrentSplit->NumberStr = "0"; GL->CurrentSplit->ItemID.setNum(0); GL->CurrentSplit->Quantity.setNum(1); GL->CurrentSplit->Price.setNum(selTotal); sprintf(tmpStr, "Deposit of $%.2f on %s", selTotal, selDate.toString("yyyy-MM-dd").ascii()); GL->CurrentSplit->Memo = tmpStr; // Finally, save the entire transaction. GL->SaveTrans(); // Now, walk throught the list one more time and update the // undeposited funds with the linked transaction and set them to be // cleared. curItem = paymentList->firstChild(); while (curItem != NULL) { if (curItem->isSelected()) { DB.dbcmd("update GL set LinkedTrans = %ld, Cleared = 1 where InternalID = %ld", GL->TransID, atol(curItem->key(intIDCol, 0))); } curItem = curItem->itemBelow(); } // All done, close the window. close(); }