Moonsoft Software Solutions

2 Calculators one set of code

Started 5 Feb 2016 · 1 reply

  1. phil_adler
    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');
    break;
    case "Felony":
    $fdate = New DateTime($arrestDate);
    $fdate->add(new DateInterval('P175D'));
    $speedyDate= $fdate->format('m-d-Y');
    break;
    }
    /* 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 http://www.philadler.com/newylo/jail-credit-calculator.

    Edited by phil_adler - 05.02.2016 21:18
  2. Moonsoft support
    Hi,
    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

Still stuck?

Customers with an active license can open a support ticket.

Log in to open a ticket