web/website/integrations/osticket/dev-view.php

35 lines
11 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php if(!defined('ROOT_DIR')||!isset($identity,$db,$view))exit;
$nav=[
'overview'=>['Overview','team-dev-150.png'],
'queue'=>['Development Queue','rank-dev-150.png'],
'approvals'=>[$team?'Approvals':'My Pending Requests','department-legal-v2-150.png'],
'new'=>['New Request','department-dev-150.png'],
'archive'=>['Archive','department-network-staff-150.png'],
];
$active=$selected?($selected['approval']==='pending'?'approvals':(in_array($selected['approval'],['consolidated','completed','denied','superseded'],true)?'archive':'queue')):$view;
$archiveCount=array_sum(array_diff_key($counts,array_flip(['approved','pending'])));
$statusText=static fn($s)=>['consolidated'=>'Merged','superseded'=>'Superseded','approved'=>'Approved','pending'=>'Awaiting approval','completed'=>'Completed','denied'=>'Denied'][$s]??$s;
?><!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title><?=$esc($selected?$selected['title']:$nav[$view][0])?> · Dev Center · DuneRealms</title><link rel="stylesheet" href="/dune-dev.css?v=dev-center-2"></head><body class="dune-dev-app"><main class="dev-desk">
<header class="dev-hero"><img src="/assets/seals/team-dev-300.png" width="116" height="116" alt="DuneRealms Dev Team imperial seal"><div><p class="eyebrow">THE IMPERIAL DEVELOPMENT BUREAU</p><h1>Dev Center</h1><p>From a clear request to a tested release.</p><span class="dev-role"><?=$esc($identity['displayName']?:$identity['username'])?> · <?=$owner?'Reviewer':($team?'Dev team':'Requester')?></span></div><a class="dev-back" href="https://cp.dunerealms.com/">← Account Center</a></header>
<nav class="dev-submenu" aria-label="Dev Center sections"><?php foreach($nav as$key=>[$label,$art]):?><a href="/dev-tasks.php?view=<?=$key?>" <?=$active===$key?'aria-current="page"':''?>><img src="https://www.dunerealms.com/assets/seals/<?=$art?>" width="34" height="34" alt=""><span><?=$esc($label)?></span><?php if($key==='approvals'&&($counts['pending']??0)):?><strong><?=$counts['pending']?></strong><?php endif;?></a><?php endforeach;?></nav>
<?php foreach($errors as$error):?><p class="dev-error" role="alert"><?=$esc($error)?></p><?php endforeach;if(isset($_GET['saved'])):?><p class="dev-success" role="status">Saved. The task’s current state is shown below.</p><?php endif;?>
<?php if($selected):?>
<section class="dev-box"><div class="dev-task-heading"><div><p class="eyebrow">TICKET #<?=$esc($selected['number'])?></p><h2><?=$esc($selected['title'])?></h2></div><div class="dev-badges"><span><?=$esc($selected['priority'])?></span><span><?=$esc($statusText($selected['approval']))?></span><span><?=$esc(ucfirst($selected['ticket_state']))?></span><?php if($selected['task_type']==='Bug'):?><span class="bug">Bug · queue priority</span><?php endif;?></div></div>
<?php $details=json_decode($selected['prompt_json'],true)?:[];foreach(dune_dev_fields()as$key=>[$label])if(!empty($details[$key])&&!in_array($key,['title','priority'],true)):?><div class="dev-detail"><h3><?=$esc($label)?></h3><p><?=$esc($details[$key])?></p></div><?php endif;?>
<?php if($team):$q=$db->prepare('SELECT d.ticket_id,d.title FROM dune_dev_task_links l JOIN dune_dev_tasks d ON d.ticket_id=l.parent_ticket_id WHERE l.child_ticket_id=?');$q->execute([$id]);$parent=$q->fetch();$q=$db->prepare('SELECT d.ticket_id,d.title FROM dune_dev_task_links l JOIN dune_dev_tasks d ON d.ticket_id=l.child_ticket_id WHERE l.parent_ticket_id=? ORDER BY d.ticket_id');$q->execute([$id]);$children=$q->fetchAll();if($parent||$children):?><details class="dev-detail"><summary><?=$parent?'Open parent work package':'Original task history · '.count($children).' linked requests'?></summary><ul><?php foreach($parent?[$parent]:$children as$linked):?><li><a href="?id=<?=(int)$linked['ticket_id']?>"><?=$esc($linked['title'])?></a></li><?php endforeach;?></ul></details><?php endif;endif;?>
<?php if(!empty($selected['execution_spec'])):?><section class="dev-detail dev-brief"><h3>Execution brief · approved scope</h3><p><?=$esc($selected['execution_spec'])?></p></section><?php endif;?>
<?php if($priorityEditor&&$selected['approval']==='approved'):?><details class="dev-detail"><summary>Edit execution brief</summary><p>The original request remains unchanged. Clarify implementation without expanding approved scope.</p><form method="post"><input type="hidden" name="csrf" value="<?=$esc($_SESSION['dune_dev_csrf'])?>"><input type="hidden" name="id" value="<?=$id?>"><label>Execution brief<textarea name="brief" minlength="30" maxlength="30000" required><?=$esc($selected['execution_spec']?:dune_dev_execution_brief($details))?></textarea></label><button name="action" value="brief">Save execution brief</button></form></details><?php endif;?>
<div class="dev-detail"><h3>Decision / completion report</h3><p><?=$esc($selected['decision_note'])?></p></div>
<?php if($priorityEditor):?><form method="post" class="dev-actions"><input type="hidden" name="csrf" value="<?=$esc($_SESSION['dune_dev_csrf'])?>"><input type="hidden" name="id" value="<?=$id?>"><label>Task priority<select name="priority"><?php foreach(['Low','Medium','High']as$p):?><option <?=$selected['priority']===$p?'selected':''?>><?=$p?></option><?php endforeach;?></select></label><button name="action" value="priority">Update priority</button></form><?php endif;?>
<?php if(($owner&&$selected['approval']==='pending')||($team&&$selected['approval']==='approved')):?><form method="post" class="dev-resolution"><input type="hidden" name="csrf" value="<?=$esc($_SESSION['dune_dev_csrf'])?>"><input type="hidden" name="id" value="<?=$id?>"><label><?=$selected['approval']==='pending'?'Review decision':'Completion report'?><textarea name="note" minlength="10" maxlength="10000" required placeholder="<?=$selected['approval']==='pending'?'Explain approval or rejection.':'Actual changes, tests, evidence, fork/merge link, deployed versus staged and remaining limitations.'?>"></textarea></label><div class="dev-actions"><?php if($selected['approval']==='pending'):?><button name="action" value="approve">Approve task</button><button class="danger" name="action" value="deny">Deny &amp; close ticket</button><?php else:?><button name="action" value="complete">Complete &amp; close ticket</button><?php endif;?></div></form><?php endif;?>
<p><?php if($team):?><a href="/scp/tickets.php?id=<?=$id?>">Native ticket, discussion &amp; attachments →</a><?php else:?><a href="/tickets.php">Your support tickets &amp; attachments →</a><?php endif;?></p></section>
<?php elseif($view==='overview'):?>
<section class="dev-overview"><article><span class="eyebrow">READY FOR EXECUTION</span><strong><?=$counts['approved']??0?></strong><h2>Approved work</h2><p>Only approved, open tasks can be selected for a run.</p><a href="?view=queue">Open development queue →</a></article><article class="dev-pending"><span class="eyebrow">REVIEW DESK</span><strong><?=$counts['pending']??0?></strong><h2>Awaiting approval</h2><p>unimatrix999 and grmacken approve or decline requests.</p><a href="?view=approvals">Review requests →</a></article><article><span class="eyebrow">PRESERVED HISTORY</span><strong><?=$archiveCount?></strong><h2>Archive</h2><p>Completed, denied and merged requests keep their history.</p><a href="?view=archive">Browse archive →</a></article></section>
<section class="dev-box dev-start"><img src="/assets/seals/department-dev-300.png" width="140" height="140" alt="Development bureau crest"><div><p class="eyebrow">A CLEAR BRIEF MAKES A BETTER BUILD</p><h2>Have something to improve?</h2><p>Staff and VIP members can submit a task with context, scope, acceptance criteria and tests. Approved bugs take priority. Work runs in scheduled morning and evening sessions.</p><a class="dev-primary" href="?view=new">Create a development request</a></div></section>
<?php elseif(in_array($view,['queue','approvals','archive'],true)):?>
<section class="dev-box"><div class="dev-task-heading"><div><p class="eyebrow"><?=$view==='queue'?'APPROVED WORK ONLY':($view==='approvals'?'OWNER REVIEW':'PRESERVED RECORDS')?></p><h2><?=$esc($nav[$view][0])?></h2></div><span class="dev-total"><?=$total?> <?=$total===1?'ticket':'tickets'?></span></div><p><?=$view==='queue'?'Approved bugs first, then High, Medium and Low. Dependencies and unfinished work still apply.':($view==='approvals'?'These requests are not yet approved for execution. Review the full request before deciding.':'Merged requests were closed administratively, not completed. Their original prompts and links remain available.')?></p>
<div class="dev-register"><?php if(!$rows):?><p class="dev-empty">No tickets in this section.</p><?php endif;foreach($rows as$row):?><a href="?id=<?=(int)$row['ticket_id']?>"><span><small>#<?=$esc($row['number'])?></small><b><?=$esc($row['title'])?></b></span><span class="dev-badges"><?php if($row['task_type']==='Bug'):?><strong class="bug">Bug</strong><?php endif;?><strong><?=$esc($row['priority'])?></strong><em><?=$esc($statusText($row['approval']))?></em></span></a><?php endforeach;?></div><nav class="dev-actions" aria-label="Task pages"><?php if($page>1):?><a href="?view=<?=$view?>&amp;page=<?=$page-1?>">Previous</a><?php endif;?><span>Page <?=$page?> / <?=$pages?></span><?php if($page<$pages):?><a href="?view=<?=$view?>&amp;page=<?=$page+1?>">Next</a><?php endif;?></nav></section>
<?php elseif($view==='new'):?>
<section class="dev-box" id="new-task"><div class="dev-task-heading"><div><p class="eyebrow">NEW DEVELOPMENT REQUEST</p><h2>Write a clear task brief</h2></div><img src="/assets/seals/team-dev-150.png" width="64" height="64" alt="Dev team"></div><p>Use English. Required fields are marked *. Staff and VIP accounts only. Your original request is preserved; an execution brief is prepared after approval. Add supporting attachments to the resulting private ticket.</p><form method="post"><input type="hidden" name="action" value="create"><input type="hidden" name="csrf" value="<?=$esc($_SESSION['dune_dev_csrf'])?>"><input type="hidden" name="submission" value="<?=$esc($_SESSION['dune_dev_submission'])?>"><div class="dev-fields"><?php foreach(dune_dev_fields()as$key=>[$label,$required,$max,$type,$hint]):?><label class="<?=$type==='textarea'?'wide':''?>"><?=$esc($label)?><?=$required?' *':''?><?php if($type==='select'):?><select name="<?=$key?>" required><?php foreach($hint as$option):?><option <?=($values[$key]??'')===$option?'selected':''?>><?=$esc($option)?></option><?php endforeach;?></select><?php elseif($type==='textarea'):?><textarea name="<?=$key?>" maxlength="<?=$max?>" <?=$required?'required':''?> placeholder="<?=$esc($hint)?>"><?=$esc($values[$key]??'')?></textarea><?php else:?><input name="<?=$key?>" maxlength="<?=$max?>" <?=$required?'required':''?> placeholder="<?=$esc($hint)?>" value="<?=$esc($values[$key]??'')?>"><?php endif;?></label><?php endforeach;?></div><label class="dev-check"><input type="checkbox" name="privacy" value="1" required> I have not included passwords, tokens, private keys or unnecessary personal data.</label><button type="submit"><?=$owner?'Create approved task':'Submit for review'?></button></form></section>
<?php endif;?>
<footer class="dev-footnote">Private development workspace · Original requests and decisions are retained · <a href="https://cp.dunerealms.com/">Return to Account Center</a></footer></main></body></html>