Created
June 14, 2014 08:52
-
-
Save esimonetti/5d2ea71a90283bbd9c11 to your computer and use it in GitHub Desktop.
Retrieve count of New Cases from a SugarCRM v7 system and format output as: {"open_cases":"XXX"}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"spinegar/sugar7wrapper": "dev-master" | |
}, | |
"minimum-stability": "dev" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('vendor/autoload.php'); | |
// SugarCRM Details | |
$sugar_url = 'https://your-sugarcrm-url.com/rest/v10/'; | |
$sugar_user = 'your_user'; | |
$sugar_password = 'your_password'; | |
// End SugarCRM Details | |
$sugar = new \Spinegar\Sugar7Wrapper\Rest(); | |
$sugar->setUrl($sugar_url)->setUsername($sugar_user)->setPassword($sugar_password)->connect(); | |
// count new cases records | |
$cases = $sugar->countRecords('Cases', | |
array( | |
'filter' => array( | |
array('status' => 'New'), | |
), | |
) | |
); | |
if(!empty($cases)) | |
{ | |
echo json_encode( | |
array( | |
'open_cases' => $cases['record_count'] | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment