<div id="body">
    <div class="outerdiv">
        <?php if(isset($error)){ ?>
        <div class="innerdiv">
            <div class="info" style="margin:30px">
           <?= htmlspecialchars($error) ?>
            </div>
        </div>
       <?php }else{ ?>
        <div id="custom-tabs" style="margin:15px;">
            <ul class="nav nav-tabs">
                <li><a target="_self" href="#tabs-1"><?php echo $this->lang->line('promise_tab_definition'); ?></a></li>
                <li><a href="#tabs-3" target="_self"><?php echo $this->lang->line('promise_tab_same_bundle'); ?></a></li>
                <li><a href="#tabs-4" target="_self"><?php echo $this->lang->line('promise_tab_same_promiser'); ?></a></li>
                <li><a href="#tabs-5" target="_self"><?php echo $this->lang->line('promise_tab_same_type'); ?></a></li>

            </ul>
            <div id="tabs-1" class="ui-corner-all">

                <div class="panelcontent">
                    <table class="bundlelist-table table table-striped table-bordered table-condensed">
                        <tr>
                            <th scope="col" colspan="2"><?php echo $this->lang->line('header_promise_definition'); ?></th>
                        </tr>
                        <tr>
                            <td><?php echo $this->lang->line('promise_belong_to_bundle'); ?></td>
                            <td><a href="<?php echo site_url(); ?>/bundle/details/bundle/<?php echo urlencode($promise['bundlename']); ?>/type/<?php echo urlencode($promise['bundletype']); ?>"><?php echo $promise['bundlename']; ?></a></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_reference_handle'); ?></td>
                            <td><?= htmlspecialchars($promise['handle']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_affected_object'); ?></td>
                            <td><?= htmlspecialchars($promise['promiser']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_stakeholder'); ?></td>
                            <td><?= htmlspecialchars($promise['promisee']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_comment_intention'); ?></td>
                            <td><?= htmlspecialchars($promise['comment']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_about'); ?></td>
                            <td><?= htmlspecialchars($promise['promise_type']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_class_context'); ?></td>
                            <td><?= htmlspecialchars($promise['class_context']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_defined_file'); ?></td>
                            <td><?= htmlspecialchars($promise['file']) ?></td>
                        </tr>

                        <tr>
                            <td><?php echo $this->lang->line('promise_defined_line'); ?></td>
                            <td><?= htmlspecialchars($promise['line_num']) ?></td>
                        </tr>

                        <tr >
                            <th scope="blue" colspan="2"><?php echo $this->lang->line('header_body_promise'); ?></th>
                        </tr>

                        <?php
                        if($promise && key_exists('body', $promise)){
                        foreach ((array) $promise['body'] as $body) { ?>
                            <tr>
                                <td><?= htmlspecialchars($body['type']) ?> =></td>
                               <?php if(is_execptional_body(urlencode($body['type']))) {?>
                                <td><a href="<?php echo site_url(); ?>/bundle/details/bundle/<?php echo urlencode($body['name']) ?>"><?= htmlspecialchars($body['name']) ?></a></td>
                                <?php } else{?>
                                <td><a href="<?php echo site_url(); ?>/welcome/body/body/<?php echo urlencode($body['name']); ?>/type/<?php echo urlencode($body['type']) ?>"><?= htmlspecialchars($body['name']) ?><?= htmlspecialchars($body['args']) ?></a></td>
                                 <?php } ?>
                            </tr>
                        <?php } }else{
                            echo "<tr><td colspan=\"2\">". $this->lang->line('promise_body_not_found')."</td></tr>";
                        }?>
                    </table>
                </div>
            </div>

            <div id="tabs-3" class="ui-corner-all">

                <table class="bundlelist-table table table-striped table-bordered table-condensed">
                    <tr>
                        <th scope="col"><?php echo $this->lang->line('promise_other_promise'); ?> <a href="<?php echo site_url(); ?>/bundle/details/bundle/<?php echo urlencode($mybundle); ?>"><span id="bundle"><?= htmlspecialchars($mybundle) ?></span></a></th>
                    </tr>


                    <?php foreach ((array) $allhandles as $p) { ?>
                        <tr>
                            <td><?php echo sprintf("<a href='%s/promise/details/%s'>%s</a>", site_url(),$p, $p); ?></td>
                        </tr>
                    <?php } ?>
                </table>

            </div>
            <div id="tabs-4" class="ui-corner-all">

                <table class="bundlelist-table table table-striped table-bordered table-condensed">
                    <tr>
                        <th scope="col"><?php echo $this->lang->line('promise_other_promiser'); ?></th>
                    </tr>


                    <?php foreach ((array) $allhandlespromiser as $p) { ?>
                        <tr>
                            <td><?php echo sprintf("<a href='%s/promise/details/%s'>%s</a>", site_url(), htmlspecialchars($p), htmlspecialchars($p)); ?></td>
                        </tr>
                    <?php } ?>
                </table>
            </div>
            <div id="tabs-5" class="ui-corner-all">

                <table class="bundlelist-table table table-striped table-bordered table-condensed">
                    <tr>
                        <th scope="col"><?php echo $this->lang->line('promise_other_promiser_type'); ?> <?php echo $type ?></th>
                    </tr>


                    <?php foreach ((array) $allhandlesbytype as $p) { ?>
                        <tr>
                            <td><?php echo sprintf("<a href='%s/promise/details/%s'>%s</a>",  site_url(), $p, $p); ?></td>
                        </tr>
                    <?php } ?>
                </table>
            </div>
        </div>
    <?php } ?>
    </div>
</div>
<div class="clear"></div>
<script type="text/javascript">
    jQuery(document).ready(function(){
        $("#custom-tabs" ).tabs();
    });
</script>











