   <?php
   // CRUD 
   @$getId = base64_decode(anti_injection($_GET['id']));  
    if(@$getId){ 
        $query = mysql_query("SELECT * FROM email_template WHERE id = + $getId");
        $result = mysql_fetch_array($query);
    }
    
   
	if(isset($_POST['update'])) {
	$subject = $_POST['subject'];
	$from_mail = $_POST['from_mail'];
	$name_from = $_POST['name_from'];
	$msg = $_POST['msg'];

	$registerID = $_POST['registerID'];
	
	$crud = new crud('email_template'); // Table
    $crud->atualizar("subject='$subject',from_mail='$from_mail',name_from='$name_from',msg='$msg'", "id='$registerID'");
	
	header("Location: index.php?mod=TPLMail&y=2");
	}
	
    
    ?>
    <script>
$().ready(function() {
           $("#msg").wysihtml5();
        CKEDITOR.replace('editor1', {
		allowedContent: true
		});  
		}); 
	</script>
	
    <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <?php echo $lang['TITLE_TPLMAIL']; ?>
          </h1>
          
        </section>

       
       <!-- Main content -->
        <section class="content">
          <div class="row">
			  
			  
            <!-- left column -->
            <div class="col-md-9">
              <!-- general form elements -->
              <div class="box box-primary">
                <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['INFO']; ?></h3>
                </div><!-- /.box-header -->
                <!-- form start -->
                <form role="form" method="POST" id="Tpl" name="Tpl">

					
                  <div class="box-body">
					  
				
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['TM_SUBJECT']; ?></label>
                      <input type="text" class="form-control" name="subject" id="subject" value="<?php echo @$result['subject']; ?>">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['EMAIL']; ?></label>
                      <input type="text" class="form-control" name="from_mail" id="from_mail" value="<?php echo @$result['from_mail']; ?>">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['TM_NAME']; ?></label>
                      <input type="text" class="form-control" name="name_from" id="name_from" value="<?php echo @$result['name_from']; ?>">
                    </div>
                    
                   <div class="form-group">
                    <textarea id="editor1" name="msg" class="form-control" style="min-height: 600px" required><?php echo @$result['msg']; ?></textarea>
                  </div>
                  
                  
                  <div class="box-footer">
					  
		  <?php if (@$result['id'] <> '') { ?>

		  <input type="submit" value="<?php echo $lang['UPDATE']; ?>" name="update" style="text-transform:uppercase" class="btn btn-info btn-lg btn-block">
		  <input type="hidden" name="registerID" value="<?php echo @$result['id']; ?>"> 
		  <? } else { ?>
		  <input type="submit" value="<?php echo $lang['REGISTER']; ?>" name="save" style="text-transform:uppercase" class="btn btn-success btn-lg btn-block">
		  <?php } ?>
					  
                  </div>
               </form>
                  </div><!-- /.box-body -->
              </div><!-- /.box -->
           </div><!-- /.col -->
           
           
           
           <div class="col-md-3">
              <!-- general form elements -->
              <div class="box box-primary">
                <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['VAR']; ?></h3>
                </div><!-- /.box-header -->
                					
                  <div class="box-body">
					  
				<table class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th>VAR</th>
                        <th>VALUE</th>
                      </tr>
                    </thead>
                    <tbody>
                    <tr>
                    <td>%NOME%</td>
                    <td>Name</td>
                    </tr>
                    <tr>
                    <td>%EMAIL%</td>
                    <td>Mail</td>
                    </tr>
                    <tr>
                    <td>%LOGIN%</td>
                    <td>Username</td>
                    </tr>
                    <tr>
                    <td>%SENHA%</td>
                    <td>Password</td>
                    </tr>
                    <tr>
                    <td>%TICKET%</td>
                    <td>ID Ticket</td>
                    </tr>
                    <tr>
                    <td>%ASSUNTO%</td>
                    <td>Subject</td>
                    </tr>
                    <tr>
                    <td>%MENSAGEM%</td>
                    <td>Message</td>
                    </tr>
                    <tr>
                    <td>%DATABR%</td>
                    <td>Date dd/mm/yyyy</td>
                    </tr>
                    <tr>
                    <td>%DATAEN%</td>
                    <td>Date mm/dd/yyyy</td>
                    </tr>
                    <tr>
                    <td>%ASSINATURA%</td>
                    <td>Signature Mail</td>
                    </tr>
                    <tr>
                    <td>%LOGO%</td>
                    <td>Logo</td>
                    </tr>
                    <tr>
                    <td>%DNS%</td>
                    <td>DNS</td>
                    </tr>
                    <tr>
                    <td>%IP1% / %IP2%</td>
                    <td>IP Address</td>
                    </tr>
                    <tr>
                    <td>%PRODUTO%</td>
                    <td>Product or Service</td>
                    </tr>
                    <tr>
                    <td>%PRECO%</td>
                    <td>Price $$</td>
                    </tr>
                    <tr>
                    <td>%DOMINIO%</td>
                    <td>Domain</td>
                    </tr>
                    <tr>
                    <td>%PEDIDO%</td>
                    <td>Order ID</td>
                    </tr>
                    <tr>
                    <td>%FORMA_PAGTO%</td>
                    <td>Gateway Pay</td>
                    </tr>
                    <tr>
                    <td>%TOTAL%</td>
                    <td>Total Price</td>
                    </tr>
                    <tr>
                    <td>%EMPRESA%</td>
                    <td>Company</td>
                    </tr>
                    <tr>
                    <td>%CIDADE%</td>
                    <td>City</td>
                    </tr>
                    <tr>
                    <td>%ENDERECO%</td>
                    <td>Address</td>
                    </tr>
                    <tr>
                    <td>%CPFCNPJ%</td>
                    <td>Tax ID</td>
                    </tr>
				</tbody>
				</table>

  
                  
                 
                </form>
                    
                   
                  </div><!-- /.box-body -->
              </div><!-- /.box -->
           </div><!-- /.col -->
           
         
           
          </div><!-- /.row -->
        </section><!-- /.content -->
       
        
      </div><!-- /.content-wrapper -->
   
   
   
   
