Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
5.8 kB
1
Indexable
Never
<?php 

include 'db_connect.php';

$varNumberOfDays = 30;

?>
<div class="col-md-12">
    <div class="card card-outline card-success">
        <div class="card-header">
            <div class="row">
                <div class="col-md-3">
                    <div class="form-group">
                        <label>From Date</label>
                        <input type="date" name="from_date" id="from_date"
                            value="<?php if(isset($_GET['from_date'])){ echo $_GET['from_date']; } ?>"
                            class="form-control">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label>To Date</label>
                        <input type="date" name="to_date" id="to_date"
                            value="<?php if(isset($_GET['to_date'])){ echo $_GET['to_date']; } ?>" class="form-control">
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="form-group">
                        <label>Users<?php //echo "<pre>"; print_r($_SESSION['login_id']);?></label>

                        <select name="user_id" id="user_id" class="form-control">
                            <option value="">Select users</option>
                            <?php 
                             $role_str = '';
                             if($_SESSION['login_type'] !='1')
                             {
                                 $role_str = "  AND manager_id='".$_SESSION['login_id']."'";
                             }
                            $qry_user = $conn->query("SELECT id, concat(firstname, ' ',lastname) as name  FROM `users` WHERE type!='1' $role_str");
                             if ($qry_user->num_rows > 0)
                             { 
                                while($row_users = $qry_user->fetch_assoc()) 
                                { ?>
                            <option value="<?=$row_users['id']?>"
                                <?php if(isset($_GET['user_id'])){ echo 'selected'; } ?>><?=$row_users['name']?>
                            </option>
                            <?php  }
                             }
                         
                            ?>


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

                <div class="col-md-3">
                    <div class="form-group">
                        <label></label> <br>
                        <button type="button" id="filter_btn" class="btn btn-primary" style="margin-top:24px;">Filter
                            Date</button>
                    </div>
                </div>
            </div>

            <div class="card-tools">
                <button class="btn btn-flat btn-sm bg-gradient-success btn-success" id="print"><i
                        class="fa fa-print"></i> Print</button>
            </div>
            <div class="card-tools p-0 pr-3">
                <!-- Add this button wherever you want it in your HTML form -->
                <button  class="btn btn-flat btn-sm bg-gradient-dark btn-dark"
                id="downloadCsvButton" onclick="downloadCsv()"><i class='fas fa-file-csv' style='font-size:21px'> Download Report</i></button>
        </div>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive" id="printable">

            </div>
        </div>
       



    </div>
</div>
<script>
$(document).ready(function() {
    progress_report();

    $('#filter_btn').click(function() {
        var from_date = $('#from_date').val();
        var to_date = $('#to_date').val();
        var user_id = $('#user_id').val();
        progress_report(from_date, to_date, user_id);

    });

});

function progress_report(from_date = '', to_date = '', user_id = '') {
    //  alert(from_date);

    $.ajax({
        url: 'filter_report.php',
        method: 'POST',
        data: {
            'action': 'progress_report',
            'from_date': from_date,
            'to_date': to_date,
            'user_id': user_id
        },
        success: function(response) {
            //alert(response);
            $('#printable').html(response);
        }
    });
}

function monthly_report(from_date = '', to_date = '', user_id = '') {
    $.ajax({
        url: 'filter_monthly_report.php',
        method: 'POST',
        data: {
            'action': 'monthly_report',
            'from_date': from_date,
            'to_date': to_date,
            'user_id': user_id
        },
        success: function(response) {
            $('#printable').html(response);
        }
    });
}

$(document).ready(function() {
    // Attach click event to the "Monthly Report" link
    $('.nav-reports').click(function(e) {
        // Prevent the default link behavior
        e.preventDefault();

        // Get the current date range or set your desired date range
        var fromDate = '2024-01-01';
        var toDate = '2024-12-31';

        // Call the monthly_report function with date parameters
        monthly_report(fromDate, toDate);
    });
});
</script>

<script>
$('#print').click(function() {
    start_load()
    var _h = $('head').clone()
    var _p = $('#printable').clone()
    var _d = "<p class='text-center'><b>Project Progress Report as of (<?php echo date("F d, Y") ?>)</b></p>"
    _p.prepend(_d)
    _p.prepend(_h)
    var nw = window.open("", "", "width=900,height=600")
    nw.document.write(_p.html())
    nw.document.close()
    nw.print()
    setTimeout(function() {
        nw.close()
        end_load()
    }, 750)
})
</script>
Leave a Comment