phpBMS

Changeset 764 for trunk/phpbms

Show
Ignore:
Timestamp:
01/15/10 15:01:40 (2 years ago)
Author:
nate
Message:
  • Product api functions now have responses consitent with the api / other table api functions.
  • api_searchByPartNumber can now distinguish between webenabled and non-webenabled records as well as inactive and non-inactive records.
  • Further described the getDefaults apiwrapper function.
  • Added a searchProductsByPartnumber function in the apiwrapper.
Location:
trunk/phpbms/modules
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/api/apiwrapper.php

    r762 r764  
    263263     * function getDefaults 
    264264     * 
    265      */ 
    266  
    267     function getDefaults($tabledefuuid){ 
     265     * @param string $tabledefuuid The uuid of the tabledefinition that you wish to get defaults. 
     266     * 
     267     * @return array An associative array response for the get 
     268     * @returnf string type The result of the procedure (either 'retrieved' if successful, or 'error' if not). 
     269     * @returnf string message The detailed message describing the result 
     270     * @returnf array extras The associative array containing the default record.  <em>Note:</em> This field only exists if type is not 'error'. 
     271     */ 
     272 
     273    public function getDefaults($tabledefuuid){ 
    268274 
    269275        $params["request"][0]["command"] = "getDefaults"; 
     
    383389     * function searchClientByEmail 
    384390     * @param string $email The email to be searched for 
    385      * @param bool $useUuid Whether to return uuids or ids. 
     391     * @param bool $returnUuid Whether to return uuids or ids. 
    386392     * 
    387393     * @return array An associative array response for the get 
    388394     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
    389395     * @returnf string message The detailed message describing the result 
    390      * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
    391      */ 
    392  
    393     public function searchClientByEmail($email, $useUuid = true) { 
     396     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'returnUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     397     */ 
     398 
     399    public function searchClientByEmail($email, $returnUuid = true) { 
    394400 
    395401        $method = "api_searchByEmail"; 
     
    397403        $data["email"] = (string)$email; 
    398404 
    399         if($useUuid !== true) 
    400             $useUuid = false; 
     405        if($returnUuid !== true) 
     406            $returnUuid = false; 
    401407 
    402408        $options = array( 
    403                           "useUuid" => $useUuid 
     409                          "useUuid" => $returnUuid 
    404410                        ); 
    405411 
     
    418424     * @param name $lastname The last name to search for in the client's table 
    419425     * @param name $postalcode The postal code to search for in the client's table 
    420      * @param bool $useUuid Whether to return uuids or ids. 
     426     * @param bool $returnUuid Whether to return uuids or ids. 
    421427     * 
    422428     * @return array An associative array response for the get 
    423429     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
    424430     * @returnf string message The detailed message describing the result 
    425      * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
    426      */ 
    427  
    428     public function searchClientByNameAndPostalcode($firstname, $lastname, $postalcode, $useUuid = true) { 
     431     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'returnUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     432     */ 
     433 
     434    public function searchClientByNameAndPostalcode($firstname, $lastname, $postalcode, $returnUuid = true) { 
    429435 
    430436        $method = "api_searchByNameAndPostalcode"; 
     
    434440        $data["postalcode"] = (string)$postalcode; 
    435441 
    436         if($useUuid !== true) 
    437             $useUuid = false; 
     442        if($returnUuid !== true) 
     443            $returnUuid = false; 
    438444 
    439445        $options = array( 
    440                           "useUuid" => $useUuid 
     446                          "useUuid" => $returnUuid 
    441447                        ); 
    442448 
     
    455461     * @param string $username The username to search for in the client's table 
    456462     * @param string $password The password to search for in the client's table 
    457      * @param bool $useUuid Whether to return uuids or ids. 
     463     * @param bool $returnUuid Whether to return uuids or ids. 
    458464     * 
    459465     * @return array An associative array response for the get 
    460466     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
    461467     * @returnf string message The detailed message describing the result 
    462      * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
    463      */ 
    464  
    465     public function searchClientByUsernameAndPassword($username, $password, $useUuid = true) { 
     468     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'returnUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     469     */ 
     470 
     471    public function searchClientByUsernameAndPassword($username, $password, $returnUuid = true) { 
    466472 
    467473        $method = "api_searchByUsernameAndPassword"; 
     
    470476        $data["password"] = (string)$password; 
    471477 
    472         if($useUuid !== true) 
    473             $useUuid = false; 
     478        if($returnUuid !== true) 
     479            $returnUuid = false; 
    474480 
    475481        $options = array( 
    476                           "useUuid" => $useUuid 
     482                          "useUuid" => $returnUuid 
    477483                        ); 
    478484 
     
    493499     * @param string $startdate The sql encoded DATETIME lower range of creation dates. 
    494500     * @param string $enddate The sql encoded DATETIME upper range of creation dates. 
    495      * @param bool $useUuid Whether to return uuids or ids. 
     501     * @param bool $returnUuid Whether to return uuids or ids. 
    496502     * 
    497503     * @return array An associative array response for the get 
    498504     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
    499505     * @returnf string message The detailed message describing the result 
    500      * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'useUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
    501      */ 
    502  
    503     function searchSalesOrdersByClientUuid($clientuuid, $ordertype = NULL, $startdate = NULL, $enddate = NULL, $useUuid = true) { 
     506     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'returnUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     507     */ 
     508 
     509    function searchSalesOrdersByClientUuid($clientuuid, $ordertype = NULL, $startdate = NULL, $enddate = NULL, $returnUuid = true) { 
    504510 
    505511        $method = "api_searchByClientUuid"; 
     
    513519            $data["enddate"] = $enddate; 
    514520 
    515         if($useUuid !== true) 
    516             $useUuid = false; 
     521        if($returnUuid !== true) 
     522            $returnUuid = false; 
    517523 
    518524        $options = array( 
    519                           "useUuid" => $useUuid 
     525                          "useUuid" => $returnUuid 
    520526                        ); 
    521527 
     
    527533            return false; 
    528534 
     535    }//end function 
     536     
     537     
     538    /* 
     539     * function searchProductsByPartnumber 
     540     * @param $partnumber 
     541     * @param $webenabled 
     542     * @param $inactive 
     543     * @param $returnUuid 
     544     * 
     545     * @return array An associative array response for the get 
     546     * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 
     547     * @returnf string message The detailed message describing the result 
     548     * @returnf array extras If the type is 'result', this will be a (possibly empty) array of uuids (or ids if the 'returnUuid' option is false).  <em>Note:</em> This field only exists if type is not 'error'. 
     549     */ 
     550     
     551    public function searchProductsByPartnumber($partnumber, $webenabled = true, $inactive = false, $returnUuid = true) { 
     552         
     553        $method = "api_searchByPartNumber"; 
     554        $tabledefuuid = "tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34"; 
     555        $data["partnumber"] = (string)$partnumber; 
     556        $data["webenabled"] = (bool)$webenabled; 
     557        $data["inactive"] = (bool)$inactive; 
     558         
     559        $returnUuid = (bool)$returnUuid; 
     560         
     561        $options = array( 
     562                          "useUuid" => $returnUuid 
     563                        ); 
     564 
     565        $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 
     566 
     567        if($response !== false) 
     568            return $response[0]; 
     569        else 
     570            return false; 
     571         
    529572    }//end function 
    530573 
  • trunk/phpbms/modules/bms/include/products.php

    r703 r764  
    534534                /* 
    535535                 * function api_searchByPartNumber 
     536                 *  
    536537                 * @param array $requestData Array containing the "partnumber" key. 
    537538                 * @param bool $returnUuid If true, returns result's uuid , if 
    538539                 * false, the id. 
     540                 *  
    539541                 * @return array An array containing response information 
    540                  * @returnf string 'type' The type of response (e.g. 'error' or 'result') 
    541                  * @returnf string 'message' Message explaining the type / result 
    542                  * @returnf array details Either the array of uuid / ids if no errors 
     542                 * @returnf string type The type of response (e.g. 'error' or 'result') 
     543                 * @returnf string message Message explaining the type / result 
     544                 * @returnf array extras Either the array of uuid / ids if no errors 
    543545                 * were encountered, or the original $requestData if there was an error 
    544546                 */ 
     
    547549                         
    548550                        /** 
    549                           *  do error search  
     551                          *  verify data integrity.  
    550552                          */ 
     553                         
     554                        $response["type"] = ""; 
     555                        $response["message"] = ""; 
    551556                        if(!isset($requestData["partnumber"])){ 
    552557                                $response["type"] = "error"; 
    553                                 $response["message"] = "Data does not contain a key of 'partnumber'."; 
    554                                 $response["details"] = $requestData; 
     558                                $response["message"] = "Data does not contain a key of 'partnumber'"; 
     559                        }//end if 
     560                         
     561                        if(!isset($requestData["webenabled"])){ 
     562                                $response["type"] = "error"; 
     563                                if($response["message"]) 
     564                                        $response["message"] .= " or 'webenabled'."; 
     565                                else 
     566                                        $response["message"] = "Data does not contain a key of 'webenabled'."; 
     567                                 
     568                        }//end if 
     569                         
     570                        if(!isset($requestData["inactive"])){ 
     571                                $response["type"] = "error"; 
     572                                if($response["message"]) 
     573                                        $response["message"] .= " or 'inactive'."; 
     574                                else 
     575                                        $response["message"] = "Data does not contain a key of 'inactive'."; 
     576                                 
     577                        }//end if 
     578                         
     579                        if($response["type"] == "error") 
    555580                                return $response; 
    556                         }//end if 
     581                         
    557582                         
    558583                        /** 
     
    567592                                WHERE 
    568593                                        `partnumber` = '".mysql_real_escape_string($requestData["partnumber"])."' 
     594                                        AND 
     595                                        `webenabled` = '".(int)$response["webenabled"]."' 
     596                                        AND 
     597                                        `inactive` = '".(int)$response["inactive"]."' 
    569598                        "; 
    570599                         
     
    576605                        $thereturn["message"] = "The function api_searchByPartNumber has been run successfully."; 
    577606                        $thereturn["type"] = ""; 
    578                         $thereturn["details"] = array(); 
     607                        $thereturn["extras"] = array(); 
    579608                        while($therecord = $this->db->fetchArray($queryresult)){ 
    580609                                 
    581610                                if($returnUuid) 
    582                                         $thereturn["details"][] = $therecord["uuid"]; 
     611                                        $thereturn["extras"][] = $therecord["uuid"]; 
    583612                                else 
    584                                         $thereturn["details"][] = $therecord["id"]; 
     613                                        $thereturn["extras"][] = $therecord["id"]; 
    585614                                         
    586615                        }//end while 
Scanned by Orvant Copyright © 2010 Kreotek, LLC. All Rights reserved.