Skip to content

Commit bdb1184

Browse files
author
Théo David
committed
[Date] add: auto copy to clipboard inverted date
1 parent 5117075 commit bdb1184

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

lib/doliproject_functions.lib.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function toggleTaskFavorite($task_id, $user_id)
2020
$task->fetch($task_id);
2121
$task->fetchObjectLinked();
2222

23-
2423
if (!empty($task->linkedObjects) && key_exists('user', $task->linkedObjects)) {
2524
foreach($task->linkedObjects['user'] as $userLinked) {
2625
if ($userLinked->id == $user_id) {

view/inverteddate.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3+
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4+
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5+
* Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
6+
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
/**
23+
* \file htdocs/projet/activity/perday.php
24+
* \ingroup projet
25+
* \brief List activities of tasks (per day entry)
26+
*/
27+
28+
// Load Dolibarr environment
29+
$res = 0;
30+
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
31+
if ( ! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
32+
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
33+
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
34+
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
35+
if ( ! $res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
36+
if ( ! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
37+
// Try main.inc.php using relative path
38+
if ( ! $res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
39+
if ( ! $res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
40+
if ( ! $res) die("Include of main fails");
41+
42+
dol_print_date(dol_now());
43+
?>
44+
<script>
45+
var today = new Date();
46+
var dd = String(today.getDate()).padStart(2, '0');
47+
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
48+
var yyyy = today.getFullYear();
49+
50+
today = mm + '/' + dd + '/' + yyyy;
51+
let invertedDate = yyyy + mm + dd
52+
navigator.clipboard.writeText(invertedDate)
53+
document.write('Date copiée');
54+
</script>
55+
<?php

0 commit comments

Comments
 (0)