
    <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <?php echo $lang['TITLE_LIST_DOMAINS']; ?>
            <small><?php echo $lang['LIST_DOMAINS']; ?></small>
          </h1>
          
        </section>

       
       <section class="content">
          <div class="row">
            <div class="col-xs-12">
				
	<?php

    if ((isset($_GET["action"])) && ($_GET["action"] == "register")) {
    $domainTLD = base64_decode($_GET['id']);
    $above = $config['above'];
    echo register_domain($domainTLD,$above);
    }
    if ((isset($_GET["action"])) && ($_GET["action"] == "renew")) {
    $domainTLD = base64_decode($_GET['id']);
    $above = $config['above'];
    echo renew($domainTLD,$above,'1');
    }
    if ((isset($_GET["action"])) && ($_GET["action"] == "epp")) {
    $domainTLD = base64_decode($_GET['id']);
    $above = $config['above'];
    echo request_epp($domainTLD,$above);
    }
    if($_POST['action'] == "updatedns") { 

    $registerID = $_POST['iddr'];
    $domainTLD = $_POST['basedomain'];
    $dns1 = $_POST['dns1'];
    $dns2 = $_POST['dns2'];
    $above = $config['above'];
    
    $crud = new crud('domains'); // Table
    $crud->atualizar("dns1='$dns1',dns2='$dns2'", "id='$registerID'");
	
	echo update_dns($domainTLD,$above,$dns1,$dns2);
    }
    if($_POST['action'] == "transfer") { 

    $registerID = $_POST['iddr'];
    $epp_code = $_POST['epp'];
    $domainTLD = $_POST['basedomain'];
    $above = $config['above'];
    
    $crud = new crud('domains'); // Table
    $crud->atualizar("epp='$epp_code'", "id='$registerID'");
	
	echo transfer_domain($domainTLD,$above,$epp_code);
    }
?>
				
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">
					  
					  <?php echo balance($config['above']); ?>
					  
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="tabela" class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th><?php echo $lang['DOMAIN_DB']; ?></th>
                        <th><?php echo $lang['DOMAIN_CUSTOMER']; ?></th>
                        <th><?php echo $lang['DOMAIN_DATE_REGISTER']; ?></th>
                        <th><?php echo $lang['DOMAIN_DATE_EXPIRE']; ?></th>
                        <th><?php echo $lang['REMAINING']; ?></th>
                        <th><?php echo $lang['STATUS']; ?></th>
                        <th><?php echo $lang['ACTIONS']; ?></th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
 		  			$query = mysql_query("SELECT p.*, c.name AS name, c.email AS email FROM domains AS p INNER JOIN customers AS c ON p.customer = c.id ORDER BY p.id ASC");
 		  			while($result = mysql_fetch_array($query)){ 
					?>
					
		            <tr>
		            <td><?php echo $result['domain']; ?><?php echo $result['tdl']; ?><br>
		            <?php 
		            $reg = $result['domain'] . "" . $result['tdl'];
		            echo urlon($reg);
		            ?>
		            </td>
		            <td><?php echo $result['name']; ?><br><small><?php echo $result['email']; ?></small></td>
		            <td><?php if($lang['DATE_FORMAT'] == 'PT') { ?><?php echo data_br($result['date_register']); ?><?php } ?><?php if($lang['DATE_FORMAT'] == 'EN') { ?><?php echo data_en($result['date_register']); ?><?php } ?></td>
		            <td><?php if($lang['DATE_FORMAT'] == 'PT') { ?><?php echo data_br($result['date_expire']); ?><?php } ?><?php if($lang['DATE_FORMAT'] == 'EN') { ?><?php echo data_en($result['date_expire']); ?><?php } ?></td>
		            <td><span class="label label-primary"><?php echo diff_date($result['date_expire'],$result['date_register']); ?> <?php echo $lang['DAYS']; ?></span></td>
		            
		          
		            <td><?php if($result['status'] == 'S') { ?> <?php echo $lang['ACTIVE']; ?> <?php } ?></td>
		            <td>
					<div class="btn-group">
                      <button type="button" class="btn btn-info btn-sm"><?php echo $lang['ACTIONS']; ?></button>
                      <button type="button" class="btn btn-info btn-sm dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                        <span class="sr-only">Toggle Dropdown</span>
                      </button>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="http://<?php echo $reg; ?>" target=_blank><?php echo $lang['BTN_VIEW_URL']; ?></a></li>
                        <li><a href="?mod=NewDomain&id=<?php echo base64_encode($result['id']); ?>"><?php echo $lang['BTN_UPDATE']; ?></a></li>
                        <li class="divider"></li>
                        <li><a href="javascript:void(0);" onclick="javascript: if (confirm('<?php echo $lang['ALERT_BTN_REGISTER_DOMAIN']; ?>')) { window.location.href='?mod=Domains&id=<?php echo base64_encode($reg); ?>&action=register' } else { void('') };"><?php echo $lang['BTN_REGISTER_DOMAIN']; ?></a></li>
                        <li><a href="javascript:void(0);" onclick="javascript: if (confirm('<?php echo $lang['ALERT_BTN_RENEW_DOMAIN']; ?>')) { window.location.href='?mod=Domains&id=<?php echo base64_encode($reg); ?>&action=renew' } else { void('') };"><?php echo $lang['BTN_RENEW_DOMAIN']; ?></a></li>
                        <li><a href="javascript:void(0);" onclick="javascript: if (confirm('Request EPP ?')) { window.location.href='?mod=Domains&id=<?php echo base64_encode($reg); ?>&action=epp' } else { void('') };">Request EPP</a></li>
                        <li><a href="javascript:void(0);" data-toggle="modal" data-target="#DNS<?php echo $result['id']; ?>">Update DNS</a></li>
                        <li><a href="javascript:void(0);" data-toggle="modal" data-target="#TR<?php echo $result['id']; ?>">Transfer Domain</a></li>
                        <li class="divider"></li>
                        <li><a href="javascript:void(0);" onclick="javascript: if (confirm('<?php echo $lang['ALERT_BTN_DELETE']; ?>')) { window.location.href='?mod=NewDomain&id=<?php echo base64_encode($result['id']); ?>&action=delete' } else { void('') };"><?php echo $lang['BTN_DELETE']; ?></a></li>
                      </ul>
                    </div>
                    
                    </td>
		            </tr>
		            
		            <!-- Modal Update DNS -->
<div id="DNS<?php echo $result['id']; ?>" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Manage Nameservers</h4>
      </div>
      <div class="modal-body">

    <form id="<?php echo $result['id']; ?>" method="POST" name="<?php echo $result['id']; ?>">
	<input name="iddr" type="hidden" value="<?php echo $result['id']; ?>" />
	<input name="action" type="hidden" value="updatedns" />
	<input name="basedomain" type="hidden" value="<?php echo $reg; ?>" />
	 
    <label for="bar">NameServer 1</label>&nbsp;
    <input id="dns1" class="form-control" name="dns1" type="text" value="<?php echo $result['dns1']; ?>" /><br>
    
    <label for="bar">NameServer 2</label>&nbsp;
    <input id="dns2" class="form-control" name="dns2" type="text" value="<?php echo $result['dns2']; ?>" />
     
      </div>
      <div class="modal-footer">
		<input type="submit" class="btn btn-info" value="Send" />
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
    </form>
  </div>
</div>
		     
		     		            <!-- Modal Transfer -->
<div id="TR<?php echo $result['id']; ?>" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Transfer Domain</h4>
      </div>
      <div class="modal-body">

    <form id="Tg<?php echo $result['id']; ?>" method="POST" name="Tg<?php echo $result['id']; ?>">
	<input name="iddr" type="hidden" value="<?php echo $result['id']; ?>" />
	<input name="action" type="hidden" value="transfer" />
	<input name="basedomain" type="hidden" value="<?php echo $reg; ?>" />
	<label for="bar"><?php echo $reg; ?></label><br>
    <label for="bar">EPP-Code</label>&nbsp;
    <input id="epp" class="form-control" name="epp" type="text" value="<?php echo $result['epp']; ?>" /><br>
    
      </div>
      <div class="modal-footer">
		<input type="submit" class="btn btn-info" value="Send" />
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
    </form>
  </div>
</div>       
		            
					<?php } ?>
					
                    </tbody>
                    <tfoot>
                      <tr>
                        <th><?php echo $lang['DOMAIN_DB']; ?></th>
                        <th><?php echo $lang['DOMAIN_CUSTOMER']; ?></th>
                        <th><?php echo $lang['DOMAIN_DATE_REGISTER']; ?></th>
                        <th><?php echo $lang['DOMAIN_DATE_EXPIRE']; ?></th>
                        <th><?php echo $lang['REMAINING']; ?></th>
                        <th><?php echo $lang['STATUS']; ?></th>
                        <th><?php echo $lang['ACTIONS']; ?></th>
                      </tr>
                    </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
       
           </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
       
       
        
        
      </div><!-- /.content-wrapper -->
   
   
   
   
