Newer
Older
ubFramework / Source / user / account / index_json.php
<?php
/*
 * Copyright (c) 2016 Christopher W. Olsen <cwolsen@ubixtechnologies.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of
 * conditions, the following disclaimer and the list of authors. Redistributions in binary
 * form must reproduce the above copyright notice, this list of conditions, the following
 * disclaimer and the list of authors in the documentation and/or other materials provided
 * with the distribution. Neither the name of the uBix Cube Project nor the names of its
 * contributors may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id: index.php 31 2015-11-04 03:10:50Z reddawg $
 *
 */

/* Main include info */
ini_set ( 'include_path', $_SERVER ['DOCUMENT_ROOT'] . "/include/" );
include ("config.php");

$ubF->session->Validate_JSON ( 'U_A_', 1 );

$query = "SELECT company,address,address2,city,state,zipcode,website,title,first_name,last_name,telephone,fax,cell,email FROM accounts WHERE account_number = '" . $ubF->session->account_number . "'";
$result = $ubF->DB ['main']->query ( $query );

$account_info = $result->fetch_assoc ();

$result->free ();

$account_info ['account_number'] = $ubF->session->account_number;
$account_info ['customer_since'] = date ( "m/d/Y", $ubF->session->customer_since );

$json_data ['data'] = $account_info;

print (json_encode ( $json_data )) ;

return;

$account_info ['pastdue_balance'] = $ubF->session->pastdue_balance + 0;

$account_info ['current_balance'] = $ubF->session->current_balance + 0;

$account_info ['balance'] = number_format ( ($ubF->session->pastdue_balance + $ubF->session->current_balance) + 0, 2 );

$account_info ['account_number'] = $ubF->session->account_number;

$account_info ['first_name'] = $ubF->session->first_name;

$account_info ['news'] = $data->libs ['ubf']->getNews ();

$query = "SELECT incident_time, message FROM account_alerts WHERE account_number = '" . $ubF->session->account_number . "' ORDER BY incident_time DESC LIMIT 5";

$result = $ubF->DB ['main']->query ( $query );

if ($result->num_rows > 0) {
  $account_info ['account_alerts'] = "";
  while ( $qD = $result->fetch_array () ) {
    $account_info ['account_alerts'] .= $qD [0] . " - " . $qD [1] . "<br />\n";
  }
}
else
  $account_info ['account_alerts'] = "No Alerts";

$json_data ['data'] = $account_info;

print (json_encode ( $json_data )) ;

?>