Exemplo n.º 1
0
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);
                }
            }
        }
    }
}
Exemplo n.º 2
0
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;
}