private static function getXAxisDates($date_range_dates, $format) { $previous_formated = array(); $x_axis_dates = array(); foreach ($date_range_dates as $date) { $formated = Common::formatDate($date, $format); if (!in_array($formated, $previous_formated)) { array_push($x_axis_dates, array('date' => $date, 'label' => $formated)); } $previous_formated[] = $formated; } return $x_axis_dates; }
public function afterFind() { $this->name = $this->first_name . " " . $this->last_name; if (!empty($this->birthdate)) { $this->birthdate_day = Common::formatDate($this->birthdate, 'd'); $this->birthdate_month = Common::formatDate($this->birthdate, 'm'); $this->birthdate_year = Common::formatDate($this->birthdate, 'Y'); } return parent::afterFind(); }
/** * Get stats * @param string $durationType e.g today,this_week,this_month,this_year, defaults to null (all time) * @param array $filters $key=>$value pair where the $key is the table field and $value is the table value: empty by default * @param mixed $sum if false then the count is return else returns the sum of the $sum field: defaults to FALSE * @param string $dateField The date field of the table to be queried for duration stats. defaults to "date_created" * @param string $from date_range from * @param string $to date_range to * @param type $conditions * @return integer count or sum */ public function getStats($durationType = '', $filters = array(), $sum = false, $dateField = 'date_created', $from = null, $to = null, $conditions = '') { $today = date('Y-m-d'); $this_month = date('m'); $this_year = date('Y'); $params = array(); foreach ($filters as $k => $v) { if ($this->hasAttribute($k)) { if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= '`' . $k . '`=:' . $k; $params[':' . $k] = $v; } } switch ($durationType) { case self::STATS_TODAY: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'DATE(`' . $dateField . '`)=:' . $dateField; $params[':' . $dateField] = $today; break; case self::STATS_THIS_WEEK: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'YEARWEEK(`' . $dateField . '`,1)=YEARWEEK(:' . $dateField . ',1)'; $params[':' . $dateField] = $today; break; case self::STATS_LAST_WEEK: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'YEARWEEK(`' . $dateField . '`,1)=YEARWEEK(:' . $dateField . ',1)'; $params[':' . $dateField] = Common::addDate($today, '-7', 'day'); break; case self::STATS_THIS_MONTH: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'YEAR(`' . $dateField . '`)=:' . $dateField . '_Y AND MONTH(`' . $dateField . '`)=:' . $dateField . '_M'; $params[':' . $dateField . '_Y'] = $this_year; $params[':' . $dateField . '_M'] = $this_month; break; case self::STATS_LAST_MONTH: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'YEAR(`' . $dateField . '`)=:' . $dateField . '_Y AND MONTH(`' . $dateField . '`)=:' . $dateField . '_M'; $date = Common::addDate($today, '-1', 'month'); $year = Common::formatDate($date, 'Y', false); $month = Common::formatDate($date, 'm', false); $params[':' . $dateField . '_Y'] = $year; $params[':' . $dateField . '_M'] = $month; break; case self::STATS_THIS_YEAR: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'YEAR(`' . $dateField . '`)=:' . $dateField . '_Y'; $params[':' . $dateField . '_Y'] = $this_year; break; case self::STATS_LAST_YEAR: if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= 'YEAR(`' . $dateField . '`)=:' . $dateField . '_Y'; $date = Common::addDate($today, '-1', 'year'); $params[':' . $dateField . '_Y'] = Common::formatDate($date, 'Y', false); break; case self::STATS_DATE_RANGE: if (empty($from) || empty($to)) { throw new CHttpException(500, '$from and $to params not given.'); } if (!empty($conditions)) { $conditions .= ' AND '; } $conditions .= '(DATE(`' . $dateField . '`)>=:from AND DATE(`' . $dateField . '`)<=:to)'; $params[':from'] = $from; $params[':to'] = $to; break; } if ($sum) { return $this->getSum($sum, $conditions, $params); } else { return $this->getTotals($conditions, $params); } }
<h4 class="panel-title"> <i class="fa fa-chevron-down"></i> <a data-toggle="collapse" data-parent="#accordion" href="#personal_info"><?php echo Lang::t('Personal Information'); ?> </a> <?php if ($can_update || Users::isMyAccount($model->id)) { ?> <span><a class="pull-right" href="<?php echo $this->createUrl('view', array('id' => $model->id, 'action' => Users::ACTION_UPDATE_PERSONAL)); ?> "><i class="fa fa-edit"></i> <?php echo Lang::t('Edit'); ?> </a></span> <?php } ?> </h4> </div> <div id="personal_info" class="panel-collapse collapse"> <div class="panel-body"> <div class="detail-view"> <?php $this->widget('application.components.widgets.DetailView', array('data' => $model, 'attributes' => array(array('name' => 'first_name'), array('name' => 'last_name'), array('name' => 'gender'), array('name' => 'birthdate', 'value' => Common::formatDate($model->birthdate, 'd M Y'), 'visible' => !empty($model->birthdate)), array('name' => 'idno'), array('name' => 'married')))); ?> </div> </div> </div> </div>
<h4 class="panel-title"> <i class="fa fa-chevron-down"></i> <a data-toggle="collapse" data-parent="#accordion" href="#personal_info"><?php echo Lang::t('Employment Details'); ?> </a> <?php if ($can_update || Users::isMyAccount($model->id)) { ?> <span><a class="pull-right" href="<?php echo $this->createUrl('view', array('id' => $model->id, 'action' => Users::ACTION_UPDATE_PERSONAL)); ?> "><i class="fa fa-edit"></i> <?php echo Lang::t('Edit'); ?> </a></span> <?php } ?> </h4> </div> <div id="personal_info" class="panel-collapse collapse"> <div class="panel-body"> <div class="detail-view"> <?php $this->widget('application.components.widgets.DetailView', array('data' => $model, 'attributes' => array(array('name' => 'staff_no'), array('name' => 'level'), array('name' => 'title'), array('name' => 'employment_date', 'value' => Common::formatDate($model->employment_date, 'd M Y'), 'visible' => !empty($model->employment_date)), array('name' => 'marriage_status'), array('name' => 'nssf_no'), array('name' => 'nhif_no'), array('name' => 'location'), array('name' => 'department'), array('name' => 'birthdate', 'value' => Common::formatDate($model->birthdate, 'd M Y'), 'visible' => !empty($model->birthdate)), array('name' => 'status', 'value' => CHtml::tag('span', array('class' => $model->status === Staff::STATUS_ACTIVE ? 'badge badge-success' : 'badge badge-danger'), $model->status), 'type' => 'raw')))); ?> </div> </div> </div> </div>
<span class="msg-title"> <span class="blue"><?php echo CHtml::encode($row['from']); ?> </span><br/> <?php echo MyYiiUtils::myShortenedString($row['message'], 20, " ...", 20); ?> </span> <span class="msg-time"> <i class="icon-time"></i> <time class="timeago" datetime="<?php echo $localtime; ?> "><?php echo Common::formatDate($localtime); ?> </time> </span> </span> </a> </li> <?php } ?> <li><a href="<?php echo Yii::app()->createUrl('msg/message/inbox'); ?> "><?php echo Lang::t('See all messages'); ?>
echo $this->showLink(Users::USER_RESOURCE_PREFIX . $user->user_level) ? CHtml::link($avator, Yii::app()->createUrl('users/user/view', array('id' => $user->id)), array('class' => '')) : $avator; ?> <?php echo CHtml::link($user->id !== Yii::app()->user->id ? CHtml::encode($user->name) : Lang::t('Me'), $this->createUrl('view', array('id' => $data->id)), array('class' => 'sender')); ?> <i class="icon-time bigger-110 orange middle"></i> <span class="time"><abbr title="<?php echo Common::formatDate($data->date_created); ?> "><time class="timeago" datetime="<?php echo $data->date_created; ?> "><?php echo Common::formatDate($data->date_created); ?> </time></abbr></span> </div> <div class="action-buttons pull-right"> <a href="#"> <i class="icon-reply green icon-only bigger-130"></i> </a> <a href="#"> <i class="icon-trash red icon-only bigger-130"></i> </a> </div> </div> <div class="message-body"> <?php