AnsweredAssumed Answered

First day of the week

Question asked by rosvol rosvol on Aug 29, 2014
Hello, everyone!   

part 1:


so, there is some issue with User Preference fdow parameter - its mismatching selected key with 1 (looks like some index related "games" ). So if you choose Monday it will show Sunday and if Truesday - Monday, etc. 


I get deeper into the code and noticed at file /modules/Users/UserViewHelper.php such lines at function setupAdvancedTabLocaleSettings(): 

// FG - Bug 4236 - Managed First Day of Week  $fdowDays = array();  foreach ($app_list_strings['dom_cal_day_long'] as $d) {   if ($d != "") {    $fdowDays[] = $d;   }  }  $this->ss->assign("FDOWOPTIONS", $fdowDays);  $currentFDOW = $this->bean->get_first_day_of_week();    if (!isset($currentFDOW)) {$currentFDOW = 0;}  $this->ss->assign("FDOWCURRENT", $currentFDOW);  $this->ss->assign("FDOWDISPLAY", $app_list_strings['dom_cal_day_long'][$currentFDOW]);  

so as you may noticed someone has fixed db side value (EditView) by setting FDOWOPTIONS with proper array $fdowDays, but at DetailView we use FDOWDISPLAY and it is still using an old array. 


so by setting $this->ss->assign("FDOWDISPLAY", $fdowDays); solves the display issue. 




New sugar7 layout using bootstrap calendar lib without supported User fdow parameter. 


after researching bootstrap calendar lib it get clear that it possoble to set up fdow while init by parameter "weekStart" and also it looks for tag attribute data-date-weekstart (tested at /clients/base/fields/date/edit.hbs) 


so work file is /clients/base/fields/date/date.js its minified and taken from source file from /jssource/src_files/clients/base/fields/date/date.js (after changing that file we should make Admin>Rebuild JS Compressed Files & Quick Repair and Rebuild) 


inside of the function _setupDatePicker  we see  $field.datepicker({....}) where by putting weekStart  we can define fdow parameter. 


seems we can use app.user.getPreference('fdow') but it return undefined so probably we should somethere define that.


then I found something here /clients/base/api/LocaleApi.php

public function localeOptions($api, $args)  {  global $locale, $sugar_config, $current_user;  $data = array();  .........  $data['timezone'] = $timezoneList = TimeDate::getTimezoneList();  $data['fdow'] = $current_user->getPreference('fdow');//our new line  $data['_hash'] = $current_user->getUserMDHash();  return $data;  }  

but it still not working, can someone help me with this?