I want the dropdown options to call a function to change the subtheme to dawn, day, dusk, or night on click.
I’m stuck here on how to write the function to setDawn() and change the user preference onlick to dawn subtheme. once I figure that out, then I can write setDay() and so forth.
any help to reference and change from the tpl file would be appreciated
Thanks for the reply @vijay1992 . Not quite what I’m looking for, I know how to create/modify subtheme and css. I need to onclick change the subtheme from the “Quick Create” button in the header.
Thanks for the reply @BrozTechnologies . Not quite what I’m looking for, I know how to create/modify subtheme and css in custom directory. I need to onclick change the subtheme dynamically from the “Quick Create” button in the header.
I solved this. with .$post from headerModuleList.tpl to a custom entrypoint and custom php script
@BrozTechnologies you were right, I had to logout at after updating encoded user db of current user record identifying key value subtheme as Var. solved this with :
$current_user->reloadPreferences();
also added custom logos in top left corner of header to represent value streams and marking custom field in every module as related value stream.
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
//echo 'Switch to ' .$_POST['value']. ' Value Stream';
switch ($_POST['value']) {
case 'company1':
$vs = 'C1';
$subt = 'dawn';
break;
case 'Company2':
$vs = 'C2';
$subt = 'dusk';
break;
case 'Company3':
$vs = 'C3';
$subt = 'day';
break;
case 'Company4':
$vs = 'C4';
$subt = 'night';
break;
};
global $current_user, $db;
$current_user -> value_stream_c = $vs;
$current_user -> save();
$sql = "SELECT contents FROM user_preferences WHERE category='global' AND assigned_user_id= '$current_user->id'";
$result = $db->query($sql);
while ($row = $db->fetchByAssoc($result)) {
$prefs = array();
$newprefs = array();
$prefs = unserialize(base64_decode($row['contents']));
$subthemeValue = $prefs['subtheme'];
$newsubtheme = $prefs['subtheme']= ($subt);
$newprefs = $prefs;
$newsubtheme2 = base64_encode(serialize($newprefs));
$update = "UPDATE user_preferences SET contents = '{$newsubtheme2}' WHERE category='global' AND assigned_user_id= '$current_user->id'";
$db->query($update);
$sql2 = "SELECT contents FROM user_preferences WHERE category='global' AND assigned_user_id= '$current_user->id'";
$result2 = $db->query($sql2);
$current_user->reloadPreferences();
unset($prefs);
unset($newprefs);
unset($newstr);
exit;
}
?>