mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
Ensured JS client dates use timezone setting
This commit is contained in:
parent
b9c00a0531
commit
25496061ee
@ -10,9 +10,10 @@ use Validator;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use DropdownButton;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use App\Models\Client;
|
||||
use App\Models\Task;
|
||||
|
||||
use App\Ninja\Repositories\TaskRepository;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
|
||||
@ -35,10 +36,7 @@ class TaskController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (!Auth::user()->account->timezone) {
|
||||
$link = link_to('/company/details', trans('texts.click_here'), ['target' => '_blank']);
|
||||
Session::flash('warning', trans('texts.timezone_unset', ['link' => $link]));
|
||||
}
|
||||
self::checkTimezone();
|
||||
|
||||
return View::make('list', array(
|
||||
'entityType' => ENTITY_TASK,
|
||||
@ -130,12 +128,15 @@ class TaskController extends BaseController
|
||||
*/
|
||||
public function create($clientPublicId = 0)
|
||||
{
|
||||
self::checkTimezone();
|
||||
|
||||
$data = [
|
||||
'task' => null,
|
||||
'clientPublicId' => Input::old('client') ? Input::old('client') : $clientPublicId,
|
||||
'method' => 'POST',
|
||||
'url' => 'tasks',
|
||||
'title' => trans('texts.new_task'),
|
||||
'minuteOffset' => Utils::getTiemstampOffset(),
|
||||
];
|
||||
|
||||
$data = array_merge($data, self::getViewModel());
|
||||
@ -151,6 +152,8 @@ class TaskController extends BaseController
|
||||
*/
|
||||
public function edit($publicId)
|
||||
{
|
||||
self::checkTimezone();
|
||||
|
||||
$task = Task::scope($publicId)->with('client', 'invoice')->firstOrFail();
|
||||
|
||||
$actions = [];
|
||||
@ -174,7 +177,7 @@ class TaskController extends BaseController
|
||||
} else {
|
||||
$actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans('texts.restore_task')];
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'task' => $task,
|
||||
'clientPublicId' => $task->client ? $task->client->public_id : 0,
|
||||
@ -183,6 +186,7 @@ class TaskController extends BaseController
|
||||
'title' => trans('texts.edit_task'),
|
||||
'duration' => $task->is_running ? $task->getCurrentDuration() : $task->getDuration(),
|
||||
'actions' => $actions,
|
||||
'minuteOffset' => Utils::getTiemstampOffset(),
|
||||
];
|
||||
|
||||
$data = array_merge($data, self::getViewModel());
|
||||
@ -281,4 +285,12 @@ class TaskController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function checkTimezone()
|
||||
{
|
||||
if (!Auth::user()->account->timezone) {
|
||||
$link = link_to('/company/details', trans('texts.click_here'), ['target' => '_blank']);
|
||||
Session::flash('warning', trans('texts.timezone_unset', ['link' => $link]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,6 +315,16 @@ class Utils
|
||||
return $date->format($format);
|
||||
}
|
||||
|
||||
public static function getTiemstampOffset()
|
||||
{
|
||||
$timezone = new DateTimeZone(Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE));
|
||||
$datetime = new DateTime('now', $timezone);
|
||||
$offset = $timezone->getOffset($datetime);
|
||||
$minutes = $offset / 60;
|
||||
|
||||
return $minutes;
|
||||
}
|
||||
|
||||
public static function toSqlDate($date, $formatResult = true)
|
||||
{
|
||||
if (!$date) {
|
||||
|
13
readme.md
13
readme.md
@ -3,9 +3,13 @@
|
||||
|
||||
If you'd like to use our code to sell your own invoicing app email us for details about our affiliate program.
|
||||
|
||||
### Getting Started
|
||||
### Installation Options
|
||||
|
||||
To setup the site you can either use the [zip file](https://www.invoiceninja.com/knowledgebase/self-host/) (easier to run) or checkout the code from GitHub (easier to make changes).
|
||||
* [Zip - Free](https://www.invoiceninja.com/knowledgebase/self-host/)
|
||||
* [Bitnami - Free](https://bitnami.com/stack/invoice-ninja)
|
||||
* [Softaculous - $30](https://www.softaculous.com/apps/ecommerce/Invoice_Ninja)
|
||||
|
||||
### Getting Started
|
||||
|
||||
If you have any questions or comments please use our [support forum](https://www.invoiceninja.com/forums/forum/support/). For updates follow [@invoiceninja](https://twitter.com/invoiceninja) or join the [Facebook Group](https://www.facebook.com/invoiceninja).
|
||||
|
||||
@ -31,12 +35,11 @@ If you'd like to translate the site please use [caouecs/Laravel4-long](https://g
|
||||
* [Jeramy Simpson](https://github.com/JeramyMywork) - [MyWork](https://www.mywork.com.au)
|
||||
* [Sigitas Limontas](https://lt.linkedin.com/in/sigitaslimontas)
|
||||
|
||||
### Documentation
|
||||
|
||||
* [Self Host](https://www.invoiceninja.com/knowledgebase/self-host/)
|
||||
### Documentation
|
||||
* [Ubuntu and Apache](http://blog.technerdservices.com/index.php/2015/04/techpop-how-to-install-invoice-ninja-on-ubuntu-14-04/)
|
||||
* [Debian and Nginx](https://www.rosehosting.com/blog/install-invoice-ninja-on-a-debian-7-vps/)
|
||||
* [API Documentation](https://www.invoiceninja.com/knowledgebase/api-documentation/)
|
||||
* [User Guide](https://www.invoiceninja.com/user-guide/)
|
||||
* [Developer Guide](https://www.invoiceninja.com/knowledgebase/developer-guide/)
|
||||
|
||||
### Frameworks/Libraries
|
||||
|
@ -132,7 +132,6 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
var clients = {!! $clients !!};
|
||||
var timeLabels = {};
|
||||
@foreach (['hour', 'minute', 'second'] as $period)
|
||||
@ -225,25 +224,25 @@
|
||||
|
||||
self.startTime.pretty = ko.computed({
|
||||
read: function() {
|
||||
return self.startTime() ? moment.unix(self.startTime()).format('MMM D YYYY h:mm:ss a') : '';
|
||||
return self.startTime() ? moment.unix(self.startTime()).utcOffset({{ $minuteOffset }}).format('MMM D YYYY h:mm:ss a') : '';
|
||||
},
|
||||
write: function(data) {
|
||||
self.startTime(moment(data, 'MMM D YYYY h:mm:ss a').unix());
|
||||
self.startTime(moment(data, 'MMM D YYYY h:mm:ss a').utcOffset({{ $minuteOffset }}).unix());
|
||||
}
|
||||
});
|
||||
|
||||
self.endTime.pretty = ko.computed({
|
||||
read: function() {
|
||||
return self.endTime() ? moment.unix(self.endTime()).format('MMM D YYYY h:mm:ss a') : '';
|
||||
return self.endTime() ? moment.unix(self.endTime()).utcOffset({{ $minuteOffset }}).format('MMM D YYYY h:mm:ss a') : '';
|
||||
},
|
||||
write: function(data) {
|
||||
self.endTime(moment(data, 'MMM D YYYY h:mm:ss a').unix());
|
||||
self.endTime(moment(data, 'MMM D YYYY h:mm:ss a').utcOffset({{ $minuteOffset }}).unix());
|
||||
}
|
||||
});
|
||||
|
||||
self.setNow = function() {
|
||||
self.startTime(moment().unix());
|
||||
self.endTime(moment().unix());
|
||||
self.startTime(moment().utcOffset({{ $minuteOffset }}).unix());
|
||||
self.endTime(moment().utcOffset({{ $minuteOffset }}).unix());
|
||||
}
|
||||
|
||||
self.duration.pretty = ko.computed(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user