Skip to content

Instantly share code, notes, and snippets.

@maranemil
maranemil / gist:bf2aa32fadefe8f74d75
Last active August 29, 2015 14:18
SugarCRM7 Ajax Request
$.ajax({
beforeSend: function (request) {
request.setRequestHeader("OAuth-Token", SUGAR.App.api.getOAuthToken());
},
url: "rest/v10/cplus_ContactsPlus/create_cplus",
data: { type: "cplus", societyname: this.model.get('name') },
dataType: "json",
type: "GET",
success: function (data) {
var obj = jQuery.parseJSON(data);
@maranemil
maranemil / gist:924f4dcfb59b2ec022b9
Last active February 5, 2020 10:56
Custom AutoIncrement Field in SugarCRM
/**
April 22, 2014 in Desarrollo, Sugar
1.) Custom AutoIncrement Field(having unique value):
For declaring “autoincrement” field in sugacrm do as follows:
Suppose we have to declare “Au Pair number” field as an autoincrement field in suagcrm. For this we have to declare vardef in custom/Extension/modules/oss_auPairs/Ext/Vardefs/vardefs.ext.php as follows:
*/
$dictionary["oss_auPairs"]["fields"]["aupair_number"] =array (
@maranemil
maranemil / gist:afe14558fb66d2290bdd
Last active August 29, 2015 14:18
Read Collections and Parent Infos in SugarCRM7
Read parent info in subpanel-list.js:
var ctx = this.context.parent, parentModelId = ctx.get("modelId"), parentModule = ctx.get("module");
if(parentModule == 'Accounts'){
// do some action here
var parentBean = app.data.createBean(parentModule, {id:parentModelId}), request = parentBean.fetch();
request.xhr.done(function(){
//get the field you need to verify
@maranemil
maranemil / gist:2d1b8aa8dc12f54cb46c
Last active August 29, 2015 14:19
SugarCRM7 Override DropDownList on Record.js or Create.js
//custom/modules/Accounts/clients/base/views/create-actions/create-actions.js
({
// CustomCreate-actions View (base)
extendsFrom: 'CreateActionsView',
events: {
'change input[name=industry]':'OverrideAccountType'
},
initialize: function (options) {
this._super('initialize', [options]);
@maranemil
maranemil / gist:606dfccd61f4e49cdb3a
Created April 16, 2015 03:17
SugarCRM7 Add Colors in Views
// http://laurenthinoul.com/how-to-add-a-record-color-to-a-listview-in-sugarcrm/
({
extendsFrom: 'RecordlistView',
initialize: function (options) {
app.view.invokeParent(this, {type: 'view', name: 'recordlist', method: 'initialize', args: [options]});
this.collection.on('data:sync:complete', function () {
this.renderColors();
}, this);
},
@maranemil
maranemil / gist:f8920962ae9ee9b0d8ce
Created April 16, 2015 05:16
SugarCRM7 Add DropDown List - Populate list with ajax
// by EvilPeri
//custom/modules/<your module>/clients/base/fields/enum/enum.js
({
extendsFrom: 'EnumField',
_render: function(){
if(this.name == 'your field name here'){
if(_.isEmpty(this.items)){
this.setItems();
return;
@maranemil
maranemil / gist:b5df6ab5ee3f3d6921a9
Last active August 29, 2015 14:19
SugarCRM7 Filter fields definitions
//clients/base/filters/operators/operators.php
//clients/base/api/FilterApi.php
//clients/base/layouts/filter/filter.js
//clients/base/layouts/filterpanel/filterpanel.js
$viewdefs['base']['filter']['operators'] = array(
'multienum' => array(
'$contains' => 'LBL_OPERATOR_CONTAINS', // is any of
'$not_contains' => 'LBL_OPERATOR_NOT_CONTAINS',
),
@maranemil
maranemil / gist:210423541f812030723d
Created April 21, 2015 07:59
PHP Error Log Settings in php scripts
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
ini_set('log_errors', 1);
//ini_set("error_log", "/path/to/php-error.log");
ini_set('html_errors',FALSE);
error_log( "Hello log errors!" ); // write some hallo in log
@maranemil
maranemil / gist:983b97ba313aa221041a
Created April 21, 2015 08:00
Set some crons in crontab for SugarCRM
sudo /opt/lampp/xampp stop
crontab -e
crontab -l
crontab: usage error: unrecognized option
usage: crontab [-u user] file
crontab [ -u user ] [ -i ] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user's crontab)
@maranemil
maranemil / gist:f585135deebdb841510b
Created April 24, 2015 08:40
Open a pdf in a new tab
// http://stackoverflow.com/questions/12730581/use-this-php-code-to-open-a-pdf-in-a-new-tab
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
exit();