SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 42 of 42
  1. #26
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Attachments Pending Approval
    Hi,

    The display is correct also the computation of total.

    Is it possible that we can add also a total on the rightside per date

    for example

    Compound-----------2013-07-22-------
    Core Molding--C-R-SC-SP-SS-T-TI--Total
    P41------------2.92-3.57-2.33--3.39 12.21 and like the total below of compound the total on the right side should has a color backgournd also..


    Thank you so much

  2. #27
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Here ya go.
    PHP Code:
    <?php  
    ob_start
    ();  
    include 
    "connection.php";  
    /*  
    Assuming that $id is called by other means but   
    defined here for testing.  So instead of checking   
    IF $id is a particular number, we check that it is set   
    and query for specific week without adjustment in query  
    */  
    $id "29"

    //$id = $_POST['id'];  
    if(isset($id)){  
        
    /*  
        We are building an array of all information with a single query.  
        */  
        
    $Reports = array();      
       
    // $dates = array();   
       // $process_names = array();  
       // $reject_types = array();  
       // $compound_types = array();  
       // $rejects = array();  
       // $reject_total = array(); 
        
    $sql "SELECT   
        r.reject_date,   
        r.reject,   
        r.process_id,   
        r.reject_type,   
        r.compound_type,   
        p.process_name   
        FROM op_reject AS r   
        JOIN process_list AS p   
        ON (p.process_id = r.process_id)  
        WHERE WEEK(reject_date) = '
    $id'  
        ORDER BY r.reject_date, compound_type  ASC"
    ;   
        
    $res mysql_query($sql); 
        
    $k=0;              
        while(
    $row mysql_fetch_assoc($res)){                  
            
    $Reports[$k]['reject_date'] = $row['reject_date']; 
            
    $Reports[$k]['process_name'] = $row['process_name']; 
            
    $Reports[$k]['reject_type'] = $row['reject_type']; 
            
    $Reports[$k]['compound_type'] = $row['compound_type']; 
            
    $Reports[$k]['reject'] = $row['reject'];  
           
    $k++;  
        } 
         
        
    //| *************************************************** |\\ 
        //| Build functions to return specific values or arrays |\\ 
        //| *************************************************** |\\ 
         
        // Returns dates array \\ 
        
    function dates($array){ 
            
    $dates = array();     
            foreach(
    $array as $k => $v){ 
                
    $dates[] = $v['reject_date']; 
            } 
            
    $dates array_unique($dates); 
            
    sort($dates); 
            return 
    $dates;  
        } 
         
        
    // Returns process_names array \\ 
        
    function process_names($array){     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                
    $process_names[] = $v['process_name']; 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names); 
            return 
    $process_names;  
        } 
         
        
    //*****************************************//     
           // Returns number of columns by date \\ 
        //*****************************************//     
        
    function columns($array,$date){ 
            
    //process names     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $date){ 
                    
    $process_names[] = $v['process_name']; 
                } 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names);                              
            
    // get reject_types by process name 
            
    $reject_types = array(); 
            foreach(
    $process_names as $process_name){ 
                foreach(
    $array as $k => $v){ 
                    if (
    $v['reject_date'] == $date &&   
                        
    $v['process_name'] == $process_name){ 
                        
    $reject_types[$process_name][$v['reject_type']] = $v['reject_type']; 
                    }     
                } 
            }     
            
    //Convert reject_type to count         
            
    $counts = array(); 
            foreach(
    $reject_types as $reject_type){ 
                
    $counts[] = count($reject_type); 
            } 
            
    //return largest value 
            
    $max_count max($counts); 
            return 
    $max_count;   
        } 
        
    //*****************************************//     
         // END Returns number of columns by date \\ 
        //*****************************************//     
         
        // Returns compound_type array for process_name \\ 
        
    function compound_types($array,$process_name){     
            
    $compound_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name){ 
                    
    $compound_types[] = $v['compound_type']; 
                }     
            } 
            
    $compound_types array_unique($compound_types); 
            
    sort($compound_types); 
            return 
    $compound_types;  
        } 
         
        
    // Returns reject_type array for date and process_name \\ 
        
    function reject_types($array,$reject_date,$process_name){     
            
    $reject_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name){ 
                    
    $reject_types[] = $v['reject_type']; 
                }     
            } 
            
    $reject_types array_unique($reject_types); 
            
    sort($reject_types); 
            return 
    $reject_types;  
        } 
          
        
    // Returns reject amount for cell \\ 
        
    function searchresults($array,$reject_date,$process_name,$reject_type,$compound_type){ 
            
    $result ""
            
    $total=0;     
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == "{$reject_date}&&   
                    
    $v['process_name'] == "{$process_name}&& 
                    
    $v['reject_type'] == "{$reject_type}&& 
                    
    $v['compound_type'] == "{$compound_type}"){ 
                    
    $total += $v['reject']; 
                } 
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
        
    // Returns reject total based on $reject_date,$process_name,$reject_type \\ 
        
    function resulttotals($array,$reject_date,$process_name,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        }  
         
        
    // Returns compound total based on $reject_date,$process_name,$compound_type \\ 
        
    function compound_resulttotals($array,$reject_date,$process_name,$compound_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
    //echo "<pre>";  
    //print_r($Reports);  
    //echo "</pre>";  

    ////Build display data BEFORE output to browser////  
    $display "<table border=0 cellpadding=0 cellspacing=0 class=\"display\">  
            <thead>  
                <tr>  
                    <th>Compound</th>\r"
    ;  
                    
    //I'll keep your id identifier in place                  
                    
    $i=1
                    
    $dates dates($Reports);                  
                    foreach(
    $dates as $date){  
                        
    //We'll run our columns function in our date loop to get column count 
                        
    $cols columns($Reports,$date);  
                         
                        
    $display .= "<th id=col".$i." colspan=\"$cols\" class=\"border\">$date</th>\r"
                        
    $display .= "<th>&nbsp;</th>\r";  
                         
                        
    $i++; 
                    } 
                
    $display .= "</tr>  
                </thead>"
    ;       
                 
                    
    $process_names process_names($Reports);  
                    foreach(
    $process_names as $process_name){                  
                        
    $display .= "<tr>\r";      
                            
    $display .= "<td>$process_name</td>\r";     
                             
                        foreach(
    $dates as $date){       
                               
    $bor=0;                                
                            
    $reject_types reject_types($Reports,$date,$process_name); 
                            
    $reject_type_count count($reject_types); 
                            
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                            
    $cols columns($Reports,$date); 
                             
                            if (
    $type_for_date == "false"){ 
                                for(
    $c=0;$c<$cols;$c++){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>&nbsp;</td>\r";     
                                     
                                    
    $bor++; 
                                } 
                            }else{ 
                                
    $rt_running_count=0;
                                foreach(
    $reject_types as $reject_type){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>$reject_type</td>\r";  
                                     
                                    
    $bor++;
                                    
    $rt_running_count++;  
                                }
                                if (
    $rt_running_count==$reject_type_count){                             
                                    for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                        
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                        
    $display .= "<td$border>&nbsp;</td>\r";     
                                         
                                        
    $bor++; 
                                    }
                                } 
                            }
                        
    $display .= "<td class=\"border\">Total</td>\r";                            
                        }                       
                
    $display .= "</tr>\r"
                    
    $compound_types compound_types($Reports,$process_name);             
                            foreach(
    $compound_types as $compound_type){                  
                                
    $display .= "<tr>\r";      
                                    
    $display .= "<td>$compound_type</td>\r"
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                            
    $display .= "<td$border>&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{
                                    
                                        
    $ct_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" class=\"border\"" '');  
                                            
    $reject searchresults($Reports,$date,$process_name,$reject_type,$compound_type); 
                                            
    $reject = (!empty($reject) ? $reject "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td$border>$reject</td>\r"
                                                 
                                            
    $bor++;
                                            
    $ct_running_count++;                                     
                                            
                                            if (
    $ct_running_count==$reject_type_count){                         
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" class=\"border\"" ''); 
                                                           
                                                    
    $display .= "<td$border>&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        }
                                         
                                            
    $compoundTotal compound_resulttotals($Reports,$date,$process_name,$compound_type); 
                                            
    $compoundTotal = (!empty($compoundTotal) ? $compoundTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total border\">$compoundTotal</td>\r";  
                                    }                                                 
                                }                          
                
    $display .= "</tr>\r";                                                                                             
                            }  
                                       
               
    //---total rejects per process and per reject type---// 
                            
    $display .= "<tr>\r";  
                            
    $display .= "<td class=\"total\">Total</td>\r";                        
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" border" '');  
                                                                  
                                            
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{ 
                                        
    $rt_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" border" '');   
                                            
    $rejectTotal resulttotals($Reports,$date,$process_name,$reject_type); 
                                            
    $rejectTotal = (!empty($rejectTotal) ? $rejectTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total$border\">$rejectTotal</td>\r"
                                                 
                                            
    $bor++;
                                            
    $rt_running_count++;                                      
                                            
                                            if (
    $rt_running_count==$reject_type_count){                             
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" border" ''); 
                                                                   
                                                    
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        } 
                                    }        
                                    
    $display .= "<th class=\"border\">&nbsp;</th>\r";                                                  
                                }   
                            
    $display .= "</tr>\r"
                            }                 
        
    $display .= "</table>\r"
    }


            if(isset(
    $display)){ 
                echo 
    "$display"
            } 
    ?>

  3. #28
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you... I will try it later and i will update you.


    Thank you

  4. #29
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I just added align="right" to those numbers so it looks a little better.
    PHP Code:
    <?php  
    ob_start
    ();  
    include 
    "connection.php";  
    /*  
    Assuming that $id is called by other means but   
    defined here for testing.  So instead of checking   
    IF $id is a particular number, we check that it is set   
    and query for specific week without adjustment in query  
    */  
    $id "29"

    //$id = $_POST['id'];  
    if(isset($id)){  
        
    /*  
        We are building an array of all information with a single query.  
        */  
        
    $Reports = array();      
       
    // $dates = array();   
       // $process_names = array();  
       // $reject_types = array();  
       // $compound_types = array();  
       // $rejects = array();  
       // $reject_total = array(); 
        
    $sql "SELECT   
        r.reject_date,   
        r.reject,   
        r.process_id,   
        r.reject_type,   
        r.compound_type,   
        p.process_name   
        FROM op_reject AS r   
        JOIN process_list AS p   
        ON (p.process_id = r.process_id)  
        WHERE WEEK(reject_date) = '
    $id'  
        ORDER BY r.reject_date, compound_type  ASC"
    ;   
        
    $res mysql_query($sql); 
        
    $k=0;              
        while(
    $row mysql_fetch_assoc($res)){                  
            
    $Reports[$k]['reject_date'] = $row['reject_date']; 
            
    $Reports[$k]['process_name'] = $row['process_name']; 
            
    $Reports[$k]['reject_type'] = $row['reject_type']; 
            
    $Reports[$k]['compound_type'] = $row['compound_type']; 
            
    $Reports[$k]['reject'] = $row['reject'];  
           
    $k++;  
        } 
         
        
    //| *************************************************** |\\ 
        //| Build functions to return specific values or arrays |\\ 
        //| *************************************************** |\\ 
         
        // Returns dates array \\ 
        
    function dates($array){ 
            
    $dates = array();     
            foreach(
    $array as $k => $v){ 
                
    $dates[] = $v['reject_date']; 
            } 
            
    $dates array_unique($dates); 
            
    sort($dates); 
            return 
    $dates;  
        } 
         
        
    // Returns process_names array \\ 
        
    function process_names($array){     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                
    $process_names[] = $v['process_name']; 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names); 
            return 
    $process_names;  
        } 
         
        
    //*****************************************//     
           // Returns number of columns by date \\ 
        //*****************************************//     
        
    function columns($array,$date){ 
            
    //process names     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $date){ 
                    
    $process_names[] = $v['process_name']; 
                } 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names);                              
            
    // get reject_types by process name 
            
    $reject_types = array(); 
            foreach(
    $process_names as $process_name){ 
                foreach(
    $array as $k => $v){ 
                    if (
    $v['reject_date'] == $date &&   
                        
    $v['process_name'] == $process_name){ 
                        
    $reject_types[$process_name][$v['reject_type']] = $v['reject_type']; 
                    }     
                } 
            }     
            
    //Convert reject_type to count         
            
    $counts = array(); 
            foreach(
    $reject_types as $reject_type){ 
                
    $counts[] = count($reject_type); 
            } 
            
    //return largest value 
            
    $max_count max($counts); 
            return 
    $max_count;   
        } 
        
    //*****************************************//     
         // END Returns number of columns by date \\ 
        //*****************************************//     
         
        // Returns compound_type array for process_name \\ 
        
    function compound_types($array,$process_name){     
            
    $compound_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name){ 
                    
    $compound_types[] = $v['compound_type']; 
                }     
            } 
            
    $compound_types array_unique($compound_types); 
            
    sort($compound_types); 
            return 
    $compound_types;  
        } 
         
        
    // Returns reject_type array for date and process_name \\ 
        
    function reject_types($array,$reject_date,$process_name){     
            
    $reject_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name){ 
                    
    $reject_types[] = $v['reject_type']; 
                }     
            } 
            
    $reject_types array_unique($reject_types); 
            
    sort($reject_types); 
            return 
    $reject_types;  
        } 
          
        
    // Returns reject amount for cell \\ 
        
    function searchresults($array,$reject_date,$process_name,$reject_type,$compound_type){ 
            
    $result ""
            
    $total=0;     
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == "{$reject_date}&&   
                    
    $v['process_name'] == "{$process_name}&& 
                    
    $v['reject_type'] == "{$reject_type}&& 
                    
    $v['compound_type'] == "{$compound_type}"){ 
                    
    $total += $v['reject']; 
                } 
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
        
    // Returns reject total based on $reject_date,$process_name,$reject_type \\ 
        
    function resulttotals($array,$reject_date,$process_name,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        }  
         
        
    // Returns compound total based on $reject_date,$process_name,$compound_type \\ 
        
    function compound_resulttotals($array,$reject_date,$process_name,$compound_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
    //echo "<pre>";  
    //print_r($Reports);  
    //echo "</pre>";  

    ////Build display data BEFORE output to browser////  
    $display "<table border=0 cellpadding=0 cellspacing=0 class=\"display\">  
            <thead>  
                <tr>  
                    <th>Compound</th>\r"
    ;  
                    
    //I'll keep your id identifier in place                  
                    
    $i=1
                    
    $dates dates($Reports);                  
                    foreach(
    $dates as $date){  
                        
    //We'll run our columns function in our date loop to get column count 
                        
    $cols columns($Reports,$date);  
                         
                        
    $display .= "<th id=col".$i." colspan=\"$cols\" class=\"border\">$date</th>\r"
                        
    $display .= "<th>&nbsp;</th>\r";  
                         
                        
    $i++; 
                    } 
                
    $display .= "</tr>  
                </thead>"
    ;       
                 
                    
    $process_names process_names($Reports);  
                    foreach(
    $process_names as $process_name){                  
                        
    $display .= "<tr>\r";      
                            
    $display .= "<td>$process_name</td>\r";     
                             
                        foreach(
    $dates as $date){       
                               
    $bor=0;                                
                            
    $reject_types reject_types($Reports,$date,$process_name); 
                            
    $reject_type_count count($reject_types); 
                            
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                            
    $cols columns($Reports,$date); 
                             
                            if (
    $type_for_date == "false"){ 
                                for(
    $c=0;$c<$cols;$c++){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>&nbsp;</td>\r";     
                                     
                                    
    $bor++; 
                                } 
                            }else{ 
                                
    $rt_running_count=0;
                                foreach(
    $reject_types as $reject_type){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>$reject_type</td>\r";  
                                     
                                    
    $bor++;
                                    
    $rt_running_count++;  
                                }
                                if (
    $rt_running_count==$reject_type_count){                             
                                    for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                        
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                        
    $display .= "<td$border>&nbsp;</td>\r";     
                                         
                                        
    $bor++; 
                                    }
                                } 
                            }
                        
    $display .= "<td class=\"border\">Total</td>\r";                            
                        }                       
                
    $display .= "</tr>\r"
                    
    $compound_types compound_types($Reports,$process_name);             
                            foreach(
    $compound_types as $compound_type){                  
                                
    $display .= "<tr>\r";      
                                    
    $display .= "<td>$compound_type</td>\r"
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                            
    $display .= "<td$border>&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{
                                    
                                        
    $ct_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" class=\"border\"" '');  
                                            
    $reject searchresults($Reports,$date,$process_name,$reject_type,$compound_type); 
                                            
    $reject = (!empty($reject) ? $reject "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td$border align=\"right\">$reject</td>\r"
                                                 
                                            
    $bor++;
                                            
    $ct_running_count++;                                     
                                            
                                            if (
    $ct_running_count==$reject_type_count){                         
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" class=\"border\"" ''); 
                                                           
                                                    
    $display .= "<td$border>&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        }
                                         
                                            
    $compoundTotal compound_resulttotals($Reports,$date,$process_name,$compound_type); 
                                            
    $compoundTotal = (!empty($compoundTotal) ? $compoundTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total border\" align=\"right\">$compoundTotal</td>\r";  
                                    }                                                 
                                }                          
                
    $display .= "</tr>\r";                                                                                             
                            }  
                                       
               
    //---total rejects per process and per reject type---// 
                            
    $display .= "<tr>\r";  
                            
    $display .= "<td class=\"total\">Total</td>\r";                        
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" border" '');  
                                                                  
                                            
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{ 
                                        
    $rt_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" border" '');   
                                            
    $rejectTotal resulttotals($Reports,$date,$process_name,$reject_type); 
                                            
    $rejectTotal = (!empty($rejectTotal) ? $rejectTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total$border\" align=\"right\">$rejectTotal</td>\r"
                                                 
                                            
    $bor++;
                                            
    $rt_running_count++;                                      
                                            
                                            if (
    $rt_running_count==$reject_type_count){                             
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" border" ''); 
                                                                   
                                                    
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        } 
                                    }        
                                    
    $display .= "<th class=\"border\">&nbsp;</th>\r";                                                  
                                }   
                            
    $display .= "</tr>\r"
                            }                 
        
    $display .= "</table>\r"
    }


            if(isset(
    $display)){ 
                echo 
    "$display"
            } 
    ?>

  5. #30
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    I just added align="right" to those numbers so it looks a little better.
    PHP Code:
    <?php  
    ob_start
    ();  
    include 
    "connection.php";  
    /*  
    Assuming that $id is called by other means but   
    defined here for testing.  So instead of checking   
    IF $id is a particular number, we check that it is set   
    and query for specific week without adjustment in query  
    */  
    $id "29"

    //$id = $_POST['id'];  
    if(isset($id)){  
        
    /*  
        We are building an array of all information with a single query.  
        */  
        
    $Reports = array();      
       
    // $dates = array();   
       // $process_names = array();  
       // $reject_types = array();  
       // $compound_types = array();  
       // $rejects = array();  
       // $reject_total = array(); 
        
    $sql "SELECT   
        r.reject_date,   
        r.reject,   
        r.process_id,   
        r.reject_type,   
        r.compound_type,   
        p.process_name   
        FROM op_reject AS r   
        JOIN process_list AS p   
        ON (p.process_id = r.process_id)  
        WHERE WEEK(reject_date) = '
    $id'  
        ORDER BY r.reject_date, compound_type  ASC"
    ;   
        
    $res mysql_query($sql); 
        
    $k=0;              
        while(
    $row mysql_fetch_assoc($res)){                  
            
    $Reports[$k]['reject_date'] = $row['reject_date']; 
            
    $Reports[$k]['process_name'] = $row['process_name']; 
            
    $Reports[$k]['reject_type'] = $row['reject_type']; 
            
    $Reports[$k]['compound_type'] = $row['compound_type']; 
            
    $Reports[$k]['reject'] = $row['reject'];  
           
    $k++;  
        } 
         
        
    //| *************************************************** |\\ 
        //| Build functions to return specific values or arrays |\\ 
        //| *************************************************** |\\ 
         
        // Returns dates array \\ 
        
    function dates($array){ 
            
    $dates = array();     
            foreach(
    $array as $k => $v){ 
                
    $dates[] = $v['reject_date']; 
            } 
            
    $dates array_unique($dates); 
            
    sort($dates); 
            return 
    $dates;  
        } 
         
        
    // Returns process_names array \\ 
        
    function process_names($array){     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                
    $process_names[] = $v['process_name']; 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names); 
            return 
    $process_names;  
        } 
         
        
    //*****************************************//     
           // Returns number of columns by date \\ 
        //*****************************************//     
        
    function columns($array,$date){ 
            
    //process names     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $date){ 
                    
    $process_names[] = $v['process_name']; 
                } 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names);                              
            
    // get reject_types by process name 
            
    $reject_types = array(); 
            foreach(
    $process_names as $process_name){ 
                foreach(
    $array as $k => $v){ 
                    if (
    $v['reject_date'] == $date &&   
                        
    $v['process_name'] == $process_name){ 
                        
    $reject_types[$process_name][$v['reject_type']] = $v['reject_type']; 
                    }     
                } 
            }     
            
    //Convert reject_type to count         
            
    $counts = array(); 
            foreach(
    $reject_types as $reject_type){ 
                
    $counts[] = count($reject_type); 
            } 
            
    //return largest value 
            
    $max_count max($counts); 
            return 
    $max_count;   
        } 
        
    //*****************************************//     
         // END Returns number of columns by date \\ 
        //*****************************************//     
         
        // Returns compound_type array for process_name \\ 
        
    function compound_types($array,$process_name){     
            
    $compound_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name){ 
                    
    $compound_types[] = $v['compound_type']; 
                }     
            } 
            
    $compound_types array_unique($compound_types); 
            
    sort($compound_types); 
            return 
    $compound_types;  
        } 
         
        
    // Returns reject_type array for date and process_name \\ 
        
    function reject_types($array,$reject_date,$process_name){     
            
    $reject_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name){ 
                    
    $reject_types[] = $v['reject_type']; 
                }     
            } 
            
    $reject_types array_unique($reject_types); 
            
    sort($reject_types); 
            return 
    $reject_types;  
        } 
          
        
    // Returns reject amount for cell \\ 
        
    function searchresults($array,$reject_date,$process_name,$reject_type,$compound_type){ 
            
    $result ""
            
    $total=0;     
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == "{$reject_date}&&   
                    
    $v['process_name'] == "{$process_name}&& 
                    
    $v['reject_type'] == "{$reject_type}&& 
                    
    $v['compound_type'] == "{$compound_type}"){ 
                    
    $total += $v['reject']; 
                } 
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
        
    // Returns reject total based on $reject_date,$process_name,$reject_type \\ 
        
    function resulttotals($array,$reject_date,$process_name,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        }  
         
        
    // Returns compound total based on $reject_date,$process_name,$compound_type \\ 
        
    function compound_resulttotals($array,$reject_date,$process_name,$compound_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
    //echo "<pre>";  
    //print_r($Reports);  
    //echo "</pre>";  

    ////Build display data BEFORE output to browser////  
    $display "<table border=0 cellpadding=0 cellspacing=0 class=\"display\">  
            <thead>  
                <tr>  
                    <th>Compound</th>\r"
    ;  
                    
    //I'll keep your id identifier in place                  
                    
    $i=1
                    
    $dates dates($Reports);                  
                    foreach(
    $dates as $date){  
                        
    //We'll run our columns function in our date loop to get column count 
                        
    $cols columns($Reports,$date);  
                         
                        
    $display .= "<th id=col".$i." colspan=\"$cols\" class=\"border\">$date</th>\r"
                        
    $display .= "<th>*</th>\r";  
                         
                        
    $i++; 
                    } 
                
    $display .= "</tr>  
                </thead>"
    ;       
                 
                    
    $process_names process_names($Reports);  
                    foreach(
    $process_names as $process_name){                  
                        
    $display .= "<tr>\r";      
                            
    $display .= "<td>$process_name</td>\r";     
                             
                        foreach(
    $dates as $date){       
                               
    $bor=0;                                
                            
    $reject_types reject_types($Reports,$date,$process_name); 
                            
    $reject_type_count count($reject_types); 
                            
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                            
    $cols columns($Reports,$date); 
                             
                            if (
    $type_for_date == "false"){ 
                                for(
    $c=0;$c<$cols;$c++){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>*</td>\r";     
                                     
                                    
    $bor++; 
                                } 
                            }else{ 
                                
    $rt_running_count=0;
                                foreach(
    $reject_types as $reject_type){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>$reject_type</td>\r";  
                                     
                                    
    $bor++;
                                    
    $rt_running_count++;  
                                }
                                if (
    $rt_running_count==$reject_type_count){                             
                                    for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                        
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                        
    $display .= "<td$border>*</td>\r";     
                                         
                                        
    $bor++; 
                                    }
                                } 
                            }
                        
    $display .= "<td class=\"border\">Total</td>\r";                            
                        }                       
                
    $display .= "</tr>\r"
                    
    $compound_types compound_types($Reports,$process_name);             
                            foreach(
    $compound_types as $compound_type){                  
                                
    $display .= "<tr>\r";      
                                    
    $display .= "<td>$compound_type</td>\r"
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                            
    $display .= "<td$border>*</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{
                                    
                                        
    $ct_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" class=\"border\"" '');  
                                            
    $reject searchresults($Reports,$date,$process_name,$reject_type,$compound_type); 
                                            
    $reject = (!empty($reject) ? $reject "*"); 
                                                                                 
                                            
    $display .= "<td$border align=\"right\">$reject</td>\r"
                                                 
                                            
    $bor++;
                                            
    $ct_running_count++;                                     
                                            
                                            if (
    $ct_running_count==$reject_type_count){                         
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" class=\"border\"" ''); 
                                                           
                                                    
    $display .= "<td$border>*</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        }
                                         
                                            
    $compoundTotal compound_resulttotals($Reports,$date,$process_name,$compound_type); 
                                            
    $compoundTotal = (!empty($compoundTotal) ? $compoundTotal "*"); 
                                                                                 
                                            
    $display .= "<td class=\"total border\" align=\"right\">$compoundTotal</td>\r";  
                                    }                                                 
                                }                          
                
    $display .= "</tr>\r";                                                                                             
                            }  
                                       
               
    //---total rejects per process and per reject type---// 
                            
    $display .= "<tr>\r";  
                            
    $display .= "<td class=\"total\">Total</td>\r";                        
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" border" '');  
                                                                  
                                            
    $display .= "<td class=\"total$border\">*</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{ 
                                        
    $rt_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" border" '');   
                                            
    $rejectTotal resulttotals($Reports,$date,$process_name,$reject_type); 
                                            
    $rejectTotal = (!empty($rejectTotal) ? $rejectTotal "*"); 
                                                                                 
                                            
    $display .= "<td class=\"total$border\" align=\"right\">$rejectTotal</td>\r"
                                                 
                                            
    $bor++;
                                            
    $rt_running_count++;                                      
                                            
                                            if (
    $rt_running_count==$reject_type_count){                             
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" border" ''); 
                                                                   
                                                    
    $display .= "<td class=\"total$border\">*</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        } 
                                    }        
                                    
    $display .= "<th class=\"border\">*</th>\r";                                                  
                                }   
                            
    $display .= "</tr>\r"
                            }                 
        
    $display .= "</table>\r"
    }


            if(isset(
    $display)){ 
                echo 
    "$display"
            } 
    ?>
    Thank you so much

  6. #31
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Is it possible that the all list of reject_acro from reject_list table per process will be displayed per date even it has no reject.

    Thank you.

  7. #32
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Something like this? Basically we use the same functions that gets the totals by date and we remove the date condition. I left some old code in this page so I looks a little butchered.
    PHP Code:
    <?php  
    ob_start
    ();  
    include 
    "connection.php";  
    /*  
    Assuming that $id is called by other means but   
    defined here for testing.  So instead of checking   
    IF $id is a particular number, we check that it is set   
    and query for specific week without adjustment in query  
    */  
    $id "29"

    //$id = $_POST['id'];  
    if(isset($id)){  
        
    /*  
        We are building an array of all information with a single query.  
        */  
        
    $Reports = array();      
       
    // $dates = array();   
       // $process_names = array();  
       // $reject_types = array();  
       // $compound_types = array();  
       // $rejects = array();  
       // $reject_total = array(); 
        
    $sql "SELECT   
        r.reject_date,   
        r.reject,   
        r.process_id,   
        r.reject_type,   
        r.compound_type,   
        p.process_name   
        FROM op_reject AS r   
        JOIN process_list AS p   
        ON (p.process_id = r.process_id)  
        WHERE WEEK(reject_date) = '
    $id'  
        ORDER BY r.reject_date, compound_type  ASC"
    ;   
        
    $res mysql_query($sql); 
        
    $k=0;              
        while(
    $row mysql_fetch_assoc($res)){                  
            
    $Reports[$k]['reject_date'] = $row['reject_date']; 
            
    $Reports[$k]['process_name'] = $row['process_name']; 
            
    $Reports[$k]['reject_type'] = $row['reject_type']; 
            
    $Reports[$k]['compound_type'] = $row['compound_type']; 
            
    $Reports[$k]['reject'] = $row['reject'];  
           
    $k++;  
        } 
         
        
    //| *************************************************** |\\ 
        //| Build functions to return specific values or arrays |\\ 
        //| *************************************************** |\\ 
         
        // Returns dates array \\ 
        
    function dates($array){ 
            
    $dates = array();     
            foreach(
    $array as $k => $v){ 
                
    $dates[] = $v['reject_date']; 
            } 
            
    $dates array_unique($dates); 
            
    sort($dates); 
            return 
    $dates;  
        } 
         
        
    // Returns process_names array \\ 
        
    function process_names($array){     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                
    $process_names[] = $v['process_name']; 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names); 
            return 
    $process_names;  
        } 
        
         
        
    //*****************************************//     
           // Returns number of columns by date \\ 
        //*****************************************// 
        /*    
        function columns($array,$date){ 
            //process names     
            $process_names = array(); 
            foreach($array as $k => $v){ 
                if ($v['reject_date'] == $date){ 
                    $process_names[] = $v['process_name']; 
                } 
            } 
            $process_names = array_unique($process_names); 
            sort($process_names);                              
            // get reject_types by process name 
            $reject_types = array(); 
            foreach($process_names as $process_name){ 
                foreach($array as $k => $v){ 
                    if ($v['reject_date'] == $date &&   
                        $v['process_name'] == $process_name){ 
                        $reject_types[$process_name][$v['reject_type']] = $v['reject_type']; 
                    }     
                } 
            }     
            //Convert reject_type to count         
            $counts = array(); 
            foreach($reject_types as $reject_type){ 
                $counts[] = count($reject_type); 
            } 
            //return largest value 
            $max_count = max($counts); 
            return $max_count;   
        } 
         */
        //*****************************************//     
         // END Returns number of columns by date \\ 
        //*****************************************//     
       
           
        //*****************************************//     
           // Returns number of columns by date \\ 
        //*****************************************//     
        
    function columns($array,$date){ 
            
    //process names     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
               
    // if ($v['reject_date'] == $date){ 
                    
    $process_names[] = $v['process_name']; 
               
    // } 
            

            
    $process_names array_unique($process_names); 
            
    sort($process_names);                              
            
    // get reject_types by process name 
            
    $reject_types = array(); 
            foreach(
    $process_names as $process_name){ 
                foreach(
    $array as $k => $v){ 
                   
    // if ($v['process_name'] == $process_name){ 
                        
    $reject_types[$process_name][$v['reject_type']] = $v['reject_type']; 
                   
    // }     
                

            }     
            
    //Convert reject_type to count         
            
    $counts = array(); 
            foreach(
    $reject_types as $reject_type){ 
                
    $counts[] = count($reject_type); 
            } 
            
    //return largest value 
            
    $max_count max($counts); 
            return 
    $max_count;   
        } 
        
    //*****************************************//     
         // END Returns number of columns by date \\ 
        //*****************************************//     
        
         
        // Returns compound_type array for process_name \\ 
        
    function compound_types($array,$process_name){     
            
    $compound_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name){ 
                    
    $compound_types[] = $v['compound_type']; 
                }     
            } 
            
    $compound_types array_unique($compound_types); 
            
    sort($compound_types); 
            return 
    $compound_types;  
        } 
         
        
    // Returns reject_type array for date and process_name \\
        /* 
        function reject_types($array,$reject_date,$process_name){     
            $reject_types = array(); 
            foreach($array as $k => $v){ 
                if ($v['reject_date'] == $reject_date &&   
                    $v['process_name'] == $process_name){ 
                    $reject_types[] = $v['reject_type']; 
                }     
            } 
            $reject_types = array_unique($reject_types); 
            sort($reject_types); 
            return $reject_types;  
        } 
        */
        
         // Returns reject_type array for process_name \\ NEW 
        
    function reject_types($array,$reject_date,$process_name){     
            
    $reject_types = array(); 
            foreach(
    $array as $k => $v){ 
                
    //if ($v['process_name'] == $process_name){ 
                    
    $reject_types[] = $v['reject_type']; 
               
    // }     
            

            
    $reject_types array_unique($reject_types); 
            
    sort($reject_types); 
            return 
    $reject_types;  
        } 
          
        
    // Returns reject amount for cell \\ 
        
    function searchresults($array,$reject_date,$process_name,$reject_type,$compound_type){ 
            
    $result ""
            
    $total=0;     
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == "{$reject_date}&&   
                    
    $v['process_name'] == "{$process_name}&& 
                    
    $v['reject_type'] == "{$reject_type}&& 
                    
    $v['compound_type'] == "{$compound_type}"){ 
                    
    $total += $v['reject']; 
                } 
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
        
    // Returns reject total based on $reject_date,$process_name,$reject_type \\ 
        
    function resulttotals($array,$reject_date,$process_name,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        }  
         
        
    // Returns compound total based on $reject_date,$process_name,$compound_type \\ 
        
    function compound_resulttotals($array,$reject_date,$process_name,$compound_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
        
         
         
    //NEW
        // Returns compound total based on $process_name,$compound_type \\ 
        
    function compound_resulttotalsALL($array,$process_name,$compound_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
    //echo "<pre>";  
    //print_r($Reports);  
    //echo "</pre>";  

    ////Build display data BEFORE output to browser////  
    $display "<table border=0 cellpadding=0 cellspacing=0 class=\"display\">  
            <thead>  
                <tr>  
                    <th>Compound</th>\r"
    ;  
                    
    //I'll keep your id identifier in place                  
                    
    $i=1
                    
    $dates dates($Reports);                  
                    foreach(
    $dates as $date){  
                        
    //We'll run our columns function in our date loop to get column count 
                        
    $cols columns($Reports,$date);  
                         
                        
    $display .= "<th id=col".$i." colspan=\"$cols\" class=\"border\">$date</th>\r"
                        
    $display .= "<th>&nbsp;</th>\r";  
                         
                        
    $i++; 
                    }
                         
    //NEW
                        
    $display .= "<th class=\"border\">TOTAL</th>\r";   
                
    $display .= "</tr>  
                </thead>"
    ;       
                 
                    
    $process_names process_names($Reports);  
                    foreach(
    $process_names as $process_name){                  
                        
    $display .= "<tr>\r";      
                            
    $display .= "<td>$process_name</td>\r";     
                             
                        foreach(
    $dates as $date){       
                               
    $bor=0;                                
                            
    $reject_types reject_types($Reports,$date,$process_name); 
                            
    $reject_type_count count($reject_types); 
                            
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                            
    $cols columns($Reports,$date); 
                             
                            if (
    $type_for_date == "false"){ 
                                for(
    $c=0;$c<$cols;$c++){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>&nbsp;</td>\r";     
                                     
                                    
    $bor++; 
                                } 
                            }else{ 
                                
    $rt_running_count=0;
                                foreach(
    $reject_types as $reject_type){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>$reject_type</td>\r";  
                                     
                                    
    $bor++;
                                    
    $rt_running_count++;  
                                }
                                if (
    $rt_running_count==$reject_type_count){                             
                                    for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                        
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                        
    $display .= "<td$border>&nbsp;</td>\r";     
                                         
                                        
    $bor++; 
                                    }
                                } 
                            }
                        
    $display .= "<td class=\"border\">Total</td>\r";                            
                        }
                    
    $display .= "<th class=\"border\">WEEK</th>\r";                        
                
    $display .= "</tr>\r"
                    
    $compound_types compound_types($Reports,$process_name);             
                            foreach(
    $compound_types as $compound_type){                  
                                
    $display .= "<tr>\r";      
                                    
    $display .= "<td>$compound_type</td>\r"
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                            
    $display .= "<td$border>&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{
                                    
                                        
    $ct_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" class=\"border\"" '');  
                                            
    $reject searchresults($Reports,$date,$process_name,$reject_type,$compound_type); 
                                            
    $reject = (!empty($reject) ? $reject "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td$border align=\"right\">$reject</td>\r"
                                                 
                                            
    $bor++;
                                            
    $ct_running_count++;                                     
                                            
                                            if (
    $ct_running_count==$reject_type_count){                         
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" class=\"border\"" ''); 
                                                           
                                                    
    $display .= "<td$border>&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        }
                                         
                                            
    $compoundTotal compound_resulttotals($Reports,$date,$process_name,$compound_type); 
                                            
    $compoundTotal = (!empty($compoundTotal) ? $compoundTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total border\" align=\"right\">$compoundTotal</td>\r";  
                                    }                                                 
                                }
                                            
    $compoundTotalALL compound_resulttotalsALL($Reports,$process_name,$compound_type); 
                                            
    $compoundTotalALL = (!empty($compoundTotalALL) ? $compoundTotalALL "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total border\" align=\"right\">$compoundTotalALL</td>\r";                           
                
    $display .= "</tr>\r";                                                                                             
                            }  
                                       
               
    //---total rejects per process and per reject type---// 
                            
    $display .= "<tr>\r";  
                            
    $display .= "<td class=\"total\">Total</td>\r";                        
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" border" '');  
                                                                  
                                            
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{ 
                                        
    $rt_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" border" '');   
                                            
    $rejectTotal resulttotals($Reports,$date,$process_name,$reject_type); 
                                            
    $rejectTotal = (!empty($rejectTotal) ? $rejectTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total$border\" align=\"right\">$rejectTotal</td>\r"
                                                 
                                            
    $bor++;
                                            
    $rt_running_count++;                                      
                                            
                                            if (
    $rt_running_count==$reject_type_count){                             
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" border" ''); 
                                                                   
                                                    
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        } 
                                    }        
                                    
    $display .= "<th class=\"border\">&nbsp;</th>\r";                                                  
                                }
                                
    //NEW
                        
    $display .= "<th class=\"border\">TOTAL</th>\r";      
                            
    $display .= "</tr>\r"
                            }                 
        
    $display .= "</table>\r"
    }


            if(isset(
    $display)){ 
                echo 
    "$display"
            } 
    ?>

  8. #33
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Drummin,


    Thank you for helping me on my problem in displaying of rejects report.
    I need your help again if it is possible to display all the list of rejects acro on the header even it has no rejects, to be the layout inline. and also We need to add additional column after of the last date like this:

    the new layout should be:

    Compound ------2013-07-22-------2013-07-23--------2013-07-24-----2013-07-25----so on-------Week 29--
    Compound Mixing ----list of all reject acro---------------------------------------------------------list of reject acro
    P28-------------per process-----------------------------------------------------------------------total per reject acro
    P35
    P41
    Total
    Final Mix----list of all reject acro
    P28-------------per process---
    P35
    P41
    P45
    Total
    Extrusion----list of all reject acro
    P28-------------per process---
    P35
    P41
    P45
    P47
    Half Shell ------2013-07-22-------2013-07-23--------2013-07-24-----2013-07-25----so on-------Week 29
    Forming ----list of all reject acro----------------------------------------------------------------list of reject acro
    P28-------------per process--------------------------------------------------------------------total per reject acro
    P35
    P41
    Total
    Deflashing----list of all reject acro
    P28-------------per process---
    P35
    P41
    P45
    Total
    HS/BD----list of all reject acro
    P28-------------per process---
    P35
    P41
    P45
    P47
    Core ------2013-07-22-------2013-07-23--------2013-07-24-----2013-07-25----so on-------Week 29
    Core Molding ----list of all reject acro---------------------------------------------------------list of reject acro
    P28-------------per process------------------------------------------------------------------total per reject acro
    P35
    P41
    Total
    Core Buffing----list of all reject acro
    P28-------------per process---
    P35
    P41
    P45
    Total
    Core Solution----list of all reject acro
    P28-------------per process---
    P35
    P41
    P45
    P47

    I hope you can help on this and I also tried my best to do it. i will inform you on the progress if i made it.


    Thank you for helping me. I appreciate it.

    I also attached the output of new code you given.
    Attached Images Attached Images

  9. #34
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much for your help

  10. #35
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Doesn't my last version do what you're asking, with totals of each compound in far right column for the week.
    Sample134.jpg

  11. #36
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    The total per date that you add is correct.

    The week total should also per reject type.

    Look at my thread #33

    Thank you so much Drummin

  12. #37
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Correct me if I'm wrong but reject_types are listed in vertical columns for each week and so there is no point of reference to display in the right column. We show totals under each of these columns for reject_type. The compound process type P28 etc. is listed in each row and so those totals are show in the far right column.

  13. #38
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Drummin View Post
    Correct me if I'm wrong but reject_types are listed in vertical columns for each week and so there is no point of reference to display in the right column. We show totals under each of these columns for reject_type. The compound process type P28 etc. is listed in each row and so those totals are show in the far right column.
    reject type or reject acro are the S-SC-SP-SH and so on and compound are P28, P35, P41 etc.. We need to total or sum all rejects per reject acro and compound for that week.


    for example SUM all SC rejects of P28.

    SuM all rejects per reject acro per compound

    We just summarize or summarize the daily to week.

    Thank you so much

  14. #39
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    So the WEEK TOTALS area is not a single column but a group of columns like shown for each week and the totals for S-SC-SP-SH etc for the week should be shown in each corresponding column, correct? Otherwise there is no reference to for example reject acro "SC" in the right column.

  15. #40
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sample:
    -----------------2013-07-22-2013-07-23--2013-07-24--2013-07-25-----2013-07-26---2013-07-27----2013-07-28------Week 29
    Core Molding--BS-C-total--SP-SH-total--TH--T-total--WS--SH--total--BS--C--total--SP--SH-total---T--TH--SS-total----BS---C--SP--SH---TH--T--WS--SS
    P28------------ 1---2-3-----4---5----9-----6----7-13----8----9----17----10--11-21----12--13--25----14--15-------29------11---13-16--18----21--21--8------

    also the reject acro that has no reject will also displayed on the total weeks list
    I hope this sample can help you to figured out.


    Thank you so much

  16. #41
    SitePoint Evangelist bronze trophy
    Join Date
    Feb 2013
    Posts
    499
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Well newphpcoder, I must say it's been fun, but I'll need end the "fun" here. This version should show totals by compound and type in the right columns. Good luck with your project.
    PHP Code:
    <?php  
    ob_start
    ();  
    include 
    "connection.php";  
    /*  
    Assuming that $id is called by other means but   
    defined here for testing.  So instead of checking   
    IF $id is a particular number, we check that it is set   
    and query for specific week without adjustment in query  
    */  
    $id "29"

    //$id = $_POST['id'];  
    if(isset($id)){  
        
    /*  
        We are building an array of all information with a single query.  
        */  
        
    $Reports = array(); 
        
    $sql "SELECT   
        r.reject_date,   
        r.reject,   
        r.process_id,   
        r.reject_type,   
        r.compound_type,   
        p.process_name   
        FROM op_reject AS r   
        JOIN process_list AS p   
        ON (p.process_id = r.process_id)  
        WHERE WEEK(reject_date) = '
    $id'  
        ORDER BY r.reject_date, compound_type  ASC"
    ;   
        
    $res mysql_query($sql); 
        
    $k=0;              
        while(
    $row mysql_fetch_assoc($res)){                  
            
    $Reports[$k]['reject_date'] = $row['reject_date']; 
            
    $Reports[$k]['process_name'] = $row['process_name']; 
            
    $Reports[$k]['reject_type'] = $row['reject_type']; 
            
    $Reports[$k]['compound_type'] = $row['compound_type']; 
            
    $Reports[$k]['reject'] = $row['reject'];  
           
    $k++;  
        } 
         
        
    //| *************************************************** |\\ 
        //| Build functions to return specific values or arrays |\\ 
        //| *************************************************** |\\ 
         
        // Returns dates array \\ 
        
    function dates($array){ 
            
    $dates = array();     
            foreach(
    $array as $k => $v){ 
                
    $dates[] = $v['reject_date']; 
            } 
            
    $dates array_unique($dates); 
            
    sort($dates); 
            return 
    $dates;  
        } 
         
        
    // Returns process_names array \\ 
        
    function process_names($array){     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                
    $process_names[] = $v['process_name']; 
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names); 
            return 
    $process_names;  
        } 
        
        
           
        
    //*****************************************//     
           // Returns number of columns by date \\ 
        //*****************************************//     
        
    function columns($array,$date){ 
            
    //process names     
            
    $process_names = array(); 
            foreach(
    $array as $k => $v){ 
                    
    $process_names[] = $v['process_name'];
            } 
            
    $process_names array_unique($process_names); 
            
    sort($process_names);                              
            
    // get reject_types by process name 
            
    $reject_types = array(); 
            foreach(
    $process_names as $process_name){ 
                foreach(
    $array as $k => $v){ 
                        
    $reject_types[$process_name][$v['reject_type']] = $v['reject_type']; 
                } 
            }     
            
    //Convert reject_type to count         
            
    $counts = array(); 
            foreach(
    $reject_types as $reject_type){ 
                
    $counts[] = count($reject_type); 
            } 
            
    //return largest value 
            
    $max_count max($counts); 
            return 
    $max_count;   
        } 
        
    //*****************************************//     
         // END Returns number of columns by date \\ 
        //*****************************************//     
        
         
        // Returns compound_type array for process_name \\ 
        
    function compound_types($array,$process_name){     
            
    $compound_types = array(); 
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name){ 
                    
    $compound_types[] = $v['compound_type']; 
                }     
            } 
            
    $compound_types array_unique($compound_types); 
            
    sort($compound_types); 
            return 
    $compound_types;  
        } 
             
         
    // Returns reject_type array for process_name \\ NEW 
        
    function reject_types($array,$reject_date,$process_name){     
            
    $reject_types = array(); 
            foreach(
    $array as $k => $v){ 
                
    //if ($v['process_name'] == $process_name){ 
                    
    $reject_types[] = $v['reject_type']; 
               
    // }     
            

            
    $reject_types array_unique($reject_types); 
            
    sort($reject_types); 
            return 
    $reject_types;  
        } 
        
         
    // Returns all reject_type array for process_name \\ NEW 
        
    function allreject_types($array){     
            
    $reject_types = array(); 
            foreach(
    $array as $k => $v){ 
                    
    $reject_types[] = $v['reject_type'];
            } 
            
    $reject_types array_unique($reject_types); 
            
    sort($reject_types); 
            return 
    $reject_types;
        } 
          
        
    // Returns reject amount for cell \\ 
        
    function searchresults($array,$reject_date,$process_name,$reject_type,$compound_type){ 
            
    $result ""
            
    $total=0;     
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == "{$reject_date}&&   
                    
    $v['process_name'] == "{$process_name}&& 
                    
    $v['reject_type'] == "{$reject_type}&& 
                    
    $v['compound_type'] == "{$compound_type}"){ 
                    
    $total += $v['reject']; 
                } 
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
        
    // Returns reject total based on $reject_date,$process_name,$reject_type \\ 
        
    function resulttotals($array,$reject_date,$process_name,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        }  
        
        
    // Returns reject total based on $process_name,$reject_type \\ 
        
    function allresulttotals($array,$process_name,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        }  
         
        
    // Returns compound total based on $reject_date,$process_name,$compound_type \\ 
        
    function compound_resulttotals($array,$reject_date,$process_name,$compound_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['reject_date'] == $reject_date &&   
                    
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
              
         
    //NEW
        // Returns compound total based on $process_name,$compound_type,$reject_type \\ 
        
    function reject_type_resulttotals($array,$process_name,$compound_type,$reject_type){ 
            
    $total=0
            foreach(
    $array as $k => $v){ 
                if (
    $v['process_name'] == $process_name && 
                    
    $v['compound_type'] == $compound_type && 
                    
    $v['reject_type'] == $reject_type){ 
                    
    $total += $v['reject']; 
                }     
            } 
            
    $total = ($total!=number_format($total2'.''') : ''); 
            return 
    $total;  
        } 
         
    //echo "<pre>";  
    //print_r(allreject_types($Reports));  
    //echo "</pre>";  

        ////Build display data BEFORE output to browser////                  
        
    $allreject_types allreject_types($Reports);                 
        
    $allreject_type_count count($allreject_types); 
        
    $Tcols=$allreject_type_count+1;    
        
    $display "<table border=0 cellpadding=0 cellspacing=0 class=\"display\">  
            <thead>  
                <tr>  
                    <th>Compound</th>\r"
    ;  
                    
    //I'll keep your id identifier in place                  
                    
    $i=1
                    
    $dates dates($Reports);                  
                    foreach(
    $dates as $date){  
                        
    //We'll run our columns function in our date loop to get column count 
                        
    $cols columns($Reports,$date);  
                         
                        
    $display .= "<th id=col".$i." colspan=\"$Tcols\" class=\"border\">$date</th>\r";
                         
                        
    $i++; 
                    }
                         
    //NEW                    
                        
    $display .= "<th class=\"border\" colspan=\"$Tcols\">WEEK TOTALS</th>\r";   
                
    $display .= "</tr>  
                </thead>"
    ;       
                 
                    
    $process_names process_names($Reports);  
                    foreach(
    $process_names as $process_name){                  
                        
    $display .= "<tr>\r";      
                            
    $display .= "<td>$process_name</td>\r";     
                             
                        foreach(
    $dates as $date){       
                               
    $bor=0;                                
                            
    $reject_types reject_types($Reports,$date,$process_name); 
                            
    $reject_type_count count($reject_types); 
                            
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                            
    $cols columns($Reports,$date); 
                             
                            if (
    $type_for_date == "false"){ 
                                for(
    $c=0;$c<$cols;$c++){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>&nbsp;</td>\r";     
                                     
                                    
    $bor++; 
                                } 
                            }else{ 
                                
    $rt_running_count=0;
                                foreach(
    $reject_types as $reject_type){     
                                    
    $border = ($bor==" class=\"border\"" '');  
                                                      
                                    
    $display .= "<td$border>$reject_type</td>\r";  
                                     
                                    
    $bor++;
                                    
    $rt_running_count++;  
                                }
                                if (
    $rt_running_count==$reject_type_count){                             
                                    for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                        
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                        
    $display .= "<td$border>&nbsp;</td>\r";     
                                         
                                        
    $bor++; 
                                    }
                                } 
                            }
                        
    $display .= "<td class=\"border\">Total</td>\r";                              
                        }        
                        
    //NEW       
                            
    $display .= "<td class=\"heading border\">$process_name</td>\r";
                        foreach(
    $allreject_types as $allreject_type){                                                  
                            
    $display .= "<td class=\"heading border\">$allreject_type</td>\r";
                        }                    
                
    $display .= "</tr>\r";
                
                
                    
    $compound_types compound_types($Reports,$process_name);             
                            foreach(
    $compound_types as $compound_type){                  
                                
    $display .= "<tr>\r";      
                                    
    $display .= "<td>$compound_type</td>\r"
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" class=\"border\"" '');  
                                                          
                                            
    $display .= "<td$border>&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{
                                    
                                        
    $ct_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" class=\"border\"" '');  
                                            
    $reject searchresults($Reports,$date,$process_name,$reject_type,$compound_type); 
                                            
    $reject = (!empty($reject) ? $reject "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td$border align=\"right\">$reject</td>\r"
                                                 
                                            
    $bor++;
                                            
    $ct_running_count++;                                     
                                            
                                            if (
    $ct_running_count==$reject_type_count){                         
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" class=\"border\"" ''); 
                                                           
                                                    
    $display .= "<td$border>&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        }
                                         
                                            
    $compoundTotal compound_resulttotals($Reports,$date,$process_name,$compound_type); 
                                            
    $compoundTotal = (!empty($compoundTotal) ? $compoundTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"border\" align=\"right\">$compoundTotal</td>\r";  
                                    }                                                 
                                }
                                
    //NEW  
                                   
    $display .= "<td class=\"total border\">$compound_type</td>\r";
                                    foreach(
    $allreject_types as $allreject_type){                  
                                           
    $reject_type_resulttotal reject_type_resulttotals($Reports,$process_name,$compound_type,$allreject_type); 
                                           
    $reject_type_resulttotal = (!empty($reject_type_resulttotal) ? $reject_type_resulttotal "&nbsp;"); 
                                                                                
                                           
    $display .= "<td align=\"right\">$reject_type_resulttotal</td>\r";
                                    }                           
                
    $display .= "</tr>\r";                                                                                             
                            }  
                                       
               
    //---total rejects per process and per reject type---// 
                            
    $display .= "<tr>\r";  
                            
    $display .= "<td class=\"total\">Total</td>\r";                        
                                                         
                                foreach(
    $dates as $date){        
                                    
    $bor=0;               
                                    
    $reject_types reject_types($Reports,$date,$process_name); 
                                    
    $reject_type_count count($reject_types); 
                                    
    $type_for_date = (!empty($reject_types) ? "true" "false"); 
                                    
    $cols columns($Reports,$date); 
                                     if (
    $type_for_date == "false"){ 
                                        for(
    $c=0;$c<$cols;$c++){ 
                                            
    $border = ($bor==" border" '');  
                                                                  
                                            
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                             
                                            
    $bor++; 
                                        } 
                                    }else{ 
                                        
    $rt_running_count=0
                                        foreach(
    $reject_types as $reject_type){     
                                            
    $border = ($bor==" border" '');   
                                            
    $rejectTotal resulttotals($Reports,$date,$process_name,$reject_type); 
                                            
    $rejectTotal = (!empty($rejectTotal) ? $rejectTotal "&nbsp;"); 
                                                                                 
                                            
    $display .= "<td class=\"total$border\" align=\"right\">$rejectTotal</td>\r"
                                                 
                                            
    $bor++;
                                            
    $rt_running_count++;                                      
                                            
                                            if (
    $rt_running_count==$reject_type_count){                             
                                                for(
    $d=$reject_type_count;$d<$cols;$d++){     
                                                    
    $border = ($bor==" border" ''); 
                                                                   
                                                    
    $display .= "<td class=\"total$border\">&nbsp;</td>\r"
                                                     
                                                    
    $bor++; 
                                                }
                                            } 
                                        } 
                                    }        
                                    
    $display .= "<th class=\"border\">&nbsp;</th>\r";                                                  
                                }
                                
    //NEW
                                    
    $display .= "<th class=\"border\">Totals</th>\r";
                                        foreach(
    $allreject_types as $allreject_type){                  
                                            
    $allresulttotal allresulttotals($Reports,$process_name,$allreject_type); 
                                            
    $allresulttotal = (!empty($allresulttotal) ? $allresulttotal "&nbsp;"); 
                                                                               
                                            
    $display .= "<td class=\"total\" align=\"right\">$allresulttotal</td>\r";
                                        }     
                                    
    $display .= "</tr>\r";   
                            }              
        
    $display .= "</table>\r"
    }


        if(isset(
    $display)){ 
            echo 
    "$display"
        } 
    ?>

  17. #42
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much... i tried this code and the output displayed was correct.


    Thank you again.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •