Sunteți pe pagina 1din 12

custom/Extension/modules/Ext/Language/en_us.PopulateCustomRecordNameFieldOnceJob.

ph
p

<?php
$mod_strings['LBL_SUGARCRM_SUGARCRM_CUSTOM_UPCURVE_FILTERPROCESSESBYRECORDNAME_JOBS
_POPULATECUSTOMRECORDNAMEFIELDONCE'] = 'Populate Custom Record Name Field Once';

var a =
"Sugarcrm\Sugarcrm\custom\UpCurve\FilterProcessesByRecordName\Jobs\PopulateCustomRe
cordNameFieldOnce";
a.split("\\").join('_').toUpperCase()

custom/Extension/modules/Ext/ScheduledTasks/en_us.PopulateCustomRecordNameFieldOnce
Job.php

<?php

array_push($job_strings,
'class::Sugarcrm\\Sugarcrm\\custom\\UpCurve\\FilterProcessesByRecordName\\Jobs\\Pop
ulateCustomRecordNameFieldOnce');

custom/src/UpCurve/FilterProcessesByRecordName(package
name)/Jobs/PopulateCustomRecordNameFieldOnce.php

<?php

namespace Sugarcrm\Sugarcrm\custom\UpCurve\FilterProcessesByRecordName\Jobs;

class PopulateCustomRecordNameFieldOnce implements \RunnableSchedulerJob


{
protected $job;

public function setJob(\SchedulersJob $job)


{
$this->job = $job;
}

public function run($data)


{
//Logic

return true;
}
}

-----------------------------------------------------------------------------------
----------------------------------

api call in js

var method = "read";


var url = app.api.buildURL("checkCampaign");
var data = {};
var options = {};

var callbacks = {
success: function successCB(res) {
debugger;
}.bind(this)
};

app.api.call(method, url, data, callbacks, options);

api in php

<?php

if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}

require_once('include/api/SugarApi.php');

class GetInboundEmailApi extends SugarApi


{
public function registerApiRest()
{
return array(
'create' => array(
'reqType' => 'GET',
'path' => array( 'GetInboundEmail', '?' ),
'pathVars' => array( 'GetInboundEmail', 'id' ),
'method' => 'GetInboundEmail',
'shortHelp' => 'Get the inbound email for the reply all
functionality',
'longHelp' => '',
),
);
}

public function GetInboundEmail($api, $args)


{
global $db;
$mailbox_id = $args[ 'id' ];
$sql = "select email_user from inbound_email where id ='$mailbox_id' and
deleted='0' limit 1";

$result = $db->query($sql);
if (!$result) {
return 'no_mailbox_id';
} else {
$row = $result->fetch_assoc();
return $row[ 'email_user' ];
}

return 0;

-----------------------------------------------------------------------------------
------------------------------
//create a status_dom
dropdown(ustom/Extension/application/Ext/Language/en_us.tags_status_dom.php)

<?php

$app_list_strings["tags_status_dom"] = array(
"Active" => "Active",
"Inactive" => "Inactive"
);

------------------------------------------------------------------

//Search for whitespaces " <?php"


ack-grep ' \<\?php'

7.9+
$compiled = $query->compile(); // create compiled prepared statement
$compiled->getSQL(); // fetches parameterized SQL
$compiled->getParameters(); // fetches parameters

$query->compileSQL()

//REMOVE FILES FROM SUGAR


<?php

class UpcurveAutoloader extends SugarAutoloader {


}

if (isset($this->installdefs['remove_files'])) {
foreach($this->installdefs['remove_files'] as $relpath){
if (UpcurveAutoloader::fileExists($relpath)) {
UpcurveAutoloader::unlink($relpath);
}
}
}

?>

UPGRADE

IN FOLDERUL INSTANTEI ex: /media/rradoi/hdd/SVM/global_partners


mkdir leUpgrade
cd leUpgrade/
mkdir 794
mkdir 800

cd /mnt/vagrant_boxes/sugar_instances/
cd ENT
cp SugarEnt-Upgrade-7.9.x-to-7.9.4.0.zip
/media/rradoi/hdd/SVM/global_partners/leUpgrade/794
cp silentUpgrade-PRO-7.9.4.0.zip
/media/rradoi/hdd/SVM/global_partners/leUpgrade/794
cp silentUpgrade-PRO-8.0.0.zip^C^Cdia/rradoi/hdd/SVM/global_partners/leUpgrade/800/
cp SugarEnt-Upgrade-7.9.4.0-to-8.0.0.zip
/media/rradoi/hdd/SVM/global_partners/leUpgrade/800/

pwd
svm ssh->sudo su
cd /vagrant/leUpgrade/794
unzip silentUpgrade-PRO-7.9.4.0.zip
php CliUpgrader.php -z SugarEnt-Upgrade-7.9.x-to-7.9.4.0.zip -l love.log -s
/var/www/html/ -u vagrant
chown -R www-data:www-data /var/www/html/
chmod -R 777 /var/www/html/
cd ../800/
nano /etc/apache2/mods-enabled/php5.load
nano /etc/apache2/mods-enabled/php7.load
phpbrew switch 7.1.1
service apache2 restart
nano /var/www/html/config.php -elasticsearch =>10.4.3.243

unzip silentUpgrade-PRO-8.0.0.zip
php CliUpgrader.php -z SugarEnt-Upgrade-7.9.4.0-to-8.0.0.zip -l
lovemeharderbaby.log -s /var/www/html/ -u vagrant
chown -R www-data:www-data /var/www/html/
chmod -R 777 /var/www/html/

YELLOW FLAGS
cd ../794
grep '\[yellow' love.log

https://gitlab.upcurvecloud.com/KnowledgeBase/SugarUpgrade/wikis/upgrading-sugar-
7.7.x-to-78

ssh -t -t -v -L9988:localhost:9942 bastion ssh -L9942:10.0.0.102:3306 -i


/home/rradoi/.ssh/kp-uswest-sugar-test.pem ec2-user@34.208.73.241
ssh -t -t -v -L9988:rds-sugardb.cgmgnfhffv6c.us-west-2.rds.amazonaws.com:9942
bastion ssh -L9942:10.0.0.30:3306 -i /opt/keys/Essent/kp-uswest-sugar-prod.pem ec2-
user@35.166.175.199

Create post install table

<?php

function createCachingTable($tableName)
{
global $db;

$createCachingTableSQL = <<<SQL
CREATE TABLE IF NOT EXISTS `accounts_process_additional_fields` (
`id` CHAR(50) NULL DEFAULT NULL,
`account_id_to_process` VARCHAR(50) NULL DEFAULT NULL,
`rel_to_calc` VARCHAR(50) NULL DEFAULT NULL,
`implodedArray` TEXT NULL,
`date_entered` TIMESTAMP NULL DEFAULT NULL
)
COLLATE='utf8_general_ci';
SQL;

$db->query($createCachingTableSQL);
}

createCachingTable('accounts_process_additional_fields');
src/scripts/post_execute/create_apaf_table.php
-----------------------------------------------------------------------------------
-------

Create post install job

<?php

$checkIfUpdateAdditionalFieldsJobExists = <<<SQL
SELECT count(*) AS count
FROM schedulers
WHERE job = 'function::update_additional_fields_job'
AND deleted=0;
SQL;
$res_check = $db->query($checkIfUpdateAdditionalFieldsJobExists);
$count_row = $db->fetchByAssoc($res_check);
$count_job = $count_row['count'];

if ($count_job == 0) {
$job = BeanFactory::newBean('Schedulers');
$job->name = "Update Additional Fields on Accounts";
$job->job = "function::update_additional_fields_job";
$job->date_time_start = $timedate->nowDb();
$job->date_time_end = NULL;
$job->job_interval = '1::0::*::*::*';//once a day
$job->status = 'Active';
$job->catch_up = true;
$job->save();
}

src/scripts/post_execute/create_jobs.php
-----------------------------------------------------------------------------------
--------

debug_print_backtrace();
-----------------------------------------------------------------------------------
---------

App.controller.context.attributes.attributes
-----------------------------------------------------------------------------------
---------

/var/www/html/modules/DynamicFields/DynamicField.php, at line 82 change if function


to if(empty($GLOBALS['dictionary'][$this->bean->object_name]['custom_fields'])){
-----------------------------------------------------------------------------------
----------
/etc/mysql/mysql.conf.d/mysqld.cnf
innodb_log_file_size = 512M
innodb_strict_mode = 0
-----------------------------------------------------------------------------------
----------

[28-Feb-2018 12:14:17 UTC] PHP Fatal error: Uncaught exception


'SugarApiExceptionInvalidParameter' with message 'Invalid link created_by_link'
in /media/extension/html/include/SugarQuery/SugarQuery.php:966
Stack trace:
#0 /media/extension/html/include/SugarQuery/SugarQuery.php(396): SugarQuery-
>loadBeans('created_by_link', Array)
#1 /media/extension/html/data/SugarBean.php(3084): SugarQuery-
>join('created_by_link', Array)
#2 /media/extension/html/include/SugarObjects/templates/person/Person.php(37):
SugarBean->retrieve(1, true, true)
#3 /media/extension/html/modules/Users/User.php(781): Person->retrieve(1, true,
true)
#4 /media/extension/html/data/BeanFactory.php(90): User->retrieve(1, true, true)
#5 /media/extension/html/modules/ProjectTask/ProjectTask.php(75):
BeanFactory::getBean('Users', 1)
#6 /media/extension/html/data/BeanFactory.php(238): ProjectTask->__construct()
#7 /media/extension/html/include/SugarObjects/VardefManager.php(769):
BeanFactory::newBean('ProjectTask')
#8 /media/extension/html/include/SugarObjects/VardefManager.php(689): VardefM in
/media/extension/html/include/SugarQuery/SugarQuery.php on line 966

DynamicFields->dynamicfield.php->setup(decomentare build cache)


-----------------------------------------------------------------------------------
---------

Entrypoint for Job Debug


http://{sugar url}/index.php?entryPoint=test

custom/entrypoints/test.php
<?php

require_once('custom/Extension/modules/Schedulers/Ext/ScheduledTasks/UpdateAddition
alFieldsJob.php');
echo "<pre>";
$job = new UpdateAdditionalFieldsOnAccounts();
$job->execute();

?>

custom/Extension/application/Ext/EntryPointRegistry/test.php
<?php

$entry_point_registry['test'] = array(
'file' => 'custom/entrypoints/test.php',
'auth' => true
);
?>
-----------------------------------------------------------------------------------
-----------

Creare Field

custom/Extension/modules/Accounts/Ext/Vardefs/field_name.php
-----------------------------------------------------------------------------------
-----------

Creare Logichook

custom/Extension/modules/Accounts/Ext/LogicHooks/PopulateAdditionalFieldsHook.php
<?php

$hook_array['after_save'][] = Array(
//Processing index. For sorting the array.
1,

//Label. A string value to identify the hook.r


'before_save additional_fields',

//The PHP file where your class is located.


'custom/modules/Accounts/hooks/PopulateAdditionalFields.php',

//The class the method is in.


'PopulateAdditionalFields',

//
'afterSavePopulateAdditionalFields'
);

'custom/modules/Accounts/hooks/PopulateAdditionalFields.php

<?php

if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class PopulateAdditionalFields
{
public function afterSavePopulateAdditionalFields($bean, $event, $arguments)
{

$this->updateNumberOfContacts($bean, $implodedArray);

private function updateNumberOfContacts($bean,$implodedArray) {

}
}

8F3MGyQRBb2xY9fv24ZC

-----------------------------------------------------------------------------------
--------------

Creare Job
custom/Extension/modules/Schedulers/Ext/ScheduledTasks/UpdateAdditionalFieldsJob.ph
p

<?php

array_push($job_strings, 'update_additional_fields_job');

class UpdateAdditionalFieldsOnAccounts
{
function execute()
{
global $db;
$sqlSelectAccounts = "SELECT acc.id, acc_cst.mph_type_c FROM accounts acc
LEFT JOIN accounts_cstm acc_cst ON acc.id = acc_cst.id_c";
$res = $db->query($sqlSelectAccounts);
while ($row = $db->fetchByAssoc($res)) {

$acc_id = $row['id'];
$acc_mph_type = $row['mph_type_c'];
$id_list = Array();

array_push($id_list, $acc_id);

if ($acc_mph_type == "HO") {
$sqlMO = "SELECT acc.id, acc_cst.mph_type_c FROM accounts acc LEFT
JOIN accounts_cstm acc_cst ON acc.id = acc_cst.id_c WHERE parent_id = '{$acc_id}'";
$resSQLMO = $db->query($sqlMO);
while ($row = $db->fetchByAssoc($resSQLMO)) {
foreach ($row as $key => $value) {
if ($value == "MO") {
array_push($id_list, $row['id']);
}
}
}
} elseif ($acc_mph_type == "MO") {
$sqlHO = "SELECT parent_id FROM accounts WHERE id ='{$acc_id}'";
$resSQLHO = $db->query($sqlHO);
while ($row = $db->fetchByAssoc($resSQLHO)) {
array_push($id_list, $row['parent_id']);
}
}

$implodedArray = implode("','", $id_list);

$this->updateDateOfLastVisit($acc_id, $implodedArray);

}
}

private function updateDateOfLastVisit($acc_id,$implodedArray) {


global $db;

$sqlSelectDateOfLastVisit = "SELECT date_start FROM meetings WHERE


parent_id in ('$implodedArray') AND status = 'Held' ORDER BY date_start DESC LIMIT
0,1";
$res_select = $db->query($sqlSelectDateOfLastVisit);
if ($res_select->num_rows == 0) {
$db->query("UPDATE accounts SET date_of_last_visit = '' WHERE
id='{$acc_id}'");
} else while ($row = $db->fetchByAssoc($res_select)) {
$date_start = $row['date_start'];
$db->query("UPDATE accounts_cstm SET date_of_last_visit =
'{$date_start}' WHERE id_c='{$acc_id}'");
}
}

function update_additional_fields_job()
{
$job = new UpdateAdditionalFieldsOnAccounts();
$job->execute();
return true;
}

custom/Extension/modules/Schedulers/Ext/Language/en_us.UpdateAdditionalFieldsJob.ph
p

<?php
$mod_strings['LBL_UPDATE_ADDITIONAL_FIELDS_JOB'] = 'Update additional fields on
Accounts';
-----------------------------------------------------------------------------------
----------------------------------

Extend field on multiple modules

/*eslint-disable */
(function wRemoveScrollFromMCEDescriptionExtension(app) {
// Please note that we need to override views depending on wether they are
// global views or for a specific module.
// Bellow are examples for both types of overrides.

// Overriding Module Controllers:

app.events.on("app:sync:complete", function extendMCEFields() {


var moduleList = ["Notes", "Contacts", "Calls", "Meetings", "Tasks"];

_.each(moduleList, function extendDescriptionField(moduleName) {


var BaseModuleHtmleditable_tinymceField =
"Base" + moduleName + "Htmleditable_tinymceField";
var BaseCustomModuleHtmleditable_tinymceField =
"Base" + moduleName + "CustomHtmleditable_tinymceField";
if (
!app.view.fields.BaseModuleHtmleditable_tinymceField &&
!app.view.fields.BaseCustomModuleHtmleditable_tinymceField
) {
app.view.declareComponent(
"field",
"htmleditable_tinymce",
moduleName,
undefined,
false,
"base"
);
}
var tinymceDescriptionField = BaseModuleHtmleditable_tinymceField;

if (app.view.fields.BaseCustomModuleHtmleditable_tinymceField) {
tinymceDescriptionField =
BaseCustomModuleHtmleditable_tinymceField;
}

if (
app.view.fields[tinymceDescriptionField].wDescriptionField ===
true
) {
return;
}

app.view.fields[tinymceDescriptionField] = app.view.fields[
tinymceDescriptionField
].extend({
wDescriptionField: true,
initialize: function(options) {
var initResult = this._super("initialize", arguments);
return initResult;
},
render: function() {
var renderResult = this._super("render", arguments);

return renderResult;
},
});
});
});
})(SUGAR.App);
-----------------------------------------------------------------------------------
---------------

Extend view snippet

;(function ( app ) {
// Please note that we need to override views depending on wether they are
// global views or for a specific module.
// Bellow are examples for both types of overrides.

// Overriding Module Controllers:


app.events.on( 'app:sync:complete', function () {

if (!app.view.views.BaseContactsPanelTopView && !
app.view.views.BaseContactsCustomPanelTopView) {
app.view.declareComponent("view", "panel-top", "Contacts", undefined,
false, "base");
}

var panelTopView = "BaseContactsPanelTopView";

if (app.view.views.BaseContactsCustomPanelTopView) {
panelTopView = "BaseContactsCustomPanelTopView";
}

if (App.view.views[panelTopView].wFilterContactsOnInvestorOverride ===
true) {
return;
}

App.view.views[panelTopView] = App.view.views[panelTopView].extend({
wFilterContactsOnInvestorOverride: true,
initialize: function(options) {
var initResult = this._super('initialize', arguments);
// custom code
return initResult;
},
render: function() {
// custom code
var renderResult = this._super('render', arguments);
// more custom code
return renderResult;
}
})
});

// Overriding Application Controllers:


app.events.on( 'app:start', function () {

if (!app.view.views.BasePanelTopView && !
app.view.views.BaseCustomPanelTopView) {
app.view.declareComponent("view", "panel-top", undefined, undefined,
false, "base");
}

var panelTopView = "BasePanelTopView";

if (app.view.views.BaseContactsCustomPanelTopView) {
panelTopView = "BaseCustomPanelTopView";
}

if (App.view.views[panelTopView].wFilterContactsOnInvestorOverride ===
true) {
return;
}

App.view.views[panelTopView] = App.view.views[panelTopView].extend({
wFilterContactsOnInvestorOverride: true,
initialize: function(options) {
var initResult = this._super('initialize', arguments);
// custom code
return initResult;
},
render: function() {
// custom code
var renderResult = this._super('render', arguments);
// more custom code
return renderResult;
}
})
})
})(SUGAR.App);

---------------------------------------------------------------------------------
Ascundere subpanel(extensie javascript in custom/include/javascript +jsgrouppings)

(function hideDriftMessagesSubpanel(app) {
app.events.on("app:sync:complete", function extendSubpanelsLayouts() {
if (!app.view.layouts.BaseSubpanelsLayout && !
app.view.layouts.BaseSubpanelsCustomLayout) {
app.view.declareComponent("layout", "subpanels", undefined, undefined,
false, "base");
}

var driftMessagesSubpanel = "BaseSubpanelsLayout";

if (app.view.layouts.BaseSubpanelsCustomLayout) {
driftMessagesSubpanel = "BaseSubpanelsCustomLayout";
}

if (App.view.layouts[driftMessagesSubpanel].uDriftMessagesSubpanel ===
true) {
return;
}

App.view.layouts[driftMessagesSubpanel] =
App.view.layouts[driftMessagesSubpanel].extend({
uDriftMessagesSubpanel: true,

render: function(options) {
var renderResult = this._super("render", arguments);
for (var i = 0; i < this._components.length; i++) {
if (
this._components[i].module == "usys_Drift_Messages" &&
this._components[6].model.link.name ==
"leads_usys_drift_messages_1"
) {
this._components[i].remove();
}
}
return renderResult;
}
});
});
})(SUGAR.App);

S-ar putea să vă placă și