Example #1
0
 /**
  * Profit colors
  *
  * @param $params
  * @param Cell $cell
  * @return mixed
  */
 public static function profit($params, Cell $cell)
 {
     $positive = 'text-primary';
     $negative = 'text-danger';
     $zero = 'text-muted';
     if (is_array($params)) {
         foreach ($params as $key => $value) {
             ${$key} = $value;
         }
     }
     $value = $cell->getOriginalValue();
     $cell->appendClass($value > 0 ? $positive : ($value < 0 ? $negative : $zero));
     return $cell->getCurrentValue();
 }
Example #2
0
 /**
  * Remaining grouping rows
  *
  * @param Row $last
  * @return array
  */
 protected function remaining(Row $last = null)
 {
     $newRows = [];
     if (!is_null($last)) {
         foreach (array_merge(array_reverse($this->groups), [':total']) as $field) {
             //New row
             $newRow = new Row();
             foreach ($this->columns as $k => $c) {
                 //Create new cell
                 $exists = array_key_exists($k, $this->sums[$field]);
                 $value = $last->field($k)->getInterValue();
                 $newCell = new Cell($k, $exists ? $this->sums[$field][$k] : ($k == $field ? $value : ''));
                 //Apply numeric conversions
                 $newCell->setTotalizer(true);
                 $this->numericConversions($k, $newCell, $last->getData());
                 //Add cell to new row
                 $newRow->addCell($newCell);
             }
             //Add new row
             $newRows[] = $newRow;
         }
     }
     return $newRows;
 }