Skip to content

Instantly share code, notes, and snippets.

View chadhutchins's full-sized avatar

Chad Hutchins chadhutchins

View GitHub Profile
@chadhutchins
chadhutchins / save-all-products.php
Created July 30, 2013 12:13
Loop through each Product (Quote line items) in SugarCRM and save it. You can use something like this to update SugarLogic/Calculated fields for a module.
<?php
$sql = "SELECT id FROM products WHERE deleted=0";
$result = $GLOBALS["db"]->query($sql);
while ($product = $GLOBALS["db"]->fetchByAssoc($result))
{
$product = BeanFactory::getBean("Products",$product["id"]);
$product->save();
}
@chadhutchins
chadhutchins / sugarcrm-quote-line-item-subtotal-sugarlogic
Created July 30, 2013 11:53
SugarLogic Calculated Field script to calculate the subtotal, with respect to quantity and provided discount (dollar amount or percentage), for product line items on SugarCRM Quotes.
ifElse(
$discount_select,
multiply(
subtract(
$discount_price,
multiply(
$discount_price,
divide(
$discount_amount,
100
<?php
// ...
// CTCode Customization
// if the field name is ctc_ctcodes_accounts_name
// change the field def and field type to IN
if ($fieldName == 'ctc_ctcodes_accounts_name')
{
$fieldName = 'id';
<?php
$beanList['Opportunities'] = 'SOCustomOpportunity';
$beanFiles['SOCustomOpportunity'] = 'custom/modules/Opportunities/SOCustomOpportunity.php';
$objectList['Opportunities'] = 'Opportunity';
<?php
include('modules/MySettings/StoreQuery.php');
class defaultSearch
{
function filterList(&$bean, $event, $arguments)
{
global $current_user, $sugar_config;
@chadhutchins
chadhutchins / AccountButtons.php
Created December 13, 2012 15:11
An easy way to add items to the action buttons used throughout the SugarCRM UI.
<?php
class AccountButtons {
function add()
{
// Based on what action we're in, add some buttons!
switch ($GLOBALS['app']->controller->action)
{
case "DetailView": // Add buttons to Detail View
@chadhutchins
chadhutchins / accounts_logic_hook.php
Created November 28, 2012 22:01
Installing Global Logic Hooks in SugarCRM using the Module Loader
<?php
class Accounts_logic_hook_class
{
function Accounts_logic_hook_method(&$bean, $event, $arguments)
{
echo "Hit the Accounts before save logic hook";
exit;
}
}
<?php
$mod_strings['LBL_ABC_MODULE_LINK2_TITLE'] = 'Link 2 Title'; // title of the link
$mod_strings['LBL_ABC_MODULE_LINK2_DESCRIPTION'] = 'The description for what link w will do. Put whatever you want here.'; // description for the link
<?php
// initialize a temp array that will hold the options we want to create
$links = array();
// add button1 to $links
$links['abc_Module']['link1'] = array(
// pick an image from /themes/Sugar5/images
// and drop the file extension
<?php
class Break_AjaxUI
{
static $first = false;
function echo_something($bean,$event,$arguments)
{
// echo something once
if (!self::$first && isset($_REQUEST['action'] && $_REQUEST['action']=='DetailView')