query($query);
$accounts=[];
while($dane=$GLOBALS['db']->fetchByAssoc($res)){
$accounts[$dane['parent_id']]['inv']=1;
$accounts[$dane['parent_id']]['id']=$dane['parent_id'];
}
$query="select parent_id from documents_accounts where parent_type='Account'";
$res=$GLOBALS['db']->query($query);
while($dane=$GLOBALS['db']->fetchByAssoc($res)){
$accounts[$dane['parent_id']]['doc']=1;
$accounts[$dane['parent_id']]['id']=$dane['parent_id'];
}
foreach ($accounts as $ac){
if($ac['doc']==1 && $ac['inv']==1){
echo "update accounts set account_type='rs' where id='".$ac['id']."';
";
}
}
foreach ($accounts as $ac){
if($ac['doc']==1 && $ac['inv']==1){
$acc = new Account();
$acc->retrieve($ac['id']);
echo $acc->name.'
';
}
}
?>