function computeMeanValue(&$where, &$ljoin, &$serie, $dates, $prop) { $d =& $serie['data']; $bs = new CBloodSalvage(); $pos = end(array_keys($where)); $i = 0; foreach ($dates as $date) { $where['operations.date'] = "BETWEEN '{$date['start']}' AND '{$date['end']}'"; $list = $bs->loadList($where, null, null, null, $ljoin); $total = 0; foreach ($list as $_bs) { $total += $_bs->{$prop}; } $count = count($list); $mean = $count ? $total / $count : 0; $d[$i] = array($i, $mean); $i++; } unset($where[$pos]); }