예제 #1
0
void product_stats::refresh()
{

    int type = Choice1->GetSelection(); //0 - by revenue, 1 - by quantity


    mysqlpp::Query query = conn->query();
    wxDateTime start_date = DatePickerCtrl1->GetValue();
    wxDateTime end_date = DatePickerCtrl2->GetValue();
    wxDateTime mysql_end_date = end_date;
    mysql_end_date.Add(wxTimeSpan::Day());

    switch(type)
    {
    case 0:
        query << "SELECT `name` , SUM( `qty` ) AS `qty`, SUM(`qty`*`price`) AS `money_net`,SUM(`qty`*`price`*`tax`) AS `money_tax`\
FROM `orders_dishes` WHERE `order_id` = ANY (SELECT `id` FROM `orders` \
WHERE `time` > '"<< wx2std(start_date.FormatISODate(),wxConvUI) <<"' AND `time` < '"<< wx2std(mysql_end_date.FormatISODate(),wxConvUI) <<"')\
 GROUP BY `name` ORDER BY `money_net` DESC LIMIT " << wx2std(Choice2->GetStringSelection(),wxConvUI);
        break;
    case 1:
        query << "SELECT `name` , SUM( `qty` ) AS `qty`, SUM(`qty`*`price`) AS `money_net`,SUM(`qty`*`price`*`tax`) AS `money_tax`\
FROM `orders_dishes` WHERE `order_id` = ANY (SELECT `id` FROM `orders` \
WHERE `time` > '"<< wx2std(start_date.FormatISODate(),wxConvUI) <<"' AND `time` < '"<< wx2std(mysql_end_date.FormatISODate(),wxConvUI) <<"')\
 GROUP BY `name` ORDER BY `qty` DESC LIMIT " << wx2std(Choice2->GetStringSelection(),wxConvUI);
        break;
    }
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        wxString info;
        info << _("Name of the product       |   Qty   |   Net   |   Taxes   |   Gross\n\n");

        wxString infoVerse;
        mysqlpp::Row row;
        mysqlpp::StoreQueryResult::size_type i;
        for (i = 0; i < res.num_rows(); ++i)
        {
            row = res[i];
            infoVerse.Clear();
            std::string name = std::string(row["name"]);
            int qty = int(row["qty"]);
            double money_net = round_2(double(row["money_net"]));
            double money_tax = round_2(double(row["money_tax"]));


            infoVerse << addSpaces(std2wx(name,wxConvUI),31);
            wxString temp;
            temp << qty;
            infoVerse << addSpaces(temp,8);
            infoVerse << addSpaces(addZero(money_net),11);
            infoVerse << addSpaces(addZero(money_tax),12);
            infoVerse << addZero(money_net + money_tax) << _T("\n");
            info << infoVerse;

        }
        TextCtrl1->ChangeValue(info);
    }

}
예제 #2
0
//==================================================================
void Filter::addZero (float frequency, float resonance)
{
    if (frequency <= 0.0f)
    {
        addZero(polToCar(newComplex(resonance, 0.0f)));
    }
    else
    {
        float theta = frequency / sampleRate * 2*M_PI;

        addZero(polToCar(newComplex(resonance,  theta)));
        addZero(polToCar(newComplex(resonance, -theta)));
    }
}
예제 #3
0
// LOWPASS
pzkContainer * t2lp(pzkContainer * pzk, real w0) {
	pzkContainer * f = createPzkContainer(pzk->nextPole, pzk->nextZero);
	uint i;
	complex tmp;
	
	f->no_wz = pzk->no_wz;
	f->amp *= pzk->amp * pow(w0,(real)(-f->no_wz));

	for( i = 0; i < pzk->nextPole; i++ ) {
		tmp = cmul2(w0, pzk->poles[i]);
		addPole(f, tmp);
		f->amp *= w0;
		if( !cisreal(tmp) ) {
			f->amp *= w0;
		}
	}
	
	for( i = 0; i < pzk->nextZero; i++ ) {
		tmp = cmul2(w0, pzk->zeros[i]);
		addZero(f, tmp);
		if( cisreal(tmp) ) {
			f->amp /= w0;
		} else {
			f->amp /= w0*w0;
		}
	}
	
	f->type = lowpass;
	return f;
	
}
예제 #4
0
// HIGHPASS
pzkContainer * t2hp(pzkContainer * pzk, real w0) {
	pzkContainer * f = createPzkContainer(pzk->nextPole, pzk->nextZero);
	uint i;
	complex tmp;
	
	f->amp = pzk->amp * pow(w0,(real)pzk->no_wz);
	f->no_wz = -pzk->no_wz;

	for( i = 0; i < pzk->nextPole; i++ ) {
		tmp.re = w0;
		tmp.im = 0;
		f->no_wz++;
		if( cisreal(pzk->poles[i]) ) {
			f->amp /= -pzk->poles[i].re;
			tmp.re /= pzk->poles[i].re;
		} else {
			tmp = cdiv(tmp, pzk->poles[i]);
			f->amp /= cabs2(pzk->poles[i]);
			f->no_wz++;
		}
		addPole(f, tmp);
	}
	
	for( i = 0; i < pzk->nextZero; i++ ) {
		tmp.re = w0;
		tmp.im = 0;
		f->no_wz--;	
		if( cisreal(pzk->zeros[i]) ) {
			f->amp *= -pzk->zeros[i].re;
			tmp.re /= pzk->zeros[i].re;
		} else {
			tmp = cdiv(tmp, pzk->zeros[i]);
			f->amp *= cabs2(pzk->zeros[i]);
			f->no_wz--;
		}
		addZero(f, tmp);
	}
	
	f->type = highpass;
	return f;
	
}
예제 #5
0
string DateTimeFormat::format(Integer time, string formatToken) {
    time_t epoch_time_as_time_t = time;
    tm *timeStruct = localtime((const time_t *) epoch_time_as_time_t);

    replaceString(formatToken, "yyyy", to_string(timeStruct->tm_year + 1));
    replaceString(formatToken, "MM", addZero(to_string(timeStruct->tm_mon + 1)));
    replaceString(formatToken, "dd", addZero(to_string(timeStruct->tm_mday)));

    replaceString(formatToken, "hh", addZero(to_string(timeStruct->tm_hour + 1 > 12 ?
                                                       timeStruct->tm_hour + 1 - 12 : timeStruct->tm_hour + 1)));
    replaceString(formatToken, "hh", addZero(to_string(timeStruct->tm_hour + 1)));
    replaceString(formatToken, "mm", addZero(to_string(timeStruct->tm_min + 1)));
    replaceString(formatToken, "ss", addZero(to_string(timeStruct->tm_sec + 1)));
    replaceString(formatToken, "aa", timeStruct->tm_hour + 1 >= 12 ? "pm" : "am");
    return formatToken;
}
예제 #6
0
// BANDSTOP
pzkContainer * t2bs(pzkContainer * pzk, real w0, real dw) {
	uint nop, noz, i;
	pzkContainer * f;
	const real w02 = w0*w0;
	complex tmp, beta, gamma, cw0, cdwp2;

	cw0.re = w0;
	cw0.im = 0;

	cdwp2.re = dw / 2;
	cdwp2.im = 0;
	
	noz = 2*pzk->nextZero;
	nop = 2*pzk->nextPole;
	
	if( pzk->no_wz > 0 ) {
		noz += pzk->no_wz;
	}
	if( pzk->no_wz < 0 ) {
		nop -= pzk->no_wz;
	}
	
	f = createPzkContainer(nop, noz);
	
	f->wz = w0;
	f->no_wz = -pzk->no_wz;
	f->amp = pzk->amp * pow(dw, (real)(pzk->no_wz));
		
	gamma.re = 0;
	gamma.im = 0;
	if( pzk->no_wz > 0 ) {
		for( i = 0; i < pzk->no_wz; i++ ) {
			addZero(f, gamma);
		}
	}
	if( pzk->no_wz < 0 ) {
		for( i = 0; i < -pzk->no_wz; i++ ) {
			addPole(f, gamma);
		}
	}

	for( i = 0; i < pzk->nextPole; i++ ) {
		if( cisreal(pzk->poles[i]) ) {
			beta.re = cdwp2.re / pzk->poles[i].re;
			tmp.re = 1 - ( w02/(beta.re*beta.re) );

			if( tmp.re >= 0 ) {
				tmp.re = sqrt( tmp.re );
				gamma.im = 0;
				gamma.re = beta.re * (1 + tmp.re);
				addPole(f, gamma);
				gamma.re = beta.re * (1 - tmp.re);
				addPole(f, gamma);
			} else {
				tmp.im = sqrt( -tmp.re );
				tmp.re = 1;
				gamma = cmul2( beta.re, tmp );
				addPole(f, gamma);
			}

			f->amp /= -pzk->poles[i].re;
			f->no_wz++;
		}
		else {
			beta = cdiv(cdwp2, pzk->poles[i]);	
			tmp = cdiv(cw0, beta);
			tmp = csqrt( csub2(1, cmlt(tmp, tmp)) );

			gamma = cmlt(beta, cadd2(1, tmp));
			addPole(f, gamma);
			gamma = cmlt(beta, csub2(1, tmp));
			addPole(f, gamma);

			f->amp /= cabs2(pzk->poles[i]);
			f->no_wz += 2;
		}
	}
	
	for( i = 0; i < pzk->nextZero; i++ ) {
		if( cisreal(pzk->zeros[i]) ) {
			beta.re = cdwp2.re / pzk->zeros[i].re;
			tmp.re = 1 - ( w02/(beta.re*beta.re) );

			if( tmp.re >= 0 ) {
				tmp.re = sqrt( tmp.re );
				gamma.im = 0;
				gamma.re = beta.re * (1 + tmp.re);
				addZero(f, gamma);
				gamma.re = beta.re * (1 - tmp.re);
				addZero(f, gamma);
			} else {
				tmp.im = sqrt( -tmp.re );
				tmp.re = 1;
				gamma = cmul2( beta.re, tmp );
				addZero(f, gamma);
			}

			f->amp *= -pzk->zeros[i].re;
			f->no_wz--;
		}
		else {
			beta = cdiv(cdwp2, pzk->zeros[i]);	
			tmp = cdiv(cw0, beta);
			tmp = csqrt( csub2(1, cmlt(tmp, tmp)) );

			gamma = cmlt(beta, cadd2(1, tmp));
			addZero(f, gamma);
			gamma = cmlt(beta, csub2(1, tmp));
			addZero(f, gamma);

			f->amp *= cabs2(pzk->zeros[i]);
			f->no_wz -= 2;
		}
	}
	
	return f;	
}