how to do a days counter by status in the mantis?

1

I'm trying to make a day counter, which counts each state in which the bug is for example: 20 days in the first state and when we change to the second state, it is 0 because has been changed to this state

I've done a few lines of code, but it's not working, it's just counting from the last time the bug was changed to today's date I'm thinking of picking up the modification dates and subtract with the dates that that bug was changed from the first state to the next and with the date the bug was changed from another state to the first state and added up.

 switch ($status_day){
        case 10:
        $day_open;
        $querya = "select * from mantis_bug_history_table where bug_id=". db_param();
        $oloco = db_query_bound ($querya, array ($id_bug));
        $rowa = db_fetch_array ($oloco);
        if($day_open='') {

              $queryyy = "select date_modified from mantis_bug_history_table where field_name='' and bug_id=". db_param() ." order by date_modified limit 1";
              db_query_bound ($queryyy, array ($id_bug));
              break;
        }
        $queryy = "select date_modified from mantis_bug_history_table where bug_id=" . db_param() . " and new_value=10 order by date_modified DESC";
        $calculo = db_query_bound ($queryy, array ($id_bug));
        $rowww = db_fetch_array ($calculo);
        $datacriadas = date ("Y-m-d ", $rowww['date_modified']);
        $comecos = new DateTime ($datacriadas);
        $date = date("Y-m-d");
        $fimm = new DateTime ($date);
        $interval = $comecos->diff($fimm);
        $day_open = $interval->format("%a");
        $queria = mysql_query("select COUNT(*) from mantis_bug_history_table where bug_id=$id_bug and new_value=10");
        $tempoinicio = mysql_fetch_array ($queria);
        $rowinicio = $tempoinicio['COUNT(*)'];
        $querio = mysql_query("select COUNT(*) from mantis_bug_history_table where bug_id=$id_bug and old_value=10");
        $tempofinal = mysql_fetch_array ($querio);
        $rowfinal = $tempofinal['COUNT(*)'];
        for( $i = 0;$i<=$rowinicio or $i<=$rowfinal;$i++) {
            echo $rowinicio;
            $datacriadas = date ("Y-m-d ", $tempoinicio['date_modified']);
            $comecos = new DateTime ($datacriadas);
            $date = date ("Y-m-d ", $tempofinal['date_modified']);
            $fimm = new DateTime ($date);
            $interval = $fimm->diff($comecos);
            $day_ope = $interval->format("%a");
            $day_open = $day_ope + $day_open;
         }
         $sqle = "UPDATE $string_table  t1 INNER JOIN mantis_custom_field_table t2 ON (t1.field_id = t2.id) SET value=$day_open WHERE t2.name='DiasStatus' AND t1.bug_id=$id_bug";
         break;
        }
    
asked by anonymous 23.06.2016 / 15:35

0 answers