Documente Academic
Documente Profesional
Documente Cultură
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;
return true;
}
}
-----------------------------------------------------------------------------------
----------------------------------
api call in js
var callbacks = {
success: function successCB(res) {
debugger;
}.bind(this)
};
api in php
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
require_once('include/api/SugarApi.php');
$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"
);
------------------------------------------------------------------
7.9+
$compiled = $query->compile(); // create compiled prepared statement
$compiled->getSQL(); // fetches parameterized SQL
$compiled->getParameters(); // fetches parameters
$query->compileSQL()
if (isset($this->installdefs['remove_files'])) {
foreach($this->installdefs['remove_files'] as $relpath){
if (UpcurveAutoloader::fileExists($relpath)) {
UpcurveAutoloader::unlink($relpath);
}
}
}
?>
UPGRADE
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
<?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
-----------------------------------------------------------------------------------
-------
<?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
-----------------------------------------------------------------------------------
---------
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,
//
'afterSavePopulateAdditionalFields'
);
'custom/modules/Accounts/hooks/PopulateAdditionalFields.php
<?php
class PopulateAdditionalFields
{
public function afterSavePopulateAdditionalFields($bean, $event, $arguments)
{
$this->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']);
}
}
$this->updateDateOfLastVisit($acc_id, $implodedArray);
}
}
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';
-----------------------------------------------------------------------------------
----------------------------------
/*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.
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);
-----------------------------------------------------------------------------------
---------------
;(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.
if (!app.view.views.BaseContactsPanelTopView && !
app.view.views.BaseContactsCustomPanelTopView) {
app.view.declareComponent("view", "panel-top", "Contacts", undefined,
false, "base");
}
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;
}
})
});
if (!app.view.views.BasePanelTopView && !
app.view.views.BaseCustomPanelTopView) {
app.view.declareComponent("view", "panel-top", undefined, undefined,
false, "base");
}
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");
}
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);