null,'client_documents.view'=>null,'draft_documents.view'=>2,'service_fiscal.view'=>null,'billing_drafts.view'=>2,'service_drafts.view'=>2,'clients.view'=>null,'services.view'=>null]; foreach(['finance_prepare','finance_review'] as $profile)foreach($rights as $right=>$unit){$exists=$host->table('permission_grants')->where(['tenant_id'=>1,'company_id'=>2,'unit_id'=>$unit,'user_id'=>$profiles[$profile]['user_id'],'permission'=>$right])->exists();$row=['profile'=>$profile,'user_id'=>$profiles[$profile]['user_id'],'permission'=>$right,'unit_id'=>$unit,'present'=>$exists];$checks[]=$row;if(!$exists)$missing[]=$row;} $out=['passed'=>true,'book'=>$book,'read_only'=>true,'grants_applied'=>0,'missing'=>$missing,'checks'=>$checks];file_put_contents($work.'/document-read-rights.json',json_encode($out,JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'book'=>$book,'missing'=>$missing,'proof'=>$work.'/document-read-rights.json']).PHP_EOL;