public function update_db()
 {
     global $wpdb;
     $id = isset($_POST['current_id']) ? (int) esc_html(stripslashes($_POST['current_id'])) : 0;
     $title = isset($_POST['title']) ? esc_html(stripslashes($_POST['title'])) : '';
     $css = isset($_POST['css']) ? stripslashes(preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", $_POST['css'])) : '';
     $default = isset($_POST['default']) ? esc_html(stripslashes($_POST['default'])) : 0;
     $save = $wpdb->update($wpdb->prefix . 'formmaker_themes', array('title' => $title, 'css' => $css, 'default' => $default), array('id' => $id));
     if ($save !== FALSE) {
         echo WDW_FMC_Library::message('Item Succesfully Saved.', 'updated');
     } else {
         echo WDW_FMC_Library::message('Error. Please install plugin again.', 'error');
     }
 }
 public function delete_all()
 {
     global $wpdb;
     $flag = FALSE;
     $isDefault = FALSE;
     $form_ids_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'formmaker');
     foreach ($form_ids_col as $form_id) {
         if (isset($_POST['check_' . $form_id])) {
             $flag = TRUE;
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $form_id));
             $arr = explode(',', get_option('contact_form_forms'));
             $arr = array_diff($arr, array((int) $form_id));
             $arr = implode(',', $arr);
             update_option('contact_form_forms', $arr);
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_views WHERE form_id="%d"', $form_id));
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_submits WHERE form_id="%d"', $form_id));
         }
     }
     if ($flag) {
         $message = 5;
     } else {
         $message = 6;
     }
     // $this->display();
     $page = WDW_FMC_Library::get('page');
     WDW_FMC_Library::spider_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
 }
    public function display()
    {
        $rows_data = $this->model->get_rows_data();
        $page_nav = $this->model->page_nav();
        $search_value = isset($_POST['search_value']) ? esc_html($_POST['search_value']) : '';
        $search_select_value = isset($_POST['search_select_value']) ? (int) $_POST['search_select_value'] : 0;
        $asc_or_desc = isset($_POST['asc_or_desc']) ? esc_html($_POST['asc_or_desc']) : 'asc';
        $order_by = isset($_POST['order_by']) ? esc_html($_POST['order_by']) : 'id';
        $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
        $ids_string = '';
        ?>
    <div style="clear: both; float: left; width: 99%;">
      <div style="float:left; font-size: 14px; font-weight: bold;">
        This section allows you to edit form themes.
        <a style="color: blue; text-decoration: none;" target="_blank" href="http://web-dorado.com/wordpress-form-maker-guide-2.html">Read More in User Manual</a>
      </div>
      <div style="float: right; text-align: right;">
        <a style="text-decoration: none;" target="_blank" href="http://web-dorado.com/files/fromContactForm.php">
          <img width="215" border="0" alt="web-dorado.com" src="<?php 
        echo WD_FMC_URL . '/images/wd_logo.png';
        ?>
" />
        </a>
      </div>
    </div>
    <form class="wrap" id="themes_form" method="post" action="admin.php?page=themes_fmc" style="float: left; width: 99%;">
      <?php 
        wp_nonce_field('nonce_fmc', 'nonce_fmc');
        ?>
      <span class="theme_icon"></span>
      <h2>
        Themes
        <a href="" class="add-new-h2" onclick="spider_set_input_value('task', 'add');
                                               spider_form_submit(event, 'themes_form')">Add new</a>
      </h2>
      <div class="buttons_div">
        <input class="button-secondary" type="submit" onclick="if (confirm('Do you want to delete selected items?')) {
                                                       spider_set_input_value('task', 'delete_all');
                                                     } else {
                                                       return false;
                                                     }" value="Delete" />
      </div>
      <div class="tablenav top">
        <?php 
        WDW_FMC_Library::search('Title', $search_value, 'themes_form');
        WDW_FMC_Library::html_page_nav($page_nav['total'], $page_nav['limit'], 'themes_form');
        ?>
      </div>
      <table class="wp-list-table widefat fixed pages">
        <thead>
          <th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" style="margin:0;"/></th>
          <th class="table_small_col <?php 
        if ($order_by == 'id') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
              spider_set_input_value('order_by', 'id');
              spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html($_POST['order_by']) == 'id' && esc_html($_POST['asc_or_desc']) == 'asc' ? 'desc' : 'asc';
        ?>
');
              spider_form_submit(event, 'themes_form')" href="">
              <span>ID</span><span class="sorting-indicator"></span></a>
          </th>
          <th class="<?php 
        if ($order_by == 'title') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
              spider_set_input_value('order_by', 'title');
              spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html($_POST['order_by']) == 'title' && esc_html($_POST['asc_or_desc']) == 'asc' ? 'desc' : 'asc';
        ?>
');
              spider_form_submit(event, 'themes_form')" href="">
              <span>Title</span><span class="sorting-indicator"></span></a>
          </th>
          <th class="table_big_col <?php 
        if ($order_by == 'default') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
              spider_set_input_value('order_by', 'default');
              spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html($_POST['order_by']) == 'default' && esc_html($_POST['asc_or_desc']) == 'asc' ? 'desc' : 'asc';
        ?>
');
              spider_form_submit(event, 'themes_form')" href="">
              <span>Default</span><span class="sorting-indicator"></span></a>
          </th>
          <th class="table_big_col">Edit</th>
          <th class="table_big_col">Delete</th>
        </thead>
        <tbody id="tbody_arr">
          <?php 
        if ($rows_data) {
            foreach ($rows_data as $row_data) {
                $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
                $default_image = $row_data->default ? 'default' : 'notdefault';
                $default = $row_data->default ? '' : 'setdefault';
                ?>
              <tr id="tr_<?php 
                echo $row_data->id;
                ?>
" <?php 
                echo $alternate;
                ?>
>
                <td class="table_small_col check-column">
                  <input id="check_<?php 
                echo $row_data->id;
                ?>
" name="check_<?php 
                echo $row_data->id;
                ?>
" type="checkbox"/>
                </td>
                <td class="table_small_col"><?php 
                echo $row_data->id;
                ?>
</td>
                <td>
                  <a onclick="spider_set_input_value('task', 'edit');
                              spider_set_input_value('current_id', '<?php 
                echo $row_data->id;
                ?>
');
                              spider_form_submit(event, 'themes_form')" href="" title="Edit"><?php 
                echo $row_data->title;
                ?>
</a>
                </td>
                <td class="table_big_col">
                  <?php 
                if ($default != '') {
                    ?>
                    <a onclick="spider_set_input_value('task', '<?php 
                    echo $default;
                    ?>
');
                                spider_set_input_value('current_id', '<?php 
                    echo $row_data->id;
                    ?>
');
                                spider_form_submit(event, 'themes_form')" href="">
                    <?php 
                }
                ?>
                  <img src="<?php 
                echo WD_FMC_URL . '/images/' . $default_image . '.png';
                ?>
" />
                  <?php 
                if ($default != '') {
                    ?>
                    </a>
                    <?php 
                }
                ?>
                </td>
                <td class="table_big_col">
                  <a onclick="spider_set_input_value('task', 'edit');
                              spider_set_input_value('current_id', '<?php 
                echo $row_data->id;
                ?>
');
                              spider_form_submit(event, 'themes_form')" href="">Edit</a>
                </td>
                <td class="table_big_col">
                  <a onclick="spider_set_input_value('task', 'delete');
                              spider_set_input_value('current_id', '<?php 
                echo $row_data->id;
                ?>
');
                              spider_form_submit(event, 'themes_form')" href="">Delete</a>
                </td>
              </tr>
              <?php 
                $ids_string .= $row_data->id . ',';
            }
        }
        ?>
        </tbody>
      </table>
      <input id="task" name="task" type="hidden" value=""/>
      <input id="current_id" name="current_id" type="hidden" value=""/>
      <input id="ids_string" name="ids_string" type="hidden" value="<?php 
        echo $ids_string;
        ?>
"/>
      <input id="asc_or_desc" name="asc_or_desc" type="hidden" value="asc"/>
      <input id="order_by" name="order_by" type="hidden" value="<?php 
        echo $order_by;
        ?>
"/>
    </form>
    <?php 
    }
    public function display()
    {
        $rows_data = $this->model->get_rows_data();
        $page_nav = $this->model->page_nav();
        $search_value = isset($_POST['search_value']) ? esc_html(stripslashes($_POST['search_value'])) : '';
        $asc_or_desc = isset($_POST['asc_or_desc']) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'desc';
        $order_by = isset($_POST['order_by']) ? esc_html(stripslashes($_POST['order_by'])) : 'id';
        $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
        $ids_string = '';
        ?>
    <div id="fm_blocked_ips_message" style="width: 99%; display: none;"></div>
    <div style="clear: both; float: left; width: 99%;">
      <div style="float:left; font-size: 14px; font-weight: bold;">
        This section allows you to block IPs.
        <a style="color: blue; text-decoration: none;" target="_blank" href="http://web-dorado.com/wordpress-form-maker-guide-2.html">Read More in User Manual</a>
      </div>
      <div style="float: right; text-align: right;">
        <a style="text-decoration: none;" target="_blank" href="http://web-dorado.com/files/fromContactForm.php">
          <img width="215" border="0" alt="web-dorado.com" src="<?php 
        echo WD_FMC_URL . '/images/wd_logo.png';
        ?>
" />
        </a>
      </div>
    </div>
    <form onkeypress="spider_doNothing(event)" class="wrap" id="blocked_ips" method="post" action="admin.php?page=blocked_ips_fmc" style="float: left; width: 99%;">
      <?php 
        wp_nonce_field('nonce_fmc', 'nonce_fmc');
        ?>
      <span class="block_icon"></span>
      <h2>Blocked IPs</h2>
      <div class="buttons_div">
        <input class="button-primary" type="submit" value="Save" onclick="spider_set_input_value('task', 'save_all');" />
        <input class="button-secondary" type="submit" value="Delete" onclick="if (confirm('Do you want to unblock selected IPs?')) {
                                                                      spider_set_input_value('task', 'delete_all');
                                                                    } else {
                                                                      return false;
                                                                    }" />
      </div>
      <div class="tablenav top">
        <?php 
        WDW_FMC_Library::search('IP', $search_value, 'blocked_ips');
        WDW_FMC_Library::html_page_nav($page_nav['total'], $page_nav['limit'], 'blocked_ips');
        ?>
      </div>
      <table class="wp-list-table widefat fixed pages">
        <thead>
          <tr>
            <th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" style="margin: 0;" /></th>
            <th class="table_small_col <?php 
        if ($order_by == 'id') {
            echo $order_class;
        }
        ?>
">
              <a onclick="spider_set_input_value('task', '');
                          spider_set_input_value('order_by', 'id');
                          spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'id' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                          spider_form_submit(event, 'blocked_ips')" href="">
                <span>ID</span><span class="sorting-indicator"></span></th>
              </a>
            <th class="<?php 
        if ($order_by == 'ip') {
            echo $order_class;
        }
        ?>
">
              <a onclick="spider_set_input_value('task', '');
                          spider_set_input_value('order_by', 'ip');
                          spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'ip' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                          spider_form_submit(event, 'blocked_ips')" href="">
                <span>IP</span><span class="sorting-indicator"></span>
              </a>
            </th>
            <th class="table_big_col">Edit</th>
            <th class="table_big_col">Delete</th>
          </tr>		  
          <tr id="tr">
            <th></th>
            <th></th>
            <th class="edit_input"><input type="text" class="input_th" id="ip" name="ip" onkeypress="return spider_check_isnum(event)"></th>
            <th class="table_big_col">
              <a class="add_tag_th button-primary button button-small" onclick="if (spider_check_required('ip', 'IP')) {return false;}
                                                                                spider_set_input_value('task', 'save');
                                                                                spider_set_input_value('current_id', '');
                                                                                spider_form_submit(event, 'blocked_ips')" href="">Add IP</a>
            </th>
            <th></th>
          </tr>
        </thead>
        <tbody id="tbody_arr">
          <?php 
        if ($rows_data) {
            foreach ($rows_data as $row_data) {
                $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
                ?>
              <tr id="tr_<?php 
                echo $row_data->id;
                ?>
" <?php 
                echo $alternate;
                ?>
>
                <td class="table_small_col check-column" id="td_check_<?php 
                echo $row_data->id;
                ?>
" >
                  <input id="check_<?php 
                echo $row_data->id;
                ?>
" name="check_<?php 
                echo $row_data->id;
                ?>
" type="checkbox" />
                </td>
                <td class="table_small_col" id="td_id_<?php 
                echo $row_data->id;
                ?>
" ><?php 
                echo $row_data->id;
                ?>
</td>
                <td id="td_ip_<?php 
                echo $row_data->id;
                ?>
" >
                  <a class="pointer" id="ip<?php 
                echo $row_data->id;
                ?>
"
                     onclick="spider_edit_ip(<?php 
                echo $row_data->id;
                ?>
)" 
                     title="Edit"><?php 
                echo $row_data->ip;
                ?>
</a>
                </td>
                <td class="table_big_col" id="td_edit_<?php 
                echo $row_data->id;
                ?>
">
                  <a onclick="spider_edit_ip(<?php 
                echo $row_data->id;
                ?>
)">Edit</a>
                </td>
                <td class="table_big_col" id="td_delete_<?php 
                echo $row_data->id;
                ?>
">
                  <a onclick="spider_set_input_value('task', 'delete');
                              spider_set_input_value('current_id', <?php 
                echo $row_data->id;
                ?>
);
                              spider_form_submit(event, 'blocked_ips')" href="">Delete</a>
                </td>
              </tr>
              <?php 
                $ids_string .= $row_data->id . ',';
            }
        }
        ?>
        </tbody>
      </table>
      <input id="task" name="task" type="hidden" value="" />
      <input id="current_id" name="current_id" type="hidden" value="" />
      <input id="ids_string" name="ids_string" type="hidden" value="<?php 
        echo $ids_string;
        ?>
" />
      <input id="asc_or_desc" name="asc_or_desc" type="hidden" value="<?php 
        echo $asc_or_desc;
        ?>
" />
      <input id="order_by" name="order_by" type="hidden" value="<?php 
        echo $order_by;
        ?>
" />
    </form>
    <?php 
    }
function form_maker_ajax_cfm()
{
    require_once WD_FMC_DIR . '/framework/WDW_FMC_Library.php';
    $page = WDW_FMC_Library::get('action');
    if ($page != 'formcontactwdcaptcha') {
        if (function_exists('current_user_can')) {
            if (!current_user_can('manage_options')) {
                die('Access Denied');
            }
        } else {
            die('Access Denied');
        }
    }
    if ($page != '') {
        require_once WD_FMC_DIR . '/admin/controllers/FMController' . ucfirst($page) . '.php';
        $controller_class = 'FMController' . ucfirst($page);
        $controller = new $controller_class();
        $controller->execute();
    }
}
 public function setdefault($id)
 {
     global $wpdb;
     $wpdb->update($wpdb->prefix . 'formmaker_themes', array('default' => 0), array('default' => 1));
     $save = $wpdb->update($wpdb->prefix . 'formmaker_themes', array('default' => 1), array('id' => $id));
     if ($save !== FALSE) {
         $message = 7;
     } else {
         $message = 2;
     }
     // $this->display();
     $page = WDW_FMC_Library::get('page');
     WDW_FMC_Library::spider_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
 }
    public function form_options($id)
    {
        $row = $this->model->get_row_data($id);
        $themes = $this->model->get_theme_rows_data();
        $queries = $this->model->get_queries_rows_data($id);
        $userGroups = get_editable_roles();
        $page_title = $row->title . ' form options';
        $label_id = array();
        $label_label = array();
        $label_type = array();
        $label_all = explode('#****#', $row->label_order_current);
        $label_all = array_slice($label_all, 0, count($label_all) - 1);
        foreach ($label_all as $key => $label_each) {
            $label_id_each = explode('#**id**#', $label_each);
            array_push($label_id, $label_id_each[0]);
            $label_order_each = explode('#**label**#', $label_id_each[1]);
            array_push($label_label, $label_order_each[0]);
            array_push($label_type, $label_order_each[1]);
        }
        $fields = explode('*:*id*:*type_submitter_mail*:*type*:*', $row->form_fields);
        $fields_count = count($fields);
        ?>
    <script>
      gen = "<?php 
        echo $row->counter;
        ?>
";
      form_view_max = 20;
      function set_preview() {
        jQuery("#preview_form").attr("href", '<?php 
        echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php'));
        ?>
&test_theme=' + jQuery("#theme").val() + '&width=1000&height=500&TB_iframe=1');
        jQuery("#edit_css").attr("href", '<?php 
        echo add_query_arg(array('action' => 'FormMakerEditCSS_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php'));
        ?>
&id=' + jQuery("#theme").val() + '&width=800&height=500&TB_iframe=1');
      }
      function set_condition() {
        field_condition ='';
	
        for(i=0;i<100;i++)
        {
          conditions = '';
          if(document.getElementById("condition"+i))
          {
            field_condition+=document.getElementById("show_hide"+i).value+"*:*show_hide*:*";
            field_condition+=document.getElementById("fields"+i).value+"*:*field_label*:*";
            field_condition+=document.getElementById("all_any"+i).value+"*:*all_any*:*";
            
            for(k=0;k<100;k++)
            {
              if(document.getElementById("condition_div"+i+"_"+k))
              {
                conditions+=document.getElementById("field_labels"+i+"_"+k).value+"***";
                conditions+=document.getElementById("is_select"+i+"_"+k).value+"***";
                if(document.getElementById("field_value"+i+"_"+k).tagName=="SELECT" && document.getElementById("field_value"+i+"_"+k).getAttribute('multiple'))
                {
                  var sel = document.getElementById("field_value"+i+"_"+k);
                  var selValues = '';
                  for(m=0; m < sel.length; m++)
                  {
                    if(sel.options[m].selected)
                    {
                      selValues += sel.options[m].value+"@@@";
                    }
                  }
                conditions+=selValues;
                }
                else
                conditions+=document.getElementById("field_value"+i+"_"+k).value;
                conditions+="*:*next_condition*:*";
              }
            }
            
            field_condition+=conditions;
            field_condition+="*:*new_condition*:*";
            
          }
        }
        document.getElementById('condition').value = field_condition;
      }      
    </script>
    <style>
    .CodeMirror {
      border: 1px solid #ccc;
      font-size: 12px;
      margin-bottom: 6px;
      background: white;
    }
    </style>
    <div style="clear: both; float: left; width: 99%;">
      <div style="float:left; font-size: 14px; font-weight: bold;">
        This section allows you to edit form options.
        <a style="color: blue; text-decoration: none;" target="_blank" href="http://web-dorado.com/wordpress-form-maker-guide-3.html">Read More in User Manual</a>
      </div>
      <div style="float: right; text-align: right;">
        <a style="text-decoration: none;" target="_blank" href="http://web-dorado.com/files/fromContactForm.php">
          <img width="215" border="0" alt="web-dorado.com" src="<?php 
        echo WD_FMC_URL . '/images/wd_logo.png';
        ?>
" />
        </a>
      </div>
    </div>
    <form class="wrap" method="post" action="admin.php?page=manage_fmc" style="float: left; width: 99%;" name="adminForm" id="adminForm">
      <?php 
        wp_nonce_field('nonce_fmc', 'nonce_fmc');
        ?>
      <h2><?php 
        echo $page_title;
        ?>
</h2>
      <div style="float: right; margin: 0 5px 0 0;">
        <input class="button-secondary" type="submit" onclick="if (spider_check_email('mailToAdd') ||
                                                                   spider_check_email('from_mail') ||
                                                                   spider_check_email('reply_to') ||
                                                                   spider_check_email('mail_from_user') ||
                                                                   spider_check_email('reply_to_user') ||
                                                                   spider_check_email('mail_from_other') ||
                                                                   spider_check_email('reply_to_other') ||
                                                                   spider_check_email('paypal_email')) {return false;}; set_condition(); spider_set_input_value('task', 'save_options')" value="Save"/>
        <input class="button-secondary" type="submit" onclick="if (spider_check_email('mailToAdd') ||
                                                                   spider_check_email('from_mail') ||
                                                                   spider_check_email('reply_to') ||
                                                                   spider_check_email('mail_from_user') ||
                                                                   spider_check_email('reply_to_user') ||
                                                                   spider_check_email('mail_from_other') ||
                                                                   spider_check_email('reply_to_other') ||
                                                                   spider_check_email('paypal_email')) {return false;}; set_condition(); spider_set_input_value('task', 'apply_options')" value="Apply"/>
        <input class="button-secondary" type="submit" onclick="spider_set_input_value('task', 'cancel_options')" value="Cancel"/>
      </div>
      <div class="submenu-box" style="width: 99%; float: left; margin: 15px 0 0 0;">
        <div class="submenu-pad">
          <ul id="submenu" class="configuration">
            <li>
              <a id="general" class="fm_fieldset_tab" onclick="form_maker_options_tabs('general')" href="#">General Options</a>
            </li>
            <li>
              <a id="custom" class="fm_fieldset_tab" onclick="form_maker_options_tabs('custom')" href="#">Email Options</a>
            </li>
            <li>
              <a id="actions" class="fm_fieldset_tab" onclick="form_maker_options_tabs('actions')" href="#">Actions after Submission</a>
            </li>
            <li>
              <a id="payment" class="fm_fieldset_tab" onclick="form_maker_options_tabs('payment')" href="#">Payment Options</a>
            </li>
            <li>
              <a id="javascript" class="fm_fieldset_tab" onclick="form_maker_options_tabs('javascript'); codemirror_for_javascript();" href="#">JavaScript</a>
            </li>
            <li>
              <a id="conditions" class="fm_fieldset_tab" onclick="form_maker_options_tabs('conditions')" href="#">Conditional Fields</a>
            </li>
          </ul>
        </div>
      </div>
      <fieldset id="general_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">General Options</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label>Published</label>
            </td>
            <td class="fm_options_value">
              <input type="radio" name="published" id="published_yes" value="1" <?php 
        echo $row->published ? "checked" : "";
        ?>
 /><label for="published_yes">Yes</label>
              <input type="radio" name="published" id="published_no" value="0" <?php 
        echo !$row->published ? "checked" : "";
        ?>
 /><label for="published_no">No</label>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label>Save data(to database)</label>
            </td>
            <td class="fm_options_value">
              <input type="radio" name="savedb" id="savedb_yes" value="1" <?php 
        echo $row->savedb ? "checked" : "";
        ?>
 /><label for="savedb_yes">Yes</label>
              <input type="radio" name="savedb" id="savedb_no" value="0" <?php 
        echo !$row->savedb ? "checked" : "";
        ?>
 /><label for="savedb_no">No</label>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="theme">Theme</label>
            </td>
            <td class="fm_options_value">
              <select id="theme" name="theme" style="width:260px;" onChange="set_preview()">
                <?php 
        foreach ($themes as $theme) {
            ?>
                  <option value="<?php 
            echo $theme->id;
            ?>
" <?php 
            echo $theme->id == $row->theme ? 'selected' : '';
            ?>
><?php 
            echo $theme->title;
            ?>
</option>
                  <?php 
        }
        ?>
              </select>
              <a href="<?php 
        echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id, 'test_theme' => $row->theme, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
        ?>
" class="button-primary thickbox thickbox-preview" id="preview_form" title="Form Preview" onclick="return false;">
                Preview
              </a>
              <a href="<?php 
        echo add_query_arg(array('action' => 'FormMakerEditCSS_fmc', 'id' => $row->theme, 'form_id' => $row->id, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
        ?>
" class="button-secondary thickbox thickbox-preview" id="edit_css" title="Edit CSS" onclick="return false;">
                Edit CSS
              </a>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="requiredmark">Required fields mark</label>
            </td>
            <td class="fm_options_value">
              <input type="text" id="requiredmark" name="requiredmark" value="<?php 
        echo $row->requiredmark;
        ?>
" style="width:250px;" />
            </td>
          </tr>
        </table>
        <div class="error_cfm" style="padding: 5px; font-size: 14px;">Front end submissions are disabled in free version.</div>
        <fieldset class="adminform">
          <legend style="color:#0B55C4;font-weight: bold;">Front end submissions access level</legend>
          <table>
            <tr>
              <td class="key">
                <label for="name">
                  Allow User to see submissions:
                </label>
              </td>
              <td>
                <?php 
        $checked_UserGroup = explode(',', $row->user_id_wd);
        $i = 0;
        foreach ($userGroups as $val => $uG) {
            echo '<input disabled="disabled" type="checkbox" value="' . $val . '"  id="user_' . $i . '"';
            if (in_array($val, $checked_UserGroup)) {
                echo 'checked="checked"';
            }
            echo 'onchange="acces_level(' . count($userGroups) . ')"/><label for="user_' . $i . '">' . $uG["name"] . '</label><br>';
            $i++;
        }
        ?>
                <input disabled="disabled" type="checkbox" value="guest"  id="user_<?php 
        echo $i;
        ?>
" onchange="acces_level(<?php 
        echo count($userGroups);
        ?>
)"<?php 
        echo in_array('guest', $checked_UserGroup) ? 'checked="checked"' : '';
        ?>
/><label for="user_<?php 
        echo $i;
        ?>
">Guest</label>
                <input disabled="disabled" type="hidden" name="user_id_wd" value="<?php 
        echo $row->user_id_wd;
        ?>
" id="user_id_wd" />
              </td>
            </tr>              
          </table>
        </fieldset>
        <?php 
        $labels_for_submissions = $this->model->get_labels($id);
        $payment_info = $this->model->is_paypal($id);
        $labels_id_for_submissions = array();
        $label_titles_for_submissions = array();
        $labels_type_for_submissions = array();
        if ($labels_for_submissions) {
            $label_id_for_submissions = array();
            $label_order_original_for_submissions = array();
            $label_type_for_submissions = array();
            if (strpos($row->label_order, 'type_paypal_')) {
                $row->label_order = $row->label_order . "item_total#**id**#Item Total#**label**#type_paypal_payment_total#****#total#**id**#Total#**label**#type_paypal_payment_total#****#0#**id**#Payment Status#**label**#type_paypal_payment_status#****#";
            }
            $label_all_for_submissions = explode('#****#', $row->label_order);
            $label_all_for_submissions = array_slice($label_all_for_submissions, 0, count($label_all_for_submissions) - 1);
            foreach ($label_all_for_submissions as $key => $label_each) {
                $label_id_each = explode('#**id**#', $label_each);
                array_push($label_id_for_submissions, $label_id_each[0]);
                $label_order_each = explode('#**label**#', $label_id_each[1]);
                array_push($label_order_original_for_submissions, $label_order_each[0]);
                array_push($label_type_for_submissions, $label_order_each[1]);
            }
            foreach ($label_id_for_submissions as $key => $label) {
                if (in_array($label, $labels_for_submissions)) {
                    array_push($labels_type_for_submissions, $label_type_for_submissions[$key]);
                    array_push($labels_id_for_submissions, $label);
                    array_push($label_titles_for_submissions, $label_order_original_for_submissions[$key]);
                }
            }
        }
        $stats_labels = array();
        $stats_labels_ids = array();
        foreach ($labels_type_for_submissions as $key => $label_type_cur) {
            if ($label_type_cur == "type_checkbox" || $label_type_cur == "type_radio" || $label_type_cur == "type_own_select" || $label_type_cur == "type_country" || $label_type_cur == "type_paypal_select" || $label_type_cur == "type_paypal_radio" || $label_type_cur == "type_paypal_checkbox" || $label_type_cur == "type_paypal_shipping") {
                $stats_labels_ids[] = $labels_id_for_submissions[$key];
                $stats_labels[] = $label_titles_for_submissions[$key];
            }
        }
        ?>
        <script type="text/javascript">
          function inArray(needle, myarray) {
            var length = myarray.length;
            for(var i = 0; i < length; i++) {
                if(myarray[i] == needle) return true;
            }
            return false;
          }

          function checked_labels(class_name) {
            var checked_ids ='';            
            jQuery('.'+class_name).each(function() {
              if(this.checked) {
                checked_ids += this.value+',';		
              }
            });              
            if(class_name == 'filed_label') {
              document.getElementById("frontend_submit_fields").value = checked_ids ;
              if(checked_ids == document.getElementById("all_fields").value)
                document.getElementById("all_fields").checked = true;
              else
                document.getElementById("all_fields").checked = false;
            }
            else {
              document.getElementById("frontend_submit_stat_fields").value = checked_ids ;
              if(checked_ids == document.getElementById("all_stats_fields").value)
                document.getElementById("all_stats_fields").checked = true;
              else
                document.getElementById("all_stats_fields").checked = false;
            }
          }
          
          jQuery(document).ready(function () {
            jQuery('.filed_label').each(function() {
              if(document.getElementById("frontend_submit_fields").value == document.getElementById("all_fields").value)
                document.getElementById("all_fields").checked = true;
              if(inArray(this.value, document.getElementById("frontend_submit_fields").value.split(","))) {
                this.checked = true;
              }
            });

            jQuery('.stats_filed_label').each(function() {
              if(document.getElementById("frontend_submit_stat_fields").value == document.getElementById("all_stats_fields").value)
                document.getElementById("all_stats_fields").checked = true;          
              if(inArray(this.value, document.getElementById("frontend_submit_stat_fields").value.split(","))) {
                this.checked = true;		
              }              
            });
              
            jQuery(document).on('change','input[name="all_fields"]',function() {
                jQuery('.filed_label').prop("checked" , this.checked);
            });

            jQuery(document).on('change','input[name="all_stats_fields"]',function() {
                jQuery('.stats_filed_label').prop("checked" , this.checked);
            });
          });
        </script>

        <style>
          li{
          list-style-type: none;
          }

          .simple_table
          {
          padding-left: 0px !important;
          }

          .simple_table input, .simple_table label, .simple_table img
          {
          display:inline-block !important;
          float:none !important;
          }
        </style>
        <fieldset class="adminform">
          <legend style="color:#0B55C4;font-weight: bold;">Fields to hide in frontend submissions</legend>
          <?php 
        if (count($label_titles_for_submissions)) {
            ?>
            <table style="margin-left:-3px;">
              <tr>
                <td> 
                  <label>Select fields:</label>
                </td>
                <td  class="simple_table">
                  <ul id="form_fields">
                    <li>
                    <input disabled="disabled" type="checkbox" name="all_fields" id="all_fields" value="submit_id,<?php 
            echo implode(',', $labels_id_for_submissions) . "," . ($payment_info ? "payment_info" : "");
            ?>
" onclick="checked_labels('filed_label')"/>
                    <label for="all_fields">Select All</label>
                    </li>
                    <?php 
            echo "<li><input disabled=\"disabled\" type=\"checkbox\" id=\"submit_id\" name=\"submit_id\" value=\"submit_id\" class=\"filed_label\"  onclick=\"checked_labels('filed_label')\"><label for=\"submit_id\">ID</label></li>";
            for ($i = 0, $n = count($label_titles_for_submissions); $i < $n; $i++) {
                $field_label = $label_titles_for_submissions[$i];
                echo "<li><input disabled=\"disabled\" type=\"checkbox\" id=\"filed_label" . $i . "\" name=\"filed_label" . $i . "\" value=\"" . $labels_id_for_submissions[$i] . "\" class=\"filed_label\" onclick=\"checked_labels('filed_label')\"><label for=\"filed_label" . $i . "\">" . (strlen($field_label) > 80 ? substr($field_label, 0, 80) . '...' : $field_label) . "</label></li>";
            }
            if ($payment_info) {
                echo "<li><input disabled=\"disabled\" type=\"checkbox\" id=\"payment_info\" name=\"payment_info\" value=\"payment_info\" class=\"filed_label\" onclick=\"checked_labels('filed_label')\"><label for=\"payment_info\">Payment Info</label></li>";
            }
            ?>
                  </ul>
                  <input type="hidden" name="frontend_submit_fields" value="<?php 
            echo $row->frontend_submit_fields;
            ?>
" id="frontend_submit_fields" />
                </td>	
              </tr>
              <?php 
            if ($stats_labels) {
                ?>
              <tr id="stats">
                <td> 
                  <label>Stats fields:</label>
                </td>
                <td class="simple_table">
                  <ul id="stats_fields">
                    <li>
                    <input disabled="disabled" type="checkbox" name="all_stats_fields" id="all_stats_fields" value="<?php 
                echo implode(',', $stats_labels_ids) . ",";
                ?>
" onclick="checked_labels('stats_filed_label')">
                    <label for="all_stats_fields">Select All</label>
                    </li>
                    <?php 
                for ($i = 0, $n = count($stats_labels); $i < $n; $i++) {
                    $field_label = $stats_labels[$i];
                    echo "<li><input disabled=\"disabled\" type=\"checkbox\" id=\"stats_filed_label" . $i . "\" name=\"stats_filed_label" . $i . "\" value=\"" . $stats_labels_ids[$i] . "\" class=\"stats_filed_label\" onclick=\"checked_labels('stats_filed_label')\" ><label for=\"stats_filed_label" . $i . "\">" . (strlen($field_label) > 80 ? substr($field_label, 0, 80) . '...' : $field_label) . "</label></li>";
                }
                ?>
                  </ul>
                  <input type="hidden" name="frontend_submit_stat_fields" value="<?php 
                echo $row->frontend_submit_stat_fields;
                ?>
" id="frontend_submit_stat_fields" />
                </td>	
              </tr>
              <?php 
            }
            ?>
            </table>
          <?php 
        }
        ?>
        </fieldset>
      </fieldset>
      <fieldset id="custom_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color: #0B55C4; font-weight: bold;">Email Options</legend>
        <table class="admintable">
          <tr valign="top">
            <td style="padding: 15px; width: 75px;">
              <label>Send E-mail</label>
            </td>
            <td style="padding: 15px;">
              <input type="radio" name="sendemail" id="sendemail_yes" value="1" <?php 
        echo $row->sendemail ? "checked" : "";
        ?>
 /><label for="sendemail_yes">Yes</label>
              <input type="radio" name="sendemail" id="sendemail_no" value="0" <?php 
        echo !$row->sendemail ? "checked" : "";
        ?>
 /><label for="sendemail_no">No</label>
            </td>
          </tr>
        </table>
        <fieldset class="fm_mail_options">
          <legend style="color:#0B55C4;font-weight: bold;">Email to Administrator</legend>
          <table class="admintable">
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mailToAdd">Email to send submissions to</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mailToAdd" name="mailToAdd" style="width: 250px;" />
                <input type="hidden" id="mail" name="mail" value="<?php 
        echo $row->mail . ($row->mail && substr($row->mail, -1) != ',' ? ',' : '');
        ?>
" />
                <img src="<?php 
        echo WD_FMC_URL . '/images/add.png';
        ?>
" 
				     style="vertical-align: middle; cursor: pointer;"
                     title="Add more emails"
                     onclick="if (spider_check_email('mailToAdd')) {return false;};cfm_create_input('mail', 'mailToAdd', 'cfm_mail_div', '<?php 
        echo WD_FMC_URL;
        ?>
')" />
                <div id="cfm_mail_div">
                  <?php 
        $mail_array = explode(',', $row->mail);
        foreach ($mail_array as $mail) {
            if ($mail && $mail != ',') {
                ?>
                      <div class="fm_mail_input">
                        <?php 
                echo $mail;
                ?>
                        <img src="<?php 
                echo WD_FMC_URL;
                ?>
/images/delete.png" class="fm_delete_img" onclick="fm_delete_mail(this, '<?php 
                echo $mail;
                ?>
')" title="Delete Email" />
                      </div>
                      <?php 
            }
        }
        ?>
                </div> 



				
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="from_mail">Email From</label>
              </td>
              <td class="fm_options_value">
                <!--<input id="from_mail" name="from_mail" value="<?php 
        echo $row->from_mail;
        ?>
" style="width:250px;" />-->
                <?php 
        $is_other = TRUE;
        for ($i = 0; $i < $fields_count - 1; $i++) {
            ?>
                  <div>
                    <input type="radio" name="from_mail" id="from_mail<?php 
            echo $i;
            ?>
" value="<?php 
            echo substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i]));
            ?>
"  <?php 
            echo substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) == $row->from_mail ? 'checked="checked"' : '';
            ?>
 onclick="wdhide('mail_from_other')" />
                    <label for="from_mail<?php 
            echo $i;
            ?>
"><?php 
            echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*'));
            ?>
</label>
                  </div>
                  <?php 
            if (substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) == $row->from_mail) {
                $is_other = FALSE;
            }
        }
        ?>
                <div style="<?php 
        echo $fields_count == 1 ? 'display:none;' : '';
        ?>
">
                  <input type="radio" id="other" name="from_mail" value="other" <?php 
        echo $is_other ? 'checked="checked"' : '';
        ?>
 onclick="wdshow('mail_from_other')" />
                  <label for="other">Other</label>
                </div>
								<input type="text" style="width: <?php 
        echo $fields_count == 1 ? '250px' : '235px; margin-left: 15px';
        ?>
; display: <?php 
        echo $is_other ? 'block;' : 'none;';
        ?>
" id="mail_from_other" name="mail_from_other" value="<?php 
        echo $is_other ? $row->from_mail : '';
        ?>
" />
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="from_name">From Name</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="from_name" name="from_name" value="<?php 
        echo $row->from_name;
        ?>
" style="width: 250px;" />
                <img src="<?php 
        echo WD_FMC_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_from_labels').style.display='block';" style="vertical-align: middle; cursor: pointer;display:inline-block; margin:0px; float:none;">
								<?php 
        $choise = "document.getElementById('from_name')";
        echo '<div style="position:relative; top:-3px;"><div id="mail_from_labels" class="email_labels" style="display:none;">';
        echo "<a onClick=\"insertAtCursor(" . $choise . ",'username'); document.getElementById('mail_from_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Username</a>";
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy" || $label_type[$i] == "type_matrix") {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = $param;
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            echo "<a onClick=\"insertAtCursor(" . $choise . ",'" . $param . "'); document.getElementById('mail_from_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">" . $fld_label . "</a>";
        }
        echo '</div></div>';
        ?>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="reply_to">Reply to<br/>(if different from "Email From") </label>
              </td>
              <td class="fm_options_value">
                <!--<input id="reply_to" name="reply_to" value="<?php 
        echo $row->reply_to;
        ?>
" style="width:250px;"/>-->
                <?php 
        $is_other = TRUE;
        for ($i = 0; $i < $fields_count - 1; $i++) {
            ?>
                  <div>
                    <input type="radio" name="reply_to" id="reply_to<?php 
            echo $i;
            ?>
" value="<?php 
            echo substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i]));
            ?>
"  <?php 
            echo substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) == $row->reply_to ? 'checked="checked"' : '';
            ?>
 onclick="wdhide('reply_to_other')" />
                    <label for="reply_to<?php 
            echo $i;
            ?>
"><?php 
            echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*'));
            ?>
</label>
                  </div>
                  <?php 
            if (substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) == $row->reply_to) {
                $is_other = FALSE;
            }
        }
        ?>
								<div style="<?php 
        echo $fields_count == 1 ? 'display: none;' : '';
        ?>
">
                  <input type="radio" id="other1" name="reply_to" value="other" <?php 
        echo $is_other ? 'checked="checked"' : '';
        ?>
 onclick="wdshow('reply_to_other')" />
                  <label for="other1">Other</label>
                </div>
								<input type="text" style="width: <?php 
        echo $fields_count == 1 ? '250px' : '235px; margin-left: 15px';
        ?>
; display: <?php 
        echo $is_other ? 'block;' : 'none;';
        ?>
" id="reply_to_other" name="reply_to_other" value="<?php 
        echo $is_other && $row->reply_to ? $row->reply_to : '';
        ?>
" />
              </td>
            </tr>
            <tr valign="top">
							<td class="fm_options_label">
								<label> CC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_cc" name="mail_cc" value="<?php 
        echo $row->mail_cc;
        ?>
" style="width:250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label> BCC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_bcc" name="mail_bcc" value="<?php 
        echo $row->mail_bcc;
        ?>
" style="width:250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label> Subject: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_subject" name="mail_subject" value="<?php 
        echo $row->mail_subject;
        ?>
" style="width:250px;" />
								<img src="<?php 
        echo WD_FMC_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_subject_labels').style.display='block';" style="vertical-align: middle;cursor: pointer; display:inline-block; margin:0px; float:none;">
								<?php 
        $choise = "document.getElementById('mail_subject')";
        echo '<div style="position:relative; top:-3px;"><div id="mail_subject_labels" class="email_labels" style="display:none;">';
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy" || $label_type[$i] == "type_matrix") {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = $param;
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            echo "<a onClick=\"insertAtCursor(" . $choise . ",'" . $param . "'); document.getElementById('mail_subject_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">" . $fld_label . "</a>";
        }
        echo '</div></div>';
        ?>
							</td>
						</tr>
						<tr valign="top">
              <td class="fm_options_label" style="vertical-align: middle;">
                <label> Mode: </label>
              </td>
              <td class="fm_options_value">
                <input type="radio" name="mail_mode" id="htmlmode" value="1" <?php 
        if ($row->mail_mode == 1) {
            echo "checked";
        }
        ?>
 /> <label for="htmlmode">HTML</label>
                <input type="radio" name="mail_mode" id="textmode" value="0" <?php 
        if ($row->mail_mode == 0) {
            echo "checked";
        }
        ?>
 /> <label for="textmode">Text</label>
              </td>
              </tr>
              <tr valign="top">
              <td class="fm_options_label" style="vertical-align: middle;">
                <label> Attach File: </label>
              </td>
              <td class="fm_options_value">
                <input type="radio" disabled="disabled" name="mail_attachment"  value="1" id="en_attach" <?php 
        if ($row->mail_attachment == 1) {
            echo "checked";
        }
        ?>
 /> <label for="en_attach">Yes</label>
                <input type="radio" disabled="disabled" name="mail_attachment" id="dis_attach" value="0" <?php 
        if ($row->mail_attachment == 0) {
            echo "checked";
        }
        ?>
 /> <label for="dis_attach">No</label>
				<div class="error_cfm" style="padding: 5px; font-size: 14px;">File attach is disabled in free version.</div>
              </td>
            </tr>
            <tr>
              <td class="fm_options_label" valign="top">
                <label>Custom Text in Email For Administrator</label>
              </td>
              <td class="fm_options_value">
                <div style="margin-bottom:5px">
                  <?php 
        $choise = "document.getElementById('script_mail')";
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy") {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            ?>
                    <input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php 
            echo htmlspecialchars(addslashes($label_label[$i]));
            ?>
" onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
, '<?php 
            echo $param;
            ?>
')" />
                    <?php 
        }
        ?>
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Ip" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
,'ip')" />
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Username" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
,'username')" />
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="User Email" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
,'useremail')" />
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="All fields list" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
, 'all')" />
                </div>
                <?php 
        if (user_can_richedit()) {
            wp_editor($row->script_mail, 'script_mail', array('teeny' => FALSE, 'textarea_name' => 'script_mail', 'media_buttons' => FALSE, 'textarea_rows' => 5));
        } else {
            ?>
                  <textarea name="script_mail" id="script_mail" cols="20" rows="10" style="width:300px; height:450px;"><?php 
            echo $row->script_mail;
            ?>
</textarea>
                  <?php 
        }
        ?>
              </td>
            </tr>
          </table>
        </fieldset>
        <fieldset class="fm_mail_options">
          <legend style="color: #0B55C4; font-weight: bold;">Email to User</legend>
          <table class="admintable">
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail">Send to</label>
              </td>
              <td class="fm_options_value">
                <?php 
        $fields = explode('*:*id*:*type_submitter_mail*:*type*:*', $row->form_fields);
        $fields_count = count($fields);
        if ($fields_count == 1) {
            ?>
                  There is no email field
                  <?php 
        } else {
            for ($i = 0; $i < $fields_count - 1; $i++) {
                ?>
                    <div>
                      <input type="checkbox" name="send_to<?php 
                echo $i;
                ?>
" id="send_to<?php 
                echo $i;
                ?>
" value="<?php 
                echo strlen($fields[$i]) != 1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) : $fields[$i];
                ?>
"  <?php 
                echo is_numeric(strpos($row->send_to, '*' . (strlen($fields[$i]) != 1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) : $fields[$i]) . '*')) ? 'checked="checked"' : '';
                ?>
 style="margin: 0px 5px 0px 0px;" />
                      <label for="send_to<?php 
                echo $i;
                ?>
"><?php 
                echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*'));
                ?>
</label>
                    </div>
                    <?php 
            }
        }
        ?>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail_from_user">Email From</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mail_from_user" name="mail_from_user" value="<?php 
        echo $row->mail_from_user;
        ?>
" style="width: 250px;" />
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail_from_name_user">From Name</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mail_from_name_user" name="mail_from_name_user" value="<?php 
        echo $row->mail_from_name_user;
        ?>
" style="width: 250px;"/>
                <img src="<?php 
        echo WD_FMC_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_from_name_user_labels').style.display='block';" style="vertical-align: middle;cursor: pointer; display:inline-block; margin:0px; float:none;">
                <?php 
        $choise = "document.getElementById('mail_from_name_user')";
        echo '<div style="position:relative; top:-3px;"><div id="mail_from_name_user_labels" class="email_labels" style="display:none;">';
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy") {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = $param;
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            echo "<a onClick=\"insertAtCursor(" . $choise . ",'" . $param . "'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">" . $fld_label . "</a>";
        }
        echo '</div></div>';
        ?>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="reply_to_user">Reply to<br />(if different from "Email Form")</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="reply_to_user" name="reply_to_user" value="<?php 
        echo $row->reply_to_user;
        ?>
" style="width:250px;"/>
              </td>
            </tr>
            <tr valign="top">
							<td class="fm_options_label">
								<label> CC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_cc_user" name="mail_cc_user" value="<?php 
        echo $row->mail_cc_user;
        ?>
" style="width:250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label> BCC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_bcc_user" name="mail_bcc_user" value="<?php 
        echo $row->mail_bcc_user;
        ?>
" style="width:250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label> Subject: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_subject_user" name="mail_subject_user" value="<?php 
        echo $row->mail_subject_user;
        ?>
" style="width:250px;" />
								<img src="<?php 
        echo WD_FMC_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_subject_user_labels').style.display='block';" style="vertical-align: middle; cursor: pointer; display:inline-block; margin:0px; float:none;">
								<?php 
        $choise = "document.getElementById('mail_subject_user')";
        echo '<div style="position:relative; top:-3px;"><div id="mail_subject_user_labels" class="email_labels" style="display:none;">';
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy") {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = $param;
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            echo "<a onClick=\"insertAtCursor(" . $choise . ",'" . $param . "'); document.getElementById('mail_subject_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">" . $fld_label . "</a>";
        }
        echo '</div></div>';
        ?>
							</td>
						</tr>
						<tr valign="top">
              <td class="fm_options_label" style="vertical-align: middle;">
                <label> Mode: </label>
              </td>
              <td class="fm_options_value">
                <input type="radio" name="mail_mode_user" id="htmlmode_user" value="1" <?php 
        if ($row->mail_mode_user == 1) {
            echo "checked";
        }
        ?>
 /> <label for="htmlmode_user">HTML</label>
                <input type="radio" name="mail_mode_user" id="textmode_user" value="0" <?php 
        if ($row->mail_mode_user == 0) {
            echo "checked";
        }
        ?>
 /> <label for="textmode_user">Text</label>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label" style="vertical-align: middle;">
                <label> Attach File: </label>
              </td>
              <td class="fm_options_value">
                <input type="radio" disabled="disabled" name="mail_attachment_user"  value="1" id="en_attach_user" <?php 
        if ($row->mail_attachment_user == 1) {
            echo "checked";
        }
        ?>
 /> <label for="en_attach_user">Yes</label>
                <input type="radio" disabled="disabled" name="mail_attachment_user" id="dis_attach_user" value="0" <?php 
        if ($row->mail_attachment_user == 0) {
            echo "checked";
        }
        ?>
 /> <label for="dis_attach_user">No</label>
				<div class="error_cfm" style="padding: 5px; font-size: 14px;">File attach is disabled in free version.</div>
              </td>
            </tr>
            <tr>
              <td class="fm_options_label" valign="top">
                <label>Custom Text in Email For User</label>
              </td>
              <td class="fm_options_value">
                <div style="margin-bottom:5px">
                  <?php 
        $choise = "document.getElementById('script_mail_user')";
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy") {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            ?>
                    <input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php 
            echo htmlspecialchars(addslashes($label_label[$i]));
            ?>
" onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
, '<?php 
            echo $param;
            ?>
')" />
                    <?php 
        }
        ?>
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Ip" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
,'ip')" />
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Username" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
,'username')" />
                  <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="User Email" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
,'useremail')" />
                  <input style="border: 1px solid silver; font-size: 10px; margin:3px;" type="button" value="All fields list" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
, 'all')" />
                </div>
                <?php 
        if (user_can_richedit()) {
            wp_editor($row->script_mail_user, 'script_mail_user', array('teeny' => FALSE, 'textarea_name' => 'script_mail_user', 'media_buttons' => FALSE, 'textarea_rows' => 5));
        } else {
            ?>
                  <textarea name="script_mail_user" id="script_mail_user" cols="20" rows="10" style="width:300px; height:450px;"><?php 
            echo $row->script_mail_user;
            ?>
</textarea>
                  <?php 
        }
        ?>
              </td>
            </tr>
          </table>
        </fieldset>
      </fieldset>
      <fieldset id="actions_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">Actions after submission</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label>Action type</label>
            </td>
            <td class="fm_options_value">
              <div><input type="radio" name="submit_text_type" id="text_type_none" onclick="set_type('none')" value="1" <?php 
        echo $row->submit_text_type != 2 && $row->submit_text_type != 3 && $row->submit_text_type != 4 && $row->submit_text_type != 5 ? "checked" : "";
        ?>
 /><label for="text_type_none">Stay on Form</label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_post" onclick="set_type('post')" value="2" <?php 
        echo $row->submit_text_type == 2 ? "checked" : "";
        ?>
 /><label for="text_type_post">Post</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_page" onclick="set_type('page')" value="5" <?php 
        echo $row->submit_text_type == 5 ? "checked" : "";
        ?>
 /><label for="text_type_page">Page</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_custom_text" onclick="set_type('custom_text')" value="3" <?php 
        echo $row->submit_text_type == 3 ? "checked" : "";
        ?>
 /><label for="text_type_custom_text">Custom Text</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_url" onclick="set_type('url')" value="4" <?php 
        echo $row->submit_text_type == 4 ? "checked" : "";
        ?>
 /><label for="text_type_url">URL</div>
            </td>
          </tr>
          <tr id="none" <?php 
        echo $row->submit_text_type == 2 || $row->submit_text_type == 3 || $row->submit_text_type == 4 || $row->submit_text_type == 5 ? 'style="display:none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label>Stay on Form</label>
            </td>
            <td class="fm_options_value">
              <img src="<?php 
        echo WD_FMC_URL . '/images/tick.png';
        ?>
" border="0">
            </td>
          </tr>
          <tr id="post" <?php 
        echo $row->submit_text_type != 2 ? 'style="display:none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="post_name">Post</label>
            </td>
            <td class="fm_options_value">
              <select id="post_name" name="post_name" style="width: 153px; font-size: 11px;">
                <option value="0">- Select Post -</option>
                <?php 
        // The Query.
        $args = array('posts_per_page' => 10000);
        query_posts($args);
        // The Loop.
        while (have_posts()) {
            the_post();
            ?>
                <option value="<?php 
            $x = get_permalink(get_the_ID());
            echo $x;
            ?>
" <?php 
            echo $row->article_id == $x ? 'selected="selected"' : '';
            ?>
><?php 
            the_title();
            ?>
</option>
                <?php 
        }
        // Reset Query.
        wp_reset_query();
        ?>
              </select>
            </td>
          </tr>
          <tr id="page" <?php 
        echo $row->submit_text_type != 5 ? 'style="display:none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="page_name">Page</label>
            </td>
            <td class="fm_options_value">
              <select id="page_name" name="page_name" style="width: 153px; font-size: 11px;">
                <option value="0">- Select Page -</option>
                <?php 
        // The Query.
        $pages = get_pages();
        // The Loop.
        foreach ($pages as $page) {
            $page_id = get_page_link($page->ID);
            ?>
                <option value="<?php 
            echo $page_id;
            ?>
" <?php 
            echo $row->article_id == $page_id ? 'selected="selected"' : '';
            ?>
><?php 
            echo $page->post_title;
            ?>
</option>
                  <?php 
        }
        // Reset Query.
        wp_reset_query();
        ?>
              </select>
            </td>
          </tr>
          <tr id="custom_text" <?php 
        echo $row->submit_text_type != 3 ? 'style="display: none;"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="submit_text">Text</label>
            </td>
            <td class="fm_options_value">
              <?php 
        if (user_can_richedit()) {
            wp_editor($row->submit_text, 'submit_text', array('teeny' => FALSE, 'textarea_name' => 'submit_text', 'media_buttons' => FALSE, 'textarea_rows' => 5));
        } else {
            ?>
                <textarea cols="36" rows="5" id="submit_text" name="submit_text" style="resize: vertical;">
                  <?php 
            echo $row->submit_text;
            ?>
                </textarea>
                <?php 
        }
        ?>
            </td>
          </tr>
          <tr id="url" <?php 
        echo $row->submit_text_type != 4 ? 'style="display:none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="url">URL</label>
            </td>
            <td class="fm_options_value">
              <input type="text" id="url" name="url" style="width:300px" value="<?php 
        echo $row->url;
        ?>
" />
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="payment_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">Payment Options</legend>
        <table class="admintable">
          <tr>
            <td colspan="2">
              <div class="error_cfm" style="padding: 5px; font-size: 14px;">Paypal Options are disabled in free version.</div>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label>Turn Paypal On</label>
            </td>
            <td class="fm_options_value">
              <div><input disabled="disabled" type="radio" name="paypal_mode" id="paypal_mode1" value="1" <?php 
        echo $row->paypal_mode == "1" ? "checked" : "";
        ?>
 /><label for="paypal_mode1">On</label></div>
              <div><input disabled="disabled" type="radio" name="paypal_mode" id="paypal_mode2" value="0" <?php 
        echo $row->paypal_mode != "1" ? "checked" : "";
        ?>
 /><label for="paypal_mode2">Off</label></div>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label>Checkout Mode</label>
            </td>
            <td class="fm_options_value">
              <div><input disabled="disabled" type="radio" name="checkout_mode" id="checkout_mode1" value="production" <?php 
        echo $row->checkout_mode == "production" ? "checked" : "";
        ?>
 /><label for="checkout_mode1">Production</label></div>
              <div><input disabled="disabled" type="radio" name="checkout_mode" id="checkout_mode2" value="testmode" <?php 
        echo $row->checkout_mode != "production" ? "checked" : "";
        ?>
 /><label for="checkout_mode2">Testmode</label></div>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="paypal_email">Paypal email</label>
            </td>
            <td class="fm_options_value">
              <input disabled="disabled" type="text" name="paypal_email" id="paypal_email" value="<?php 
        echo $row->paypal_email;
        ?>
" class="text_area" style="width:250px">
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="payment_currency">Payment Currency</label>
            </td>
            <td class="fm_options_value">
              <select disabled="disabled" id="payment_currency" name="payment_currency" style="width:253px">
                <option value="USD" <?php 
        echo $row->payment_currency == 'USD' ? 'selected' : '';
        ?>
>$ &#8226; U.S. Dollar</option>
                <option value="EUR" <?php 
        echo $row->payment_currency == 'EUR' ? 'selected' : '';
        ?>
>&#8364; &#8226; Euro</option>
                <option value="GBP" <?php 
        echo $row->payment_currency == 'GBP' ? 'selected' : '';
        ?>
>&#163; &#8226; Pound Sterling</option>
                <option value="JPY" <?php 
        echo $row->payment_currency == 'JPY' ? 'selected' : '';
        ?>
>&#165; &#8226; Japanese Yen</option>
                <option value="CAD" <?php 
        echo $row->payment_currency == 'CAD' ? 'selected' : '';
        ?>
>C$ &#8226; Canadian Dollar</option>
                <option value="MXN" <?php 
        echo $row->payment_currency == 'MXN' ? 'selected' : '';
        ?>
>Mex$ &#8226; Mexican Peso</option>
                <option value="HKD" <?php 
        echo $row->payment_currency == 'HKD' ? 'selected' : '';
        ?>
>HK$ &#8226; Hong Kong Dollar</option>
                <option value="HUF" <?php 
        echo $row->payment_currency == 'HUF' ? 'selected' : '';
        ?>
>Ft &#8226; Hungarian Forint</option>
                <option value="NOK" <?php 
        echo $row->payment_currency == 'NOK' ? 'selected' : '';
        ?>
>kr &#8226; Norwegian Kroner</option>
                <option value="NZD" <?php 
        echo $row->payment_currency == 'NZD' ? 'selected' : '';
        ?>
>NZ$ &#8226; New Zealand Dollar</option>
                <option value="SGD" <?php 
        echo $row->payment_currency == 'SGD' ? 'selected' : '';
        ?>
>S$ &#8226; Singapore Dollar</option>
                <option value="SEK" <?php 
        echo $row->payment_currency == 'SEK' ? 'selected' : '';
        ?>
>kr &#8226; Swedish Kronor</option>
                <option value="PLN" <?php 
        echo $row->payment_currency == 'PLN' ? 'selected' : '';
        ?>
>zl &#8226; Polish Zloty</option>
                <option value="AUD" <?php 
        echo $row->payment_currency == 'AUD' ? 'selected' : '';
        ?>
>A$ &#8226; Australian Dollar</option>
                <option value="DKK" <?php 
        echo $row->payment_currency == 'DKK' ? 'selected' : '';
        ?>
>kr &#8226; Danish Kroner</option>
                <option value="CHF" <?php 
        echo $row->payment_currency == 'CHF' ? 'selected' : '';
        ?>
>CHF &#8226; Swiss Francs</option>
                <option value="CZK" <?php 
        echo $row->payment_currency == 'CZK' ? 'selected' : '';
        ?>
>Kc &#8226; Czech Koruny</option>
                <option value="ILS" <?php 
        echo $row->payment_currency == 'ILS' ? 'selected' : '';
        ?>
>&#8362; &#8226; Israeli Sheqel</option>
                <option value="BRL" <?php 
        echo $row->payment_currency == 'BRL' ? 'selected' : '';
        ?>
>R$ &#8226; Brazilian Real</option>
                <option value="TWD" <?php 
        echo $row->payment_currency == 'TWD' ? 'selected' : '';
        ?>
>NT$ &#8226; Taiwan New Dollars</option>
                <option value="MYR" <?php 
        echo $row->payment_currency == 'MYR' ? 'selected' : '';
        ?>
>RM &#8226; Malaysian Ringgit</option>
                <option value="PHP" <?php 
        echo $row->payment_currency == 'PHP' ? 'selected' : '';
        ?>
>&#8369; &#8226; Philippine Peso</option>
                <option value="THB" <?php 
        echo $row->payment_currency == 'THB' ? 'selected' : '';
        ?>
>&#xe3f; &#8226; Thai Bahtv</option>
              </select>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="tax">Tax</label>
            </td>
            <td class="fm_options_value">
              <input type="text" name="tax" id="tax" value="<?php 
        echo $row->tax;
        ?>
" class="text_area" style="width: 40px;" onKeyPress="return check_isnum_point(event)"> %
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="javascript_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">JavaScript</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label for="javascript">Javascript</label>
            </td>
            <td class="fm_options_value" style="width:650px;">
              <textarea style="margin: 0px; height: 400px; width: 600px;" cols="60" rows="30" name="javascript" id="form_javascript"><?php 
        echo $row->javascript;
        ?>
</textarea>
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="conditions_fieldset" class="adminform fm_fieldset_deactive">
				<legend style="color:#0B55C4;font-weight: bold;">Conditional Fields</legend>
				<?php 
        $ids = array();
        $types = array();
        $labels = array();
        $paramss = array();
        $all_ids = array();
        $all_labels = array();
        $select_and_input = array("type_text", "type_password", "type_textarea", "type_name", "type_number", "type_phone", "type_submitter_mail", "type_address", "type_checkbox", "type_radio", "type_own_select", "type_paypal_price", "type_paypal_select", "type_paypal_checkbox", "type_paypal_radio", "type_paypal_shipping");
        $select_type_fields = array("type_address", "type_checkbox", "type_radio", "type_own_select", "type_paypal_select", "type_paypal_checkbox", "type_paypal_radio", "type_paypal_shipping");
        $fields = explode('*:*new_field*:*', $row->form_fields);
        $fields = array_slice($fields, 0, count($fields) - 1);
        foreach ($fields as $field) {
            $temp = explode('*:*id*:*', $field);
            array_push($ids, $temp[0]);
            array_push($all_ids, $temp[0]);
            $temp = explode('*:*type*:*', $temp[1]);
            array_push($types, $temp[0]);
            $temp = explode('*:*w_field_label*:*', $temp[1]);
            array_push($labels, $temp[0]);
            array_push($all_labels, $temp[0]);
            array_push($paramss, $temp[1]);
        }
        foreach ($types as $key => $value) {
            if (!in_array($types[$key], $select_and_input)) {
                unset($ids[$key]);
                unset($labels[$key]);
                unset($types[$key]);
                unset($paramss[$key]);
            }
        }
        $ids = array_values($ids);
        $labels = array_values($labels);
        $types = array_values($types);
        $paramss = array_values($paramss);
        $chose_ids = implode('@@**@@', $ids);
        $chose_labels = implode('@@**@@', $labels);
        $chose_types = implode('@@**@@', $types);
        $chose_paramss = implode('@@**@@', $paramss);
        $all_ids_cond = implode('@@**@@', $all_ids);
        $all_labels_cond = implode('@@**@@', $all_labels);
        $show_hide = array();
        $field_label = array();
        $all_any = array();
        $condition_params = array();
        $count_of_conditions = 0;
        if ($row->condition != "") {
            $conditions = explode('*:*new_condition*:*', $row->condition);
            $conditions = array_slice($conditions, 0, count($conditions) - 1);
            $count_of_conditions = count($conditions);
            foreach ($conditions as $condition) {
                $temp = explode('*:*show_hide*:*', $condition);
                array_push($show_hide, $temp[0]);
                $temp = explode('*:*field_label*:*', $temp[1]);
                array_push($field_label, $temp[0]);
                $temp = explode('*:*all_any*:*', $temp[1]);
                array_push($all_any, $temp[0]);
                array_push($condition_params, $temp[1]);
            }
        } else {
            $show_hide[0] = 1;
            $all_any[0] = 'and';
            $condition_params[0] = '';
            if ($all_ids) {
                $field_label[0] = $all_ids[0];
            }
        }
        ?>
					<div>
					<span style="font-size:13px;">Add Condition<span/>
					<img src="<?php 
        echo WD_FMC_URL . '/images/add_condition.png';
        ?>
" title="add" onclick="add_condition('<?php 
        echo $chose_ids;
        ?>
', '<?php 
        echo htmlspecialchars(addslashes($chose_labels));
        ?>
', '<?php 
        echo $chose_types;
        ?>
', '<?php 
        echo htmlspecialchars(addslashes($chose_paramss));
        ?>
', '<?php 
        echo $all_ids_cond;
        ?>
', '<?php 
        echo htmlspecialchars(addslashes($all_labels_cond));
        ?>
')" style="cursor: pointer; vertical-align: middle; margin-left:15px;">
					</div>
					<?php 
        for ($k = 0; $k < $count_of_conditions; $k++) {
            if (in_array($field_label[$k], $all_ids)) {
                ?>
					<div id="condition<?php 
                echo $k;
                ?>
" >
						<div id="conditional_fileds<?php 
                echo $k;
                ?>
">
							<select id="show_hide<?php 
                echo $k;
                ?>
" name="show_hide<?php 
                echo $k;
                ?>
" style="width:60px; ">
							<option value="1" <?php 
                if ($show_hide[$k] == 1) {
                    echo 'selected="selected"';
                }
                ?>
>show</option>
							<option value="0" <?php 
                if ($show_hide[$k] == 0) {
                    echo 'selected="selected"';
                }
                ?>
>hide</option>
							</select> 
							
							<select id="fields<?php 
                echo $k;
                ?>
" name="fields<?php 
                echo $k;
                ?>
" style="width:400px; " onChange="" >
							<?php 
                foreach ($all_labels as $key => $value) {
                    if ($field_label[$k] == $all_ids[$key]) {
                        $selected = 'selected="selected"';
                    } else {
                        $selected = '';
                    }
                    echo '<option value="' . $all_ids[$key] . '" ' . $selected . '>' . $value . '</option>';
                }
                ?>
							</select> 
							<span>if</span>
							
							<select id="all_any<?php 
                echo $k;
                ?>
" name="all_any<?php 
                echo $k;
                ?>
" style="width:45px; ">
							<option value="and" <?php 
                if ($all_any[$k] == "and") {
                    echo 'selected="selected"';
                }
                ?>
>all</option>
							<option value="or" <?php 
                if ($all_any[$k] == "or") {
                    echo 'selected="selected"';
                }
                ?>
>any</option>
							</select> 
							
							<span>of the following match:</span>	
							<img src="<?php 
                echo WD_FMC_URL . '/images/add.png';
                ?>
" title="add" onclick="add_condition_fields(<?php 
                echo $k;
                ?>
,'<?php 
                echo $chose_ids;
                ?>
', '<?php 
                echo htmlspecialchars(addslashes($chose_labels));
                ?>
', '<?php 
                echo $chose_types;
                ?>
', '<?php 
                echo htmlspecialchars(addslashes($chose_paramss));
                ?>
')" style="cursor: pointer; vertical-align: middle;">
							
							<img src="<?php 
                echo WD_FMC_URL . '/images/page_delete.png';
                ?>
" onclick="delete_condition('<?php 
                echo $k;
                ?>
')" style="cursor: pointer; vertical-align: middle;">
						</div>
						
						<?php 
                if ($condition_params[$k]) {
                    $_params = explode('*:*next_condition*:*', $condition_params[$k]);
                    $_params = array_slice($_params, 0, count($_params) - 1);
                    foreach ($_params as $key => $_param) {
                        $key_select_or_input = '';
                        $param_values = explode('***', $_param);
                        $multiselect = explode('@@@', $param_values[2]);
                        if (in_array($param_values[0], $ids)) {
                            ?>
								<div id="condition_div<?php 
                            echo $k;
                            ?>
_<?php 
                            echo $key;
                            ?>
">
								<select id="field_labels<?php 
                            echo $k;
                            ?>
_<?php 
                            echo $key;
                            ?>
" onchange="change_choices(this.options[this.selectedIndex].id+'_<?php 
                            echo $key;
                            ?>
','<?php 
                            echo $chose_ids;
                            ?>
', '<?php 
                            echo $chose_types;
                            ?>
', '<?php 
                            echo htmlspecialchars(addslashes($chose_paramss));
                            ?>
')" style="width:350px;"/>
									<?php 
                            foreach ($labels as $key1 => $value) {
                                if ($param_values[0] == $ids[$key1]) {
                                    $selected = 'selected="selected"';
                                    if ($types[$key1] == "type_checkbox" || $types[$key1] == "type_paypal_checkbox") {
                                        $multiple = 'multiple="multiple" class="multiple_select"';
                                    } else {
                                        $multiple = '';
                                    }
                                    $key_select_or_input = $key1;
                                } else {
                                    $selected = '';
                                }
                                if ($field_label[$k] != $ids[$key1]) {
                                    echo '<option id="' . $k . '_' . $key1 . '" value="' . $ids[$key1] . '" ' . $selected . '>' . $value . '</option>';
                                }
                            }
                            ?>
	
								</select>
								
								<select id="is_select<?php 
                            echo $k;
                            ?>
_<?php 
                            echo $key;
                            ?>
" style="vertical-align: top;">
								<option value="==" <?php 
                            if ($param_values[1] == "==") {
                                echo 'selected="selected"';
                            }
                            ?>
>is</option>
								<option value="!=" <?php 
                            if ($param_values[1] == "!=") {
                                echo 'selected="selected"';
                            }
                            ?>
>is not</option>
								</select>
								
								<?php 
                            if ($key_select_or_input != '' && in_array($types[$key_select_or_input], $select_type_fields)) {
                                ?>
								<select id="field_value<?php 
                                echo $k;
                                ?>
_<?php 
                                echo $key;
                                ?>
" <?php 
                                echo $multiple;
                                ?>
 style="vertical-align: top; width: 200px;">
								<?php 
                                switch ($types[$key_select_or_input]) {
                                    case "type_own_select":
                                    case "type_paypal_select":
                                        $w_size = explode('*:*w_size*:*', $paramss[$key_select_or_input]);
                                        break;
                                    case "type_radio":
                                    case "type_checkbox":
                                    case "type_paypal_radio":
                                    case "type_paypal_checkbox":
                                    case "type_paypal_shipping":
                                        $w_size = explode('*:*w_flow*:*', $paramss[$key_select_or_input]);
                                        break;
                                }
                                $w_choices = explode('*:*w_choices*:*', $w_size[1]);
                                $w_choices_array = explode('***', $w_choices[0]);
                                $w_choices_price = explode('*:*w_choices_price*:*', $w_choices[1]);
                                $w_choices_price_array = explode('***', $w_choices_price[0]);
                                for ($m = 0; $m < count($w_choices_array); $m++) {
                                    if ($types[$key_select_or_input] == "type_paypal_checkbox") {
                                        $w_choice = $w_choices_array[$m] . '*:*value*:*' . $w_choices_price_array[$m];
                                    } else {
                                        $w_choice = $w_choices_array[$m];
                                    }
                                    if (in_array(esc_html($w_choice), $multiselect)) {
                                        $selected = 'selected="selected"';
                                    } else {
                                        $selected = '';
                                    }
                                    echo '<option id="choise_' . $k . '_' . $m . '" value="' . $w_choice . '" ' . $selected . '>' . $w_choices_array[$m] . '</option>';
                                }
                                if ($types[$key_select_or_input] == "type_address") {
                                    $w_countries = array("", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe");
                                    $w_options = '';
                                    foreach ($w_countries as $w_country) {
                                        if (in_array($w_country, $multiselect)) {
                                            $selected = 'selected="selected"';
                                        } else {
                                            $selected = '';
                                        }
                                        echo '<option value="' . $w_country . '" ' . $selected . '>' . $w_country . '</option>';
                                    }
                                }
                                ?>
	
								</select>
								<?php 
                            } else {
                                if ($key_select_or_input != '' && ($types[$key_select_or_input] == "type_number" || $types[$key_select_or_input] == "type_phone")) {
                                    $onkeypress_function = "onkeypress='return check_isnum_space(event)'";
                                } else {
                                    if ($key_select_or_input != '' && $types[$key_select_or_input] == "type_paypal_price") {
                                        $onkeypress_function = "onkeypress='return check_isnum_point(event)'";
                                    } else {
                                        $onkeypress_function = "";
                                    }
                                }
                                ?>
								<input id="field_value<?php 
                                echo $k;
                                ?>
_<?php 
                                echo $key;
                                ?>
" type="text" value="<?php 
                                echo $param_values[2];
                                ?>
" <?php 
                                echo $onkeypress_function;
                                ?>
 style="vertical-align: top; width: 200px;"><?php 
                            }
                            ?>
								
								<img src="<?php 
                            echo WD_FMC_URL . '/images/delete.png';
                            ?>
" id="delete_condition<?php 
                            echo $k;
                            ?>
_<?php 
                            echo $key;
                            ?>
" onclick="delete_field_condition('<?php 
                            echo $k;
                            ?>
_<?php 
                            echo $key;
                            ?>
')" style="vertical-align: top;">
								</div>
								<?php 
                        }
                    }
                }
                ?>
					</div>
					<?php 
            }
        }
        ?>
				<input type="hidden" id="condition" name="condition" value="<?php 
        echo $row->condition;
        ?>
" />	
				
			</fieldset>
      <input type="hidden" name="fieldset_id" id="fieldset_id" value="<?php 
        echo WDW_FMC_Library::get('fieldset_id', 'general');
        ?>
" />

      <input type="hidden" id="task" name="task" value=""/>
      <input type="hidden" id="current_id" name="current_id" value="<?php 
        echo $row->id;
        ?>
" />
    </form>
    <script>
      jQuery(window).load(function () {
        form_maker_options_tabs(jQuery("#fieldset_id").val());
        spider_popup();
        function hide_email_labels(event) {
          var e = event.toElement || event.relatedTarget;
          if (e.parentNode == this || e == this) {
             return;
          }
          this.style.display="none";
        }
        if(document.getElementById('mail_from_labels')) {
          document.getElementById('mail_from_labels').addEventListener('mouseout',hide_email_labels,true);
        }
        if(document.getElementById('mail_subject_labels')) {
          document.getElementById('mail_subject_labels').addEventListener('mouseout',hide_email_labels,true);
        }
        if(document.getElementById('mail_from_name_user_labels')) {
          document.getElementById('mail_from_name_user_labels').addEventListener('mouseout',hide_email_labels,true);
        }
        if(document.getElementById('mail_subject_user_labels')) {
          document.getElementById('mail_subject_user_labels').addEventListener('mouseout',hide_email_labels,true);
        }
      });
      function wd_fm_apply_options() {
        set_condition();
        spider_set_input_value('task', 'apply_options');
        document.getElementById('adminForm').submit();
      }
    </script>
    <?php 
    }
 public function delete_all()
 {
     global $wpdb;
     $flag = FALSE;
     $ips_id_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'formmaker_blocked');
     foreach ($ips_id_col as $ip_id) {
         if (isset($_POST['check_' . $ip_id])) {
             $flag = TRUE;
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE id="%d"', $ip_id));
         }
     }
     if ($flag) {
         $message = 5;
     } else {
         $message = 2;
     }
     // $this->display();
     $page = WDW_FMC_Library::get('page');
     WDW_FMC_Library::spider_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
 }
 public function unblock_ip()
 {
     global $wpdb;
     $flag = FALSE;
     $form_id = isset($_POST['form_id']) && esc_html($_POST['form_id']) != '' ? esc_html($_POST['form_id']) : 0;
     $cid = isset($_POST['post']) && $_POST['post'] != '' ? $_POST['post'] : NULL;
     if (count($cid)) {
         array_walk($cid, create_function('&$value', '$value = (int)$value;'));
         $cids = implode(',', $cid);
         $query = 'SELECT * FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id IN ( ' . $cids . ' )';
         $rows = $wpdb->get_results($query);
         foreach ($rows as $row) {
             $flag = TRUE;
             $ips = $wpdb->get_var($wpdb->prepare('SELECT ip FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE ip="%s"', $row->ip));
             if ($ips) {
                 $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE ip="%s"', $ips));
             }
         }
     }
     if ($flag) {
         echo WDW_FMC_Library::message('IPs Succesfully Unblocked.', 'updated');
     } else {
         echo WDW_FMC_Library::message('You must select at least one item.', 'error');
     }
     $this->display($form_id);
 }
    public function display($form_id)
    {
        global $wpdb;
        $forms = $this->model->get_form_titles();
        $statistics = $this->model->get_statistics($form_id);
        $labels_parameters = $this->model->get_labels_parameters($form_id);
        $sorted_labels_id = $labels_parameters[0];
        $sorted_label_types = $labels_parameters[1];
        $lists = $labels_parameters[2];
        $sorted_label_names = $labels_parameters[3];
        $sorted_label_names_original = $labels_parameters[4];
        $rows = isset($labels_parameters[5]) ? $labels_parameters[5] : NULL;
        $group_ids = isset($labels_parameters[6]) ? $labels_parameters[6] : NULL;
        $where_choices = $labels_parameters[7];
        $order_by = isset($_POST['order_by']) ? esc_html(stripslashes($_POST['order_by'])) : 'group_id';
        $asc_or_desc = isset($_POST['asc_or_desc']) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'desc';
        $style_id = $this->model->hide_or_not($lists['hide_label_list'], '@submitid@');
        $style_date = $this->model->hide_or_not($lists['hide_label_list'], '@submitdate@');
        $style_ip = $this->model->hide_or_not($lists['hide_label_list'], '@submitterip@');
        $style_username = $this->model->hide_or_not($lists['hide_label_list'], '@submitterusername@');
        $style_useremail = $this->model->hide_or_not($lists['hide_label_list'], '@submitteremail@');
        $oder_class_default = "manage-column column-autor sortable desc";
        $oder_class = "manage-column column-title sorted " . $asc_or_desc;
        $ispaypal = FALSE;
        $temp = array();
        $m = count($sorted_label_names);
        $n = count($rows);
        $group_id_s = array();
        $group_id_s = $this->model->sort_group_ids(count($sorted_label_names), $group_ids);
        $ka_fielderov_search = $lists['ip_search'] || $lists['startdate'] || $lists['enddate'] || $lists['username_search'] || $lists['useremail_search'] ? TRUE : FALSE;
        $is_stats = false;
        $blocked_ips = $this->model->blocked_ips();
        ?>
    <script type="text/javascript">
      function clickLabChBAll(ChBAll) {
        <?php 
        if (isset($sorted_label_names)) {
            $templabels = array_merge(array('submitid', 'submitdate', 'submitterip', 'submitterusername', 'submitteremail'), $sorted_labels_id);
            $sorted_label_names_for_check = array_merge(array('ID', 'Submit date', "Submitter's IP", "Submitter's Username", "Submitter's Email Address"), $sorted_label_names_original);
        } else {
            $templabels = array('submitid', 'submitdate', 'submitterip', 'submitterusername', 'submitteremail');
            $sorted_label_names_for_check = array('ID', 'Submit date', "Submitter's IP", 'Submitter\'s Username', 'Submitter\'s Email Address');
        }
        ?>
        if (ChBAll.checked) {
          document.forms.admin_form.hide_label_list.value = '';
          for (i = 0; i <= ChBAll.form.length; i++) {
            if (typeof(ChBAll.form[i]) != "undefined") {
              if (ChBAll.form[i].type == "checkbox") {
                ChBAll.form[i].checked = true;
              }
            }
          }
        }
        else {
          document.forms.admin_form.hide_label_list.value = '@<?php 
        echo implode($templabels, '@@');
        ?>
@' + '@payment_info@';
          for (i = 0; i <= ChBAll.form.length; i++) {
            if (typeof(ChBAll.form[i]) != "undefined") {
              if (ChBAll.form[i].type == "checkbox") {
                ChBAll.form[i].checked = false;
              }
            }
          }
        }
        renderColumns();
      }
      function remove_all() {
        document.getElementById('startdate').value = '';
        document.getElementById('enddate').value = '';
        document.getElementById('ip_search').value = '';
		document.getElementById('username_search').value='';
		document.getElementById('useremail_search').value='';
        <?php 
        $n = count($rows);
        for ($i = 0; $i < count($sorted_label_names); $i++) {
            if ($sorted_label_types[$i] != "type_mark_map") {
                ?>
            document.getElementById('<?php 
                echo $form_id . '_' . $sorted_labels_id[$i] . '_search';
                ?>
').value='';
            <?php 
            }
        }
        ?>
      }
      function show_hide_filter() {
        if (document.getElementById('fields_filter').style.display == "none") {
          document.getElementById('fields_filter').style.display = '';
          document.getElementById('filter_img').src = '<?php 
        echo WD_FMC_URL . '/images/filter_hide.png';
        ?>
';
        }
        else {
          document.getElementById('fields_filter').style.display = "none";
          document.getElementById('filter_img').src = '<?php 
        echo WD_FMC_URL . '/images/filter_show.png';
        ?>
';
        }
      }
      jQuery(document).ready(function () { 
        jQuery('.theme-detail').click(function () {
          jQuery(this).siblings('.themedetaildiv').toggle();
          return false;
        });
      });
    </script>
    <div id="sbox-overlay" onclick="toggleChBDiv(false)"
       style="z-index: 65555; position: fixed; top: 0px; left: 0px; visibility: visible; zoom: 1; background-color: #000000; opacity: 0.7; filter: alpha(opacity=70); display: none;">
    </div>
    <div style="background-color: #FFFFFF; width: 350px; max-height: 350px; overflow-y: auto; padding: 20px; position: fixed; top: 100px; display: none; border: 2px solid #AAAAAA;  z-index: 65556;" id="ChBDiv">
      <form action="#">
        <?php 
        wp_nonce_field('nonce_fmc', 'nonce_fmc');
        ?>
        <p style="font-weight: bold; font-size: 18px; margin-top: 0px;">Select Columns</p>
        <div class="fm_check_labels"><input type="checkbox" <?php 
        echo $lists['hide_label_list'] === '' ? 'checked="checked"' : '';
        ?>
 onclick="clickLabChBAll(this)" id="ChBAll"/><label for="ChBAll"> All</label></div>
        <?php 
        foreach ($templabels as $key => $curlabel) {
            if (strpos($lists['hide_label_list'], '@' . $curlabel . '@') === FALSE) {
                ?>
        <div class="fm_check_labels"><input type="checkbox" checked="checked" onclick="clickLabChB('<?php 
                echo $curlabel;
                ?>
', this)" id="fm_check_id_<?php 
                echo $curlabel;
                ?>
" /><label for="fm_check_id_<?php 
                echo $curlabel;
                ?>
"> <?php 
                echo stripslashes($sorted_label_names_for_check[$key]);
                ?>
</label></div>
            <?php 
            } else {
                ?>
        <div class="fm_check_labels"><input type="checkbox" onclick="clickLabChB('<?php 
                echo $curlabel;
                ?>
', this)" id="fm_check_id_<?php 
                echo $curlabel;
                ?>
"/><label for="fm_check_id_<?php 
                echo $curlabel;
                ?>
"> <?php 
                echo stripslashes($sorted_label_names_for_check[$key]);
                ?>
</label></div>
            <?php 
            }
        }
        $ispaypal = FALSE;
        for ($i = 0; $i < count($sorted_label_names); $i++) {
            if ($sorted_label_types[$i] == 'type_paypal_payment_status') {
                $ispaypal = TRUE;
            }
        }
        if ($ispaypal) {
            ?>
        <div class="fm_check_labels">
          <input type="checkbox" onclick="clickLabChB('payment_info', this)" id="fm_check_payment_info" <?php 
            echo strpos($lists['hide_label_list'], '@payment_info@') === FALSE ? 'checked="checked"' : '';
            ?>
 />
          <label for="fm_check_payment_info"> Payment Info</label>
        </div>
	        <?php 
        }
        ?>
        <div style="text-align: center; padding: 20px;">
          <input type="button" class="button-secondary" onclick="toggleChBDiv(false);" value="Done" />
        </div>
      </form>
    </div>
    <div style="clear: both; float: left; width: 99%;">
      <div style="float:left; font-size: 14px; font-weight: bold;">
        This section allows you to view and manage form submissions.
        <a style="color: blue; text-decoration: none;" target="_blank" href="http://web-dorado.com/wordpress-form-maker-guide-6.html">Read More in User Manual</a>
      </div>
      <div style="float: right; text-align: right;">
        <a style="text-decoration: none;" target="_blank" href="http://web-dorado.com/files/fromContactForm.php">
          <img width="215" border="0" alt="web-dorado.com" src="<?php 
        echo WD_FMC_URL . '/images/wd_logo.png';
        ?>
" />
        </a>
      </div>
    </div>
    <form action="admin.php?page=submissions_fmc" method="post" id="admin_form" name="admin_form">
      <?php 
        wp_nonce_field('nonce_fmc', 'nonce_fmc');
        ?>
      <input type="hidden" name="option" value="com_formmaker" />
      <input type="hidden" id="task" name="task" value="" />
      <input type="hidden" id="current_id" name="current_id" value="" />
      <input type="hidden" name="asc_or_desc" id="asc_or_desc" value="<?php 
        echo $asc_or_desc;
        ?>
" />
      <input type="hidden" name="order_by" id="order_by" value="<?php 
        echo $order_by;
        ?>
" />
      <br />
      <table width="99%">
        <tr style="line-height: inherit !important;">
          <td align="left" width="300">
            <select name="form_id" id="form_id" style="width:99%" onchange="document.admin_form.submit();">
              <option value="0" selected="selected"> - Select a Form - </option>
              <?php 
        if ($forms) {
            foreach ($forms as $form) {
                ?>
              <option value="<?php 
                echo $form->id;
                ?>
" <?php 
                if ($form_id == $form->id) {
                    $chosen_form_title = $form->title;
                    echo 'selected="selected"';
                }
                ?>
> <?php 
                echo $form->title;
                ?>
 </option>
                  <?php 
            }
        }
        ?>
            </select>
          </td>
          <?php 
        if ($form_id > 0) {
            ?>
          <td class="reports"><strong>Entries</strong><br /><?php 
            echo $statistics["total_entries"];
            ?>
</td>
          <td class="reports"><strong>Views</strong><br /><?php 
            echo $statistics["total_views"];
            ?>
</td>
          <td class="reports"><strong>Conversion Rate</strong><br/><?php 
            echo $statistics["conversion_rate"];
            ?>
</td>
          <td class="form_title">
            <span class="form_title_cont" title="<?php 
            echo $chosen_form_title;
            ?>
"><?php 
            echo $chosen_form_title;
            ?>
</span>
          </td>
          <td style="text-align: right;" width="300">
            <span class="exp_but_span">Export to</span>
            <input type="button" class="button-secondary" value="CSV" onclick="window.location='<?php 
            echo add_query_arg(array('action' => 'generete_csv_fmc', 'form_id' => $form_id), admin_url('admin-ajax.php'));
            ?>
'" />&nbsp;
            <input type="button" class="button-secondary" value="XML" onclick="window.location='<?php 
            echo add_query_arg(array('action' => 'generete_xml_fmc', 'form_id' => $form_id), admin_url('admin-ajax.php'));
            ?>
'" />
          </td>			
        </tr>       
        <tr>
          <td align="left" colspan="4">
            <input type="hidden" name="hide_label_list" value="<?php 
            echo $lists['hide_label_list'];
            ?>
" />
            <img src="<?php 
            echo WD_FMC_URL . '/images/filter_show.png';
            ?>
" width="40" style="vertical-align: bottom; cursor: pointer;" onclick="show_hide_filter()" title="Search by fields" id="filter_img" />
            <input type="button" class="button-secondary" onclick="spider_form_submit(event, 'admin_form')" value="Go" />
            <input type="button" class="button-secondary" onclick="remove_all(); spider_form_submit(event, 'admin_form')" value="Reset" />
          </td>
          <td align="right" colspan="2">
            <br />
            <?php 
            if (isset($sorted_label_names)) {
                ?>
            <input type="button" class="button-secondary" onclick="toggleChBDiv(true)" value="Add/Remove Columns" />
              <?php 
            }
            ?>
            <input class="button-secondary" type="button" onclick="spider_set_input_value('task', 'block_ip'); spider_form_submit(event, 'admin_form')" value="Block IP" />
            <input class="button-secondary" type="button" onclick="spider_set_input_value('task', 'unblock_ip'); spider_form_submit(event, 'admin_form')" value="Unblock IP" />
            <input class="button-secondary" type="button" onclick="if (confirm('Do you want to delete selected items?')) {
                                                                     spider_set_input_value('task', 'delete_all');
                                                                     spider_form_submit(event, 'admin_form')
                                                                   } else {
                                                                     return false;
                                                                   }" value="Delete"/>
          </td>
        </tr>
          <?php 
        } else {
            ?>
          <td></td>
        </tr>
            <?php 
        }
        ?>
      </table>
      <div class="tablenav top" style="width: 99%;">
        <?php 
        WDW_FMC_Library::html_page_nav($lists['total'], $lists['limit'], 'admin_form');
        ?>
      </div>    
      <div class="submit_content" style="width: 99%;">
        <table class="wp-list-table widefat fixed posts table_content">
          <thead>
            <tr>
              <th class="table_small_col count_col sub-align">#</th>
              <th scope="col" id="cb" class="manage-column column-cb check-column table_small_col sub-align form_check"><input id="check_all" type="checkbox"></th>
              <th scope="col" id="submitid_fc" class="table_small_col sub-align submitid_fc <?php 
        if ($order_by == "group_id") {
            echo $oder_class;
        } else {
            echo $oder_class_default;
        }
        ?>
" <?php 
        echo $style_id;
        ?>
>
                <a href="" class="sub_id" onclick="spider_set_input_value('order_by', 'group_id');
                                                   spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'group_id' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                                                   spider_form_submit(event, 'admin_form')">
                  <span>ID</span>
                  <span class="sorting-indicator" style="margin-top: 8px;"></span>
                </a>
              </th>
              <th class="table_small_col sub-align">Edit</th>
              <th class="table_small_col sub-align">Delete</th>
              <th scope="col" id="submitdate_fc" class="table_large_col submitdate_fc <?php 
        if ($order_by == "date") {
            echo $oder_class;
        } else {
            echo $oder_class_default;
        }
        ?>
" <?php 
        echo $style_date;
        ?>
>
                <a href="" onclick="spider_set_input_value('order_by', 'date');
                                    spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'date' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                                    spider_form_submit(event, 'admin_form')">
                  <span>Submit date</span>
                  <span class="sorting-indicator"></span>
                </a>
              </th>
              <th scope="col" id="submitterip_fc" class="table_medium_col_uncenter submitterip_fc <?php 
        if ($order_by == "ip") {
            echo $oder_class;
        } else {
            echo $oder_class_default;
        }
        ?>
" <?php 
        echo $style_ip;
        ?>
>
                <a href="" onclick="spider_set_input_value('order_by', 'ip');
                                    spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'ip' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                                    spider_form_submit(event, 'admin_form')">
                  <span>Submitter's IP</span>
                  <span class="sorting-indicator"></span>
                </a>
              </th>	
			  
			   <th scope="col" id="submitterusername_fc" class="table_medium_col_uncenter submitterusername_fc <?php 
        if ($order_by == "display_name") {
            echo $oder_class;
        } else {
            echo $oder_class_default;
        }
        ?>
" <?php 
        echo $style_username;
        ?>
>
                <a href="" onclick="spider_set_input_value('order_by', 'display_name');
                                    spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'display_name' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                                    spider_form_submit(event, 'admin_form')">
                  <span>Submitter's Username</span>
                  <span class="sorting-indicator"></span>
                </a>
              </th>	
			  
			  <th scope="col" id="submitteremail_fc" class="table_medium_col_uncenter submitteremail_fc <?php 
        if ($order_by == "user_email") {
            echo $oder_class;
        } else {
            echo $oder_class_default;
        }
        ?>
" <?php 
        echo $style_useremail;
        ?>
>
                <a href="" onclick="spider_set_input_value('order_by', 'user_email');
                                    spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == 'user_email' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                                    spider_form_submit(event, 'admin_form')">
                  <span>Submitter's Email Address</span>
                  <span class="sorting-indicator"></span>
                </a>
              </th>	
			  
			
              <?php 
        for ($i = 0; $i < count($sorted_label_names); $i++) {
            $styleStr = $this->model->hide_or_not($lists['hide_label_list'], $sorted_labels_id[$i]);
            $styleStr2 = $this->model->hide_or_not($lists['hide_label_list'], '@payment_info@');
            $field_title = $this->model->get_type_address($sorted_label_types[$i], $sorted_label_names_original[$i]);
            if ($sorted_label_types[$i] == 'type_paypal_payment_status') {
                $ispaypal = TRUE;
                ?>
              <th <?php 
                echo $styleStr;
                ?>
 id="<?php 
                echo $sorted_labels_id[$i] . '_fc';
                ?>
" class="table_large_col <?php 
                echo $sorted_labels_id[$i] . '_fc';
                if ($order_by == $sorted_labels_id[$i] . "_field") {
                    echo $oder_class . '"';
                } else {
                    echo $oder_class_default . '"';
                }
                ?>
">
                <a href="" onclick="spider_set_input_value('order_by', '<?php 
                echo $sorted_labels_id[$i] . '_field';
                ?>
');
                                    spider_set_input_value('asc_or_desc', '<?php 
                echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == $sorted_labels_id[$i] . '_field' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
                ?>
');
                                    spider_form_submit(event, 'admin_form')">	
                  <span><?php 
                echo $field_title;
                ?>
</span>
                  <span class="sorting-indicator"></span>
                </a>
              </th>
              <th class="table_large_col payment_info_fc" <?php 
                echo $styleStr2;
                ?>
>Payment Info</th>
                  <?php 
            } else {
                ?>
              <th <?php 
                echo $styleStr;
                ?>
 id="<?php 
                echo $sorted_labels_id[$i] . '_fc';
                ?>
" class="<?php 
                echo $sorted_label_types[$i] == 'type_mark_map' || $sorted_label_types[$i] == 'type_matrix' ? 'table_large_col ' : '';
                echo $sorted_labels_id[$i] . '_fc';
                if ($order_by == $sorted_labels_id[$i] . "_field") {
                    echo $oder_class . '"';
                } else {
                    echo $oder_class_default . '"';
                }
                ?>
">
                <a href="" onclick="spider_set_input_value('order_by', '<?php 
                echo $sorted_labels_id[$i] . '_field';
                ?>
');
                                    spider_set_input_value('asc_or_desc', '<?php 
                echo isset($_POST['asc_or_desc']) && isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) == $sorted_labels_id[$i] . '_field' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
                ?>
');
                                    spider_form_submit(event, 'admin_form')">
                  <span><?php 
                echo $field_title;
                ?>
</span>
                  <span class="sorting-indicator"></span>
                </a>
              </th>
                  <?php 
            }
        }
        ?>
		           
            </tr>
            <tr id="fields_filter" style="display: none;">
              <th></th>
              <th></th>
              <th></th>
              <th></th>
              <th class="submitid_fc" <?php 
        echo $style_id;
        ?>
 ></th>
              <th width="150" class="submitdate_fc" <?php 
        echo $style_date;
        ?>
>
                <table align="center" style="margin:auto" class="simple_table">
                  <tr class="simple_table">
                    <td class="simple_table" style="text-align: left;">From:</td>
                    <td style="text-align: center;" class="simple_table">
                      <input class="inputbox" type="text" name="startdate" id="startdate" size="10" maxlength="10" value="<?php 
        echo $lists['startdate'];
        ?>
" />
                    </td>
                    <td style="text-align: center;" class="simple_table">
                      <input type="reset" style="width: 22px; border-radius: 3px !important;" class="button" value="..." onclick="return showCalendar('startdate','%Y-%m-%d');" />
                    </td>
                  </tr>
                  <tr class="simple_table">
                    <td style="text-align: left;" class="simple_table">To:</td>
                    <td style="text-align: center;" class="simple_table">
                      <input class="inputbox" type="text" name="enddate" id="enddate" size="10" maxlength="10" value="<?php 
        echo $lists['enddate'];
        ?>
" />
                    </td>
                    <td style="text-align: center;" class="simple_table">
                      <input type="reset" style="width: 22px; border-radius: 3px !important;" class="button" value="..." onclick="return showCalendar('enddate','%Y-%m-%d');" />
                    </td>
                  </tr>
                </table>
              </th>
              <th class="table_medium_col_uncenter submitterip_fc" <?php 
        echo $style_ip;
        ?>
>
                <input type="text" name="ip_search" id="ip_search" value="<?php 
        echo $lists['ip_search'];
        ?>
" onChange="this.form.submit();" />
              </th>
			
			   </th>
              <th class="table_medium_col_uncenter submitterusername_fc" <?php 
        echo $style_username;
        ?>
>
                <input type="text" name="username_search" id="username_search" value="<?php 
        echo $lists['username_search'];
        ?>
" onChange="this.form.submit();" />
              </th>
			  
			  </th>
              <th class="table_medium_col_uncenter submitteremail_fc" <?php 
        echo $style_useremail;
        ?>
>
                <input type="text" name="useremail_search" id="useremail_search" value="<?php 
        echo $lists['useremail_search'];
        ?>
" onChange="this.form.submit();" />
              </th>
			  
              <?php 
        for ($i = 0; $i < count($sorted_label_names); $i++) {
            $styleStr = $this->model->hide_or_not($lists['hide_label_list'], $sorted_labels_id[$i]);
            if (!$ka_fielderov_search) {
                if ($lists[$form_id . '_' . $sorted_labels_id[$i] . '_search']) {
                    $ka_fielderov_search = TRUE;
                }
            }
            switch ($sorted_label_types[$i]) {
                case 'type_mark_map':
                    ?>
                      <th class="table_large_col <?php 
                    echo $sorted_labels_id[$i];
                    ?>
_fc" <?php 
                    echo $styleStr;
                    ?>
></th>
                      <?php 
                    break;
                case 'type_paypal_payment_status':
                    ?>
                      <th class="table_large_col <?php 
                    echo $sorted_labels_id[$i];
                    ?>
_fc" <?php 
                    echo $styleStr;
                    ?>
>
                        <select style="font-size: 11px; margin: 0; padding: 0; height: inherit;" name="<?php 
                    echo $form_id . '_' . $sorted_labels_id[$i];
                    ?>
_search" id="<?php 
                    echo $form_id . '_' . $sorted_labels_id[$i];
                    ?>
_search" onChange="this.form.submit();" value="<?php 
                    echo $lists[$form_id . '_' . $sorted_labels_id[$i] . '_search'];
                    ?>
" >
                          <option value="" ></option>
                          <option value="canceled" >Canceled</option>
                          <option value="cleared" >Cleared</option>
                          <option value="cleared by payment review" >Cleared by payment review</option>
                          <option value="completed" >Completed</option>
                          <option value="denied" >Denied</option>
                          <option value="failed" >Failed</option>
                          <option value="held" >Held</option>
                          <option value="in progress" >In progress</option>
                          <option value="on hold" >On hold</option>
                          <option value="paid" >Paid</option>
                          <option value="partially refunded" >Partially refunded</option>
                          <option value="pending verification" >Pending verification</option>
                          <option value="placed" >Placed</option>
                          <option value="processing" >Processing</option>
                          <option value="refunded" >Refunded</option>
                          <option value="refused" >Refused</option>
                          <option value="removed" >Removed</option>
                          <option value="returned" >Returned</option>
                          <option value="reversed" >Reversed</option>
                          <option value="temporary hold" >Temporary hold</option>
                          <option value="unclaimed" >Unclaimed</option>
                        </select>	
                        <script> 
                          var element = document.getElementById('<?php 
                    echo $form_id . '_' . $sorted_labels_id[$i];
                    ?>
_search');
                          element.value = '<?php 
                    echo $lists[$form_id . '_' . $sorted_labels_id[$i] . '_search'];
                    ?>
';
                        </script>
                      </th>
                      <th class="table_large_col  payment_info_fc" <?php 
                    echo $styleStr2;
                    ?>
></th>
                      <?php 
                    break;
                default:
                    ?>
                      <th class="<?php 
                    echo $sorted_labels_id[$i];
                    ?>
_fc" <?php 
                    echo $styleStr;
                    ?>
>
                        <input name="<?php 
                    echo $form_id . '_' . $sorted_labels_id[$i] . '_search';
                    ?>
" id="<?php 
                    echo $form_id . '_' . $sorted_labels_id[$i] . '_search';
                    ?>
" type="text" value="<?php 
                    echo $lists[$form_id . '_' . $sorted_labels_id[$i] . '_search'];
                    ?>
"  onChange="this.form.submit();" >
                      </th>
                      <?php 
                    break;
            }
        }
        ?>
            </tr>
          </thead>
          <?php 
        $k = 0;
        for ($www = 0, $qqq = count($group_id_s); $www < $qqq; $www++) {
            $i = $group_id_s[$www];
            $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
            $temp = $this->model->array_for_group_id($group_id_s[$www], $rows);
            $data = $temp[0];
            $userinfo = get_userdata($data->user_id_wd);
            $useremail = $userinfo ? $userinfo->user_email : "";
            $username = $userinfo ? $userinfo->display_name : "";
            ?>
            <tr <?php 
            echo $alternate;
            ?>
>
              <td class="table_small_col count_col sub-align"><?php 
            echo $www + 1;
            ?>
</td>
              <th class="check-column table_small_col sub-align" style="padding: 0;">
                <input type="checkbox" name="post[]" value="<?php 
            echo $data->group_id;
            ?>
">
              </th>   
              <td class="table_small_col sub-align submitid_fc" id="submitid_fc" <?php 
            echo $style_id;
            ?>
>
                <a href="" onclick="spider_set_input_value('task', 'edit');						  
                                    spider_set_input_value('current_id',<?php 
            echo $data->group_id;
            ?>
);
                                    spider_form_submit(event, 'admin_form');" ><?php 
            echo $data->group_id;
            ?>
                </a>
              </td> 
              <td class="table_small_col sub-align">
                <a href="" onclick="spider_set_input_value('task', 'edit');						  
                                    spider_set_input_value('current_id',<?php 
            echo $data->group_id;
            ?>
);
                                    spider_form_submit(event, 'admin_form');">Edit
                </a>
              </td>
              <td class="table_small_col sub-align">
                <a href="" onclick="spider_set_input_value('task', 'delete');						  
                                    spider_set_input_value('current_id',<?php 
            echo $data->group_id;
            ?>
);
                                    spider_form_submit(event, 'admin_form');">Delete
                </a>
              </td>		 
              <td  class="table_large_col submitdate_fc sub-align" id="submitdate_fc" <?php 
            echo $style_date;
            ?>
>
                <a href="" onclick="spider_set_input_value('task', 'edit');						  
                                    spider_set_input_value('current_id',<?php 
            echo $data->group_id;
            ?>
);
                                    spider_form_submit(event, 'admin_form');" ><?php 
            echo $data->date;
            ?>
                </a>
              </td>
              <td class="table_medium_col_uncenter submitterip_fc sub-align" id="submitterip_fc" <?php 
            echo $style_ip;
            ?>
>
                <a class="thickbox-preview" href="<?php 
            echo add_query_arg(array('action' => 'fromipinfoinpopup_fmc', 'data_ip' => $data->ip, 'width' => '400', 'height' => '300', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
            ?>
" title="Show submitter information" <?php 
            echo !in_array($data->ip, $blocked_ips) ? '' : 'style="color: #FF0000;"';
            ?>
><?php 
            echo $data->ip;
            ?>
</a>
              </td>
			  
			  
			  
			  <td  class="table_large_col submitterusername_fc sub-align" id="submitterusername_fc" <?php 
            echo $style_username;
            ?>
>
               <?php 
            echo $username;
            ?>
              </td>
			  
			  <td  class="table_large_col submitteremail_fc sub-align" id="submitteremail_fc" <?php 
            echo $style_useremail;
            ?>
>
                <?php 
            echo $useremail;
            ?>
              </td>
			  
			  
			  
              <?php 
            for ($h = 0; $h < $m; $h++) {
                $not_label = TRUE;
                for ($g = 0; $g < count($temp); $g++) {
                    $styleStr = $this->model->hide_or_not($lists['hide_label_list'], $sorted_labels_id[$h]);
                    if ($temp[$g]->element_label == $sorted_labels_id[$h]) {
                        if (strpos($temp[$g]->element_value, "***map***")) {
                            $map_params = explode('***map***', $temp[$g]->element_value);
                            ?>
              <td class="table_large_col <?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc sub-align" id="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
>
                <a class="thickbox-preview" href="<?php 
                            echo add_query_arg(array('action' => 'frommapeditinpopup_fmc', 'long' => $map_params[0], 'lat' => $map_params[1], 'width' => '620', 'height' => '550', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                            ?>
" title="Show on Map">Show on Map</a>
              </td>
                    <?php 
                        } elseif (strpos($temp[$g]->element_value, "*@@url@@*")) {
                            ?>
              <td class="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc sub-align" id="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
>
                      <?php 
                            $new_files = explode("*@@url@@*", $temp[$g]->element_value);
                            foreach ($new_files as $new_file) {
                                if ($new_file) {
                                    $new_filename = explode('/', $new_file);
                                    $new_filename = $new_filename[count($new_filename) - 1];
                                    ?>
                <a target="_blank" class="fm_fancybox" rel="group_<?php 
                                    echo $www;
                                    ?>
" href="<?php 
                                    echo $new_file;
                                    ?>
"><?php 
                                    echo $new_filename;
                                    ?>
</a><br />
                          <?php 
                                }
                            }
                            ?>
              </td>
                      <?php 
                        } elseif (strpos($temp[$g]->element_value, "***star_rating***")) {
                            $view_star_rating_array = $this->model->view_for_star_rating($temp[$g]->element_value, $temp[$g]->element_label);
                            $stars = $view_star_rating_array[0];
                            ?>
              <td align="center" class="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc sub-align" id="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
><?php 
                            echo $stars;
                            ?>
</td>
                      <?php 
                        } elseif (strpos($temp[$g]->element_value, "***matrix***")) {
                            ?>
   
              <td class="table_large_col <?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc sub-align" id="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
>
                <a class="thickbox-preview" href="<?php 
                            echo add_query_arg(array('action' => 'show_matrix_fmc', 'matrix_params' => $temp[$g]->element_value, 'width' => '620', 'height' => '550', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                            ?>
" title="Show Matrix">Show Matrix</a>
              </td>
                      <?php 
                        } elseif (strpos($temp[$g]->element_value, "@@@") !== FALSE || $temp[$g]->element_value == "@@@" || $temp[$g]->element_value == "@@@@@@@@@") {
                            ?>
              <td class="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
>
                <p><?php 
                            echo str_replace("@@@", " ", $temp[$g]->element_value);
                            ?>
</p>
              </td>
                      <?php 
                        } elseif (strpos($temp[$g]->element_value, "***grading***")) {
                            $view_grading_array = $this->model->view_for_grading($temp[$g]->element_value);
                            $items = $view_grading_array[0];
                            ?>
              <td class="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc sub-align" id="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
>
                <p><?php 
                            echo $items;
                            ?>
</p>
              </td>
                      <?php 
                        } else {
                            if (strpos($temp[$g]->element_value, "***quantity***")) {
                                $temp[$g]->element_value = str_replace("***quantity***", " ", $temp[$g]->element_value);
                            }
                            if (strpos($temp[$g]->element_value, "***property***")) {
                                $temp[$g]->element_value = str_replace("***property***", " ", $temp[$g]->element_value);
                            }
                            ?>
              <td class="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc sub-align" id="<?php 
                            echo $sorted_labels_id[$h];
                            ?>
_fc" <?php 
                            echo $styleStr;
                            ?>
>
                <p><?php 
                            echo str_replace("***br***", '<br>', stripslashes($temp[$g]->element_value));
                            ?>
</p>
              </td>
                      <?php 
                        }
                        $not_label = FALSE;
                    }
                }
                if ($not_label) {
                    ?>
              <td class="<?php 
                    echo $sorted_labels_id[$h];
                    ?>
_fc sub-align" id="<?php 
                    echo $sorted_labels_id[$h];
                    ?>
_fc" <?php 
                    echo $styleStr;
                    ?>
><p>&nbsp;</p></td>
                  <?php 
                }
            }
            if ($ispaypal) {
                $styleStr = $this->model->hide_or_not($lists['hide_label_list'], '@payment_info@');
                ?>
              <td class="table_large_col payment_info_fc sub-align" id="payment_info_fc" <?php 
                echo $styleStr;
                ?>
>
                <a class="thickbox-preview" href="<?php 
                echo add_query_arg(array('action' => 'paypal_info', 'id' => $i, 'width' => '600', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                ?>
">
                  <img src="<?php 
                echo WD_FMC_URL . '/images/info.png';
                ?>
" />
                </a>
              </td>
                <?php 
            }
            ?>
            </tr>
            <?php 
            $k = 1 - $k;
        }
        ?>
        </table>
      </div>	 
      <?php 
        if ($sorted_label_types) {
            foreach ($sorted_label_types as $key => $sorted_label_type) {
                if ($this->model->check_radio_type($sorted_label_type)) {
                    $is_stats = true;
                    break;
                }
            }
            if ($is_stats) {
                ?>
		  <br /><br />
		  <h1 style="border-bottom: 1px solid; padding-bottom:7px; width:99%; color: hsl(197, 100%, 32%);">Statistics</h1>		
		  <table class="wp-list-table widefat fixed posts table_content" style="width: 99%;">
		    <tr>
          <td class="key" style="vertical-align: middle;width: 9%">
            <label for="sorted_label_key">Select a Field:</label>
          </td>
          <td width="330">
            <select id="sorted_label_key">
              <option value="">Select a Field</option>
                <?php 
                foreach ($sorted_label_types as $key => $sorted_label_type) {
                    if ($sorted_label_type == "type_checkbox" || $sorted_label_type == "type_radio" || $sorted_label_type == "type_own_select" || $sorted_label_type == "type_country" || $sorted_label_type == "type_paypal_select" || $sorted_label_type == "type_paypal_radio" || $sorted_label_type == "type_paypal_checkbox" || $sorted_label_type == "type_paypal_shipping") {
                        ?>
                    <option value="<?php 
                        echo $key;
                        ?>
"><?php 
                        echo $sorted_label_names_original[$key];
                        ?>
</option>
                    <?php 
                    }
                }
                ?>
            </select>
          </td>
          <td></td>
		    </tr>
		    <tr>
          <td class="key" style="vertical-align: middle;">
            <label>Select a Date:</label>
          </td>
          <td width="330">
            From: <input class="inputbox"  type="text" name="startstats" id="startstats" size="9" maxlength="9" />
                  <input type="reset" class="button" style="width: 22px; border-radius: 3px !important;"  value="..." name="startstats_but" id="startstats_but" onclick="return showCalendar('startstats','%Y-%m-%d');" /> 
                     
            To: <input class="inputbox" type="text" name="endstats" id="endstats" size="9" maxlength="9" />
                <input type="reset" class="button" style="width: 22px; border-radius: 3px !important;"  value="..." name="endstats_but" id="endstats_but" onclick="return showCalendar('endstats','%Y-%m-%d');" />
          </td>
          <td class="key" style="vertical-align: middle;">
            <input type="button" onclick="show_stats()" class="button-secondary" value="Show">
          </td>
		    </tr>
		  </table>
		  <div id="div_stats"></div>	
        <?php 
            }
        }
        ?>
    </form>	
    <script> 
      jQuery(window).load(function() {
        spider_popup();
      });
	  function show_stats() { 
		jQuery('#div_stats').html('<div id="saving"><div id="saving_text">Loading</div><div id="fadingBarsG"><div id="fadingBarsG_1" class="fadingBarsG"></div><div id="fadingBarsG_2" class="fadingBarsG"></div><div id="fadingBarsG_3" class="fadingBarsG"></div><div id="fadingBarsG_4" class="fadingBarsG"></div><div id="fadingBarsG_5" class="fadingBarsG"></div><div id="fadingBarsG_6" class="fadingBarsG"></div><div id="fadingBarsG_7" class="fadingBarsG"></div><div id="fadingBarsG_8" class="fadingBarsG"></div></div></div>');
		if(jQuery('#sorted_label_key').val()!="") {	 	  
		  jQuery('#div_stats').load('<?php 
        echo add_query_arg(array('action' => 'get_stats_fmc', 'page' => 'submissions_fmc'), admin_url('admin-ajax.php'));
        ?>
', {
		    'task': 'show_stats',
		    'form_id' : '<?php 
        echo $form_id;
        ?>
',
		    'sorted_label_key' : jQuery('#sorted_label_key').val(),
			'startdate' : jQuery('#startstats').val(), 
			'enddate' : jQuery('#endstats').val()
		    });
	    }		
		else
		  jQuery('#div_stats').html("Please select the field!")
	  }
      <?php 
        if ($ka_fielderov_search) {
            ?>
 
        document.getElementById('fields_filter').style.display = '';
        <?php 
        }
        ?>
    </script>
    <?php 
    }