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

include_once("class.database.php");

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

class set_weekdays
{ // class : begin


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

var $id;   // KEY ATTR. WITH AUTOINCREMENT

var $mon;   // (normal Attribute)
var $tue;   // (normal Attribute)
var $wed;   // (normal Attribute)
var $thr;   // (normal Attribute)
var $fri;   // (normal Attribute)
var $sat;   // (normal Attribute)
var $sun;   // (normal Attribute)
var $cid;   // (normal Attribute)
var $bid;   // (normal Attribute)
var $org_id;   // (normal Attribute)

var $database; // Instance of class database


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

function set_weekdays()
{

$this->database = new Database();

}


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


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

function getmon()
{
return $this->mon;
}

function gettue()
{
return $this->tue;
}

function getwed()
{
return $this->wed;
}

function getthr()
{
return $this->thr;
}

function getfri()
{
return $this->fri;
}

function getsat()
{
return $this->sat;
}

function getsun()
{
return $this->sun;
}

function getcid()
{
return $this->cid;
}

function getbid()
{
return $this->bid;
}

function getorg_id()
{
return $this->org_id;
}

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


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

function setmon($val)
{
$this->mon =  $val;
}

function settue($val)
{
$this->tue =  $val;
}

function setwed($val)
{
$this->wed =  $val;
}

function setthr($val)
{
$this->thr =  $val;
}

function setfri($val)
{
$this->fri =  $val;
}

function setsat($val)
{
$this->sat =  $val;
}

function setsun($val)
{
$this->sun =  $val;
}

function setcid($val)
{
$this->cid =  $val;
}

function setbid($val)
{
$this->bid =  $val;
}

function setorg_id($val)
{
$this->org_id =  $val;
}

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

function select($id)
{

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


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

$this->mon = $row->mon;

$this->tue = $row->tue;

$this->wed = $row->wed;

$this->thr = $row->thr;

$this->fri = $row->fri;

$this->sat = $row->sat;

$this->sun = $row->sun;

$this->cid = $row->cid;

$this->bid = $row->bid;

$this->org_id = $row->org_id;

}





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

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

}

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

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

$sql = "INSERT INTO set_weekdays ( mon,tue,wed,thr,fri,sat,sun,cid,bid,org_id ) VALUES ( '$this->mon','$this->tue','$this->wed','$this->thr','$this->fri','$this->sat','$this->sun','$this->cid','$this->bid','$this->org_id' )";
$result = $this->database->query($sql);
$this->id = mysql_insert_id($this->database->link);

}

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

function update($id)
{



$sql = " UPDATE set_weekdays SET  mon = '$this->mon',tue = '$this->tue',wed = '$this->wed',thr = '$this->thr',fri = '$this->fri',sat = '$this->sat',sun = '$this->sun',cid = '$this->cid',bid = '$this->bid',org_id = '$this->org_id' WHERE id = $id ";

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



}
// **********************
// SELECT ALL
// **********************

function selectall($cond='',$limit='',$order)
{
	$sql =  "SELECT * FROM set_weekdays ";
	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
// **********************

/*Org Select all*/
function selectorgall()
{
	$org_id=$_SESSION['org_id'];
	$sql =  "SELECT * FROM set_weekdays WHERE org_id='$org_id' ";
	$result =  $this->database->query($sql);
	$result = $this->database->result;
	$this->rows=array();
	while($row=mysql_fetch_object($result))
	{
	$this->rows[] = $row;
	}
	return $this->rows;
}
/*Org Select all*/

/*  Check org */
 function check_org($org_id,$course,$batch)
	{
		$org_id=$_SESSION['org_id'];
		$sql =  "SELECT * FROM set_weekdays WHERE org_id = '$org_id' AND cid = '$course' AND bid = '$batch';";
		$result =  $this->database->query($sql);
		$result = $this->database->result;
		if($row=mysql_fetch_object($result))
		{
			return $row->id;
		}
		else 
		{
			return -1;
		}
	}
	/*  Check org */
	
	
/*Update Weekdays*/	
function update_weekdays($org_id,$course,$batch)
{
	$org_id=$_SESSION['org_id'];
$sql = " UPDATE set_weekdays SET  mon = '$this->mon',tue = '$this->tue',wed = '$this->wed',thr = '$this->thr',fri = '$this->fri',sat = '$this->sat',sun = '$this->sun',org_id = '$this->org_id' WHERE org_id = $org_id  AND cid = '$course' AND bid = '$batch';";
$result = $this->database->query($sql);
}
/*Update Weekdays*/	
/*Select Weekdays*/
function select_weekdays($org_id,$course,$batch)
{
	$org_id=$_SESSION['org_id'];

$sql =  "SELECT * FROM set_weekdays WHERE org_id = $org_id  AND cid = '$course' AND bid = '$batch';";
$result =  $this->database->query($sql);
$result = $this->database->result;
$row = mysql_fetch_object($result);


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

$this->mon = $row->mon;

$this->tue = $row->tue;

$this->wed = $row->wed;

$this->thr = $row->thr;

$this->fri = $row->fri;

$this->sat = $row->sat;

$this->sun = $row->sun;

$this->cid = $row->cid;

$this->bid = $row->bid;

$this->org_id = $row->org_id;

}
/*Select Weekdays*/
	
} // class : end

?>