<?php
defined('_JEXEC') or die('Restricted access');

?>
<!-- Php Show field Modal -->
<div class="modal fade" id="field-custom-order-by-modal" tabindex="-1" role="dialog" aria-labelledby="field-custom-order-by-modal-Label" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
          <?php //var_dump($layout->custom_field_mask_list); ?>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h4 class="modal-title" id="field-sql-show-select-Label"><?php echo cck_lang_text("COM_OS_CCK_LABEL_ORIGINAL_SELECT_MODAL")?></h4>
        
        <?php echo $original_select_order_by; ?>
        
        <div class="original_select_note">
            * In this query, order by, pagination, alphabetical and access values will also be added.
        </div>
      </div>
      <?php if($layout->type != 'add_instance'){ ?>  
      <div class="modal-header">
          <?php //var_dump($layout->custom_field_mask_list); ?>
        <!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>-->
        <h4 class="modal-title" id="field-custom-order-by-modal-Label"><?php echo cck_lang_text("COM_OS_CCK_LABEL_MAIL_FIELD_MODAL")?></h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <span class="col-lg-8"><label>Title</label></span>
          <!--<span class="col-lg-5"><label>Mask(without styles)</label></span>-->
          
          <span class="col-lg-4"><label>ID</label></span>
        </div>
          
        <?php
        //var_dump($layout->custom_field_mask_list);
        if(isset($layout->custom_field_mask_list)){
//            var_dump($layout->custom_field_mask_list);
          foreach ($layout->custom_field_mask_list as $key => $value) { 
              
            $lay_params = unserialize($layout->params);
            $prefix = (stripos($value->field_type, 'pricefield_') !== FALSE) ? 'price.' : 'instance.';
            $field_title = isset($lay_params['fields'][$value->title.'_alias'])?$lay_params['fields'][$value->title.'_alias']:'';?>
            <div id="field-custom-row-<?php echo $value->fid; ?>" class="row">
              <!--<span class="col-lg-5"><?php //echo $value->name; ?></span>-->
              <?php 
              if($entities_type[$value->fk_eid] == 'os_cck_entity'){
                  if(stripos($value->field_type, 'pricefield_') !== FALSE){ ?>
                      <span onclick="addMaskCustomOrderBy('(price.fk_fid=<?php echo $value->fid; ?> AND price.price_value= )');" class="col-lg-8 addMaskCustom">
                  <?php }elseif($value->title == 'cck_instance_id'){ ?>
                      <span onclick="addMaskCustomOrderBy('ei.eiid');" class="col-lg-8 addMaskCustom">
                  <?php }elseif($value->title == 'cck_number_of_views'){ ?>
                      <span onclick="addMaskCustomOrderBy('ei.hits');" class="col-lg-8 addMaskCustom">
                    <?php } else{ ?>
                      <span onclick="addMaskCustomOrderBy('<?php echo 'instance.'. $value->title; ?>');" class="col-lg-8 addMaskCustom">
                  <?php } ?>
                  
                    <?php echo $value->name; ?></span>

              <?php }elseif($entities_type[$value->fk_eid] == 'joomla_user'){ ?>
                  <span onclick="addMaskCustomOrderBy('<?php echo getWhereForSqlShowJoomlaUser($value->db_field_name); ?>');" class="col-lg-8 addMaskCustom"><?php echo $value->name; ?></span>
              <?php }elseif($entities_type[$value->fk_eid] == 'custom_sql'){ ?>
                  <span onclick="addMaskCustomOrderBy('<?php echo 't.'. $value->fid; ?>');" class="col-lg-8 addMaskCustom"><?php echo $value->name; ?></span>
              <?php } ?>
                  <span class="col-lg-4"><?php echo $value->fid; ?></span>
              
            </div>
            <?php
          } 
        }  
        ?>
      </div>
      <?php } ?>
    </div>
  </div>
</div>
<!-- CustomCode field Modal -->