Title: Adding new dropdowns
Last modified: August 11, 2019

---

# Adding new dropdowns

 *  Resolved [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/)
 * Hi,
    Great plugin, LOVE IT. I want to add 2 more drop down values apart from “
   Reg” and “PTO”. I have made the changes in time_min.js But I can see that time_cal.
   php contains many complex calculations for calculating the total no of hours.
   Can you help me with the time_cal.php, tell me where to make the changes 🙂 Thank
   you

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11821342)
 * Hi Rhett,
    I have tried but did not succeed. Please have a look at my `function
   sumrows()` and can you tell me where I am going wrong?
 *     ```
       function sumrows() {
       	var e, t, il, vab, d, n, a, o, i, s, m, l, r, illr, vabbr, u, y, _;
       	e = t = d = n = a = o = i = s = m = il = vab = 0, l = r = illr = vabbr = u = y = _ = "";
       	var p, c, g = document.getElementById("Reg"),
       		v = document.getElementById("PTO"),
       		h = document.getElementById("pto_row"),
       	    ill = document.getElementById("ILL"),
       		illrow = document.getElementById("ill_row"),
       		vabb = document.getElementById("VABB"),
       		vabbrow = document.getElementById("vabb_row"),
       		b = document.getElementById("OT"),
       		f = document.getElementById("ot_row"),
       		w = document.getElementById("Bonus"),
       		E = document.getElementById("TOT"),
       		B = document.getElementById("TOTamt"),
       		k = document.getElementsByName("hours[]"),
       		T = document.getElementsByName("date[]"),
       		I = rate,
       		F = 0;
       	if (exempt <= 0 && 15 <= period) {
       		var M = parseInt(T[0].value),
       			x = new Date(864e5 * M);
       		for (c = weekday[x.getDay()]; weekbegin != weekday.indexOf(c);) c = weekday[x.getDay()], x.setDate(x.getDate() - 1);
       		for (x /= 864e5; db_date[F] < x;) F++;
       		if (M - 7 < x)
       			for (; db_date[F] < M;) "Reg" == db_hourtype[F] && (s = parseFloat(db_hours[F]), db_date[F + 1] ? next_entry = db_date[F + 1] : next_entry = db_date[F] + 1, db_date[F] == next_entry ? m += s : (s += m, m = 0), 0 == m && (i = exempt < 0 && 8 < s ? 8 : parseFloat(s), a = (parseFloat(a) + i).toFixed(2))), F++, x++;
       		i = s = m = 0
       	}
       	for (F = 0; F < T.length;) 0 < k[F].value && (k[F].style.backgroundColor = "#555", k[F].style.color = "#FFF", s = parseFloat(k[F].value), _ = k[F].nextSibling.value, next_entry = 0, exempt <= 0 && "Reg" == _ && (T[F + 1] && (next_entry = T[F + 1].value), T[F].value == next_entry && "Reg" == k[F + 1].nextSibling.value ? m += s : (s += m, m = 0)), 0 == m && ("Reg" == _ && (i = exempt < 0 && 8 < s ? parseFloat(s) - 8 : 0, exempt < 0 && (n = (parseFloat(n) + i).toFixed(2)), exempt <= 0 && (a = (parseFloat(a) + s - i).toFixed(2))), exempt < 0 && 0 < n && (d = (parseFloat(d) + parseFloat(n)).toFixed(2), n = 0), "Reg" == _ && (e = (parseFloat(e) + s).toFixed(2)), "PTO" == _ && (t = (parseFloat(t) + s).toFixed(2)), "ILL" == _ && (ill = (parseFloat(ill) + s).toFixed(2)), "VABB" == _ && (vab = (parseFloat(vab) + s).toFixed(2)), o = (parseFloat(o) + s).toFixed(2))), 0 == m && exempt <= 0 && (p = (c = new Date(864e5 * (parseInt(T[F].value) + 2))).getDay(), weekbegin != p && T[F + 1] || (40 < a && (d = (parseFloat(d) + (parseFloat(a) - 40)).toFixed(2)), a = 0)), F++;
       	0 < (e = (parseFloat(e) - parseFloat(d)).toFixed(2)) && (l = 1 < e ? " hrs" : " hr"), 0 < t ? (r = 1 < t ? " hrs" : " hr", h.style.display = "table-row") : h.style.display = "none", 0 < il ? (illr = 1 < il ? " hrs" : " hr", illrow.style.display = "table-row") : illrow.style.display = "none", 0 < vab ? (vabbr = 1 < vab ? " hrs" : " hr", vabbrow.style.display = "table-row") : vabbrow.style.display = "none", 0 < d ? (u = 1 < d ? " hrs" : " hr", f.style.display = "table-row") : f.style.display = "none", 0 < o && (y = 1 < o ? " hrs" : " hr"), g.value = e + l, v.value = t + r, ill.value = il + illr, vabb.value = vab + vabbr, b.value = d + u, E.value = o + y, w.value = 0 < pay_bonus ? currency + pay_bonus : 0, 0 < I && (B.value = (parseFloat(o) * parseFloat(I)).toFixed(2), B.value = currency + (parseFloat(B.value) + parseFloat(pay_bonus) + parseFloat(d) * (.5 * parseFloat(I))).toFixed(2)), 0 === summary_updated && set_opacity(1), show_save(0)
       }
       ```
   
    -  This reply was modified 6 years, 9 months ago by [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/).
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11822433)
 * Hi subhamkotnala, A note that if these files are changed on your local installation,
   WordPress will overwrite them on the next version update of the plugin.
 *  The original design allows for 2 items in the dropdown and a text field, with
   the ability for the text field to be an infinite field to store more values. 
   I suggest using the text field to categorize time values if more categories are
   needed. I believe adding a new dropdown can be accomplished, but if a new field
   is added to JS, there will be additional work required to add these fields to
   the database and related functions.
 * I will look at the JS file and see if I can still help you.
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11822778)
 * Hi Rhett,
    Yes I understand that these files will get affected if there is an
   update but I’m helpless. That is one of my primary requirements to have 2 more
   drop downs. For time being I have I’m not updating the plugin. And regarding 
   the changes in other files such as time_cal.php and time_functions.php, I have
   made some changes (just replicating PTO with different id, value and database
   column name). I just want the time_min.js changes which I’m struggling to. I 
   just want to add 2 more drop downs.
 * Thanks a lot in advance
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11825044)
 * Hi subhamkotnala,
 *  For JS function sumrows(), additional dropdown variables should be treated exactly
   as PTO is treated, so as to not influence the overtime calculations. Any operation
   that affects PTO will need a similar operation to affect Ill variable, and anywhere
   that Reg is specified should not affect the new Ill variable.
 * Additionally, the new variable will need to be added to the select in addweek(),
   and total field rows populated in an array in time_cal.php.
 * Hope this helps!
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11826382)
 * Hi Rhett,
    Thanks for your concern. I have made some changes in the code introducing
   2 variables il and vab. Can you please look at the code which I posted in my 
   question? That’s what I did. But it doesn’t seem to work. Can you please go through
   the code and tell me where I am going wrong? Thanks a lot in advance
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11828859)
 * Hi subhamkotnala. Just to emphasize… your plugin will not be able to receive 
   future updates to these files without an update overwriting your modifications.
   This would exclude you from security updates as well as being compatible with
   the PRO add-on. But also, if in the future we create an option to allow more 
   dropdown items, you will not be able to use it.
 * I have looked at sumrows(), it looks like the new values Ill and vabb need to
   be added to the TOTamt (B), this occurs immediately before summary_updated is
   evaluated. Hope this helps!
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11834001)
 * Hi Rhett,
    Thanks a lot for your concern. Can you provide me your email id so
   that I can mail you the code? I am facing a small issue. Thanks in advance
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11835298)
 * Sure, this forum won’t allow email addresses in replies. If there is something
   else you need assistance with (like billing, Pro add-on, or troubleshooting),
   please contact us in the upper right corner of the plugin admin page (support&
   diagnostics). Thank you!
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11835513)
 * Hi Rhett,
    It would be better if I use this forum to clarify my doubt. I am facing
   a strange issue. Please hang up on me for this. I have added 2 more drop down
   values ILL and VABB. I have added the all the local variables in the function`
   sumrows()` The issue is everything seems to work fine. Even the values for the
   new types are getting inserted and updated too in the database(I have checked
   thoroughly). Now the issue, when I am selecting ILL or VABB in the drop down,
   the summary below is getting displayed calculating the no of hours for respective
   drop downs. Fine as of now. But the real thing is occurring when I am submitting
   the time report. Now I am not seeing VABB in the summary as well as in the drop
   down but ILL is visible perfectly with the no of hours. The strange thing is 
   the no of hours for VABB is getting inserted in the database, even the total 
   no of hours is perfect except that the summary of the VABB is not visible. I 
   have inspected the VABB summary row and set the display to “table-rows” but I
   can see that the value for VABB after submitting is becoming 0 but somehow the
   correct value is getting inserted in the database. I have made appropriate change
   in time_cal.php too.
 * Can you please suggest me which part of the code to examine, for this issue.
   
   I know it is strange. Thanks a lot for sparing your valuable time 🙂
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11835624)
 * Hi, I would be speculating on the issue without having all the files that have
   changed. It’s not something I can support since it’s not really apart of the 
   original plugin.
 * But, I can try to assist. To summarize the issue, are you saying that your addition
   of Ill is working, and VABB is not (as far as displaying)? At first glance, I
   recommend stepping through and ensuring both variables are handled the same way
   and subject to identical operations.
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11838998)
 * Hi Rhett,
    I got the exact issue. After submit the value of `vabb` is becoming
   0. Can you guess where the problem might be?
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11839009)
 * Hi subhamkotnala,
 *  If vabb is 0 after saving, then it might not be successfully setting the JS 
   vabb array from the db values on time_cal.php.
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11840541)
 * Hi Rhett,
    Can you give me some hint as to which part of the code in time_cal.
   php deals with setting JS vabb array from db values? Because only `vabb` has 
   that issue, `ill` works perfectly.
 *  Plugin Author [RLDD](https://wordpress.org/support/users/rermis/)
 * (@rermis)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11841530)
 * Hi again,
 *  I can try to help, but I don’t have the files you’ve changed, so it’s pure speculation.
 * 1) Make sure the query is pulling vabb entries from the db. This occurs in time_cal.
   php, in the $entry_query_string variable. You might have to run the query manually
   and/or echo $entry_query_string variable to the interface.
 * 2) Make sure the entries (from $entry_query_string variable) are loaded into 
   the corresponding JS variables in time_load_entries.php. You can see these values
   from the F12 console.
 *  Thread Starter [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * (@subhamkotnala)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11853641)
 * Hi Rhett,
    It worked finally. `vabb`was somehow not getting populated in `hours[]`.
   I fixed it 🙂 Thanks for your concern I appreciate it.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Adding new dropdowns’ is closed to new replies.

 * ![](https://ps.w.org/dynamic-time/assets/icon-256x256.png?rev=2049979)
 * [Dynamic Time](https://wordpress.org/plugins/dynamic-time/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/dynamic-time/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/dynamic-time/)
 * [Active Topics](https://wordpress.org/support/plugin/dynamic-time/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dynamic-time/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dynamic-time/reviews/)

 * 15 replies
 * 2 participants
 * Last reply from: [subhamkotnala](https://wordpress.org/support/users/subhamkotnala/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/adding-new-dropdowns/#post-11853641)
 * Status: resolved