I have a manage quotations page. I need a search based on quotation name and project customer in drop down. With respect to quotation name, I got right search. But drop down user search is not working correctly. The drop down is using another model. The code I followed is given below:-
manageprojects.php
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form">
<?php $this->renderPartial('_search',array(
'model'=>$bots,
'modell'=>$model,
)); ?>
</div>
_search.php
<?php
/* #var $this QuotationsController */
/* #var $model Aquotations */
/* #var $form CActiveForm */
?>
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<style>
.row1{width:auto; overflow:hidden;}
.row20{width:20%;display:inline-block;}
</style>
<div class="row1">
<div class="row20">
<?php echo $form->label($model,'Quotation Serial No'); ?>
<?php echo $form->textField($model,'serial_no'); ?>
</div>
<div class="row20">
<?php echo $form->label($model,'Project'); ?>
<?php echo $form->textField($model,'project_id',array('size'=>60,'maxlength'=>255,'id' =>'projectsid','onkeyup' => "searchcprojects()")); ?>
<div id="searchresult" style="background:#90EE90;"></div>
</div>
<div class="row20">
<?php echo $form->label($model,'Select User'); ?>
<?php echo CHtml::dropDownList('user_id', $model->id, CHtml::listData($model::model()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => 'Select User', 'class' => 'span12')); ?>
</div>
<div class="row20">
<?php echo CHtml::submitButton('Search', array("class" => "btn btn-danger")); ?>
</div>
</div><!--row1-->
<?php $this->endWidget(); ?>
project Controller
$model = new Acustomers();
$bot=new Aquotations('search');
$bot->unsetAttributes(); // clear any default values
if(isset($_GET['Aquotations'])){
$bot->attributes=$_GET['Aquotations'];
}
$this->render('managequotations',array(
'bots' => $bot,
'model' => $model,
You need to use the activeDropDownList not the dropDownList:
<?php echo CHtml::activeDropDownList($model, 'user_id',
CHtml::listData(User::model()->findAll(array('order' => 'name')),'id','name'),
array('empty' => 'Select User', 'class' => 'span12'));
?>
Related
I need to create a common search in yii2 grid which will search from all the column of grid view table.This is what I did so far.
index.php
<div class="pull-right">
<?php yii\widgets\Pjax::begin(['id' => 'search-form' , 'timeout' => false, 'clientOptions' => ['method' => 'POST']]) ?>
<?php $form = ActiveForm::begin(['options' => ['data-pjax' => true ]]); ?>
<?= $form->field($model, 'searchString')->textInput(['maxlength' => 200])->label(false) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php yii\widgets\Pjax::end() ?>
</div>
<?php Pjax::begin(['id' => 'assets']); ?>
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
/** column names **/
]);
?>
<?php Pjax::end(); ?>
$this->registerJs(
'$("document").ready(function(){
$("#search-form").on("pjax:end", function() {
$.pjax.reload({container:"#assets"});
});
});'
);
Now when I submit searchbox didn't get desired result. Is there anything which I need to do to get output which I want. I looked from these links.
Link1
Link2
Please help me to achieve this.
the script is osclasss
This is the original code
?php if ( osc_count_categories() ) { ?>
<div class="cell selector">
<?php osc_categories_select('sCategory', null, __('Select a category', 'bender')) ; ?>
</div>
<div class="cell reset-padding">
<?php } else { ?>
<div class="cell">
<?php } ?>
<button class="ui-button ui-button-big js-submit"><?php _e("Search", 'bender');?></button>
</div>
How can I edit this code to make the user select a city for search not a category ?
Thank you everyone.
I found the solution =)
Thanks to https://stackoverflow.com/users/3465265/key
Just add this code
<?php $aCities = City::newInstance()->listAll(); ?>
<?php if(count($aCities) > 0 ) { ?>
<select name="sCity" id="sCity">
<option value=""><?php _e('Select a city...')?></option>
<?php foreach($aCities as $city) { ?>
<option value="<?php echo $city['s_name'] ; ?>"><?php echo $city['s_name'] ; ?></option>
<?php } ?>
</select>
<?php } ?>
If anyone can implemented the braintree payment gateway in php so help me to recurring billing in php application using braintree payment gateway
My Code is follows:
<?php function braintree_text_field($label, $name, $result) {
echo('<div>' . $label . '</div>');
$fieldValue = isset($result) ? $result->valueForHtmlField($name) : '';
echo('<div><input type="text" name="' . $name .'" value="' . $fieldValue . '" /></div>');
$errors = isset($result) ? $result->errors->onHtmlField($name) : array();
foreach($errors as $error) {
echo('<div style="color: red;">' . $error->message . '</div>');
}
echo("\n");
}c
?>
<head>
<title>Braintree Payment - Debt Relief</title>
</head>
<body>
<?php
if (isset($_GET["id"])) {
$result = Braintree_TransparentRedirect::confirm($_SERVER['QUERY_STRING']);
}
if (isset($result) && $result->success) { ?>
<h1>Braintree Payment -Debt Relief</h1>
<?php $transaction = $result->transaction; ?>
<table>
<tr><td>transaction id</td><td><?php echo htmlentities($transaction->id); ?></td></tr>
<tr><td>transaction status</td><td><?php echo htmlentities($transaction->status); ?></td></tr>
<tr><td>transaction amount</td><td><?php echo htmlentities($transaction->amount); ?></td></tr>
<tr><td>customer first name</td><td><?php echo htmlentities($transaction->customerDetails->firstName); ?></td></tr>
<tr><td>customer last name</td><td><?php echo htmlentities($transaction->customerDetails->lastName); ?></td></tr>
<tr><td>customer email</td><td><?php echo htmlentities($transaction->customerDetails->email); ?></td></tr>
<tr><td>credit card number</td><td><?php echo htmlentities($transaction->creditCardDetails->maskedNumber); ?></td></tr>
<tr><td>expiration date</td><td><?php echo htmlentities($transaction->creditCardDetails->expirationDate); ?></td></tr>
</table>
<?php
} else {
if (!isset($result)) { $result = null; } ?>
<h1>Braintree Payment -Debt Relief</h1>
<?php if (isset($result)) { ?>
<div style="color: red;"><?php echo $result->errors->deepSize(); ?> error(s)</div>
<?php } ?>
<form method="POST" action="<?php echo Braintree_TransparentRedirect::url() ?>" autocomplete="off">
<fieldset>
<legend>Customer</legend>
<?php braintree_text_field('First Name', 'transaction[customer][first_name]', $result); ?>
<?php braintree_text_field('Last Name', 'transaction[customer][last_name]', $result); ?>
<?php braintree_text_field('Email', 'transaction[customer][email]', $result); ?>
</fieldset>
<fieldset>
<legend>Payment Information</legend>
<?php braintree_text_field('Credit Card Number', 'transaction[credit_card][number]', $result); ?>
<?php braintree_text_field('Expiration Date (MM/YY)', 'transaction[credit_card][expiration_date]', $result); ?>
<?php braintree_text_field('CVV', 'transaction[credit_card][cvv]', $result); ?>
</fieldset>
<?php
define('TRANSACTION_PATH',BASE_URL.'admin/single_transactions');
$tr_data = Braintree_TransparentRedirect::transactionData(
array('redirectUrl' => TRANSACTION_PATH,
/* array('redirectUrl' => BASE_PATH.'admin/single_transactions'. parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH),*/
'transaction' => array('amount' => '10.00', 'type' => 'sale'))) ?>
<input type="hidden" name="tr_data" value="<?php echo $tr_data ?>" />
<br />
<input type="submit" value="Submit" />
</form>
<?php } ?>
</body>
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
Transparent Redirect does not support recurring billing, as you cannot create subscriptions with it. Please follow our Recurring Billing guide for more information on how to use it.
My page of categories not have option of limiting the post numbers, also not permit that this page to be paginated. I tried put the respective code that generate the pagination in other place as Query posts, in page.php, but no work:
<?php get_template_part( 'includes/pagination'); ?>
I tried insert this code here:
query_category)); ?>
isset( $category ) && isset( $category->term_id )? $category->term_id : 0, 'orderby' => 'id' ) ); ?>
<?php foreach($cats as $cat): ?>
<?php query_posts( apply_filters( 'themify_query_posts_page_args', 'cat='.$cat->cat_ID.'&posts_per_page='.$themify->posts_per_page.'&paged='.$themify->paged.'&order='.$themify->order.'&orderby='.$themify->orderby ) ); ?>
<?php if(have_posts()): ?>
<!-- category-section -->
<div class="category-section clearfix <?php echo $cat->slug; ?>-category">
<h3 class="category-section-title"><?php echo $cat->cat_name; ?></h3>
<!-- loops-wrapper -->
<div id="loops-wrapper" class="loops-wrapper <?php echo $themify->layout . ' ' . $themify->post_layout; ?>">
<?php while(have_posts()) : the_post(); ?>
<?php get_template_part('includes/loop', 'query'); ?>
<?php endwhile;?>
</div>
<!-- /loops-wrapper -->
I'm building a site with Zend 2.3 and what I want to do is to paginate the results using
Zend Paginator. I don't get any error, in fact I can see every link correctly, however they don't work properly.
When I want to paginate the news within a category, Paginator generates the following links:
........./index/categories/1
........./index/categories/2
........./index/categories/3
............................
Instead the links I want (i.e category 2) should be like:
............/index/categories/2/1
............/index/categories/2/2
............/index/categories/2/3
This is my module.config:
'index'=>array(
'type'=>'Segment',
'options'=>array(
'route' => '/index[/[:action][/:id][/:id2]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index'
),
),
),
I've already tried passing $cat_id from controller to URL helper ('id'=>$this->id) but it doesn't work. Only it seems to work when I hardcode the id value, for example:
First
This doesn't work:
First
So my question is, How can I do it work passing vars to Paginator?
Thanks
It's hard to create an example with such limited information but generally you'd follow this:
This would be in your controller
// This is some array of data that you've pulled from a data source
$arrayOfYourData = array();
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($arrayOfYourData));
$paginator->setItemCountPerPage(25);
$paginator->setCurrentPageNumber((int) $this->params()->fromQuery('page',1));
// now return $paginator to your view by assigning it to ViewModel, etc
Then in your view you would have something like this example
<?php echo $this->paginationControl($paginator, 'Sliding', 'your-namespace/pagination_control.phtml', array('route'=>'some/route', 'routeOptions'=>array('action'=>'some-action')); ?>
and then you should have a views/your-namespace/pagination_control.phtml as such:
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<?php echo $this->firstItemNumber; ?> - <?php echo $this->lastItemNumber; ?>
of <?php echo $this->totalItemCount; ?>
<!-- First page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->first)); ?>">
First
</a> |
<?php else: ?>
<span class="disabled">First</span> |
<?php endif; ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->previous)); ?>">
< Previous
</a> |
<?php else: ?>
<span class="disabled">< Previous</span> |
<?php endif; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->next)); ?>">
Next >
</a> |
<?php else: ?>
<span class="disabled">Next ></span> |
<?php endif; ?>
<!-- Last page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->last)); ?>">
Last
</a>
<?php else: ?>
<span class="disabled">Last</span>
<?php endif; ?>
</div>
<?php endif; ?>