Tuesday, December 6, 2011

Database Module in Joomla 1.7




Create a folder mod_userdatas above
1. Helper.php

<?php

defined('_JEXEC') or die;

class modUserDataHelper
{
  function getData( &$params )
  {
  
   // Database query  
   $list = array();   
   $query = " SELECT id, name, username "    
   ." FROM #__users "
   ." WHERE block=0 "    
   ." ORDER BY id DESC "
   ." LIMIT " . $params->get( 'limit' );    
   $db =& JFactory::getDBO();
   $db->setQuery( $query );  
   $rows = $db->loadObjectList();
     
   // Get list items
   if ($rows!=null)
   {
    $i=0;
    foreach ($rows as $row) 
    {    
     $list["users"][$i]["id"]=$row->id;
     $list["users"][$i]["name"]=$row->name;
     $list["users"][$i]["username"]=$row->username;
     $i++;  
    }
    return $list;
   }
     
  }
}

2. mod_userdata.xml
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" version="1.7" client="site" method="upgrade">
 <name>User Data Module</name>
 <author>Minitek.gr</author>
 <creationDate>03/08/2011</creationDate>
 <copyright>Copyright (C) 2011. All rights reserved.</copyright>
 <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
 <authorEmail>your_email</authorEmail>
 <authorUrl>www.minitek.gr</authorUrl>
 <version>1.7.1</version>
 <description>Users Data Module</description>
 <languages>
 </languages>
 <files>
  <filename module="mod_userdata">mod_userdata.php</filename>
  <filename>mod_userdata.xml</filename>
  <filename>helper.php</filename>
  <filename>index.html</filename>
  <folder>tmpl</folder>
 </files>
 <config>
  <fields name="params">
   <fieldset name="basic">
    <field name="moduleclass_sfx" type="text" 
     default="" label="Module Class Suffix" 
     description="Suffix for individual css styling" />
    <field name="limit" type="text" default="10" 
       label="Limit Displayed Users" description="Limit Displayed Users" />
    <field name="user_id" type="radio" default="1" 
      label="Display user ID" description="Display user ID">
     <option value="0">JNO</option>
     <option value="1">JYES</option>
    </field>
    <field name="user_name" type="radio" default="1" 
      label="Display Name" description="Display Name">
     <option value="0">JNO</option>
     <option value="1">JYES</option>
    </field>
    <field name="user_username" type="radio" default="1" 
     label="Display Username" description="Display Username">
     <option value="0">JNO</option>
     <option value="1">JYES</option>
    </field>
   </fieldset>
  </fields>
 </config>
</extension>

3.mod_userdata.php
<?php

defined('_JEXEC') or die;

// Include the syndicate functions only once
require_once dirname(__FILE__).'/helper.php';

// Get the user data
$list = modUserDataHelper::getData($params);

// Get the layout
require JModuleHelper::getLayoutPath('mod_userdata', $params->get('layout', 'default'));
 
4. tmpl/default.php place the default.php in tmpl folder
 
<?php
s
defined('_JEXEC') or die; ?>

<div class="moduletable<?php echo $params->get( 'moduleclass_sfx' ) ?>">

 <ul>
  <?php for ($i=0;$i< sizeof($list["users"]); $i++) { ?> 
 
  <li>
   <?php if ($params->get( 'user_id' )) { ?>
   <span><?php echo $list["users"][$i]["id"];?></span>
  <?php } ?>
  <?php if ($params->get( 'user_name' )) { ?>
   <span><?php echo $list["users"][$i]["name"];?></span>
  <?php } ?>
  <?php if ($params->get( 'user_username' )) { ?>
   <span><?php echo $list["users"][$i]["username"];?></span>
  <?php } ?>
  </li>
 
 <?php } ?>
 </ul>

</div>
 
5. Place index.html under tmpl folder
 
<html><body bgcolor="#FFFFFF"></body></html>
 
Now zip the mod_userdata folder  and upload the module from 
adminstrator/extension and upload 
Activate and place the module 

Joomla 1.7 - Create a Hello World Simple Module

  1. Create a folder called mod_helloworld in modules
  2. Create a mod_helloworld.php file
  3. Create a mod_helloworld.xml file
  4. Create a helper.php file
  5. Create a template file tmpl/default.php
  6. Discover new modules by going to “Extension Manager” -> “Discover”

The code for mod_helloworld.php

<?php
defined('_JEXEC') or die; // no direct access allowed
 
require_once dirname(__FILE__).DS.'helper.php'; // get helper files
 
$hello = modHelloWorldHelper::getHello($params);
require JModuleHelper::getLayoutPath('mod_helloworld');
?>

The helper.php file

<?php
 class modHelloWorldHelper
 {
     /**
      * Retrieves the hello message
      *
      * @param array $params An object containing the module parameters
      * @access public
      */    
     function getHello( $params )
     {
         return 'Hello, World!';
     }
 }
?>

Include the template file for the default view

<?php
defined('_JEXEC') or die;
echo $hello; 
?>

The mod_helloworld.xml file

 <?xml version="1.0" encoding="utf-8"?>
 <extension type="module" version="1.7.0" client="site" method="upgrade">
     <name>Hello World!</name>
     <author>Harshal Shah </author>
     <version>1.7.0</version>
     <description>Reinholds simple Hello World module.</description>
     <files>
    <filename module="mod_helloworld">mod_helloworld.php</filename>
         <filename>mod_helloworld.xml</filename>
         <filename>index.html</filename>
         <filename>helper.php</filename>
         <filename>tmpl/default.php</filename>
         <filename>tmpl/index.html</filename>
     </files>
     <params>
     </params>
 </extension>

Create both index.html files to prevent direct directory browsing

<html><body></body></html>

Sunday, September 18, 2011

Connect two Amazon EC2 using ssh

1.Make sure you have the rightscript Managessh private key ssh installed.
2. Make sure both the instance install same ssh key.
3. It works like a cream

Wednesday, July 20, 2011

Amazon HAPROXY haproxy[12490]: proxy test has no server available!

This happens when haproxy is trying to find a status file on the server mentioned in rightscale_lb.cfg
If there is no file it does not recognize the server and errors out

haproxy proxy test has no server available!




server srv3.0  ip-xx-xx-xx-xxx.ec2.internal:80 cookie srv03.0 check inter 2000 rise 2 fall 3


Fix
comment out the contents from cookie something like this and restart the server service haproxy restart
server srv3.0  ip-xx-xx-xx-xx.ec2.internal:80 
#cookie srv03.0 check inter 2000 rise 2 fall 3

Saturday, July 9, 2011

Joomla 1.6 & Joomla 1.5 Remove index.php from the URL

This works!!!! If not mail me harshal82@gmail.com

Joomla 1.6 .
My Joomla is installed /var/www/joomla


1. Go to Site->Global Configuration and enable Search Firendly URL and use URL rewriting. Save.

2. Go to /var/www/joomla (myroot)  and rename htaccess.txt to .htaccess.
3. Enable apache mod rewrite  from terminal sudo a2enmod rewrite
4. Open nano .htaccess under /var/www/joomla

and below should be the setting

# RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* /joomla/index.php/$1 [L]
#
## End - Joomla! core SEF Section.



The line in red redirects the page to relavent page without changing the url.

http://yoursite/joomla/test should deliver the page.
 

Thursday, June 16, 2011

Set up Apache with SSL Complete Simple Guide

Set up Apache with SSL Complete Simple Guide 

If you already have the certificate and key go to step 2 

Step 1

Creating Certificate Authorities and self-signed SSL certificates


Following is a step-by-step guide to creating your own CA (Certificate Authority) -- and also self-signed SSL server certificates -- with openssl on Linux. Self-signing is the simpler route to take, but making one's own CA allows the signing of multiple server certificates using the same CA and involves only a few extra steps.

After using openssl to generate the necessary files, you'll need to integrate them into Apache. This process differs between Linux distros and versions of Apache. Additional references exist at the end of this document. My instructions for Setting up SSL: Ubuntu and Apache 2 are kept most current, and will carry you through to completion.

Making a homemade CA or self-signed certificate will cause the client web browser to prompt with a message whether to trust the certificate signing authority (yourself) permanently (store it in the browser), temporarily for that session, or to reject it. The message "web site certified by an unknown authority... accept?" may be a business liability for general public usage, although it's simple enough for the client to accept the certificate permanently.

Whichever route you take, you'll save the periodic expense of paying a recognized signing authority. This is purely for name recognition -- they've paid the major browser producers to have their CA pre-loaded into them. So if you're on a budget, have a special need or small audience, this may be useful.

Before you start
You need Apache and openssl. Compiling them from source, handling dependencies, etc. is beyond the scope of this document. You can consult their documentation, or go with a mainstream Linux distro that will do the preliminary work for you.

Now you need to decide whether you'll make a CA (Certificate Authority) and sign a server certificate with it -- or just self-sign a server certificate. Both procedures are detailed below.

(1A) Create a self-signed certificate.

Complete this section if you do NOT want to make a CA (Certificate Authority). If you want to make a CA, skip 1A entirely and go to 1B instead.

Some steps in this document require priviledged access, and you'll want to limit access to the cert files to all but the root user. So you should su to root and create a working directory that only root has read/write access to (for example: mkdir certwork, chmod 600 certwork). Go to that directory.

Generate a server key:

openssl genrsa -des3 -out server.key 4096

Then create a certificate signing request with it. This command will prompt for a series of things (country, state or province, etc.). Make sure that "Common Name (eg, YOUR name)" matches the registered fully qualified domain name of your box (or your IP address if you don't have one). I also suggest not making a challenge password at this point, since it'll just mean more typing for you.

The default values for the questions ([AU], Internet Widgits Pty Ltd, etc.) are stored here: /etc/ssl/openssl.cnf. So if you've got a large number of certificate signing requests to process you probably want to carefully edit that file where appropriate. Otherwise, just execute the command below and type what needs to be typed:

openssl req -new -key server.key -out server.csr

Now sign the certificate signing request. This example lasts 365 days:

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Make a version of the server.key which doesn't need a password:

openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key

These files are quite sensitive and should be guarded for permissions very carefully. Chown them to root, if you're not already sudo'd to root. I've found that you can chmod 000 them. That is, root will always retain effective 600 (read) rights on everything.

Now that you've just completed Step 1A, skip ahead to Step 2.

(1B) Generate your own CA (Certificate Authority).

Complete this section if you want to make a CA (Certificate Authority) and sign a server certificate with it. The steps for making a server certificate are also included here. If you'd rather one-time self-sign a server certificate, skip this step entirely and go to 1A instead.

Some steps in this document require priviledged access, and you'll want to limit access to the cert files to all but the root user. So you should su to root and create a working directory that only root has read/write access to (for example: mkdir certwork, chmod 600 certwork). Go to that directory.

In this step you'll take the place of VeriSign, Thawte, etc. You'll first build the CA key, then build the certificate itself.

The Common Name (CN) of the CA and the Server certificates must NOT match or else a naming collision will occur and you'll get errors later on. In this step, you'll provide the CA entries. In a step below, you'll provide the Server entries. In this example, I just added "CA" to the CA's CN field, to distinguish it from the Server's CN field. Use whatever schema you want, just make sure the CA and Server entries are not identical.

CA:
Common Name (CN): www.somesite.edu CA
Organization (O): Somesite
Organizational Unit (OU): Development

Server:
Common Name (CN): www.somesite.edu
Organization (O): Somesite
Organizational Unit (OU): Development

If you don't have a fully qualified domain name, you should use the IP that you'll be using to access your SSL site for Common Name (CN). But, again, make sure that something differentiates the entry of the CA's CN from the Server's CN.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt

Generate a server key and request for signing (csr).

This step creates a server key, and a request that you want it signed (the .csr file) by a Certificate Authority (the one you just created in Step #1B above.)

Think carefully when inputting a Common Name (CN) as you generate the .csr file below. This should match the DNS name, or the IP address you specify in your Apache configuration. If they don't match, client browsers will get a "domain mismatch" message when going to your https web server. If you're doing this for home use, and you don't have a static IP or DNS name, you might not even want worry about the message (but you sure will need to worry if this is a production/public server). For example, you could match it to an internal and static IP you use behind your router, so that you'll never get the "domain mismatch" message if you're accessing the computer on your home LAN, but will always get that message when accessing it elsewhere. Your call -- is your IP stable, do you want to repeat these steps every time your IP changes, do you have a DNS name, do you mainly use it inside your home or LAN, or outside?

openssl genrsa -des3 -out server.key 4096
openssl req -new -key server.key -out server.csr

Sign the certificate signing request (csr) with the self-created Certificate Authority (CA) that you made earlier.

Note that 365 days is used here. After a year you'll need to do this again.

Note also that I set the serial number of the signed server certificate to "01". Each time you do this, especially if you do this before a previously-signed certificate expires, you'll need to change the serial key to something else -- otherwise everyone who's visited your site with a cached version of your certificate will get a browser warning message to the effect that your certificate signing authority has screwed up -- they've signed a new key/request, but kept the old serial number. There are a couple ways to rectify that. crl's (certificate revocation list) is one method, but beyond the scope of the document. Another method is for all clients which have stored the CA certificate to go into their settings and delete the old one manually. But for the purposes of this document, we'll just avoid the problem. (If you're a sysadmin of a production system and your server.key is compromised, you'll certainly need to worry.)

The command below does a number of things. It takes your signing request (csr) and makes a one-year valid signed server certificate (crt) out of it. In doing so, we need to tell it which Certificate Authority (CA) to use, which CA key to use, and which Server key to sign. We set the serial number to 01, and output the signed key in the file named server.crt. If you do this again after people have visited your site and trusted your CA (storing it in their browser), you might want to use 02 for the next serial number, and so on. You might create some scheme to make the serial number more "official" in appearance or makeup but keep in mind that it is fully exposed to the public in their web browsers, so it offers no additional security in itself.

openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt

To examine the components if you're curious:

openssl rsa -noout -text -in server.key
openssl req -noout -text -in server.csr
openssl rsa -noout -text -in ca.key
openssl x509 -noout -text -in ca.crt

Make a server.key which doesn't cause Apache to prompt for a password.

Here we create an insecure version of the server.key. The insecure one will be used for when Apache starts, and will not require a password with every restart of the web server. But keep in mind that while this means you don't have to type in a password when restarting Apache (or worse -- coding it somewhere in plaintext), it does mean that anyone obtaining this insecure key will be able to decrypt your transmissions. Guard it for permissions VERY carefully.

openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key

These files are quite sensitive and should be guarded for permissions very carefully. Chown them to root, if you're not already sudo'd to root. I've found that you can chmod 000 them. That is, root will always retain effective 600 (read) rights on everything.

(2) Copy files into position and tweak Apache.

Some professors like to pause for a moment after a long lecture, and do a little recap. It's a good pedagogical tool, so let's do so here. If you took route 1A above, you should have four files in a working directory:

server.crt: The self-signed server certificate.
server.csr: Server certificate signing request.
server.key: The private server key, does not require a password when starting Apache.
server.key.secure: The private server key, it does require a password when starting Apache.

If you took route 1B and created a CA, you'll have two additional files:

ca.crt: The Certificate Authority's own certificate.
ca.key: The key which the CA uses to sign server signing requests.

The CA files are important to keep if you want to sign additional server certificates and preserve the same CA. You can reuse these so long as they remain secure, and haven't expired.

At a bare minimum, the following considerations must now be addressed:
  • You'll need a virtual host and document root set up for the SSL instance.
  • You'll need to turn on the SSL engine and enable/load the SSL module.
  • Apache must reference server.crt and server.key somewhere in its configuration.
  • Apache must be listening to a port for which SSL is enabled (443 is default).

 
 Step 2
Setting up SSL: Ubuntu and Apache 2

This document requires that you've got a signed server.crt and a server.key file available.

The remaining steps involve Apache and other tweaks detailed step-by-step below. This file was originally written for Ubuntu 6.06, but has been kept current and verified with 10.04 Lucid Lynx. It should work with most/all releases in between -- and probably Debian-based distros in general, with little or no modification.

(1) Preliminaries and Packages.

If you have a registered DNS name, be sure that you properly set it up. On the Gnome console: System->Administration->Networking:General. Your host/domain name here should match the one you'll be using in later steps. You can also edit /etc/hosts directly if you're comfortable with that route.

If you haven't done so already, use apt-get, Synaptic or some other tool to get and install Apache 2. I prefer apache2-mpm-prefork. You should also have openssl by this point.

(2) Copy the server.crt and server.key files into position.

This step suggests putting certificate-related files in this location: /etc/apache2/ssl. If the "ssl" directory doesn't already exist there, go ahead and mkdir it now.

Then copy the server.key and server.crt files into position:

cp server.key /etc/apache2/ssl
cp server.crt /etc/apache2/ssl

(3) Enable ssl.

You'll want to run the /usr/sbin/a2enmod script. If you look at this script, it's simply a general purpose utility to establish a symlink between a module in /etc/apache2/mods-available to /etc/apache2/mods-enabled (or give a message to the effect that a given module doesn't exist or that it's already symlinked for loading).

a2enmod ssl

(4) Create a stub SSL conf. file (if needed) and establish a necessary symlink.

NOTE. Ubuntu 10.04 already ships with a stub SSL conf file (/etc/apache2/sites-available/default-ssl), so you won't need to copy the 'default' conf as a stub for the 'default-ssl' conf -- but you will STILL need a symlink between it and the sites-enabled directory.

So if using an Ubuntu prior to ~10.04:

cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default-ssl

For all versions of Ubuntu:

Next, establish a symlink from the 'available' default-ssl file to the 'enabled' file. The symlinking methodology between those two directories is similar in philosophy to mods-available and mods-enabled (previous step). The general idea is that enabled files exist as symlinks created to their available counterparts. Ubuntu prefixes '000-' in front of the default file, so we may as well keep the same convention with default-ssl:

ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl

(5) Set up the document roots.

The default location for HTML pages with an initial install of Ubuntu is /var/www and there exists no separate place for ssl files. I prefer to serve up basic HTML pages in /var/www/html and SSL pages in /var/www-ssl/html. Whatever works for you. But at this point I create the directories.

cd /var/www
mkdir html
cd /var
mkdir www-ssl
cd www-ssl
mkdir html

(6) Configure virtual hosts.

su to the superuser and make a backup of the original Apache configuration file. Call it whatever you want. My practice is to add "_original" to any default configuration file before I make changes -- in case I need to revert. You should not make a backup of the following file in the sites-enabled directory, since both the original and backup will be loaded when you restart Apache. Also note that a symlink exists from /etc/apache2/sites-enabled/000-default to /etc/apache2/sites-available/default. Back it up in the sites-available directory or some other location outside of Apache altogether.

sudo su
cd /etc/apache2/sites-available
cp /etc/apache2/sites-available/default default_original

(Note: If using Ubuntu 10.04+ you may want to backup the original SSL conf also):
cp /etc/apache2/sites-available/default-ssl default-ssl_original

Now you need to declare the IP of your box (or FQDN/DNS name) and document roots you created in a previous step.

To configure HTTP over port 80 (edit /etc/apache2/sites-available/default):

NameVirtualHost *:80

(Note: Look down just a bit and make a change to the virtual host settings.)
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/
(Note: Use your assigned IP or DNS name followed with ":80" if you have one for ServerName).

Similar procedure for HTTPS over port 443 (edit /etc/apache2/sites-available/default-ssl):

NameVirtualHost *:443

(Note: Look down just a bit and make a change to the virtual host settings.)
<VirtualHost *:443>
ServerName localhost
DocumentRoot /var/www-ssl/html/
(Note: Again, use your assigned IP or a DNS name followed with ":443" if you have one for ServerName.)

(7) Instruct Apache to listen to 443.

Go to this file /etc/apache2/ports.conf and add the following to it:

Listen 443

I noted that starting with Ubuntu 7.10 (or thereabouts), the ports.conf may already have an IfModule clause in it for the SSL portion. If you see this, you can just leave it as-is:

<IfModule mod_ssl.c>
    Listen 443
</IfModule>

(8) Turn on the SSL engine.

Make sure the following are in your default-ssl file. The SSLengine should be on, and the cert and key should be properly pathed:

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

(9) Make an /etc/hosts tweak (if need be) -- and restart apache.

When starting and stopping Apache there may be a complaint such as "Could not determine the server's fully qualified domain name, using 127.0.1.1 for ServerName". You may encounter this if you don't have a DNS name for your server, and are just using an IP. If this applies to you, go into your /etc/hosts file and make the following changes. Basically, we'll be adding "localhost.localdomain" to the 127.0.0.1 IP and whatever system name you chose when you installed Ubuntu (assuming you've not changed it). The final line below should be there if you have a static IP, and corresponding DNS name registered to it. If this is the case, earlier steps that wanted ServerName should have a value which corresponds to the DNS name also indicated here.

127.0.0.1 localhost localhost.localdomain {your system name}
127.0.1.1 {your system name}
{static IP if you you have one} {fully qualified DNS host name if you have one}

It may be that I first noticed additional behavior with Ubuntu 8.04 Hardy Heron. If you don't have a fully qualified domain name (FQDN) for your box, you may need to make an additional tweak. In your /etc/apache2/apache2.conf file, you may want to add the following line at the very end of the file if Apache is still complaining about lacking a fully qualified domain name at startup:

ServerName localhost

Restart Apache.

cd /etc/init.d
./apache2 restart

Done -- test it out!


 

Monday, May 16, 2011

Simple Custom Dialog box using Jquery

<html>
<head>
import the jquery plugins from the jquery website like
jquery.js
jquery.ui.core.min.js etc..there will be two part one will be the core and one for the ui.
Also include the css files that come along with the zip file which you download from the jquery website
<script type="text/javascript">


    var divContents = "<h1>";
         divContents +="<a href=\"www.google.com\">";
         divContents +="Google";
         divContents +="</a>";
         divContents +="</h1>";
         divContents +="<h1>";
         divContents +="<a href=\"www.yahoo.com\">";
         divContents +="Yahoo";
         divContents +="</a>";
         divContents +="</h1>";
       
       
       var resumeortrackclaimdiv = jQuery('<div id="resumeortrackclaim"></div>')
         .html(divContents)
         .dialog({
              autoOpen: false,
              modal:true,
              draggable: true,
              resizable: false,
              height: 120,
              width: 270,
              position: ['center'],
                 overlay: { opacity: 0, background: 'black'},
                 open: function(){jQuery(".ui-dialog-titlebar-close").focus();}
         });
    jQuery('#ui-dialog-title-resumeortrackclaim').append("<span>Resume Or Track Claim</span>")
      
     jQuery('#my-claim-button').click(function() {
         resumeortrackclaimdiv.dialog('open');
         return false;
         });


/* this will create a a div and dialog box
    But the style sheet will be default since we want a custom dialog box we need to modify the css file for the dialog box.
*/


/* Now change the css content to create a default dialog box*/


.ui-dialog .ui-dialog-titlebar {
    padding: 0px;
    position: none;
}

.ui-widget-header {
    background: none;
    border: 0px ;
}

#resumeortrackclaim {
    height: 100px !important;
    width: 250px !important;
}

.ui-dialog-titlebar {
    height :20px;
    widht:300px;
    background-color:black;
    padding:4px;
}


.ui-dialog .ui-dialog-content {
    background: none repeat scroll 0 0 transparent;
    border: 0 none;
    overflow: auto;
    padding: 0 !important;
    position: relative;
}

.ui-dialog-content {
     margin-top:15px;
     margin-left: 7px;
    }
   
.ui-dialog .ui-dialog-titlebar {
    padding: 0.5em 2px 0.3em !important;
    color: #FFFFFF;
    font-size: 14px;
    font-weight: bold;
}


.ui-dialog-titlebar-close {
    background-image: url("../images/close.png") !important;
    border:0 none;
    padding: 0px !important;
    height: 18px !imporant;
    width: 18px !important;
    }
   
.ui-icon .ui-widget-content .ui-widget-header  {
    background-image: url("../images/close.png") !important;
    height: 18px !imporant;
    width: 18px !important;
    }
   
.ui-widget-overlay {
    background: black;
    opacity: 0.7 !important;
    filter: alpha(opacity = 50);
    position: absolute;
    top: 0;
    left: 0;
 }

 .ui-icon {
    background-image: url("../images/close.png") !important;
    height: 18px !imporant;
    width: 18px !important;
}

.ui-widget-content .ui-icon {
     background-image: url("../images/close.png") !important;
}

.ui-widget-header .ui-icon {
     background-image: url("../images/close.png") !important;
}


.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus {
    background: url("../images/close.png") repeat-x  !important;
    border: none !important;
    height: 18px !imporant;
    width: 18px !important;
    color: #212121;
    font-weight: normal;
}

.ui-state-hover {
    background-color: black transparent !important;
    }
   
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus {
    background-color: black transparent !important;
}

</script>
</head>

<body>
</body>
</html>



You can also create the div in body and initially hide that div and display it on click
Here #resumeortrackclaim will be placed in the body

/* jQuery('#resumeortrackclaim').hide();
   
     jQuery('#resumeortrackclaim').dialog({
         autoOpen: false,
         modal:true,
         draggable: true,
         resizable: false,
         height: 120,
         width: 270,
         position: ['center'],
            overlay: { opacity: 0, background: 'black'},
            open: function(){jQuery(".ui-dialog-titlebar-close").focus();}
     });
   
     jQuery('#my-claim-button').click(function() {
         jQuery('#resumeortrackclaim').dialog('open');
         return false;
     });
*/

Place the below div in body

<div id="resumeortrackclaim">
<div style="display: block; position: absolute;   overflow: hidden; z-index: 1002; outline: 0pt none; " class="ui-dialog ui-draggable" tabindex="-1">
<div class="ui-dialog-container" style="position: relative; width: 100%; height: 100%;"><div class="ui-dialog-titlebar" unselectable="on" style="-moz-user-select: none;">
    <span class="ui-dialog-title" unselectable="on" style="-moz-user-select: none;">Resume Or Track Claim
       </span>
   <a class="ui-dialog-titlebar-close" href="#" unselectable="on" style="-moz-user-select: none;">
    </a>
</div>
<div title="Resume Or Track Claim" id="dialog-modal" class="ui-dialog-content" style="width: 270px;" >
  <h1>
    <a href="https://process.phoneclaim.com/ATT/Default.aspx?clientID=313&amp;UserAction=CompleteExisting&amp;Culture=en-US&amp;Mode=LIVE">Resume Claim
    </a>
  </h1>
 <h1>
  <a href="https://process.phoneclaim.com/ATT/Default.aspx?clientID=313&amp;UserAction=TrackStatus&amp;Culture=en-US&amp;Mode=LIVE">
     Track Claim
   </a>
 </h1>
 </div>
</div>
</div>

     <div class="ui-dialog-buttonpane" style="position: absolute; bottom: 0pt; display: none;">
     </div>
 </div>

Tuesday, April 12, 2011

Steps to do SSH Login from Remote Server without the password

Steps to do SSH Login from Remote Server without the password

Open 2 terminal screens - 1 for local and one for remote

1. ~/.ssh$ ssh-keygen -t rsa
    Press enter for the rest of the steps below
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/localadmin/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:

    You will get 2 files generated .pub is the public key and other one is the private key.
    :~/.ssh$ ls
    id_rsa  id_rsa.pub

2 :~/.ssh$ vi id_rsa.pub
 Now right click and copy the key

3. Go to remote server terminal screen
  Create a user using useradd -m "name of the user same as the user on your localhost"

 a. Now go to /home/youruser and create a directory .ssh
    remotehost:/home/youruser/.ssh# ls
    remotehost:/home/youruser/.ssh# nano authorized_keys

 Now paste the key which you copied in previous step
 b.
    remotehost:/home/youruser/.ssh# chmod 600 authorized_keys
    remotehost:/home/youruser/.ssh# cd ..
    remotehost:/home/youruser/# chmod 755 .ssh
    remotehost:/home/youruser# cd ..
    remotehost:/home# chown -R youruser youruser
    remotehost:/home# chgrp -R youruser youruser


4. Now come back to your localhost screen

    localhost:~/.ssh$ ssh usercreatedonremoteserver(Step 3 a)@remoteserveripaddress

     You should be able to login from the localhost

     Tip : change of owner and change of group is required. Step 3 b.

Wednesday, March 23, 2011

Access database in php

<?php
error_reporting(-1);

$man_db = db_query("SELECT DISTINCT manufacture_name FROM {drup_deductible} WHERE drup_deductible.carrier_name LIKE '%Verizon%' ORDER BY manufacture_name");
$model_db = db_query("SELECT DISTINCT model_name FROM {drup_deductible} WHERE manufacture_name LIKE '%".$_REQUEST['manufacturer']."%' ORDER BY model_name");
$deduct_db = db_query("SELECT drup_deductible.tier_name, drup_tier.tier_name, drup_tier.tier_amount, drup_tier.tier_premium FROM {drup_tier},{drup_deductible} WHERE drup_tier.tier_name = drup_deductible.tier_name AND drup_deductible.carrier_name = 'Verizon' LIMIT 1");

$today = date('m/d/Y');
if($today >= "06/01/2011"){
    $effectiveDate = "05/17/2009";
} else {
    $effectiveDate = "02/01/11";
}

function dropdownfunc($name, $rowname, $source){
    foreach($source as $row) {
        if ($row->$rowname == $_REQUEST[$name])
        {
            $s = " SELECTED";
        } else {
            $s = "";
        }
        echo '<option value="'.$row->$rowname.'"'. $s.'>'.$row->$rowname.'</option>';
    }
}
?>
<div id="newwrapper">
    <div style="margin-top: -23px; margin-left: -22px; /margin-left: -15px; width: 975px; position: relative;">
        <div style="float:left; width:648px; margin-right: 5px;">
            <div id="vz-redesign-top"></div>
            <div style="padding-left: 25px; margin-top: 20px; /margin-top: 0px; position: relative; min-height: 200px;">
                <p style="font-size: 16px;">Select your manufacturer and model</p>
                <form method="POST" action="lookup">
                    <div style="float:left;width:160px;padding-right:15px; margin-top: 0px;">
                        <span style="font-size: 16px !important;">Manufacturer</span><br/>
                        <select name="manufacturer" onchange="this.form.submit();">
                            <option value="">Select a manufacturer</option>
                            <?php dropdownfunc('manufacturer', 'manufacture_name', $man_db); ?>
                        </select>
                    </div>
                    <input type="hidden" name="_submit" value="1">
                    <div style="float:left;width:150px;">
                        <span style="font-size:16px !important; margin-bottom: 10px;">Model</span><br/>
                        <select name="model" onchange="this.form.submit();"><br/>
                            <option value="">Select a model</option>
                            <?php dropdownfunc('model', 'model_name', $model_db); ?>
                        </select>
                    </div>
               </form>

               </form>
               </div>
               </div>
               </div>
               </div>

Sunday, March 20, 2011

JQuery Dialog Box capture input

JQuery Dialog Box capture input

<html lang="en">
<head>
  <title></title>
  <link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
  <script type="text/javascript" src="js/jquery-ui-1.8.7.custom.min.js"></script>
   <link type="text/css" href="js/demos.css" rel="stylesheet" />
  <script type="text/javascript">
    $(function() {
        var cancel = function() {
            $("#myDialog").dialog("close");
        }
        var getResponse = function(){
          var answer;
          $("input").each(function(){
            (this.checked == true) ? answer = $(this).val() : null;
          });
          $("<p>").text(answer).insertAfter($("#poll"));
          $("#myDialog").dialog("close");
        }
        var dialogOpts = {
          modal: true,
          buttons: {
            "Done": getResponse,
            "Cancel": cancel
          },
          autoOpen: false
        };
        $("#myDialog").dialog(dialogOpts);
        $("#poll").click(function() {
          $("#myDialog").dialog("open");
        }); 
    });
  </script>
</head>
<body>
    <button id="poll">Poll</button>
    <div id="myDialog" class="flora" title="This is the title">
      <p>Question?</p>
      <label for="yes">Yes!</label><input type="radio" id="yes" value="yes" name="question"><br>
      <label for="no">No!</label><input type="radio" id="no" value="no" name="question">
    </div>
</body>
</html>

Friday, March 18, 2011

Gmail Ubuntu Desktop Simple Mail

Send a simple mail from Ubuntu Desktop using ssmtp

1. Install ssmpt from System- >Administration->Synaptic
2. Go to /etc/ssmtp and edit ssmtp.conf

Debug=YES
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=yourgmailusername@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=yourgmailusername@gmail.com

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
UseSTARTTLS=YES
FromLineOverride=YES

AuthUser=yourgmailusername@gmail.com
AuthPass=yourgmailpassword
AuthMethod=Login
AuthMethod=PLAIN


Now from terminal

localadmin@localadmin:~$ ssmtp destinationemailaddress@yahoo.com
To : destinationemailaddress@yahoo.com
From : youremailaddress@gmail.com
Subject : hi

Hi
Now press Cntrl D. If any difficulty instead of yahoo try any other gmail address.

If you get this - it means your username or password is in correct
Authorization failed (535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 27sm2207505yhl.25)


Thursday, March 17, 2011

Drupal 7 theme_table pagination sort

Drupal 7 theme_table  pagination sort

function deductible_menu_page($content = NULL, $arg1 = NULL, $arg2 = NULL){
  /*$tablesort = tablesort_sql($header);
    $result = pager_query($sql . $tablesort, $limit);
    $rows = array();
     // Then you can pass the data to the theme functions
    $output .= theme('table', $header, $rows);
    $output .= theme('pager', NULL, $limit, 0);
    */
   
    $headervariable =  array(
    array('data' => t('Carrier'), 'field' => 'carrier_name', 'sort' => 'asc'),
    array('data' => t('Manufacture'), 'field' => 'manufacture_name', 'sort' => 'asc'),
    array('data' => t('Model'), 'field' => 'model_name', 'sort' => 'asc'),
    array('data' => t('Tier'), 'field' => 'tier_name', 'sort' => 'asc'),
    t('Delete'),t('Update'));
    //$result = db_query("SELECT deductible_id,carrier_name,manufacture_name,model_name,tier_name FROM {drup_deductible}");
    $entries_per_page=3;
    $select = db_select('drup_deductible', 'pv')->extend('PagerDefault')->extend('TableSort');
    $result = $select
    ->fields('pv', array('deductible_id','carrier_name', 'manufacture_name', 'model_name', 'tier_name'))
    ->limit($entries_per_page)
    ->orderByHeader($headervariable)
    ->execute();
   
    $listitems=array();
    $bigitems = array();
    foreach ($result as $item) {
        watchdog('Deductibe', 'hi', array(), WATCHDOG_DEBUG);
        $listitems=array($item->carrier_name,
        $item->manufacture_name,
        $item->model_name,
        $item->tier_name,
        l('Delete','deductible/deductible/delete/'.$item->deductible_id),
        l('Update','deductible/deductible/update/'.$item->deductible_id)
        );
        $bigitems[]=$listitems;
    }

    //   return print_r($bigitems);
    if (count($listitems) == 0)
    $make[] = array("No Models Entered Yet");
    else{
        watchdog('Deductibe', 'a', array(), WATCHDOG_DEBUG);
    }

    $link_to_add_form = l('Add More Deductible','deductible/add_deductible');
    $variable=array(
             'header' =>  $headervariable,
             'rows'  =>  $bigitems,
             'attributes' => array(),
             'caption' => NULL,
             'colgroups' => NULL,
             'sticky' => NULL,
             'empty' => NULL,
    );
    // return print_r($items);
    $output= '<div id="car">'.theme_table($variable).'<br/>'.$link_to_add_form.'</div>';
    $output .= theme('pager');
    $output .= theme('sort');
    return $output;
   
}



Drupal 7 Ajax Pagination Update Delete Insert Form theme_table

Drupal 7 Ajax Pagination Update Delete Insert Form  theme_table  - Implemented below

deductible.module

<?php
//;$Id$

/**
 * @file
 * Enables a single blog for an individual or multiple users.
 */
// After you learn Form API in Chapter 5, you'll be able to
// make these settings configurable.

function deductible_help($section) {
    switch ($section) {
        case 'admin/help#deductible':
            return t('This module stores deductible for given make an Model');
    }
}

function deductible_menu(){
  
  
  $items['deductible/add_deductible'] = array(
    'title' => '',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('adddeductible'),
    'access callback' => TRUE,
     'file'=>'deductible.inc',
    'weight' => 0,
  );
  

    //watchdog('Deductibe', '1', array(), WATCHDOG_DEBUG);
    $items['deductible/display_deductibles'] = array(
    //    'title'=>'Calculate Deductible',
        'access arguments' => array('administer user'),
        'page callback' => 'deductible_menu_page',
        'page arguments' => array(t('Display Deductible')),
        'access callback' => TRUE,
        'file'=> 'deductible.inc',
    //'type' => MENU_CALLBACK,
    );
  
    $items['deductible/deductible/delete/%'] = array(
    //    'title'=>'Calculate Deductible',
        'access arguments' => array('administer user'),
        'page callback' => 'delete_deductible',
        'access callback' => TRUE,
        'page arguments' => array(0,1,2,3),
        'file'=> 'deductible.inc',
    //'type' => MENU_LOCAL_TASK,
    );
  
    //watchdog('Deductibe', '2', array(), WATCHDOG_DEBUG);
    return $items;
}



/**
 * Implementation of hook_perm().
 */
function deductible_perm() {
  return array('administer user');
}



function theme_deductible($form) {
    watchdog('Deductibe', 'abf', array(), WATCHDOG_DEBUG);
    $output = drupal_render($form['Title']);
    return $output;
}

function deductible_theme($existing, $type, $theme, $path) {
    return array(
    'deductible' => array(
      'arguments' => array('form' => NULL),
        'template' => 'deductible',  
        'render element' => 'form',  
    //  'file'=> 'deductibleadd.inc',  
    ),
    'list' => array(
      'arguments' => array('form' => NULL),
        'template' => 'list',  
        'render element' => 'form',      
          ),
      'carrier' => array(
      'arguments' => array('form' => NULL),
        'template' => 'carrier',  
        'render element' => 'form',      
          ),  
    );
}

function deductible_block_info() {
    $blocks = array();
    // The array key defines the $delta parameter used in all
    // other block hooks.
    $blocks['list'] = array(
       // The name of the block on the blocks administration page.
       'info' => t('List'),
       'file'=>'list.inc',
       'access arguments' => array('administer user'),
    );
    return $blocks;
}

function deductible_block_view($delta = '') {
 $block = array();
 switch ($delta) {
 case "list":
 $form = drupal_get_form('display_list');
 $block["content"] = $form;
 break;
 }
 return $block;
 }

deductible.inc

 <?php

function adddeductible($form, &$form_state) {
      $form = array();
    $path = drupal_get_path('module', 'Deductible');
    //$form_state['redirect'] = 'deductilbe/display_results';
    $result = db_query("SELECT carrier_name FROM {drup_carrier}");
    $form['#prefix']='<div id="ooo" class="dedwrapper">';
    $form['#suffix']='</div>';
    $carrier_names[] = array();
    $carrier_names[0]='--Select--';
   // $manufacture_names[]='Select';
          foreach ($result as $carrier) {
              $carrier_names[$carrier->carrier_name] = $carrier->carrier_name;
          }
  $selectedcarrier = isset($form_state['values']['carrier_select']) ? $form_state['values']['carrier_select'] : NULL;        
  $selectedmanufacture = isset($form_state['values']['manufacture_select']) ? $form_state['values']['manufacture_select'] : NULL;
  $selectedmodel = isset($form_state['values']['model_select']) ? $form_state['values']['model_select'] : NULL;
 
    $form['carrier_select'] = array(
    '#type' => 'select',
    '#title' => t('Carrier'),
    '#options' => $carrier_names,
      '#default_value' => $carrier_names[0],
    '#ajax' => array(
     'callback' => 'deductible_callback_formanufacture',
      'wrapper' => 'manufacturediv',
    ),
  );
 
  $form['manufacture_select'] = array(
    '#type' => 'select',
    '#title' => t('Manufacture'),
    '#options' => getManufactureList($selectedcarrier),
      //'#default_value' => $manufacture_names[0],
       '#prefix' => '<div id="manufacturediv">',
    '#suffix' => '</div>',
    '#ajax' => array(
     'callback' => 'deductible_callback_formodel',
      'wrapper' => 'modeldiv',
    ),
  );
 
  $form['model_select'] = array(
    '#type' => 'select',
    '#title' => t('Model'),
    '#prefix' => '<div id="modeldiv">',
    '#suffix' => '</div>',
   // '#default_value' => isset($form_state['values']['model_select']) ? $form_state['values']['model_select'] : 'Select',
    '#options' => getModelList($selectedmanufacture),
  '#ajax' => array(
     'callback' => 'deductible_callback_fortier',
      'wrapper' => 'tierdiv',
    ),
   );
 
   $form['tier_select'] = array(
    '#type' => 'select',
    '#title' => t('Tier'),
    '#prefix' => '<div id="tierdiv">',
    '#suffix' => '</div>',
  //  '#default_value' => isset($form_state['values']['tier_select']) ? $form_state['values']['tier_select'] : NULL,
    '#options' => getTierList($selectedmodel),
   );
 
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Save'),
        '#submit' => array('deductible_submit'),
    );
 //$form['#theme'] = 'deductible';
  return $form;
}

function deductible_callback_formanufacture($form, $form_state) {
     watchdog('Deductibe', 'In ajax', array(), WATCHDOG_DEBUG);
  return $form['manufacture_select'];
}

function deductible_callback_formodel($form, $form_state) {
     watchdog('Deductibe', 'In ajax', array(), WATCHDOG_DEBUG);
  return $form['model_select'];
}

function deductible_callback_fortier($form, $form_state) {
     watchdog('Deductibe', 'In ajax', array(), WATCHDOG_DEBUG);
  return $form['tier_select'];
}


function getManufactureList($selectedCarrier = NULL){
    $manufacture_names = array();
        if(isset($selectedCarrier)){
             $manufacture_names[0]='--Select--';
    watchdog('Deductibe', 'In select'.$selectedCarrier, array(), WATCHDOG_DEBUG);  
        $result = db_query("SELECT manufacture_name FROM {drup_manufacture}");
          foreach ($result as $manufacture_name) {
              $manufacture_names[$manufacture_name->manufacture_name] = $manufacture_name->manufacture_name;
          }
        }
          return $manufacture_names;
}

function getTierList($selectedModel = NULL){
    $tiers = array();
  
        if(isset($selectedModel)){
             $tiers[0]='--Select--';
    watchdog('Deductibe', 'In select'.$selectedModel, array(), WATCHDOG_DEBUG);  
        $result = db_query("SELECT tier_amount FROM {drup_tier} ");
  
  
          foreach ($result as $tier) {
              $tiers[$tier->tier_amount] = $tier->tier_amount;
          }
        }
          return $tiers;
}

function getModelList($selectedManufacture = NULL){
//    watchdog('Deductibe', 'FUNNY CATCH -JACK'.$selectedManufacture, array(), WATCHDOG_DEBUG);  
  
    $model_names = array();
        if(isset($selectedManufacture)){
    watchdog('Deductibe', 'In select'.$selectedManufacture, array(), WATCHDOG_DEBUG);  
        $result = db_query("SELECT model_name FROM {drup_model} WHERE model_manufacture  = :contents", array(':contents' => trim($selectedManufacture)));
  
    $model_names = array();
 
          foreach ($result as $model) {
               $model_names[0]='--Select--';
              $model_names[$model->model_name] = $model->model_name;
          }
        }
          return $model_names;
}

function deductible_submit($form, &$form_state){

  $carselect = isset($form_state['values']['carrier_select'])?$form_state['values']['carrier_select']:NULL;
  $manselect=isset($form_state['values']['manufacture_select'])?$form_state['values']['manufacture_select']:NULL;
  $modselect = isset($form_state['values']['model_select'])?$form_state['values']['model_select']:NULL;
  $tierselect = isset($form_state['values']['tier_select'])?$form_state['values']['tier_select']:NULL;
 // watchdog('Deductibe', 'Some Jacky'.$manselect, array(), WATCHDOG_DEBUG);  
 
  if(isset($carselect)&&isset($manselect)&&isset($modselect)&&isset($tierselect)){
      if(strlen($carselect)>0&&strlen($manselect)>0&&strlen($modselect)>0&&strlen($tierselect)>0){
         watchdog('Deductibe', 'Some Jacky'.strlen($carselect), array(), WATCHDOG_DEBUG);  
        $insertquery = db_insert('drup_deductible')->fields(array(
      'carrier_name'=>$carselect,
       'manufacture_name'=>$manselect,
       'model_name'=>$modselect,
         'tier_name'=>$tierselect
      ))->execute();
      if($insertquery!==false){
           $message = 'Deductible Added';
         drupal_set_message(t($message));
         $form_state['redirect'] = 'deductible/display_deductibles';
      }else{
          drupal_set_message(t('Error-Contact Administrator- Database issue'));
      }
      }else{
          watchdog('Deductibe', 'Some Jacky'.$carselect.$manselect.$modselect.$tierselect, array(), WATCHDOG_DEBUG);  
          drupal_set_message(t('Please select all entries'));
      }
  }else{
      drupal_set_message(t('Error-Contact Administrator'));
  }
}

function deductible_menu_page($content = NULL, $arg1 = NULL, $arg2 = NULL){
  /*$tablesort = tablesort_sql($header);
    $result = pager_query($sql . $tablesort, $limit);
    $rows = array();
     // Then you can pass the data to the theme functions
    $output .= theme('table', $header, $rows);
    $output .= theme('pager', NULL, $limit, 0);
    */
  
    $headervariable =  array(t('Carrier Name'),t('Manufacture Name'),t('Model Name'),t('Tier Name'),t('Delete'),t('Update'));
    //$result = db_query("SELECT deductible_id,carrier_name,manufacture_name,model_name,tier_name FROM {drup_deductible}");
    $entries_per_page=3;
    $select = db_select('drup_deductible', 'pv')->extend('PagerDefault')->extend('TableSort');
    $result = $select
    ->fields('pv', array('deductible_id','carrier_name', 'manufacture_name', 'model_name', 'tier_name'))
    ->limit($entries_per_page)
    ->orderByHeader($headervariable)
    ->execute();
  
    $listitems=array();
    $bigitems = array();
    foreach ($result as $item) {
        watchdog('Deductibe', 'hi', array(), WATCHDOG_DEBUG);
        $listitems=array($item->carrier_name,
        $item->manufacture_name,
        $item->model_name,
        $item->tier_name,
        l('Delete','deductible/deductible/delete/'.$item->deductible_id),
        l('Update','deductible/deductible/update/'.$item->deductible_id)
        );
        $bigitems[]=$listitems;
    }

    //   return print_r($bigitems);
    if (count($listitems) == 0)
    $make[] = array("No Models Entered Yet");
    else{
        watchdog('Deductibe', 'a', array(), WATCHDOG_DEBUG);
    }

    $link_to_add_form = l('Add More Deductible','deductible/add_deductible');
    $variable=array(
             'header' =>  $headervariable,
             'rows'  =>  $bigitems,
             'attributes' => array(),
             'caption' => NULL,
             'colgroups' => NULL,
             'sticky' => NULL,
             'empty' => NULL,
    );
    // return print_r($items);
    $output= '<div id="car">'.theme_table($variable).'<br/>'.$link_to_add_form.'</div>';
    $output .= theme('pager');
    $output .= theme('sort');
    return $output;
  
}

function delete_deductible($content = NULL, $arg1 = NULL, $arg2 = NULL,$arg3=NULL)
{

    global $base_root;
    $url=$base_root . request_uri();
    $output =  '<div>' . $url . '</div>';
    watchdog('Deductibe', 'In delete'.$arg3, array(), WATCHDOG_DEBUG);
    if(isset($arg3)){
        delete_entry($arg3);
    }
    drupal_goto($path = 'deductible/display_deductibles',  array(), $http_response_code = 302);
    //return $output.$arg2;
}

function delete_entry($arg){

    try{
        $num_deleted = db_delete('drup_deductible')
        ->condition('deductible_id', $arg)
        ->execute();
    }catch(Exception $e){
    }
    if($num_deleted!==false){
        drupal_set_message('<div id="msg">'.t('The deductible has been deleted').'</div>');
    //    $form_state['redirect'] = 'deductible/display_deductibles';
    }else{
        drupal_set_message(t('Some issue- Unable to delete'));
    //    $form_state['redirect'] = 'deductible/display_results';
    }
}


/*function adddeductible_form($form, &$form_state){
    $form = array();
    $path = drupal_get_path('module', 'Deductible');
    //$form_state['redirect'] = 'deductilbe/display_results';
    $result = db_query("SELECT manufacture_name FROM {drup_manufacture}");
  
    $manufacture_names = array();
          foreach ($result as $manufacture) {
              $manufacture_names[] = $manufacture->manufacture_name;
          }
  $selected = isset($form_state['values']['manufacture_select']) ? $form_state['values']['manufacture_select'] : key($manufacture_names);
 
  $form['manufacture_select'] = array(
    '#type' => 'select',
    '#title' => t('Manufacture'),
    '#options' => $manufacture_names,
      '#default_value' => $selected,
    '#ajax' => array(
     'callback' => 'deductible_dependent_dropdown_callback',
      'wrapper' => 'dropdown-second-replace',
    ),
  );

  $form['model_select'] = array(
    '#type' => 'select',
    '#title' => t('Model'),
    '#prefix' => '<div id="dropdown-second-replace">',
    '#suffix' => '</div>',
    '#default_value' => isset($form_state['values']['model_select']) ? $form_state['values']['model_select'] : 'Select',
    '#options' => getModelList($selected),
      '#ajax' => array(
     'callback' => 'deductible_dependent_dropdown_callback2',
      'wrapper' => 'dropdown-third-replace',
    ),
   );
 


  
$form['#attached'] = array
    (
    'css' => array
    (
        'type' => 'file',
        'data' => $path . '/root.css',
    ),
    'js' => array
    (
        'type' => 'file',
        'data' => $path . '/root.js',
    ),
    );
  
    $form['#theme'] = 'deductible';
    return $form;
}
*/
/*function deductible_dependent_dropdown_callback($form, $form_state) {
     watchdog('Deductibe', 'In ajax', array(), WATCHDOG_DEBUG);
  return $form['manufacture_select'];
}


*/

/*function deductible_submit($form, &$form_state){
  watchdog('Deductibe', 'In add', array(), WATCHDOG_DEBUG);
  global $user;
  $username = $user->name;
  watchdog('Deductibe', $form_state['values']['manufacture_select'], array(), WATCHDOG_DEBUG);
   $form_state['redirect'] = 'deductible/add_manufacture';
  /*$Make = $form_state['values']['Make'];
  $Model = $form_state['values']['Model'];
  $Deductible = $form_state['values']['Deductible'];
      $insertquery = db_insert('Deductible')->fields(array(
      'username' => $username,
      'Make'=>$form_state['values']['Make'],
       'model'=>$form_state['values']['Model'],
       'deductible'=>$form_state['values']['Deductible']
      ))->execute();
      if($insertquery!==false){
           $message = 'You have submitted the '  . ' form which contains the following data:<pre>' . print_r($form_state['values']['Make'],true) . '</pre>';
         drupal_set_message(t($message));
         $form_state['redirect'] = 'deductible/display_results';
      }else{
          drupal_set_message(t('Error-Contact Administrator'));
      }*/
//}


/*function deductible_menu_page($content = NULL, $arg1 = NULL, $arg2 = NULL,$arg3=NULL)
{
    $result = db_query("SELECT itemid,make,model,deductible FROM {Deductible}");
    $listitems=array();
    $bigitems = array();
    foreach ($result as $item) {
        watchdog('Deductibe', 'hi', array(), WATCHDOG_DEBUG);
        $listitems=array($item->make,
        $item->model,
        $item->deductible,
        l('Delete','deductible/delete/'.$item->itemid),
        l('Update','deductible/update/'.$item->itemid)
        );
        $bigitems[]=$listitems;
    }

    //   return print_r($bigitems);
    if (count($listitems) == 0)
    $make[] = array("No Models Entered Yet");
    else{
        watchdog('Deductibe', 'a', array(), WATCHDOG_DEBUG);
    }

    $link_to_add_form = l('Add More Models','deductible/calculate');
    $variable=array(
             'header' =>  array(t('Make'), t('Model'),t('Deductible'),t('Delete'),t('Update')),
             'rows'  =>  $bigitems,
             'attributes' => array(),
             'caption' => NULL,
             'colgroups' => NULL,
             'sticky' => NULL,
             'empty' => NULL,
    );
    // return print_r($items);
    return theme_table($variable).'<br/>'.$link_to_add_form;
}*/
/*  $form['justtext'] = array(
    '#type' => 'textfield',
    '#title' => t("Who"),
    '#prefix' => '<div id="replace_textfield_div1">',
    '#suffix' => '</div>',
  );*/
/*  if (!empty($form_state['values']['manufacture_select'])) {
    $form['justtext']['#description'] = t("Say why you chose") .  " '{$form_state['values']['manufacture_select']}'";
   /* $selected=$form_state['values']['manufacture_select'];
     $form['model_select']['#options'] = getModelList($selected);*/
 // }

 /*     $form['fs'] = array(
      '#type'=>'fieldset',
      '#attributes'=>array('style'=>'width:50%;'),
      '#weight'=>$weight,
    );
  */


function display_list(){
    $form = array();
    $path = drupal_get_path('module', 'Deductible');
    $form['#attached'] = array
    (
    'css' => array
    (
        'type' => 'file',
        'data' => $path . '/root.css',
    ),
    'js' => array
    (
        'type' => 'file',
        'data' => $path . '/root.js',
    ),
    );
    $form['#theme'] = 'list';
    return $form;
}