Need help setFilterGrid with total qty at the last row

Hi…

Good day!

I already had codes on setFilterGrid on my table, now I need to add the total qty at the row which is i don’t have any idea if it is possible using javascript and how. I want to happen is every time I filter the item code the Quantity will SUM and display on the last row.

here is my code:


<?php
include('connection.php');
?>
<html>
<title>Raw Materials Inventory</title>
<head>
<link rel="stylesheet" type="text/css" href="css/kanban.css" />
<script language="javascript" type="text/javascript" src="tablefilter.js"></script>

<style>
table {
    font: 14px/28px Verdana, Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    }

th {
    padding: 0 0.6em;
    text-align: left;
    }

tr.yellow th {
    border-top: 1px solid #FB7A31;
    border-bottom: 1px solid #FB7A31;
    background: #FFC;
    }

td {
    border-bottom: 1px solid #CCC;
    padding: 0 0.6em;
    }

td+td {
    border-left: 1px solid #CCC;
    text-align: center;
    }
</style>
</head>
<body>
<form>
<?php
$current = "in";
include("menu.php");

echo "<div style='clear: both;'>&nbsp;</div><div style='clear: both;'>&nbsp;</div>";
$result = mysql_query("SELECT s.bin_location, s.shelved_qty, s.issued_qty, r.wh_code, m.component, m.mat_code, m.description, m.uom FROM wms_shelving AS s LEFT JOIN wms_receiving AS r ON s.rm_id = r.rm_id LEFT JOIN bom_material AS m ON r.uid_mat = m.uid_mat WHERE s.shelved_qty > s.issued_qty OR ISNULL(s.issued_qty) ORDER BY m.component, m.mat_code");


echo "<table id='inventory'>";
echo "<tr class='yellow'>
<th>Component</th>
<th>Item Code</th>
<th>Description</th>
<th>WH Location</th>
<th>UoM</th>
<th>Quantity</th>
</tr>";
while($row = mysql_fetch_array($result))
    {
        $component = $row['component'];
        $itemcode = $row['mat_code'];
        $description = $row['description'];
        $wh_location = $row['bin_location'];
        $uom = $row['uom'];
        $remaining_qty = $row["shelved_qty"] - $row["issued_qty"];
echo "<tr>";
echo "<td>$component</td>";
echo "<td>$itemcode</td>";
echo "<td>$description</td>";
echo "<td>$wh_location</td>";
echo "<td>$uom</td>";
echo "<td>$remaining_qty</td>";
echo "</tr>" ;
    }
echo "</table>";
?>
</form>
<script language="javascript" type="text/javascript">
    var fnsFilters = {
        sort_select: true,
        loader: true,
        col_5: "none",
        col_4: "none",
        col_3: "select",
        col_2: "none",
        col_1: "select",
        col_0: "select",
        on_change: true,
        display_all_text: "Filter",
        rows_counter: false,
        btn_reset: false,
        alternate_rows: false,
        btn_reset_text: "Display Existing Item Code",
        col_width: ["auto","auto","auto", "auto", "auto", "auto"]
    }
    setFilterGrid("inventory",fnsFilters);
</script>
</body>

</html>

Any help is highly appreciated.

Thank you so much.

Hi…

I found code that has a sum below from this link :

Sample Table 7:


<script language="javascript" type="text/javascript">
//<![CDATA[
var totRowIndex = tf_Tag(tf_Id('table7'),"tr").length;
	var table7_Props = 	{
					rows_counter: true,
					loader: true,
					loader_text: "Filtering data...",
					col_operation: {
								id: ["table8Tot1","table8Tot2"],
								col: [2,4],
								operation: ["sum","sum"],
								write_method: ["innerHTML","setValue"],
								exclude_row: [totRowIndex],
								decimal_precision: [1,0]
							},
					rows_always_visible: [totRowIndex]						
				};
var tf7 = setFilterGrid( "table7",table7_Props );
//*** Note ***
//You can also write operation results in elements outside the table.	
//]]>
</script>

Honestly, I cannot understand the whole code because it has no html code or sample code of table.
So it’s to hard for me to adopt that code in my present code:


<html>
<title>Raw Materials Inventory</title>
<head>
<link rel="stylesheet" type="text/css" href="css/kanban.css" />
<script language="javascript" type="text/javascript" src="tablefilter.js"></script>

<style>
table {
    font: 14px/28px Verdana, Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    }

th {
    padding: 0 0.6em;
    text-align: left;
    }

tr.yellow th {
    border-top: 1px solid #FB7A31;
    border-bottom: 1px solid #FB7A31;
    background: #FFC;
    }

td {
    border-bottom: 1px solid #CCC;
    padding: 0 0.6em;
    }

td+td {
    border-left: 1px solid #CCC;
    text-align: center;
    }
</style>
</head>
<body>
<form>
<!--<div id="ddcolortabs">
<ul>
<li> <a href="SalesOrder.php" title="Sales Order"><span>Order Management</span></a></li>
<li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li>
<li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li>
<li><a href="fsn.php" title="Finished Stock Note"><span>WMS FG</span></a></li>
<li id="current"><a href="ReceivingMaterials.php" title="WMS RM"><span>WMS RM</span></a></li>
<li><a href="StockRequisition1.php" title="Stock Requisition"><span>Stock Requisition</span></a></li>
<li><a href="calendar_days.php" title="Calendar Days"><span>Calendar Days</span></a></li>
</ul>
</div>
-->
<div id="ddcolortabs1">
<ul>
<li><a href="ReceivingMaterials.php" title="Raw Materials"><span>Raw Materials</span></a></li>
<li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li>
<li><a href="Picking.php" title="Picking"><span>Picking</span></a></li>
<li><a href="Issuance.php" title="Issuance"><span>Issuance</span></a></li>
<li id="current"><a href="wmsinventory.php" title="Inventory"><span>Inventory</span></a></li
</ul>
</div><div style='clear: both;'>&nbsp;</div><div style='clear: both;'>&nbsp;</div><table id='inventory'><tr class='yellow'>
<th>Component</th>
<th>Item Code</th>
<th>Description</th>
<th>WH Location</th>
<th>UoM</th>
<th>Quantity</th>
</tr><tr><td>Chemicals</td><td>MAT-CHE-0010</td><td>Barium Sulfate, 25kg./bag</td><td>WAREHOUSE 1</td><td>kg</td><td>200</td></tr><tr><td>Chemicals</td><td>MAT-CHE-0075 </td><td>Kaolin Clay</td><td>WAREHOUSE 1</td><td>kg</td><td>200</td></tr><tr><td>Chemicals</td><td>MAT-CHE-0080</td><td>Light Magnesium Carbonate</td><td>WAREHOUSE 2</td><td>kg</td><td>325</td></tr><tr><td>Chemicals</td><td>MAT-CHE-0080</td><td>Light Magnesium Carbonate</td><td>WAREHOUSE 2</td><td>kg</td><td>250</td></tr><tr><td>Ringpull</td><td>PAC-EZO-0050</td><td>Ringpull, SONOCO 300dia; EOE part # 115-0356-56</td><td>WAREHOUSE 2</td><td>pc</td><td>151800</td></tr><tr><td>Sticker</td><td>PAC-STK-0080A</td><td>Blank Label Sticker, 3"X4",sheet form (additional carton label for SHIREBROOK order)</td><td>WAREHOUSE 3</td><td>pc</td><td>464</td></tr><tr><td>Tin Can/PET/P-bag</td><td>PAC-PET-0000</td><td>PET 3B-DSPI</td><td>WAREHOUSE 1</td><td>pc</td><td>94500</td></tr></table><table id=''></form>
<script language="javascript" type="text/javascript">
    var fnsFilters = {
        sort_select: true,
        loader: true,
        col_5: "none",
        col_4: "none",
        col_3: "select",
        col_2: "none",
        col_1: "select",
        col_0: "select",
        on_change: true,
        display_all_text: "Filter",
        rows_counter: false,
        btn_reset: false,
        alternate_rows: false,
        btn_reset_text: "Display Existing Item Code",
        col_width: ["auto","auto","auto", "auto", "auto", "auto"]
    }
    setFilterGrid("inventory",fnsFilters);
</script>
</body>

</html>

I hope somebody can help me. To merge the two javascript. So that after I filter the Item Code below the Quantiy will display the SUM.

Thank you so much

Hi,

I have this code for setFilterGrid and it works fine:



<form name="material_form" action="<?php echo $PHP_SELF; ?>" method="post" autocomplete="off">
<div id="WH_list">
<table id="mat_list">
<thead>
<tr>
<th>DATE ENTRY</th>
<th>PO NUMBER</th>
<th>KIND</th>
<th>ITEM CODE</th>
<th>DESCRIPTION</th>
<th>UoM</th>
<th>SUPPLIER</th>
<th>QTY</th>
<th>WH #</th>
<th>ROW #</th>
<th>RACK #</th>
<th>LEVEL</th>
<th>RECEIVED BY</th>
</tr>
</thead>

<?php
$sql = "SELECT m.date_entry, m.po_number, m.kind, r.item_code, r.sup_code, u.uom, s.supplier_name, ";
$sql .= "m.qty, w.whse, w.row, w.rack, w.level, o.employee ";
$sql .= "FROM material_data_in AS m LEFT JOIN raw_material AS r ON (m.mat_id = r.item_code) ";
$sql .= "LEFT JOIN uom_list AS u ON (u.uom_id = m.uom_id) ";
$sql .= "LEFT JOIN supplier AS s ON (s.supplier_id = m.supplier_id) ";
$sql .= "LEFT JOIN warehouse AS w ON (w.id = warehouse_id) ";
$sql .= "LEFT JOIN rm_receiver AS o ON (o.emp_id = m.received_by)";
$res = mysql_query($sql);

while($row_mat_list = mysql_fetch_assoc($res)){
$date_entry           = $row_mat_list['date_entry'];
$po_number            = $row_mat_list['po_number'];
//$unique_id            = $row_mat_list['unique_id'];
$kind                 = $row_mat_list['kind'];
$item_code            = $row_mat_list['item_code'];
$description          = $row_mat_list['sup_code'];
$uom                  = $row_mat_list['uom'];
$supplier             = $row_mat_list['supplier_name'];
$qty                  = $row_mat_list['qty'];
$qty                  = number_format($qty, 2);
$whse                 = $row_mat_list['whse'];
$row                  = $row_mat_list['row'];
$rack                 = $row_mat_list['rack'];
$level                = $row_mat_list['level'];
$received_by          = utf8_encode($row_mat_list['employee']);

echo "<tr>";
echo "<td>$date_entry</td>";
echo "<td>$po_number</td>";
echo "<td>$kind</td>";
echo "<td>$item_code</td>";
echo "<td>$description</td>";
echo "<td>$uom</td>";
echo "<td>$supplier</td>";
echo "<td>$qty</td>";
echo "<td>$whse</td>";
echo "<td>$row</td>";
echo "<td>$rack</td>";
echo "<td>$level</td>";
echo "<td>$received_by</td>";
echo "</tr>";
}

echo "<tr>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td id='totalHERE' style='color:red;border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "<td style='border:none;'></td>";
echo "</tr>";
?>
</table>
<table id=''>
</form>
<script language="javascript" type="text/javascript">
var totalRowDex = tf_Tag(tf_Id('mat_list'), "tr").length;
var inventProp = {
    rows_counter: true,
    loader: true,
    loader_text: "FilterING DaTa....",
    col_operation: {
        id: ["totalHERE"],
        col: [7],
        operation: ["sum"],
        write_method: ["innerHTML"],
        exclude_row: [totalRowDex],
        decimal_precision: [2]

    },
    rows_always_visible: [totalRowDex]
};
setFilterGrid("mat_list", inventProp);
</script>
</form>


now my problem is, how can I make the total qty has a comma every 3 digits. Because the Total = 80000000.00 how can I make it 80,000,000.00

I hope somebody can help me.

Thank you so much.