<div class="col-sm-12">
    <div class="row gray">
        <div class="col-sm-12 ">
            <div class="col-sm-12">
                <h4>Edit Explore Expert Resume Feature</h4>  
                <hr>
            </div>
            <div class="col-sm-12">
                <div class="col-sm-12  ">
                    <?php
//                    echo validation_errors();
                    $feature_id = $this->session->userdata('feature_id');
                    ?>
                    <form id="formID2" name="exploreExpertResumeFeature"
                          action="<?php echo base_url() . 'super_admin_virtual_classroom/edit-explore-expert-resume-feature'; ?>"  
                          method="post"  enctype="multipart/form-data">
                        <input type="hidden" name="feature_price_id" value="<?php echo $feature_id; ?>">
                        <div class="form-group col-sm-12"><br></div>
                        <div class="form-group col-sm-6">
                            <span>
                                <h4>Explore Expert Resume Per Day</h4>
                            </span>
                        </div>   
                        <div class="form-group col-sm-6">
                            <div class="input-group">
                                <input type = "text" 
                                       data-errormessage-value-missing="Explore Expert Resume Number is Required!" 
                                       class="form-control validate[required, custom[number], custom[nonZeroValue]] text-input"
                                       id="explore_expert_resume_per_day"
                                       name="explore_expert_resume_per_day"
                                       value="<?php
                                       if (set_value('explore_expert_resume_per_day')) {
                                           echo set_value('explore_expert_resume_per_day');
                                       } else {
                                           echo $feature_info->explore_expert_resume_per_day;
                                       }
                                       ?>" placeholder="Please Type Explore Expert Resume Number.."   >
                                <span class="input-group-addon"  title="Please Type Explore Expert Resume Number"><i class="fa fa-language"></i></span>
                            </div>
                        </div>
                        <div class="col-sm-12"><br> </div>


                        <div class="form-group col-sm-6">
                            <span>
                                <h4>Feature Price Status</h4>
                            </span>
                        </div>   

                        <div class="col-sm-2">
                            <select data-errormessage-value-missing="Feature Price Status is Required!" 
                                    class="form-control validate[required] text-input"
                                    name="feature_price_status" id="feature_price_status"
                                    oninput="priceOption(this.value)">
                                <option value="">Status</option>
                                <?php // if ($feature_info->feature_price_status != 3) { ?>
                                    <option value="1">Active</option>
                                    <option value="0">Inactive</option>
                                <?php // } ?>
                                <?php // if ($feature_info->feature_price_status == 3) { ?>
                                    <option value="3">Free</option>
                                <?php // } ?>

                            </select>
                        </div>
                        <div class="col-sm-4" id="free_message"></div>
                        <div class="col-sm-12"><br></div>

                        <div id="price_option" style="display: <?php
                        if ($feature_info->feature_price_status != 3) {
                            echo 'block';
                        } if ($feature_info->feature_price_status == 3) {
                            echo 'none';
                        }
                        ?>">
                            <div class="form-group col-sm-6">
                                <span>
                                    <h4>Price</h4>
                                </span>
                            </div>

                            <div class="col-sm-2">
                                <select data-errormessage-value-missing="Currency is Required!" 
                                        class="form-control validate[required] text-input"
                                        name="currency" id="currency">
                                    <option value="">Currency</option>
                                    <option value="1">BDT</option>
                                    <option value="2">USD</option>
                                </select>
                            </div>

                            <div class="form-group col-sm-4">
                                <?php
//                                if (set_value('currency')) {
//                                    $this->load->library('ForeignExchange');
//                                    $fx = new ForeignExchange('BDT', 'USD');
//                                    $currency_type = set_value('currency');
//                                    if ($currency_type == 1) {
//                                        if (set_value('price')) {
//                                            $price = fmtMoney(set_value('price'));
//                                        } else {
//                                            $price = fmtMoney($feature_info->explore_expert_resume_price);
//                                        }
//                                    } else if ($currency_type == 2) {
//                                        if (set_value('price')) {
//                                            $price = fmtMoney($fx->toForeign(set_value('price')));
//                                        } else {
//                                            $price = fmtMoney($fx->toForeign($feature_info->explore_expert_resume_price));
//                                        }
//                                    }
//                                } else if ($feature_info->feature_price_currency) {
//                                    $this->load->library('ForeignExchange');
//                                    $fx = new ForeignExchange('BDT', 'USD');
//                                    $currency_type = $feature_info->feature_price_currency;
//                                    if ($currency_type == 1) {
//                                        if (set_value('price')) {
//                                            $price = fmtMoney(set_value('price'));
//                                        } else {
//                                            $price = fmtMoney($feature_info->explore_expert_resume_price);
//                                        }
//                                    } else if ($currency_type == 2) {
//                                        if (set_value('price')) {
//                                            $price = fmtMoney($fx->toForeign(set_value('price')));
//                                        } else {
//                                            $price = fmtMoney($fx->toForeign($feature_info->explore_expert_resume_price));
//                                        }
//                                    }
//                                }
                                ?>
                                <div class="input-group">
                                    <input type="text" 
                                           data-errormessage-value-missing="Price is Required!" 
                                           class="form-control validate[required, custom[number], custom[nonZeroValue]] text-input"
                                           id="price"
                                           name="price"
                                           value="<?php
                                           if ($price) {
                                               echo $price;
                                           }
                                           ?>"
                                           placeholder="Please type price"   >
                                    <span class="input-group-addon"  title="Please Type Price"><i class="fa fa-dollar"></i></span>
                                </div>
                            </div>
                            <div class="col-sm-12"><br></div>
                        </div>


                        <div class="col-sm-12"><br></div>


                        <div class="form-group col-sm-4 col-sm-offset-4">
                            <input type="submit" class="green-btn btn btn-default" value="Update!"><br/><br/>
                        </div>
                        <div class="col-sm-3"></div>
                    </form>

                </div>

            </div>

        </div>

    </div><!-- /.row gray -->


</div>

</div>
<script>
    document.forms['exploreExpertResumeFeature'].elements['currency'].value = '<?php
                                           if (set_value('currency')) {
                                               echo set_value('currency');
                                           } else {
                                               echo $feature_info->feature_price_currency;
                                           }
                                           ?>';
    document.forms['exploreExpertResumeFeature'].elements['feature_price_status'].value = '<?php
                                           if (set_value('feature_price_status')) {
                                               echo set_value('feature_price_status');
                                           } else {
                                               echo $feature_info->feature_price_status;
                                           }
                                           ?>';


    var xmlhttp = false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        xmlhttp = new XMLHttpRequest();
    }

    function priceOption(feature_price_status) {
        if (feature_price_status == '3') {
            document.getElementById("price_option").setAttribute("style", "display:none");
            serverPage = '<?php echo base_url(); ?>super_admin_virtual_classroom/select_free_explore_expert_resume_feature_for_edit/' + '<?php echo $feature_id; ?>';
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {
//                    alert(xmlhttp.responseText);
                    if (xmlhttp.responseText === '1') {
                        document.getElementById('free_message').innerHTML = '<span style=color:red>You already have a free feature. <p>You can edit existing free feature</p></span>';
                        document.getElementById('feature_price_status').value = '';
                    } else if (xmlhttp.responseText === '2') {
                        document.getElementById('free_message').innerHTML = '';
                    }
                }
            }
            xmlhttp.send(null);

        } else if (feature_price_status === '1' || feature_price_status === '0') {
            document.getElementById("price_option").setAttribute("style", "display:block");
            document.getElementById('free_message').innerHTML = '';
        }

    }
</script>