Witam zrobiłem na podstawie daty urodzenia user_fields z datą przyjęcia do radia o banalnej nazwie user_dpdr i wszystko cacy działa tyle że chciałbym zmienić zapis w bazie danych, właściwie kolejność z
rok - miesiąc - dzień
na
miesiąc - dzień - rok
oto kod
<?php
if (!defined("IN_FUSION")) {
die("Access denied");
}
// Handle Display, viewed by all
if ($profile_method == "display") {
if (isset($user_data['user_dpdr']) && $user_data['user_dpdr'] != "0000-00-00") {
$user_dpdr = explode("-", $user_data['user_dpdr']);
$months = explode("|", $locale['months']);
// neue Berechnung:
$today = date("Ymd");
$birthday = $user_dpdr[0] . $user_dpdr[1] . $user_dpdr[2];
$years = floor(($today - $birthday) / 10000);
echo "<tr>\n";
echo "<td class='tbl1'>" . $locale['uf_dpdr'] . "</td>\n";
echo "<td class='tbl1' align='right'>" . number_format($user_dpdr[2]) . ". " . $months[number_format($user_dpdr[1])] . " " . $user_dpdr[0] . " (" . $years . " " . ($years == 1 ? $locale['uf_dpdr_year'] : $locale['uf_dpdr_years']) . ")</td>\n";
echo "</tr>\n";
}
}
// Handle Input, only if admin or unregistered
elseif ($profile_method == "input") {
if (isset($user_data['user_dpdr'])) {
$user_dpdr = $user_data['user_dpdr'];
} else {
$user_dpdr = "0000-00-00";
}
$user_dpdr = explode("-", $user_dpdr);
$months = explode("|", $locale['months']);
echo "<tr>\n";
echo "<td class='tbl" . $this->getErrorClass("user_dpdr") . "'><label for='user_day'>" . $locale['uf_dpdr'] . $required . "</label></td>\n";
echo "<td class='tbl" . $this->getErrorClass("user_dpdr") . "'>\n";
echo "<select name='user_day' id='user_day' class='textbox'>\n";
echo "<option value='00'" . ($user_dpdr[2] == "00" ? " selected='selected'" : "") . ">" . $locale['uf_dpdr_day'] . "</option>\n";
for ($j = 1; $j <= 31; $j++) {
echo "<option value='" . $j . "'" . ($user_dpdr[2] == $j ? " selected='selected'" : "") . ">" . $j . "</option>\n";
}
echo "</select>\n";
echo "<select name='user_month' id='user_month' class='textbox'>\n";
echo "<option value='00'" . ($user_dpdr[1] == "00" ? " selected='selected'" : "") . ">" . $locale['uf_dpdr_month'] . "</option>\n";
for ($j = 1; $j <= 12; $j++) {
echo "<option value='" . $j . "'" . ($user_dpdr[1] == $j ? " selected='selected'" : "") . ">" . $months[$j] . "</option>\n";
}
echo "</select>\n";
echo "<select name='user_year' id='user_year' class='textbox'>\n";
echo "<option value='00'" . ($user_dpdr[0] == "0000" ? " selected='selected'" : "") . ">" . $locale['uf_dpdr_year'] . "</option>\n";
for ($j = date("Y"); (date("Y") - 99) <= $j; $j--) {
echo "<option value='" . $j . "'" . ($user_dpdr[0] == $j ? " selected='selected'" : "") . ">" . $j . "</option>\n";
}
echo "</select>\n";
echo "</td>\n";
echo "</tr>\n";
if ($required) {
$this->setRequiredJavaScript("user_day", $locale['uf_dpdr_error']);
$this->setRequiredJavaScript("user_month", $locale['uf_dpdr_error']);
$this->setRequiredJavaScript("user_year", $locale['uf_dpdr_error']);
}
}
// Handle Register and Update, Update only if admin or unregistered
elseif ($profile_method == "validate_insert" || $profile_method == "validate_update") {
$user_day = "00";
$user_month = "00";
$user_year = "0000";
if (isset($_POST['user_day']) && isNum($_POST['user_day']) && $_POST['user_day'] != "00") {
$user_day = $_POST['user_day'];
}
if (isset($_POST['user_month']) && isNum($_POST['user_month']) && $_POST['user_month'] != "00") {
$user_month = $_POST['user_month'];
}
if (isset($_POST['user_year']) && isNum($_POST['user_year']) && $_POST['user_year'] != "0000") {
$user_year = $_POST['user_year'];
}
if (($user_day != "00" && $user_month != "00" && $user_year != "0000") || $this->_isNotRequired("user_dpdr")) {
$this->_setDBValue("user_dpdr", $user_year . "-" . str_pad($user_month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($user_day, 2, "0", STR_PAD_LEFT));
} else {
$this->_setError("user_dpdr", $locale['uf_dpdr_error'], TRUE);
}
}
Przypuszczam że to tu trzeba zmienić.
$this->_setDBValue("user_dpdr", $user_year . "-" . str_pad($user_month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($user_day, 2, "0", STR_PAD_LEFT));
Tyle że jak poprzestawiam to mam error nie mogę wykminić tych " jak je poprzestawiać a może jeszcze robię gdzieś błąd.
Pozdrawiam i z góry dziękuje za pomoc.
popraw sobie tą stopkę
|