<?php

    $query = mysql_query("SELECT * FROM config WHERE id = '1'");
    $result = mysql_fetch_array($query);
   
	if(isset($_POST['paypal'])) {
	if($_POST['paypalatv'] == '') {
	$paypal = 'N';		
	} else {
	$paypal = $_POST['paypalatv'];
	}
	$paypal_user = $_POST['paypal_user'];
	$paypal_pwd = $_POST['paypal_pwd'];
	$paypal_signature = $_POST['paypal_signature'];
	$registerID = $_POST['registerID'];
	
	$crud = new crud('config'); // Table
    $crud->atualizar("paypal='$paypal',paypal_signature='$paypal_signature',paypal_pwd='$paypal_pwd',paypal_user='$paypal_user'", "id='$registerID'");
	
	header("Location: index.php?mod=Gateways&y=2");
	}
	if(isset($_POST['pagseguro'])) {
	if($_POST['pagseguroatv'] == '') {
	$pagseguro = 'N';		
	} else {
	$pagseguro = $_POST['pagseguroatv'];
	}
	$pagseguro_email = $_POST['pagseguro_email'];
	$pagseguro_token = $_POST['pagseguro_token'];
	$registerID = $_POST['registerID'];
	
	$crud = new crud('config'); // Table
    $crud->atualizar("pagseguro='$pagseguro',pagseguro_email='$pagseguro_email',pagseguro_token='$pagseguro_token'", "id='$registerID'");
	
	header("Location: index.php?mod=Gateways&y=2");
	}
    ?>
    
   
    <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <?php echo $lang['GATEWAYS']; ?>
          </h1>
          
        </section>

       
       <section class="content">
          <div class="row">
            <div class="col-xs-12">
				
				<!-- ALERTS -->
				<?php if($_GET['y'] == '2') { ?>
				<div class="callout callout-success">
                    <h4><?php echo $lang['ALERT_GATEWAYS_UPDATE']; ?></h4>
                    <p><?php echo $lang['ALERT_GATEWAYS_UPDATE_TXT']; ?></p>
                  </div>
				<?php } ?>
				
              <div class="box">
				
                <div class="box-body">
					<h3>PayPal</h3>
                  <table class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th><?php echo $lang['PAYPAL_USER']; ?></th>
                        <th><?php echo $lang['PAYPAL_PWD']; ?></th>
                        <th><?php echo $lang['PAYPAL_SIG']; ?></th>
                        <th><?php echo $lang['ACTIVE']; ?></th>
                        <th width="120"><?php echo $lang['ACTIONS']; ?></th>
                      </tr>
                    </thead>
                    <tbody>
					<form method="POST" name="PayPal">
					<input type="hidden" name="registerID" value="1">
		            <tr>
		            <td><input type="text" class="form-control" name="paypal_user" value="<?php echo $config['paypal_user']; ?>" required></td>
					<td><input type="text" class="form-control" name="paypal_pwd" value="<?php echo $config['paypal_pwd']; ?>" required></td>
					<td><input type="text" class="form-control" name="paypal_signature" value="<?php echo $config['paypal_signature']; ?>" required></td>
					<td><input type="checkbox" name="paypalatv" value="S" <?php if (@$config['paypal'] == 'S') { echo "checked"; } ?>></td>
					<td><input type="submit" class="btn btn-info" name="paypal" value="<?php echo $lang['BTN_SAVE_UP']; ?>"> </td>
		            </tr>
		            </form>
                    </tbody>
                  </table>
                  <h3>PagSeguro</h3>
                  <table class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th><?php echo $lang['PAGSEGURO_EMAIL']; ?></th>
                        <th><?php echo $lang['PAGSEGURO_TOKEN']; ?></th>
                        <th><?php echo $lang['ACTIVE']; ?></th>
                        <th width="120"><?php echo $lang['ACTIONS']; ?></th>
                      </tr>
                    </thead>
                    <tbody>
					<form method="POST" name="PagSeguro">
					<input type="hidden" name="registerID" value="1">
		            <tr>
		            <td><input type="text" class="form-control" name="pagseguro_email" value="<?php echo $config['pagseguro_email']; ?>" required></td>
					<td><input type="text" class="form-control" name="pagseguro_token" value="<?php echo $config['pagseguro_token']; ?>" required></td>
					<td><input type="checkbox" name="pagseguroatv" value="S" <?php if (@$config['pagseguro'] == 'S') { echo "checked"; } ?>></td>
					<td><input type="submit" class="btn btn-info" name="pagseguro" value="<?php echo $lang['BTN_SAVE_UP']; ?>"> </td>
		            </tr>
		            </form>
                    </tbody>
                  </table>
                  
                  
                </div><!-- /.box-body -->
              </div><!-- /.box -->
       
           </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
       
       
        
        
      </div><!-- /.content-wrapper -->
   
   
   
   
