Skip to content

Commit

Permalink
Restrict Price / Amount / Balance input number range
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisjacquet committed May 4, 2022
1 parent 05ce3c2 commit 386a5e2
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -76,6 +76,7 @@ Changes in 9.0
- Remove Student Assignment Submission files on delete in Assignments.php, thank to @khanhchauminh
- Add microseconds to filename format to make it harder to predict in Assignments.php & StudentAssignments.fnc.php, thanks to @khanhchauminh
- Restrict Sort Order input number range, program wide
- Restrict Price / Amount / Balance input number range, program wide, thanks to @nhienit2010

Changes in 8.9.5
----------------
Expand Down
8 changes: 4 additions & 4 deletions classes/core/StaffWidget.php
Expand Up @@ -148,8 +148,8 @@ function html( $value = '' )
<input type="radio" name="fsa_bal_ge" value="" checked /> &lt;</label>&nbsp;
<label class="sizep2">
<input type="radio" name="fsa_bal_ge" value="Y" /> &ge;</label>
<input name="fsa_balance" id="fsa_balance" type="number" step="any"' .
( $value ? ' value="' . AttrEscape( $value ) . '"' : '') . ' />
<input name="fsa_balance" id="fsa_balance" type="number" step="0.01"' .
( $value ? ' value="' . AttrEscape( $value ) . '"' : '') . ' min="-999999999999999" max="999999999999999" />
</td></tr>';
}
}
Expand Down Expand Up @@ -388,8 +388,8 @@ function html()
{
return '<tr class="st"><td>' . _( 'Staff Payroll Balance' ) . '</td><td><label>' .
_( 'Between' ) .
' <input type="number" name="balance_low" step="any" /></label> <label>&amp;
<input type="number" name="balance_high" step="any" /></label>
' <input type="number" name="balance_low" step="0.01" min="-999999999999999" max="999999999999999" /></label> <label>&amp;
<input type="number" name="balance_high" step="0.01" min="-999999999999999" max="999999999999999" /></label>
</td></tr>';
}
}
12 changes: 6 additions & 6 deletions classes/core/Widget.php
Expand Up @@ -604,9 +604,9 @@ function html()
}

return $html . '</td><td><label>' . _( 'Between' ) .
' <input type="number" name="gpa_low" min="0" step="0.01" /></label>' .
' <input type="number" name="gpa_low" min="0" max="99999" step="0.01" /></label>' .
' <label>&amp;' .
' <input type="number" name="gpa_high" min="0" step="0.01" /></label>
' <input type="number" name="gpa_high" min="0" max="99999" step="0.01" /></label>
</td></tr>';
}
}
Expand Down Expand Up @@ -1091,9 +1091,9 @@ function extra( $extra )
function html()
{
return '<tr class="st"><td>' . _( 'Balance' ) . '</td><td><label>' . _( 'Between' ) .
' <input type="number" name="balance_low" step="any" /></label>' .
' <input type="number" name="balance_low" step="0.01" min="-999999999999999" max="999999999999999" /></label>' .
' <label>&amp;' .
' <input type="number" name="balance_high" step="any" /></label>
' <input type="number" name="balance_high" step="0.01" min="-999999999999999" max="999999999999999" /></label>
</td></tr>';
}
}
Expand Down Expand Up @@ -1895,8 +1895,8 @@ function html( $value = '' )
<input type="radio" name="fsa_bal_ge" value="" checked /> &lt;</label>&nbsp;
<label class="sizep2">
<input type="radio" name="fsa_bal_ge" value="Y" /> &ge;</label>
<input name="fsa_balance" id="fsa_balance" type="number" step="any"' .
( $value ? ' value="' . AttrEscape( $value ) . '"' : '') . ' />
<input name="fsa_balance" id="fsa_balance" type="number" step="0.01"' .
( $value ? ' value="' . AttrEscape( $value ) . '"' : '') . ' min="-999999999999999" max="999999999999999" />
</td></tr>';
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/Accounting/functions.inc.php
Expand Up @@ -39,7 +39,7 @@ function _makeIncomesTextInput( $value, $column )

if ( $column === 'AMOUNT' )
{
$extra = ' type="number" step="any"';
$extra = ' type="number" step="0.01" max="999999999999" min="-999999999999"';
}
elseif ( ! $value )
{
Expand Down Expand Up @@ -106,7 +106,7 @@ function _makePaymentsTextInput( $value, $name )

if ( $name === 'AMOUNT' )
{
$extra = ' type="number" step="any"';
$extra = ' type="number" step="0.01" max="999999999999" min="-999999999999"';
}
elseif ( ! $value )
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Food_Service/MenuItems.php
Expand Up @@ -484,7 +484,7 @@ function makeTextInput( $value, $name )
}
elseif ( mb_strpos( $name, 'PRICE' ) !== false )
{
$extra = ' type="number" step="any" min="-9999999" max="9999999"';
$extra = ' type="number" step="0.01" min="-999999999" max="999999999"';
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Food_Service/Students/Transactions.php
Expand Up @@ -175,7 +175,7 @@ function options_locale( $option )
'',
'values[AMOUNT]',
'',
'type="number" step="any" max="9999999" min="0" required'
'type="number" step="0.01" max="999999999999" min="0" required'
);

$link['add']['html']['remove'] = button( 'add' );
Expand Down
2 changes: 1 addition & 1 deletion modules/Food_Service/Users/Transactions.php
Expand Up @@ -149,7 +149,7 @@ function options_locale( $option )
'',
'values[AMOUNT]',
'',
'type="number" step="any" max="9999999" min="0" required'
'type="number" step="0.01" max="999999999999" min="0" required'
);

$link['add']['html']['remove'] = button( 'add' );
Expand Down
6 changes: 3 additions & 3 deletions modules/School_Setup/Configuration.php
Expand Up @@ -686,21 +686,21 @@
ProgramConfig( 'food_service', 'FOOD_SERVICE_BALANCE_WARNING' ),
'values[PROGRAM_CONFIG][food_service][FOOD_SERVICE_BALANCE_WARNING]',
_( 'Food Service Balance minimum amount for warning' ),
' type="number" step="any" required'
' type="number" step="0.01" max="999999999999" min="-999999999999" required'
) . '</td></tr>';

echo '<tr><td>' . TextInput(
ProgramConfig( 'food_service', 'FOOD_SERVICE_BALANCE_MINIMUM' ),
'values[PROGRAM_CONFIG][food_service][FOOD_SERVICE_BALANCE_MINIMUM]',
_( 'Food Service Balance minimum amount' ),
' type="number" step="any" required'
' type="number" step="0.01" max="999999999999" min="-999999999999" required'
) . '</td></tr>';

echo '<tr><td>' . TextInput(
ProgramConfig( 'food_service', 'FOOD_SERVICE_BALANCE_TARGET' ),
'values[PROGRAM_CONFIG][food_service][FOOD_SERVICE_BALANCE_TARGET]',
_( 'Food Service Balance target amount' ),
' type="number" step="any" required'
' type="number" step="0.01" max="999999999999" min="-999999999999" required'
) . '</td></tr></table>';
}

Expand Down
2 changes: 1 addition & 1 deletion modules/Student_Billing/MassAssignFees.php
Expand Up @@ -72,7 +72,7 @@
'',
'amount',
_( 'Amount' ),
' type="number" step="any" required'
' type="number" step="0.01" max="999999999999" min="-999999999999" required'
) . '</td></tr>';

echo '<tr><td>' . DateInput( '', 'due', _( 'Due Date' ), false ) . '</td></tr>';
Expand Down
2 changes: 1 addition & 1 deletion modules/Student_Billing/MassAssignPayments.php
Expand Up @@ -72,7 +72,7 @@
'',
'amount',
_( 'Amount' ),
' type="number" step="any" required'
' type="number" step="0.01" max="999999999999" min="-999999999999" required'
) . '</td></tr>';

echo '<tr><td>' . DateInput(
Expand Down
4 changes: 2 additions & 2 deletions modules/Student_Billing/functions.inc.php
Expand Up @@ -115,7 +115,7 @@ function _makeFeesTextInput( $value, $name )

if ( $name === 'AMOUNT' )
{
$extra = ' type="number" step="any"';
$extra = ' type="number" step="0.01" max="999999999999" min="-999999999999"';
}
elseif ( ! $value )
{
Expand Down Expand Up @@ -173,7 +173,7 @@ function _makePaymentsTextInput( $value, $name )

if ( $name === 'AMOUNT' )
{
$extra = ' type="number" step="any"';
$extra = ' type="number" step="0.01" max="999999999999" min="-999999999999"';
}
elseif ( ! $value )
{
Expand Down

0 comments on commit 386a5e2

Please sign in to comment.