private function recalculate_tree($nodo) { $suma_hijos = 0; $hijos_del_padre = $this->get_hijos($nodo->getPreviousId()); if ($hijos_del_padre != null) { foreach ($hijos_del_padre as $row) { $valor_actual = $row->getData(); $valor_porcentual = $row->getConectoresConfigure(); $valor_minimo = $row->getValorMinimo(); $valor_maximo = $row->getValorOptimo(); $division = $valor_actual / $valor_maximo; if ($this->soy_padre($row)) { $valor_minimo = 0; } if ($valor_actual <= $valor_minimo) { $division = 0; } else { if ($division >= 1) { $suma_hijos = $suma_hijos + $valor_porcentual / 100; } else { $suma_hijos = $suma_hijos + $valor_actual * ($valor_porcentual / 100) / $valor_maximo; } } } $padre = TmpDataReportsPeer::retrieveByPK($nodo->getPreviousId()); $valor_final = $suma_hijos * 100; $padre->setData($valor_final); $padre->save(); //print_r('-'.$valor_final.'-'); $this->validar_si_tiene_padre($padre); } }
private function recalculate_tree($nodo, $fecha = null) { $suma_hijos = 0; $hijos_del_padre = $this->get_hijos($nodo->getPreviousId()); if ($hijos_del_padre != null) { foreach ($hijos_del_padre as $row) { $proyeccionBean = $this->obtenerValoresDeProyecciones($row, $fecha); $valor_actual = $row->getData(); $valor_porcentual = $row->getConectoresConfigure(); $valor_minimo = $proyeccionBean['object']->getValorMinimo(); $valor_maximo = $proyeccionBean['object']->getValorOptimo(); $division = $valor_actual / $valor_maximo; if ($this->soy_padre($row)) { $valor_minimo = 0; } if ($valor_actual <= $valor_minimo) { $division = 0; } else { if ($division >= 1) { $suma_hijos = $suma_hijos + $valor_porcentual / 100; } else { $suma_hijos = $suma_hijos + $valor_actual * ($valor_porcentual / 100) / $valor_maximo; } } } $padre = TmpDataReportsPeer::retrieveByPK($nodo->getPreviousId()); if (is_object($padre)) { $valor_final = $suma_hijos * 100; $padre->setData($valor_final); $padre->save(); $this->validar_si_tiene_padre($padre, $fecha); } } }