I'd like to know if there's a way to get contacts into a model so I can display a dropdown of contacts to choose from.
I can get it from "_contact_details" table, but I hope there's a better way than that.
You can fetch data using query from _contact_details table then need link for the same where you can use, open this with ifram will better way :
//slug
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
// on click redirect to the option view
<select onclick="document.location=this.value">
<option value="<?php echo JRoute::_(ContactHelperRoute::getContactRoute($item->slug, $item->catid)); ?>&tmpl=component'">
<?php echo $item->name; ?></option>
</select>
Related
I want multiselect dropdown list, country name followed by country flag.
and for now, I implemented multiselect dropdown using:
http://davidstutz.github.io/bootstrap-multiselect/
<h4>Employee should be from Country</h4>
<?php
$html6= "";
$qry = "SELECT * FROM jb_country";
$runQuery = mysql_query($qry);
$html6 .= "<select name='pref_emp_country[]' class='form-control' id='my-select' multiple='multiple'>";
while ($sub_cat = mysql_fetch_assoc($runQuery)) {
$html6 .= "<option value=" .$sub_cat['id']. ">" .$sub_cat['name']. "</option>";
} echo $html6 .= "</select>";
?>
this is my code using bootstrap-multiselect.
multiselect countries are working fine. but now i want to add flags of each country before country name.
I want to know how can i do this!!
Thanks for time saving help
I'm trying to make our packing slips and invoices more useful, especially when we have bundled products.
How can I show just the parent item and not the children in an invoice?
When I use $order->getAllItems() I get two lines in output:
parent-child sku
child sku
If I use $order->getAllVisibleItems() I only get the parent, which is what I want.
Parent sku
Now invoice->getAllItems with produces the two lines Parent-Child and Child
But invoice->getAllVisibleItems with produces no lines
So it will show qty and amt on the invoice twice. not good for customers or packers.
<?php
require_once '../mage1/app/Mage.php';
require_once('Zend/Pdf.php');
$app = Mage::app();
Mage::register('isSecureArea', true);
$orderId = '500000555' ;
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
foreach ($order->getAllVisibleItems() as $item){
echo 'ITEM: ' . $item->getSku() . '<br />';
}
//vs invoice
echo 'Invoice Section <br />' ;
if ($order->hasInvoices()) {
echo 'Order has invoices' . '<br />';
foreach ($order->getInvoiceCollection() as $_eachInvoice) {
foreach ($_eachInvoice->getAllVisibleItems as $invitem){
//foreach ($_eachInvoice->getAllItems() as $invitem){
//echo 'Object <br />';
var_dump(get_object_vars($invitem));
//print_r($invitem); echo '<br /><br /><br /><br />';
echo 'INVOICE ITEM: ' . $invitem->getSku() . '<br />';
}
}
} else { echo 'no invoices' ; };
?>
Just Use $invoice->getAllVisibleItems() and for order use $order->getAllVisibleItems()
Just a word of Advise try to use get_class_method, get_class, get_class_vars for getting familiar with a class.
I have a dropdown <select> field which gets its values from the db. I'm currently looking for a way to use set_select() but have been unsuccessful. Here's my existing view:
<select name="userbase">
<?php echo $userbase_list; ?>
</select>
The variable $userbase_list is a string containing all the <option value="">text</option> html to be inserted. Since this <select> is generated from the db, does that mean I can't use the CI set_select() anymore?
$array_of_options= array("key_one"=>"val_one", "key_two"=>"val_two");
foreach($array_of_options as $k => $v)
{
$selected = ($v === $db_result) ? 'selected=selected' : '';
echo '<option '.$selected.' value='.$k.'>' . $v . '</option>';
}
Magento Admin has a store select drop down list of all the stores.
I have added an addititional "SELECT ALL STORES" value to allow me to know when a user wishes to carry out a task on all stores.
I based this customisation on enterprise magento version 1.9 although I think the version is quite irrelevant since my question is quite generic to magento I think.
How do I stop my "SELECT ALL STORES" from being selected by default in the search ?
/index.php/admin/admin/urlrewrite/index
The store list select form is built here:
app\code\core\Adminhtml\Block\Widget\Grid\Column\Filter\Store.php
Once I found that, I could override it to the local code pool and make the modifications I needed.
public function getHtml()
{
$storeModel = Mage::getSingleton('adminhtml/system_store');
/* #var $storeModel Mage_Adminhtml_Model_System_Store */
$websiteCollection = $storeModel->getWebsiteCollection();
$groupCollection = $storeModel->getGroupCollection();
$storeCollection = $storeModel->getStoreCollection();
$allShow = $this->getColumn()->getStoreAll();
$html = '<select name="' . $this->_getHtmlName() . '" ' . $this->getColumn()->getValidateClass() . '>';
$value = $this->getColumn()->getValue();
//if ($allShow) {
$html .= '<option value=""' . (**$value == 0** ? ' selected="selected"' : '') . '>' . Mage::helper('adminhtml')->__('All Store Views') . '</option>';
//} else {
// $html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
//}
Im having a bit of trouble putting some code together ... What im trying to do is add some code to the code i have at the moment to check radiobuttons that are checked in the database.
The code i have at the moment takes all roles from the database, outputs them using a foreach statement, but also splits the results into 2 columns, this is what i have at the moment.
<?php
$i = 0;
$output = "";
foreach($roles as $row){
if($i > 0){
$i = 0;
}
if($i == 0) {
$output .= "<div class='box'>";
}
$output .= '<div class="row">';
$output .= ' <input name="_'.$row->key.'" type="radio" id="'.$row->key.'" class="radio" />';
$output .= ' <label for="'.$row->key.'" style="text-transform: lowercase;">'.$row->name.'</label>';
$output .= '</div>';
if($i ==0) {
$output .= "</div>";
}
$i++;
}
if($i != 1) {
$output .= "</div>";
}
echo $output;
?>
Ok, so what i want to do is check the radio button in the code that i posted, only when there is a match in the database, So to get the values that were checked by the user, i use the following.
Model
function get_roles_by_id($freelancerid)
{
$query = $this->db->query('SELECT * FROM '.$this->table_name.' WHERE user_id = "'.$freelancerid.'"');
return $query->result();
}
Then my controller looks like this
$data['positions'] = $this->freelancer_roles->get_roles_by_id($freelancer_id);
As that is bring back an array i cant use a foreach statement to check the radio button id's that are returned in the positions array.
Could someone help me to figure this out.
Cheers,
I think I understand your question and it seems a fairly simple thing you are trying to do. If
You should have your model only return an array of the names of the checkboxes saved by the user in the following format: array("checkbox1", "checkbox2", "checkbox3") then in your output
you can simply use the native php function in_array()
for example:
$output .= '<div class="row">';
$output .= ' <input name="_'.$row->key.'" type="radio" id="'.$row->key.'" class="radio"';
if(in_array($row->name, $data['positions']) { $output .= ' checked '; }
$output . = '/>';
$output .= ' <label for="'.$row->key.'" style="text-transform: lowercase;">'.$row->name.'</label>';
$output .= '</div>';
As a side note, you have the following code:
if($i > 0){
$i = 0;
}
if($i == 0) {
$output .= "<div class='box'>";
}
If you follow the logic in that code you will see that $i will always equal 0 for the second if statement, making both if statements redundant.