<?php
/*
*
* -------------------------------------------------------
* CLASSNAME:        client_org
* GENERATION DATE:  03.01.2014
* FOR MYSQL TABLE:  client_org
* FOR MYSQL DB:     web-school
* -------------------------------------------------------
* CODE GENERATED BY:
* PHP-MYSQL-CLASS GENERATOR
* -------------------------------------------------------
*
*/

include_once("class.database.php");

// **********************
// CLASS DECLARATION
// **********************

class client_org
{ // class : begin


// **********************
// ATTRIBUTE DECLARATION
// **********************

var $id;   // KEY ATTR. WITH AUTOINCREMENT

var $admin_id;   // (normal Attribute)
var $school_name;   // (normal Attribute)
var $contact_person;   // (normal Attribute)
var $contact_email;   // (normal Attribute)
var $phone_number;   // (normal Attribute)
var $address;   // (normal Attribute)
var $pb_no;   // (normal Attribute)
var $mobile;   // (normal Attribute)
var $fax;   // (normal Attribute)
var $sms_credict;   // (normal Attribute)
var $email_credict;   // (normal Attribute)
var $created_date;   // (normal Attribute)
var $updated_date;   // (normal Attribute)
var $package_start_date;   // (normal Attribute)
var $daily_agenda;   // (normal Attribute)
var $start_date;   // (normal Attribute)
var $end_date;   // (normal Attribute)
var $attendance_type;   // (normal Attribute)
var $language;   // (normal Attribute)
var $timezone;   // (normal Attribute)
var $country;   // (normal Attribute)
var $currency_type;   // (normal Attribute)
var $logo;   // (normal Attribute)
var $grading_type;   // (normal Attribute)
var $user_key;   // (normal Attribute)
var $status;   // (normal Attribute)

var $database; // Instance of class database


// **********************
// CONSTRUCTOR METHOD
// **********************

function client_org()
{

$this->database = new Database();

}


// **********************
// GETTER METHODS
// **********************


function getid()
{
return $this->id;
}

function getadmin_id()
{
return $this->admin_id;
}

function getschool_name()
{
return $this->school_name;
}

function getcontact_person()
{
return $this->contact_person;
}

function getcontact_email()
{
return $this->contact_email;
}

function getphone_number()
{
return $this->phone_number;
}

function getaddress()
{
return $this->address;
}

function getpb_no()
{
return $this->pb_no;
}

function getmobile()
{
return $this->mobile;
}

function getfax()
{
return $this->fax;
}

function getsms_credict()
{
return $this->sms_credict;
}

function getemail_credict()
{
return $this->email_credict;
}

function getcreated_date()
{
return $this->created_date;
}

function getupdated_date()
{
return $this->updated_date;
}

function getpackage_start_date()
{
return $this->package_start_date;
}

function getdaily_agenda()
{
return $this->daily_agenda;
}

function getstart_date()
{
return $this->start_date;
}

function getend_date()
{
return $this->end_date;
}

function getattendance_type()
{
return $this->attendance_type;
}

function getlanguage()
{
return $this->language;
}

function gettimezone()
{
return $this->timezone;
}

function getcountry()
{
return $this->country;
}

function getcurrency_type()
{
return $this->currency_type;
}

function getlogo()
{
return $this->logo;
}

function getgrading_type()
{
return $this->grading_type;
}

function getuser_key()
{
return $this->user_key;
}

function getstatus()
{
return $this->status;
}

// **********************
// SETTER METHODS
// **********************


function setid($val)
{
$this->id =  $val;
}

function setadmin_id($val)
{
$this->admin_id =  $val;
}

function setschool_name($val)
{
$this->school_name =  $val;
}

function setcontact_person($val)
{
$this->contact_person =  $val;
}

function setcontact_email($val)
{
$this->contact_email =  $val;
}

function setphone_number($val)
{
$this->phone_number =  $val;
}

function setaddress($val)
{
$this->address =  $val;
}

function setpb_no($val)
{
$this->pb_no =  $val;
}

function setmobile($val)
{
$this->mobile =  $val;
}

function setfax($val)
{
$this->fax =  $val;
}

function setsms_credict($val)
{
$this->sms_credict =  $val;
}

function setemail_credict($val)
{
$this->email_credict =  $val;
}

function setcreated_date($val)
{
$this->created_date =  $val;
}

function setupdated_date($val)
{
$this->updated_date =  $val;
}

function setpackage_start_date($val)
{
$this->package_start_date =  $val;
}

function setdaily_agenda($val)
{
$this->daily_agenda =  $val;
}

function setstart_date($val)
{
$this->start_date =  $val;
}

function setend_date($val)
{
$this->end_date =  $val;
}

function setattendance_type($val)
{
$this->attendance_type =  $val;
}

function setlanguage($val)
{
$this->language =  $val;
}

function settimezone($val)
{
$this->timezone =  $val;
}

function setcountry($val)
{
$this->country =  $val;
}

function setcurrency_type($val)
{
$this->currency_type =  $val;
}

function setlogo($val)
{
$this->logo =  $val;
}

function setgrading_type($val)
{
$this->grading_type =  $val;
}

function setuser_key($val)
{
$this->user_key =  $val;
}

function setstatus($val)
{
$this->status =  $val;
}

// **********************
// SELECT METHOD / LOAD
// **********************

function select($id)
{

$sql =  "SELECT * FROM client_org WHERE id = $id;";
$result =  $this->database->query($sql);
$result = $this->database->result;
$row = mysql_fetch_object($result);


$this->id = $row->id;

$this->admin_id = $row->admin_id;

$this->school_name = $row->school_name;

$this->contact_person = $row->contact_person;

$this->contact_email = $row->contact_email;

$this->phone_number = $row->phone_number;

$this->address = $row->address;

$this->pb_no = $row->pb_no;

$this->mobile = $row->mobile;

$this->fax = $row->fax;

$this->sms_credict = $row->sms_credict;

$this->email_credict = $row->email_credict;

$this->created_date = $row->created_date;

$this->updated_date = $row->updated_date;

$this->package_start_date = $row->package_start_date;

$this->daily_agenda = $row->daily_agenda;

$this->start_date = $row->start_date;

$this->end_date = $row->end_date;

$this->attendance_type = $row->attendance_type;

$this->language = $row->language;

$this->timezone = $row->timezone;

$this->country = $row->country;

$this->currency_type = $row->currency_type;

$this->logo = $row->logo;

$this->grading_type = $row->grading_type;

$this->user_key = $row->user_key;

$this->status = $row->status;

}





// **********************
// DELETE
// **********************

function delete($id)
{
$sql = "DELETE FROM client_org WHERE id = $id;";
$result = $this->database->query($sql);

}

// **********************
// INSERT
// **********************

function insert()
{
$this->id = ""; // clear key for autoincrement

$sql = "INSERT INTO client_org ( admin_id,school_name,contact_person,contact_email,phone_number,address,pb_no,mobile,fax,sms_credict,email_credict,created_date,updated_date,package_start_date,daily_agenda,start_date,end_date,attendance_type,language,timezone,country,currency_type,logo,grading_type,user_key,status ) VALUES ( '$this->admin_id','$this->school_name','$this->contact_person','$this->contact_email','$this->phone_number','$this->address','$this->pb_no','$this->mobile','$this->fax','$this->sms_credict','$this->email_credict','$this->created_date','$this->updated_date','$this->package_start_date','$this->daily_agenda','$this->start_date','$this->end_date','$this->attendance_type','$this->language','$this->timezone','$this->country','$this->currency_type','$this->logo','$this->grading_type','$this->user_key','$this->status' )";
$result = $this->database->query($sql);
$this->id = mysql_insert_id($this->database->link);

}

// **********************
// UPDATE
// **********************

function update($id)
{



$sql = " UPDATE client_org SET  admin_id = '$this->admin_id',school_name = '$this->school_name',contact_person = '$this->contact_person',contact_email = '$this->contact_email',phone_number = '$this->phone_number',address = '$this->address',pb_no = '$this->pb_no',mobile = '$this->mobile',fax = '$this->fax',sms_credict = '$this->sms_credict',email_credict = '$this->email_credict',created_date = '$this->created_date',updated_date = '$this->updated_date',package_start_date = '$this->package_start_date',daily_agenda = '$this->daily_agenda',start_date = '$this->start_date',end_date = '$this->end_date',attendance_type = '$this->attendance_type',language = '$this->language',timezone = '$this->timezone',country = '$this->country',currency_type = '$this->currency_type',logo = '$this->logo',grading_type = '$this->grading_type',user_key = '$this->user_key',status = '$this->status' WHERE id = $id ";

$result = $this->database->query($sql);



}


// **********************
// SELECT ALL
// **********************
function selectall($cond='',$limit='',$order)
{
	$sql =  "SELECT * FROM client_org ";
	if($cond!='')
		$sql .= " WHERE $cond ";
	
	if($order!='')
		$sql .= " ORDER BY $order ";
		
	if($limit!='')
		$sql .= " LIMIT $limit ";
	
	$sql .=";";
	
	$result =  $this->database->query($sql);
	$result = $this->database->result;
	$this->rows=array();
	while($row=mysql_fetch_object($result))
	{
	$this->rows[] = $row;
	}
	return $this->rows;
}

// **********************
// CUSTOM METHOD / LOAD
// **********************
/*Activate User*/
function activateUser($userkey)
	{
		$sql =  "SELECT * FROM client_org WHERE user_key = '$userkey'";
		$result =  $this->database->query($sql);
		$result = $this->database->result;
		if($row=mysql_fetch_object($result))
		{
			 
			$this->select($row->id);
			if(($this->status==-1))
			{
				$this->setstatus(1);
			}
			$this->update($row->id);
			$sql= "Update client_org set user_key='' where id=$row->id"; 
			$this->database->query($sql);
			return true;
		}
		else
		{
			return false;
		}
		return false;
	}
/*Activate User*/
	
	/*Select Email*/
function selectuserbyemail($email)
{

$sql =  "SELECT * FROM admin_users WHERE email = '$email';";
$result =  $this->database->query($sql);
$result = $this->database->result;
$row = mysql_fetch_object($result);

$this->id = $row->id;

$this->admin_id = $row->admin_id;

$this->school_name = $row->school_name;

$this->contact_person = $row->contact_person;

$this->contact_email = $row->contact_email;

$this->phone_number = $row->phone_number;

$this->address = $row->address;

$this->pb_no = $row->pb_no;

$this->mobile = $row->mobile;

$this->fax = $row->fax;

$this->sms_credict = $row->sms_credict;

$this->email_credict = $row->email_credict;

$this->created_date = $row->created_date;

$this->updated_date = $row->updated_date;

$this->package_start_date = $row->package_start_date;

$this->daily_agenda = $row->daily_agenda;

$this->user_key = $row->user_key;

$this->status = $row->status;


}
	/*Select Email*/
	
	
} // class : end

?>