Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Problem viewing shift reports (http://www.go4expert.com/forums/viewing-shift-reports-t23988/)

newphpcoder 25Nov2010 10:52

Problem viewing shift reports
 
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 Code:

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 
"<table cellspacing='3' style='font-family: arial narrow; font-size: 12px; border-width: 2px 2px 2px 2px; border-style: solid;'>";
            echo 
"<tr><b> Date: &nbsp;  " $_POST['clt_shift_date'] . "</b></tr>";
        
            echo 
"<tr>";
            echo 
"<th class='tdclass'>Operation</th>";
            
$shift_ctr count($clt_shift);
            for(
$ctr 0$ctr $shift_ctr$ctr++)
                echo 
"<th colspan='2' class='tdclass'>" $clt_shift[$ctr] . "</th>";
                
            echo 
"</tr>";
            
            echo 
"<tr>";
            echo 
"<td class='tdclass'></td>";
            
$shift_ctr count($clt_shift);
            for(
$ctr 0$ctr $shift_ctr$ctr++)
                echo 
"<td class='tdclass'>Input</td><td class='tdclass'>Output</td>";
                
            echo 
"</tr>";
            
            
$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 
"<td class='tdclass'>&nbsp;</td>";
                            echo 
"<td class='tdclass'>&nbsp;</td>";
                            }
                        }
                    echo 
"</tr>";
                    echo 
"<tr>";
                    echo 
"<td class='tdclass'>" $opname "</td>";
                    
$tdctr 0;
                    }
                elseif(
$last_opname != $opname)
                    {
                    echo 
"<tr>";
                    echo 
"<td class='tdclass'>" $opname "</td>";
                    }
                
                
$last_opname $opname;
                
                for(
$ctr=0$ctr $shift_ctr$ctr++)
                    {
                        
                    if(
$row2["shift"] == $clt_shift[$ctr])
                        {
                        echo 
"<td class='tdclass'>" number_format($row2["inputqty"],2) . "</td>";
                        echo 
"<td class='tdclass'>" number_format($row2["outputqty"],2) . "</td>";
                        
$tdctr++;
                        
$ctr $shift_ctr+1;
                        }
                    elseif(
$ctr == $tdctr)
                        {
                        echo 
"<td class='tdclass'>&nbsp;</td>";
                        echo 
"<td class='tdclass'>&nbsp;</td>";
                        
$tdctr++;
                        }
                    }
                }
            echo 
"</table>";
            }
            
        } 

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


All times are GMT +5.5. The time now is 07:19.