
<div class="breadcrumb">
    <h1>Point Category</h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li>Add New Point</li>

    </ul>
</div>


<div class="separator-breadcrumb border-top"></div>

<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Add New Point Category</div>
                <form action="" method="post" enctype="multipart/form-data">

					<?php if(isset($adminDetail->admin_id) && $adminDetail->admin_id!=0) { ?>
						<input type="hidden" id="admin_id" name="admin_id" value="<?php echo $adminDetail->admin_id ?>" />
						<input type="hidden" id="admin_type" name="admin_type" value="<?php echo $adminDetail->admin_type ?>" />
					<?php }else{ ?>
						<input type="hidden" id="admin_type" name="admin_type" value="administrator" />
					<?php } ?>

                    <div class="row">

                        <div class="col-md-6 form-group mb-3">
                            <label for="pointcategory_title">Title </label>
                            <input type="text" class="form-control" id="pointcategory_title" name="pointcategory_title" value="<?php echo $pointDetail->pointcategory_title; ?>" placeholder="Enter title">
                            <div class="invalid-tooltip" id="msg_pointcategory_title"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="pointcategory_desc">Description </label>
                            <input type="text" class="form-control" id="pointcategory_desc" name="pointcategory_desc" value="<?php echo $pointDetail->pointcategory_desc; ?>" placeholder="Enter code">
                            <div class="invalid-tooltip" id="msg_pointcategory_desc"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="pointcategory_mPoints">Min. Purchase </label>
                            <input type="text" class="form-control" id="pointcategory_mPoints" name="pointcategory_mPoints" value="<?php echo $pointDetail->pointcategory_mPoints; ?>" placeholder="Enter code">
                            <div class="invalid-tooltip" id="msg_pointcategory_mPoints"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="pointcategory_mTopup">Min. TopUp </label>
                            <input type="text" class="form-control" id="pointcategory_mTopup" name="pointcategory_mTopup" value="<?php echo $pointDetail->pointcategory_mTopup; ?>" placeholder="Enter code">
                            <div class="invalid-tooltip" id="msg_pointcategory_mTopup"></div>
                        </div>
                        <div class="col-md-12">
                            <button class="btn btn-primary" id="submit" name="submit">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
	
	$( "form" ).on( "submit", function(e) {
      e.preventDefault();
      var pointcategory_title = $("#pointcategory_title").val();
      var pointcategory_desc = $("#pointcategory_desc").val();
      var pointcategory_mPoints = $("#pointcategory_mPoints").val();
      var pointcategory_mTopup = $("#pointcategory_mTopup").val();
      
      
      if($("#pointcategory_title").val()==''){
          $("#pointcategory_title").addClass('error');
          $("#pointcategory_title").focus();
          $("#msg_pointcategory_title").html('Please select type').show();
          return false;
      }else{
          if(pointcategory_title !=''){
              $("#pointcategory_title").removeClass('error');
              $("#msg_pointcategory_title").hide();
          }

          <?php if(!isset($_REQUEST['pointcategory_id'])){ ?>
              $.ajax({
                      url: "pointcategoryadd.php",
                      data: { act:"load",
                            pointcategory_title:pointcategory_title,pointcategory_desc:pointcategory_desc,pointcategory_mTopup:pointcategory_mTopup,pointcategory_mPoints:pointcategory_mPoints },
                      method: 'POST',
                      success: function(msg){
                          if(msg!=''){
                              window.location='pointcategorylist.php';
                              //return false;
                          }
                      }
                  });
          <?php }else{  ?>
           
            $.ajax({      
                    url: "pointcategoryadd.php",
                    data: { act:"load",
                          pointcategory_title:pointcategory_title,pointcategory_desc:pointcategory_desc,pointcategory_mTopup:pointcategory_mTopup,pointcategory_mPoints:pointcategory_mPoints,pointcategory_id:<?php echo $_REQUEST['pointcategory']; ?> },
                    method: 'POST',
                    success: function(msg){
                        if(msg!=''){
                          window.location='pointcategorylist.php';
                        }
                    }
                });
         <?php }
          ?>
      }

  });
</script>