Skip to content

Instantly share code, notes, and snippets.

@jmertic
jmertic / pm-record-logic.js
Created July 30, 2014 15:54
pm-record-logic.js for this blog post http://wp.me/p419c4-2SB
View pm-record-logic.js
({
className: 'pm-record-logic tcenter',
initialize: function(options) {
this._super("initialize", arguments);
this.context.on('button:pm_record_reports:click', this.pmRecordReports, this);
},
pmRecordReports: function() {
var object_id = this.model.get('id');
var object_name = this.model.attributes._module;
app.api.call('GET', app.api.buildURL('PM_ProcessManager/' + object_id + '/record_reports/' + object_name), null, {
@jmertic
jmertic / pm-record-logic.hbs
Created July 30, 2014 15:51
pm-record-logic.hbs for this blog post http://wp.me/p419c4-2SB
View pm-record-logic.hbs
<div id="pm-record-logic">
</div>
@jmertic
jmertic / pm-record-logic.php
Created July 30, 2014 15:50
pm-record-logic.php for this blog post http://wp.me/p419c4-2SB
View pm-record-logic.php
<?php
$viewdefs['base']['layout']['pm-record-logic'] = array(
'type' => 'simple',
'components' => array(
array(
'view' => 'pm-record-logic',
),
),
);
@jmertic
jmertic / record.php
Created July 30, 2014 15:49
./custom/clients/base/views/record/record.php for this blog post http://wp.me/p419c4-2SB
View record.php
<?php
require_once('clients/base/layouts/record/record.php');
if(isset($viewdefs['base']['layout']['record']['components'])){
foreach($viewdefs['base']['layout']['record']['components'] as &$subArray){
if(isset($subArray['layout']['components'])){
foreach($subArray['layout']['components'] as &$subsubArray){
if(isset($subsubArray['layout']['components'])){
$subsubArray['layout']['components'][] = array(
'layout' => 'pm-record-logic',
@jmertic
jmertic / record.php
Created July 30, 2014 15:46
record.php for this blog post http://wp.me/p419c4-2SB
View record.php
<?php
require_once('clients/base/views/record/record.php');
foreach($viewdefs['base']['view']['record']['buttons'] as &$set){
if( $set['type'] == 'actiondropdown' && $set['name'] == 'main_dropdown'){
$set['buttons'][] = array(
'type' => 'rowaction',
'event' => 'button:pm_record_reports:click',
'name' => 'pm_record_reports',
@jmertic
jmertic / pm-record-logic.js
Created July 30, 2014 15:43
pm-record-logic.js for this blog post http://wp.me/p419c4-2SB
View pm-record-logic.js
initialize: function(options) {
this._super("initialize", arguments);
this.context.on('button:pm_record_reports:click', this.pmRecordReports, this);
},
View gist:5a1e09870b4c754a39e4
{
"grant_type":"password",
"client_id":"sugar",
"client_secret":"",
"username":"admin",
"password":"password",
"platform":"myspecialapp" // change 'myspecialapp' to whatever you want to refer to your app as
}
View profileactions.hbt
...abbreviated
<div class="dropdown-menu scroll pull-right">
<ul role="menu">
<li class="profileactions-profile"><a href="{{profileUrl}}">{{str "LBL_PROFILE"}}</a></li>
<li class="profileactions-employees"><a href="{{employeesUrl}}">{{str "LBL_EMPLOYEES"}}</a></li>
{{#if showAdmin}}
<li class="administration"><a href="#Administration">{{str "LBL_ADMIN"}}</a></li>
{{/if}}
<li class="profileactions-about"><a href="#bwc/index.php?module=Home&action=About">{{str "LNK_ABOUT"}}</a></li>
<li class="profileactions-logout"><a href="#logout/?clear=1">{{str "LBL_LOGOUT"}}</a></li>
@jmertic
jmertic / ReportsExportCsvApi.php
Created November 7, 2013 02:40
Example of extending the REST API in Sugar 7. This example overrides the OOTB Reports export functionality to enable CSV exports. To use this, drop the file in the custom/Reports/clients/base/api/ directory.
View ReportsExportCsvApi.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*
* Copyright (c) 2013, John Mertic
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
View gist:7336266
<?php
function link_record_beans($bean1, $bean2){
$m1 = $bean1->module_dir;
$m2 = $bean2->module_dir;
$rel=getRelationshipByModules($m1, $m2); //see link to previous post for this function
if($rel !== FALSE){
if($rel[1] == $m1){
$class = $bean1->object_name;
$id = $bean1->id;