
<div class="breadcrumb">
    <h1>Point</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</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="point_title">Title </label>
                            <input type="text" class="form-control" id="point_title" name="point_title" value="<?php echo $pointDetail->pointmaster_title; ?>" placeholder="Enter title">
                            <div class="invalid-tooltip" id="msg_point_title"></div>
                        </div>

                        <div class="col-md-6 form-group mb-3">
                            <label for="point_type">Type <span class="asterisk">*</span></label>
                            <select class="form-control" id="point_type" name="point_type">
                            	<option value="">Select Type</option>
                            	<option value="REFERRAL" <?php echo (isset($pointDetail) && $pointDetail->pointmaster_type == "REFERRAL") ? "selected='selected'" : ""; ?>>REFERRAL</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_point_type"></div>
                        </div>

                        <div class="col-md-6 form-group mb-3">
                            <label for="point_code">Code </label>
                            <input type="text" class="form-control" id="point_code" name="point_code" value="<?php echo $pointDetail->pointmaster_code; ?>" placeholder="Enter code">
                            <div class="invalid-tooltip" id="msg_point_code"></div>
                        </div>

                        <div class="col-md-6 form-group mb-3">
                            <label for="point_sender">Sender </label>
                            <input type="text" class="form-control" id="point_sender" name="point_sender" value="<?php echo $pointDetail->pointmaster_sender; ?>" placeholder="Enter sender">
                            <div class="invalid-tooltip" id="msg_point_sender"></div>
                        </div>


                        <div class="col-md-6 form-group mb-3">
                            <label for="point_receiver">Receiver </label>
                            <input type="text" class="form-control" id="point_receiver" name="point_receiver" value="<?php echo $pointDetail->pointmaster_receiver; ?>" placeholder="Enter receiver">
                            <div class="invalid-tooltip" id="msg_point_receiver"></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 point_title = $("#point_title").val();
      var point_type = $("#point_type").val();
      var point_code = $("#point_code").val();
      var point_sender = $("#point_sender").val();
      var point_receiver = $("#point_receiver").val();
      
      //$("#template_content_data").val();
      
      if($("#point_type").val()=='')
       {
          $("#point_type").addClass('error');
          $("#point_type").focus();
          $("#msg_point_type").html('Please select type').show();
          return false;
        }
        else
        {
          if(point_type !='')
            {
              $("#point_type").removeClass('error');
              $("#msg_point_type").hide();
            }

          <?php if(!isset($_REQUEST['point_id']))
          { ?>
            
              $.ajax({
                      url: "pointadd.php",
                      data: { act:"load",
                            point_title:point_title,point_type:point_type,point_code:point_code,point_sender:point_sender,point_receiver:point_receiver },
                      method: 'POST',
                      success: function(msg){
                          if(msg!=''){
                              window.location='pointlist.php';
                              //return false;
                          }
                      }
                  });
          <?php 
          }else
          {  ?>
           
            $.ajax({      
                    url: "pointadd.php",
                    data: { act:"load",
                          point_title:point_title,point_type:point_type,point_code:point_code,point_id:<?php echo $_REQUEST['point_id']; ?>,point_sender:point_sender,point_receiver:point_receiver },
                    method: 'POST',
                    success: function(msg){
                        if(msg!=''){
                            window.location='pointlist.php';
                        }
                    }
                });
         <?php }
          ?>
      }

  });
</script>