<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<?php /* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */ ?>
<div    data-type="<?php echo $tpl->get('thread')->type ?>"
        class="bez_thread
        <?php
        if ($tpl->get('thread')->state == 'opened') {
            echo 'priority_' . $tpl->get('thread')->priority;
        }
        ?>">

<h1 class="thread_box_header">

<a href="<?php echo $tpl->url('thread', 'id', $tpl->get('thread')->id) ?>">
    Proyecto: <?php echo $tpl->get('thread')->id ?>
</a>

<?php 
/* desde aqui todo el codigo es nuevo para logara la personalizacion de la herramienta
Rev
*/

// en esta linea se agrega las variables para cambio de nombre de cliente desde el titulo
// limpia el nombre del cliente. si auditadopropio es "" es porque no es propio
//$titulo1= explode("Año: na",$titulo1);
//$titulo1= $titulo1[0];
$titulo = $tpl->get('thread')->title;

//$rest = substr($variable, 0, 20);
$variable= explode('-',$titulo);
$titulo1= $variable[0];
if (isset($titulo1)){
$titulo2=$titulo1;
}
else{
$titulo2= $titulo;
}

$auditadoPropio= $variable[1];
//$titulo1= explode("Año: na",$titulo1);
//$titulo1= $titulo1[0];
if (isset($auditadoPropio)){
$auditado=$auditadoPropio;
//echo "paso por aqui";
}

?>

<?php if ($tpl->get('thread')->type == 'project'): ?>
    <?php $tpl->getLang('project');
    echo $auditado; ?>
<?php elseif (!empty($tpl->get('thread')->label_name)): ?>
    <?php echo $tpl->get('thread')->label_name ?>
<?php else: ?>
    <i style="color: #777"><?php echo $tpl->getLang('issue_type_no_specified') ?></i>
<?php endif ?>

(<?php echo $tpl->getLang('state_' . $tpl->get('thread')->state) ?>)

<?php if ($tpl->get('thread')->private == '1'): ?>
    <?php echo inlineSVG(DOKU_PLUGIN . 'bez/images/lock.svg') ?>
<?php endif ?>
</h1>

<h1 class="thread_header"><?php echo $titulo2;
$tpl->get('thread')->title;
?></h1>

<div class="timebox">
    <span>
        <strong><?php echo $tpl->getLang('open') ?>:</strong>
        <?php echo $tpl->date($tpl->get('thread')->create_date) ?>
    </span>


<?php if ($tpl->get('thread')->state == 'closed' || $tpl->get('thread')->state == 'rejected'): ?>
    <span>
        <strong><?php echo $tpl->getLang('closed') ?>:</strong>
        <?php echo $tpl->date($tpl->get('thread')->close_date) ?>
    </span>

    <span>
        <strong><?php echo $tpl->getLang('report_priority') ?>: </strong>
        <?php echo $tpl->date_diff_days($tpl->get('thread')->create_date, $tpl->get('thread')->close_date, '%a') ?>
    </span>
<?php endif ?>
</div>

<table class="data">
<tr>
    <th><?php echo $tpl->getLang('reporter') ?>:</th>
    <td>
        <?php echo $tpl->user_name($tpl->get('thread')->original_poster) ?>
    </td>

    <th><?php echo $tpl->getLang('coordinator') ?>:</th>
    <td>
        <?php if ($tpl->get('thread')->coordinator == ''): ?>
            <i style="font-weight: normal; color: #aaa"><?php echo $tpl->getLang('none') ?></i>
        <?php else: ?>
            <?php echo $tpl->user_name($tpl->get('thread')->coordinator) ?>
        <?php endif?>
    </td>
</tr>
</table>

<?php echo $tpl->get('thread')->content_html ?>
<?php if (!$tpl->get('no_actions')): ?>
    <div class="bez_buttons">

        <?php if ($tpl->param('kid') == '' &&
            $tpl->get('thread')->acl_of('state') >= BEZ_PERMISSION_CHANGE &&
            ($tpl->get('thread')->can_be_closed() ||
                $tpl->get('thread')->can_be_rejected() ||
                $tpl->get('thread')->can_be_reopened())): ?>

            <a class="bds_inline_button"
               id="plugin__bez_thread_change_state_button"
               href="<?php echo $tpl->url('thread', 'id', $tpl->get('thread')->id) ?>#k_">
                <?php if ($tpl->get('thread')->can_be_closed()): ?>
                    ↬ <?php echo $tpl->getLang('js')['close_issue' . $tpl->get('lang_suffix')] ?>
                <?php elseif ($tpl->get('thread')->can_be_rejected()): ?>
                    ↛ <?php echo $tpl->getLang('js')['reject_issue' . $tpl->get('lang_suffix')] ?>
                <?php elseif ($tpl->get('thread')->can_be_reopened()): ?>
                    ↻ <?php echo $tpl->getLang('js')['reopen_issue'. $tpl->get('lang_suffix')]  ?>
                <?php endif?>
            </a>
        <?php endif ?>

        <?php if (count($tpl->get('thread')->changable_fields(array('label_id', 'title', 'content', 'coordinator'))) > 0): ?>
            <a href="<?php echo $tpl->url('thread_report', 'action', 'edit', 'id', $tpl->get('thread')->id) ?>" class="bds_inline_button">
                ✎ <?php echo $tpl->getLang('edit') ?>
            </a>
        <?php endif ?>

        <?php if ($tpl->get('thread')->acl_of('id') >= BEZ_PERMISSION_DELETE && $tpl->get('thread')->can_be_removed()): ?>
            <a class="bds_inline_button bez_commcause_delete_prompt"
               href="<?php echo $tpl->url('thread', 'id', $tpl->get('thread')->id, 'action', 'delete');
               ?>">
                ✕ <?php echo $tpl->getLang('delete') ?>
            </a>
        <?php endif ?>

        <a class="bds_inline_button" href="
            <?php echo $tpl->mailto($tpl->user_email($tpl->get('thread')->coordinator),
                                       '#'.$tpl->get('thread')->id.' '.$tpl->get('thread')->title,
            $tpl->url('thread', 'id', $tpl->get('thread')->id)) ?>">
            ✉ <?php echo $tpl->getLang('send_mail') ?>
        </a>

        <?php if ($tpl->get('thread')->type == 'issue'): ?>
            <a href="<?php echo $tpl->url('8d', 'id', $tpl->get('thread')->id) ?>" class="bds_inline_button bds_report_button">
                ⎙ <?php echo $tpl->getLang('8d_report') ?>
            </a>
        <?php else: ?>
            <a href="<?php echo $tpl->url('kp', 'id', $tpl->get('thread')->id) ?>" class="bds_inline_button bds_report_button">
                ⎙ <?php echo $tpl->getLang('kp_report') ?>
            </a>
        <?php endif ?>
    </div>
<?php endif ?>

</div>

</body>


</html>

