how to Get cat id and expertise value in my controler - yii

This is my controller and I am trying to get category id and expertise data from my database field. Everything is working, but the problem is that I'm not getting the category id. The problem occurs when I am trying to print all record on my view controller. here is my part of code $cat_id =Yii::$app->request->get('categori_id');.
//start premium adviser section
public function actionPremiumsearch()
{
if(isset($_GET['login-button1']))
{
$model=new UserDetail();
$request = Yii::$app->request;
$post = $request->get();
$cat_id =Yii::$app->request->get('categori_id');
//var_dump($cat_id);exit;
//print_r($cat_id);exit;
$expertise =Yii::$app->request->get('expertise');
//print_r($expertise);exit;
//var_dump($cat_id);exit;
//$cat = $request->cat_id();
//echo $cat;
//print_r($post);
//$cat_id = $request->get('categori_id');
//echo $cat_id;
//$cat_id = $post['categories']['categori_id'];
//echo $cat_id;exit;
//print_r($cat_id);exit;
//print_r($post);
//$cat_id = $post['categori_id'];
//print_r($cat_id);
//$service_id = $post['Service']['id'];
//echo $service_id.' '.$expertise.' '.$cat_id;
//exit;
//echo "button1";
$query = new Query;
// compose the query
$query->select('kpt_users.*,kpt_user_details.*,kpt_user_services.*')
->from('kpt_users')
->join( 'INNER JOIN',
'kpt_user_details',
'kpt_user_details.user_id =kpt_users.id'
)
->join( 'LEFT JOIN',
'kpt_user_services',
'kpt_user_services.user_id= kpt_users.id'
)
//->Where(['kpt_users.user_role_id' =>$role_id,'kpt_user_services.service_id'=>$service_id])
->Where('kpt_users.status = 1')
->andWhere('kpt_users.user_role_id = 2')
//->andFilterWhere(['like', 'kpt_user_services.service_id', $this->service_id])
//->andFilterWhere(['like', 'kpt_user_details.categori_id', $this->categori_id])
//->andFilterWhere(['like', 'kpt_user_details.expertise', $this->expertise])
//->andWhere(['like', 'kpt_user_services.service_id', $service_id])
//->andWhere(['like', 'kpt_user_details.categori_id', $categori_id])
// ->andWhere(['like', 'kpt_user_details.expertise', $expertise])
//->andWhere('kpt_user_details = 2')
//->andWhere(['like', 'categori_id', $cat_id])
//->andWhere(['like', 'name', 'alex'])
//->andWhere(['like','kpt_user_services.service_id'=>$service_id,'kpt_user_details.categori_id'=>$cat_id])
->limit(2);
// build and execute the query
$rows = $query->all();
//var_dump($rows);exit;
return $this->render('personalinsurance', [
'result' => $rows,
'model' => $model,
]);
}
if(isset($_GET['login-button2'])){
//echo "kanak";
//echo "button1";
$query = new Query;
// compose the query
$query->select('kpt_users.*,kpt_user_details.*,kpt_user_services.*')
->from('kpt_users')
->join( 'INNER JOIN',
'kpt_user_details',
'kpt_user_details.user_id =kpt_users.id'
)
->join( 'LEFT JOIN',
'kpt_user_services',
'kpt_user_services.user_id= kpt_users.id'
)
//->Where(['kpt_users.user_role_id' =>$role_id,'kpt_user_services.service_id'=>$service_id])
->limit(4);
// build and execute the query
$rows = $query->all();
//var_dump($rows);exit;
return $this->render('corporateinsurance', [
'result' => $rows,
]);
}
if(isset($_GET['login-button3'])){
//echo "kanak3";
//echo "button1";
$query = new Query;
// compose the query
$query->select('kpt_users.*,kpt_user_details.*,kpt_user_services.*')
->from('kpt_users')
->join( 'INNER JOIN',
'kpt_user_details',
'kpt_user_details.user_id =kpt_users.id'
)
->join( 'LEFT JOIN',
'kpt_user_services',
'kpt_user_services.user_id= kpt_users.id'
)
//->Where(['kpt_users.user_role_id' =>$role_id,'kpt_user_services.service_id'=>$service_id])
->limit(4);
// build and execute the query
$rows = $query->all();
//var_dump($rows);exit;
return $this->render('sbasedplanning', [
'result' => $rows,
]);
}
if(isset($_GET['login-button4'])){
// echo "kanak4";
//echo "button1";
$query = new Query;
// compose the query
$query->select('kpt_users.*,kpt_user_details.*,kpt_user_services.*')
->from('kpt_users')
->join( 'INNER JOIN',
'kpt_user_details',
'kpt_user_details.user_id =kpt_users.id'
)
->join( 'LEFT JOIN',
'kpt_user_services',
'kpt_user_services.user_id= kpt_users.id'
)
//->Where(['kpt_users.user_role_id' =>$role_id,'kpt_user_services.service_id'=>$service_id])
->Where(['kpt_users.user_role_id' =>$role_id,'kpt_user_details.categori_id'=>$category_id])
->limit(4);
// build and execute the query
$rows = $query->all();
//var_dump($rows);exit;
return $this->render('taxplanning', [
'result' => $rows,
]);
}
}
This is my view controller with the foreach-loop. When I am trying to print the record, the category ID is missing. How can I get all data with category ID?
<?php foreach ($result as $rows):
$path = Yii::$app->params['imagePath'];
// print_r ($rows);exit;
?>
<?php $first_name = $rows['first_name'];
//echo $first_name;exit;
$agency_name = $rows['agency_name'];
$seller_name = $rows['seller_name'];
$reff_no = $rows['reff_no'];
$credentials = $rows['credentials'];
$photo = $rows['photo'];
$contact = $rows['contact'];
//echo $contact;exit;
$year_exp = $rows['year_exp'];
$expertise = $rows['expertise'];
$gender = $rows['gender'];
$title = $rows['title'];
$rnf = $rows['reff_no'];
$user_name = $rows['user_name'];
$user_email = $rows['user_email'];
$first_name = $rows['first_name'];
$user_id = $rows['user_id'];
$user_role_id = $rows['user_role_id'];
$service_id1 = $rows['service_id'];
//print_r( $service_id1);
// $service_name = $rows['service_name'];
$credentials = $rows['credentials'];
//echo "User Name: {$user_name}" . "<br>";
//echo "Ratings: {$rating}" . "<br>";
// echo "RNF: {$reff_no}" . "<br>";
//echo "Service Name: {$title}" . "<br>";
//echo "Service id: {$service_id}" . "<br>";
//echo "user role id: {$user_role_id}" . "<br>";
?>
<div class="parent">
<div class="col-lg-12 no-padding">
<div class="col-lg-6">
<div class="big-image">
<?php if($rows['photo']){ ?>
<img src=<?php echo $path; ?><?php echo $rows['photo']; ?> />
<?php } else { ?>
<?php echo Html::img('#web/images/banner/product-main.png'); ?>
<?php } ?>
<?php //echo Html::img('#web/images/banner/product-main.png'); ?></div>
</div>
<div class="col-lg-6">
<div class="product-name">
<h2><?php //echo $first_name?></h2>
<h2><a target="_blank" href="index.php?r=userslisting/user&id=<?php echo $rows['user_id']; ?>"><?php echo $rows['first_name'];?></a> </h2>
</div>
<div class="rating-point">
<p>Reating 4.5/5</p>
</div>
<div class="star">
<span><?php echo Html::img('#web/images/banner/star-full.png'); ?></span>
<span><?php echo Html::img('#web/images/banner/star-full.png'); ?></span>
<span><?php echo Html::img('#web/images/banner/star-full.png'); ?></span>
<span><?php echo Html::img('#web/images/banner/star-hafe.png'); ?></span>
<span><?php echo Html::img('#web/images/banner/star-0.png'); ?></span>
</div>
<div class="rating-point rnf">
<p class="pro-title">RNF</p>
<p class="pro-head-1"><?php echo $rnf?></p>
</div>
<div class="rating-point rank">
<p class="pro-title">Rank/Title</p>
<p class="pro-head-1"><?php echo $title?></p>
</div>
<div class="rating-point ss">
<p class="pro-title">service specialzation</p>
<p class="pro-head-1"><?php echo $expertise?></p>
</div>
<div class="rating-point creden">
<p class="pro-title">Credentials</p>
<p class="pro-head-1"><?php echo $credentials ?></p>
</div>
<div class="rating-point yoe">
<p class="pro-title">Years OF Experience</p>
<p class="pro-head-1"><?php echo $year_exp ?></p>
</div>
<div class="rating-point mail">
<p class="pro-title">Email</p>
<p class="pro-head-1"><?php echo $user_email; ?></p>
</div>
<div class="view-more">
<input type="button" class="btn btn-primary serch-select view-more" value="ENQUIRE" name="ENQUIRE">
<div class="enquiry">
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
<div class="alert alert-success">
Thank you for contacting us. We will respond to you as soon as possible.
</div>
<?php else: ?>
<form id="contact-form" action="" method="post" role="form">
<div class="form-group">
<div class="col-lg-12 no-padding">
<div class="name-1"><input type="text" name="name" class="form-control transparent" value="" placeholder="Name" required> </div>
<div class="contact-1"><input type="text" name="contact" class="form-control transparent" value="" placeholder="Contact No." required> </div>
</div>
</div>
<div class="form-group">
<div class="col-lg-12 no-padding">
<div class="email-1"><input type="email" name="email" class="form-control transparent" value="" placeholder="Email" required> </div>
<div class="subject-1"><input type="text" name="subject" class="form-control transparent" value="" placeholder="Subject" required></div>
</div>
</div>
<div class="form-group"><textarea name="message" class="form-control" rows="6" placeholder="Message"></textarea></div>
<input id="form-token" type="hidden" name="<?=Yii::$app->request->csrfParam?>"
value="<?=Yii::$app->request->csrfToken?>"/>
<div class="form-group submit-button">
<input type="hidden" name="user_id" value="<?php echo $rows['user_id']; ?>" />
<input type="hidden" name="user_name" value="<?php echo $rows['first_name'].' '.$rows['last_name']; ?>" />
<input type="hidden" name="user_email" value="<?php echo $rows['user_email']; ?>" />
<input type="submit" class="btn btn-primary" name="contact-button">
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="clear"></div>
<?php endforeach; ?>
Here is my form
<div class="serch-select-premium">
<?php $form = ActiveForm::begin(['action' =>['site/premiumsearch'], 'id' => '', 'method' => 'get',]); ?>
<?= $form->field($model, 'type_a_keyword')->textInput(['maxlength' => true, 'placeholder' => "Type a keyword"])->label(false); ?>
<?= Html::submitButton('Personal Insurance', ['class' => '','id' => 'personalinsurance', 'name' => 'login-button1']) ?>
<?= Html::submitButton('Corporate Insurance', ['class' => '','id' => 'corporateinsurance', 'name' => 'login-button2']) ?>
<?= Html::submitButton('Solution Based Planning', ['class' => '', 'id' => 'sbasedplanning','name' => 'login-button3']) ?>
<?= Html::submitButton('Tax Planning', ['class' => '','id' => 'taxplanning', 'name' => 'login-button4']) ?>
<?php ActiveForm::end(); ?>
</div>

Related

Issue to open dialog: Yii

I have used ajaxSubmitButton in my form.On click of button i am trying to open dialog When i click the button ,the dialog opens and it displays entire code written for that form . How to resolve this?
my code for button is :
<div class="btnalign" style="margin-top: 20px;margin-left:20px;">
<?=CHtml::ajaxSubmitButton('Mail to Client', Yii::app()->createUrl('reply/composeMail'),
array('type'=>'POST',
'data'=> 'js:{"data1":callData()}',
//'success' => 'function(response){afterSubmitForm(response);}'
'success'=>'js:function(string){ alert(string);$.fn.yiiGridView.update("my-grid"); }'
),
array('class' => 'btn btn-primary'));
?>
</div>
my controller code:
public function actionComposeMail()
{
if(Yii::app()->request->isAjaxRequest){
print_r($_POST['data1']);
if(isset($_POST['data1'])){
$model=new Reply;
$model->scenario = 'compose';
EQuickDlgs::render('_compose',array(
'model'=>$model,
));
}else{
echo "Please select row to Mail.";
}
}
else
{
echo "The request is invalid.";
}
}
my dialog form code is:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'reply-form',
'enableAjaxValidation'=>true,
'htmlOptions' => array('enctype' => 'multipart/form-data'),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.For multiple recipients please seperate by comma</p>
<?php echo $form->errorSummary($model); ?>
<div class="row col2">
<?php echo $form->labelEx($model,'email_from'); ?>
<?php echo $form->textField($model,'email_from',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_from'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'email_to'); ?>
<?php echo $form->textField($model,'email_to',array('size'=>60,'maxlength'=>150)); ?>
<?php echo $form->error($model,'email_to'); ?>
</div>
<div style="clear:both"></div>
<div class="row col2">
<?php echo $form->labelEx($model,'email_cc'); ?>
<?php echo $form->textField($model,'email_cc',array('size'=>60,'maxlength'=>250)); ?>
<?php echo $form->error($model,'email_cc'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'subject'); ?>
<?php echo $form->textField($model,'subject',array('size'=>60,'maxlength'=>250)); ?>
<?php echo $form->error($model,'subject'); ?>
</div>
<div style="clear:both"></div>
<div class="row">
<?php echo $form->labelEx($model,'message'); ?>
<?php echo $form->textArea($model,'message',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'message'); ?>
</div>
<div style="clear:both"></div>
<div style="clear:both"></div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Send' : 'Send',array('class' => 'btn')); ?>
</div>
<?php $this->endWidget(); ?>
Image of dialog
You must use renderPartial() instead of render() and try to call Yii::app()->end() at the end in your mail form view
public function actionComposeMail()
{
if(Yii::app()->request->isAjaxRequest){
print_r($_POST['data1']);
if(isset($_POST['data1'])){
$model=new Reply;
$model->scenario = 'compose';
$this->renderPartial('_compose',array(
'model'=>$model,
));
}else{
echo "Please select row to Mail.";
}
}
else
{
echo "The request is invalid.";
}
}

OpenCart text at login page doesnt get changed if I change lines in language files

I run an opencart shop 1.5.6.4 with vqmod installed.
I installed xml from opencart in order to force a login before reaching my shop. So it's a closed shop. I customized my login page inside css to hide all menu bars and I "copied" the language selector from the shop into the login page.
It's working, but since then the language texts from the connected language files don't get recognized anymore and the login page texts are like "entry_password". But in the language folders/files I connected them correctly.
Do you have any hints how to fix this?
Yes, I could write them directly into my login.tpl but then I would only have one language available.
I tried to uninstall all vqmod xmls via vqmod manager and got the same result.
It looks like the language isn't loaded correctly, but I really don't know why.
This is my login.tpl in catalog/view/theme/default/template/account:
<?php echo $header; ?>
<style>
INLINE CSS
</style>
<div id="banner">
<center><img src="BANNER URL" alt="header" /></center><br/>
</div>
<?php if ($success) { ?>
<div class="success">Login erfolgreich</div>
<?php } ?>
<?php if ($error_warning) { ?>
<div class="warning">Login fehlgeschlagen</div>
<?php } ?>
<div id="content">
<div class="login-content">
<div class="left">
<h2><?php echo $text_new_customer; ?></h2>
<div class="content">
<p><b><?php echo $text_register; ?></b></p>
<p><?php echo $text_register_account; ?></p>
<?php echo $button_continue; ?></div>
</div>
<div class="right">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<div id="language_selector">Sprache | Language<br>
<img src="image/flags/de.png" alt="Deutsch" title="Deutsch" onclick="$('input[name=\'language_code\']').attr('value', 'de'); $(this).parent().parent().submit();">
<img src="image/flags/gb.png" alt="English" title="English" onclick="$('input[name=\'language_code\']').attr('value', 'en'); $(this).parent().parent().submit();">
<img src="image/flags/nl.png" alt="Nederlands" title="Nederlands" onclick="$('input[name=\'language_code\']').attr('value', 'nl'); $(this).parent().parent().submit();">
<input type="hidden" name="language_code" value="">
<input type="hidden" name="redirect" value="http://MYDOMAIN/opencart/index.php?route=account/login">
</div>
<div class="content">
<h2>Login</h2>
<b>E-Mail:</b><br />
<input type="text" name="email" value="<?php echo $email; ?>" />
<br />
<br />
<b>Password</b><br />
<input type="password" name="password" value="<?php echo $password; ?>" />
<br />
<?php echo $text_forgotten; ?><br />
<br />
<input type="submit" value="<?php echo $button_login; ?>" class="button" />
<?php if ($redirect) { ?>
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
<?php } ?>
</div>
</form>
</div>
</div>
<?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('#login input').keydown(function(e) {
if (e.keyCode == 13) {
$('#login').submit();
}
});
//--></script>
<?php echo $footer; ?>
I want to change the div class content in order to make the h2 and b fields in multilanguage by reading it out from the language-php files:
<div class="content">
<h2><?php echo $text_login; ?></h2>
<b><?php echo $entry_email; ?></b><br />
<input type="text" name="email" value="<?php echo $email; ?>" />
<br />
<br />
<b><?php echo $entry_password; ?></b><br />
<input type="password" name="password" value="<?php echo $password; ?>" />
<br />
<?php echo $text_forgotten; ?><br />
<br />
<input type="submit" value="<?php echo $button_login; ?>" class="button" />
<?php if ($redirect) { ?>
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
<?php } ?>
</div>
this is a language-file login.php example: (located in /catalog/language/english/account/)
<?php
// Heading
$_['heading_title'] = 'Account Login';
// Text
$_['text_account'] = 'Account';
$_['text_login'] = 'Login';
$_['text_new_customer'] = 'New Customer';
$_['text_register'] = 'Register Account';
$_['text_register_account'] = 'By creating an account you will be able to shop faster, be up to date on an order\'s status, and keep track of the orders you have previously made.';
$_['text_returning_customer'] = 'Returning Customer';
$_['text_i_am_returning_customer'] = 'I am a returning customer';
$_['text_forgotten'] = 'Forgotten Password';
// Entry
$_['entry_email'] = 'E-Mail Address:';
$_['entry_password'] = 'Password:';
// Error
$_['error_login'] = 'Warning: No match for E-Mail Address and/or Password.';
$_['error_approved'] = 'Warning: Your account requires approval before you can login.';
?>
this is my controller-file login.php example which should connect $entry_email, $entry_password and $text_login into the active language file (english language file see above).
It is located in /catalog/controller/account
<?php
class ControllerAccountLogin extends Controller {
private $error = array();
public function index() {
$this->load->model('account/customer');
// Login override for admin users
if (!empty($this->request->get['token'])) {
$this->customer->logout();
$this->cart->clear();
unset($this->session->data['wishlist']);
unset($this->session->data['shipping_address_id']);
unset($this->session->data['shipping_country_id']);
unset($this->session->data['shipping_zone_id']);
unset($this->session->data['shipping_postcode']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_address_id']);
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
$customer_info = $this->model_account_customer->getCustomerByToken($this->request->get['token']);
if ($customer_info && $this->customer->login($customer_info['email'], '', true)) {
// Default Addresses
$this->load->model('account/address');
$address_info = $this->model_account_address->getAddress($this->customer->getAddressId());
if ($address_info) {
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_country_id'] = $address_info['country_id'];
$this->session->data['shipping_zone_id'] = $address_info['zone_id'];
$this->session->data['shipping_postcode'] = $address_info['postcode'];
}
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_country_id'] = $address_info['country_id'];
$this->session->data['payment_zone_id'] = $address_info['zone_id'];
}
} else {
unset($this->session->data['shipping_country_id']);
unset($this->session->data['shipping_zone_id']);
unset($this->session->data['shipping_postcode']);
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
}
$this->redirect($this->url->link('common/home'));
}
}
if ($this->customer->isLogged()) {
$this->redirect($this->url->link('common/home'));
}
$this->language->load('account/account');
$this->document->setTitle($this->language->get('heading_title'));
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
unset($this->session->data['guest']);
// Default Shipping Address
$this->load->model('account/address');
$address_info = $this->model_account_address->getAddress($this->customer->getAddressId());
if ($address_info) {
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_country_id'] = $address_info['country_id'];
$this->session->data['shipping_zone_id'] = $address_info['zone_id'];
$this->session->data['shipping_postcode'] = $address_info['postcode'];
}
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_country_id'] = $address_info['country_id'];
$this->session->data['payment_zone_id'] = $address_info['zone_id'];
}
} else {
unset($this->session->data['shipping_country_id']);
unset($this->session->data['shipping_zone_id']);
unset($this->session->data['shipping_postcode']);
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
}
// Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$this->redirect(str_replace('&', '&', $this->request->post['redirect']));
} else {
$this->redirect($this->url->link('common/home'));
}
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_login'),
'href' => $this->url->link('account/login', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_new_customer'] = $this->language->get('text_new_customer');
$this->data['text_register'] = $this->language->get('text_register');
$this->data['text_register_account'] = $this->language->get('text_register_account');
$this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
$this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
$this->data['text_forgotten'] = $this->language->get('text_forgotten');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_password'] = $this->language->get('entry_password');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['button_login'] = $this->language->get('button_login');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
$this->data['action'] = $this->url->link('account/login', '', 'SSL');
$this->data['register'] = $this->url->link('account/register', '', 'SSL');
$this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
// Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295)
if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) {
$this->data['redirect'] = $this->request->post['redirect'];
} elseif (isset($this->session->data['redirect'])) {
$this->data['redirect'] = $this->session->data['redirect'];
unset($this->session->data['redirect']);
} else {
$this->data['redirect'] = '';
}
if (isset($this->session->data['success'])) {
$this->data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$this->data['success'] = '';
}
if (isset($this->request->post['email'])) {
$this->data['email'] = $this->request->post['email'];
} else {
$this->data['email'] = '';
}
if (isset($this->request->post['password'])) {
$this->data['password'] = $this->request->post['password'];
} else {
$this->data['password'] = '';
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/login.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/login.tpl';
} else {
$this->template = 'default/template/account/login.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
protected function validate() {
if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) {
$this->error['warning'] = $this->language->get('error_login');
}
$customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']);
if ($customer_info && !$customer_info['approved']) {
$this->error['warning'] = $this->language->get('error_approved');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>
What I already tried:
- Replace login.tpl with original default login.tpl (in catalog/view/theme/default/template/account)
- Remove all vqmod xml's from vqmod manager.
Thanks in advance for your help.
language-file login.php
$_['text_email1'] = 'Email Address';
$_['text_pass1'] = 'Password';
controller-file login.php
$this->data['email1'] = $this->language->get('text_email1');
$this->data['pass1'] = $this->language->get('text_pass1');
Login.tpl
<div class="content">
<h2><?php echo $text_login ?></h2>
<b><?php echo $email1 ?></b><br />
<input type="text" name="email" value="<?php echo $email; ?>" />
<br />
<br />
<b> <?php echo $pass1 ?> </b><br />
<input type="password" name="password" value="<?php echo $password; ?>" />
<br />
<?php echo $text_forgotten; ?><br />
<br />
<input type="submit" value="<?php echo $button_login; ?>" class="button" />
<?php if ($redirect) { ?>
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
<?php } ?>
</div>
Add the code in language and controller file,and change div class content with this.

AJAX validation in search

I am new to Yii, I have two tables. master_customer,master_client. In the client model, in the view I have a search box, If I enter a few letters in the search box, it must automatically get the data and give results from master_customers(like google suggestions). I have made relations in the client model with the master_customer.
please help me with the code. Thanks in advance
CONTROLLER action:
public function actionIndex()
{
$criteria = new CDbCriteria();
if(isset($_GET['q']))
{
$q = "%".$_GET['q']."%";
$criteria->condition = 'cust_name='.$q;
$arrTier3 = MasterCustomers::model()->findAll($criteria);
//$criteria->compare(MasterCustomers::model()->cust_name,$q, true);
//$criteria->compare('$data->customers->cust_name', $q, true, 'OR');
print_r($arrTier3);
die();
}
$dataProvider=new CActiveDataProvider('Host', array('criteria'=>$criteria));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
view :
<!--Content-->
<div id="content">
<div style="padding: 10px;">
<a href="<?php echo $this->createUrl('/Controller/create');?>" title="Create New Host" class="btn btn-primary circle_ok" style="text-decoration: none;" >Add New Host to Customer</a>
<div style="float:right">
<?php
echo CHtml::link('Upload Customer CSV', array('/Controller/uploadCustomers'), array(
'onclick'=>'return hs.htmlExpand(this, { objectType: "iframe", wrapperClassName: "full-size", align: "center" } )',
'class'=>'btn btn-primary',
'id'=>'upload_link',
));
?>
</div>
</div>
<h3><?php echo $title; ?></h3>
<div class="innerLR">
<div class="row-fluid">
<?php
$obj=$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
//'afterAjaxUpdate'=>'\'changeTRColor()\'',
//'itemView'=>'_view',
'columns'=>array(
array( // display 'create_time' using an expression
'name'=>'name',
'value'=>'$data->host_name',
),
array(
'name'=>'serviceId',
'value'=>'$data->host_serviceid',
),
array(
'name'=>'customer',
'value'=>'$data->customers->cust_name',
),
array(
'class'=>'CButtonColumn',
'template'=>'{delete}{update}',)
),
));
?>
<form method="get">
<input type="search" placeholder="search" name="q" value="<?=isset($_GET['q']) ? CHtml::encode($_GET['q']) : '' ; ?>" />
<input type="submit" value="search" />
</form>
</div>
<div class="separator bottom"></div>
</div>
</div>
<!-- // Content END -->
<div class="clearfix"></div>
<!-- // Sidebar menu & content wrapper END -->
<div id="footer" class="hidden-print">
<?php $this->renderPartial('application.views.layouts._footer_inc'); ?>
</div>
If you need a search like google that searches on each key press and update GridView then you can try like this. In your javascript write
<script type="text/javascript">
$(document).ready(function () {
$('#id of your search box').keyup(function () {
$.fn.yiiGridView.update('id of your grid to be updated', {
data: $(this).serialize()
});
});
});
</script>
In your controller check the $_POST variable that what value it has, so you can grab that value and search in master_customers for that specific value and render the view again.

Yii CJuiDialog isn't being recognized

I've went through this tutorial http://www.yiiframework.com/wiki/561/ajax-login-form-with-validation-errors-inside-jquery-modal-dialog/ It appears to be functioning properly, but instead of the form being in the modal dialog, it just renders it right on the page like zii.widgets.jui.CJuiDialog isn't even there.
<?php $this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'login-dialog',
'options'=>array(
'title'=>'Login',
'autoOpen'=>false,
),
));?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'user_login_form',
'enableAjaxValidation'=>false,
'enableClientValidation'=>true,
'method' => 'POST',
'clientOptions'=>array(
'validateOnSubmit'=>true,
'validateOnChange'=>true,
'validateOnType'=>false,
),
)); ?>
<h1>
Login</h1>
<p>
Please fill out the following form with your login credentials:</p>
<p class="note">
Fields with <span class="required">*</span> are required.</p>
<div id="login-error-div" class="errorMessage" style="display: none;">
</div>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username',array("onfocus"=>"$('#login-error- div').hide();")); ?>
<?php //echo $form->error($model,'username'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password',array("onfocus"=>"$('#login-error- div').hide();")); ?>
<?php //echo $form->error($model,'password'); ?>
<p class="hint">
Hint: You may login with <tt>demo/demo</tt>.
</p>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe'); ?>
<?php echo $form->error($model,'rememberMe'); ?>
</div>
<div class="row submit">
<?php echo CHtml::ajaxSubmitButton(
'Sign In',
array('/site/login.GetLogin'),
array(
'beforeSend' => 'function(){
$("#login").attr("disabled",true);
}',
'complete' => 'function(){
$("#user_login_form").each(function(){ this.reset();});
$("#login").attr("disabled",false);
}',
'success'=>'function(data){
var obj = jQuery.parseJSON(data);
// View login errors!
// alert(data);
if(obj.login == "success"){
$("#user_login_form").html("<h4>
Login Successful! Please Wait...</h4>
");
parent.location.href = "/";
}
else{
$("#login-error-div").show();
$("#login-error-div").html("Login failed! Try again.");$("#login-error-div").append("
");
}
}'
),
array("id"=>"login","class" => "btn btn-primary")
); ?>
</div>
<?php $this->endWidget(); ?>
</div>
<!-- form -->
<?php $this->endWidget('zii.widgets.jui.CJuiDialog'); ?>
Its suppose to render like this above so when i click the link below it opens
echo CHtml::link('Login', array('/site/login.GetLogin'), array('onclick'=>'$("#login-dialog").dialog("open"); return false;'));
Its built in a widget, if you have a look at the tutorial. Here's the complete widget
<?php
class loginProvider extends CWidget{
public static function actions(){
return array(
'GetLogin'=>'application.components.actions.getLogin',
);
}
public function run(){
$this->renderContent();
}
protected function renderContent(){
echo '<span style="float:right;">';
if(Yii::app()->user->isGuest){
echo CHtml::link('Login', array('/site/login.GetLogin'), array('onclick'=>'$("#login-dialog").dialog("open"); return false;'));
echo '</span>';
$this->getController()- >renderPartial('application.components.views.login',array('model'=>new LoginForm));
}
else
echo CHtml::link('Logout ('.Yii::app()->user->name.')', array('site/logout'), array('visible'=>!Yii::app()->user->isGuest));
echo '</span>';
}
}

Sort on custom field

I need your help with my widget type code for wordpress. I have a custom field called ordermetakey. I need this below box to sort the posts on this custom field ASC. Its a numeric timestamp.
<div class="list-block">
<ul>
<?php $postslist = get_posts('numberposts=5'); foreach ($postslist as $post) : setup_postdata($post); ?>
<li>
<p><strong><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br \> <span><?php echo get_post_meta($post->ID, 'standplaats', true); ?></span></p>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="list-block">
<ul>
<?php $postslist = get_posts( array(
'meta_key' => 'ordermetakey',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => 5
);
foreach ($postslist as $post) : setup_postdata($post); ?>
<li>
<p><strong><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br \> <span><?php echo get_post_meta($post->ID, 'standplaats', true); ?></span></p>
</li>
<?php endforeach; ?>
</ul>
</div>