Thursday, January 24, 2013

Downloading You Tube Video

Downloading You Tube videos will not be headache any more now. As a simple utility in linux exists to download them effectively.

$ sudo apt-get install youtube-dl

//To install the utility

Then to download just do the following

$ youtube-dl youttube url

just like

$youtube-dl http://www.youtube.com/watch?v=KU8r1mNC3iM

Press Enter and you are done. That easy stuff!!

Wednesday, October 17, 2012

Creating Simple Android Application

Today I am going to start with How to make a Simple Application in Android. Before Starting It we must be clear about some aspects related to Android Development. As We already know now from previous post about Setting up of Android SDK with Eclipse. So We will uncover the basic file hierarchy of Android App.

Starting of Android Application. 

  • Open Up your Eclipse. Then go to File - > New Project - > Android Project. A dialog box will be opened up as shown.
New Android Project
  • Now you have to fill some details. Like Project Name, Project Location. After Clicking Next you will be asked to Select for API version. Select According to your requirement.
  • After then Enter Package name like if your application name is sample. Then Package can be com.simple. Check for Activity automatic creation as it is needed. After finishing Project is now created and you will have a hierarchical view just like below (if we have created application named test).
Hierarchical View of Application

Various Files In Android

  • src :- This folder contains the main core Activity file for the application being created. And the major work of coding goes into this folder.
  • gen:- These are automatic generated configuration file that will be used by the system.
  • res:- The Main designing part goes here in this folder. Here in various folders like drawable-hdpi and similar named folders hold the various images to be used by the application. Next it contains the folder layout where you will be defining the layout for different views of your application.
  • values:- This sub folder of res holds the different string.xml and other files for handling the data that will be referred in time to time in the application that is being developed.
  • AndroidManifest.xml will hold the values like the permission granting for internet access and some other system related requirements that will be additional.

Project Development

TestActivity is the file in case of application test where we will be spending most of our time in performing coding. The pre generated code for this particular file is as below. (Remember Android Programming is nothing but JAVA programming with API's and Android Additional services.)
So, If one knows java it is not going to be difficult to learn AP (Android Programming).


So in the next post we will come to the actual coding of this test application. Till then Good Byee!!





Saturday, October 13, 2012

Setting up Android with Eclipse


Eclipse is most widely used when it comes to use for Android Development. Following are the various phases that has to be done in order to install it and make necessary changes to setup with Android SDK .

Download and Install JDK
Download and install the latest JDK (JDK 1.6 Update 18) from JDK download page
Download and Install Eclipse IDE
Download and install Eclipse Classic 3.5 (Galileo) from Eclipse download page. You can also use the  Java or RCP version of Eclipse.
Download and Install Android SDK Starter Package
The Android SDK starter package includes only a single component, the latest version of the SDK Tools. Included in that component is a tool called Android SDK and AVD Manager that you can use to download other components from the SDK repository site.
  • Download the latest Android SDK  starter package  from the SDK download page.
  • Unpack the archive to a suitable location on your machine. By default, the SDK files are unpacked into a directory named  android-sdk- . For example, on Windows platform the directory will be android-sdk-windows.

Android SDK
Add Android Platforms to Your SDK
To add one or more Android platforms (for example, Android 1.6 or Android 2.1) to your SDK, use the Android SDK and AVD Manager, included in the SDK starter package. It is recommended  to download multiple platforms, so that you can build your application on the lowest version you want to support, but test against higher versions that you intend the application to run on.
  • Launch the Android SDK and AVD Manager on Windows by executing SDK Setup.exe at the root of the SDK directory. On Mac OS X or Linux, execute the android tool in the /tools/ folder.
  • On Available Packages menu, select the platforms to download (1.1 to 2.1).

If you find error on HTTP SSL while fetching the repository url , try to use http instead of https by checking the Force https://… sources to be fetched using http://… option on Settings menu.

Download and Installing Eclipse. Download it From here http://www.eclipse.org/downloads/

Download and Install ADT Plugin
To install  the ADT Plugin, you can take advantage of the Eclipse remote update feature. By setting up a remote update site, you can easily download, install, and check for ADT updates. Alternatively, you can download the latest ADT to your development computer as a local site archive.
  • Launch Eclipse, then select Help –> Install New Software.
  • In Available Software dialog, click Add
  • Enter a name for the remote site (ex: Android Plugin) in the Name field and in the Locationfield, enter this URL:
    https://dl-ssl.google.com/android/eclipse/
    and then click OK. If you have trouble acquiring the plugin, you can try using ‘http’  instead of  ’https’  in the URL.

Select the checkbox next to Developer Tools, which will automatically select the nested toolsAndroid DDMS and Android Development Tools and then click Next.
  • On the next dialog, click Next to read and accept the license agreement and install any dependencies, then click Finish.
  • Restart Eclipse
  • To check whether the ADT has been installed correctly, try to create a new project by selectFile > New > Project., you shoud find Android Project listed on project wizard.


Friday, August 17, 2012

Android Sample Application

Those who are compatible with even core Java need not be worry about the coding as android platform is supporting to use the basic skills that you earned so far in colleges qnd universities.

First of all we will start with android sdk installation. Currently  I am giving the tutorial about installtion in Linux and the other is same around for windows. Eclipse is basically prefered as it comes along with the basic settings to install sdk.

Sunday, July 29, 2012

HTML Presentation


Normally in Every Day Life one encounters with the problem of making presentation. Problem is not with making presentation but its after effects become a headache. If you were told to put the same content on  some sort of blog this thing make your mind go out of nuts by doing a large copy paste work. So For that We are having an alternative which we never thought about but yes somebody did.

Making Presentation in HTML

DZ Slides is the name that let you help in making the Slides in HTML and CSS and that too with the help of basic and simple syntax that you are already familiar with.


And That's It. A One Single html file with few javascript transition and you are done. And If you are wondering how to include text, images, videos and but about their usability then don't worry about it HTML 5 will make you at ease.

For Downloading the needed files and the script please refer to. https://github.com/paulrouget/dzslides

Introduction to Android


Android is the name in OS for mobile computing which is well known to the techno geeks and the smartphone and tablet users. So Many Version till now developed for this OS and the 4.0 IceCream Sandwich being the latest one.

Now a days I am trying hands on this fantastic platform to build some applications. The basic necessity and the way that one need to opt for will be guided in the next posts. I will explain every aspect and will try to make the most of them clear to the readers.

Android Logo


Android Development is the reliable way to get into the S/W Development industry, a now a days when the mobile computing is on its full swings. Job opportunities are lot in this field. One can get master in Android Development by using a little bit of logical thinking. 

Friday, November 4, 2011

How to get back ubuntu panel with default icons

Once the Terminal window opens, enter the following command at the prompt:

gconftool-2 – -shutdown

(Note: There should be no spaces between the two dashes before shutdown.)

EDIT – Reader nickrud has suggested a better method instead of shutting down gconfd. Instead use the following command (thanks nickrud!)

gconftool – -recursive-unset /apps/panel

(Remember: There should be no spaces between the two dashes before shutdown.)

Then enter the next command:

rm -rf ~/.gconf/apps/panel

And enter one more command:

pkill gnome-panel

That's it!

Both top and bottom panels will appear (if missing) with their default settings. Now you can customize them to your preference and get on with using Ubuntu.

Monday, October 10, 2011

Locale Issue resolved in Postgresql

Though I developed a full fledge application in Punjabi for Complaint Management Branch of DC Office in Punjabi, but yesterday I faced a hrassing issue of POSTGRESQL. I did not know why it happened, why I was not able to resolve it yesterday?

I was testing the application yesterday on Windows , because I am making the application Cross Browser Compatible and yes OS Independent too. Thatzz why I need testing. But I faced very absurd issue, absurd so because i did it earlier and now i am not being able to understand it. Actually while Entering data in Punjabi I realized data being entering in glyph form.

At first I realized that issue might be non- rendering of Unicode by windows, so i make some changes in php files to make it work. But then i realized that something is wron with the database. I found that LC_Collate and LC_Ctype (i.e localization issue was there). So, I keep on searching and searching to change the locale (which was the main blunder I was making.)

I even changed the OS system locale and tried for that but not complete results obtained.

And Today In the evening when I was sleeping consciously, I realised that I had heard about a 'C' being used in lc_collate and lc_ctype . I kept on thinking What was that?

Then I understood that this is what i was looking for, setting lc_collation and lc_ctype to 'C' and defining encoding to UTF-8 will make you to enter any sort of language supporting unicodes.

In linux one is not going to face such issues because in that what you need to do is that.

Go, to System->Administration->Language Support.

You will see two tab . 1) Language and 2) Text

Select English(Indian) after that installing postgresql will set your database to default locale of 'en_IN' which will allow to enter hindi, punjabi, english and any language that India supports. ;-)

But it sets this to default , if you will fall in love with latin or greek some day and wants to enjoy those beautiful structure of glyph of these language in db you wont be able to do it with your predefined lc_collation.

In that case and in case of windows you have to use lc_collation and lc_ctype to be 'C'.

Not a big thing to do that just define this thing while creating database.

See some screenshot below:-

[caption id="attachment_72" align="aligncenter" width="1024" caption="LC_COLLATION and LC_CTYPE"]LC_COLLATION and LC_CTYPE[/caption]

Another image show data stored in punjabi.

[caption id="attachment_73" align="aligncenter" width="1024" caption="Punjabi Data Entered in POSTGRESQL"]Punjabi Data Entered in POSTGRESQL[/caption]

Thursday, September 29, 2011

Bank Salary Slip Generation for Payroll Management System

Today I completed, one more section of Payroll Management System and that is Generation of Bank Salary Slip. As I am making this Web Based payroll software for a contract based firm working at Trident Group, dhaula, they need an individual slip which they ll give to Bank for payment of their employees. So, I did the same.

Here is the code for the bankslip.php to generate odt
<?php
session_start();
if($_SESSION['user']!='admin') {
    header('location:../checklogin/error.php');
}
require_once('../library/odf.php');
include '../dbfiles/config.php';
class bankslip {
    private $op;
    private $query;
    public function download_slip() {
        $odf = new odf("bankslip.odt");
        if($_POST['month']!='' && $_POST['year']=='') {
            echo "<script>alert('You forgot to submit year'); window.location='bankslip.php';</script>";
        }
        elseif ($_POST['month']=='' && $_POST['year']!='') {
            echo "<script>alert('You forgot to enter month'); window.location='bankslip.php';</script>";
        }
        elseif (($_POST['month']!='' && $_POST['year']!='') && $_POST['current']!='') {
            echo "<script>alert('Hello!! I didnt told you to select all options'); window.location='bankslip.php';</script>";
        }
        elseif (($_POST['month']=='' && $_POST['year']=='') && $_POST['current']=='') {
            echo "<script>alert('Hello!! I told you to select one option'); window.location='bankslip.php';</script>";
        }
        elseif ($_POST['month']!=''&& $_POST['year']!='') {
            $this->op= 'defined';
            $month= $_POST['month'];
            $year= $_POST['year'];

        }
        elseif ($_POST['current']!='') {
            $this->op= 'current';
            $month= date('n')-1;
            $year= date('Y');
        }
        switch ($month) {
            case 1:
                $monthname= 'January';
                break;
            case 2:
                $monthname= 'February';
                break;
            case 3:
                $monthname= 'March';
                break;
            case 4:
                $monthname= 'April';
                break;
            case 5:
                $monthname= 'May';
                break;
            case 6:
                $monthname= 'June';
                break;
            case 7:
                $monthname= 'July';
                break;
            case 8:
                $monthname= 'August';
                break;
            case 9:
                $monthname= 'September';
                break;
            case 10:
                $monthname= 'October';
                break;
            case 11:
                $monthname= 'November';
                break;
            case 12:
                $monthname= 'December';
                break;
        }
        $odf->setVars('month', $monthname);
        $odf->setVars('year', $year);
        $this->query= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance, accno from workers, worker_fixeds, worker_varys, worker_acc where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and workers.id=worker_acc.id and month='$month' and year='$year'");
        $bank = $odf->setSegment('emp');
        $s=1;
        while($result= mysql_fetch_array($this->query)) {
            if(!$result) {
                header('location:qerror.php?op='.mysql_error());
            }
            $cal= sprintf('%.2f',($result['rate'])*($result['workdays']));
            $ded= $result['pf']+$result['esi']+$result['advance'];
            if($result['workdays']<20) {
                $wages= sprintf('%.2f',(($result['rate'])*($result['workdays']))+0);
                $netpay= sprintf('%.0f', ($wages-$ded));
                $total= sprintf('%.0f', ($total+$netpay));
            }
            else {
                $wages= sprintf('%.2f',(($result['rate'])*($result['workdays']))+$result['hra']);
                $netpay= sprintf('%.0f', ($wages-$ded));
                $total= sprintf('%.0f', ($total+$netpay));
            }
            $bank->s($s);
            $bank->accno($result['accno']);
            $bank->name($result['worker_fname'].' '.$result['worker_lname']);
            $bank->amount($netpay);
            $bank->merge();
            $s=$s+1;
        }
        $odf->mergeSegment($bank);
        $odf->setVars('total', $total);
        $odf->exportAsAttachedFile('Bankslip.odt');
    }
}
$bank_slip= new bankslip();
$bank_slip->download_slip();
?>

Wednesday, September 28, 2011

JOD Converter, a Great Utility for Conversion of the Documents

There is always a requirement for a programmer to be able to present the reports and all other important documents in various available formats and this was a requirement for me too. So, to add this ability to my existing and upcoming projects too, I looked upon the existing solution suitable for me. And thus after a lot of search I found a solution, a utility that will be helpful to me to perform the conversion of these files.

It is JOD COnverter. (Not a S/W purely, it is a library basically.)

JODConverter, the Java OpenDocument Converter, converts documents between different office formats. It leverages OpenOffice.org, which provides arguably the best import/export filters for OpenDocument and Microsoft Office formats available today.

JODConverter automates all conversions supported by OpenOffice.org, including

  • Microsoft Office to OpenDocument, and viceversa

    • Word to OpenDocument Text (odt); OpenDocument Text (odt) to Word

    • Excel to OpenDocument Spreadsheet (ods); OpenDocument Spreadsheet (ods) to Excel

    • PowerPoint to OpenDocument Presentation (odp); OpenDocument Presentation (odp) to PowerPoint

  • Any format to PDF

    • OpenDocument (Text, Spreadsheet, Presentation) to PDF

    • Word to PDF; Excel to PDF; PowerPoint to PDF

    • RTF to PDF; WordPerfect to PDF; ...

  • And more


    • OpenDocument Presentation (odp) to Flash; PowerPoint to Flash

    • RTF to OpenDocument; WordPerfect to OpenDocument

    • Any format to HTML (with limitations)

    • Support for OpenOffice.org 1.0 and old StarOffice formats

    • ..

Tuesday, September 27, 2011

Branch/Dept Detail entering Section for CMS

R&D is also going hand in hand with the Project Development of S/W. Today I worked on a new section for Complaint Management system. This section was of Entering new details of New Branch/Dept into the DB, to whom complaint has been not directed so far. By doing so they ll make an entry which they will going to refer late on while creating dispatch and entering complaints.

Take a look below on the section designed:-

Though Javascript validations is still to be done...

[caption id="attachment_59" align="aligncenter" width="1024" caption="Branc/Dept detail entering section"]Branc/Dept detail entering section[/caption]

Monday, September 26, 2011

PHP explode function on array

Today while working on the project of PHP-Reportica , I felt need of  applying php explode function on some php variable. Though usage of explode function was bit easy and I already used it, but this time I need to use it in much complicated way.

I was having a field with value of  selected_table_name.select_field_name. Now I had easily separated these two using function as:-

$explode_data= explode(".",  $tab_field);

Two arrays are formed now viz.  $explode_data[0] and $explode_data[1]. But issue was that first array might have redundant entries of same table names. Now, I stuck at this point, How to do it???

I find solution after about one hour spending one this thing. I came to know about a PHP function called unique array which removes redundant entries from an array.  Here below is what I needed:-
 foreach ($_POST['selfield'] as $mystring) {
$rs=explode(",",$mystring);
$first[]= $rs[0];
}
$uniqtab= array_unique($first);
$count= count($uniqtab);
$i=0;
foreach ($uniqtab as $table){
    echo $table;
     if ($i < ($count - 1)) {
      echo ', ';
   }
   $i=$i+1;
}

Friday, September 23, 2011

Salary Slip Generation for Payroll System

Today I am Done with generation of salary slip for Workers in Payroll Management System. for the time I am done with only the phase of downloading complete slips for every employee.

Here Below is snapshot:-

[caption id="attachment_45" align="aligncenter" width="1024" caption="Salary Slip Generation"]Salary Slip Generation[/caption]

And below is the Complete Coding for Generating the Odt file
<?php
require_once('../library/odf.php');
include_once '../dbfiles/config.php';
class salaryslip {
private $query= array();
private $result= array();
private $calsal;
private $acc;
private $ded;
private $totwages;
private $netpay;
private $month;
public function slip() {
$odf = new odf("slip.odt");
$article = $odf->setSegment('articles');
$this->month= date('n')-1;
if($_GET['op']=='comp') {
$this->query[0]= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance, accno from workers, worker_fixeds, worker_varys, worker_acc where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and workers.id=worker_acc.id and month='$this->month'");
if(!$this->query[0]) {
header('location:qerror.php?op=uperror');
}
while($this->result[0]=mysql_fetch_array($this->query[0])) {
$comp_name= $this->result[0]['worker_fname'].' '.$this->result[0]['worker_lname'];
$this->ded=($this->result[0]['pf']+$this->result[0]['esi']+$this->result[0]['advance']);
$article->name($comp_name);
$article->accno($this->result[0]['accno']);
$article->ecode($this->result[0]['id']);
$article->basic($this->result[0]['gross']);
$article->days($this->result[0]['workdays']);
$this->calsal= sprintf('%.2f',($this->result[0]['rate'])*($this->result[0]['workdays']));
$article->calsal($this->calsal);
if($this->result[0]['workdays']<20) {
$article->hra('0');
$this->totwages=sprintf('%.2f',($this->calsal)+0);
$article->total($this->totwages);
}
else {
$article->hra($this->result[0]['hra']);
$this->totwages=sprintf('%.2f',($this->calsal)+$this->result[0]['hra']);
$article->total($this->totwages);
}
$article->pf($this->result[0]['pf']);
$article->esi($this->result[0]['esi']);
$article->advance($this->result[0]['advance']);
$article->totalded($this->ded);
$this->netpay= sprintf('%.2f',($this->totwages)-($this->ded));
$article->netpay($this->netpay);
$article->merge();
}
}
$odf->mergeSegment($article);
$odf->exportAsAttachedFile('CompleteSlip.odt');
}
}
$sh= new salaryslip();
$sh->slip();
?>

Thursday, September 22, 2011

Total For Final Salary sheet of Project

One thing which I forgot was total of each field  i.e gross, hra, cal salary, total wages, pf, esi etc. What I did, I declared an array named total in class finalsheet of page salarysheet.php

So Code Snippet got modified as below:-
<?php class finalsheet{
private $query= array();
private $result= array();
private $total= array();
private $calsal;
private $ded;
private $totwages;
private $netpay;
private $month;
public function seedata(){
$this->total[1]=0;
$this->total[2]=0;
$this->total[3]=0;
$this->total[4]=0;
$this->total[5]=0;
$this->total[6]=0;
$this->total[7]=0;
$this->total[8]=0;
$this->total[9]=0;
$this->total[10]=0;
$this->total[11]=0;
$this->month= date('n')-1;
$this->query[0]=mysql_query("Select id from worker_varys where month='$this->month'");
$count= mysql_num_rows($this->query[0]);
if($count==0){
echo "<script>var check= confirm('No data for updation');
if(check==true){
window.location='newsheet.php';}
else{
window.location='adminhome.php';}
</script>";
}
else{
$this->query[1]= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance from workers, worker_fixeds, worker_varys where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and month='$this->month'");
if(!$this->query[1]){
header('location:qerror.php?op=uperror');
}
$this->i=1;
while($this->result[2]=mysql_fetch_array($this->query[1])){
if(($this->i)%2==0){
echo "<tr>";
}
else{
echo "<tr>";
}
echo "<input type='hidden' name=id[] value=".$this->result[2]['id']." />";
echo "<td>".$this->i."</td>";
echo "<td style='width:120px;'>".$this->result[2]['worker_fname'].' '.$this->result[2]['worker_lname']."</td>";
echo "<td>".$this->result[2]['gross']."</td>";
echo "<td>".$this->result[2]['rate']."</td>";
echo "<td>".$this->result[2]['workdays']."</td>";
$this->calsal= sprintf('%.2f',($this->result[2]['rate'])*($this->result[2]['workdays']));
echo "<td>".$this->calsal."</td>";
if($this->result[2]['workdays']<20){
echo "<td>0</td>";
$this->total[5]= sprintf('%.2f', ($this->total[5]) + 0);
$this->totwages=sprintf('%.2f',($this->calsal)+0);
echo "<td>".$this->totwages."</td>";
}
else{
echo "<td>".$this->result[2]['hra']."</td>";
$this->total[5]= sprintf('%.2f', ($this->total[5]) + ($this->result[2]['hra']));
$this->totwages=sprintf('%.2f',($this->calsal)+$this->result[2]['hra']);
echo "<td>".$this->totwages."</td>";
}
echo "<td>".$this->result[2]['pf']."</td>";
echo "<td>".$this->result[2]['esi']."</td>";
echo "<td>".$this->result[2]['advance']."</td>";
$this->ded=($this->result[2]['pf']+$this->result[2]['esi']+$this->result[2]['advance']);
echo "<td>".$this->ded."</td>";
$this->netpay= sprintf('%.2f',($this->totwages)-($this->ded));
echo "<td>".$this->netpay."</td>";
$this->total[1]= $this->total[1] + $this->result[2]['gross'];
$this->total[2]= sprintf('%.2f', ($this->total[2]) + ($this->result[2]['rate']));
$this->total[3]= sprintf('%.2f', ($this->total[3]) + ($this->result[2]['workdays']));
$this->total[4]= sprintf('%.2f', ($this->total[4]) + ($this->calsal));
$this->total[6]= sprintf('%.2f', ($this->total[6]) + ($this->totwages));
$this->total[7]= sprintf('%.2f', ($this->total[7]) + ($this->result[2]['pf']));
$this->total[8]= sprintf('%.2f', ($this->total[8]) + ($this->result[2]['esi']));
$this->total[9]= sprintf('%.2f', ($this->total[9]) + ($this->result[2]['advance']));
$this->total[10]= sprintf('%.2f', ($this->total[10]) + ($this->ded));
$this->total[11]= sprintf('%.2f', ($this->total[11]) + ($this->netpay));
echo "</tr>";
$this->i=$this->i+1;
}
echo '<tr><td colspan="2" align="right" style="font-size:medium;">Total
</td>';
echo '<td>'.$this->total[1].'</td>';
echo '<td>'.$this->total[2].'</td>';
echo '<td>'.$this->total[3].'</td>';
echo '<td>'.$this->total[4].'</td>';
echo '<td>'.$this->total[5].'</td>';
echo '<td>'.$this->total[6].'</td>';
echo '<td>'.$this->total[7].'</td>';
echo '<td>'.$this->total[8].'</td>';
echo '<td>'.$this->total[9].'</td>';
echo '<td>'.$this->total[10].'</td>';
echo '<td>'.$this->total[11].'</td></tr>';
}
}
}
$sh= new finalsheet();
$sh->seedata();
?>
And Below is the screen shot of fields that get total. It is clearly visible total being performed at last row.

[caption id="attachment_41" align="aligncenter" width="1024" caption="Total of Every Field of Salary sheet"][/caption]

Wednesday, September 21, 2011

Field Listing Section of First Part of Reporting Tool

The day quite went tough as I had to struggle a lot while outputting the Field list on each selection of table via AJAX in Reporting Tool Project. But as is said, "All Well that Ends Well". Same happened with me. After doing so much struggle, I was able to resolve the issues.

Continuing to the previous Post's code,

If user selects the table, (I am showing a code snippet)

index.php
<h2><span>Please Select the </span>Credentials</h2><br/>
<form>
<label>Select The Table</label>
<?php
include_once 'config.php';
if($op=='mysql'){

}
elseif ($op=='postgresql') {
$query=pg_query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';");
echo '<select name="table" onchange="return showfield(this.value);">';
while($result=pg_fetch_array($query)){
echo'<option value="'.$result['table_name'].'">'.$result['table_name'].'</option>';
}
}
echo '</select>';
?>
</form>

After that is shown

ajax.js
function showfield(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("result").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","showfield.php?table="+str,true);
xmlhttp.send();
}

This above ajax.js script which is issuing an ajax call for every selection of new table from the list.

and after that is

showfield.php
<?php
include_once 'config.php';
$t=$t.$_GET['table'];
$query= pg_query("SELECT column_name FROM information_schema.columns WHERE table_name ='$t';");
echo '<table border=1>';
echo '<tr><th colspan="5">Select Field</th></tr><tr>';
$i=1;
while($result=pg_fetch_array($query)){
echo '<td><input type="checkbox" name="field[]" value="'.$result['column_name'].'"/>'.$result[column_name].'</td>';
$i=$i+1;
if($i>5){
echo '</tr><tr>';
$i=1;
}
}
echo '</tr><tr><td colspan="5"><input type="submit" value="Enter fields" onclick="enterfield();" /></td>';
echo '<td colspan="5"><input type="submit" value="Clear Selected Fields" onclick="clear();" /></td></tr>';
echo '</table>';
?>

Which will List the all fields for a table. On the Selection of which and after submission will added to another table and user will again allowed to check whether they are sure to opt for all these fields. So Next Task after this will be Selection of Fields and Confirmation and Submission for Query Generation.

Tuesday, September 20, 2011

UML Diagram of Payroll System

Today I completed the Basic Functionality of Payroll Management System. Here Below is the UML Diagram for Payroll Management System. R&D of both projects Complaint Management system and Payroll Management System will go hand in hand.

[caption id="attachment_33" align="aligncenter" width="1024" caption="UML Diagram of Payroll system"][/caption]

Monday, September 19, 2011

Selection of Formatting Logic

Logic Behind Generating is query is clearly visible in my mind, but I was stuck with the thing that how I am going to display the O/P in which format and that too importanly how???  So Brainstorming begins and along with that searching too, so as to collect some information about Formatting of Reports. But I did not work. so Whole Day went in thinking about the formatting. Hope fully tomorrow I will get the solution

Friday, September 16, 2011

Table Listing in Reporting tool Project

So, Today I started first with preparing Front End page for Selecting out which Tables of  database you want to work on. While Selecting a table you will be prompted to select the Fields, from which you have to select the fields for your query.  Ok Leave it this          is the next part of phase 1.

Below is the code discussed which is front end and will show you the each and every table of selected database:-

index.php
<html lang="en">
<head>
<script class="jsbin" src="jquery.min.js"></script>
<meta charset="utf-8" />
<link href="tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="tablecloth/tablecloth.js"></script>
<script type="text/javascript" src="myscript.js"></script>
<script type="text/javascript">
var t = new ScrollableTable(document.getElementById('myScrollTable'), 150,250);
</script>

<title></title>
<script>
function showfield()// jQuery Function
{
var name = $("input[name='table']:checked").val();
jQuery.ajax({
url:'showfield.php',
type:"POST",
data: { clientdata : name },
success:function(data){ document.getElementById("result").innerHTML= data;}
});
return false;
}
</script>
<script>
function enterfield()// jQuery Function
{
var Selected = new Array();
jQuery("input[name='field[]']:checked").each(function(){
Selected.push(jQuery(this).val());
});

jQuery.ajax({
url:'enterfield.php',
type:"POST",
data: { clientdata : Selected },
success:function(data){ document.getElementById("enterfield").innerHTML= data;}
});
return false;
}
</script>
</head>
<body>
<form>
<table style="margin-left: auto; margin-right: auto;" id="myScrollTable">
<tr>
<th>
Select Table
</th>
</tr>
<?php
include_once 'config.php';
if($op=='mysql'){

}
elseif ($op=='postgresql') {
$query=pg_query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';");
/*Above Query retrieve table names from selected database in config.php */ 
while($result=pg_fetch_array($query)){
echo'<tr><td>';
echo'<input type="radio" name="table" value="'.$result['table_name'].'"onclick="showfield();" />'.$result['table_name'].'</td>';
echo '</tr>';
}
}
?>
</table>
</form>
<div id="result">

</div>
<div id="enterfield">

</div>
<p><tt id="results"></tt></p>
</body>
</html>

After That is the showfield.php from which fields for table are displayed for every click on radio button of table
showfield.php
<?php
include_once 'config.php';
$t= $_POST['clientdata'];
$query= pg_query("SELECT column_name FROM information_schema.columns WHERE table_name ='$t';");
echo '<table>';
echo '<tr><th>Select Field</th></tr>';
while($result=pg_fetch_array($query)){
echo '<tr><td><input type="checkbox" name="field[]" value="'.$result['column_name'].'" onclick="enterfield();"/>'.$result[column_name].'</td></tr>';
echo'</br>';
}
echo '</table>';
?>

Thursday, September 15, 2011

Reporting Tool for PHP

Today I am over to my 3rd project that is the Reporting tool for PHP. As far as DIO Sir searched and also I searched we had not found any suitable tool for PHP to generate automatic reports on the basis of queries that are being generated. Those We found are not FOSS and which are FOSS were not living upto our expectations.

So An anlaysis started today regarding Generation of PHP Reporting Tool.

I divided it into 3 sections as per as following:-

  1. Dynamic Query Generation

  2. Display Formatted Report (preferably in Doc) on the basis of user selection of Fields formatting

  3. Final PHP code generated which is report code and can be integrated with the project


So I will work on these phases one by one. And Regarding the Feasibility of this Project, This Project is quite feasible but being feasible it is quite time consuming. Because I need to work a lot on the formatting of reports.

Wednesday, August 17, 2011

Reporting in Complaint Management System

Today I did the last remaining job of the Complaint Management System Project, and that was the issue of Reporting. Few days earlier I got stuck regarding choosing the proper reporting tool. But then mind moved on to the my oldy friend ODTPHP and ya it's true, old is gold it would never cheat. ODTPHP made me happy and did what I wanted. But a bit stress on my mind was also put upon by me as I was not able to find any suitable o/p from googling. The feature that I was looking for in ODTPHP was that I had to insert a separate segment in a cell of every row of column. In short I need to do this:-

$odf= new odf("report.php");

$article= $odf->setSegment('complaint');

while(some cond){

$article->dispatch->setVars();

}