From c6aa77a9e6299cf3103f97274e573cc9938c1215 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff <support@anuko.com> Date: Thu, 28 Feb 2019 16:04:17 +0000 Subject: [PATCH] A bit more progress on timesheet coding. --- WEB-INF/lib/ttTimesheetHelper.class.php | 74 +++++++++++++++++++++++++ WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 2 + WEB-INF/resources/de.lang.php | 2 + WEB-INF/resources/en.lang.php | 1 + WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 2 + WEB-INF/resources/fa.lang.php | 2 + WEB-INF/resources/fi.lang.php | 2 + WEB-INF/resources/fr.lang.php | 2 + WEB-INF/resources/gr.lang.php | 2 + WEB-INF/resources/he.lang.php | 2 + WEB-INF/resources/hu.lang.php | 2 + WEB-INF/resources/it.lang.php | 2 + WEB-INF/resources/ja.lang.php | 1 + WEB-INF/resources/ko.lang.php | 1 + WEB-INF/resources/nl.lang.php | 2 + WEB-INF/resources/no.lang.php | 1 + WEB-INF/resources/pl.lang.php | 2 + WEB-INF/resources/pt-br.lang.php | 2 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 1 + WEB-INF/resources/sk.lang.php | 2 + WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 2 + WEB-INF/resources/sv.lang.php | 2 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 1 + WEB-INF/resources/zh-tw.lang.php | 1 + WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/timesheet_add.tpl | 14 ++++- WEB-INF/templates/timesheets.tpl | 24 +++----- timesheet_add.php | 51 ++++++++++++----- 35 files changed, 179 insertions(+), 32 deletions(-) diff --git a/WEB-INF/lib/ttTimesheetHelper.class.php b/WEB-INF/lib/ttTimesheetHelper.class.php index 636504e3..e14bbd7b 100644 --- a/WEB-INF/lib/ttTimesheetHelper.class.php +++ b/WEB-INF/lib/ttTimesheetHelper.class.php @@ -408,4 +408,78 @@ class ttTimesheetHelper { // TODO: send email to submitter here... return true; } + + // The timesheetItemsExist determines whether tt_log records exist in the specified period + // for inclusion in a new timesheet. + static function timesheetItemsExist($fields) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $client_id = (int) $fields['client_id']; + + $start_date = new DateAndTime($user->date_format, $fields['start_date']); + $start = $start_date->toString(DB_DATEFORMAT); + + $end_date = new DateAndTime($user->date_format, $fields['end_date']); + $end = $end_date->toString(DB_DATEFORMAT); + + if (isset($fields['project_id'])) $project_id = (int) $fields['project_id']; + + // Our query is different depending on tracking mode. + if (MODE_TIME == $user->getTrackingMode()) { + // In "time only" tracking mode there is a single user rate. + $sql = "select count(*) as num from tt_log l, tt_users u". + " where l.status = 1 and l.client_id = $client_id and l.invoice_id is null". + " and l.date >= ".$mdb2->quote($start)." and l.date <= ".$mdb2->quote($end). + " and l.user_id = u.id and l.group_id = $group_id and l.org_id = $org_id". + " and l.billable = 1"; // l.billable * u.rate * time_to_sec(l.duration)/3600 > 0 // See explanation below. + } else { + // sql part for project id. + if ($project_id) $project_part = " and l.project_id = $project_id"; + + // When we have projects, rates are defined for each project in tt_user_project_binds table. + $sql = "select count(*) as num from tt_log l, tt_user_project_binds upb". + " where l.status = 1 and l.client_id = $client_id $project_part and l.invoice_id is null". + " and l.date >= ".$mdb2->quote($start)." and l.date <= ".$mdb2->quote($end). + " and l.group_id = $group_id and l.org_id = $org_id". + " and upb.user_id = l.user_id and upb.project_id = l.project_id". + " and l.billable = 1"; // l.billable * upb.rate * time_to_sec(l.duration)/3600 > 0 + // Users with a lot of clients and projects (Jaro) may forget to set user rates properly. + // Specifically, user rate may be set to 0 on a project, by mistake. This leads to error.no_invoiceable_items + // and increased support cost. Commenting out allows us to include 0 cost items in invoices so that + // the problem becomes obvious. + + // TODO: If the above turns out useful, rework the query to simplify it by removing left join. + } + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['num']) { + return true; + } + } + + if ($user->isPluginEnabled('ex')) { + // sql part for project id. + if ($project_id) $project_part = " and ei.project_id = $project_id"; + + $sql = "select count(*) as num from tt_expense_items ei". + " where ei.client_id = $client_id $project_part and ei.invoice_id is null". + " and ei.date >= ".$mdb2->quote($start)." and ei.date <= ".$mdb2->quote($end). + " and ei.group_id = $group_id and ei.org_id = $org_id". + " and ei.cost <> 0 and ei.status = 1"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['num']) { + return true; + } + } + } + + return false; + } } diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index d4d24c72..34ba35f6 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -103,6 +103,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', 'error.no_groups' => 'La seva base de dades està buida. Iniciï sessió com a administrador i creï un nou grup.', 'error.upload' => 'Error pujant l\\\'arxiu.', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 2ca15cc9..e43d2cc0 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -105,6 +105,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', 'error.no_groups' => 'VaÅ¡e databáze je prázdná. PÅihlaÅ¡te se jako admin a vytvoÅte nový tým.', // TODO: replace "team" with "group". 'error.upload' => 'Chyba pÅenosu souboru.', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index de4813f6..1247264e 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -96,6 +96,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Der er ingen fakturerbar emner.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Der finde ingen bruger med dette brugernavn.', 'error.no_groups' => 'Din database er tom, log ind som administrator og lav et nyt team.', // TODO: replace "team" with "group". 'error.upload' => 'Fil upload problem.', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index a14e3452..72f4b5cb 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -90,6 +90,8 @@ $i18n_key_words = array( 'error.invoice_exists' => 'Rechnung mit dieser Nummer existiert bereits.', 'error.role_exists' => 'Rolle mit diesem Rang existiert bereits.', 'error.no_invoiceable_items' => 'Keine Einträge zur Rechnungsstellung gefunden.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Benutzer mit diesen Anmeldedaten nicht vorhanden.', 'error.no_groups' => 'Die Datenbank ist leer. Als Administrator anmelden und ein neues Gruppe erzeugen.', 'error.upload' => 'Fehler beim hochladen einer Datei.', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index b6f0054b..6701a4c3 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -89,6 +89,7 @@ $i18n_key_words = array( 'error.invoice_exists' => 'Invoice with this number already exists.', 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'There are no invoiceable items.', +'error.no_records' => 'There are no records.', 'error.no_login' => 'No user with this login.', 'error.no_groups' => 'Your database is empty. Login as admin and create a new group.', 'error.upload' => 'File upload error.', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 99c4431d..7a2bf9a9 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -101,6 +101,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', 'error.no_groups' => 'Su base de datos esta vacÃa. Inicie sesión como administrador y cree un nuevo grupo.', 'error.upload' => 'Error subiendo el archivo.', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 4f40c7e7..6f37883e 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -103,6 +103,8 @@ $i18n_key_words = array( // Google auto-translates below as "No billable invoices found." which seems wrong. // 'error.no_invoiceable_items' => 'Arveldatavaid arveid ei leitud.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Sellise tunnusega kasutajat ei ole.', // TODO: Improve translation of error.no_groups. Replace meeskond with grupp? diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 566b5081..5a6c6aa8 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -101,6 +101,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Ø¢ÛØªÙ Û Ø¬Ùت ÙاکتÙر کرد٠ÙجÙد Ùدارد.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Ú©Ø§Ø±Ø¨Ø±Û Ø¨Ø§ اÛÙ ÙØ§Ù Ú©Ø§Ø±Ø¨Ø±Û Ù ÙجÙد ÙÛست.', 'error.no_groups' => 'پاÛگا٠داد٠ش٠ا خاÙÛ Ø§Ø³Øª با کاربر admin Ùارد Ø´ÙÛد ٠تÛ٠اÛجاد Ú©ÙÛد.', // TODO: replace "team" with "group". 'error.upload' => 'خطا در آپÙÙد ÙاÛÙ.', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 226e8496..9f577f3d 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -98,6 +98,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Ei laskutettavia syötteitä.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Tuntematon käyttäjänimi.', 'error.no_groups' => 'Tietokanta on tyhjä. Kirjaudu ylläpitäjänä ja luo uusi tiimi.', // TODO: replace "team" with "group". 'error.upload' => 'Virhe tiedoston lataus.', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index a90cc042..be5c9d22 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -96,6 +96,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Il n\\\'y a pas d\\\'éléments à facturer.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Aucun utilisateur avec cet identifiant.', 'error.no_groups' => 'Votre base de données est vide. Connectez-vous comme administrateur et créez une nouvelle équipe.', // TODO: replace "team" with "group". 'error.upload' => 'Erreur de chargement du fichier.', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index 7257a33f..28898273 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -91,6 +91,8 @@ $i18n_key_words = array( 'error.invoice_exists' => 'Το ÏιμολÏγιο με Î±Ï ÏÏν Ïον αÏÎ¹Î¸Î¼Ï Ï ÏάÏÏει ήδη.', 'error.role_exists' => 'Î ÏÏÎ»Î¿Ï Ïε Î±Ï Ïή Ïη ÏειÏά Ï ÏάÏÏει ήδη.', 'error.no_invoiceable_items' => 'Îεν Ï ÏάÏÏÎ¿Ï Î½ ÏÏοιÏεία ÏÏÎ¿Ï ÏιμολÏγηÏη.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Îεν Ï ÏάÏÏει ÏÏήÏÏÎ·Ï Î¼Îµ Î±Ï Ïά Ïα ÏÏοιÏεία.', 'error.no_groups' => 'ΠβάÏη δεδομÎνÏν ÏÎ±Ï ÎµÎ¯Î½Î±Î¹ κενή. Î£Ï Î½Î´ÎµÎ¸ÎµÎ¯Ïε ÏÏ Î´Î¹Î±ÏειÏιÏÏÎ®Ï ÎºÎ±Î¹ Î´Î·Î¼Î¹Î¿Ï ÏγήÏÏε μια νÎα ομάδα.', 'error.upload' => 'ΣÏάλμα ÏÏÏÏÏÏÎ·Ï Î±ÏÏÎµÎ¯Î¿Ï .', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 47c06c85..d9ab0d1c 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -112,6 +112,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => '××× ×¤×¨×××× ×××××', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => '×שת×ש ×× ××× × ×§×××', 'error.no_groups' => '×ס×ס ×× ×ª×× ×× ×©×× ×¨×ק. ×ת××ר ××× ×× ×צ×ר צ××ת ××ש', // TODO: replace "team" with "group". 'error.upload' => 'ש×××× ×××¢×ת ק×××¥', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index bd699aca..38ec28cb 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -103,6 +103,8 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', // 'error.no_groups' => 'Your database is empty. Login as admin and create a new group.', 'error.upload' => 'File feltöltési hiba.', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 351c1cd6..e4d328e6 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -95,6 +95,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Non ci sono voci fatturabili.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Non esiste un utente con questo username.', 'error.no_groups' => 'Il database è vuoto. Loggati come amministratore e crea un nuovo gruppo.', 'error.upload' => 'Errore di caricamento file.', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 53f1c506..3f0db6e0 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -104,6 +104,7 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'ãã®ãã°ã¤ã³ã¨é¢é£ãããã¦ã¼ã¶ã¼ã¯ãã¾ããã', 'error.no_groups' => 'ããªãã®ãã¼ã¿ãã¼ã¹ã¯ç©ºãã¦ãã¾ãã管çè ã«ãã°ã¤ã³ãã¦æ°è¦ãã¼ã ãä½æãã¦ãã ããã', // TODO: replace "team" with "group". 'error.upload' => 'ãã¡ã¤ã«ã®ã¢ãããã¼ãã®ã¨ã©ã¼ã', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index d8da0d81..d59c1634 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -103,6 +103,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', 'error.no_login' => '본 ë¡ê·¸ì¸ê³¼ ì°ê³ë ì¬ì©ìê° ììµëë¤.', 'error.no_groups' => 'ë¹ì ì ë°ì´í°ë² ì´ì¤ë ë¹ì´ììµëë¤. ê´ë¦¬ìë¡ ë¡ê·¸ì¸íì¬ ìë¡ì´ íì ìì±íììì¤.', // TODO: replace "team" with "group". 'error.upload' => 'íì¼ ì ë¡ë ì¤ë¥.', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 848e0f34..8aa557e6 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -89,6 +89,8 @@ $i18n_key_words = array( 'error.invoice_exists' => 'Dit nummer is al eens toegekend aan een factuur.', 'error.role_exists' => 'Een rol met deze rangorde bestaat al.', 'error.no_invoiceable_items' => 'Er zijn geen factuureerbare onderdelen.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Een medewerker met deze inlognaam bestaat niet.', 'error.no_groups' => 'Uw database is leeg. Meld je aan als admin en maak een nieuw groep.', 'error.upload' => 'Fout bij het uploaden van het bestand.', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index 1474cac3..cdcc05de 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -104,6 +104,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Det er ingen bruker med dette brukernavnet.', 'error.no_groups' => 'Databasen din er tom. Logg inn som admin og opprett et nytt team.', // TODO: replace "team" with "group". 'error.upload' => 'Feil med lasting av fil.', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 94a094e8..11166236 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -99,6 +99,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Brak przedmiotów do faktury.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Użytkownik o takiej nazwie nie istnieje.', 'error.no_groups' => 'Twoja baza danych jest pusta. Zaloguj siÄ jako administrator i stwórz nowy zespóÅ.', // TODO: replace "team" with "group". 'error.upload' => 'BÅÄ d podczas wysyÅania pliku.', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index a10fe4c6..bfeb7e72 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -97,6 +97,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Não há items faturáveis.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Não há usuário com este login.', 'error.no_groups' => 'Sua base de dados está vazia. Entre como admin e crie uma equipe nova.', // TODO: replace "team" with "group". 'error.upload' => 'Erro no envio do arquivo.', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 9da1e358..b9b746c9 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -101,6 +101,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', // 'error.no_groups' => 'Your database is empty. Login as admin and create a new group.', // 'error.upload' => 'File upload error.', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 70fc0ac1..050bddef 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -107,6 +107,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', 'error.no_groups' => 'Baza de date este goala. Intra ca admin si adauga o noua echipa.', // TODO: replace "team" with "group". 'error.upload' => 'Eroare la upload-ul fisierului.', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index 6c1daa24..2d04e8f9 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -88,6 +88,7 @@ $i18n_key_words = array( 'error.invoice_exists' => 'СÑÑÑ Ñ Ñаким номеÑом Ñже еÑÑÑ.', 'error.role_exists' => 'Ð Ð¾Ð»Ñ Ñ Ñаким Ñангом Ñже еÑÑÑ.', 'error.no_invoiceable_items' => 'ÐÐµÑ Ð·Ð°Ð¿Ð¸Ñей Ð´Ð»Ñ Ð²ÐºÐ»ÑÑÐµÐ½Ð¸Ñ Ð² ÑÑÑÑ.', +'error.no_records' => 'ÐÐµÑ Ð·Ð°Ð¿Ð¸Ñей.', 'error.no_login' => 'ÐÐµÑ Ð¿Ð¾Ð»ÑзоваÑÐµÐ»Ñ Ñ Ñаким логином.', 'error.no_groups' => 'ÐаÑа база даннÑÑ Ð¿ÑÑÑа. ÐойдиÑе в ÑиÑÑÐµÐ¼Ñ ÐºÐ°Ðº админиÑÑÑаÑÐ¾Ñ Ð¸ ÑоздайÑе новÑÑ Ð³ÑÑппÑ.', 'error.upload' => 'ÐÑибка загÑÑзки Ñайла.', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index a1253d9b..0ed07029 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -101,6 +101,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Neexistujú položky, ktoré by bolo možné fakturovaÅ¥.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Neexistuje použÃvateľ s týmto prihlasovacÃm menom.', 'error.no_groups' => 'VaÅ¡a databáza je prázdna. Prihláste sa ako admin a vytvorte nový tÃm.', // TODO: replace "team" with "group". 'error.upload' => 'Prenos súboru bol neúspeÅ¡ný.', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index 68e2df6a..e9388450 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -98,6 +98,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', // 'error.no_groups' => 'Your database is empty. Login as admin and create a new group.', // 'error.upload' => 'File upload error.', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 8976bda5..5d2b9f88 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -96,6 +96,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Nema stavke za naplatu.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Nema korisnika pod ovom prijavom', 'error.no_groups' => 'VaÅ¡a baza podataka je prazna. Prijavite se kao administrator i napravite novi tim.', // TODO: replace "team" with "group". 'error.upload' => 'GreÅ¡ka pri otpremanju podatka.', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 715481d3..ba2f6665 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -95,6 +95,8 @@ $i18n_key_words = array( // TODO: translate the following. // 'error.role_exists' => 'Role with this rank already exists.', 'error.no_invoiceable_items' => 'Det finns inga debiterbara tidsregistreringar.', +// TODO: translate the following. +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'Det finns ingen användare med det här användarnamnet.', 'error.no_groups' => 'Databasen är tom. Logga in som administratör och skapa en ny grupp.', 'error.upload' => 'Ett fel uppstod när filen laddades upp.', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index eb92614a..22e87237 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -110,6 +110,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', // 'error.no_login' => 'No user with this login.', 'error.no_groups' => 'Veritabanınız boÅ. Yeni bir ekip yaratmak için yönetici olarak giriÅ yapın.', // TODO: replace "team" with "group". 'error.upload' => 'Dosya yükleme hatası.', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index d31db325..a1583eb4 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -97,6 +97,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', 'error.no_login' => '没æ该ç»å½ä¿¡æ¯çç¨æ·ã', 'error.no_groups' => 'æ¨çæ°æ®åºæ²¡æä»»ä½è®°å½ã请以管çå身份ç»å½å¹¶å建ä¸ä¸ªæ°å¢éã', // TODO: replace "team" with "group". 'error.upload' => 'ä¸ä¼ æ件åºéã', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index ca0dad53..42f15202 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -101,6 +101,7 @@ $i18n_key_words = array( // 'error.invoice_exists' => 'Invoice with this number already exists.', // 'error.role_exists' => 'Role with this rank already exists.', // 'error.no_invoiceable_items' => 'There are no invoiceable items.', +// 'error.no_records' => 'There are no records.', 'error.no_login' => 'æ²æ該ç»éè³è¨ç使ç¨è ã', 'error.no_groups' => 'æ¨çè³æ庫æ²æä»»ä½è¨éãè«ä»¥ç®¡çå¡èº«ä»½ç»é並åµå»ºä¸åæ°åéã', // TODO: replace "team" with "group". 'error.upload' => 'ä¸å³æ件åºé¯ã', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 5b3b25e2..a3dbfb19 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@ <br> <table cellspacing="0" cellpadding="4" width="100%" border="0"> <tr> - <td align="center"> Anuko Time Tracker 1.18.46.4791 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> | + <td align="center"> Anuko Time Tracker 1.18.46.4792 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> | <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> | <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> | <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a> diff --git a/WEB-INF/templates/timesheet_add.tpl b/WEB-INF/templates/timesheet_add.tpl index e24a36b3..f4becf7f 100644 --- a/WEB-INF/templates/timesheet_add.tpl +++ b/WEB-INF/templates/timesheet_add.tpl @@ -7,6 +7,18 @@ <td align="right">{$i18n.label.thing_name} (*):</td> <td>{$forms.timesheetForm.timesheet_name.control}</td> </tr> +{if $show_client} + <tr> + <td align="right">{$i18n.label.client}:</td> + <td>{$forms.timesheetForm.client.control}</td> + </tr> +{/if} +{if $show_project} + <tr> + <td align="right">{$i18n.label.project}:</td> + <td>{$forms.timesheetForm.project.control}</td> + </tr> +{/if} <tr> <td align="right">{$i18n.label.start_date} (*):</td> <td>{$forms.timesheetForm.start.control}</td> @@ -17,7 +29,7 @@ </tr> <tr> <td align = "right">{$i18n.label.comment}:</td> - <td>{$forms.timesheetForm.submitter_comment.control}</td> + <td>{$forms.timesheetForm.comment.control}</td> </tr> <tr> <td></td> diff --git a/WEB-INF/templates/timesheets.tpl b/WEB-INF/templates/timesheets.tpl index af65d14b..df4782b6 100644 --- a/WEB-INF/templates/timesheets.tpl +++ b/WEB-INF/templates/timesheets.tpl @@ -18,10 +18,8 @@ {if $show_client} <td class="tableHeader">{$i18n.label.client}</td> {/if} -{if $not_client} <td class="tableHeader">{$i18n.label.submitted}</td> <td class="tableHeader">{$i18n.label.approved}</td> -{/if} <td class="tableHeader">{$i18n.label.view}</td> {if $can_edit} <td class="tableHeader">{$i18n.label.edit}</td> @@ -33,13 +31,11 @@ {if $show_client} <td>{$timesheet.client_name|escape}</td> {/if} - {if $not_client} <td>{if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td> - {if $timesheet.approval_status == null} + {if $timesheet.approval_status == null} <td></td> - {else} + {else} <td>{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td> - {/if} {/if} <td><a href="timesheet_view.php?id={$timesheet.id}">{$i18n.label.view}</a></td> {if $can_edit} @@ -48,11 +44,10 @@ </tr> {/foreach} </table> -{if $not_client} + <table width="100%"> - <tr><td align="center"><br><form><input type="button" onclick="chLocation('reports.php');" value="{$i18n.button.add}"></form></td></tr> + <tr><td align="center"><br><form><input type="button" onclick="chLocation('timesheet_add.php');" value="{$i18n.button.add}"></form></td></tr> </table> -{/if} {if $inactive_timesheets} <table cellspacing="1" cellpadding="3" border="0" width="100%"> @@ -63,10 +58,8 @@ {if $show_client} <td class="tableHeader">{$i18n.label.client}</td> {/if} - {if $not_client} <td class="tableHeader">{$i18n.label.submitted}</td> <td class="tableHeader">{$i18n.label.approved}</td> - {/if} <td class="tableHeader">{$i18n.label.view}</td> {if $can_edit} <td class="tableHeader">{$i18n.label.edit}</td> @@ -78,13 +71,11 @@ {if $show_client} <td>{$timesheet.client_name|escape}</td> {/if} - {if $not_client} <td>{if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td> - {if $timesheet.approval_status == null} + {if $timesheet.approval_status == null} <td></td> - {else} + {else} <td>{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td> - {/if} {/if} <td><a href="timesheet_view.php?id={$timesheet.id}">{$i18n.label.view}</a></td> {if $can_edit} @@ -93,11 +84,10 @@ </tr> {/foreach} </table> - {if $not_client} + <table width="100%"> <tr><td align="center"><br><form><input type="button" onclick="chLocation('reports.php');" value="{$i18n.button.add}"></form></td></tr> </table> - {/if} {/if} </td> </tr> diff --git a/timesheet_add.php b/timesheet_add.php index 1ab4b704..e8eb5659 100644 --- a/timesheet_add.php +++ b/timesheet_add.php @@ -43,31 +43,56 @@ if (!$user->isPluginEnabled('ts')) { if ($request->isPost()) { $cl_name = trim($request->getParameter('timesheet_name')); - $cl_comment = trim($request->getParameter('submitter_comment')); - - // Report settings are stored in session bean before we get here. - $bean = new ActionForm('reportBean', new Form('reportForm'), $request); - $bean->loadBean(); + $cl_client = $request->getParameter('client'); + $cl_project = $request->getParameter('project'); + $cl_start = $request->getParameter('start'); + $cl_finish = $request->getParameter('finish'); + $cl_comment = trim($request->getParameter('comment')); } +$user_id = $user->getUser(); + $form = new Form('timesheetForm'); $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'timesheet_name','style'=>'width: 250px;','value'=>$cl_name)); +// Dropdown for clients if the clients plugin is enabled. +$showClient = $user->isPluginEnabled('cl'); +if ($showClient) { + $clients = ttGroupHelper::getActiveClients(); + $form->addInput(array('type'=>'combobox','name'=>'client','style'=>'width: 250px;','data'=>$clients,'datakeys'=>array('id','name'),'value'=>$cl_client,'empty'=>array(''=>$i18n->get('dropdown.select')))); +} +// Dropdown for projects. +$showProject = MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode(); +if ($showProject) { + $projects = $user->getAssignedProjects(); + $form->addInput(array('type'=>'combobox','name'=>'project','style'=>'width: 250px;','data'=>$projects,'datakeys'=>array('id','name'),'value'=>$cl_project,'empty'=>array(''=>$i18n->get('dropdown.all')))); +} $form->addInput(array('type'=>'datefield','maxlength'=>'20','name'=>'start','value'=>$cl_start)); $form->addInput(array('type'=>'datefield','maxlength'=>'20','name'=>'finish','value'=>$cl_finish)); - -$form->addInput(array('type'=>'textarea','name'=>'submitter_comment','style'=>'width: 250px; height: 40px;','value'=>$cl_comment)); +$form->addInput(array('type'=>'textarea','name'=>'comment','style'=>'width: 250px; height: 40px;','value'=>$cl_comment)); $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); if ($request->isPost()) { // Validate user input. if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); + if (!ttValidDate($cl_start)) $err->add($i18n->get('error.field'), $i18n->get('label.start_date')); + if (!ttValidDate($cl_finish)) $err->add($i18n->get('error.field'), $i18n->get('label.end_date')); if (!ttValidString($cl_comment, true)) $err->add($i18n->get('error.field'), $i18n->get('label.comment')); + if ($err->no() && ttTimesheetHelper::getTimesheetByName($cl_name, $user_id)) $err->add($i18n->get('error.object_exists')); + $fields = array('user_id' => $user_id, + 'name' => $cl_name, + 'client_id' => $cl_client, + 'project_id' => $cl_project, + 'start_date' => $cl_start, + 'end_date' => $cl_finish, + 'comment' => $cl_comment); + if ($err->no() && !ttTimesheetHelper::timesheetItemsExist($fields)) $err->add($i18n->get('error.no_records')); + // Finished validating user input. + /* if ($err->no()) { - $user_id = $bean->getDetachedAttribute('timesheet_user_id'); - if (!ttTimesheetHelper::getTimesheetByName($cl_name, $user_id)) { - if (ttTimesheetHelper::insert(array('user_id' => $user_id, + // TODO: use $fields. + if (ttTimesheetHelper::insert(array('user_id' => $user_id, 'client_id' => $bean->getAttribute('client'), 'name' => $cl_name, 'comment' => $cl_comment))) { @@ -75,13 +100,13 @@ if ($request->isPost()) { exit(); } else $err->add($i18n->get('error.db')); - } else - $err->add($i18n->get('error.object_exists')); - } + } */ } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.timesheetForm.timesheet_name.focus()"'); +$smarty->assign('show_client', $showClient); +$smarty->assign('show_project', $showProject); $smarty->assign('title', $i18n->get('title.add_timesheet')); $smarty->assign('content_page_name', 'timesheet_add.tpl'); $smarty->display('index.tpl'); -- 2.20.1