Files
SGF/scripts/sgf-document-read-rights.php
2026-11-11 09:00:17 +02:00

6 lines
1.1 KiB
PHP

<?php
$book=$argv[1]??'8085';require __DIR__.'/sgf-single-bootstrap.php';$profiles=json_decode(file_get_contents($s['root'].'/single-profiles.json'),true)['profiles'];$missing=[];$checks=[];
$rights=['issuer_documents.view'=>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;