<?php
/*
* SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to UNLICENSE
*/
namespace issue_v;
require_once "model/issue.php";
require_once "class/issue.class.php";
?>
<?php function userPanel(?\user $u, string $style, string $role, string $ts) : void { ?>
<div class="<?=$style?>">
<?php if (!$u) { ?>
<p class="text-center">
<span class="glyphicon glyphicon-ban-circle"></span>
<?=$role?>
</p>
<?php } else { ?>
<table>
<tbody>
<tr>
<td><?=\datalsts\objHeadCircle($u, 30)?> </td>
<td>
<?=$u->getDisplayName()?>
<small>
<?=$role?>
<br />
<?=$ts?>
</small>
</td>
</tr>
</tbody>
</table>
<?php } ?>
</div>
<?php } ?>
<?php function issue(\issue $i) : void { ?>
<?php $m = $i->getOPMesg(); ?>
<div id="issueModal-<?=$i->guid?>" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">
<span class="glyphicon glyphicon-inbox"></span>
<?=$i->name?>
<small>#<?=$i->numb?></small>
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-8">
<p><?=$m->renderMesg()?></p>
<hr />
<?php foreach ($i->getMesgs_ordByDatetime() as $rm) { ?>
<div class="panel panel-default">
<div class="panel-body">
<?php if ($rm->objtype == "mesg") { ?>
<div class="row">
<div class="col-xs-1">
<?=\datalsts\objHeadCircle($rm->getAuthor(), 40)?>
</div>
<div class="col-xs-11">
<strong><?=$rm->getAuthor()->getDisplayName()?></strong>
<small><?=$rm->created?></small>
<br />
<?=$rm->renderMesg()?>
<?php if ($rm->getAttachment()) { ?>
<br />
<br />
<a href="<?=$rm->getAttachment()?>" class="btn btn-info">
<span class="glyphicon glyphicon-save"></span>
<?=$rm->attachment?>
</a>
<?php } ?>
</div>
</div>
<?php } else { ?>
<?=\datalsts\objHeadCircle($rm->getAuthor(), 25)?>
<?=$rm->renderMesg()?>
<small><?=$rm->created?></small>
<?php } ?>
</div>
</div>
<?php } ?>
<form method="post" action="<?=ap()?>" enctype="multipart/form-data">
<?=\formctrl\formname( "iss-mesg-add" )?>
<?=\formctrl\hidden( "issue", $i->guid )?>
<?=\formctrl\textarea( "New message", "mesg", 5 )?>
<div class="btn-group pull-right">
<button type="submit" name="input[postMesg]" class="btn btn-primary" title="Post message">
<span class="glyphicon glyphicon-envelope"></span>
</button>
<button type="submit" name="input[closeIssue]" class="btn btn-default" title="Close issue">
<span class="glyphicon glyphicon-ok"></span>
</button>
<button type="submit" name="input[advIssue]" class="btn btn-default" title="Advance issue">
<span class="glyphicon glyphicon-chevron-up"></span>
</button>
<button type="button" class="btn btn-default" data-toggle="collapse" data-target="#assignCollapse-<?=$i->guid?>" title="Assign issue">
<span class="glyphicon glyphicon-share-alt"></span>
</button>
</div>
<div class="collapse" id="assignCollapse-<?=$i->guid?>">
<div class="form-group">
<label>Select assignee</label>
<select name="input[assignee]" class="form-control selectpicker">
<option data-icon="glyphicon-user" value="<?=$i->getParent()->getParent()->getOwner()->guid?>">
<?=$i->getParent()->getParent()->getOwner()->getDisplayName()?>
</option>
<?php foreach ($i->getParent()->getParent()->getMembers() as $memb) { ?>
<option data-icon="glyphicon-user" value="<?=$memb->guid?>">
<?=$memb->getDisplayName()?>
</option>
<?php } ?>
</select>
</div>
<button type="submit" name="input[assIssue]" class="btn btn-default">
<span class="glyphicon glyphicon-share-alt"></span> Post and assign issue
</button>
</div>
<?=\formctrl\file( "Attachment", "attachment" )?>
</form>
</div>
<div class="col-md-4">
<?php $closer = $i->getCloser(); ?>
<?php $assigns = $i->getAssignees(); ?>
<?php $owner = $i->getOwner(); ?>
<?php $author = $m->getAuthor(); ?>
<?php $members = $i->getMembers(); ?>
<?php if ($closer) { ?>
<?=userPanel($closer, "alert alert-success", "closed", $i->closed)?>
<?php } ?>
<?php if (count($assigns) == 0) { ?>
<?=userPanel(NULL, "alert alert-danger", "unassigned", "")?>
<?php } ?>
<?php foreach ($assigns as $assign) { ?>
<?php if ($assign->signedoff != "") { ?>
<?=userPanel($assign->assignee, "alert alert-success", "signed off", $assign->signedoff)?>
<?php } else { ?>
<?=userPanel($assign->assignee, "alert alert-warning", "assigned", $assign->assigned)?>
<?php } ?>
<?php } ?>
<?=userPanel($owner, "alert alert-info", "opened", $i->created)?>
<?php if ($author->guid != $owner->guid) { ?>
<?=userPanel($author, "alert alert-info", "authored", $m->created)?>
<?php } ?>
<?php if (count($members) != 0) { ?>
<hr />
<?php } ?>
<?php foreach ($members as $m) { ?>
<?=userPanel($m, "well", "cc'd", "")?>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>