Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #330 from InfyOmLabs/develop
Browse files Browse the repository at this point in the history
Release v1.8.2-alpha
  • Loading branch information
mitulgolakiya authored Sep 4, 2019
2 parents 52c7f08 + 1a6fd4b commit 9b78c57
Show file tree
Hide file tree
Showing 40 changed files with 1,687 additions and 54 deletions.
7 changes: 4 additions & 3 deletions app/Http/Requests/UpdateUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public function rules()
{
$id = $this->route('user')->id;
$rules = [
'name' => 'required|unique:users,name,'.$id,
'email' => 'required|email|unique:users,email,'.$id.'|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
'phone' => 'nullable|numeric|digits:10',
'name' => 'required|unique:users,name,'.$id,
'email' => 'required|email|unique:users,email,'.$id.'|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
'phone' => 'nullable|numeric|digits:10',
'role_id' => 'required',
];

return $rules;
Expand Down
14 changes: 8 additions & 6 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,17 @@ class User extends Authenticatable
* @var array
*/
public static $rules = [
'name' => 'required|unique:users,name',
'email' => 'required|email|unique:users,email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
'phone' => 'nullable|numeric|digits:10',
'name' => 'required|unique:users,name',
'email' => 'required|email|unique:users,email|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
'phone' => 'nullable|numeric|digits:10',
'role_id' => 'required',
];

public static $messages = [
'phone.digits' => 'The phone number must be 10 digits long.',
'email.regex' => 'Please enter valid email.',
'photo.mimes' => 'The profile image must be a file of type: jpeg, jpg, png.',
'phone.digits' => 'The phone number must be 10 digits long.',
'email.regex' => 'Please enter valid email.',
'photo.mimes' => 'The profile image must be a file of type: jpeg, jpg, png.',
'role_id.required' => 'Please select user role.',
];

public static $setPasswordRules = [
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/DashboardRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getWorkReport($input)
$result = [];
// preparing a date array for displaying a labels
foreach ($dates['dateArr'] as $date) {
$date = date('d-M', strtotime($date));
$date = date('jS M', strtotime($date));
$result['date'][] = $date;
}
$result['projects'] = array_keys($projects);
Expand Down
4 changes: 4 additions & 0 deletions app/Repositories/ReportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ public function getReport($report)
$project = $entry->task->project;
$client = $project->client;
$duration = $entry->duration;
$projectPrefix = $project->prefix;
$taskNumber = $entry->task->task_number;

// prepare client and duration
$result[$clientId]['name'] = $client->name;
Expand Down Expand Up @@ -306,6 +308,8 @@ public function getReport($report)
$time = $result[$clientId]['projects'][$project->id]['users'][$entry->user_id]['tasks'][$entry->task_id]['duration'] + $entry->duration;
$result[$clientId]['projects'][$project->id]['users'][$entry->user_id]['tasks'][$entry->task_id]['duration'] = $time;
$result[$clientId]['projects'][$project->id]['users'][$entry->user_id]['tasks'][$entry->task_id]['time'] = $this->getDurationTime($time);
$result[$clientId]['projects'][$project->id]['users'][$entry->user_id]['tasks'][$entry->task_id]['project_prefix'] = $projectPrefix;
$result[$clientId]['projects'][$project->id]['users'][$entry->user_id]['tasks'][$entry->task_id]['task_number'] = $taskNumber;
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "infyomlabs/infy-tracker",
"type": "project",
"version": "1.8.1-alpha",
"version": "1.8.2-alpha",
"description": "Create Projects / Tasks, Track Time, Show Daily Reports",
"keywords": [
"time",
Expand Down
6 changes: 4 additions & 2 deletions database/factories/ReportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

$factory->define(Report::class, function (Faker $faker) {
$user = factory(User::class)->create();
$startDate = date('Y-m-d H:i:s', strtotime('-1 day'));
$endDate = date('Y-m-d H:i:s');

return [
'name' => $faker->word,
'owner_id' => $user->id,
'start_date' => $faker->dateTime,
'end_date' => $faker->dateTime,
'start_date' => $startDate,
'end_date' => $endDate,
];
});
5 changes: 4 additions & 1 deletion database/factories/TaskFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@

$factory->define(Task::class, function (Faker $faker) {
$project = factory(Project::class)->create();
$dueDate = date('Y-m-d H:i:s', strtotime('+ 4hours'));

$dueDate = date('Y-m-d H:i:s', strtotime('+ 4hours'));

return [
'title' => $faker->sentence,
'description' => $faker->text,
'project_id' => $project->id,
'due_date' => $faker->dateTime,
'due_date' => $dueDate,
'status' => Task::STATUS_ALL,
'task_number' => $faker->unique()->randomDigitNotNull,
];
Expand Down
3 changes: 3 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'is_active' => true,
'is_email_verified' => true,
'set_password' => true,
];
});
29 changes: 29 additions & 0 deletions resources/assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,32 @@ window.displaySuccessMessage = function (message) {
position: 'top-right',
});
};

$(function () {
$(".dataTables_length").css('padding-top', '6px');
$(".dataTables_info").css('padding-top', '24px');
});

$.extend($.fn.dataTable.defaults, {
drawCallback: function (settings) {
let thisTableId = settings.sTableId;
if (settings.fnRecordsDisplay() > settings._iDisplayLength) {
$('#' + thisTableId + '_paginate').show();
} else {
$('#' + thisTableId + '_paginate').hide();
}
}
});

//focus on select2
$(document).on('focus', '.select2-selection.select2-selection--single', function (e) {
$(this).closest(".select2-container").siblings('select:enabled').select2('open');
});

$(function () {
$(".modal").on('shown.bs.modal', function () {
setTimeout(function () {
$(".modal").find('input:text, .select2-selection.select2-selection--single').first().focus();
},150);
});
});
8 changes: 5 additions & 3 deletions resources/assets/js/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ timeRange.on('apply.daterangepicker', function (ev, picker) {
});

window.cb = function (start, end) {
timeRange.find('span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
timeRange.find('span').html(start.format('MMM D, YYYY') + ' - ' + end.format('MMM D, YYYY'));
};

cb(start, end);
Expand Down Expand Up @@ -67,7 +67,6 @@ window.loadUserWorkReport = function (startDate, endDate, userId) {
window.prepareUserWorkReport = function (result) {
$('#daily-work-report').html('');
let data = result.data;
console.log(result);
if (data.totalRecords === 0) {
$('#work-report-container').html('');
$('#work-report-container').append('<div align="center" class="no-record">No Records Found</div>');
Expand Down Expand Up @@ -96,12 +95,15 @@ window.prepareUserWorkReport = function (result) {
mode: 'index',
callbacks: {
label: function (tooltipItem, data) {
result = roundToQuarterHour(tooltipItem.yLabel);
if(result == '0min') {
return '';
}
let label = data.datasets[tooltipItem.datasetIndex].label || '';

if (label) {
label += ': ';
}
result = roundToQuarterHour(tooltipItem.yLabel);
return label + result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/dashboard/developers-daily-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $datePicker.on('apply.daterangepicker', function (ev, picker) {
});

window.cb = function (start) {
$datePicker.find('span').html(start.format('MMMM D, YYYY'));
$datePicker.find('span').html(start.format('MMM D, YYYY'));
};

cb(start);
Expand Down
14 changes: 12 additions & 2 deletions resources/assets/js/profile/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $('#editProfileForm').submit(function (event) {
if(!isValidate){
return false;
}
let loadingButton = jQuery(this).find("#btnEditSave");
let loadingButton = jQuery(this).find("#btnPrEditSave");
loadingButton.button('loading');
$.ajax({
url: usersUrl + 'profile-update',
Expand Down Expand Up @@ -120,4 +120,14 @@ function validatePassword() {
return false;
}
return true;
}
}

$(".changeType").click(function () {
let inputField = $(this).parent().siblings();
let oldType = inputField.attr('type');
if(oldType == 'password') {
inputField.attr('type', 'text');
} else {
inputField.attr('type', 'password');
}
});
4 changes: 4 additions & 0 deletions resources/assets/js/report/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ $('#end_date').datetimepicker({
maxDate: moment()
});

$(function () {
$('form').find('input:text').filter(':input:visible:first').first().focus();
});

$("#start_date").on("dp.change", function (e) {
$('#end_date').data("DateTimePicker").minDate(e.date);
});
Expand Down
9 changes: 5 additions & 4 deletions resources/assets/js/task/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ $(document).on('change', '#task_users', function () {
taskId = taskUserId[1];
userId = taskUserId[0];
}
let url = taskDetailUrl + '/' + taskId
let url = taskDetailUrl + '/' + taskId;
if (userId !== 0) {
url = url + '?user_id=' + userId
url = url + '?user_id=' + userId;
}
$.ajax({
url: url,
Expand Down Expand Up @@ -374,7 +374,8 @@ window.drawTaskDetailTable = function (data) {
$('#no-record-info-msg').hide();
stopLoader();

$('#taskDetailsTable tbody').on('click', 'td.details-control', function () {
$('#taskDetailsTable tbody').off('click', 'tr td.details-control');
$('#taskDetailsTable tbody').on('click', 'tr td.details-control', function () {
var tr = $(this).closest('tr');
var row = taskDetailsTable.row(tr);

Expand All @@ -384,7 +385,7 @@ window.drawTaskDetailTable = function (data) {
tr.removeClass('shown');
} else {
// Open this row
row.child(formatCollapsableRow(row.data())).show();
row.child('<div style="padding-left:50px;">' + row.data().note + '</div>').show();
tr.addClass('shown');
}
});
Expand Down
5 changes: 2 additions & 3 deletions resources/assets/js/task/task_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ Dropzone.options.dropzone = {
let newFileName = fileNameExtArr[0];
let newFileExt = fileNameExtArr[1];
let prevFileName = fileuploded.innerHTML.split('.')[0];
let fileUrl = attachmentUrl + fileName;
fileuploded.innerHTML = fileName;

$(".dz-preview:last-child").children(':last-child').attr('data-file-id', attachment.id);
$(".dz-preview:last-child").children(':last-child').attr('data-file-url', attachment.file_url);
$(file.previewTemplate).find('.dz-remove').attr('data-file-id', attachment.id);
$(file.previewTemplate).find('.dz-remove').attr('data-file-url', attachment.file_url);
if($.inArray(newFileExt,['jpg','jpge','png']) > -1) {
$(".previewEle").find('.' + prevFileName).attr('href', attachment.file_url);
$(".previewEle").find('.' + prevFileName).attr('class', newFileName);
Expand Down
1 change: 1 addition & 0 deletions resources/assets/js/time_entries/time_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ $('#startTime,#endTime').on('dp.change', function (selected) {
$('#startTime').data("DateTimePicker").maxDate(moment().endOf('now'));
$('#endTime').data("DateTimePicker").maxDate(moment().endOf('now'));
});
$('#endTime').val(moment().format('YYYY-MM-DD HH:mm:ss'));

$('#editTimeEntryForm').submit(function (event) {
event.preventDefault();
Expand Down
96 changes: 94 additions & 2 deletions resources/assets/js/time_tracker/time_tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ $("#stopTimer").click(function (e) {
enableTimerData();

$('#loader').show();
storeTimeEntry();
checkTimeEntry();
});

function enableTimerData() {
Expand All @@ -215,10 +215,102 @@ function stopTime() {
seconds = minutes = hours = 0;
}

function storeTimeEntry() {
function diff_mins(dt2, dt1) {
dt2 = new Date(dt2);
dt1 = new Date(dt1);
var diff = (dt2.getTime() - dt1.getTime()) / 1000;
diff /= (60);
return Math.abs(Math.round(diff));
}

function adjustTimeEntry() {
let startDate = getItemFromLocalStorage('start_time');
$("#tmAdjustValidationErrorsBox").show();
$("#tmAdjustValidationErrorsBox").html("Time Entry must be less than 12 hours.");
$('#adjustStartTime').val(startDate);
$('#adjustStartTime').attr('disabled', 'true');
$("#timeEntryAdjustModal").modal();
$('#stopTimer').removeAttr('disabled');
}

$('#timeEntryAdjustModal').on('hidden.bs.modal', function () {
$('#adjustEndTime').prop('disabled', false);
$('#adjustStartTime').prop('disabled', false);
$("#adjustEndTime").data("DateTimePicker").date(null);
$("#adjustStartTime").data("DateTimePicker").date(null);
resetModalForm('#timeEntryAdjustForm');
$('#tmAdjustValidationErrorsBox').hide();
});

$('#adjustStartTime').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
useCurrent: true,
icons: {
up: "icon-arrow-up icons",
down: "icon-arrow-down icons",
previous: 'icon-arrow-left icons',
next: 'icon-arrow-right icons',
},
sideBySide: true,
maxDate: moment().endOf('day'),
});
$('#adjustEndTime').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
useCurrent: true,
icons: {
up: "icon-arrow-up icons",
down: "icon-arrow-down icons",
previous: 'icon-arrow-left icons',
next: 'icon-arrow-right icons',
},
sideBySide: true,
maxDate: moment().endOf('day'),
});

$('#adjustStartTime,#adjustEndTime').on('dp.change', function () {
const startTime = $('#adjustStartTime').val();
const endTime = $('#adjustEndTime').val();
let minutes = 0;
if (endTime) {
const diff = new Date(Date.parse(endTime) - Date.parse(startTime));
minutes = diff / (1000 * 60);
if (!Number.isInteger(minutes)) {
minutes = minutes.toFixed(2);
}
}
$('#adjustDuration').val(minutes).prop('disabled', true);
$('#adjustStartTime').data("DateTimePicker").maxDate(moment().endOf('now'));
$('#adjustEndTime').data("DateTimePicker").maxDate(moment().endOf('now'));
if(minutes < 720) {
$('#tmAdjustValidationErrorsBox').hide();
}
});

$('#adjustBtnSave').click(function () {
let startTime = $('#adjustStartTime').val();
let endTime = $('#adjustEndTime').val();
let totalMin = diff_mins(endTime, startTime);
if(totalMin > 720) {
$("#tmAdjustValidationErrorsBox").show();
$("#tmAdjustValidationErrorsBox").html("Time Entry must be less than 12 hours.");
} else {
$("#adjustBtnCancel").trigger('click');
storeTimeEntry(startTime, endTime);
}
});

function checkTimeEntry() {
let startTime = getItemFromLocalStorage('start_time');
let endTime = getCurrentTime();
let totalMin = diff_mins(endTime, startTime);
if(totalMin > 720) {
adjustTimeEntry();
} else {
storeTimeEntry(startTime, endTime);
}
}

function storeTimeEntry(startTime, endTime) {
$.ajax({
url: storeTimeEntriesUrl,
type: 'POST',
Expand Down
Loading

0 comments on commit 9b78c57

Please sign in to comment.