where_active(); foreach ($o->find_all() as $ao) { if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0) $ao->status = 0; $ao->save(); if ($ao->saved()) $c++; } printf("%s services made inactive\n",$c); } } ?>