code igniter . i have issue to show upcoming birthday of month(like July) custom - codeigniter

I am beginner in development i have issue to show upcoming birthday of month(like July) guide me to please fix this problem here is code. here is code to show upcoming birthday.
<h3 class="panel-title"><?php echo 'Upcomming Birthday' ?> - <?php echo date("F"); ?></h3>
<ul class="leave_apps">
<?php
$m = date("m"); // Month value
$y = date("Y"); // Year value
$num = cal_days_in_month(CAL_gregorian , $m, $y);
?>
<?php
for ($i = 0; $i < count($employee); $i++) :
$mem_bod_explode = explode("-", $employee[$i]->date_of_birth);
$m_bday = mktime(0, 0, 0, $mem_bod_explode[1], $mem_bod_explode[2], $y);
$start_date = date('Y-m', $m_bday) . '-01';
$end_date = date('Y-m', $m_bday) . '-' . $num;
if (date('Y-m-d') == date('Y-m-d', $m_bday)) {
$present_bday[] = $employee[$i];
$date = date('Y-m-d', $m_bday);
$pdate[] = date('d M Y', strtotime($date));
} else if (date('Y-m-d', $m_bday) > $start_date && date('Y-m-d', $m_bday) <= $end_date) {
$future_bday[] = $employee[$i];
$date = date('Y-m-d', $m_bday);
$fdate[] = date('d M Y', strtotime($date));
}
?>
<?php endfor; ?>
<?php if (!empty($present_bday)):foreach ($present_bday as $key => $v_bday): ?>
<li>
<a href="<?php echo base_url() ?>admin/employee/view_employee/<?php echo $v_bday->employee_id ?>">
<h5>
<div class="pull-left">
<img class="img-circle" src="<?php echo base_url() . $v_bday->photo ?>">
</div>
<span><?php echo $v_bday->first_name . ' ' . $v_bday->last_name ?></span>
<small class="apps_category" style="color:red">(Today)</small>
<p class="leave_para"><?php echo $pdate[$key]; ?></p>
</li>
<?php endforeach; ?>
<?php endif; ?>

Related

CStarRating shows radio group instead of stars when update?

I have edited Comment module from a tutorial to review module.
In this module i using CStarRating widget. When view, submit, delete rate post it OK. but when i click edit/update, edit old post and click update to edit rate post then star don't show, instead this radio group ???
Here is code:
CommentList.php
<?php
/** #var CArrayDataProvider $comments */
$comments = $model->getCommentDataProvider();
$comments->setPagination(false);
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$comments,
'itemView'=>'comment.views.comment._view'
));
$this->renderPartial('comment.views.comment._form', array(
'comment'=>$model->commentInstance
));
_view.php
<?php
?>
<nav id = "atext" >
<div>
<span class="ext-comment-head">
wrote on
<span class="ext-comment-date">
<?php echo Yii::app()->format->formatDateTime(
is_numeric($data->createDate) ? $data->createDate : strtotime($data->createDate)
);
?>
</span>
</span>
<span class="ext-comment-options">
<?php if (!Yii::app()->user->isGuest && (Yii::app()->user->id == $data->userId)) {
echo CHtml::ajaxLink('delete', array('/comment/comment/delete', 'id'=>$data->id), array(
'success'=>'function(){ $("#ext-comment-'.$data->id.'").remove(); }',
'type'=>'POST',
), array(
'id'=>'delete-comment-'.$data->id,
'confirm'=>'Are you sure you want to delete this item?',
));
echo " | ";
echo CHtml::ajaxLink('edit', array('/comment/comment/update', 'id'=>$data->id), array(
'replace'=>'#ext-comment-'.$data->id,
'type'=>'GET',
), array(
'id'=>'ext-comment-edit-'.$data->id,
));
} ?>
</span>
<p id = "apa">
<br>
</p>
<table id = "atable">
<td id = "test123">
<?php
$model=new Comment;
$a=$data->id;
$colArr=$model->attributes;
for ($i = 0; $i < count($colArr); $i++) {
$key=key($colArr);
$val=$colArr[$key];
next($colArr);
if (($key<> 'average') and($key<>'id') and ($key<>'message')
and ($key<>'userId') and ($key<>'createDate') ) {
$a=$a+100;
echo $data->getAttributeLabel($key).' ('.$data->$key.')';
$this->widget('CStarRating',array(
'name'=>'Comment['.$a.']',
'value'=>$data->$key,
'minRating'=>1, //minimal value
'maxRating'=>5,//max value
'starCount'=>5, //number of stars
'readOnly'=>true,
));
}
echo "<br>";
}
?>
</td>
<td id = "average-teacher">
<p>
<?php echo nl2br(CHtml::encode($data->message)); ?>
</p>
</td>
</table>
<br style="clear: both;"/>
</div>
</nav>
</div>
_form.php
<br>
<br>
<?php if (Yii::app()->user->isGuest) {
?><div class="ext-comment-not-loggedin">
Sorry, you have to login to leave a comment.
</div><?php } else { ?>
<div id="ext-comment-form-<?php echo $comment->isNewRecord ? 'new' : 'edit-'.$comment->id; ?>" class="form" >
<nav id = "comment-a">
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'ext-comment-form',
'action'=>array('/comment/comment/create'),
'enableAjaxValidation'=>false
)); ?>
<?php /** #var CActiveForm $form */
echo $form->errorSummary($comment); ?>
<div class="row">
<?php echo $form->labelEx($comment,'message'); ?>
<?php echo $form->textArea($comment,'message',array('rows'=>3, 'cols'=>76)); ?>
<?php echo $form->error($comment,'message'); ?>
</div>
<?php
$model=new Comment;
$colArr=$model->attributes;
for ($i = 0; $i < count($colArr); $i++) {
$key=key($colArr);
if (($key<> 'average') and ($key<>'id') and ($key<>'message') and ($key<>'userId')
and ($key<>'createDate') ){
$this->widget('CStarRating',array(
'name'=>'Comment['.$key.']',
'value'=>$model->$key,
'minRating'=>1, //minimal value
'maxRating'=>5,//max value
'starCount'=>5, //number of stars
));
echo " ".$model->getAttributeLabel($key)."<br>";
echo "<br>";}
next($colArr);
}
?>
<div class="row buttons">
<?php if ($comment->isNewRecord) {
echo "<br>";
echo $form->hiddenField($comment, 'type');
echo $form->hiddenField($comment, 'key');
echo CHtml::ajaxSubmitButton('Submit',
array('/comment/comment/create'),
array(
'replace'=>'#ext-comment-form-new',
'error'=>"function(){
$('#Comment_message').css('border-color', 'red');
$('#Comment_message').css('background-color', '#fcc');
}"
),
array('id'=>'ext-comment-submit' . (isset($ajaxId) ? $ajaxId : ''))
);
} else {
echo CHtml::ajaxSubmitButton('Update',
array('/comment/comment/update', 'id'=>$comment->id),
array(
'replace'=>'#ext-comment-form-edit-'.$comment->id,
'error'=>"function(){
$('#Comment_message').css('border-color', 'red');
$('#Comment_message').css('background-color', '#fcc');
}"
),
array('id'=>'ext-comment-submit' . (isset($ajaxId) ? $ajaxId : ''))
);
}
echo "<br>";
?>
</div>
<?php $this->endWidget() ?>
</nav>
</div><!-- form -->
<?php } ?>
Hope someone can help me :( And sorry about my english :(

Show all subcategories of current parent caregory in sidebar navigation in MAGENTO

Trying to build sidebar category structure in Magento so that all children for an active category show when clicked. Using below as sample, when you go into main catalog only Main Cats appear. Then when clicking any Sub Cat the children for that respective category appear and so on.
For example
Main Cat 1
Sub Cat 1
Sub/Sub 1
Sub/Sub 1
Sub/Sub 1
Sub Cat 1
Sub Cat 1
Main Cat 2
Main Cat 3
Here's the current code I have, but once you get to the last category, only the Main Cats show (in other words, if you click on Sub/Sub, the menu closes and shows only the Main Cats).
<aside id="sidebar">
<div class="sidebar-nav">
<h2><?php echo $this->__('Products') ?></h2>
<ul>
<?php foreach ($store_cats as $cat) {
if ($cat->getName() == $current_cat) {
echo '<li>'.$cat->getName()."<ul>";
foreach ($obj->getCurrentChildCategories() as $subcat) {
echo '<li>'.$subcat->getName()."</li>";
}
echo "</ul></li>";
} else {
echo '<li>'.$cat->getName()."</li>";
}
} ?>
</ul>
</div>
<div class="sidebar-nav">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('holiday-nav-links')->toHtml() ?>
</div>
<div class="sidebar-nav">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('about-us-nav-links')->toHtml() ?>
</div>
</aside>
Any help is much appreciated. Thank you in advance for the help!
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Please check this link http://fishpig.co.uk/magento/tutorials/display-categories-and-subcategories-in-magento/
hope this help you
Had to do this very thing a few days back . get my whole function, may include some unnecessary html parts though. Shows 2nd level categories level onwards (for 3rd level category view as well)
public function getCatTree()
{
$treeHtml = '';
$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
$category = Mage::registry('current_category');
$level = $category->getLevel();
switch($level)
{
case 4 :
$level3Cat = $category->getParentCategory();
$level2Cat = $level3Cat->getParentCategory();
break;
case 3 :
$level2Cat = $category->getParentCategory();
break;
case 2 :
$level2Cat = $category;
break;
default :
$level2Cat = null;
break;
}
//get the level 2 category ID
$categoryId = $level2Cat->getId();
if (count($_categories) > 0)
{
foreach ($_categories as $_category)
{
//match with the level 2 category, then list all its children
if ($_category->getId() == $categoryId)
{
$_category = Mage::getModel('catalog/category')->load($_category->getId());
$_catChildrens = $_category->getAllChildren();
foreach(explode(',',$_catChildrens) as $index=>$child)
{
$cat = Mage::getModel('catalog/category')->load($child);
if($cat->getLevel() == 3 && $cat->getIsActive())
{
$isParent = ($cat->hasChildren()) ? 'parent' : '';
$treeHtml .= '<li class="level1 nav'.$cat->getLevel().' '.$isParent.'">'.
'<a href="'.$cat->getUrl().'">'.
$cat->getName().
'</a>';
if($cat->hasChildren())
{
$treeHtml .= '<div class="sub-menu-wrap"><ul class="level1">';
foreach($cat->getChildrenCategories() as $indx=>$_subcategory)
{
if($_subcategory->getIsActive())
{
$cat4 = Mage::getModel('catalog/category')->load($indx);
$treeHtml .= '<li class="level2 nav'.$cat4->getLevel().'">'.
'<a href="'.$cat4->getUrl().'">'.
$cat4->getName().
'</a></li>';
}
}
$treeHtml .= '</ul></div>';
}
$treeHtml .= '</li>';
}
}
return $treeHtml;
}
}
}
}

How to make Installments on product page get Final or SpecialPrice instead of GrantTotal?

Maybe someone can help me on this one. I want to insert a dropdown installments on product page, and must show the price numbers with 2 decimals, for example: R$ 300,00 instead of R$ 300,0000. Thank you!
This is the code that i have and tried to modify it but with no success:
<?php
$standad = Mage::getSingleton('moip/standard');
$api = Mage::getSingleton('moip/api');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('o2ti_moip/css/formulario.css'); ?> "media="all">
<?php
$_product = $this->getProduct( );
$_coreHelper = $this->helper('core');
?>
<?php if ($standad->getConfigData('parcelamento')): ?>
<label id="dadoscartaoopc">Parcelamento no Cartão de Crédito:</label>
<select name="payment[credito_parcelamento]" id="credito_parcelamentoproduto" >
<?php
$parcelamento = $api->getParcelamento($_product->getFinalPrice());
foreach ($parcelamento as $k => $v): ?>
<option value="<?php echo $k ?>"><?php echo $k . "x R$ " . $v['valor'] . " | Total: R$ " .$v['total']."" ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<div id="addparcelas">
<?php
$standard = Mage::getSingleton('moip/standard');
$parcelamento = $standard->getInfoParcelamento();
if ($parcelamento['juros1'] == 0)
{
echo "<div id=\"addparcelasdesc\"> Sem juros até ".$parcelamento['ate1']." parcelas,</div>";
if ($parcelamento['ate1'] < 13)
{
echo "após juros de 1,99% ao mês.";
}
}
if ($parcelamento['juros1'] >= "1.99")
{
echo "Com juros de ".$parcelamento['juros1']." ao mês.";
}
?>
</div>
Printscreen of the actual dropdown: http://postimg.org/image/pokqf6xxj/03a4fda4/
Solution:
<?php
$standad = Mage::getSingleton('moip/standard');
$api = Mage::getSingleton('moip/api');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('o2ti_moip/css/formulario.css'); ?> "media="all">
<?php
$_product = $this->getProduct( );
$_coreHelper = $this->helper('core');
?>
<?php if ($standad->getConfigData('parcelamento')): ?>
<label id="parcelamentoproduto">PARCELAMENTO NO CARTÃO DE CRÉDITO:</label>
<select name="payment[credito_parcelamento]" id="credito_parcelamentoproduto" >
<?php
$parcelamento = $api->getParcelamento($_product->getFinalPrice());
foreach ($parcelamento as $k => $v): ?>
<option value="<?php echo $k ?>"><?php echo $k . "x R$ " . number_format($v['valor'],2,',',' ') . " ---------- Total: R$ " .number_format($v['total'],2,',',' ')."" ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<div id="addparcelas">
<?php
$standard = Mage::getSingleton('moip/standard');
$parcelamento = $standard->getInfoParcelamento();
if ($parcelamento['juros1'] == 0)
{
echo "<div id=\"addparcelasdesc\"> Sem juros até ".$parcelamento['ate1']." parcelas,</div>";
if ($parcelamento['ate1'] < 13)
{
echo "após juros de 1,99% ao mês.";
}
}
if ($parcelamento['juros1'] >= "1.99")
{
echo "Com juros de ".$parcelamento['juros1']." ao mês.";
}
?>
</div>

Codeigniter nested foreach in slideshow?

I ask this https://stackoverflow.com/a/14277726/1670630 on other post but my problem still exist.
In codeigniter 2.1 I'm trying to display channels by category. So if i have a category called Film, i should see a list of Channels within Film. I tried a nested foreach loop to accomplish this but can't seem to get it to work in the slidshow and limit by number of row.
My model:
<?php
class Pages_model extends CI_Model {
function get_channels_by_categ_tv()
{
$this->db->select('categories.category_name, channels.channel_name');
$this->db->from('type_categ');
$this->db->join('categories', 'categories.category_id = type_categ.category_id');
$this->db->join('channels', 'channels.channel_id = type_categ.channel_id');
$this->db->order_by('categories.category_id');
//$this->db->group_by(array('categories.category_id'));
$query = $this->db->get();
if($query->num_rows() == 0)
{
#no channels
return false;
}
return $query->result_array();
}
}
I have this in the view:
<ul class="slides">
<li>
<?php $cat_shown = ''; ?>
<div class="programe-tv_link">
<?php $cat_show = ''; $cnl_show = '';?>
<?php foreach ($category_chaneels as $category): ?>
<?php
if ($cat_show != $category['category_name']) {
$cat_show = $category['category_name'];
echo '<p>' . $cat_show . '</p>';
}
$cnl_show = $category['channel_name'];
echo '<dd> >>' . $cnl_show . '</dd> ';
?>
<?php endforeach; ?>
</div>
</li>
<li>
<div class="programe-tv_link">
<p>Arte</p>
<dd> >> Acasa</dd>
<dd> >> Antena 1</dd>
<dd> >> Pro TV</dd>
</div>
<div class="programe-tv_link">
<p>Music Box</p>
<dd> >> Acasa</dd>
<dd> >> Antena 1</dd>
<dd> >> Pro TV</dd>
<dd> >> TLC</dd>
</div>
</li>
</ul>
I atache image with ilustration,
sorry for my english and if you don't understund me please write here. THX in advance.
My finale code is this.
<div id="programe-tv-slide" class="flexslider">
<strong>Programe TV</strong>
<div class="redLine"></div>
<?php $cat_cnl = array();
$list = array();
$i=1;
foreach ($category_chaneels as $option) {
$catname = $option['category_name'];
$chlname = $option['channel_name'];
$cat_cnl[$catname][$i] = $chlname;
$list[$i] = $catname;
$i++;
};
?>
<?php
$rows = array_chunk($cat_cnl, 4, TRUE);
foreach ($rows as $row) { //var_dump($rows);
?>
<ul class="slides">
<?php
echo ('<li>');
foreach ($row as $category => $channels) {
echo '<div class="programe-tv_link">';
echo '<p>' . $category . '</p>';
foreach ($channels as $channel) {
echo '<dd>' . $channel . '</dd> ';
};
echo '</div>';
};
echo ('</li>');
?>
</ul>
<?php }; ?>
</div>

I need to get a list of sibling categories in magento 1.7

So far I think i am working at something like this
<?php
$parentId = $_category->getParentId();
$cats = Mage::getModel('catalog/category')->load($parentId)->getChildred();
$catIds = explode(',',$cats);
?>
<ul>
<?php foreach($catIds as $catId): ?>
<li>
<?php
$category=Mage::getModel('catalog/category')->load($catId)
echo $category->getName();
?>
</li>
<?php endforeach; ?>
</ul>
I am trying to have lateral movement in subcategories without having to go up a layer.
Let me know if that made sense.
The below code will helps you to load 2nd level (sub)category. you can set the $_rootCatId as dynamic also by Mage::app()->getStore()->getRootCategoryId();.
$_rootCatId = 2;//Root Category
$_rootCategory = Mage::getModel('catalog/category')->load($_rootCatId);
$_catName = $_rootCategory->getName();
if($_rootCategory->hasChildren())
{
$_collection = Mage::getResourceModel('catalog/category_collection')
->addAttributeToFilter('is_active', 1)
->addAttributeToSort('position', 'asc')
->joinUrlRewrite()
->addIdFilter($_rootCategory->getChildren())
->load();
foreach($_collection AS $_sub)
{
$_subCat = Mage::getModel('catalog/category')->load($_sub->getId());
if($_subCat->hasChildren())
{
echo '<li class="leve10 nav-'. $_subCat->getId() .'">';
echo '<a id="subCatLink">';
echo '<span>'. $this->htmlEscape($_subCat->getName()) .'</span>
</a>
</li>';
echo '<ul id="subCatUl" class="no-display" style="padding:0px 13px;">';
$__collection = Mage::getResourceModel('catalog/category_collection')
->addAttributeToFilter('is_active', 1)
->addAttributeToSort('position', 'asc')
->joinUrlRewrite()
->addIdFilter($_subCat->getChildren())
->load();
foreach($__collection AS $__sub)
{
$__subCat = Mage::getModel('catalog/category')->load($__sub->getId());
echo '<li class="leve20 nav-'. $__subCat->getId() .'">
<a href="'. $this->getCategoryUrl($__subCat) .'">
<span>'. $this->htmlEscape($__subCat->getName()) .'</span>
</a>
</li>';
}
echo '</ul>';
}
else
{
echo '<li class="leve10 nav-'. $_subCat->getId() .'">
<a href="'. $this->getCategoryUrl($_subCat) .'">
<span>'. $this->htmlEscape($_subCat->getName()) .'</span>
</a>
</li>';
}
}
}
else
echo 'No Categories Found...';
Assuming that your $_category is a valid instance of Mage_Catalog_Model_Category:
<?php $_siblings = $_category->getParentCategory()->getChildrenCategories(); ?>
<ul>
<?php foreach($_siblings as $_sibling): ?>
<li>
<?php echo $_sibling->getName(); ?>
</li>
<?php endforeach; ?>
</ul>

Resources