Don't delete templates
[fa-stable.git] / admin / users.php
index 578def433910715c67acbdfdef8f3f883a62682c..afca5d6c0e9b25e005581db3d8d5affd4a13e8ec 100644 (file)
@@ -20,7 +20,7 @@ include_once($path_to_root . "/includes/ui.inc");
 
 include_once($path_to_root . "/admin/db/users_db.inc");
 
-simple_page_mode(false);
+simple_page_mode(true);
 //-------------------------------------------------------------------------------------------------
 
 function can_process() 
@@ -60,14 +60,14 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
 
        if (can_process())
        {
-       if ($selected_id != ''
+       if ($selected_id != -1
        {
-               update_user($_POST['user_id'], $_POST['real_name'], $_POST['phone'],
+               update_user($selected_id, $_POST['user_id'], $_POST['real_name'], $_POST['phone'],
                        $_POST['email'], $_POST['Access'], $_POST['language'], 
                                $_POST['profile'], check_value('rep_popup'), $_POST['pos']);
 
                if ($_POST['password'] != "")
-                       update_user_password($_POST['user_id'], md5($_POST['password']));
+                       update_user_password($selected_id, $_POST['user_id'], md5($_POST['password']));
 
                display_notification_centered(_("The selected user has been updated."));
        } 
@@ -76,10 +76,9 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']),
                                $_POST['phone'], $_POST['email'], $_POST['Access'], $_POST['language'],
                                $_POST['profile'], check_value('rep_popup'), $_POST['pos']);
-
+                       $id = db_insert_id();
                        // use current user display preferences as start point for new user
-                       update_user_display_prefs($_POST['user_id'], 
-                               user_price_dec(), user_qty_dec(), user_exrate_dec(), 
+                       update_user_display_prefs($id, user_price_dec(), user_qty_dec(), user_exrate_dec(), 
                                user_percent_dec(), user_show_gl_info(), user_show_codes(), 
                                user_date_format(), user_date_sep(), user_tho_sep(), 
                                user_dec_sep(), user_theme(), user_pagesize(), user_hints(), 
@@ -104,20 +103,24 @@ if ($Mode == 'Delete')
 //-------------------------------------------------------------------------------------------------
 if ($Mode == 'RESET')
 {
-       $selected_id = '';
-       unset($_POST); // clean all input fields
+       $selected_id = -1;
+       $sav = get_post('show_inactive');
+       unset($_POST);  // clean all input fields
+       $_POST['show_inactive'] = $sav;
 }
 
-$result = get_users();
+$result = get_users(check_value('show_inactive'));
 start_form();
 start_table($table_style);
 
-if ($_SESSION["wa_current_user"]->access == 2)
+//if ($_SESSION["wa_current_user"]->access == 2)
        $th = array(_("User login"), _("Full Name"), _("Phone"),
                _("E-mail"), _("Last Visit"), _("Access Level"), "", "");
-else           
-       $th = array(_("User login"), _("Full Name"), _("Phone"),
-               _("E-mail"), _("Last Visit"), _("Access Level"), "");
+//else         
+//     $th = array(_("User login"), _("Full Name"), _("Phone"),
+//             _("E-mail"), _("Last Visit"), _("Access Level"), "");
+
+inactive_control_column($th);
 table_header($th);     
 
 $k = 0; //row colour counter
@@ -130,6 +133,8 @@ while ($myrow = db_fetch($result))
        $last_visit_date = sql2date($myrow["last_visit_date"]);
 
        /*The security_headings array is defined in config.php */
+       $not_me = strcasecmp($myrow["user_id"], $_SESSION["wa_current_user"]->username) &&
+       $_SESSION["wa_current_user"]->access == 2;
 
        label_cell($myrow["user_id"]);
        label_cell($myrow["real_name"]);
@@ -137,32 +142,34 @@ while ($myrow = db_fetch($result))
        email_cell($myrow["email"]);
        label_cell($last_visit_date, "nowrap");
        label_cell($security_headings[$myrow["full_access"]]);
-       edit_button_cell("Edit".$myrow["user_id"], _("Edit"));
-    if (strcasecmp($myrow["user_id"], $_SESSION["wa_current_user"]->username) &&
-       $_SESSION["wa_current_user"]->access == 2)
-               delete_button_cell("Delete".$myrow["user_id"], _("Delete"));
+       
+    if ($not_me)
+               inactive_control_cell($myrow["id"], $myrow["inactive"], 'users', 'id');
+       elseif (check_value('show_inactive'))
+               label_cell('');
+
+       edit_button_cell("Edit".$myrow["id"], _("Edit"));
+    if ($not_me)
+               delete_button_cell("Delete".$myrow["id"], _("Delete"));
        else
                label_cell('');
        end_row();
 
 } //END WHILE LIST LOOP
 
-end_table();
-end_form();
-echo '<br>';
-
+inactive_control_row($th);
+end_table(1);
 //-------------------------------------------------------------------------------------------------
-start_form();
-
 start_table($table_style2);
 
 $_POST['email'] = "";
-if ($selected_id != ''
+if ($selected_id != -1
 {
        if ($Mode == 'Edit') {
                //editing an existing User
                $myrow = get_user($selected_id);
 
+               $_POST['id'] = $myrow["id"];
                $_POST['user_id'] = $myrow["user_id"];
                $_POST['real_name'] = $myrow["real_name"];
                $_POST['phone'] = $myrow["phone"];
@@ -193,7 +200,7 @@ label_cell(_("Password:"));
 label_cell("<input type='password' name='password' size=22 maxlength=20 value='" . $_POST['password'] . "'>");
 end_row();
 
-if ($selected_id != ''
+if ($selected_id != -1
 {
        table_section_title(_("Enter a new password to change, leave empty to keep current."));
 }
@@ -218,7 +225,7 @@ check_row(_("Use popup window for reports:"), 'rep_popup', $_POST['rep_popup'],
 
 end_table(1);
 
-submit_add_or_update_center($selected_id == '', '', 'default');
+submit_add_or_update_center($selected_id == -1, '', 'both');
 
 end_form();
 end_page();