24 February 2015

How to send an SMS in hebrew or any other language other than english with clickatell in vtiger

Today we had to modify vtiger to allow users to send sms in language other than english, after lot of research we were able to get this done

When sending sms through clickatell, you need to convert the message string to a UNICODE characters before submitting to the gateway. Because clickatell has its own unicode convertor.

So we added following function to modules/SMSNotifier/providers/clickatell.php

public function hex_chars($data){
    $mb_hex = '';
    for($i = 0 ; $i<mb_strlen($data,'UTF-8') ; $i++){
        $c = mb_substr($data,$i,1,'UTF-8');
        $o = unpack('N',mb_convert_encoding($c,'UCS-4BE','UTF-8'));
        $mb_hex .= sprintf('%04X',$o[1]);
    }
    return $mb_hex;
} 

then converted the message string passed in send function as follows

$params['text'] = $this->hex_chars($message);

you also have to pass unicode parameter to your message as follows

$params['unicode'] = 1;

25 December 2014

Enable Jquery Tooltip for Click Event Only

Let us say we have a div element as follows

<div title = "jQuery Tooltip on Click" id = "tooltip" > jQuery Tooltip on Click </div>

you can use below mentioned script to enable jquery tooltip only on click

jQuery("document").ready(function(){ 

    $('#tooltip').tooltip({disabled: true}).on("click", function() { 
     
     if($("#tooltip").hasClass("opentooltip")){ 
      
      $("#tooltip").tooltip("close"); 
      
      $("#tooltip").removeClass("opentooltip"); 
     
     } else {
      
      $("#tooltip").addClass("opentooltip"); 
      
      $(this).tooltip("enable").tooltip("open").off("mouseover mouseout mouseleave");
      
     }
     
    });
    // Disable Default MouseOver Behavior for Div
    $("#tooltip").hover(function(e){ e.preventDefault(); });
    
   });

05 July 2014

Sample Code to Perform Insert, Update and Read Operation on Lead Module of Zoho through Zoho API

Before using, sign up for Zoho CRM Zoho Sign UP and set your zoho credentials
<?php

 $username = "";
 $password = "";
 $param = "SCOPE=ZohoCRM/crmapi&EMAIL_ID=".$username."&PASSWORD=".$password;
 
 $ch = curl_init("https://accounts.zoho.com/apiauthtoken/nb/create");
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
 $result = curl_exec($ch);
 
 $anArray = explode("\n",$result);
 $authToken = explode("=",$anArray['2']);

 curl_close($ch);
 

Sample Code to create Invoice into Quickbooks using Quickbook API


Few days ago, we were working on a project to sync Quickbooks invoice data with 3rd party application,
But after writing initial code we were getting error CheckNullResponseAndThrowException - Response Null or Empty everytime, but as such there was no solution available for this problem even on google, so somehow we were able to debug the problem, the problem was with customer id that needs to be passed as a string instead of integer value

So here is sample working code you can use to generate invoice

<?php
require_once('../config.php');
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'DataService/DataService.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');

//Specify QBO or QBD
$serviceType = IntuitServicesType::QBO;

// Please set your own config values
$accessToken = 'NULL';
$accessTokenSecret = 'NULL';
$consumerKey = 'NULL';
$consumerSecret = 'NULL';
$realmId = 'NULL';

20 June 2014

Increase Default Logout time of Vtiger

Today one of our client asked us to increase default Logout time of Vtiger, so here is a small chunk of code that you can add to increase it yourself

Open config.inc.php in root folder and add following code at top

ini_set("session.gc_maxlifetime", 3600);

The above code will increase default logout time to 1 Hour