:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/kreative_crm/quatation/**
:: Editing File: dashboard_backup.php
<?php include_once("session.php"); include("db.php"); include("header.php"); ?> <?php $sql = " /* --- 1. Select Inward Transactions --- */ SELECT i.id AS transaction_id, i.inward_no AS ref_no, /* Display Inward No. */ 'INWARD' AS type, ib.box_4H, ib.box_5H, ib.box_6H, ib.box_7H, ib.box_8H, ib.box_9H, ib.box_10H, ib.box_CL, ib.total_box, i.created_at AS transaction_date FROM inward AS i JOIN inward_box AS ib ON i.id = ib.inward_id UNION ALL /* --- 2. Select Outward Transactions --- */ SELECT o.id AS transaction_id, o.outward_no AS ref_no, /* Display Outward No. */ 'OUTWARD' AS type, /* Outward boxes are negative stock movement */ -ob.box_4H AS box_4H, -ob.box_5H AS box_5H, -ob.box_6H AS box_6H, -ob.box_7H AS box_7H, -ob.box_8H AS box_8H, -ob.box_9H AS box_9H, -ob.box_10H AS box_10H, -ob.box_CL AS box_CL, -ob.total_box AS total_box, o.created_at AS transaction_date FROM outward AS o JOIN outward_box AS ob ON o.id = ob.challan_id /* Order by transaction date for a proper ledger view */ ORDER BY transaction_date DESC; "; $res = mysqli_query($conn, $sql); // ----------------------------------------------------------------- // PHP: Initialize variables to hold the running total (final stock) // ----------------------------------------------------------------- $final_stock = [ 'box_4H' => 0, 'box_5H' => 0, 'box_6H' => 0, 'box_7H' => 0, 'box_8H' => 0, 'box_9H' => 0, 'box_10H' => 0, 'box_CL' => 0, 'total_box' => 0 ]; // PHP: Store all rows in an array and calculate the final balance $ledger_rows = []; while ($row = mysqli_fetch_assoc($res)) { // Accumulate the stock figures (since the query already signs them) $final_stock['box_4H'] += (int)$row['box_4H']; $final_stock['box_5H'] += (int)$row['box_5H']; $final_stock['box_6H'] += (int)$row['box_6H']; $final_stock['box_7H'] += (int)$row['box_7H']; $final_stock['box_8H'] += (int)$row['box_8H']; $final_stock['box_9H'] += (int)$row['box_9H']; $final_stock['box_10H'] += (int)$row['box_10H']; $final_stock['box_CL'] += (int)$row['box_CL']; $final_stock['total_box'] += (int)$row['total_box']; $ledger_rows[] = $row; } ?> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"> <!-- Body main section starts --> <main> <div class="container-fluid 5box"> <div class="row row-cols-xxl-5 row-cols-md-3 row-cols-1 g-0" style="border-bottom: 1px solid #878a99;"> <a href="list_parties.php"><div class="col"> <!-- count_farmers --> <?php $sql_farmers = mysqli_query($conn, "SELECT COUNT(*) FROM party where type='Farmer';"); $count_farmers = mysqli_fetch_row($sql_farmers)[0]; ?> <div class="py-4 px-3" style=""> <h6 class="text-muted text-uppercase fs-13">Listed Farmers<i class="ri-arrow-up-circle-line text-success fs-18 float-end align-middle"></i></h5> <div class="d-flex align-items-center"> <div class="flex-shrink-0"> <!--<i class="fas fa-rocket display-6 text-muted"></i>--> <img src="assets/svg/listed-farmer.png" width="50px;"> </div> <div class="flex-grow-1 ms-3"> <h2 class="mb-0" ><span style="color:#878a99" class="counter-value" data-target="197"> <?php echo $count_farmers; ?> </span></h2> </div> </div> </div> </div><!-- end col --></a> <a href="list_parties.php"><div class="col"> <!-- count_farmers --> <?php $sql_vendors = mysqli_query($conn, "SELECT COUNT(*) FROM party where type='Vendor';"); $count_vendors = mysqli_fetch_row($sql_vendors)[0]; ?> <div class="mt-3 mt-md-0 py-4 px-3"> <h5 class="text-muted text-uppercase fs-13">Listerd Vendors <i class="ri-arrow-up-circle-line text-success fs-18 float-end align-middle"></i></h5> <div class="d-flex align-items-center"> <div class="flex-shrink-0"> <!--<i class="fa fa-dollar-sign display-6 text-muted"></i>--> <img src="assets/svg/listed-vendor.png" width="50px;"> </div> <div class="flex-grow-1 ms-3"> <h2 class="mb-0"><span style="color:#878a99" class="counter-value" data-target="489.4"> <?php echo $count_vendors; ?></span></h2> </div> </div> </div> </div><!-- end col --> <a href="payments_list.php"> <div class="col"> <?php $sql_amount = mysqli_query($conn, "SELECT SUM(outstaing_amount) FROM payment"); $count_amount = mysqli_fetch_row($sql_amount)[0]; $intAmount = (int)$count_amount; ?> <div class="mt-3 mt-md-0 py-4 px-3"> <h5 class="text-muted text-uppercase fs-13">Total Outstaing Amount <i class="ri-arrow-down-circle-line text-danger fs-18 float-end align-middle"></i></h5> <div class="d-flex align-items-center"> <div class="flex-shrink-0"> <!-- <i class="fa fa-chart-line display-6 text-muted"></i>--> <img src="assets/svg/total-sales.png" width="50px;"> </div> <div class="flex-grow-1 ms-3"> <h2 class="mb-0"><span style="color:#878a99" class="counter-value" data-target="32.89"><?php echo $intAmount; ?></span></h2> </div> </div> </div> </div><!-- end col --> <a href="payments_list.php"> <div class="col"> <?php $sql_recevied_amount = mysqli_query($conn, "SELECT SUM(recevied_amount) FROM payment"); $count_recevied_amount= mysqli_fetch_row($sql_recevied_amount)[0]; $intRecevied_amount = (int)$count_recevied_amount; ?> <div class="mt-3 mt-lg-0 py-4 px-3"> <h5 class="text-muted text-uppercase fs-13">Total Recevied Amount<i class="ri-arrow-up-circle-line text-success fs-18 float-end align-middle"></i></h5> <div class="d-flex align-items-center"> <div class="flex-shrink-0"> <!-- <i class="fa fa-trophy display-6 text-muted"></i>--> <img src="assets/svg/total-profit.png" width="50px;"> </div> <div class="flex-grow-1 ms-3"> <h2 class="mb-0"><span style="color:#878a99" class="counter-value" data-target="1596.5"><?php echo $intRecevied_amount; ?></span></h2> </div> </div> </div> </div><!-- end col --> <a href="payments_list.php"> <div class="col"> <?php $pending_amount = $count_amount - $count_received_amount; ?> <div class="mt-3 mt-lg-0 py-4 px-3"> <h5 class="text-muted text-uppercase fs-13">Total Pending Amount <i class="ri-arrow-down-circle-line text-danger fs-18 float-end align-middle"></i></h5> <div class="d-flex align-items-center"> <div class="flex-shrink-0"> <!--<i class="fa fa-heart display-6 text-muted"></i>--> <img src="assets/svg/total-box.png" width="50px;"> </div> <div class="flex-grow-1 ms-3"> <h2 class="mb-0"><span style="color:#878a99" class="counter-value" data-target="2659"><?php /* echo $pending_amount; */ ?>0.00</span></h2> </div> </div> </div> </div><!-- end col --> </div> <br><br> <?php $sort_order = 'ASC'; ?> <div class="row "> <div class="col-xxl-5 team-section"> <div class="card card-height-100"> <div class="card-header align-items-center"> <a href="team_list.php"><h4 class="card-title mb-0 flex-grow-1" style="float:left">Team Members</h4></a> <div class="flex-shrink-0" style="float:right"> <div class="dropdown card-header-dropdown"> <a class="text-reset dropdown-btn" href="#" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="fw-semibold text-uppercase fs-12">Sort by : </span> <span class="text-muted" id="current-order"><?php echo $sort_order; ?><i class="fa fa-chevron-down ms-1"></i></span> </a> <div class="dropdown-menu dropdown-menu-end"> <a class="dropdown-item sort-link" href="?sort=ASC" data-order="ASC" id="sort-asc">ASC</a> <a class="dropdown-item sort-link" href="?sort=DESC" data-order="DESC" id="sort-desc">DESC</a> </div> </div> </div> </div><!-- end card header --> <div class="card-body"> <div class="table-responsive table-card"> <table class="table table-borderless table-nowrap align-middle mb-0"> <thead class="table-light text-muted"> <tr> <th scope="col">Member</th> <th scope="col">Occupation</th> <!--<th scope="col">Hours</th> <th scope="col">Expense</th>--> </tr> </thead> <tbody> <tr> <?php // Default sort order if (isset($_GET['sort'])) { $requested_order = strtoupper($_GET['sort']); // Validate the input to prevent SQL injection if ($requested_order === 'ASC' || $requested_order === 'DESC') { $sort_order = $requested_order; } } $sql = "SELECT employee_id, employee_name, occupation FROM team_details ORDER BY employee_name " . $sort_order; // Sorting by ID is safest, change to employee_name if preferred $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { ?> <td class="d-flex"> <img src="assets/images/avatar/avatar-1.jpg" alt="" class="avatar-xs rounded-3 me-2"> <div> <h5 class="fs-13 mb-0"><?php echo $row['employee_name']; ?></h5> <!--<p class="fs-12 mb-0 text-muted"><?php echo $row['occupation']; ?></p>--> </div> </td> <td> <?php echo $row['occupation']; ?> </td> <!--<td>258</td>--> </tr> <?php } } ?> </tbody></table></div> </div><!-- end cardbody --> </div><!-- end card --> </div><!-- end col --> <?php $sql1 = " SELECT 'Banana' AS product_name, SUM(box_4H) AS remaining_box_4H, SUM(box_5H) AS remaining_box_5H, SUM(box_6H) AS remaining_box_6H, SUM(box_7H) AS remaining_box_7H, SUM(box_8H) AS remaining_box_8H, SUM(box_9H) AS remaining_box_9H, SUM(box_10H) AS remaining_box_10H, SUM(box_CL) AS remaining_box_CL, SUM(total_box) AS grand_total_boxes FROM ( /* --- 1. Select Inward Transactions (Positive Stock) --- */ SELECT ib.box_4H, ib.box_5H, ib.box_6H, ib.box_7H, ib.box_8H, ib.box_9H, ib.box_10H, ib.box_CL, ib.total_box FROM inward AS i JOIN inward_box AS ib ON i.id = ib.inward_id WHERE i.product_name LIKE '%Banana%' UNION ALL /* --- 2. Select Outward Transactions (Negative Stock) --- */ SELECT /* Outward boxes are subtracted from the total sum */ -ob.box_4H AS box_4H, -ob.box_5H AS box_5H, -ob.box_6H AS box_6H, -ob.box_7H AS box_7H, -ob.box_8H AS box_8H, -ob.box_9H AS box_9H, -ob.box_10H AS box_10H, -ob.box_CL AS box_CL, -ob.total_box AS total_box FROM outward AS o JOIN outward_box AS ob ON o.id = ob.challan_id WHERE o.product_name LIKE '%Apple%' ) AS stock_movements; "; $res1 = mysqli_query($conn, $sql1); $remaining_stock = []; if ($res1) { // Fetch the single row of summed data $remaining_stock = mysqli_fetch_assoc($res1); } else { // If query fails, initialize array with zeros/nulls to prevent "Undefined index" warnings // In a production environment, you would log this error. error_log("Stock Query Error: " . mysqli_error($conn)); $remaining_stock = [ 'product_name' => 'Error', 'remaining_box_4H' => 0, 'remaining_box_5H' => 0, 'remaining_box_6H' => 0, 'remaining_box_7H' => 0, 'remaining_box_8H' => 0, 'remaining_box_9H' => 0, 'remaining_box_10H' => 0, 'remaining_box_CL' => 0, 'grand_total_boxes' => 0 ]; } ?> <div class="col-7 product-stock"> <div class="card"> <div class="card-header d-flex justify-content-between align-items-center"> <h6 class="mb-0"> Product Stock</h5> <!--<div class="btn-group" role="group"> <button type="button" class="btn btn-outline-secondary active">Cold Storage 1</button> <button type="button" class="btn btn-outline-secondary">Cold Storage 2</button> <button type="button" class="btn btn-outline-secondary">Cold Storage 3</button> </div> --> </div> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-striped table-hover mb-0"> <style> /* Custom styling for the header/body rows */ .product-stock .table thead tr th, .table-balance th { padding: 18px !important; } .table-balance th:first-child { font-weight: 500; color: #666; /* Label color */ } </style> <tbody class="table-balance"> <tr> <th>Apple Boxes</th> <td>250</td> </tr> <tr> <th>Pomegranate</th> <td>90</td> </tr> <tr> <th>Kiwi</th> <td>80</td> </tr> <tr> <th>Strawberries</th> <td>60</td> </tr> <tr> <th>Grapes</th> <td>50</td> </tr> <tr> <th>Malta (Orange)</th> <td>40</td> </tr> <!-- Total Box Row Highlighted --> <tr class="bg-light font-weight-bold total-row" style="background-color: rgb(15 98 106) !important"> <th scope="row" style="color:#fff">Total Boxes Remaining</th> <td style="color:#cab27d !important; font-size: 1.25em;"><?php /*htmlspecialchars($remaining_stock['grand_total_boxes'] ?? 0)*/ ?> 570 </td> </tr> </tbody> </table> </div> </div> </div> </div> </div> <div class="row"> <div class="col-lg-4 col-xxl-2 order-1-lg"> <div class="row"> <div class="col-sm-6 col-lg-12"> <a href="coldstorage_list.php"> <div class="card bg-primary profit-card-2"> <div class="card-body"> <i class="ph-duotone ph-calendar-check icon-bg"></i> <span class="bg-white h-50 w-50 d-flex-center b-r-50"> <i class="ph-duotone ph-calendar-check text-primary f-s-24"></i> </span> <div class="mt-3"> <?php $sql_coldstorage = mysqli_query($conn, "SELECT COUNT(*) FROM cold_storage;"); $count_coldstorage = mysqli_fetch_row($sql_coldstorage)[0]; ?> <h4 class="text-white"><?php echo $count_coldstorage; ?>+</h4> <p class="f-w-500 mb-0 txt-ellipsis-1">Active Coldstorage</p> </div> </div> </div> </a> </div> <div class="col-sm-6 col-lg-12"> <div class="card project-profit-card"> <div class="card-body"> <div class="profit-arrow"> <span class="bg-white text-primary h-45 w-45 d-flex-center"> <i class="ph-bold ph-arrow-up-right f-s-18"></i> </span> </div> <span class="bg-primary h-45 w-45 d-flex-center b-r-50"> <i class="ph-bold ph-chart-line-up f-s-24"></i> </span> <div class="mt-3"> <h4 class="text-dark">40.2K+</h4> <p class="f-w-500 mb-0 txt-ellipsis-1">Total profit Progress</p> </div> </div> </div> </div> </div> </div> <div class="col-md-7 col-lg-4"> <!--<a href="list_farmers"> <div class="header-box"> <h5>List of Farmers</h5> </div> </a> --> <ul class="box-list"> <a href="list_farmers.php"> <li class=" d-flex justify-content-between align-items-center mt-3" style="border-left: 4px solid rgba(var(--primary), 1);"> <h5 class="mb-0 txt-ellipsis-1 flex-grow-1"> List of Farmers</h5> <span class="badge bg-primary"><i class="fa fa-long-arrow-right"></i></span> </li> </a> </ul> <br> <div class="card"> <div class="card-body px-2 pt-2 equal-card" style="padding: 45px;"> <div class="table-responsive app-scroll"> <table class="table table-bottom-border align-middle mb-0"> <?php $sql = "SELECT * FROM farmers ORDER BY id DESC Limit 3"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { ?> <tr class="border-0" style="border-bottom:1px solid rgba(var(--secondary), 0.2) !important;"> <td> <div class="d-flex align-items-center"> <div class="h-40 w-40 d-flex-center b-r-12 overflow-hidden bg-danger-600"> <img alt="image" class="img-fluid" src="assets/images/avatar/3.png"> </div> <div class="flex-grow-1 ps-2"> <div class="fw-medium txt-ellipsis-1"><?php echo $row['farmer_name']; ?></div> <div class="text-muted f-s-12 txt-ellipsis-1"><?php echo $row['contact']; ?></div> </div> </div> </td> <!-- <td><span class="badge text-light-primary f-s-12 f-w-700">350</span> </td> --> <td> <div class="form-check form-switch"> <label class="form-check-label f-w-500" for="tableCheck">Active</label> <input checked="" class="form-check-input w-25 form-check-primary" id="tableCheck" type="checkbox"> </div> </td> </tr> <?php } } ?> </table> </div> </div> </div> </div> <div class="col-sm-6 col-lg-4 col-xxl-3"> <ul class="box-list"> <a href="vendors_list.php"> <li class=" d-flex justify-content-between align-items-center mt-3" style="border-left: 4px solid rgba(var(--danger), 1);"> <h5 class="mb-0 txt-ellipsis-1 flex-grow-1"> List of Vendors</h5> <span class="badge bg-primary"><i class="fa fa-long-arrow-right"></i></span> </li> </a> <br> </ul> <div class="card"> <div class="card-body"> <!--<ul class="nav nav-tabs app-tabs-primary border-0 flex-nowrap overflow-auto" id="Outline" role="tablist"> <li class="nav-item" role="presentation"> <button class="nav-link active" id="clientTab" data-bs-toggle="tab" data-bs-target="#clientTabPane" type="button" role="tab" aria-controls="clientTabPane" aria-selected="true">Client</button> </li> <li class="nav-item" role="presentation"> <button class="nav-link" id="activeTab" data-bs-toggle="tab" data-bs-target="#activeTabPane" type="button" role="tab" aria-controls="activeTabPane" aria-selected="false">Active</button> </li> <li class="nav-item" role="presentation"> <button class="nav-link" id="orderTab" data-bs-toggle="tab" data-bs-target="#orderTabPane" type="button" role="tab" aria-controls="orderTabPane" aria-selected="false">Deactivate</button> </li> </ul> --> <ul class="box-list client-list"> <?php $sql = "SELECT * FROM vendors ORDER BY id DESC Limit 2"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { ?> <li class="d-flex align-items-center justify-content-between" style="margin-bottom: 2rem;"> <div class="h-45 w-45 d-flex-center b-r-12 overflow-hidden bg-success-500 flex-shrink-0"> <img alt="task" class="img-fluid" src="assets/images/avatar/5.png"> </div> <div class="ms-2 flex-grow-1"> <p class="mb-0 f-w-500 f-s-16 txt-ellipsis-1"><?php echo $row['name']; ?></p> <p class="mb-0 f-s-12 txt-ellipsis-1"><?php echo $row['phone']; ?></p> </div> <span class="h-30 w-30 d-flex-center b-r-50"> <a href="vendors_list.php"> <i class="ti ti-chevron-right text-primary f-s-20"></i> </a> </span> </li> <?php } } ?> </ul> </div> </div> </div> <div class="col-sm-6 col-lg-4 col-xxl-3"> <ul class="box-list"> <?php if($user_id == '1') { $sql_noti = mysqli_query($conn, "SELECT COUNT(*) FROM notifications WHERE is_read='0'"); $sql = "SELECT * FROM notifications WHERE is_read='0' ORDER BY created_at desc LIMIT 3"; } else { $sql_noti = mysqli_query($conn, "SELECT COUNT(*) FROM notifications WHERE `user_id` ='$user_id' AND is_read='0'"); $sql = "SELECT * FROM notifications WHERE is_read='0' AND `user_id` ='$user_id' ORDER BY created_at desc LIMIT 3 "; } $count_noti = mysqli_fetch_row($sql_noti)[0]; ?> <a href="notifications_list.php"> <li class=" d-flex justify-content-between align-items-center mt-3" style="border-left: 4px solid rgba(var(--primary), 1);"> <h5 class="mb-0 txt-ellipsis-1 flex-grow-1"> Notifications</h5> <span class="badge bg-primary"><?php echo $count_noti;?> New</span> </li> </a> <br> <?php $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($note = mysqli_fetch_assoc($result)) { ?> <li class="d-flex align-items-center justify-content-between"> <!--<div class="h-40 w-40 d-flex-center b-r-12 overflow-hidden bg-primary text-white flex-shrink-0"> TN </div> --> <div class="ms-2 flex-grow-1"> <p class="mb-0 f-w-500 f-s-18 txt-ellipsis-1"> <span class="<?php echo ($note['type'] == 'success') ? 'text-success' : (($note['type'] == 'error') ? 'text-danger' : 'text-secondary'); ?>"> <?php echo mysqli_real_escape_string($conn, $note['message'])?> </span> </p> <p class="mb-0 f-s-12 txt-ellipsis-1"><span class="badge text-light-primary"> <?php echo date("d-M-Y H:i", strtotime($note['created_at'])); ?></span></p> </div> <a href="notifications_list.php" target="_blank" class="text-light-success bg-remove h-45 w-45 d-flex-center b-r-50"> <i class="ti ti-message f-s-20"></i> </a> </li> <?php } }?> </ul> </div> </div> </div> </main> </div> </div> <!-- Body main section ends --> <?php include("footer.php"); ?> <script> $(document).ready(function() { // Function to update the URL parameter $('.sort-link').on('click', function(e) { e.preventDefault(); var newSortOrder = $(this).data('order'); var currentUrl = window.location.href.split('?')[0]; // Get the base URL var currentParams = new URLSearchParams(window.location.search); // Set or update the 'sort' parameter currentParams.set('sort', newSortOrder); // Redirect to the new URL window.location.href = currentUrl + '?' + currentParams.toString(); }); }); </script>