Example #1
0
                 print '<td>BILLING INITIALLY APPROVED</td>';
             } elseif ($row['accounting_approval'] && $row['billing_initial_approval'] && !$row['billing_final_approval']) {
                 print '<td>ACCOUNTING APPROVED</td>';
             } elseif ($row['accounting_approval'] && $row['billing_initial_approval'] && $row['billing_final_approval']) {
                 print '<td>COMPLETED</td>';
             } elseif ($row['status'] == "REJECTED") {
                 print '<td>REJECTED</td>';
             } elseif ($row['status'] == "VOIDED") {
                 print '<td>VOIDED</td>';
             } elseif ($row['accounting_approval'] && !$row['billing_initial_approval'] && !$row['billing_final_approval']) {
                 print '<td>ACCOUNTING APPROVED</td>';
             }
             print '<td>' . $refund_assigned_to . '</td>';
             print '</td></tr>';
         }
         instantiate_page_variables($row, $tempOrigStartPosition, $page, $URL_String_BACK, $URL_String_FORWARD);
     }
     if ($currentRowSize > $_SESSION['RowsPerPage']) {
         //only conditionally display the pagination
         displayPagination($row, $tempOrigStartPosition, $URL_String_BACK, $URL_String_FORWARD);
     }
 } elseif (array_key_exists('userid', $_SESSION)) {
     //If user is logged in show page
     if (isset($_POST['_search_submit']) && $_POST['_search_submit'] != "" && $_POST['_search_submit'] != NULL) {
         showSearchPage($_SESSION['username'], $_SESSION['access']);
         $userIDSearched = "";
         if (isset($_POST['refund_search_term']) && strpos($_POST['refund_search_term'], '_by')) {
             echo '<center> Please further specify by selecting a name from the drop down below: </center>';
             echo '<br>';
             $query_users = 'SELECT user_id, first_name, last_name FROM users';
             $result_users = mysqli_query($db, $query_users);
Example #2
0
function reportNew()
{
    //include 'dump_all_page_contents.php';
    showHeaderALL($_SESSION['username'], $_SESSION['access']);
    include 'connectToDB.php';
    include 'pagination_functionality.php';
    //echo 'will print';
    //die();
    //Upon initial login to the app set some of the initial global settings
    $_SESSION['RowsPerPage'] = 10;
    $_SESSION['initialOffset'] = 0;
    ///////////////////////////////////////////////////////////////////////////////
    instantiate_initialOffset();
    if ($accessLvl == 'U') {
        //is access is only at the user level, then must match the refunds pulled to display only the current users created refunds
        if (!isset($_SESSION['order'])) {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount, status,refund_id, payable,assigned_to \n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.created_by = U.user_id \n\t\t\tWHERE status !='deleted' AND status !='VOIDED' AND status='NEW' \n\t\t\tORDER BY dt_request,U.last_name,status LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        } else {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount, status,refund_id, payable,assigned_to \n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.created_by = U.user_id \n\t\t\tWHERE status !='deleted' AND status !='VOIDED' AND status='NEW' \n\t\t\tORDER BY " . $_SESSION['order'] . " LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        }
    } else {
        if (!isset($_SESSION['order'])) {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount, status,refund_id, payable,assigned_to,\n\t\t\taccounting_approval,billing_initial_approval,billing_final_approval \n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.created_by = U.user_id \n\t\t\tWHERE status !='deleted' AND status !='VOIDED' AND status='NEW'\n\t\t\tORDER BY dt_request,U.last_name,status LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        } else {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount, status,refund_id, payable,assigned_to,\n\t\t\taccounting_approval,billing_initial_approval,billing_final_approval \t\t\t\n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.created_by = U.user_id \n\t\t\tWHERE status !='deleted' AND accounting_approval=0 AND status='NEW' \n\t\t\tORDER BY " . $_SESSION['order'] . " LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        }
    }
    $result = mysqli_query($db, $query);
    $arrayRefundUsers = array();
    $queryUserIDs = "SELECT user_id, first_name, last_name FROM users";
    $resultUserIDs = mysqli_query($db, $queryUserIDs);
    $ctr = 0;
    while ($row = mysqli_fetch_array($resultUserIDs)) {
        $arrayRefundUsers[$row['user_id']] = $row['first_name'] . ' ' . $row['last_name'];
    }
    ///////HEADINGS FROM THE REFUNDS PAGE//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    print '<br><br>';
    print '<center>Displaying: <b>NEW Refunds Report</b></center>';
    print '<br /><br /><div align = "center">';
    print '<table border="1" cellpadding = "3">
	<tr>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?encounter_num=y>Encounter Number</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?refund_id=y>Refund ID</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?encounter_date=y>Date Requested</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?encounter_date=y>Urgent</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?requested_by=y>Requested By</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?payable_order=y>Payable To</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?amount_order=y>Amount</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?status_order=y>Status</a></b></center></td>
	<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?status_order=y>Assigned To</a></b></center></td>';
    ///////END HEADINGS FROM THE REFUNDS PAGE////////////////////?////////////////////////////////////////////////////////////////////////////////////////////////////////
    $current_date = date("Y-m-d H:i:s");
    while ($row = mysqli_fetch_array($result)) {
        $today_dt = $entered_dt = $interval = $refund_requested_by = $date_requested = $refund_assigned_to = $interval = "";
        calculateInterval($row, $refund_requested_by, $date_requested, $today_dt, $entered_dt, $interval, $refund_assigned_to);
        //$refund_assigned_to=$row['assigned_to'];
        $currentRowSize = sizeof($row);
        $refund_assigned_to = "";
        $queryUserIDs = "SELECT first_name, last_name FROM users WHERE user_id= '{$row['assigned_to']}'";
        $resultUserIDs = mysqli_query($db, $queryUserIDs);
        while ($rowUserIds = mysqli_fetch_array($resultUserIDs)) {
            //build up the assigned to username
            $refund_assigned_to = $rowUserIds['first_name'] . ' ' . $rowUserIds['last_name'];
        }
        if ($result_display_ctr < $_SESSION['RowsPerPage']) {
            $result_display_ctr++;
            if ($interval->days > 30 && $row['status'] != "COMPLETED") {
                print '<tr bgcolor=#FF0000>';
            } elseif ($interval->days >= 15 && $interval->days < 30 && $row['status'] != "COMPLETED") {
                print '<tr bgcolor=yellow>';
            } elseif ($interval->days <= 1 && $row['status'] != "COMPLETED") {
                print '<tr bgcolor=#009900>';
            } else {
                print '<tr>';
            }
            //print '<tr>
            print '<td><a href="' . $_SERVER['PHP_SELF'] . '?refund_id=' . $row['refund_id'] . '&action=edit">' . $row['NG_enc_id'] . '</a></td>
		<td><a href="' . $_SERVER['PHP_SELF'] . '?refund_id=' . $row['refund_id'] . '&action=edit">' . $row['refund_id'] . '</a></td>
		<td>' . $row['dt_request'] . '</td>
		<td>' . ($row['urgent'] ? 'Yes' : 'No') . '</td>
		<td>' . $row['first_name'] . ' ' . $row['last_name'] . '</td>
		<td>' . $row['payable'] . '</td>';
            print '<td>$ ' . $row['amount'] . '</td>';
            if (!$row['accounting_approval'] && !$row['billing_initial_approval'] && !$row['billing_final_approval']) {
                print '<td>NEW</td>';
            } elseif (!$row['accounting_approval'] && $row['billing_initial_approval']) {
                print '<td>ACCOUNTING APPROVAL</td>';
            } elseif ($row['accounting_approval'] && $row['billing_initial_approval'] && !$row['billing_final_approval']) {
                print '<td>ACCOUNTING APPROVED</td>';
            } elseif ($row['accounting_approval'] && $row['billing_initial_approval'] && $row['billing_final_approval']) {
                print '<td>COMPLETED</td>';
            } elseif ($row['status'] == "REJECTED") {
                print '<td>REJECTED</td>';
            } elseif ($row['status'] == "VOIDED") {
                print '<td>VOIDED</td>';
            } elseif ($row['accounting_approval'] && !$row['billing_initial_approval'] && !$row['billing_final_approval']) {
                print '<td>ACCOUNTING APPROVED</td>';
            }
            print '<td>' . $refund_assigned_to . '</td>';
            print '</td></tr>';
        }
        instantiate_page_variables($row, $tempOrigStartPosition, $page, $URL_String_BACK, $URL_String_FORWARD);
    }
    print '</table></div>';
    if ($currentRowSize > $_SESSION['RowsPerPage']) {
        //only conditionally display the pagination
        //include 'dump_all_page_contents.php';
        displayPaginationReports($row, $tempOrigStartPosition, $URL_String_BACK, $URL_String_FORWARD);
    }
    /*
    print <<<EDITUSERPAGE
    	<br><center><a href="reports.php"><button value="Back" name="Back">Back To Reports Page</button></a></center>
    EDITUSERPAGE;
    	
    showFooter();
    */
}
Example #3
0
function showPage($username = '', $accessLvl = '', $errors = '')
{
    global $db;
    showHeader($username, $accessLvl);
    include 'pagination_functionality.php';
    //echo 'badabeeboo';
    if ($errors) {
        //show errors at top of page
        print '<h2 class = "error"> The following errors were encountered:</h2>';
        print '<ul><li>';
        print implode('</li><li>', $errors);
        print '</li></ul>';
    }
    //Upon initial login to the app set some of the initial global settings
    $_SESSION['RowsPerPage'] = 10;
    $_SESSION['initialOffset'] = 0;
    ///////////////////////////////////////////////////////////////////////////////
    instantiate_initialOffset();
    //dump out session info for debugging purposes
    //include 'dump_all_page_contents.php';
    //print 'Here are your new Renewal Requests: ';
    //lists all refunds open for the users department
    //show list of refunds pending approval if user is administrator
    print '<br><br>';
    print '<h2 align="center">Welcome ' . $_SESSION['loginName'] . '! </h2>';
    $specifier = "";
    $query_dept_id = "SELECT dept_id FROM users WHERE user_id={$_SESSION['userid']}";
    $result_dept_id = mysqli_query($db, $query_dept_id);
    $rowquery_dept_id = mysqli_fetch_array($result_dept_id);
    $query_name = "SELECT name FROM departments WHERE dept_id={$rowquery_dept_id['dept_id']}";
    $result_name = mysqli_query($db, $query_name);
    $rowquery_dept_name = mysqli_fetch_array($result_name);
    //BUILD SPECS AND specifier to modify sql query as necessary
    //what dept are you?
    //possible depts: PAR2,PAR1 (Billing)
    //Accounting
    //on creation mark as new
    //if PAR2 only display:
    // 'NEW' AND 'PAR2 Initial'
    //if (amt>500) --> set status to: 'PAR2 Initial'
    //else --> set status to: 'Accounting Approval'
    //if PAR1 only display:
    // 'ACCOUNTING APPROVED'
    //if Accounting only display:
    // 'ACCOUNTING APPROVAL'
    $specifier = "";
    if ($rowquery_dept_name[0] == 'Admin') {
        //echo $rowquery_dept_name[0];
        //$specifier= " WHERE status='NEW' OR status='PAR2 Initial' AND modified_by!='{$_SESSION['userid']}' AND created_by!='{$_SESSION['userid']}' ";
        $specifier = " WHERE 1=1 ";
        //$specifier= " WHERE status='NEW' OR status='PAR2 Initial' AND modified_by!='{$_SESSION['userid']}' ";
    } elseif (strtoupper($rowquery_dept_name[0]) == 'ACCOUNTING') {
        //echo $rowquery_dept_name[0];
        $specifier = " WHERE (status= 'ACCOUNTING APPROVAL' AND modified_by!='{$_SESSION['userid']}' ) OR (created_by='{$_SESSION['userid']}' && status!='COMPLETED' ) ";
    } elseif (strtoupper($rowquery_dept_name[0]) == 'PAR1') {
        //echo $rowquery_dept_name[0];
        $specifier = " WHERE (status= 'ACCOUNTING APPROVED' AND modified_by!='{$_SESSION['userid']}' ) OR (created_by='{$_SESSION['userid']}' && status!='COMPLETED' ) ";
    } elseif (strtoupper($rowquery_dept_name[0]) == 'PAR2') {
        //echo $rowquery_dept_name[0];
        $specifier = " WHERE created_by='{$_SESSION['userid']}' && status!='COMPLETED' ";
        //$specifier= " WHERE U.dept_id='1' AND created_by=='{$_SESSION['userid']}' ";
        //PAR2 can only create, so they are presented with only the refunds PAR2s have created
    } elseif ($rowquery_dept_name[0] == 'Billing') {
        //echo $rowquery_dept_name[0];
        $specifier = " WHERE (status='NEW' OR status='PAR2 Initial' AND modified_by!='{$_SESSION['userid']}' ) OR (created_by='{$_SESSION['userid']}' && status!='COMPLETED' ) ";
    }
    /*
    echo $rowquery_dept_name[0];
    echo '<br>';
    echo 'specifier is ';
    echo $specifier;
    echo '<br>';
    */
    if ($accessLvl == 'U') {
        //is access is only at the user level, then must match the refunds pulled to display only the current users created refunds
        //change user groups
        if (!isset($_SESSION['order'])) {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount,status,refund_id,payable,accounting_approval,billing_initial_approval,billing_final_approval,urgent \n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.assigned_to = U.user_id" . $specifier . "\n\t\t\tORDER BY dt_request,U.last_name,status LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        } else {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount,status,refund_id,payable,accounting_approval,billing_initial_approval,billing_final_approval,urgent \n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.assigned_to = U.user_id" . $specifier . "\n\t\t\tORDER BY " . $_SESSION['order'] . " LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        }
    } else {
        if (!isset($_SESSION['order'])) {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount, status,refund_id,payable,accounting_approval,billing_initial_approval,billing_final_approval,urgent\n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.assigned_to = U.user_id" . $specifier . "\n\t\t\tORDER BY dt_request,U.last_name,status LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        } else {
            $query = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount, status,refund_id,payable,accounting_approval,billing_initial_approval,billing_final_approval,urgent\n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.assigned_to = U.user_id" . $specifier . "\n\t\t\tORDER BY " . $_SESSION['order'] . " LIMIT " . $_SESSION['initialOffset'] . "," . $_SESSION['RowsPerPage'];
        }
    }
    //index debug query
    /*
    	echo 'the query is from functions.php called from index page <br>';
    	echo $query;
    	echo '<br>';
    */
    //index debug query
    $result = mysqli_query($db, $query);
    $row = @mysqli_fetch_array($result);
    $sizeOfResultSet = sizeof($row);
    //FULL RESULT SET
    $queryFullResultSet = "SELECT NG_enc_id, U.first_name, U.last_name, dt_request,amount,status,refund_id,payable,accounting_approval,billing_initial_approval,billing_final_approval,urgent \n\t\t\tFROM refund AS R \n\t\t\tINNER JOIN \n\t\t\tusers AS U \n\t\t\tON R.assigned_to = U.user_id" . $specifier;
    $resultFull = mysqli_query($db, $queryFullResultSet);
    $rowEntire = @mysqli_fetch_array($resultFull);
    $numResultENTIRERows = $resultFull->num_rows;
    //END FULL RESULT SET
    /*
    echo 'the query was ';
    echo $query ;
    echo '<br>';
    */
    //include 'dump_all_page_contents.php';
    //echo 'comes from functions.php page ~ line 500';
    //echo $_SESSION['just_reordered'];
    //echo '<br>';
    if ($_SESSION['just_reordered'] == 1) {
        //$pageNumRedirect="&page_number=1";
        $pageNumRedirect = "&page_number=0";
        $_SESSION['just_reordered'] = 0;
    }
    /*
    if(isset($_GET['page_number']) && isset($_GET['page_number'])){
    	$pageNumRedirect="&page_number=";
    	$pageNumRedirect.=$_GET['page_number'];
    }else{
    	$pageNumRedirect="&page_number=1";
    }
    */
    if ($rowquery_dept_id['dept_id'] == 3) {
        //3 is PAR2, only PAR2 creates
        print '<h3 align="center"><a href="reset_addRefund.php">Create a NEW Refund Request</a></h3>';
        echo '<br>';
    }
    if ($sizeOfResultSet) {
        if (strtoupper($rowquery_dept_name[0]) == "PAR2") {
            print '<p align="center"> Refund Requests which you\'ve Requested:</p>';
        } else {
            print '<p align="center"> All ' . $rowquery_dept_name[0] . ' Refund Requests:</p>';
        }
        print '<div align = "center">';
        print '<table border="1" cellpadding = "3"><tr>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?encounter_num=y' . $pageNumRedirect . '>ENCOUNTER Number</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?refund_id=y' . $pageNumRedirect . '>Refund ID</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?encounter_date=y' . $pageNumRedirect . '>Date Requested</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?encounter_date=y' . $pageNumRedirect . '>Urgent</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?requested_by=y' . $pageNumRedirect . '>Requested By</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?payable_order=y' . $pageNumRedirect . '>Payable To</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?amount_order=y' . $pageNumRedirect . '>Amount</a></b></center></td>
		<td><center><b><a href=' . $_SERVER['PHP_SELF'] . '?status_order=y' . $pageNumRedirect . '>Status</a></b></center></td>';
        $result = mysqli_query($db, $query);
        $result_display_ctr = 0;
        $numResultRows = $result->num_rows;
        /*
        echo 'the numResults is ';
        echo $numResultRows;
        echo '<br>';
        var_dump($result);
        */
        while ($row = @mysqli_fetch_array($result)) {
            $today_dt = $entered_dt = $interval = $refund_requested_by = $date_requested = $refund_assigned_to = $interval = "";
            calculateInterval($row, $refund_requested_by, $date_requested, $today_dt, $entered_dt, $interval, $refund_assigned_to);
            $currentRowSize = sizeof($row);
            if ($result_display_ctr < $_SESSION['RowsPerPage']) {
                $result_display_ctr++;
                /*
                if($row['urgent']){
                	print '<tr class="urgent" >';
                }
                elseif($interval->days>30 && $row['status']!="COMPLETED"){
                	print '<tr class="30Days">';
                }elseif(($interval->days>=15 && $interval->days<30) && $row['status']!="COMPLETED"){
                	print '<tr class="15Days">';
                }elseif(($interval->days<=1) && $row['status']!="COMPLETED"){
                	print '<tr class="new">';
                }else{
                	print '<tr>';
                }
                */
                /*
                				
                urgent = #EE0000;
                30Days=#FF69B4;
                15Days=yellow;
                new=00BB00;
                completed=white;
                */
                if ($row['urgent']) {
                    print '<tr bgcolor=#EE0000 height=50>';
                } elseif ($interval->days > 30 && $row['status'] != "COMPLETED") {
                    print '<tr bgcolor=#FF69B4>';
                } elseif ($interval->days >= 15 && $interval->days < 30 && $row['status'] != "COMPLETED") {
                    print '<tr bgcolor=yellow>';
                } elseif ($interval->days <= 1 && $row['status'] != "COMPLETED") {
                    print '<tr bgcolor=#00BB00>';
                } else {
                    print '<tr>';
                }
                print '<td><a href="search_landing.php?refund_id=' . $row['refund_id'] . '&action=edit">' . $row['NG_enc_id'] . '</a></td>';
                print '<td><a href="search_landing.php?refund_id=' . $row['refund_id'] . '&action=edit">' . $row['refund_id'] . '</a></td>';
                print '<td>' . $row['dt_request'] . '</td>
				<td>' . ($row['urgent'] ? 'Yes' : 'No') . '</td>
				<td>' . $row['first_name'] . ' ' . $row['last_name'] . '</td>
				<td>' . $row['payable'] . '</td>';
                print '<td>' . '$' . $row['amount'] . '</td>
				<td>' . $row['status'] . '</td>';
                print '</tr>';
            }
            instantiate_page_variables($numResultENTIRERows, $tempOrigStartPosition, $page, $URL_String_BACK, $URL_String_FORWARD);
            //instantiate_page_variables($row,$tempOrigStartPosition,$page,$URL_String_BACK,$URL_String_FORWARD);
        }
        print '</table></div>';
        //if ($currentRowSize>$_SESSION['RowsPerPage']){ //only conditionally display the pagination
        displayPaginationINDEX($numResultENTIRERows, $tempOrigStartPosition, $URL_String_BACK, $URL_String_FORWARD);
        //}
        echo '<center>';
        echo 'TOTAL Results: ' . $numResultENTIRERows . ' Records ';
        echo '<h2>' . ceil($numResultENTIRERows / $_SESSION['RowsPerPage']) . ' Page(s) </h2>';
        echo '</center>';
    } else {
        //print message saying they have no refunds to are
        echo '<center><b>You currently have no Active Refunds for approval!</b></center>';
    }
    showFooter();
}