<?php echo $header; ?>
<?php echo $column_left; ?>

<div id="content" class="isl-module-content">
  <script>var islConfig = <?php echo json_encode($islConfig); ?>;</script>
  <div class="page-header">
    <div class="container-fluid">
      <h1><?php echo $heading_title; ?></h1>

      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
          <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>

      <div class="pull-right">
        <button onclick="$('#form-isl-<?php echo $islConfig['name']; ?>-post').submit();" type="submit" class="save-changes btn btn-primary" data-toggle="tooltip" title="<?php echo $button_save; ?>"><i class="fa fa-save"></i></button>
        <a href="<?php echo $url_module; ?>" class="btn btn-default" data-toggle="tooltip" title="<?php echo $text_cancel; ?>"><i class="fa fa-reply"></i></a>
      </div>
    </div>
  </div>

  <div class="container-fluid">
    <?php if ($error_warning) { ?>
      <div class="alert alert-danger">
        <i class="fa fa-exclamation-circle" style="margin-right:10px"></i><?php echo $error_warning; ?>
      </div>
    <?php } ?>
    <?php if ($success) { ?>
      <div class="alert alert-success autoSlideUp">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <i class="fa fa-check-circle" style="margin-right:10px"></i><?php echo $success; ?>
      </div>
      <script>$('.autoSlideUp').delay(5000).fadeOut(600, function(){ $(this).show().css({'visibility':'hidden'}); }).slideUp(600);</script>
    <?php } ?>

    <div class="page-content">
      <div class="panel panel-default">
        <form action="<?php echo $url_form; ?>" method="post" enctype="multipart/form-data" id="form-isl-<?php echo $islConfig['name']; ?>-post" class="form-horizontal">

          <div class="panel-heading">
            <h3 id="_top" class="panel-title"><i class="fa fa-pencil"></i> <?php echo $sub_title; ?></h3>
          </div>

          <div class="panel-body">

            <div class="row">
              <div class="<?php echo !empty($info_form_post_content) ? 'col-md-9' : 'col-xs-12' ?>">

                <ul class="nav nav-tabs lang-tabs" role="tablist">
                  <?php foreach ($languages as $language) { ?>
                    <li>
                      <a href="#lang-<?php echo $language['language_id']; ?>" role="tab" data-toggle="tab">
                        <img src="<?php echo $language['flag_url']; ?>"> <?php echo $language['name']; ?>
                      </a>
                    </li>
                  <?php } ?>
                </ul>
                <div class="tab-content">
                  <?php foreach ($languages as $language) { ?>
                    <div class="tab-pane" id="lang-<?php echo $language['language_id']; ?>">
                      <div class="form-group required">
                        <label class="col-sm-3 control-label"><?php echo $entry_title; ?></label>
                        <div class="col-sm-9">
                          <input name="<?php echo $module_setting; ?>[title][<?php echo $language['language_id']; ?>]" class="form-control isl-title-<?php echo $language['language_id']; ?>" type="text" value="<?php echo !empty($setting['post']['title'][$language['language_id']]) ? $setting['post']['title'][$language['language_id']] : $setting['post']['title'][0]; ?>" >
                        </div>
                      </div>
                      <div class="form-group required">
                        <label class="col-sm-3 control-label"><?php echo $entry_excerpt; ?></label>
                        <div class="col-sm-9">
                          <textarea name="<?php echo $module_setting; ?>[excerpt][<?php echo $language['language_id']; ?>]" class="form-control" rows="6"><?php echo !empty($setting['post']['excerpt'][$language['language_id']]) ? $setting['post']['excerpt'][$language['language_id']] : $setting['post']['excerpt'][0]; ?></textarea>
                        </div>
                      </div>
                      <div class="form-group required">
                        <label class="col-sm-3 control-label"><?php echo $entry_content; ?></label>
                        <div class="col-sm-9">
                          <?php $content = !empty($setting['post']['content'][$language['language_id']]) ? $setting['post']['content'][$language['language_id']] : $setting['post']['content'][0]; ?>
                          <textarea name="<?php echo $module_setting; ?>[content][<?php echo $language['language_id']; ?>]" data-isl-summernote='300'><?php echo $content; ?></textarea>
                        </div>
                      </div>

                      <div class="form-group">
                        <label class="col-sm-3 control-label"><?php echo $entry_meta_title; ?></label>
                        <div class="col-sm-9">
                          <input name="<?php echo $module_setting; ?>[meta_title][<?php echo $language['language_id']; ?>]" class="form-control" type="text" value="<?php echo !empty($setting['post']['meta_title'][$language['language_id']]) ? $setting['post']['meta_title'][$language['language_id']] : $setting['post']['meta_title'][0]; ?>" >
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label"><?php echo $entry_meta_desc; ?></label>
                        <div class="col-sm-9">
                          <textarea name="<?php echo $module_setting; ?>[meta_description][<?php echo $language['language_id']; ?>]" class="form-control" rows="4"><?php echo !empty($setting['post']['meta_description'][$language['language_id']]) ? $setting['post']['meta_description'][$language['language_id']] : $setting['post']['meta_description'][0]; ?></textarea>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label"><?php echo $entry_meta_keywords; ?></label>
                        <div class="col-sm-9">
                          <input name="<?php echo $module_setting; ?>[meta_keyword][<?php echo $language['language_id']; ?>]" class="form-control" type="text" value="<?php echo !empty($setting['post']['meta_keyword'][$language['language_id']]) ? $setting['post']['meta_keyword'][$language['language_id']] : $setting['post']['meta_keyword'][0]; ?>" >
                          <div class="isl-help">Comma separated value. Ex: <code>ecommerce, marketing, opencart</code></div>
                        </div>
                      </div>

                    </div>
                  <?php } ?>
                </div> <!-- /.tab-content -->

              </div>

              <?php if (!empty($info_form_post_content)) { ?>
              <div class="col-md-3">
                <div class="panel panel-default panel-info">
                  <div class="panel-heading"><?php echo $text_information; ?></div>
                  <div class="panel-body">
                    <ul class="isl-list">
                      <?php foreach ($info_form_post_content as $info) { ?>
                        <li><?php echo $info ?></li>
                      <?php } ?>
                    </ul>
                  </div>
                </div>
              </div>
              <?php } ?>
            </div>

            <h3 id="_settings" class="isl-legend"><?php echo $text_settings; ?></h3>
            <hr class="isl-hr">

            <div class="row">
              <div class="<?php echo !empty($info_form_post_setting) ? 'col-md-9' : 'col-xs-12' ?>">

                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_url_alias; ?></label>
                  <div class="col-sm-9">
                    <input name="<?php echo $module_setting; ?>[url_alias]" class="form-control" type="text" value="<?php echo $setting['post']['url_alias']; ?>" >
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_author; ?></label>
                  <div class="col-sm-6 col-md-4">
                    <select name="<?php echo $module_setting; ?>[author_id]" class="form-control">
                      <?php foreach ($users as $author) { ?>
                        <option value="<?php echo $author['author_id']; ?>" <?php echo $author['author_id'] == $setting['post']['author_id'] ? 'selected="selected"' : ''; ?>><?php echo $author['name']; ?></option>

                      <?php } ?>
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_featured; ?></label>
                  <div class="col-sm-6 col-md-3">
                    <select name="<?php echo $module_setting; ?>[is_featured]" class="form-control">
                      <option value="1" <?php echo $setting['post']['is_featured'] == '1' ? 'selected="selected"' : ''; ?>><?php echo $text_yes; ?></option>
                      <option value="0" <?php echo $setting['post']['is_featured'] != '1' ? 'selected="selected"' : ''; ?>><?php echo $text_no; ?></option>
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_image; ?></label>
                  <div class="col-sm-9">
                    <a href="#" id="thumb-post-image" data-toggle="image" class="img-thumbnail">
                      <img src="<?php echo $setting['post']['image_thumb']; ?>" alt="" title="" data-placeholder="<?php echo $no_image; ?>" >
                    </a>
                    <input type="hidden" name="<?php echo $module_setting; ?>[image]" value="<?php echo $setting['post']['image']; ?>" id="input-post-image" >
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_category; ?></label>
                  <div class="col-sm-9">
                    <div class="well well-sm isl-well col-md-9" style="max-height:220px;">
                      <table class="table table-striped table-hover table-condensed isl-m0">
                        <thead>
                          <tr>
                            <td class="isl-w-s text-center"><?php echo $entry_canonical; ?></td>
                            <td><?php echo $entry_categories; ?></td>
                          </tr>
                        </thead>
                        <tbody>
                          <tr>
                            <td class="isl-w-s text-center">
                              <label><input type="radio" name="<?php echo $module_setting; ?>[category_id]" value="0" <?php echo !$setting['post']['category_id'] ? 'checked' : ''; ?>></label>
                            </td>
                            <td>
                              <label>
                                <?php echo $text_none; ?>
                              </label>
                            </td>
                          </tr>
                          <?php foreach ($categories as $category) { ?>
                            <tr>
                              <td class="isl-w-s text-center">
                                <label><input type="radio" name="<?php echo $module_setting; ?>[category_id]" value="<?php echo $category['category_id']; ?>" <?php echo $setting['post']['category_id'] == $category['category_id'] ? 'checked' : ''; ?>></label>
                              </td>
                              <td>
                                <label>
                                  <input type="checkbox" name="<?php echo $module_setting; ?>[categories][]" value="<?php echo $category['category_id']; ?>" <?php echo in_array($category['category_id'], $setting['post']['categories']) ? 'checked' : ''; ?>>
                                  <?php echo $category['path_html']; ?>
                                </label>
                              </td>
                            </tr>
                          <?php } ?>
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">Related Post</label>
                  <div class="col-sm-6">
                    <select name="<?php echo $module_setting; ?>[meta][related_post]" class="form-control" data-isl-toggle='{"target":"related_post_custom"}'>
                      <option value="0" <?php echo !$setting['post']['meta']['related_post'] ? 'selected="selected"' : ''; ?>><?php echo $text_disabled; ?></option>
                      <option value="tags" <?php echo $setting['post']['meta']['related_post'] == 'tags' ? 'selected="selected"' : ''; ?>><?php echo $text_by_post_tags; ?></option>
                      <option value="custom" <?php echo $setting['post']['meta']['related_post'] == 'custom' ? 'selected="selected"' : ''; ?>><?php echo $text_custom_select; ?></option>
                    </select>

                    <div class="related_post_custom related_post_custom_v_custom isl-mt-10" style="<?php echo $setting['post']['meta']['related_post'] != 'custom' ? 'display:none;' : ''; ?>">
                      <input type="text" placeholder="Type post title" data-isl-autocomplete='{"type":"post", "target":"isl-autocomplete-post", "name":"<?php echo $module_setting; ?>[meta][related_post_items][]", "route":"<?php echo $islConfig['path']; ?>"}' class="form-control">
                      <div class="well well-sm isl-well isl-autocomplete-post">
                        <?php foreach ($related_post_items as $post) { ?>
                          <div class="isl-autocomplete-post<?php echo $post['post_id']; ?>"><i class="fa fa-minus-circle pointer"></i> <?php echo $post['title']; ?><input type="hidden" name="<?php echo $module_setting; ?>[meta][related_post_items][]" value="<?php echo $post['post_id']; ?>"></div>
                        <?php } ?>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">Related Product</label>
                  <div class="col-sm-6">
                    <input type="text" placeholder="Type product name" data-isl-autocomplete='{"type":"product", "target":"isl-autocomplete-product", "name":"<?php echo $module_setting; ?>[meta][related_product_items][]"}' class="form-control">
                    <div class="well well-sm isl-well isl-autocomplete-product">
                      <?php foreach ($related_product_items as $product) { ?>
                        <div class="isl-autocomplete-product<?php echo $product['product_id']; ?>"><i class="fa fa-minus-circle pointer"></i> <?php echo $product['name']; ?><input type="hidden" name="<?php echo $module_setting; ?>[meta][related_product_items][]" value="<?php echo $product['product_id']; ?>"></div>
                      <?php } ?>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_publish; ?></label>
                  <div class="col-sm-6 col-md-4">
                    <div class="input-group date">
                      <input type="text" name="<?php echo $module_setting; ?>[publish]" value="<?php echo date('Y-m-d', strtotime($setting['post']['publish'])); ?>" data-date-format="YYYY-MM-DD" class="form-control">
                      <span class="input-group-btn">
                        <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
                      </span>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_unpublish; ?></label>
                  <div class="col-sm-6 col-md-4">
                    <div class="input-group date">
                      <input type="text" id="unpublish-post" name="<?php echo $module_setting; ?>[unpublish]" value="<?php echo $setting['post']['unpublish'] ? date('Y-m-d', strtotime($setting['post']['unpublish'])) : ''; ?>" data-date-format="YYYY-MM-DD" class="form-control">
                      <a onclick="$('#unpublish-post').val('')" class="pointer text-muted" data-toggle="tooltip" title="Clear date" style="position:absolute;right:-15px;top:.5em;"><i class="fa fa-close"></i></a>
                      <span class="input-group-btn">
                        <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
                      </span>
                    </div>
                  </div>
                </div>
                <!--
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_sort_order; ?></label>
                  <div class="col-sm-6 col-md-3">
                    <input type="number" name="<?php echo $module_setting; ?>[sort_order]" value="<?php echo $setting['post']['sort_order']; ?>" min="0" class="form-control isl-w-s isl-inline-block">
                    <i class="fa fa-question-circle text-primary isl-ml-5" data-toggle="tooltip" title="Sort order 0 will be put in last order."></i>
                  </div>
                </div>
                -->
                <div class="form-group">
                  <label class="col-sm-3 control-label"><?php echo $entry_status; ?></label>
                  <div class="col-sm-6 col-md-3">
                    <select name="<?php echo $module_setting; ?>[status]" class="form-control">
                      <option value="1" <?php echo $setting['post']['status'] == '1' ? 'selected="selected"' : ''; ?>><?php echo $text_publish; ?></option>
                      <option value="0" <?php echo $setting['post']['status'] != '1' ? 'selected="selected"' : ''; ?>><?php echo $text_draft; ?></option>
                    </select>
                  </div>
                </div>

              </div>
              <?php if (!empty($info_form_post_setting)) { ?>
              <div class="col-md-3">
                <div class="panel panel-default panel-info">
                  <div class="panel-heading"><?php echo $text_information; ?></div>
                  <div class="panel-body">
                    <ul class="isl-list">
                      <?php foreach ($info_form_post_setting as $info) { ?>
                        <li><?php echo $info ?></li>
                      <?php } ?>
                    </ul>
                  </div>
                </div>
              </div>
              <?php } ?>
            </div>


          </div> <!-- /.panel-body -->
        </form>
      </div>
    </div> <!-- /.page-content -->

  </div> <!-- /.container-fluid -->
</div>

<?php echo $footer; ?>
