adds delete button to edit pages (#10)
authorTaylor Hurt <taylor.a.hurt@gmail.com>
Tue, 30 Aug 2016 22:39:07 +0000 (18:39 -0400)
committeranuko <support@anuko.com>
Tue, 30 Aug 2016 22:39:07 +0000 (22:39 +0000)
WEB-INF/templates/mobile/client_edit.tpl
WEB-INF/templates/mobile/project_edit.tpl
WEB-INF/templates/mobile/task_edit.tpl
WEB-INF/templates/mobile/user_edit.tpl
mobile/client_edit.php
mobile/expense_delete.php
mobile/project_edit.php
mobile/task_edit.php
mobile/user_edit.php

index 578aa64..5cee575 100644 (file)
@@ -32,7 +32,7 @@
 {/if}
         <tr><td>&nbsp;</td></tr>
         <tr>
-          <td colspan="2" align="center" height="50">{$forms.clientForm.btn_save.control} {$forms.clientForm.btn_copy.control}</td>
+          <td colspan="2" align="center" height="50">{$forms.clientForm.btn_save.control} {$forms.clientForm.btn_copy.control} {$forms.clientForm.btn_delete.control}</td>
         </tr>
       </table>
     </td>
index c94e475..b8266f4 100644 (file)
@@ -36,7 +36,7 @@
           <td>&nbsp;</td>
         </tr>
         <tr>
-          <td colspan="2" align="center" height="50">{$forms.projectForm.btn_save.control} {$forms.projectForm.btn_copy.control}</td>
+          <td colspan="2" align="center" height="50">{$forms.projectForm.btn_save.control} {$forms.projectForm.btn_copy.control} {$forms.projectForm.btn_delete.control}</td>
         </tr>
       </table>
     </td>
index 5af8d93..f913628 100644 (file)
@@ -28,7 +28,7 @@
           <td>&nbsp;</td>
         </tr>
         <tr>
-          <td colspan="2" align="center" height="50">{$forms.taskForm.btn_save.control} {$forms.taskForm.btn_copy.control}</td>
+          <td colspan="2" align="center" height="50">{$forms.taskForm.btn_save.control} {$forms.taskForm.btn_copy.control} {$forms.taskForm.btn_delete.control}</td>
         </tr>
       </table>
     </td>
index 7f81ca0..cbfded7 100644 (file)
@@ -105,7 +105,7 @@ function handleClientControl() {
       <td colspan="2" align="center">{$i18n.label.required_fields}</td>
     </tr>
     <tr>
-      <td colspan="2" align="center" height="50">{$forms.userForm.btn_submit.control}</td>
+      <td colspan="2" align="center" height="50">{$forms.userForm.btn_submit.control} {$forms.userForm.btn_delete.control}</td>
     </tr>
   </table>
 </table>
index 2c553da..cd6266d 100644 (file)
@@ -70,6 +70,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t
   $form->addInput(array('type'=>'checkboxgroup','name'=>'projects','data'=>$projects,'datakeys'=>array('id','name'),'layout'=>'H','value'=>$cl_projects));
 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
 $form->addInput(array('type'=>'submit','name'=>'btn_copy','value'=>$i18n->getKey('button.copy')));
+$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
 
 if ($request->isPost()) {
   // Validate user input.
@@ -112,6 +113,11 @@ if ($request->isPost()) {
       } else
         $err->add($i18n->getKey('error.client_exists'));
     }
+    
+    if ($request->getParameter('btn_delete')) {
+      header("Location: client_delete.php?id=$cl_id");
+      exit();
+    }
   }
 } // isPost
 
index 38800b6..b027bd9 100644 (file)
@@ -26,7 +26,7 @@
 // | https://www.anuko.com/time_tracker/credits.htm
 // +----------------------------------------------------------------------+
 
-require_once('initialize.php');
+require_once('../initialize.php');
 import('form.Form');
 import('DateAndTime');
 import('ttExpenseHelper');
@@ -74,5 +74,5 @@ $form->addInput(array('type'=>'submit','name'=>'cancel_button','value'=>$i18n->g
 $smarty->assign('expense_item', $expense_item);
 $smarty->assign('forms', array($form->getName() => $form->toArray()));
 $smarty->assign('title', $i18n->getKey('title.delete_expense'));
-$smarty->assign('content_page_name', 'expense_delete.tpl');
-$smarty->display('index.tpl');
+$smarty->assign('content_page_name', 'mobile/expense_delete.tpl');
+$smarty->display('mobile/index.tpl');
index c1eb180..490a11e 100644 (file)
@@ -81,6 +81,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
   $form->addInput(array('type'=>'checkboxgroup','name'=>'tasks','data'=>$all_tasks,'layout'=>'H','value'=>$cl_tasks));
 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
 $form->addInput(array('type'=>'submit','name'=>'btn_copy','value'=>$i18n->getKey('button.copy')));
+$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
 
 if ($request->isPost()) {
   // Validate user input.
@@ -123,6 +124,11 @@ if ($request->isPost()) {
       } else
         $err->add($i18n->getKey('error.project_exists'));
     }
+    
+    if ($request->getParameter('btn_delete')) {
+      header("Location: project_delete.php?id=$cl_project_id");
+      exit();
+    }
   }
 } // isPost
 
index fd5b35b..248167f 100644 (file)
@@ -65,6 +65,8 @@ $form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status,
 $form->addInput(array('type'=>'checkboxgroup','name'=>'projects','layout'=>'H','data'=>$projects,'datakeys'=>array('id','name'),'value'=>$cl_projects));
 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
 $form->addInput(array('type'=>'submit','name'=>'btn_copy','value'=>$i18n->getKey('button.copy')));
+$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
+
 
 if ($request->isPost()) {
   // Validate user input.
@@ -105,6 +107,11 @@ if ($request->isPost()) {
       } else
         $err->add($i18n->getKey('error.task_exists'));
     }
+    
+    if ($request->getParameter('btn_delete')) {
+      header("Location: task_delete.php?id=$cl_task_id");
+      exit();
+    }
   }
 } // isPost
 
index 156e320..6077a13 100644 (file)
@@ -161,67 +161,75 @@ $form->addInputElement($table);
 
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$user_id));
 $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.save')));
+$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
 
 if ($request->isPost()) {
-  // Validate user input.
-  if (!ttValidString($cl_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name'));
-  if (!ttValidString($cl_login)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
-  if (!$auth->isPasswordExternal() && ($cl_password1 || $cl_password2)) {
-    if (!ttValidString($cl_password1)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
-    if (!ttValidString($cl_password2)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
-    if ($cl_password1 !== $cl_password2)
-      $err->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
-  }
-  if (!ttValidEmail($cl_email, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
-  if (!ttValidFloat($cl_rate, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.users.default_rate'));
-
-  if ($err->no()) {
-    $existing_user = ttUserHelper::getUserByLogin($cl_login);
-    if (!$existing_user || ($user_id == $existing_user['id'])) {
-
-      $fields = array(
-        'name' => $cl_name,
-        'login' => $cl_login,
-        'password' => $cl_password1,
-        'email' => $cl_email,
-        'status' => $cl_status,
-        'rate' => $cl_rate,
-        'projects' => $assigned_projects);
-      if (right_assign_roles & $user->rights) {
-        $fields['role'] = $cl_role;
-        $fields['client_id'] = $cl_client_id;
-      }
-
-      if (ttUserHelper::update($user_id, $fields)) {
-
-        // If our own login changed, set new one in cookie to remember it.
-        if (($user_id == $user->id) && ($user->login != $cl_login)) {
-          setcookie('tt_login', $cl_login, time() + COOKIE_EXPIRE, '/');
-        }
-
-        // In case the name of the "on behalf" user has changed - set it in session.
-        if (($user->behalf_id == $user_id) && ($user->behalf_name != $cl_name)) {
-          $_SESSION['behalf_name'] = $cl_name;
+  if ($request->getParameter('btn_submit')) {
+    // Validate user input.
+    if (!ttValidString($cl_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name'));
+    if (!ttValidString($cl_login)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
+    if (!$auth->isPasswordExternal() && ($cl_password1 || $cl_password2)) {
+      if (!ttValidString($cl_password1)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
+      if (!ttValidString($cl_password2)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
+      if ($cl_password1 !== $cl_password2)
+        $err->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
+    }
+    if (!ttValidEmail($cl_email, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
+    if (!ttValidFloat($cl_rate, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.users.default_rate'));
+  
+    if ($err->no()) {
+      $existing_user = ttUserHelper::getUserByLogin($cl_login);
+      if (!$existing_user || ($user_id == $existing_user['id'])) {
+  
+        $fields = array(
+          'name' => $cl_name,
+          'login' => $cl_login,
+          'password' => $cl_password1,
+          'email' => $cl_email,
+          'status' => $cl_status,
+          'rate' => $cl_rate,
+          'projects' => $assigned_projects);
+        if (right_assign_roles & $user->rights) {
+          $fields['role'] = $cl_role;
+          $fields['client_id'] = $cl_client_id;
         }
-
-        // If we deactivated our own account, do housekeeping and logout.
-        if ($user->id == $user_id && !is_null($cl_status) && $cl_status == INACTIVE) {
-          // Remove tt_login cookie that stores login name.
-          unset($_COOKIE['tt_login']);
-          setcookie('tt_login', NULL, -1);
-
-          $auth->doLogout();
-          header('Location: login.php');
+  
+        if (ttUserHelper::update($user_id, $fields)) {
+  
+          // If our own login changed, set new one in cookie to remember it.
+          if (($user_id == $user->id) && ($user->login != $cl_login)) {
+            setcookie('tt_login', $cl_login, time() + COOKIE_EXPIRE, '/');
+          }
+  
+          // In case the name of the "on behalf" user has changed - set it in session.
+          if (($user->behalf_id == $user_id) && ($user->behalf_name != $cl_name)) {
+            $_SESSION['behalf_name'] = $cl_name;
+          }
+  
+          // If we deactivated our own account, do housekeeping and logout.
+          if ($user->id == $user_id && !is_null($cl_status) && $cl_status == INACTIVE) {
+            // Remove tt_login cookie that stores login name.
+            unset($_COOKIE['tt_login']);
+            setcookie('tt_login', NULL, -1);
+  
+            $auth->doLogout();
+            header('Location: login.php');
+            exit();
+          }
+  
+          header('Location: users.php');
           exit();
-        }
-
-        header('Location: users.php');
-        exit();
-
+  
+        } else
+          $err->add($i18n->getKey('error.db'));
       } else
-        $err->add($i18n->getKey('error.db'));
-    } else
-      $err->add($i18n->getKey('error.user_exists'));
+        $err->add($i18n->getKey('error.user_exists'));
+    }
+  }
+  
+  if ($request->getParameter('btn_delete')) {
+    header("Location: user_delete.php?id=$user_id");
+    exit();
   }
 } // isPost