public static function addAction($user_id, $msg) { $user = null; $dnevnik_id = null; if (UsersDB::isSalesman(["uporabnik_id" => $user_id])) { $user = UsersDB::getSalesman(["id" => $user_id]); $dnevnik_id = $user["dnevnik_id"]; if (!isset($user["dnevnik_id"])) { // echo $user_id; // echo $msg; // a; $params["uporabnik_id"] = $user_id; $dnevnik_id = $params["dnevnik_id"] = self::insertDiary(); UsersDB::updateSalesmanDiary($params); } } else { if (UsersDB::isAdmin(["uporabnik_id" => $user_id])) { $user = UsersDB::getAdmin(["id" => $user_id]); $dnevnik_id = $user["dnevnik_id"]; if (!isset($user["dnevnik_id"])) { $params["uporabnik_id"] = $user_id; $dnevnik_id = $params["dnevnik_id"] = self::insertDiary(); UsersDB::updateAdminDiary($params); } } else { throw new InvalidArgumentException("Le administrator in prodajalec lahko dodajata vnose v dnevnik."); } } $actionParams["dnevnik_id"] = $dnevnik_id; $actionParams["opis"] = $msg; return parent::modify("INSERT INTO akcija (dnevnik_id, opis) " . " VALUES (:dnevnik_id, :opis)", $actionParams); }
public static function updateUserForm($values = ["ime" => "", "priimek" => "", "mail" => "", "uporabnisko_ime" => "", "geslo" => "", "aktiven" => ""]) { $rules = ["id" => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 1]]]; $data = filter_input_array(INPUT_POST, $rules); if (self::checkValues($data)) { $result = UsersDB::getSalesman($data); $result["geslo2"] = $result["geslo"]; $_SESSION["uid"] = $data["id"]; $_SESSION["uname"] = $result["uporabnisko_ime"]; $form = new OsebaForm('registracija', $result, "spreminjanje"); echo ViewHelper::render("view/admin-user-edit.php", ["form" => $form]); } else { $values["geslo2"] = $values["geslo"]; $form = new OsebaForm('registracija', $values, "spreminjanje"); echo ViewHelper::render("view/admin-user-edit.php", ["form" => $form]); } }
public static function profileForm() { $result = UsersDB::getSalesman(["id" => $_SESSION["id"]]); $result["geslo2"] = $result["geslo"]; $_SESSION["uid"] = $_SESSION["id"]; $_SESSION["uname"] = $result["uporabnisko_ime"]; $form = new OsebaForm('registracija', $result, "profil"); echo ViewHelper::render("view/salesman-profile.php", ["form" => $form]); }