1. We apologize for the slow support at the moment. Hugh (cheesegrits) is scheduled for some major back surgery this month to repair two ruptured discs which are severely hampering his ability to work, and one of our stalwart community support members is on vacation for the month. Please bear with us.

Colour Coding Fields

Discussion in 'Community' started by mamies, Sep 12, 2012.

  1. mamies Member

    Level: Community
    Hi All,

    I have just run into a feature I would like to add and I am sure that Fabrik is capable of doing this.

    I currently have a table that shows some information followed by expiry dates, I was hoping that I could have the expiry dates colour coded (preferably the cell background) which shows it as red if the date has passed or orange if the date is a month away.

    This will be able to let people know when dates are coming up and passed.

    I was also hoping to include an email alert (this might be in the too hard basket) which would also email an address when the particular date had passed containing what field had gone over the date and what expiry date had done.

    Let me know what you guys think.

    Thanks,
  2. mamies Member

    Level: Community
    Sorry I also put this in the Fabrik 3 section when it should be in the Fabrik 2 section.

    If an administrator is able to move it that would be great.

    Thanks
  3. troester Well-Known Member

    Level: Standard
  4. mamies Member

    Level: Community
    I am only having an issue with the date part now.

    I currenty have in the default_row.php part of my template

    Code (text):

    <?php
    if( ! function_exists('getSpanClass')){
    function getSpanClass($heading)
    {
    if ($heading > date('d-m-Y')) echo "class='cell_red'";
    elseif (($heading <= date('d-m-Y')) && ($heading >= date('d-m-Y', strtotime('-30 days')) )) echo "class='cell_yellow'";
    }
    }
    ?>
    <tr id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">
    <?php foreach ($this->headings as $heading=>$label) { ?>
    <td <?php echo $this->cellClass[$heading]?>>
    <span <?php
    if(isset($this->_row->data->$heading) and is_numeric($this->_row->data->$heading)):
    getSpanClass($this->_row->data->$heading);
    endif;
    ?>>
    <?php
    echo @$this->_row->data->$heading;
    ?>
    </span>
    </td>
    <?php }?>
    </tr>
    Does anyone have any idea where I have gone wrong.
  5. mamies Member

    Level: Community
    OK I had a little sleep and now I have changed a couple of things but it still doesn't seem to want to work.

    I changed the date formats to reflect the date in the database table and not the date that is displayed in the website table.

    Code (text):

    <?php
    if( ! function_exists('getSpanClass')){
    function getSpanClass($heading)
    {
    if ($heading <= date('Y-m-d H:i:s')) echo "class='cell_red'";
    elseif (($heading > date('Y-m-d H:i:s')) && ($heading <= date('Y-m-d H:i:s', strtotime('+30 days')) )) echo "class='cell_yellow'";
    }
    }
    ?>
    <tr id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">
    <?php foreach ($this->headings as $heading=>$label) { ?>
    <td <?php echo $this->cellClass[$heading]?>>
    <span <?php
    if(isset($this->_row->data->$heading) and is_numeric($this->_row->data->$heading)):
    getSpanClass($this->_row->data->$heading);
    endif;
    ?>>
    <?php
    echo @$this->_row->data->$heading;
    ?>
    </span>
    </td>
    <?php }?>
    </tr>
     
    I also have the appropriate classes in the template.css file
    Code (text):

    .cell_red {
    color: #FF0000;
    font-weight:bold;
    }
    .cell_yellow {
    color: #D96D00;
    font-weight:bold;
    }
     
    Still not sure where I am going wrong. When I change the date values to a number I used 10 for the red one and had the number 7 in the cell it worked great. It seems to have only stopped when I changed the cells to dates.

    Thanks,
  6. mamies Member

    Level: Community
    Does anyone have any idea.

    I have also been asked for the date to be green if the date is further then a month away. This wasn't too bad. I just created a new class in the template.css file and linked it up under the fabric element where it asks for cell class and it works great.
  7. mamies Member

    Level: Community
    Still no ideas.

Share This Page