Skip to content

Instantly share code, notes, and snippets.

View esimonetti's full-sized avatar
📃
Open to new opportunities

Enrico Simonetti esimonetti

📃
Open to new opportunities
View GitHub Profile
@esimonetti
esimonetti / SugarCronFilteredJobs.php
Created May 2, 2017 04:13 — forked from jhoffmann/SugarCronFilteredJobs.php
Both files go into custom/include/SugarQueue, then run a Repair to regenerate cache/file_map.php and you're good to go.
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
require_once 'include/SugarQueue/SugarCronJobs.php';
require_once 'custom/include/SugarQueue/SugarJobFilteredQueue.php';
// Sample configuration:
//
@esimonetti
esimonetti / sugarpdf.pdfmanager.php
Created June 19, 2017 10:04
This is just an example of how to print all pdf templates of a module (Contacts) landscape instead of portrait.
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-06-19 on Sugar 7.9.0.0
// filename: custom/modules/Contacts/sugarpdf/sugarpdf.pdfmanager.php
//
// This is just an example of how to print all pdf templates of a module (Contacts) landscape instead of portrait.
// After this customisation is installed, and the system is repaired, all PDF templates for Contacts will be printed landscape instead of portrait
@esimonetti
esimonetti / detail.hbs
Last active June 20, 2017 07:59
This is an example of how to have templates on sidecar modules, printable on either portrait or landscape based on user's choice. It excludes Reports, Quotes and Project as they do have a custom pdf generation
{{!--
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-06-20 on Sugar 7.9.0.0
// filename: custom/clients/base/fields/pdfaction/detail.hbs
//
// Allow for landscape pdf template printing for all modules aside Quotes, Reports and Projects
@esimonetti
esimonetti / indexFinder.php
Last active August 21, 2017 06:22
Sugar 7.9.1.0 POC to remove sorting for all listview, subpanel and popup selection list fields that do not have a database index
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-08-18 on Sugar 7.9.1.0
// filename: custom/include/indexFinder.php
//
// Tool that helps retrieve and cache indexes on a per-module basis
@esimonetti
esimonetti / saveAllContactsAndTriggerAllWorkflows.php
Created August 23, 2017 02:58
Save all Sugar Contacts, preserving the date modified and modified by. Enforce advanced workflows to trigger for each of the contacts
<?php
// Enrico Simonetti
// enricosimonetti.com
function usage($error = '') {
if(!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
print(' php ' . __FILE__ . ' --instance /full/path' . PHP_EOL);
exit(1);
}
@esimonetti
esimonetti / triggerAllWorkflowsForContacts.php
Last active August 23, 2017 04:26
Enforce advanced workflows to trigger for each of the contacts, without processing a save
<?php
// Enrico Simonetti
// enricosimonetti.com
function usage($error = '') {
if(!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
print(' php ' . __FILE__ . ' --instance /full/path' . PHP_EOL);
exit(1);
}
@esimonetti
esimonetti / FakeLinkApi.php
Created August 24, 2017 04:25 — forked from elchele/FakeLinkApi.php
Customization for pulling external/ad-hoc data into a Sugar subpanel
<?php
/* File: ./custom/clients/base/api/FakeLinkApi.php */
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class FakeLinkApi extends SugarApi {
public function registerApiRest() {
return array(
'filterRelatedRecords' => array(
@esimonetti
esimonetti / CustomAccountsRelateApi.php
Last active August 25, 2017 04:59
Sugar 7.9.1.0 example of how to extend the RelateApi to display on the Account's Notes subpanel all its Notes and all its first level members Accounts Notes
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-08-25 on Sugar 7.9.1.0
// filename: custom/modules/Accounts/clients/base/api/CustomAccountsRelateApi.php
//
// Display on the Account's Notes subpanel all its Notes and all its first level members Accounts Notes
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-01 tested on Sugar 7.9.1.0
// Forcing custom Sugar Cache to autoload: https://gist.github.com/esimonetti/78999f4dfbac22fd26bab8453a0ed149
//
// file: custom/Extension/application/Ext/Include/autoload_custom_redis_cache.php
SugarAutoloader::addDirectory('custom/include/SugarCache/');
@esimonetti
esimonetti / notifications.js
Last active November 24, 2017 00:59
Sample customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-24 tested on Sugar 7.9.2.0
// Sample customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
//
// IMPORTANT: Lowering the delay values through the configuration options will increase the frequency of the amount of requests completed to the server, for every user's open browser tab. You need to consider the server load implications and sizing requirements.
//
// file: custom/clients/base/views/notifications/notifications.js