MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/public_html/imenso.co/matrix/admin/assigned_to.php
<?php include 'admin_header.php';
error_reporting(0);
// include('../PHPExcel/Classes/PHPExcel/IOFactory.php');

require '../vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;

if(isset($_POST['save']))
{
    if(isset($_POST['assign_id']))
    {
        $assignment_ids = $_POST['assign_id'];
        foreach($assignment_ids as $assignment_id)
        {
            $conn->query("UPDATE assignments SET user_id='".$_POST['operator_id']."' WHERE id=".$assignment_id."") ;  
        }
    }
}

?>
<div class="container" style="background: #fff;position:relative; margin-top:42px ">
    <div class="assignment-dashboard">
        <form action="" method="POST" >
            <div class="row">
                <div class="col-sm-8 border-right">
                    <h5 class="mt-3 mb-3">ASSIGNED FOLDERS <span class="font-weight-light small text-info total_count">[0]</span><div class="pull-right"> 
                        <strong class="badge badge-secondary checked_count">0</strong></div></h5>
                     <input type="text" name="search" class="mb-3 assignment_to"  placeholder="Search: [Folder Index/User]" id="search" style=" width: -webkit-fill-available; text-align: center;">
                    <div class="table-responsive" id="assignment_to_table">
                        <table class="table table-striped table-sm table-bordered" >
                            <thead>
                                <tr>
                                    <th>Action</th>
                                    <th>
                                        <a href="javascript:;" class="column_sort_assign" id="assignment_no" data-order="desc"> Folder Index</a> 
                                    </th>
                                    <th>
                                        <a href="javascript:;" class="column_sort_assign" id="no_of_record" data-order="desc"> Data Count</a>
                                    </th>
                                    <th>
                                       Completed Count
                                    </th>
                                    <th>
                                        <a href="javascript:;" class="column_sort_assign" id="name" data-order="desc">Assigned To</a> 
                                    </th>
                                    <th>
                                        <a href="javascript:;" class="column_sort_assign" id="assignment_date" data-order="desc">Assigned Date</a>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $total = 0 ;
                                
                                $result = $conn->query("SELECT assignments.* , 
                                
                                SUM(if(assignment_details.doc_title != '' OR assignment_details.doc_date != '' OR assignment_details.doc_description != '', 1, 0)) as completed_count  , 
                                
                                users.name as user_name FROM assignments inner join users on users.id = assignments.user_id inner join assignment_details on assignment_details.assignment_id = assignments.id  WHERE assignments.deleted=0 AND assignments.assignment_status_id = 1   group by assignments.id");
                                while($row = $result->fetch_assoc()) {
                                $total = $total + $row['no_of_record'] ;
                                   
                                ?>
                                <tr>
                                    <td><input type="checkbox" class="chk_assign_id" name="assign_id[]" value="<?php echo $row['id'] ?>" file_count="<?php echo $row['no_of_record'] ?>"  /></td>
                                    <td><a href="show_doc.php?assignment_no=<?php echo $row['assignment_no'] ?>" target="_blank" > <?php echo $row['assignment_no'] ?></a> </td>
                                    <td> <?php echo $row['no_of_record'] ?></td>
                                    <td><?php echo $row['completed_count'] ?></td>
                                    <td> <?php echo $row['user_name'] ?></td> 
                                    <td><?php echo date('m/d/Y ', strtotime($row['assignment_date'])) ?></td>
                                </tr>
                                <?php
                                }
                                ?> 
                            </tbody>
                            <!--<tfoot>-->
                            <!--    <tr>-->
                            <!--        <th>Action</th>-->
                            <!--        <th>Folder Index</th>-->
                            <!--        <th>Data Count</th>-->
                            <!--        <th>Assign To </th>-->
                            <!--        <th>Assigned Date</th>-->

                            <!--    </tr>-->
                            <!--</tfoot>-->
                        </table>
                    </div>
                </div>
                <div class="col-sm-4">
                    <h5 class="mt-3 mb-3">RE-ASSIGN TO:</h5>
                    <?php
                    $sql = "SELECT users.* , sum(assignments.no_of_record) as no_of_pending FROM users inner join role_user on role_user.user_id = users.id left join assignments on assignments.user_id = users.id and assignments.assignment_status_id = 1  WHERE role_user.role_id IN ('2','3')  group by users.id";
                    $result = $conn->query($sql);
                    while($row = $result->fetch_assoc()) {
                        ?> 
                        <div class="card mb-3">
                            <div class="card-body">
                                <div class="card-text pull-left">
                                    <img src="../images/user.png" class="rounded-circle border mr-3" alt="Cinque Terre" width="36"> 
                                    <strong><?php echo $row["name"]; ?></strong> 
                                    <span class="badge badge-info "><?php echo  $row["no_of_pending"]; ?></span>
                                </div>
                                <div class="card-link pull-right" style="margin-top: 6px;">
                                    <input type="radio" class=""   name="operator_id" value="<?php echo $row["id"] ; ?>"  >
                              </div>
                            </div>
                        </div>
                        <?php
                    }
                    ?>
                    <div class="text-right">
                        <input class="btn btn-primary" type="submit" name="save" value="Assign" />
                    </div>
                    
                </div>
            </div>
        </form>
    </div>
</div>

<?php
?>
<script>
    $(document).ready(function(){
        
        $(".total_count").html("[<?php echo $total ?>]");
        $('input:radio[name="operator_id"]:visible:first').attr('checked','checked');
        $(".chk_assign_id").change(function() {
            var total = 0 ;
            $("input[name='assign_id[]']:checked").each(function () {
                total = total + parseInt($(this).attr("file_count"));
            });

            $(".checked_count").html(total); 
        }); 
    });
</script>
<?php $conn->close();

//include 'admin_footer.php';
?>