Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem viewing shift reports

newphpcodernewphpcoder Member Posts: 21
Good day!

I have 2 kinds of shift and it is also the same they are only different in Forms. I copy the code for shift and i edit it, but i only edit the names of database,fields and tables, so I don't why the shift for 10-6 was not view or appear. Here is the code:

[PHP]
If($_POST["clt_shift_date"])
{


$clt_shift[] = '10-6';
$clt_shift[] = '6-2';
$clt_shift[] = '2-10';

$firstclt_shift_date = $_POST["clt_shift_date"];
$firstclt_shift_date = date("Y-m-d", strtotime('-1 day',strtotime($firstclt_shift_date)));

$query = "SELECT d.operation_name, SUM(d.input_qty) AS inputqty, d.input_unit, SUM(d.output_qty) AS outputqty, d.output_unit, d.shift FROM clt_traceability d, clt_transact t WHERE ((t.clt_date = '$firstclt_shift_date' AND d.shift = '10-6') || (t.clt_date = '" . $_POST["clt_shift_date"] . "' AND d.shift = '6-2') || (t.clt_date = '" . $_POST["clt_shift_date"] . "' AND d.shift = '2-10')) AND d.clt_transact_id = t.clt_transact_id GROUP BY d.operation_name, d.output_unit, d.input_unit, d.shift ORDER BY d.operation_name, FIELD(d.shift,'10-6','6-2','2-10')";
$result = mysql_query($query);

if($result)
{
echo ""; echo " Date:   " . $_POST['clt_shift_date'] . ""; echo ""; echo "Operation"; $shift_ctr = count($clt_shift); for($ctr = 0; $ctr < $shift_ctr; $ctr++) echo "" . $clt_shift[$ctr] . ""; echo ""; echo ""; echo ""; $shift_ctr = count($clt_shift); for($ctr = 0; $ctr < $shift_ctr; $ctr++) echo "InputOutput"; echo ""; $last_opname = ""; $tdctr = 0; while($row2 = mysql_fetch_array($result)) { $opname = $row2["operation_name"]; $i = strpos($opname," ",0); $opname = substr($opname,$i); if($last_opname != $opname && $last_opname != "") { if($tdctr < $shift_ctr) { for($tdctr=$tdctr; $tdctr < $shift_ctr; $tdctr++) { echo " "; echo " "; } } echo ""; echo ""; echo "" . $opname . ""; $tdctr = 0; } elseif($last_opname != $opname) { echo ""; echo "" . $opname . ""; } $last_opname = $opname; for($ctr=0; $ctr < $shift_ctr; $ctr++) { if($row2["shift"] == $clt_shift[$ctr]) { echo "" . number_format($row2["inputqty"],2) . ""; echo "" . number_format($row2["outputqty"],2) . ""; $tdctr++; $ctr = $shift_ctr+1; } elseif($ctr == $tdctr) { echo " "; echo " "; $tdctr++; } } } echo "
";
}

}
[/PHP]

Only the 6-2 and 2-10 data was appear.

Thank you
Sign In or Register to comment.