| Server IP : 138.197.176.125 / Your IP : 216.73.217.122 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/suitesupport.varianceinfotech.net/ |
Upload File : |
<?php
include_once("includes/main/WebUI.php");
require_once("include/utils/utils.php");
require_once("modules/Emails/mail.php");
global $current_user;
$current_user = Users::getActiveAdminUser();
//email address
//define("ADMIN_EMAIL","info@varianceinfotech.com");
//define("SUPPORT_EMAIL","techsupport@varianceinfotech.com");
define("ADMIN_EMAIL","varianceinfotech@gmail.com");
define("SUPPORT_EMAIL","varianceinfotechtech203@gmail.com");
define("SALES_EMAIL","urvi.variance@gmail.com");
define("ADMIN_NAME","Rahul");
define("SUPPORT_NAME","Vijay");
define("SALES_NAME","Urvi");
//email address
$ADMINEMAIL = constant("ADMIN_EMAIL");
$SUPPORTEMAIL = constant("SUPPORT_EMAIL");
$SALESEMAIL = constant("SALES_EMAIL");
// get the webhook response
$body = @file_get_contents('php://input');
/*$body = '{"id": "198","object": "event","attempt": 1,"webhook": "trial_cancelled","created_at": 1375705760,"data": {"lineitem": {"id": "458","plan_id": "83","plan_name": "30-day Free Trial Version","order_number": "198","price": "10.00","subtotal": "100.00","discount": "0.00","tax": "0.00","total": "100.00","payout_amount": "70.00","created_at": "1375705758","trial": true,"trial_ends": 1378297758,"trial_status": "Trial Cancelled","subscription": true,"subscription_status": "Active","structure": "Per User Pricing","numbers_users": "10","frequency": "Monthly Fee"},"member": {"id": "14","username": "sampleuser","display_name": "Sample User","email": "sample1.user@email.com","url": "https://store.suitecrm.com/members/sampleuser"},"quitreason":{"quit_reason" : "test1" },"licensekey": {"key": "28aded8s9f83890ef6csdf9309526f8a7","user_count": "10","updated_at": "1375705760","created_at": "1375705760","active": true},"addon": {"id": "18","name": "MultiSMTP","shortname": "test-addon","url": "https://store.suitecrm.com/addons/test-addon","updated_at": "1375356990","created_at": "1335990852"}}}'; */
/*
{"id":74747,"attempt":1,"webhook":"trial_cancelled","created_at":1641196148,"data":{"lineitem":{"id":37136,"plan_id":930,"plan_name":"One Time Cost","order_number":17713,"order_source":"","price":"199.00","subtotal":"199.00","discount":"0.00","tax":"0.00","total":"199.00","payout_amount":"139.30","created_at":1638866338,"object":"lineitem","trial":true,"trial_ends":1641458338,"trial_status":"Trial Cancelled","subscription":false,"subscription_status":null,"structure":"Flat Pricing","number_users":null,"frequency":"One-time Fee"},"member":{"id":23690,"username":"joetcw","display_name":"joetcw","email":"joetcw@hotmail.com","company":null,"url":"https:\/\/store.suitecrm.com\/customer\/joetcw","avatar":"https:\/\/www.gravatar.com\/avatar\/3a787f161eb913000a049ceb33c1fbd7?d=mm","object":"member"},"licensekey":{"key":"fcf8f5ef3e31d87f8e3110d1da87ab0c","user_count":0,"updated_at":1640850550,"created_at":1638866338,"trialing_until":null,"plan_id":"930","plan_name":"One Time Cost","object":"licensekey","source":"","customer_key":null,"active":true,"suspended":false},"quitreason":{"changed_crm":null,"crm_name":"0","testing":"1","not_needed":"0","not_tried":"0","install_issues":"0","lack_of_support":"0","quit_reason":"","created_at":1641196148,"formatted_reason":"Done testing for a future project. "},"addon":{"id":380,"name":"Reminder and Notification","shortname":"reminder-and-notification","url":"https:\/\/store.suitecrm.com\/addons\/reminder-and-notification","updated_at":1639724808,"created_at":1560837133,"object":"addon"}},"object":"event"}
*/
//store webhook response in file
file_put_contents("suiteCRMWebhookResponse.txt",$body);
// decode the json data into a php object
$response = json_decode($body);
file_put_contents('testsuitecrmwebhook.txt', $body);
//exit;
file_put_contents("suiteCRMWebhookResponse1.txt",print_r($array, true));
switch ($response->webhook){
case 'sale_new':
// Someone purchased your add-on, your code goes here
file_put_contents("suiteCRMWebhookResponse2.txt",$response->webhook);
SugarOutfittersHelper::sale_new($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
case 'subscription_cancelled':
file_put_contents("suiteCRMWebhookResponse3.txt",$response->webhook);
// subscription cancelled, your code goes here
SugarOutfittersHelper::subscription_cancelled($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
case 'trial_cancelled':
file_put_contents("suiteCRMWebhookResponseTrialCancelled.txt",$response);
// trial cancelled, your code goes here
SugarOutfittersHelper::trial_cancelled($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
case 'case_created':
file_put_contents("suiteCRMWebhookResponse4.txt",$response->webhook);
// case created, your code goes here
SugarOutfittersHelper::case_created($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
case 'case_updated':
file_put_contents("suiteCRMWebhookResponse5.txt",$response->webhook);
// case updated, your code goes here
SugarOutfittersHelper::case_updated($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
case 'case_comment_created':
file_put_contents("suiteCRMWebhookResponse6.txt",$response->webhook);
// case comment created, your code goes here
SugarOutfittersHelper::case_comment_created($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
case 'trial_converted':
file_put_contents("suiteCRMWebhookResponse7.txt",$response->webhook);
// case comment created, your code goes here
SugarOutfittersHelper::trial_converted($response, $ADMINEMAIL, $SUPPORTEMAIL, $SALESEMAIL);
break;
default:
//defaul case
break;
}//end of switch
class SugarOutfittersHelper {
public static function sale_new($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
$addon = $response->data->addon;
$member = $response->data->member;
$lineitem = $response->data->lineitem;
if ($member->email != ''){
$addOnName = 'SuiteCRM-'.$addon->name;
$contactId = SugarOutfittersHelper::getContactsData($member->email);
if($contactId == 0){
$recordModelContacts = Vtiger_Record_Model::getCleanInstance('Contacts');
$recordModelContacts->set('mode', '');
$recordModelContacts->set('assigned_user_id',1);
$recordModelContacts->set('lastname',$member->display_name);
$recordModelContacts->set('email',$member->email);
$recordModelContacts->set('technology','SuiteCRM');
$recordModelContacts->set('lead_stage','New Lead');
$recordModelContacts->set('leadsource','SuiteCRM-Addons');
$recordModelContacts->save();
if($recordModelContacts->getId()) {
$id = SugarOutfittersHelper::addCustomerOrder($recordModelContacts->getId(),$addOnName, $member->email, $lineitem);
/*if($id) {
$memberEmailId = $member->email;
$subject = "Thanks for your order of SuiteCRM Extension";
$contentAdmin = SugarOutfittersHelper::sale_new_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$memberEmailId,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}*/
}
}else{
$customerOrderId = SugarOutfittersHelper::getCustomerOrderData($contactId,$addOnName);
if($customerOrderId == 0){
$id = SugarOutfittersHelper::addCustomerOrder($contactId,$addOnName, $member->email, $lineitem);
/*if($id) {
$memberEmailId = $member->email;
$subject = "Thanks for your order of SuiteCRM Extension";
$contentAdmin = SugarOutfittersHelper::sale_new_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$memberEmailId,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}*/
}
}
}
}
public static function subscription_cancelled($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
$addon = $response->data->addon;
$member = $response->data->member;
$addOnName = 'SuiteCRM-'.$addon->name;
$subject = "Your SuiteCRM Extension has been cancelled";
$memberEmailId = $member->email;
$contactId = SugarOutfittersHelper::getContactsData($memberEmailId);
if($contactId != 0){
$customerOrderId = SugarOutfittersHelper::getCustomerOrderDataSubScriptionCancelled($contactId,$addOnName);
if(!empty($customerOrderId)){
foreach ($customerOrderId as $key => $value) {
$recordModelCustomerOrder = Vtiger_Record_Model::getInstanceById($value,'CustomerOrder');
$recordModelCustomerOrder->set('mode', 'edit');
$recordModelCustomerOrder->set('subscription_status','Cancelled');
$recordModelCustomerOrder->save();
}
$contentAdmin = SugarOutfittersHelper::subscription_cancelled_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$memberEmailId,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}
}
}
public static function trial_cancelled($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
$addon = $response->data->addon;
$member = $response->data->member;
$addOnName = 'SuiteCRM-'.$addon->name;
$quitReason = $response->data->quitreason;
$trialCancelledReason = '';
/*if($quitReason->changed_crm == true){
$trialCancelledReason .= 'The customer canceled due to changing CRMs.';
}else if($quitReason->crm_name != ''){
$trialCancelledReason .= 'The name of the CRM that the customer changed to : '.$quitReason->crm_name;
}else if($quitReason->testing == true){
$trialCancelledReason .= 'The customer was testing the add-on for a future project.';
}else if($quitReason->not_needed == true){
$trialCancelledReason .= 'The customer did not need the add-on anymore.';
}else if($quitReason->not_tried == true){
$trialCancelledReason .= 'The customer was not able to try the add-on yet.';
}else if($quitReason->install_issues == true){
$trialCancelledReason .= 'The customer had issues installing or setting up the add-on.';
}else if($quitReason->lack_of_support == true){
$trialCancelledReason .= 'The customer could not get the support needed to get the add-on working.';
}
if($quitReason->quit_reason != ''){
$trialCancelledReason .= "\nAdditional Information of Quit Reason : ".$quitReason->quit_reason;
}//end of if*/
if($quitReason->formatted_reason != ''){
$trialCancelledReason .= $quitReason->formatted_reason;
}
$subject = "Your SuiteCRM Extension has been cancelled";
$memberEmailId = $member->email;
$contactId = SugarOutfittersHelper::getContactsData($memberEmailId);
if($contactId != 0){
$customerOrderId = SugarOutfittersHelper::getCustomerOrderData($contactId,$addOnName);
$recordModelCustomerOrder = Vtiger_Record_Model::getInstanceById($customerOrderId,'CustomerOrder');
$recordModelCustomerOrder->set('mode', 'edit');
$recordModelCustomerOrder->set('order_status','Trial Cancelled');
$recordModelCustomerOrder->set('trial_cancellation_reason',html_entity_decode($trialCancelledReason));
$recordModelCustomerOrder->save();
/*if($recordModelCustomerOrder->getId()) {
$contentAdmin = SugarOutfittersHelper::trial_cancelled_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$memberEmailId,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL, $SALESEMAIL,$OutgoingConfigurationEmail);
}*/
}
}
public static function trial_converted($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
$addon = $response->data->addon;
$member = $response->data->member;
$addOnName = 'SuiteCRM-'.$addon->name;
$subject = "Your SuiteCRM Extension has been approved";
$memberEmailId = $member->email;
$contactId = SugarOutfittersHelper::getContactsData($memberEmailId);
if($contactId != 0){
$customerOrderId = SugarOutfittersHelper::getCustomerOrderData($contactId,$addOnName);
$recordModelCustomerOrder = Vtiger_Record_Model::getInstanceById($customerOrderId,'CustomerOrder');
$recordModelCustomerOrder->set('mode', 'edit');
$recordModelCustomerOrder->set('order_status','Trial Converted');
$recordModelCustomerOrder->save();
if($recordModelCustomerOrder->getId()) {
$contentAdmin = SugarOutfittersHelper::trial_converted_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$memberEmailId,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}
}
}
public static function case_created($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
file_put_contents("suiteCRMWebhookResponse8.txt",$response->webhook);
$member = $response->data->member;
$addon = $response->data->addon;
$addOnName = 'SuiteCRM-'.$addon->name;
$subject = "SuiteCRM Store - Client created Case";
//$cc = $ADMINEMAIL.",".$SALESEMAIL;
$contentAdmin = SugarOutfittersHelper::case_created_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$SUPPORTEMAIL,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}
public static function case_updated($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
file_put_contents("suiteCRMWebhookResponse9.txt",$response->webhook);
$member = $response->data->member;
$addon = $response->data->addon;
$addOnName = 'SuiteCRM-'.$addon->name;
$subject = "SuiteCRM Store - Case has been updated";
//$cc = $SUPPORTEMAIL.",".$SALESEMAIL;
$contentAdmin = SugarOutfittersHelper::case_updated_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$SUPPORTEMAIL,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}
public static function case_comment_created($response,$ADMINEMAIL,$SUPPORTEMAIL,$SALESEMAIL) {
file_put_contents("suiteCRMWebhookResponse10.txt",$response->webhook);
$member = $response->data->member;
$addon = $response->data->addon;
$addOnName = 'SuiteCRM-'.$addon->name;
$subject = "SuiteCRM Store - Case comments has been added";
$contentAdmin = SugarOutfittersHelper::case_comment_created_email_templete($response);
$OutgoingConfigurationEmail = SugarOutfittersHelper::getFromEmailAddress();
send_mail("SuiteCRM-Addons",$SUPPORTEMAIL,"Variance Infotech PVT LTD",$OutgoingConfigurationEmail,$subject,$contentAdmin,$ADMINEMAIL,$SALESEMAIL,$OutgoingConfigurationEmail);
}
public static function sale_new_email_templete($response){
global $site_URL;
$addon = $response->data->addon;
$member = $response->data->member;
$lineitem = $response->data->lineitem;
$bodyHtml = "<html>
<head></head>
<body>
<div style='width:100%;''>
<p>Hello,</p>
<p>Thank you for using VIPL ".$addon->name." from SuiteCRM Store.</p>
<p>Your Order number : ".$lineitem->order_number."</p>
<p>Please review User manual and steps mentioned in the installation guide.</p>
<p>For any questions or concern feel free to email us on <a href='#'>info@varianceinfotech.com</a> OR call us on our phone # +1-630-861-8263. Please quote your order number for any communication with our team.</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</div>
</body>
</html>";
return $bodyHtml;
}
public static function subscription_cancelled_email_templete($response){
global $site_URL;
$addon = $response->data->addon;
$member = $response->data->member;
$lineitem = $response->data->lineitem;
$quitReason = $response->data->quitreason;
$dateCreated = date('m/d/Y H:i:s',$response->created_at);
$bodyHtml = "<html>
<head></head>
<body>
<p>Hello,</p>
<p>We're really sorry that you have cancelled SuiteCRM extensions - ".$addon->name." from SuiteCRM Store.</p>
<p>Your Order number : ".$lineitem->order_number."</p>
<p>Let us know if you're facing any problem with extensions so our team will help you on the same.</p>
<p>We're committed to provide you best Post sales service to make sure your investment will be worthful.</p>
<p>For any questions or concern feel free to email us on <a href='#'>info@varianceinfotech.com</a> OR call us on our phone # +1-630-861-8263. Please quote your order number for any communication with our team.</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</body>
</html>";
return $bodyHtml;
}
public static function trial_cancelled_email_templete($response){
global $site_URL;
$addon = $response->data->addon;
$member = $response->data->member;
$lineitem = $response->data->lineitem;
$bodyHtml = "<html>
<head></head>
<body>
<div style='width:100%;''>
<p>Hello,</p>
<p>We're really sorry that you have cancelled SuiteCRM extensions - ".$addon->name." Trial from SuiteCRM Store.</p>
<p>Your Order number : ".$lineitem->order_number."</p>
<p>Let us know if you're facing any problem with extensions so our team will help you on the same.</p>
<p>We're committed to provide you best Post sales service to make sure your investment will be worthful.</p>
<p>For any questions or concern feel free to email us on <a href='#'>info@varianceinfotech.com</a> OR call us on our phone # +1-630-861-8263. Please quote your order number for any communication with our team.</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</div>
</body>
</html>";
return $bodyHtml;
}
public static function trial_converted_email_templete($response){
global $site_URL;
$addon = $response->data->addon;
$member = $response->data->member;
$lineitem = $response->data->lineitem;
$bodyHtml = "<html>
<head></head>
<body>
<div style='width:100%;''>
<p>Hello,</p>
<p>We're pleased to inform you that SuiteCRM extensions - ".$addon->name." has been converted from Trial to Paid.</p>
<p>Your Order number : ".$lineitem->order_number."</p>
<p>Let us know if you're facing any problem with extensions so our team will help you on the same.</p>
<p>We're committed to provide you best Post sales service to make sure your investment will be worthful.</p>
<p>For any questions or concern feel free to email us on <a href='#'>info@varianceinfotech.com</a> OR call us on our phone # +1-630-861-8263. Please quote your order number for any communication with our team.</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</div>
</body>
</html>";
return $bodyHtml;
}
public static function case_created_email_templete($response){
global $site_URL;
$case = (array)$response->data->case;
$caseId = $case['id'];
$caseStatus = $case['status'];
$caseDescription = $case['description'];
$member = $response->data->member;
$addon = $response->data->addon;
$bodyHtml = "<html>
<body>
<p>Hello,</p>
<p>Following case has been created by client</p>
<p>Case number : ".$caseId." </p>
<p>Client name : ".$member->display_name."</p>
<p>Extension detail : ".$addon->name."</p>
<p>Case Status : ".$caseStatus."</p>
<p>Case Details : ".$caseDescription."</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</body>
</html>";
return $bodyHtml;
}
public static function case_updated_email_templete($response){
global $site_URL;
$case = (array)$response->data->case;
$caseId = $case['id'];
$caseStatus = $case['status'];
$caseDescription = $case['description'];
$member = $response->data->member;
$addon = $response->data->addon;
$bodyHtml = "<html>
<body>
<p>Hello,</p>
<p>Following case has been created by client</p>
<p>Case number : ".$caseId." </p>
<p>Client name : ".$member->display_name."</p>
<p>Extension detail : ".$addon->name."</p>
<p>Case Status : ".$caseStatus."</p>
<p>Case Details : ".$caseDescription."</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</body>
</html>";
return $bodyHtml;
}
public static function case_comment_created_email_templete($response){
global $site_URL;
$case = (array)$response->data->case;
$caseId = $case['id'];
$caseStatus = $case['status'];
$caseDescription = $case['description'];
$member = $response->data->member;
$addon = $response->data->addon;
$comment = $response->data->comment;
$bodyHtml = "<html>
<body>
<p>Hello,</p>
<p>Following case has been created by client</p>
<p>Case number : ".$caseId." </p>
<p>Client name : ".$member->display_name."</p>
<p>Extension detail : ".$addon->name."</p>
<p>Case Status : ".$caseStatus."</p>
<p>Case Details : ".$caseDescription."</p>
<p>Comments : ".$comment->content."</p>
<p>Enjoy the power of SuiteCRM extension build by Variance InfoTech Team.</p>
<p><b>Our Online Support Hours :</b><br>
11:30 PM US Eastern Time to 09:00 AM US Eastern Time<br>
04:30 AM GMT Time to 02:00 PM GMT Time</p>
<p>Thank you,<br>SuiteCRM Team<br>Variance Infotech Pvt Ltd</p>
</body>
</html>";
return $bodyHtml;
}
public static function getFromEmailAddress() {
$db = PearDatabase::getInstance();
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$fromEmail = false;
$result = $db->pquery('SELECT from_email_field FROM vtiger_systems', array());
if($db->num_rows($result) > 0) {
$fromEmail = decode_html($db->query_result($result, 0, 'from_email_field'));
if(empty($fromEmail)) {
$result1 = $db->pquery('SELECT email1 FROM vtiger_users WHERE is_admin=?', array('on'));
if ($db->num_rows($result1)) {
$fromEmail = decode_html($db->query_result($result1, 0, 'email1'));
if (empty($fromEmail)) $fromEmail = $currentUserModel->get('email1');
}
}
}
return $fromEmail;
}
public static function getContactsData($email){
global $adb;
$selContact = $adb->pquery("select vtiger_contactdetails.*, vtiger_contactsubdetails.leadsource from vtiger_contactdetails INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid INNER JOIN vtiger_contactsubdetails ON vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid WHERE vtiger_contactdetails.email = ? AND vtiger_contactsubdetails.leadsource = ? AND vtiger_crmentity.deleted = 0",array($email, 'SuiteCRM-Addons'));
$countContact = $adb->num_rows($selContact);
if($countContact > 0){
$contactId = $adb->query_result($selContact,0,'contactid');
}else{
$contactId = 0;
}
return $contactId;
}
public static function getCustomerOrderData($contactId,$addOnName){
global $adb;
$selCustomerOrder = $adb->pquery("select vtiger_customerorder.* from vtiger_customerorder INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_customerorder.customerorderid WHERE vtiger_customerorder.contact_name = ? AND vtiger_customerorder.addons_name = ? AND vtiger_customerorder.order_status != ? AND vtiger_crmentity.deleted = 0",array($contactId,$addOnName,'Trial Cancelled'));
$countCustomerOrder = $adb->num_rows($selCustomerOrder);
if($countCustomerOrder > 0){
$customerOrderId = $adb->query_result($selCustomerOrder,0,'customerorderid');
}else{
$customerOrderId = 0;
}
return $customerOrderId;
}
public static function getCustomerOrderDataSubScriptionCancelled($contactId,$addOnName){
global $adb;
$selCustomerOrder = $adb->pquery("select vtiger_customerorder.* from vtiger_customerorder INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_customerorder.customerorderid WHERE vtiger_customerorder.contact_name = ? AND vtiger_customerorder.addons_name = ? AND vtiger_crmentity.deleted = 0",array($contactId,$addOnName));
$countCustomerOrder = $adb->num_rows($selCustomerOrder);
if($countCustomerOrder > 0){
$customerOrderId = array();
for($i=0;$i<$countCustomerOrder;$i++) {
$customerOrderId[] = $adb->query_result($selCustomerOrder,$i,'customerorderid');
}
}else{
$customerOrderId = array();
}
return $customerOrderId;
}
public static function addCustomerOrder($contactId,$addOnName,$customerEmail,$lineItemData){
$recordModelCustomerOrder = Vtiger_Record_Model::getCleanInstance('CustomerOrder');
$recordModelCustomerOrder->set('mode', '');
$recordModelCustomerOrder->set('assigned_user_id',1);
$recordModelCustomerOrder->set('customerEmail',$customerEmail);
$recordModelCustomerOrder->set('plan_name', $lineItemData->plan_name);
$recordModelCustomerOrder->set('addons_name',$addOnName);
$recordModelCustomerOrder->set('order_no', $lineItemData->order_number);
$recordModelCustomerOrder->set('order_date', date('Y-m-d', $lineItemData->created_at));
$recordModelCustomerOrder->set('order_status','New Order');
$recordModelCustomerOrder->set('order_source', 'SuiteCRM Store');
$recordModelCustomerOrder->set('contact_name',$contactId);
$recordModelCustomerOrder->set('trial_exp_date', date('Y-m-d', $lineItemData->trial_ends));
//$recordModelCustomerOrder->set('trial_status', $lineItemData->trial_status);
$recordModelCustomerOrder->set('order_price', $lineItemData->price);
$recordModelCustomerOrder->set('order_total', $lineItemData->total);
$recordModelCustomerOrder->set('order_payout_amt', $lineItemData->payout_amount);
$recordModelCustomerOrder->set('subscription_status', $lineItemData->subscription_status);
$recordModelCustomerOrder->set('cf_1155', 'E1');
$recordModelCustomerOrder->save();
return $recordModelCustomerOrder->getId();
}
}//end of class