Ejemplo n.º 1
0
int main(int, char **)
{

    // Load our configuration file
    if (!loadCfg("/usr/local/etc/taa.cf")) {
        syslog(LOG_NOTICE, "Unable to load configuration file.  Aborting.\n");
        exit(-1);
    }
    ADB::setDefaultHost(cfgVal("TAAMySQLHost"));
    ADB::setDefaultDBase(cfgVal("TAAMySQLDB"));
    ADB::setDefaultUser(cfgVal("TAAMySQLUser"));
    ADB::setDefaultPass(cfgVal("TAAMySQLPass"));

    openlog("qwestconnect", LOG_PID, LOG_DAEMON);

    ConnectNotice   cn;
    int             retVal;
    retVal = extractConnectInfo(stdin, cn);

    if (retVal > 0) {
        //printf("Got connection info successfully.\n");
        //printf("Action = '%s', DSL Number = '%s'\n", cn.connType, cn.custCirc);
        retVal = storeConnectNotice(cn);
        if (retVal > 0) {
            syslog(LOG_NOTICE, "Successfully stored Qwest Connect info for DSL Number '%s'\n", cn.custCirc);
        } else {
            syslog(LOG_NOTICE, "No matching customers found for DSL Number '%s'\n", cn.custCirc);
            createSalesTicket(cn);
        }
    } else {
        // printf("Unable to get connection info (retcode = %d).\n", retVal);
    }

    // Regardless of anything else we have done, we now check for
    // to see if any orphaned records (those without a customer ID)
    // have now been added into the system.  So, each time we get a 
    // connect notice, it will "fix" the database.  Since we get connect
    // notices often, this will keep things pretty well up-to-date.
    scanOrphans();
}
Ejemplo n.º 2
0
static void 
generateCommands()
{
	ConfigItemList lst = uclOptions;

	if (dbgLevel > 1) 
		printf("SysName: %s\n", uclSysName);

	if (dbgLevel > 3) {
		printf("[Config]\n");
		while (lst != listNil(ConfigItem)) {
			printf("\t`%s' = `%s'\n", 
			       cfgName(car(lst)), cfgVal(car(lst)));
			lst = cdr(lst);
		}
		printf("[C'est Tout]\n");

		printf("Compile Only: %s\n", uclState(uclIsCompileOnly));
		printf("Link Only:    %s\n", uclState(uclIsLink));
		printf("Optimize:     %s\n", uclState(uclOptimize));
		printf("Debug:        %s\n", uclState(uclDebug));
		printf("Profile:      %s\n", uclState(uclIsCompileOnly));
		printf("OutputDir:    %s\n", uclOutputDir ? uclOutputDir : "(null)");
		printf("OutputFile:   %s\n", uclOutputFile ? uclOutputFile : "(null)");
	}

	ccInitCommand();
	ccSetCommandName(uclGetCommandName());
	ccPushArguments(uclStartOptions);

	if (uclIsCompileOnly) {
		/* -D, -I, -U, -g, -O, -p, -o, -Wfnonstd */
		ccPushArguments(uclGetGeneralCompileOptions());
		ccPushArguments(uclCompileOnlyArguments());
		ccPushArgument(car(uclFileList));
		ccPushArguments(uclPostOptions);
	}
	else {
		ccPushArguments(uclGetPreLinkOptions());
		ccPushArguments(uclFileList);
		ccPushArguments(uclTwixtOptions);
		ccPushArguments(uclGetPostLinkOptions());
		ccPushArguments(uclPostOptions);
	}
	uclCommand = ccCompleteCommand();
}
Ejemplo n.º 3
0
void    parseEmail(const char *tmplName, long CustomerID, const char *LoginID, const char *DomainName, int holdForSync, const char *emailFrom, const char *emailTo, const char *emailSubject, SElement *extraVars)
{
    FParser  parser;
	char 	 tmpstr[1024];
    char     srcTextFile[1024];
    FILE     *srcTextFP;
    char     srcHTMLFile[1024];
    FILE     *srcHTMLFP;
    int      tmpFP;
    bool     doHTML = false;
	Q3StrList tmplist(TRUE);
	QString	 qst;
	QString	 tmpqstr2;
	char     contactName[256];
	char     phoneNumber[32];

    // Default fields
    char     msgFrom[1024];
    char     msgTo[1024];
    char     msgSubj[1024];
	
	char     theDate[64];
	QDate    theQDate;
    QTime    theQTime = QTime::currentTime();
    char     curDateTime[1024];
	
	theQDate    = QDate::currentDate();
	strcpy(theDate, theQDate.toString());
	
    sprintf(curDateTime, "%04d%02d%02d%02d%02d%02d",
            theQDate.year(), theQDate.month(), theQDate.day(),
            theQTime.hour(), theQTime.minute(), theQTime.second());
	
	ADB             DB;
	CustomersDB     CDB;
	LoginsDB        LDB;
	AddressesDB     addrDB;
	ADBTable        LTDB;
    ADBTable        emailDB("EmailQueue");

    // Extract the template from the DB and store it in /tmp somewhere
    DB.query("select * from EmailTemplates where Name = '%s'", tmplName);
    if (!DB.rowCount) return;
    DB.getrow();
    strcpy(srcTextFile, "/tmp/taatextXXXXXX");
    strcpy(srcHTMLFile, "/tmp/taahtmlXXXXXX");
    tmpFP = mkstemp(srcTextFile);
    close(tmpFP);
    srcTextFP = fopen(srcTextFile, "w");
    fprintf(srcTextFP, "%s", DB.curRow["TextPart"]);
    fclose(srcTextFP);
    tmpFP = mkstemp(srcHTMLFile);
    close(tmpFP);
    srcHTMLFP = fopen(srcHTMLFile, "w");
    fprintf(srcHTMLFP, "%s", DB.curRow["HTMLPart"]);
    fclose(srcHTMLFP);

    if (strlen(DB.curRow["HTMLPart"])) doHTML = true;

    // Get our defaults from the passed in options.
    strcpy(msgFrom, emailFrom);
    if (strlen(emailTo)) strcpy(msgTo, emailTo);
    else sprintf(msgTo, "%s@%s", LoginID, cfgVal("EmailDomain"));

    if (strlen(emailSubject)) strcpy(msgSubj, emailSubject);
    else strcpy(msgSubj, DB.curRow["DefaultSubject"]);

	
	CDB.get(CustomerID);
	LDB.get(CustomerID, LoginID);
	LTDB.setTableName("LoginTypes");
	LTDB.get(LDB.getLong("LoginType"));
	strcpy(tmpstr, CDB.getStr("BillingAddress"));
	addrDB.get(REF_CUSTOMER, CustomerID, tmpstr);
	
	// Since there is no default phone number, grab the first one from
	// the database.
	strcpy(phoneNumber, "");
	DB.query("select PhoneNumber from CustomerContacts where Active <> 0 and CustomerID = %ld", CustomerID);
	if (DB.rowCount) {
	    DB.getrow();
	    strcpy(phoneNumber, DB.curRow["PhoneNumber"]);
	}
	
	// fprintf(stderr, "parseFile: Reading File '%s'\n", SrcFile);
	
	
	// Check to see if we have a contact name.
	if (strlen((const char *)CDB.getStr("ContactName"))) {
	    strcpy(contactName, CDB.getStr("ContactName"));
	} else {
	    strcpy(contactName, CDB.getStr("FullName"));
	}
	
    parser.set("DomainName",     DomainName);
    parser.set("CompanyName",    CDB.getStr("FullName"));
    parser.set("ContactName",    contactName);
    parser.set("LoginID",        LoginID);
    parser.set("NICName",        contactName);
    parser.set("Addr1",          addrDB.Address1);
    parser.set("Addr2",          addrDB.Address2);
    parser.set("City",           addrDB.City);
    parser.set("State",          addrDB.State);
    parser.set("ZIP",            addrDB.ZIP);
    parser.set("DayPhone",       phoneNumber);
    parser.set("EvePhone",       phoneNumber);
    parser.set("CurrentDate",    theDate);
    parser.set("LoginType",      LTDB.getStr("LoginType"));
    parser.set("LoginTypeD",     LTDB.getStr("Description"));

    //fprintf(stderr, "Checking for extra variables to parse....\n");
    if (extraVars != NULL) {
        int j = 0;
        while(strlen(extraVars[j].Name)) {
            //fprintf(stderr, "Adding '%s' as '%s'....\n", extraVars[j].Name, extraVars[j].Value);
            parser.set(extraVars[j].Name, extraVars[j].Value);
            j++;
        }
    }

    // Parse the files and put them into the database now.
    emailDB.setValue("ProcessID",       tmplName);
    emailDB.setValue("EmailTime",       curDateTime);
    emailDB.setValue("HoldForSync",     holdForSync);
    emailDB.setValue("EmailFrom",       msgFrom);
    emailDB.setValue("EmailTo",         msgTo);
    emailDB.setValue("EmailSubject",    msgSubj);
    emailDB.setValue("TextBody",        parser.parseFileToMem(srcTextFile));
    if (doHTML) {
        emailDB.setValue("HTMLBody",    parser.parseFileToMem(srcHTMLFile));
    }
    emailDB.ins();


    // Remove our temp files
    unlink(srcTextFile);
    unlink(srcHTMLFile);
}
Ejemplo n.º 4
0
void PrintTreeWidget::printHeader(QPainter *p)
{
    QDate       theDate;
    QTime       theTime;
    QRect       rect;
    QBrush      bbrush;
    QString     tmpSt;
    char        tmpstr[1024];
    int         xPos = prLeftMargin;
    
    float       headerPcts[20];
    float       colWidths[20];
    float       totWidth = 0;
    
    int         numCols;
    
    theDate = QDate::currentDate();
    theTime = QTime::currentTime();

    // p->rotate(55);
    // Draw our Company Name header and the date at the top of the page
    p->setFont(QFont("helvetica", 10, QFont::Bold));
    rect.setCoords(prLeftMargin, 30,  399, 60);
    p->drawText(rect, Qt::AlignLeft, cfgVal("CompanyName"));
    sprintf(tmpstr, "%s %s", (const char *) theDate.toString(), (const char *) theTime.toString());
    rect.setCoords(400, 30, prLeftMargin+540, 60);
    p->drawText(rect, Qt::AlignRight, tmpstr);
    
    // Now, draw the report title, centered on the page.
    // If we have a date range for the report, shrink down the title by 12
    // pixels so we can display the dates on the page.  If not, give the
    // title the full height.
    if (showDateLine) {
	    p->setFont(QFont("helvetica", 18, QFont::Bold));
	    rect.setCoords(0, 40, 611, 95);
	    p->drawText(rect, Qt::AlignCenter|Qt::AlignVCenter, myTitle);
	    p->setFont(QFont("helvetica",  8, QFont::Normal));
	    rect.setCoords(0, 96, 611, 112);
	    p->drawText(rect, Qt::AlignCenter|Qt::AlignVCenter, myDateLine);
    } else {
	    p->setFont(QFont("helvetica", 18, QFont::Bold));
	    rect.setCoords(0, 40, 611, 112);
	    p->drawText(rect, Qt::AlignCenter|Qt::AlignVCenter, myTitle);
    }

    // Now, calculate the column widths.
    // We'll take the strlens and convert them into pixel values
    // based on the percentage of the total.  That way, our report will
    // always be the full width of the page.
    numCols = myTree->columnCount();
    
    if (!numCols) return;
    
    if (numCols > 20) numCols = 20;
    
    // Get the width of each header item.
    QTreeWidgetItem *hdr = myTree->headerItem();
    for (int i = 0; i < numCols; i++) {
        colWidths[i] = hdr->text(i).length();
    }

    // Now, get the longest item for each of the keys.
    QTreeWidgetItem *curItem;
    for (int j = 0; j < myTree->topLevelItemCount(); j++) {
        curItem = myTree->topLevelItem(j);
        for (int i = 0; i < numCols; i++) {
            if (curItem->text(i).length() > colWidths[i]) {
                colWidths[i] = curItem->text(i).length();
            }
        }
    }
    
    // Now, add up the widths.
    
    for (int i = 0; i < numCols; i++) {
        totWidth += colWidths[i];
        
    }
    
    // Now, get our percentages.
    for (int i = 0; i < numCols; i++) {
        headerPcts[i] = colWidths[i] / totWidth * 540;
        sprintf(tmpstr, "%f", rint(headerPcts[i]));
        prColWidths[i] = atoi(tmpstr);       // 1" margin
        // fprintf(stderr, "Column %d width = %f (%f) = %d pixels.\n", i, colWidths[i], headerPcts[i], prColWidths[i]);
    }
    
    // Now, draw the titles.
    //xPos = 36;
    xPos = prLeftMargin;
    p->setFont(QFont("helvetica", 8, QFont::Normal));
    for (int i = 0; i < numCols; i++) {
        rect.setCoords(xPos+1, 113, xPos + prColWidths[i] - 1, 129);
        bbrush.setStyle(Qt::SolidPattern);
        bbrush.setColor(Qt::black);
        //p->setBackgroundMode(OpaqueMode);
        p->setPen(Qt::white);
        p->fillRect(rect, bbrush);
        p->drawText(rect, Qt::AlignCenter|Qt::AlignVCenter, myTree->headerItem()->text(i));
        xPos += prColWidths[i];
    }
    // Reset our pen
    p->setBackgroundMode(Qt::TransparentMode);
    p->setPen(Qt::black);
}
Ejemplo n.º 5
0
long AcctsRecv::SaveTrans(void)
{
	ADB		    DB;
	BillablesDB	BDB;
	// CustomersDB CDB;
	int			ARAcct = 0;
	
	int         SrcAcct, DstAcct = 0;
	
	// We need to get the AR account number
	ARAcct = atoi(cfgVal("AcctsRecvAccount"));
	
	// Now, load the Billable Item so we can have its account number.
	BDB.get(ARDB->getLong("ItemID"));
	
	// CDB.get(ARDB->CustomerID.toInt());
	// CDB.CurrentBalance.setNum(CDB.CurrentBalance.toFloat() + ARDB->Amount.toFloat());
	// CDB.upd();

	if (InternalID) {
	} else {
		// Its a new transaction.
		InternalID = ARDB->ins();
		GL->BaseDesc = ARDB->getStr("Memo");
		
		switch(ARDB->getInt("TransType")) {
		    case TRANSTYPE_PAYMENT:
		        DstAcct = atoi(cfgVal("UndepositedFundsAcct"));
		        SrcAcct = ARAcct;
		        break;
		        
		    case TRANSTYPE_CCPAYMENT:
		        DstAcct = atoi(cfgVal("UndepositedCCAcct"));
		        SrcAcct = ARAcct;
		        break;
		        
		    default:
		        SrcAcct = ARAcct;
                if (myIntAcctNo) DstAcct = myIntAcctNo;
                else DstAcct = BDB.getInt("IntAccountNo");
		        break;
		}
		
		// First, put in the AR account split
		GL->AddSplit();
		GL->CurrentSplit->IntAccountNo.setNum(SrcAcct);
		GL->CurrentSplit->Amount.setNum(ARDB->getFloat("Amount"));
		GL->CurrentSplit->TransType.setNum(ARDB->getInt("TransType"));
		GL->CurrentSplit->TransTypeLink.setNum(InternalID);
		GL->CurrentSplit->TransDate = ARDB->getStr("TransDate");
		GL->CurrentSplit->BilledDate = ARDB->getStr("BilledDate");
		GL->CurrentSplit->DueDate = ARDB->getStr("DueDate");
		GL->CurrentSplit->Cleared.setNum(ARDB->getInt("Cleared"));
		GL->CurrentSplit->Number.setNum(atol(ARDB->getStr("RefNo")));
		GL->CurrentSplit->NumberStr = ARDB->getStr("RefNo");
		GL->CurrentSplit->ItemID.setNum(ARDB->getLong("ItemID"));
		GL->CurrentSplit->Quantity.setNum(ARDB->getFloat("Quantity"));
		GL->CurrentSplit->Price.setNum(ARDB->getFloat("Price"));
		GL->CurrentSplit->Memo = ARDB->getStr("Memo");
		
		// Now, put in the sales split.
		GL->AddSplit();
		GL->CurrentSplit->IntAccountNo.setNum(DstAcct);
		GL->CurrentSplit->Amount.setNum(ARDB->getFloat("Amount") * -1.0);
		GL->CurrentSplit->TransType.setNum(ARDB->getInt("TransType"));
		GL->CurrentSplit->TransTypeLink.setNum(InternalID);
		GL->CurrentSplit->TransDate = ARDB->getStr("TransDate");
		GL->CurrentSplit->BilledDate = ARDB->getStr("BilledDate");
		GL->CurrentSplit->DueDate = ARDB->getStr("DueDate");
		GL->CurrentSplit->Cleared.setNum(ARDB->getInt("Cleared"));
		GL->CurrentSplit->Number.setNum(atol(ARDB->getStr("RefNo")));
		GL->CurrentSplit->NumberStr = ARDB->getStr("RefNo");;
		GL->CurrentSplit->ItemID.setNum(ARDB->getLong("ItemID"));
		GL->CurrentSplit->Quantity.setNum(ARDB->getFloat("Quantity"));
		GL->CurrentSplit->Price.setNum(ARDB->getFloat("Price"));
		GL->CurrentSplit->Memo = ARDB->getStr("Memo");
		
		GL->SaveTrans();
		#ifdef DBDEBUG
		//fprintf(stderr, "GL Trans ID = %ld\n", GL->TransID);
		#endif
		ARDB->setValue("GLTransID", GL->TransID);
		ARDB->upd();
	}
	
	applyCredits(ARDB->getLong("CustomerID"));
	
	return(InternalID);
}