<?php
  /**
   * Menus
   *
   * @package Wojo Framework
   * @author wojoscripts.com
   * @copyright 2017
   * @version $Id: categories.tpl.php, v1.00 2016-05-05 10:12:05 gewa Exp $
   */
  if (!defined("_WOJO"))
      die('Direct access to this location is not allowed.');
	  
  if(!Auth::hasPrivileges('manage_menus')): print Message::msgError(Lang::$word->NOACCESS); return; endif;
?>
<?php switch(Url::segment($this->segments)): case "edit": ?>
<!-- Start edit -->
<h2><?php echo Lang::$word->MU_EDIT;?></h2>
<form method="post" id="wojo_form" name="wojo_form">
  <div class="row horizontal-gutters">
    <div class="columns screen-70 tablet-50 mobile-100 phone-100">
      <div class="wojo segment form">
        <div class="wojo block fields">
          <div class="field">
            <label><?php echo Lang::$word->NAME;?>
              <i class="icon asterisk"></i></label>
            <input type="text" placeholder="<?php echo Lang::$word->NAME;?>" value="<?php echo $this->data->name;?>" name="name">
          </div>
          <div class="field">
            <label><?php echo Lang::$word->MU_TYPE;?>
              <i class="icon asterisk"></i></label>
            <select name="content_type" id="contenttype" class="wojo fluid selection dropdown">
              <option value=""><?php echo Lang::$word->MU_TYPE;?></option>
              <?php echo Utility::loopOptionsSimpleAlt($this->contenttype, $this->data->content_type);?>
            </select>
          </div>
          <div class="field" id="contentid" style="display:<?php echo ($this->data->content_type != "web") ? 'block' : 'none';?>">
            <label><?php echo Lang::$word->MU_PAGE;?></label>
            <select name="page_id" id="page_id" class="wojo fluid selection dropdown">
              <?php if($this->data->content_type == "page"):?>
              <?php echo Utility::loopOptions($this->pagelist, "id", "title", $this->data->page_id);?>
              <?php endif;?>
            </select>
          </div>
          <div id="webid" style="display:<?php echo ($this->data->content_type == "web") ? 'block' : 'none';?>">
            <div class="field">
              <label><?php echo Lang::$word->MU_EXT_URL;?></label>
              <input type="text" name="web" placeholder="<?php echo Lang::$word->MU_EXT_URL;?>" value="<?php echo $this->data->link;?>">
            </div>
            <div class="field">
              <label><?php echo Lang::$word->MU_TARGET_L;?></label>
              <select name="target" class="wojo fluid selection dropdown">
                <option value=""><?php echo Lang::$word->MU_TARGET;?></option>
                <option value="_blank" <?php Validator::getSelected($this->data->target, "_blank");?>><?php echo Lang::$word->MU_TARGET_B;?></option>
                <option value="_self" <?php Validator::getSelected($this->data->target, "_self");?>><?php echo Lang::$word->MU_TARGET_S;?></option>
              </select>
            </div>
          </div>
        </div>
        <div class="wojo fields">
          <div class="field">
            <label><?php echo Lang::$word->PUBLISHED;?></label>
            <div class="wojo inline fields">
              <div class="wojo checkbox radio field">
                <input name="active" type="radio" value="1" <?php Validator::getChecked($this->data->active, 1);?>>
                <label><?php echo Lang::$word->YES;?></label>
              </div>
              <div class="wojo checkbox radio field">
                <input name="active" type="radio" value="0" <?php Validator::getChecked($this->data->active, 0);?>>
                <label><?php echo Lang::$word->NO;?></label>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="content-center"><a href="<?php echo Url::url("/admin/menus");?>" class="wojo small basic button"><?php echo Lang::$word->CANCEL;?></a>
        <button type="button" data-action="processMenu" name="dosubmit" class="wojo primary button"><?php echo Lang::$word->MU_UPDATE;?></button>
      </div>
    </div>
    <div class="columns screen-30 tablet-50 mobile-100 phone-100">
      <h3><?php echo Lang::$word->MU_AVAIL;?></h3>
      <p class="wojo small text"><?php echo Lang::$word->MU_INFO1;?></p>
      <div class="wojo space divider"></div>
      <div id="sortlist" class="dd">
        <?php if($this->sortlist) : echo $this->sortlist; endif;?>
      </div>
    </div>
  </div>
  <input type="hidden" name="id" value="<?php echo $this->data->id;?>">
</form>
<script src="<?php echo SITEURL;?>/assets/nestable.js"></script>
<script type="text/javascript" src="<?php echo ADMINVIEW;?>/js/menus.js"></script>
<script type="text/javascript"> 
// <![CDATA[  
  $(document).ready(function() {
	  $.Menus({
		  url: "<?php echo ADMINVIEW;?>",
	  });
  });
// ]]>
</script>
<?php break;?>
<?php default: ?>
<h2><?php echo Lang::$word->META_M_MENUS;?></h2>
<p class="wojo small text"><?php echo Lang::$word->MU_INFO;?></p>
<form method="post" id="wojo_form" name="wojo_form">
  <div class="row horizontal-gutters">
    <div class="columns screen-70 tablet-50 mobile-100 phone-100">
      <div class="wojo segment form">
        <div class="wojo block fields">
          <div class="field">
            <label><?php echo Lang::$word->NAME;?>
              <i class="icon asterisk"></i></label>
            <input type="text" placeholder="<?php echo Lang::$word->NAME;?>" name="name">
          </div>
          <div class="field">
            <label><?php echo Lang::$word->MU_TYPE;?>
              <i class="icon asterisk"></i></label>
            <select name="content_type" id="contenttype" class="wojo fluid selection dropdown">
              <option value=""><?php echo Lang::$word->MU_PAGE;?></option>
              <?php echo Utility::loopOptionsSimpleAlt($this->contenttype);?>
            </select>
          </div>
          <div class="field" id="contentid">
            <label><?php echo Lang::$word->MU_PAGE;?></label>
            <select name="content_id" id="page_id" class="wojo fluid selection dropdown">
              <option value="0"><?php echo Lang::$word->NONE;?></option>
            </select>
          </div>
          <div id="webid" class="hide-all">
            <div class="field">
              <label><?php echo Lang::$word->MU_EXT_URL;?></label>
              <input type="text" name="web" placeholder="<?php echo Lang::$word->MU_EXT_URL;?>">
            </div>
            <div class="field">
              <label><?php echo Lang::$word->MU_TARGET_L;?></label>
              <select name="target" class="wojo fluid selection dropdown">
                <option value=""><?php echo Lang::$word->MU_TARGET;?></option>
                <option value="_blank"><?php echo Lang::$word->MU_TARGET_B;?></option>
                <option value="_self"><?php echo Lang::$word->MU_TARGET_S;?></option>
              </select>
            </div>
          </div>
        </div>
        <div class="wojo fields">
          <div class="field">
            <label><?php echo Lang::$word->PUBLISHED;?></label>
            <div class="wojo inline fields">
              <div class="wojo checkbox radio field">
                <input name="active" type="radio" value="1" checked="checked">
                <label><?php echo Lang::$word->YES;?></label>
              </div>
              <div class="wojo checkbox radio field">
                <input name="active" type="radio" value="0">
                <label><?php echo Lang::$word->NO;?></label>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="content-center">
        <button type="button" data-action="processMenu" name="dosubmit" class="wojo primary button"><?php echo Lang::$word->MU_CREATE;?></button>
      </div>
    </div>
    <div class="columns screen-30 tablet-50 mobile-100 phone-100">
      <h2><?php echo Lang::$word->MU_AVAIL;?></h2>
      <p class="wojo small text"><?php echo Lang::$word->MU_INFO1;?></p>
      <div class="wojo space divider"></div>
      <div id="sortlist" class="dd">
        <?php if($this->sortlist) : echo $this->sortlist; endif;?>
      </div>
    </div>
  </div>
</form>
<script src="<?php echo SITEURL;?>/assets/nestable.js"></script>
<script type="text/javascript" src="<?php echo ADMINVIEW;?>/js/menus.js"></script>
<script type="text/javascript"> 
// <![CDATA[  
  $(document).ready(function() {
	  $.Menus({
		  url: "<?php echo ADMINVIEW;?>",
	  });
  });
// ]]>
</script>
<?php break;?>
<?php endswitch;?>