Thursday, June 14, 2012

[Solved] Problems Installing Payslip module using vtlib in vtiger


When installing Payslip module using vtib from "VtigerCRM_5.2.0_Vtlib.pdf", I faced some problems. I want to share how I solved those problem.

Problem 1:
------------------------------------------------------------------------------------------------------------
I installed the Payslip module but when I clicked on Payslip link in vtiger, it showed blank page.

For this, open your php.ini file
Remove comment from line:
             error_reporting = E_ALL & ~E_NOTICE

Tuesday, May 22, 2012

Dependent Dropdown in SugarCRM (SugarCE)

In order to make dependent dropdown, first you need to create 2 independent dropdown list from sugar admin panel. Let's say country_c and city_c with Item Name as below:

For country_c menu:
Item Name                    Display Name
AAA                             Thailand
BBB                              Nepal

For city_c menu:
Item Name                   Display Name
AAA_1                        Bangkok
AAA_2                        Phuket
BBB_1                         Lumbini
BBB_2                         Pokhara

Here you can see that if Item Name for country is AAA then the corresponding Item Name for city is AAA_1, AAA_2 i.e. it starts with AAA.

Wednesday, April 11, 2012

How to make Nagios monitor its service at particular Time Period

I am considering that you already know how to add custom services. If not, please have a look at my previous post:  http://codebyte.blogspot.com/2012/03/adding-custom-services-for-windows-host.html

Suppose you want to monitor your service at 16:00 to 16:15 and 18:00 to 18:15 hours everyday.

First of all, you need to open your timeperiod.cfg file in your nagios server installation directory.
Add the following lines,
define timeperiod{
         timeperiod_name               24X7custom
         alias                                   24X7custom
         sunday                               16:00-16:15,18:00-18:15
         monday                             16:00-16:15,18:00-18:15
         tuesday                             16:00-16:15,18:00-18:15
         wednesday                        16:00-16:15,18:00-18:15
         thursday                           16:00-16:15,18:00-18:15
         friday                                16:00-16:15,18:00-18:15
         saturday                           16:00-16:15,18:00-18:15
}

Tuesday, March 27, 2012

Adding custom services for Windows host to be monitored by Nagios (Monitoring MS SQL Database Table)

Nagios has many in-built services which can be easily configured for a host so that it can be monitored. Services for Windows host like check cpu load, drive space, running processes can be monitored by using various parameters in check_nt command.
While monitoring, situation comes when you have to monitor a specific service which may be a part of an application, size of particular file or a table in database and many others. In these cases, you have to make your own customized program/script to monitor them. Nagios should be configured to run this customized program and get its output and show the service status.

Saturday, March 24, 2012

Kannel–A quick installation and configuration guide

Kannel is free and open source SMS and WAP gateway. It is easy to use, install and configure. This article will describe a quick and easy steps for installing and configuring this gateway for sending and receiving SMS.
Installation
Kannel in based on Linux and can be easily installed from repository. It is available in both aptitude and yum repositories and can be installed right away by giving their respective commands.
apt-get install kannel
or
yum install kannel
If you don’t find it in repository, then you can add more repositories. This link gives guide to add repository to CentOS. You can find for other Linux distribution too.
Configuration
After you install, you will find a file named kannel.conf at /etc/. The configuration file for my modem Nokia30 is shown below.

Monday, March 19, 2012

[Solved] Kinamu Reporter 'Invalid argument supplied' Problem

You might have seen the below error in Kinamu Reporter:
Warning: Invalid argument supplied for foreach() in \modules\KReports\KReportQuery.php on line 401
Warning: reset() expects parameter 1 to be array, null given in \modules\KReports\KReportQuery.php on line 784
Warning: Invalid argument supplied for foreach() in \modules\KReports\KReportQuery.php on line 785

This problem comes when you have not added any field in the selection criteria.
While creating report, on the right panel under Report Definition, you can see 2 things: Selectioncriteria and Display Fields. Problem occurs when you add fields only in Display Field but not in Selectioncriteria.

Let us suppose that you added first name and last name from module contacts in Display Fields, then the query will be:
select first name, last name from contacts

This statement should work but in basic version of Kinamu Reporter, this statement alone does not work. So you need to specify parameters in Selectioncriteria also. Adding parameters in Selectioncriteria means that you are specifying where clause for the query statement. For e.g. if you set first_name = 'Poonam' in Selectioncriteria, then the query will be:
select first name, last name from contacts where first_name = 'Poonam'

This solves the problem.

Thursday, March 15, 2012

Remove 'View Change Log' from SugarCRM Detail View

For 'Contacts' Module

1. Copy file from  'sugarcrm\modules\Contacts\metadata\detailviewdefs.php' to  sugarcrm\custom\modules\Contacts\metadata\detailviewdefs.php

Inside the form array, add 1 line,
'hideAudit' => true,

Go to Admin->Repair->Quick Repair and Rebuild. This will execute the code.

Do the same for other modules replacing 'Contacts' by 'your-module'.

Remove 'Direct Reports' from SugarCRM Contacts subpanel

Create Directory: sugarcrm\custom\Extension\modules\Contacts\Ext\Layoutdefs

Create a file named layoutdefs.ext.php inside this directory with code as below:
<?php unset($layout_defs['Contacts']['subpanel_setup']['contacts']); ?>

Go to Admin->Repair->Quick Repair and Rebuld. This will execute the code

Remove 'Duplicate' from Detail View of SugarCRM

1. Copy file from  'sugarcrm\modules\Contacts\metadata\detailviewdefs.php' to  sugarcrm\custom\modules\Contacts\metadata\detailviewdefs.php

2. Inside the form arrary, you will see an array with values 'edit', 'delete', 'duplicate'. Remove 'duplicate' from the array.

Go to Admin->Repair->Quick Repair and Rebuild. This will execute the code.

Remove 'Import Contacts' from SugarCRM

1. Go to directory: sugarcrm\custom\Extension\modules\Contacts\Ext\Menus
   (Create the directory if you already don't have one)
2. Create a file: menu.ext.php
   
Write the below code in that file

foreach ($final_module_menu as $key => $val){
if($val[1] == $mod_strings['LNK_IMPORT_CONTACTS'])
unset($final_module_menu[$key]);
}

If you check the file sugarcrm\modules\Contacts\Menu.php, you can see the code for all menus that are seen in Action Menu of contacts.

$final_module_menu is the array which contains all those values:
$final_module_array =
Array (
    [0] =>Array ( [0] => index.php?module=Contacts&action=EditView&return_module=Contacts&return_action=index [1] => Create Contact [2] => CreateContacts [3] => Contacts )
    [1] => Array ( [0] => index.php?module=Contacts&action=ImportVCard [1] => Create Contact From vCard [2] => CreateContacts [3] => Contacts )
    [2] => Array ( [0] => index.php?module=Contacts&action=index&return_module=Contacts&return_action=DetailView [1] => View Contacts [2] => Contacts [3] => Contacts )
    [3] => Array ( [0] => index.php?module=Import&action=Step1&import_module=Contacts&return_module=Contacts&return_action=index [1] => Import Contacts [2] => Import [3] => Contacts ) )

So comparing $val[1] with the value of the item we want to remove, gives the required $key value.

After making any changes in the file, go to Admin->Repair->Quick Repair and Rebuild. This will execute the code.

Note: Sugarcrm Version - Sugarcrm 6.0.2

Tuesday, October 4, 2011

Using Rsync to synchronize files/folders from Windows to Linux with SSH tunnel


Rsync Server on Linux

1. Rsync can be found in Linux repository and is easy to install using yum or apt-get commands.
                >> yum install rsync
                >> apt-get install rsync

2. Create a file rsyncd.conf at /etc and add following lines
                >> nano /etc/rsyncd.conf
               [your_user_sync]
                path = /home/your_user/backup
                comment = backup
                uid = your_user
                gid = your_user
                read only = false
                auth users = your_user
                secrets file = /etc/rsyncd.secrets
Here your_user is the username in your Linux machine.

Thursday, July 28, 2011

Nagios Client (NRPE) installation in Linux

i. Create Account Information
Become the root user. You may have to use sudo -s on Ubuntu and other distros.
su -l
Create a new nagios user account and give it a password.
/usr/sbin/useradd nagios
passwd nagios

ii. Install the Nagios Plugins
Create a directory for storing the downloads.
mkdir ~/downloads
cd ~/downloads

Nagios Client(NSClient) Installation in Windows

Installing nagios client is very simple. Download NSClient from location:
http://nsclient.org/nscp/downloads

You can download NSClient for 64 or 32 bit computer as required.

Copy NSClient in any folder. For e.g. D:\Nagios

Double click and install it. You will be asked for following information:
Allowed host: 'IP of your nagios server'
NSClient Password: 'Password you used when installing nagios server'
Also, enable the modules you need.

 Now configuration is finished. Restart NSClient. Fo this, go to 
Control Panel->Administrative Tools->Services->NSClient++
Start/Restart it.

Quick Installation of Nagios in CentOS

Nagios is a system and network monitoring application. Installation process is as below:

Prerequisites:
Before installing Nagios, you need to install the following on your linux machine:
     Apache
     PHP
     GCC compiler
     GD development libraries
You can use yum to install these packages by running the command:
yum install httpd php
yum install gcc glibc glibc-common
yum install gd gd-devel

Thursday, July 21, 2011

Completely Unistall MySQL

Whenever you install MySQL, uninstall it and try to install it again, you might not be able to do so because MySQL will ask for the old password. You cannot install MySQL if you do not have the old password. Solution for this is:

  • Uninstall MySQL
  • Go to your MySQL installation folder for e.g. C:\Program Files and delete the MySQL folder
  • Delete MySQL from your AppData folder. I am using windows XP and in my case, the location is C:\Documents and Settings\All Users\Application Data. Here you will find MySQL folder. Delete this folder.
  • Finally, reinstall MySQL and you should be able to install it successfully.

Sunday, July 17, 2011

Transferring cake baked code from windows to centos (linux)

First thing to do is to install cakephp in centos. Please refer to my previous blog on this(http://codebyte.blogspot.com/2011/07/installing-cakephp-in-centos.html) if you have not already installed cakphp.

Now, transfer your code to your document root (For e.g. /var/www/html in my case). Suppose, the name of your application is myapp, then
1. Open var/www/html/myapp/webroot/index.php

  • Search for if (!defined('CAKE_CORE_INCLUDE_PATH')).
  • You may find something like: define('CAKE_CORE_INCLUDE_PATH', 'C:' . DS. 'xampp' .DS. 'cake' if you used xampp in windows.
  • Change this to the location of your installed cakephp folder. For e.g. define('CAKE_CORE_INCLUDE_PATH', .DS . 'var' . DS. 'www' .DS. 'html' .DS. 'cake')

2. Open /var/www/html/myapp/config/database.php and provide appropriate database settings.

Finally, restart your apache server (/etc/init.d/httpd restart).

Installing CakePHP on CentOS

Download Cakephp
https://github.com/cakephp/cakephp/downloads

Rename it to something like cake. Extract from .tar.gz files.
tar -xvzf cake

Put 'cake' folder inside your document root. For e.g. if your document root is /var/www/html, put the cake folder inside it. Then follow some guidelines below.
1. Give appropriate permission setting for your 'cake' folder.
2. Open /cake/app/config/core.php. Go to the line where security.salt is defined and change it to some other value. Also do the same for security.cipherSeed.
3. Rename database.default.php to database.php and provide appropriate database settings

Now, open your browser and go to http://localhost/cake.

If you do no see any color in the page, you might want to check two things. Go to /etc/httpds/conf/httpd.conf and
1.  Search for mod_rewrite.so and check if LoadModule rewrite_module_modules modules/mod_rewrite.so is commented. If so, remove the comment.
2. Search for 'Options Indexed FollowSymLinks' and change 'AllowOverride None' to 'AllowOverride All' as below:
   <Directory />
    Options Indexed FollowSymLinks
    AllowOverride All
   </Directory>
 Note: Make sure you make the change in 'Options Indexed FollowSymLinks' and not in 'Options FollowSymLinks'.

Finally, restart apache (/etc/init.d/httpd restart).

Slow Connection to MySQL installed on windows from linux (Solved)

If you have MySQL installed in Windows server and you are querying from Linux, you might notice that the performance of you application is very slow. This is because, when your application in Linux connects to database in Windows, even a simple query takes 3-4 seconds to execute.

The solution for this problem is to put a line 'skip-nam-resovle' in my.ini of your mysql server. Search for [mysqld] in my.ini and put that line below it as below.

[mysqld]
skip-name-resolve

Saturday, June 25, 2011

Installing SugarCRM on Apache Web Server

Steps:
1. Create a database say 'sugarcrm'.

2. If you want to use open source SugarCRM, download SugarCRM Community Edition
   http://www.sugarcrm.com/crm/download/sugar-suite.html

3. Unzip it and place inside your application server deployment folder. Rename it with some name for e.g. sugarcrm.

4. Open your browser and type the url of your sugarcrm. For e.g. http://localhost/sugarcrm in my case. You will then see the sugarcrm page, click next. After that you will see a page as shown below.



  • Check if  php, database and web server are of supported version. If you are working in linux:     
    • You might need to give enough write permission to session variables by giving read and write access to 'session' located in  /var/lib/php/session
    •  Give appropriate read and write permission to config.php file located inside sugarcrm folder
    •  Give appropriate read and write permission to folders inside sugarcrm like custom, cache and modules
    • To install MB string and curl
      • yum install php_curl, php_mbstring (for CentOS)
    • If you are working in windows and want to  install MB strings, go to php.ini and    
      • ;extension=php_mbstring.dll with
      • extension=php_mbstring.dll
        check if php_mbstring.dll is present inside php 'ext' folder. 
      • To enable curl, uncheck php_curl.dll and check if it is present inside php 'ext' folder
    • Restart web server

5. Finally, you should be able to see 'Confirm Setting' page as shown below. In this page, if you see some of the modules not found, then you can enable the modules in php.ini as mentioned in step 4.


Now, after some steps, you will be redirected to sugarcrm login page. Login to the page and make the settings according to your requirement.

Connect MSSQL using ODBC in Linux (CentOS)

For connecting MSSQL using ODBC in Linux you can use unixODBC and freeTDS.  unixODBC is a tool for using ODBC in Non Windows platform. MSSQL uses Tabular Data Stream (TDS) as a communication protocol which is same like in Sybase. freeTDS is an implementation of TDS protocol.

Installing unixODBC
      1.      Install gcc
#yum install gcc

      2.      Download unixODBC and untar it
#mkdir /root/downloads
#cd /root/downloads
#wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.0.tar.gz
#tar –xzf unixODBC-2.3.0.tar.gz
#cd unixODBC-2.3.0

      3.      Install unixODBC
#./configure
#make
#make install

Installing freeTDS
     1.      Set environmental variable at /etc/profile. Add following lines at end
#nano /etc/profile


# TDS
SYBASE=/usr/local 
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib 
export SYBASE LD_LIBRARY_PATH 
/etc/profile

     2.      Download freeTDS and untar it
#cd /root/downloads
#wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-0.82.tar.gz
#tar –xzf freetds-0.82.tar.gz
#cd freetds-0.82
     3.      Install freeTDS
# ./configure --with-tdsver=8.0 --with-unixodbc=/usr/local
#make
#make install

     4.      Now all your library will be inside /usr/local/lib and configuration files inside /usr/local/etc

     5.      Make template to register ODBC driver with unixODBC
#nano /usr/local/etc/tds.driver.template


[FreeTDS]
Description     = v0.63 with protocol v8.0
Driver          = /usr/local/lib/libtdsodbc.so
tds.driver.template
     6.      Now install the driver entry using above template
# odbcinst -i -d -f /usr/local/etc/tds.driver.template

     7.      Make template to create ODBC data source name
#nano /usr/local/etc/tds.datasource.template


[MSSQLTest]
Driver  = FreeTDS
Description     = Sample Database
Trace   = No
Server      = 192.168.0.1
Port      = 1433
Database        = TestDB
tds.datasource.template
     8.      Now create odbc data source using above template
# odbcinst -i -s -f /usr/local/etc/tds.datasource.template

     9.      Finish. You can test it by giving command
                       # isql -v MSSQLTest username password