<file_sep><?php
function escape($string){
	return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}

function revertescape($string){
	return htmlspecialchars_decode($string, ENT_QUOTES);
}
?><file_sep><?php

require_once 'core/init.php';
if (Input::exists()) {
    $delprewardID = Input::get('delprewardID');


    function exists($data){
        if(empty($data)){
            return "Required";
        }else{
            return "Valid";
        }
    }

    function CheckAllcondition($data1){
        if ($data1 === "Valid") {
            return "Passed";
        }else{
            return "Failed";
        }
    }

    // $delprIDerror = exists($delprewardID);
    // $delkpinameerror = exists($delname);

    
    

    // $allCondition = checkAllcondition();

    //if ($allCondition === "Passed") {
        // try{
            $delprewobj = new Preward();
            $delprewobj->deletepreward($delprewardID);

            $array = [ 
                'delprewardID' => $delprewardID,
                // "condition"=> $allCondition
                // "lastinsertid"=>$id
            ];


        // } catch (Exception $e){
        //     echo $e->getMessage();
        //}
    // }elseif ($allCondition === "Failed") {
    //     $array = [
    //             "delprewardID" => $delprIDerror,
    //             "condition"=> $allCondition
    //         ];
    // }
    echo json_encode($array);
}
?><file_sep><?php
require_once 'core/init.php';
if(Input::exists()){
	$email = escape(Input::get('email'));
	function exists($data){
		if(empty($data)){
			return "Required";
		}else{
			return "Valid";
		}
	}

	function condition($data1){
		if($data1 === "Valid"){
			return "Passed";
		}else{
			return "Failed";
		}
	}

	$emailerror = exists($email);
	if($emailerror === "Valid"){
		if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
		  $emailerror = "Invalid email";
		}else{
			$emailerror = "Valid";
		}
	}

	$condition = condition($emailerror);

	if($condition === "Passed"){
		try {
			$user = new User();
			$result = $user->searchOnly($email);
			if($result){
				$userID = $result->userID;
				$email = $result->email;

				$password = <PASSWORD>();
				$salt = Hash::salt(32);
				$newpassword = Hash::make($password, $salt);

				$user->update(array(
		  			"password" => <PASSWORD>,
		  			"salt" => $salt

		  		), $userID, "userID");

		  		
				$array = [
					"condition" => $condition,
					"email" => $email
				];
			}else{
				$array = [
					"emailerror" => true,
					"condition" => $condition
				];
			}


		} catch (Exception $e) {
			echo $e->getMessage();
		}
	}elseif($condition === "Failed"){
		$array = [
			"email" => $emailerror,
			"condition" => $condition
		];
	}
	echo json_encode($array);
}
?><file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}

$company2 = new Company();
$reward = new Preward();
$user = new User();

if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
    $checkid2 = $resultresult->companyID;
    $idfrom2 = 'companyID';
    $companyresult = $company2->searchCompany($checkid2);
    $allcompany = $companyresult;
}
else {
  $checkid2 = $resultresult->corporateID;
    $idfrom2 = 'corporateID';
    $companyresult = $company2->searchCompany($checkid2);
    $allcompany = $company2->searchCompanyCorporate($checkid2);
}

$view=' ';
              
              if($allcompany){
                foreach ($allcompany as $row) {                             
                $view .='<div class="row mb-3">

                <br>   
                  <h6><button class="btn btn-sm btn-link" data-toggle="collapse" data-target="#company'.$row->companyID.'" aria-expanded="false" aria-controls="company'.$row->companyID.'"><i class="fas fa-caret-down"></i></button>'.$row->company.'</h6>
              
                <br>

                <div class="container-fluid">
                  <div class="collapse multi-collapse" id="company'.$row->companyID.'">
                   <table class="table table-responsive-sm table-sm my-3">  
                     
                                <thead>
                                  <tr>
                                    <th>Name</th>
                                    <th>Current Point</th>
                                    <th class="text-right">Action</th>
                                  </tr>
                                </thead>
                                <tbody>';
                                
                                  $point = $reward->searchPointComReward($row->companyID);
                              
                                if (empty($point)){
                                  $view .='<tr><td colspan="3" class="text-center">Nothing to show</td></tr>';
                                }

                                  else{
                                    foreach($point as $key){
                                  $userresult =$user->searchUser($key->userID);
                                  $view .='
                                  <tr>  
                                    <td>';
                                    if (empty($userresult->profilepic)){
                                    $view .='<div class="d-flex card-img-top"><img src="img/userprofile.png" class="mr-1 rounded-circle" style="width:30px;height: 30px;">'.$userresult->firstname.' '.$userresult->lastname.'</td>';}
                                    else {
                                    $view .='<div class="d-flex card-img-top "></div><img src="data:image/jpeg;base64,'.base64_encode($userresult->profilepic).'" class="mr-1 rounded-circle" style="width:30px;height: 30px;">'.$userresult->firstname.' '.$userresult->lastname.'</td>';}
                                    $view .='
                                    <td>'.$key->currentpoint.'</td>
                                    <td class="text-right"><a class="btn btn-white btn-sm editpointall" data-toggle="modal" data-target="#editpoint" data-backdrop="static" id="'.$key->pointID.'"><i class="fas fa-edit"></i></a> 
                                    <a class="btn btn-white btn-sm pointlogview" data-toggle="modal" data-target="#pointlogview" data-backdrop="static" id="'.$key->userID.'"><i class="fas fa-history"></i></a></td> 
                                  </tr>';
                                  } // foreach scoreresult
                                  } //tutup if scoreresult
                                $view .='
                              </tbody>
                            </table>
                          </div> <!-- collapse multi-collapse-->
                        </div>
                      </div> <!-- tutup row mb-3 --> 
                      ';

                } //tutup foreach allcompany
        
            } //tutup if allcompany
          
            else{
            $view .='
            <div class="card my-3 shadow-sm p-2 text-center">
              <i class="far fa-building my-3" style="font-size:40px;"></i>
              <h5>'.$array['nocompanyfound'].'</h5>
              <p>'.$array['nocompanyfoundexplain'].'</p>
            </div>';
            }

$view .= "
<script type='text/javascript'>
  $('.categorylog').on('change', function(){
    var apuserID=$('#userid2').val();
    var catlog = $('.categorylog').val();

     console.log(apuserID);
    $.ajax({
      url:'ajax-getcatlog.php',
      method:'POST',
      data:{apuserID:apuserID,catlog:catlog},
      dataType:'json',
      success:function(data){
        console.log(data);
        $('#pointlogviews').html(data.view);
        $('#pform').modal({show:true});
      }
    });
    });
 </script>";
           echo ($view);
           ?>
<file_sep><?php
session_start();
date_default_timezone_set("Asia/Kuala_Lumpur");
$GLOBALS['config'] = array(
	'database' => array(
		'host' => 'localhost',
		'username' => 'root',
		'password' => '',
		'db' => 'claimdb'
	),
	'remember' => array(
		'cookie_name' => 'hash',
		'cookie_expiry' => 604800
	),
	'session' => array(
		'session_name' => 'user',
		'token_name' => 'token'
	)
);

spl_autoload_register(function($class){
	require_once 'class/'.$class.'.php';
});

require_once 'functions/cleaner.php';

if (Cookie::exists(Config::get('remember/cookie_name')) && !Session::exists(Config::get('session/session_name'))) {
	$hash = Cookie::get(Config::get('remember/cookie_name'));
	$hashCheck = Database::getInstance()->get('user_session', array('hash', '=', $hash));
	
	if($hashCheck->count()){
		$user = new User($hashCheck->first()->user_id);
		$user->login();
	}
}

if(isset($_GET['lang'])){
	if($_GET['lang'] == "en"){
		require_once 'lg/en.php'; 
	}elseif ($_GET['lang'] == "zh") {
		require_once 'lg/zh.php'; 
	}elseif($_GET['lang'] == "bm"){
		require_once 'lg/bm.php'; 
	}else{
		require_once 'lg/en.php'; 
	}
}else{
	require_once 'lg/en.php'; 
}
?><file_sep><?php
require_once 'core/init.php';


if(isset($_POST['vrewardID'])){


  $id = $_POST['vrewardID'];
  $rewuser = new Preward();
  $row = $rewuser->searchRewardID($id);

  $array = [
  	"rewardID" => $row->rewardID,
  	"reward" => $row->reward,
  	"quantity" => $row->quantity,
  	"points" => $row->points
  ];

  echo json_encode($array);
}<file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}
include 'include/header.php';

$id = $user->data()->userID;
$cid = $user->data()->companyID;

$reward = new Preward();
$kpireward = new Rewards();

if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
    $checkid2 = $resultresult->companyID;
    $idfrom2 = 'companyID';
    
    $rewardresult= $reward->searchmreward($resultresult->companyID, 'companyID');
    // $kpirewardresult= $kpireward->AllRewards($checkid2);
    // $rewardresult3 = $reward->getclaimreward($checkid2);
}
else {
  $checkid2 = $resultresult->corporateID;
    $idfrom2 = 'corporateID';
    $rewardresult= $reward->searchmreward($resultresult->corporateID, 'corporateID');
    // $kpirewardresult= $kpireward->AllRewards($resultresult->corporateID);
    // $rewardresult3 = $reward->getclaimreward($resultresult->corporateID);

}

$rewardresult3 = $reward->getclaimreward($id);
$rewardresult2 = $reward->searchPointReward($id);
?>
<body>
<style>
  .rewardimg {
  object-fit: contain;
  display: block; 
  overflow: auto; 
  margin-left: auto;
  margin-right: auto;
}
</style>
  <div class="d-flex" id="wrapper">
    <?php include 'include/navbar.php';?>
    <div class="container-fluid">
     <h4 class="my-5"><i class='fas fa-gift'></i> Reward</h4>


                          <div class="row">
                            <div class="col">
                              <ul class="nav nav-pills" id="prewardtab">
                                <li class='nav-item'>
                                  <a class='nav-link active' data-toggle='tab' href='#allr'>All</a>
                                </li>
                                <li class='nav-item'>
                                  <a class='nav-link' data-toggle='tab' href='#claimed'>Claimed</a>
                                </li>
                                <li class='nav-item'>
                                  <a class='nav-link' data-toggle='tab' href='#expired'>Expired</a>
                                </li>
                              </ul>
                            </div>
                          </div>

                        <div class="container-fluid">
                          <div class="card-body">
                            <div class="tab-content">
                              <div class="tab-pane fade show active" id="allr">
                               <div class="row mb-3">
                                <div class="col text-right">
                                  <form>
                                    <input type="checkbox" id="affordpoint" data-id="<?php echo $checkid2?>"> Afford Point
                                    <select type="text" class="form-control-sm" id="category">
                                      <option type="text" value="all">All</option>
                                      <option type="text" value="Gift">Gift</option>
                                      <option type="text" value="Cash">Cash</option>
                                      <option type="text" value="Voucher">Voucher</option>
                                      <option type="text" value="Item">Item</option>
                                      <option type="text" value="Other">Other</option>
                                    </select>
                                  </form>
                                </div>
                            </div>

                      <div class="row px-sm-2 px-0" id="catdata">
                          <?php
                   if($rewardresult){
                              foreach ($rewardresult as $row) {
                              date_default_timezone_set('Asia/Kuala_Lumpur');
                              $today = date('Y-m-d H:i:s');
                            ?>
                        <div class="col-sm-4 col-lg-3 col-md-3">
                          
                          <div class="card" style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; ">
                            <?php
                            if (empty($row->reward_img)){
                              echo'<div class="d-flex card-img-top"><img src="img/nopicture.png" width="180" height="200"  alt="Reward Picture" class="rewardimg"></div>';}
                              else {?>
                                <div class="d-flex card-img-top "><img src="data:image/jpeg;base64,<?php echo base64_encode($row->reward_img);?>" width="180" height="200" alt="Reward Picture" class="rewardimg"></div><?php } ?>

                              <div class="card-body">
                                <h5 class="card-title">
                                  <span class='badge badge-success'>
                                    <?php echo $row->category;?>
                                  </span>
                                  <strong><?php echo $row->reward;?></strong>
                                </h5>
                                <p class="card-text">
                                <span class='badge badge-pill badge-warning'> P </span>
                                  <?php echo $row->points;?><br>
                                  <?php echo $row->description;?><br>
                                  Valid til: <?php echo $row->expiredate;?>
                                </p>

                                <?php
                              
                              $expdate = $row->expiredate;
                              $entrydate = $row->entrydate;
                              $uid = $reward->searchAllClaim5($row->rewardID, $id);
                              
                              
                              if (empty($uid)){ //check $count
                                $count = 0;
                               }
                              else{
                               $count = count($uid);
                               }

                               if ($expdate < $today){
                                 echo '<button type="button" class="btn btn-outline-danger pull-right" disabled>Expired</button>';
                               }

                              elseif ($row->quantity == 0 || $entrydate > $today){
                                echo '<button type="button" class="btn btn-outline-danger pull-right" disabled>Unavailable</button>';
                               }

                              elseif ($count == $row->rewardLimit){
                                  echo '<button type="button" class="btn btn-outline-danger pull-right" disabled>Reach Limit</button>';
                                 }

                              else {
                                echo '<button type="button" class="btn btn-primary pull-right viewreward" data-toggle="modal" data-target="#viewreward" data-backdrop="static" id="'.$row->rewardID.'">Claim</button>';
                                 }
                               
                                ?> 
                              </div>
                          </div>
                        </div>

                          <?php
                          }
                        }
                    else{
                    echo 'You have no reward currently';
                  }
                  
                  ?>
                      
                    </div>
                  </div>

                  <!--claimed-->
                              <div class="tab-pane fade" id="claimed">
                               <div class="row mb-3">
                                <div class="col text-right">
                                  <form>
                                    <select type="text" class="form-control-sm" id="category2">
                                      <option type="text" value="all2">All</option>
                                      <option type="text" value="Gift">Gift</option>
                                      <option type="text" value="Cash">Cash</option>
                                      <option type="text" value="Voucher">Voucher</option>
                                      <option type="text" value="Item">Item</option>
                                      <option type="text" value="Other">Other</option>
                                    </select>
                                  </form>
                                </div>
                            </div>
                             
                      <div class="row px-sm-2 px-0" id="catdata2">
                          <?php
                          if($rewardresult3){
                           foreach ($rewardresult3 as $row1) { ?> 
                       <div class="col-sm-4 col-lg-3 col-md-3">
                          
                          <div class="card" style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; ">
                            
                            <?php
                            if (empty($row1->reward_img)){
                              echo'<div class="d-flex card-img-top"><img src="img/nopicture.png" width="180" height="200" alt="Reward Picture" class="rewardimg"></div>';}
                              else {?>
                                <div class="d-flex card-img-top"><img src="data:image/jpeg;base64,<?php echo base64_encode($row1->reward_img);?>" width="180" height="200" alt="Reward Picture" class="rewardimg"></div><?php } ?>

                              <div class="card-body">
                                <h5 class="card-title">
                                  <span class='badge badge-success'>
                                    <?php echo $row1->category;?>
                                  </span>
                                  <strong><?php echo $row1->reward;?></strong>
                                </h5>
                                <p class="card-text">
                                <span class='badge badge-pill badge-warning'> P </span>
                                  <?php echo $row1->points;?><br>
                                  <?php echo $row1->description;?><br>
                                  Date Claimed: <?php echo $row1->date;?>
                                </p>
                            </div>
                          </div>
                        </div>
                        <?php
                  }
                }
                else{
                    echo 'You have no reward currently';
                  }
                  ?>
                      </div>
                    </div><!--claimed-->
                      
                    <div class="tab-pane fade" id="expired">
                               <div class="row mb-3">
                                <div class="col text-right">
                                  <form>
                                    <select type="text" class="form-control-sm" id="category3">
                                      <option type="text" value="all3">All</option>
                                      <option type="text" value="Gift">Gift</option>
                                      <option type="text" value="Cash">Cash</option>
                                      <option type="text" value="Voucher">Voucher</option>
                                      <option type="text" value="Item">Item</option>
                                      <option type="text" value="Other">Other</option>
                                    </select>
                                  </form>
                                </div>
                            </div>

                       <?php
                    if ($rewardresult){
                    ?>
                      <div class="row px-sm-2 px-0" id="catdata3">
                          <?php
                           foreach ($rewardresult as $row2) { 
                            $expdate = $row2->expiredate;
                            if ($expdate < $today){ ?> 
                       <div class="col-sm-4 col-lg-3 col-md-3">
                          
                          <div class="card" style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; ">
                            
                            <?php
                            if (empty($row2->reward_img)){
                              echo'<div class="d-flex card-img-top"><img src="img/nopicture.png" width="180" height="200" alt="Reward Picture" class="rewardimg"></div>';}
                              else {?>
                                <div class="d-flex card-img-top"><img src="data:image/jpeg;base64,<?php echo base64_encode($row2->reward_img);?>" width="180" height="200" alt="Reward Picture" class="rewardimg"></div><?php } ?>

                              <div class="card-body">
                                <h5 class="card-title">
                                  <span class='badge badge-success'>
                                    <?php echo $row2->category;?>
                                  </span>
                                  <strong><?php echo $row2->reward;?></strong>
                                </h5>
                                <p class="card-text">
                                <span class='badge badge-pill badge-warning'> P </span>
                                  <?php echo $row2->points;?><br>
                                  <?php echo $row2->description;?><br>
                                  Valid til: <?php echo $row2->expiredate;?>
                                </p>
                            </div>
                          </div>
                        </div>
                        <?php
                  }
                }
              }
              else{
                    echo 'You have no reward currently';
                  }
                  ?>
                      </div>
                    </div><!--Expired-->

                  </div>
                </div> 
              </div>

              </div><!--Point -->

            </div><!--tab content-->
          </div>
        </div>
</div>
            </body> 

    <!-- /#page-content-wrapper -->
<!-- <script type="text/javascript">
  $(document).ready(function(){
     $("#sidebar-wrapper .active").removeClass("active");
     $("#yourkpinavid").addClass("active");
  });
</script> -->

<script type="text/javascript">
$("body").on("click", ".viewreward", function(e){

e.preventDefault();
vrewardID=$(this).attr('id');
$.ajax({
    url: "ajax-getviewpr.php",
    type: "POST",
    data: {vrewardID:vrewardID},

    success:function(response){
    data = JSON.parse(response);
    
      $("#vrewardID").val(data.rewardID);
      $("#vpoints").val(data.points);
    }

  });

});

  $('#category').on('change', function(){

      var category = $('#category').val();
      //var All = $('#category').val('All');
      //var chartType = $('#chartType').val();
      //var myChart = document.getElementById('myChart').getContext('2d');
    $.ajax({
      url:"ajax-getcategory.php",
      method:"POST",
      data:{category:category},
      //dataType:"json",
      success:function(data){
        $("#catdata").html(data);
        console.log(data);
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
      }
    });
    });

      $(document).ready(function(){
    $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
        localStorage.setItem('activeTab', $(e.target).attr('href'));
    });
    var activeTab = localStorage.getItem('activeTab');
    if(activeTab){
        $('#reward a[href="' + activeTab + '"]').tab('show');
    }
    });

    $(document).ready(function(){
    $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
        localStorage.setItem('activeTab', $(e.target).attr('href'));
    });
    var activeTab = localStorage.getItem('activeTab');
    if(activeTab){
        $('#prewardtab a[href="' + activeTab + '"]').tab('show');
    }
    });

  $('#category2').on('change', function(){

      var cat = $('#category2').val();
      //var All = $('#category').val('All');
      //var chartType = $('#chartType').val();
      //var myChart = document.getElementById('myChart').getContext('2d');
    $.ajax({
      url:"ajax-getcatclaimed.php",
      method:"POST",
      data:{cat:cat},
      //dataType:"json",
      success:function(data){
        $("#catdata2").html(data);
        console.log(data);
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
      }
    });
    });

  $('#category3').on('change', function(){

      var catExp = $('#category3').val();
      //var All = $('#category').val('All');
      //var chartType = $('#chartType').val();
      //var myChart = document.getElementById('myChart').getContext('2d');
    $.ajax({
      url:"ajax-getcatExp.php",
      method:"POST",
      data:{catExp:catExp},
      //dataType:"json",
      success:function(data){
        $("#catdata3").html(data);
        console.log(data);
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
      }
    });
    });

  $('#affordpoint').on('change', function(event){

      var checkbox = $(event.target);
      var isChecked = $(checkbox).is(':checked');

      if(isChecked == true){
        var Apoint = $('#affordpoint').val();
        console.log(Apoint);
      $.ajax({
      url:"ajax-getAffordPoint.php",
      method:"POST",
      data:{Apoint:Apoint},
      //dataType:"json",
      success:function(data){
      $("#catdata").html(data);
      // console.log(data);
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
          }
        });
      }
      else{
        var varewardID = $('#affordpoint').data('id');
        console.log(varewardID);
      $.ajax({
      url:"ajax-vareward.php",
      method:"POST",
      data:{varewardID:varewardID},
      //dataType:"json",
      success:function(data){
      $("#catdata").html(data);
      console.log(data);
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
      }
    });
    }
  });

</script>
<!-- /#wrapper -->
<?php include 'include/form.php';?><file_sep><?php
require_once 'core/init.php';

 
if(isset($_POST['apuserID']) && isset($_POST['catlog'])){

  $user = new User();
  $resultresult = $user->data();
  $userID = $resultresult ->userID;
  $rewuser = new Preward();
  
  $corporateID = $resultresult->corporateID;
  $companyID = $resultresult->companyID;

 
  $apuserID = escape(Input::get('apuserID'));

  $id2 = $_POST['catlog'];
  if ($id2==="allhistory"){
    $row = $rewuser->searchpointlog($apuserID);
  }
  else {   
    $row = $rewuser->getCategorylog($apuserID, $id2);
  }
  
  $view=" ";
    
    if (empty($row)){
      $view .='<div>Nothing to show</div>';
    }

    if($row){
      foreach ($row as $row2) {
        // $userresult1 = $user->searchOnly($row1->userID);
        $view .=
        "<li class='list-group-item list-group-item-action'>
            <div>".$row2->action_name."<span class='float-right'>".$row2->actionDate."</span></div>
            <div><small>Description: ".$row2->description."</small></div>
        </li>
        ";
      }
    }
    

    $array = [
     
        // "apuserID" => $apuserID,
        "view" => $view,
      ];

  echo json_encode($array);
  

// echo($viewlog);
}<file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}
include 'include/header.php';

?>

<body>
<div class="d-flex" id="wrapper">
    <?php include 'include/navbar.php';?>
    <div class="container-fluid">
     <h4 class="my-5"><i class='fa fa-map-pin'></i> Allocate Point</h4>


                      <div class="card mb-3 shadow-sm" >
                        <div class="card-body">
                          <div id="allocatepointview"></div>
                        </div>
                      </div>
      </div>
    </div>
</body>
          
 <script type='text/javascript'>
                $(document).ready(function(){
                  $(document).on('click', '#closepoint', function(){
                    $('#pform').modal('hide');
                    location.reload(); 
                  });
                });
  </script>
            <div class='modal fade' id='pointlogview' tabindex="-1">
              <div class='modal-dialog modal-lg modal-dialog-scrollable'>
                <div class='modal-content'>
                  <div class='modal-header bg-primary'>
                    <h6 class='modal-title text-white' id='pointlog'>History</h6>  
                    <button type='button' class='close text-white' id='closepoint' data-dismiss='modal'>&times;</button>
                  </div>
                  
                  <div class='modal-body'>
                    <form class='text-right'>
                        <select type='text' class='form-control-sm categorylog'>
                          <option type='text' value='allhistory'>All</option>
                          <option type='text' value='Claim Reward'>Claimed Reward</option>
                          <option type='text' value='Add point'>Added point</option>
                          <option type='text' value='Reduce Point'>Reduced Point</option>
                        </select>
                      </form>
                      <hr>
                    <input type='hidden' id='userid2' value=''>
                    <div id='pointlogviews'></div> 
                  </div>
                </div>
              </div>
            </div>

<script type="text/javascript">
$(document).ready(function(){

    function getAllocatepoints(){
      $.ajax({
        url:"ajax-getAllocatepoint.php",
        success:function(data){
          $("#allocatepointview").html(data);
        }
      });
    }

    getAllocatepoints();

  $("body").on("click", ".editpointall", function(e){

e.preventDefault();
pointID=$(this).attr('id');
$.ajax({
    url: "ajax-getpoint.php",
    type: "POST",
    data: {pointID:pointID},

    success:function(response){
    data = JSON.parse(response);
    
      
      // $("#pointlog").val(data.currentpoint);
      $("#pointID").val(data.pointID);
      $("#auserID").val(data.userID);
      $("#apcompanyID").val(data.companyID);
    }

  });

});


$("body").on("click", ".pointlogview", function(e){

e.preventDefault();
apuserID=$(this).attr('id');
// var apuserID = document.getElementById('apuserID').value;
  var alldata = 
      {
       apuserID:apuserID
      }
 console.log(alldata);
$.ajax({
    url: "ajax-getviewpointlog.php",
    method:'POST',
    data:alldata,
    dataType:'json',
    success:function(data){
    console.log(data);
    $("#userid2").val(data.apuserID);
    $('#pointlogviews').html(data.view);
    $('#pform').modal({show:true});
    }

  });

});

});

// $(document).on('click',function(){
// $('.collapse').collapse('hide');
// });
</script>

<?php include 'include/form.php';?><file_sep>  
<?php
require_once 'core/init.php';


if(isset($_POST['rewardID'])){


  $id = $_POST['rewardID'];
  $rewuser = new Preward();
  $row = $rewuser->searchRewardID($id);

  $array = [
  	"rewardID" => $row->rewardID,
  	"reward" => $row->reward,
  	"description" => $row->description,
  	"rewardLimit" => $row->rewardLimit,
  	"points" => $row->points,
  	"category" => $row->category,
  	"expiredate" => $row->expiredate,
  	"entrydate" => $row->entrydate,
  	"quantity" => $row->quantity,
  	"companyID" => $row->companyID,
  ];
  echo json_encode($array);
  




}<file_sep>  
<?php
require_once 'core/init.php'; 
if (Input::exists()) {
	// $currentuser= new User();
 //    $userid = $currentuser->data()->userID;
    $currentcompany = new User();
    $companyid = $currentcompany->data()->companyID;
    $currentcorporate= new User();
    $corporateid = $currentcorporate->data()->corporateID;

	$pointID = Input::get('pointID');
	$pointlogs = Input::get('pointlogs');
	$desclog = Input::get('desclog');
	$auserID = Input::get('auserID');

	$logrewarduser = new Preward();
    $key = $logrewarduser->searchPointReward4($pointID);

    $prevcurrentpoint =$key->currentpoint;
    $prevtotalpoint = $key->totalpoint;

	date_default_timezone_set('Asia/Kuala_Lumpur');
    $today = date('Y-m-d H:i:s');
	
	function checkValid($data){
		if(empty($data)){
			return "Required";
		}else{
			return "Valid";
		}
	}

	function checkPoint($data1, $newcurrentpoint){
		if(empty($data1)){
			return "Required";
		}
		else{
			if($newcurrentpoint <= 0){
				return "current point cannot be 0/-";
			}else{
				return "Valid";
			}
		}
	}

	$newcurrentpoint = ((int)$prevcurrentpoint+(int)$pointlogs);
	$newTotalPoint = ((int)$prevtotalpoint+(int)$pointlogs);


	function checkAllcondition($data1, $data2){
		if ($data1 === "Valid" && $data2 === "Valid") {
			return "Passed";
		}else{
			return "Failed";
		}
	}

	$pointlogerror = checkPoint($pointlogs, $newcurrentpoint);
	$desclogerror = checkValid($desclog);

	$allcondition = checkAllcondition($pointlogerror, $desclogerror);

	
	if ($allcondition === "Passed") {
		try{
			$prewardobject = new preward();
			$prewardobject->updatepoint(array(
				'currentpoint'=> $newcurrentpoint,
				'totalpoint' => $newTotalPoint,
            ),$pointID);

            // $id = $prewardobject->lastinsertid();
			if ($pointlogs > 0){
			$prewardobject->insertpointlog(array(
                'pointID' => $pointID,
				'previouspoint' => $prevcurrentpoint,
				'currentpoint' => $newcurrentpoint,
				'totalpoint' => $newTotalPoint,
				'description' => $desclog,
				'userID' => $auserID,
				'actionDate' => $today,
				'action_name'=>"Add Point",
            ));}

            else{
			$prewardobject->insertpointlog(array(
                'pointID' => $pointID,
				'previouspoint' => $prevcurrentpoint,
				'currentpoint' => $newcurrentpoint,
				'totalpoint' => $newTotalPoint,
				'description' => $desclog,
				'userID' => $auserID,
				'actionDate' => $today,
				'action_name'=>"Reduce Point",
            ));
            }
            			
			$array=[
				'pointlogs'=> $pointlogs,
				'currentpoint'=> $newcurrentpoint,
				'description' => $desclog,
				'condition'=> $allcondition
			];

		} catch (Exception $e){
			echo $e->getMessage();
		}
	}else{
		$array = [
				'currentpoint'=> $pointlogerror,
				'description' => $desclogerror,
				//'condition'=> $allcondition
				
		];
	}
	echo json_encode($array);
}
?><file_sep><?php
	$array = 
	[
		"viewmoreoption" => "Click to view more options",
		"viewda" => "Click to Add Doer Action",
		"viewcda" => "Click to view or close Doer Action",
		"viewkr" => "Click to Add Key Result",
		"viewckr" => "Click to View Contribute OKR",
		"viewcollapse" => "Click to collapse or show",
		"committed" => "Committed",
		"aspirational" => "Aspirational",
		"toplevel" => "Top Level",
		"reportsubmit" => "Report Submitted",
		"reportnotsubmit" => "Report Not Submitted",
		"reportreview" => "Report Review",
		"reportnotreview" => "Report Not Review",
		"totalobjective" => "Total Objectives",
		"howmany" => "How many objectives created in this Timeframe",
		"loginrate" => "Login Rate",
		"updaterate" => "Update Rate",
		"currentprogress" => "Current Progress",
		"togo" => "To Go",
		"expected" => "Expected",
		"supervisor" => "Supervisor",
		"admin" => "Admin",
		"chief" => "Chief",
		"superior" => "Superior",
		"manager" => "Manager",
		"evaluate" => "Evaluate",
		"progressremarks" => "Progress's Remarks",
		"problemremarks" => "Problem's Remarks",
		"nextweekplanremarks" => "Next week Plan Remarks",
		"problem" => "Problem",
		"nextweekplan" => "Next Week Plan",
		"plan" => "Plan",
		"draft" => "Draft",
		"department" => "Department",
		"team" => "Team",
		"project" => "Project",
		"campaign" => "Campaign",
		"optional" => "optional",
		"active" => "Active",
		"notactive" => "Not Active",
		"description" => "Description",
		"marksas" => "Marks as ",
		"unit" => "Unit",
		"percentage" => "Percentage",
		"currency" => "Currency",
		"metric" => "Metric",
		"startvalue" => "Start Value",
		"endvalue" => "End Value",
		"new" => "New",
		"okrlogs" => "OKR Logs",
		"alignto" => "Align to",
		"owner" => "Owner",
		"overallprogress" => "Overall Progress",
		"progresstimeline" => "Progress Timeline",
		"keyactivity" => "Doer Action",
		"showkeyactivity" => "Show <b>Doer</b> Action",
		"contributetitle" => "contribute",
		"own" => "own",
		"contribute" => "Contribute",
		"okr" => "OKR",
		"home" => "Home",
		"no" => "No",
		"add" => "Add",
		"delete" => "Delete",
		"update" => "Update",
		"edit" => "Edit",
		"cancel" => "Cancel",
		"submit" => "Submit",
		"create" => "Create",
		"week" => "Week",
		"submitat" => "Submit at",
		"status" => "Status",
		"action" => "Action",
		"leader" => "Leader",
		"type" => "Type",
		"name" => "<NAME>",
		"email" => "Email",
		"jobposition" => "Job Position",
		"role" => "Roles",
		"timeframe" => "Timeframe",
		"progress" => "Progress",
		"membership" => "Membership",
		"view" => "View",
		"startdate" => "Start Date",
		"enddate" => "End Date",
		"next" => "Next",
		"previous" => "Previous",
		"profile" => "Profile",
		"firstname" => "<NAME>",
		"lastname" => "<NAME>",
		"changepassword" => "<PASSWORD>",
		"noobjectivefound" => "No OKR founds",
		"noobjectivefoundexplain" => "You haven't create any OKR for this Timeframe",
		"nokeyresultfound" => "No Key Result founds",
		"nokeyresultfoundexplain" => "You haven't create any Key Result for this Objective",
		"noalignobjective" => "No Align Objective founds",
		"noalignobjectiveexplain" => "No Objective are align to this Objective",
		"noactivityfound" => "No Doer Action founds",
		"noactivityfoundexplain" => "You haven't create any Doer Action for Key Result",
		"objectivetitle" => "Objective",
		"alignobjectivetitle" => "Contribute",
		"keyresulttitle" => "Key Result",
		"keyresultshort" => "KR",
		"activitytitle" => "Action",
		"activityshort" => "DA",
		"report" => "Report",
		"excellent" => "Excellent",
		"ontrack" => "On-track",
		"notstart" => "Not Start",
		"lagging" => "Lagging",
		"danger" => "Danger",
		"reportsubmitted" => "Report Submitted",
		"reportsubmittedexplain" => "You have submitted the report for this week:",
		"reportnotsubmitted" => "No Report Submitted",
		"reportnotsubmittedexplain" => "You haven't submit any report for this week:",
		"nocompanyfound" => "No Company founds",
		"nocompanyfoundexplain" => "You haven't create any Company",
		"nogroupfound" => "No Group founds",
		"nogroupfoundexplain" => "You haven't create any Group",
		"nouserfound" => "No Users founds",
		"nouserfoundexplain" => "You haven't create any User",
		"notimeframefound" => "No Timeframe founds",
		"notimeframefoundexplain" => "You haven't create any timeframe. Add your custom timeframe that suit your organization",
		"nologfound" => "No logs found",
		"nologfoundexplain" => "There is no logs for this Objective",
		"group" => "Group",
		"personal" => "Personal",
		"people" => "People",
		"engagementrate" => "Engagement Rate",
		"last30days" => "last 30 days",
		"last60days" => "last 60 days",
		"last90days" => "last 90 days",
		"okrhealth" => "OKR Health",
		//navbar
		"dashboard" => "Dashboard",
		"yourokr" => "Your OKR",
		"weeklyreport" => "PPP & 1-to-1",
		"corporate" => "Corporate",
		"companies" => "Companies",
		"company" => "Company",
		"groups" => "Groups",
		"users" => "Users",
		"user" => "User",
		"okrs" => "OKRs",
		"alignment" => "Alignment",
		//topbar
		"admindashboard" => "Admin Dashboard",
		"supervisordashboard" => "Supervisor Dashboard",
		"personalsetting" => "Personal Settings",
		"logout" => "Logout",
		//home-dashboard
		"yourplanforweek" => "Your Plan for Week",
		"done" => "Done",
		"inprogress" => "In Progress",
		"stuck" => "Stuck",
		"issue" => "Issue",
		"calendar" => "<b>Doer</b> Calendar",
		"objective" => "Objective",
		//home-yourokr
		"objectivestatusexcellent" => "Congrats for achieve your goal",
		"objectivestatusontrack" => "Ahead by ",
		"objectivestatusnotstart" => "Timeframe Not Start yet",
		"objectivestatusontrack2" => "On-track",
		"objectivestatuslagging" => "Lagging by ",
		"objectivestatusdanger" => "Lagging too much by ",
		"keyresultexcellent" => "Congrats for achieve your Key Result",
		"activityexcellent" => "Congrats for achieve your Doer Action",

		"successaddactivity" => "You have successfully added an Doer Action",
		"successaddactivityexplain" => "What's your next step?",
		"successaddactivitybutton" => "Add More Doer Action",

		"deleteactivity" => "Are you sure you want to delete this Doer Action?",
		"successdeleteactivity" => "You have successfully Delete an Doer Action",

		"successeditactivity" => "You have successfully edit an Doer Action",

		"successupdateactivity" => "You have successfully Update an Doer Action",

		"successaddcompany" => "You have successfully added a Company",
		"successaddcompanyexplain" => "What's your next step?",
		"successaddcompanybutton" => "Add More Company",

		"successeditcompany" => "You have successfully edit a Company",

		"deletecompany" => "Are you sure you want to delete this Company?",
		"successdeletecompany" => "You have successfully Delete a Company",

		"successeditcorporate" => "You have successfully edit a Corporate",

		"successaddgroup" => "You have successfully added a Group",
		"successaddgroupexplain" => "What's your next step?",
		"successaddgroupbutton" => "Add More Group",

		"deletegroup" => "Are you sure you want to remove this Group?",
		"successdeletegroup" => "You have successfully Delete a Group",

		"successeditgroup" => "You have successfully edit a Group",

		"successaddkeyresult" => "You have successfully added a Key Result",
		"successaddkeyresultexplain" => "What's your next step?",
		"successaddkeyresultbutton" => "Add More Key Result",

		"deletekeyresult" => "Are you sure you want to delete this Key Result?",
		"deletekeyresultexplain" => "Just note that the <i>Doer Action</i> under this <b>Key Result</b> will also delete.",
		"successdeletekeyresult" => "You have successfully Delete a Key result",

		"successeditkeyresult" => "You have successfully edit a Key Result",

		"successupdatekeyresult" => "You have successfully Update a Key Result",

		"successaddobjective" => "You have successfully added an Objective",
		"successaddobjectiveexplain" => "What's your next step?",
		"successaddobjectivebutton" => "Add More Objective",
		"successaddobjectivebutton2" => "Add Key Result",

		"successeditobjective" => "You have successfully edit a Objective",

		"deleteobjective" => "Are you sure you want to delete this Objective?",
		"deleteobjectiveexplain" => "Just note that the <i>Key Result</i> under this <b>Objective</b> will also delete.",
		"successdeleteobjective" => "You have successfully Delete a Objective",

		"successaddplan" => "You have successfully added a Plan",
		"successaddplanexplain" => "What's your next step?",
		"successaddplanbutton" => "Add More Plan",

		"successupdateplan" => "You have successfully updated the Plan",

		"deleteplan" => "Are you sure you want to delete this Plan?",
		"successdeleteplan" => "You have successfully Delete a Plan",

		"successsubmitreport" => "You have successfully submitted Weekly Report",

		"successevaluatereport" => "You have successfully evaluated Weekly Report",

		"successaddtimeframe" => "You have successfully added a Timeframe",
		"successaddtimeframeexplain" => "What's your next step?",
		"successaddtimeframebutton" => "Add More Timeframe",

		"successedittimeframe" => "You have successfully edit a Timeframe",

		"deletetimeframe" => "Are you sure you want to delete this Timeframe?",
		"deletetimeframeexplain" => "Just note that the <i>Plan</i> under this <b>Timeframe</b> will also delete.",
		"successdeletetimeframe" => "You have successfully Delete a Timeframe",

		"reachmaxnumofuser" => "You have reach the maximum of user",
		"reachmaxnumofuserexplain" => "Contact Us for increasing the number of user",

		"successadduser" => "You have successfully added a User",
		"successadduserexplain" => "What's your next step?",
		"successadduserbutton" => "Add More User",

		"deleteuser" => "Are you sure you want to delete this User?",
		"successdeleteuser" => "You have successfully Delete a User",

		"successedituser" => "You have successfully edit a User",

		"notsubmitreport" => "No Report Submited",
		"notsubmitreportexplain" => "Your underlings not submit any report",

		"nookrsfoundfor" => "No OKR founds for",
		"notcreateokr" => "You haven't create any OKR"
	];
?><file_sep><?php
echo "Please wait!";
require_once 'core/init.php';

$user = new User();
$user->logout();

Redirect::to('login.php');
?><file_sep><?php
require_once 'core/init.php';


if(isset($_POST['catExp'])){

  $user = new User();
  $resultresult = $user->data();
  $userID = $resultresult ->userID;
  $rewuser = new Preward();
  
  $corporateID = $resultresult->corporateID;
  $companyID = $resultresult->companyID;
  date_default_timezone_set('Asia/Kuala_Lumpur');
  $today = date('Y-m-d H:i:s');

  $id = $_POST['catExp'];
  if ($id==="all3"){
      if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
        $row = $rewuser->RewardExpired($resultresult->companyID, 'companyID');
    }
      else {
        $row = $rewuser->RewardExpired($resultresult->corporateID, 'corporateID');
    }
  }
  else {
    if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
        $row = $rewuser->RewardExpiredCat($resultresult->companyID, 'companyID', $id);
    }
    else {
        $row = $rewuser->RewardExpiredCat($resultresult->corporateID, 'corporateID', $id);
    }
  }
  
  $view = ' ';

   if ($row){
                                
                              foreach ($row as $key) {
                            
                        $view .= '<div class="col-sm-4 col-lg-3 col-md-3">
                          
                          <div class="card" style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; ">
                            <!-- <div class="px-2 btn btn-outline-danger btn-sm text-uppercase" style="width: 120px; font-size: 14px;font-weight: 900;left: 13px;top: 15px;position: absolute;background: white;" >
                            </div> --> ';
                            
                            if (empty($key->reward_img)){
                              $view .='<div class="d-flex card-img-top"><img src="img/nopicture.png" width="180" height="200"  alt="Reward Picture" class="rewardimg"></div>';}
                              else {
                                $view .= '<div class="d-flex card-img-top"><img src="data:image/jpeg;base64,'.base64_encode($key->reward_img).'" width="180" height="200" alt="Reward Picture" class="rewardimg"></div>'; }

                              $view .= '<div class="card-body">
                                <h5 class="card-title">
                                  <span class="badge badge-success">'
                                     .$key->category.'</span>
                                  <strong>'.$key->reward.'</strong>
                                </h5>
                                <p class="card-text">
                                <span class="badge badge-pill badge-warning"> P </span>'
                                   .$key->points.'<br>'
                                   .$key->description.'<br>
                                  Valid til:'.$key->expiredate.
                                '</p>

                              </div>
                          </div>
                        </div>';

                          
             }

             
           }
                  
  else {
    $view .= 'You have no reward currently';
  }


  $array = ['view' => $view,
  ];

  echo ($view);
  

}<file_sep>
<?php
require_once 'core/init.php'; 
if (Input::exists()) {
	$currentuser= new User();
    $userid = $currentuser->data()->userID;
    $currentcompany = new User();
    $companyid = $currentcompany->data()->companyID;
    $currentcorporate= new User();
    $corporateid = $currentcorporate->data()->corporateID;

	$vrewardID = Input::get('vrewardID');
	$vpoints = Input::get('vpoints');
	$vquantity = Input::get('vquantity');

	$pr = new Preward();
	$currentpoint = $pr->searchPointReward2($userid);
	
	if(empty($currentpoint)){
	$tpoint = null;
	$pointID = null;
	$currentquantity = null;
	$rname = null;

	$totalcpoint = null;
	$totalquantity = null;
	}
	else{
	$tpoint = $pr->searchPointReward2($userid)->totalpoint;
	$pointID = $pr->searchPointReward2($userid)->pointID;
	$currentquantity = $pr->searchRewardID($vrewardID)->quantity;
	$currentpoint = $pr->searchPointReward2($userid)->currentpoint;
	$rname = $pr->searchRewardID($vrewardID)->reward;

	$totalcpoint = $currentpoint - $vpoints;
	$totalquantity = $currentquantity - 1;
	}

	function checkValid($data){
		if(empty($data)){
			return "Required";
		}else{
			return "Valid";
		}
	}

    function getCurrentTime(){

		date_default_timezone_set('Asia/Kuala_Lumpur');
		$date = date('Y-m-d H:i:s');

		return $date;
	}

	function checkCurrentPoint($data1, $currentpoint){
			if(empty($data1) || empty($currentpoint)){
				return "You don't have point";
			}
			elseif($currentpoint < $data1){
				return "Not enough point";
			}
			else{
				return "Valid";
			}
	}

	$date = getCurrentTime();

	function checkAllcondition($data1){
		if ($data1 === "Valid") {
			return "Passed";
		}else{
			return "Failed";
		}
	}

	$vpointserror = checkCurrentPoint($vpoints, $currentpoint);
	$allcondition = checkAllcondition($vpointserror);

	if ($allcondition === "Passed") {
		try{
			$prewardobject = new Preward();
			$prewardobject->insertclaimreward(array(
				'date' => $date,
				'rewardID' => $vrewardID,
				'userID' => $userid,
				'companyID' => $companyid,
				'corporateID' => $corporateid,
				'status' => 'Not Receive',
			));
			$prewardobject->updatepoint(array(
				'currentpoint'=> $totalcpoint,
				'userID' => $userid,
				'companyID' => $companyid,
				'corporateID' => $corporateid,
			),$pointID);
			$prewardobject->editpreward(array(
				'quantity'=> $totalquantity,
			),$vrewardID);
			$prewardobject->insertpointlog(array(
                'pointID' => $pointID,
				'previouspoint' => $currentpoint,
				'currentpoint' => $totalcpoint,
				'totalpoint' => $tpoint,
				'description' => "Claim ".$rname,
				'userID' => $userid,
				'actionDate' => $date,
				'action_name'=>"Claim Reward",
            ));
			
			$array=[
				'date' => $date,
				'rewardID' => $vrewardID,
				'currentpoint'=> $totalcpoint,
				'quantity' => $totalquantity,
				'condition'=> $allcondition
			];

		} catch (Exception $e){
			echo $e->getMessage();
		}
	}else{
		$array = [
				'date' => $date,
				'rewardID'=>$vrewardID,
				'currentpoint'=> $vpointserror,
				'quantity' => $totalquantity,
				"condition"=> $allcondition
				
		];
	}
	echo json_encode($array);
}
?><file_sep><!-- Claim Reward -->
<script type="text/javascript">
$(document).ready(function(){
	$('.afterviewreward').hide();
	var form = $('#viewrewardform');
	$("#vbutton").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		const vquantity		= document.getElementById('vquantity').value;
		const vpoints 	= document.getElementById('vpoints').value;
		const vrewardID 	= document.getElementById('vrewardID').value;
  //     };
		// var alldata = form.serialize();
		const alldata = "&vrewardID="+vrewardID+"&vpoints="+vpoints;
		// console.log(alldata);
		console.log(alldata);
		$.ajax({
			url: "ajax-claimpreward.php",
			type: "POST",
			data: alldata,
			success:function(data){
				console.log(data);
				var obj = JSON.parse(data);
				console.log(obj);
				 if(obj.condition === "Passed"){
						$('.beforeviewreward').hide();
						$('.afterviewreward').show();
						loaddata();
						$(document).on('click', "#doneID5", function(){
			              $("#viewreward").modal("hide");
			              modalformrefresh();
			              loaddata();
			          });
			
				 
				}
				else{
					//checkvalidity("claim_rewardIDerror", "#claim_rewardIDerror", "claim_rewardID", obj.claim_rewardID);
					checkvalidity("vpointserror", "#vpointserror", "vpoints", obj.currentpoint);
					
					
					
				}
			}
		});
	});
	$(document).on('click', "#closeviewreward", function(){
		// location.reload();
		$("#viewreward").modal("hide");
		
	});
	function checkvalidity(data1, data2, data3, data4){
		document.getElementById(data1).innerHTML = data4;
		if (data4 === "Required") {
			$(data2).removeClass("text-success").addClass("text-danger");
			$(data3).removeClass("border-success").addClass("border-danger");
		}else if (data4 === "Valid") {
			$(data2).removeClass("text-danger").addClass("text-success");
			$(data3).removeClass("border-danger").addClass("border-success");
		}else{
			$(data2).removeClass("text-success").addClass("text-danger");
			$(data3).removeClass("border-success").addClass("border-danger");
		}
	}
	function clearform(data1, data2, data3){
		$(data1).removeClass("text-success").removeClass("text-danger");
		document.getElementById(data2).textContent=" ";
		$(data3).removeClass("border-success").removeClass("border-danger");
	}
	function modalformrefresh(){
		$('.beforeviewreward').show();
		$('.afterviewreward').hide();
		document.getElementById("viewrewardform").reset();
		 clearform("#vpointserror", "vpointserror", "#vpoints");
		 //clearform("#dateerror", "dateerror", "#date");
		 // location.reload();
		
	}
	function loaddata(){
      // var category = 'all';
      var category = $('#category').val();
      var afford = document.getElementById("affordpoint").checked;
      
      //var All = $('#category').val('All');
      //var chartType = $('#chartType').val();
      //var myChart = document.getElementById('myChart').getContext('2d');
      if(afford == true){
      	var Apoint = $('#affordpoint').val();
      	$.ajax({
      url:"ajax-getAffordPoint.php",
      method:"POST",
      data:{Apoint:Apoint},
      //dataType:"json",
      success:function(data){
      $("#catdata").html(data);
      console.log('afford');
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
          }
        });
      // console.log('afford');
      }
      else{
     
    $.ajax({
      url:"ajax-getcategory.php",
      method:"POST",
      data:{category:category},
      //dataType:"json",
      success:function(data){
        $("#catdata").html(data);
        console.log('all');
        //dataCategory = [data.gift, data.cash, data.voucher, data.item, data.other];
        //updateCat(dataCategory);
      }
    });
    // console.log('all');
    }
	}
});
//});
</script>

<div class="modal fade" id="viewreward" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header bg-primary">
		 		<h5 class="modal-title" id="exampleModalLabel">Claim Reward</h5>
	  				<button type="button" class="close text-white" id="closeviewreward" data-dismiss="modal">&times;</button>
  			</div>
  		<div class="modal-body">
  			<div class="beforeviewreward">
  				<form id="viewrewardform">
					<input type="hidden" class="form-control type" name="vrewardID" id="vrewardID">
					
					<input type="hidden" class="form-control type" name="vquantity" id="vquantity">
						<div class="row">
							<p>Are you sure you want to claim this reward?	</p>
							<input type="hidden" class="form-control type" name="vpoints" id="vpoints">
							<small><span id="vpointserror"></span></small>
						</div>
						<br>
								
						<button name="submit" value="vbutton" type="submit" id="vbutton" class="btn btn-primary shadow-sm float-right">Claim</button>
				</form>
			</div>
				<div class="afterviewreward">
					<div class="p-5 text-center">
						<i class="fas fa-check-circle text-success my-3" style="font-size: 80px;"></i>
						<h4>You have successfully claim a Reward</h4>
						<button type="button" class="btn btn-outline-primary my-3" id="doneID5">Done</button>
					</div>
				</div>
			
		</div>
		
		</div>
	</div>
</div>
<!-- Claim Reward -->

<!-- Receive Reward -->
<script type="text/javascript">
$(document).ready(function(){
	$('.afterreceived').hide();
	var form = $('#receivedform');
	$("#rbutton").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		const claimID		= document.getElementById('claimID').value;
		// const claimstatus 	= document.getElementById('claimstatus').value;
  //     };
		// var alldata = form.serialize();
		const alldata = "&claimID="+claimID;
		// console.log(alldata);
		console.log(alldata);
		$.ajax({
			url: "ajax-claimreceived.php",
			type: "POST",
			data: alldata,
			success:function(data){
				console.log(data);
				var obj = JSON.parse(data);
				console.log(obj);
				 // if(obj.condition === "Passed"){
						$('.beforereceived').hide();
						$('.afterreceived').show();
						loaddata3();
						$(document).on('click', "#doneID2", function(){
			              $("#receivereward").modal("hide");
			              modalformrefresh();
			              loaddata3();
			          });
			
				 
				// }
				// else{
					//checkvalidity("claim_rewardIDerror", "#claim_rewardIDerror", "claim_rewardID", obj.claim_rewardID);
					// checkvalidity("vpointserror", "#vpointserror", "vpoints", obj.currentpoint);
					
					
					
				// }
			}
		});
	});
	$(document).on('click', "#closereceived", function(){
		// location.reload();
		$("#receivereward").modal("hide");
		modalformrefresh();
		
	});
	function checkvalidity(data1, data2, data3, data4){
		document.getElementById(data1).innerHTML = data4;
		if (data4 === "Required") {
			$(data2).removeClass("text-success").addClass("text-danger");
			$(data3).removeClass("border-success").addClass("border-danger");
		}else if (data4 === "Valid") {
			$(data2).removeClass("text-danger").addClass("text-success");
			$(data3).removeClass("border-danger").addClass("border-success");
		}else{
			$(data2).removeClass("text-success").addClass("text-danger");
			$(data3).removeClass("border-success").addClass("border-danger");
		}
	}
	function clearform(data1, data2, data3){
		$(data1).removeClass("text-success").removeClass("text-danger");
		document.getElementById(data2).textContent=" ";
		$(data3).removeClass("border-success").removeClass("border-danger");
	}
	function modalformrefresh(){
		$('.beforereceived').show();
		document.getElementById("receivedform").reset();
		 // clearform("#vpointserror", "vpointserror", "#vpoints");
		 //clearform("#dateerror", "dateerror", "#date");
		 // location.reload();
		
	}

	function loaddata3(){
      var companyID = $('#companyID').val();
     
    $.ajax({
      url:"ajax-getclaimpointreward.php",
      method:"POST",
      data:{companyID:companyID},
      success:function(data){
        $("#claimpointrewardview").html(data);
        console.log('companyID');
      }
    });

	}
});

</script>
<div class="modal fade" id="receivereward" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header bg-primary">
		 		<h5 class="modal-title" id="exampleModalLabel">Claim Reward</h5>
	  				<button type="button" class="close text-white" id="closereceived" data-dismiss="modal">&times;</button>
  			</div>
  		<div class="modal-body">
  			<div class="beforereceived">
  				<form id="receivedform">
					<input type="hidden" class="form-control type" name="claimID" id="claimID">
					
					<!-- <input type="hidden" class="form-control type" name="claimstatus" id="claimstatus"> -->
						<div class="row">
							<p>Are you sure the user has received the claimed reward?</p>
						</div>
						<br>
								
						<button name="submit" value="rbutton" type="submit" id="rbutton" class="btn btn-primary shadow-sm float-right">Yes</button>
				</form>
			</div>
				<div class="afterreceived">
					<div class="p-5 text-center">
						<i class="fas fa-check-circle text-success my-3" style="font-size: 80px;"></i>
						<h4>You have successfully confirmed the claimed reward</h4>
						<button type="button" class="btn btn-outline-primary my-3" id="doneID2">Done</button>
					</div>
				</div>
			
		</div>
		
		</div>
	</div>
</div>
<!-- Receive Reward --><file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}

$reward = new Preward();
$userID = $resultresult->userID;

if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
  $checkid2 = $resultresult->companyID;
    $idfrom2 = 'companyID';
    
    $rewardresult= $reward->searchAllReward($resultresult->companyID, 'companyID');
}
else {
  $checkid2 = $resultresult->corporateID;
    $idfrom2 = 'corporateID';
    $rewardresult= $reward->searchAllReward($resultresult->corporateID, 'corporateID');

}

 $view = ' ';
       
                                if($rewardresult){
                                  $view .='
                              <table class="table table-responsive-sm table-sm my-3 text-center">
                                <thead>
                                  <tr>
                                    <th> </th>
                                    <th>Name</th>
                                    <th>Description</th>
                                    <th>Quantity</th>
                                    <th>Limit (Per Person)</th>
                                    <th>Point</th>
                                    <th>Category</th>
                                    <th>Deadline</th>
                                    <th>Date Entry</th>
                                    <th>Action</th>
                                  </tr>
                                </thead>
                                <tbody>';
                   
                                foreach ($rewardresult as $row) {
                          $view .='
                                  <tr>
                                    <td>';
                                      if (empty($row->reward_img)){
                                      $view .='<img src="img/nopicture.png" width="150" height="150" style="object-fit: cover;" alt="Reward Picture">';}
                                      else {
                                      $view .='<img src="data:image/jpeg;base64,'.base64_encode($row->reward_img).'" width="150" height="150" style="object-fit: contain;" alt="Reward Picture">';} 
                                      $view .='</td>
                                    <td class="align-middle">'.$row->reward.'</td>
                                    <td class="align-middle">'.$row->description.'</td>
                                    <td class="align-middle">'.$row->quantity.'</td>
                                    <td class="align-middle">'.$row->rewardLimit.' time</td>
                                    <td class="align-middle">'.$row->points.' pts</td>
                                    <td class="align-middle">'.$row->category.'</td>
                                    <td class="align-middle">'.$row->expiredate.'</td>
                                    <td class="align-middle">'.$row->entrydate.'</td>';
                                    if ($row->userID == $userID){
                                    $view .= '<td class="align-middle"><a class="btn btn-white btn-sm editbutton" data-toggle="modal" data-target="#editpreward" data-backdrop="static" id="'.$row->rewardID.'"><i class="fas fa-edit text-success"></i></a>
                                        <a class="btn btn-white btn-sm deletebutton" data-toggle="modal" data-target="#removepreward" data-backdrop="static" id="'.$row->rewardID.'"><i class="fas fa-remove text-danger"></i></a></td>
                                      </tr>';}
                                      else{
                                        $view .= '<td class="align-middle"><a class="btn btn-white btn-sm text-muted"><i class="fas fa-edit"></i></a>
                                        <a class="btn btn-white btn-sm text-muted"><i class="fas fa-remove"></i></a></td>
                                      </tr>';
                                      }
                              
                                }
                              $view .='
                              </tbody>
                            </table>
                          </div>';
            }
            else{
            $view .='
            <div class="col">
              <p class="text-center">Nothing to show</p>
          </div>

            ';
            }

              echo ($view);
            ?>

<file_sep><?php
require_once 'core/init.php';
include 'include/header.php';
?>
<script type="text/javascript">
  $(document).ready(function(){
    $('.after').hide();
    $('#forgetemailnotfound').hide();
    var form = $('#forgetpasswordform');
    form.on('submit', function(e){
      e.preventDefault();
      e.stopPropagation();
      var email = document.getElementById("email").value;
      var alldata = "email="+email;
      console.log(alldata);
      $.ajax({
        url: "ajax-forgetpassword.php",
        type: "POST",
        data: alldata,
        success:function(data){
          var obj = JSON.parse(data);
          console.log(obj);
          if(obj.condition === "Passed"){
            if(obj.emailerror){
              $('#forgetemailnotfound').show();
            }else{
              $('.before').hide();
              $('.after').show();
              document.getElementById("recoveryemail").innerHTML = obj.email;
            }

          }else{
            checkvalidity("emailerror","#emailerror", "#email", obj.email);
          }
        }
      });
    });

    function checkvalidity(data1, data2, data3, data4){
      document.getElementById(data1).innerHTML = data4;
      if(data4 === "Required"){
        $(data2).removeClass("text-success").addClass("text-danger");
        $(data3).removeClass("border-success").addClass("border-danger");
      }else if(data4 === "Valid"){
        $(data2).removeClass("text-danger").addClass("text-success");
        $(data3).removeClass("border-danger").addClass("border-success");
      }else{
        $(data2).removeClass("text-success").addClass("text-danger");
        $(data3).removeClass("border-success").addClass("border-danger");
      }
    }

    function clearform(data1, data2, data3){
      $(data1).removeClass("text-success").removeClass("text-danger");
      document.getElementById(data2).innerHTML="";
      $(data3).removeClass("border-success").removeClass("border-danger");
    }

  });
</script>
<body class="bg-light">
  <div class="row">
    <div class="col"></div>

    <div class="col my-5 py-5">
      <div class="before">
            <div class="text-center mb-5 mt-3">
              <h4>Welcome to <a class="navbar-brand link font-poetsen-one" href="/index.php" id="logo" style="font-size: 25px;"><span class="text-dark">Claim System</span></a></h4>
              <h5>Forget Password </h5>
              <small>Back to <a href="login.php">Login</a></small>
            </div>
            <div class='alert alert-danger alert-dismissible' id="forgetemailnotfound">
              <button type='button' class='close' data-dismiss='alert'>&times;</button><strong>Email not found</strong>
            </div>
            <form id="forgetpasswordform">
              <div class="form-group">
                <div class="row">
                  <div class="col-3"><label>Email :</label></div>
                  <div class="col">
                    <input type="text" class="form-control form-control-sm shadow-sm" id="email" name="email" autocomplete="off">
                    <small><span id="emailerror"></span></small>
                  </div>
                </div>
              </div>
              
              <div class="text-center">
                <button name="submit" value="login" type="submit" class="btn btn-primary shadow-sm">Submit</button>
              </div>

            </form>
          </div>
          <div class="after">
            <div class="p-5 text-center">
              <i class='far fa-check-circle text-success my-3' style='font-size:80px;'></i>
              <h4>Yey get new password <span id="recoveryemail"></span></h4>
              <a href="login.php" class="btn btn-outline-primary my-3" role="button">Login Now !</a>
            </div>
          </div>
    </div>
    <div class="col"></div>
  </div>

  </div>
    <!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->

<file_sep><?php
require_once 'core/init.php'; 
if (Input::exists()) {
	$currentuser= new User();
    $userid = $currentuser->data()->userID;
    $currentcompany = new User();
    $companyid = $currentcompany->data()->companyID;
    $currentcorporate= new User();
    $corporateid = $currentcorporate->data()->corporateID;

	$claimID = Input::get('claimID');
	$claimstatus = Input::get('claimstatus');
	
	function checkValid($data){
		if(empty($data)){
			return "Required";
		}else{
			return "Valid";
		}
	}


	function checkAllcondition($data1){
		if ($data1 === "Valid") {
			return "Passed";
		}else{
			return "Failed";
		}
	}

	// $claimstatuserror = checkValid($claimstatus);
	// $allcondition = checkAllcondition($claimstatuserror);

	// if ($allcondition === "Passed") {
	// 	try{
			$prewardobject = new Preward();
			$prewardobject->updateclaimed(array(
				'claim_rewardID'=> $claimID,
				'status'=> 'Received',
			),$claimID);
			
			$array=[
				'claim_rewardID'=> $claimID,
				'status' => 'Received',
				// 'condition'=> $allcondition
			];

	// 	} catch (Exception $e){
	// 		echo $e->getMessage();
	// 	}
	// }else{
	// 	$array = [
	// 			'status' => 'Received',
	// 			"condition"=> $allcondition
				
	// 	];
	// }
	echo json_encode($array);
}
?><file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}

$company2 = new Company();
$reward = new Preward();
$kpireward = new Rewards();
$user = new User();

if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
    $checkid2 = $resultresult->companyID;
    $idfrom2 = 'companyID';
    $claimresult= $reward->searchAllComClaim($checkid2);
}
else {
    $checkid2 = $resultresult->corporateID;
    $idfrom2 = 'corporateID';
    $claimresult= $reward->searchAllCorClaim($checkid2);
}

$view = '';

                   if($claimresult){       
                      $view .='<table class="table table-responsive-sm table-sm my-3">
                            <thead>
                              <th>Name</th>
                              <th>Reward</th>
                              <th>Date Claimed</th>
                              <th>Status</th>
                            </thead>
                            <tbody>';

                    foreach ($claimresult as $key) {
                      $userresult =$user->searchUser($key->userID); 
                      $rewardr = $reward->searchRewardID($key->rewardID);                            
                            $view .='
                              <tr>
                                <td>'.$userresult->firstname.' '.$userresult->lastname.'</td>
                                <td>'.$rewardr->reward.'</td>
                                <td>'.$key->date.'</td>
                                <td>';
                                  
                             if($key->status == "Received"){
                                $view .= '<button type="button" class="btn btn-outline-primary text-dark" disabled>Received</button>';} 
                              else{
                                $view .= '<button type="button" class="btn btn-primary receivereward" data-toggle="modal" data-target="#receivereward" data-backdrop="static" id="'.$key->claim_rewardID.'">Pending</button>';
                                    }
                                    
                            $view .='         
                                </td>
                              </tr>';
                           
                    } 
                  }
                    else{
                      $view .= '<p class="text-center">Nothing to show</p>';
                            }
                  $view .='
                               </tbody>
                          </table>';

echo ($view);
?>
          


<file_sep><?php
if($resultresult->corporateID){
	$corporateobject = new Corporate();
	$corporateresult = $corporateobject->searchCorporate($resultresult->corporateID);
	if($corporateresult){
		if($corporateresult->package === "Trial"){
			$packageversion = "<span class='badge badge-pill badge-secondary mx-2'>Trial</span>";
			$navbarpackage = "Trial";
		}elseif($corporateresult->package === "Free"){
			$packageversion = "<span class='badge badge-pill badge-dark mx-2'>Free</span>";
        	$navbarpackage = "Free";
		}elseif($corporateresult->package === "Basic"){
			$packageversion = "<span class='badge badge-pill badge-info mx-2'>Basic</span>";
			$navbarpackage = "Basic";
		}elseif($corporateresult->package === "Pro"){
			$packageversion = "<span class='badge badge-pill badge-primary mx-2'>Pro</span>";
			$navbarpackage = "Pro";
		}elseif($corporateresult->package === "Business"){
			$packageversion = "<span class='badge badge-pill badge-danger mx-2''>Business</span>";
			$navbarpackage = "Business";
		}elseif($corporateresult->package === "Enterprise"){
			$packageversion = "<span class='badge badge-pill badge-dark mx-2' style='color:gold;'>Enterprise</span>";
			$navbarpackage = "Enterprise";
		}else{
			$packageversion = "";
		}
	}
}else{
	$companyobject = new Company();
	$companyresult = $companyobject->searchCompany($resultresult->companyID);
	if($companyresult){
		if($companyresult->package === "Trial"){
			$packageversion = "<span class='badge badge-pill badge-secondary mx-2'>Trial</span>";
			$navbarpackage = "Trial";
		}elseif($companyresult->package === "Free"){
			$packageversion = "<span class='badge badge-pill badge-dark mx-2'>Free</span>";
			$navbarpackage = "Free";
		}elseif($companyresult->package === "Basic"){
			$packageversion = "<span class='badge badge-pill badge-info mx-2'>Basic</span>";
			$navbarpackage = "Basic";
		}elseif($companyresult->package === "Pro"){
			$packageversion = "<span class='badge badge-pill badge-primary mx-2'>Pro</span>";
			$navbarpackage = "Pro";
		}elseif($companyresult->package === "Business"){
			$packageversion = "<span class='badge badge-pill badge-danger mx-2'>Business</span>";
			$navbarpackage = "Business";
		}elseif($companyresult->package === "Enterprise"){
			$packageversion = "<span class='badge badge-pill badge-dark mx-2' style='color:gold;'>Enterprise</span>";
			$navbarpackage = "Enterprise";
		}else{
			$packageversion = "";
		}
	}else{
		$packageversion = "";
	}
}

 if (empty($resultresult->corporateID) && empty($resultresult->companyID)) {
   $packageversion = "<span class='badge badge-pill badge-warning mx-2'>Coaching</span>";
			$navbarpackage = "Coaching";
  }

?>

<nav class="navbar navbar-expand-xl navbar-light bg-white sticky-top shadow-sm text-dark">
	<button class="btn" id="menu-toggle"><i class='fas fa-bars text-dark'></i></button>
	<a class="navbar-brand link font-poetsen-one mx-2" href="#" id="logo" style="font-size: 25px;"><span class="text-dark">Doer</span><span class="text-primary">HRM</span></a>
	<div class="dropdown mr-auto">
	  <button type="button" class="btn btn-lght dropdown-toggle" data-toggle="dropdown">
	    <i class='fas fa-globe'></i> 
	    <?php 

	    if(Input::get('lang')){
	    	$extlg = Input::get('lang');
	    	echo $extlg;
	    }else{
	    	$extlg = "en";
	    	echo $extlg;
	    }

	    if(Input::get('id')){
	    	$extid = "id=".Input::get('id')."&";
	    }else{
	    	$extid = "";
	    }
	    ?>
	  </button>
	  
	  <div class="dropdown-menu">
	    <a class="dropdown-item <?php if(Input::get('lang') === "en"){echo "active disabled";}?>" href="?<?php echo $extid;?>lang=en">en (English)</a>
	    <a class="dropdown-item <?php if(Input::get('lang') === "zh"){echo "active disabled";}?>" href="?<?php echo $extid;?>lang=zh">zh (简体中文)</a>
	    <a class="dropdown-item <?php if(Input::get('lang') === "bm"){echo "active disabled";}?>" href="?<?php echo $extid;?>lang=bm">bm (Bahasa Melayu)</a>
	  </div>
	</div> 
	<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
	   <span class="navbar-toggler-icon" style="color:black;"></span>
	</button>
	<div class="collapse navbar-collapse " id="collapsibleNavbar">
		<ul class="navbar-nav ml-auto ">	
		  <span class="navbar-text mt-1">
		    <?php echo $packageversion;?>
		  </span>
		  <!--<li class="nav-item">
		  	<a class="nav-link mt-2" href="#">
		  		<i class='fas fa-mail-bulk' style="font-size: 24px;"></i>
		  	</a>
		  </li>
		  <li class="nav-item">
		  	<a class="nav-link mt-2" href="#">
		  		<i class='far fa-question-circle' style="font-size: 24px;"></i>
		  	</a>
		  </li>-->
		  <li class="nav-item dropdown mr-4">
		    <a class="nav-link" href="#" id="navbardrop" data-toggle="dropdown">
		    	<?php
		    	if($resultresult->profilepic){
		    		?>
		    		<img src="data:image/jpeg;base64,<?php echo base64_encode($resultresult->profilepic);?>" class="rounded-circle" width="35" height="35" style="object-fit: cover;">
		    		<?php
		    	}else{
		    		?>
		    		<img src="img/userprofile.png" class="rounded-circle" width="35" height="35" style="object-fit: cover;">
		    		<?php
		    	}
		    	?>
				
			</a>
			<div class="dropdown-menu dropdown-menu-right rounded-lg shadow-lg">
				<a class='dropdown-item px-5 pt-3 text-center' href="personal.php?lang=<?php echo $extlg?>" id="personaltab">
					<?php
			    	if($resultresult->profilepic){
			    		$profilepic = "data:image/jpeg;base64,".base64_encode($resultresult->profilepic);
			    	}else{
			    		$profilepic = "img/userprofile.png";
			    	}
			    	?>
					<div class="media">
					  <img src="<?php echo $profilepic;?>" class="align-self-center mr-3" style="width:70px">
					  <div class="media-body">
					    <h5 class="font-weight-lighter"><?php echo $resultresult->firstname." ".$resultresult->lastname." <small class='badge badge-primary'>".$resultresult->role."</small> ";?></h5>
					    <p class="m-0"><?php echo $resultresult->email;?></p>
					  </div>
					</div>
				</a>

				<?php
				if($resultresult->role === "Client"){
					?><center><center>
					<a class='btn btn-outline-dark my-2' style="border-radius: 50px;" href='clientprofile.php?lang=<?php echo $extlg?>' id="clientdashboard">Company Profile</a>
				</center> <?php
				}
				if($resultresult->role == "Coach"){
				?>
				<center>
					<a class='btn btn-outline-dark my-2' style="border-radius: 50px;" href='coachprofile.php?lang=<?php echo $extlg?>' id="coachdashboardtab">Coach Profile</a>
				</center>
				
				<?php
				}?>

				<?php
				if($resultresult->admin == true){
					?>
					<center><div class="dropdown-header">Dashboard</div></center> 
					<center>
						<a class='btn btn-outline-dark my-2' style="border-radius: 50px;" href='dashboard-admin.php?lang=<?php echo $extlg?>' id="admindashboardtab"><?php echo $array['admindashboard']?></a>
					</center>
					<?php
						$userobject = new User();
						$userresult = $userobject->searchinviteduser($resultresult->userID);
						$onlyinvited = 0;
						if($userresult){
							$totalinvited = count($userresult);
							foreach ($userresult as $row) {
								if($row->status === "Done"){
									$onlyinvited++;
								}
							}
						}else{
							$totalinvited = 0;
						}
		
						if($onlyinvited >= 2 && $navbarpackage === "Trial"){
							?>
							<center>
								<button class='btn btn-lg btn-outline-warning my-2' type="button" onclick="upgradepackage(<?php echo $resultresult->companyID;?>)">Upgrade Now to Basic Package</button>
							</center>
							<?php
						}
		
						if($navbarpackage === "Trial" || $navbarpackage === "Free"){
							?>
							<center>
								<button class='btn btn-outline-success my-2' type="button" data-toggle="modal" data-target="#inviteusers">Successfully Invite 2 Users Now <br> for <br>Free Check In Customization</button>
							</center>
							<center><?php echo "<span id='totalinviteuser'>".$totalinvited."</span>";?> users invited | <?php echo "<span id='totalsuccess'>".$onlyinvited."</span>";?> users successfully invited</center>
							<?php
						}
					}
	
					?>
				<div class="dropdown-divider"></div>
				<center><a class="btn btn-outline-dark my-2" href="logout.php"><?php echo $array['logout']?></a></center>
				<div class="dropdown-divider"></div>
				<span class="dropdown-item-text"><center><small>DoerHRM</small></center></span>
			</div>
		  </li>
		</ul>
	</div>
</nav>
<style type="text/css">
	#myModal {
	    width:30%;
	    position:fixed;
	    bottom:60px;
	    right:5px;
	    margin:20px;
	    z-index: 2;
	}
	@media only screen and (max-width: 1200px) {
		#myModal {
		    width:50%;
		    position:fixed;
		    bottom:60px;
		    right:5px;
		    margin:20px;
		    z-index: 2;
		}
	}
	@media only screen and (max-width: 600px) {
		#myModal {
		    width:90%;
		    position:fixed;
		    bottom:60px;
		    right:5px;
		    margin:20px;
		    z-index: 2;
		}
	}
	#toggleguide {
	    position:fixed;
	    bottom:5px;
	    right:5px;
	    margin:20px;
	    z-index: 2;
	}
</style>
<div id="myModal" style="display: none">
	<div class='card shadow-lg rounded mb-2'>
		<div class="card-body bg-light">
		   <h6 class="mb-n1">Welcome to DoerHRM!</h6>
		</div>
	</div>

	<div class='card shadow-lg rounded'>
		<div class="card-body bg-light">
		  <div class="m-2">
		    We are platform that can help company to improve to another level. Are you lost? Let's see how can I help you?<br>
		    <?php
		    if($resultresult->admin == true){
		    	?>
		    	<a href="tutorial-admin.php" class="btn btn-outline-primary m-2" role="button" style="border-radius: 50px; border: 1px solid;"><b>Setup the Environment</b></a><br>
		    	<?php
		    }

		    if($resultresult->becomesupervisor == true){
		    	?>
		    	<a href="#" class="btn btn-outline-primary m-2" role="button" style="border-radius: 50px; border: 1px solid;">Supervisor & Trainee</a>
		    	<?php
		    }

		    if($navbarpackage === "Trial" || $navbarpackage === "Pro" || $navbarpackage === "Business" || $navbarpackage === "Enterprise"){
		    	?>
		    	<a href="tutorial-okr.php" class="btn btn-outline-primary m-2" role="button" style="border-radius: 50px; border: 1px solid;">How to use <b>OKR</b></a>
		    	<?php
		    }

		    if ($navbarpackage === "Business" || $navbarpackage === "Enterprise") {
		    	?>
		    	<a href="#" class="btn btn-outline-primary m-2" role="button" style="border-radius: 50px; border: 1px solid;">How to use <b>Coaching</b></a>
		    	<?php
		    }

		    if ($navbarpackage === "Enterprise"){
		    	?>
		    	<a href="#" class="btn btn-outline-primary m-2" role="button" style="border-radius: 50px; border: 1px solid;">How to use <b>KPI</b></a>
		    	<a href="#" class="btn btn-outline-primary m-2" role="button" style="border-radius: 50px; border: 1px solid;">How to use <b>360 Feedback</b></a>
		    	<?php
		    }
		    ?>
		  </div>
		</div>
	</div>
</div>

<button type="button" class="btn btn-primary btn-lg shadow-lg border border-white" style="border-radius: 100px; border: 1px solid;" id="toggleguide"><i class='fas fa-question'></i></button>

<script type="text/javascript">
	$(document).ready(function() {
	  if (window.localStorage.getItem("myModal") != null) {
	    var pb = window.localStorage.getItem("myModal");
	    if (pb == "true") {
	      $("#myModal").hide();
	    }else{
	      setTimeout($("#myModal").show('fade'), 1000);
	    }
	  }

	  $("#toggleguide").click(function() {
	    var v = $("#myModal").is(":visible")
	    $("#myModal").toggle('fade');
	    window.localStorage.setItem("myModal", v)
	  });
	});
</script><file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}
include 'include/header.php';

?>
<body>
  <div class="d-flex" id="wrapper">
    <?php include 'include/navbar.php';?>
    <div class="container-fluid">
     <h4 class="my-5"><i class='fa fa-list-alt'></i>  Manage Reward</h4>

                          <div class="col text-right">
                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#createpreward" data-backdrop="static"><i class='fas fa-plus'></i> Add Reward</button>
                          </div>
                     <div id="managerewardview"> </div>
    </div>
  </div>
</body>

    <!-- /#page-content-wrapper -->
<!--<script type="text/javascript">
  //$(document).ready(function(){
     //$("#sidebar-wrapper .active").removeClass("active");
    // $("#yourkpinavid").addClass("active");
 // });
</script> -->
<!-- /#wrapper -->
<script>

$(document).ready(function(){

    function getviewreward(){
      $.ajax({
        url:"ajax-getviewmanagereward.php",
        success:function(data){
          $("#managerewardview").html(data);
        }
      });
    }

    getviewreward();

  


  $("body").on("click", ".editbutton", function(e){

e.preventDefault();
rewardID=$(this).attr('id');
$.ajax({
    url: "ajax-getpointreward.php",
    type: "POST",
    data: {rewardID:rewardID},

    success:function(response){
    data = JSON.parse(response);
    
      
      $("#upreward").val(data.reward);
      $("#updesc").val(data.description);
      $("#upLimit").val(data.rewardLimit);
      $("#uppoints").val(data.points);
      $("#upcategory").val(data.category);
      $("#upexpdate").val(data.expiredate);
      $("#upentdate").val(data.entrydate);
      $("#upquantity").val(data.quantity);
      $("#rewardID").val(data.rewardID);
    }

  });

});

  $("body").on("click", ".deletebutton", function(e){

e.preventDefault();
rewardID=$(this).attr('id');
$.ajax({
    url: "ajax-getpointreward.php",
    type: "POST",
    data: {rewardID:rewardID},

    success:function(response){
    data = JSON.parse(response);
    
      
      $("#delpreward").val(data.reward);
      $("#delprewardID").val(data.rewardID);
      $("#delcompanyID").val(data.companyID);
    }

  });

});

  });
</script>
<?php include 'include/form.php';?><file_sep><?php
class Database{
	//properties of class Database
	private static $_instance = null;
	private $_pdo, 
			$_query, 
			$_error = false, 
			$_results,
			$_count = 0,
			$_insertid;
			
	//Methods of class Database
	//get connection to database with PDO
	private function __construct(){
		try{
			$this->_pdo = new PDO('mysql:host='.Config::get('database/host').';dbname='.Config::get('database/db'),Config::get('database/username'),Config::get('database/password'));
		}catch(PDOException $e){
			die($e->getMessage());
		}
	}
	
	//create instance for connection
	public static function getInstance(){
		if(!isset(self::$_instance)){
			self::$_instance = new Database();
		}
		return self::$_instance;
	}

	public function lastInsertId(){
		return $this->_pdo->lastinsertid();
	}
	
	//execute the sql statement and save to results variable
	public function query($sql, $params = array()){
		$this->_error = false;
		if($this->_query = $this->_pdo->prepare($sql)){
			$x = 1;
			if(count($params)){
				foreach($params as $param){
					$this->_query->bindValue($x, $param);
					$x++;
				}
			}
			if($this->_query->execute()){
				$this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
				$this->_count = $this->_query->rowCount();
				
			}else{
				$this->_error = true;
			}
		}
		return $this;
	}

	public function queryall($sql = null){
		$this->_error = false;
		if($this->_query = $this->_pdo->prepare($sql)){

			if($this->_query->execute()){
				$this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
				$this->_count = $this->_query->rowCount();
				
			}else{
				$this->_error = true;
			}
		}
		return $this;
	}

	public function actionall($action, $table){
		$sql = "{$action} FROM {$table}";
		if(!$this->queryall($sql)->error()){
			return $this;
		}
		return false;
	}

	public function getall($table){
		return $this->actionall('SELECT *', $table);
	}

	//restructure the sql statement from function get and delete
	public function action($action, $table, $where = array()){
		if(count($where) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];
			
			if(in_array($operator, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?";
				if(!$this->query($sql, array($value))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionOne($action, $table, $where1 = array(), $where2 = array()){
		if(count($where1) === 3 && count($where2) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ?";
				if(!$this->query($sql, array($value1, $value2))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionTwo($action, $table, $where1 = array(), $where2 = array(), $where3){
		if(count($where1) === 3 && count($where2) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? AND verified = ?";
				if(!$this->query($sql, array($value1, $value2, $where3))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function action2($action, $table, $where1 = array(), $where2 = array(), $where3 = array()){
		if(count($where1) === 3 && count($where2) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? AND {$field3} {$operator3} ?";
				if(!$this->query($sql, array($value1, $value2, $value3))->error()){
					return $this;
				}
			}
		}
		return false;
	}
	
	public function action2_1($action, $table, $where1 = array(), $where2 = array(), $where3 = array()){
		if(count($where1) === 3 && count($where2) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND ({$field2} {$operator2} ? OR {$field3} {$operator3} ?)";
				if(!$this->query($sql, array($value1, $value2, $value3))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function action3($action, $table, $where1 = array(), $where2 = array(), $where3 = array(), $where4 = array()){
		if(count($where1) === 3 && count($where2) === 3 && count($where3) === 3 && count($where4) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];

			$field4 		= $where4[0];
			$operator4 		= $where4[1];
			$value4 		= $where4[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators) && in_array($operator4, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? AND ({$field3} {$operator3} ? AND {$field4} {$operator4} ?)";
				if(!$this->query($sql, array($value1, $value2, $value3, $value4))->error()){
					return $this;
				}
			}
		}
		return false;
	}
	
	public function action3_1($action, $table, $where1 = array(), $where2 = array(), $where3 = array(), $where4 = array(), $where5 = array(), $where6 = array()){
		if(count($where1) === 3 && count($where2) === 3 && count($where3) === 3 && count($where4) === 3 && count($where5) === 3 && count($where6) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];

			$field4 		= $where4[0];
			$operator4 		= $where4[1];
			$value4 		= $where4[2];

			$field5 		= $where5[0];
			$operator5 		= $where5[1];
			$value5 		= $where5[2];

			$field6 		= $where6[0];
			$operator6 		= $where6[1];
			$value6 		= $where6[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators) && in_array($operator4, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? AND (({$field3} {$operator3} ? AND {$field4} {$operator4} ?) OR ({$field5} {$operator5} ? AND {$field6} {$operator6} ?))";
				if(!$this->query($sql, array($value1, $value2, $value3, $value4, $value5, $value6))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function action4($action, $table, $where1 = array(), $where2 = array(), $where3 = array(), $where4 = array(), $where5 = array()){
		if(count($where1) === 3 && count($where2) === 3 && count($where3) === 3 && count($where4) === 3 && count($where5) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];

			$field4 		= $where4[0];
			$operator4 		= $where4[1];
			$value4 		= $where4[2];

			$field5 		= $where5[0];
			$operator5 		= $where5[1];
			$value5 		= $where5[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators) && in_array($operator4, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? AND ({$field3} {$operator3} ? AND {$field4} {$operator4} ? AND {$field5} {$operator5} ?)";
				if(!$this->query($sql, array($value1, $value2, $value3, $value4, $value5))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionDesc($action, $table, $where = array(), $where2){
		if(count($where) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];
			
			if(in_array($operator, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? ORDER BY {$where2} DESC";
				if(!$this->query($sql, array($value))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionDescN($action, $table, $where = array(), $where2, $where3 = array(), $where4){
		if(count($where) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];
			
			if(in_array($operator, $operators) && in_array($operator3, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field3} {$operator3} ? AND {$where2} NOT IN (SELECT {$where4} FROM {$table} WHERE {$field} {$operator} ? ) GROUP BY {$where2}";
				if(!$this->query($sql, array($value, $value3))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionGroup($action, $table, $where = array(), $where2){
		if(count($where) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];
			
			if(in_array($operator, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? GROUP BY {$where2}";
				if(!$this->query($sql, array($value))->error()){
					return $this;
				}
			}
		}
		return false;
	}


	public function actionPcom($action, $table, $where1 = array(), $where2 = array(), $where3 = array()){
		if(count($where1) === 3 && count($where2) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators)){
				$sql = "{$action} FROM {$table} WHERE parent_comment_id = '0' AND ( {$field1} {$operator1} ? OR {$field2} {$operator2} ? ) AND {$field3} {$operator3} ?  ORDER BY comment_id DESC";
				if(!$this->query($sql, array($value1, $value2, $value3))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionCcom($action, $table, $where1 = array()){
		if(count($where1) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			if(in_array($operator1, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ?";
				if(!$this->query($sql, array($value1))->error()){
					return $this;
				}
			}
		}
		return false;
	}
	
	public function actionE($action, $table, $where1 = array(), $where2 = array(), $where3 = array()){
		if(count($where1) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];
			

			
			if(in_array($operator1, $operators) && in_array($operator2, $operators) && in_array($operator3, $operators)){
				$sql = "{$action} FROM {$table} WHERE ({$field1} {$operator1} ? OR {$field2} {$operator2} ?) AND {$field3} {$operator3} ?";
				if(!$this->query($sql, array($value1, $value2, $value3))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionsum($action, $table, $where = array()){
		if(count($where) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];
			
			if(in_array($operator, $operators)){
				$sql = "{$action} AS totalsize FROM {$table} WHERE {$field} {$operator} ?";
				if(!$this->query($sql, array($value))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionGetKPITotalYear($action, $table, $where1 = array(), $where2 = array()){
		if(count($where1) === 3 && count($where2) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? GROUP BY month";
				if(!$this->query($sql, array($value1, $value2))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionProgress($action, $table, $where = array(), $where2, $where3 = array(), $where4){
		if(count($where) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];
			
			if(in_array($operator, $operators) && in_array($operator3, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? AND {$field3} {$operator3} ? AND {$where2} IN (SELECT MAX({$where2}) FROM {$table}  GROUP BY {$where4})";
				if(!$this->query($sql, array($value, $value3))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionProgressDate($action, $table, $where = array(), $where2, $where3 = array(), $where4, $where5 = array()){
		if(count($where) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];

			$field5 		= $where5[0];
			$operator5 		= $where5[1];
			$value5 		= $where5[2];
			
			if(in_array($operator, $operators) && in_array($operator3, $operators) && in_array($operator5, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? AND {$field3} {$operator3} ? AND {$field5} {$operator5} ? AND {$where2} IN (SELECT MAX({$where2}) FROM {$table}  GROUP BY {$where4})";
				if(!$this->query($sql, array($value, $value3, $value5))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionProgressDateAll($action, $table, $where = array(), $where3 = array(), $where4, $where5 = array()){
		if(count($where) === 3 && count($where3) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];

			$field3 		= $where3[0];
			$operator3 		= $where3[1];
			$value3 		= $where3[2];

			$field5 		= $where5[0];
			$operator5 		= $where5[1];
			$value5 		= $where5[2];
			
			if(in_array($operator, $operators) && in_array($operator3, $operators) && in_array($operator5, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? AND {$field3} {$operator3} ? AND {$field5} {$operator5} ?";
				if(!$this->query($sql, array($value, $value3, $value5))->error()){
					return $this;
				}
			}
		}
		return false;
	}


	
	//select function and pass to function action

	public function getProgress($table, $where1, $where2, $where3, $where4){
		return $this->actionProgress('SELECT *', $table, $where1, $where2, $where3, $where4);
	}

	public function getProgressDate($table, $where1, $where2, $where3, $where4, $where5){
		return $this->actionProgressDate('SELECT *', $table, $where1, $where2, $where3, $where4, $where5);
	}

	public function getProgressDateAll($table, $where1, $where3, $where4, $where5){
		return $this->actionProgressDateAll('SELECT *', $table, $where1, $where3, $where4, $where5);
	}

	public function getYearKPI($table, $where1,$where2){
		return $this->actionGetKPITotalYear('SELECT sum(progress) AS progress,sum(weightage) as weightage,month,year,assignTo', $table, $where1,$where2);
	}

	public function getsum($table , $where){
		return $this->actionsum('SELECT SUM(size)', $table, $where);
	}

	public function get($table, $where){
		return $this->action('SELECT *', $table, $where);
	}
	
	public function getE($table, $where1, $where2, $where3){
		return $this->actionE('SELECT *', $table, $where1, $where2, $where3);
	}

	public function getPcomm($table, $where1, $where2, $where3){
		return $this->actionPcom('SELECT *', $table, $where1, $where2, $where3);
	}

	public function getCcomm($table, $where1){
		return $this->actionCcom('SELECT *', $table, $where1);
	}

	public function getOne($table, $where1, $where2){
		return $this->actionOne('SELECT *', $table, $where1, $where2);
	}

	public function getTwo($table, $where1, $where2, $where3){
		return $this->actionTwo('SELECT *', $table, $where1, $where2, $where3);
	}

	public function get2($table, $where1, $where2, $where3){
		return $this->action2('SELECT *', $table, $where1, $where2, $where3);
	}
	
	public function get2_1($table, $where1, $where2, $where3){
		return $this->action2_1('SELECT *', $table, $where1, $where2, $where3);
	}

	public function get3($table, $where1, $where2, $where3, $where4){
		return $this->action3('SELECT *', $table, $where1, $where2, $where3, $where4);
	}
	
	public function get3_1($table, $where1, $where2, $where3, $where4, $where5, $where6){
		return $this->action3_1('SELECT *', $table, $where1, $where2, $where3, $where4, $where5, $where6);
	}

	public function get4($table, $where1, $where2, $where3, $where4, $where5){
		return $this->action4('SELECT *', $table, $where1, $where2, $where3, $where4, $where5);
	}

	public function getDesc($table, $where1, $where2){
		return $this->actionDesc('SELECT *', $table, $where1, $where2);
	}

	public function getGroup($table, $where1, $where2, $where3, $where4){
		return $this->actionDescN('SELECT *', $table, $where1, $where2, $where3, $where4);
	}
	
	public function getGroupS($table, $where1, $where2){
		return $this->actionGroup('SELECT *', $table, $where1, $where2);
	}

	
	
	//delete function and pass to function action
	public function delete($table, $where){
		return $this->action('DELETE ', $table, $where);
	}
	
	//insert function
	public function insert($table, $fields = array()){
		$keys = array_keys($fields);
		$values = null;
		$x = 1;

		foreach($fields as $field) {
			$values .= '?';
			if($x < count($fields)) {
				$values .= ', ';
			}
			$x++;
		}

		$sql = "INSERT INTO {$table} (`" . implode('`,`' , $keys) . "`) VALUES ({$values})";

		if(!$this->query($sql, $fields)->error()) {
			return true;
		}
		return false;
	}
	
	//update function
	public function update($table, $id, $fields, $idname){
		$set = '';
		$x = 1;

		foreach($fields as $name => $value) {
		  $set .= "{$name} = ?";
		  if($x < count($fields)) {
			$set .= ', ';
		  }
		  $x++;
		}

		$sql = "UPDATE {$table} SET {$set} WHERE {$idname} = {$id}";

		if (!$this->query($sql, $fields)->error()) {
		  return true;
		}
		return false;
	}

	//get results
	public function results(){
		return $this->_results;
	}
	
	public function first(){
		return $this->results()[0];
	}
	
	//get errors
	public function error(){
		return $this->_error;
	}
	
	//get count 
	public function count(){
		return $this->_count;
	}

	public function sumbase($table, $where){
		return $this->action1('SELECT baselineID, categoryID, (jan+feb+mar+apr+may+jun+jul+aug+sept+oct+nov+dece) ', $table, $where);
	}

	public function leftJoin($table1, $table2, $where = array(), $action = 'SELECT') {

        if(count($where) === 3){
            $operators = array('=', '!=', '>', '<', '>=', '<=');

            $field = $where[0];
            $operator = $where[1];
            $value = $where[2];

            if(in_array($operator, $operators)) {

            }

            $sql = "{$action} category.category,baseline.baselineID,SUM(baseline.targetval) AS targetvalue,SUM(baseline.jan) AS jan, SUM(baseline.feb) AS feb ,SUM(baseline.mar) AS mar,SUM(baseline.apr) AS apr,SUM(baseline.may) AS may,SUM(baseline.jun) AS jun,SUM(baseline.jul) AS jul,SUM(baseline.aug) AS aug,SUM(baseline.sept) AS sept,SUM(baseline.oct)AS oct,SUM(baseline.nov) AS nov,SUM(baseline.dece) AS dece FROM {$table1},{$table2} WHERE {$table1}.categoryID = {$table2}.categoryID AND {$field} {$operator} ? GROUP BY category";

            if(!$this->query($sql, array($value))->error()) {
                return $this;
            }
        } 

    }

   public function claimJoin($table1, $table2, $where = array(), $action = 'SELECT') {

        if(count($where) === 3){
            $operators = array('=', '!=', '>', '<', '>=', '<=');

            $field = $where[0];
            $operator = $where[1];
            $value = $where[2];

            if(in_array($operator, $operators)) {
            	$sql = "{$action} m.reward, m.description, m.rewardLimit, m.points, m.category, m.expiredate, m.reward_img, c.date FROM {$table1} c, {$table2} m WHERE c.rewardID = m .rewardID and m.{$field} {$operator} ?";

            if(!$this->query($sql, array($value))->error()) {
                return $this;
            }

            }            
        } 

    }

	public function action1($action, $table, $where = array()){
		if(count($where) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];
			
			if(in_array($operator, $operators)){
				$sql = "{$action} AS total FROM {$table} WHERE {$field} {$operator} ?";
				if(!$this->query($sql, array($value))->error()){
					return $this;
				}
			}
		}
		return false;
	}
	
	public function actionalllimit($action, $table, $start, $per_page){
		$sql = "{$action} FROM {$table} LIMIT $start, $per_page";
		if(!$this->queryall($sql)->error()){
			return $this;
		}
		return false;
	}

	public function getalllimit($table , $start, $per_page){
		return $this->actionalllimit('SELECT *', $table, $start, $per_page);
	}

	public function actionlimit($action,$table, $select){


		$sql = "{$action} FROM {$table} WHERE country IN {$select}";
		if(!$this->queryall($sql)->error()){
			return $this ;
		}
		return false ;
	}

	public function getlimit($table , $select){
		return $this->actionlimit('SELECT *', $table, $select);
	}

	// PRS part 

	public function actionOrder($action, $table, $where = array(), $select) {

        if(count($where) === 3){
            $operators = array('=', '!=', '>', '<', '>=', '<=');

            $field = $where[0];
            $operator = $where[1];
            $value = $where[2];

            if(in_array($operator, $operators)) {            

                $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? ORDER BY {$select} DESC LIMIT 5";

            if(!$this->query($sql, array($value))->error()) {
                return $this;
            }
		}
		} 
		

    }

    	public function getOrder($table, $where, $select){
		return $this->actionOrder('SELECT *', $table, $where, $select);
	}
	
	public function actionOrder2($action, $table, $where = array(), $select) {

        if(count($where) === 3){
            $operators = array('=', '!=', '>', '<', '>=', '<=');

            $field = $where[0];
            $operator = $where[1];
            $value = $where[2];

            if(in_array($operator, $operators)) {            }

                $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? ORDER BY {$select} < CURDATE() ASC";

            if(!$this->query($sql, array($value))->error()) {
                return $this;
            }

        } 

    }
    public function getOrder2($table, $where, $select){
		return $this->actionOrder2('SELECT *', $table, $where, $select);
	}

	public function getGroupY($table, $where1, $where2){
		return $this->actionGroupY('SELECT ', $table, $where1, $where2);
	}

	
	public function actionGroupY($action, $table, $where = array(), $where2){
		if(count($where) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field 		= $where[0];
			$operator 	= $where[1];
			$value 		= $where[2];
			
			if(in_array($operator, $operators)){
				$sql = "{$action}   {$where2} AS year FROM {$table} WHERE {$field} {$operator} ? GROUP BY {$where2}";
				if(!$this->query($sql, array($value))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function actionOrder3($action, $table, $where1 = array(), $where2 = array(), $select){
		if(count($where1) === 3 && count($where2) === 3){
			$operators = array('=','>','<','>=','<=');
			
			$field1 		= $where1[0];
			$operator1 		= $where1[1];
			$value1 		= $where1[2];

			$field2 		= $where2[0];
			$operator2 		= $where2[1];
			$value2 		= $where2[2];
			
			if(in_array($operator1, $operators) && in_array($operator2, $operators)){
				$sql = "{$action} FROM {$table} WHERE {$field1} {$operator1} ? AND {$field2} {$operator2} ? ORDER BY {$select} < CURDATE() ASC";
				if(!$this->query($sql, array($value1, $value2))->error()){
					return $this;
				}
			}
		}
		return false;
	}

	public function getOrder3($table, $where1, $where2, $select){
		return $this->actionOrder3('SELECT *', $table, $where1, $where2, $select);
	}

	public function claimJoinTwo($table1, $table2, $where1 = array(), $where2 = array(), $action = 'SELECT' ){
        if(count($where1) === 3 && count($where2) === 3){
            $operators = array('=','>','<','>=','<=');

            $field1         = $where1[0];
            $operator1         = $where1[1];
            $value1         = $where1[2];

            $field2         = $where2[0];
            $operator2         = $where2[1];
            $value2         = $where2[2];

            if(in_array($operator1, $operators) && in_array($operator2, $operators)){
                $sql = "{$action} m.reward, m.description, m.rewardLimit, m.points, m.category, m.expiredate, m.reward_img, c.date FROM {$table1} c, {$table2} m WHERE c.rewardID = m.rewardID and c.{$field1} {$operator1} ? AND m.{$field2} {$operator2} ?";
                if(!$this->query($sql, array($value1, $value2))->error()){
                    return $this;
                }
            }
        }
        return false;
    }

}
?><file_sep><?php
class Rewards{
	private $_data, 
			$_db;


            public function __construct($id = null){
                $this->_db = Database::getInstance();
            }
            
            public function lastinsertid(){
                return $this->_db->lastinsertid();
            }
            
            public function data(){
                return $this->_data;
            }
            
            public static function exists(){
                return(!empty($this->_data)) ? true : false;
            }
            

public function addKpiRewards($fields = array()){
	if(!$this->_db->insert('rewardskpi', $fields)){
		throw new Exception("Error Processing Request");
		
	}
}


public function addKpiRewardsLog($fields = array()){
	if(!$this->_db->insert('logrewards_kpi', $fields)){
		throw new Exception("Error Processing Request");
		
	}
}




public function updateKpiRewards($fields = array(), $id = null){

	if (!$this->_db->update('rewardskpi', $id, $fields, 'rewardsKPI_ID')) {
	  throw new Exception('There was a problem updating rewards.');
	}
}



public function updateKpiRewardsLog($fields = array(), $id = null){

	if (!$this->_db->update('logrewards_kpi', $id, $fields, 'logrewards_KPI_ID')) {
	  throw new Exception('There was a problem updating rewards.');
	}
}

//guna dlm form

public function searchReward($id = null){
    if($id){
        $field = (is_numeric($id)) ? 'userID' : null;
        $data = $this->_db->get('rewardskpi', array($field, '=', $id));
        if($data->count()){
          //  $this->_data = $data->first();//satu data paling ats
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}

public function deleteKpiRewards($id = null){
    if($id){
        $field = (is_numeric($id)) ? 'rewardsKPI_ID' : 'name';
        $data = $this->_db->delete('rewardskpi', array($field, '=', $id));
    }
    return "failed delete ";
}


// zara tambah function baruu


    public function searchClassOnly($id = null, $idfrom = null){
		if($id){
			$field = (is_numeric($id)) ? $idfrom : null;
			$data = $this->_db->getGroupS('rewardskpi', array($field, '=', $id), "class");
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
    }





    public function AllRewards($corporateID = null){
        if($corporateID){
            $field = (is_numeric($corporateID)) ? 'corporateID' : null;
            $data = $this->_db->get('rewardskpi', array($field, '=', $corporateID));
            if($data->count()){
                $this->_data = $data->results();
                return $this->_data;
            }
        }
    }





public function searchRewardbyClass($id= null, $idfrom=null){

    if($id){
        $field1 = (is_numeric($id)) ? $idfrom : null;
     

        $data = $this->_db->get('rewardskpi', array($field1, '=',$id));
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}



//searchrewardOnly untuk getkpireward by id
//guna first
public function searchRewardOnly($rewardsKPI_ID = null){
    if($rewardsKPI_ID){
        $field = (is_numeric($rewardsKPI_ID)) ? 'rewardsKPI_ID' : null;
        $data = $this->_db->get('rewardskpi', array($field, '=', $rewardsKPI_ID));
        if($data->count()){
            $this->_data = $data->first();
            return $this->_data;
        }
    }
}

public function searchClassClaim($companyID = null, $class=null){
    if($companyID){
        $field = (is_numeric($companyID)) ? 'companyID' : null;
        $field2 = ($class) ? 'class' : null;
        $data = $this->_db->getOne('rewardskpi', array($field, '=', $companyID), array($field2, '=', $class));
        if($data->count()){
            $this->_data = $data->first();
            return $this->_data;
        }
    }
}


public function searchForm($id = null){
    if($id){
        $field = (is_numeric($id)) ? 'scoreresultID' : null;
        $data = $this->_db->get('scoreresult', array($field, '=', $id));
        if($data->count()){
            $this->_data = $data->first();
            return $this->_data;
        }
    }
}


public function searchForm2($companyID = null, $year=null){
    if($companyID){
        $field = (is_numeric($companyID)) ? 'companyID' : null;
        $field2 = (is_numeric($year)) ? 'year' : null;
        $data = $this->_db->getOne('scoreresult', array($field, '=', $companyID), array($field2, '=', $year));
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}


public function updateStatus($fields = array(), $id = null){

	if (!$this->_db->update('scoreresult', $id, $fields, 'scoreresultID')) {
	  throw new Exception('There was a problem updating rewards.');
	}
}



public function searchAssignScore($companyID = null){
    if($companyID){
        $field = (is_numeric($companyID)) ? 'companyID' : 'email' ;
        $data = $this->_db->get('users', array($field, '=', $companyID));
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}

public function searchGrade($id = null){
    if($id){
        $field = (is_numeric($id)) ? 'userID' : null;
        $data = $this->_db->get('scoreresult', array($field, '=', $id));
        if($data->count()){
          //  $this->_data = $data->first();//satu data paling ats
            $this->_data = $data->first();
            return $this->_data;
        }
    }
}




}
?><file_sep><?php
require_once 'core/init.php';
$user= new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php?error=error");
  }
}
include 'include/header.php';

?>
<body>
  <div class="d-flex" id="wrapper">
    <?php include 'include/navbar.php';?>
    <div class="container-fluid" >
     <h4 class="my-5"><i class='fa fa-list-alt'></i> Claim Page</h4>

                  
                      <div class="row">
                       <div class="col">
                      <div id="claimpointrewardview"></div>
                        </div>
                      </div>
   
              </div>
            </div>
            </body> 
          


<script type="text/javascript">


$(document).ready(function(){

    function getclaimpointrewards(){
      $.ajax({
        url:"ajax-getclaimpointreward.php",
        success:function(data){
          $("#claimpointrewardview").html(data);
        }
      });
    }

    getclaimpointrewards();

 $("body").on("click", ".receivereward", function(e){

e.preventDefault();
claimID=$(this).attr('id');
$.ajax({
    url: "ajax-getclaimedreward.php",
    type: "POST",
    data: {claimID:claimID},

    success:function(response){
    data = JSON.parse(response);
    
      $("#claimID").val(data.claim_rewardID);
      $("#claimcompID").val(data.companyID);
    }

  });

});

});
</script>
<?php include 'include/form.php';?><file_sep><?php
require_once 'core/init.php';


if(isset($_POST['category'])){

  $user = new User();
  $resultresult = $user->data();
  $userID = $resultresult ->userID;
  $rewuser = new Preward();
  
  $corporateID = $resultresult->corporateID;
  $companyID = $resultresult->companyID;

  $id = $_POST['category'];
  if ($id==="all"){
    if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
        $row= $rewuser->searchmreward($resultresult->companyID, 'companyID');
    }
    else {
    $row= $rewuser->searchmreward($resultresult->corporateID, 'corporateID');
    }
  }
  else {   
    if (empty($resultresult->corporateID) || $resultresult->corporateID == 0) {
        $row = $rewuser->getCategory($resultresult->companyID, 'companyID', $id);
    }
    else {
        $row = $rewuser->getCategory($resultresult->corporateID, 'corporateID', $id);
    }
  }
  
  $view = ' ';
  
                              if(empty($row)){
                                $view .= 'You have no reward currently';
                              } 

                               elseif ($row){
                                
                              foreach ($row as $row1) {
                              date_default_timezone_set('Asia/Kuala_Lumpur');
                              $today = date('Y-m-d H:i:s');
                            
                        $view .= '<div class="col-sm-4 col-lg-3 col-md-3">
                          
                          <div class="card" style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; ">
                            <!-- <div class="px-2 btn btn-outline-danger btn-sm text-uppercase" style="width: 120px; font-size: 14px;font-weight: 900;left: 13px;top: 15px;position: absolute;background: white;" >
                            </div> --> ';
                            
                            if (empty($row1->reward_img)){
                              $view .='<div class="d-flex card-img-top"><img src="img/nopicture.png" width="180" height="200" alt="Reward Picture" class="rewardimg"></div>';}
                              else {
                                $view .= '<div class="d-flex card-img-top"><img src="data:image/jpeg;base64,'.base64_encode($row1->reward_img).'" width="200" height="180" alt="Reward Picture" class="rewardimg"></div>'; }

                              $view .= '<div class="card-body">
                                <h5 class="card-title">
                                  <span class="badge badge-success">'
                                     .$row1->category.'</span>
                                  <strong>'.$row1->reward.'</strong>
                                </h5>
                                <p class="card-text">
                                <span class="badge badge-pill badge-warning"> P </span>'
                                   .$row1->points.'<br>'
                                   .$row1->description.'<br>
                                  Valid til:'.$row1->expiredate.
                                '</p>';

                              
                              
                              $expdate = $row1->expiredate;
                              $entrydate = $row1->entrydate;
                              $uid = $rewuser->searchAllClaim5($row1->rewardID, $userID);
                              
                              
                              if (empty($uid)){ //check $count
                                $count = 0;
                               }
                              else{
                               $count = count($uid);
                               }

                              if ($expdate < $today){
                                 $view .= '<button type="button" class="btn btn-outline-danger pull-right" disabled>Expired</button>';
                               }

                              elseif ($row1->quantity == 0 || $entrydate > $today){
                                $view .= '<button type="button" class="btn btn-outline-danger pull-right" disabled>Unavailable</button>';
                               }

                              elseif ($count == $row1->rewardLimit){
                                  $view .= '<button type="button" class="btn btn-outline-danger pull-right" disabled>Reach Limit</button>';
                                 }

                               else {
                                $view .=  '<button type="button" class="btn btn-primary pull-right viewreward" data-toggle="modal" data-target="#viewreward" data-backdrop="static" id="'.$row1->rewardID.'">Claim</button>';
                                 }
                               
                                $view .= '
                              </div>
                          </div>
                        </div>';

                          
             }
           }
                  
                    
     

  else {
    $view .= 'You have no reward currently';
  }

  $array = ['view' => $view,
  ];

  echo ($view);
  

}<file_sep> <?php
require_once 'core/init.php';
$user = new User();
if(!$user->isLoggedIn()){
  Redirect::to("login.php");
}else{
  $resultresult = $user->data();
  $userlevel = $resultresult->role;
  if($resultresult->verified == false || $resultresult->superadmin == true){
    $user->logout();
    Redirect::to("login.php");
  }
}

  $reward = new Preward();

  $apuserID = escape(Input::get('apuserID'));

  // $id = $user->data()->userID;
  
  $s = $reward->searchpointlog($apuserID);
    
    $view ="";
    
    if (empty($s)){
      $view .='<div>Nothing to show</div>';
    }
    
    if($s){
      foreach ($s as $row1) {
        // $userresult1 = $user->searchOnly($row1->userID);
        $view .=
        "<li class='list-group-item list-group-item-action' id='try'>
            <div>".$row1->action_name."<span class='float-right'>".$row1->actionDate."</span></div>
            <div><small>Description: ".$row1->description."</small></div>
        </li>";
        }
    }

      

    $array = [
     
        "apuserID" => $apuserID,
        "view" => $view,
      ];

  echo json_encode($array);

?>
<file_sep><?php
require_once 'core/init.php';
if(Input::exists()){

    $currentuser= new User();
    $userid = $currentuser->data()->userID;
    $currentcompany = new User();
    $companyid = $currentcompany->data()->companyID;
    $currentcorporate= new User();
    $corporateid = $currentcorporate->data()->corporateID;
    
    
	$upreward = escape(Input::get('upreward'));
	$updesc = escape(Input::get('updesc'));
    $upLimit = escape(Input::get('upLimit'));
    $uppoints = escape(Input::get('uppoints'));
    $upcategory = escape(Input::get('upcategory'));
    $upexpdate = escape(Input::get('upexpdate'));
    $upentdate = escape(Input::get('upentdate'));
    $upquantity = escape(Input::get('upquantity'));
    $upreward_img = escape(Input::get('upreward_img'));
    $rewardID = Input::get('rewardID');




    $logrewarduser = new Preward();
    $value = $logrewarduser->searchRewardID($rewardID);
  
	$prevrewardname =$value->reward;
	$prevrewarddesc = $value->description;
    $prevrewardrewardlimit = $value->rewardLimit;
    $prevrewardpoints = $value->points;
    $prevrewardcategory = $value->category;
    $prevrewardexpiredate = $value->expiredate;


   
   if(!empty($_FILES['upreward_img']['name'])){
    $files = file_get_contents($_FILES['upreward_img']['tmp_name']);
    // print_r($files);
    }
    else{
    $files = null;
    }

	function exists($data){
		if(empty($data)){
			return "Required";
		}else{
			return "Valid";
		}
	}

    function checkAllCondition($data1,$data2,$data3,$data4,$data5,$data6,$data7, $data8){

		if($data1 === "Valid" && $data2 === "Valid" && $data3 === "Valid" && $data4 ==="Valid" && $data5 ==="Valid" && $data6 ==="Valid" && $data7 === "Valid" && $data8 === "Valid"){
			return "Passed";
		}else{
			return "Failed";
		}
	}

    function checkInt($value){
        if(empty($value)){
            return "Required";
        }else{
            if(is_numeric($value)){
                return "Valid";
            }else{
                return "Required";
            }
        }

    }
      
    
    $uprewarderror = exists($upreward);
    $updescerror = exists($updesc);
    $upLimiterror = checkInt($upLimit);
    $uppointerror = checkInt($uppoints);
    $upcaterror = exists($upcategory);
    $upexpdateerror = exists($upexpdate);
    $upentdateerror = exists($upentdate);
    $upquantityerror = checkInt($upquantity);


    $allcondition = checkAllcondition($uprewarderror, $updescerror, $upLimiterror, $uppointerror, $upcaterror, $upexpdateerror, $upentdateerror, $upquantityerror);


	if($allcondition === "Passed"){

		try{
			$prewardobject = new Preward();

            if ($files == null){
			$prewardobject->editpreward(array(
				'reward'=>$upreward,
                'description'=>$updesc,
                'rewardLimit'=>$upLimit,
                'points'=>$uppoints,
                'category'=>$upcategory,
                'expiredate'=>$upexpdate,
                'entrydate'=>$upentdate,
                'userID' => $userid,
                'companyID' => $companyid,
                'corporateID' => $corporateid,
                'quantity' => $upquantity,
			), $rewardID);}

            else{
                $prewardobject->editpreward(array(
                'reward'=>$upreward,
                'description'=>$updesc,
                'rewardLimit'=>$upLimit,
                'points'=>$uppoints,
                'category'=>$upcategory,
                'expiredate'=>$upexpdate,
                'entrydate'=>$upentdate,
                'userID' => $userid,
                'companyID' => $companyid,
                'corporateID' => $corporateid,
                'quantity' => $upquantity,
                'reward_img' => $files,
            ), $rewardID);
            }

            $prewardobject = new preward();
			$prewardobject->addRewardsLog(array(
                'rewardID' => $rewardID,
                'action'=>"Update Reward",
                'name'=> $upreward,
                'previousName'=>$prevrewardname,
                'previousDescription'=>$prevrewarddesc,
                'description' => $updesc,
                'previousRewardLimit'=>$prevrewardrewardlimit,
                'rewardLimit' => $upLimit,
                'previousPoints'=>$prevrewardpoints,
                'points' => $uppoints,
                'previousCategory'=>$prevrewardcategory,
                'category' => $upcategory,
                'previousExpiredate'=>$prevrewardexpiredate,
				'expiredate' => $upexpdate,
				'actionDate' => $upexpdate,
                'userID' => $userid,
				
	
            ));









            $array=[
                'condition'=> $allcondition
            ];

		}catch (Exception $e){
			echo $e->getMessage();
		}

	}else{

		$array = [ 
            'reward' => $uprewarderror,
            'description' => $updescerror,
            'rewardLimit' => $upLimiterror,
            'points' => $uppointerror,
            'category'=>$upcaterror,
            'expiredate' => $upexpdateerror,
            'entrydate' => $upentdateerror,
            'rewardID'=>$rewardID,
            'quantity' => $upquantityerror,
            'condition'=> $allcondition
			];
	}
	echo json_encode($array);
}

?><file_sep><?php
require_once 'core/init.php';


if(isset($_POST['claimID'])){


  $id = $_POST['claimID'];
  $rewuser = new Preward();
  $row = $rewuser->searchAllClaim3($id);

  $array = [
  	"claim_rewardID" => $row->claim_rewardID,
  	"status" => $row->status,
  	"companyID" => $row->companyID,
  ];
  echo json_encode($array);
}<file_sep><?php
class Preward{
	private $_data,
			$_db;

public function __construct($id = null){
	$this->_db = Database::getInstance();
}

public function lastinsertid(){
	return $this->_db->lastinsertid();
}

public function data(){
	return $this->_data;
}

public static function exists(){
	return(!empty($this->_data)) ? true : false;
}

public function createpreward($fields = array()){
	if(!$this->_db->insert('merit_rewards', $fields)){
		throw new Exception("Error Processing Request");
		
	}
}

public function addRewardsLog($fields = array()){
	if(!$this->_db->insert('logmerit_rewards', $fields)){
		throw new Exception("Error Processing Request");
		
	}
}
public function insertpointlog($fields = array()){
	if(!$this->_db->insert('logpoints', $fields)){
		throw new Exception("Error Processing Request");
		
	}
}


public function searchAllReward($id = null, $idfrom = null){
		if($id){
			$field = (is_numeric($id)) ? $idfrom : null;
			$data = $this->_db->get('merit_rewards', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function editpreward($fields = array(), $id = null){
	if(!$this->_db->update('merit_rewards', $id, $fields, 'rewardID')){
		throw new Exception("There is an error while updating kpi.");
		
	}
}

public function searchRewardID($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'rewardID' : null;
			$data = $this->_db->get('merit_rewards', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->first();
				return $this->_data;
			}
		}
}

public function deletepreward($id = null){
    if($id){
        $field = (is_numeric($id)) ? 'rewardID' : 'reward';
        $data = $this->_db->delete('merit_rewards', array($field, '=', $id));
    }
    return "failed delete ";
}

public function getCategory($id = null, $idfrom = null, $category = null){
	
	if($id and $category){
		$field1 = (is_numeric($id)) ? $idfrom : null;
		$field2 = ($category) ? 'category' : null;

		$data = $this->_db->getOrder3('merit_rewards', array($field1, '=',$id), array($field2, '=',$category), 'expiredate');
		if($data->count()){

			$this->_data = $data->results();
			return $this->_data;
		}
	}	

}

public function getCategorylog($id = null, $action_name = null){
	
	if($id and $action_name){
		$field1 = (is_numeric($id)) ? 'userID' : null;
		$field2 = ($action_name) ? 'action_name' : null;

		$data = $this->_db->getOrder3('logpoints', array($field1, '=',$id), array($field2, '=',$action_name), 'actionDate');
		if($data->count()){

			$this->_data = $data->results();
			return $this->_data;
		}
	}	

}

public function searchAllCorReward($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'corporateID' : null;
			$data = $this->_db->get('merit_rewards', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function searchAllComReward($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'companyID' : null;
			$data = $this->_db->get('merit_rewards', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function insertclaimreward($fields = array()){
	if(!$this->_db->insert('claim_merit_reward', $fields)){
		throw new Exception("Error Processing Request");
		
	}
}

public function searchPointReward($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'userID' : null;
			$data = $this->_db->get('merit_points', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function searchPointReward2($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'userID' : null;
			$data = $this->_db->get('merit_points', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->first();
				return $this->_data;
			}
		}
}

public function getclaimreward($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'userID' : null;
			$data = $this->_db->claimJoin('claim_merit_reward', 'merit_rewards', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}

}

public function getcategoryclaimed($userID = null, $category = null){
        if($userID and $category){
        $field1 = (is_numeric($userID))? 'userID':null;
        $field2 = ($category) ? 'category' : 'category';

        $data = $this->_db->claimJoinTwo('claim_merit_reward', 'merit_rewards', array($field1, '=', $userID), array($field2, '=', $category));

        if($data->count()){
                $this->_data = $data->results();
                return $this->_data;
            }
    }

}

public function getusercategoryclaimed($userID = null, $category = null){
        if($userID and $category){
        $field1 = (is_numeric($userID))? 'userID':null;
        $field2 = ($category) ? 'category' : 'category';

        $data = $this->_db->claimJoinTwo('claim_merit_reward', 'merit_rewards', array($field1, '=', $userID), array($field2, '=', $category));

        if($data->count()){
                $this->_data = $data->results();
                return $this->_data;
            }
    }

}

public function searchAllClaim($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'rewardID' : null;
			$data = $this->_db->get('claim_merit_reward', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->first();
				return $this->_data;
			}
		}
}

public function searchAllCorClaim($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'corporateID' : null;
			$data = $this->_db->get('claim_merit_reward', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function searchAllComClaim($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'companyID' : null;
			$data = $this->_db->get('claim_merit_reward', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function searchAllClaim2($id = null, $corporateID = null){
		if($id and $corporateID){
			$field1 = (is_numeric($id)) ? 'rewardID' : null;
			$field2 = (is_numeric($corporateID)) ? 'corporateID' : null;
			$data = $this->_db->getOne('claim_merit_reward', array($field1, '=', $id), array($field2, '=', $corporateID));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}
public function searchAllClaim5($id = null, $userID = null){
	if($id and $userID){
		$field1 = (is_numeric($id)) ? 'rewardID' : null;
		$field2 = (is_numeric($userID)) ? 'userID' : null;
		$data = $this->_db->getOne('claim_merit_reward', array($field1, '=', $id), array($field2, '=', $userID));
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}

public function searchAllClaim4($id = null, $companyID = null){
	if($id and $companyID){
		$field1 = (is_numeric($id)) ? 'rewardID' : null;
		$field2 = (is_numeric($corporateID)) ? 'companyID' : null;
		$data = $this->_db->getOne('claim_merit_reward', array($field1, '=', $id), array($field2, '=', $companyID));
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}

public function searchAllClaim3($id = null){
	if($id){
		$field = (is_numeric($id)) ? 'claim_rewardID' : null;
		$data = $this->_db->get('claim_merit_reward', array($field, '=', $id));
		if($data->count()){
			$this->_data = $data->first();
			return $this->_data;
		}
	}
}


public function getAffPoint($id = null){
	
		if($id){
			$field1 = (is_numeric($id)) ? 'corporateID' : null;
			$data = $this->_db->claimJoin1('merit_rewards', 'merit_points', array($field1, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}

}

public function getAffPoint2($id = null){
		if($id){
			$field1 = (is_numeric($id)) ? 'corporateID' : null;
			$data = $this->_db->get('merit_rewards', array($field1, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}

public function updatepoint($fields = array(), $id = null){
	if(!$this->_db->update('merit_points', $id, $fields, 'pointID')){
		throw new Exception("There is an error while updating kpi.");
		
	}
}

public function updateclaimed($fields = array(), $id = null){
	if(!$this->_db->update('claim_merit_reward', $id, $fields, 'claim_rewardID')){
		throw new Exception("There is an error while updating reward.");
		
	}
}

public function searchAllCorKPIReward($id = null){
		if($id){
			$field = (is_numeric($id)) ? 'corporateID' : null;
			$data = $this->_db->get('rewardskpi', array($field, '=', $id));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
}




public function searchChart($id=null){
    if($id){
        // $field = (is_numeric($companyID)) ? 'companyID' : null;
        $field = (is_numeric($id)) ? 'companyID' : null;
        $data = $this->_db->getDesc('claim_merit_reward', array($field, '=', $id), 'date');
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}


public function searchChart2($id=null){
    if($id){
        // $field = (is_numeric($companyID)) ? 'companyID' : null;
        $field = (is_numeric($id)) ? 'corporateID' : null;
        $data = $this->_db->getDesc('claim_merit_reward', array($field, '=', $id), 'date');
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}


public function searchChart3($id=null){
    if($id){
        // $field = (is_numeric($companyID)) ? 'companyID' : null;
        $field = (is_numeric($id)) ? 'corporateID' : null;
        $data = $this->_db->getGroupY('claim_merit_reward', array($field, '=', $id), "year(date)");
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}

public function searchPointReward3($id = null, $idfrom = null){
	if($id){
		$field = (is_numeric($id)) ? $idfrom : null;
		$data = $this->_db->getOrder('merit_points', array($field, '=', $id), 'totalpoint');
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}

public function searchChart4($id=null){
    if($id){
        // $field = (is_numeric($companyID)) ? 'companyID' : null;
        $field = (is_numeric($id)) ? 'companyID' : null;
        $data = $this->_db->getGroupY('claim_merit_reward', array($field, '=', $id),"year(date)");
        if($data->count()){
            $this->_data = $data->results();
            return $this->_data;
        }
    }
}

public function searchUserClaim($id = null,  $idfrom = null, $year = null){
	if($id and $year){
		$field1 = (is_numeric($id)) ? $idfrom : null;
		$field2 = (is_numeric($year)) ? 'YEAR(date)' : null;
		$data = $this->_db->getOne('claim_merit_reward', array($field1, '=', $id), array($field2, '=', $year));
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}


public function searchPointComReward($id = null){
	if($id){
		$field = (is_numeric($id)) ? 'companyID' : null;
		$data = $this->_db->get('merit_points', array($field, '=', $id));
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}
public function searchPointReward4($id = null){
	if($id){
		$field = (is_numeric($id)) ? 'pointID' : null;
		$data = $this->_db->get('merit_points', array($field, '=', $id));
		if($data->count()){
			$this->_data = $data->first();
			return $this->_data;
		}
	}
}

public function searchmreward($id = null, $idfrom = null){
	if($id){
		$field = (is_numeric($id)) ? $idfrom : null;
		$data = $this->_db->getOrder2('merit_rewards', array($field, '=', $id), 'expiredate');
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}

public function searchAllClaimMeritCor($id = null){
	if($id){
		$field = (is_numeric($id)) ? 'corporateID' : null;
		$data = $this->_db->get('claim_merit_reward', array($field, '=', $id));
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}


public function searchpointlog($id = null){
	if($id){
		$field = (is_numeric($id)) ? 'userID' : null;
		$data = $this->_db->getOrder2('logpoints', array($field, '=', $id), 'actionDate');
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
	}
}

}?><file_sep><?php
class Company{
	private $_data,
			$_db;
	
	public function __construct(){
		$this->_db = Database::getInstance();
	}
	 
	public function data(){
		return $this->_data;
	}
	
	public function lastinsertid(){
		return $this->_db->lastInsertId();
	}

	public static function exists($name){
		return (!empty($this->_data)) ? true : false;
	}
	
	public function addCompany($fields = array()){
		if(!$this->_db->insert('company', $fields)) {
		  throw new Exception('There was a problem adding a company.');
		}
	}
	
	
	public function searchAllCompany(){
		$data = $this->_db->getall('company');
		if($data->count()){
			$this->_data = $data->results();
			return $this->_data;
		}
		return false;
	}

	public function updateCompany($fields = array(), $id = null, $companyID){
		if (!$this->_db->update('company', $id, $fields, $companyID)) {
		  throw new Exception('There was a problem updating objective.');
		}
	}
	
	public function searchCompany($companyID = null){
		if($companyID){
			$field = (is_numeric($companyID)) ? 'companyID' : 'company';
			$data = $this->_db->get('company', array($field, '=', $companyID));
			if($data->count()){
				$this->_data = $data->first();
				return $this->_data;
			}
		}
		return false;
	}

	public function searchCompanyResult($companyID = null){
		if($companyID){
			$field = (is_numeric($companyID)) ? 'companyID' : 'company';
			$data = $this->_db->get('company', array($field, '=', $companyID));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
		return false;
	}

	public function searchCompanyCorporate($corporateID = null){
		if($corporateID){
			$field = (is_numeric($corporateID)) ? 'corporateID' : 'company';
			$data = $this->_db->get('company', array($field, '=', $corporateID));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
		return false;
	}

	public function searchCompanyMember($companyID = null){
		if($companyID){
			$field = (is_numeric($companyID)) ? 'companyID' : 'company';
			$data = $this->_db->get('user', array($field, '=', $companyID));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
		return false;
	}

	public function searchCompanyLeadership($userID = null){
		if($userID){
			$field = (is_numeric($userID)) ? 'leaderID' : 'company';
			$data = $this->_db->get('company', array($field, '=', $userID));
			if($data->count()){
				$this->_data = $data->results();
				return $this->_data;
			}
		}
		return false;
	}

	public function searchLeaderByCompanyID($companyID = null){
		if($companyID){
			$field = (is_numeric($companyID)) ? 'companyID' : 'company';
			$data = $this->_db->get('company', array($field, '=', $companyID));
			if($data->count()){
				$this->_data = $data->first();
				return $this->_data;
			}
		}
		return false;
	}
	
	public function deleteCompany($companyID = null){
		if($companyID){
			$field = (is_numeric($companyID)) ? 'companyID' : 'name';
			$data = $this->_db->delete('company', array($field, '=', $companyID));
			return $data;
		}
		return false;
	}
}
?><file_sep><?php
require_once 'core/init.php';


if(isset($_POST['cat'])){

  $user = new User();
  $resultresult = $user->data();
  
  $rewuser = new Preward();
  $userID = $resultresult ->userID;
  $corporateID = $resultresult->corporateID;

  $id = $_POST['cat'];
  if ($id==="all2"){
      $row = $rewuser->getclaimreward($userID);

  }
  else {
    $row = $rewuser->getusercategoryclaimed($userID,$id);
  }
  
  $view = ' ';

   if ($row){
                                
  foreach ($row as $key1) {
                            
  $view .= '<div class="col-sm-4 col-lg-3 col-md-3">
                          
                          <div class="card" style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; ">
                            <!-- <div class="px-2 btn btn-outline-danger btn-sm text-uppercase" style="width: 120px; font-size: 14px;font-weight: 900;left: 13px;top: 15px;position: absolute;background: white;" >
                            </div> --> ';
                            
  if (empty($key1->reward_img)){
      $view .='<div class="d-flex card-img-top"><img src="img/nopicture.png" width="200" height="200" style="object-fit: contain;display: flex;overflow: auto;" alt="Reward Picture" class="product"></div>';}
  else {
      $view .= '<div class="d-flex card-img-top"><img src="data:image/jpeg;base64,'.base64_encode($key1->reward_img).'" width="200" height="200" style="object-fit: contain;display: flex; overflow: auto;" alt="Reward Picture" class="product"></div>'; }

      $view .= '<div class="card-body">
                                <h5 class="card-title">
                                  <span class="badge badge-success">'
                                     .$key1->category.'</span>
                                  <strong>'.$key1->reward.'</strong>
                                </h5>
                                <p class="card-text">
                                <span class="badge badge-pill badge-warning"> P </span>'
                                   .$key1->points.'<br>'
                                   .$key1->description.'<br>
                                  Valid til:'.$key1->expiredate.
                                '</p>
                                </div>
                          </div>
                        </div>';

                          
    }
  }

  else {
    $view .= 'You have no reward currently';
  }

  $array = ['view' => $view,
  ];

  echo ($view);
  

}<file_sep>
<?php
require_once 'core/init.php'; 
if (Input::exists()) {
	$currentuser= new User();
    $userid = $currentuser->data()->userID;
    $currentcompany = new User();
    $companyid = $currentcompany->data()->companyID;
    $currentcorporate= new User();
    $corporateid = $currentcorporate->data()->corporateID;

	$reward = Input::get('reward');
	$description = Input::get('description');
	$rewardLimit = Input::get('rewardLimit');
	$points = Input::get('points');
	$category = Input::get('category');
	$expiredate = Input::get('expiredate');	
	$entrydate = Input::get('entrydate');
	$quantity = Input::get('quantity');
	$reward_img = Input::get('reward_img');

	if(!empty($_FILES['reward_img']['name'])){
		$files = file_get_contents($_FILES['reward_img']['tmp_name']);
		// print_r($files);
	}
	else{
		$files = null;
	}

	
	function checkValid($data){
		if(empty($data)){
			return "Required";
		}else{
			return "Valid";
		}
	}

    function checkInt($value){
		if(empty($value)){
			return "Required";
		}else{
			if(is_numeric($value)){
				return "Valid";
			}else{
				return "Required";
			}
		}

	}



	function checkAllcondition($data1, $data2, $data3, $data4, $data5, $data6, $data7, $data8){
		if ($data1 === "Valid" && $data2 === "Valid" && $data3 === "Valid" && $data4 ==="Valid" && $data5 ==="Valid" && $data6 ==="Valid" && $data7 === "Valid" && $data8 === "Valid") {
			return "Passed";
		}else{
			return "Failed";
		}
	}

	$prewardnameerror = checkValid($reward);
	$descriptionerror = checkValid($description);
	$rewardLimiterror = checkInt($rewardLimit);
	$pointserror = checkInt($points);
	$categoryerror = checkValid($category);
	$expiredateerror = checkValid($expiredate);
	$entrydateerror = checkValid($entrydate);
	$quantityerror = checkInt($quantity);

	$allcondition = checkAllcondition($prewardnameerror, $descriptionerror,$rewardLimiterror,$pointserror, $categoryerror,$expiredateerror, $entrydateerror, $quantityerror);

	if ($allcondition === "Passed") {
		try{
			$prewardobject = new preward();
			$prewardobject->createpreward(array(
				'reward'=> $reward,
				'description' => $description,
				'rewardLimit' => $rewardLimit,
				'points' => $points,
				'category' => $category,
				'expiredate' => $expiredate,
				'entrydate' => $entrydate,
				'userID' => $userid,
				'companyID' => $companyid,
				'corporateID' => $corporateid,
				'quantity' => $quantity,
				'reward_img' => $files
				//"lastinsertid"=>$id
	
            ));

            $id = $prewardobject->lastinsertid();

            $prewardobject = new preward();
			$prewardobject->addRewardsLog(array(
                'rewardID' => $id,
                'action'=>"Create Reward",
				'name'=> $reward,
				'description' => $description,
				'rewardLimit' => $rewardLimit,
				'points' => $points,
				'category' => $category,
				'expiredate' => $expiredate,
				'actionDate' => $entrydate,
                'userID' => $userid
				
	
            ));
            

			
			$array=[
				'reward'=> $reward,
				'description'=> $description,
				'quantity' => $quantity,
				'rewardLimit'=> $rewardLimit,
				'points'=> $points,
				'category'=> $category,
				'expiredate'=> $expiredate,
				'entrydate'=> $entrydate,
				'quantity' => $quantity,
				// 'reward_img' => $data,
				'condition'=> $allcondition
			];

		} catch (Exception $e){
			echo $e->getMessage();
		}
	}else{
		$array = [
				'reward'=> $prewardnameerror,
				'description' => $descriptionerror,
				'rewardLimit' => $rewardLimiterror,
				'points' => $pointserror,
				'category' => $categoryerror,
				'expiredate' => $expiredateerror,
				'entrydate' => $entrydateerror,
				'quantity' => $quantityerror,
				//'condition'=> $allcondition
				
		];
	}
	echo json_encode($array);
}
?>
<file_sep><?php include 'forms/appointform.php';?> 
<?php include 'forms/rewardform.php';?> 
<?php include 'forms/claimform.php';?> 


<file_sep><?php
	$array = 
	[
		"viewmoreoption" => "点击查看更多选项",
		"viewda" => "点击添加 Doer 行动",
		"viewcda" => "点击查看或关闭 Doer 行动",
		"viewkr" => "单击以添加关键结果",
		"viewckr" => "点击查看贡献 OKR",
		"viewcollapse" => "单击以折叠或显示",
		"committed" => "承诺",
		"aspirational" => "抱负",
		"toplevel" => "顶层",
		"reportsubmit" => "已提交报告",
		"reportnotsubmit" => "还没提交报告",
		"reportreview" => "已评论报告",
		"reportnotreview" => "还没评论报告",
		"totalobjective" => "总目的",
		"howmany" => "在此时间范围内创建了多少个目的",
		"loginrate" => "登录率",
		"updaterate" => "更新率",
		"currentprogress" => "目前的进展",
		"togo" => "剩下",
		"expected" => "预期",
		"supervisor" => "主管",
		"admin" => "管理员",
		"chief" => "首席",
		"superior" => "优越",
		"manager" => "经理",
		"evaluate" => "评估",
		"progressremarks" => "进度的评论",
		"problemremarks" => "难题的评论",
		"nextweekplanremarks" => "下周计划的评论",
		"problem" => "难题",
		"nextweekplan" => "下周计划",
		"plan" => "计划",
		"draft" => "草案",
		"department" => "部门",
		"team" => "团队",
		"project" => "项目",
		"campaign" => "暂时活动",
		"optional" => "可选",
		"active" => "活跃",
		"notactive" => "不活跃",
		"description" => "描述",
		"marksas" => "标记为", 
		"unit" => "单元",
		"percentage" => "百分比",
		"currency" => "货币",
		"metric" => "测量",
		"startvalue" => "起始值",
		"endvalue" => "终值",
		"new" => "新",
		"okrlogs" => "日志",
		"alignto" => "对齐",
		"owner" => "所有者",
		"overallprogress" => "总体进程",
		"progresstimeline" => "进步行为",
		"keyactivity" => "关键活动",
		"showkeyactivity" => "显示关键活动",
		"contributetitle" => "助于",
		"own" => "拥有",
		"contribute" => "由贡献",
		"okr" => "目的和关键结果章节",
		"home" => "主页",
		"no" => "没有",
		"add" => "加",
		"delete" => "删除",
		"update" => "更新",
		"edit" => "编辑",
		"submit" => "提交",
		"create" => " 创造",
		"cancel" => "取消",
		"week" => "周",
		"submitat" => "提交于",
		"status" => "状态",
		"action" => "行动",
		"leader" => "领导",
		"type" => "类型",
		"name" => "全名",
		"email" => "电子邮件",
		"jobposition" => "工作职位",
		"role" => "角色",
		"timeframe" => "大体时间",
		"progress" => "进度",
		"membership" => "成员",
		"view" => "视图",
		"startdate" => "开始日期",
		"enddate" => "结束日期",
		"next" => "下周",
		"previous" => "上周",
		"profile" => "侧面",
		"firstname" => "名字",
		"lastname" => "姓",
		"changepassword" => "<PASSWORD>",
		"noobjectivefound" => "没有创造目的和关键结果",
		"noobjectivefoundexplain" => "您还没有在任何大体时间创造目的和关键结果",
		"nokeyresultfound" => "没有创造关键结果",
		"nokeyresultfoundexplain" => "您还没有为了这目的创造关键结果",
		"noalignobjective" => "没有创造对齐目的",
		"noalignobjectiveexplain" => "这个目的没有被其他目的对齐",
		"noactivityfound" => "没有创造活动",
		"noactivityfoundexplain" => "您还没有为了这关键结果创造活动",
		"objectivetitle" => "目的",
		"alignobjectivetitle" => "助于",
		"keyresulttitle" => "关键结果",
		"keyresultshort" => "KR",
		"activitytitle" => "活动",
		"activityshort" => "Act",
		"report" => "报告",
		"excellent" => "优秀",
		"ontrack" => "步入正轨",
		"notstart" => "还没开始",
		"lagging" => "落后",
		"danger" => "危险",
		"reportsubmitted" => "报告已提交",
		"reportsubmittedexplain" => "您已经提交了本周的报告:",
		"reportnotsubmitted" => "没有报告提交",
		"reportnotsubmittedexplain" => "您本周未提交任何报告:",
		"nocompanyfound" => "没有创造公司",
		"nocompanyfoundexplain" => "您尚未创建任何公司",
		"nogroupfound" => "没有创造部门",
		"nogroupfoundexplain" => "您尚未创建任何部门",
		"nouserfound" => "没有创造员工帐户",
		"nouserfoundexplain" => "您尚未创建任何员工帐户",
		"notimeframefound" => "没有创造大体时间",
		"notimeframefoundexplain" => "您尚未创建任何大体时间",
		"nologfound" => "没有创造日志",
		"nologfoundexplain" => "您尚未创建任何日志",
		"group" => "部门",
		"personal" => "个人",
		"people" => "人",
		"engagementrate" => "参与率",
		"last30days" => "最近30天",
		"last60days" => "最近60天",
		"last90days" => "最近90天",
		"okrhealth" => "目的和关键结果的健康",
		//navbar
		"dashboard" => "仪表板",
		"yourokr" => "您的目的和关键结果",
		"weeklyreport" => "每周报告",
		"corporate" => "企业",
		"companies" => "全公司",
		"company" => "公司",
		"groups" => "全部门",
		"users" => "全员工",
		"user" => "员工",
		"okrs" => "全目的和关键结果",
		"alignment" => "对齐目的结构体",
		//topbar
		"admindashboard" => "管理仪表板",
		"supervisordashboard" => "主管仪表板",
		"personalsetting" => "个人设定",
		"logout" => "登出",
		//home-dashboard
		"yourplanforweek" => "您的计划周",
		"done" => "做完",
		"inprogress" => "进行中",
		"stuck" => "卡住",
		"issue" => "问题",
		"calendar" => "日历",
		"objective" => "目的",
		//home-yourokr
		"objectivestatusexcellent" => "恭喜您达成目标",
		"objectivestatusontrack" => "先 ",
		"objectivestatusnotstart" => "时间表尚未开始",
		"objectivestatusontrack2" => "步入正轨",
		"objectivestatuslagging" => "落后 ",
		"objectivestatusdanger" => "滞后太多 ",
		"keyresultexcellent" => "恭喜您达成关键成果",
		"activityexcellent" => "恭喜您达成活动",

		"successaddactivity" => "您已成功添加活动",
		"successaddactivityexplain" => "下一步是什么？",
		"successaddactivitybutton" => "添加更多活动",


		"deleteactivity" => "您确定要删除此活动吗？",
		"successdeleteactivity" => "您已成功删除活动",
		
		"successeditactivity" => "您已成功编辑活动",
		"successupdateactivity" => "您已成功更新活动进度",

		"successaddcompany" => "您已成功添加公司",
		"successaddcompanyexplain" => "下一步是什么？",
		"successaddcompanybutton" => "添加更多公司",

		"successeditcompany" => "您已成功编辑公司",
		"deletecompany" => "您确定要删除该公司吗？",
		"successdeletecompany" => "您已成功删除公司",

		"successeditcorporate" => "您已成功编辑企业",

		"successaddgroup" => "您已成功添加部门",
		"successaddgroupexplain" => "下一步是什么？",
		"successaddgroupbutton" => "添加更多部门",

		"deletegroup" => "您确定要删除该部门吗？",
		"successdeletegroup" => "您已成功删除部门",

		"successeditgroup" => "您已成功编辑部门",

		"successaddkeyresult" => "您已成功添加关键结果",
		"successaddkeyresultexplain" => "下一步是什么？",
		"successaddkeyresultbutton" => "添加更多关键结果",

		"deletekeyresult" => "您确定要删除该关键结果吗？",
		"deletekeyresultexplain" => "请注意，此<b>关键结果</b>下的<i>活动</i>也将删除。",
		"successdeletekeyresult" => "您已成功删除关键结果",

		"successeditkeyresult" => "您已成功编辑关键结果",

		"successupdatekeyresult" => "您已成功更新关键结果进度",

		"successaddobjective" => "您已成功添加目的",
		"successaddobjectiveexplain" => "下一步是什么？",
		"successaddobjectivebutton" => "添加更多目的",
		"successaddobjectivebutton2" => "添加关键结果",

		"successeditobjective" => "您已成功编辑目的",

		"deletekeyresult" => "您确定要删除该目的吗？",
		"deletekeyresultexplain" => "请注意，此<b>目的</b>下的<i>关键结果</i>也将删除。",
		"successdeletekeyresult" => "您已成功删除目的",

		"successaddplan" => "您已成功添加计划",
		"successaddplanexplain" => "下一步是什么？",
		"successaddplanbutton" => "添加更多计划",

		"successupdateplan" => "您已成功更新计划进度",

		"deleteplan" => "您确定要删除该计划吗？",
		"successdeleteplan" => "您已成功删除计划",

		"successsubmitreport" => "您已成功提交每周报告",

		"successevaluatereport" => "您已成功评估报告",

		"successaddtimeframe" => "您已成功添加大体时间",
		"successaddtimeframeexplain" => "下一步是什么？",
		"successaddtimeframebutton" => "添加更多大体时间",

		"successedittimeframe" => "您已成功编辑大体时间",

		"deletetimeframe" => "您确定要删除该大体时间吗？",
		"deletetimeframeexplain" => "请注意，此<b>大体时间</b>下的<i>目的</i>也将删除。",
		"successdeletetiemframe" => "您已成功删除大体时间",

		"reachmaxnumofuser" => "您已达到用户数上限",
		"reachmaxnumofuserexplain" => "联系我们以增加用户数量",

		"successadduser" => "您已成功添加员工",
		"successadduserexplain" => "下一步是什么？",
		"successadduserbutton" => "添加更多员工",

		"deleteuser" => "您确定要删除该员工吗？",
		"successdeleteuser" => "您已成功删除员工",

		"successedituser" => "您已成功编辑员工",

		"notsubmitreport" => "没有报告提交",
		"notsubmitreportexplain" => "您的下属未提交任何报告",

		"nookrsfoundfor" => "没有创造目的和关键结果给",
		"notcreateokr" => "您尚未创建任何目的和关键结"

	];
?><file_sep><?php
	$array = 
	[
		"viewmoreoption" => "Klik untuk melihat lebih banyak pilihan",
		"viewda" => "Klik untuk Menambah Doer Action",
		"viewcda" => "Klik untuk melihat atau menutup Doer Action",
		"viewkr" => "Klik untuk Menambah Keputusan Utama",
		"viewckr" => "Klik untuk Melihat Sumbang OKR",
		"viewcollapse" => "Klik untuk meruntuhkan atau menunjukkan",
		"committed" => "komited",
		"aspirational" => "Cita Tinggi",
		"toplevel" => "Tahap Teratas",
		"reportsubmit" => "Laporan Telah Hantar",
		"reportnotsubmit" => "Laporan Belum Hantar",
		"reportreview" => "Lapran Telah Ulas",
		"reportnotreview" => "Laporan Belum Ulas",
		"totalobjective" => "Jumlah Objektif",
		"howmany" => "Berapa banyak objektif yang dibuat dalam Tempoh Masa ini",
		"loginrate" => "Kadar Log Masuk",
		"updaterate" => "Kadar Kemas Kini",
		"currentprogress" => "Kemajuan Semasa",
		"togo" => "Yang Tinggal",
		"expected" => "Dijangka",
		"supervisor" => "Penyelia",
		"admin" => "Admin",
		"chief" => "Pemimpin",
		"superior" => "Unggul",
		"manager" => "Pengurus",
		"evaluate" => "Menilai",
		"progressremarks" => "Kata-kata Kemajuan",
		"problemremarks" => "Kata-kata Masalah",
		"nextweekplanremarks" => "Kata-kata Pelan Minggu Depan",
		"problem" => "Masalah",
		"nextweekplan" => "Pelan Minggu Depan",
		"plan" => "Pelan",
		"draft" => "Draf",
		"department" => "Jabatan",
		"team" => "Kumpulan",
		"project" => "Projek",
		"campaign" => "kempen",
		"optional" => "pilihan",
		"active" => "Aktif",
		"notactive" => "Tak Aktif",
		"description" => "Keterangan",
		"marksas" => "Tanda Sebagai ",
		"unit" => "Unit",
		"percentage" => "Peratusan",
		"currency" => "Mata Wang",
		"metric" => "Metrik",
		"startvalue" => "Nilai Mula",
		"endvalue" => "Nilai Akhir",
		"new" => "Baru",
		"okrlogs" => "OKR Logs",
		"alignto" => "Jajarkan",
		"owner" => "Pemilik",
		"overallprogress" => "Kemajuan Keseluruhan",
		"progresstimeline" => "Kemajuan Garis Masa",
		"keyactivity" => "Aktiviti Utama",
		"showkeyactivity" => "Tunjukkan Aktiviti Utama",
		"contributetitle" => "Menyumbang",
		"own" => "Memiliki",
		"contribute" => "Menyumbang",
		"okr" => "OKR",
		"home" => "Laman Utama",
		"no" => "Tidak",
		"add" => "Tambah",
		"delete" => "Padam",
		"update" => "Kemas Kini",
		"edit" => "Edit",
		"cancel" => "Batal",
		"submit" => "Hantar",
		"create" => "Cipta",
		"week" => "Minggu",
		"submitat" => "Hantar kepada",
		"status" => "Status",
		"action" => "Tindakan",
		"leader" => "Ketua",
		"type" => "Jenis",
		"name" => "<NAME>",
		"email" => "Emel",
		"jobposition" => "Jawatan Kerja",
		"role" => "Peranan",
		"timeframe" => "Tempoh",
		"progress" => "Kemajuan",
		"membership" => "Keahlian",
		"view" => "Lihat",
		"startdate" => "Tarikh Mula",
		"enddate" => "Tarikh Akhir",
		"next" => "Seterusnya",
		"previous" => "Sebelumnya",
		"profile" => "Profil",
		"firstname" => "<NAME>",
		"lastname" => "<NAME>",
		"changepassword" => "<PASSWORD>",
		"noobjectivefound" => "Tiada OKR",
		"noobjectivefoundexplain" => "Anda belum mencipta sebarang OKR untuk Tempoh Masa ini",
		"nokeyresultfound" => "Tiada Keputusan Utama",
		"nokeyresultfoundexplain" => "Anda belum mencipta sebarang Keputusan Utama untuk Objektif ini",
		"noalignobjective" => "Tiada Jajaran Objektif Ditemui",
		"noalignobjectiveexplain" => "Tiada Objektif yang jajar kepada Objektif ini",
		"noactivityfound" => "Tiada Aktiviti",
		"noactivityfoundexplain" => "Anda belum mencipta sebarang Aktiviti untuk Keputusan Utama ini",
		"objectivetitle" => "Objektif",
		"alignobjectivetitle" => "Menyumbang",
		"keyresulttitle" => "Keputusan Utama",
		"keyresultshort" => "KR",
		"activitytitle" => "Aktiviti",
		"activityshort" => "Act",
		"report" => "Laporan",
		"excellent" => "Cemerlang",
		"ontrack" => "At<NAME>",
		"notstart" => "Belum Mula",
		"lagging" => "Lambat",
		"danger" => "Bahaya",
		"reportsubmitted" => "Laporan Telah Hantar",
		"reportsubmittedexplain" => "Anda telah Hantar Laporan untuk Minggu ini:",
		"reportnotsubmitted" => "Laporan Belum Hantar",
		"reportnotsubmittedexplain" => "Anda belum Hantar Laporan untuk Minggu ini:",
		"nocompanyfound" => "Tiada Syarikat",
		"nocompanyfoundexplain" => "Anda Belum Mencipta Syarikat",
		"nogroupfound" => "Tiada Kumpulan",
		"nogroupfoundexplain" => "Anda Belum Mencipta Kumpulan",
		"nouserfound" => "Tiada Kakitangan",
		"nouserfoundexplain" => "Anda Belum Mencipta Kakitangan",
		"notimeframefound" => "Tiada Tempoh Masa",
		"notimeframefoundexplain" => "Anda Belum Mencipta Tempoh",
		"nologfound" => "Tiada Logs",
		"nologfoundexplain" => "Tiada logs untuk Objektif ini",
		"group" => "Kumpulan",
		"personal" => "Peribadi",
		"people" => "Orang",
		"engagementrate" => "Kadar Pertunangan",
		"last30days" => "30 hari lepas",
		"last60days" => "60 hari lepas",
		"last90days" => "90 hari lepas",
		"okrhealth" => "Kesihantan OKR",
		//navbar
		"dashboard" => "Papan Pemuka",
		"yourokr" => "OKR kamu",
		"weeklyreport" => "Laporan Mingguan",
		"corporate" => "Korporat",
		"companies" => "Semua Syarikat",
		"company" => "Syarikat",
		"groups" => "Semua Kumpulan",
		"users" => "<NAME>",
		"user" => "Kakitangan",
		"okrs" => "Semua OKR",
		"alignment" => "Kejajaran",
		//topbar
		"admindashboard" => "Papan Pemuka Admin",
		"supervisordashboard" => "Supervisor Dashboard",
		"personalsetting" => "Papan Pemuka Penyelia",
		"logout" => "Log Keluar",
		//home-dashboard
		"yourplanforweek" => "Pelan kamu pada minggu ini",
		"done" => "Selesai",
		"inprogress" => "Masih Dijalankan",
		"stuck" => "Tersangkut",
		"issue" => "Masalah",
		"calendar" => "Kalendar",
		"objective" => "Objektif",
		//home-yourokr
		"objectivestatusexcellent" => "Tahniah kerana mencapai matlamat anda",
		"objectivestatusontrack" => "Lebih sebanyak ",
		"objectivestatusnotstart" => "Tempoh Masa Belum Mula Lagi",
		"objectivestatusontrack2" => "Atas Landasan",
		"objectivestatuslagging" => "Lambat sebanyak ",
		"objectivestatusdanger" => "Lambat terlampau sebanyak ",
		"keyresultexcellent" => "Tahniah kerana mencapai Keputusan Utama anda",
		"activityexcellent" => "Tahniah kerana mencapai Aktiviti anda",

		"successaddactivity" => "Anda telah berjaya menambah Aktiviti",
		"successaddactivityexplain" => "Apakah langkah yang seterusnya?",
		"successaddactivitybutton" => "Tambah lebih Aktiviti",

		"deleteactivity" => "Adakah anda pasti mahu memadam Aktiviti ini?",
		"successdeleteactivity" => "Anda telah berjaya memadam Aktiviti",

		"successeditactivity" => "Anda telah berjaya edit Aktiviti",

		"successupdateactivity" => "Anda telah berjaya mengemas kini Aktiviti",

		"successaddcompany" => "Anda telah berjaya menambah Syarikat",
		"successaddcompanyexplain" => "Apakah langkah yang seterusnya?",
		"successaddcompanybutton" => "Tambah Lebih Syarikat",

		"successeditcompany" => "Anda telah berjaya edit Syarikat",

		"deletecompany" => "Adakah anda pasti mahu memadam Syarikat ini?",
		"successdeletecompany" => "Anda telah berjaya memadam Syarikat",

		"successeditcorporate" => "Anda telah berjaya edit Korporat",

		"successaddgroup" => "Anda telah berjaya menambah Kumpulan",
		"successaddgroupexplain" => "Apakah langkah yang seterusnya?",
		"successaddgroupbutton" => "Tambah Lebih Kumpulan",

		"deletegroup" => "Adakah anda pasti mahu memadam Kumpulan ini?",
		"successdeletegroup" => "Anda telah berjaya memadam Kumpulan",

		"successeditgroup" => "Anda telah berjaya edit Kumpulan",

		"successaddkeyresult" => "Anda telah berjaya menambah Keputusan Utama",
		"successaddkeyresultexplain" => "Apakah langkah yang seterusnya?",
		"successaddkeyresultbutton" => "Tambah Lebih Keputusan Utama",

		"deletekeyresult" => "Adakah anda pasti mahu memadam Keputusan Utama ini?",
		"deletekeyresultexplain" => "Perhatikan bahawa <i> Aktiviti </i> di bawah ini <b> Keputusan Utama </b> juga akan dipadamkan.",
		"successdeletekeyresult" => "Anda telah berjaya memadam Keputusan Utama",

		"successeditkeyresult" => "Anda telah berjaya edit Keputusan Utama",

		"successupdatekeyresult" => "Anda telah berjaya mengemas kini Keputusan Utama",

		"successaddobjective" => "Anda telah berjaya menambah Objektif",
		"successaddobjectiveexplain" => "Apakah langkah yang seterusnya?",
		"successaddobjectivebutton" => "Tambah Lebih Objektif",
		"successaddobjectivebutton2" => "Tambah Lebih Keputusan Utama",

		"successeditobjective" => "Anda telah berjaya edit Objektif",

		"deleteobjective" => "Adakah anda pasti mahu memadam Objektif ini?",
		"deleteobjectiveexplain" => "Perhatikan bahawa <i> Keputusan Utama </i> di bawah ini <b> Objektif </b> juga akan dipadamkan.",
		"successdeleteobjective" => "Anda telah berjaya memadam Objektif",

		"successaddplan" => "Anda telah berjaya menambah Pelan",
		"successaddplanexplain" => "Apakah langkah yang seterusnya?",
		"successaddplanbutton" => "Tambah lebih Pelan",

		"successupdateplan" => "Anda telah berjaya mengemas kini Pelan",

		"deleteplan" => "Adakah anda pasti mahu memadam Pelan ini?",
		"successdeleteplan" => "Anda telah berjaya memadam Pelan",

		"successsubmitreport" => "Anda telah berjaya menghantar Laporan Migguan",

		"successevaluatereport" => "Anda telah berjaya menilai Laporan Migguan",

		"successaddtimeframe" => "Anda telah berjaya menambah Tempoh Masa",
		"successaddtimeframeexplain" => "Apakah langkah yang seterusnya?",
		"successaddtimeframebutton" => "Tambah Lebih Tempoh Masa",

		"successedittimeframe" => "Anda telah berjaya edit Tempoh Masa",

		"deletetimeframe" => "Adakah anda pasti mahu memadam Tempoh Masa ini?",
		"deletetimeframeexplain" => "Perhatikan bahawa <i> OKR </i> di bawah ini <b> Tempoh Masa </b> juga akan dipadamkan.",
		"successdeletetimeframe" => "Anda telah berjaya memadam Tempoh Masa",

		"reachmaxnumofuser" => "Anda telah mencapai maksimum pengguna",
		"reachmaxnumofuserexplain" => "Hubungi Kami untuk meningkatkan bilangan pengguna",

		"successadduser" => "Anda telah berjaya menambah pengguna",
		"successadduserexplain" => "Apakah langkah yang seterusnya?",
		"successadduserbutton" => "Tambah Lebih Pengguna",

		"deleteuser" => "Adakah anda pasti mahu memadam Pengguna ini?",
		"successdeleteuser" => "Anda telah berjaya memadam Pengguna",

		"successedituser" => "Anda telah berjaya edit Pengguna",

		"notsubmitreport" => "Tiada Laporan Dihantar",
		"notsubmitreportexplain" => "Kakitangan anda tidak mengemukakan sebarang laporan",

		"nookrsfoundfor" => "Tiada OKR untuk",
		"notcreateokr" => "Anda belum lagi mecipta OKR"
	];
?><file_sep><?php
require_once 'core/init.php';


if(isset($_POST['pointID'])){


  $id = $_POST['pointID'];
  $rewuser = new Preward();
  $row = $rewuser->searchPointReward4($id);

  $array = [
  	"pointID" => $row->pointID,
  	// "currentpoint" => $row->currentpoint,
  	"totalpoint" => $row->totalpoint,
  	"userID" => $row->userID,
    "companyID" => $row->companyID,
   ];
  echo json_encode($array);
}