// 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;
+ }
}
// '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.',
// '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.',
// 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.',
'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.',
'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.',
// '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.',
// 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?
// 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' => 'خطا در آپلود فایل.',
// 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.',
// 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.',
'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' => 'Σφάλμα φόρτωσης αρχείου.',
// 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' => 'שגיאה בהעלת קובץ',
// '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.',
// 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.',
// 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' => 'ファイルのアップロードのエラー。',
// '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' => '파일 업로드 오류.',
'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.',
// '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.',
// 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.',
// 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.',
// '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.',
// '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.',
'error.invoice_exists' => 'Счёт с таким номером уже есть.',
'error.role_exists' => 'Роль с таким рангом уже есть.',
'error.no_invoiceable_items' => 'Нет записей для включения в счёт.',
+'error.no_records' => 'Нет записей.',
'error.no_login' => 'Нет пользователя с таким логином.',
'error.no_groups' => 'Ваша база данных пуста. Войдите в систему как администратор и создайте новую группу.',
'error.upload' => 'Ошибка загрузки файла.',
// 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ý.',
// '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.',
// 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.',
// 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.',
// '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ı.',
// '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' => '上传文件出错。',
// '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' => '上傳文件出錯。',
<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>
<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>
</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>
{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>
{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}
</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%">
{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>
{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}
</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>
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))) {
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');