<?php $this->load->view("top_application"); ?>
<section>
  <div class="tz">
    <!--LEFT SECTION-->
    <div class="tz-l">

      <?php $this->load->view("members/left"); ?>

    </div>
    <!--CENTER SECTION-->
    <div class="tz-4"> 
      <div class="tz-2-com tz-2-main">
        <h4>Update Contact Details</h4>
        <div class="db-list-com tz-db-table">
          <div class="ds-boar-title">
            <h2>Update Contact Details</h2>
          </div>
          <div class="hom-cre-acc-left hom-cre-acc-right">
            <div class="">
              <?php
              echo validation_message();
              echo error_message();
              ?>
              <form class="" action="" enctype="multipart/form-data" method="post">
                <div class="row compnayprofilePicture">
                  <div class="input-field col s8">
                    <div class="row">
                      <div class="input-field col s4">
                        <select name="mtitle">
                          <option value="" disabled selected>Title*</option>
                          <option <?php echo ($mres['title'] == 'Mr.' || $this->input->post('mtitle') == 'Mr.') ? 'selected' : ''; ?> value="Mr.">Mr.</option>
                          <option <?php echo ($mres['title'] == 'Mrs.' || $this->input->post('mtitle') == 'Mrs.') ? 'selected' : ''; ?> value="Mrs.">Mrs.</option>
                          <option <?php echo ($mres['title'] == 'Miss.' || $this->input->post('mtitle') == 'Miss.') ? 'selected' : ''; ?> value="miss.">Miss.</option>
                          <option <?php echo ($mres['title'] == 'Dr.' || $this->input->post('mtitle') == 'Dr.') ? 'selected' : ''; ?> value="Dr.">Dr.</option>
                          <option <?php echo ($mres['title'] == 'Ms.' || $this->input->post('mtitle') == 'Ms.') ? 'selected' : ''; ?> value="Ms.">Ms.</option>

                        </select>
                      </div>
                      <div class="input-field col s4">
                        <input id="first_name" name="first_name" type="text" value="<?php echo set_value('first_name', $mres['first_name']); ?>" class="validate">
                        <label for="first_name">First Name*</label>
                      </div>
                      <div class="input-field col s4">
                        <input id="last_name" name="last_name" type="text" value="<?php echo set_value('last_name', $mres['last_name']); ?>" class="validate">
                        <label for="last_name">Last Name*</label>
                      </div>
                    </div>
                    <div class="row">
                      <div class="input-field col s12">
                        <input id="company_name" name="company_name" type="text" value="<?php echo set_value('company_name', $mres['company_name']); ?>" class="validate">
                        <label for="Company_name">Company Name*</label>
                      </div>
                    </div>
                  </div>
                  <div class="input-field col s4 text-right">
                    <div class="">
                      <img src="<?php echo get_image('user', $mres['profile_picture'], '125', '125', 'R'); ?>" class="profile_picture" /><div class="clearfix"></div>
                      <a href="javascript:void(0);" onclick="$('#picture').trigger('click');" class="profile_picture btn btn-xs btn-info"><i class="fa fa-plus-circle"></i> Profile Picture</a>
                    </div>
                    <input id="picture" name="picture" type="file" class="validate" style="display: none;" />
                  </div>
                </div>

                <div class="row">
                  <div class="input-field col s12">
                    <input id="list_phone" name="designation" type="text" value="<?php echo set_value('designation', $mres['designation']); ?>" class="validate">
                    <label for="list_phone">Designation*</label>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <textarea id="address" name="address" class="validate"><?php echo set_value('address', $mres['address']); ?></textarea>
                    <label for="email">Address*</label>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input id="list_phone" name="country" readonly="readonly" type="text" value="India" class="validate">
                    <label for="country">Country</label>                  
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <select name="state" id="state">
                      <option value="" disabled selected>State*</option>
                      <?php
                      foreach ($state as $sk => $sval) {
                        $sel = ($mres['state'] == $sval['id'] || $this->input->post('state') == $sval['id']) ? 'selected' : '';
                        ?>
                        <option value="<?php echo $sval['id']; ?>" <?php echo $sel; ?>><?php echo $sval['name']; ?></option>
                        <?php
                      }
                      ?>
                    </select>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12 cityListDiv">
                    <select name="city" id="city">
                      <option value="" disabled selected>Select City*</option>
                      <?php
                      foreach ($city as $ck => $cval) {
                        $csel = ($cval['id'] == $mres['city'] || $this->input->post('city') == $cval['id']) ? 'selected' : '';
                        ?>
                        <option value="<?php echo $cval['id']; ?>" <?php echo $csel; ?>><?php echo $cval['city']; ?></option>
                        <?php
                      }
                      ?>
                    </select>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input id="locality" name="locality" type="text" value="<?php echo set_value('locality', $mres['locality']); ?>" class="validate">
                    <label for="locality">Locality</label>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input id="landmark" name="landmark" type="text" value="<?php echo set_value('landmark', $mres['landmark']); ?>" class="validate">
                    <label for="landmark">Landmark</label>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input id="company_name" name="zipcode" type="text" value="<?php echo set_value('zipcode', $mres['zipcode']); ?>" class="validate">
                    <label for="zipocde">Pincode*</label>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <span class="btn btn-info">Mobile : <?php echo $this->session->userdata('mobile'); ?></span> <span class="btn btn-success">Verified</span>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input id="company_name" name="alt_mobile" type="text" value="<?php echo set_value('alt_mobile', $mres['alt_mobile']); ?>" class="validate">
                    <label for="alt_mobile">Alt Mobile No.</label>
                  </div>
                </div>
                <div class="row"> </div>
                <div class="row">
                  <?php
                  if ($mres['user_email']) {
                    ?>
                    <div class="db-v2-list-form-inn-tit">
                      <h5>Email Address - <?php echo $mres['user_email']; ?></h5>
                      <input type="hidden" name="email" value="<?php echo $mres['user_email']; ?>" />
                    </div>
                    <?php
                  } else {
                    ?>
                    <div class="input-field col s12">
                      <input id="company_name" name="email" type="text" value="<?php echo $this->input->post('email'); ?>" class="validate">
                      <label for="zipocde">Email*</label>
                    </div>
                    <?php
                  }
                  ?>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input id="alt_email" name="alt_email" type="text" value="<?php echo set_value('alt_email', $mres['alt_email']); ?>" class="validate">
                    <label for="alt_email">Alt. Email</label>
                  </div>
                </div>
                <div class="row">
                  <div class="input-field col s12">
                    <input type="text" name="website" value="<?php echo set_value('website', $mres['website']); ?>" class="validate">
                    <label>Website</label>
                  </div>
                </div>

                <div class="row">
                  <input type="hidden" name="city_id" id="city_id" value="" />
                  <div class="input-field col s12 v2-mar-top-40"> <button class="waves-effect waves-light btn-large full-btn" type="submit">Update Contact Details</button> </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
    
  </div>
</section>
<?php $this->load->view("bottom_application"); ?>
<script type="text/javascript">
  $('#state').change(function () {
    var stId = $(this).val();
    $.post('<?php echo site_url(); ?>home/get_citylist', {stateId: stId}, function (data) {
      $('#city').html('');
      $('#city').html(data);
      $('select').material_select();
    });
  });
</script>