Skip to content
Snippets Groups Projects
Commit 6ec763ea authored by Piotr Gawron's avatar Piotr Gawron
Browse files

javascript functionality to setup end date automatically when start date changes

parent 16d5ace1
No related branches found
No related tags found
1 merge request!20When setting visit start date, end date is steup automatically for +3 months
function visit_dates_begaviour(startDateInput, endDateInput) {
$(startDateInput).change(function () {
var object = $(this);
try {
var date = new Date(object.val());
date.setMonth(date.getMonth() + 3);
$(endDateInput).val(date.toISOString().substring(0, 10));
} catch (err) {
//there was a problematic date to process
}
});
}
......@@ -3,8 +3,8 @@
{% load filters %}
{% block styles %}
{{ block.super }}
{% include "includes/datepicker.css.html" %}
{{ block.super }}
{% include "includes/datepicker.css.html" %}
{% endblock styles %}
{% block ui_active_tab %}'visits'{% endblock ui_active_tab %}
......@@ -14,63 +14,71 @@
{% block title %}{{ block.super }} - Add new visit{% endblock %}
{% block breadcrumb %}
{% include "visits/breadcrumb.html" %}
{% include "visits/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="box box-info">
<div class="box-header with-border">
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default">Cancel</a>
</div>
{% block content %}
<div class="box box-info">
<div class="box-header with-border">
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default">Cancel</a>
</div>
{% comment %}
<div class="box-header with-border">
<h3 class="box-title">Details of a visit</h3>
</div>
{% endcomment %}
<form method="post" action="" class="form-horizontal">
{% csrf_token %}
<div class="box-body">
<div class="col-sm-6">
{% for field in form %}
<div class="form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}">
<label class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|add_class:'form-control' }}
</div>
{% comment %} <div class="box-header with-border">
<h3 class="box-title">Details of a visit</h3>
</div>{% endcomment %}
<form method="post" action="" class="form-horizontal">
{% csrf_token %}
<div class="box-body">
<div class="col-sm-6">
{% for field in form %}
<div class="form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}">
<label class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|add_class:'form-control' }}
</div>
{% if field.errors %}
<span class="help-block">
{% if field.errors %}
<span class="help-block">
{{ field.errors }}
</span>
{% endif %}
</div>
{% endfor %}
</div>
</div><!-- /.box-body -->
{% endif %}
</div>
{% endfor %}
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-success">Add</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-success">Add</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
{% endblock %}
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
{{ block.super }}
<script src="{% static 'js/visit.js' %}"></script>
<script>
visit_dates_begaviour($("[name='datetime_begin']"),$("[name='datetime_end']"));
</script>
{% include "includes/datepicker.js.html" %}
{% include "includes/datepicker.js.html" %}
{% endblock scripts %}
......@@ -3,11 +3,11 @@
{% load filters %}
{% block styles %}
{{ block.super }}
<!-- DataTables -->
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
{{ block.super }}
<!-- DataTables -->
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
{% include "includes/datepicker.css.html" %}
{% include "includes/datepicker.css.html" %}
{% endblock styles %}
{% block ui_active_tab %}'visits'{% endblock ui_active_tab %}
......@@ -17,186 +17,189 @@
{% block title %}{{ block.super }} - Details of visit ({{ visit.follow_up_title }}) {% endblock %}
{% block breadcrumb %}
{% include "subjects/breadcrumb.html" %}
{% include "subjects/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="box box-info">
<div class="box-header with-border">
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default"
onclick="history.back()">Back</a>
<a href="{% url 'web.views.subject_visit_details' visit.subject.id %}" type="button"
class="btn btn-block btn-default">Subject's visits</a>
</div>
{% block content %}
<div class="box box-info">
<div class="box-header with-border">
<a href="{% url 'web.views.visits' %}" class="btn btn-block btn-default"
onclick="history.back()">Back</a>
<a href="{% url 'web.views.subject_visit_details' visit.subject.id %}" type="button"
class="btn btn-block btn-default">Subject's visits</a>
</div>
<div class="box-header with-border">
<h3 class="box-title">Details of visit
<div class="box-header with-border">
<h3 class="box-title">Details of visit
</h3>
</div>
</h3>
</div>
<form method="post" action="" class="form-horizontal">
{% csrf_token %}
<div class="box-body">
{% for field in vform %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|add_class:'form-control' }}
</div>
{% if field.errors %}
<span class="help-block">
<form method="post" action="" class="form-horizontal">
{% csrf_token %}
<div class="box-body">
{% for field in vform %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|add_class:'form-control' }}
</div>
{% if field.errors %}
<span class="help-block">
{{ field.errors }}
</span>
{% endif %}
</div>
{% endfor %}
<div class="col-md-6 form-group">
<label class="col-sm-4 control-label">
Visit finished
</label>
<div class="col-sm-8">
{% if visFinished %}
<div class="btn btn-block">YES</div>
{% else %}
<div class="btn btn-block">
{% if canFinish %}
<a href="{% url 'web.views.visit_mark' vid 'finished' %}"
class="btn btn-warning btn-block">Mark as finished</a>
{% else %}
Waiting for appointments to finish.
{% endif %}
</div>
{% endif %}
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-12">
<button type="submit" class="btn btn-block btn-success">Save</button>
{% endif %}
</div>
{% endfor %}
<div class="col-md-6 form-group">
<label class="col-sm-4 control-label">
Visit finished
</label>
<div class="col-sm-8">
{% if visFinished %}
<div class="btn btn-block">YES</div>
{% else %}
<div class="btn btn-block">
{% if canFinish %}
<a href="{% url 'web.views.visit_mark' vid 'finished' %}"
class="btn btn-warning btn-block">Mark as finished</a>
{% else %}
Waiting for appointments to finish.
{% endif %}
</div>
</div><!-- /.box-footer -->
</form>
<div class="box-header with-border">
<h3 class="box-title">Visit's appointments</h3>
{% endif %}
</div>
</div>
<div>
<a href="{% url 'web.views.appointment_add' vid %}" class="btn btn-app">
<i class="fa fa-plus"></i>
Add new appointment
</a>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-12">
<button type="submit" class="btn btn-block btn-success">Save</button>
</div>
</div><!-- /.box-footer -->
</form>
{% if loApp %}
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>No.</th>
<th>Type</th>
<th>Date</th>
<th>Time</th>
<th>Length [min]</th>
<th>Responsible</th>
<th>Plan/Modify</th>
</tr>
</thead>
<tbody>
{% for app in loApp %}
<tr>
<td>{{ forloop.counter }}</td>
<td style="background-color:{{ app.color }} !important">
<font COLOR="{{ app.font_color }}">
{% for type in app.appointment_types.all %}
{{ type.code }},
{% endfor %}
</font>
</td>
<td>{{ app.datetime_when | date:"d-M-Y" }}</td>
<td>{{ app.datetime_when | time:"H:i" }}</td>
<td>{{ app.length }}</td>
<td>
{% if app.flying_team %}{{ app.worker_assigned.first_name }}
{{ app.worker_assigned.last_name }}
{% else %} {{ app.flying_team }}
{% endif %}
</td>
<td>
{% ifequal app.status "SCHEDULED" %}
<a href="{% url 'web.views.appointment_edit' app.id %}" type="button"
class="btn btn-block btn-default">Edit</a>
{% else %}
{{ app.status }}
{% endifequal %}
</td>
</tr>
{% endfor %}
<div class="box-header with-border">
<h3 class="box-title">Visit's appointments</h3>
</div>
</tbody>
</table>
{% else %}
<p>No appointments found.</p>
{% endif %}
<div>
<a href="{% url 'web.views.appointment_add' vid %}" class="btn btn-app">
<i class="fa fa-plus"></i>
Add new appointment
</a>
</div>
<div class="box-header with-border">
<h3 class="box-title">Subject's details</h3>
</div>
{% if loApp %}
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>No.</th>
<th>Type</th>
<th>Date</th>
<th>Time</th>
<th>Length [min]</th>
<th>Responsible</th>
<th>Plan/Modify</th>
</tr>
</thead>
<tbody>
{% for app in loApp %}
<tr>
<td>{{ forloop.counter }}</td>
<td style="background-color:{{ app.color }} !important">
<font COLOR="{{ app.font_color }}">
{% for type in app.appointment_types.all %}
{{ type.code }},
{% endfor %}
</font>
</td>
<td>{{ app.datetime_when | date:"d-M-Y" }}</td>
<td>{{ app.datetime_when | time:"H:i" }}</td>
<td>{{ app.length }}</td>
<td>
{% if app.flying_team %}{{ app.worker_assigned.first_name }}
{{ app.worker_assigned.last_name }}
{% else %} {{ app.flying_team }}
{% endif %}
</td>
<td>
{% ifequal app.status "SCHEDULED" %}
<a href="{% url 'web.views.appointment_edit' app.id %}" type="button"
class="btn btn-block btn-default">Edit</a>
{% else %}
{{ app.status }}
{% endifequal %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No appointments found.</p>
{% endif %}
<div class="box-header with-border">
<h3 class="box-title">Subject's details</h3>
</div>
<form class="form-horizontal">
<div class="box-body">
{% for field in sform %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
</label>
<form class="form-horizontal">
<div class="box-body">
{% for field in sform %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|disable|add_class:'form-control' }}
</div>
<div class="col-sm-8">
{{ field|disable|add_class:'form-control' }}
</div>
{% if field.errors %}
<span class="help-block">
{% if field.errors %}
<span class="help-block">
{{ field.errors }}
</span>
{% endif %}
</div>
{% endfor %}
</div><!-- /.box-body -->
<div class="box-footer">
<td><a href="{% url 'web.views.subject_edit' visit.subject.id %}" type="button"
class="btn btn-block btn-default">Edit subject</a></td>
<a href="{% url 'web.views.subjects' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a>
</div><!-- /.box-footer -->
</form>
</div>
{% endif %}
</div>
{% endfor %}
</div><!-- /.box-body -->
</form>
{% endblock %}
<div class="box-footer">
<td><a href="{% url 'web.views.subject_edit' visit.subject.id %}" type="button"
class="btn btn-block btn-default">Edit subject</a></td>
<a href="{% url 'web.views.subjects' %}" class="btn btn-block btn-default" onclick="history.back()">Back</a>
</div><!-- /.box-footer -->
</form>
</div>
</form>
{% endblock %}
</div>
</div>
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script src="{% static 'js/visit.js' %}"></script>
<script>
visit_dates_begaviour($("[name='datetime_begin']"),$("[name='datetime_end']"));
</script>
{% include "includes/datepicker.js.html" %}
{% include "includes/datepicker.js.html" %}
{% endblock scripts %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment