My current project need to customisely showing some extra information base on calculations of the dates that has been selected. I have writen a function, and I can't find the AJAX code that the booking system returns the data and calculations base on the valid date to trigger my function.
My function is easy:
function calculate_date_duration() {
var year_1 = document.querySelector('.selection-start-date').getAttribute('data-year');
var month_1 = document.querySelector('.selection-start-date').getAttribute('data-month');
var date_1 = document.querySelector('.selection-start-date a').textContent;
var year_2 = document.querySelector('.selection-end-date').getAttribute('data-year');
var month_2 = document.querySelector('.selection-end-date').getAttribute('data-month');
var date_2 = document.querySelector('.selection-end-date a').textContent;
var day_1 = new Date(year_1, month_1, date_1);
var day_2 = new Date(year_2, month_2, date_2);
console.log(day_1);
console.log(day_2);
var day_selected = day_2.getTime() - day_1.getTime();
var date_duration = parseInt(day_selected / (1000 * 60 * 60 * 24)) +1;
console.log(date_duration);
var display_pane = document.querySelector('.wc-bookings-booking-cost');
display_pane.innerHTML = display_pane.innerHTML + '<br>Total booking cost:<strong><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>' + (date_duration*120) + '</bdi></span></strong>';}
The date select duration ajax is in wp-content/plugins/woocommerce-bookings/dist/frontend.js, search success, the last one in this file is the codes after validating the selected duration.
Related
I am trying to get my power bi data from my HRIS platform to calculate hours worked - hours on lunch, to get a total of hours worked in a day.
I have tried grouping, pivots, formulas, and because my HRIS platform send the "check-in" time at the start of a shift and the "check-in" time when they clock back in from lunch, as the same "check-in" classification, I cannot associate it with one or the other, it picks the most recent one, if I say return "check-in" (My data set is intraday and updates every hour so I can get all Clock events for the current day)
I have included an example of what my data looks like right from the HRIS into Power Bi
Sample Data Set
Full Data Sheet Columns
Formula's Used in Order:
Check In =
IF(AND(Merge1[Current Day]=Merge1[Day of the
Week],Merge1[Clock_Event_Type]="Check-in"),
Merge1[Clock_Event_Time_-_No_Time_Zone])
Check Out (Lunch) =
IF(Merge1[Day of the Week]= Merge1[Current Day],
IF(Merge1[Clock_Event_Type]= "Check-out
(meal)",Merge1[Clock_Event_Time_-_No_Time_Zone],BLANK()))
Check in (Lunch) = IF(Merge1[Current Day]=Merge1[Day of the
Week],
VAR checkin = Merge1[Check In]
VAR outlunch = Merge1[Check Out (Lunch)]
VAR timeinfromlunch = IF(checkin>outlunch,checkin)
return timeinfromlunch)
Check Out = IF(Merge1[Day of the Week]= Merge1[Current Day],
IF(Merge1[Clock_Event_Type] = "Check-out",
Merge1[Clock_Event_Time_-_No_Time_Zone]),BLANK())
Current Time = IF(AND(Merge1[Current Day]=Merge1[Day of the
Week],Merge1[Clock_Event_Type]="Check-in"),
NOW()
)
CPH Calc (Intraday Shift) = IF(Merge1[Current Time]<Merge1[Shift
End Today],Merge1[Current Time],Merge1[Check Out])
Hours Worked =
IF(AND(Merge1[Current Day]=Merge1[Day of the
Week],Merge1[Clock_Event_Type]="Check-in"),
VAR totalsecondsinbreak = DATEDIFF(Merge1[Check Out
(Lunch)],Merge1[Check in (Lunch)],SECOND)
VAR total_secondsworking = DATEDIFF(Merge1[Check In],Merge1[CPH
Calc (Intraday Shift)],SECOND)
VAR totalseconds = total_secondsworking-totalsecondsinbreak
VAR DAXHours = (totalseconds/60)/60
RETURN IF(Merge1[Clock_Event_Time_-
_No_Time_Zone]=0,BLANK(),DAXHours))
Shift Start Today = IF(Merge1[Current Day]=Merge1[Day of the
Week],TODAY() + Merge1[Start Shift])
Shift End Today = IF(Merge1[Current Day]=Merge1[Day of the
Week],TODAY() + Merge1[End Shift])
On Queue (Milliseconds) = IF(AND(Merge1[Current Day]=Merge1[Day
of the Week],Merge1[Clock_Event_Type]="Check-in"),
VAR onqueueseconds = RELATED('Table (2)'[On Queue])
VAR milliseconds = onqueueseconds
VAR total_second = milliseconds/1000
VAR minutes = total_second/60
VAR hours_decimal = minutes/60
VAR hours = INT(hours_decimal)
return onqueueseconds)
Utilization =
IF(AND(Merge1[Current Day]=Merge1[Day of the
Week],Merge1[Clock_Event_Type]="Check-in"),
VAR productivetime = Merge1[Hours Productive Time]
VAR workedtime = Merge1[Hours Worked]
VAR Ult = IFERROR(productivetime/workedtime,BLANK())
return Ult
)
Hours Productive Time =
IF(AND(Merge1[Current Day]=Merge1[Day of the
Week],Merge1[Clock_Event_Type]="Check-in"),
VAR milliseconds = Merge1[On Queue (Milliseconds)]
VAR total_second = milliseconds/1000
//VAR minutes = total_second/60
//VAR hours_decimal = minutes/60
//VAR hours = INT(hours_decimal)
VAR DAXHours = (total_second/60)/60
return DAXHours+.5)
I am using Magento 2.2.3. my default currency is INR, but it shows in the wrong format:
But it should be ₹77,65,000.00. How do we correct price format? Currently its wrong... like USD.
You can set the currency format by following code.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); // Instance of Pricing Helper
$price = 1000; //Your Price
$formattedPrice = $priceHelper->currency($price, true, false);
?>
File path: vendor/magento/zendframework1/library/Zend/Locale/Data/en.xml
On line number 3353, under section currencyFormat and type = "standard", change the pattern from <pattern>¤#,##0.00</pattern> to <pattern>¤ #,##,##0.00</pattern>
Still, on PDP page and cart page summary the price format does not change because the prize format is coming from the JS in which Magento using a RegExp function for only US price format.
For that, please change the code in the below file.
File path: vendor/magento/module-catalog/view/base/web/js/price-utils.js (First extend this file in your theme directory and do the respected changes)
Under the function formatPrice below this line comment all the line in the respective function.
i = parseInt(
amount = Number(Math.round(Math.abs(+amount || 0) + 'e+' + precision) + ('e-' + precision)),
10
) + '';
And add this set of code below the above line.
var x=i;
x=x.toString();
var afterPoint = '';
if(x.indexOf('.') > 0)
afterPoint = x.substring(x.indexOf('.'),x.length);
x = Math.floor(x);
x=x.toString();
var lastThree = x.substring(x.length-3);
var otherNumbers = x.substring(0,x.length-3);
if(otherNumbers != '')
lastThree = ',' + lastThree;
var response = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree + afterPoint;
return pattern.replace('%s', response);
deploy and `rm -rf var/cache/*
And then you're done. For Example: A price previously displayed like 453,453, will now display in the Indian manner like 4,53,453.
Good day,
Disclaimer: I am very new to development.
I am developing an app and the user needs to enter a start time and end time. I then want to do a calculation to get the time taken. Below is the code I am using but it returns "an empty string".
dtiStartTime = new sap.m.DateTimeInput({
id : "StartTime", placeholder:"Select Start Time", type:"Time",width:"100px"
});
dtitotalTime = new sap.m.DateTimeInput({type:"Time",value:""});
dtiStopTime = new sap.m.DateTimeInput({
id : "StopTime", placeholder:"Select Stop Time", type:"Time",width:"100px",
change: [function(oEvent){totalTime.setValue(dtiStopTime.getValue() - dtiStartTime.getValue())}]
});
"getValue()" of DateTimeInput returns a javascript Date() object.
If you call "getTime()" of the Date object you get the time in milliseconds and can subtract them from each other. Afterwards you need to transform them into a value that you need (minutes/hours)...
var startDate = dtiStartTime.getValue();
var stopDate = dtiStopTime.getValue();
var differenceInMilliseconds = stopDate.getTime() - startDate.getTime();
Here is an example how to get the difference in seconds:
var start = this.byId('dateTimeStart').getDateValue();
var ende = this.byId('dateTimeEnde').getDateValue();
var diffInSeconds = (ende.getTime() - start.getTime())/1000;
I have a view with 2 columns, both type of String. One is always "08:00" and one depends on the user input. It could be 02:30 or 13:45, etc...
I want to convert all the column of 08:00's and all the other column of values, add them together and then divide the total...
Example:
Column 1 | Column 2
02:50 | 08:00
05:15 | 08:00
15:25 | 08:00
03:15 | 08:00
It would be something like:(~26)/(8*4)=~0.8%.
It's a timekeeping application. I have the normal-time of 8 hours and the time the employee worked, and I want to add a button that will calculate the ratio between the 2 columns.
Thank you,
Florin
This is the code I used to calculate the ration between 2 columns of strings:
var vec:NotesViewEntryCollection = viewSearch.getAllEntries();
var c = vec.getCount()
var data = #DbColumn(#DbName(),"vwSearch",4);
var totalH = 0;
var totalM = 0;
for(var i=0;i<c;i++){
var str = data[i].toString();
var a = str.split(":",2)[0];
var b = str.split(":",2)[1];
var hour = parseInt(a);
var minutes = parseInt(b);
totalH += hour;
totalM += minutes;
if(totalM >= 60)
{
totalH++;
totalM-=60;
}
}
var h_necesare = c*8;
getComponent("h_lucrate").setValue(totalH+" ore, si "+totalM+" minute.");
getComponent("h_necesare").setValue(h_necesare);
getComponent("raport").setValue(totalH-h_necesare);
am using KeywordQuery to search and.. the SortList does not affect result, it is always return first 5 results. Any suggestion? The code is bellow...
using (KeywordQuery query = new KeywordQuery(site))
{
var fedManager = new FederationManager(application);
var owner = new SearchObjectOwner(SearchObjectLevel.SPSite, site.RootWeb);
query.SourceId = fedManager.GetSourceByName("NewsRS", owner).Id;
query.QueryText = string.Format("WorkflowStatusOWSCHCS:Approved PublishedUntilDate>=\"{0}\" OR NewsNewsPublishedDate<=\"{0}\"", DateTime.Now);
query.KeywordInclusion = KeywordInclusion.AllKeywords;
query.RowLimit = 5;
query.StartRow = 1;
query.SelectProperties.Add("NewsFriendlyUrl");
query.SelectProperties.Add("NewsNewsTeaser");
query.SelectProperties.Add("NewsNewsDate");
query.SelectProperties.Add("NewsPublishedUntilDate");
query.SelectProperties.Add("NewsNewsContent");
query.SelectProperties.Add("NewsNewsPublishedDate");
query.SelectProperties.Add("NewsNewsImage");
query.SortList.Add("NewsNewsDate", SortDirection.Descending);
var searchExecutor = new SearchExecutor();
var myResults = searchExecutor.ExecuteQuery(query);
}
}
... the NewsNewsDate is marked as Sortable
query.RowLimit = 5; => You are explicitly specifying the Rowlimit to be 5. That is why it returns the first 5 results always. Change the rowlimit and set it to the number of results you need.