<?php
/*
* @popup work here
*/

if ( ! function_exists('CMB_popup') ) {
	function CMB_popup() {
		$get_options_val = get_option('cmb_setting_options');
		cmb_popup_content($get_options_val);
	} 
	function cmb_data_front_exist($array = array(), $data) {
		if(!empty($array)) {
			foreach($array as $arr) {
				if($arr==$data){
					return true;
					break;
				}
			}
		}
		return false;
	}
?>
<?php function cmb_popup_content($get_options_val){ ?>
<?php if($get_options_val['cmb_act_popup'] == '1') { ?>
<style type="text/css">
.cmb-modal-box {
	<?php if($get_options_val['cmb_themes'] == 'A') { ?>
	background:#FFFFFF !important;
	color:#000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'B') { ?>
	background:#5bc0de !important;
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'C') { ?>
	background:#5cb85c !important;
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'D') { ?>
	background:#d9534f !important;
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'E') { ?>
	background:#f0ad4e !important;
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'F') { ?>
	background:#337ab7 !important;
	color:#FFFFFF !important;
	<?php } ?>
}
.cmb_top_header {
	<?php if($get_options_val['cmb_themes'] == 'A') { ?>
	color:#000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'B') { ?>
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'C') { ?>
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'D') { ?>
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'E') { ?>
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'F') { ?>
	color:#FFFFFF !important;
	<?php } ?>
}
.cmb_btn_style {
	<?php if($get_options_val['cmb_themes'] == 'A') { ?>
	background-color: #f0ad4e !important;
	border-color: #f0ad4e !important;
	color:#FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'B') { ?>
	background-color: #FFFFFF !important;
	border-color: #FFFFFF !important;
	color:#000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'C') { ?>
	background-color: #FFFFFF !important;
	border-color: #FFFFFF !important;
	color:#000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'D') { ?>
	background-color: #FFFFFF !important;
	border-color: #FFFFFF !important;
	color:#000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'E') { ?>
	background-color: #FFFFFF !important;
	border-color: #FFFFFF !important;
	color:#000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'F') { ?>
	background-color: #FFFFFF !important;
	border-color: #FFFFFF !important;
	color:#000000 !important;
	<?php } ?>
}
.cmb_button_bg {
	<?php if($get_options_val['cmb_themes'] == 'A') { ?>
	background: #FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'B') { ?>
	background: #5bc0de !important;
	<?php } else if($get_options_val['cmb_themes'] == 'C') { ?>
	background: #5cb85c !important;
	<?php } else if($get_options_val['cmb_themes'] == 'D') { ?>
	background: #d9534f !important;
	<?php } else if($get_options_val['cmb_themes'] == 'E') { ?>
	background: #f0ad4e !important;
	<?php } else if($get_options_val['cmb_themes'] == 'F') { ?>
	background: #337ab7 !important;
	<?php } ?>
}
.clb-text {
	<?php if($get_options_val['cmb_themes'] == 'A') { ?>
	color: #000000 !important;
	<?php } else if($get_options_val['cmb_themes'] == 'B') { ?>
	color: #FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'C') { ?>
	color: #FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'D') { ?>
	color: #FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'E') { ?>
	color: #FFFFFF !important;
	<?php } else if($get_options_val['cmb_themes'] == 'F') { ?>
	color: #FFFFFF !important;
	<?php } ?>
}
</style>

<div id="popup" class="cmb-modal-box">
  <header> <a href="javascript:;" class="js-modal-close cmb-close">×</a>
    <!--<h3><a href="#">Modal</a> Title</h3>-->
  </header>
  <div class="cmb-modal-body">
    <?php if($get_options_val['cmb_themes'] == 'A') { ?>
    <h2 class="cmb_top_header"><img style="width:50px;height:50px;" src="<?php echo plugins_url();?>/call-me-back/icon/call-back-request.png" />&nbsp;&nbsp;<?php echo $get_options_val['cmb_popup_top_text']; ?></h2>
    <?php } else { ?>
    <h2 class="cmb_top_header"><img style="width:50px;height:50px;" src="<?php echo plugins_url();?>/call-me-back/icon/white.png" />&nbsp;&nbsp;<?php echo $get_options_val['cmb_popup_top_text']; ?></h2>
    <?php }?>
    <div class="cmb_top_style"><?php echo $get_options_val['cmb_popup_top_html']; ?></div>
    <?php if(cmb_data_front_exist($get_options_val['cmb_fields'],'name')) { ?>
    <div class="form-group-cmb">
      <label for="cmb_name"><?php echo $get_options_val['cmb_popup_name_text']; ?></label>
      <input type="text" class="form-control-cmb form-control-cmb-width" id="cmb_name" <?php if(cmb_data_front_exist($get_options_val['cmb_r_fields'],'name')){echo "data-required='1'";} else {echo "data-required='0'";}?> name="cmb_name">
      <div class="cmb-errors" id="cmb_name_info">
        <div></div>
        <span><?php echo $get_options_val['cmb_popup_name_text']; ?> <?php echo $get_options_val['cmb_popup_required_text']; ?></span></div>
    </div>
    <?php } ?>
    <?php if(cmb_data_front_exist($get_options_val['cmb_fields'],'email')) { ?>
    <div class="form-group-cmb">
      <label for="cmb_email"><?php echo $get_options_val['cmb_popup_email_text']; ?></label>
      <input type="text" class="form-control-cmb form-control-cmb-width" id="cmb_email" <?php if(cmb_data_front_exist($get_options_val['cmb_r_fields'],'email')){echo "data-required='1'";} else {echo "data-required='0'";}?>>
      <div class="cmb-errors" id="cmb_email_info">
        <div></div>
        <span><?php echo $get_options_val['cmb_popup_email_text']; ?> <?php echo $get_options_val['cmb_popup_required_text']; ?></span></div>
    </div>
    <?php } ?>
    <?php if(cmb_data_front_exist($get_options_val['cmb_fields'],'phone')) { ?>
    <div class="form-group-cmb">
      <label for="cmb_phone"><?php echo $get_options_val['cmb_popup_phone_text']; ?></label>
      <input type="text" class="form-control-cmb form-control-cmb-width" id="cmb_phone" <?php if(cmb_data_front_exist($get_options_val['cmb_r_fields'],'phone')){echo "data-required='1'";} else {echo "data-required='0'";}?>>
      <div class="cmb-errors" id="cmb_phone_info">
        <div></div>
        <span><?php echo $get_options_val['cmb_popup_phone_text']; ?> <?php echo $get_options_val['cmb_popup_required_text']; ?></span></div>
    </div>
    <?php } ?>
    <?php if(cmb_data_front_exist($get_options_val['cmb_fields'],'message')) { ?>
    <div class="form-group-cmb">
      <label for="cmb_message"><?php echo $get_options_val['cmb_popup_message_text']; ?></label>
      <textarea class="form-control-cmb form-control-cmb-width" id="cmb_message" rows="2" <?php if(cmb_data_front_exist($get_options_val['cmb_r_fields'],'message')){echo "data-required='1'";} else {echo "data-required='0'";}?>></textarea>
      <div class="cmb-errors" id="cmb_message_info">
        <div></div>
        <span><?php echo $get_options_val['cmb_popup_message_text']; ?> <?php echo $get_options_val['cmb_popup_required_text']; ?></span></div>
    </div>
    <?php } ?>
	<?php if(cmb_data_front_exist($get_options_val['cmb_fields'],'from_to')) { ?>
	<div class="form-group-cmb">
      <div style="float:left;">
	  	<label for="cmb_call_from"><?php echo $get_options_val['cmb_popup_from_text']; ?></label>
      	<input type="text" class="form-control-cmb form-control-cmb-width-mini cmbtimepicker" id="cmb_call_from" <?php if(cmb_data_front_exist($get_options_val['cmb_r_fields'],'from_to')){echo "data-required='1'";} else {echo "data-required='0'";}?>>
		 <div class="cmb-errors" id="cmb_from_info">
        <div></div>
        <span><?php echo $get_options_val['cmb_popup_from_text']; ?> <?php echo $get_options_val['cmb_popup_required_text']; ?></span></div>
	  </div>
	  <div style="float:right;">
	  	<label for="cmb_call_to"><?php echo $get_options_val['cmb_popup_to_text']; ?></label>
      	<input type="text" class="form-control-cmb form-control-cmb-width-mini cmbtimepicker" id="cmb_call_to" <?php if(cmb_data_front_exist($get_options_val['cmb_r_fields'],'from_to')){echo "data-required='1'";} else {echo "data-required='0'";}?>>
		<div class="cmb-errors" id="cmb_to_info">
        <div></div>
        <span><?php echo $get_options_val['cmb_popup_to_text']; ?> <?php echo $get_options_val['cmb_popup_required_text']; ?></span></div>
	  </div>
	  <div style="clear:both;"></div>
    </div>
	<?php } ?>
    <div style="margin-top:10px;"><button type="button" onclick="cmbPopupSubmit();" class="cmbbtn cmb_btn_style"><?php echo $get_options_val['cmb_popup_button_text']; ?></button></div>
	<div class="cmb_loader"><img src="<?php echo plugins_url();?>/call-me-back/icon/loader.gif" /></div>
  </div>
  <!--<footer> <a href="#" class="js-modal-close">Close Button</a> </footer>-->
</div>
<div class="<?php echo $get_options_val['cmb_btn_position']; ?> cmb_button_bg" id="clb-bottom-btn" style="width: 254px;"><a class="js-open-modal" data-modal-id="popup" href="javascript:;"><img class="clb-bottom-btn-photo" src="<?php echo $get_options_val['cmb_button_image']; ?>">
  <div class="clb-text"><?php echo $get_options_val['cmb_popup_call_text']; ?>
    <div class="after"></div>
  </div>
  </a></div>
  <input type="hidden" id="cmb_ajax_post_url" value="<?php echo admin_url( 'admin-ajax.php' ); ?>" />
  <input type="hidden" id="cmb_call_success_text" value="<?php echo $get_options_val['cmb_popup_success_text']; ?>" />
<?php } ?>
<?php } ?>
<?php } ?>
