<?php include("includes/head.php");?>

<body>
<form name="frmStockholdersCategories" id="frmStockholdersCategories">
  <input type="hidden" name="action_type" value="add">
  <div class="modal-content">
    <div class="modal-header"> <a href='#' onclick='parent.$.colorbox.close(); return false;'>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span> </button>
      </a>
      <h4 class="modal-title" id="myModalLabel">Add Category</h4>
    </div>
    <div class="modal-body">
      <table class="table table-bordered table-hover table-striped">
        <tr>
          <td>Abbreviation <span style="color: #FF0000;">*</span></td>
          <td><input type="text" class="form-control" name="category_abbreviation" id="category_abbreviation" value="" placeholder="Enter Catgory Abbreviation" required />
          </td>
        </tr>
        <tr>
          <td>Name <span style="color: #FF0000;">*</span></td>
          <td><input type="text" class="form-control" name="category_title" id="category_title" value="" placeholder="Enter Catgory Full Name" required />
          </td>
        </tr>
        <tr>
          <td>Description</td>
          <td><textarea name="category_description" id="category_description" rows="5" cols="60"></textarea>
          </td>
        </tr>
         <tr>
            <td>Orientation</td>
            <td>
              <select class="form-control custom-select-value" name="category_orientation" id="category_orientation" required style="width:250px;">
                <option value="">Select Orientation</option>
                <option value="red" style="background-color:#FF0000;">Resistant</option>
                <option value="orange" style=" background-color:#FF9933;">Neutral</option>
                <option value="green" style="background-color:#00FF00;">Supportive</option>
              </select>
            </td>
          </tr>
          <tr>
            <td>Influence</td>
            <td>
              <select class="form-control custom-select-value" name="category_influence" id="category_influence" required style="width:250px;">
                <option value="">Select Influence</option>
                <option value="500">Low</option>
                <option value="900">Medium</option>
                <option value="1300">High</option>
              </select>
            </td>
          </tr>
      </table>
    </div>
    <div class="modal-footer"> 
      <a href='#' onclick='parent.$.colorbox.close(); return false;'><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></a>
      <!--<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');">Save & Finish</button>-->      
      <button data-loading-text="Saving..." type="submit" class="btn btn-success"> <i class="fa fa-floppy-o"></i> Save </button>
    </div>
  </div>
</form>

<!-- jquery
		============================================ -->
<!--<script src="js/vendor/jquery-1.11.3.min.js"></script>-->
<!-- bootstrap JS
		============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- summernote JS
		============================================ -->
<script src="js/summernote.min.js"></script>
<script src="js/summernote-active.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 type="text/javascript">
$(document).ready(function(e){
    
	$("#frmStockholdersCategories").on('submit', function(e){
	
	e.preventDefault();
	
	var catdata = new FormData(this);
	
	var cat_abbreviation = $("#category_abbreviation").val();
	var cat_title = $("#category_title").val();
	
	if(cat_abbreviation=='' || cat_title=='')
	{		
		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({		
		type: 'POST',
        url: 'categoriesActions.php',
		processData: false,
		contentType: false,
        data: catdata,
		cache: false,
		dataType: 'JSON',		
        success:function(response){
            if(response[0].message == 'ok'){
			
				$(':input').not(':button, :submit, :reset, :hidden, :checkbox, :radio').val('');
    			$(':checkbox, :radio').prop('checked', false);
				$('#frmStockholdersCategories').trigger("reset");
				
				getCategoriesList('s1');
				
				//$('#myModal').modal('hide');
				
				Lobibox.notify('success', {
                    title: 'Success',
                    msg: 'Category added successfully.'
                });
				
				parent.$.colorbox.close();
				
				//window.location.href = 'sh-identifying.php';
				
            }else{
				Lobibox.notify('error', {
                    title: 'Error',
                    msg: 'Some problem occurred, Please try again.'
                });
            }
        },
		error:function(html)
		{
			getCategoriesList();
			
			/*Lobibox.notify('error', {
                    title: 'Error',
                    msg: 'Some problem occurred, Please try again.'
                });*/
				
			parent.$.colorbox.close();
        }
    });
	}
	});
	
});
</script>
</body>
</html>
