Skip to main content

Posts

Showing posts from May, 2014

ADD CUSTOM FIELD TO SUGARCRM

Create custom/Extension/modules/{module_name}/Ext/Vardefs/Vardefs.php  Here play with dictionary array and define fields accordingly Create file custom/Extension/modules/{module_name}/Ext/Language/en_us.{custom_modulename}.php This is a language file and you have to define variable that actually displays a label, here you have to use modstring array. Create file custom/modules/{module_name}/metadata/detailviewdefs.php place your cusotm fields here if you want to display those fields in detail view of that module. Create file custom/modules/{module_name}/metadata/editviewdefs.php Place your fields here if you want to show these fields in edit view

ADD CHECK BOX IN DEFAULT SEARCH FORM IN SUGARCRM

If you want to search for only customer type of accounts, then follow these steps you will be successful to achieve this functionality Open   SearchFields.php place this code inside this file ‘customer_only’ => array( ‘query_type’=>’default’, ‘db_field’=>array(‘account_type’), ‘operator’=>’in’, ‘closed_values’ => array(‘Customer’), ‘type’=>’bool’, ), Now open searchdefs.php ‘customer_only’ => array ( ‘name’ => ‘customer_only’, ‘label’ => ‘LBL_CUSTOMER_ONLY_FILTER’, ‘type’ => ‘bool’, ‘default’ => false, ‘width’ => ’10%’, ), to be on safer side repair and rebuild and open your account module and check this check box will be there and will be functional.

CUSTOM WHERE CLASS IN SUGARCRM DASHLETS

How to add custom where class in sugar dashlets??? for example if you want to see top opportunities dashlet containing only filtered opportunities on some condition then you can do this as below require_once(‘modules/Opportunities/Dashlets/MyOpportunitiesDashlet/MyOpportunitiesDashlet.php’); class MyOpportunitiesCustomDashlet extends MyOpportunitiesDashlet { function MyOpportunitiesCustomDashlet($id, $def = null) { global $current_user, $app_strings, $dashletData; require(‘modules/Opportunities/Dashlets/MyOpportunitiesDashlet/MyOpportunitiesDashlet.data.php’); parent::MyOpportunitiesDashlet($id, $def); } function process($lvsParams = array()) { $lvsParams = array( ‘custom_select’ => ”, ‘custom_from’ => ”, ‘custom_where’ => ‘ AND opportunities.sales_stage=\’Qualification\”, ‘distinct’ => true ); parent::process($lvsParams); } } these codes are only hints, you should know where these piece of codes should be placed to be working..

AJAX BANNED MODULES

In SugarCRM if you want to ban ajax only for particular modules then go to your config_override.php file and add this code $sugar_config['addAjaxBannedModules'][] = “KReports”; //disable ajaxgui for specific module in config override. Now you have done

SUGARCRM ACL ROLES

If you want to get roles for particular user one of the easiest way is Get user roles global $current_user; require_once(“modules/ACLRoles/ACLRole.php”); $acl_role_obj = new ACLRole(); $user_roles = $acl_role_obj->getUserRoles($current_user->id); // grab a list of the current user’s roles foreach ($user_roles as $role) { $role_to_check=$role; }

CONDITIONAL STATEMENTS

Conditional statement syntax is almost same as in other langauges If condition syntax if (condition) { //Code to let user access the site here; } if else statement syntax if(condition){ //code that should be executed if true }else{ //code that should be executed if condition false } ifelse statement syntax if(condition1){ //code }elseif(condition2){ //code } Switch statement in php switch(variable){ case ‘one’: //code break; case ‘two’: //code here break; default: //default code here break; } note: break statement is very important

LOOPS

for loop: for($start=0; $start < 11; $start++) { echo "for loop test";//text will be printed 11 times } while loop: while (condition) { //statement } do while loop: do statement while (condition) The difference is that your statement gets executed at least once. In a normal while loop, the condition could be met before your statement gets executed.

CONTINUE & BREAK

continue and break statements in php are very importants these are very usefull in loops if you want to skip at any point in loop and you want that after this condition below code should not be executed then use continue example: for($i=0;$i<10;$i++){ if($i==6) break;// loop will be terminated and after 6 it will be outside from loop scope echo "before continue"; continue; echo "after continue";//this will never be executed }

SORTING PHP ARRAY VALUES

There may be times when you want to sort the values inside of an array. For example, suppose your array values are not in alphabetical order. Like this one: $full_name = array(); $full_name["Roger"] = "Waters"; $full_name["Richard"] = "Wright"; $full_name["Nick"] = "Mason"; $full_name["David"] = "Gilmour"; To sort this array, you just use the assort( ) function. This involves nothing more complex than typing the word asort, followed by round brackets. In between the round brackets, type in the name of your Associative array: asort( $full_name ); The letter “a” tells PHP that the array is an Associative one. (If you don’t have the “a” before “sort”, your key names will turn in to numbers!). The “a” also tells PHP to sort by the Value, and NOT by the key. In our script above, the surnames will be sorted. If you want to sort using the Key, then you can use ksort() instead. If you have a Scalar ar...

FOR EACH LOOP AND ASSOCIATIVE ARRAY

You can iterate over an associative array using for each loop like below $arr=array("one"=>1,"two"=>2,"three"=>3); foreach ($arr as $key => $value) { print "Key = " . $key . " Value = " . $value . " "; } you can get array keys by using $keys=array_keys($arr); now $keys contain array of keys;//array(“one”,”two”,”three”);

HOW TO SEARCH AN ELEMENT IN MULTIDIMENTIONAL ARRAY

How to search in multidimensional array function in_multiarray($elem, $array,&$path) { foreach($array as $key => $value) { if($array[$key] == $elem){ $path[$key]=$key;return true; } else if(is_array($array[$key])){ $path[$key]=$key; if(in_multiarray($elem, ($array[$key]),$path)){ return true; } } } return false; } $path=array(); if(in_multiarray(1212,$arr,$path)){ echo "TRUE"; print_r($arr); }else{ echo "FALSE"; }

LOGGING IN PHP

Simple and easy way for logging in php First, install Apache log4php. create a configuration file named config.xml containing: 1.<configuration xmlns="http://logging.apache.org/log4php/"> 2.    <appender name="myAppender"> 3.        <param name="file" value="myLog.log" /> 4.    </appender> 5.    <root> 6.        <level value="WARN" /> 7.        <appender_ref ref="myAppender" /> 8.    </root> 9.</configuration> This configuration file does the following: line 2: Creates an appender named myAppender using appender class LoggerAppenderFile which is used for logging to a file. line 3: Sets the file parameter, which tells the appender to which file to write. line 6: Sets the root logger level to WARN. This means that logging requests with the level lower than WARN will ...

MYSQL FORMATED OUTPUT

Most of the time when we run select statement in mysql command line if number of columns are more then we get output that is unread able from that command line ,get mysql select output formated sql select output vertically formated using following command select * from test\G; by appending \G at the end of your select statement you will get result as following *************************** 1. row *************************** column1: abc column2: test column3: admin column4: 2012-11-15 column5: test@gmail.com column6: test column7: test2 7 rows in set (0.00 sec)

PHP DATABASE CONNECTION

//connecting to db $conn = mysql_connect("localhost","peter","abc123"); if (!$conn) { die('Could not connect: ' . mysql_error()); } // some code mysql_close($conn); // closing connection //query db $data=$conn->query("SELECT * FROM myTable "); foreach($data as $row) { print_r($row); }

Create Forms in codeigniter instantly

Create Forms in codeigniter instantly Guys this is very useful website if you want to create forms in CodeIgniter http://formigniter.org/app/ some snaps here You can download source code from  https://github.com/ollierattue/FormIgniter

Remove Index.php in CodeIgniter

If you are using  Codeigniter  you are noticed that by default  index.php  will be included with your  URL . But you can easily remove index.php from your CodeIgniter’s URL so that your URL should be like: http://techmatters1.blogspot.com /site/contact To do this just follows the following steps: Open  config.php  from  system/application/config  directory and replace $config['index_page'] = “index.php”  by  $config['index_page'] = “” Create a  “.htaccess”  file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it: RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] In some case the default setting for  uri_protocol  does not work properly. To solve this...