GXP 2000 XML SugarCRM
Comment on GXP-2000 XML PhonebookRe: GXP 2000 XML SugarCRM
I have these files in my /var/www/html/grandstream/services directory.
I even went as far as trying to create the gs_phonebook.xml file and put it in with the other files mentioned above.
I go to the phone book update and it sits for a split second and goes back the main screen.
But nothing changes if I add one etc.
Could you please shed some light on what Im doing wrong.
I even went as far as trying to create the gs_phonebook.xml file and put it in with the other files mentioned above.
I go to the phone book update and it sits for a split second and goes back the main screen.
But nothing changes if I add one etc.
Could you please shed some light on what Im doing wrong.
Re: GXP 2000 XML SugarCRM
Instead of cronjob you can create xml on the fly. With apache for example put into .htaccess:
RewriteEngine on
RewriteRule ^gs_phonebook\.xml$ gs_phonebook.php
RewriteEngine on
RewriteRule ^gs_phonebook\.xml$ gs_phonebook.php
GXP 2000 XML SugarCRM
Here is my example of the gs_phonebook.php. It looks up the names from sugarCRM database and splits them to groupes (work: Cell: Other:)
WORKS WITH TRIXBOX and A@H
set your DB user name and password in the begining of the php file!!
Create gs-phonebook.xml and allow writing to it!!
Add a cron job to lounch the php file every hour!!
HAVE fun
Christian
Munlan
WORKS WITH TRIXBOX and A@H
set your DB user name and password in the begining of the php file!!
Create gs-phonebook.xml and allow writing to it!!
Add a cron job to lounch the php file every hour!!
HAVE fun
Christian
<?php
//##########################################
//# Config section
header("Content-type: text/xml");
$host = "localhost";
$user = "root";
$pass = "passw0rd";
$database = "sugarcrm";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT id, first_name, last_name, phone_home, phone_work, accountindex, phone_mobile, phone_other FROM contacts WHERE deleted = 0 ";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
//$SelectPersonInfo = mysql_query($Query,$ConnectionSuccess);
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$SelectPersonInfo = mysql_query($query,$linkID);
$PersonDirectoryListing = "<?xml version=\"1.0\"?>\n";
$PersonDirectoryListing .= "<AddressBook>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
while ($row = mysql_fetch_array($SelectPersonInfo)) {
$CellPhoneT1 = ereg_replace("[ ()]", "", $row['phone_mobile']);
$CellPhone = ereg_replace("[ +]", "00", $CellPhoneT1);
$HomePhoneT1 = ereg_replace("[ ()]", "", $row['phone_home']);
$HomePhone = ereg_replace("[ +]", "00", $HomePhoneT1);
$WorkPhoneT1 = ereg_replace("[ ()]", "", $row['phone_work']);
$WorkPhone = ereg_replace("[ +]", "00", $WorkPhoneT1);
$OtherPhoneT1 = ereg_replace("[ ()]", "", $row['phone_other']);
$OtherPhone = ereg_replace("[ +]", "00", $OtherPhoneT1);
$FirstName = ereg_replace("[ ()]", "", $row['first_name']);
$LastName = ereg_replace("[ ()]", "", $row['last_name']);
if ($row["phone_home"]) {
$PersonDirectoryListing .= "<Contact>\n";
$PersonDirectoryListing .= "<LastName>$LastName </LastName>\n";
$PersonDirectoryListing .= "<FirstName>$FirstName Home:</FirstName>\n";
$PersonDirectoryListing .= "<Phone>\n";
$PersonDirectoryListing .= "<phonenumber>$HomePhone</phonenumber>\n";
$PersonDirectoryListing .= "<accountindex>0</accountindex>\n";
$PersonDirectoryListing .= "</Phone>\n";
$PersonDirectoryListing .= "</Contact>\n";
}
if ($row["phone_mobile"]) {
$PersonDirectoryListing .= "<Contact>\n";
$PersonDirectoryListing .= "<LastName>$LastName</LastName>\n";
$PersonDirectoryListing .= "<FirstName>$FirstName Cell:</FirstName>\n";
$PersonDirectoryListing .= "<Phone>\n";
$PersonDirectoryListing .= "<phonenumber>$LongDistanceExtension$CellPhone</phonenumber>\n";
$PersonDirectoryListing .= "<accountindex>0</accountindex>\n";
$PersonDirectoryListing .= "</Phone>\n";
$PersonDirectoryListing .= "</Contact>\n";
}
if ($row["phone_work"]) {
$PersonDirectoryListing .= "<Contact>\n";
$PersonDirectoryListing .= "<LastName>$LastName</LastName>\n";
$PersonDirectoryListing .= "<FirstName>$FirstName Work:</FirstName>\n";
$PersonDirectoryListing .= "<Phone>\n";
$PersonDirectoryListing .= "<phonenumber>$LongDistanceExtension$WorkPhone</phonenumber>\n";
$PersonDirectoryListing .= "<accountindex>0</accountindex>\n";
$PersonDirectoryListing .= "</Phone>\n";
$PersonDirectoryListing .= "</Contact>\n";
}
if ($row["phone_other"]) {
$PersonDirectoryListing .= "<Contact>\n";
$PersonDirectoryListing .= "<LastName>$LastName</LastName>\n";
$PersonDirectoryListing .= "<FirstName>$FirstName Other:</FirstName>\n";
$PersonDirectoryListing .= "<Phone>\n";
$PersonDirectoryListing .= "<phonenumber>$OtherPhone</phonenumber>\n";
$PersonDirectoryListing .= "<accountindex>0</accountindex>\n";
$PersonDirectoryListing .= "</Phone>\n";
$PersonDirectoryListing .= "</Contact>\n";
}
}
}
$PersonDirectoryListing .= "</AddressBook>\n";
# If the variable ID is not passed in on the GET string, then do the
# entire company directory, unless last is passed in. If so then we
# will be using a LIKE filter in our SQL query
$fp = fopen('gs_phonebook.xml', 'wb');
fwrite($fp, $PersonDirectoryListing);
fclose($fp);
print($$PersonDirectoryListing);
echo $PersonDirectoryListing;
?>
Munlan
Featured -
Search:








