Skip to content

Instantly share code, notes, and snippets.

View betobaz's full-sized avatar

Betobaz betobaz

  • Betobaz
  • Veracruz, Mexico
View GitHub Profile
var sys = require('util'),
rest = require('restler');
var baseurl = "<<instance URL>>/rest/v10"
// get oAuth token
var jsonData = {"grant_type":"password","username":"<<username>>","password":"<<password>>","client_id":"sugar"};
rest.postJson(baseurl+'/oauth2/token', jsonData).on('2XX', function(data) {
if ( data.error ) {
sys.puts("Error: " + data.error_message);
@betobaz
betobaz / logic_hook_notificador.php
Created June 12, 2013 17:03
Notifica por correo y consumiendo un api
<?php
class CasesLogicHook{
protected $urlApiNotifications = 'http://node.test.dev/api/notifications';
protected $notificaciones = array(
'Assigned' => array(
'id_template' => '26735934-183c-4f76-3e97-50984ae40813',
'message' => "El caso con número {case_number} ha sido asignado para su precesamiento.",
),
@betobaz
betobaz / day3x2.php
Last active December 18, 2015 09:59
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="stylesheet" href="style.css">
</head>
<body>
@betobaz
betobaz / PABSCases.php
Created June 7, 2013 17:24
SugarCRM CE logic hook para el envio de notificaciones
<?php
class AbproCases{
protected $urlApiNotifications = 'http://node.abpro.dev/api/notifications';
protected $notificaciones = array(
'Assigned' => array(
'id_template' => '26735934-183c-4f76-3e97-50984ae40813',
'message' => "El caso con número {case_number} ha sido asignado para su precesamiento.",
),
@betobaz
betobaz / cases.metadata.editviewdef.php
Created June 6, 2013 18:58
Archivo de meta datos de la vista de edición de casos
<?php
$viewdefs ['Cases'] =
array (
'EditView' =>
array (
'templateMeta' =>
array (
'maxColumns' => '2',
'widths' =>
array (
@betobaz
betobaz / contacts_birthday_job.php
Last active December 18, 2015 03:38
Job para actualizar el campo birthday_today_c para indicar que el contacto cumple años el día. Se requiere crear un campo personalizado de tipo casilla de verificación que se llame birthday_today_c
<?php
array_push($job_strings, 'contacts_birthday_job');
function contacts_birthday_job(){
clearContactsBirthday();
$GLOBALS['log']->debug('JOB::contacts_birthday_job:start');
setBirthday();
return true;
}
function clearContactsBirthday(){
<?php
if ($data['type'] == 'parent') {
//See if we need to join anything by inspecting the where clause
$match = preg_match('/(^|[\s(])parent_(\w+)_(\w+)\.name/', $where, $matches);
if ($match) {
$joinTableAlias = 'jt' . $jtcount;
$joinModule = $matches[2];
$joinTable = $matches[3];
$localTable = $this->table_name;
@betobaz
betobaz / how_util.js
Created December 6, 2012 16:18
Plugin para gestionar campos de comparación
$('input.compare').managerFieldCompare({
"types":["eq","lt" , "gt", "lte", "gte", "btn"],
"comboClass": "input input-small",
"inputClass": "input input-small",
callback: function(inputs){
$(inputs).datepicker();
}
});
@betobaz
betobaz / Sugarcrm:EditView modify pre display
Created November 21, 2012 23:44
Modificación del vista de edición para asignar valores antes de desplegar
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.edit.php');
class CustomViewEdit extends ViewEdit {
var $ev;
var $type ='edit';
var $useForSubpanel = false; //boolean variable to determine whether view can be used for subpanel creates
var $useModuleQuickCreateTemplate = false; //boolean variable to determine whether or not SubpanelQuickCreate has a separate display function
var $showTitle = true;
@betobaz
betobaz / gist:2966537
Created June 21, 2012 15:42
Consulta con Linq con agrupadores dinamicos
from d in Vt_cxc_docs_clas2
where Math.Round((double)d.Saldo, 2, MidpointRounding.AwayFromZero) != 0
group d by new{
agrupador = "ClasificacionContable" == "" ? d.Desc_clas :
"Corporativo" == "Corporativo" ? d.Nom_corp :
"ClasificacionAlterna" == "" ? d.Des_clas2:
"TipoImpuesto" == "" ? d.Des_impto:
"CondicionPago" == "" ? d.Des_cnd_pag:
"MedioEnvio" == "" ? d.Des_med_env:
"Vendedor" == "" ? d.Nom_vendedor: