<?php
/**
 * The more columns view file of kanban module of ZDOO.
 *
 * @copyright   Copyright 2009-2020 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Gang Liu <liugang@easycorp.ltd>
 * @package     kanban
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<style>
#moreColumns {top: 48px; right: -400px; width: 400px; position: fixed; z-index: 1050; background-color: rgb(255,255,255);}
#moreColumns .panel .panel-body {overflow: auto; padding: 0px 20px;}
#moreColumns .parent-item,#moreColumns .child-item {padding: 20px 0px; border-bottom: 1px solid #ddd; line-height: 26px; overflow: hidden;}
#moreColumns .title {width: 250px; float: left;}
#moreColumns .label-child {border-radius: 12px; background-color: #DDDDDD; color: #333; margin-right: 10px;}
#moreColumns .btn {float: right; line-height: 26px; height: 26px; padding: 0 20px;}
</style>
<div class='panel'>
  <div class='panel-heading text-center'>
    <strong><?php echo $lang->kanban->archivedColumn;?></strong>
    <button type="button" class="close" aria-hidden="true">×</button>
  </div>
  <div class='panel-body'>
    <?php foreach($columns as $column):?>
    <div class="item-body">
      <div class="item parent-item" data-archived='<?php echo $column->archived;?>' data-id="<?php echo $column->id;?>">
        <div class="title text-ellipsis"><?php echo $column->name;?></div>
        <?php if($this->kanban->isClickable($column, 'restoreColumn') && $column->archived == '1') echo html::a(inlink('restoreColumn', "columnID={$column->id}"), $lang->kanban->restore, "class='btn btn-primary restoreConfirmer text-right' data-confirmButton='{$lang->kanban->restore}' data-confirmTitle='{$lang->kanbancolumn->confirmRestore}' data-confirmDetail='{$lang->kanbancolumn->confirmRestoreDetail}' data-confirming='{$lang->kanban->restoring}'");?>
      </div>
      <?php if(!empty($column->child) && $column->archived == '0'):?>
      <?php foreach($column->child as $childColumn):?>
        <div class="item child-item" data-id="<?php echo $childColumn->id;?>" data-archived='<?php echo $childColumn->archived;?>'>
          <div class="title text-ellipsis"><label class="label label-child"><?php echo $lang->kanban->child;?></label><?php echo $childColumn->name;?></div>
          <?php if($this->kanban->isClickable($childColumn, 'restoreColumn') && $childColumn->archived == '1') echo html::a(inlink('restoreColumn', "columnID={$childColumn->id}"), $lang->kanban->restore, "class='btn btn-primary restoreConfirmer text-right' data-confirmButton='{$lang->kanban->restore}' data-confirmTitle='{$lang->kanbancolumn->confirmRestore}' data-confirmDetail='{$lang->kanbancolumn->confirmRestoreDetail}' data-confirming='{$lang->kanban->restoring}'");?>
        </div>
      <?php endforeach;?>
      <?php endif;?>
    </div>
    <?php endforeach;?>
  </div>
</div>
<script>
$(function()
{
    $('#moreColumns .panel .close').click(function()
    {
        $('#moreColumns').animate({right: -400}, 500);
    });

    $.setAjaxConfirmer('.restoreConfirmer', function(data)
    {
        if(data.result == 'success')
        {
            var $this = $('#moreColumns .panel-body .item[data-id=' + data.columnID + ']');
            if($this.hasClass('parent-item'))
            { 
                $this.parent().remove(); 
            }
            else
            {
                var childCount = $this.parents('.item-body').find('.child-item').length;
                if(childCount == 1)
                { 
                    $this.parents('.item-body').remove();
                }
                else
                {
                    $this.remove();
                }
            }
        }
    });
})
</script>
