X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=expense_edit.php;h=db26f1b64d9dcfacd3909a1bcc62fedf501eee61;hb=b0e8ffd3af439b5dc6dd5044a46a906d9833932b;hp=1703c17626e8055f5a42c212aac5a7d736bad6c9;hpb=9e82b53fc5d8cb1e54b5fde774fa68a916f28b4c;p=timetracker.git diff --git a/expense_edit.php b/expense_edit.php index 1703c176..db26f1b6 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -33,7 +33,7 @@ import('DateAndTime'); import('ttExpenseHelper'); // Access check. -if (!ttAccessCheck(right_data_entry)) { +if (!ttAccessCheck(right_data_entry) || !$user->isPluginEnabled('ex')) { header('Location: access_denied.php'); exit(); } @@ -68,7 +68,7 @@ if ($request->isPost()) { $form = new Form('expenseItemForm'); // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) { +if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -93,7 +93,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); // Dropdown for clients if the clients plugin is enabled. - if (in_array('cl', explode(',', $user->plugins))) { + if ($user->isPluginEnabled('cl')) { $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) @@ -119,7 +119,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t 'empty'=>array(''=>$i18n->getKey('dropdown.select')))); } } -$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'item_name','style'=>'width: 250px;','value'=>$cl_item_name)); +$form->addInput(array('type'=>'textarea','maxlength'=>'800','name'=>'item_name','style'=>'width: 250px; height:'.NOTE_INPUT_HEIGHT.'px;','value'=>$cl_item_name)); $form->addInput(array('type'=>'text','maxlength'=>'40','name'=>'cost','style'=>'width: 100px;','value'=>$cl_cost)); $form->addInput(array('type'=>'datefield','name'=>'date','maxlength'=>'20','value'=>$cl_date)); // Hidden control for record id. @@ -131,7 +131,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getK if ($request->isPost()) { // Validate user input. - if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client) + if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client) $err->add($i18n->getKey('error.client')); if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { if (!$cl_project) $err->add($i18n->getKey('error.project')); @@ -140,14 +140,6 @@ if ($request->isPost()) { if (!ttValidFloat($cl_cost)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.cost')); if (!ttValidDate($cl_date)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.date')); - // Determine lock date. - $lock_interval = $user->lock_interval; - $lockdate = 0; - if ($lock_interval > 0) { - $lockdate = new DateAndTime(); - $lockdate->decDay($lock_interval); - } - // This is a new date for the expense item. $new_date = new DateAndTime($user->date_format, $cl_date); @@ -161,16 +153,17 @@ if ($request->isPost()) { // Save record. if ($request->getParameter('btn_save')) { // We need to: - // 1) Prohibit updating locked entries (that are in locked interval). - // 2) Prohibit saving unlocked entries into locked interval. + // 1) Prohibit updating locked entries (that are in locked range). + // 2) Prohibit saving unlocked entries into locked range. // Now, step by step. - // 1) Prohibit updating locked entries. - if($lockdate && $item_date->before($lockdate)) - $err->add($i18n->getKey('error.period_locked')); - // 2) Prohibit saving completed unlocked entries into locked interval. - if($err->no() && $lockdate && $new_date->before($lockdate)) - $err->add($i18n->getKey('error.period_locked')); + // 1) Prohibit saving locked entries in any form. + if ($user->isDateLocked($item_date)) + $err->add($i18n->getKey('error.range_locked')); + + // 2) Prohibit saving unlocked entries into locked range. + if ($err->no() && $user->isDateLocked($new_date)) + $err->add($i18n->getKey('error.range_locked')); // Now, an update. if ($err->no()) { @@ -185,8 +178,8 @@ if ($request->isPost()) { // Save as new record. if ($request->getParameter('btn_copy')) { // We need to prohibit saving into locked interval. - if($lockdate && $new_date->before($lockdate)) - $err->add($i18n->getKey('error.period_locked')); + if ($user->isDateLocked($new_date)) + $err->add($i18n->getKey('error.range_locked')); // Now, a new insert. if ($err->no()) { @@ -203,7 +196,7 @@ if ($request->isPost()) { header("Location: expense_delete.php?id=$cl_id"); exit(); } -} // POST +} // isPost $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list);