function update_sever_controls($window)
{
    global $mainwin, $sever_table;
    $itemlist = wb_get_control($window, ID_SEVERITYLIST);
    $id = db_get_id($sever_table, wb_get_selected($itemlist));
    wb_set_text(wb_get_control($window, ID_NAME), db_get_data($sever_table, $id, "name"));
    $sel = wb_get_selected($itemlist);
    wb_set_enabled(wb_get_control($window, ID_SETITEM), $sel != -1);
    wb_set_enabled(wb_get_control($window, ID_DELETEITEM), $sel != -1);
}
function update_item($window)
{
    global $id_edit;
    $name = wb_get_text(wb_get_control($window, ID_NAME));
    $descr = wb_get_text(wb_get_control($window, ID_DESCRIPTION));
    // Fetch the id from table 'cat'
    $id_cat = (int) db_get_id("cat", wb_get_selected(wb_get_control($window, ID_CATLIST)));
    $id_prior = (int) db_get_id("priority", wb_get_selected(wb_get_control($window, ID_PRIORLIST)));
    $id_sever = (int) db_get_id("severity", wb_get_selected(wb_get_control($window, ID_SEVERLIST)));
    $res = db_edit_record("item", $id_edit, "name\ndescription\ncat\npriority\nseverity", array($name, $descr, $id_cat, $id_prior, $id_sever));
    if (!$res) {
        wb_message_box($window, "Problem editing this record.", null, WBC_WARNING);
    }
    return $res;
}
Exemple #3
0
 /**
  *	$.ajax({ method: log_in, user_name: x...x, encrypted: x...x, remember_me: Y/N });
  *
  *	status: ok
  * message: x...x
  *	  data: first_name	: x...x
  *			last_name	: x...x
  *			user_role	: x...x
  *			start_page	: x...x
  */
 private function log_in($data)
 {
     $user_name = $data['user_name'];
     $encrypted = $data['encrypted'];
     $error = '';
     $user_id = db_get_id('JKY_Users', 'status = "Active" AND user_name = "' . $user_name . '"');
     if (!$user_id) {
         $error .= set_is_invalid('User Name');
     }
     if (is_empty($error)) {
         $password = $this->get_password($user_id);
         $password = MD5(get_session('user_time') . $password);
         if ($password !== $encrypted) {
             $error .= set_is_invalid('Password');
         }
     }
     $return = array();
     if (is_empty($error)) {
         $this->set_user_session($user_id);
         $return['status'] = 'ok';
         $return['data'] = $this->get_user_data();
     } else {
         $return['status'] = 'error';
         $return['message'] = $error;
     }
     echo json_encode($return);
 }
function get_selected_tree_item_id($window)
{
    global $cat_table, $it_list;
    // Below: get id of selected treeview element. See comment in update_items()
    $it_list = wb_get_control($window, ID_TREE);
    $sel_text = wb_get_text($it_list);
    $cat_data = db_get_data("cat", null, "name");
    $sel_index = (int) array_search($sel_text, $cat_data);
    $cat_data = db_get_data("cat", null, "id");
    $id_cat = $cat_data[$sel_index];
    $id = db_get_id($cat_table, $sel_index);
    return $id;
}