update
This commit is contained in:
@@ -108,6 +108,7 @@ class DictionaryController extends MainController implements ControllerInterface
|
||||
//'User' => array('User' => 'Index'),
|
||||
'Słowniki' => array('Dictionary' => 'Index'),
|
||||
'Zmienne serwisu' => array('Setup' => 'Index'),
|
||||
'Ustawienia formularza' => array('FormSettings' => 'Index'),
|
||||
// 'Kategorie produktów' => array('ProductCategory' => 'Index'),
|
||||
// 'Serie produktów' => array('ProductSeries' => 'Index'),
|
||||
// 'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
|
||||
@@ -150,4 +151,4 @@ class DictionaryController extends MainController implements ControllerInterface
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
61
_rejestracja/Admin/controller/FormSettingsController.php
Normal file
61
_rejestracja/Admin/controller/FormSettingsController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
class FormSettingsController extends MainController implements ControllerInterface {
|
||||
|
||||
public function IndexAction($param) {
|
||||
$errors = array();
|
||||
|
||||
if (Request::GetPost('doFormSettingsEdit')) {
|
||||
$post = Request::GetAllPost();
|
||||
$errors = RegistrationFormSettings::Validate($post);
|
||||
|
||||
if (empty($errors)) {
|
||||
RegistrationFormSettings::SaveSettings($post);
|
||||
$this->smarty->assign('info', 'Zapisano ustawienia formularza.');
|
||||
$this->smarty->assign('type', 'ok');
|
||||
} else {
|
||||
$this->smarty->assign('info', 'Popraw pola formularza.');
|
||||
$this->smarty->assign('type', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
$settings = RegistrationFormSettings::GetSettings();
|
||||
$this->smarty->assign('settings', $settings);
|
||||
$this->smarty->assign('errors', $errors);
|
||||
}
|
||||
|
||||
public function preDispatch($param) {
|
||||
$this->RunShared('Auth', $param);
|
||||
$this->Run($param);
|
||||
$admin = AuthDAL::GetAdmin();
|
||||
$this->user = $admin;
|
||||
|
||||
$this->smarty->assign('titleAdmin', 'Administracja');
|
||||
$struct = array(
|
||||
'Słowniki' => array('Dictionary' => 'Index'),
|
||||
'Zmienne serwisu' => array('Setup' => 'Index'),
|
||||
'Ustawienia formularza' => array('FormSettings' => 'Index'),
|
||||
);
|
||||
|
||||
$this->smarty->assign('structure', $this->renderStruct($struct));
|
||||
}
|
||||
|
||||
private function renderStruct($struct) {
|
||||
$return = '';
|
||||
|
||||
foreach ($struct as $k => $row) {
|
||||
$return .= '<li><a href="' . Router::GenerateUrl('dictpig', $row) . '">' . $k . '</a></li>';
|
||||
}
|
||||
|
||||
$html = '<ul>';
|
||||
$html .= $return;
|
||||
$html .= '</ul>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function postDispatch($param) {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -144,6 +144,7 @@ class SetupController extends MainController implements ControllerInterface {
|
||||
//'User' => array('User' => 'Index'),
|
||||
'Słowniki' => array('Dictionary' => 'Index'),
|
||||
'Zmienne serwisu' => array('Setup' => 'Index'),
|
||||
'Ustawienia formularza' => array('FormSettings' => 'Index'),
|
||||
// 'Kategorie produktów' => array('ProductCategory' => 'Index'),
|
||||
// 'Serie produktów' => array('ProductSeries' => 'Index'),
|
||||
// 'Materiał produktów' => array('ProductSpec' => 'Index', 'type' => 2),
|
||||
@@ -179,4 +180,4 @@ class SetupController extends MainController implements ControllerInterface {
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
72
_rejestracja/Admin/template/partial/FormSettings/Index.tpl
Normal file
72
_rejestracja/Admin/template/partial/FormSettings/Index.tpl
Normal file
@@ -0,0 +1,72 @@
|
||||
<div class="panelRightTop"></div>
|
||||
<div class="panelRightBody">
|
||||
<div class="paddedContent">
|
||||
{dropDownContainer title="Ustawienia formularza"}
|
||||
{if isset($info)}
|
||||
<div class="{if $type == 'error'}error{else}info{/if}">{$info}</div>
|
||||
{/if}
|
||||
<form method="post" action="">
|
||||
<table align="center" class="adminTable" cellpadding="2" cellspacing="2" style="width: 760px;">
|
||||
<tr>
|
||||
<th colspan="3">Dni udzialu</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 240px;">Jeden dzien z noclegiem</td>
|
||||
<td><textarea name="registration_form_days_lodging" class="input" style="width: 420px; height: 70px;">{$settings.days_lodging_text}</textarea></td>
|
||||
<td>{if isset($errors.registration_form_days_lodging)}<span class="validate">{$errors.registration_form_days_lodging}</span>{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jeden dzien bez noclegu</td>
|
||||
<td><textarea name="registration_form_days_no_lodging" class="input" style="width: 420px; height: 90px;">{$settings.days_no_lodging_text}</textarea></td>
|
||||
<td>{if isset($errors.registration_form_days_no_lodging)}<span class="validate">{$errors.registration_form_days_no_lodging}</span>{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3">Ceny z parametrow formularza</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nazwa</td>
|
||||
<td>Cena normalna netto</td>
|
||||
<td>Cena obnizona netto</td>
|
||||
</tr>
|
||||
{foreach from=$settings.prices key=priceKey item=price}
|
||||
{if $priceKey != 'one_day'}
|
||||
<tr>
|
||||
<td>{$price.name} (ID {$price.id})</td>
|
||||
<td><input type="text" name="price[{$price.id}]" value="{$price.price}" class="input" /></td>
|
||||
<td><input type="text" name="price_prom[{$price.id}]" value="{$price.price_prom}" class="input" /></td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
<tr>
|
||||
<th colspan="3">Ceny jednego dnia</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jeden dzien - cena obnizona netto</td>
|
||||
<td><input type="text" name="registration_form_one_day_price_prom" value="{$settings.one_day_price_prom}" class="input" /></td>
|
||||
<td>{if isset($errors.registration_form_one_day_price_prom)}<span class="validate">{$errors.registration_form_one_day_price_prom}</span>{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jeden dzien - cena normalna netto</td>
|
||||
<td><input type="text" name="registration_form_one_day_price_normal" value="{$settings.one_day_price_normal}" class="input" /></td>
|
||||
<td>{if isset($errors.registration_form_one_day_price_normal)}<span class="validate">{$errors.registration_form_one_day_price_normal}</span>{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3">VAT</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mnoznik VAT</td>
|
||||
<td><input type="text" name="registration_form_vat_multiplier" value="{$settings.vat_multiplier}" class="input" /></td>
|
||||
<td>{if isset($errors.registration_form_vat_multiplier)}<span class="validate">{$errors.registration_form_vat_multiplier}</span>{/if}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="2">
|
||||
<input type="submit" value="Zapisz" name="doFormSettingsEdit" class="button buttonZapisz" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
{/dropDownContainer}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panelRightBottom"></div>
|
||||
Binary file not shown.
@@ -16,14 +16,19 @@ class IndexController extends MainController implements ControllerInterface {
|
||||
//Utils::ArrayDisplay($_POST);
|
||||
//SessionProxy::SetValue("infoSent",'true');
|
||||
|
||||
$registrationSettings = RegistrationFormSettings::GetSettings();
|
||||
$vatMultiplier = $registrationSettings['vat_multiplier'];
|
||||
$arrayPriceVat = array();
|
||||
$arrayPricePromVat = array();
|
||||
|
||||
$arrayPrice = Utils::GetArrayList('mf_parameters', 'id_mf_parameters', 'price');
|
||||
$arrayPriceProm = Utils::GetArrayList('mf_parameters', 'id_mf_parameters', 'price_prom');
|
||||
foreach ($arrayPrice as $key => $price) {
|
||||
$priceVat = $price*1.23;
|
||||
$priceVat = $price*$vatMultiplier;
|
||||
$arrayPriceVat[$key] = $priceVat;
|
||||
}
|
||||
foreach ($arrayPriceProm as $key => $price) {
|
||||
$priceVat = $price*1.23;
|
||||
$priceVat = $price*$vatMultiplier;
|
||||
$arrayPricePromVat[$key] = $priceVat;
|
||||
}
|
||||
|
||||
@@ -32,6 +37,9 @@ class IndexController extends MainController implements ControllerInterface {
|
||||
$this->smarty->assign('arrayPriceVatJson', str_replace('"', '', json_encode($arrayPriceVat)));
|
||||
$this->smarty->assign('arrayPricePromJson', str_replace('"', '', json_encode($arrayPriceProm)));
|
||||
$this->smarty->assign('arrayPricePromVatJson', json_encode($arrayPricePromVat));
|
||||
$this->smarty->assign('registrationSettings', $registrationSettings);
|
||||
$this->smarty->assign('registrationPricesJson', json_encode($registrationSettings['prices']));
|
||||
$this->smarty->assign('registrationVatMultiplier', $vatMultiplier);
|
||||
|
||||
|
||||
$type = 1;
|
||||
@@ -213,11 +221,20 @@ class IndexController extends MainController implements ControllerInterface {
|
||||
$arrayPrice2Value = array();
|
||||
|
||||
$objParticipant->setFeeFull(serialize($arrayFee));
|
||||
if (isset($arrayFee['disc'])) {
|
||||
unset($arrayFee['disc']);
|
||||
$arrayFeeForCalculation = $arrayFee;
|
||||
if (isset($arrayFeeForCalculation['disc'])) {
|
||||
unset($arrayFeeForCalculation['disc']);
|
||||
}
|
||||
if (Request::GetPost('conference_fee') == 5) {
|
||||
$resultPrice = RegistrationFormSettings::GetOneDayPrice(Request::GetPost('conference_fee_disc'));
|
||||
foreach ($arrayFeeForCalculation as $feeKey => $feeValue) {
|
||||
if ($feeValue == 5) {
|
||||
unset($arrayFeeForCalculation[$feeKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($arrayObjParameters as $objParam) {
|
||||
if (in_array($objParam->GetId(), $arrayFee) != '') {
|
||||
if (in_array($objParam->GetId(), $arrayFeeForCalculation) != '') {
|
||||
if (Request::GetPost('conference_fee_disc') == 2) {
|
||||
if($objParam->GetId() != 2 || $_POST['fee_room1'] != null){
|
||||
$resultPrice = $resultPrice + $objParam->getPrice();
|
||||
|
||||
211
_rejestracja/core/class/RegistrationFormSettings.class.php
Normal file
211
_rejestracja/core/class/RegistrationFormSettings.class.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
class RegistrationFormSettings {
|
||||
|
||||
const DAYS_LODGING = 'registration_form_days_lodging';
|
||||
const DAYS_NO_LODGING = 'registration_form_days_no_lodging';
|
||||
const VAT_MULTIPLIER = 'registration_form_vat_multiplier';
|
||||
const ONE_DAY_PRICE_PROM = 'registration_form_one_day_price_prom';
|
||||
const ONE_DAY_PRICE_NORMAL = 'registration_form_one_day_price_normal';
|
||||
|
||||
private static $defaults = array(
|
||||
'registration_form_days_lodging' => "3/4 listopada\n4/5 listopada",
|
||||
'registration_form_days_no_lodging' => "3 listopada\n4 listopada\n5 listopada",
|
||||
'registration_form_vat_multiplier' => '1.23',
|
||||
'registration_form_one_day_price_prom' => '1300',
|
||||
'registration_form_one_day_price_normal' => '1600',
|
||||
);
|
||||
|
||||
private static $priceParameterIds = array(
|
||||
'full_conference' => 1,
|
||||
'single_room' => 2,
|
||||
'accompanying_person' => 3,
|
||||
'english_conference' => 4,
|
||||
'legacy_one_day' => 5,
|
||||
);
|
||||
|
||||
public static function GetSettings() {
|
||||
$variables = self::GetVariables();
|
||||
$vatMultiplier = self::NormalizeNumber(self::GetVariableValue($variables, self::VAT_MULTIPLIER));
|
||||
|
||||
if (!$vatMultiplier) {
|
||||
$vatMultiplier = self::$defaults[self::VAT_MULTIPLIER];
|
||||
}
|
||||
|
||||
return array(
|
||||
'days_lodging_text' => self::GetVariableValue($variables, self::DAYS_LODGING),
|
||||
'days_no_lodging_text' => self::GetVariableValue($variables, self::DAYS_NO_LODGING),
|
||||
'days_lodging' => self::ParseList(self::GetVariableValue($variables, self::DAYS_LODGING)),
|
||||
'days_no_lodging' => self::ParseList(self::GetVariableValue($variables, self::DAYS_NO_LODGING)),
|
||||
'vat_multiplier' => (float)$vatMultiplier,
|
||||
'one_day_price_prom' => (float)self::NormalizeNumber(self::GetVariableValue($variables, self::ONE_DAY_PRICE_PROM)),
|
||||
'one_day_price_normal' => (float)self::NormalizeNumber(self::GetVariableValue($variables, self::ONE_DAY_PRICE_NORMAL)),
|
||||
'prices' => self::GetPriceSettings((float)$vatMultiplier),
|
||||
);
|
||||
}
|
||||
|
||||
public static function SaveSettings($post) {
|
||||
self::SaveVariable(self::DAYS_LODGING, self::NormalizeListText($post[self::DAYS_LODGING]), 'Dni udzialu - jeden dzien z noclegiem');
|
||||
self::SaveVariable(self::DAYS_NO_LODGING, self::NormalizeListText($post[self::DAYS_NO_LODGING]), 'Dni udzialu - jeden dzien bez noclegu');
|
||||
self::SaveVariable(self::VAT_MULTIPLIER, self::NormalizeNumber($post[self::VAT_MULTIPLIER]), 'Mnoznik VAT dla cen formularza rejestracji');
|
||||
self::SaveVariable(self::ONE_DAY_PRICE_PROM, self::NormalizeNumber($post[self::ONE_DAY_PRICE_PROM]), 'Cena netto promocyjna - jeden dzien');
|
||||
self::SaveVariable(self::ONE_DAY_PRICE_NORMAL, self::NormalizeNumber($post[self::ONE_DAY_PRICE_NORMAL]), 'Cena netto normalna - jeden dzien');
|
||||
|
||||
foreach (self::$priceParameterIds as $key => $id) {
|
||||
if (!isset($post['price'][$id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$objParam = MfParametersDAL::GetById($id);
|
||||
if (!$objParam || $objParam->GetId() == '-1') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$price = isset($post['price'][$id]) ? self::NormalizeNumber($post['price'][$id]) : '';
|
||||
$priceProm = isset($post['price_prom'][$id]) ? self::NormalizeNumber($post['price_prom'][$id]) : '';
|
||||
$objParam->setPrice($price);
|
||||
$objParam->setPriceProm($priceProm);
|
||||
MfParametersDAL::Save($objParam);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Validate($post) {
|
||||
$errors = array();
|
||||
$required = array(
|
||||
self::DAYS_LODGING => 'Podaj dni dla opcji z noclegiem.',
|
||||
self::DAYS_NO_LODGING => 'Podaj dni dla opcji bez noclegu.',
|
||||
self::VAT_MULTIPLIER => 'Podaj mnoznik VAT.',
|
||||
self::ONE_DAY_PRICE_PROM => 'Podaj cene promocyjna za jeden dzien.',
|
||||
self::ONE_DAY_PRICE_NORMAL => 'Podaj cene normalna za jeden dzien.',
|
||||
);
|
||||
|
||||
foreach ($required as $field => $message) {
|
||||
if (!isset($post[$field]) || trim($post[$field]) === '') {
|
||||
$errors[$field] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array(self::VAT_MULTIPLIER, self::ONE_DAY_PRICE_PROM, self::ONE_DAY_PRICE_NORMAL) as $field) {
|
||||
if (isset($post[$field]) && trim($post[$field]) !== '' && !self::IsNumber($post[$field])) {
|
||||
$errors[$field] = 'Pole musi byc liczba.';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['price']) && is_array($post['price'])) {
|
||||
foreach ($post['price'] as $id => $value) {
|
||||
if (trim($value) !== '' && !self::IsNumber($value)) {
|
||||
$errors['price_' . $id] = 'Cena musi byc liczba.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['price_prom']) && is_array($post['price_prom'])) {
|
||||
foreach ($post['price_prom'] as $id => $value) {
|
||||
if (trim($value) !== '' && !self::IsNumber($value)) {
|
||||
$errors['price_prom_' . $id] = 'Cena promocyjna musi byc liczba.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public static function GetOneDayPrice($discountType) {
|
||||
$settings = self::GetSettings();
|
||||
return $discountType == 2 ? $settings['one_day_price_normal'] : $settings['one_day_price_prom'];
|
||||
}
|
||||
|
||||
public static function GetVatMultiplier() {
|
||||
$settings = self::GetSettings();
|
||||
return $settings['vat_multiplier'];
|
||||
}
|
||||
|
||||
private static function GetPriceSettings($vatMultiplier) {
|
||||
$prices = array();
|
||||
|
||||
foreach (self::$priceParameterIds as $key => $id) {
|
||||
$objParam = MfParametersDAL::GetById($id);
|
||||
$net = $objParam && $objParam->GetId() != '-1' ? (float)$objParam->GetPrice() : 0;
|
||||
$prom = $objParam && $objParam->GetId() != '-1' ? (float)$objParam->GetPriceProm() : 0;
|
||||
|
||||
$prices[$key] = array(
|
||||
'id' => $id,
|
||||
'name' => $objParam && $objParam->GetId() != '-1' ? $objParam->GetName() : '',
|
||||
'price' => $net,
|
||||
'price_prom' => $prom,
|
||||
'price_vat' => $net * $vatMultiplier,
|
||||
'price_prom_vat' => $prom * $vatMultiplier,
|
||||
);
|
||||
}
|
||||
|
||||
$prices['one_day'] = array(
|
||||
'price_prom' => (float)self::GetVariableRaw(self::ONE_DAY_PRICE_PROM),
|
||||
'price_normal' => (float)self::GetVariableRaw(self::ONE_DAY_PRICE_NORMAL),
|
||||
);
|
||||
|
||||
return $prices;
|
||||
}
|
||||
|
||||
private static function GetVariables() {
|
||||
$variables = array();
|
||||
$db = Registry::Get('db');
|
||||
$stmt = $db->execute("select variable,value,description from wp_setup order by variable,value");
|
||||
$array = $stmt->FetchAllAssoc();
|
||||
|
||||
foreach ($array as $variable) {
|
||||
$variables[$variable['variable']] = array(
|
||||
'variable' => $variable['variable'],
|
||||
'value' => $variable['value'],
|
||||
'description' => $variable['description'],
|
||||
);
|
||||
}
|
||||
|
||||
return $variables;
|
||||
}
|
||||
|
||||
private static function GetVariableValue($variables, $name) {
|
||||
if (isset($variables[$name])) {
|
||||
return $variables[$name]['value'];
|
||||
}
|
||||
|
||||
return self::$defaults[$name];
|
||||
}
|
||||
|
||||
private static function GetVariableRaw($name) {
|
||||
$variables = self::GetVariables();
|
||||
return self::NormalizeNumber(self::GetVariableValue($variables, $name));
|
||||
}
|
||||
|
||||
private static function SaveVariable($name, $value, $description) {
|
||||
SetupDAL::SaveVariable($name, $value, $description);
|
||||
}
|
||||
|
||||
private static function ParseList($text) {
|
||||
$text = str_replace(array("\r\n", "\r"), "\n", $text);
|
||||
$items = explode("\n", $text);
|
||||
$return = array();
|
||||
|
||||
foreach ($items as $item) {
|
||||
$item = trim($item);
|
||||
if ($item !== '') {
|
||||
$return[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private static function NormalizeListText($text) {
|
||||
return implode("\n", self::ParseList($text));
|
||||
}
|
||||
|
||||
private static function NormalizeNumber($value) {
|
||||
return str_replace(',', '.', trim($value));
|
||||
}
|
||||
|
||||
private static function IsNumber($value) {
|
||||
return is_numeric(self::NormalizeNumber($value));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
22
_rejestracja/sql/2026-04-24-registration-form-settings.sql
Normal file
22
_rejestracja/sql/2026-04-24-registration-form-settings.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
INSERT INTO wp_setup (`variable`, `value`, `description`)
|
||||
SELECT 'registration_form_days_lodging', '3/4 listopada
|
||||
4/5 listopada', 'Dni udzialu - jeden dzien z noclegiem'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM wp_setup WHERE `variable` = 'registration_form_days_lodging');
|
||||
|
||||
INSERT INTO wp_setup (`variable`, `value`, `description`)
|
||||
SELECT 'registration_form_days_no_lodging', '3 listopada
|
||||
4 listopada
|
||||
5 listopada', 'Dni udzialu - jeden dzien bez noclegu'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM wp_setup WHERE `variable` = 'registration_form_days_no_lodging');
|
||||
|
||||
INSERT INTO wp_setup (`variable`, `value`, `description`)
|
||||
SELECT 'registration_form_vat_multiplier', '1.23', 'Mnoznik VAT dla cen formularza rejestracji'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM wp_setup WHERE `variable` = 'registration_form_vat_multiplier');
|
||||
|
||||
INSERT INTO wp_setup (`variable`, `value`, `description`)
|
||||
SELECT 'registration_form_one_day_price_prom', '1300', 'Cena netto promocyjna - jeden dzien'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM wp_setup WHERE `variable` = 'registration_form_one_day_price_prom');
|
||||
|
||||
INSERT INTO wp_setup (`variable`, `value`, `description`)
|
||||
SELECT 'registration_form_one_day_price_normal', '1600', 'Cena netto normalna - jeden dzien'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM wp_setup WHERE `variable` = 'registration_form_one_day_price_normal');
|
||||
145
_rejestracja/sql/apply-2026-04-24-registration-form-settings.php
Normal file
145
_rejestracja/sql/apply-2026-04-24-registration-form-settings.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* One-off form settings seed for XXXV Konferencja registration.
|
||||
*
|
||||
* Usage:
|
||||
* - Browser: /_rejestracja/sql/apply-2026-04-24-registration-form-settings.php?run=20260424
|
||||
* - CLI: php apply-2026-04-24-registration-form-settings.php --run
|
||||
*
|
||||
* Remove this file from the server after a successful production run.
|
||||
*/
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$settings = array(
|
||||
'registration_form_days_lodging' => array(
|
||||
'value' => "3/4 listopada\n4/5 listopada",
|
||||
'description' => 'Dni udzialu - jeden dzien z noclegiem',
|
||||
),
|
||||
'registration_form_days_no_lodging' => array(
|
||||
'value' => "3 listopada\n4 listopada\n5 listopada",
|
||||
'description' => 'Dni udzialu - jeden dzien bez noclegu',
|
||||
),
|
||||
'registration_form_vat_multiplier' => array(
|
||||
'value' => '1.23',
|
||||
'description' => 'Mnoznik VAT dla cen formularza rejestracji',
|
||||
),
|
||||
'registration_form_one_day_price_prom' => array(
|
||||
'value' => '1300',
|
||||
'description' => 'Cena netto promocyjna - jeden dzien',
|
||||
),
|
||||
'registration_form_one_day_price_normal' => array(
|
||||
'value' => '1600',
|
||||
'description' => 'Cena netto normalna - jeden dzien',
|
||||
),
|
||||
);
|
||||
|
||||
$isCli = PHP_SAPI === 'cli';
|
||||
$approved = $isCli
|
||||
? in_array('--run', $argv, true)
|
||||
: (isset($_GET['run']) && $_GET['run'] === '20260424');
|
||||
|
||||
header_safe('Content-Type: text/plain; charset=utf-8');
|
||||
|
||||
if (!$approved) {
|
||||
echo "DRY RUN ONLY\n";
|
||||
echo "To apply form settings seed, run with ?run=20260424 in browser or --run in CLI.\n";
|
||||
echo "No database changes were made.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$configPath = __DIR__ . '/../core/config/Strona/db.config.ini';
|
||||
if (!is_file($configPath)) {
|
||||
fail("Config file not found: " . $configPath);
|
||||
}
|
||||
|
||||
$config = parse_ini_file($configPath, true);
|
||||
if (!isset($config['db'])) {
|
||||
fail("Missing [db] section in config.");
|
||||
}
|
||||
|
||||
$dbConfig = $config['db'];
|
||||
foreach (array('prodHost', 'prodUser', 'prodPass', 'prodDb') as $key) {
|
||||
if (!array_key_exists($key, $dbConfig)) {
|
||||
fail("Missing db config key: " . $key);
|
||||
}
|
||||
}
|
||||
|
||||
$mysqli = new mysqli(
|
||||
$dbConfig['prodHost'],
|
||||
$dbConfig['prodUser'],
|
||||
$dbConfig['prodPass'],
|
||||
$dbConfig['prodDb']
|
||||
);
|
||||
|
||||
if ($mysqli->connect_errno) {
|
||||
fail("MySQL connection failed: " . $mysqli->connect_error);
|
||||
}
|
||||
|
||||
$mysqli->set_charset('utf8');
|
||||
|
||||
echo "Applying registration form settings seed...\n";
|
||||
|
||||
$inserted = 0;
|
||||
$skipped = 0;
|
||||
|
||||
foreach ($settings as $variable => $row) {
|
||||
if (setup_variable_exists($mysqli, $variable)) {
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_setup_variable($mysqli, $variable, $row['value'], $row['description']);
|
||||
$inserted++;
|
||||
}
|
||||
|
||||
echo "Form settings seed complete.\n";
|
||||
echo "Inserted: " . $inserted . "\n";
|
||||
echo "Skipped: " . $skipped . "\n";
|
||||
$mysqli->close();
|
||||
|
||||
function setup_variable_exists(mysqli $mysqli, $variable) {
|
||||
$stmt = $mysqli->prepare("SELECT COUNT(*) AS cnt FROM wp_setup WHERE variable = ?");
|
||||
if (!$stmt) {
|
||||
fail("Prepare failed: " . $mysqli->error);
|
||||
}
|
||||
|
||||
$stmt->bind_param('s', $variable);
|
||||
if (!$stmt->execute()) {
|
||||
fail("Setup check failed: " . $stmt->error);
|
||||
}
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
|
||||
return isset($row['cnt']) && (int)$row['cnt'] > 0;
|
||||
}
|
||||
|
||||
function insert_setup_variable(mysqli $mysqli, $variable, $value, $description) {
|
||||
$stmt = $mysqli->prepare("INSERT INTO wp_setup (variable, value, description) VALUES (?, ?, ?)");
|
||||
if (!$stmt) {
|
||||
fail("Prepare failed: " . $mysqli->error);
|
||||
}
|
||||
|
||||
$stmt->bind_param('sss', $variable, $value, $description);
|
||||
if (!$stmt->execute()) {
|
||||
fail("Insert failed for " . $variable . ": " . $stmt->error);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
function fail($message) {
|
||||
echo "ERROR: " . $message . "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function header_safe($header) {
|
||||
if (!headers_sent() && PHP_SAPI !== 'cli') {
|
||||
header($header);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -72,7 +72,10 @@
|
||||
</div>
|
||||
<div class="entry">
|
||||
<div class="label">{translate word='NIP Instytucji'}:</div>
|
||||
<div class="value">{formField name="nip" type="text" errorClass="warning"}</div>
|
||||
<div class="value">
|
||||
{formField name="nip" type="text" errorClass="warning"}
|
||||
<div style="font-size: 11px; line-height: 1.3; margin-top: 4px;">{translate word='Do wypełnienia w przypadku posiadania identyfikatora wewnętrznego w KSEF i prośba o podanie KSeF ID wew.'}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cb"></div>
|
||||
<div class="entry">
|
||||
@@ -178,32 +181,27 @@
|
||||
</div>
|
||||
<div class="show--day-select" id="one-day-lodging-days" style="display:none; width:100%; margin-bottom:30px; flex-direction:column; gap:10px;">
|
||||
<span>{translate word='registration_select_day'}:</span>
|
||||
<label class="control control--radio">3/4 listopada
|
||||
<input type="radio" name="participation_days" value="3/4 listopada" />
|
||||
<div class="control__indicator"></div>
|
||||
</label>
|
||||
<label class="control control--radio">4/5 listopada
|
||||
<input type="radio" name="participation_days" value="4/5 listopada" />
|
||||
{foreach from=$registrationSettings.days_lodging item=day}
|
||||
<label class="control control--radio">{$day}
|
||||
<input type="radio" name="participation_days" value="{$day}" />
|
||||
<div class="control__indicator"></div>
|
||||
</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="show--day-select" id="one-day-no-lodging-days" style="display:none; width:100%; margin-bottom:30px; flex-direction:column; gap:10px;">
|
||||
<span>{translate word='registration_select_day'}:</span>
|
||||
<label class="control control--radio">3 listopada
|
||||
<input type="radio" name="participation_days" value="3 listopada" />
|
||||
<div class="control__indicator"></div>
|
||||
</label>
|
||||
<label class="control control--radio">4 listopada
|
||||
<input type="radio" name="participation_days" value="4 listopada" />
|
||||
<div class="control__indicator"></div>
|
||||
</label>
|
||||
<label class="control control--radio">5 listopada
|
||||
<input type="radio" name="participation_days" value="5 listopada" />
|
||||
{foreach from=$registrationSettings.days_no_lodging item=day}
|
||||
<label class="control control--radio">{$day}
|
||||
<input type="radio" name="participation_days" value="{$day}" />
|
||||
<div class="control__indicator"></div>
|
||||
</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
<script>
|
||||
{literal}
|
||||
var registrationPrices = {/literal}{$registrationPricesJson}{literal};
|
||||
var registrationVatMultiplier = parseFloat('{/literal}{$registrationVatMultiplier}{literal}');
|
||||
|
||||
$(function () {
|
||||
$('#conference_1').show();
|
||||
calculatePrice();
|
||||
@@ -254,13 +252,13 @@
|
||||
}
|
||||
|
||||
if ($('#conference_fee_1').is(':checked')) {
|
||||
sumPrice = !promo ? 1300 : 1600;
|
||||
sumPriceVat = !promo ? 1599 : 1968;
|
||||
sumPrice = !promo ? parseFloat(registrationPrices.one_day.price_prom) : parseFloat(registrationPrices.one_day.price_normal);
|
||||
sumPriceVat = sumPrice * registrationVatMultiplier;
|
||||
price_info += '1-dniowa';
|
||||
}
|
||||
if ($('#conference_fee_1_lodging').is(':checked')) {
|
||||
sumPrice = !promo ? 1300 : 1600;
|
||||
sumPriceVat = !promo ? 1599 : 1968;
|
||||
sumPrice = !promo ? parseFloat(registrationPrices.one_day.price_prom) : parseFloat(registrationPrices.one_day.price_normal);
|
||||
sumPriceVat = sumPrice * registrationVatMultiplier;
|
||||
price_info += '1-dniowa z noclegiem';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user