<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<div class="" id="addSub">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal heading -->
<div class="modal-header">
    <a class="btn  pull-right mar" href="<?php echo base_url(); ?>index.php/subscriber/subscriber_list"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> </a>
    <h3 class="modal-title" align="left">Add Subscriber Details</h3>
</div>
<!-- // Modal heading END -->
<!-- Modal body -->
<div class="modal-body">
<div class="innerAll">
<div class="innerLR">
<form class="form-horizontal" role="form" id = "add_subscriber" action="<?php echo base_url(); ?>index.php/subscriber/add_subscriber" method = "post" enctype="multipart/form-data">
<?php $this->load->view('admin/flashdata_admin'); ?>
<div class = "form-group mmar" id="give_msgs" style="text-align: center"></div>
<div class = "form-group mmar" id="all_msgs" style="text-align: center"></div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left ">Upload  Subscriber Image: </label>
    <div class="col-sm-9">
        <input type="file" class="form-control " name = "sub_image" id="sub_image"/>
    </div>
</div>
<!--<div  class="form-group mmar">
										<label  class="col-sm-3 control-label text-center">Crop Image: </label>
										<div class="col-sm-9">
											<img src="<?php echo base_url(); ?>assets/images/avatar-large.jpg" class="img-responsive" id="jcrop-target-2" alt=""/>

										</div>
									</div> -->
<div class="form-group mmar">
    <!--<label  class="col-sm-3 control-label text-center">Salutation: </label>
    <div class="col-sm-2">
        <select class="cust_select col-md-12 marl-n validate[required] text-input" name = "sub_salution">
            <option value = "mr">Mr.</option>
            <option value = "mrs">Mr.s</option>
        </select>
    </div> -->
    <label  class="col-sm-3 control-label text-left">Surname: </label>
    <div class="col-sm-9">
        <input type="text" class="form-control" name = "sub_last_name" id="sub_last_name"/>
    </div>


</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left">Name: </label>
    <div class="col-sm-9">
        <input type="text" class="form-control" name = "sub_first_name" id="sub_first_name"/>
    </div>

</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left ">Date of Birth: </label>
    <div class="col-sm-4">
        <input type="text" data-date-format="dd-mm-yyyy" class="form-control date" name = "sub_dob" id="sub_dob" readonly/>
    </div>

    <label  class="col-sm-2 control-label text-left ">NRIC: </label>
    <div class="col-sm-3">
        <input type="text" class="form-control" name = "sub_nric" id="sub_nric"/>
    </div>
</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left">Email ID: </label>
    <div class="col-sm-4">
        <input type="text" class="form-control " value="" name = "sub_email" id="sub_email"/>
    </div>
    <label  class="col-sm-2 control-label text-left">Gender: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n" id = "gender" name = "gender">
            <option value = "">--select--</option>
            <option value = "1">Male</option>
            <option value = "2">Female</option>
        </select>
    </div>
</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left">Phone No.: </label>
    <div class="col-sm-9">
        <div style="float: left;margin-right:10px;">
            <?php if (count($country_code) > 0) {?>
                <select name="country_code" id="country_code" class="cust_select marl-n " style="width:118px">
                    <option value="">Country Code</option>
                    <?php
                    foreach($country_code as $code => $name) {?>
                        <option value="<?php echo $code;?>"
                            <?php if ($code == '65') {?> selected="selected" <?php } ?>
                            ><?php echo $name;?></option>
                    <?php } ?>
                </select>
            <?php } ?>
        </div>

        <div style="margin-left: 10px">
            <div id ="phone_no" style="float:left;margin-right:10px"> +65 </div>
            <input type="text" class="form-control " value="" name = "sub_phonno" id = "sub_phonno" style="width:180px"/>
        </div>
    </div>
</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left">Mobile Number: </label>
    <div style="float: left;margin-right:10px;">
        <?php if (count($country_code) > 0) {?>
            <select name="country_code_mobile" id="country_code_mobile" class="cust_select marl-n " style="width:118px">
                <option value="">Country Code</option>
                <?php
                foreach($country_code as $code => $name) {?>
                    <option value="<?php echo $code;?>"
                        <?php if ($code == '65') {?> selected="selected" <?php } ?>
                        ><?php echo $name;?></option>
                <?php } ?>
            </select>
        <?php } ?>
    </div>
    <div style="margin-left: 10px" class="col-sm-6 control-label text-left">
        <div id ="mobile_no" style="float:left;margin-right:10px"> +65 </div>
        <input type="text" class="form-control " value="" name = "mobile_number" id = "mobile_number" style="width:180px"/>
    </div>
</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left">Subscriber Type: </label>
    <div class="col-sm-9">
        <select class="cust_select marl-n " id = "subscriber_type" name = "sub_type">
            <option value = "1">Individual</option>
            <option value = "2">School Library</option>
            <option value = "3">Student</option>
            <option value = "4">Other</option>
        </select>
    </div>

</div>
<div class = "form-group mmar" id = "sub_details">

</div>

<div class = "form-group mmar" id = "sub_school_details">
</div>
<div class = "form-group mmar" id = "sub_teacher_details">
</div>
<div class = "form-group mmar" id = "sub_other_details">
</div>
<div class="modal-header">
    <h3 class="modal-title">Subscription References</h3>
</div>

<div class="form-group mmar">
    <!-- <label  class="col-sm-3 control-label text-left">Campaign: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n " id = "campaign" name = "campaign">
            <option value = "">--Select--</option>
            <?php //foreach($arrCampaign as $campaign) {?>
                <option value = "<?php //echo $campaign['id'];?>"><?php //echo $campaign['name'];?></option>
            <?php// } ?>
        </select>
    </div> -->
    <label  class="col-sm-3 control-label text-left">Sales Agent: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n " id = "sales_agent" name = "sales_agent">
            <option value = "">--Select--</option>
            <?php foreach($arrAgent as $Agent) {?>
                <option value = "<?php echo $Agent['id'];?>"><?php echo $Agent['first_name']." ".$Agent['last_name'];?></option>
            <?php } ?>
        </select>
    </div>

</div>


<div class="modal-header">
    <h3 class="modal-title">Home Address</h3>
</div>

<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left">Country: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n " name = "sub_home_country" id = "sub_home_country">
            <option value="">-- Select --</option>
            <option value = "1">Singapore</option>
            <option value = "2">Malaysia</option>
            <option value = "3">Hong Kong</option>
            <option value = "4">Thiland</option>
        </select>
    </div>
    <label  class="col-sm-3 control-label text-left">City: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n " name = "sub_home_city" id = "sub_home_city">
            <option value="">-- Select --</option>
            <option value = "1">Singapore</option>
            <option value = "2">Kuala Lumpur</option>
            <option value = "3">Victoria City</option>
            <option value = "4">Bankok</option>
        </select>
    </div>
</div>
<div id="home_address_id">
    <div class="form-group mmar">
        <label  class="col-sm-3 control-label text-left">Block: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_home_block" id = "sub_home_block"/>
        </div>
        <label  class="col-sm-3 control-label text-left">Unit No.: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_home_unit_no" id = "sub_home_unit_no"/>
        </div>
    </div>
    <div class="form-group mmar">
        <label  class="col-sm-3 control-label text-left">Street name: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_home_street" id = "sub_home_street"/>
        </div>
        <label  class="col-sm-3 control-label text-left">Building Name: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_home_build" id = "sub_home_build"/>
        </div>
    </div>
    <div class="form-group mmar">
        <label  class="col-sm-3 control-label text-left">Postal Code: </label>
        <div class="col-sm-5">
            <input type="text" class="form-control " name = "sub_home_code" id = "sub_home_code"/>
        </div>

    </div>
</div>
<div class="form-group mmar" id="address_1">
    <label  class="col-sm-3 control-label text-left">Address 1: </label>
    <div class="col-sm-9">
        <textarea name="address_1" id="address_1_text" class="form-control" placeholder="please enter address 1"></textarea>
    </div>
</div>
<br/>
<div style = "clear:both">

<div class="form-group mmar">
    <input type="checkbox" name="same_above" id="same_above" value="same" onclick="sameAsAbove()"/> <b>Mailing address same as above</b>
    <br/>
</div>

<div class="modal-header">
    <h3 class="modal-title">Mailing Address</h3>
</div>
<div class="form-group mmar">
    <label  class="col-sm-3 control-label text-left ">Country: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n validate[required] text-input" name = "sub_country" id = "sub_country">
            <option value="">-- Select --</option>
            <option value = "1">Singapore</option>
            <option value = "2">Malaysia</option>
            <option value = "3">Hong Kong</option>
            <option value = "4">Thiland</option>
        </select>
    </div>
    <label  class="col-sm-3 control-label text-left">City: </label>
    <div class="col-sm-3">
        <select class="cust_select marl-n validate[required] text-input" name = "sub_city" id = "sub_city">
            <option value="">-- Select --</option>
            <option value = "1">Singapore</option>
            <option value = "2">Kuala Lumpur</option>
            <option value = "3">Victoria City</option>
            <option value = "4">Bankok</option>
        </select>
    </div>
</div>
<div id="mail_address_all_field">
    <div class="form-group mmar">
        <label  class="col-sm-3 control-label text-left">Block: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_block" id = "sub_block"/>
        </div>
        <label  class="col-sm-3 control-label text-left">Unit No.: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_unit_no" id = "sub_unit_no"/>
        </div>
    </div>
    <div class="form-group mmar">
        <label  class="col-sm-3 control-label text-left">Street name: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_street" id = "sub_street"/>
        </div>
        <label  class="col-sm-3 control-label text-left">Building Name: </label>
        <div class="col-sm-3">
            <input type="text" class="form-control " name = "sub_build" id = "sub_build"/>
        </div>
    </div>
    <div class="form-group mmar">
        <label  class="col-sm-3 control-label text-left">Postal Code: </label>
        <div class="col-sm-5">
            <input type="text" class="form-control validate[required] text-input" name = "sub_code" id = "sub_code"/>
        </div>
    </div>
</div>
<div class="form-group mmar" id="address_2">
    <label  class="col-sm-3 control-label text-left">Address 2: </label>
    <div class="col-sm-9">
        <textarea name="address_2" id="address_2_text" class="form-control" placeholder="please enter address 2"></textarea>
    </div>
</div>
<br/>
<div style = "clear:both">

</div>
<div class="form-group">
    <div class="col-sm-offset-4 col-sm-8">
        <input type="hidden" id="system_base_url" value="<?php echo base_url();?>">
        <input type = "hidden" name = "prevNric"  id = "prevNric" value =">" />
        <input type = "hidden" name = "prevFirstName"  id = "prevFirstName" value ="" />
        <input type = "hidden" name = "prevLastName"  id = "prevLastName" value ="" />
        <input type = "hidden" name = "prevDob"  id = "prevDob" value ="" />
        <button type="submit" class="btn btn-primary" id="submit_sub">Submit</button>
        <a class="btn" href="<?php echo base_url(); ?>index.php/subscriber/subscriber_list"> <button type="button" class="btn btn-primary">Cancel</button></a>
    </div>
</div>
</form>
</div>
</div>
</div>
<!-- // Modal body END -->
</div>
</div>
</div>
<script src="<?php echo base_url();?>assets/js/main.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/custom.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_multiselect/js/jquery.multi-select.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_fuelux-radio/fuelux-radio.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_multiselect/multiselect.init.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/subscriber.js"></script>


<script>
    $(document).ready(function() {
        $("#address_2").hide();
        $("#address_1").hide();
        $("#add_subscriber").validationEngine();

        $("#sub_country").change(function(){
            var country_val = parseInt($("#sub_country").val());
            if (country_val > 1) {
                $("#address_2").show();
                $("#mail_address_all_field").hide();
            } else {
                $("#address_2").hide();
                $("#mail_address_all_field").show();
            }
        });

        $("#sub_home_country").change(function(){
            var sub_home_country = parseInt($("#sub_home_country").val());
            if (sub_home_country > 1) {
                $("#address_1").show();
                $("#home_address_id").hide();
            } else {
                $("#address_1").hide();
                $("#home_address_id").show();
            }
        });
    });
    function sameAsAbove(){
        if($('#same_above').is(":checked")) {
            $("#sub_block").val($("#sub_home_block").val());
            $("#sub_unit_no").val($("#sub_home_unit_no").val());
            $("#sub_street").val($("#sub_home_street").val());
            $("#sub_country").val($("#sub_home_country").val());
            $("#sub_city").val($("#sub_home_city").val());
            $("#sub_code").val($("#sub_home_code").val());
            $("#sub_build").val($("#sub_home_build").val());
            $("#address_2_text").val($("#address_1_text").val());

            var intCountryVal = parseInt($("#sub_country").val());
            if (intCountryVal > 1) {
                $("#address_2").show();
                $("#mail_address_all_field").hide();
            } else {
                $("#address_2").hide();
                $("#mail_address_all_field").show();
            }
        }else{
            $("#shipping_name").val('');
            $("#sub_block").val('');
            $("#sub_unit_no").val('');
            $("#sub_street").val('');
            $("#sub_country").val('');
            $("#sub_city").val('');
            $("#sub_code").val('');
            $("#sub_build").val('');
        }
    }
</script>
