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j '  'P$a ( `D$Na L?u80e J,K˷NI'0eݷ(NI'؀ 2ipIIKp`:O'`ʤxB8Ѥx Ѥx $ $P6 :vRNb 'p,>NB 'P]-->P T+*^h& p '‰a ‰ (ĵt#u33;Nt̵'ޯ; [3W ~]0KH1q@8]O2]3*̧7# *p>us p _6]/}-4|t'|Smx= DoʾM×M_8!)6lq':l7!|4} '\ne t!=hnLn (~Dn\+‰_4k)0e@OhZ`F `.m1} 'vp{F`ON7Srx 'D˸nV`><;yMx!IS钦OM)Ե٥x 'DSD6bS8!" ODz#R >S8!7ّxEh0m$MIPHi$IvS8IN$I p$O8I,sk&I)$IN$Hi$I^Ah.p$MIN$IR8I·N "IF9Ah0m$MIN$IR8IN$I 3jIU;kO$ɳN$+ q.x* tEXtComment

Viewing File: /home/u403625155/domains/oceanheightcap.com/public_html/admin/plans.php

<?php
require "header.php";
?>

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                    <h1 class="h3 mb-2 text-gray-800">Edit Plans</h1>
                    
                    <!-- DataTales Example -->
                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary">Data Tables </h6>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table" id="dataTable" width="100%" cellspacing="0">
                                    <thead>
                                    <tr>
                                    <th>Plan Name</th>
                                            <th>Active</th>
                                            <th>ROI</th>
                                            <th>Amount</th>
                                            <th>Term</th>
                                            <th>Duration</th>
                                            <th>Slug</th>
                                            <th>Edit</th>
                                            <th>Delete</th>
                                            
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                        <th>Plan Name</th>
                                            <th>Active</th>
                                            <th>ROI</th>
                                            <th>Amount</th>
                                            <th>Term </th>
                                            <th>Duration</th>
                                            <th>Slug</th>
                                            <th>Edit</th>
                                            <th>Delete</th>
                                        </tr>
                                    </tfoot>
                                    <tbody>
                                        <?php
                                        $accounts_query=mysqli_query($conn,"SELECT * FROM `iv_schemes`");
                                        if(mysqli_num_rows($accounts_query)>0){
                                            while($row=mysqli_fetch_assoc($accounts_query)){ 
                                                $name=$row['name'];
                                                $active=$row['active'];
                                                $amount=$row['amount'];
                                                $term=$row['term'];
                                                $ROI=$row['ROI'];
                                                $slug=$row['slug'];
                                                $plan_id=$row['id'];
                                                $duration=$row['duration'];
                                                echo "
                                                <tr >
                                                
                                                <td>$name</td>
                                                <td>$active</td>
                                                <td>$ROI</td>
                                                <td>$$amount</td>
                                                <td>$term</td>
                                                <td>$duration</td>
                                                <td>$slug</td>
                                                <td>
                                                <button class='btn btn-light' value='$plan_id' onclick=openModal(this.value)><i class='fas fa-cog'></i></button>
                                                <button id='hiddenEditbtn' class='btn d-none' data-toggle='modal' data-target='#editPlanModal'></button>
                                                </td>
                                                <td>
                                                <button class='btn btn-danger' value='$plan_id' onclick=confirmDelete(this.value)>&times</button>
                                                </td>
                                               
                                            ";
                                            }
                                        }
                                        
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->

            <!-- Footer -->
            <footer class="sticky-footer bg-white">
                <div class="container my-auto">
                    <div class="copyright text-center my-auto">
                        <span>Copyright &copy; <?php echo $sitename; ?> <?php echo Date("Y");  ?></span>
                    </div>
                </div>
            </footer>
            <!-- End of Footer -->

        </div>
        <!-- End of Content Wrapper -->

    </div>
    <!-- End of Page Wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-primary" href="index.php?logout=true">Logout</a>
                </div>
            </div>
        </div>
    </div>

    <!--
        Edit users Modal
    -->



    <div class="modal fade" id="editPlanModal" tabindex="-1" role="dialog" aria-labelledby="Edit plans modal"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Edit this Plan</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    

                <form class="user" method="post" id="plan-form">
                    <input type="hidden" name="plan_id" id="plan_id" value="<?php echo $plan_id ?>"/>
                                <div class="form-group row">
                                    <div class="col-sm-6 mb-3 mb-sm-0">
                                        <label>Plan name: </label>
                                        <input type="text" class="form-control form-control-user" id="planname"
                                            placeholder="Plan Name" name="pname">
                                    </div>
                                    <div class="col-sm-6">
                                    <label>Slug: </label>
                                        <input type="text" class="form-control form-control-user" id="slugname"
                                            placeholder="Slug" name="slug">
                                    </div>
                                </div>
                                <div class="row">
                                <div class="form-group col-6">
                                <label>ROI </label>
                                    <input type="number" class="form-control form-control-user" id="roi"
                                        placeholder="ROI %" name="roi">
                                </div>
                                <div class="form-group col-6">
                                <label>Referral bonus </label>
                                    <input type="number" class="form-control form-control-user" id="ref"
                                        placeholder="Referral bonus%" name="ref">
                                </div>
                                </div>
                                

                               
                                <div class="row">
                                <div class="form-group col-6">
                                <label>Term : </label>
                                    <input type="number" class="form-control form-control-user" id="term"
                                        placeholder="Term" name="term">
                                </div>
                                <div class="form-group col-6">
                                <label>Duration : </label>
                                <select name="duration" class="form-control">
                                    <option id="days" value="1">day(s)</option>
                                    <option id="weeks" value="7">week(s)</option>
                                    <option id="months" value="30">Month(s)</option>
                                    
                                </select>
                                   
                                </div>
                                
                                
                                </div>
                               <div class="row">
                                <div class="form-group col-6">
                                <label>Min Amount: </label>
                                    <input type="number" class="form-control form-control-user" id="planamount"
                                        placeholder="Amount" name="amount">
                                </div>
                                
                                <div class="form-group col-6">
                                <label>Max Amount: </label>
                                    <input type="number" class="form-control form-control-user" id="maxamount"
                                        placeholder="Max amount" name="maxamount">
                                </div>
                                
                                </div>
                                
                                <div class="form-group">
                                <label>Active: </label>
                                
                                
                                    <select name="active" class="form-control" id="select-box">
                                     <option value="" selected hidden>Activate plan</option>  
                                     <option value="yes" id="active-yes">Active</option>
                                     <option value="no" value="no" id="active-no">Not active</option>
                                    </select>
                                </div>

                                <button type="button" name="edit" class="btn btn-primary btn-user btn-block" id="user-submit" onclick="submit_form()">
                                    Edit Plan
                                </button>
                                <hr>
                                
                                 
                            </form>


                </div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                    
                </div>
            </div>
        </div>
    </div>

<!-- Create modal-->


<div class="modal fade" id="createModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Create a new plan?</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form method="post" id="createform">
                    <div class="container">
                        <div class="row">
                        <div class="form-group col-md-6 col-sm-6 col-6">
                            <label>Plan Name</label>
                           <input type="text" name="newplanname" id="newplanname" Placeholder="Plan Name" class="form-control"  required/> 
                        </div>
                        <div class="form-group col-md-6 col-sm-6 col-6">
                            <label>Slug</label>
                           <input type="text" name="newslug" id="newslug" Placeholder="Slug"  class="form-control" required/> 
                        </div>
                                    </div>
                                    </div>
                                    <div class="row">
                        <div class="form-group col-6">
                            <label>Amount</label>
                           <input type="number" name="newamount" id="newamount" Placeholder="Amount" class="form-control" required/> 
                        </div>
                        <div class="form-group col-6">
                            <label>Max amount</label>
                           <input type="number" name="newmaxamount" id="newmaxamount" Placeholder="Max amount" class="form-control" required/> 
                        </div>
                        
                        </div>
                        
                        <div class="form-group">
                            <label>ROI</label>
                           <input type="number" name="newroi" id="newroi" Placeholder="ROI %" class="form-control" required/> 
                        </div>

                        
                        <div class="row">
                        <div class="form-group col-6">
                            <label>Term</label>
                           <input type="number" name="newterm" id="newterm" Placeholder="Term" class="form-control" required/> 
                        </div>
                        <div class="form-group col-6">
                            <label>Duration</label>
                           <select name="newduration" id="newduration" class="form-control" required> 
                           <option id="newdays" value="1">day(s)</option>
                                    <option id="newweeks" value="7">week(s)</option>
                                    <option id="newmonths" value="30">Month(s)</option>
                                    
                           </select>
                        </div>
                        
                        </div>
                        <div class="form-group">
                           <button class="btn btn-block btn-primary" name="create-plan">Create plan</button> 
                           
                        </div>
                                        
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                    
                </div>
            </div>
        </div>
    </div>
<?php
if(isset($_POST['create-plan'])){
    $planname=$_POST['newplanname'];
    $slug=$_POST['newslug'];
    $amount=$_POST['newamount'];
    $maxamount=$_POST['newmaxamount'];
    $roi=$_POST['newroi'];
    $term=$_POST['newterm'];
    $returns = 0;
    $durations = $_POST['newduration'];
    if($durations==1){
        $period="days";
    }
    else if($durations==7){
        $period="weeks";
    }
    else{
        $period="months";
    }
    $days=intval($durations)*intval($term);
    
    $insert=mysqli_query($conn, "INSERT INTO `iv_schemes`(`name`,`slug`,`amount`,`roi`,`returns`,`term`,`max_amount`,`days`,`duration`) VALUES('$planname','$slug','$amount','$roi','$returns','$term','$maxamount','$days','$period')");
    if($insert){
        echo "
        <script>
            swal('Great!', 'New Staking plan created!', 'success');
        </script>
        ";
    }
    else{
        $err= mysqli_error($conn);
        echo $err;
        echo "
        <script>
            swal('Great!',$err, 'success');
        </script>
        ";
    }
}

?>


<!--unblock modal-->

  










<?php
require "footer.php";
?>
     <script>



if ( window.history.replaceState ) {

  window.history.replaceState( null, null, window.location.href );
}
function submit_form(){
    var myFormData=$("#plan-form").serialize();
    disable_btn();
    $.ajax({
        'type':'post',
        'url':'ajax/edit-plans.php',
        'data':myFormData,
        'success':function(data){
            //alertify.alert(data);
            swal("Great!",data,"success");
            enable_btn();
        }
    });
}

function confirmDelete(val){
    swal({
  title: "Are you sure?",
  text: "Once deleted, you will not be able to recover this Plan!",
  icon: "warning",
  buttons: true,
  dangerMode: true,
})
.then((willDelete) => {
  if (willDelete) {
    $.ajax({
        'type':'post',
        'url':'ajax/delete-plan.php',
        'data':{'id':val},
        'success':function(data){
            //alertify.alert(data);
            swal("Poof! Plan deleted!", {
            icon: "success",
    });
        }
    });
    
  } else {
    swal("Your plan is safe!");
  }
});
}

function disable_btn(){
   $("#user-submit").attr("disabled",true); 
   
}
function enable_btn(){
      $("#user-submit").attr("disabled",false); 
}
</script>
    <style>
    edit-btn:hover{
        color: #000;
        cursor: pointer;
    }
</style>

<script>
    function openModal(id){
        
        $.ajax({
            type:'post',
            url:'ajax/fill-plan-inputs.php',
            data:{'id':id},
            success:function(data){
                 
                var plandata=JSON.parse(data);
                
                $("#planname").val(plandata.name);
                $("#slugname").val(plandata.slug);
                $("#roi").val(plandata.ROI);
                
                $("#term").val(plandata.term);
                $("#planamount").val(plandata.amount);
                $("#maxamount").val(plandata.max_amount);
                $("#ref").val(plandata.ref);
                $("#plan_id").val(plandata.id);
               if(plandata.duration=="days"){
                   $("#days").attr("selected",true)
               }
               else if(plandata.duration=="weeks"){
                   $("#weeks").attr("selected",true);
               }
               else {
                   $("#months").attr("selected",true);
               }
                
               if(plandata.active=="yes"){
                   $("#active-yes").attr("selected",true);
               }  
                  else{
                      $("#active-no").attr("selected",true);
                  }
               
                document.getElementById("hiddenEditbtn").click();
            }
        });
    }
    
    
</script>

</body>

</html>
Back to Directory=ceiIENDB`