Category Archives: Notepad

osTicket 1.9.4 – Show Due Date Column

Andrew (another one) got in contact with me asking if I could help him to how to show an extra column in osTicket 1.9.4, he tired to follow my previous post without much luck (after rereading it, I’m surprised if that’s ever helped anyone!).

He wanted the ability to see and sort by a “Due Date” column. Well it turns out to be a really easy feature to add.

Here is a GitHub Gist of the modified tickets.inc.php

Instructions for use:

  1. Backup /[osticket-install]/include/staff/tickets.inc.php
  2. Download the following file and copy it to /[osticket-install]/include/staff/tickets.inc.php
  3. Test! (If it break badly, I’m sorry, please restore your backup file).

As a side note, it also got me to finally setup a github account!

Here is the step by step instructions:

  1. Update the sort options ~Line 170.Effectively what we are doing here is adding the ‘duedate’=>’duedate’ to the array. So replace $sortOptions with below:
    [gist id = “c66ef9d90bdcbf874685” file = “step-1.php” width = “90%”]
  2. Add the heading to the table ~Line 374
    Just add the following line in after the closing </th> tag for the line <a <?php echo $date_sort; ?>………
    [gist id = “c66ef9d90bdcbf874685” file = “step-2.php” width = “90%”]
  3. Add the data row to the table ~ Line 468
    After the <td align=”center” nowrap><?php echo Format::db_datetime($row[‘effective_date’]); ?></td> add:
    [gist id = “c66ef9d90bdcbf874685” file = “step-3.php” width = “90%”]
  4. Finally fix up the footer ~ Line 506
    Change <td colspan=”7″> to:
    [gist id = “c66ef9d90bdcbf874685” file = “step-4.php” width = “90%]
  5. Thats it!

Don’t break it!

 

Generate CSS sprites from cmd with css-sprite and node.js

Update: I’ve also found a different method, this time instead using a Python script called “Glue“.

I did this about 12 months, but recently had to setup a new development environment.
Here are some notes on setting up css-sprite.

  1. Install node.js
  2. Install css-sprite
    npm install css-sprite -g
  3. Have fun.

Usage:

  1. Create two folders src (add png files here) and images
  2. run the command from cmd:
    css-sprite images/ src/*.png -p scss -s sprite.scss 
  3. (Here I'm using scss, you can choose from LESS, SCSS or CSS, depending on the project).

cforms v14.6 – switching to custom CSS 403 error

Quick Notes:
TL;DR – When activating a custom CSS from the folder:
/plugins/cforms-custom/[your-css-file].css
You get a 403 error while running WordPress 4.

The issue seems to be in: cforms-css.php
~Line: 142:
Change: echo ‘<option style=”background:#fbd0d3″ selected=”selected” value=”../../cforms-custom/’.$f.'”>’.$f.'</option>’.”\n”;
To: (removing one of the ../)
echo ‘<option style=”background:#fbd0d3″ selected=”selected” value=”../cforms-custom/’.$f.'”>’.$f.'</option>’.”\n”;

Then again on ~Line: 144:
echo ‘<option value=”../../cforms-custom/’.$f.'”>’.$f.'</option>’;
To: (removing one of the ../)
echo ‘<option value=”../cforms-custom/’.$f.'”>’.$f.'</option>’;

This then causes an issue on the frontend. To fix this:

edit: cforms.php

Replace the following (~Line 1209):

if( $cformsSettings[‘global’][‘cforms_no_css’]<>’1′ )
echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . $cforms_root . ‘/styling/’ . $cformsSettings[‘global’][‘cforms_css’] . ‘” />’.”\n”;

With:

if( $cformsSettings[‘global’][‘cforms_no_css’]<>’1′ ){
if (strpos($cformsSettings[‘global’][‘cforms_css’],’cforms-custom’) !== false) {
$cformsCSSpath = “/”;
}else{
$cformsCSSpath = ‘/styling/’;
}
echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . $cforms_root . $cformsCSSpath . $cformsSettings[‘global’][‘cforms_css’] . ‘” />’.”\n”;
}

 

 

I hope that helps someone.

 

This doesn’t appear to work on both the front and the back end…

osTicket 1.9.2 – Easy Custom Column in Ticket View

Dec 14 Update:While these rough instructions can be roughly used in osTicket 1.9.4, it doesn’t return the value from a list, just an ID (Which on a technical level is better in the long run, just makes this process a little harder).
I’m working on fixing this and will post the info once I’ve had a chance to work it out.
New instructions for 1.9.4 can be found here: https://www.andrewbennett.com.au/2014/12/osticket-1-9-4-easy-custom-column-in-ticket-view/

TL;DR (I rushed these notes for myself).

File to edit: /include/staff/tickets.inc.php

1) Added To the top to make things easier. (line 2-3)
The Name field (currently “field_17” ) needs to be worked out from the database by looking at the [tbl_prefix]_ticket__cdata
The Desc field (Currently “Sample 1”) is what your users will see as the column heading.

$CustomList1Name = “field_17”;
$CustomList1Desc = “Sample 1”;

2) Add custom1 to allow sorting. (~Line 157)

$sortOptions=array(‘date’=>’effective_date’,’ID’=>’ticket.`number`’,
‘pri’=>’pri.priority_urgency’,’name’=>’user.name’,’subj’=>’cdata.subject’,
‘status’=>’ticket.status’,’assignee’=>’assigned’,’staff’=>’staff’,
‘dept’=>’dept.dept_name’,
‘custom1’=>’Custom1’); //AB Added

3) Edit the last two lines, frst remove the ; after “pri.priority_color'” then add the last line  (~Line 243)
After line:

$qselect.=’ ,IF(ticket.duedate IS NULL,IF(sla.id IS NULL, NULL, DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)), ticket.duedate) as duedate ‘
.’ ,CAST(GREATEST(IFNULL(ticket.lastmessage, 0), IFNULL(ticket.closed, 0), IFNULL(ticket.reopened, 0), ticket.created) as datetime) as effective_date ‘
.’ ,CONCAT_WS(” “, staff.firstname, staff.lastname) as staff, team.name as team ‘
.’ ,IF(staff.staff_id IS NULL,team.name,CONCAT_WS(” “, staff.lastname, staff.firstname)) as assigned ‘
.’ ,IF(ptopic.topic_pid IS NULL, topic.topic, CONCAT_WS(” / “, ptopic.topic, topic.topic)) as helptopic ‘
.’ ,cdata.priority_id, cdata.subject, pri.priority_desc, pri.priority_color’
.’ ,cdata.’.$CustomList1Name.’ as Custom1 ‘ //AB – Custom 1
;

4) Add Column Heading (~ Line 337)

<!– AB – Custom Col 1 –>
<th width=”60″>
<a <?php echo $custom1_sort; ?> href=”tickets.php?sort=custom1&order=<?php echo $negorder; ?><?php echo $qstr; ?>”
title=”Sort By <?php echo $CustomList1Desc; ?> <?php echo $negorder; ?>”><?php echo $CustomList1Desc; ?></a></th>
<!– AB – Custom Col 1 –>

5) Add Column Data (~ Line 435)

<!– AB – Custom Col 1 –>
<td nowrap>&nbsp;<?php echo $row[‘Custom1’]; ?>&nbsp;</td>
<!– AB – Custom Col 1 –>

When I get around to it I will upload the file to github or bitbucket.

Spago BI Installation

TL;DR

Installing Spago BI.

  1. First install JDK and set 3 system paths:
    • JAVA_HOME: C:\Program Files\Java\jdk<version>
    • JRE_HOME: C:\Program Files\Java\jre<version>
    • Add to PATH: ;C:\Program Files (x86)\Java\jdk<version>\bin
  2. Now run the SpagoBI installer.
  3. Run SpagoBI from Start Menu
  4. Open up a browser and enjoy.

Here are some rough notes from installing Spago BI in a somewhat blind way. (I should have probably read the docs first.)

Installation Platform:

  • Windows Server 2003 R2 x64
  • 2gb ram
  • 2 vcpus
  • XenServer 6 as host.
  1. Download the SpagoBI 4.2 installer and unzip and run.
  2. Run installer, I ticked all the options (not sure that this was the best idea).
  3. Each package selected in Step 2 has to be individually downloaded, so it takes a while.
  4. Java needs to be installed. I grabbed the JDK from Ninite.
    But the System Path Variables also need to be put in place before Spago will run. (I used the Program Files (x86) folder in the paths below).

    • JAVA_HOME: C:\Program Files\Java\jdk<version>
    • JRE_HOME: C:\Program Files\Java\jre<version>
  5. After startup, open your browser at:
    http://localhost:8080/SpagoBISpagoBI login page will appair. Log yourself as:
    – biadmin/biadmin (technical user)
    – biuser/biuser (business or functional user)
    – bidemo/bidemo (showcase user)
  6. Nothing loaded for me. Trying a reboot.
  7. Reading the console output, I possibly shouldn’t have left everything ticked in step 2, now that it has to try and load them all.
    Finally it loaded and reported the following in the console:
    INFO: Server startup in 630557 ms (that’s 10.5 minutes!)
  8. Can’t connect to sample database, I found a “start.bat” file which complained about not having access to “JAVA”. Looks like I need to add JAVA bin folder to the System Path. Restarting Spago / Tomcat
  9. This time round, a second command prompt window has also opened loading the foodmart database.
  10. Demo now appears to be working.

asp.net Clean up CSS output

How to get rid of all the ugly auto markup generated in ASP.net:

http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series.aspx

New ClientIDMode Property on Controls

ASP.NET 4 supports a new ClientIDMode property on the Control base class.  The ClientIDMode property indicates how controls should generate client ID values when they render.  The ClientIDMode property supports four possible values:

  • AutoID—Renders the output as in .NET 3.5 (auto-generated IDs which will still render prefixes like ctrl00 for compatibility)
  • Predictable (Default)— Trims any “ctl00” ID string and if a list/container control concatenates child ids (example: id=”ParentControl_ChildControl”)
  • Static—Hands over full ID naming control to the developer – whatever they set as the ID of the control is what is rendered (example: id=”JustMyId”)
  • Inherit—Tells the control to defer to the naming behavior mode of the parent container control

 

asp.net Masterpages and Metatags

There are a couple of ways to edit meta tags in MasterPages in asp.net (vb).

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.Title = String.Format(“Master Page Tutorials :: About :: {0:d}”, DateTime.Now)

‘ Programmatically add a <meta> element to the Header
Dim keywords As New HtmlMeta()
keywords.Name = “keywords”
keywords.Content = “master page,asp.net,tutorial”

Page.Header.Controls.Add(keywords)

‘ Programmatically add a <meta> element to the Header
Dim description As New HtmlMeta()
description.Name = “description”
description.Content = “This is a Sample Description”

Page.Header.Controls.Add(description)

End Sub

New way: (thanks to: http://weblogs.asp.net/scottgu/archive/2010/01/05/asp-net-4-seo-improvements-vs-2010-and-net-4-0-series.aspx)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.Title = String.Format(“Master Page Tutorials :: About :: {0:d}”, DateTime.Now)

Page.MetaDescription = “Hello World”
Page.MetaKeywords = “Some, keywords, that, go here”

End Sub

I prefer the output of the first type, even tho it has more code involved.