From c6aa77a9e6299cf3103f97274e573cc9938c1215 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff 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 @@
- +{if $show_client} + + + + +{/if} +{if $show_project} + + + + +{/if} @@ -17,7 +29,7 @@ - + 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} {/if} -{if $not_client} -{/if} {if $can_edit} @@ -33,13 +31,11 @@ {if $show_client} {/if} - {if $not_client} - {if $timesheet.approval_status == null} + {if $timesheet.approval_status == null} - {else} + {else} - {/if} {/if} {if $can_edit} @@ -48,11 +44,10 @@ {/foreach}
 Anuko Time Tracker 1.18.46.4791 | Copyright © Anuko | +  Anuko Time Tracker 1.18.46.4792 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} 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 @@ {$i18n.label.thing_name} (*): {$forms.timesheetForm.timesheet_name.control}
{$i18n.label.client}:{$forms.timesheetForm.client.control}
{$i18n.label.project}:{$forms.timesheetForm.project.control}
{$i18n.label.start_date} (*): {$forms.timesheetForm.start.control}
{$i18n.label.comment}:{$forms.timesheetForm.submitter_comment.control}{$forms.timesheetForm.comment.control}
{$i18n.label.client}{$i18n.label.submitted} {$i18n.label.approved}{$i18n.label.view}{$i18n.label.edit}{$timesheet.client_name|escape}{if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}{$i18n.label.view}
-{if $not_client} + - +


-{/if} {if $inactive_timesheets} @@ -63,10 +58,8 @@ {if $show_client} {/if} - {if $not_client} - {/if} {if $can_edit} @@ -78,13 +71,11 @@ {if $show_client} {/if} - {if $not_client} - {if $timesheet.approval_status == null} + {if $timesheet.approval_status == null} - {else} + {else} - {/if} {/if} {if $can_edit} @@ -93,11 +84,10 @@ {/foreach}
{$i18n.label.client}{$i18n.label.submitted} {$i18n.label.approved}{$i18n.label.view}{$i18n.label.edit}{$timesheet.client_name|escape}{if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}{$i18n.label.view}
- {if $not_client} +

- {/if} {/if} 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