* @var $tableRegPrimary * @var $tableRegDeleted * @var $tableTemplate * @var $tableSuccess * @var $tableList * @var $tableError * @var $listId * @var $templateId * @var $packageNum */ set_time_limit(0); require_once '../../components/Controller.php'; include Controller::getBasePath() . '/include/config.php'; require_once './models/MailTemplates.php'; require_once './mailer_settings.php'; $modelMailTemplate = new MailTemplates(); $modelMailTemplate->initMailer(); $result['success_count'] = $result['error_count'] = 0; $numReg = 0; $result['type'] = null; $type =& $result['type']; function replaceTemplateVars($string) { global $GLOBALS; preg_match_all("/\\{\\{(.*)\\}\\}/iU", $string, $output_array); $replace = array(); foreach ($output_array[1] as $v) { $v = str_replace(']', '', htmlspecialchars_decode($v, ENT_QUOTES)); $v = str_replace('"', '', $v); $v = str_replace("'", '', $v); $v_arr = explode('[', $v);
/** * Lists all models. */ public function actionIndex() { if (isset($_POST['oper']) && $_POST['oper'] == 'edit') { $mtID = intval($_POST["id"]); $mt = MailTemplates::model()->findByPk($mtID); if ($mt) { $mt->Title = $_POST["Title"] ? $_POST["Title"] : null; $mt->Message_Body = $_POST["Message_Body"] ? $_POST["Message_Body"] : null; if ($mt->validate()) { $mt->save(); echo "mails\n"; } } die; } if (isset($_POST['oper']) && $_POST['oper'] == 'add') { } if (isset($_POST['oper']) && $_POST['oper'] == 'del') { die; } $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword); mysql_select_db(Yii::app()->params->dbname); mysql_query("SET NAMES 'utf8'"); Yii::import('ext.phpgrid.inc.jqgrid'); // set columns $col = array(); $col["title"] = "Message_ID"; // caption of column $col["name"] = "Message_ID"; $col["dbname"] = "mail_templates.Message_ID"; // grid column name, same as db field or alias from sql $col["resizable"] = false; $col["editable"] = false; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = false; $col["sortable"] = true; $cols[] = $col; $col = array(); $col["title"] = "Title"; // caption of column $col["name"] = "Title"; $col["dbname"] = "mail_templates.Title"; // grid column name, same as db field or alias from sql $col["resizable"] = false; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; $col = array(); $col["title"] = "Message Body"; // caption of column $col["name"] = "Message_Body"; $col["dbname"] = "mail_templates.Message_Body"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = false; $col["edittype"] = "textarea"; $col["editoptions"] = array("rows"=>15, "cols"=>80); $cols[] = $col; $g = new jqgrid(); $grid["caption"] = "Mail Templates"; // $grid["multiselect"] = true; $grid["autowidth"] = true; $grid["resizable"] = true; //$grid["toppager"] = true; $grid["sortname"] = 'mail_templates.Message_ID'; $grid["sortorder"] = "ASC"; $grid["add_options"] = array( 'width'=>'600', "closeAfterEdit"=>true, // close dialog after add/edit "top"=>"200", // absolute top position of dialog "left"=>"200" // absolute left position of dialog ); $g->set_options($grid); $g->set_actions(array( "add"=>true, // allow/disallow add "edit"=>true, // allow/disallow edit "delete"=>false, // allow/disallow delete "rowactions"=>true, // show/hide row wise edit/del/save option "export"=>true, // show/hide export to excel option "autofilter" => true, // show/hide autofilter for search "search" => "advance" // show single/multi field search condition (e.g. simple or advance) ) ); $g->select_command = "SELECT mail_templates.* FROM mail_templates"; // set database table for CRUD operations $g->table = "mail_templates"; $g->set_columns($cols); // group columns header $g->set_group_header( array( "useColSpanStyle"=>true, "groupHeaders"=>array( array( "startColumnName"=>'Note_ID', // group starts from this column "numberOfColumns"=>3, // group span to next 2 columns "titleText"=>'Mail Template Information' // caption of group header ), ) ) ); // render grid and get html/js output $out = $g->render("mail_templates"); $this->render('index',array( 'out'=>$out, )); }
<?php if (isset($_POST['template_id']) && ($template_id = $_POST['template_id'])) { require_once '../../components/Controller.php'; require_once Controller::getBasePath() . '/include/config.php'; require_once './models/MailTemplates.php'; $controller = new Controller(); $template = MailTemplates::findOne($template_id); $result = array(); function generate($language = '') { global $controller; global $template; $language_part = $language ? '_' . $language : ''; $body = $controller->renderPartial('/templates/' . $template['file_name'] . $language_part . '.' . $template['file_extension'], $GLOBALS, $GLOBALS['basePath']); // $template['info']['embedded_images'] = array(); ///start embedded_images if (isset($template['embedded_images'])) { $embeddedImages = explode('|', $template['embedded_images']); if (count($embeddedImages) > 0) { $path = $cid = array(); foreach ($embeddedImages as $embeddedImage) { $pathCid = explode('=', $embeddedImage); if (count($pathCid) === 2) { $path[] = $pathCid[0]; $cid[] = 'cid:' . $pathCid[1]; } } function getUrlByPath($path) { global $baseUrl;
<form action="" method="POST" id="f_register" class="mail-form"> <input type="hidden" name="from" value=""/> <input type="hidden" name="from_name" value=""/> <input type="hidden" name="reply_to" value=""/> <input type="hidden" name="reply_to_name" value=""/> <input type="hidden" name="bcc" value=""/> <input type="hidden" name="bcc_name" value=""/> <input type="hidden" name="cc" value=""/> <table id="table_reg"> <tr> <td><label for="template">Template:</label></td> <td> <select id="template"> <option value=""></option> <?php foreach (MailTemplates::listData('id', 'name') as $t_id => $t_name):?> <option value="<?= $t_id ?>"><?= $t_name ?></option> <? endforeach; ?> </select> </td> </tr> <tr> <td><label for="language-template">Language:</label></td> <td> <select id="language-template"> </select> </td> </tr>