Thursday, December 11, 2014

Object Oriented Programming in PHP

One of the most popular web scripting language now a days in PHP formerly known as Personal Home Page as a developer this programming language one of my favorite in building different types of application from website to business applications on wide variety on clients. In this article I would like to share with you my experience in writing object oriented programming in PHP.

At first learning how to program in object oriented is quiet focusing if you have trained in procedural programming also known as structured programming. In object oriented programming we start in declaring a class which acts as blue print of our object. In our class we declare public variable that we will use are attributes or properties of our object and then after that we create our methods also know as behavior that will carry out the actions of our class. In this example I wrote a a class math and then I declare two variables as public variable which means I can use this two variables outside of my class. In PHP 5 we use the keyword  __construct which allows us to pass parameters in our function solve as our method in our class. 

We later create an object that will inherit the attributes and methods of our class math I called our object product. As you observe I am also using a keyword $this this keyword in PHP act as a pointer to pointing the attributes we have in our class in this case our attributes are $val1 and $val2. After which I create a function to perform the multiplication of the two value that we pass in our function parameters. I called the function named solve() this function will not only perform multiplication operation but also display the computed result on our web page.

public function solve() {
$sum = ($this->val1 * $this->val2);
echo "The product of " .$this->val1. " and " 
    .$this->val2. " is " .$sum.".";
}


To create an object I used the follow commands   $product = new math(2,4);  and I also pass two values to be multiplied by our function. Take note we know that we create an object by using the new statement in PHP. After which we display the result in our web page by declaring the following statements below.

echo "<h1> <font color='green'>"; echo $product->solve(); echo "</h1> </font>";   


I hope this object oriented programming article that I wrote will give you some insights how to write object oriented program using PHP as your programming language. The benefits of learning object oriented programming in PHP is very significant you can make your code must easier to write, maintain and most important you can easy learn how to use PHP framework like Zend, CakePHP, CodeIgniter and Symfony because this frameworks are written in object oriented way.

If you have some questions about my works feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

People here in the Philippines who wish to contact me can reach me in my mobile numbers 09173084360 and 09993969756.


Sample Output of Our Program


Program Listing

<?php class math { public $val1, $val2; public function __construct($val1, $val2 ) 
{
$this->val1 = $val1; $this->val2 = $val2;
}
public function solve()
{ $sum = ($this->val1 * $this->val2);
echo "The product of " .$this->val1. " and " .$this->val2. " is " .$sum.".";
}
} $product = new math(2,4); echo "<h1> <font color='green'>"; echo $product->solve(); echo "</h1> </font>";
?>


Worker's Payroll System Using JavaScript

In this article I would like to share with you a program that is being developed and presented to me by my student we called this program workers payroll system written in Javascript. Before I publish this code I ask permission from them if they allow me to share their work to other people specially students that are new in Javascript and they yes to here is it. 

The following are my student contribute in writing this program JB Vie C. Busaing,  Maricar S. Conde, John Paul C. Divinagracia, Nylre Jel C. Ortega, Krisha Carey L. Ureta and  Arvel B. Vergara.

What this program will do is to compute the net pay of the employee in the company after all the deductions like tax, cash advances, pagibig and many other deductions. The deductions are based here in the Philippines.

I you have some questions regarding to our work you can send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.





Sample Output of Our Program



Wednesday, December 10, 2014

Payroll System With Payslip Generator in C++

In this article I would like to share with you Payroll System with Payslip Generator that I wrote for a client before using C++ as my programming language what is good about this program it has a login system and a payroll system that will ask the user to enter the time in and time out of employee in a week of work and it generates reports by the end of the computation process. I hope you will find my work useful in your learning in C++ programming. 

I hope you will find my work useful and beneficial in your quest to learn object oriented programming in PHP and MySQL. If you have some questions about my works feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

People here in the Philippines who wish to contact me can reach me in my mobile numbers 09173084360 and 09993969756.

Thank you very much and Happy Programming.




Sample Output of Our Program

Program Listing

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <conio.h>

using namespace std;
int some (string s){
    istringstream buffer(s);
    int some_int;
    buffer>>some_int;
    return some_int;
}

 int start();

main() {
     char pass2[20],user[20];
        char ch;
        // Admin Account
        int pass=0,user2=0;
        // User Account
        int pass1=0,user1=0;
        // Employee Account
        int pass3=0,user3=0;

     do {
         system("cls");
         cout << "\t \n =====================================";
         cout << "\t \n          PASSWORD SECURITY             ";
         cout << "\t \n =====================================";
         cout << "\n\n";
         cout << "\t Enter User Name     : ";
         cin >> pass2;
         cout << "\t Enter your Password : ";
         cin >> user;

        // Admin Account
        user2=strcmp(pass2,"admin");
        pass=strcmp(user,"admin");


       // User Account
        user1=strcmp(pass2,"user");
        pass1=strcmp(user,"user");


      // Employee Account
        user3=strcmp(pass2,"emp");
        pass3=strcmp(user,"emp");


         // For Admin Account

        if (pass==0 && user2==0) {
            cout << "\t \n Welcome to the System! Administrator";
            cout << "\n\n";
            start();
         }

         // For user account
        if (pass1==0 && user1==0) {
            cout << "\t \n Welcome to the System! Users";
            cout << "\n\n";
            start();
         }

         // For Employee account
        if (pass3==0 && user3==0) {
            cout << "\t \n Welcome to the System! Employees";
            cout << "\n\n";
            start();
         }


         else {
            cout << "\t \n Intruder Detected Try Again.";
            cout << "\n\n";
           system("pause");
        }

     } while (pass != 0 && user2!=0 || pass1!=0 && user1!=0
              || pass3==0 && user3==0);
       cout << "\n\n";
       system("pause");
}

int start() {

    ofstream output ("dtr.txt", ios::app);
    ofstream payslip ("payslip.txt", ios::app);
    ifstream read_file ("employee.txt");

    string id, display;
    string day[]= {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
    string time_in[5], time_out[5];
    int time_in_conversion[5], time_out_conversion[5];
    int lunch_break = 1;
    int total_hrs = 0;
    float sss =0.00;
    float pilhealth= 0.00,widtax= 0.00,pagibig = 0.00;

    float net_income =0.00, gross_income=0.00;
    float  gsis = 0.00;
    float  rate_per_hr ;
    float tax = 0.00;
    int regular_time;
    float deduction = 0.00;

    cin.ignore();
    cout<<"Enter employee id: ";
    getline(cin, id);
   output << "\n";
   output << id << setw(3) << ":";
    while (!read_file.eof()){

        getline(read_file, display);

        if (id==display){

            cout<<"Welcome Employee No : "<<id << setw(10);
            getline (read_file, display);
            cout << "\n\n";
            cout<<setw(5) <<"Name          : " << setw(2) << display<<endl;
            payslip << "\n";
            payslip<<"Name        : "<<setw(2) <<display<<endl;
            getline (read_file, display);
            cout<<setw(8) <<"Position       : " << setw(2) << display<<endl;
            payslip<<"\nPosition    : "<<setw(2) <<display <<endl;
            getline (read_file, display);
            cout<<setw(10) <<"Department   : " << setw(2) << display<<endl;
            payslip<<"\nDepartment  : "<<setw(2)<< display<<endl;


            for (int a = 0; a<5 ; a++){
            cout << "\n";
          cout <<setw(5) << day[a];
            cout << "\n";
            cout<<"\tTime in: ";
            cin>>time_in[a];


            cout<<"\tTime out: ";
            cin>>time_out[a];

            output<<  day[a] << setw(8);
            output<<setw(6) << time_in[a] <<"AM"<< "-";
            output<<setw(4) <<time_out[a]<<"PM ";

            time_in_conversion[a] = some (time_in[a]);
            time_out_conversion[a] = some (time_out[a]);

            total_hrs +=((time_out_conversion[a] - time_in_conversion[a])-lunch_break);
            cout<<"\n\tTotal Hours: "<<total_hrs;
            }



cout<<"\n\t Total Worked Hours: "<<total_hrs;

cout<<"\n\t Enter rate per hour: ";
cin>>rate_per_hr;
cout<<"\n\t Enter SSS : ";
cin>>sss;
cout<<"\n\t Enter PagIBIG : ";
cin>>pagibig;
cout<<"\n\t Enter Philhealth: ";
cin>>pilhealth;
cout<<"\n\t Enter Withholding tax: ";
cin>>widtax;

    gross_income = total_hrs*rate_per_hr;
    net_income = gross_income - (pilhealth+widtax+pagibig+sss);
    deduction =(pilhealth+widtax+pagibig+sss);
cout << setprecision(2) << fixed;
cout<<"\nRate per hour       : Php "<<rate_per_hr;
cout<<"\nGross Income        : Php "  <<gross_income;
cout<<"\nTotal deductions    : Php " <<deduction;
cout<<"\nNet Income          : Php "    <<net_income;
payslip << setprecision(2) << fixed;
payslip<<"\n***********Deductions*************";
payslip<<"\n\nSSS            : Php "<<sss;
payslip<<"\nPhilhealth       : Php "<<pilhealth;
payslip<<"\nPagIBIG          : Php "<<pagibig;
payslip<<"\nWitholding tax   : Php "<<widtax;
payslip<<"\n__________________________________";
payslip<<"\n          total  : Php "<<deduction<<endl;
payslip<<"\n\nGross pay      : Php "<<gross_income;
payslip<<"\n Net Income     : Php " <<net_income;
payslip<<"\n\n";
payslip<<"\n*******************************";
output<<"\nTotal hours: "<<total_hrs;
output<<"\n";

output.close();
payslip.close();
    }


    }
cout << "\n\n";
system("pause");
}



Product File Maintenance System in Visual Basic 6

This is another application that is being shared by my close friend Mr. Dave R. Marcellana he called this program Product File Maintenance System in Visual Basic 6 it is a module for his Point of Sale System that we previously published in our website. What is good about this program it will show how to create a basic CRUD application using Visual Basic 6. When we say CRUD it stands for create, retrieve, update and delete of records from our database in this case Dave using Microsoft Access to store all the information to the table. 

I hope you will find the work of  Dave useful in your learning how to create a database application using Microsoft Visual Basic 6 and Microsoft Access.

If you have some questions about our work feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. I will be happy to read all your emails and suggestions how I can improve my works in programming.

People here in the Philippines who wish to contact me can reach me at my mobile numbers 09173084360 and 09993969756.

Thank you very much and Happy Productive Programming.


Sample Output of Our Program


Decimal To Binary Converter in C++

In this article I would like to share with you a sample program that I wrote in my spare time I called this program Decimal To Binary Converter 1.0 in C++. What does the program will to is to ask the user to enter any integer value and then it will convert into its binary equivalent. The code is very easy to understand and can be used in your programming assignments and activities in C++ programming. In this program I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler. All this software is freely available over the Internet free to download and use.

If you have some questions about my work feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. I will be happy to read all your emails and suggestions how I can improve my works in programming.

People here in the Philippines who wish to contact me can reach me at my mobile numbers 09173084360 and 09993969756.

Thank you very much and Happy Productive Programming.



Sample Output of Our Program

Program Listing

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    char reply;
   do {
    int decimal_number=0, quotient=0;
    int binary_number[100],a=1,b=0;

    system("COLOR 9A");
    cout << "\n";
    cout << "\t================================\n";
    cout << "\tDecimal To Binary Converter 1.0\n";
    cout << "\t================================\n";
    cout << "\n";
    cout <<"Please Enter Any Decimal Number :=> ";
    cin >> decimal_number;

    quotient = decimal_number;

    while(quotient!=0){
        binary_number[a++]= quotient % 2;
        quotient = quotient / 2;
    }

    cout << "The Binary Value of Decimal Number is "
        <<decimal_number << ". => ";
    for(b = a-1 ; b>0; b--) {
    cout << binary_number[b];
    }
   cout << "\n\n";
  cout << "Do you want to continue y/n : ";
  cin >> reply;
   } while(reply=='Y' || reply=='y');
   cout << "\n\n";
   cout << "\t Thank You For Using This Software.";
   cout << "\n\n";
   system("pause");
}



Tuesday, December 9, 2014

Addition of Numbers in PHP Using OOP

As I try to improve my programming skills in PHP I modify my previous code and converted it into Object Oriented Programming approach. This program is very simple application that will ask the user to enter three numbers and find the total sum of the three numbers. I will give the user a chance to clear the text box using the clear button.

The things that you can learn in this sample program it will introduce you will the concept of object oriented programming by creating a class, creating an object and using the attributes like the variables we declare and the use of behavior or method to carry out the addition of the three numbers. I use Twitter Bootstrap CSS framework to improve the appearance of the web page. I make this program very simple to understand and use for beginners that are new in PHP programming and object oriented approach in PHP.

If you have some questions about my work feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. I will be happy to read all your emails and suggestions how I can improve my works in programming.

People here in the Philippines who wish to contact me can reach me at my mobile numbers : 09173084360 and 09993969756.

Thank you very much and Happy Productive Programming.



Sample Output of Our Program

Program Listing

header.php

<head>
<title> Addition of Numbers in OOP </title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<style type="text/css">
#wrapper {
margin: 0 auto;
float: none;
width:70%;
}
.header {
padding:10px 0;
}
.title {
padding: 0 5px 0 0;
float:left;
margin:0;
}
.container form input {
height: 30px;
}
</style>
</head>
<body>
<div id="wrapper">
<div class="header">
<h3 class="title"> Addition of Numbers Using OOP</h3>
<br>
</div>

index.php

<html>
<body>
<?php include 'template-parts/header.php' ?><br>
<?php 
class find_sum {
    private $val1 , $val2, $val3;
    public function __construct($val_1, $val_2, $val_3){
        $this->val1 = $val_1;
        $this->val2 = $val_2;
$this->val3 = $val_3;
    }
    public function add(){
       return $this->val1 + $this->val2 + $this->val3;
    }
}
?>
<div class="container home">
<?php
    $value1 = $_POST['num1'];
    $value2 = $_POST['num2'];
$value3 = $_POST['num3'];
    if(isset($_POST['solve']))
    {
        $add_calc = new find_sum($value1,$value2,$value3);    
$result = "The total sum of $value1, $value2 
         and $value3 is ".$add_calc->add().".";
    }
if (isset($_POST['clear']))
{
$value1=""; $value2=""; $value3="";
$holder=""; $result="";
}
?>
<form action="index.php" method="post">
<font size="4">
<label> Enter First Number: </label>
<input type="text" placeholder="first number"  name="num1" value="<?php echo $value1; ?>" />
<br />
<label> Enter Second Number: </label>
<input type="text" placeholder="second number"  name="num2" value="<?php echo $value2; ?>"  />
<br />
<label> Enter Third Number: </label>
<input type="text" placeholder="third number"  name="num3" value="<?php echo $value3; ?>"  />
<br /> </font>
<input type="submit" name="solve" value="Compute"
 title="Click here to find the total sum." class="btn btn-info">
<input type="submit" name="clear" value="Clear"
 title="Click here to clear text box." class="btn btn-info">
</form>
<?php
echo "<br>";
echo "<font size='5'>";
echo $result;
echo "</font>";
?>
</div>
</body>
</html>

Monday, December 8, 2014

Users Address Book in PHP and MySQL Using OOP

Hi there In this article I would like to share with you an application that I wrote using PHP and MySQL using object oriented programming approach. Most of the database applications that I developed through the years in PHP and MySQL is written in structured or procedural format. One of the benefits of object oriented approach in programming particularly in PHP and MySQL is that our application is becomes more easier to maintain, update compared to structured approach. Object oriented programming is design for large scale software development that more developers or programmers involved.

 I called this program Users Address Book it allows the user to add, edit and update information of the person about this address,mobiles numbers and other important information related to the person. It introduces the beginners in object oriented approach on how to create and object and use it effectively in writing a database application in PHP and MySQL.

I hope you will find my work useful and beneficial in your quest to learn object oriented programming in PHP and MySQL. If you have some questions about my works feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

People here in the Philippines who wish to contact me can reach me in my mobile numbers 09173084360 and 09993969756.

Thank you very much and Happy Programming.



Main Page of Our Program


Add of Record Page


After we save the record it will return to main page


Update of Record Page


Saturday, December 6, 2014

Point of Sale System in Visual Basic 6

In this article I would like to share with you an application that is written by a friend of mine named Mr. Dave R. Marcellana. This fellow is a close friend of mine he is also a programmer just like me I ask him if he can share some of his codes to us and he agree to share his Point of Sale System written entirely in Microsoft Visual Basic 6 and Microsoft Access.

This system is very useful in small and medium businesses just like a retail store or a small supermarket. It can track down daily sales, generate reports and perform of inventory of stocks that makes running a business is a breeze and efficient.

If you have some questions about this application your can send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much and Happy Productive Programming.










Sample Output of Our Program