<?php
/**
 * The ajaxGetDropMenu view file of project module of ZDOO.
 *
 * @copyright   Copyright 2009-2018 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Tingting Dai <daitingting@xirangit.com>
 * @package     project 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php
js::set('projectID', $projectID);
js::set('module', $module);
js::set('method', $method);
js::set('extra', $extra);

$mineMenu      = '';
$otherMenu     = '';
$finishedMenu  = '';
$suspendedMenu = '';
foreach($projects as $project)
{
    $url  = $project->type == 'normal' ? $link : $this->createLink('kanban', 'browse', "projectID=%s");
    $menu = "<li class='text-nowrap text-ellipsis'>" . html::a(sprintf($url, $project->id), "<i class='icon-folder'></i> " . $project->name). "</li>";

    if($project->status == 'doing' and $project->PM == $this->app->user->account) $mineMenu  .= $menu;
    if($project->status == 'doing' and $project->PM != $this->app->user->account) $otherMenu .= $menu;
    if($project->status == 'finished') $finishedMenu .= $menu;
    if($project->status == 'suspend') $suspendedMenu .= $menu;
}
?>
<input type='text' class='form-control' id='search' value='' onkeyup='searchItems(this.value, "project", v.projectID, v.module, v.method, v.extra)' placeholder='<?php echo $this->lang->project->search;?>'/>

<div id='searchResult'>
  <div id='defaultMenu'>
    <ul>
      <?php
      if($mineMenu && $otherMenu) echo "<li class='heading'>{$lang->project->mine}</li>";
      echo $mineMenu;
 
      if($mineMenu && $otherMenu) echo "<li class='heading'>{$lang->project->other}</li>";
      echo $otherMenu;
      ?>
    </ul>
    <div>
      <?php echo html::a($this->createLink('project', 'index', "status={$currentProject->status}"), "<i class='icon-grid'></i> " . $lang->project->browse, "id='backButton'");?>
      <?php if($finishedMenu or $suspendedMenu):?>
      <div class='pull-right actions'>
        <?php if($finishedMenu):?>
        <div><a id='finishedMore' href='javascript:switchFinished()'><?php echo $lang->project->finished . ' <i class="icon-angle-right"></i>';?></a></div>
        <?php endif;?>
        <?php if($suspendedMenu):?>
        <div><a id='suspendMore' href='javascript:switchSuspend()'><?php echo $lang->project->suspended . ' <i class="icon-angle-right"></i>';?></a></div>
        <?php endif;?>
      </div>
      <?php endif;?>
    </div>
  </div>

  <?php if($finishedMenu) echo "<div id='finishedMenu'><ul>{$finishedMenu}</ul></div>";?>
  <?php if($suspendedMenu) echo "<div id='suspendMenu'><ul>{$suspendedMenu}</ul></div>";?>
</div>
