Ejemplo n.º 1
0
function GetTemplateById()
{
	$connection = new DBConnection();
	$settingsModel = new App\Model\Settings($connection, 'mail_settings');
    $settings = $settingsModel->getAll();

    $API_KEY = $settings['sendwithus_key'];
    $options = array();
    $api = new API($API_KEY, $options);

    $templateId = $_POST['templateId'];
    if ($templateId != "")
    {
        $response = $api->get_template($templateId);
        $response = $api->get_template($templateId,$response->versions[0]->id);


        // Get html body
        /*
        $d = new DOMDocument;
        $mock = new DOMDocument;
        $d->loadHTML($response->html);
        $body = $d->getElementsByTagName('body')->item(0);
        foreach ($body->childNodes as $child){
            $mock->appendChild($mock->importNode($child, true));
        }
        $response->html = $mock->saveHTML();
        */
        echo json_encode($response);
    }else{
        echo json_encode(array('text'=>'' , 'html' => '','id' => '','name' => ''));
    }
}
Ejemplo n.º 2
0
 /**
  * Returns PDF body based on template name
  * @param string $name
  * @param array $data
  * @return string
  */
 public function getBody($name, array $data)
 {
     $pdfTemplate = $this->model->getPdfTemplateBySlug($name);
     $pdfContent = '';
     if (is_array($pdfTemplate)) {
         if ($pdfTemplate['pdf_external_id']) {
             $API_KEY = $this->settings->get('pdf_sendwithus_key');
             $options = array();
             $api = new API($API_KEY, $options);
             $response = $api->get_template($pdfTemplate['pdf_external_id']);
             $response = $api->get_template($pdfTemplate['pdf_external_id'], $response->versions[0]->id);
             $pdfContent = $response->html;
         } else {
             $pdfContent = $pdfTemplate['content'];
         }
     }
     $this->template->setContent($pdfContent);
     $this->template->setData($data);
     return $this->template->process();
 }
Ejemplo n.º 3
0
 public function testBatchCancel()
 {
     $batch_api = $this->api->start_batch();
     $data = array('segment' => 'Batch Updated Customer');
     for ($i = 1; $i <= 10; $i++) {
         $result = $batch_api->create_customer(sprintf('*****@*****.**', $i), $data);
         $this->assertTrue($result->success);
         $this->assertEquals('Batched', $result->status);
         $this->assertEquals($i, $batch_api->command_length());
     }
     $result = $batch_api->cancel();
     $this->assertTrue($result->success);
     $this->assertEquals('Canceled', $result->status);
     $this->assertEquals(0, $batch_api->command_length());
 }
Ejemplo n.º 4
0
    //
    $templateRow = $db->getRow('mail_templates','mail_templates_id="'.$_POST['mail_templates_id'].'"','mail_external_id, mail_template_title, mail_templates_id');
    $templateId = $templateRow["mail_external_id"];
    
	$settingsModel = new App\Model\Settings($db, 'mail_settings');
    $settings = $settingsModel->getAll();
    
	if(!$templateId){
		echo '<p>Sendwithus theme is not defined for this template "'.$templateRow['mail_template_title'].'"</p>';
		echo '<p><a href=\'mails_templates.php?action=edit&mtid='.$templateRow['mail_templates_id'].'\'>Go to edit</a></p>';
		exit();
	}

    $API_KEY = $settings['sendwithus_key'];
    $options = array();
    $api = new API($API_KEY, $options);
    $response = $api->get_template($templateId);
    $response = $api->get_template($templateId,$response->versions[0]->id);

    $_POST["mail_html"] = $response->html;
    $_POST["mail_plain"] = $response->text;
    //
}else{
	$_POST = array();
}

if(isset($_GET['buyref']) || isset($_GET['sellref']) || isset($_GET['tdref']) || isset($_GET['twref'])) {
	$traderef='';
	if(isset($_GET['buyref'])) {
		$traderef = $_GET['buyref'];
		$tradeDetails = $db->getRow('trades','trade_ref="'.$traderef.'"');
Ejemplo n.º 5
0
$action = array_get($_GET, 'action');
switch ($action) {
    case 'edit':
        $local_template = $templateModel->getRecord($_GET['id']);
        $pdf_external_id = $local_template['pdf_external_id'];
        
		$settings = new App\Model\Settings($db, 'pdf');
		$settings = $settings->getAll();
		
		$selectTemplateHtml = '<option value="">Empty</option>';
		
		if(array_key_exists('pdf_sendwithus_key', $settings) && isset($settings['pdf_sendwithus_key'])){
			$API_KEY = $settings['pdf_sendwithus_key'];
			$tags = explode(',', trim($settings['pdf_sendwithus_tags']));
			$options = array();
			$api = new API($API_KEY, $options);
			$response = $api->emails();
			foreach($response as $template){
				$matched = count(array_filter($tags)) == 0;
			    foreach($tags as $tag){
					if (isset($template->tags) && in_array(trim($tag), $template->tags)) {
						$matched = true;
						break;
				  	}
				}
				if($matched){
					$selected = $pdf_external_id == $template->id ? "selected='selected'" : "";
					$selectTemplateHtml .= "<option value='". $template->id ."'".$selected.">". $template->name ."</option>";
				}
			}
		}
Ejemplo n.º 6
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* @author Abhik Chakraborty
*/
use sendwithus\API;
require_once BASE_PATH . '/plugins/EmailerSendWithUs/libs/sendwithus/vendor/autoload.php';
$emailer = new EmailerSendWithUs();
$api_key = $emailer->get_api_key();
$entity_selected = false;
$templates_found = false;
$groups_found = false;
$api = new API($api_key);
// get the templates
$templates = $api->emails();
$templates_array = array();
if (is_array($templates) && count($templates) > 0) {
    foreach ($templates as $key => $templateObj) {
        if (property_exists($templateObj, 'name') && property_exists($templateObj, 'id')) {
            $templates_array[$templateObj->id] = $templateObj->name;
        }
    }
    $templates_found = true;
}
//get the groups, sending email to a selected group feature is not added yet
/*$groups = $api->list_groups();
$groups_array = array();
if (is_array($groups->groups) && count($groups->groups) > 0) { 
	foreach ($groups->groups as $key=>$groupsObj) {
		$groups_array[$groupsObj->id] = $groupsObj->name;
Ejemplo n.º 7
0
function mailSender($hdr_from, $hdr_to, $email, $subject, $header, $body, $attachment = '', $templet = 0, $html = 0, $tag = 0, $info = 0, $replyTo = null)
{
    global $database, $session;
    Logger("ZDISHAEMAILSENTTEST");
    $body_original = $body;
    $body2 = isset($info['emailmssg2']) ? $info['emailmssg2'] : null;
    $body3 = isset($info['emailmssg3']) ? $info['emailmssg3'] : null;
    /*
    This is a wrapper function for sending emails
      $hdr_from  - THe from address to be kept in the header
      $hdr_to    - The to name and address to be kept in the Header
      $email     - Email address to which the mail to be sent
      $subject   - Subject of the email
      $body      - The body of the email
      $attachment - Mail Attachment
    */
    if (!defined('ECHO_EMAILS')) {
        define('ECHO_EMAILS', false);
    }
    if (!defined('PHP_EMAILS')) {
        define('PHP_EMAILS', false);
    }
    if (!defined('HTTP_METHOD')) {
        define('HTTP_METHOD', 'http://');
    }
    if (!defined('DOC_ROOT')) {
        define('DOC_ROOT', '/i/');
    }
    if (!defined('MAIL_TYPE')) {
        define('MAIL_TYPE', 'mail');
    }
    $encodeArray = array('en' => 'UTF-8', 'fr' => 'iso-8859-1');
    /* Construct the header portion */
    /* clear html injects Begin */
    if (!empty($templet)) {
        $templet = forReadFile($templet);
    } else {
        $templet = forReadFile("editables/email/simplemail.html");
    }
    if ($html == 2) {
        $templet = str_replace('%user_msg%', $info['user_msg'], $templet);
        $templet = str_replace('%image_link%', $info['image_link'], $templet);
        $templet = str_replace('%site_link%', $info['site_link'], $templet);
        $templet = str_replace('%image_src%', $info['image_src'], $templet);
        $templet = str_replace('%lend_image_src%', $info['lend_image_src'], $templet);
        $templet = str_replace('%borrower_link%', $info['borrower_link'], $templet);
        $templet = str_replace('%borrower_name%', $info['borrower_name'], $templet);
        $templet = str_replace('%fbrating%', $info['fbrating'], $templet);
        $templet = str_replace('%fbrating_count%', $info['fbrating_count'], $templet);
        $templet = str_replace('%fbrating_link%', $info['fbrating_link'], $templet);
        $templet = str_replace('%location%', $info['location'], $templet);
        $templet = str_replace('%loan_use%', $info['loan_use'], $templet);
        $templet = str_replace('%lend_link%', $info['lend_link'], $templet);
        $templet = str_replace('%amount_req%', $info['amount_req'], $templet);
        $templet = str_replace('%interest%', $info['interest'], $templet);
        $templet = str_replace('%statusbar%', $info['statusbar'], $templet);
        $templet = str_replace('%content_mail%', $body, $templet);
    } else {
        if ($html == 3) {
            error_log('HTML: ' . $html);
            $templet = str_replace('%header%', $header, $templet);
            $templet = str_replace('%content_mail%', $body, $templet);
            if (!empty($info['image_src'])) {
                $templet = str_replace('%image_src%', '<img class="" id="mainImage" src="' . $info['image_src'] . '" style="width:100%; cursor:auto" width="100%">', $templet);
            } else {
                $templet = str_replace('%image_src%', '', $templet);
            }
            if (!empty($info['link']) && !empty($info['anchor'])) {
                $templet = str_replace('%linked_text%', "<a href='" . $info['link'] . "'>" . $info['anchor'] . "</a>", $templet);
            } else {
                $templet = str_replace('%linked_text%', '', $templet);
            }
            if (!empty($info['footer'])) {
                $footer = $info['footer'];
            } else {
                $footer = "View our latest loan projects here!";
            }
            if (!empty($info['button_url'])) {
                $button_url = $info['button_url'];
            } else {
                $button_url = "https://www.zidisha.org/microfinance/lend.html";
            }
            if (!empty($info['button_text'])) {
                $button_text = $info['button_text'];
            } else {
                $button_text = "View Loans";
            }
            if (empty($tag)) {
                $tag = ACCOUNT_NOTIFICATIONS_TAG;
            }
            if ($tag == ACCOUNT_NOTIFICATIONS_TAG) {
                $template = SENDWITHUS_TEMPLATE_ACCOUNT;
            } elseif ($tag == BORROWER_NOTIFICATIONS_TAG) {
                $template = SENDWITHUS_TEMPLATE_BORROWER_ACCOUNT;
            } elseif ($tag == COMMENT_NOTIFICATIONS_TOBORROWER_TAG) {
                $template = SENDWITHUS_TEMPLATE_COMMENTS_TOBORROWER;
            } elseif ($tag == COMMENT_NOTIFICATIONS_TAG) {
                $template = SENDWITHUS_TEMPLATE_COMMENTS;
            } elseif ($tag == NEWS_TAG) {
                $template = SENDWITHUS_TEMPLATE_NEWS;
            } elseif ($tag == NEW_THIS_WEEK_TAG) {
                $template = SENDWITHUS_TEMPLATE_3FEATURES;
            } elseif ($tag == PROMOTE_LOAN_TAG) {
                $template = SENDWITHUS_TEMPLATE_PROMOTELOAN;
            } elseif ($tag == LENDER_FIRSTLOAN_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_FIRSTLOAN;
            } elseif ($tag == LENDER_FULLY_FUNDED_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_FULLYFUNDED;
            } elseif ($tag == LENDER_DISBURSED_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_DISBURSED;
            } elseif ($tag == LENDER_REPAYMENT_TAG) {
                $template = SENDWITHUS_TEMPLATE_LENDER_REPAYMENT;
            } elseif ($tag == INVITE_CREDIT_TAG) {
                $template = SENDWITHUS_TEMPLATE_INVITE_CREDIT;
            } elseif ($tag == INVITE_ACCEPTED_TAG) {
                $template = SENDWITHUS_TEMPLATE_INVITE_ACCEPTED_CREDIT;
            } elseif ($tag == NEW_LENDER_INTRO_TAG) {
                $template = SENDWITHUS_TEMPLATE_NEW_LENDER_INTRO;
            }
        }
    }
    $hdr_from = stripslashes(clearPost($hdr_from));
    $hdr_to = stripslashes(clearPost($hdr_to));
    if ($replyTo != null) {
        $replyTo = stripslashes(clearPost($replyTo));
    }
    $email = clearPost($email);
    $subject = clearPost($subject);
    $body = clearPost($body);
    /* Html inject removed */
    include_once PEAR_DIR . 'Mail/mime.php';
    global $bannerURL, $config, $smarty;
    $crlf = chr(10);
    // as required in the PEAR manuals for use with PEAR mail. We use chr(10) instead of /n, because /n was displayed as the last line of the email.
    $uname = $database->getUserNamesByEmail($email);
    $cc = '';
    if (count($uname) > 1) {
        Logger("Multiple users found on same email " . $email);
    } elseif (isset($uname[0]['username'])) {
        $ulevel = $database->getUserLevel($uname[0]['username']);
        $brwrid = $database->getUserId($uname[0]['username']);
        if ($ulevel == BORROWER_LEVEL) {
            $behalfid = $database->getborrowerbehalfid($brwrid);
            if ($behalfid > 0) {
                $behalfdetail = $database->getBorrowerbehalfdetail($behalfid);
                $cc = $behalfdetail['email'];
            }
        }
    } else {
        Logger("No user with email address " . $email);
    }
    $headers = array('From' => $hdr_from, 'Subject' => stripslashes($subject), 'Reply-To' => $replyTo, 'Cc' => $cc);
    $mime = new Mail_mime($crlf);
    $language = "en";
    if (isset($_GET["language"])) {
        $language = $_GET["language"];
    }
    /* modify the encoding in mine with what is given for chosen language */
    $mime->_build_params['text_encoding'] = '7bit';
    //get_lang('mail_text_encoding');
    $mime->_build_params['html_encoding'] = '7bit';
    //get_lang('mail_html_encoding');
    $mime->_build_params['html_charset'] = isset($encodeArray[$language]) ? $encodeArray[$language] : $encodeArray['en'];
    //get_lang('mail_html_charset');
    $mime->_build_params['text_charset'] = isset($encodeArray[$language]) ? $encodeArray[$language] : $encodeArray['en'];
    //get_lang('mail_text_charset');
    $mime->_build_params['head_charset'] = isset($encodeArray[$language]) ? $encodeArray[$language] : $encodeArray['en'];
    // get_lang('mail_head_charset');
    if ($html) {
        $body = str_replace('#content#', $body, $templet);
    }
    $siteurl = SITE_URL;
    $body = str_replace('#link#', $siteurl, $body);
    $body = str_replace('#SiteUrl#', $siteurl, $body);
    $parserfile = 'css_parser.php';
    require_once $parserfile;
    $cssparser = new cssParser();
    //$css is css stylesheet string
    //$cssparser->ParseStr($css);
    $cssfile = FULL_PATH . 'css/default/style.css';
    $cssparser->parseFile($cssfile);
    $htmlholder = new htmlholder($body);
    $htmlholder->replaceCSS($cssparser->codestr_holder);
    $page = $htmlholder->out();
    $page = str_replace('#SiteUrl#', $siteurl, $page);
    $mime->setHTMLBody($page);
    if (!is_array($attachment)) {
        $attach_files = explode(',', $attachment);
    } else {
        $attach_files = $attachment;
    }
    if (count($attach_files) > 0) {
        foreach ($attach_files as $file) {
            if ($file != '') {
                $mime->addAttachment("../emailimages/" . $file);
            }
        }
    }
    $body = $mime->get();
    $hdrs = $mime->headers($headers);
    $params = false;
    if (MAIL_TYPE == 'smtp') {
        $params['host'] = SMTP_HOST;
        $params['port'] = SMTP_PORT;
        $params['auth'] = SMTP_AUTH == '1' ? true : false;
        $params['username'] = SMTP_USER;
        $params['password'] = SMTP_PASS;
    }
    if (1) {
        $mail_type = 'mail';
    } else {
        $mail_type = MAIL_TYPE;
    }
    if (ECHO_EMAILS === true) {
        echo $email . "<br/>";
        print_r($hdrs);
        echo "<br/>" . $body . "<br/>";
        $result = 1;
    } elseif (PHP_EMAILS) {
        include_once PEAR_DIR . 'Mail.php';
        $mailer = Mail::factory('mail');
        $mailer->send($email, $hdrs, $body);
        $result = 1;
    } else {
        $sendwithus_api = new API(SENDWITHUS_API_KEY);
        if (empty($body2)) {
            $email_data = array('subject' => $headers['Subject'], 'header' => $header, 'image_src' => $info['image_src'], 'content' => $body_original, 'content2' => $info['content2'], 'link' => array('text' => $info['anchor'], 'url' => $info['link']), 'loan_use' => $info['loan_use'], 'statusbar' => $info['statusbar'], 'footer' => $footer, 'button' => array('url' => $button_url, 'text' => $button_text));
        } else {
            $email_data = array('subject' => $headers['Subject'], 'header' => $header, 'heading' => $info['heading'], 'title' => $info['title'], 'percent' => $info['percent'], 'image_src' => $info['image_src'], 'content' => $body_original, 'link' => array('text' => $info['anchor'], 'url' => $info['link']), 'heading2' => $info['heading2'], 'title2' => $info['title2'], 'percent2' => $info['percent2'], 'image_src2' => $info['image_src2'], 'content2' => $body2, 'link2' => array('text2' => $info['anchor2'], 'url2' => $info['link2']), 'heading3' => $info['heading3'], 'title3' => $info['title3'], 'percent3' => $info['percent3'], 'image_src3' => $info['image_src3'], 'content3' => $body3, 'link3' => array('text3' => $info['anchor3'], 'url3' => $info['link3']), 'footer' => $footer, 'button' => array('url' => $button_url, 'text' => $button_text));
            $template = SENDWITHUS_TEMPLATE_3FEATURES;
        }
        $result = $sendwithus_api->send($template, array('address' => $email), $email_data);
    }
    return $result;
}
Ejemplo n.º 8
0
function addNewMailTemplate($mail_templates_id=0) {
	$db=new DBConnection();
	
    if($mail_templates_id&&!$_POST['_form_submit']) {
        $_SESSION['admin']['uedit']=$mail_templates_id;
        
        $query='SELECT * FROM mail_templates WHERE mail_templates_id='.($mail_templates_id+0).'';
        $res=$db->rq($query);
        foreach ($db->fetch($res) AS $RowName=>$RowValue) {
            $_POST[$RowName]=$RowValue;
        }
    }

	$settingsModel = new App\Model\Settings($db, 'mail_settings');
    $settings = $settingsModel->getAll();

    $API_KEY = $settings['sendwithus_key'];
    $options = array();
    $api = new API($API_KEY, $options);
    $response = $api->emails();
    $tags = explode(',', trim($settings['sendwithus_tags']));
    
    $selectTemplateHtml = '<option value="">Empty</option>';
    foreach($response as $template)
    {
    	$matched = count(array_filter($tags)) == 0;
    	foreach($tags as $tag){
    		if (isset($template->tags) && in_array(trim($tag), $template->tags)) {
				$matched = true;
				break;
			}
    	}
    	
    	if($matched){
    		$selectTemplateHtml .= "<option value='". $template->id ."' ".(isset($_POST['mail_external_id']) && $_POST['mail_external_id'] == "$template->id" ? "selected='selected'" : "") .">". $template->name ."</option>";
		}
    }
    // End
    
    $db->close();
    
	$templateVariables = Array(
    	'mail_template_title',
		'user_first_name',
       	'user_username',
		'user_last_name',
        'user_account_num',
    	'user_password',
		'user_password_org',
		'trade_details',
 		'trade_date',
      	'trade_sell_status',
 		'trade_buy_status',
 		'trade_value',
		'transfer_value',
		'transfer_date',
		'thanks',
		'company_name',
		'site_url',
		'funding_overviews',
		'trading_overviews',
		'trade_ref',
		'user_account_name',
		'user_admin_ref',
		'user_phone',
		'user_email',
		'user_mailing_address',
		'user_city',
		'user_state',
		'user_postal',
		'user_country',
		'user_advisor1',
		'user_advisor2',
		'user_app_date'
    );
    
    sort($templateVariables);
    
    $templateVariablesContent = '';
    
    if(count($templateVariables) == 0){
    	$templateVariablesContent = '<p>Variables are not defined for this template type.</p>';
   	}else{
   		$templateVariablesContent .= '<ul class="variable_list">';
   		foreach($templateVariables as $var){
   			$templateVariablesContent .= "<li>{{$var}}</li>";
   		}
   		$templateVariablesContent .= '</ul>';
   	}

    $pcontent='';
    $pcontent.='
<div class="mainHolder">
<div class="hintHolder ui-state-default"><b>'.(($mail_templates_id>0)?'Editing':'Creating New').' Mail Template</b></div> 
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="js/jquery.simplemodal-1.3.3.min.js"></script>
<link type="text/css" href="css/basic.css" rel="stylesheet" media="screen" />

<script type="text/javascript">

jQuery(function ($) {
	$(".basic").click(function (e) {
		var themeId  = $("#MailTemplate").val();
		var contentBody = tinyMCE.get("mail_html").getContent();
		
		$.ajax({
		  type:"post",
		  url: "ajax_theme.php",
		  data: {action: "GetTemplateById" ,themeId : themeId, contentBody:contentBody },
		  success: function(data) {
		  	$(".mailTArea").html(data);
		  	tinyMCE.get("mail_html").setContent(data);
          }
		})
		
		return false;
	});

});

$(document).ready(function(){
    ShowTemplate();
});

$(document).ready(function(){
    $("#MailTemplate").change(function(){
        tinyMCE.get("mail_html").setContent("loading...", {format : "raw"});
        $(".mailTArea").html("loading...");
        ShowTemplate();
    });
});

function ShowTemplate(){
     var externalId = $("#MailTemplate").val();

        $.ajax({
		  type:"post",
		  url: "ajax_theme.php",
		  dataType: "json",
		  data: {action: "GetTemplateById" ,templateId : externalId },
		  success: function(data) {
            tinyMCE.get("mail_html").setContent(data.html, {format : "raw"});
            $(".mailTArea").html(data.text);
            $("#template_name").val(data.name);
            $("#template_version").val(data.id);
          }
		});
}

tinyMCE.init({
	// General options
	mode : "textareas",
        theme : "advanced",
        editor_selector : "mceEditor",
        readonly : true,
        visual: false
});
</script>

<div id="basic-modal-content" style="display:none">
</div>
		
<form name="addNewMailTemplate" method="POST" id="MainForms" action="">
<fieldset class="mainFormHolder left" style="width:800px;">
	<legend>Template information</legend>
	<div class="formsLeft">Title:</div>
	<div class="formsRight">
		<input class="text-input" type="text" name="mail_template_title" id="mail_template_title" value="'.$_POST['mail_template_title'].'" />
		(used in admin area only)
	</div>
	
	<br />
	<div class="formsLeft">Mail From:</div>
	<div class="formsRight">
		<input class="text-input" type="text" name="mail_from_mail" id="mail_from_mail" value="'.$_POST['mail_from_mail'].'" />
		(ex: noreply@site.com)
	</div>
	
	<br />
	<div class="formsLeft">Mail BCC:</div>
	<div class="formsRight">
		<input class="text-input" type="text" name="mail_bcc" id="mail_bcc" value="'.$_POST['mail_bcc'].'" />
		(ex: noreply@site.com)
	</div>
	
	<br />
	<div class="formsLeft">Mail From Name:</div>
	<div class="formsRight">
		<input class="text-input" type="text" name="mail_from" id="mail_from" value="'.$_POST['mail_from'].'" />
		(ex: John Doe)
	</div>
	
	<br />
	<div class="formsLeft">Mail Subject:</div>
	<div class="formsRight">
		<input class="text-input" type="text" name="mail_subject" id="mail_subject" value="'.$_POST['mail_subject'].'" />
	</div>
	
	<br />
	<div class="formsLeft">Auto Mail?:</div>
	<div class="formsRight">
		<select name="mail_single" class="text-input">
			<option value="1"'.(($_POST['mail_single']==1)?' selected':'').'>No</option>
			<option value="0"'.(($_POST['mail_single']==0)?' selected':'').'>Yes</option>
		</select>
	</div>
	
	<br />
	<div class="formsLeft">Theme:</div>
	<div class="formsRight">
		<select name="mail_external_id" id="MailTemplate" class="text-input">'.$selectTemplateHtml.'</select>
	</div>

	<br />
	<div class="formsLeft">HTML Content:</div>
	<div class="formsRight">
		<br />
		<textarea name="mail_html" style="width:100%" class="mceEditor">Loading...</textarea>
	</div>
	
	<br />
	<div class="formsLeft">Plain Text Content:</div>
	<div class="formsRight">
		<br />
		<textarea name="mail_plain" style="width:100%" class="mailTArea">Loading...</textarea>
	</div>
	<input type="hidden" id="template_name" name="template_name" value="" />
	<input type="hidden" id="template_version" name="template_version" value="" />
	<input type="hidden" name="_form_submit" value="1" />
	<input type="submit" name="_submit" value="'.getLang('sform_savebtn').'" class="submitBtn ui-state-default" />';
    if($mail_templates_id) {
        $pcontent.='
	<input type="hidden" name="mtid" value="'.$mail_templates_id.'">
	<input type="button" name="_delete" value="'.getLang('sform_delbtn').'" class="submitBtn ui-state-default" onclick="if(confirm(\'Are you sure you want to delete this mail template?\')) location=\'?action=delete&mtid='.($_POST['mail_templates_id']+0).'\';" />';
    }
    $pcontent.='
	<input type="button" name="_cancel" value="'.getLang('sform_backbtn').'" class="submitBtn ui-state-default" onclick="location=\'mails_templates.php\';" />
	</fieldset>
	
	<fieldset class="mainFormHolder left" style="width: 300px;">
    	<legend>Variables</legend>
        '.$templateVariablesContent.'
	</fieldset>
	<br class="clear" />
</form>
</div>';
    return $pcontent;
}