<div class="col-sm-12">
    <div class="row gray">
        <div class="col-sm-12 ">
            <div class="col-sm-12">
                <h4>Edit Virtual Classroom 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');

                    $url = 'super_admin_virtual_classroom/edit-virtual-classroom-feature/';
                    echo form_open($url, 'class="" id="formID2" name="virtualClassroomFeature"');
                    ?>

                    <input type="hidden" name="feature_price_id" value="<?php echo $feature_id; ?>">
                    <input type="hidden" name="feature_holding_user" value="<?php echo count($feature_selected_user); ?>">
                    <div class="form-group col-sm-12"><br></div>


                    <div class="form-group col-sm-6">
                        <span>
                            <h4>Number of Live Classroom</h4>
                        </span>
                    </div>
                    <div class="form-group col-sm-6">
                        <div class="input-group">
                            <input type="text" 
                                   data-errormessage-value-missing="Classroom Number is Required!" 
                                   class="form-control validate[required, custom[number], custom[nonZeroValue], custom[cn_cpd]] text-input"
                                   id="classroom_number"
                                   name="classroom_number"
                                   value="<?php
                                   if (set_value('classroom_number')) {
                                       echo set_value('classroom_number');
                                   } else {
                                       echo $feature_info->virtual_classroom_number;
                                   }
                                   ?>"
                                   oninput="check_change()"
                                   placeholder="Please Type Classroom Number.."   >
                            <span class="input-group-addon"  title="Please Type Classroom Number"><i class="fa fa-language"></i></span>
                        </div>
                        <span id="classroom_number_message" style="color:red;"><?php echo form_error('classroom_number'); ?></span>
                    </div>
                    <div class="col-sm-12"><br> </div>


                    <div class="form-group col-sm-6">
                        <span>
                            <h4>Virtual classroom per day</h4>
                        </span>
                    </div>
                    <div class="form-group col-sm-6">
                        <div class="input-group">
                            <input type="text" 
                                   data-errormessage-value-missing="Virtual classroom per day is required!" 
                                   class="form-control validate[required, custom[integer], custom[nonZeroValue], custom[cn_cpd]] text-input"
                                   id="virtual_classroom_per_day"
                                   name="virtual_classroom_per_day"
                                   value="<?php
                                   if (set_value('virtual_classroom_per_day')) {
                                       echo set_value('virtual_classroom_per_day');
                                   } else {
                                       echo $feature_info->virtual_classroom_per_day;
                                   }
                                   ?>"
                                   placeholder="Please type classroom number.." >
                            <span class="input-group-addon"  title="Please Type Classroom Number"><i class="fa fa-language"></i></span>
                        </div>
                        <span id="virtual_classroom_per_day_message" style="color:red;"><?php echo form_error('virtual_classroom_per_day'); ?></span>
                    </div>
                    <div class="col-sm-12"><br></div>


                    <div class="form-group col-sm-6">
                        <span>
                            <h4>Maximum number of attendees in a classroom</h4>
                        </span>
                    </div>
                    <div class="form-group col-sm-6">
                        <div class="input-group">
                            <input type="text" 
                                   data-errormessage-value-missing="Attendees  Number is Required!" 
                                   class="form-control validate[required, custom[number], custom[nonZeroValue]] text-input"
                                   id="attendees_number"
                                   name="attendees_number"
                                   value="<?php
                                   if (set_value('attendees_number')) {
                                       echo set_value('attendees_number');
                                   } else {
                                       echo $feature_info->virtual_classroom_attendees_number;
                                   }
                                   ?>" oninput="check_change()"
                                   placeholder="Please Type Attendees  Number..">
                            <span class="input-group-addon"  title="Please Type attendees  Number"><i class="fa fa-language"></i></span>
                        </div>
                        <span id="attendees_number_message" style="color:red;"><?php echo form_error('attendees_number'); ?></span>
                    </div>
                    <div class="col-sm-12"><br> </div>


                    <div class="form-group col-sm-6">
                        <span>
                            <h4>Class Type</h4>
                        </span>
                    </div>   
                    <div class="form-group col-sm-6">
                        <div class="input-group">
                            <select data-errormessage-value-missing="Class Type is Required!" 
                                    class="form-control validate[required] text-input" 
                                    id="class_type"
                                    name="class_type">
                                <option value=""> -Select Class Type- </option>
                                <option value="1">Live Broadcast</option>
                                <option value="2">Live Broadcast with Recording</option>
                            </select>
                            <span class="input-group-addon" id="basic-addon1" title="Please select Course Language"><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>Storage Capacity</h4>
                        </span>
                    </div>
                    <div class="form-group col-sm-6">
                        <div class="input-group">
                            <input type="text" 
                                   data-errormessage-value-missing="Storage Capacity is Required!" 
                                   class="form-control validate[required, custom[number], custom[nonZeroValue]] text-input"
                                   id="storage_capacity"
                                   name="storage_capacity"
                                   value="<?php
                                   if (set_value('storage_capacity')) {
                                       echo set_value('storage_capacity');
                                   } else {
                                       echo $feature_info->feature_price_storage;
                                   }
                                   ?>" oninput="check_change()"
                                   placeholder="Please Type Storage Capacity.."   >
                            <span class="input-group-addon"  title="Please Type Storage Capacity"><i class="fa fa-empire"></i></span>
                        </div>
                        <span id="storage_capacity_message" style="color:red;"><?php echo form_error('storage_capacity'); ?></span>
                    </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) {
                                echo '<option value="1">Active</option>';
                                if (count($feature_selected_user) == 0 || $feature_info->feature_price_talhatraining == 1) {
                                    echo '<option value="0">Inactive </option>';
                                }
                            }
                            ?>
                            <?php if ($feature_info->feature_price_status == 3) { ?>
                                <option value="3">Free</option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="col-sm-4" id="free_message">
                        <span id="feature_price_status_message" style="color:red;"><?php echo form_error('feature_price_status'); ?></span>
                    </div>
                    <div class="col-sm-12"><br></div>


                    <div id="price_option" style="display: 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($fx->toForeign(set_value('price')));
//                                    } else {
//                                        $price = fmtMoney($fx->toForeign($feature_info->virtual_classroom_price));
//                                    }
//                                } else if ($currency_type == 2) {
//                                    if (set_value('price')) {
//                                        $price = fmtMoney(set_value('price'));
//                                    } else {
//                                        $price = fmtMoney($fx->toForeign($feature_info->virtual_classroom_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($fx->toForeign(set_value('price')));
//                                    } else {
//                                        $price = fmtMoney(($feature_info->virtual_classroom_price));
//                                    }
//                                } else if ($currency_type == 2) {
//                                    if (set_value('price')) {
//                                        $price = fmtMoney(set_value('price'));
//                                    } else {
//                                        $price = fmtMoney($fx->toForeign($feature_info->virtual_classroom_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="form-group col-sm-6">
                        <span>
                            <h4>Talharaining feature</h4>
                        </span>
                    </div>

                    <div class="form-group col-sm-6">
                        <div class="input-group">
                            <div class="radio radio-success">
                                <?php if ($feature_info->feature_price_talhatraining == 1) { ?>
                                    <input type="radio" name="feature_price_talhatraining" id="yes" value="1" checked onclick="priceOption();">
                                    <label for="yes">Yes</label>
                                    <span style="margin-right: 30px"></span>
                                <?php } ?>
                                <?php if ($feature_info->feature_price_talhatraining != 1) { ?>
                                    <input type="radio" name="feature_price_talhatraining" id="no" value="2" checked onclick="priceOption();">
                                    <label for="no">No</label>
                                <?php } ?>
                            </div>
                        </div>
                        <span id="feature_price_talhatraining_message" style="color:red;"><?php echo form_error('feature_price_talhatraining'); ?></span>
                    </div>

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

                    <?php if ($feature_info->feature_price_talhatraining == 1) { ?>
                        <div id="tt_feature" style="display: none">
                            <div class="form-group col-sm-6">
                                <span>
                                    <h4>Resource Person</h4>
                                </span>
                            </div>

                            <?php
                            $selected_tt_teacher = array();
                            foreach ($feature_selected_user as $value) {
                                $selected_tt_teacher[$value->person_id] = TRUE;
                            }
                            ?>

                            <div class="col-sm-6">
                                <input class="col-sm-12"
                                       type="hidden" name="to_address" id="to_address" value="" >
                                <div class="col-sm-12 padding-zero">

                                    <select name="resource_person"  
                                            id="resource_person"
                                            data-errormessage-value-missing="course_days is is Required!"
                                            class="tokenize-sample validate[]"
                                            title="" 
                                            multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                                                <?php
                                                foreach ($tt_resource_person as $v_person) {
                                                    if ($tt_resource_person_feature_info[$v_person->person_id]->feature_price_talhatraining == 1 && !$selected_tt_teacher[$v_person->person_id]) {
                                                        continue;
                                                    }
                                                    ?>
                                            <option value="<?php echo $v_person->person_id; ?>" <?php
                                            if ($selected_tt_teacher[$v_person->person_id]) {
                                                echo 'selected="1"';
                                            }
                                            ?>>
                                                        <?php echo $v_person->person_first_name . ' (' . $v_person->person_email . ')'; ?>
                                            </option>

                                            <?php
                                        }
                                        ?>
                                    </select>
                                </div>
                                <script type="text/javascript">
                                    $('select#resource_person').tokenize({placeholder: '<span style="font-size:14px;">Please type resource person name</span>'});
                                </script>
                                <span style="color: red;" id="resource_person_message"><?php echo form_error('resource_person'); ?></span>
                            </div>
                            <div class="col-sm-12"><br></div>
                        </div>
                    <?php } ?>

                    <div class="col-sm-12 text-center" id="form_message">  </div>
                    <div class="form-group col-sm-4 col-sm-offset-4">
                        <input type="submit" class="green-btn btn btn-default" value="Update!" onclick="checkFields()"><br/><br/>
                    </div>
                    <div class="col-sm-3"></div>
                    <?php echo form_close(); ?>
                </div>
            </div>
        </div><!-- /.row gray -->
    </div>
</div>
<?php
$feature_type = 'paid';
if ($feature_info->feature_price_status == 3) {
    $feature_type = 'free';
}
?>
