currently i using multiple datepicker (http://keith-wood.name/datepick.html). I need to pass dates from MySQL table with PHP (reservations) to calendar and change CSS style for show state.
occupied - red
pending - yellow
free - grey
preview on another site: http://www.chata-vysocina.eu/en/rezervace/
Anyone have some tips how to do that?
Thank you,
Tomas
Ok, i resolved my problem with following lines.
<script>
var dates = [
[2013, 12, 24],
[2013, 12, 25]
];
var today = new Date();
$('#reserve').multiDatesPicker({
firstDay: 1,
numberOfMonths: 4,
dateFormat: "dd-mm-yy",
altField: '#dates',
minDate: 0,
beforeShowDay: function (date){
var year = date.getFullYear(), month = date.getMonth(), day = date.getDate();
// see if the current date should be highlighted
for (var i=0; i < dates.length; ++i)
if (year == dates[i][0] && month == dates[i][1] - 1 && day == dates[i][2])
return [false, 'booked'];
return [false];
}
});
</script>
Related
Thank you for taking the time to look at this.
I have a sheet where I've cobbled together a script that moves a row on edit of a certain value, and then does a multi-sort of the involved sheets so that the row is in order on the new sheet. Works great.
However, now asking if I can make this work with filters. This is where things go wonky. When a filters is engaged, the sort function wrecks the filter when they move a row. Also, the filtered bracket shrinks, and though rows get sorted, and end up within the filtered bracket, others get pushed out, etc. It's a bit hard to explain, so here are two examples:
Script functioning in an unfiltered sheet: https://docs.google.com/spreadsheets/d/1Uwge7eS6DXJvbNi-7kRY9djg4Cq2r4QO9BeyNjnhkCg/edit?usp=sharing
Script functioning and wrecking filters: https://docs.google.com/spreadsheets/d/1fXJ8_5bqYCOpm6PlModT-GpymL8zrS0NXkhSYweZX6Y/edit?usp=sharing
(you can turn the filters off and on to reset it if you need to)
When a row is moved can it be sorted within the active filtered set? I'm not sure this is possible. Is it?
My work around would be to have the sorting functions execute onOpen so that they don't disrupt anyones filtered data, but this sheet has a fair number of users, and so I'm not sure if it's ever closed. Any other suggestions?
I appreciate your time and consideration. Thank you. I hope I can return the favour one day.
Here is the script:
SORT_DATA_RANGE = "A2:F99"
SORT_ORDER= [
{column: 4, ascending: true},
{column: 5, ascending: true}];
function onEdit(event) {
movethings1(event);
sortthings1()
sortthings2();
}
function movethings1(event) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(r.getColumn() == 2 && ( r.getValue() == "paid" || r.getValue() == "unpaid"
|| r.getValue() == "pending") ) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet;
if(r.getValue() == "paid")
targetSheet= ss.getSheetByName("Paid");
else if(r.getValue() == "unpaid")
targetSheet= ss.getSheetByName("Unpaid");
else if(r.getValue() == "pending")
targetSheet= ss.getSheetByName("Unpaid");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);}
}
function sortthings1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Unpaid");
var range = sheet.getRange(SORT_DATA_RANGE);
range.sort(SORT_ORDER);}
function sortthings2() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Paid");
var range = sheet.getRange(SORT_DATA_RANGE);
range.sort(SORT_ORDER);
ss.toast('done that thing you wanted');}
i need help please with this code :
dump missing date in data for chartjs
my table for example with values:
bonus date
5 : 18-04-2020
10 : 19-04-2020
0 : 20-04-2020
0 : 21-04-2020
55 : 22-04-2020
44 : 23-04-2020
30 : 24-04-2020
i get last 7 days date in database, chartjs display all dates, but i want in chart not to display 30 : 24-04-2020 last date but i want to display 0: 25-04-2020 if not exists in database because user not have any bonus yet today.. i think need to add 1 day in last date in chartjs ? or in database query ?
my code :
var graphData = [55, 10, 0, 0, 55, 44, 30],
labels = ["18-04-2020", "19-04-2020", "20-04-2020", "21-04-2020", "22-04-2020", "23-04-2020", "24-04-2020"];
for (var i = 0; i < labels.length; i++) {
//make sure we are not checking the last date in the labels array
if (i + 1 < labels.length) {
var date1 = moment(labels[i], "DD-MM-YYYY");
var date2 = moment(labels[i + 1], "DD-MM-YYYY");
//if the current date +1 is not the same as it's next neighbor we have to add in a new one
if (!date1.add(1, "days").isSame(date2)) {
//add the label
labels.splice(i + 1, 0, date1.format("DD-MM-YYYY"));
//add the data
graphData.splice(i + 1, 0, 0);
}
}
}
var ctx = document.getElementById("chart").getContext("2d");
var data = {
labels:labels,
datasets: [{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: graphData
}]
};
var myLineChart = new Chart(ctx).Line(data);
I use the DHTMLX Scheduler in Timeline view for a project and the working hours are from 7AM to 5PM. I was able to make an AM/PM view per day but the first_hour and last_hour configs are not respected in the view. The screenshot shows more. The first event in the morning should be displayed far more left as it starts at 7:30Am.
My config:
scheduler.locale.labels.timeline_tab = "Timeline";
scheduler.locale.labels.section_custom = "Section";
scheduler.config.dblclick_create = false;
scheduler.config.edit_on_create = false;
scheduler.config.details_on_dblclick = false;
scheduler.config.details_on_create = false;
scheduler.config.start_on_monday = true;
scheduler.config.first_hour = 7;
scheduler.config.last_hour = 17;
scheduler.config.full_day = true;
scheduler.config.mark_now = false;
scheduler.config.drag_move = false;
scheduler.config.drag_resize = false;
//===============
//Configuration
//===============
scheduler.createTimelineView({
name: "timeline",
x_unit: "hour",
x_date: "%A",
x_step: 12,
x_size: 14,
x_start: 0,
x_length: 14,
y_unit: scheduler.serverList('teams'), // sections and events from same ajax call
y_property: "team_id",
render: "bar",
section_autoheight: false,
dy: 30,
dx: 100,
// first_hour: 7,
// last_hour: 17,
second_scale: {
x_unit: "day", // unit which should be used for second scale
x_date: "%D %j %M"
}
});
Any help will be appreciated.
EDIT:
After update based on the answer here the result:
first_hour, last_hour configs applied for Y-axis in Day, Week, Units views (check Documentation).
Currently, to hide hours at the beginning and end of the day in the Timeline view, you should have only 1 X-axis like in this sample. I.e. visible part of the event is from 10 to 18 because of first_hour, end_hour properties of createTimelineView method. Check the screenshot.
There is also ignore_[viewName] function which can be used to hide interval that equal to min step of the scale (12 hours in your case).
This could help solve your issue if set min step = 6 (hours) and disable 6-7 AM and 5-6 PM by addMarkedTimespan. I tried to create a snippet for you http://snippet.dhtmlx.com/46ba545ad , but found out that the second part of this condition if(date.getHours() < 6 || date.getHours() > 17){ is not working correctly. The event can be created until 6 PM. We will fix it ASAP, but now I can't specify the exact time. I suggest you use the first way with 1 scale to solve the issue.
I am searching for a way to sort my spreadsheet. I have looked around and found the "on edit" function but I am not entirely sure on how to use it. And how does it work with the runtime of only 5 minutes for google scripts, does a cellchange act as a trigger?
I found the following code:
function AutoSortOnEdit() {
var sheetNames = ["testsheet456", "testsheet457", "testsheet458"];
var ss = SpreadsheetApp.getActiveSpreadsheet();
sheetNames.forEach(function(name) {
var sheet = ss.getSheetByName(name);
var range = sheet.getRange(5, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
range.sort({column: 1, ascending: true});
});
Personally i would use this slightly modified version:
function AutoSortOnEdit() {
var sheet = SpreadsheetApp.openById("...").getSheetByName("...");
var range = sheet.getRange(5, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
range.sort({column: 1, ascending: true});
});
Now I want to sort the sheet in alphabetical order sorted by the first row.
My questions are:
Does "ascending" mean that it sorts in alphabetical order?
Where do empty cells land(they should be at the end obviously)?
Does it gets triggered on every change? Can i manipulate to only sort it when Column A gets edited?
Regards Jonny
Edit: In the end i went with my slighlty modified version since onEdit was after all not fitting in the situation.
Yes, ascending is alphabetical. This code looks for only a change in the sheet named Sheet1 and only column A. The function must be named OnEdit (not AutoSortOnEdit).
function onEdit()
{
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var sheetName= sheet.getSheetName();
if(sheetName=="Sheet1"){ //sheet to run on edit
var editRange = sheet.getActiveRange();
var editRow = editRange.getRow();
var editCol = editRange.getColumn();
var lr = sheet.getLastRow()
var range = sheet.getRange("A1:A"+lr);//apply on edit to
var rangeRowStart = range.getRow();
var rangeRowEnd = rangeRowStart + range.getHeight()-1;
var rangeColStart = range.getColumn();
var rangeColEnd = rangeColStart + range.getWidth()-1;
if (editRow >= rangeRowStart && editRow <= rangeRowEnd
&& editCol >= rangeColStart && editCol <= rangeColEnd)
{
var range = sheet.getSheetByName(sheetName).getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());//Assumes header row
range.sort({column: 1, ascending: true});
}}}
Simple event triggers are limited to a 30 second execution time.
onEdit() events must be named simply onEdit() or onEdit(event)
onEdit can take a variable that represents the event that triggered it, that among other things, includes the range that was edited.
Sheet has it's own sort(). If you are trying to sort the entire sheet it is simpler to use that.
function onEdit(event){
if(event.range.getSheet().getName() == "Sheet1" && event.range.getColumn() == 1){//checks to see if the edited range was both on Sheet1 and column 1 (A)
event.range.getSheet().sort(1,true); //sort by first column
// event.range.getSheet().sort(1,false); //decending
}
}
multiple sheets can watched by expanding the conditionals, or aditional if statements.
I have used Kendo Datepicker (kendo-date-picker)into one of my projects and now I want to restrict the date selection into current month. Yes, I can do it programmatically, but I want to know whether is there any configuration option to restrict the date selection into current month.
For example, if I am in April 2015, I should not be able to select any date outside of April 2015.
You can try this way:
$(document).ready(function() {
// JavaScript counts months from 0 to 11. January is 0. December is 11.
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
$("#datepicker").kendoDatePicker({
min: firstDay,
max: lastDay
});
});
See this Demo
You can override the style to hide the other month dates.
.k-other-month {
visibility: hide;
}