<?php include("includes/head.php");?>
<?php 
//$_GET['sid'] = '2';
if(isset($_GET['sid']) && $_GET['sid']!='')
{
	$query_shInfo = "SELECT * FROM ".TBL_STAKEHOLDERS." WHERE id = '$_GET[sid]'";
	$shInfo = $con->getSingleRow($query_shInfo);
}
?>
<body>
<form name="frmStockholders" id="frmStockholders">
  <input type="hidden" name="action" value="updateGenInfo">
  <input type="hidden" name="shid" value="<?php echo isset($_GET['sid'])?$_GET['sid']:'';?>">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close" onClick="$.colorbox.close();"><span aria-hidden="true">&times;</span> </button>
    <h4 class="modal-title" id="myModalLabel">Update Stakeholder General Info</h4>
  </div>
  <div class="modal-body">
    <div role="tabpanel">
      <!-- Tab panes -->
      <div class="tab-content">
        <!--<div role="tabpanel" class="tab-pane active" id="uploadTab">upload Tab</div>
            <div role="tabpanel" class="tab-pane" id="browseTab">browseTab</div>-->
        <div id="TabGeneral" class="tab-pane in active custon-tab-style1">
          <div class="basic-login-form-ad">
            <div class="row" style="margin-top:30px;">
              <div class="col-lg-10">
                <div class="all-form-element-inner">
                  <div class="form-group-inner">
                    <div class="row">
                      <div class="col-lg-5">
                        <label class="login2 pull-right pull-right-pro">Name of Stackholder <span style="color: #FF0000;">*</span></label>
                      </div>
                      <div class="col-lg-7">
                        <input type="text" class="form-control" name="name" id="sh_name" value="<?php echo isset($shInfo['name'])?$shInfo['name']:'';?>" required/>
                      </div>
                    </div>
                  </div>
                  <div class="form-group-inner">
                    <div class="row">
                      <div class="col-lg-5">
                        <label class="login2 pull-right pull-right-pro">Abbreviation <span style="color: #FF0000;">*</span></label>
                      </div>
                      <div class="col-lg-7">
                        <input type="text" class="form-control" name="abbreviation" id="sh_abbreviation" value="<?php echo isset($shInfo['abbreviation'])?$shInfo['abbreviation']:'';?>" required/>
                      </div>
                    </div>
                  </div>
                  <div class="form-group-inner">
                    <div class="row">
                      <div class="col-lg-5">
                        <label class="login2 pull-right pull-right-pro">Logo <span style="color: #FF0000;">*</span></label>
                      </div>
                      <div class="col-lg-7">
                        <input type="file" name="sh_logo" id="sh_logo" value=""/>
                        <input type="hidden" name="old_sh_logo" value="<?php echo isset($shInfo['sh_logo'])?$shInfo['sh_logo']:'';?>">
                        <img src="uploads/stake-holders/<?php echo isset($shInfo['sh_logo'])?$shInfo['sh_logo']:'';?>" width="50" height="50"> </div>
                    </div>
                  </div>
                  <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">Areas of Operations </label>
                        </div>
                        <div class="col-lg-7">
                          <input type="text" class="form-control" name="areas_of_operations" id="sh_areas_of_operations" value="<?php echo isset($shInfo['areas_of_operations'])?$shInfo['areas_of_operations']:'';?>"/>
                        </div>
                      </div>
                    </div>
                    <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">PWD Oriented</label>
                        </div>
                        <div class="col-lg-7">
                          <input type="checkbox" class="" name="pwd_oriented" id="sh_pwd_oriented" value="Y" <?php if(isset($shInfo['pwd_oriented']) && $shInfo['pwd_oriented']=='Y'){?>checked<?php }?> />
                        </div>
                      </div>
                    </div>
                    <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">Address </label>
                        </div>
                        <div class="col-lg-7">
                          <input type="text" class="form-control" name="address" id="sh_address" value="<?php echo isset($shInfo['address'])?$shInfo['address']:'';?>"/>
                        </div>
                      </div>
                    </div>
                    <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">Focal Person </label>
                        </div>
                        <div class="col-lg-7">
                          <input type="text" class="form-control" name="focal_person" id="sh_focal_person" value="<?php echo isset($shInfo['focal_person'])?$shInfo['focal_person']:'';?>"/>
                        </div>
                      </div>
                    </div>
                    <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">Contact# </label>
                        </div>
                        <div class="col-lg-7">
                          <input type="text" class="form-control" name="tel_no" id="sh_tel_no" value="<?php echo isset($shInfo['tel_no'])?$shInfo['tel_no']:'';?>"/>
                        </div>
                      </div>
                    </div>
                    <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">E-mail </label>
                        </div>
                        <div class="col-lg-7">
                          <input type="text" class="form-control" name="email" id="sh_email" value="<?php echo isset($shInfo['email'])?$shInfo['email']:'';?>"/>
                        </div>
                      </div>
                    </div>
                    
                    <div class="form-group-inner">
                      <div class="row">
                        <div class="col-lg-5">
                          <label class="login2 pull-right pull-right-pro">Website </label>
                        </div>
                        <div class="col-lg-7">
                          <input type="text" class="form-control" name="website_url" id="website_url" value="<?php echo isset($shInfo['website_url'])?$shInfo['website_url']:'';?>"/>
                        </div>
                      </div>
                    </div>
                    
                  <div class="form-group-inner">
                    <div class="row">
                      <div class="col-lg-5">
                        <label class="login2 pull-right pull-right-pro">Select Category <span style="color: #FF0000;">*</span></label>
                      </div>
                      <div class="col-lg-7">
                        <div class="form-select-list">
                          <select class="form-control custom-select-value" name="category_id" id="sh_category_id" required>
                            <option value="">Select Category</option>
                            <?php 
								$selQry_listings = "SELECT * FROM ".TBL_CATEGORIES." ORDER BY category_title";
								$listingsInfo =  $con->getMultiRow($selQry_listings, __FILE__,__LINE__);
								$totListings = count($listingsInfo);	
									for($t=0;$t<$totListings;$t++)
									{
								?>
                            <option value="<?php echo $listingsInfo[$t]['category_id'];?>" <?php if ( isset($shInfo['category_id']) && $shInfo['category_id']==$listingsInfo[$t]['category_id']){?> selected<?php }?>><?php echo $listingsInfo[$t]['category_title'];?></option>
                            <?php }?>
                          </select>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-lg-12">
                <div class="static-table-list">
                  <table class="table" border="1">
                    <thead>
                      <tr>
                        <th colspan="3" style="text-align:center;">Pre-Defined Orientation</th>
                      </tr>
                      <tr>
                        <th width="33%">Title</th>
                        <th width="33%">Def.</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <td>SH interest</td>
                        <td><div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="Low" name="orientation_sh_interest" id="orientation_sh_interest_low" <?php if ( isset($shInfo['orientation_sh_interest']) && $shInfo['orientation_sh_interest']=='Low'){?>checked <?php }?> >
                                <i></i> Low </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="Medium" name="orientation_sh_interest" id="orientation_sh_interest_medium" <?php if ( isset($shInfo['orientation_sh_interest']) && $shInfo['orientation_sh_interest']=='Medium'){?>checked <?php }?>>
                                <i></i> Medium </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="High" name="orientation_sh_interest" id="orientation_sh_interest_high" <?php if ( isset($shInfo['orientation_sh_interest']) && $shInfo['orientation_sh_interest']=='High'){?>checked <?php }?>>
                                <i></i> High </label>
                              </div>
                            </div>
                          </div></td>
                      </tr>
                      <tr>
                        <td>SH Influence</td>
                        <td><div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="10" name="orientation_sh_influence" id="orientation_sh_influence_low" <?php if ( isset($shInfo['orientation_sh_influence']) && $shInfo['orientation_sh_influence']=='10'){?>checked <?php }?>>
                                <i></i> Low </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="16" name="orientation_sh_influence" id="orientation_sh_influence_medium" <?php if ( isset($shInfo['orientation_sh_influence']) && $shInfo['orientation_sh_influence']=='16'){?>checked <?php }?>>
                                <i></i> Medium </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="20" name="orientation_sh_influence" id="orientation_sh_influence_high" <?php if ( isset($shInfo['orientation_sh_influence']) && $shInfo['orientation_sh_influence']=='20'){?>checked <?php }?>>
                                <i></i> High </label>
                              </div>
                            </div>
                          </div></td>
                      </tr>                      
                      <tr>
                        <td>Current Orientation</td>
                        <td><div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="green" name="sh_current_orientation" id="sh_current_orientation_low" <?php if ( isset($shInfo['sh_current_orientation']) && $shInfo['sh_current_orientation']=='green'){?>checked <?php }?>>
                                <i></i> <span style="color:#00FF00">Supportive</span> </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="red" name="sh_current_orientation" id="sh_current_orientation_medium" <?php if ( isset($shInfo['sh_current_orientation']) && $shInfo['sh_current_orientation']=='red'){?>checked <?php }?>>
                                <i></i> <span style="color: #FF0000">Resistant</span> </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="orange" name="sh_current_orientation" id="sh_current_orientation_high" <?php if ( isset($shInfo['sh_current_orientation']) && $shInfo['sh_current_orientation']=='orange'){?>checked <?php }?>>
                                <i></i> <span style="color: #FF9900;">Neutral</span> </label>
                              </div>
                            </div>
                          </div></td>
                      </tr>
                      <tr>
                        <td>Desired Orientation</td>
                        <td><div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="green" name="sh_desired_orientation" id="sh_desired_orientation_low" <?php if ( isset($shInfo['sh_desired_orientation']) && $shInfo['sh_desired_orientation']=='green'){?>checked <?php }?>>
                                <i></i> <span style="color:#00FF00">Supportive</span> </label>
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="i-checks pull-left">
                                <label>
                                <input type="radio" value="orange" name="sh_desired_orientation" id="sh_desired_orientation_high" <?php if ( isset($shInfo['sh_desired_orientation']) && $shInfo['sh_desired_orientation']=='orange'){?>checked <?php }?>>
                                <i></i> <span style="color: #FF9900;">Neutral</span> </label>
                              </div>
                            </div>
                          </div></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal" onClick="$.colorbox.close();">Close</button>
    <!--<button type="button" class="btn btn-primary save">Save changes</button>-->
    <!--<button class="btn btn-sm btn-primary login-submit-cs" type="button" onClick="shActions('frmStockholders');">Update & Finish</button>-->
    <button data-loading-text="Saving..." type="submit" class="btn btn-success"> <i class="fa fa-floppy-o"></i> Save </button>
  </div>
</form>
<!-- jquery
		============================================ -->
<!--<script src="js/vendor/jquery-1.11.3.min.js"></script>-->
<!-- bootstrap JS
		============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- notification JS
		============================================ -->
<script src="js/Lobibox.js"></script>
<script src="js/notification-active.js"></script>
<!-- main JS
		============================================ -->
<script src="js/main.js"></script>
<script>
$(document).ready(function(e){
   
	$("#frmStockholders").on('submit', function(e){
	
	e.preventDefault();
	
	var shdata = new FormData(this);
	
	var sh_name = $("#sh_name").val();
	var sh_abbreviation = $("#sh_abbreviation").val();
	var sh_category_id = $("#sh_category_id").val();
	
	if(sh_name=='' || sh_abbreviation=='' || sh_category_id=='')
	{		
		Lobibox.notify('error', {                    
			title: 'Error',					
			position: 'top right',//top left,top right,bottom left,bottom right,
			msg: 'Please, enter all mandatory fields in General Info Tab'
		});
	}
	else
	{
    	$.ajax({
		async: true,
		type: 'POST',
        url: 'sh-update-config.php',
		processData: false,
		contentType: false,
        data: shdata,
		cache: false,
		dataType: 'JSON',
        success:function(response){
			
            if(response[0].message == 'ok'){
								
				$('#myModal').modal('hide');
				
				$('#shName').html(response[0].name);
				$('#shCatTitle').html(response[0].category_title);
				$('#shAbbreviation').html(response[0].abbreviation);
				$('#shInterest').html(response[0].interest);
				$('#shInfluence').html(response[0].influence);
				$('#shCurrentOrientation').html(response[0].current_orientation);
				$('#shDesiredOrientation').html(response[0].desired_orientation);
				
				$("#shLogo").attr("src",response[0].sh_logo);
				
				Lobibox.notify('success', {
                    title: 'Success',
                    msg: 'Stakeholder updated successfully.'
                });
				
            }else{
                //alert('Some problem occurred, please try again.');
				$('#myModal').modal('hide');
				
				Lobibox.notify('error', {
                    title: 'Error',
                    msg: 'Some problem occurred, please try again.'
                });
            }
        },
		error:function(html)
		{			
			$('#myModal').modal('hide');
			
			Lobibox.notify('error', {
                    title: 'Error',
                    msg: 'Some problem occurred, Please try again.'
                });
        }
    });
	}
	});
	
});
</script>
</body>
</html>
