/** * Lists all models. */ public function actionIndex() { if (isset($_POST['oper']) && $_POST['oper'] == 'edit') { $id = intval($_POST["id"]); $message = CustomMessages::model()->findByPk($id); if ($message) { $error_string= ''; $message->Message_Text = $_POST['Message_Text'] ? $_POST["Message_Text"] : ' '; $message->Message_Type = $_POST['Message_Type'] ? $_POST["Message_Type"] : ' '; if ($message->validate() && $error_string == '') { $message->save(); echo "video\n"; } else { die($error_string); } } die; } if (isset($_POST['oper']) && $_POST['oper'] == 'add') { // var_dump($_POST);die; $error_string= ''; $message = new CustomMessages(); $message->Message_Text = $_POST['Message_Text'] ? $_POST["Message_Text"] : ' '; $message->Message_Type = $_POST['Message_Type'] ? $_POST["Message_Type"] : ' '; if ($message->validate() && $error_string == '') { $message->save(); } else { die($error_string); } die; } if (isset($_POST['oper']) && $_POST['oper'] == 'del') { $id = intval($_POST["id"]); $message = CustomMessages::model()->findByPk($id); if ($message) { $message->delete(); } 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"] = "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; // set columns $col = array(); $col["title"] = "Message_Text"; // caption of column $col["name"] = "Message_Text"; $col["dbname"] = "Message_Text"; // 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"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Message_Type"; // caption of column $col["name"] = "Message_Type"; $col["dbname"] = "Message_Type"; // 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"] = true; $cols[] = $col; $g = new jqgrid(); $grid["caption"] = "Custom messages"; // $grid["multiselect"] = true; $grid["autowidth"] = true; $grid["resizable"] = true; //$grid["toppager"] = true; $grid["sortname"] = 'Message_ID'; $grid["sortorder"] = "ASC"; $grid["add_options"] = array( 'width'=>'420', "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"=>true, // 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 custom_messages.* FROM custom_messages"; // set database table for CRUD operations $g->table = "custom_messages"; $g->set_columns($cols); // group columns header $g->set_group_header( array( "useColSpanStyle"=>true, "groupHeaders"=>array( array( "startColumnName"=>'Message_ID', // group starts from this column "numberOfColumns"=>2, // group span to next 2 columns "titleText"=>'ID' // caption of group header ), ) ) ); // render grid and get html/js output $out = $g->render("Messages"); $this->render('index',array( 'out'=>$out, )); }
<div class="modal_box" id="ask_using_last_card" style="display:none;"> <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/cancel.png" alt="" class="hidemodal cancelbutton"/> <h2><h2><?=CustomMessages::getMessage(1);?> <span id="sum_to_pay"></span> ?</h2> <div id="last_cc_info"> <input type="hidden" name="monthly_payment" class="monthly_payment" value="0"> </div> <div class="center"> <button class="button hidemodal" id="use_last_card" style="display: inline-block;">Use This Card</button> <button class="button hidemodal" id="use_new_card" style="margin-left: 30px;">Use Other Card</button> </div> </div>