From ed3ad9344b70d0055c6afc79192bce09bcbb1e8b Mon Sep 17 00:00:00 2001 From: karthick Date: Wed, 13 May 2015 19:44:56 +0530 Subject: [PATCH 001/108] Sorting of weekly rows Refer section 2.7 on FotoNation-TE-features-v1.9 --- app/controllers/wkexpense_controller.rb | 3 ++- app/controllers/wktime_controller.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index bd7135328..e65146061 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -146,7 +146,8 @@ def findWkTEByCond(cond) def findEntriesByCond(cond) #WkExpenseEntry.find(:all, :conditions => cond, :order => 'project_id, issue_id, activity_id, spent_on') - WkExpenseEntry.where(cond).order('project_id, issue_id, activity_id, spent_on') + #WkExpenseEntry.where(cond).order('project_id, issue_id, activity_id, spent_on') + WkExpenseEntry.joins(:project).joins(:activity).joins("LEFT OUTER JOIN issues ON issues.id = wk_expense_entries.issue_id").where(cond).order('projects.name, issues.subject, enumerations.name, wk_expense_entries.spent_on') end def setValueForSpField(teEntry,spValue,decimal_separator,entry) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index aa50888df..4cab9487c 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1298,7 +1298,8 @@ def findWkTEByCond(cond) def findEntriesByCond(cond) #TimeEntry.find(:all, :conditions => cond, :order => 'project_id, issue_id, activity_id, spent_on') - TimeEntry.where(cond).order('project_id, issue_id, activity_id, spent_on') + #TimeEntry.where(cond).order('project_id, issue_id, activity_id, spent_on') + TimeEntry.joins(:project).joins(:activity).joins("LEFT OUTER JOIN issues ON issues.id = time_entries.issue_id").where(cond).order('projects.name, issues.subject, enumerations.name, time_entries.spent_on') end def setValueForSpField(teEntry,spValue,decimal_separator,entry) From 1274f99c971b93ff26b531610560fd4e86adf50f Mon Sep 17 00:00:00 2001 From: arulbaskar Date: Fri, 15 May 2015 12:57:38 +0530 Subject: [PATCH 002/108] time format and submit time sheet --- app/controllers/wktime_controller.rb | 5 +- assets/javascripts/edit.js | 129 +++++++++++++++++++++++++-- init.rb | 19 +++- 3 files changed, 138 insertions(+), 15 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 4cab9487c..5595f93e4 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -549,7 +549,7 @@ def total_all(total) end def getStatus - status = getTimeEntryStatus(params[:startDate].to_date,User.current.id) + status = getTimeEntryStatus(params[:startDate].to_date,params[:user_id]) respond_to do |format| format.text { render :text => status } end @@ -775,7 +775,8 @@ def gatherEntries end #timeEntry.hours = hours[j].blank? ? nil : hours[j].to_f #to allow for internationalization on decimal separator - setValueForSpField(teEntry,hours[j],decimal_separator,entry) + #setValueForSpField(teEntry,hours[j],decimal_separator,entry) + teEntry.hours = hours[j].blank? ? nil : hours[j]#.to_f unless custom_fields.blank? teEntry.custom_field_values.each do |custom_value| diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index dbf33770b..cb0346a59 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -718,8 +718,9 @@ function validateTotal(hourField, day, maxHour){ } maxHour= Number(maxHour); if (maxHour > 0 && dayTotal > maxHour){ - val = val.replace(decSeparator, '\.'); - val = Number(val); + //val = val.replace(decSeparator, '\.'); + //#val = Number(val); + val = validateHours(val, hourField) val = val - (dayTotal - maxHour); /*if(val == 0) { @@ -740,6 +741,7 @@ function validateTotal(hourField, day, maxHour){ function calculateTotal(day){ var issueTable = document.getElementById("issueTable"); var totalSpan = document.getElementById("total_hours"); + var tab = document.getElementById("tab"); var rowCount = issueTable.rows.length; var dayTotal = 0.0; var hours, i, j, k, val, children; @@ -752,19 +754,128 @@ function calculateTotal(day){ val = myTrim(hours[day-1].value); //replace any . with . for internationalization - val = val.replace(decSeparator, '\.'); - if(isNaN(val)) //if(val == 0 || isNaN(val)) + if (tab.value =="wkexpense") { - hours[day-1].value = ""; - } - - if( val != '' && !isNaN(val)){ - dayTotal += Number(val); + val = val.replace(decSeparator, '\.'); + if(isNaN(val)) //if(val == 0 || isNaN(val)) + { + hours[day-1].value = ""; + } + + if( val != '' && !isNaN(val)){ + dayTotal += Number(val); + } + }else{ + dayTotal += validateHours(val,hours[day-1]) } } return dayTotal; } +function validateHours(hoursValue,hoursDay){ + var valid =false + hoursValue = hoursValue.trim(); + var indexStr='',indexNextStr='',contcatStr=''; + var hours ='',mins='',timeValue='',concatvalue =''; + var total=0; + if (!isNaN(hoursValue)) { + hours = hoursValue; + }else if (hoursValue.indexOf('.') ==1){ + valid = checkStr(hoursValue,'.') + }else if (hoursValue.indexOf(",")==1){ + valid = checkStr(hoursValue,",") + if(!valid){ + hours = hoursValue.replace(",", "."); + } + }else if (hoursValue.indexOf(":")==1){ + valid = checkStr(hoursValue,":") + if(!valid){ + var val = hoursValue.split(":"); + hours= val[0]; + mins = val[1]; + } + }else{ + for (i = 0; i < hoursValue.length-1; i++){ + indexStr = hoursValue[i]; + indexNextStr = hoursValue[i+1] + if (!indexNextStr.trim() && indexStr && !contcatStr){ + if (isNaN(indexStr)){ + valid = true + break; + }else{ + timeValue += indexStr; + } + }else{ + if (!isNaN(indexStr)){ + timeValue += indexStr; + }if (isNaN(indexNextStr)){ + contcatStr += indexNextStr; + }else if (indexNextStr){ + if (contcatStr =="h" || contcatStr =="hour" || contcatStr =="hours" ){ + contcatStr =''; + hours = timeValue + timeValue='' + concatvalue='' + }else if (contcatStr =="m" || contcatStr =="min"){ + contcatStr =''; + mins = timeValue + timeValue='' + concatvalue='' + } + concatvalue +=indexNextStr; + } + } + } + } + if (contcatStr =="h" || contcatStr =="hour" || contcatStr =="hours" ){ + contcatStr =''; + hours = timeValue + timeValue= '' + concatvalue='' + }else if (contcatStr =="m" || contcatStr =="min"){ + mins = timeValue + timeValue='' + concatvalue='' + }else if (contcatStr){ + valid = true + } + if (!mins.trim()){ + mins = concatvalue + } + if (hours && mins){ + if(parseInt(mins) >60){ + valid = true; + } + } + if (valid){ + hoursDay.value=''; + }else{ + total = totalHours(hours,mins) + } + return total; +} +function checkStr(hoursValue,type){ + var valid =true; + hoursValue = hoursValue.replace(type, "."); + if (!isNaN(hoursValue)) { + valid = false + } + return valid +} +function totalHours(hours,mins){ + var minhour =0,total=0; + if (!isNaN(hours) && hours.trim()) + { + total = parseFloat(hours) + } + if (!isNaN(mins) && mins.trim()) + { + minhour = parseFloat(mins)/60; + total +=parseFloat(minhour) + } + return total +} + //There is a bug in IE7, the getElementsByName doesn't get the new elements //Workaround for the getElementsByName bug found in IE7 function myGetElementsByName(parent, tag, name){ diff --git a/init.rb b/init.rb index ecf12f669..f46f640d6 100644 --- a/init.rb +++ b/init.rb @@ -112,18 +112,18 @@ def view_layouts_base_html_head(context={}) end def view_timelog_edit_form_bottom(context={ }) - showWarningMsg(context[:request]) + showWarningMsg(context[:request],context[:time_entry].user_id) end def view_issues_edit_notes_bottom(context={}) - showWarningMsg(context[:request]) + showWarningMsg(context[:request],User.current.id) end - def showWarningMsg(req) + def showWarningMsg(req,user_id) wktime_helper = Object.new.extend(WktimeHelper) host_with_subdir = wktime_helper.getHostAndDir(req) "
#{l(:label_warning_wktime_time_entry)} - 'getStatus',:host => host_with_subdir,:protocol => req.protocol)}'> + 'getStatus',:host => host_with_subdir,:protocol => req.protocol,:user_id => user_id)}'>
" end @@ -138,6 +138,17 @@ def view_projects_show_sidebar_bottom(context={}) end end end + def controller_issues_edit_before_save(context={}) + if !context[:time_entry].blank? + if !context[:time_entry].hours.blank? && !context[:time_entry].activity_id.blank? + wktime_helper = Object.new.extend(WktimeHelper) + status= wktime_helper.getTimeEntryStatus(context[:time_entry].spent_on,context[:time_entry].user_id) + if !status.blank? && ('a' == status || 's' == status) + raise "#{l(:label_warning_wktime_time_entry)}" + end + end + end + end end From 6aa93a2519bae332d64bb00712d7a50ee1942a63 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 18 May 2015 11:31:33 +0530 Subject: [PATCH 003/108] updated review to rating in readme.doc --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 8d0e1d5d4..203f442a1 100644 --- a/README.rdoc +++ b/README.rdoc @@ -77,4 +77,4 @@ Release Notes for 1.8.1 - Support for code hooks - Filters will be remembered in list page. -Please provide your review at http://www.redmine.org/plugins/wk-time +Please provide your rating at http://www.redmine.org/plugins/wk-time From 71658acbfac177be27fae6b16d2e8bd860321b1f Mon Sep 17 00:00:00 2001 From: karthick Date: Mon, 18 May 2015 12:50:46 +0530 Subject: [PATCH 004/108] Fix for blank issue added when project had no issue 1.Set allowBlankIssue= false 2. Select a project in time and expense tab without any issue and add hours for that project. 3. There is a black issue saved for that project --- app/controllers/wktime_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 5595f93e4..3ea7b129f 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -744,7 +744,9 @@ def gatherEntries @teEntrydisabled=false unless entryHash.nil? entryHash.each_with_index do |entry, i| - if !entry['project_id'].blank? + if !entry['project_id'].blank? && !((Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].blank? || + Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].to_i == 0) && + entry['issue_id'].blank?) hours = params['hours' + (i+1).to_s()] ids = params['ids' + (i+1).to_s()] comments = params['comments' + (i+1).to_s()] From b47c31d74f893842843da27018ea344682a7a111 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Mon, 18 May 2015 16:22:49 +0530 Subject: [PATCH 005/108] Show Detail Time Entry popup change image icon show detail time entry popup change image icon for with command and without command... --- app/views/wktime/_edit_hours.html.erb | 13 +++++++++++-- assets/images/withcommand.png | Bin 0 -> 717 bytes assets/images/withoutcommand.png | Bin 0 -> 752 bytes assets/javascripts/edit.js | 15 ++++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 assets/images/withcommand.png create mode 100644 assets/images/withoutcommand.png diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index 096af8910..e7276e162 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -65,8 +65,17 @@ <% if show_custfield_img %> - <% image_tg = image_tag('text_list_bullets.png', :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', - :title => "#{entry.nil? || @prev_template || cvs.blank? ? l(:label_custom_field_plural) : cvs.join(',')}") %> + + <% imgname ="" %> + + <% if !cvs.blank? || !comment.blank? %> + <% imgname = "withcommand.png" %> + <% else %> + <% imgname = "withoutcommand.png" %> + <% end %> + <% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', + :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? l(:label_custom_field_plural) : cvs.join(',')}") %> + <% if disable %> <%= image_tg %> <% else %> diff --git a/assets/images/withcommand.png b/assets/images/withcommand.png new file mode 100644 index 0000000000000000000000000000000000000000..1f0c3de4a8ca04f17077e5cc1fab5fc36564e876 GIT binary patch literal 717 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GXl47y|-)LR^7dhRS~oRewRK;xCk4 z3FQ6*alzs)E)F2^%D=3oA6QG?vy^^jto#ktQuPNUTmK&@%ToRs#IE|wSoH^}lCk19 z&;-V+-z?=H8LR#>S9}F(WG?#xQc(Gut@I6R*?Z>lZ!G1XfNJ1&F;x8lngbLBDrTts z15^B#z4R4GSrteGhW@aWega$c2c*3M;^6;`6(AGXO5U=Tz6ZGh=ogrGz*3)pvOxDh z4FSsntz#|w05%^ip7tLo%To3k*lle zOgM7-=dlGgmppIm?45L?W746&|Na2M-!=QD&YE?i`Ov#h|DHa3^3m(YnH#@0ZdkkK zipBW{FV3HN+Sh;Z?$aYj9Eak7A<24hqjpQ7#DS0R zzdzskd++<(u|{{(Ca})t*>pQ)hmpoZf9F$42_c(qM^2sDXf?e!y#Ks=03$<*+y!fP zQ{#t|oHm#Ex=fkmz|%DEa@A6(2i4!Mwb@g|2^mKPm=~fH++S{k4q$HJ>mz9X$>DEi=ePTi=#1HZb_+SWA`#a77Z;~ ze$S&un!<6hp&>fkBNbGI>`hIid;5j-wQX(WS$nu6y4u=W!d#}XRso%G*we)^L_(7F z;6}aXK#7Kj-)(I_{l9NHsco&=OC_=HvnO6Tt%>P4D7u4N`nux8Wlb4Uokm|#42Ro2n%7u}bw+GfHivHD4E?3*9FJkwJrSzeg` z*1h55rO?UBp`xYVzRy~*_1f~vBQ{ExtS`;KQ@kw8yS&-=*_F?(Kkr3n=i&ugaJm)i3ueDd$yy2X58L-3A}y=*&fJ(*o!yv}HOpFRJ5 Qpm!KNUHx3vIVCg!02*ITrvLx| literal 0 HcmV?d00001 diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index dbf33770b..25d0a8eb1 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -38,12 +38,25 @@ $(document).ready(function() { if( !commentInRow && e_comments.val() != "") { edits[comment_col-1].title = e_comments.val() + "," +custFldToolTip; + } else { edits[comment_col-1].title = custFldToolTip; + } - + //show detail popup dialog ok button to change image + var x = document.getElementsByName("custfield_img"+comment_row+"[]"); + if( e_comments.val() != "" || custFldToolTip ) + { + $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withcommand.png"}); + + } + else + { + $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withoutcommand.png"}); + } + $( this ).dialog( "close" ); //unregister this event since this is showing a 'don't leave' message //loosk like this is not supported in Opera From f4d9312d0d5fd1c8eaac48ccb3d9574b3c7aacec Mon Sep 17 00:00:00 2001 From: karthick Date: Mon, 18 May 2015 19:15:02 +0530 Subject: [PATCH 006/108] Add account groups to settings Account groups added to general tab in settings of weekTime. --- app/views/settings/_tab_general.html.erb | 12 ++++++++++++ config/locales/en.yml | 4 +--- config/locales/fr.yml | 3 ++- config/locales/it.yml | 1 + init.rb | 3 ++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/views/settings/_tab_general.html.erb b/app/views/settings/_tab_general.html.erb index 030c00374..d3b6ddfc9 100644 --- a/app/views/settings/_tab_general.html.erb +++ b/app/views/settings/_tab_general.html.erb @@ -27,5 +27,17 @@

<%= check_box_tag('settings[wktime_use_detail_popup]', 1, @settings['wktime_use_detail_popup'].to_i == 1) %>

+ <% + accGroup = Group.order('lastname') + unless accGroup.blank? + accountGroups = accGroup.collect {|t| [t.lastname, t.id] } + accountGroups.unshift(["",0]) + end + %> +

+ + <%= select_tag('settings[wktime_account_groups]', + options_for_select(accountGroups, :selected => @settings['wktime_account_groups'].blank? ? 0 : @settings['wktime_account_groups']), :multiple=> true)%> +

\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index aad0ee835..cba8ffac2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,6 +27,7 @@ en: label_wk_enter_comment_in_row: Enter Comment in row label_wk_enter_cf_in_row: Enter Custom Field in row label_wk_use_detail_popup: Use Detail Time Entry Popup + label_wk_account_groups: Account Groups label_wk_approval_system: Approval System label_wk_use_approval_system: Use Approval System label_wk_auto_approve: "Auto approve" @@ -111,9 +112,6 @@ en: permission_approve_time_entries: Approve time logs field_currency: Currency - - - diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b0364eb85..53b89b667 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -25,7 +25,8 @@ fr: label_wk_enter_issue_id: Utiliser l'ID pour saisir la demande label_wk_work_time_header: Affichez l'entête effort - label_wk_allow_blank_issue: Permettre une demande vierge + label_wk_allow_blank_issue: Permettre une demande vierge + label_wk_account_groups: Account Groups label_wk_enter_comment_in_row: Saisir le commentaire sur la ligne label_wk_enter_cf_in_row: Saisir le champ personalisé sur la ligne diff --git a/config/locales/it.yml b/config/locales/it.yml index 63264d04f..f9d2b53de 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -26,6 +26,7 @@ it: label_wk_enter_issue_id: Enter issue as ID label_wk_work_time_header: Show work time header label_wk_allow_blank_issue: Allow Blank Issue + label_wk_account_groups: Account Groups label_wk_enter_comment_in_row: Enter Comment in row label_wk_enter_cf_in_row: Enter Custom Field in row diff --git a/init.rb b/init.rb index f46f640d6..cec11100b 100644 --- a/init.rb +++ b/init.rb @@ -56,7 +56,8 @@ def self.included(base) 'wktime_nonsub_sch_hr' => '23', 'wktime_nonsub_sch_min' => '0', 'wkexpense_projects' => [''], - 'wktime_allow_filter_issue' => '0' + 'wktime_allow_filter_issue' => '0', + 'wktime_account_groups' => ['0'] }) menu :top_menu, :wkTime, { :controller => 'wktime', :action => 'index' }, :caption => :label_te, :if => Proc.new { Object.new.extend(WktimeHelper).checkViewPermission } From 34a7266ab9bef2ea95a24a116e9a2c77158473c1 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 18 May 2015 20:03:16 +0530 Subject: [PATCH 007/108] language file change --- app/views/settings/_tab_approval.html.erb | 2 +- config/locales/en.yml | 6 ++++-- config/locales/fr.yml | 5 ++--- config/locales/it.yml | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/settings/_tab_approval.html.erb b/app/views/settings/_tab_approval.html.erb index 8fc3e5d1d..d4e141451 100644 --- a/app/views/settings/_tab_approval.html.erb +++ b/app/views/settings/_tab_approval.html.erb @@ -15,7 +15,7 @@

<%= text_area_tag 'settings[wktime_submission_ack]', @settings['wktime_submission_ack']%>

- <%= l(:label_wk_warning_nonsub_notification) %> + <%= l(:label_redmine_restart_warning) %>

<%= check_box_tag('settings[wktime_nonsub_mail_notification]', 1, @settings['wktime_nonsub_mail_notification'].to_i == 1) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index cba8ffac2..9ebaafcd6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,7 +27,6 @@ en: label_wk_enter_comment_in_row: Enter Comment in row label_wk_enter_cf_in_row: Enter Custom Field in row label_wk_use_detail_popup: Use Detail Time Entry Popup - label_wk_account_groups: Account Groups label_wk_approval_system: Approval System label_wk_use_approval_system: Use Approval System label_wk_auto_approve: "Auto approve" @@ -68,7 +67,7 @@ en: label_wk_nonsub_mail_subject: Non submission time notification label_wk_nonsub_mail_notification: Send email for non submission label_wk_nonsub_mail_message: Non submission email message - label_wk_warning_nonsub_notification: "Note: Any change to the below settings require redmine restart" + label_redmine_restart_warning: "Note: Any change to the below settings require redmine restart" label_wk_minutes: Minutes label_wkexpense_entry_projects: Restrict Expense Entry to these projects @@ -112,6 +111,9 @@ en: permission_approve_time_entries: Approve time logs field_currency: Currency + + + diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 53b89b667..7d6a172e4 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -25,8 +25,7 @@ fr: label_wk_enter_issue_id: Utiliser l'ID pour saisir la demande label_wk_work_time_header: Affichez l'entête effort - label_wk_allow_blank_issue: Permettre une demande vierge - label_wk_account_groups: Account Groups + label_wk_allow_blank_issue: Permettre une demande vierge label_wk_enter_comment_in_row: Saisir le commentaire sur la ligne label_wk_enter_cf_in_row: Saisir le champ personalisé sur la ligne @@ -70,7 +69,7 @@ fr: label_wk_nonsub_mail_subject: Notification de retard label_wk_nonsub_mail_notification: Envoyer un courriel pour les retards label_wk_nonsub_mail_message: Corps du courriel de retard - label_wk_warning_nonsub_notification: "Note: une modification des paramètres de configuration sous-jacents demandera un redémarrage de Redmine" + label_redmine_restart_warning: "Note: une modification des paramètres de configuration sous-jacents demandera un redémarrage de Redmine" label_wk_minutes: Minutes label_wkexpense_entry_projects: Limiter la saisie de dépense à ces projets diff --git a/config/locales/it.yml b/config/locales/it.yml index f9d2b53de..edee57b31 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -26,7 +26,6 @@ it: label_wk_enter_issue_id: Enter issue as ID label_wk_work_time_header: Show work time header label_wk_allow_blank_issue: Allow Blank Issue - label_wk_account_groups: Account Groups label_wk_enter_comment_in_row: Enter Comment in row label_wk_enter_cf_in_row: Enter Custom Field in row @@ -70,7 +69,7 @@ it: label_wk_nonsub_mail_subject: Non submission time notification label_wk_nonsub_mail_notification: Send email for non submission label_wk_nonsub_mail_message: Non submission email message - label_wk_warning_nonsub_notification: "Note: Any change to the below settings require redmine restart" + label_redmine_restart_warning: "Note: Any change to the below settings require redmine restart" label_wk_minutes: Minutes label_wkexpense_entry_projects: Restrict Expense Entry to these projects From 9063336546bb1afe9160f1be12ff7f6001d26d2a Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 19 May 2015 10:55:40 +0530 Subject: [PATCH 008/108] Remove checkbox on timesheet list page --- app/views/wktime/_list.html.erb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/views/wktime/_list.html.erb b/app/views/wktime/_list.html.erb index 6d17f22ea..a1738e2fa 100644 --- a/app/views/wktime/_list.html.erb +++ b/app/views/wktime/_list.html.erb @@ -3,12 +3,6 @@ - @@ -20,8 +14,6 @@ <% @entries.each do |entry| -%> "> - - From a5c14eece431a8d24575c4934facaffbb64d50ad Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 19 May 2015 11:42:10 +0530 Subject: [PATCH 009/108] Add label Account Groups --- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + config/locales/it.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 9ebaafcd6..1924ff17d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -32,6 +32,7 @@ en: label_wk_auto_approve: "Auto approve" label_wk_submission_ack: Submission Acknowledgement Text label_wk_reject_reason: Reject Reason + label_wk_account_groups: Account Groups label_wk_enter_issue_As: Enter Issue As label_wk_enter_issue_Description: Enter issue as Subject diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7d6a172e4..e1f15e79f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -22,6 +22,7 @@ fr: label_wk_signature: Signature label_wk_submitted_by: Soumis par label_wk_approved_by: Approuvé par + label_wk_account_groups: Account Groups label_wk_enter_issue_id: Utiliser l'ID pour saisir la demande label_wk_work_time_header: Affichez l'entête effort diff --git a/config/locales/it.yml b/config/locales/it.yml index edee57b31..12fffeee9 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -22,6 +22,7 @@ it: label_wk_signature: Firma label_wk_submitted_by: Inserito da label_wk_approved_by: Approvato da + label_wk_account_groups: Account Groups label_wk_enter_issue_id: Enter issue as ID label_wk_work_time_header: Show work time header From 53f950957c35407aae4e19d6560880d8f5a836bb Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Tue, 19 May 2015 14:46:12 +0530 Subject: [PATCH 010/108] Hour textfield size changed edit page hours textfield size and command textbox size changed. --- app/controllers/wktime_controller.rb | 12 +++++++++++- app/views/wktime/_edit_hours.html.erb | 3 ++- app/views/wktime/_edit_issues2.html.erb | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 3ea7b129f..8fa6d5ddc 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -535,6 +535,16 @@ def showWorktimeHeader Setting.plugin_redmine_wktime['wktime_work_time_header'].to_i == 1 end + def Hourtextfieldsize + hrtextfiledsize = 0 + if params[:controller] == "wktime" + hrtextfiledsize = 4 + else + hrtextfiledsize = 7 + end + return hrtextfiledsize + end + def maxHour Setting.plugin_redmine_wktime['wktime_restr_max_hour'].to_i == 1 ? (Setting.plugin_redmine_wktime['wktime_max_hour_day'].blank? ? 8 : Setting.plugin_redmine_wktime['wktime_max_hour_day']) : 0 @@ -1498,5 +1508,5 @@ def set_filter_session session[:wkexpense][:status] = params[:status] session[:wkexpense][:group_id] = params[:group_id] end - end + end end \ No newline at end of file diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index e7276e162..9ee7a3eff 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -22,7 +22,8 @@ %> <%#if this is from a previous template, don't print the hours%> + @@ -18,6 +19,7 @@ +
- <%= link_to image_tag('toggle_check.png'), - {}, - :onclick => 'toggleIssuesSelection(this); return false;', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> - <%= l(:field_start_date) %> <%= l(:field_user) %> <%= controller.getLabelforSpField %>
<%= check_box_tag("ids[]", entry.spent_on, false, :id => nil) %><%=h format_date(entry.spent_on) %> <%=h entry.user.login %> <%= controller.getUnit(entry) %> <%=h html_hours("%.2f" % entry.hours) %> - <%=h text_field_tag('hours' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : ("%.2f" % entry.hours) ,:size => 7, + + <%=h text_field_tag('hours' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : ("%.2f" % entry.hours) ,:size => "#{controller.Hourtextfieldsize}", :disabled => disable, :onchange => "validateTotal(this, #{@wday_index},'#{controller.maxHour}');") %> diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 4ff718a89..5ca7a877c 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -110,8 +110,9 @@ if params[:enter_issue_id].blank? Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 %> <% if @editable %> - <%=h text_field_tag(isTemplate ? '__template__time_entry[][comments]' : 'time_entry[][comments]', - entry.nil? ? '' : entry.comments)%> + + <%=h text_field_tag(isTemplate ? '__template__time_entry[][comments]' : 'time_entry[][comments]', + (entry.nil? ? '' : entry.comments),:size => 35)%> <% else %> <%=h entry.nil? ? '' : entry.comments%> <% end %> From 49ed975017069bc82d4262943e9cdca3588820b3 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 20 May 2015 13:06:50 +0530 Subject: [PATCH 011/108] Issue #17 Redmine crashed on Postgres request --- app/controllers/wktime_controller.rb | 6 ++++-- app/views/wktime/_te_new.html.erb | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 8fa6d5ddc..3c1fde1c3 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -470,8 +470,9 @@ def getusers if !userList.blank? projmembers = userList[0].blank? ? nil : userList[0] else - projmembers = project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC").distinct("#{User.table_name}.id") + projmembers = project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") end + projmembers = projmembers.to_a.uniq if !projmembers.nil? projmembers.each do |m| userStr << m.user_id.to_s() + ',' + m.name + "\n" end @@ -1147,7 +1148,7 @@ def setMembers if !hookProjMem.blank? projMem = hookProjMem[0].blank? ? [] : hookProjMem[0] else - projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC").distinct("#{User.table_name}.id") + projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") end @members = projMem.collect{|m| [ m.name, m.user_id ] } elsif filter_type == '2' @@ -1161,6 +1162,7 @@ def setMembers @members = hookMem[0].blank? ? @members : hookMem[0] end end + @members = @members.uniq end def setup diff --git a/app/views/wktime/_te_new.html.erb b/app/views/wktime/_te_new.html.erb index 891b6231c..ef2532aa2 100644 --- a/app/views/wktime/_te_new.html.erb +++ b/app/views/wktime/_te_new.html.erb @@ -23,6 +23,7 @@ <% else %> <% projmem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") + projmem = projmem.to_a.uniq if !projmem.nil? %> <%=h select_tag('user_id', options_for_select( projmem.collect{|m| [ m.name, m.user_id ] }, From 1b2d0ed087bdd1b3bb07d80684fd8a49fb6eae80 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Thu, 21 May 2015 10:40:15 +0530 Subject: [PATCH 012/108] Use Detail Time Entry Popup when Command in row and no custom fields the popup does n't shown --- app/views/wktime/_edit_hours.html.erb | 17 ++++++++++------- assets/javascripts/edit.js | 12 ++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index 9ee7a3eff..15f233ad1 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -66,17 +66,20 @@ <% if show_custfield_img %> - - <% imgname ="" %> - - <% if !cvs.blank? || !comment.blank? %> + <% imgname ="" %> + <% if !cvs.blank? || !comment.blank? %> <% imgname = "withcommand.png" %> <% else %> <% imgname = "withoutcommand.png" %> <% end %> - <% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', - :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? l(:label_custom_field_plural) : cvs.join(',')}") %> - + <% if !@new_custom_field_values.blank? || ( Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? || + Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0) %> + <% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', + :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? l(:label_custom_field_plural) : cvs.join(',')}") %> + <% else %> + <%= image_tg ="" %> + <% end %> + <% if disable %> <%= image_tg %> <% else %> diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index 956386e48..a5aa319a3 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -45,18 +45,17 @@ $(document).ready(function() { edits[comment_col-1].title = custFldToolTip; } - //show detail popup dialog ok button to change image + //show detail popup dialog ok button to change image var x = document.getElementsByName("custfield_img"+comment_row+"[]"); - if( e_comments.val() != "" || custFldToolTip ) - { + if( (e_comments.val() != "" || custFldToolTip) && (!commentInRow || custFldToolTip ) ) + { $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withcommand.png"}); } else - { + { $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withoutcommand.png"}); - } - + } $( this ).dialog( "close" ); //unregister this event since this is showing a 'don't leave' message //loosk like this is not supported in Opera @@ -168,6 +167,7 @@ function showCustomField() { } function updateCustomField() { + if(cf_ids != ''){ var cust_fids = cf_ids.split(','); var i, j,cust_field, ck_cust_field, custom_fields; From a9c2d9433fd673d36d32fc49dbeacf6c65751076 Mon Sep 17 00:00:00 2001 From: arulbaskar Date: Thu, 21 May 2015 10:49:21 +0530 Subject: [PATCH 013/108] time entry submit issue or project not deleted --- app/helpers/wktime_helper.rb | 20 +++++++++ config/locales/en.yml | 1 + init.rb | 81 +++++++++++++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index cf883fcce..17893b1a4 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -720,4 +720,24 @@ def is_number(val) def to_boolean(str) str == 'true' end + def getStatus_Project_Issue(issue_id,project_id) + if !issue_id.blank? + cond = getIssueSqlString(issue_id) + end + if !project_id.blank? + cond = getProjectSqlString(project_id) + end + sDay = getDateSqlString('t.spent_on') + time_sqlStr = " SELECT t.* FROM time_entries t inner join wktimes w on w.begin_date = #{ sDay} and w.user_id =t.user_id #{cond}" + time_entry = TimeEntry.find_by_sql(time_sqlStr) + expense_sqlStr = " SELECT t.* FROM wk_expense_entries t inner join wkexpenses w on w.begin_date = #{ sDay} and w.user_id =t.user_id #{cond}" + expense_entry = WkExpenseEntry.find_by_sql(expense_sqlStr) + ret = (!time_entry.blank? && time_entry.size > 0) || (!expense_entry.blank? && expense_entry.size > 0) + end + def getIssueSqlString(issue_id) + " where t.issue_id = #{issue_id} and (w.status ='s' OR w.status ='a')" + end + def getProjectSqlString(project_id) + " where t.project_id = #{project_id} and (w.status ='s' OR w.status ='a')" + end end \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 1924ff17d..6d1aa96a0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -111,6 +111,7 @@ en: permission_approve_time_entries: Approve time logs field_currency: Currency + error_project_issue_associate: Cannot be deleted because time/expense entries associated diff --git a/init.rb b/init.rb index cec11100b..b5c31886c 100644 --- a/init.rb +++ b/init.rb @@ -7,7 +7,84 @@ def self.included(base) end end + module ProjectsControllerPatch + def self.included(base) + base.class_eval do + def destroy + @project_to_destroy = @project + if api_request? || params[:confirm] + wktime_helper = Object.new.extend(WktimeHelper) + ret = wktime_helper.getStatus_Project_Issue(nil,@project_to_destroy.id) + if ret + #render_403 + #return false + flash.now[:error] = l(:error_project_issue_associate) + return + else + @project_to_destroy.destroy + respond_to do |format| + format.html { redirect_to admin_projects_path } + format.api { render_api_ok } + end + end + end + # hide project in layout + @project = nil + end + end + end + end + module IssuesControllerPatch + def self.included(base) + base.class_eval do + def destroy + @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f + if @hours > 0 + case params[:todo] + when 'destroy' + wktime_helper = Object.new.extend(WktimeHelper) + issue_id = @issues.map(&:id) + ret = wktime_helper.getStatus_Project_Issue(issue_id[0],nil) + if ret + flash.now[:error] = l(:error_project_issue_associate) + return + end + when 'nullify' + TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL') + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.where(['issue_id IN (?)', @issues]). + update_all("issue_id = #{reassign_to.id}") + end + else + # display the destroy form if it's a user request + return unless api_request? + end + end + @issues.each do |issue| + begin + + issue.reload.destroy + rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists + # nothing to do, issue was already deleted (eg. by a parent) + end + end + respond_to do |format| + format.html { redirect_back_or_default _project_issues_path(@project) } + format.api { render_api_ok } + end + end + end + end + end + CustomFieldsHelper.send(:include, WktimeHelperPatch) +ProjectsController.send(:include, ProjectsControllerPatch) +IssuesController.send(:include, IssuesControllerPatch) Redmine::Plugin.register :redmine_wktime do name 'Time & Expense' @@ -145,11 +222,11 @@ def controller_issues_edit_before_save(context={}) wktime_helper = Object.new.extend(WktimeHelper) status= wktime_helper.getTimeEntryStatus(context[:time_entry].spent_on,context[:time_entry].user_id) if !status.blank? && ('a' == status || 's' == status) - raise "#{l(:label_warning_wktime_time_entry)}" + raise "#{l(:label_warning_wktime_time_entry)}" end end end - end + end end From 3e6b2947cfe5abd00c4f09a3625a6601d37488af Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 21 May 2015 11:18:48 +0530 Subject: [PATCH 014/108] Issue 14 Status updater name Add to timesheet form username of user that changed --- app/controllers/wktime_controller.rb | 11 +++++++++-- app/views/wktime/_list.html.erb | 2 ++ config/locales/en.yml | 1 + config/locales/fr.yml | 1 + config/locales/it.yml | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 3c1fde1c3..8a32ee561 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -53,25 +53,32 @@ def index spField = getSpecificField() entityNames = getEntityNames() selectStr = "select v1.user_id, v1.startday as spent_on, v1." + spField - wkSelectStr = selectStr + ", w.status " + wkSelectStr = selectStr + ", w.status " sqlStr = " from " sDay = getDateSqlString('t.spent_on') #Martin Dube contribution: 'start of the week' configuration if ActiveRecord::Base.connection.adapter_name == 'SQLServer' + wkSelectStr = wkSelectStr +", un.firstname + ' ' + un.lastname as status_updater " sqlStr += "(select ROW_NUMBER() OVER (ORDER BY " + sDay + " desc, user_id) AS rownum," + sDay + " as startday, " sqlStr += " t.user_id, sum(t." + spField + ") as " + spField + " ,max(t.id) as id" + " from " + entityNames[1] + " t, users u" + " where u.id = t.user_id and u.id in (#{ids})" sqlStr += " and t.spent_on between '#{@from}' and '#{@to}'" unless @from.blank? && @to.blank? sqlStr += " group by " + sDay + ", user_id ) as v1" else + if ActiveRecord::Base.connection.adapter_name == 'SQLite' + wkSelectStr = wkSelectStr +", un.firstname || ' ' || un.lastname as status_updater " + else + wkSelectStr = wkSelectStr +", concat(un.firstname,' ' ,un.lastname) as status_updater " + end sqlStr += "(select " + sDay + " as startday, " sqlStr += " t.user_id, sum(t." + spField + ") as " + spField + " ,max(t.id) as id" + " from " + entityNames[1] + " t, users u" + " where u.id = t.user_id and u.id in (#{ids})" sqlStr += " and t.spent_on between '#{@from}' and '#{@to}'" unless @from.blank? && @to.blank? sqlStr += " group by startday, user_id order by startday desc, user_id ) as v1" + end - wkSqlStr = " left outer join " + entityNames[0] + " w on v1.startday = w.begin_date and v1.user_id = w.user_id" + wkSqlStr = " left outer join " + entityNames[0] + " w on v1.startday = w.begin_date and v1.user_id = w.user_id left outer join users un on un.id = w.statusupdater_id" #status = params[:status] if !status.blank? && status != 'all' wkSqlStr += " WHERE w.status = '#{status}'" diff --git a/app/views/wktime/_list.html.erb b/app/views/wktime/_list.html.erb index a1738e2fa..7c8d1223a 100644 --- a/app/views/wktime/_list.html.erb +++ b/app/views/wktime/_list.html.erb @@ -7,6 +7,7 @@ <%= l(:field_user) %> <%= controller.getLabelforSpField %> <%= l(:field_status) %><%= l(:field_status_updater) %>
<%=h entry.user.login %> <%= controller.getUnit(entry) %> <%=h html_hours("%.2f" % entry.hours) %> <%=h statusString(entry.status) unless entry.status.blank? %><%=h entry.status_updater %> <% #if entry.editable_by?(User.current) %> <%= link_to image_tag('edit.png'), {:controller => controller.controller_name, :action => 'edit', :startday => entry.spent_on, :user_id => entry.user_id, :tab => controller.controller_name}, diff --git a/config/locales/en.yml b/config/locales/en.yml index 6d1aa96a0..42abea292 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -104,6 +104,7 @@ en: text_wk_warning_min_hour: "You have not entered the Minimum hours (%{value}) required per day" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Amount + field_status_updater: "Status updated by" label_wk_allow_filter_issue: Allow User filtering to My Issues diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e1f15e79f..43168cfca 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -106,6 +106,7 @@ fr: text_wk_warning_min_hour: "Vous n'avez pas saisi le minimum d'heures (%{value}) requis par jour" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Montant + field_status_updater: Status updated by label_wk_allow_filter_issue: Allow User filtering to My Issues label_wk_no_user_current_project: no users in selected project diff --git a/config/locales/it.yml b/config/locales/it.yml index 12fffeee9..aeb9fbb12 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -104,6 +104,7 @@ it: text_wk_warning_min_hour: "You have not entered the Minimum hours (%{value}) required per day" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Amount + field_status_updater: Status updated by label_wk_allow_filter_issue: Allow User filtering to My Issues label_wk_no_user_current_project: no users in selected project From 185fb3cd0d5384990bc21526de477329fc52fe41 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 21 May 2015 13:36:33 +0530 Subject: [PATCH 015/108] Account groups shows error when there is no groups --- app/views/settings/_tab_expense.html.erb | 3 ++- app/views/settings/_tab_general.html.erb | 3 ++- app/views/settings/_tab_time.html.erb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/settings/_tab_expense.html.erb b/app/views/settings/_tab_expense.html.erb index 1ddc678c2..0e655ab2d 100644 --- a/app/views/settings/_tab_expense.html.erb +++ b/app/views/settings/_tab_expense.html.erb @@ -1,11 +1,12 @@
<%= l(:label_wkexpense) %> <% + trackers = Array.new tracker = Tracker.order('name') unless tracker.blank? trackers = tracker.collect {|t| [t.name, t.id] } - trackers.unshift(["",0]) end + trackers.unshift(["",0]) %>

diff --git a/app/views/settings/_tab_general.html.erb b/app/views/settings/_tab_general.html.erb index d3b6ddfc9..2ba6ddcea 100644 --- a/app/views/settings/_tab_general.html.erb +++ b/app/views/settings/_tab_general.html.erb @@ -28,11 +28,12 @@ <%= check_box_tag('settings[wktime_use_detail_popup]', 1, @settings['wktime_use_detail_popup'].to_i == 1) %>

<% + accountGroups = Array.new accGroup = Group.order('lastname') unless accGroup.blank? accountGroups = accGroup.collect {|t| [t.lastname, t.id] } - accountGroups.unshift(["",0]) end + accountGroups.unshift(["",0]) %>

diff --git a/app/views/settings/_tab_time.html.erb b/app/views/settings/_tab_time.html.erb index e6df462ea..5582b3ddb 100644 --- a/app/views/settings/_tab_time.html.erb +++ b/app/views/settings/_tab_time.html.erb @@ -31,11 +31,12 @@

<% end %> <% + trackers = Array.new tracker = Tracker.order('name') unless tracker.blank? trackers = tracker.collect {|t| [t.name, t.id] } - trackers.unshift(["",0]) end + trackers.unshift(["",0]) %>

From 56fff4c10202838274d4aae85198385a7e040838 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Thu, 21 May 2015 14:46:03 +0530 Subject: [PATCH 016/108] namespace correct the method and names --- app/controllers/wkexpense_controller.rb | 3 +++ app/controllers/wktime_controller.rb | 15 ++++----------- app/views/wktime/_edit_hours.html.erb | 6 +++--- .../images/{withcommand.png => withcommant.png} | Bin .../{withoutcommand.png => withoutcommant.png} | Bin assets/javascripts/edit.js | 4 ++-- 6 files changed, 12 insertions(+), 16 deletions(-) rename assets/images/{withcommand.png => withcommant.png} (100%) rename assets/images/{withoutcommand.png => withoutcommant.png} (100%) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index e65146061..e3c64487c 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -111,6 +111,9 @@ def deleteEntry end end + def textfield_size + 7 + end private def getSpecificField "amount" diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 8a32ee561..08b7a1de4 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -542,17 +542,7 @@ def showWorktimeHeader !Setting.plugin_redmine_wktime['wktime_work_time_header'].blank? && Setting.plugin_redmine_wktime['wktime_work_time_header'].to_i == 1 end - - def Hourtextfieldsize - hrtextfiledsize = 0 - if params[:controller] == "wktime" - hrtextfiledsize = 4 - else - hrtextfiledsize = 7 - end - return hrtextfiledsize - end - + def maxHour Setting.plugin_redmine_wktime['wktime_restr_max_hour'].to_i == 1 ? (Setting.plugin_redmine_wktime['wktime_max_hour_day'].blank? ? 8 : Setting.plugin_redmine_wktime['wktime_max_hour_day']) : 0 @@ -637,6 +627,9 @@ def testapi end end + def textfield_size + 4 + end private diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index 15f233ad1..e7cc6c51e 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -23,7 +23,7 @@ <%#if this is from a previous template, don't print the hours%>

- <%=h text_field_tag('hours' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : ("%.2f" % entry.hours) ,:size => "#{controller.Hourtextfieldsize}", + <%=h text_field_tag('hours' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : ("%.2f" % entry.hours) ,:size => "#{controller.textfield_size}", :disabled => disable, :onchange => "validateTotal(this, #{@wday_index},'#{controller.maxHour}');") %> @@ -68,9 +68,9 @@ <% if show_custfield_img %> <% imgname ="" %> <% if !cvs.blank? || !comment.blank? %> - <% imgname = "withcommand.png" %> + <% imgname = "withcommant.png" %> <% else %> - <% imgname = "withoutcommand.png" %> + <% imgname = "withoutcommant.png" %> <% end %> <% if !@new_custom_field_values.blank? || ( Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? || Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0) %> diff --git a/assets/images/withcommand.png b/assets/images/withcommant.png similarity index 100% rename from assets/images/withcommand.png rename to assets/images/withcommant.png diff --git a/assets/images/withoutcommand.png b/assets/images/withoutcommant.png similarity index 100% rename from assets/images/withoutcommand.png rename to assets/images/withoutcommant.png diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index a5aa319a3..cbeaf3994 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -49,12 +49,12 @@ $(document).ready(function() { var x = document.getElementsByName("custfield_img"+comment_row+"[]"); if( (e_comments.val() != "" || custFldToolTip) && (!commentInRow || custFldToolTip ) ) { - $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withcommand.png"}); + $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withcommant.png"}); } else { - $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withoutcommand.png"}); + $(x[comment_col-1]).attr({src: "/plugin_assets/redmine_wktime/images/withoutcommant.png"}); } $( this ).dialog( "close" ); //unregister this event since this is showing a 'don't leave' message From 2c75660dd3df78223c861bf1be2b50e4f7456986 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 21 May 2015 15:12:50 +0530 Subject: [PATCH 017/108] 0005 Error when changing supervisor --- app/controllers/wktime_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 08b7a1de4..c41a5c67a 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -39,13 +39,15 @@ def index if user_id.blank? ids = User.current.id.to_s elsif user_id.to_i == 0 - @members.each_with_index do |users,i| - if i == 0 - ids = users[1].to_s - else - ids +=',' + users[1].to_s - end - end + unless @members.blank? + @members.each_with_index do |users,i| + if i == 0 + ids = users[1].to_s + else + ids +=',' + users[1].to_s + end + end + end ids = '0' if ids.nil? else ids = user_id From c52f242d52f491b672b45a0d9ede18a639a0ced2 Mon Sep 17 00:00:00 2001 From: arulbaskar Date: Fri, 22 May 2015 11:12:27 +0530 Subject: [PATCH 018/108] boolean check hook --- app/helpers/wktime_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 17893b1a4..a7d61f2ab 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -707,7 +707,7 @@ def checkViewPermission loggableProjects ||= Project.where(Project.allowed_to_condition(User.current, :log_time)) viewMenu = call_hook(:view_wktime_menu) viewMenu = viewMenu.blank? ? '' : (viewMenu.is_a?(Array) ? (viewMenu[0].blank? ? '': viewMenu[0]) : viewMenu) - @manger_user = ( !viewMenu.blank? && viewMenu) + @manger_user = ( !viewMenu.blank? && to_boolean(viewMenu)) ret = (!viewProjects.blank? && viewProjects.size > 0) || (!loggableProjects.blank? && loggableProjects.size > 0) || @manger_user end ret From fe1ad5abdea836465ddc3e9f9d6453acdb4b8a27 Mon Sep 17 00:00:00 2001 From: arulbaskar Date: Fri, 22 May 2015 19:21:27 +0530 Subject: [PATCH 019/108] lock time sheet --- app/controllers/wktime_controller.rb | 4 ++++ app/helpers/wktime_helper.rb | 19 ++++++++++++++----- app/views/wktime/_edit_issues.html.erb | 4 ++-- assets/javascripts/wkstatus.js | 4 ++-- init.rb | 4 ++-- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index c41a5c67a..930c3578f 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -114,6 +114,10 @@ def edit @prev_template = true end end + locked = call_hook(:controller_lock_sheet,{ :startday => @startday}) + locked = locked[0].blank? ? '' : locked[0] + @lockedsheet = !locked.blank? && locked + @editable = false if @lockedsheet respond_to do |format| format.html { render :layout => !request.xhr? diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index a7d61f2ab..336d2e6d9 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -551,9 +551,18 @@ def set_cf_value(col_values, custom_field_values, setting_name) end def getTimeEntryStatus(spent_on,user_id) - #result = Wktime.find(:all, :conditions => [ 'begin_date = ? AND user_id = ?', getStartDay(spent_on), user_id]) - result = Wktime.where(['begin_date = ? AND user_id = ?', getStartDay(spent_on), user_id]) - return result[0].blank? ? 'n' : result[0].status + #result = Wktime.find(:all, :conditions => [ 'begin_date = ? AND user_id = ?', getStartDay(spent_on), user_id]) + start_day = getStartDay(spent_on) + locked = call_hook(:controller_lock_sheet,{ :startday => start_day}) + locked = locked.blank? ? '' : (locked.is_a?(Array) ? (locked[0].blank? ? '': locked[0].to_s) : locked.to_s) + locked = ( !locked.blank? && to_boolean(locked)) + if locked + result = 'l' + else + result = Wktime.where(['begin_date = ? AND user_id = ?', start_day, user_id]) + result = result[0].blank? ? 'n' : result[0].status + end + return result end def time_expense_tabs @@ -706,8 +715,8 @@ def checkViewPermission viewProjects = Project.where(Project.allowed_to_condition(User.current, :view_time_entries )) loggableProjects ||= Project.where(Project.allowed_to_condition(User.current, :log_time)) viewMenu = call_hook(:view_wktime_menu) - viewMenu = viewMenu.blank? ? '' : (viewMenu.is_a?(Array) ? (viewMenu[0].blank? ? '': viewMenu[0]) : viewMenu) - @manger_user = ( !viewMenu.blank? && to_boolean(viewMenu)) + viewMenu = viewMenu.blank? ? '' : (viewMenu.is_a?(Array) ? (viewMenu[0].blank? ? '': viewMenu[0].to_s) : viewMenu.to_s) + @manger_user = ( !viewMenu.blank? && to_boolean(viewMenu)) ret = (!viewProjects.blank? && viewProjects.size > 0) || (!loggableProjects.blank? && loggableProjects.size > 0) || @manger_user end ret diff --git a/app/views/wktime/_edit_issues.html.erb b/app/views/wktime/_edit_issues.html.erb index ab81bd874..2e18e7ff9 100644 --- a/app/views/wktime/_edit_issues.html.erb +++ b/app/views/wktime/_edit_issues.html.erb @@ -94,7 +94,7 @@ currencySym = "" <% end %>
- +<% if !@lockedsheet %> <% if @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r' %> <%= submit_tag l(:button_save), :id => 'wktime_save', :name => 'wktime_save', :disabled => !(@row > 0)%> <%= submit_tag l(:button_save_continue), :id => 'wktime_save_continue', :name => 'wktime_save_continue' , :disabled => !(@row > 0)%> @@ -121,7 +121,7 @@ currencySym = "" <% end %> <% end %> <% end %> - +<% end %>

<% if @editable %> diff --git a/assets/javascripts/wkstatus.js b/assets/javascripts/wkstatus.js index 9567241b9..cd48c31d1 100644 --- a/assets/javascripts/wkstatus.js +++ b/assets/javascripts/wkstatus.js @@ -14,7 +14,7 @@ $(document).ready(function(){ if(txtEntryDate!=null){ showEntryWarning(txtEntryDate.value); txtEntryDate.onchange=function(){showEntryWarning(this.value)}; - } + } }); function showEntryWarning(entrydate){ @@ -32,7 +32,7 @@ function showEntryWarning(entrydate){ } function showMessage(data,divID){ - if(data!=null && ('s'== data || 'a'== data)){ + if(data!=null && ('s'== data || 'a'== data || 'l'== data)){ divID.style.display = 'block'; } else{ diff --git a/init.rb b/init.rb index b5c31886c..8b8cd459e 100644 --- a/init.rb +++ b/init.rb @@ -178,7 +178,7 @@ def controller_timelog_edit_before_save(context={ }) if !context[:time_entry].hours.blank? && !context[:time_entry].activity_id.blank? wktime_helper = Object.new.extend(WktimeHelper) status= wktime_helper.getTimeEntryStatus(context[:time_entry].spent_on,context[:time_entry].user_id) - if !status.blank? && ('a' == status || 's' == status) + if !status.blank? && ('a' == status || 's' == status || 'l' == status) raise "#{l(:label_warning_wktime_time_entry)}" end end @@ -221,7 +221,7 @@ def controller_issues_edit_before_save(context={}) if !context[:time_entry].hours.blank? && !context[:time_entry].activity_id.blank? wktime_helper = Object.new.extend(WktimeHelper) status= wktime_helper.getTimeEntryStatus(context[:time_entry].spent_on,context[:time_entry].user_id) - if !status.blank? && ('a' == status || 's' == status) + if !status.blank? && ('a' == status || 's' == status || 'l' == status) raise "#{l(:label_warning_wktime_time_entry)}" end end From 3c263c5b90884b56638690d9cb99fbba8d9b5d09 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Fri, 22 May 2015 20:15:46 +0530 Subject: [PATCH 020/108] Approval permission --- app/controllers/wktime_controller.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 930c3578f..88d2eba6b 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -606,18 +606,14 @@ def findTEProjects() def check_approvable_status te_projects=[] - ret = false + ret = false + if !@entries.blank? + @te_projects = @entries.collect{|entry| entry.project}.uniq + te_projects = @approvable_projects & @te_projects if !@te_projects.blank? + end hookPerm = call_hook(:controller_check_approvable, {:params => params}) if !hookPerm.blank? ret = hookPerm[0] - #if (approvable[0].to_s)=='true' - # ret = true - #end - else - if !@entries.blank? - @te_projects = @entries.collect{|entry| entry.project}.uniq - te_projects = @approvable_projects & @te_projects if !@te_projects.blank? - end end ret = ((ret || !te_projects.blank?) && (@user.id != User.current.id || (!Setting.plugin_redmine_wktime[:wktime_own_approval].blank? && Setting.plugin_redmine_wktime[:wktime_own_approval].to_i == 1 )))? true: false From a026a6245e7503edab11c9322ff499974f10302e Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 26 May 2015 12:33:25 +0530 Subject: [PATCH 021/108] Permission changes Allow users with 'edit time log' to edit others timesheet --- app/controllers/wktime_controller.rb | 6 ++++-- app/views/wktime/_edit_hours.html.erb | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 88d2eba6b..7b905178d 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -166,7 +166,8 @@ def update entrycount += 1 entrynilcount += 1 if (entry.hours).blank? allowSave = true - if (!entry.id.blank? && !entry.editable_by?(@user)) + #if (!entry.id.blank? && !entry.editable_by?(@user)) + if (!entry.id.blank? && !entry.editable_by?(User.current)) allowSave = false end if to_boolean(@edittimelogs) @@ -958,7 +959,8 @@ def user_allowed_to?(privilege, entity) def can_log_time?(project_id) ret = false set_loggable_projects - @logtime_projects.each do |lp| + #@logtime_projects.each do |lp| + @currentUser_loggable_projects.each do |lp| if lp.id == project_id ret = true break diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index e7cc6c51e..473d43bd9 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -6,7 +6,7 @@ if @editable #hookCellEditPerm = call_hook(:view_cell_edit, :entry => entry) if @edittimelogs.blank? - disable = !@prev_template && !entry.nil? && !entry.editable_by?(@user) + disable = !@prev_template && !entry.nil? && !entry.editable_by?(User.current) else if (@edittimelogs == 'true') disable = !@prev_template && !entry.nil? && !(to_boolean(@edittimelogs)) @@ -14,7 +14,7 @@ if (!@manage_projects.blank? && @manage_projects.size > 0 && User.current.id != @user.id) disable = !@prev_template && !entry.nil? && !(to_boolean(@edittimelogs)) else - disable = !@prev_template && !entry.nil? && !entry.editable_by?(@user) + disable = !@prev_template && !entry.nil? && !entry.editable_by?(User.current) end end end From 94e0b5ea0b9b9879554b2b0d60cd7ed1d8a66074 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 26 May 2015 15:03:45 +0530 Subject: [PATCH 022/108] Allow TE menu for account user --- app/helpers/wktime_helper.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 336d2e6d9..69e0d8388 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -717,7 +717,7 @@ def checkViewPermission viewMenu = call_hook(:view_wktime_menu) viewMenu = viewMenu.blank? ? '' : (viewMenu.is_a?(Array) ? (viewMenu[0].blank? ? '': viewMenu[0].to_s) : viewMenu.to_s) @manger_user = ( !viewMenu.blank? && to_boolean(viewMenu)) - ret = (!viewProjects.blank? && viewProjects.size > 0) || (!loggableProjects.blank? && loggableProjects.size > 0) || @manger_user + ret = (!viewProjects.blank? && viewProjects.size > 0) || (!loggableProjects.blank? && loggableProjects.size > 0) || isAccountUser || @manger_user end ret end @@ -729,6 +729,7 @@ def is_number(val) def to_boolean(str) str == 'true' end + def getStatus_Project_Issue(issue_id,project_id) if !issue_id.blank? cond = getIssueSqlString(issue_id) @@ -743,10 +744,29 @@ def getStatus_Project_Issue(issue_id,project_id) expense_entry = WkExpenseEntry.find_by_sql(expense_sqlStr) ret = (!time_entry.blank? && time_entry.size > 0) || (!expense_entry.blank? && expense_entry.size > 0) end + def getIssueSqlString(issue_id) " where t.issue_id = #{issue_id} and (w.status ='s' OR w.status ='a')" end + def getProjectSqlString(project_id) " where t.project_id = #{project_id} and (w.status ='s' OR w.status ='a')" end + + def isAccountUser + group = nil + isAccountUser = false + groupusers = Array.new + accountGrpIds = Setting.plugin_redmine_wktime['wktime_account_groups'] if !Setting.plugin_redmine_wktime['wktime_account_groups'].blank? + accountGrpIds = accountGrpIds.collect{|i| i.to_i} + + if !accountGrpIds.blank? + accountGrpIds.each do |group_id| + scope = User.in_group(group_id) + groupusers << scope.all + end + end + grpUserIds = groupusers[0].collect{|user| user.id}.uniq + isAccountUser = grpUserIds.include?(User.current.id) + end end \ No newline at end of file From 75110bc8864e26b242ac7a32a9ac858a4988722e Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 26 May 2015 15:11:39 +0530 Subject: [PATCH 023/108] 006 issue description is shown without issue --- app/views/wktime/_edit_issues2.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 5ca7a877c..e836788f1 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -66,7 +66,7 @@ if params[:enter_issue_id].blank? options_for_select(issues, :selected => entry.nil? ? 0 : entry.issue_id, :required => true), :style=> "width:#{Setting.plugin_redmine_wktime['wktime_issue_dd_width']}px" ) %> <% else %> - <%= entry.issue.subject if !entry.nil? && !entry.issue.nil? %> + <%= entry.issue.tracker.to_s() + " #" + entry.issue.id.to_s() + ": " + entry.issue.subject if !entry.nil? && !entry.issue.nil? %> <% end %> <% else %> From 466f68cbb7acfb590eed17324e9ff033bba9382b Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 27 May 2015 13:10:35 +0530 Subject: [PATCH 024/108] Account user changes --- app/controllers/wktime_controller.rb | 17 +++++++++++------ app/helpers/wktime_helper.rb | 4 ++-- init.rb | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 7b905178d..2e65df434 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -486,11 +486,12 @@ def getusers else projmembers = project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") end - projmembers = projmembers.to_a.uniq if !projmembers.nil? - projmembers.each do |m| - userStr << m.user_id.to_s() + ',' + m.name + "\n" + if !projmembers.nil? + projmembers = projmembers.to_a.uniq + projmembers.each do |m| + userStr << m.user_id.to_s() + ',' + m.name + "\n" + end end - respond_to do |format| format.text { render :text => userStr } end @@ -1208,8 +1209,12 @@ def set_managed_projects if !view_projects.blank? @manage_view_spenttime_projects = view_projects[0].blank? ? nil : view_projects[0] else - view_spenttime_projects ||= Project.where(Project.allowed_to_condition(User.current, :view_time_entries)).order('name') - @manage_view_spenttime_projects = @manage_projects & view_spenttime_projects + if isAccountUser + @manage_view_spenttime_projects = Project.all + else + view_spenttime_projects ||= Project.where(Project.allowed_to_condition(User.current, :view_time_entries)).order('name') + @manage_view_spenttime_projects = @manage_projects & view_spenttime_projects + end end @manage_view_spenttime_projects = setTEProjects(@manage_view_spenttime_projects) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 69e0d8388..82c1147cf 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -716,8 +716,8 @@ def checkViewPermission loggableProjects ||= Project.where(Project.allowed_to_condition(User.current, :log_time)) viewMenu = call_hook(:view_wktime_menu) viewMenu = viewMenu.blank? ? '' : (viewMenu.is_a?(Array) ? (viewMenu[0].blank? ? '': viewMenu[0].to_s) : viewMenu.to_s) - @manger_user = ( !viewMenu.blank? && to_boolean(viewMenu)) - ret = (!viewProjects.blank? && viewProjects.size > 0) || (!loggableProjects.blank? && loggableProjects.size > 0) || isAccountUser || @manger_user + #@manger_user = (!viewMenu.blank? && to_boolean(viewMenu)) + ret = (!viewProjects.blank? && viewProjects.size > 0) || (!loggableProjects.blank? && loggableProjects.size > 0) || isAccountUser || (!viewMenu.blank? && to_boolean(viewMenu)) end ret end diff --git a/init.rb b/init.rb index 8b8cd459e..20d58c567 100644 --- a/init.rb +++ b/init.rb @@ -90,7 +90,7 @@ def destroy name 'Time & Expense' author 'Adhi Software Pvt Ltd' description 'This plugin is for entering Time & Expense' - version '1.8.1' + version '1.9' url 'http://www.redmine.org/plugins/wk-time' author_url 'http://www.adhisoftware.co.in/' @@ -216,6 +216,7 @@ def view_projects_show_sidebar_bottom(context={}) end end end + def controller_issues_edit_before_save(context={}) if !context[:time_entry].blank? if !context[:time_entry].hours.blank? && !context[:time_entry].activity_id.blank? From e7465243b80e581ca5d6a8a1c808d55a6fa17ed3 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 28 May 2015 11:27:15 +0530 Subject: [PATCH 025/108] 2.11 Allow the user to select multiple status items --- app/controllers/wktime_controller.rb | 6 +++--- app/helpers/wktime_helper.rb | 6 +++--- app/views/wktime/_te_index.html.erb | 1 + config/locales/en.yml | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 2e65df434..2212511cd 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -82,9 +82,9 @@ def index wkSqlStr = " left outer join " + entityNames[0] + " w on v1.startday = w.begin_date and v1.user_id = w.user_id left outer join users un on un.id = w.statusupdater_id" #status = params[:status] - if !status.blank? && status != 'all' - wkSqlStr += " WHERE w.status = '#{status}'" - if status == 'n' + if !status.blank? + wkSqlStr += " WHERE w.status in ('#{status.join("','")}')" + if status.include?('n') wkSqlStr += " OR w.status IS NULL" end end diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 82c1147cf..449e19387 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -15,12 +15,12 @@ def options_for_period_select(value) end def options_wk_status_select(value) - options_for_select([[l(:label_all), 'all'], + options_for_select([[l(:wk_status_empty), 'empty'], [l(:wk_status_new), 'n'], + [l(:wk_status_rejected), 'r']], [l(:wk_status_submitted), 's'], [l(:wk_status_approved), 'a'], - [l(:wk_status_rejected), 'r']], - value.blank? ? 'all' : value) + value.blank? ? 'n' : value) end def statusString(status) diff --git a/app/views/wktime/_te_index.html.erb b/app/views/wktime/_te_index.html.erb index 5c8647ea1..bb46dc381 100644 --- a/app/views/wktime/_te_index.html.erb +++ b/app/views/wktime/_te_index.html.erb @@ -94,6 +94,7 @@ $(document).ready(function() <%=h select_tag('status', options_for_select(options_wk_status_select(status), :selected => status.nil? ? 0 : status.to_s ), + :multiple=> true, :onchange => "this.form.submit();") %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 42abea292..a7a215cb7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -96,6 +96,7 @@ en: error_not_permitted_save: Not permitted to Save wk_status_new: New + wk_status_empty: Empty wk_status_submitted: Submitted wk_status_approved: Approved wk_status_rejected: Rejected From 4ee2fa3ee7f7a9c06ec9e9bfc07a5cc19481da78 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 28 May 2015 11:42:11 +0530 Subject: [PATCH 026/108] 2.11 code correction --- app/helpers/wktime_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 449e19387..e8f51e51f 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -17,9 +17,9 @@ def options_for_period_select(value) def options_wk_status_select(value) options_for_select([[l(:wk_status_empty), 'empty'], [l(:wk_status_new), 'n'], - [l(:wk_status_rejected), 'r']], + [l(:wk_status_rejected), 'r'], [l(:wk_status_submitted), 's'], - [l(:wk_status_approved), 'a'], + [l(:wk_status_approved), 'a']], value.blank? ? 'n' : value) end From 2c4f64de7781de14b2f3b0ccad0a4e8382a7d32e Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Thu, 28 May 2015 15:21:57 +0530 Subject: [PATCH 027/108] Account user changes --- app/controllers/wktime_controller.rb | 19 ++++++++--- app/views/wktime/_edit_issues.html.erb | 46 +++++++++++++------------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 2212511cd..0e67575bd 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -104,6 +104,11 @@ def edit setup findWkTE(@startday) @editable = @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r' + hookPerm = call_hook(:controller_check_editable, {:editable => @editable}) + @editable = hookPerm.blank? ? @editable : hookPerm[0] + hookPerm = call_hook(:controller_check_locked, {:startdate => @startday}) + @locked = hookPerm.blank? ? false : hookPerm[0] + @editable = false if @locked set_edit_time_logs @entries = findEntries() set_project_issues(@entries) @@ -114,10 +119,6 @@ def edit @prev_template = true end end - locked = call_hook(:controller_lock_sheet,{ :startday => @startday}) - locked = locked[0].blank? ? '' : locked[0] - @lockedsheet = !locked.blank? && locked - @editable = false if @lockedsheet respond_to do |format| format.html { render :layout => !request.xhr? @@ -213,6 +214,14 @@ def update end elsif !params[:wktime_unapprove].blank? && !@wktime.nil? && @wktime.status == 'a' && allowApprove errorMsg = updateStatus(:s) + elsif !params[:wktime_submit].blank? && !@wktime.nil? + #if TE sheet is read only mode with submit button + if !Setting.plugin_redmine_wktime['wktime_uuto_approve'].blank? && + Setting.plugin_redmine_wktime['wktime_uuto_approve'].to_i == 1 + errorMsg = updateStatus(:a) + else + errorMsg = updateStatus(:s) + end end end rescue Exception => e @@ -224,7 +233,7 @@ def update if !@entries.blank? || !params[:wktime_approve].blank? || (!params[:wktime_reject].blank? || !params[:hidden_wk_reject].blank?) || !params[:wktime_unsubmit].blank? || !params[:wktime_unapprove].blank? || - ((!params[:wktime_submit].blank? || !cvParams.blank?) && total > 0.0 && @wkvalidEntry) + ((!params[:wktime_submit].blank? || !cvParams.blank?) && total > 0.0) # && @wkvalidEntry respMsg = l(:notice_successful_update) else respMsg = l(:error_wktime_save_nothing) diff --git a/app/views/wktime/_edit_issues.html.erb b/app/views/wktime/_edit_issues.html.erb index 2e18e7ff9..57308c46a 100644 --- a/app/views/wktime/_edit_issues.html.erb +++ b/app/views/wktime/_edit_issues.html.erb @@ -94,34 +94,34 @@ currencySym = "" <% end %> -<% if !@lockedsheet %> -<% if @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r' %> - <%= submit_tag l(:button_save), :id => 'wktime_save', :name => 'wktime_save', :disabled => !(@row > 0)%> - <%= submit_tag l(:button_save_continue), :id => 'wktime_save_continue', :name => 'wktime_save_continue' , :disabled => !(@row > 0)%> - <% if !Setting.plugin_redmine_wktime[:wktime_use_approval_system].blank? && - Setting.plugin_redmine_wktime[:wktime_use_approval_system].to_i == 1 %> - <%= submit_tag l(:button_submit),:id => 'wktime_submit', :name => 'wktime_submit', :onclick => "return validateMinhour('#{controller.minHour}','#{getNonWorkingDayColumn(params[:startday])}');" , :disabled => !(@row > 0)%> +<% if !@locked %> + <% if @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r' %> + <%= submit_tag l(:button_save), :id => 'wktime_save', :name => 'wktime_save', :disabled => !(@row > 0)%> + <%= submit_tag l(:button_save_continue), :id => 'wktime_save_continue', :name => 'wktime_save_continue' , :disabled => !(@row > 0)%> + <% if !Setting.plugin_redmine_wktime[:wktime_use_approval_system].blank? && + Setting.plugin_redmine_wktime[:wktime_use_approval_system].to_i == 1 %> + <%= submit_tag l(:button_submit),:id => 'wktime_submit', :name => 'wktime_submit', :onclick => "return validateMinhour('#{controller.minHour}','#{getNonWorkingDayColumn(params[:startday])}');" , :disabled => !(@row > 0)%> + <% end %> <% end %> -<% end %> -<% if !Setting.plugin_redmine_wktime[:wktime_use_approval_system].blank? && - Setting.plugin_redmine_wktime[:wktime_use_approval_system].to_i == 1 %> - <% if !@wktime.nil? && @wktime.status == 's' %> - <%= submit_tag l(:button_wk_unsubmit), :name => 'wktime_unsubmit', :disabled => !(@row > 0)%> + <% if !Setting.plugin_redmine_wktime[:wktime_use_approval_system].blank? && + Setting.plugin_redmine_wktime[:wktime_use_approval_system].to_i == 1 %> + <% if !@wktime.nil? && @wktime.status == 's' %> + <%= submit_tag l(:button_wk_unsubmit), :name => 'wktime_unsubmit', :disabled => !(@row > 0)%> <% if controller.check_approvable_status() %> - <%= submit_tag l(:button_wk_approve), :name => 'wktime_approve', :disabled => !(@row > 0)%> - <%=h hidden_field_tag('wktime_notes', "") %> - <% # the jquery dialog box doesn't port the reject button value%> - <%=h hidden_field_tag('hidden_wk_reject', "") %> - <%= submit_tag l(:button_wk_reject), :name => 'wktime_reject', :disabled => !(@row > 0), - :onclick => "return showNotes();" %> - <% end %> - <% elsif !@wktime.nil? && @wktime.status == 'a' %> - <% if controller.check_approvable_status() %> - <%= submit_tag l(:button_wk_unapprove), :id => 'wktime_unapprove', :name => 'wktime_unapprove'%> + <%= submit_tag l(:button_wk_approve), :name => 'wktime_approve', :disabled => !(@row > 0)%> + <%=h hidden_field_tag('wktime_notes', "") %> + <% # the jquery dialog box doesn't port the reject button value%> + <%=h hidden_field_tag('hidden_wk_reject', "") %> + <%= submit_tag l(:button_wk_reject), :name => 'wktime_reject', :disabled => !(@row > 0), + :onclick => "return showNotes();" %> + <% end %> + <% elsif !@wktime.nil? && @wktime.status == 'a' %> + <% if controller.check_approvable_status() %> + <%= submit_tag l(:button_wk_unapprove), :id => 'wktime_unapprove', :name => 'wktime_unapprove'%> + <% end %> <% end %> <% end %> <% end %> -<% end %>
<% if @editable %> From ee50df36f31288f3af63086fc38b09c65fcd3c1e Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 28 May 2015 16:24:13 +0530 Subject: [PATCH 028/108] Change label to modified by in timesheet list --- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- config/locales/it.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index a7a215cb7..a43a60613 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,7 +105,7 @@ en: text_wk_warning_min_hour: "You have not entered the Minimum hours (%{value}) required per day" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Amount - field_status_updater: "Status updated by" + field_status_updater: "Modified by" label_wk_allow_filter_issue: Allow User filtering to My Issues diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 43168cfca..7c750d13e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -106,7 +106,7 @@ fr: text_wk_warning_min_hour: "Vous n'avez pas saisi le minimum d'heures (%{value}) requis par jour" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Montant - field_status_updater: Status updated by + field_status_updater: Modified by label_wk_allow_filter_issue: Allow User filtering to My Issues label_wk_no_user_current_project: no users in selected project diff --git a/config/locales/it.yml b/config/locales/it.yml index aeb9fbb12..d95353702 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -104,7 +104,7 @@ it: text_wk_warning_min_hour: "You have not entered the Minimum hours (%{value}) required per day" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Amount - field_status_updater: Status updated by + field_status_updater: Modified by label_wk_allow_filter_issue: Allow User filtering to My Issues label_wk_no_user_current_project: no users in selected project From c976bfbd286cf04409653f0934262c3bf9b85da6 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 28 May 2015 16:41:03 +0530 Subject: [PATCH 029/108] Removed the on change submission for status filter --- app/views/wktime/_te_index.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/wktime/_te_index.html.erb b/app/views/wktime/_te_index.html.erb index bb46dc381..f3c20300b 100644 --- a/app/views/wktime/_te_index.html.erb +++ b/app/views/wktime/_te_index.html.erb @@ -94,8 +94,7 @@ $(document).ready(function() <%=h select_tag('status', options_for_select(options_wk_status_select(status), :selected => status.nil? ? 0 : status.to_s ), - :multiple=> true, - :onchange => "this.form.submit();") %> + :multiple=> true) %> <%= render :partial => 'wktime/date_range' %> From 27398fbcbd1452d490de6f8dfa91fad5b2c49f79 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 28 May 2015 16:48:09 +0530 Subject: [PATCH 030/108] label name changes --- app/views/wktime/_list.html.erb | 2 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- config/locales/it.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/wktime/_list.html.erb b/app/views/wktime/_list.html.erb index 7c8d1223a..0762b4b09 100644 --- a/app/views/wktime/_list.html.erb +++ b/app/views/wktime/_list.html.erb @@ -7,7 +7,7 @@ <%= l(:field_user) %> <%= controller.getLabelforSpField %> <%= l(:field_status) %> -<%= l(:field_status_updater) %> +<%= l(:field_status_modified_by) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a43a60613..c2d593e44 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,7 +105,7 @@ en: text_wk_warning_min_hour: "You have not entered the Minimum hours (%{value}) required per day" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Amount - field_status_updater: "Modified by" + field_status_modified_by: "Modified by" label_wk_allow_filter_issue: Allow User filtering to My Issues diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7c750d13e..025ce2d21 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -106,7 +106,7 @@ fr: text_wk_warning_min_hour: "Vous n'avez pas saisi le minimum d'heures (%{value}) requis par jour" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Montant - field_status_updater: Modified by + field_status_modified_by: Modified by label_wk_allow_filter_issue: Allow User filtering to My Issues label_wk_no_user_current_project: no users in selected project diff --git a/config/locales/it.yml b/config/locales/it.yml index d95353702..15cd60567 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -104,7 +104,7 @@ it: text_wk_warning_min_hour: "You have not entered the Minimum hours (%{value}) required per day" text_wk_warning_max_hour: "You have entered hours above Maximum hours (%{value}) allowed per day" field_amount: Amount - field_status_updater: Modified by + field_status_modified_by: Modified by label_wk_allow_filter_issue: Allow User filtering to My Issues label_wk_no_user_current_project: no users in selected project From 530e92f9cbd33eee65afe60e5d1830070e4ba422 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 28 May 2015 19:56:53 +0530 Subject: [PATCH 031/108] Method added to get Account user projects --- app/controllers/wktime_controller.rb | 3 ++- app/helpers/wktime_helper.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 0e67575bd..f5d7a9d5b 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1219,7 +1219,8 @@ def set_managed_projects @manage_view_spenttime_projects = view_projects[0].blank? ? nil : view_projects[0] else if isAccountUser - @manage_view_spenttime_projects = Project.all + #@manage_view_spenttime_projects = Project.all + @manage_view_spenttime_projects = getAccountUserProjects else view_spenttime_projects ||= Project.where(Project.allowed_to_condition(User.current, :view_time_entries)).order('name') @manage_view_spenttime_projects = @manage_projects & view_spenttime_projects diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index e8f51e51f..f43428f51 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -769,4 +769,8 @@ def isAccountUser grpUserIds = groupusers[0].collect{|user| user.id}.uniq isAccountUser = grpUserIds.include?(User.current.id) end + + def getAccountUserProjects + Project.where(:status => "#{Project::STATUS_ACTIVE}") + end end \ No newline at end of file From 7d5227f9fa469421dfef9dc156cb1433d8042aff Mon Sep 17 00:00:00 2001 From: karthick Date: Fri, 29 May 2015 17:47:07 +0530 Subject: [PATCH 032/108] get add date string method --- app/helpers/wktime_helper.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index f43428f51..2ea5f923d 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -773,4 +773,17 @@ def isAccountUser def getAccountUserProjects Project.where(:status => "#{Project::STATUS_ACTIVE}") end + + def getAddDateStr(dtfield,noOfDays) + if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' + dateSqlStr = "date(#{dtfield}) + " + noOfDays.to_s + elsif ActiveRecord::Base.connection.adapter_name == 'SQLite' + dateSqlStr = "date(#{dtfield} , '+' || " + noOfDays.to_s + " || ' days')" + elsif ActiveRecord::Base.connection.adapter_name == 'SQLServer' + dateSqlStr = "DateAdd(d, " + noOfDays.to_s + ", " + dtfield +")" + else + dateSqlStr = "adddate(" + dtfield + ", " + noOfDays.to_s + ")" + end + dateSqlStr + end end \ No newline at end of file From 20f33883ab80644bd3350e5b6bbe8e10217b1868 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 29 May 2015 18:46:39 +0530 Subject: [PATCH 033/108] Changes for retrieving empty timesheets --- app/controllers/wkexpense_controller.rb | 32 ++++++++------ app/controllers/wktime_controller.rb | 59 ++++++++++++++++++------- app/helpers/wktime_helper.rb | 16 ++++--- 3 files changed, 70 insertions(+), 37 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index e3c64487c..40a17e098 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -123,33 +123,38 @@ def getEntityNames ["#{Wkexpense.table_name}", "#{WkExpenseEntry.table_name}"] end - def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr) - spField = getSpecificField() - result = WkExpenseEntry.find_by_sql("select count(*) as id from (" + selectStr + sqlStr + wkSqlStr + ") as v2") + def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) + spField = getSpecificField() + + dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" + teSqlStr = "(" + wkSelectStr + " ,exp.currency" + sqlStr + " inner join wk_expense_entries exp on v1.id = exp.id " + wkSqlStr + ") tmp2" + query = "select * from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + + "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.currency, tmp2.status_updater from " + query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr + query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3" + if !status.blank? + query += " WHERE tmp3.status in ('#{status.join("','")}')" + end + query = query + " order by tmp3.spent_on desc, tmp3.user_id " + + result = WkExpenseEntry.find_by_sql("select count(*) as id from (" + query + ") as v2") @entry_count = result[0].id setLimitAndOffset() rangeStr = formPaginationCondition() - @entries = WkExpenseEntry.find_by_sql(wkSelectStr + " ,exp.currency" + sqlStr + - " inner join wk_expense_entries exp on v1.id = exp.id " + wkSqlStr + rangeStr) - + @entries = WkExpenseEntry.find_by_sql(query + rangeStr) @unit = @entries.blank? ? l('number.currency.format.unit') : @entries[0][:currency] - - #@total_hours = TimeEntry.visible.sum(:hours, :include => [:user], :conditions => cond.conditions).to_f - - result = WkExpenseEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + selectStr + sqlStr + wkSqlStr +") as v2") + result = WkExpenseEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + query + ") as v2") @total_hours = result[0].amount end def findWkTEByCond(cond) - #@wktimes = Wkexpense.find(:all, :conditions => cond) @wktimes = Wkexpense.where(cond) end def findEntriesByCond(cond) - #WkExpenseEntry.find(:all, :conditions => cond, :order => 'project_id, issue_id, activity_id, spent_on') - #WkExpenseEntry.where(cond).order('project_id, issue_id, activity_id, spent_on') WkExpenseEntry.joins(:project).joins(:activity).joins("LEFT OUTER JOIN issues ON issues.id = wk_expense_entries.issue_id").where(cond).order('projects.name, issues.subject, enumerations.name, wk_expense_entries.spent_on') end @@ -216,6 +221,7 @@ def validateEntry(stDate) def getTEName "expense" end + # Returns the ExpenseEntry scope for index and report actions def expense_entry_scope(options={}) scope = @query.results_scope(options) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index f5d7a9d5b..b260ae4ea 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -53,9 +53,9 @@ def index ids = user_id end spField = getSpecificField() - entityNames = getEntityNames() - selectStr = "select v1.user_id, v1.startday as spent_on, v1." + spField - wkSelectStr = selectStr + ", w.status " + entityNames = getEntityNames() + teSelectStr = "select v1.user_id, v1.startday as spent_on, v1." + spField + wkSelectStr = teSelectStr + ", case when w.status is null then 'n' else w.status end as status " sqlStr = " from " sDay = getDateSqlString('t.spent_on') #Martin Dube contribution: 'start of the week' configuration @@ -82,14 +82,14 @@ def index wkSqlStr = " left outer join " + entityNames[0] + " w on v1.startday = w.begin_date and v1.user_id = w.user_id left outer join users un on un.id = w.statusupdater_id" #status = params[:status] - if !status.blank? - wkSqlStr += " WHERE w.status in ('#{status.join("','")}')" - if status.include?('n') - wkSqlStr += " OR w.status IS NULL" - end - end + #if !status.blank? + # wkSqlStr += " WHERE w.status in ('#{status.join("','")}')" + # if status.include?('n') + # wkSqlStr += " OR w.status IS NULL" + # end + #end - findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr) + findBySql(teSelectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) respond_to do |format| format.html { render :layout => !request.xhr? @@ -1311,20 +1311,45 @@ def getEntityNames ["#{Wktime.table_name}", "#{TimeEntry.table_name}"] end - def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr) + def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) spField = getSpecificField() - result = TimeEntry.find_by_sql("select count(*) as id from (" + selectStr + sqlStr + wkSqlStr + ") as v2") + + dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" + + teSqlStr = "(" + wkSelectStr + sqlStr + wkSqlStr + ") tmp2" + query = "select * from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + + "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.status_updater from " + query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr + query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3" + if !status.blank? + query += " WHERE tmp3.status in ('#{status.join("','")}')" + end + query = query + " order by tmp3.spent_on desc, tmp3.user_id " + + result = TimeEntry.find_by_sql("select count(*) as id from (" + query + ") as v2") @entry_count = result[0].id setLimitAndOffset() - rangeStr = formPaginationCondition() - @entries = TimeEntry.find_by_sql(wkSelectStr + sqlStr + wkSqlStr + rangeStr) - @unit = nil - #@total_hours = TimeEntry.visible.sum(:hours, :include => [:user], :conditions => cond.conditions).to_f + rangeStr = formPaginationCondition() - result = TimeEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + selectStr + sqlStr + wkSqlStr + ") as v2") + @entries = TimeEntry.find_by_sql(query + rangeStr) + @unit = nil + result = TimeEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + query + ") as v2") @total_hours = result[0].hours end + def getAllWeekSql(from, to) + noOfDays = 't4.i*7*10000 + t3.i*7*1000 + t2.i*7*100 + t1.i*7*10 + t0.i*7' + sqlStr = "select u.id, v.* from " + + "(select " + getAddDateStr(from, noOfDays) + "selected_date from " + + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0, " + + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1, " + + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, users u " + + "where selected_date between '#{from}' and '#{to}'" + end + def findWkTEByCond(cond) #@wktimes = Wktime.find(:all, :conditions => cond) @wktimes = Wktime.where(cond) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 2ea5f923d..86433de39 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -15,12 +15,12 @@ def options_for_period_select(value) end def options_wk_status_select(value) - options_for_select([[l(:wk_status_empty), 'empty'], + options_for_select([[l(:wk_status_empty), 'e'], [l(:wk_status_new), 'n'], [l(:wk_status_rejected), 'r'], [l(:wk_status_submitted), 's'], [l(:wk_status_approved), 'a']], - value.blank? ? 'n' : value) + value.blank? ? ['e','n','r','s','a'] : value) end def statusString(status) @@ -31,7 +31,9 @@ def statusString(status) when 'r' statusStr = l(:wk_status_rejected) when 's' - statusStr = l(:wk_status_submitted) + statusStr = l(:wk_status_submitted) + when 'e' + statusStr = l(:wk_status_empty) else statusStr = l(:wk_status_new) end @@ -776,13 +778,13 @@ def getAccountUserProjects def getAddDateStr(dtfield,noOfDays) if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' - dateSqlStr = "date(#{dtfield}) + " + noOfDays.to_s + dateSqlStr = "date('#{dtfield}') + " + noOfDays.to_s elsif ActiveRecord::Base.connection.adapter_name == 'SQLite' - dateSqlStr = "date(#{dtfield} , '+' || " + noOfDays.to_s + " || ' days')" + dateSqlStr = "date('#{dtfield}' , '+' || " + noOfDays.to_s + " || ' days')" elsif ActiveRecord::Base.connection.adapter_name == 'SQLServer' - dateSqlStr = "DateAdd(d, " + noOfDays.to_s + ", " + dtfield +")" + dateSqlStr = "DateAdd(d, " + noOfDays.to_s + ",'#{dtfield}')" else - dateSqlStr = "adddate(" + dtfield + ", " + noOfDays.to_s + ")" + dateSqlStr = "adddate('#{dtfield}', " + noOfDays.to_s + ")" end dateSqlStr end From 6104525ab5fa830c7ebbc489a4c15a0a91ec6c45 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 29 May 2015 19:23:31 +0530 Subject: [PATCH 034/108] changes for retrieving timesheets for all time --- app/controllers/wkexpense_controller.rb | 8 ++++++++ app/controllers/wktime_controller.rb | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index 40a17e098..b1d6cdb49 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -150,6 +150,14 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) @total_hours = result[0].amount end + def getAllTimeRange(ids) + query = "select #{getDateSqlString('t.spent_on')} as startday " + + "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" + result = WkExpenseEntry.find_by_sql(query) + @from = result[0].startday + @to = result[result.size - 1].startday + end + def findWkTEByCond(cond) @wktimes = Wkexpense.where(cond) end diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index b260ae4ea..e26ff37db 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -52,6 +52,11 @@ def index else ids = user_id end + + if @from.blank? && @to.blank? + getAllTimeRange(ids) + end + spField = getSpecificField() entityNames = getEntityNames() teSelectStr = "select v1.user_id, v1.startday as spent_on, v1." + spField @@ -1350,6 +1355,14 @@ def getAllWeekSql(from, to) "where selected_date between '#{from}' and '#{to}'" end + def getAllTimeRange(ids) + query = "select #{getDateSqlString('t.spent_on')} as startday " + + "from time_entries t where user_id in (#{ids}) group by startday order by startday" + result = TimeEntry.find_by_sql(query) + @from = result[0].startday + @to = result[result.size - 1].startday + end + def findWkTEByCond(cond) #@wktimes = Wktime.find(:all, :conditions => cond) @wktimes = Wktime.where(cond) From b9066bb6b8a8d12a7d570e9a39fd0186654c8dbb Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 29 May 2015 19:38:56 +0530 Subject: [PATCH 035/108] bug fixing --- app/controllers/wkexpense_controller.rb | 2 +- app/controllers/wktime_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index b1d6cdb49..fa53ba9f2 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -155,7 +155,7 @@ def getAllTimeRange(ids) "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" result = WkExpenseEntry.find_by_sql(query) @from = result[0].startday - @to = result[result.size - 1].startday + @to = result[result.size - 1].startday + 6 end def findWkTEByCond(cond) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index e26ff37db..dda94fe71 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1360,7 +1360,7 @@ def getAllTimeRange(ids) "from time_entries t where user_id in (#{ids}) group by startday order by startday" result = TimeEntry.find_by_sql(query) @from = result[0].startday - @to = result[result.size - 1].startday + @to = result[result.size - 1].startday + 6 end def findWkTEByCond(cond) From 82ed45376c55b32b0b409d60c5b21ac2baa30810 Mon Sep 17 00:00:00 2001 From: karthick Date: Mon, 1 Jun 2015 18:29:55 +0530 Subject: [PATCH 036/108] Add new timesheet issue --- app/controllers/wktime_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index dda94fe71..fcbd9f1a6 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -109,7 +109,7 @@ def edit setup findWkTE(@startday) @editable = @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r' - hookPerm = call_hook(:controller_check_editable, {:editable => @editable}) + hookPerm = call_hook(:controller_check_editable, {:editable => @editable, :user => @user}) @editable = hookPerm.blank? ? @editable : hookPerm[0] hookPerm = call_hook(:controller_check_locked, {:startdate => @startday}) @locked = hookPerm.blank? ? false : hookPerm[0] From 8b23f380c513de1dae9f78c7ca25126ffc374fd9 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Tue, 2 Jun 2015 10:48:01 +0530 Subject: [PATCH 037/108] All time date range --- app/controllers/wkexpense_controller.rb | 9 +++++++-- app/controllers/wktime_controller.rb | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index fa53ba9f2..170df55a1 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -154,8 +154,13 @@ def getAllTimeRange(ids) query = "select #{getDateSqlString('t.spent_on')} as startday " + "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" result = WkExpenseEntry.find_by_sql(query) - @from = result[0].startday - @to = result[result.size - 1].startday + 6 + if !result.blank? + @from = result[0].startday + @to = result[result.size - 1].startday + 6 + else + @from = Date.today - 30 + @to = Date.today + end end def findWkTEByCond(cond) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index fcbd9f1a6..59faa0bf1 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1359,8 +1359,13 @@ def getAllTimeRange(ids) query = "select #{getDateSqlString('t.spent_on')} as startday " + "from time_entries t where user_id in (#{ids}) group by startday order by startday" result = TimeEntry.find_by_sql(query) - @from = result[0].startday - @to = result[result.size - 1].startday + 6 + if !result.blank? + @from = result[0].startday + @to = result[result.size - 1].startday + 6 + else + @from = Date.today - 30 + @to = Date.today + end end def findWkTEByCond(cond) From 309c3920c2c7627af57d2040c413f09145b28538 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 2 Jun 2015 11:52:25 +0530 Subject: [PATCH 038/108] all time date range - bug fixing --- app/controllers/wkexpense_controller.rb | 7 ++++--- app/controllers/wktime_controller.rb | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index 170df55a1..93de51dc4 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -156,10 +156,11 @@ def getAllTimeRange(ids) result = WkExpenseEntry.find_by_sql(query) if !result.blank? @from = result[0].startday - @to = result[result.size - 1].startday + 6 + #@to = result[result.size - 1].startday + 6 + @to = getEndDay(Date.today) else - @from = Date.today - 30 - @to = Date.today + @from = Date.civil(Date.today.year, Date.today.month, 1) + @to = (@from >> 1) - 1 end end diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 59faa0bf1..41c870d1c 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1361,10 +1361,11 @@ def getAllTimeRange(ids) result = TimeEntry.find_by_sql(query) if !result.blank? @from = result[0].startday - @to = result[result.size - 1].startday + 6 + #@to = result[result.size - 1].startday + 6 + @to = getEndDay(Date.today) else - @from = Date.today - 30 - @to = Date.today + @from = Date.civil(Date.today.year, Date.today.month, 1) + @to = (@from >> 1) - 1 end end From ea224bcf38c3fccfa53d2042707d7583bc60038f Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 2 Jun 2015 12:33:43 +0530 Subject: [PATCH 039/108] Appropriate Start date for all users --- app/controllers/wktime_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 41c870d1c..8b53fc97f 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1322,7 +1322,7 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" teSqlStr = "(" + wkSelectStr + sqlStr + wkSqlStr + ") tmp2" - query = "select * from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + + query = "select user_id, spent_on, #{spField}, status, status_updater from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr @@ -1352,7 +1352,7 @@ def getAllWeekSql(from, to) "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, users u " + - "where selected_date between '#{from}' and '#{to}'" + "where selected_date between (case when u.created_on > '#{from}' then (#{getDateSqlString('date(u.created_on)')}) else '#{from}' end) and '#{to}'" end def getAllTimeRange(ids) From b11b0ba5f8bf7458842bd28370fc3528c205360a Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 2 Jun 2015 15:48:00 +0530 Subject: [PATCH 040/108] Disallow time entry delete if timesheet is locked --- app/helpers/wktime_helper.rb | 2 +- config/locales/en.yml | 1 + config/locales/fr.yml | 3 + config/locales/it.yml | 3 + init.rb | 148 +++++++++++++++++++++++------------ 5 files changed, 107 insertions(+), 50 deletions(-) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 86433de39..bc8f73710 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -555,7 +555,7 @@ def set_cf_value(col_values, custom_field_values, setting_name) def getTimeEntryStatus(spent_on,user_id) #result = Wktime.find(:all, :conditions => [ 'begin_date = ? AND user_id = ?', getStartDay(spent_on), user_id]) start_day = getStartDay(spent_on) - locked = call_hook(:controller_lock_sheet,{ :startday => start_day}) + locked = call_hook(:controller_check_locked,{ :startdate => start_day}) locked = locked.blank? ? '' : (locked.is_a?(Array) ? (locked[0].blank? ? '': locked[0].to_s) : locked.to_s) locked = ( !locked.blank? && to_boolean(locked)) if locked diff --git a/config/locales/en.yml b/config/locales/en.yml index c2d593e44..04511ce55 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -114,6 +114,7 @@ en: permission_approve_time_entries: Approve time logs field_currency: Currency error_project_issue_associate: Cannot be deleted because time/expense entries associated + error_time_entry_delete: "Cannot be deleted. The timesheet with this entry is locked" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 025ce2d21..89949ee0e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -112,5 +112,8 @@ fr: label_wk_no_user_current_project: no users in selected project permission_approve_time_entries: Approve time logs + field_currency: Currency + error_project_issue_associate: Cannot be deleted because time/expense entries associated + error_time_entry_delete: "Cannot be deleted. The timesheet with this entry is locked" diff --git a/config/locales/it.yml b/config/locales/it.yml index 15cd60567..028476496 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -110,4 +110,7 @@ it: label_wk_no_user_current_project: no users in selected project permission_approve_time_entries: Approve time logs + field_currency: Currency + error_project_issue_associate: Cannot be deleted because time/expense entries associated + error_time_entry_delete: "Cannot be deleted. The timesheet with this entry is locked" diff --git a/init.rb b/init.rb index 20d58c567..82ce0c82e 100644 --- a/init.rb +++ b/init.rb @@ -7,10 +7,10 @@ def self.included(base) end end - module ProjectsControllerPatch - def self.included(base) - base.class_eval do - def destroy +module ProjectsControllerPatch + def self.included(base) + base.class_eval do + def destroy @project_to_destroy = @project if api_request? || params[:confirm] wktime_helper = Object.new.extend(WktimeHelper) @@ -31,60 +31,110 @@ def destroy # hide project in layout @project = nil end - end - end + end + end +end + +module IssuesControllerPatch + def self.included(base) + base.class_eval do + def destroy + @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f + if @hours > 0 + case params[:todo] + when 'destroy' + wktime_helper = Object.new.extend(WktimeHelper) + issue_id = @issues.map(&:id) + ret = wktime_helper.getStatus_Project_Issue(issue_id[0],nil) + if ret + flash.now[:error] = l(:error_project_issue_associate) + return + end + when 'nullify' + TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL') + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.where(['issue_id IN (?)', @issues]). + update_all("issue_id = #{reassign_to.id}") + end + else + # display the destroy form if it's a user request + return unless api_request? + end + end + @issues.each do |issue| + begin + + issue.reload.destroy + rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists + # nothing to do, issue was already deleted (eg. by a parent) + end + end + respond_to do |format| + format.html { redirect_back_or_default _project_issues_path(@project) } + format.api { render_api_ok } + end + end end - module IssuesControllerPatch - def self.included(base) - base.class_eval do - def destroy - @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f - if @hours > 0 - case params[:todo] - when 'destroy' + end +end + +module TimelogControllerPatch + def self.included(base) + base.send(:include) + + base.class_eval do + def destroy wktime_helper = Object.new.extend(WktimeHelper) - issue_id = @issues.map(&:id) - ret = wktime_helper.getStatus_Project_Issue(issue_id[0],nil) - if ret - flash.now[:error] = l(:error_project_issue_associate) - return - end - when 'nullify' - TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL') - when 'reassign' - reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) - if reassign_to.nil? - flash.now[:error] = l(:error_issue_not_found_in_project) - return - else - TimeEntry.where(['issue_id IN (?)', @issues]). - update_all("issue_id = #{reassign_to.id}") + errMsg = "" + destroyed = TimeEntry.transaction do + @time_entries.each do |t| + status = wktime_helper.getTimeEntryStatus(t.spent_on, t.user_id) + if !status.blank? && ('a' == status || 's' == status || 'l' == status) + errMsg = "#{l(:error_time_entry_delete)}" + end + if errMsg.blank? + unless (t.destroy && t.destroyed?) + raise ActiveRecord::Rollback + end + end + end + end + + respond_to do |format| + format.html { + if errMsg.blank? + if destroyed + flash[:notice] = l(:notice_successful_delete) + else + flash[:error] = l(:notice_unable_delete_time_entry) + end + else + flash[:error] = errMsg + end + redirect_back_or_default project_time_entries_path(@projects.first) + } + format.api { + if destroyed + render_api_ok + else + render_validation_errors(@time_entries) + end + } end - else - # display the destroy form if it's a user request - return unless api_request? - end - end - @issues.each do |issue| - begin - - issue.reload.destroy - rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists - # nothing to do, issue was already deleted (eg. by a parent) - end - end - respond_to do |format| - format.html { redirect_back_or_default _project_issues_path(@project) } - format.api { render_api_ok } end end - end - end end +end CustomFieldsHelper.send(:include, WktimeHelperPatch) ProjectsController.send(:include, ProjectsControllerPatch) IssuesController.send(:include, IssuesControllerPatch) +TimelogController.send(:include, TimelogControllerPatch) Redmine::Plugin.register :redmine_wktime do name 'Time & Expense' @@ -177,7 +227,7 @@ class WktimeHook < Redmine::Hook::ViewListener def controller_timelog_edit_before_save(context={ }) if !context[:time_entry].hours.blank? && !context[:time_entry].activity_id.blank? wktime_helper = Object.new.extend(WktimeHelper) - status= wktime_helper.getTimeEntryStatus(context[:time_entry].spent_on,context[:time_entry].user_id) + status = wktime_helper.getTimeEntryStatus(context[:time_entry].spent_on,context[:time_entry].user_id) if !status.blank? && ('a' == status || 's' == status || 'l' == status) raise "#{l(:label_warning_wktime_time_entry)}" end From 47e0d4dd8a09e59c935cdc758b9f54aaa3dfbf7e Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 2 Jun 2015 16:38:21 +0530 Subject: [PATCH 041/108] Empty time sheet for non project members --- app/controllers/wktime_controller.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 8b53fc97f..86e591c12 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -37,7 +37,7 @@ def index end ids = nil if user_id.blank? - ids = User.current.id.to_s + ids = is_member_of_any_project() ? User.current.id.to_s : '0' elsif user_id.to_i == 0 unless @members.blank? @members.each_with_index do |users,i| @@ -50,7 +50,7 @@ def index end ids = '0' if ids.nil? else - ids = user_id + ids = user_id end if @from.blank? && @to.blank? @@ -1545,6 +1545,12 @@ def set_edit_time_logs @edittimelogs = editPermission.blank? ? '' : editPermission[0].to_s end + def is_member_of_any_project + querystr = "select count(user_id) as id_count from members where user_id = " + User.current.id.to_s + result = Member.find_by_sql(querystr) + ret = result[0].id_count > 0 ? true : false + end + def set_filter_session if params[:searchlist].blank? && (session[:wktimes].nil? || session[:wkexpense].nil?) From 4f967f4116461644b1e3e7badfcb119cd9f75e8b Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 2 Jun 2015 20:16:44 +0530 Subject: [PATCH 042/108] Change method is_member_of_any_project --- app/controllers/wktime_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 86e591c12..caeddf711 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1546,9 +1546,9 @@ def set_edit_time_logs end def is_member_of_any_project - querystr = "select count(user_id) as id_count from members where user_id = " + User.current.id.to_s - result = Member.find_by_sql(querystr) - ret = result[0].id_count > 0 ? true : false + cond = "user_id = " + User.current.id.to_s + projMember = Member.where(cond) + ret = projMember.size > 0 end def set_filter_session From 766dafebd0f27ba40f092f5c0c6e6cbc62e08c8a Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Wed, 3 Jun 2015 15:01:45 +0530 Subject: [PATCH 043/108] Members dropdown default select members --- app/controllers/wktime_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index caeddf711..07815d510 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1162,8 +1162,8 @@ def setMembers project_id = session[:wktimes][:project_id] end hookMem = call_hook(:controller_get_member, { :filter_type => filter_type}) - if filter_type == '1' || (hookMem.blank? && filter_type !='2') - hookProjMem = call_hook(:controller_project_member, { :project_id => project_id}) + if ( filter_type !='2') + hookProjMem = call_hook(:controller_project_member, { :project_id => @selected_project}) if !hookProjMem.blank? projMem = hookProjMem[0].blank? ? [] : hookProjMem[0] else From 7c9d91946badc7551a9489e3d0090772c383e6cc Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 3 Jun 2015 17:14:10 +0530 Subject: [PATCH 044/108] Bug fixing Accounts user allowed to add/edit timesheet --- app/controllers/wktime_controller.rb | 19 ++++++++++--------- app/views/wktime/_te_new.html.erb | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 07815d510..30efd34f1 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -494,7 +494,7 @@ def getactivities def getusers project = Project.find(params[:project_id]) userStr = "" - userList = call_hook(:controller_project_member,{ :project_id => params[:project_id]}) + userList = call_hook(:controller_project_member, {:project_id => params[:project_id], :page => params[:page]}) if !userList.blank? projmembers = userList[0].blank? ? nil : userList[0] else @@ -672,16 +672,17 @@ def check_permission ret = (@user.id == User.current.id && @logtime_projects.size > 0) end end - editPermission = call_hook(:controller_check_permission,{:params => params}) - editPermission = editPermission.blank? ? '' : (editPermission.is_a?(Array) ? (editPermission[0].blank? ? '': editPermission[0]) : editPermission) + editPermission = call_hook(:controller_check_permission, {:params => params}) + #editPermission = editPermission.blank? ? '' : (editPermission.is_a?(Array) ? (editPermission[0].blank? ? '': editPermission[0]) : editPermission) if !editPermission.blank? - ret = false - if editPermission - ret = true - end - end + #ret = false + #if editPermission + # ret = true + #end + ret = editPermission[0] || (@user.id == User.current.id && @logtime_projects.size > 0) + end return ret - end + end def getGrpMembers userList = [] diff --git a/app/views/wktime/_te_new.html.erb b/app/views/wktime/_te_new.html.erb index ef2532aa2..526c0d3ad 100644 --- a/app/views/wktime/_te_new.html.erb +++ b/app/views/wktime/_te_new.html.erb @@ -2,7 +2,7 @@ <%= back_url_hidden_field_tag %> @@ -17,7 +17,7 @@
<%=l(:label_member)%> -<% ddMember = call_hook(:view_member_dropdown, {:project_id => @selected_project.id}) %> +<% ddMember = call_hook(:view_member_dropdown, {:project_id => @selected_project.id, :page => 'new'}) %> <% if !ddMember.blank? %> <%= ddMember %> <% else %> From a4c65aaf4df7b7a8c47109e50271d511cc920668 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 3 Jun 2015 18:40:07 +0530 Subject: [PATCH 045/108] bug fixing in all time date range --- app/controllers/wktime_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 30efd34f1..2683ede7e 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1365,8 +1365,8 @@ def getAllTimeRange(ids) #@to = result[result.size - 1].startday + 6 @to = getEndDay(Date.today) else - @from = Date.civil(Date.today.year, Date.today.month, 1) - @to = (@from >> 1) - 1 + @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) + @to = getEndDay((@from >> 1) - 1) end end From 3f35d94f168aba94fe683122e7cfe1e868930cf4 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 3 Jun 2015 18:41:38 +0530 Subject: [PATCH 046/108] bug fixing --- app/controllers/wkexpense_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index 93de51dc4..261863725 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -159,8 +159,8 @@ def getAllTimeRange(ids) #@to = result[result.size - 1].startday + 6 @to = getEndDay(Date.today) else - @from = Date.civil(Date.today.year, Date.today.month, 1) - @to = (@from >> 1) - 1 + @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) + @to = getEndDay((@from >> 1) - 1) end end From 0a9de2aa84eaad0c9395fd3f80d601fc6d590e01 Mon Sep 17 00:00:00 2001 From: arulbaskar Date: Wed, 3 Jun 2015 19:51:17 +0530 Subject: [PATCH 047/108] Timesheet lock delete --- app/controllers/wktime_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 2683ede7e..b1cbb5442 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -329,6 +329,12 @@ def destroy setup #cond = getCondition('spent_on', @user.id, @startday, @startday+6) #TimeEntry.delete_all(cond) + hookPerm = call_hook(:controller_check_locked, {:startdate => @startday}) + locked = hookPerm.blank? ? false : hookPerm[0] + if locked + flash[:error] = l(:error_time_entry_delete) + redirect_to :action => 'index' , :tab => params[:tab] + else @entries = findEntries() @entries.each do |entry| entry.destroy() @@ -344,6 +350,7 @@ def destroy render_api_ok } end + end end def new From 0e804f19110325ec36bccc48f30d929f3976a997 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 4 Jun 2015 11:47:30 +0530 Subject: [PATCH 048/108] Filter alltime using created on date and current date --- app/controllers/wkexpense_controller.rb | 26 ++++++++++++------------- app/controllers/wktime_controller.rb | 15 ++++++++------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index 261863725..d3ce97dbc 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -150,19 +150,19 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) @total_hours = result[0].amount end - def getAllTimeRange(ids) - query = "select #{getDateSqlString('t.spent_on')} as startday " + - "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" - result = WkExpenseEntry.find_by_sql(query) - if !result.blank? - @from = result[0].startday - #@to = result[result.size - 1].startday + 6 - @to = getEndDay(Date.today) - else - @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) - @to = getEndDay((@from >> 1) - 1) - end - end + #def getAllTimeRange(ids) + #query = "select #{getDateSqlString('t.spent_on')} as startday " + + # "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" + #result = WkExpenseEntry.find_by_sql(query) + #if !result.blank? + # @from = result[0].startday + # #@to = result[result.size - 1].startday + 6 + # @to = getEndDay(Date.today) + #else + # @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) + # @to = getEndDay((@from >> 1) - 1) + #end + #end def findWkTEByCond(cond) @wktimes = Wkexpense.where(cond) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index b1cbb5442..2c4e1bd75 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1170,8 +1170,8 @@ def setMembers project_id = session[:wktimes][:project_id] end hookMem = call_hook(:controller_get_member, { :filter_type => filter_type}) - if ( filter_type !='2') - hookProjMem = call_hook(:controller_project_member, { :project_id => @selected_project}) + if filter_type == '1' || (hookMem.blank? && filter_type !='2') + hookProjMem = call_hook(:controller_project_member, { :project_id => project_id}) if !hookProjMem.blank? projMem = hookProjMem[0].blank? ? [] : hookProjMem[0] else @@ -1352,6 +1352,7 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) end def getAllWeekSql(from, to) + to = to.blank? || to > Date.today ? getEndDay(Date.today) : to noOfDays = 't4.i*7*10000 + t3.i*7*1000 + t2.i*7*100 + t1.i*7*10 + t0.i*7' sqlStr = "select u.id, v.* from " + "(select " + getAddDateStr(from, noOfDays) + "selected_date from " + @@ -1364,11 +1365,13 @@ def getAllWeekSql(from, to) end def getAllTimeRange(ids) - query = "select #{getDateSqlString('t.spent_on')} as startday " + - "from time_entries t where user_id in (#{ids}) group by startday order by startday" - result = TimeEntry.find_by_sql(query) + #query = "select #{getDateSqlString('t.spent_on')} as startday " + + # "from time_entries t where user_id in (#{ids}) group by startday order by startday" + #result = TimeEntry.find_by_sql(query) + query = "select date(min(created_on)) as startday from users where id in (#{ids})" + result = User.find_by_sql(query) if !result.blank? - @from = result[0].startday + @from = getStartDay(result[0].startday) #@to = result[result.size - 1].startday + 6 @to = getEndDay(Date.today) else From 98117a5e516145d1916aa54d4e5b3cf0b3e3dd98 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Thu, 4 Jun 2015 12:10:54 +0530 Subject: [PATCH 049/108] bug fixing --- app/controllers/wktime_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 2c4e1bd75..619a503a7 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1355,12 +1355,15 @@ def getAllWeekSql(from, to) to = to.blank? || to > Date.today ? getEndDay(Date.today) : to noOfDays = 't4.i*7*10000 + t3.i*7*1000 + t2.i*7*100 + t1.i*7*10 + t0.i*7' sqlStr = "select u.id, v.* from " + - "(select " + getAddDateStr(from, noOfDays) + "selected_date from " + + "(select " + getAddDateStr(from, noOfDays) + " selected_date from " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + - "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, users u " + + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, " + + "(select distinct u.* from projects p " + + "inner join members m on p.id = m.project_id and p.status not in (#{Project::STATUS_CLOSED},#{Project::STATUS_ARCHIVED}) " + + "inner join users u on m.user_id = u.id) u " + "where selected_date between (case when u.created_on > '#{from}' then (#{getDateSqlString('date(u.created_on)')}) else '#{from}' end) and '#{to}'" end From 249d293d479faa615281818a09199ce1bf6e9dde Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 4 Jun 2015 12:20:35 +0530 Subject: [PATCH 050/108] Bug fixing for account user new timesheet error. --- app/controllers/wktime_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 619a503a7..76411c46b 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1507,7 +1507,7 @@ def getSelectedProject(projList) elsif !session[:wktimes].blank? selected_proj_id = session[:wktimes][:project_id] end - if !selected_proj_id.blank? + if !selected_proj_id.blank? && !isAccountUser sel_project = projList.select{ |proj| proj.id == selected_proj_id.to_i } selected_project ||= sel_project[0] if !sel_project.blank? else From d5db5eabbb3fd04b0a9467bd80d80ec4e3d1657a Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 4 Jun 2015 14:50:27 +0530 Subject: [PATCH 051/108] Bug fixing --- app/controllers/wktime_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 76411c46b..c13fed1eb 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1373,7 +1373,8 @@ def getAllTimeRange(ids) #result = TimeEntry.find_by_sql(query) query = "select date(min(created_on)) as startday from users where id in (#{ids})" result = User.find_by_sql(query) - if !result.blank? + stDate = result[0].startday if !result.blank? + if !stDate.blank? @from = getStartDay(result[0].startday) #@to = result[result.size - 1].startday + 6 @to = getEndDay(Date.today) From b5625aff273779554c855a1269a1702baec25ff9 Mon Sep 17 00:00:00 2001 From: karthick Date: Thu, 4 Jun 2015 16:28:51 +0530 Subject: [PATCH 052/108] Remove project id in empty timesheet --- app/views/wktime/_edit_issues2.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index e836788f1..5d336ff2a 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -20,7 +20,11 @@ if params[:enter_issue_id].blank? :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:#{Setting.plugin_redmine_wktime['wktime_project_dd_width']}px" ) %> <% else %> <% if project.blank? %> - <%= project_id %> + <% if entry.nil? %> + <%= '' %> + <% else %> + <%= project_id %> + <% end %> <% else %> <%= project[0] %> <% end %> From d5aa1c48d964b303837b37ed8ab70623678c34b2 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Thu, 4 Jun 2015 16:56:33 +0530 Subject: [PATCH 053/108] closed project and issue name when project and issue are closed display corresponding names.. remove corresponding id. --- app/views/wktime/_edit_issues2.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 5d336ff2a..f4deb2731 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -10,10 +10,11 @@ if params[:enter_issue_id].blank? project = projects.detect {|p| p[1].to_i == entry.project_id} unless entry.nil? #check if the project, which was previously reported time, is still visible #if it is not visible, just show the id alone - projects.unshift( [ entry.project_id, entry.project_id ] ) if !entry.nil? && project.blank? + projects.unshift( [ entry.project.name, entry.project_id ] ) if !entry.nil? && project.blank? %> +<% project_name = entry.nil? ? (@logtime_projects.blank? ? 0 : @logtime_projects[0].id) : entry.project.name %> <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][project_id]' : 'time_entry[][project_id]', options_for_select(projects, :selected => project_id), @@ -23,7 +24,7 @@ if params[:enter_issue_id].blank? <% if entry.nil? %> <%= '' %> <% else %> - <%= project_id %> + <%= project_name %> <% end %> <% else %> <%= project[0] %> From a4b2a4ff9fb491ecb802871adf4c84a9c2214738 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Thu, 4 Jun 2015 19:32:59 +0530 Subject: [PATCH 054/108] bug fixing --- app/controllers/wktime_controller.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index c13fed1eb..2ed577210 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -680,12 +680,7 @@ def check_permission end end editPermission = call_hook(:controller_check_permission, {:params => params}) - #editPermission = editPermission.blank? ? '' : (editPermission.is_a?(Array) ? (editPermission[0].blank? ? '': editPermission[0]) : editPermission) if !editPermission.blank? - #ret = false - #if editPermission - # ret = true - #end ret = editPermission[0] || (@user.id == User.current.id && @logtime_projects.size > 0) end return ret @@ -995,7 +990,7 @@ def can_log_time?(project_id) def check_editperm_redirect - hookPerm = call_hook(:controller_edit_timelog_permission) + hookPerm = call_hook(:controller_edit_timelog_permission, {:params => params}) if !hookPerm.blank? allow = hookPerm[0] || check_editPermission else From 421ef6982a8851381c0ae67d7cb7f4e8071b8db5 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 5 Jun 2015 14:55:39 +0530 Subject: [PATCH 055/108] bug fixed to show admin users timesheets --- app/controllers/wktime_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 2ed577210..3e37c4a58 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -37,7 +37,8 @@ def index end ids = nil if user_id.blank? - ids = is_member_of_any_project() ? User.current.id.to_s : '0' + #ids = is_member_of_any_project() ? User.current.id.to_s : '0' + ids = User.current.id.to_s elsif user_id.to_i == 0 unless @members.blank? @members.each_with_index do |users,i| @@ -1356,9 +1357,10 @@ def getAllWeekSql(from, to) "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, " + - "(select distinct u.* from projects p " + - "inner join members m on p.id = m.project_id and p.status not in (#{Project::STATUS_CLOSED},#{Project::STATUS_ARCHIVED}) " + - "inner join users u on m.user_id = u.id) u " + + "(select distinct u.id, u.created_on from projects p " + + "inner join members m on p.id = m.project_id " + #and p.status not in (#{Project::STATUS_CLOSED},#{Project::STATUS_ARCHIVED}) + "inner join users u on m.user_id = u.id " + + "union select u.id, u.created_on from users u where admin = 1) u " + "where selected_date between (case when u.created_on > '#{from}' then (#{getDateSqlString('date(u.created_on)')}) else '#{from}' end) and '#{to}'" end From 0b7417f6007965cc5d7058e0a0a8d41ca7d1962a Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Fri, 5 Jun 2015 15:21:04 +0530 Subject: [PATCH 056/108] default Member selection --- app/controllers/wktime_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 3e37c4a58..9cc0a0b64 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1180,7 +1180,9 @@ def setMembers userList.each do |users| @members << [users.name,users.id.to_s()] end - else + else + projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") + @members = projMem.collect{|m| [ m.name, m.user_id ] } if !hookMem.blank? @members = hookMem[0].blank? ? @members : hookMem[0] end From 9752b280cf21e18aaf6d6a65c0df7194a93feb06 Mon Sep 17 00:00:00 2001 From: karthick Date: Fri, 5 Jun 2015 16:58:41 +0530 Subject: [PATCH 057/108] logic change in query --- app/controllers/wkexpense_controller.rb | 34 ++++++++++++----------- app/controllers/wktime_controller.rb | 36 ++++++++++++++----------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index d3ce97dbc..b543da7c4 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -132,9 +132,13 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.currency, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr - query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3" + query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 " + query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id from wk_expense_entries t, users u " + query = query + " where u.id = t.user_id and u.id in (#{ids}) group by user_id ) vw on vw.user_id = tmp3.user_id" + query += " WHERE not (tmp3.spent_on not between vw.min_spent_on and '#{Date.today}' and tmp3.status = 'e') " + + "and vw.min_spent_on is not null " if !status.blank? - query += " WHERE tmp3.status in ('#{status.join("','")}')" + query += " and tmp3.status in ('#{status.join("','")}') " end query = query + " order by tmp3.spent_on desc, tmp3.user_id " @@ -150,19 +154,19 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) @total_hours = result[0].amount end - #def getAllTimeRange(ids) - #query = "select #{getDateSqlString('t.spent_on')} as startday " + - # "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" - #result = WkExpenseEntry.find_by_sql(query) - #if !result.blank? - # @from = result[0].startday - # #@to = result[result.size - 1].startday + 6 - # @to = getEndDay(Date.today) - #else - # @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) - # @to = getEndDay((@from >> 1) - 1) - #end - #end + def getAllTimeRange(ids) + query = "select #{getDateSqlString('t.spent_on')} as startday " + + "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" + result = WkExpenseEntry.find_by_sql(query) + if !result.blank? + @from = result[0].startday + @to = result[result.size - 1].startday + 6 + #@to = getEndDay(Date.today) + else + @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) + @to = getEndDay((@from >> 1) - 1) + end + end def findWkTEByCond(cond) @wktimes = Wkexpense.where(cond) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 9cc0a0b64..00473de2b 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1325,16 +1325,22 @@ def getEntityNames def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) spField = getSpecificField() + current_date = Date.today + dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" teSqlStr = "(" + wkSelectStr + sqlStr + wkSqlStr + ") tmp2" - query = "select user_id, spent_on, #{spField}, status, status_updater from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + + query = "select tmp3.user_id, tmp3.spent_on, tmp3.#{spField}, tmp3.status, tmp3.status_updater from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr - query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3" + query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 " + query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id from time_entries t, users u " + query = query + " where u.id = t.user_id and u.id in (#{ids}) group by user_id ) vw on vw.user_id = tmp3.user_id" + query += " WHERE not (tmp3.spent_on not between vw.min_spent_on and '#{Date.today}' and tmp3.status = 'e') " + + "and vw.min_spent_on is not null " if !status.blank? - query += " WHERE tmp3.status in ('#{status.join("','")}')" + query += " and tmp3.status in ('#{status.join("','")}') " end query = query + " order by tmp3.spent_on desc, tmp3.user_id " @@ -1350,7 +1356,7 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) end def getAllWeekSql(from, to) - to = to.blank? || to > Date.today ? getEndDay(Date.today) : to + #to = to.blank? || to > Date.today ? getEndDay(Date.today) : to noOfDays = 't4.i*7*10000 + t3.i*7*1000 + t2.i*7*100 + t1.i*7*10 + t0.i*7' sqlStr = "select u.id, v.* from " + "(select " + getAddDateStr(from, noOfDays) + " selected_date from " + @@ -1362,21 +1368,21 @@ def getAllWeekSql(from, to) "(select distinct u.id, u.created_on from projects p " + "inner join members m on p.id = m.project_id " + #and p.status not in (#{Project::STATUS_CLOSED},#{Project::STATUS_ARCHIVED}) "inner join users u on m.user_id = u.id " + - "union select u.id, u.created_on from users u where admin = 1) u " + - "where selected_date between (case when u.created_on > '#{from}' then (#{getDateSqlString('date(u.created_on)')}) else '#{from}' end) and '#{to}'" + "union select u.id, u.created_on from users u where admin = '1') u " + + "where selected_date between '#{from}' and '#{to}'" end def getAllTimeRange(ids) - #query = "select #{getDateSqlString('t.spent_on')} as startday " + - # "from time_entries t where user_id in (#{ids}) group by startday order by startday" - #result = TimeEntry.find_by_sql(query) - query = "select date(min(created_on)) as startday from users where id in (#{ids})" - result = User.find_by_sql(query) - stDate = result[0].startday if !result.blank? - if !stDate.blank? + query = "select #{getDateSqlString('t.spent_on')} as startday " + + "from time_entries t where user_id in (#{ids}) group by startday order by startday" + result = TimeEntry.find_by_sql(query) + #query = "select date(min(created_on)) as startday from users where id in (#{ids})" + #result = User.find_by_sql(query) + #stDate = result[0].startday if !result.blank? + if !result.blank? @from = getStartDay(result[0].startday) - #@to = result[result.size - 1].startday + 6 - @to = getEndDay(Date.today) + @to = result[result.size - 1].startday + 6 + #@to = getEndDay(Date.today) else @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) @to = getEndDay((@from >> 1) - 1) From 14f16eaef85bfba16c635c80b8488c2bd77b0d17 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 5 Jun 2015 17:09:32 +0530 Subject: [PATCH 058/108] added order by --- app/helpers/wktime_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index bc8f73710..69307adb4 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -773,7 +773,7 @@ def isAccountUser end def getAccountUserProjects - Project.where(:status => "#{Project::STATUS_ACTIVE}") + Project.where(:status => "#{Project::STATUS_ACTIVE}").order('name') end def getAddDateStr(dtfield,noOfDays) From 010fe9041468801c6e4c3361589757e1f1cc5a6d Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 5 Jun 2015 18:47:18 +0530 Subject: [PATCH 059/108] Changed end date for all time date range --- app/controllers/wkexpense_controller.rb | 4 ++-- app/controllers/wktime_controller.rb | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index b543da7c4..06ab1ca1c 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -133,8 +133,8 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.currency, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 " - query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id from wk_expense_entries t, users u " - query = query + " where u.id = t.user_id and u.id in (#{ids}) group by user_id ) vw on vw.user_id = tmp3.user_id" + query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id as usrid from wk_expense_entries t, users u " + query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id" query += " WHERE not (tmp3.spent_on not between vw.min_spent_on and '#{Date.today}' and tmp3.status = 'e') " + "and vw.min_spent_on is not null " if !status.blank? diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 00473de2b..c836c142e 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1335,8 +1335,8 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 " - query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id from time_entries t, users u " - query = query + " where u.id = t.user_id and u.id in (#{ids}) group by user_id ) vw on vw.user_id = tmp3.user_id" + query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id as usrid from time_entries t, users u " + query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id" query += " WHERE not (tmp3.spent_on not between vw.min_spent_on and '#{Date.today}' and tmp3.status = 'e') " + "and vw.min_spent_on is not null " if !status.blank? @@ -1382,7 +1382,10 @@ def getAllTimeRange(ids) if !result.blank? @from = getStartDay(result[0].startday) @to = result[result.size - 1].startday + 6 - #@to = getEndDay(Date.today) + currentWeekEndDay = getEndDay(Date.today) + if currentWeekEndDay > @to + @to = currentWeekEndDay + end else @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) @to = getEndDay((@from >> 1) - 1) From 60d3cf8b7ade722c74ca78e84e42e18dc9579f86 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 5 Jun 2015 19:06:24 +0530 Subject: [PATCH 060/108] bug fixing --- app/controllers/wkexpense_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index 06ab1ca1c..d46f30e89 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -161,7 +161,10 @@ def getAllTimeRange(ids) if !result.blank? @from = result[0].startday @to = result[result.size - 1].startday + 6 - #@to = getEndDay(Date.today) + currentWeekEndDay = getEndDay(Date.today) + if currentWeekEndDay > @to + @to = currentWeekEndDay + end else @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) @to = getEndDay((@from >> 1) - 1) From 112dd5b333ba5eca47228141c085d4a54f5b278e Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Fri, 5 Jun 2015 20:01:48 +0530 Subject: [PATCH 061/108] bug fixing --- app/controllers/wktime_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index c836c142e..4d09c8b6f 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -233,7 +233,6 @@ def update rescue Exception => e errorMsg = e.message end - if errorMsg.nil? #when the are entries or it is not a save action if !@entries.blank? || !params[:wktime_approve].blank? || @@ -663,7 +662,7 @@ def check_permission ret = false setup set_user_projects - status = getTimeEntryStatus(@startday,@user_id) + status = getTimeEntryStatus(@startday, @user_id) approve_projects = @approvable_projects & @logtime_projects if (status != 'n' && (!approve_projects.blank? && approve_projects.size > 0)) #for approver @@ -993,7 +992,7 @@ def can_log_time?(project_id) def check_editperm_redirect hookPerm = call_hook(:controller_edit_timelog_permission, {:params => params}) if !hookPerm.blank? - allow = hookPerm[0] || check_editPermission + allow = hookPerm[0] || (check_editPermission && @user.id == User.current.id) else allow = check_editPermission end From 02e95cd2a200b12cabf1e89156ad6238be930b11 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 8 Jun 2015 20:09:14 +0530 Subject: [PATCH 062/108] bug fixing Added blank check before calling collect --- app/controllers/wktime_controller.rb | 2 +- app/helpers/wktime_helper.rb | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 4d09c8b6f..1f38058d3 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1172,7 +1172,7 @@ def setMembers else projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") end - @members = projMem.collect{|m| [ m.name, m.user_id ] } + @members = projMem.collect{|m| [ m.name, m.user_id ] } if !projMem.blank? elsif filter_type == '2' userList = [] userList = getGrpMembers diff --git a/app/helpers/wktime_helper.rb b/app/helpers/wktime_helper.rb index 69307adb4..09833fb2a 100644 --- a/app/helpers/wktime_helper.rb +++ b/app/helpers/wktime_helper.rb @@ -48,10 +48,12 @@ def options_for_wktime_project(projects, needBlankRow=false) end #Project.project_tree(projects) do |proj_name, level| - project_tree(projects) do |proj, level| - indent_level = (level > 0 ? (' ' * 2 * level + '» ').html_safe : '') - sel_project = projects.select{ |p| p.id == proj.id } - projArr << [ (indent_level + sel_project[0].name), sel_project[0].id ] + if !projects.blank? + project_tree(projects) do |proj, level| + indent_level = (level > 0 ? (' ' * 2 * level + '» ').html_safe : '') + sel_project = projects.select{ |p| p.id == proj.id } + projArr << [ (indent_level + sel_project[0].name), sel_project[0].id ] + end end projArr end @@ -760,7 +762,9 @@ def isAccountUser isAccountUser = false groupusers = Array.new accountGrpIds = Setting.plugin_redmine_wktime['wktime_account_groups'] if !Setting.plugin_redmine_wktime['wktime_account_groups'].blank? - accountGrpIds = accountGrpIds.collect{|i| i.to_i} + if !accountGrpIds.blank? + accountGrpIds = accountGrpIds.collect{|i| i.to_i} + end if !accountGrpIds.blank? accountGrpIds.each do |group_id| @@ -768,7 +772,8 @@ def isAccountUser groupusers << scope.all end end - grpUserIds = groupusers[0].collect{|user| user.id}.uniq + grpUserIds = Array.new + grpUserIds = groupusers[0].collect{|user| user.id}.uniq if !groupusers.blank? && !groupusers[0].blank? isAccountUser = grpUserIds.include?(User.current.id) end From 7ca3b50eefb88d381bbab5ae7b33c2c0c83e586b Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 9 Jun 2015 12:18:00 +0530 Subject: [PATCH 063/108] Fix for Deprecation Warning in Timestamp on db migration --- db/migrate/001_create_wktimes.rb | 2 +- db/migrate/002_create_wk_expense_entries.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/001_create_wktimes.rb b/db/migrate/001_create_wktimes.rb index ffa255bcb..d7e4b8d00 100644 --- a/db/migrate/001_create_wktimes.rb +++ b/db/migrate/001_create_wktimes.rb @@ -10,7 +10,7 @@ def change t.references :submitter, :class => "User", :null => true t.references :statusupdater, :class => "User" t.string :notes - t.timestamps + t.timestamps null: false end add_index :wktimes, :user_id add_index :wktimes, :begin_date diff --git a/db/migrate/002_create_wk_expense_entries.rb b/db/migrate/002_create_wk_expense_entries.rb index 5efc4a2d7..d49c543ed 100644 --- a/db/migrate/002_create_wk_expense_entries.rb +++ b/db/migrate/002_create_wk_expense_entries.rb @@ -28,7 +28,7 @@ def change t.references :submitter, :class => "User", :null => true t.references :statusupdater, :class => "User" t.string :notes - t.timestamps + t.timestamps null: false end add_index :wkexpenses, :user_id add_index :wkexpenses, :begin_date From 821a5bb75a23797c9aa8ac4ca380718f29a496e0 Mon Sep 17 00:00:00 2001 From: karthick Date: Tue, 9 Jun 2015 13:14:13 +0530 Subject: [PATCH 064/108] Fix to show the full name in list and edit page --- app/views/wktime/_edit_header.html.erb | 2 +- app/views/wktime/_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wktime/_edit_header.html.erb b/app/views/wktime/_edit_header.html.erb index 8a870a303..385f4c535 100644 --- a/app/views/wktime/_edit_header.html.erb +++ b/app/views/wktime/_edit_header.html.erb @@ -9,7 +9,7 @@ - diff --git a/app/views/wktime/_list.html.erb b/app/views/wktime/_list.html.erb index 0762b4b09..69e3e4797 100644 --- a/app/views/wktime/_list.html.erb +++ b/app/views/wktime/_list.html.erb @@ -16,7 +16,7 @@ "> - + From 4bbda7cb1fa271ee2eec792f3fbd05c7063c156b Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Wed, 10 Jun 2015 10:40:45 +0530 Subject: [PATCH 065/108] selected project account user selected project can be changed based on project dropdown --- app/controllers/wktime_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 1f38058d3..713ba73e9 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -32,7 +32,7 @@ def index end set_user_projects if (!@manage_view_spenttime_projects.blank? && @manage_view_spenttime_projects.size > 0) - @selected_project = getSelectedProject(@manage_view_spenttime_projects) + @selected_project = getSelectedProject(@manage_view_spenttime_projects,true) setMembers end ids = nil @@ -355,7 +355,7 @@ def destroy def new set_user_projects - @selected_project = getSelectedProject(@manage_projects) + @selected_project = getSelectedProject(@manage_projects,false) # get the startday for current week @startday = getStartDay(Date.today) render :action => 'new' @@ -1169,7 +1169,7 @@ def setMembers hookProjMem = call_hook(:controller_project_member, { :project_id => project_id}) if !hookProjMem.blank? projMem = hookProjMem[0].blank? ? [] : hookProjMem[0] - else + else projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") end @members = projMem.collect{|m| [ m.name, m.user_id ] } if !projMem.blank? @@ -1508,14 +1508,14 @@ def getTEName "time" end - def getSelectedProject(projList) + def getSelectedProject(projList,projstatus) #selected_proj_id = params[:project_id] if !params[:tab].blank? && params[:tab] =='wkexpense' selected_proj_id = session[:wkexpense][:project_id].blank? ? params[:project_id] : session[:wkexpense][:project_id] elsif !session[:wktimes].blank? selected_proj_id = session[:wktimes][:project_id] end - if !selected_proj_id.blank? && !isAccountUser + if !selected_proj_id.blank? && projstatus #( !isAccountUser || !projList.blank? ) sel_project = projList.select{ |proj| proj.id == selected_proj_id.to_i } selected_project ||= sel_project[0] if !sel_project.blank? else From 62668674c13a026fd534669a97734224e5bbef27 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Wed, 10 Jun 2015 12:37:38 +0530 Subject: [PATCH 066/108] closed issue id --- app/views/wktime/_edit_issues2.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index f4deb2731..521bc6fd7 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -14,7 +14,7 @@ if params[:enter_issue_id].blank? %> - \ No newline at end of file diff --git a/app/views/wkexpense/_wkexpense_cf_in_row_header.html.erb b/app/views/wkexpense/_wkexpense_cf_in_row_header.html.erb index b1905c691..e69de29bb 100644 --- a/app/views/wkexpense/_wkexpense_cf_in_row_header.html.erb +++ b/app/views/wkexpense/_wkexpense_cf_in_row_header.html.erb @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/app/views/wktime/_edit_issues.html.erb b/app/views/wktime/_edit_issues.html.erb index 57308c46a..1db7865ad 100644 --- a/app/views/wktime/_edit_issues.html.erb +++ b/app/views/wktime/_edit_issues.html.erb @@ -73,11 +73,21 @@ currencySym = "" - - - - - + + <% if controller.enterCommentInRow %> + + <% end %> + <% if !controller.getUnitLabel.blank? %> + + <% end %> + <% if controller.getUnitLabel.blank? %> + <% if controller.enterCustomFieldInRow(1) %> + + <% end %> + <% if controller.enterCustomFieldInRow(2) %> + + <% end %> + <% end %> <% thours.each_with_index do |th,i| %> <% end %> diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index fcde33f25..6c62e47bd 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -122,17 +122,14 @@ if params[:enter_issue_id].blank? <%=h entry.nil? ? '' : entry.comments%> <% end %> -<% else %> -<% # leave a blank td %> - <% end %> - +<% if !(controller.getUnitDDHTML).blank? %> + +<% end %> <%= render :partial => controller.getCFInRowHTML , :locals => {:entry => entry, :isTemplate => false }%> diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index 7494669f2..f1054d51a 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -5,12 +5,12 @@ <% if !Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? && Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 %> -<% else %> - <% end %> - +<% if !controller.getUnitLabel.blank? %> + +<% end %> <%= render :partial => controller.getCFInRowHeaderHTML %> <% startOfWeek = getStartOfWeek %> diff --git a/app/views/wktime/_wktime_cf_in_row.erb b/app/views/wktime/_wktime_cf_in_row.erb index c131883fa..1b7035e9f 100644 --- a/app/views/wktime/_wktime_cf_in_row.erb +++ b/app/views/wktime/_wktime_cf_in_row.erb @@ -1,26 +1,27 @@ - <% end %> - - <% end %> - \ No newline at end of file diff --git a/app/views/wktime/_wktime_cf_in_row_header.html.erb b/app/views/wktime/_wktime_cf_in_row_header.html.erb index c1a1e6de5..e0a7fddc0 100644 --- a/app/views/wktime/_wktime_cf_in_row_header.html.erb +++ b/app/views/wktime/_wktime_cf_in_row_header.html.erb @@ -1,19 +1,19 @@ - <% end %> - - <% end %> - \ No newline at end of file diff --git a/app/views/wktime/_worktime_header.html.erb b/app/views/wktime/_worktime_header.html.erb index e7095d80d..fb898953c 100644 --- a/app/views/wktime/_worktime_header.html.erb +++ b/app/views/wktime/_worktime_header.html.erb @@ -1,16 +1,23 @@ - - - - - + <% if controller.enterCommentInRow %> + + <% end %> + <% if controller.getUnitLabel.blank? %> + <% if controller.enterCustomFieldInRow(1) %> + + <% end %> + <% if controller.enterCustomFieldInRow(2) %> + + <% end %> + <% end %> + <% for i in 0..6%> <% if (isEditable) %> - + <% else %> <% end %> diff --git a/app/views/wktime/edit.html.erb b/app/views/wktime/edit.html.erb index edcad8acf..64fd116de 100644 --- a/app/views/wktime/edit.html.erb +++ b/app/views/wktime/edit.html.erb @@ -14,6 +14,15 @@ showWorkHeader = true; footerRows = 2; headerRows = 4; + <% if controller.enterCommentInRow %> + hStartIndex = hStartIndex + 1 ; + <% end %> + <% if controller.enterCustomFieldInRow(1) %> + hStartIndex = hStartIndex + 1 ; + <% end %> + <% if controller.enterCustomFieldInRow(2) %> + hStartIndex = hStartIndex + 1 ; + <% end %> <% end %> <% if !Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].blank? && Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].to_i == 1 %> diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index a04650f90..d8019f3ae 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -11,7 +11,7 @@ var allowBlankIssue = false; var commentInRow = false; var footerRows = 1; var headerRows = 1; -var hStartIndex = 6; +var hStartIndex = 2; var issueField = 'Issue'; var submissionack=""; var minHourAlertMsg=""; From 827454f1fc7cfda30f74c03b30e24cc5d6e83534 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Mon, 15 Jun 2015 20:26:52 +0530 Subject: [PATCH 077/108] Remove extra spaces remove extra spaces from project, issues and activity dropdown --- app/views/wktime/_issue_header.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index f1054d51a..16b06c6ab 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -1,6 +1,6 @@ - - - + + + <% if !Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? && Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 %> From c2be996377817e0dfc1efd5009155d7352d85ccf Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 16 Jun 2015 11:04:28 +0530 Subject: [PATCH 078/108] Fix for member dropdown not loading properly --- app/controllers/wktime_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 473003df5..261b22fc8 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -32,9 +32,9 @@ def index end set_user_projects if (!@manage_view_spenttime_projects.blank? && @manage_view_spenttime_projects.size > 0) - @selected_project = getSelectedProject(@manage_view_spenttime_projects, false) - setMembers + @selected_project = getSelectedProject(@manage_view_spenttime_projects, false) end + setMembers ids = nil if user_id.blank? #ids = is_member_of_any_project() ? User.current.id.to_s : '0' @@ -1182,6 +1182,7 @@ def retrieve_date_range def setMembers @groups = Group.sorted.all @members = Array.new + projMem = nil if !params[:tab].blank? && params[:tab] =='wkexpense' filter_type = session[:wkexpense][:filter_type] project_id = session[:wkexpense][:project_id] @@ -1195,7 +1196,7 @@ def setMembers if !hookProjMem.blank? projMem = hookProjMem[0].blank? ? [] : hookProjMem[0] else - projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") + projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") if !@selected_project.blank? end @members = projMem.collect{|m| [ m.name, m.user_id ] } if !projMem.blank? elsif filter_type == '2' @@ -1205,8 +1206,8 @@ def setMembers @members << [users.name,users.id.to_s()] end else - projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") - @members = projMem.collect{|m| [ m.name, m.user_id ] } + projMem = @selected_project.members.order("#{User.table_name}.firstname ASC,#{User.table_name}.lastname ASC") if !@selected_project.blank? + @members = projMem.collect{|m| [ m.name, m.user_id ] } if !projMem.blank? if !hookMem.blank? @members = hookMem[0].blank? ? @members : hookMem[0] end @@ -1540,7 +1541,7 @@ def getSelectedProject(projList, setFirstProj) selected_proj_id = session[:wktimes][:project_id] end if !selected_proj_id.blank? && !setFirstProj #( !isAccountUser || !projList.blank? ) - sel_project = projList.select{ |proj| proj.id == selected_proj_id.to_i } + sel_project = projList.select{ |proj| proj.id == selected_proj_id.to_i } if !projList.blank? selected_project ||= sel_project[0] if !sel_project.blank? else selected_project ||= projList[0] if !projList.blank? From 5d177eacdad7e24b4ad9023e3ebc104213692c7b Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Tue, 16 Jun 2015 11:18:05 +0530 Subject: [PATCH 079/108] remove spaces remove space from time entry textbox and delete buttton --- app/views/wktime/_issue_header.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index 16b06c6ab..78b9250fc 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -16,9 +16,9 @@ <% startOfWeek = getStartOfWeek %> <% for i in 0..6%> - + <% end %> - + <% if controller.showWorktimeHeader %> From c1f68fbc75a91f0c433ca5242b7aed733e8e17da Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Tue, 16 Jun 2015 15:02:39 +0530 Subject: [PATCH 080/108] remove space --- app/views/wktime/_issue_header.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index 78b9250fc..d4c5ce4f7 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -16,9 +16,9 @@ <% startOfWeek = getStartOfWeek %> <% for i in 0..6%> - + <% end %> - + <% if controller.showWorktimeHeader %> From 898a7f74d797bd3eacaef763708e405dc0432ca0 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 16 Jun 2015 16:10:32 +0530 Subject: [PATCH 081/108] bug fixing in issue dropdown --- assets/javascripts/edit.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index d8019f3ae..a5590a79c 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -467,9 +467,22 @@ function updateDropdown(itemStr, row, dropdown, showId, needBlankOption, skipFir } } } - if(selectedVal && !selectedValSet){ - dropdown[row-1].options[needBlankOption ? i+1 : i] = new Option( - selectedText, selectedVal, false, true); + + var addExistingOption = true; + if(showId) { //for issue dropdown + var hoursFld = document.getElementsByName("hours" + row + "[]"); + addExistingOption = false; + for(var j = 0; j < hoursFld.length; j++) { + if(hoursFld[j].value) { + addExistingOption = true; + break; + } + } + } + if (addExistingOption === true) { + if(selectedVal && !selectedValSet){ + dropdown[row-1].options[needBlankOption ? i+1 : i] = new Option(selectedText, selectedVal, false, true); + } } } From 35b1f12a6e7c87323a5bb863b29302cbb2c091b8 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Thu, 18 Jun 2015 13:16:55 +0530 Subject: [PATCH 082/108] Empty filter logic change --- app/controllers/wkexpense_controller.rb | 34 +++-------- app/controllers/wktime_controller.rb | 76 +++++++++++++++---------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index a116d0535..e506dc24b 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -128,51 +128,33 @@ def getEntityNames end def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) - spField = getSpecificField() - + spField = getSpecificField() dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" teSqlStr = "(" + wkSelectStr + " ,exp.currency" + sqlStr + " inner join wk_expense_entries exp on v1.id = exp.id " + wkSqlStr + ") tmp2" - query = "select * from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + + query = "select tmp3.user_id, tmp3.spent_on, tmp3.#{spField}, tmp3.status, tmp3.status_updater, tmp3.created_on, tmp3.currency from (select tmp1.id as user_id, tmp1.created_on, tmp1.selected_date as spent_on, " + "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.currency, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 " query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id as usrid from wk_expense_entries t, users u " - query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id" - query += " WHERE not (tmp3.spent_on not between vw.min_spent_on and '#{Date.today}' and tmp3.status = 'e') " + - "and vw.min_spent_on is not null " - if !status.blank? - query += " and tmp3.status in ('#{status.join("','")}') " - end + query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id " + query = query + getWhereCond(status) query = query + " order by tmp3.spent_on desc, tmp3.user_id " result = WkExpenseEntry.find_by_sql("select count(*) as id from (" + query + ") as v2") - @entry_count = result[0].id - + @entry_count = result[0].id setLimitAndOffset() rangeStr = formPaginationCondition() - @entries = WkExpenseEntry.find_by_sql(query + rangeStr) @unit = @entries.blank? ? l('number.currency.format.unit') : @entries[0][:currency] result = WkExpenseEntry.find_by_sql("select sum(v2." + spField + ") as " + spField + " from (" + query + ") as v2") @total_hours = result[0].amount end - def getAllTimeRange(ids) - query = "select #{getDateSqlString('t.spent_on')} as startday " + + def getTEAllTimeRange(ids) + teQuery = "select #{getDateSqlString('t.spent_on')} as startday " + "from wk_expense_entries t where user_id in (#{ids}) group by startday order by startday" - result = WkExpenseEntry.find_by_sql(query) - if !result.blank? - @from = result[0].startday - @to = result[result.size - 1].startday + 6 - currentWeekEndDay = getEndDay(Date.today) - if currentWeekEndDay > @to - @to = currentWeekEndDay - end - else - @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) - @to = getEndDay((@from >> 1) - 1) - end + teResult = WkExpenseEntry.find_by_sql(teQuery) end def findWkTEByCond(cond) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 261b22fc8..2d658f7ad 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1348,25 +1348,18 @@ def getEntityNames end def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) - spField = getSpecificField() - - current_date = Date.today - - dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" - + spField = getSpecificField() + dtRangeForUsrSqlStr = "(" + getAllWeekSql(@from, @to) + ") tmp1" teSqlStr = "(" + wkSelectStr + sqlStr + wkSqlStr + ") tmp2" - query = "select tmp3.user_id, tmp3.spent_on, tmp3.#{spField}, tmp3.status, tmp3.status_updater from (select tmp1.id as user_id, tmp1.selected_date as spent_on, " + + + query = "select tmp3.user_id, tmp3.spent_on, tmp3.#{spField}, tmp3.status, tmp3.status_updater, tmp3.created_on from (select tmp1.id as user_id, tmp1.created_on, tmp1.selected_date as spent_on, " + "case when tmp2.#{spField} is null then 0 else tmp2.#{spField} end as #{spField}, " + "case when tmp2.status is null then 'e' else tmp2.status end as status, tmp2.status_updater from " query = query + dtRangeForUsrSqlStr + " left join " + teSqlStr query = query + " on tmp1.id = tmp2.user_id and tmp1.selected_date = tmp2.spent_on where tmp1.id in (#{ids}) ) tmp3 " query = query + " left outer join (select min( #{getDateSqlString('t.spent_on')} ) as min_spent_on, t.user_id as usrid from time_entries t, users u " - query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id" - query += " WHERE not (tmp3.spent_on not between vw.min_spent_on and '#{Date.today}' and tmp3.status = 'e') " + - "and vw.min_spent_on is not null " - if !status.blank? - query += " and tmp3.status in ('#{status.join("','")}') " - end + query = query + " where u.id = t.user_id and u.id in (#{ids}) group by t.user_id ) vw on vw.usrid = tmp3.user_id " + query = query + getWhereCond(status) query = query + " order by tmp3.spent_on desc, tmp3.user_id " result = TimeEntry.find_by_sql("select count(*) as id from (" + query + ") as v2") @@ -1380,40 +1373,65 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) @total_hours = result[0].hours end + def getWhereCond(status) + current_date = getEndDay(Date.today) + query = "WHERE ((tmp3.spent_on between " + query = query + "case when vw.min_spent_on is null then date(#{getDateSqlString('tmp3.created_on')}) else vw.min_spent_on end " + query = query + "and '#{current_date}') OR " + query = query + "((tmp3.spent_on < case when vw.min_spent_on is null then date(#{getDateSqlString('tmp3.created_on')}) else vw.min_spent_on end " + query = query + "and tmp3.status <> 'e') " + query = query + "OR (tmp3.spent_on > '#{current_date}' and tmp3.status <> 'e'))) " + if !status.blank? + query += " and tmp3.status in ('#{status.join("','")}') " + end + query + end + def getAllWeekSql(from, to) #to = to.blank? || to > Date.today ? getEndDay(Date.today) : to entityNames = getEntityNames() noOfDays = 't4.i*7*10000 + t3.i*7*1000 + t2.i*7*100 + t1.i*7*10 + t0.i*7' - sqlStr = "select u.id, v.* from " + + sqlStr = "select u.id, u.created_on, v.selected_date from " + "(select " + getAddDateStr(from, noOfDays) + " selected_date from " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, " + - "(select distinct u.id, u.created_on from users u " + - "inner join #{entityNames[1]} t on u.id = t.user_id) u " + + "(select distinct u.id, u.created_on from users u )u " + "where selected_date between '#{from}' and '#{to}'" end - def getAllTimeRange(ids) - query = "select #{getDateSqlString('t.spent_on')} as startday " + + def getTEAllTimeRange(ids) + teQuery = "select #{getDateSqlString('t.spent_on')} as startday " + "from time_entries t where user_id in (#{ids}) group by startday order by startday" - result = TimeEntry.find_by_sql(query) - #query = "select date(min(created_on)) as startday from users where id in (#{ids})" - #result = User.find_by_sql(query) - #stDate = result[0].startday if !result.blank? - if !result.blank? - @from = getStartDay(result[0].startday) - @to = result[result.size - 1].startday + 6 - currentWeekEndDay = getEndDay(Date.today) + teResult = TimeEntry.find_by_sql(teQuery) + end + + def getUserAllTimeRange(ids) + usrQuery = "select date(min(created_on)) as startday from users where id in (#{ids})" + usrResult = User.find_by_sql(usrQuery) + end + + def getAllTimeRange(ids) + teResult = getTEAllTimeRange(ids) + usrResult = getUserAllTimeRange(ids) + currentWeekEndDay = getEndDay(Date.today) + @to = currentWeekEndDay + if !teResult.blank? + @from = teResult[0].startday + @to = teResult[teResult.size - 1].startday + 6 if currentWeekEndDay > @to @to = currentWeekEndDay end - else - @from = getStartDay(Date.civil(Date.today.year, Date.today.month, 1)) - @to = getEndDay((@from >> 1) - 1) end + if !usrResult.blank? + stDate = usrResult[0].startday if !usrResult.blank? + stDate = getStartDay(stDate) + if ((!@from.blank? && stDate < @from) || @from.blank?) + @from = stDate + end + end end def findWkTEByCond(cond) From abff1679a57494dcd5e58aaf158f5cda6f9a2a16 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Thu, 18 Jun 2015 13:37:07 +0530 Subject: [PATCH 083/108] Fix for postgres --- app/controllers/wktime_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 2d658f7ad..a53229cf0 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1376,9 +1376,9 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) def getWhereCond(status) current_date = getEndDay(Date.today) query = "WHERE ((tmp3.spent_on between " - query = query + "case when vw.min_spent_on is null then date(#{getDateSqlString('tmp3.created_on')}) else vw.min_spent_on end " + query = query + "case when vw.min_spent_on is null then #{getDateSqlString('date(tmp3.created_on)')} else vw.min_spent_on end " query = query + "and '#{current_date}') OR " - query = query + "((tmp3.spent_on < case when vw.min_spent_on is null then date(#{getDateSqlString('tmp3.created_on')}) else vw.min_spent_on end " + query = query + "((tmp3.spent_on < case when vw.min_spent_on is null then #{getDateSqlString('date(tmp3.created_on)')} else vw.min_spent_on end " query = query + "and tmp3.status <> 'e') " query = query + "OR (tmp3.spent_on > '#{current_date}' and tmp3.status <> 'e'))) " if !status.blank? From 61d7179b0c1d9d80d49d7e9e4f8d625f3728f62c Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Thu, 18 Jun 2015 15:15:38 +0530 Subject: [PATCH 084/108] bug fixing --- app/controllers/wktime_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index a53229cf0..7cb35ea0d 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1398,7 +1398,7 @@ def getAllWeekSql(from, to) "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, " + - "(select distinct u.id, u.created_on from users u )u " + + "(select distinct u.id, u.created_on from users u) u " + "where selected_date between '#{from}' and '#{to}'" end @@ -1417,18 +1417,19 @@ def getAllTimeRange(ids) teResult = getTEAllTimeRange(ids) usrResult = getUserAllTimeRange(ids) currentWeekEndDay = getEndDay(Date.today) + @from = getStartDay(Date.today) @to = currentWeekEndDay - if !teResult.blank? + if !teResult.blank? && teResult.size > 0 @from = teResult[0].startday @to = teResult[teResult.size - 1].startday + 6 if currentWeekEndDay > @to @to = currentWeekEndDay end end - if !usrResult.blank? - stDate = usrResult[0].startday if !usrResult.blank? - stDate = getStartDay(stDate) - if ((!@from.blank? && stDate < @from) || @from.blank?) + if !usrResult.blank? && usrResult.size > 0 + stDate = usrResult[0].startday + stDate = getStartDay(stDate) if !stDate.blank? + if (!stDate.blank? && stDate < @from) @from = stDate end end From bd41b3caea89246c5a6c8a9b2bd1a63aa7892de5 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Fri, 19 Jun 2015 10:48:33 +0530 Subject: [PATCH 085/108] browser issue Lock T&E Label --- app/views/wktime/_te_index.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/wktime/_te_index.html.erb b/app/views/wktime/_te_index.html.erb index f3c20300b..f2c127317 100644 --- a/app/views/wktime/_te_index.html.erb +++ b/app/views/wktime/_te_index.html.erb @@ -9,7 +9,6 @@ <%= link_to l(:"button_new_#{controller_name}"), url_for(:controller => controller_name, :action => 'new'), :class => 'icon icon-time-add' %> <% end %> -

<%= form_tag({:controller => controller_name, :action => 'index'}, :method => :get, :id => 'query_form') do %> <%=h hidden_field_tag('tab', "#{controller_name}") %> From fb6d75def64a750b0626bb8378f17226f011ef48 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Fri, 19 Jun 2015 15:39:28 +0530 Subject: [PATCH 086/108] rename Admin groups to T&E Admin Groups --- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- config/locales/it.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 04511ce55..e37eedba3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -32,7 +32,7 @@ en: label_wk_auto_approve: "Auto approve" label_wk_submission_ack: Submission Acknowledgement Text label_wk_reject_reason: Reject Reason - label_wk_account_groups: Account Groups + label_wk_account_groups: T&E Admin Groups label_wk_enter_issue_As: Enter Issue As label_wk_enter_issue_Description: Enter issue as Subject diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 89949ee0e..001147b50 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -22,7 +22,7 @@ fr: label_wk_signature: Signature label_wk_submitted_by: Soumis par label_wk_approved_by: Approuvé par - label_wk_account_groups: Account Groups + label_wk_account_groups: T&E Admin Groups label_wk_enter_issue_id: Utiliser l'ID pour saisir la demande label_wk_work_time_header: Affichez l'entête effort diff --git a/config/locales/it.yml b/config/locales/it.yml index 028476496..38541b8d6 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -22,7 +22,7 @@ it: label_wk_signature: Firma label_wk_submitted_by: Inserito da label_wk_approved_by: Approvato da - label_wk_account_groups: Account Groups + label_wk_account_groups: T&E Admin Groups label_wk_enter_issue_id: Enter issue as ID label_wk_work_time_header: Show work time header From 088d80f75a814591a6c4552d3c42843a45038cb8 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Mon, 22 Jun 2015 15:01:30 +0530 Subject: [PATCH 087/108] percentage table --- app/views/settings/_tab_display.html.erb | 6 +++--- app/views/wktime/_edit_hours.html.erb | 9 ++++----- app/views/wktime/_edit_issues2.html.erb | 12 ++++++------ app/views/wktime/_issue_header.html.erb | 11 +++++------ 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/views/settings/_tab_display.html.erb b/app/views/settings/_tab_display.html.erb index de5e7326c..31df70fa4 100644 --- a/app/views/settings/_tab_display.html.erb +++ b/app/views/settings/_tab_display.html.erb @@ -2,13 +2,13 @@

<%= l(:label_display) %>

- <%= text_field_tag 'settings[wktime_project_dd_width]', @settings['wktime_project_dd_width'], :size => 3 %> px + <%= text_field_tag 'settings[wktime_project_dd_width]', @settings['wktime_project_dd_width'], :size => 3 %> %

- <%= text_field_tag 'settings[wktime_issue_dd_width]', @settings['wktime_issue_dd_width'], :size => 3 %> px + <%= text_field_tag 'settings[wktime_issue_dd_width]', @settings['wktime_issue_dd_width'], :size => 3 %> %

- <%= text_field_tag 'settings[wktime_actv_dd_width]', @settings['wktime_actv_dd_width'], :size => 3 %> px + <%= text_field_tag 'settings[wktime_actv_dd_width]', @settings['wktime_actv_dd_width'], :size => 3 %> %

<%= check_box_tag('settings[wktime_work_time_header]', 1, @settings['wktime_work_time_header'].to_i == 1) %> diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index ecf616dba..d6708b25f 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -21,10 +21,9 @@ end %> <%#if this is from a previous template, don't print the hours%> -

<% @wday_index += 1 %> <% end %> diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 6c62e47bd..695fb6e9f 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -13,12 +13,12 @@ if params[:enter_issue_id].blank? projects.unshift( [ entry.project.name, entry.project_id ] ) if !entry.nil? && project.blank? %> - - - + + + <% if !Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? && Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 %> @@ -9,14 +9,13 @@ <% if !controller.getUnitLabel.blank? %> - + <% end %> - <%= render :partial => controller.getCFInRowHeaderHTML %> <% startOfWeek = getStartOfWeek %> <% for i in 0..6%> - + <% end %> From a22fb4517beb472082ef026aade9a0a033292b48 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 23 Jun 2015 13:24:47 +0530 Subject: [PATCH 088/108] Revert "percentage table" This reverts commit 088d80f75a814591a6c4552d3c42843a45038cb8. --- app/views/settings/_tab_display.html.erb | 6 +++--- app/views/wktime/_edit_hours.html.erb | 9 +++++---- app/views/wktime/_edit_issues2.html.erb | 12 ++++++------ app/views/wktime/_issue_header.html.erb | 11 ++++++----- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/views/settings/_tab_display.html.erb b/app/views/settings/_tab_display.html.erb index 31df70fa4..de5e7326c 100644 --- a/app/views/settings/_tab_display.html.erb +++ b/app/views/settings/_tab_display.html.erb @@ -2,13 +2,13 @@
<%= l(:label_display) %>

- <%= text_field_tag 'settings[wktime_project_dd_width]', @settings['wktime_project_dd_width'], :size => 3 %> % + <%= text_field_tag 'settings[wktime_project_dd_width]', @settings['wktime_project_dd_width'], :size => 3 %> px

- <%= text_field_tag 'settings[wktime_issue_dd_width]', @settings['wktime_issue_dd_width'], :size => 3 %> % + <%= text_field_tag 'settings[wktime_issue_dd_width]', @settings['wktime_issue_dd_width'], :size => 3 %> px

- <%= text_field_tag 'settings[wktime_actv_dd_width]', @settings['wktime_actv_dd_width'], :size => 3 %> % + <%= text_field_tag 'settings[wktime_actv_dd_width]', @settings['wktime_actv_dd_width'], :size => 3 %> px

<%= check_box_tag('settings[wktime_work_time_header]', 1, @settings['wktime_work_time_header'].to_i == 1) %> diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index d6708b25f..ecf616dba 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -21,9 +21,10 @@ end %> <%#if this is from a previous template, don't print the hours%> -

<% @wday_index += 1 %> <% end %> diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 695fb6e9f..6c62e47bd 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -13,12 +13,12 @@ if params[:enter_issue_id].blank? projects.unshift( [ entry.project.name, entry.project_id ] ) if !entry.nil? && project.blank? %> - - - + + + <% if !Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? && Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 %> @@ -9,13 +9,14 @@ <% if !controller.getUnitLabel.blank? %> - + <% end %> + <%= render :partial => controller.getCFInRowHeaderHTML %> <% startOfWeek = getStartOfWeek %> <% for i in 0..6%> - + <% end %> From 9f50ee4e2c91af69d2b01522e86e05a5670e63ad Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Tue, 23 Jun 2015 15:30:41 +0530 Subject: [PATCH 089/108] Fix to hide duplicate activity --- app/views/wktime/_edit_issues2.html.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 6c62e47bd..29ebf7279 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -88,23 +88,25 @@ if params[:enter_issue_id].blank? <% activity = nil activities = nil + selectedActId = entry.nil? ? 0 : entry.activity_id projActList = @projActivities[project_id] #activities = activities.sort_by{|name, id| name} unless activities.blank? unless projActList.blank? projActList = projActList.sort_by{|name| name} - - activity = projActList.detect {|a| a.id == entry.activity_id} unless entry.nil? + activityName = entry.activity.name unless entry.nil? + activity = projActList.detect {|a| a.name == activityName} unless entry.nil? + selectedActId = activity.id if !activity.blank? #check if the activity, which was previously reported time, is still visible #if it is not visible, just show the id alone activities = projActList.collect {|a| [a.name, a.id]} - activities.unshift( [ entry.activity.name, entry.activity_id ] )if !entry.nil? && activity.blank? + activities.unshift( [ activityName, entry.activity_id ] )if !entry.nil? && activity.blank? end %> <% else %> - - <% end %> <% activity = nil activities = nil - selectedActId = entry.nil? ? 0 : entry.activity_id projActList = @projActivities[project_id] #activities = activities.sort_by{|name, id| name} unless activities.blank? unless projActList.blank? projActList = projActList.sort_by{|name| name} - activityName = entry.activity.name unless entry.nil? - activity = projActList.detect {|a| a.name == activityName} unless entry.nil? - selectedActId = activity.id if !activity.blank? + + activity = projActList.detect {|a| a.id == entry.activity_id} unless entry.nil? #check if the activity, which was previously reported time, is still visible #if it is not visible, just show the id alone activities = projActList.collect {|a| [a.name, a.id]} - activities.unshift( [ activityName, entry.activity_id ] )if !entry.nil? && activity.blank? + activities.unshift( [ entry.activity.name, entry.activity_id ] )if !entry.nil? && activity.blank? end %> - - - +<% if controller.checkDDWidth +check = true +end +%> + + + <% if !Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? && Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 %> @@ -9,14 +13,13 @@ <% if !controller.getUnitLabel.blank? %> - + <% end %> - <%= render :partial => controller.getCFInRowHeaderHTML %> <% startOfWeek = getStartOfWeek %> <% for i in 0..6%> - + <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e37eedba3..b1ab9520c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -76,7 +76,7 @@ en: label_wk_description: Description label_wk_date_exists: This date already exists label_wk_select_holiday: Please select a holiday - + label_display_note: "Note: Please make sure the sum of Project, Issue and Activity dropdown width not exceed 50%" button_new_wktime: New Timesheet button_continue: Continue diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 001147b50..3fad2b074 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -78,6 +78,7 @@ fr: label_wk_description: Description label_wk_date_exists: This date already exists label_wk_select_holiday: Please select a holiday + label_display_note: "Note: Please make sure the sum of Project, Issue and Activity dropdown width not exceed 50%" button_new_wktime: Nouvelle feuille de temps button_continue: Continuer diff --git a/config/locales/it.yml b/config/locales/it.yml index 38541b8d6..e8fd1505d 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -78,6 +78,7 @@ it: label_wk_description: Description label_wk_date_exists: This date already exists label_wk_select_holiday: Please select a holiday + label_display_note: "Note: Please make sure the sum of Project, Issue and Activity dropdown width not exceed 50%" button_new_wktime: Nuovo Timesheet button_continue: Continua diff --git a/init.rb b/init.rb index 82ce0c82e..f0963f15a 100644 --- a/init.rb +++ b/init.rb @@ -146,9 +146,9 @@ def destroy settings(:partial => 'settings', :default => { - 'wktime_project_dd_width' => '150', - 'wktime_issue_dd_width' => '250', - 'wktime_actv_dd_width' => '75', + 'wktime_project_dd_width' => '15', + 'wktime_issue_dd_width' => '25', + 'wktime_actv_dd_width' => '10', 'wktime_closed_issue_ind' => '0', 'wktime_restr_min_hour' => '0', 'wktime_min_hour_day' => '0', From c71c1c4a541a8db725daa5cee6c9dd3bf6eaf3cb Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 24 Jun 2015 12:35:21 +0530 Subject: [PATCH 091/108] host changed in api test file --- app/views/wktime/testapi.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wktime/testapi.html.erb b/app/views/wktime/testapi.html.erb index 8cb384912..27c5e9c71 100644 --- a/app/views/wktime/testapi.html.erb +++ b/app/views/wktime/testapi.html.erb @@ -1,6 +1,6 @@ Time & Expense
<%=l(:field_user)%><%=h @user.login %> + <%=h @user.name %> <%=h hidden_field_tag('user_id', @user.id) %>
<%=h format_date(entry.spent_on) %><%=h entry.user.login %><%=h entry.user.name %> <%= controller.getUnit(entry) %> <%=h html_hours("%.2f" % entry.hours) %> <%=h statusString(entry.status) unless entry.status.blank? %> <%=h entry.status_updater %> -<% project_name = entry.nil? ? (@logtime_projects.blank? ? 0 : @logtime_projects[0].id) : entry.project.name %> + <% project_name = entry.nil? ? (@logtime_projects.blank? ? 0 : @logtime_projects[0].id) : entry.project.name %> <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][project_id]' : 'time_entry[][project_id]', options_for_select(projects, :selected => project_id), @@ -52,7 +52,7 @@ if params[:enter_issue_id].blank? if !curr_issue_found if !entry.nil? if !entry.issue_id.nil? - issues.unshift([ entry.issue_id, entry.issue_id ]) + issues.unshift([ entry.issue.subject, entry.issue_id ]) else if Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].blank? || Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].to_i == 0 From b1ac3a57d0f40a7ae6a3b72d5f05aa4b3a533a04 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Wed, 10 Jun 2015 12:59:15 +0530 Subject: [PATCH 067/108] variable name change --- app/controllers/wktime_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 713ba73e9..3012d183f 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -32,7 +32,7 @@ def index end set_user_projects if (!@manage_view_spenttime_projects.blank? && @manage_view_spenttime_projects.size > 0) - @selected_project = getSelectedProject(@manage_view_spenttime_projects,true) + @selected_project = getSelectedProject(@manage_view_spenttime_projects, false) setMembers end ids = nil @@ -355,7 +355,7 @@ def destroy def new set_user_projects - @selected_project = getSelectedProject(@manage_projects,false) + @selected_project = getSelectedProject(@manage_projects, true) # get the startday for current week @startday = getStartDay(Date.today) render :action => 'new' @@ -1508,14 +1508,14 @@ def getTEName "time" end - def getSelectedProject(projList,projstatus) + def getSelectedProject(projList, setFirstProj) #selected_proj_id = params[:project_id] if !params[:tab].blank? && params[:tab] =='wkexpense' selected_proj_id = session[:wkexpense][:project_id].blank? ? params[:project_id] : session[:wkexpense][:project_id] elsif !session[:wktimes].blank? selected_proj_id = session[:wktimes][:project_id] end - if !selected_proj_id.blank? && projstatus #( !isAccountUser || !projList.blank? ) + if !selected_proj_id.blank? && !setFirstProj #( !isAccountUser || !projList.blank? ) sel_project = projList.select{ |proj| proj.id == selected_proj_id.to_i } selected_project ||= sel_project[0] if !sel_project.blank? else From 74f9ba60808af4167a8d751ace2a08816893192a Mon Sep 17 00:00:00 2001 From: karthick Date: Wed, 10 Jun 2015 19:05:12 +0530 Subject: [PATCH 068/108] Fix for Unable to submit unsaved timesheet issue When auto approve timesheet is checked --- app/controllers/wktime_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 3012d183f..de330fc55 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -220,7 +220,7 @@ def update end elsif !params[:wktime_unapprove].blank? && !@wktime.nil? && @wktime.status == 'a' && allowApprove errorMsg = updateStatus(:s) - elsif !params[:wktime_submit].blank? && !@wktime.nil? + elsif !params[:wktime_submit].blank? && !@wktime.nil? && ( @wktime.status == 'n' || @wktime.status == 'r') #if TE sheet is read only mode with submit button if !Setting.plugin_redmine_wktime['wktime_uuto_approve'].blank? && Setting.plugin_redmine_wktime['wktime_uuto_approve'].to_i == 1 From 01f6de5f201e67461c4defb7250717a1c14ab96f Mon Sep 17 00:00:00 2001 From: karthick Date: Fri, 12 Jun 2015 19:28:05 +0530 Subject: [PATCH 069/108] Show Error message when add blank issue --- app/controllers/wktime_controller.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index de330fc55..ade0f80ff 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -179,9 +179,16 @@ def update end if to_boolean(@edittimelogs) allowSave = true - end - errorMsg = updateEntry(entry) if allowSave - break unless errorMsg.blank? + end + if !((Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].blank? || + Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].to_i == 0) && + entry.issue.blank?) + errorMsg = updateEntry(entry) if allowSave + break unless errorMsg.blank? + else + errorMsg = "#{l(:field_issue)} #{l('activerecord.errors.messages.blank')} " + break unless errorMsg.blank? + end end if !params[:wktime_submit].blank? && useApprovalSystem @wktime.submitted_on = Date.today @@ -776,9 +783,7 @@ def gatherEntries @teEntrydisabled=false unless entryHash.nil? entryHash.each_with_index do |entry, i| - if !entry['project_id'].blank? && !((Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].blank? || - Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].to_i == 0) && - entry['issue_id'].blank?) + if !entry['project_id'].blank? hours = params['hours' + (i+1).to_s()] ids = params['ids' + (i+1).to_s()] comments = params['comments' + (i+1).to_s()] From eb0e6ba7c42d900fe11dad334d54303bbc59746b Mon Sep 17 00:00:00 2001 From: karthick Date: Fri, 12 Jun 2015 19:47:55 +0530 Subject: [PATCH 070/108] 0017 Custom fields tooltip confusing --- app/views/wktime/_edit_hours.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wktime/_edit_hours.html.erb b/app/views/wktime/_edit_hours.html.erb index 473d43bd9..ecf616dba 100644 --- a/app/views/wktime/_edit_hours.html.erb +++ b/app/views/wktime/_edit_hours.html.erb @@ -75,7 +75,7 @@ <% if !@new_custom_field_values.blank? || ( Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? || Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0) %> <% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', - :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? l(:label_custom_field_plural) : cvs.join(',')}") %> + :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? '' : cvs.join(',')}") %> <% else %> <%= image_tg ="" %> <% end %> From d7ba125bb56693364feb8a6833ca2d78d854118e Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 15 Jun 2015 10:55:34 +0530 Subject: [PATCH 071/108] Fix to show non member time/expense sheets --- app/controllers/wktime_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index ade0f80ff..a783db977 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1361,6 +1361,7 @@ def findBySql(selectStr,sqlStr,wkSelectStr,wkSqlStr, status, ids) def getAllWeekSql(from, to) #to = to.blank? || to > Date.today ? getEndDay(Date.today) : to + entityNames = getEntityNames() noOfDays = 't4.i*7*10000 + t3.i*7*1000 + t2.i*7*100 + t1.i*7*10 + t0.i*7' sqlStr = "select u.id, v.* from " + "(select " + getAddDateStr(from, noOfDays) + " selected_date from " + @@ -1369,10 +1370,8 @@ def getAllWeekSql(from, to) "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, " + - "(select distinct u.id, u.created_on from projects p " + - "inner join members m on p.id = m.project_id " + #and p.status not in (#{Project::STATUS_CLOSED},#{Project::STATUS_ARCHIVED}) - "inner join users u on m.user_id = u.id " + - "union select u.id, u.created_on from users u where admin = '1') u " + + "(select distinct u.id, u.created_on from users u " + + "inner join #{entityNames[0]} t on u.id = t.user_id) u " + "where selected_date between '#{from}' and '#{to}'" end From f38d2c302dcf8b8996d8df2bcd1fb576b60a8bfc Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 15 Jun 2015 11:09:00 +0530 Subject: [PATCH 072/108] Fix to show non member time/expense sheets --- app/controllers/wktime_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index a783db977..08d40cacf 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -1371,7 +1371,7 @@ def getAllWeekSql(from, to) "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, " + "(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v, " + "(select distinct u.id, u.created_on from users u " + - "inner join #{entityNames[0]} t on u.id = t.user_id) u " + + "inner join #{entityNames[1]} t on u.id = t.user_id) u " + "where selected_date between '#{from}' and '#{to}'" end From 28e34646b4ad567b1a2ad22dea79dab24d2553b1 Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 15 Jun 2015 13:26:41 +0530 Subject: [PATCH 073/108] Fix to show issue name instead of id --- app/views/wktime/_edit_issues2.html.erb | 2 +- assets/javascripts/edit.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 521bc6fd7..14170afa2 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -52,7 +52,7 @@ if params[:enter_issue_id].blank? if !curr_issue_found if !entry.nil? if !entry.issue_id.nil? - issues.unshift([ entry.issue.subject, entry.issue_id ]) + issues.unshift([ entry.issue.tracker.to_s() + " #" + entry.issue.id.to_s() + ": " + entry.issue.subject, entry.issue_id ]) else if Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].blank? || Setting.plugin_redmine_wktime['wktime_allow_blank_issue'].to_i == 0 diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index cbeaf3994..cf4fe2643 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -252,7 +252,7 @@ function projectChanged(projDropdown, row){ url: issUrl, type: 'get', data: {project_id: id, user_id: uid,tracker_id: trackerListArr, format:fmt,startday:startday, issue_assign_user: issue_assign_user}, - success: function(data){ updateDropdown(data, row, issDropdown, true, allowBlankIssue, true,null); }, + success: function(data){ updateDropdown(data, row, issDropdown, true, allowBlankIssue, true, null); }, beforeSend: function(){ $this.addClass('ajax-loading'); }, complete: function(){ $this.removeClass('ajax-loading'); } }); @@ -354,7 +354,7 @@ function issueIdChanged(id, row){ function updateIssDropdowns(itemStr, projDropdowns,projIds) { - var items = itemStr.split('\n'); + var items = itemStr.split('\n'); var i, index, itemStr2='', val, text; var prev_project_id=0, project_id=0; var j, id; @@ -398,14 +398,14 @@ function updateIssueDD(itemStr, project_id, projDropdowns, issDropdowns) for (j=0; j < projDropdowns.length; j++){ proj_id = projDropdowns[j].options[projDropdowns[j].selectedIndex].value; if(proj_id != '' && project_id == proj_id){ - if(issDropdowns[j]){ + if(issDropdowns[j]){ if(issDropdowns[j].value != ""){ issue_id = issDropdowns[j].options[issDropdowns[j].selectedIndex].value; } - else{ - issue_id=null; + else { + issue_id = null; } - updateDropdown(itemStr, j+1, issDropdowns, true, allowBlankIssue, true, issue_id); + updateDropdown(itemStr, j+1, issDropdowns, true, allowBlankIssue, true, issue_id); } } } @@ -433,7 +433,8 @@ function updateActDropdown(data, row, actDropdown){ function updateDropdown(itemStr, row, dropdown, showId, needBlankOption, skipFirst, selectedVal) { var items = itemStr.split('\n'); - var selectedValSet = false; + var selectedValSet = false; + var selectedText = dropdown[row-1].options[dropdown[row-1].selectedIndex].text; dropdown[row-1].options.length = 0; if(needBlankOption){ dropdown[row-1].options[0] = new Option( "", "", false, false); @@ -465,7 +466,7 @@ function updateDropdown(itemStr, row, dropdown, showId, needBlankOption, skipFir } if(selectedVal && !selectedValSet){ dropdown[row-1].options[needBlankOption ? i+1 : i] = new Option( - selectedVal, selectedVal, false, true); + selectedText, selectedVal, false, true); } } From 56f9e472842ce9276c6d8012b9d1635e68ff3be3 Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Mon, 15 Jun 2015 15:00:20 +0530 Subject: [PATCH 074/108] show activity name --- app/views/wktime/_edit_issues2.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 14170afa2..fcde33f25 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -98,7 +98,7 @@ if params[:enter_issue_id].blank? #if it is not visible, just show the id alone activities = projActList.collect {|a| [a.name, a.id]} - activities.unshift( [ entry.activity_id, entry.activity_id ] )if !entry.nil? && activity.blank? + activities.unshift( [ entry.activity.name, entry.activity_id ] )if !entry.nil? && activity.blank? end %> From 211ba9d2e54967c4c7835a56e932bd463fd88e6d Mon Sep 17 00:00:00 2001 From: suganya-thulasiraman Date: Mon, 15 Jun 2015 15:02:08 +0530 Subject: [PATCH 075/108] bug fixing --- assets/javascripts/edit.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/edit.js b/assets/javascripts/edit.js index cf4fe2643..a04650f90 100644 --- a/assets/javascripts/edit.js +++ b/assets/javascripts/edit.js @@ -434,7 +434,10 @@ function updateDropdown(itemStr, row, dropdown, showId, needBlankOption, skipFir { var items = itemStr.split('\n'); var selectedValSet = false; - var selectedText = dropdown[row-1].options[dropdown[row-1].selectedIndex].text; + var selectedText = ""; + if (selectedVal) { + selectedText = dropdown[row-1].options[dropdown[row-1].selectedIndex].text; + } dropdown[row-1].options.length = 0; if(needBlankOption){ dropdown[row-1].options[0] = new Option( "", "", false, false); From 5cd70b3d3b0ddaa2667f0856ce7e68000c6c38fa Mon Sep 17 00:00:00 2001 From: karthick Date: Mon, 15 Jun 2015 20:03:36 +0530 Subject: [PATCH 076/108] Fix for extra space in the edit timelogs --- app/controllers/wkexpense_controller.rb | 4 +++ app/controllers/wktime_controller.rb | 20 +++++++++++++ app/views/wkexpense/_wkexpense_cf_in_row.erb | 2 -- .../_wkexpense_cf_in_row_header.html.erb | 2 -- app/views/wktime/_edit_issues.html.erb | 20 +++++++++---- app/views/wktime/_edit_issues2.html.erb | 13 ++++----- app/views/wktime/_issue_header.html.erb | 6 ++-- app/views/wktime/_wktime_cf_in_row.erb | 29 ++++++++++--------- .../wktime/_wktime_cf_in_row_header.html.erb | 12 ++++---- app/views/wktime/_worktime_header.html.erb | 19 ++++++++---- app/views/wktime/edit.html.erb | 9 ++++++ assets/javascripts/edit.js | 2 +- 12 files changed, 91 insertions(+), 47 deletions(-) diff --git a/app/controllers/wkexpense_controller.rb b/app/controllers/wkexpense_controller.rb index d46f30e89..a116d0535 100644 --- a/app/controllers/wkexpense_controller.rb +++ b/app/controllers/wkexpense_controller.rb @@ -47,6 +47,10 @@ def showWorktimeHeader false end + def enterCustomFieldInRow(row) + false + end + def maxHour 0 end diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 08d40cacf..473003df5 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -578,6 +578,26 @@ def showWorktimeHeader !Setting.plugin_redmine_wktime['wktime_work_time_header'].blank? && Setting.plugin_redmine_wktime['wktime_work_time_header'].to_i == 1 end + + def enterCommentInRow + !Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? && + Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 1 + end + + def enterCustomFieldInRow(row) + entry = nil + custom_field_values = entry.nil? ? @new_custom_field_values : entry.custom_field_values + cf_value = nil + if row.to_i == 1 + !Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].blank? && + (cf_value = custom_field_values.detect { |cfv| + cfv.custom_field.id == Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].to_i }) != nil + else + !Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].blank? && + (cf_value = custom_field_values.detect { |cfv| + cfv.custom_field.id == Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].to_i }) != nil + end + end def maxHour Setting.plugin_redmine_wktime['wktime_restr_max_hour'].to_i == 1 ? diff --git a/app/views/wkexpense/_wkexpense_cf_in_row.erb b/app/views/wkexpense/_wkexpense_cf_in_row.erb index ec4211b7f..e69de29bb 100644 --- a/app/views/wkexpense/_wkexpense_cf_in_row.erb +++ b/app/views/wkexpense/_wkexpense_cf_in_row.erb @@ -1,2 +0,0 @@ -
<%= currencySym %> ><%= ("%.2f" % th) %> - <% if !(controller.getUnitDDHTML).blank? %> - <%= render :partial => controller.getUnitDDHTML , :locals => {:entry => entry} %> - <% end %> - + <%= render :partial => controller.getUnitDDHTML , :locals => {:entry => entry} %> + <%= l(:field_comments)%><%= controller.getUnitLabel %><%= controller.getUnitLabel %> <% custom_field_values = entry.nil? ? @new_custom_field_values : entry.custom_field_values cf_value = nil if !Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].blank? && (cf_value = custom_field_values.detect { |cfv| cfv.custom_field.id == Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].to_i }) != nil %> - <% if @editable %> - <%= custom_field_tag "time_entry[]", cf_value %> - <% else %> - <%= cf_value.value %> - <% end %> + + <% if @editable %> + <%= custom_field_tag "time_entry[]", cf_value %> + <% else %> + <%= cf_value.value %> + <% end %> + + <% cf_value = nil if !Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].blank? && (cf_value = custom_field_values.detect { |cfv| cfv.custom_field.id == Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].to_i }) != nil %> - <% if @editable %> - <%= custom_field_tag "time_entry[]", cf_value %> - <% else %> - <%= cf_value.value %> - <% end %> + + <% if @editable %> + <%= custom_field_tag "time_entry[]", cf_value %> + <% else %> + <%= cf_value.value %> + <% end %> + <% cf_value = nil if !Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].blank? && (cf_value = @new_custom_field_values.detect { |cfv| cfv.custom_field.id == Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].to_i }) != nil %> - + <%= cf_value.custom_field.name %> + + + <% cf_value = nil if !Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].blank? && (cf_value = @new_custom_field_values.detect { |cfv| cfv.custom_field.id == Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].to_i }) != nil %> - + <%= cf_value.custom_field.name %> +
<%= l(:"label_#{str}") %><%= text_field_tag "#{str}_#{(i+1)}" ,'0:00',:size => 7, :onchange => "validateHr(this,#{(i+1)});" %><%= text_field_tag "#{str}_#{(i+1)}" ,'0:00',:size => 4, :onchange => "validateHr(this,#{(i+1)});" %><%= value %><%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
- + <%=h text_field_tag('hours' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : ("%.2f" % entry.hours) ,:size => "#{controller.textfield_size}", - :disabled => disable, + :disabled => disable,:width => "80%", :onchange => "validateTotal(this, #{@wday_index},'#{controller.maxHour}');") %> <%=h hidden_field_tag('ids' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : entry.id) %> @@ -75,7 +74,7 @@ <% if !@new_custom_field_values.blank? || ( Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? || Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0) %> <% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', - :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? '' : cvs.join(',')}") %> + :width => "20%",:plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? '' : cvs.join(',')}") %> <% else %> <%= image_tg ="" %> <% end %> @@ -87,7 +86,7 @@ <% end %> <% end %> - <% end %> + <% end %> + <% project_name = entry.nil? ? (@logtime_projects.blank? ? 0 : @logtime_projects[0].id) : entry.project.name %> <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][project_id]' : 'time_entry[][project_id]', options_for_select(projects, :selected => project_id), - :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:#{Setting.plugin_redmine_wktime['wktime_project_dd_width']}px" ) %> + :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:100%" ) %> <% else %> <% if project.blank? %> <% if entry.nil? %> @@ -65,11 +65,11 @@ if params[:enter_issue_id].blank? %> - + <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][issue_id]' : 'time_entry[][issue_id]', options_for_select(issues, :selected => entry.nil? ? 0 : entry.issue_id, :required => true), - :style=> "width:#{Setting.plugin_redmine_wktime['wktime_issue_dd_width']}px" ) %> + :style=> "width:100%" ) %> <% else %> <%= entry.issue.tracker.to_s() + " #" + entry.issue.id.to_s() + ": " + entry.issue.subject if !entry.nil? && !entry.issue.nil? %> <% end %> @@ -101,11 +101,11 @@ if params[:enter_issue_id].blank? activities.unshift( [ entry.activity.name, entry.activity_id ] )if !entry.nil? && activity.blank? end %> - + <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][activity_id]' : 'time_entry[][activity_id]', activities.blank? ? nil : options_for_select(activities, :selected => entry.nil? ? 0 : entry.activity_id), - :style=> "width:#{Setting.plugin_redmine_wktime['wktime_actv_dd_width']}px" ) %> + :style=> "width:100%" ) %> <% else %> <%= entry.activity.name unless entry.nil?%> <% end %> diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index d4c5ce4f7..2f0cc01a5 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -1,6 +1,6 @@ -<%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= controller.getUnitLabel %><%= controller.getUnitLabel %><%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
+ + <%=h text_field_tag('hours' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : ("%.2f" % entry.hours) ,:size => "#{controller.textfield_size}", - :disabled => disable,:width => "80%", + :disabled => disable, :onchange => "validateTotal(this, #{@wday_index},'#{controller.maxHour}');") %> <%=h hidden_field_tag('ids' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : entry.id) %> @@ -74,7 +75,7 @@ <% if !@new_custom_field_values.blank? || ( Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? || Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0) %> <% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]', - :width => "20%",:plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? '' : cvs.join(',')}") %> + :plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template || cvs.blank? ? '' : cvs.join(',')}") %> <% else %> <%= image_tg ="" %> <% end %> @@ -86,7 +87,7 @@ <% end %> <% end %> - <% end %> + <% end %> + <% project_name = entry.nil? ? (@logtime_projects.blank? ? 0 : @logtime_projects[0].id) : entry.project.name %> <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][project_id]' : 'time_entry[][project_id]', options_for_select(projects, :selected => project_id), - :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:100%" ) %> + :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:#{Setting.plugin_redmine_wktime['wktime_project_dd_width']}px" ) %> <% else %> <% if project.blank? %> <% if entry.nil? %> @@ -65,11 +65,11 @@ if params[:enter_issue_id].blank? %> - + <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][issue_id]' : 'time_entry[][issue_id]', options_for_select(issues, :selected => entry.nil? ? 0 : entry.issue_id, :required => true), - :style=> "width:100%" ) %> + :style=> "width:#{Setting.plugin_redmine_wktime['wktime_issue_dd_width']}px" ) %> <% else %> <%= entry.issue.tracker.to_s() + " #" + entry.issue.id.to_s() + ": " + entry.issue.subject if !entry.nil? && !entry.issue.nil? %> <% end %> @@ -101,11 +101,11 @@ if params[:enter_issue_id].blank? activities.unshift( [ entry.activity.name, entry.activity_id ] )if !entry.nil? && activity.blank? end %> - + <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][activity_id]' : 'time_entry[][activity_id]', activities.blank? ? nil : options_for_select(activities, :selected => entry.nil? ? 0 : entry.activity_id), - :style=> "width:100%" ) %> + :style=> "width:#{Setting.plugin_redmine_wktime['wktime_actv_dd_width']}px" ) %> <% else %> <%= entry.activity.name unless entry.nil?%> <% end %> diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index 2f0cc01a5..d4c5ce4f7 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -1,6 +1,6 @@ -<%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= controller.getUnitLabel %><%= controller.getUnitLabel %><%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][activity_id]' : 'time_entry[][activity_id]', - activities.blank? ? nil : options_for_select(activities, :selected => entry.nil? ? 0 : entry.activity_id), + activities.blank? ? nil : options_for_select(activities, :selected => selectedActId), :style=> "width:#{Setting.plugin_redmine_wktime['wktime_actv_dd_width']}px" ) %> <% else %> <%= entry.activity.name unless entry.nil?%> From f3a3fefe2818b938fcf51abb0525d56e100f08aa Mon Sep 17 00:00:00 2001 From: dhinesh rajasekar Date: Wed, 24 Jun 2015 12:27:31 +0530 Subject: [PATCH 090/108] percentage table validation percentage table validation and add label note for plugins display tab. --- app/controllers/wktime_controller.rb | 12 ++++++++ app/views/settings/_tab_display.html.erb | 7 +++-- app/views/wktime/_edit_issues2.html.erb | 35 ++++++++++++------------ app/views/wktime/_issue_header.html.erb | 15 ++++++---- config/locales/en.yml | 2 +- config/locales/fr.yml | 1 + config/locales/it.yml | 1 + init.rb | 6 ++-- 8 files changed, 49 insertions(+), 30 deletions(-) diff --git a/app/controllers/wktime_controller.rb b/app/controllers/wktime_controller.rb index 7cb35ea0d..05e7cf19f 100644 --- a/app/controllers/wktime_controller.rb +++ b/app/controllers/wktime_controller.rb @@ -682,6 +682,18 @@ def testapi def textfield_size 4 end + + def checkDDWidth + ret = true + project_dd_width = Setting.plugin_redmine_wktime['wktime_project_dd_width'].to_i + issue_dd_width = Setting.plugin_redmine_wktime['wktime_issue_dd_width'].to_i + actv_dd_width = Setting.plugin_redmine_wktime['wktime_actv_dd_width'].to_i + ddtotal = project_dd_width + issue_dd_width + actv_dd_width + if ddtotal > 50 + ret = false + end + ret + end private diff --git a/app/views/settings/_tab_display.html.erb b/app/views/settings/_tab_display.html.erb index de5e7326c..ad68ccc44 100644 --- a/app/views/settings/_tab_display.html.erb +++ b/app/views/settings/_tab_display.html.erb @@ -2,17 +2,18 @@
<%= l(:label_display) %>

- <%= text_field_tag 'settings[wktime_project_dd_width]', @settings['wktime_project_dd_width'], :size => 3 %> px + <%= text_field_tag 'settings[wktime_project_dd_width]', @settings['wktime_project_dd_width'], :size => 3 %> %

- <%= text_field_tag 'settings[wktime_issue_dd_width]', @settings['wktime_issue_dd_width'], :size => 3 %> px + <%= text_field_tag 'settings[wktime_issue_dd_width]', @settings['wktime_issue_dd_width'], :size => 3 %> %

- <%= text_field_tag 'settings[wktime_actv_dd_width]', @settings['wktime_actv_dd_width'], :size => 3 %> px + <%= text_field_tag 'settings[wktime_actv_dd_width]', @settings['wktime_actv_dd_width'], :size => 3 %> %

<%= check_box_tag('settings[wktime_work_time_header]', 1, @settings['wktime_work_time_header'].to_i == 1) %>

+ <%= l(:label_display_note) %>
<%= l(:button_export) %> diff --git a/app/views/wktime/_edit_issues2.html.erb b/app/views/wktime/_edit_issues2.html.erb index 29ebf7279..8b596eabd 100644 --- a/app/views/wktime/_edit_issues2.html.erb +++ b/app/views/wktime/_edit_issues2.html.erb @@ -12,13 +12,16 @@ if params[:enter_issue_id].blank? #if it is not visible, just show the id alone projects.unshift( [ entry.project.name, entry.project_id ] ) if !entry.nil? && project.blank? %> - -
+<% if controller.checkDDWidth +ddwidth = true +end +%> + <% project_name = entry.nil? ? (@logtime_projects.blank? ? 0 : @logtime_projects[0].id) : entry.project.name %> <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][project_id]' : 'time_entry[][project_id]', options_for_select(projects, :selected => project_id), - :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:#{Setting.plugin_redmine_wktime['wktime_project_dd_width']}px" ) %> + :onchange => "projectChanged(this,#{@row.to_s()});", :style=> "width:100%" ) %> <% else %> <% if project.blank? %> <% if entry.nil? %> @@ -65,49 +68,47 @@ if params[:enter_issue_id].blank? %> - + <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][issue_id]' : 'time_entry[][issue_id]', options_for_select(issues, :selected => entry.nil? ? 0 : entry.issue_id, :required => true), - :style=> "width:#{Setting.plugin_redmine_wktime['wktime_issue_dd_width']}px" ) %> + :style=> "width:100%" ) %> <% else %> <%= entry.issue.tracker.to_s() + " #" + entry.issue.id.to_s() + ": " + entry.issue.subject if !entry.nil? && !entry.issue.nil? %> <% end %> + <%=h hidden_field_tag(isTemplate ? '__template__time_entry[][project_id]' : 'time_entry[][project_id]', - entry.nil? ? '' : entry.project_id.to_s ) %> + (entry.nil? ? '' : entry.project_id.to_s) ) %> + <%=h text_field_tag(isTemplate ? '__template__time_entry[][issue_id]' : 'time_entry[][issue_id]', - entry.nil? ? '' : entry.issue_id, :onkeypress => "issueAutocomplete(this,#{@row.to_s()});") %> + entry.nil? ? '' : entry.issue_id, :onkeypress => "issueAutocomplete(this,#{@row.to_s()});", :style => "width:100%" ) %> + <% if @editable %> <%=h select_tag(isTemplate ? '__template__time_entry[][activity_id]' : 'time_entry[][activity_id]', - activities.blank? ? nil : options_for_select(activities, :selected => selectedActId), - :style=> "width:#{Setting.plugin_redmine_wktime['wktime_actv_dd_width']}px" ) %> + activities.blank? ? nil : options_for_select(activities, :selected => entry.nil? ? 0 : entry.activity_id), + :style=> "width:100%" ) %> <% else %> <%= entry.activity.name unless entry.nil?%> <% end %> diff --git a/app/views/wktime/_issue_header.html.erb b/app/views/wktime/_issue_header.html.erb index d4c5ce4f7..5f6e35970 100644 --- a/app/views/wktime/_issue_header.html.erb +++ b/app/views/wktime/_issue_header.html.erb @@ -1,6 +1,10 @@ -<%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= params[:enter_issue_id].blank? ? l(:field_project) : '' %><%= l(:field_issue) %><%= l(:field_activity) %><%= controller.getUnitLabel %><%= controller.getUnitLabel %><%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>
<%= l('date.abbr_day_names')[(i+(startOfWeek))%7] %>
<%= I18n.localize(@startday+i, :format=>:short) unless @startday.nil? %>