phpBMS

Show
Ignore:
Timestamp:
04/07/09 11:44:18 (3 years ago)
Author:
nate
Message:
  • Merged Nathan branch back into trunk.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/bms/include/discounts.php

    r285 r485  
    3939if(class_exists("phpbmsTable")){ 
    4040        class discounts extends phpbmsTable{ 
    41          
     41 
    4242                function getDefaults(){ 
    43                          
     43 
    4444                        $therecord = parent::getDefaults(); 
    45                          
     45 
    4646                        $therecord["type"]="percent"; 
    47                          
     47 
    4848                        return $therecord; 
    4949                } 
    50          
    51                  
    52                 function formatValue($variables){ 
    53                  
     50 
     51 
     52                function verifyVariables($variables){ 
     53 
     54                        //table's default is fine 
     55                        if(isset($variables["type"])){ 
     56 
     57                                switch($variables["type"]){ 
     58 
     59                                        case "percent": 
     60                                        case "amount": 
     61                                        break; 
     62 
     63                                        default: 
     64                                                $this->verifyErrors[] = "The value of the `type` field is invalid. 
     65                                                        It must be either 'percent' or 'amount'."; 
     66                                        break; 
     67 
     68                                }//end switch 
     69 
     70                        }//end if 
     71 
     72                        return parent::verifyVariables($variables); 
     73 
     74                }//end method --verifyVariables-- 
     75 
     76 
     77                function prepareVariables($variables){ 
     78 
    5479                        if($variables["type"] == "percent") 
    5580                                $variables["value"] = ((real) str_replace("%","",$variables["percentvalue"])); 
    56                         else  
     81                        else 
    5782                                $variables["value"] =  currencyToNumber($variables["amountvalue"]); 
    58                  
     83 
    5984                        return $variables; 
    6085                } 
    61          
    62                  
    63                 function updateRecord($variables, $modifiedby = NULL){ 
    64                          
    65                         $variables = $this->formatValue($variables); 
    66                                                  
    67                         parent::updateRecord($variables,$modifiedby); 
    68                 } 
    69          
    70          
    71                 function insertRecord($variables,$createdby = NULL){ 
    72                  
    73                         $variables = $this->formatValue($variables); 
    74                         return parent::insertRecord($variables,$createdby); 
    75                 } 
    76                  
    77          
     86 
     87 
    7888                function getTotals($id=0){ 
    79                  
     89 
    8090                        $returnArray["Invoice"]["total"]=0; 
    8191                        $returnArray["Invoice"]["sum"]=0; 
    8292                        $returnArray["Order"]["total"]=0; 
    8393                        $returnArray["Order"]["sum"]=0; 
    84                          
     94 
    8595                        if($id>0){ 
    8696                                $querystatement="SELECT invoices.type,count(invoices.id) as total,sum(discountamount) as sum 
    87                                                                 FROM discounts inner join invoices on discounts.id=invoices.discountid  
     97                                                                FROM discounts inner join invoices on discounts.id=invoices.discountid 
    8898                                                                WHERE discounts.id=".((int) $id)." and (invoices.type=\"Order\" or invoices.type=\"Invoice\") GROUP BY invoices.type"; 
    8999                                $queryresult = $this->db->query($querystatement); 
    90          
     100 
    91101                                while($therecord=$this->db->fetchArray($queryresult)){ 
    92102                                        $returnArray[$therecord["type"]]["total"]=$therecord["total"]; 
    93103                                        $returnArray[$therecord["type"]]["sum"]=$therecord["sum"]; 
    94104                                } 
    95                                  
     105 
    96106                        } 
    97          
     107 
    98108                        return $returnArray; 
    99          
     109 
    100110                }//end function 
    101                  
     111 
    102112        }//end class 
    103113}//end if 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.