Changeset 750
- Timestamp:
- 01/13/10 14:15:06 (2 years ago)
- Location:
- trunk/phpbms/modules
- Files:
-
- 3 modified
-
api/apiwrapper.php (modified) (4 diffs)
-
bms/include/clients.php (modified) (11 diffs)
-
bms/include/invoices.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/modules/api/apiwrapper.php
r748 r750 48 48 * 49 49 * @param string $hostname The hostname of the target script 50 * @param string $urlPath The path from the host to the target script(usually something like 'modules/api/api_json.php').50 * @param string $urlPath The location of the target script in relation to $hostname (usually something like 'modules/api/api_json.php'). 51 51 * @param string $username The username of an user with portal access 52 52 * @param string $password The password of the same user with portal access … … 197 197 else 198 198 return false; 199 200 }//end function 201 202 203 /* 204 * function searchClientByEmail 205 * @param string $email The email to be searched for 206 * @param array $options An associative array of options. Possible options are : 'useUuid' 207 * 208 * @return array An associative array response for the get 209 * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 210 * @returnf string message The detailed message describing the result 211 * @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'. 212 */ 213 214 public function searchClientByEmail($email, $options = NULL) { 215 216 $method = "api_searchByEmail"; 217 $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 218 $data["email"] = (string)$email; 219 220 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 221 222 if($response !== false) 223 return $response[0]; 224 else 225 return false; 226 227 }//end function 228 229 /* 230 * function searchClientByNameAndPostalcode 231 * @param $firstname 232 * @param $lastname 233 * @param $postalcode 234 * @param array $options An associative array of options. Possible options are : 'useUuid' 235 * 236 * @return array An associative array response for the get 237 * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 238 * @returnf string message The detailed message describing the result 239 * @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'. 240 */ 241 242 public function searchClientByNameAndPostalcode($firstname, $lastname, $postalcode, $options = NULL) { 243 244 $method = "api_searchByNameAndPostalcode"; 245 $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 246 $data["firstname"] = (string)$firstname; 247 $data["lastname"] = (string)$lastname; 248 $data["postalcode"] = (string)$postalcode; 249 250 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 251 252 if($response !== false) 253 return $response[0]; 254 else 255 return false; 256 257 }//end function 258 259 260 /* 261 * function searchClientByUsernameAndPassword 262 * @param $username 263 * @param $password 264 * @param array $options An associative array of options. Possible options are : 'useUuid' 265 * 266 * @return array An associative array response for the get 267 * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 268 * @returnf string message The detailed message describing the result 269 * @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'. 270 */ 271 272 public function searchClientByUsernameAndPassword($username, $password, $options = NULL) { 273 274 $method = "api_searchByUsernameAndPassword"; 275 $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 276 $data["username"] = (string)$username; 277 $data["password"] = (string)$password; 278 279 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 280 281 if($response !== false) 282 return $response[0]; 283 else 284 return false; 285 286 }//end function 287 288 289 /* 290 * function searchSalesOrdersByClientUuid 291 * @param $clientuuid 292 * @param $ordertype 293 * @param $startdate 294 * @param $enddate 295 * @param array $options An associative array of options. Possible options are : 'useUuid' 296 * 297 * @return array An associative array response for the get 298 * @returnf string type The result of the get (either 'result' if successful, or 'error' if not). 299 * @returnf string message The detailed message describing the result 300 * @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'. 301 */ 302 303 function searchSalesOrdersByClientUuid($clientuuid, $ordertype = NULL, $startdate = NULL, $enddate = NULL, $options = NULL) { 304 305 $method = "api_searchByClientUuid"; 306 $tabledefuuid = "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883"; 307 $data["clientid"] = $clientuuid; 308 if($ordertype !== NULL) 309 $data["type"] = $ordertype; 310 if($startdate !== NULL) 311 $data["startdate"] = $startdate; 312 if($enddate !== NULL) 313 $data["enddate"] = $enddate; 314 315 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 316 317 if($response !== false) 318 return $response[0]; 319 else 320 return false; 321 322 }//end function 323 324 325 /* 326 * function getFile 327 * @param string $url The full url to the api_servfile.php url. This can be retrieved from the getRecords method on a `files` table get (the 'apifileurl' key in the record). 328 * 329 * @return mixed The file if successful, false, if not. 330 */ 331 332 public function getFile($url) { 333 334 $urlInfo = parse_url($url); 335 336 $oldHost = $this->apiHostname; 337 $oldPort = $this->port; 338 $oldUrl = $this->apiUrl; 339 340 $this->apiHostname = $urlInfo["host"]; 341 if($port === 0 || (int)$port > 0) 342 $this->port = $urlInfo["port"]; 343 else 344 $this->port = NULL; 345 $this->apiUrl = $urlInfo["path"]."?".$urlInfo["query"]; 346 347 $response = $this->_callServer(array()); 348 349 $this->apiUrl = $oldUrl; 350 $this->apiHostname = $oldHost; 351 $this->port = $oldPort; 352 353 if($response !== false) 354 return $response; 355 else{ 356 $this->errorMessage = ""; 357 return false; 358 }//end if 199 359 200 360 }//end function … … 318 478 * 319 479 * @param array $params 480 * @param bool $decode 320 481 * 321 482 * @return array False if major (i.e. connection) error has occurred. Otherwise, returns an array of associative arrays. 322 483 */ 323 484 324 private function _callServer($params ) {485 private function _callServer($params, $decode = false) { 325 486 326 487 $params["phpbmsusername"] = $this->username; … … 382 543 if(ini_get("magic_quotes_runtime")) $response = stripslashes($response); 383 544 384 $decode = $this->_decode($response); 385 386 if($response && $decode === false) { 387 $this->errorMessage = "Bad Response. Got This:".$response; 388 return false; 389 } else { 390 $response = $decode; 391 } 545 if($decode){ 546 $decodedResponse = $this->_decode($response); 547 548 if($response && $decodedResponse === false) { 549 $this->errorMessage = "Bad Response. Got This:".$response; 550 return false; 551 } else { 552 $response = $decodedResponse; 553 } 554 }//end if 392 555 393 556 -
trunk/phpbms/modules/bms/include/clients.php
r713 r750 441 441 * false, the id. 442 442 * @return array An array containing response information 443 * @returnf string 'type'The type of response (e.g. 'error' or 'result')444 * @returnf string 'message'Message explaining the type / result445 * @returnf array details Either the array of uuid / ids if no errors446 * were encountered, or the original $requestDataif there was an error443 * @returnf string type The type of response (e.g. 'error' or 'result') 444 * @returnf string message Message explaining the type / result 445 * @returnf array extras Either the array of uuid / ids if no errors 446 * were encountered, or the empty if there was an error 447 447 */ 448 448 … … 455 455 $response["type"] = "error"; 456 456 $response["message"] = "Data does not contain a key of 'email'"; 457 $response["details"] = $requestData;458 457 return $response; 459 458 }//end if … … 479 478 $thereturn["type"] = "result"; 480 479 $thereturn["message"] = "The function api_searchByEmail has been run successfully."; 481 $thereturn[" details"] = array();480 $thereturn["extras"] = array(); 482 481 while($therecord = $this->db->fetchArray($queryresult)){ 483 482 484 483 if($returnUuid) 485 $thereturn[" details"][] = $therecord["uuid"];484 $thereturn["extras"][] = $therecord["uuid"]; 486 485 else 487 $thereturn[" details"][] = $therecord["id"];486 $thereturn["extras"][] = $therecord["id"]; 488 487 489 488 }//end while … … 500 499 * false, the id. 501 500 * @return array An array containing response information 502 * @returnf string 'type'The type of response (e.g. 'error' or 'result')503 * @returnf string 'message'Message explaining the type / result504 * @returnf array details Either the array of uuid / ids if no errors505 * were encountered, or the original $requestDataif there was an error501 * @returnf string type The type of response (e.g. 'error' or 'result') 502 * @returnf string message Message explaining the type / result 503 * @returnf array extras Either the array of uuid / ids if no errors 504 * were encountered, or the empty if there was an error 506 505 */ 507 506 … … 527 526 528 527 $response["type"] = "error"; 529 $response["details"] = $requestData;530 528 $response["message"] = ""; 531 529 … … 574 572 * report findings 575 573 */ 576 $thereturn[" details"] = array();574 $thereturn["extras"] = array(); 577 575 $thereturn["type"] = "result"; 578 576 $thereturn["message"] = "The function api_searchByNameAndPostalcode has been run successfully."; … … 580 578 581 579 if($returnUuid) 582 $thereturn[" details"][] = $therecord["uuid"];580 $thereturn["extras"][] = $therecord["uuid"]; 583 581 else 584 $thereturn[" details"][] = $therecord["id"];582 $thereturn["extras"][] = $therecord["id"]; 585 583 586 584 }//end while … … 597 595 * false, the id. 598 596 * @return array An array containing response information 599 * @returnf string 'type'The type of response (e.g. 'error' or 'result')600 * @returnf string 'message'Message explaining the type / result601 * @returnf array details Either the array of uuid / ids if no errors602 * were encountered, or the original $requestDataif there was an error597 * @returnf string type The type of response (e.g. 'error' or 'result') 598 * @returnf string message Message explaining the type / result 599 * @returnf array extras Either the array of uuid / ids if no errors 600 * were encountered, or the empty if there was an error 603 601 */ 604 602 … … 623 621 624 622 $response["type"] = "error"; 625 $response["details"] = $requestData;626 623 $response["message"] = ""; 627 624 … … 665 662 * report findings 666 663 */ 667 $thereturn[" details"] = array();664 $thereturn["extras"] = array(); 668 665 $thereturn["type"] = "result"; 669 666 $thereturn["message"] = "The function api_searchByUsernameAndPassword has been run successfully."; … … 671 668 672 669 if($returnUuid) 673 $thereturn[" details"][] = $therecord["uuid"];670 $thereturn["extras"][] = $therecord["uuid"]; 674 671 else 675 $thereturn[" details"][] = $threturn["id"];672 $thereturn["extras"][] = $threturn["id"]; 676 673 677 674 }//end while -
trunk/phpbms/modules/bms/include/invoices.php
r734 r750 1225 1225 * false, the id. 1226 1226 * @return array An array containing response information 1227 * @returnf string 'type'The type of response (e.g. 'error' or 'result')1228 * @returnf string 'message'Message explaining the type / result1229 * @returnf array details Either the array of uuid / ids if no errors1230 * were encountered, or the original $requestDataif there was an error1227 * @returnf string type The type of response (e.g. 'error' or 'result') 1228 * @returnf string message Message explaining the type / result 1229 * @returnf array extras Either the array of uuid / ids if no errors 1230 * were encountered, or the empty if there was an error 1231 1231 */ 1232 1232 … … 1239 1239 $response["type"] = "error"; 1240 1240 $response["message"] = "Data does not contain a key of 'clientid'."; 1241 $response["details"] = $requestData;1242 1241 1243 1242 return $response; … … 1271 1270 * report findings 1272 1271 */ 1273 $thereturn[" details"] = array();1272 $thereturn["extras"] = array(); 1274 1273 $thereturn["message"] = "The function api_searchByPartNumber has been run successfully."; 1275 1274 $thereturn["type"] = "result"; … … 1277 1276 1278 1277 if($returnUuid) 1279 $thereturn[" details"][] = $therecord["uuid"];1278 $thereturn["extras"][] = $therecord["uuid"]; 1280 1279 else 1281 $thereturn[" details"][] = $therecord["id"];1280 $thereturn["extras"][] = $therecord["id"]; 1282 1281 1283 1282 }//end while