Calc Builder Support

Calc Builder support
Public write access is disabled. Please login

2 Calculators one set of code 05.02.2016 21:17

I have 2 calculators within one set of code. Both use date pickers

here is the code:

/* Start Jail Calculator */
$date1 = new DateTime($sdate);
$date2 = new DateTime($edate);
$count = date_diff($date1,$date2);
$total = $count->days;
$inlinedate1 = $total;
$date1 = new DateTime($sdate2);
$date2 = new DateTime($edate2);
$count2 = date_diff($date1,$date2);
$total = $count2->days;
$inlinedate2 = $total;
$date1 = new DateTime($sdate3);
$date2 = new DateTime($edate3);
$count3 = date_diff($date1,$date2);
$total = $count3->days;
$inlinedate3 = $total;
$date1 = new DateTime($sdate4);
$date2 = new DateTime($edate4);
$count4 = date_diff($date1,$date2);
$total = $count4->days;
$inlinedate4 = $total;
$date1 = new DateTime($sdate5);
$date2 = new DateTime($edate5);
$count5 = date_diff($date1,$date2);
$total = $count5->days;
$inlinedate5 = $total;
$grandtotalinline = $inlinedate1 + $inlinedate2 + $inlinedate3 + $inlinedate4 + $inlinedate5;
/* End Jail Calculator */

/* Start Speedy Calculator */
$ctype = "$caseType";
switch ($ctype) {
case "Misdemeanor":
$mdate = New DateTime($arrestDate);
$mdate->add(new DateInterval('P90D'));
$speedyDate= $mdate->format('m-d-Y');
case "Felony":
$fdate = New DateTime($arrestDate);
$fdate->add(new DateInterval('P175D'));
$speedyDate= $fdate->format('m-d-Y');
/* End Speedy Calculator */

Now when I choose a date in one calculator the formulas work on both either giving me zeros or just a certain # of days. How can i stop this behavior. for an example please see

Edited by phil_adler - 05.02.2016 21:18

Re: 2 Calculators one set of code 08.02.2016 09:51

yes, inside one calculator, all code is executed from top to bottom when you launch the calculation (either with the calculate button, or because of the inline fields). If you want to separate the two calculators, you should create another calculator, so each one will have its fields and code, and then create a new module typed 'Calcbuilder', select the second calculator and publish at the same position than the original.

Hope this helps, regards
Moonsoft Team
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Our clients' feedback