Newer
Older
ubFramework / Portal / docroot / user / dialer / preferences.php
@Christopher W. Olsen Christopher W. Olsen on 10 Dec 2017 5 KB Cleaning Up Making It A Sub Module
<?php

/**
 * ****************************************************************************************
 * Copyright (c) 2013 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: preferences.php 940 2017-09-07 20:12:42Z reddawg $
 *
 * ***************************************************************************************
 */

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

/* Assign the page title */
$ubF->tpl->assign ( "PAGE_TITLE", "Dialer Preferences" );

/* Main defines */
$ubF->tpl->define ( array (
    "index" => "user/wrapper/default.html" 
) );
$ubF->tpl->define ( array (
    "menu" => "user/dialer/menu.html" 
) );
$ubF->tpl->define ( array (
    "body" => "user/dialer/preferences.html" 
) );

$ubF->session->Validate ( 'U_D_', 1 );

if ( isset ( $data ['up'] ) ) {
  $query = "UPDATE accounts SET bc_ro = " . $data ['bc_ro'] . ",bc_dailylimit = " . $data ['bc_dailylimit'] . ",bc_threshold = " . $data ['bc_threshold'] . ",bc_ramount = " . $data ['bc_ramount'] . ",dc_ro = " . $data ['dc_ro'] . ",dc_dailylimit = " . $data ['dc_dailylimit'] . ",dc_threshold = " . $data ['dc_threshold'] . ",dc_ramount = " . $data ['dc_ramount'] . " WHERE account_number = '" . $ubF->session->account_number . "'";
  if ( $ubF->DB['main']->query ( $query ) === true )
    $messages = "Your Preferences Have Been Updated<br />";
  else
    $messages = "Error Updating Preferences<br />";
  
  if ( $data ['bc_ro'] == 0 ) {
    $b0 = "checked";
    $b1 = "disabled";
  }
  else {
    $b0 = "disabled";
    $b1 = "checked";
  }
  
  if ( $data ['dc_ro'] == 0 ) {
    $d0 = "checked";
    $d1 = "disabled";
  }
  else {
    $d0 = "disabled";
    $d1 = "checked";
  }
  
  $ubF->tpl->assign ( "BC_DAILYLIMIT", number_format ( $data ['bc_dailylimit'], 2 ) );
  $ubF->tpl->assign ( "DC_DAILYLIMIT", number_format ( $data ['dc_dailylimit'], 2 ) );
  
  $ubF->tpl->assign ( "BC_THRESHOLD", number_format ( $data ['bc_threshold'], 2 ) );
  $ubF->tpl->assign ( "DC_THRESHOLD", number_format ( $data ['dc_threshold'], 2 ) );
  
  $ubF->tpl->assign ( "BC_RAMOUNT", number_format ( $data ['bc_ramount'], 2 ) );
  $ubF->tpl->assign ( "DC_RAMOUNT", number_format ( $data ['dc_ramount'], 2 ) );
}
else {
  if ( $ubF->session->bc_ro == 0 ) {
    $b0 = "checked";
    $b1 = "disabled";
  }
  else {
    $b0 = "disabled";
    $b1 = "checked";
  }
  
  if ( $ubF->session->dc_ro == 0 ) {
    $d0 = "checked";
    $d1 = "disabled";
  }
  else {
    $d0 = "disabled";
    $d1 = "checked";
  }
  
  $ubF->tpl->assign ( "BC_DAILYLIMIT", $ubF->session->bc_dailylimit );
  $ubF->tpl->assign ( "DC_DAILYLIMIT", $ubF->session->dc_dailylimit );
  
  $ubF->tpl->assign ( "BC_THRESHOLD", $ubF->session->bc_threshold );
  $ubF->tpl->assign ( "DC_THRESHOLD", $ubF->session->dc_threshold );
  
  $ubF->tpl->assign ( "BC_RAMOUNT", $ubF->session->bc_ramount );
  $ubF->tpl->assign ( "DC_RAMOUNT", $ubF->session->dc_ramount );
}

$ubF->tpl->assign ( "BC_CPM", $ubF->session->press1_cpm );
$ubF->tpl->assign ( "DC_CPM", $ubF->session->dialer_cpm );
$ubF->tpl->assign ( "BC_BALANCE", number_format ( $ubF->session->press1_prepay, 2 ) );
$ubF->tpl->assign ( "DC_BALANCE", number_format ( $ubF->session->dialer_prepay, 2 ) );

$ubF->tpl->assign ( "B0", $b0 );
$ubF->tpl->assign ( "D0", $d0 );
$ubF->tpl->assign ( "B1", $b1 );
$ubF->tpl->assign ( "D1", $d1 );

$ubF->tpl->assign ( "MESSAGES", $messages );

/* Parse and print */
$ubF->tpl->parse ( "MENU", array (
    "menu" 
) );
$ubF->tpl->parse ( "BODY", array (
    "body" 
) );
$ubF->tpl->parse ( "INDEX", array (
    "index" 
) );
$ubF->tpl->FastPrint ( "INDEX" );

?>