system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
<?php
class Model_MCategories
{
function showCategories()
{
$pagesize=10;
if(isset($_GET['size']))
{
$pagesize=$_GET['size'];
}
if(isset($_GET['page']))
{
$start = trim($_GET['page']-1) * $pagesize;
$end = $pagesize;
}
else
{
$start = 0;
$end = $pagesize;
}
$total=0;
$query_string = split('&size',$_SERVER['QUERY_STRING']);
$select="select * from categorey_table ";
$obj=new Bin_Query();
$obj->executeQuery($select);
$total = ceil($obj->totrows/ $pagesize);
if($obj->totrows<=$pagesize)
{
$select1="select * from categorey_table LIMIT $start,$end ";
$obj2=new Bin_Query();
$obj2->executeQuery($select1);
// print_r($obj->records);
//return Display_DCategories::showTestimonals($obj->records);
return Display_DCategories::showCategories($obj2->records,1,$this->data['paging'],$this->data['prev'],$this->data['next'],$start,$total,$query_string[0]);
}
else
{
$tmp = new Lib_Paging('classic',array('totalpages'=>$total, 'length'=>10),'pagination');
$this->data['paging'] = $tmp->output;
$this->data['prev'] =$tmp->prev;
$this->data['next'] = $tmp->next;
$sql1 = "select * from categorey_table LIMIT $start,$end";
$obj2 = new Bin_Query();
$obj2->executeQuery($sql1);
return Display_DCategories::showCategories($obj2->records,1,$this->data['paging'],$this->data['prev'],$this->data['next'],$start,$total,$query_string[0]);
}
}
function insertCategories()
{
$cat=$_POST['txtcat'];
$name=$_POST['txtname'];
$date=$_POST['txtdate'];
$status=$_POST['txtstatus'];
$insert="insert into categorey_table (categorey_cat,categorey_name,categorey_date,categorey_status) values('$cat','$name','$date','$status')";
$obj=new Bin_Query();
if($obj->updateQuery($insert))
{
$_SESSION['message'] = 'Categories has been added Successfully';
}
else
{
$_SESSION['error_message'] = 'Oops unable to insert Categories';
}
}
function showEdit()
{
$testid=$_GET['id'];
$select="select * from categorey_table where categorey_id='$testid' ";
$obj=new Bin_Query();
$obj->executeQuery($select);
// print_r($obj->records);
if($obj->records[0]['categorey_image']=='')
$obj->records[0]['categorey_image']='uploads/testimonals/no_image1.gif';
return $obj->records[0];
}
function updateCategories()
{
$testid=$_GET['id'];
$name=$_POST['txtname'];
$date=$_POST['txtdate'];
$cat=$_POST['txtcat'];
$status=$_POST['txtstatus'];
$update="update categorey_table set categorey_name='$name',categorey_date='$date',categorey_cat='$cat',categorey_status='$status' where categorey_id='$testid'";
$obj=new Bin_Query();
if($obj->updateQuery($update))
{
$_SESSION['message']="Category updated Sucessfully";
}
else
{
$_SESSION['error_message']="Oops unable to update";
}
}
function deleteCategories()
{
if(isset($_POST['delete']))
{
//$esc=$_POST['check'];
foreach($_POST as $key=>$item)
{
if($key==$item)
{
$sql1="delete from categorey_table WHERE categorey_id='".$key."' ";
}
$obj=new Bin_Query();
if($obj->updateQuery($sql1))
{
$_SESSION['message']=" User Deleted Sucessfully";
}
/* else
{
$_SESSION['error_message']=" Process failed";
}
*/
}
}
}
}
?>