<?php
defined('_JEXEC') or die('Restricted access');
?>
<!-- CustomCode field Modal -->
<div class="modal fade" id="field-custom-modal" tabindex="-1" role="dialog" aria-labelledby="field-custom-modal-Label" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h4 class="modal-title" id="field-custom-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-3"><label>Title</label></span>
          <span class="col-lg-3"><label>Mask(without styles) <i title="<?php echo cck_lang_text("COM_OS_CCK_LABEL_MASK_WITHOUT_STYLE_DESC")?>" class="glyphicon glyphicon-info-sign date_tooltip"></i></label></span>
          <span class="col-lg-3"><label>Mask(with styles) <i title="<?php echo cck_lang_text("COM_OS_CCK_LABEL_MASK_WITH_STYLE_DESC")?>" class="glyphicon glyphicon-info-sign date_tooltip"></i></label></span>
          <span class="col-lg-3"><label>ID</label></span>
        </div>

        <?php
//        var_dump($layout->enteties);
//        var_dump($layout_params['child_entities']);
        
        if(isset($layout->custom_field_mask_list)){
          foreach ($layout->custom_field_mask_list as $key => $value) { ?>
           <?php $lay_params = unserialize($layout->params);
            $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-3"><?php echo !empty($field_title)?$field_title:$value->title; ?></span>
              <span onclick="addMaskCustom('<?php echo $value->mask; ?>');" class="col-lg-3 addMaskCustom">
                <?php echo $value->mask; ?></span>
              <span onclick="addMaskCustom('<?php echo '{|f-'.$value->fid.'|}'; ?>');" class="col-lg-3 addMaskCustom">
                <?php echo '{|f-'.$value->fid.'|}'; ?></span>
              <span class="col-lg-3"><?php echo $value->fid; ?></span>
            </div>
            <?php
          } 
          foreach ($layout_params['child_entities'] as $child_entities) { ?>
           <?php $lay_params = unserialize($layout->params);
//            var_dump($layout_params['fields'][$child_entities->data_field_name.'_alias']);
            $field_title = $layout->enteties[$child_entities->childEntityId]->name . ' - ' . $layout_params['fields'][$child_entities->data_field_name.'_alias'];?>
            <div id="field-custom-row-<?php echo $child_entities->childEntityId; ?>" class="row">
              <span class="col-lg-3"><?php echo $field_title; ?></span>
              <span onclick="addMaskCustom('<?php echo '{|f-'.$child_entities->data_field_name.'|}'; ?>');" class="col-lg-3 addMaskCustom">
                <?php echo '{|f-'.$child_entities->data_field_name.'|}'; ?></span>
              <span onclick="addMaskCustom('<?php echo '{|'.$child_entities->data_field_name.'|}'; ?>');" class="col-lg-3 addMaskCustom">
                <?php echo '{|'.$child_entities->data_field_name.'|}'; ?></span>
              <span class="col-lg-3"><?php echo $child_entities->data_field_name; ?></span>
            </div>
            <?php
          } 
        }  
        ?>
      </div>
    </div>
  </div>
</div>
<!-- CustomCode field Modal -->