getByCompanyId( $company_id ); } else { $clf->getAll(); } if ( $clf->getRecordCount() > 0 ) { foreach ( $clf as $c_obj ) { echo 'Company: ' . $c_obj->getName() . "...\n"; $cbf = new ClientBalanceFactory(); $cbf->StartTransaction(); $tmp_clf = new ClientListFactory(); if ( isset( $client_id ) && $client_id > 0 ) { $tmp_clf->getByIdAndCompanyId( $client_id, $c_obj->getId() ); } else { $tmp_clf->getByCompanyId( $c_obj->getId() ); } $max = $tmp_clf->getRecordCount(); $i = 0; foreach ( $tmp_clf as $tmp_c_obj ) { //if ( !in_array( $tmp_c_obj->getId(), array(195,1249,1800) ) ) { // continue; //} echo ' ' . $i . '/' . $max . ' Recalculating: ' . $tmp_c_obj->getCompanyName() . "...\n"; $cbf->reCalculateBalance( $tmp_c_obj->getId(), $tmp_c_obj->getCompany() ); $i++; } //$cbf->FailTransaction(); $cbf->CommitTransaction(); } } } //Debug::Display(); ?>