JJWDesign Development
Browse: Home / Blog Posts

Run your Power Meter Backwards!

By admin on March 23, 2010

Ever get tired of the Power Company raising rates each year. Well, you can thank Florida government/politicians for that. So, what the hell can you do. You need electricity, right? Luckily those same politicians in Tallahassee, FL have made it so that the power company have to support local small businesses. You’ve probably seen the offers to fix your AC duct work or enhance your insulation. Well, that’s just part of the deal – take it if you need it.

You should also take advantage of the Solar Rebates! If you afford it, do it. Get a solar hot water heater to start. Then get an array of solar panels on your roof. You might even be able to watch your meter go backwards – Net Metering! Here’s a short video made at one of the BlueChip Energy residential solar customer installations showing their power meter running backwards. This is not a joke, it’s real.

Power Meter Running Backwards Video

Posted in Solar Energy | Tagged Solar Energy Systems | Leave a response

BlueChip Energy (Solar) – New Front Page Design

By admin on March 23, 2010

Solar Energy Systems

BlueChip Energy™ gets a new design for it’s Solar Energy Business Web site. Does it say too much? Possibly. I’ve gotten mixed reviews for this index page. Some people claim that it is too flashy, but it wasn’t built with Flash. It was built using some of the latest JQuery techniques on the Web, including the JQuery UI. Take a look and let me know what you think. There’s a nice tabs section which describes the BlueChip Energy™ customers, the technology and why BlueChip Energy™ is an industry leader in the solar energy market.

http://www.bluechipenergy.org

Posted in Portfolio, Solar Energy | Tagged Solar Energy, Solar Energy Systems | Leave a response

SQL Conditions – A CakePHP Component Class

By admin on September 29, 2009

“aka: How to add advanced search functionality to your CakePHP Application”

Advanced search functionality is something that I’ve always built into my applications.  Even back in the days of writing CGI/PERL applications, I’ve always had some class or set of functions to help build SQL conditions (aka WHERE expressions) based on user input (GET/POST). When I started to work with CakePHP, I noticed that it lacked this functionality. There was no “cake way” of defining advanced search parameters. Luckily CakePHP makes up for it by being a great MVC! There is a way to input conditions into the paginate/find methods, but you have to define the conditions yourself. So, I decide to take some old PHP search code and rewrite it to build the conditions based on search criteria. Hence, this sql_conditions.php component class was born.

A CakePHP Component Class for Management of Search Conditions

This class is used to define complex conditions arrays for use in CakePHP model find/paginate methods. It provides an easy way to “map” conditions from input form fields (GET/POST) to database field(s). This is a common task involved in creating advanced search forms. This class also saves the defined criteria in Session for retrieval.

Advanced Search Example – CakePHP Blog:

Let’s take the CakePHP Blog Tutorial as an example. Make sure you complete the Blog Tutorial before proceeding.

1. First download, extract and copy this component (sql_conditions.php) to your app/controllers/components/ directory.

Download sql_conditions.1.0a.zip

2. Open your posts_controller.php and add the following $component (SqlConditions) and search criteria variables to your controller class:

var $components = array(
    'SqlConditions' => array(
        'conditions' => 'criteria_conditions',
        'admin_conditions' => 'admin_criteria_conditions',
           'active_actions' => array('index', 'admin_index'),
       ),
   );
// For use with SqlConditions component.
// Regular Site Search Conditions
var $criteria_conditions = array(
    array('name' => 'search_keywords', 'fields' => array('Post.title','Post.body')),
    array('name' => 'search_min_created', 'fields' => 'Post.created', 'type' => 'date', 'condition' => '>'),
);
// Admin Search Conditions
var $admin_criteria_conditions = array(
    array('name' => 'admin_keywords', 'fields' => array('Post.title','Post.body')),
    array('name' => 'admin_min_created', 'fields' => 'Post.created', 'type' => 'date', 'condition' => '>'),
);

What we’re doing with this code is defining how the component should be used with this controller. This is only a very simple example! There are two criteria arrays to define; one for non-admin actions and one for admin actions. You can call the criteria variables whatever you like, just make sure to set ‘conditions’ and ‘admin_conditions’ to the variable names when calling the component. Also, you can set ‘active_actions’ if you need to use this component in actions other than the default two: ‘index’ and ‘admin_index’. Typically, the ‘active_actions’ setting is not needed.

A quick note on criteria naming conventions. I like to prefix my non-admin type criteria names with ‘search_’ and prefix my admin type criteria names with ‘admin_’. This helps to differentiate the two types of criteria conditions as well as “help prevent” any conflicts with might occur with other named parameters.

The criteria arrays can be made up of many different criteria which are applied to build the conditional array. Each criteria contains several parameters. The criteria supports comparison against multiple fields, such as the ‘search_keywords’ criteria above which will be compared against ‘Post.title’ or ‘Post.body’. This example would allow you to search for keywords in the title “or” body of the posts. Input can be compared as a string, a number or even as a date.

Criteria Parameters: ‘name’, ‘fields’, ‘condition’, ‘type’
- name: variable name to be used in the advanced search Forms or URLs.
- field name(s): field(s) to be use for comparison (array or ,;| separated)
- type of comparison: (default: string)
numeric – compared as a number
date – compare as a date
string – compare as a string
string_equal – check for exact string (Ex: Category Name)
- condition: logical comparison operator
examples: <, <=, =, <=>, >= or > (default: =)
- boundary: Set to true for boundary word matching (default: false).

3. Next open your default layout: app/views/layouts/default.ctp and add the following two simple forms just after id=”content” DIV; or in your content section. You will probably want to move this to a custom CakePHP element later.

echo $form->create('Post', array('action' => 'index', 'class' => 'advanced_search'));
echo $form->input('search_keywords', array('default' => @$this->params['named']['search_keywords'],'div' => false));
echo $form->submit('Go!', array('div' => false,));
echo $form->end();

echo $form->create('Post', array('action' => 'index', 'class' => 'advanced_search'));
echo $form->input('clear_conditions', array('type' => 'hidden', 'value' => 1, 'div' => false,));
echo $form->submit('Reset', array('div' => false,));
echo $form->end();

The first form is used to perform the keyword search. The second form is to clear the search criteria from the session. Note, you can also search using a URL with named parameters. Please see the CakePHP documentation for more information on using named parameters.

4. Last, we call the build method and then add the returned SQL Conditions array to the index action’s paginate call.

function index() {
    // SQL Conditions Component (Criteria)
    $sql_conditions = $this->SqlConditions->build();
    $this->Post->recursive = 0;
    $this->set('posts', $this->paginate($sql_conditions));
}

This is where we actually build out the SQL conditions array to be used. All the work is done for you based on the criteria set and named parameters input. Note, you may wish to use debug($sql_conditions) to view the resulting array to gain a better understanding of this method.

5. That’s it. Test out your new advanced keyword search for your blog entries! Also, try to use the ‘search_min_created’ criteria to search by minimum date created.

Final thoughts: Use at your own risk. While some of this code logic has been around for years, this component has not been used in a production environment. Also, feel free to post any comments and/or bugs you may wish to come across.

Cheers,
Jeff Walters

Posted in CakePHP, PHP, Portfolio | Tagged CakePHP, PHP | 2 Responses

Tools and Reports Modules for SugarCRM CE

By admin on September 29, 2009

Over the past couple of years I have worked with SugarCRM. During that time I’ve tried to overcome the lack of Reports and Tools in the Community Edition (CE) by incorporating my own custom reports and tools for marketing professionals to be able to use thru SugarCRM custom modules. These reports and tool were eventually compiled into a SugarCRM package which is now available for download thru the Sugar Forge web site.

SugarCRM Tools and Reports by JJWDesign: A collection of field developed and tested tools and reports. They we’re developed with SugarCRM CE and used for the daily maintenance and management of SugarCRM CE by sales and marketing administrators.

Posted in PHP, Portfolio, SugarCRM | Tagged PHP, SugarCRM | 1 Response

New Application Types for MS Word

By admin on September 29, 2009

Have you ever wondered why the new Microsoft 2007 Word file type (.docx) can not be downloaded directly from your Apache server? Well, the answer is because it doesn’t recognize what kind of application type it is, therefore it can’t send the correct header information to your browser. Fortunately, the fix for this is rather simple with Apache. Just add these application types for MS Word to your server’s httpd configuration (httpd.conf or apache2.conf) and files will start downloading like magic.

# New Application Types for MS Word.
addtype application/onenote                                                         onetoc onetoc2 onetmp onepkg
addtype application/vnd.ms-excel.addin.macroEnabled.12                              xlam
addtype application/vnd.ms-excel.sheet.binary.macroEnabled.12                       xlsb
addtype application/vnd.ms-excel.sheet.macroEnabled.12                              xlsm
addtype application/vnd.ms-excel.template.macroEnabled.12                           xltm
addtype application/vnd.ms-powerpoint.addin.macroEnabled.12                         ppam
addtype application/vnd.ms-powerpoint.presentation.macroEnabled.12                  pptm
addtype application/vnd.ms-powerpoint.slide.macroEnabled.12                         sldm
addtype application/vnd.ms-powerpoint.slideshow.macroEnabled.12                     ppsm
addtype application/vnd.ms-powerpoint.template.macroEnabled.12                      potm
addtype application/vnd.ms-word.document.macroEnabled.12                            docm
addtype application/vnd.ms-word.template.macroEnabled.12                            dotm
addtype application/vnd.openxmlformats-officedocument.presentationml.presentation   pptx
addtype application/vnd.openxmlformats-officedocument.presentationml.slide          sldx
addtype application/vnd.openxmlformats-officedocument.presentationml.slideshow      ppsx
addtype application/vnd.openxmlformats-officedocument.presentationml.template       potx
addtype application/vnd.openxmlformats-officedocument.spreadsheetml.sheet           xlsx
addtype application/vnd.openxmlformats-officedocument.spreadsheetml.template        xltx
addtype application/vnd.openxmlformats-officedocument.wordprocessingml.document     docx
addtype application/vnd.openxmlformats-officedocument.wordprocessingml.template     dotx

Posted in Linux Ubuntu, Server Administration | Tagged Apache | Leave a response

« PreviousNext »

Categories

  • CakePHP
  • Friends and Family
  • Google
  • jQuery
  • Linux Ubuntu
  • MySQL Tips
  • PHP
  • Portfolio
  • SEO
  • Server Administration
  • Software
  • Solar Energy
  • SugarCRM
  • Technology
  • Uncategorized
  • Web Design
  • Windows
  • Word Press

Recent Comments

  • admin on jQuery: Kiosk Up Down Scroll Buttons
  • Lulik on jQuery: Kiosk Up Down Scroll Buttons
  • admin on SQL Conditions – A CakePHP Component Class
  • grggnn on SQL Conditions – A CakePHP Component Class
  • Vinay on Tools and Reports Modules for SugarCRM CE

Tag Cloud

Apache Backups CakePHP Free Google IP Address JS Downloader Logic Hooks Metal Fabrication MySQL Open Source PHP Popup Blocker Popups Robocopy SEO Shell Solar Energy Solar Energy Systems SugarCRM Virus WAMP WordPress Virus XCopy

Archives

  • April 2010
  • March 2010
  • September 2009
  • August 2009
  • July 2008
  • March 2008
  • November 2007
  • October 2007
  • August 2007
  • July 2007

Copyright © JJWDesign 2012 Web Design and Development Tips.