Commit ba9421a2 authored by François Jacquet's avatar François Jacquet

Format PHP code

Some equality checks were changed from == to === and != to !==
parent 8156c56c
......@@ -10,6 +10,7 @@ Changes in 4.6
- PHP 7.3 compat: use count() for array variables only, program wide
- SQL ELIGIBILITY_ACTIVITIES table: Add COMMENT column in Update.fnc.php & rosariosis.sql
- Add Comment column to Activities list in Activities.php
- Format PHP code, program wide
Changes in 4.5.1
----------------
......
This diff is collapsed.
......@@ -821,9 +821,9 @@ function _makeSchoolInput( $value, $column )
}
// Mab - allow school to be edited if illegal value.
if ( $_REQUEST['student_id'] != 'new' )
if ( $_REQUEST['student_id'] !== 'new' )
{
if ( $id != 'new' )
if ( $id !== 'new' )
{
if ( is_array( $schools[ $value ] ) )
{
......
......@@ -487,7 +487,7 @@ $addJavascripts .= 'var menuStudentID = "' . UserStudentID() . '",
</span>
<?php // CoursePeriod SELECT (Teachers only).
if ( User( 'PROFILE' ) == 'teacher' ) : ?>
if ( User( 'PROFILE' ) === 'teacher' ) : ?>
<?php // Error if no quarters.
......
......@@ -307,7 +307,7 @@ function appendStaffSQL( $sql, $extra = array() )
if ( isset( $_REQUEST['profile'] )
&& $_REQUEST['profile'] !== '' )
{
if ( User( 'PROFILE' ) == 'admin' )
if ( User( 'PROFILE' ) === 'admin' )
{
$options = array(
'admin' => _( 'Administrator' ),
......
This diff is collapsed.
......@@ -15,16 +15,17 @@ if ( $_REQUEST['values']
{
foreach ( (array) $_REQUEST['values'] as $id => $columns )
{
if ( $id!='new')
if ( $id !== 'new' )
{
$sql = "UPDATE ACCOUNTING_PAYMENTS SET ";
foreach ( (array) $columns as $column => $value)
foreach ( (array) $columns as $column => $value )
{
$sql .= DBEscapeIdentifier( $column ) . "='" . $value . "',";
}
$sql = mb_substr($sql,0,-1) . " WHERE ID='".$id."'";
DBQuery($sql);
$sql = mb_substr( $sql, 0, -1 ) . " WHERE ID='" . $id . "'";
DBQuery( $sql );
}
elseif ( $columns['AMOUNT'] !== ''
&& $columns['PAYMENT_DATE'] )
......@@ -34,29 +35,37 @@ if ( $_REQUEST['values']
$sql = "INSERT INTO ACCOUNTING_PAYMENTS ";
$fields = 'ID,SYEAR,SCHOOL_ID,';
$values = "'".$id."','".UserSyear()."','".UserSchool()."',";
$values = "'" . $id . "','" . UserSyear() . "','" . UserSchool() . "',";
$go = 0;
foreach ( (array) $columns as $column => $value)
foreach ( (array) $columns as $column => $value )
{
if ( !empty($value) || $value=='0')
if ( ! empty( $value ) || $value == '0' )
{
if ( $column=='AMOUNT')
if ( $column == 'AMOUNT' )
{
$value = preg_replace('/[^0-9.-]/','',$value);
$value = preg_replace( '/[^0-9.-]/', '', $value );
// FJ fix SQL bug invalid amount.
if ( !is_numeric($value))
if ( ! is_numeric( $value ) )
{
$value = 0;
}
}
$fields .= DBEscapeIdentifier( $column ) . ',';
$values .= "'" . $value . "',";
$go = true;
}
}
$sql .= '(' . mb_substr( $fields, 0, -1 ) . ') values(' . mb_substr( $values, 0, -1 ) . ')';
if ( $go)
DBQuery($sql);
if ( $go )
{
DBQuery( $sql );
}
}
}
......@@ -88,19 +97,24 @@ if ( ! $_REQUEST['modfunc'] )
'COMMENTS' => '_makePaymentsTextInput',
);
$payments_RET = DBGet( "SELECT '' AS REMOVE,ID,AMOUNT,PAYMENT_DATE,COMMENTS FROM ACCOUNTING_PAYMENTS WHERE SYEAR='".UserSyear()."' AND STAFF_ID IS NULL AND SCHOOL_ID='".UserSchool()."' ORDER BY ID",$functions);
$payments_RET = DBGet( "SELECT '' AS REMOVE,ID,AMOUNT,PAYMENT_DATE,COMMENTS FROM ACCOUNTING_PAYMENTS WHERE SYEAR='" . UserSyear() . "' AND STAFF_ID IS NULL AND SCHOOL_ID='" . UserSchool() . "' ORDER BY ID", $functions );
$i = 1;
$RET = array();
foreach ( (array) $payments_RET as $payment)
foreach ( (array) $payments_RET as $payment )
{
$RET[ $i ] = $payment;
$RET[$i] = $payment;
$i++;
}
if (! empty( $RET ) && ! $_REQUEST['print_statements'] && AllowEdit())
$columns = array('REMOVE' => '');
if ( ! empty( $RET ) && ! $_REQUEST['print_statements'] && AllowEdit() )
{
$columns = array( 'REMOVE' => '' );
}
else
{
$columns = array();
}
$columns += array(
'AMOUNT' => _( 'Amount' ),
......@@ -119,19 +133,23 @@ if ( ! $_REQUEST['modfunc'] )
);
}
if ( ! $_REQUEST['print_statements'] && AllowEdit())
if ( ! $_REQUEST['print_statements'] && AllowEdit() )
{
echo '<form action="Modules.php?modname='.$_REQUEST['modname'].'" method="POST">';
echo '<form action="Modules.php?modname=' . $_REQUEST['modname'] . '" method="POST">';
DrawHeader( '', SubmitButton() );
$options = array();
}
else
$options = array('center'=>false,'add'=>false);
{
$options = array( 'center' => false, 'add' => false );
}
ListOutput($RET,$columns,'Expense','Expenses',$link,array(),$options);
ListOutput( $RET, $columns, 'Expense', 'Expenses', $link, array(), $options );
if ( ! $_REQUEST['print_statements'] && AllowEdit())
if ( ! $_REQUEST['print_statements'] && AllowEdit() )
{
echo '<div class="center">' . SubmitButton() . '</div>';
}
echo '<br />';
......@@ -140,39 +158,41 @@ if ( ! $_REQUEST['modfunc'] )
WHERE f.SYEAR='" . UserSyear() . "'
AND f.SCHOOL_ID='" . UserSchool() . "'" );
$table = '<table class="align-right"><tr><td>'._('Total from Incomes').': '.'</td><td>'.Currency( $incomes_total ).'</td></tr>';
$table = '<table class="align-right"><tr><td>' . _( 'Total from Incomes' ) . ': ' . '</td><td>' . Currency( $incomes_total ) . '</td></tr>';
$table .= '<tr><td>'._('Less').': '._('Total from Expenses').': '.'</td><td>'.Currency($payments_total).'</td></tr>';
$table .= '<tr><td>' . _( 'Less' ) . ': ' . _( 'Total from Expenses' ) . ': ' . '</td><td>' . Currency( $payments_total ) . '</td></tr>';
$table .= '<tr><td>'._('Balance').': <b>'.'</b></td><td><b id="update_balance">'.Currency(($incomes_total-$payments_total)).'</b></td></tr>';
$table .= '<tr><td>' . _( 'Balance' ) . ': <b>' . '</b></td><td><b id="update_balance">' . Currency( ( $incomes_total - $payments_total ) ) . '</b></td></tr>';
//add General Balance
$table .= '<tr><td colspan="2"><hr /></td></tr><tr><td>'._('Total from Incomes').': '.'</td><td>'.Currency($incomes_total).'</td></tr>';
$table .= '<tr><td colspan="2"><hr /></td></tr><tr><td>' . _( 'Total from Incomes' ) . ': ' . '</td><td>' . Currency( $incomes_total ) . '</td></tr>';
if ( $RosarioModules['Student_Billing'])
if ( $RosarioModules['Student_Billing'] )
{
$student_payments_total = DBGetOne( "SELECT SUM(p.AMOUNT) AS TOTAL
FROM BILLING_PAYMENTS p
WHERE p.SYEAR='".UserSyear()."'
AND p.SCHOOL_ID='".UserSchool()."'" );
WHERE p.SYEAR='" . UserSyear() . "'
AND p.SCHOOL_ID='" . UserSchool() . "'" );
$table .= '<tr><td>& '._('Total from Student Payments').': '.'</td><td>'.Currency($student_payments_total).'</td></tr>';
$table .= '<tr><td>& ' . _( 'Total from Student Payments' ) . ': ' . '</td><td>' . Currency( $student_payments_total ) . '</td></tr>';
}
else
{
$student_payments_total = 0;
}
$table .= '<tr><td>'._('Less').': '._('Total from Expenses').': '.'</td><td>'.Currency($payments_total).'</td></tr>';
$table .= '<tr><td>' . _( 'Less' ) . ': ' . _( 'Total from Expenses' ) . ': ' . '</td><td>' . Currency( $payments_total ) . '</td></tr>';
$staff_payments_total = DBGetOne( "SELECT SUM(p.AMOUNT) AS TOTAL
FROM ACCOUNTING_PAYMENTS p
WHERE p.STAFF_ID IS NOT NULL
AND p.SYEAR='".UserSyear()."'
AND p.SCHOOL_ID='".UserSchool()."'" );
AND p.SYEAR='" . UserSyear() . "'
AND p.SCHOOL_ID='" . UserSchool() . "'" );
$table .= '<tr><td>& '._('Total from Staff Payments').': '.'</td><td>'.Currency($staff_payments_total).'</td></tr>';
$table .= '<tr><td>& ' . _( 'Total from Staff Payments' ) . ': ' . '</td><td>' . Currency( $staff_payments_total ) . '</td></tr>';
$table .= '<tr><td>' . _( 'General Balance' ) . ': </td>
<td><b id="update_balance">' . Currency( ( $incomes_total + $student_payments_total - $payments_total - $staff_payments_total ) ) .
<td><b id="update_balance">' . Currency( ( $incomes_total + $student_payments_total - $payments_total - $staff_payments_total ) ) .
'</b></td></tr></table>';
DrawHeader( $table );
......
......@@ -14,18 +14,19 @@ if ( $_REQUEST['values']
&& $_POST['values']
&& AllowEdit() )
{
foreach ( (array) $_REQUEST['values'] as $id => $columns)
foreach ( (array) $_REQUEST['values'] as $id => $columns )
{
if ( $id!='new')
if ( $id !== 'new' )
{
$sql = "UPDATE ACCOUNTING_INCOMES SET ";
foreach ( (array) $columns as $column => $value)
foreach ( (array) $columns as $column => $value )
{
$sql .= DBEscapeIdentifier( $column ) . "='" . $value . "',";
}
$sql = mb_substr($sql,0,-1) . " WHERE ID='".$id."'";
DBQuery($sql);
$sql = mb_substr( $sql, 0, -1 ) . " WHERE ID='" . $id . "'";
DBQuery( $sql );
}
elseif ( $columns['AMOUNT'] !== ''
&& $columns['ASSIGNED_DATE'] )
......@@ -33,24 +34,31 @@ if ( $_REQUEST['values']
$sql = "INSERT INTO ACCOUNTING_INCOMES ";
$fields = 'ID,SCHOOL_ID,SYEAR,';
$values = db_seq_nextval('ACCOUNTING_INCOMES_SEQ').",'".UserSchool()."','".UserSyear()."',";
$values = db_seq_nextval( 'ACCOUNTING_INCOMES_SEQ' ) . ",'" . UserSchool() . "','" . UserSyear() . "',";
$go = 0;
foreach ( (array) $columns as $column => $value)
foreach ( (array) $columns as $column => $value )
{
if ( !empty($value) || $value=='0')
if ( ! empty( $value ) || $value == '0' )
{
if ( $column=='AMOUNT')
$value = preg_replace('/[^0-9.-]/','',$value);
if ( $column == 'AMOUNT' )
{
$value = preg_replace( '/[^0-9.-]/', '', $value );
}
$fields .= DBEscapeIdentifier( $column ) . ',';
$values .= "'" . $value . "',";
$go = true;
}
}
$sql .= '(' . mb_substr( $fields, 0, -1 ) . ') values(' . mb_substr( $values, 0, -1 ) . ')';
if ( $go)
DBQuery($sql);
if ( $go )
{
DBQuery( $sql );
}
}
}
......@@ -82,19 +90,24 @@ if ( ! $_REQUEST['modfunc'] )
'AMOUNT' => '_makeIncomesAmount',
);
$incomes_RET = DBGet( "SELECT '' AS REMOVE,f.ID,f.TITLE,f.ASSIGNED_DATE,f.COMMENTS,f.AMOUNT FROM ACCOUNTING_INCOMES f WHERE f.SYEAR='".UserSyear()."' AND f.SCHOOL_ID='".UserSchool()."' ORDER BY f.ASSIGNED_DATE",$functions);
$incomes_RET = DBGet( "SELECT '' AS REMOVE,f.ID,f.TITLE,f.ASSIGNED_DATE,f.COMMENTS,f.AMOUNT FROM ACCOUNTING_INCOMES f WHERE f.SYEAR='" . UserSyear() . "' AND f.SCHOOL_ID='" . UserSchool() . "' ORDER BY f.ASSIGNED_DATE", $functions );
$i = 1;
$RET = array();
foreach ( (array) $incomes_RET as $income)
foreach ( (array) $incomes_RET as $income )
{
$RET[ $i ] = $income;
$RET[$i] = $income;
$i++;
}
if (! empty( $RET ) && ! $_REQUEST['print_statements'] && AllowEdit() && !isset($_REQUEST['_ROSARIO_PDF']))
$columns = array('REMOVE' => '');
if ( ! empty( $RET ) && ! $_REQUEST['print_statements'] && AllowEdit() && ! isset( $_REQUEST['_ROSARIO_PDF'] ) )
{
$columns = array( 'REMOVE' => '' );
}
else
{
$columns = array();
}
$columns += array(
'TITLE' => _( 'Income' ),
......@@ -116,15 +129,21 @@ if ( ! $_REQUEST['modfunc'] )
if ( empty( $_REQUEST['print_statements'] ) )
{
echo '<form action="Modules.php?modname='.$_REQUEST['modname'].'" method="POST">';
if (AllowEdit())
echo '<form action="Modules.php?modname=' . $_REQUEST['modname'] . '" method="POST">';
if ( AllowEdit() )
{
DrawHeader( '', SubmitButton() );
}
$options = array();
}
else
$options = array('center'=>false);
{
$options = array( 'center' => false );
}
ListOutput($RET,$columns,'Income','Incomes',$link,array(),$options);
ListOutput( $RET, $columns, 'Income', 'Incomes', $link, array(), $options );
if ( ! $_REQUEST['print_statements']
&& AllowEdit() )
......@@ -137,42 +156,44 @@ if ( ! $_REQUEST['modfunc'] )
$payments_total = DBGetOne( "SELECT SUM(p.AMOUNT) AS TOTAL
FROM ACCOUNTING_PAYMENTS p
WHERE p.STAFF_ID IS NULL
AND p.SYEAR='".UserSyear()."'
AND p.SCHOOL_ID='".UserSchool()."'" );
AND p.SYEAR='" . UserSyear() . "'
AND p.SCHOOL_ID='" . UserSchool() . "'" );
$table = '<table class="align-right"><tr><td>'._('Total from Incomes').': '.'</td><td>'.Currency($incomes_total).'</td></tr>';
$table = '<table class="align-right"><tr><td>' . _( 'Total from Incomes' ) . ': ' . '</td><td>' . Currency( $incomes_total ) . '</td></tr>';
$table .= '<tr><td>'._('Less').': '._('Total from Expenses').': '.'</td><td>'.Currency($payments_total).'</td></tr>';
$table .= '<tr><td>' . _( 'Less' ) . ': ' . _( 'Total from Expenses' ) . ': ' . '</td><td>' . Currency( $payments_total ) . '</td></tr>';
$table .= '<tr><td>'._('Balance').': <b>'.'</b></td><td><b id="update_balance">'.Currency(($incomes_total-$payments_total)).'</b></td></tr>';
$table .= '<tr><td>' . _( 'Balance' ) . ': <b>' . '</b></td><td><b id="update_balance">' . Currency( ( $incomes_total - $payments_total ) ) . '</b></td></tr>';
//add General Balance
$table .= '<tr><td colspan="2"><hr /></td></tr><tr><td>'._('Total from Incomes').': '.'</td><td>'.Currency($incomes_total).'</td></tr>';
$table .= '<tr><td colspan="2"><hr /></td></tr><tr><td>' . _( 'Total from Incomes' ) . ': ' . '</td><td>' . Currency( $incomes_total ) . '</td></tr>';
if ( $RosarioModules['Student_Billing'])
if ( $RosarioModules['Student_Billing'] )
{
$student_payments_total = DBGetOne( "SELECT SUM(p.AMOUNT) AS TOTAL
FROM BILLING_PAYMENTS p
WHERE p.SYEAR='".UserSyear()."'
AND p.SCHOOL_ID='".UserSchool()."'" );
WHERE p.SYEAR='" . UserSyear() . "'
AND p.SCHOOL_ID='" . UserSchool() . "'" );
$table .= '<tr><td>& '._('Total from Student Payments').': '.'</td><td>'.Currency($student_payments_total).'</td></tr>';
$table .= '<tr><td>& ' . _( 'Total from Student Payments' ) . ': ' . '</td><td>' . Currency( $student_payments_total ) . '</td></tr>';
}
else
{
$student_payments_total[1]['TOTAL'] = 0;
}
$table .= '<tr><td>'._('Less').': '._('Total from Expenses').': '.'</td><td>'.Currency($payments_total).'</td></tr>';
$table .= '<tr><td>' . _( 'Less' ) . ': ' . _( 'Total from Expenses' ) . ': ' . '</td><td>' . Currency( $payments_total ) . '</td></tr>';
$staff_payments_total = DBGetOne( "SELECT SUM(p.AMOUNT) AS TOTAL
FROM ACCOUNTING_PAYMENTS p
WHERE p.STAFF_ID IS NOT NULL
AND p.SYEAR='".UserSyear()."'
AND p.SCHOOL_ID='".UserSchool()."'" );
AND p.SYEAR='" . UserSyear() . "'
AND p.SCHOOL_ID='" . UserSchool() . "'" );
$table .= '<tr><td>& '._('Total from Staff Payments').': '.'</td><td>'.Currency($staff_payments_total).'</td></tr>';
$table .= '<tr><td>& ' . _( 'Total from Staff Payments' ) . ': ' . '</td><td>' . Currency( $staff_payments_total ) . '</td></tr>';
$table .= '<tr><td>' . _( 'General Balance' ) . ': </td>
<td><b id="update_balance">' . Currency( ( $incomes_total + $student_payments_total - $payments_total - $staff_payments_total ) ) .
<td><b id="update_balance">' . Currency( ( $incomes_total + $student_payments_total - $payments_total - $staff_payments_total ) ) .
'</b></td></tr></table>';
DrawHeader( $table );
......
<?php
require_once 'modules/Accounting/functions.inc.php';
if (User('PROFILE')=='teacher')//limit to teacher himself
$_REQUEST['staff_id'] = User('STAFF_ID');
if ( User( 'PROFILE' ) === 'teacher' ) //limit to teacher himself
{
$_REQUEST['staff_id'] = User( 'STAFF_ID' );
}
if ( empty( $_REQUEST['print_statements'] ) )
{
......@@ -19,43 +22,52 @@ if ( $_REQUEST['values']
// Add eventual Dates to $_REQUEST['values'].
AddRequestedDates( 'values', 'post' );
foreach ( (array) $_REQUEST['values'] as $id => $columns)
foreach ( (array) $_REQUEST['values'] as $id => $columns )
{
if ( $id!='new')
if ( $id !== 'new' )
{
$sql = "UPDATE ACCOUNTING_SALARIES SET ";
foreach ( (array) $columns as $column => $value)
foreach ( (array) $columns as $column => $value )
{
$sql .= DBEscapeIdentifier( $column ) . "='" . $value . "',";
}
$sql = mb_substr($sql,0,-1) . " WHERE STAFF_ID='".UserStaffID()."' AND ID='".$id."'";
DBQuery($sql);
$sql = mb_substr( $sql, 0, -1 ) . " WHERE STAFF_ID='" . UserStaffID() . "' AND ID='" . $id . "'";
DBQuery( $sql );
}
// New: check for Title
elseif ( $columns['TITLE'] )
{
$sql = "INSERT INTO ACCOUNTING_SALARIES ";
$fields = 'ID,STAFF_ID,SCHOOL_ID,SYEAR,ASSIGNED_DATE,';
$values = db_seq_nextval('ACCOUNTING_SALARIES_SEQ').",'".UserStaffID()."','".UserSchool()."','".UserSyear()."','".DBDate()."',";
$values = db_seq_nextval( 'ACCOUNTING_SALARIES_SEQ' ) . ",'" . UserStaffID() . "','" . UserSchool() . "','" . UserSyear() . "','" . DBDate() . "',";
$go = 0;
foreach ( (array) $columns as $column => $value)
foreach ( (array) $columns as $column => $value )
{
if ( !empty($value) || $value=='0')
if ( ! empty( $value ) || $value == '0' )
{
if ( $column=='AMOUNT')
$value = preg_replace('/[^0-9.-]/','',$value);
if ( $column == 'AMOUNT' )
{
$value = preg_replace( '/[^0-9.-]/', '', $value );
}
$fields .= DBEscapeIdentifier( $column ) . ',';
$values .= "'" . $value . "',";
$go = true;
}
}
$sql .= '(' . mb_substr( $fields, 0, -1 ) . ') values(' . mb_substr( $values, 0, -1 ) . ')';
if ( $go)
DBQuery($sql);
if ( $go )
{
DBQuery( $sql );
}
}
}
......@@ -76,57 +88,75 @@ if ( $_REQUEST['modfunc'] === 'remove'
}
}
if (UserStaffID() && ! $_REQUEST['modfunc'])
if ( UserStaffID() && ! $_REQUEST['modfunc'] )
{
$salaries_total = 0;
$functions = array('REMOVE' => '_makeSalariesRemove','ASSIGNED_DATE' => 'ProperDate','DUE_DATE' => '_makeSalariesDateInput','COMMENTS' => '_makeSalariesTextInput','AMOUNT' => '_makeSalariesAmount');
$salaries_RET = DBGet( "SELECT '' AS REMOVE,f.ID,f.TITLE,f.ASSIGNED_DATE,f.DUE_DATE,f.COMMENTS,f.AMOUNT FROM ACCOUNTING_SALARIES f WHERE f.STAFF_ID='".UserStaffID()."' AND f.SYEAR='".UserSyear()."' AND f.SCHOOL_ID='".UserSchool()."' ORDER BY f.ASSIGNED_DATE",$functions);
$functions = array( 'REMOVE' => '_makeSalariesRemove', 'ASSIGNED_DATE' => 'ProperDate', 'DUE_DATE' => '_makeSalariesDateInput', 'COMMENTS' => '_makeSalariesTextInput', 'AMOUNT' => '_makeSalariesAmount' );
$salaries_RET = DBGet( "SELECT '' AS REMOVE,f.ID,f.TITLE,f.ASSIGNED_DATE,f.DUE_DATE,f.COMMENTS,f.AMOUNT FROM ACCOUNTING_SALARIES f WHERE f.STAFF_ID='" . UserStaffID() . "' AND f.SYEAR='" . UserSyear() . "' AND f.SCHOOL_ID='" . UserSchool() . "' ORDER BY f.ASSIGNED_DATE", $functions );
$i = 1;
$RET = array();
foreach ( (array) $salaries_RET as $salary)
foreach ( (array) $salaries_RET as $salary )
{
$RET[ $i ] = $salary;
$RET[$i] = $salary;
$i++;
}
if (! empty( $RET ) && ! $_REQUEST['print_statements'] && AllowEdit() && !isset($_REQUEST['_ROSARIO_PDF']))
$columns = array('REMOVE' => '');
if ( ! empty( $RET ) && ! $_REQUEST['print_statements'] && AllowEdit() && ! isset( $_REQUEST['_ROSARIO_PDF'] ) )
{
$columns = array( 'REMOVE' => '' );
}
else
{
$columns = array();
}
$columns += array( 'TITLE' => _( 'Salary' ), 'AMOUNT' => _( 'Amount' ), 'ASSIGNED_DATE' => _( 'Assigned' ), 'DUE_DATE' => _( 'Due' ), 'COMMENTS' => _( 'Comment' ) );
$columns += array('TITLE' => _('Salary'),'AMOUNT' => _('Amount'),'ASSIGNED_DATE' => _('Assigned'),'DUE_DATE' => _('Due'),'COMMENTS' => _('Comment'));
if ( empty( $_REQUEST['print_statements'] ) )
$link['add']['html'] = array('REMOVE'=>button('add'),'TITLE'=>_makeSalariesTextInput('','TITLE'),'AMOUNT'=>_makeSalariesTextInput('','AMOUNT'),'ASSIGNED_DATE'=>ProperDate(DBDate()),'DUE_DATE'=>_makeSalariesDateInput('','DUE_DATE'),'COMMENTS'=>_makeSalariesTextInput('','COMMENTS'));
{
$link['add']['html'] = array( 'REMOVE' => button( 'add' ), 'TITLE' => _makeSalariesTextInput( '', 'TITLE' ), 'AMOUNT' => _makeSalariesTextInput( '', 'AMOUNT' ), 'ASSIGNED_DATE' => ProperDate( DBDate() ), 'DUE_DATE' => _makeSalariesDateInput( '', 'DUE_DATE' ), 'COMMENTS' => _makeSalariesTextInput( '', 'COMMENTS' ) );
}
if ( empty( $_REQUEST['print_statements'] ) )
{
echo '<form action="Modules.php?modname='.$_REQUEST['modname'].'" method="POST">';
if (AllowEdit())
echo '<form action="Modules.php?modname=' . $_REQUEST['modname'] . '" method="POST">';
if ( AllowEdit() )
{
DrawHeader( '', SubmitButton() );
}
$options = array();
}
else
$options = array('center'=>false);
{
$options = array( 'center' => false );
}
ListOutput($RET,$columns,'Salary','Salaries',$link,array(),$options);
ListOutput( $RET, $columns, 'Salary', 'Salaries', $link, array(), $options );
if ( ! $_REQUEST['print_statements'] && AllowEdit())
if ( ! $_REQUEST['print_statements'] && AllowEdit() )
{
echo '<div class="center">' . SubmitButton() . '</div>';
}
echo '<br />';
if ( empty( $_REQUEST['print_statements'] ) )
{
$payments_total = DBGetOne( "SELECT SUM(p.AMOUNT) AS TOTAL
FROM ACCOUNTING_PAYMENTS p
WHERE p.STAFF_ID='".UserStaffID()."'
AND p.SYEAR='".UserSyear()."'
AND p.SCHOOL_ID='".UserSchool()."'" );
WHERE p.STAFF_ID='" . UserStaffID() . "'
AND p.SYEAR='" . UserSyear() . "'
AND p.SCHOOL_ID='" . UserSchool() . "'" );
$table = '<table class="align-right"><tr><td>'._('Total from Salaries').': '.'</td><td>'.Currency($salaries_total).'</td></tr>';
$table = '<table class="align-right"><tr><td>' . _( 'Total from Salaries' ) . ': ' . '</td><td>' . Currency( $salaries_total ) . '</td></tr>';
$table .= '<tr><td>'._('Less').': '._('Total from Staff Payments').': '.'</td><td>'.Currency($payments_total).'</td></tr>';
$table .= '<tr><td>' . _( 'Less' ) . ': ' . _( 'Total from Staff Payments' ) . ': ' . '</td><td>' . Currency( $payments_total ) . '</td></tr>';
$table .= '<tr><td>' . _( 'Balance' ) . ': </td>
<td><b>' . Currency( ( $salaries_total - $payments_total ), 'CR' ) .
<td><b>' . Currency( ( $salaries_total - $payments_total ), 'CR' ) .
'</b></td></tr></table>';
DrawHeader( $table );
......
<?php
DrawHeader(ProgramTitle());
DrawHeader( ProgramTitle() );
$extra['SELECT'] = ",(COALESCE(
(SELECT SUM(f.AMOUNT)
......@@ -15,18 +15,24 @@ $extra['SELECT'] = ",(COALESCE(
AND p.SYEAR=s.SYEAR)
,0)) AS BALANCE";
$extra['columns_after'] = array('BALANCE' => _('Balance'));
$extra['columns_after'] = array( 'BALANCE' => _( 'Balance' ) );
$extra['link']['FULL_NAME'] = false;
$extra['new'] = true;
$extra['functions'] = array('BALANCE' => '_makeCurrency');
$extra['functions'] = array( 'BALANCE' => '_makeCurrency' );
if (User('PROFILE')=='parent' || User('PROFILE')=='teacher')
if ( User( 'PROFILE' ) === 'parent' || User( 'PROFILE' ) === 'teacher' )
{
$_REQUEST['search_modfunc'] = 'list';
Search('staff_id',$extra);
}
function _makeCurrency($value,$column)
Search( 'staff_id', $extra );
/**
* @param $value
* @param $column
*/
function _makeCurrency( $value, $column )
{
return Currency($value*-1);
return Currency( $value * -1 );
}
<?php
require_once 'modules/Accounting/functions.inc.php';