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/invoices.php

    r451 r485  
    4040        class invoices extends phpbmsTable{ 
    4141 
     42                var $availableClientIDs = array(); 
     43                var $availableUserIDs = array(); 
     44                var $availableStatusIDs = array(); 
     45 
    4246                function showClientType($id){ 
    4347 
     
    437441                } 
    438442 
     443                /*------[verification related functions]---------------------------*/ 
     444 
     445                function populateClientArray(){ 
     446 
     447                        $this->availableClientIDs = array(); 
     448 
     449                        $querystatement = " 
     450                                SELECT 
     451                                        `id` 
     452                                FROM 
     453                                        `clients`; 
     454                                "; 
     455 
     456                        $queryresult = $this->db->query($querystatement); 
     457 
     458                        if($this->db->numRows($queryresult)){ 
     459                                while($therecord = $this->db->fetchArray($queryresult)) 
     460                                        $this->availableClientIDs[] = $therecord["id"]; 
     461                        }else{ 
     462                                $this->availableClientIDs[] = "none"; 
     463                        }//end if 
     464 
     465                }//end method --populateClientArray-- 
     466 
     467 
     468                function populateUserArray(){ 
     469 
     470                        $this->availableUserIDs = array(); 
     471 
     472                        $querystatement = " 
     473                                SELECT 
     474                                        `id` 
     475                                FROM 
     476                                        `users`; 
     477                                "; 
     478 
     479                        $queryresult = $this->db->query($querystatement); 
     480 
     481                        $this->availableUserIDs[] = 0;//for none 
     482 
     483                        while($therecord = $this->db->fetchArray($queryresult)) 
     484                                $this->availableUserIDs[] = $therecord["id"]; 
     485 
     486                }//end method  --populateUserArray-- 
     487 
     488 
     489                function populateInvoiceStatusArray(){ 
     490 
     491                        $this->availableStatusIDs = array(); 
     492 
     493                        $querystatement = " 
     494                                SELECT 
     495                                        `id` 
     496                                FROM 
     497                                        `invoicestatuses`; 
     498                                "; 
     499 
     500                        $queryresult = $this->db->query($querystatement); 
     501 
     502                        if($this->db->numRows($queryresult)){ 
     503                                while($therecord = $this->db->fetchArray($queryresult)) 
     504                                        $this->availableStatusIDs[] = $therecord["id"]; 
     505                        }else{ 
     506                                $this->availableStatusIDs[] = "none"; 
     507                        }//end if 
     508 
     509                }//end method --populateInvoiceStatusArray-- 
     510 
     511 
     512                function verifyVariables($variables){ 
     513 
     514                        //must have a client 
     515                        if(isset($variables["clientid"])){ 
     516 
     517                                //must be numeric and positive 
     518                                if(!$variables["clientid"] || (int)$variables["clientid"] > 0){ 
     519 
     520                                        if(!count($this->availableClientIDs)) 
     521                                                $this->populateClientArray(); 
     522 
     523                                        if(!in_array(((int)$variables["clientid"]),$this->availableClientIDs)) 
     524                                                $this->verifyErrors[] = "The `clientid` field does not give an existing/acceptable client id number."; 
     525                                }else 
     526                                        $this->verifyErrors[] = "The `clientid` field must be a non-negative number or equivalent to 0."; 
     527 
     528                        }else 
     529                                $this->verifyErrors[] = "The `clientid` field must be set."; 
     530 
     531                        //table default (NULL) is not enough 
     532                        if(isset($variables["type"])){ 
     533 
     534                                switch($variables["type"]){ 
     535 
     536                                        case "Quote": 
     537                                        case "Order": 
     538                                        case "Invoice": 
     539                                        case "VOID": 
     540                                                break; 
     541 
     542                                        default: 
     543                                                $this->verifyErrors[] = "The value of the `type` field is invalid.  It must be 'Quote', 
     544                                                        'Order', 'Invoice', or 'VOID'."; 
     545                                                break; 
     546 
     547                                }//end switch 
     548 
     549                        }else 
     550                                $this->verifyErrors[] = "The `type` field must be set."; 
     551 
     552                        //check assigned to id 
     553                        if(isset($variables["assignedtoid"])){ 
     554 
     555                                //assignedtoid needs to be a non-negative number or equivalent to 0 
     556                                if( !$variables["assignedtoid"] || ((int)$variables["assignedtoid"]) > 0 ){ 
     557 
     558                                        if(!count($this->availableUserIDs)) 
     559                                                $this->populateUserArray(); 
     560 
     561                                        if(!in_array(((int)$variables["assignedtoid"]),$this->availableUserIDs)) 
     562                                                $this->verifyErrors[] = "The `assignedtoid` field does not give an existing/acceptable user id number."; 
     563                                }else 
     564                                        $this->verifyErrors[] = "The `assignedtoid` field must be a non-negative number or equivalent to 0."; 
     565 
     566                        }//end if 
     567 
     568                        //check status id 
     569                        if(isset($variables["statusid"])){ 
     570 
     571                                //assignedtoid needs to be a non-negative number or equivalent to 0 
     572                                if( !$variables["statusid"] || ((int)$variables["statusid"]) > 0 ){ 
     573 
     574                                        if(!count($this->availableStatusIDs)) 
     575                                                $this->populateInvoiceStatusArray(); 
     576 
     577                                        if(!in_array(((int)$variables["statusid"]),$this->availableStatusIDs)) 
     578                                                $this->verifyErrors[] = "The `statusid` field does not give an existing/acceptable status id number."; 
     579                                }else 
     580                                        $this->verifyErrors[] = "The `statusid` field must be a non-negative number or equivalent to 0."; 
     581 
     582                        }//end if 
     583 
     584                        //check booleans 
     585                                //readytopost 
     586                                if(isset($variables["readytopost"])) 
     587                                        if($variables["readytopost"] && $variables["readytopost"] != 1) 
     588                                                $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 
     589 
     590                                //weborder 
     591                                if(isset($variables["weborder"])) 
     592                                        if($variables["weborder"] && $variables["weborder"] != 1) 
     593                                                $this->verifyErrors[] = "The `weborder` field must be a boolean (equivalent to 0 or exactly 1)."; 
     594 
     595                                //shiptosameasbilling 
     596                                if(isset($variables["shiptosameasbilling"])) 
     597                                        if($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] != 1) 
     598                                                $this->verifyErrors[] = "The `shiptosameasbilling` field must be a boolean (equivalent to 0 or exactly 1)."; 
     599                        //check addresss ids 
     600                        //check secondary line item ids 
     601 
     602                        return parent::verifyVariables($variables); 
     603 
     604                }//end method 
     605 
    439606 
    440607                function prepareVariables($variables){ 
     
    544711                function updateRecord($variables, $modifiedby = NULL){ 
    545712 
    546                         if($modifiedby === NULL) 
    547                                 $modifiedby = $_SESSION["userinfo"]["id"]; 
     713                        //if($modifiedby === NULL) 
     714                        //      $modifiedby = $_SESSION["userinfo"]["id"]; 
    548715 
    549716 
     
    551718                                return false; 
    552719 
    553                         $variables = $this->prepareVariables($variables); 
     720                        //$variables = $this->prepareVariables($variables); 
    554721 
    555722                        if(!hasRights(20)){ 
     
    606773                                $createdby = $_SESSION["userinfo"]["id"]; 
    607774 
    608                         $variables = $this->prepareVariables($variables); 
     775                        //$variables = $this->prepareVariables($variables); 
    609776 
    610777                        $newid = parent::insertRecord($variables, $createdby); 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.