Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.12.151.11
Current Path : /var/www/oasis/src_old/ |
| Current File : /var/www/oasis/src_old/display_details_in_grid_withdegree_rv.php |
<?php
include_once("/JSON.php");
$json = new Services_JSON();
function getsearchcondition($cond,$val)
{
switch($cond)
{
case 'eq':
$cond="=";
$value="'".$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'ne':
$cond="!=";
$value="'".$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'lt':
$cond="<";
$value="'".$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'le':
$cond="<=";
$value="'".$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'gt':
$cond=">";
$value="'".$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'ge':
$cond=">=";
$value="'".$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'cn':
$cond="like '%";
$value=$val."%'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'nc':// Doesnot Contain
$cond="not like '%";
$value=$val."%'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'bw':
$cond="like '";
$value=trim($val)."%'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'bn'://Does Not Begin With
$cond="not like '";
$value=trim($val)."%'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'ew':
$cond="like '%";
$value=$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'en'://Does Not Ends With
$cond="not like '%";
$value=$val."'";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'in'://Is in
$cond="in '(";
$value=$val."')";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
case 'in'://Is not in
$cond="notin '(";
$value=$val."')";
$final_value[0]=$cond;
$final_value[1]=$value;
return $final_value;
break;
}
}
function viewUserSchemaDeiatlstest($aobj_context)
{
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from
(select s.internal_code as id,s.module_name as grid_module_name,t.value as grid_module_type
from s_user_schema s inner join s_ref_type t on t.internal_code=s.module_type )a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from
s_user_schema s inner join s_ref_type t on t.internal_code=s.module_type";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select s.internal_code as id,s.module_name as grid_module_name,t.value as grid_module_type
from s_user_schema s inner join s_ref_type t on t.internal_code=s.module_type )a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select s.internal_code as id,s.module_name as grid_module_name,t.value as grid_module_type
from s_user_schema s inner join s_ref_type t on t.internal_code=s.module_type
ORDER BY $sidx $sord LIMIT $start , $limit";
//echo $SQL;
}
//echo $SQL;
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ $responce->rows[$i]['id']=$row[id]; //id
$responce->rows[$i]['cell']=array($row[grid_module_name],$row[grid_module_type]);
$i++;
}
echo json_encode($responce);
// return the formated data
}
function CollegeDetailsPopup($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$mod_type = $_GET['type'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
$cond='';
$value='';
/* if($mod_type == '')
{
$cond=' ';
}
else
{
$cond= "and c.{$mod_type} is NULL";
} */
$search =$aobj_context->mobj_data["_search"];
// to take th e parameters from Search field
$filter_toolbal_cond="";
if($search=='true')
{
$Colcode =$aobj_context->mobj_data["FCOLLCODE"];
$Desc =$aobj_context->mobj_data["FCOLLNAME"];
if(isset($Colcode) && !empty($Colcode))
$filter_toolbal_cond.="FCOLLCODE like '{$Colcode}%'";
/* if(isset($Desc) && !empty($Desc))
$filter_toolbal_cond.=" and FDESCPN like '{$Desc}%'"; */
}
if($search=='true')
{
$count_id="select count(distinct FCOLLCODE) as count from
college where {$filter_toolbal_cond}";
}
else
{
$count_id="select count(distinct FCOLLCODE) as count from
college ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if($count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if($search=='true')
{
$SQL="select * from (select FCOLLCODE as id,FCOLLCODE,FCOLLNAME from college)a where {$filter_toolbal_cond}
group by FCOLLCODE
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select FCOLLCODE as id,FCOLLCODE,FCOLLNAME from college
ORDER BY $sidx $sord LIMIT $start , $limit";
}
// echo $SQL;
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$responce->rows[$i]['id']=$row[id]; //id
$responce->rows[$i]['cell']=array($row[FCOLLCODE],$row[FCOLLNAME]);
$i++;
}
echo json_encode($responce);
}
function degreeDetailsPopupOld($aobj_context)
{
include_once("/JSON.php");
//echo $lstr_ids;
session_start();
$college_code = $_SESSION['collcode'];
$json = new Services_JSON();
$mod_type = $_GET['type'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
$cond='';
$value='';
if($mod_type == '')
{
$cond=' ';
}
else
{
$cond= "and c.{$mod_type} is NULL";
}
$search =$aobj_context->mobj_data["_search"];
// to take th e parameters from Search field
$filter_toolbal_cond="";
if($search=='true')
{
$Degcode =$aobj_context->mobj_data["FDEGREE"];
$Desc =$aobj_context->mobj_data["FDESCPN"];
if(isset($Degcode) && !empty($Degcode))
$filter_toolbal_cond.=" d.FDEGREE like '{$Degcode}%'";
/* if(isset($Desc) && !empty($Desc))
$filter_toolbal_cond.=" and FDESCPN like '{$Desc}%'"; */
}
if($search=='true')
{
$count_id="select count(distinct FDEGREE) as count from
colldeg where {$filter_toolbal_cond}";
}
else
{
$count_id="select count(distinct FDEGREE) as count from
colldeg ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if($search=='true')
{
$SQL="select c.FDEGREE as id, c.FDEGREE,d.FDESCPN
from colldeg c inner join degree d on
d.FDEGREE=c.FDEGREE and FCOLLCODE='{$college_code}'
and c.FDELETED = 'F'
{$cond} where {$filter_toolbal_cond} group by FDEGREE
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = " select c.FDEGREE as id, c.FDEGREE,d.FDESCPN
from colldeg c inner join degree d on
d.FDEGREE=c.FDEGREE and FCOLLCODE='{$college_code}'
and c.FDELETED = 'F'
{$cond} group by FDEGREE
ORDER BY $sidx $sord LIMIT $start , $limit";
}
// echo $SQL;
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ $responce->rows[$i]['id']=$row[id]; //id
$responce->rows[$i]['cell']=array($row[FDEGREE],$row[FDESCPN]);
$i++;
}
echo json_encode($responce);
}
function degreeDetailsPopup($aobj_context)
{
session_start();
$college_code = $_SESSION['collcode'];
$type = ($aobj_context->mobj_data["type"]);
if($mod_type == '')
{
$cond=' ';
}
else
{
$cond= "and c.{$mod_type} is NULL";
}
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('FDEGREE','FDESCPN');
$display_obj->display_qry = " select distinct c.FDEGREE as id, c.FDEGREE,d.FDESCPN
from colldeg c inner join degree d on
d.FDEGREE=c.FDEGREE and FCOLLCODE='{$college_code}'
and c.FDELETED = 'F'
{$cond}
where 1=1";
$display_obj->DisplayDetailsInGrid();
}
function ExamnoDetailsPopup($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$DegCode =$_GET['DegCode'];
if(!$sidx)
$sidx =1;
$cond='';
$value='';
// to take th e parameters from Search field
$search =$aobj_context->mobj_data["_search"];
// to take th e parameters from Search field
$filter_toolbal_cond="";
if($search=='true')
{
$Examno =$aobj_context->mobj_data["fexamno"];
if(isset($DegCode) && !empty($DegCode))
$filter_toolbal_cond.=" fdegree like '{$DegCode}%'";
if(isset($Examno) && !empty($Examno))
$filter_toolbal_cond.="AND fexamno like '{$Examno}%'";
}
if($search=='true')
{
$count_id="select count(*)as count from degree where {$filter_toolbal_cond}";
}
else
{
$count_id="select count(*)as count from degree where fdegree ='".$DegCode."'";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if($search=='true')
{
$SQL="select * from (select fexamno as id, fexamno,fexamname from degree where {$filter_toolbal_cond})a
ORDER BY $sidx $sord LIMIT $start,$limit";
//where $field_name $cond$value
}
else
{
$SQL = "select fexamno as id, fexamno,fexamname from degree where fdegree='".$DegCode."'
ORDER BY $sidx $sord LIMIT $start , $limit";
// echo $SQL;
}
//echo $SQL;
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ $responce->rows[$i]['id']=$row[id]; //id
$responce->rows[$i]['cell']=array($row[fexamno],$row[fexamname]);
$i++;
}
echo json_encode($responce);
}
function SubjectMarkDetailsPopup($aobj_context)
{
session_start();
$college_code = $_SESSION['collcode'];
$Degree_code = $aobj_context->mobj_data["DegCode"];
$Exam_no = $aobj_context->mobj_data["Examno"];
$module = $aobj_context->mobj_data["module"];
$category = $aobj_context->mobj_data["category"];
//$search =$aobj_context->mobj_data["_search"];
$cat_cond="";
$select_category_cond = "select Value from markentrycodition
where FMODULE='{$module}' and Code='{$category}' and FDELETED='F'";
$lobj_select_category_cond = $aobj_context->mobj_db->GetRow($select_category_cond);
if(!empty($lobj_select_category_cond) && ($lobj_select_category_cond['Value']!='0' || $lobj_select_category_cond['Value']!=0))
$cat_cond=" and ".$lobj_select_category_cond['Value'];
if($module == 'ME')
{
$get_freezed_subject = "select trim(FMESTATUS{$Exam_no}) as type from colldeg
where FDEGREE = '{$Degree_code}'
and FCOLLCODE='{$college_code}' ";
$obj_get_status = $aobj_context->mobj_db->GetRow($get_freezed_subject);
$freezed_cond="";
if(is_null($obj_get_status['type']) or empty($obj_get_status['type']))
$freezed_cond ="";
else
{
$count_type = strlen($obj_get_status['type'])-2;
$freezed_module1 = substr($obj_get_status['type'],1,$count_type);
$frz_module = "'".str_replace("*","','",$freezed_module1)."'";
$freezed_cond = "and s.FCSUBCODE NOT IN ({$frz_module}) ";
}
}
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('fcsubcode','fsubname','fssubname','fshortname','fsmaxmarks');
$display_obj->display_qry ="select fcsubcode as id,fcsubcode,fsubname,fssubname,
concat(fshortname,'(',fsubshort,')') as fshortname,fsmaxmarks from
subject s inner join colldeg c on
s.FDEGREE = c.FDEGREE
and s.fdegree = '{$Degree_code}' and s.fexamno='{$Exam_no}'
where c.FCOLLCODE='{$college_code}' {$cat_cond} {$freezed_cond} ";
$display_obj->DisplayDetailsInGrid();
/* include_once("/JSON.php");
session_start();
$college_code = $_SESSION['collcode'];
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$Degree_code = $aobj_context->mobj_data["DegCode"];
$Exam_no = $aobj_context->mobj_data["Examno"];
$module = $aobj_context->mobj_data["module"];
$category = $aobj_context->mobj_data["category"];
$search =$aobj_context->mobj_data["_search"];
$select_category_cond="select * from markentrycodition where Code={$category}";
$cat_cond='';
$freezed_cond='';
$lobj_select_category_cond = $aobj_context->mobj_db->GetRow($select_category_cond);
//var_dump($lobj_select_category_cond);
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$DegCode =$_GET['DegCode'];
if(!$sidx)
$sidx =1;
$cond='';
$value='';
// the actual query for the grid data
//echo $frz_module; die();
$filter_toolbal_cond="";
// to take th e parameters from Search field
if($search=='true')
//if(isset($_GET['searchField']) && $_GET["searchField"]!='')
{
$ffsubcode =$aobj_context->mobj_data["ffsubcode"];
$fshortname =$aobj_context->mobj_data["fshortname"];
if(isset($DegCode) && !empty($DegCode))
$filter_toolbal_cond.=" fdegree = '{$DegCode}'";
if(isset($Exam_no) && !empty($Exam_no))
$filter_toolbal_cond.="AND fexamno ='{$Exam_no}'";
if(isset($ffsubcode) && !empty($ffsubcode))
$filter_toolbal_cond.="AND fcsubcode like '{$ffsubcode}%'";
if(isset($fshortname) && !empty($fshortname))
$filter_toolbal_cond.="AND fshortname like '{$fshortname}%'";
$filter_toolbal_cond.="and fretain='T' and fintass='T'";
}
if($search=='true')
{
$count_id="select count(*) as count from subject where {$filter_toolbal_cond} ";
}
else
{
$count_id="select count(*) as count from subject where fdegree = '".$Degree_code."'and fexamno='".$Exam_no."' and fretain='T' and fintass='T'";
//echo $count_id; die();
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
//var_dump($obj_get_status); die();
if( $_GET["_search"]=='true')
{
$SQL="select * from (select fcsubcode,fsubname,fssubname,fshortname,fsmaxmarks subject where fdegree = '".$Degree_code."'and fexamno='".$Exam_no."' and fretain='T' and fintass='T')a
where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = " select fcsubcode as id,fcsubcode,fsubname,fssubname,fshortname,fsmaxmarks from
subject s inner join colldeg c on
s.FDEGREE = c.FDEGREE
and s.fdegree = '{$Degree_code}' and s.fexamno='{$Exam_no}'
where c.FCOLLCODE='{$college_code}'
{$cat_cond} {$freezed_cond}
ORDER BY $sidx $sord LIMIT $start , $limit
";
//echo $SQL; die();
}
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ $responce->rows[$i]['id']=$row[id]; //id
$responce->rows[$i]['cell']=array($row[fcsubcode],$row[fsubname],
$row[fssubname],$row[fshortname],$row[fsmaxmarks]);
$i++;
}
echo json_encode($responce); */
}
function subjectDetailsPopup($aobj_context)
{
include_once("/JSON.php");
//echo $lstr_ids;
$subCode=$_GET['subCode'];
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$exam = $_GET['exam'];
$degree_code = $_GET['degree_code'];
$searchField = $_GET['searchField'];
$mand_field = $_GET['mand_field'];
if($mand_field=='' )
{
$mand_field_cond=" ";
}
else $mand_field_cond=" and FMANDATORY='F'"; // for candindate disaply no need to check FMANDATORY='F'";
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('FCSUBCODE','FSUBNAME','FSHORTNAME');
$display_obj->display_qry ="select FSUBCODE as id,
FSUBCODE,FSUBSHORT,FSUBNAME from degree d inner join subject s on
s.FDEGREE=d.FDEGREE and d.FEXAMNO=s.FEXAMNO
where d.FDEGREE='{$degree_code}' and s.FEXAMNO='{$exam}'
{$mand_field_cond} and ifnull(FSUSPEND,'F')!='T'
{$cond}
group by FSUBCODE";
//echo $display_obj->display_qry;
return $display_obj->DisplayDetailsInGrid();
}
function getstudentEntryDetails($aobj_context)
{
session_start();
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from
(select FSLNO as id,FSLNO,FNAME,FDEGREE,FFATNAME,FMOTNAME from studadm
where FCOLLCODE = '{$_SESSION['collcode']}' )a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from studadm
where FCOLLCODE = '{$_SESSION['collcode']}' ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select FSLNO as id,FSLNO,FNAME,FDEGREE,FFATNAME,FMOTNAME from studadm
where FCOLLCODE = '{$_SESSION['collcode']}' )a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select FSLNO as id,FSLNO,FNAME,FDEGREE,FFATNAME,FMOTNAME from studadm
where FCOLLCODE = '{$_SESSION['collcode']}'
ORDER BY $sidx $sord LIMIT $start , $limit";
//echo $SQL;
}
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[FSLNO],$value[FNAME],$value[FDEGREE],$value[FFATNAME],$value[FMOTNAME]);
}
// return the formated data
echo $json->encode($responce);
}
//--- end by naveen
function SubjectCodePopupForAnswerScript($aobj_context)
{
session_start();
$College_Code = $_SESSION['collcode'];
$degree_code = ($aobj_context->mobj_data["DegCode"]);
$exam_no = ($aobj_context->mobj_data["Examno"]);
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('FCSUBCODE','FSUBNAME','FSHORTNAME');
$display_obj->display_qry ="select S.FCSUBCODE as id, S.FCSUBCODE,S.FSUBNAME,S.FSHORTNAME from
subject S INNER JOIN colldeg C ON
S.FDEGREE=C.FDEGREE AND FCOLLCODE='{$College_Code}'
WHERE S.FDEGREE='{$degree_code}' AND S.FEXAMNO='{$exam_no}'
AND ifnull(S.FDELETED,'F')='F'";
$display_obj->DisplayDetailsInGrid();
}
function SubjectShortNamePopup($aobj_context)
{
include_once("/JSON.php");
//echo $_GET['searchField']; die();
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$Degree_code = $aobj_context->mobj_data["DegCode"];
$Exam_no = $aobj_context->mobj_data["Examno"];
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
//$DegCode =$_GET['DegCode'];
if(!$sidx)
$sidx =1;
$cond='';
$value='';
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["searchField"]!='')
{
$cond='where FDEGREE like ';
$value="'%".$_GET['searchField']."%'";
}
$count_id="select count(*) as count from subject where fdegree = '{$Degree_code}'and fexamno='{$Exam_no}' and fretain='T' and fintass='T'";
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select fshortname,fshortname as id subject where fdegree = '{$Degree_code}'and fexamno='{$Exam_no}' and fretain='T' and fintass='T')a
where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select fshortname as id,fshortname from subject where fdegree = '{$Degree_code}'and fexamno='{$Exam_no}' and fretain='T' and fintass='T'
ORDER BY $sidx $sord LIMIT $start , $limit";
// echo $SQL;
}
//echo $SQL; die();
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ $responce->rows[$i]['id']=$row[id]; //id
$responce->rows[$i]['cell']=array($row[fshortname]);
$i++;
}
echo json_encode($responce);
}
function studentRegisterNoPopup($aobj_context)
{
session_start();
$CollegeCode = $_SESSION['collcode'];
$degree = $aobj_context->mobj_data["degree"];
$module_name_for_save = $aobj_context->mobj_data["module_name_for_save"];
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('Fregno','Fname','FDoB');
if($module_name_for_save=="SaveAbsentEntrySubjectwiseQP")
{
$display_obj->display_qry ="select Fregno as id ,Fregno,Fname,FDoB from
student
where fregno!='' ";
}
else
{
$display_obj->display_qry ="select Fregno as id ,Fregno,Fname,FDoB from
student where fcollcode= '{$CollegeCode}' and FDEGREE = '{$degree}'
and fregno!='' ";
}
$display_obj->DisplayDetailsInGrid();
}
//jijo updated
function RegnoDetailsPopup($aobj_context)
{
session_start();
$CollegeCode = $_SESSION['collcode'];
$degree = $aobj_context->mobj_data["degree"];
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('Regno');
$display_obj->display_qry ="select internal_code as id ,FREGNO from
mresult where FCOLLCODE= '{$CollegeCode}'";
//echo $display_obj->display_qry; die();
$display_obj->DisplayDetailsInGrid();
}
function deleteUserSchemaDeiatls($aobj_context)
{
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$lstr_qry = "delete
from s_user_schema
where internal_code in (".$lstr_ids.")";
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
$drop_table="drop table module_{$lstr_ids}";
$lobj_rs = $aobj_context->mobj_db->Execute($drop_table);
$drop_table="drop table module_{$lstr_ids}_details";
$lobj_rs = $aobj_context->mobj_db->Execute($drop_table);
$root_file_name=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/Report_details/report_result_".$lstr_ids.".php";
$root_js_name=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/grid_display_files/module_".$lstr_ids.".js";
if(file_exists($root_file_name))
unlink($root_file_name);
if(file_exists($root_js_name))
unlink($root_js_name);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function display_user_schema_group_master_grid($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (
select usg.internal_code as id,us.module_name as grid_schema_name,name as grid_group_name,multiple as grid_multiple
from s_user_schema us inner join
s_user_schema_group usg on usg.ref_s_user_schema_code=us.internal_code)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count
from s_user_schema_group";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select usg.internal_code as id,us.module_name as grid_schema_name,name as grid_group_name,multiple as grid_multiple,sequence as grid_group_sequence
from s_user_schema us inner join
s_user_schema_group usg on usg.ref_s_user_schema_code=us.internal_code )
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select usg.internal_code as id,us.module_name as grid_schema_name,name as grid_group_name,multiple as grid_multiple,sequence as grid_group_sequence
from s_user_schema us inner join
s_user_schema_group usg on usg.ref_s_user_schema_code=us.internal_code
ORDER BY $sidx $sord LIMIT $start , $limit";
} //echo $SQL ;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_schema_name],$value[grid_group_name],$value[grid_multiple],$value[grid_group_sequence]);
}
// return the formated data
echo $json->encode($responce);
}
function delete_user_schema_group_master_setup_details($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
//to drop the Group user schema Tables
$qry="select CONCAT('user_schema_',ms.INTERNAL_CODE,'_group_',msg.internal_code) as group_table_name
from s_user_schema_group msg inner join s_user_schema ms on ms.internal_code=msg.ref_s_user_schema_code
where msg.internal_code=$lstr_ids";
$lobj_rs = $aobj_context->mobj_db->GetRow($qry);
$drop_qry="drop table IF EXISTS ". $lobj_rs['group_table_name'];
$lobj_rs = $aobj_context->mobj_db->Execute($drop_qry);
$lstr_qry = "delete
from s_user_schema_group
where internal_code in (".$lstr_ids.")";
// echo $lstr_qry
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
$delete_eles="delete from s_user_schema_elements where ref_s_user_schema_group_code={$lstr_ids}";
$lobj_rs = $aobj_context->mobj_db->Execute($delete_eles);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function display_user_schema_element_master_grid($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from(
select uss.internal_code as id,us.module_name as grid_Schema_name,uss.name as grid_name,
s1.value as grid_data_type,uss.sequence as grid_sequence,usg.name as grid_group_name,description as grid_description,
default_value as grid_default_value,
if(optional=1,'Yes','No') as grid_optional
from s_user_schema_elements uss
inner join s_user_schema us on us.internal_code=uss.ref_s_user_schema_code
left join s_user_schema_group usg on usg.internal_code=ref_s_user_schema_group_code
left join s_ref_type s1 on s1.internal_code=data_type)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count
from s_user_schema_elements uss
inner join s_user_schema us on us.internal_code=uss.ref_s_user_schema_code
left join s_user_schema_group usg on usg.internal_code=ref_s_user_schema_group_code
left join s_ref_type s1 on s1.internal_code=data_type";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select uss.internal_code as id,us.module_name as grid_Schema_name,uss.name as grid_name,
s1.value as grid_data_type,uss.sequence as grid_sequence,usg.name as grid_group_name,description as grid_description,
default_value as grid_default_value,
if(optional=1,'Yes','No') as grid_optional,ref_data.module_name as grid_ref_module_name,s2.value as grid_meta_type
from s_user_schema_elements uss
inner join s_user_schema us on us.internal_code=uss.ref_s_user_schema_code
left join s_user_schema_group usg on usg.internal_code=ref_s_user_schema_group_code
left join s_ref_type s1 on s1.internal_code=data_type
left join s_user_schema ref_data on ref_data.internal_code=uss.ref_module_code
left join s_ref_type s2 on s2.internal_code=s_ref_type_meta)
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select uss.internal_code as id,us.module_name as grid_Schema_name,uss.name as grid_name,
s1.value as grid_data_type,uss.sequence as grid_sequence,usg.name as grid_group_name,description as grid_description,
default_value as grid_default_value,
if(optional=1,'Yes','No') as grid_optional,ref_data.module_name as grid_ref_module_name,s2.value as grid_meta_type
from s_user_schema_elements uss
inner join s_user_schema us on us.internal_code=uss.ref_s_user_schema_code
left join s_user_schema_group usg on usg.internal_code=ref_s_user_schema_group_code
left join s_ref_type s1 on s1.internal_code=data_type
left join s_user_schema ref_data on ref_data.internal_code=uss.ref_module_code
left join s_ref_type s2 on s2.internal_code=s_ref_type_meta
ORDER BY $sidx $sord LIMIT $start , $limit";
}
//echo $SQL ;
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$responce->rows[$i]['id']=$row[id];
$responce->rows[$i]['cell']=array($row[grid_Schema_name],$row[grid_name],$row[grid_data_type],$row[grid_sequence],
$row[grid_group_name],$row[grid_description],$row[grid_default_value],$row[grid_optional],$row[grid_ref_module_name],$row[grid_meta_type]);
$i++;
}
// return the formated data
echo $json->encode($responce);
// return the formated data
}
function delete_user_schema_element_master_setup_details($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
//to drop field in File
$lstr_get_schema = "select ref_s_user_schema_code
from s_user_schema_elements
where internal_code in (".$lstr_ids.")";
$lobj_lstr_get_schema = $aobj_context->mobj_db->GetRow($lstr_get_schema);
$schema_id= $lobj_lstr_get_schema[ref_s_user_schema_code];
// to drop the multiple group field name if exstis
$drop_field="select CONCAT('user_schema_',sus.INTERNAL_CODE,'_group_',susg.internal_code)
as table_name,
concat('u_',sus.internal_code,'_g_',susg.internal_code,'_ele_',suse.internal_code) as field_name
from
s_user_schema_elements suse
inner join s_user_schema_group susg
on susg.internal_code=suse.ref_s_user_schema_group_code
inner join s_user_schema sus on sus.internal_code=susg.ref_s_user_schema_code
where suse.internal_code=". $lstr_ids ." and multiple=1";
$lobj_rs_drop_field = $aobj_context->mobj_db->GetRow($drop_field);
if(count($lobj_rs_drop_field['table_name'])>0)
{
$table_count="show tables like '".$lobj_rs_drop_field['table_name']."'";
$lobj_rs_table_count = $aobj_context->mobj_db->GetRow($table_count);
if(count($lobj_rs_table_count)>0)
{
foreach ($lobj_rs_table_count as $key=>$value)
$alter_qr="alter table ". $value ." drop ".$lobj_rs_drop_field['field_name'] ;
$lobj_rs_drop = $aobj_context->mobj_db->Execute($alter_qr);
}
}
$drop_meta="select CONCAT('module_',sus.INTERNAL_CODE)
as table_name,CONCAT('m_',sus.INTERNAL_CODE,'_ele_',suse.internal_code) as field_name
from
s_user_schema_elements suse
inner join s_user_schema sus on sus.internal_code=suse.ref_s_user_schema_code
inner join s_ref_type s1 on s1.internal_code=suse.s_ref_type_meta
where suse.internal_code={$lstr_ids} and s1.value='Meta'";
$lobj_drop_meta = $aobj_context->mobj_db->GetRow($drop_meta);
if(!empty($lobj_drop_meta['table_name']))
{
$table_count="show tables like '".$lobj_drop_meta['table_name']."'";
$lobj_rs_table_count = $aobj_context->mobj_db->GetRow($table_count);
if(count($lobj_rs_table_count)>0)
{
foreach ($lobj_rs_table_count as $key=>$value)
$alter_qr="alter table ". $value ." drop ".$lobj_drop_meta['field_name'] ;
$lobj_rs_drop = $aobj_context->mobj_db->Execute($alter_qr);
}
}
$lstr_qry = "delete
from s_user_schema_elements
where internal_code in (".$lstr_ids.")";
//echo $lstr_qry ;
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
require_once(dirname(__FILE__)."\create_file.php");
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function getUserSchemaDetailsForRefrencedata($aobj_context)
{
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$module_id = $_GET['ref_module_code'];
if(!$sidx)
$sidx =1;
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (select internal_code as id,
data1 as grid_field1,
data2 as grid_field2
from s_ref_data where ref_s_user_schema_code = $module_id)a where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count
from s_ref_data where ref_s_user_schema_code = $module_id";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select internal_code as id,
data1 as grid_field1,
data2 as grid_field2
from s_ref_data where ref_s_user_schema_code = $module_id )a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select internal_code as id,
data1 as grid_field1,
data2 as grid_field2
from s_ref_data where ref_s_user_schema_code = $module_id
ORDER BY $sidx $sord LIMIT $start , $limit";
// echo $SQL;
}
//echo $SQL;
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_field1],$value[grid_field2]);
}
/* $i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$responce->rows[$i]['id']=$row[id];
$responce->rows[$i]['cell']=array($row[grid_module_name],$row[grid_field1],$row[grid_field2],$row[grid_field3],
$row[grid_field4],$row[grid_field5],$row[grid_tree_data] );
$i++;
} */
//var_dump($responce->rows);
echo $json->encode($responce);
}
function viewUserSchemaModuleDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
$s_indx=explode("grid_",$sidx);
if(!empty($s_indx[1]))
$sidx =$s_indx[1];
$table_name=$_GET['table_name'];
$schema_ids=explode("_",$table_name);
$schema_id=$schema_ids[1];
// this field we are not using for main query display selection since we need to get the data from REference tables, we are mannualy doing the quey below
$table_field_name=stripcslashes($_GET['field_name']);
$details_array=$_GET['details_array'];
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name_value=explode('grid_',$_GET['searchField']);
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
$pos = strpos($_GET['searchField'], "grid_d");
if ($pos === false) {
$field_name=$field_name_value[1];}
else
{ $field_name=$_GET['searchField'];}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from ( select internal_code as id,$table_field_name from $table_name ) a where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from $table_name";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from ( select internal_code as id,$table_field_name from $table_name )a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=10000");
$aobj_context->mobj_db->execute("set @a:=0");
$select_ref_module_code="select GROUP_CONCAT(join_table_name SEPARATOR ' ') as qry from
(select @a:=@a+1,ref_module_code,
concat(' left join module_',ref_module_code, ' as module_',ref_module_code,'_',@a,' on module_',ref_module_code,'_',@a,'.internal_code =m_',ref_s_user_schema_code, '_ele_',internal_code) as join_table_name
from s_user_schema_elements
where ref_s_user_schema_code=$schema_id and is_multiple_group=0 and ref_module_code>0)j";
$obj_select_ref_module_code = $aobj_context->mobj_db->GetRow($select_ref_module_code);
$join_qry=(count($obj_select_ref_module_code)>0)?$obj_select_ref_module_code[qry]:'';
$get_display_cols="select GROUP_CONCAT(field_name) as field_name from (select table_name,name,field_name as grid_field_name,
if(ref_module_code=0,concat('module_',internal_code,'.',field_name),concat(\"concat(\",(field_id),\") as \",field_name)) as field_name
,ref_module_code from
(select s.internal_code, ref_module_code,concat('module_',s.internal_code) as table_name ,
field_id,
su.name,ifnull(multiple,0) as multiple,ifnull(ug.name,'0None') as group_name,concat('m_',s.internal_code,'_ele_',su.internal_code) as field_name from s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
left join s_user_schema_group ug on ug.internal_code=su.ref_s_user_schema_group_code
left join module_meta_columns mmc on mmc.module_id=su.ref_module_code
where s.internal_code={$schema_id} and t.value='Meta' order by ug.sequence,su.sequence,su.internal_code ) l
where multiple=0 ) a ";
$lobj_get_display_cols = $aobj_context->mobj_db->GetRow($get_display_cols);
$SQL = " select $table_name.internal_code as id,".$lobj_get_display_cols[field_name]." from $table_name $join_qry
ORDER BY $sidx $sord LIMIT $start , $limit";
//echo $SQL;
$SQL1 = " select internal_code as id,$table_field_name from $table_name
ORDER BY $sidx $sord LIMIT $start , $limit";
}
//echo $SQL;
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL);
if((mysql_error()!=''))
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL1);
foreach($lobj_rs as $key =>$value)
{
$val='';
$responce->rows[$key]['id']=$value[id];
$l=0;
foreach($value as $key1 =>$value1)
{
if($key1!='id'){
$val[$l]=$value[$key1];
$l++;
}
}
$responce->rows[$key]['cell']=($val);
}
echo $json->encode($responce);
}
function viewUserSchemaSrefDataDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$search_by_user = trim($_GET['search_by_user']);
if(!empty($search_by_user))
{
$table_field_name=stripcslashes($_GET['field_name']);
if(strpos($table_field_name,",")===false)
{
$search_by_user= " where grid_data1 like '%{$search_by_user}%' ";
}
else
{
$search_by_user= " where (grid_data1 like '%{$search_by_user}%' or grid_data2 like '%{$search_by_user}%' or concat(grid_data2,'-',grid_data1) like '%{$search_by_user}%' or concat(grid_data1,'-',grid_data2) like '%{$search_by_user}%' ) ";
}
}
if(!$sidx)
$sidx =1;
$table_name=$_GET['table_name'];
$table_field_name=stripcslashes($_GET['field_name']);
$details_array=$_GET['details_array'];
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name_value=explode('grid_',$_GET['searchField']);
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
$pos = strpos($_GET['searchField'], "grid_d");
if ($pos === false) {
$field_name=$field_name_value[1];}
else
{ $field_name=$_GET['searchField'];}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from ( select internal_code as id,$table_field_name from $table_name ) a where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from (select internal_code as id,$table_field_name from $table_name ) a $search_by_user ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from ( select internal_code as id,$table_field_name from $table_name )a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = " select * from (select internal_code as id,$table_field_name from $table_name ) a $search_by_user
ORDER BY $sidx $sord LIMIT $start , $limit";
}
//echo $SQL;
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$val='';
$responce->rows[$key]['id']=$value[id];
$l=0;
foreach($value as $key1 =>$value1)
{
if($key1!='id'){
$val[$l]=$value[$key1];
$l++;
}
}
$responce->rows[$key]['cell']=($val);
}
echo $json->encode($responce);
}
function deleteUserSchemaModuleDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$table = $aobj_context->mobj_data["table_name"];
$schema_code_obj=explode("_",$table);
$schema_code=$schema_code_obj[1];
$lstr_del_meta_qry = "delete
from {$table}
where internal_code in (".$lstr_ids.")";
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_del_meta_qry);
$lstr_del_details_qry = "delete
from {$table}_details
where ref_s_module_code in (".$lstr_ids.")";
//echo $lstr_del_details_qry;
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_del_details_qry);
// delete from grup details
$lstr_del_group_details_qry="select concat('user_schema_',ref_s_user_schema_code,'_group_', ref_s_user_schema_group_code)
as group_table,
ref_s_user_schema_group_code from s_user_schema_elements where ref_s_user_schema_code={$schema_code}
and ref_s_user_schema_group_code>0 group by ref_s_user_schema_group_code";
$obj_lstr_del_group_details_qry = $aobj_context->mobj_db->GetAll($lstr_del_group_details_qry);
if(count($obj_lstr_del_group_details_qry)>0)
{
foreach($obj_lstr_del_group_details_qry as $key=>$value)
{
$delete_group="delete from ".$value["group_table"]." where ref_s_ref_data_code={$lstr_ids}";
$lobj_delete_group = $aobj_context->mobj_db->Execute($delete_group);
}
}
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function deleteUserSchemaModuleGroupDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$s_ref_data_code = $aobj_context->mobj_data["s_ref_data_code"];
$table_name = $aobj_context->mobj_data["table_name"];
$id = $aobj_context->mobj_data["id"];
$lstr_del_meta_qry = "delete
from {$table_name}
where ref_s_ref_data_code in ({$s_ref_data_code}) and internal_code in({$id})";
echo $lstr_del_meta_qry;
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_del_meta_qry);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function displayFormulaSetUpDetails($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
// to get the Componnet Name
$get_table_name="select concat('module_',s.internal_code) as table_name,
concat('m_',s.internal_code,'_ele_',su.internal_code) as field_name
from s_user_schema s inner join s_user_schema_elements su
on su.ref_s_user_schema_code=s.internal_code
where module_name='Salary Components' and su.name='Name'";
$lobj_rs = $aobj_context->mobj_db->getRow($get_table_name);
$table_name=$lobj_rs[table_name];
$display_name=$lobj_rs[field_name];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
else
$indx=explode("grid_",$sidx);
$sidx=empty($indx[1])?'1':$indx[1];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (
select formula_name as grid_formula_name,t.{$display_name} as grid_formula_component,formula as grid_formula_value
from formula_header fh inner join
formula_details fd on fh.internal_code=fd.ref_formula_header_code
left join {$table_name} t on t.internal_code=ref_component_code)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from (
select formula_name as grid_formula_name,t.{$display_name} as grid_formula_component,
formula as grid_formula_value
from formula_header fh inner join
formula_details fd on fh.internal_code=fd.ref_formula_header_code
left join {$table_name} t on t.internal_code=ref_component_code)a ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select fd.internal_code as id,formula_name as grid_formula_name,
t.{$display_name} as grid_formula_component,formula_for_ui as grid_formula_value
from formula_header fh inner join
formula_details fd on fh.internal_code=fd.ref_formula_header_code
left join {$table_name} t on t.internal_code=ref_component_code )
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select fd.internal_code as id,formula_name as grid_formula_name,t.{$display_name} as grid_formula_component,
formula_for_ui as grid_formula_value
from formula_header fh inner join
formula_details fd on fh.internal_code=fd.ref_formula_header_code
left join {$table_name} t on t.internal_code=ref_component_code
ORDER BY $sidx $sord LIMIT $start , $limit";
}
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_formula_name],$value[grid_formula_component],$value[grid_formula_value] );
}
// return the formated data
echo $json->encode($responce);
}
function deleteFormulaSetUpDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
//to drop the Group user schema Tables
$get_header_id="select ref_formula_header_code from formula_details where internal_code={$lstr_ids}";
$lobj_get_header_id = $aobj_context->mobj_db->getRow($get_header_id);
$selct_count="select count(ref_formula_header_code) as count from formula_details
where ref_formula_header_code={$lobj_get_header_id[ref_formula_header_code]}";
$lobj_selct_count = $aobj_context->mobj_db->getRow($selct_count);
if($lobj_selct_count[count]=='1')
{
$drop_qry_header="delete from formula_header where internal_code={$lobj_get_header_id[ref_formula_header_code]}";
$lobj_rs = $aobj_context->mobj_db->Execute($drop_qry_header);
$drop_qry_header_details="delete from formula_details where internal_code={$lstr_ids}";
$lobj_rs = $aobj_context->mobj_db->Execute($drop_qry_header_details);
}
else
{
$drop_qry_header_details="delete from formula_details where internal_code={$lstr_ids}";
$lobj_rs = $aobj_context->mobj_db->Execute($drop_qry_header_details);
echo $drop_qry_header_details;
}
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function displayUserSetUpDetails($aobj_context)
{
include_once("/JSON.php");
session_start();
$college_code=$_SESSION['collcode'];
$user_id= $_SESSION['user_id'];
$user_type=$_SESSION['user_type'];
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
$where_cond='';
if(strtolower($user_type)==strtolower('System'))
{
$where_cond=" where t.value='Admin'";
}
else
{
$where_cond=" where college_code='{$college_code}' ";
}
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from
(select s.internal_code as id,college_code as grid_college_code,
s.sysusr as grid_sysusr,
s.sysusrkey as grid_sysusrkey,
t.value as grid_user_type,
ifnull(s.real_name,'') as grid_real_name,
ifnull(s.email_id,'') as grid_email_id
from s_sysdb s inner join s_ref_type t on t.internal_code=s.user_type
{$where_cond} and s.internal_code!={$user_id}
)a
where $field_name $cond$value";
}
else
{
$count_id=" select count(*) as count
from s_sysdb s {$where_cond} and s.internal_code!={$user_id}
";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select s.internal_code as id,college_code as grid_college_code,
s.sysusr as grid_sysusr,
s.sysusrkey as grid_sysusrkey,
t.value as grid_user_type,
ifnull(s.real_name,'') as grid_real_name,
ifnull(s.email_id,'') as grid_email_id
from s_sysdb s inner join s_ref_type t on t.internal_code=s.user_type
{$where_cond} and s.internal_code!={$user_id}
)a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select s.internal_code as id,college_code as grid_college_code,
s.sysusr as grid_sysusr,
s.sysusrkey as grid_sysusrkey,
t.value as grid_user_type,
ifnull(s.real_name,'') as grid_real_name,
ifnull(s.email_id,'') as grid_email_id
from s_sysdb s inner join s_ref_type t on t.internal_code=s.user_type
{$where_cond} and s.internal_code!={$user_id}
ORDER BY $sidx $sord LIMIT $start , $limit";
// echo $SQL;
}
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_college_code],$value[grid_sysusr],$value[grid_sysusrkey],$value[grid_user_type],
$value[grid_real_name],$value[grid_email_id]);
}
// return the formated data
echo $json->encode($responce);
}
function deleteUserSetUpDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$lstr_qry = "update
s_sysdb set FDELETED='T'
where internal_code in (".$lstr_ids.")";
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function viewTransactionSeriesGrid($aobj_context)
{
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from
(select tsp.internal_code as id,
us.module_name as grid_ref_module_code,
uss.name as grid_ref_module_element_code,
series_name as grid_series_name,
prefix as grid_prefix,
starting_no as grid_starting_no,
ending_no as grid_ending_no,
last_no as grid_last_no,
starting_date as grid_starting_date,
ending_date as grid_ending_date
from transaction_series_prefix tsp
inner join s_user_schema us on us.internal_code=ref_module_code
inner join s_user_schema_elements uss on uss.internal_code=ref_module_element_code
)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from
transaction_series_prefix";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select tsp.internal_code as id,
us.module_name as grid_ref_module_code,
uss.name as grid_ref_module_element_code,
series_name as grid_series_name,
prefix as grid_prefix,
starting_no as grid_starting_no,
ending_no as grid_ending_no,
last_no as grid_last_no,
DATE_FORMAT(starting_date,'%d/%m/%Y') as grid_starting_date,
DATE_FORMAT(ending_date,'%d/%m/%Y') as grid_ending_date
from transaction_series_prefix tsp
inner join s_user_schema us on us.internal_code=ref_module_code
inner join s_user_schema_elements uss on uss.internal_code=ref_module_element_code
)a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select tsp.internal_code as id,
us.module_name as grid_ref_module_code,
uss.name as grid_ref_module_element_code,
series_name as grid_series_name,
prefix as grid_prefix,
starting_no as grid_starting_no,
ending_no as grid_ending_no,
last_no as grid_last_no,
DATE_FORMAT(starting_date,'%d/%m/%Y') as grid_starting_date,
DATE_FORMAT(ending_date,'%d/%m/%Y') as grid_ending_date
from transaction_series_prefix tsp
inner join s_user_schema us on us.internal_code=ref_module_code
inner join s_user_schema_elements uss on uss.internal_code=ref_module_element_code
ORDER BY $sidx $sord LIMIT $start , $limit";
//echo $SQL;
}
//echo $SQL;
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_ref_module_code],$value[grid_ref_module_element_code],
$value[grid_series_name],$value[grid_prefix],$value[grid_starting_no],
$value[grid_ending_no],$value[grid_last_no],$value[grid_starting_date],$value[grid_ending_date]);
}
// return the formated data
echo $json->encode($responce);
}
function deleteTransactionSeries($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$lstr_qry = "delete
from transaction_series_prefix
where internal_code in (".$lstr_ids.")";
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function viewUserSchemaModuleGroupDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$s_ref_data_code=$_GET['s_ref_data_code'];
if(!$sidx)
$sidx =1;
$s_indx=explode("grid_",$sidx);
if(!empty($s_indx[1]))
$sidx =$s_indx[1];
$table_name=$_GET['table_name'];
$schema_ids=explode("_",$table_name);
$schema_id=$schema_ids[2];
$group_id=$schema_ids[4];
// this field we are not using for main query display selection since we need to get the data from REference tables, we are mannualy doing the quey below
$table_field_name=stripcslashes($_GET['field_name']);
$details_array=$_GET['details_array'];
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name_value=explode('grid_',$_GET['searchField']);
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$search_value=$final_value[1];
}
$pos = strpos($_GET['searchField'], "grid_d");
if ($pos === false) {
$field_name=$field_name_value[1];}
else
{ $field_name=$_GET['searchField'];}
$aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=10000");
$select_ref_module_code="select GROUP_CONCAT(join_table_name SEPARATOR ' ') as qry from
(select ref_module_code,concat('u_',{$schema_id},'_g_',{$group_id},'_ele_',internal_code) as field_id,
concat(' left join module_',ref_module_code, ' on module_',ref_module_code,'.internal_code =u_',{$schema_id},'_g_',{$group_id},'_ele_',internal_code) as join_table_name
from s_user_schema_elements
where ref_s_user_schema_code={$schema_id} and ref_s_user_schema_group_code={$group_id} and ref_module_code>0)j";
$obj_select_ref_module_code = $aobj_context->mobj_db->GetRow($select_ref_module_code);
$join_qry=(count($obj_select_ref_module_code)>0)?$obj_select_ref_module_code[qry]:'';
// to form the fields dynamically
$select_field_ids="select concat('u_',{$schema_id},'_g_',{$group_id},'_ele_',internal_code) as field_id,name,
ref_module_code from s_user_schema_elements where ref_s_user_schema_code={$schema_id} and ref_s_user_schema_group_code={$group_id} order by internal_code";
$lobj_select_field_ids = $aobj_context->mobj_db->GetAll($select_field_ids);
foreach($lobj_select_field_ids as $key =>$value)
{
if($value[ref_module_code]=='0')
{
$fields.=$value[field_id].",";
$sum_field.="sum(".$value[field_id].") as ".$value[field_id].",";
}
else
{
$aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=10000");
$qry=" select concat('module_',schema_id) as table_name,GROUP_CONCAT(name SEPARATOR '-ele-') as name,
GROUP_CONCAT(field_name separator ',\'-\',') as field_name from
(select * from
(select s.internal_code as schema_id,su.name,ifnull(multiple,0) as multiple,ifnull(ug.name,'0None') as group_name,concat('m_',s.internal_code,'_ele_',su.internal_code) as field_name from s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
left join s_user_schema_group ug on ug.internal_code=su.ref_s_user_schema_group_code
where s.internal_code=$value[ref_module_code] and t.value='Meta' order by ug.sequence,su.sequence,su.internal_code ) l where multiple=0 limit 2) a group by schema_id";
$lobj_rs = $aobj_context->mobj_db->GetRow($qry);
$fields.="concat(".$lobj_rs[field_name].") as $value[field_id]".",";
$sum_field.="'' as ".$value[field_id].",";
}
}
$fields=substr($fields,0,strlen($fields)-1);
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from
( select $table_name.internal_code as id,$fields from $table_name $join_qry
where ref_s_ref_data_code= $s_ref_data_code )a where $field_name $cond$search_value";
}
else
{
$count_id="select count(*) as count from $table_name where ref_s_ref_data_code=$s_ref_data_code";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from ( select $table_name.internal_code as id,$fields from $table_name $join_qry
where ref_s_ref_data_code= $s_ref_data_code )a where $field_name $cond$search_value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL="select $table_name.internal_code as id,$fields from $table_name $join_qry
where ref_s_ref_data_code= $s_ref_data_code ORDER BY $sidx $sord LIMIT $start , $limit";
// echo $SQL;
//echo $SQL;
$SQL1 = " select internal_code as id,$table_field_name from $table_name where ref_s_ref_data_code=$s_ref_data_code
ORDER BY $sidx $sord LIMIT $start , $limit";
}
//echo $SQL;
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL);
if((mysql_error()!=''))
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL1);
foreach($lobj_rs as $key =>$value)
{
$val='';
$responce->rows[$key]['id']=$value[id];
$l=0;
foreach($value as $key1 =>$value1)
{
if($key1!='id'){
$val[$l]=$value[$key1];
$l++;
}
}
$responce->rows[$key]['cell']=($val);
}
echo $json->encode($responce);
}
function showGridForFormulaMapping($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include_once("/JSON.php");
//echo $lstr_ids;
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$module_id = trim($_GET['module_id']);
$id = trim($_GET['id']);
$search_by_user = trim($_GET['search_by_user_map']);
$qry="select a.*,meta_cols.field_id as field_name,ifnull(field_name,a.name) as name,ifnull(table_name,0) as table_name from
(select s.internal_code as schema_id,t.value as meta, su.internal_code,name ,t1.value as data_type,su.ref_module_code,db_field from
s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=su.data_type
where module_name='Employee' and is_multiple_group=0 and su.internal_code={$id}
and ((
t1.value in('List Of Values','Reference Data')) or (t.value='meta' and is_unique=1))) a
left join module_meta_columns meta_cols on meta_cols.module_id=ref_module_code";
//echo $qry;
$get_source_details = $aobj_context->mobj_db->GetRow($qry);
if($get_source_details["ref_module_code"]<>0)
$table_name="module_".$module_id;
else if ($get_source_details["meta"]=='Meta')
$table_name="module_".$get_source_details["schema_id"];
else if ($get_source_details["meta"]=='User')
$table_name="module_".$get_source_details["schema_id"]."_details";
if(!empty($search_by_user))
{
$table_field_name=stripcslashes($_GET['field_name']);
if(strpos($table_field_name,",")===false)
{
$search_by_user= " where grid_data1 like '%{$search_by_user}%' ";
}
else
{
$search_by_user= " where (grid_data1 like '%{$search_by_user}%' or grid_data2 like '%{$search_by_user}%' or concat(grid_data2,'-',grid_data1) like '%{$search_by_user}%' or concat(grid_data1,'-',grid_data2) like '%{$search_by_user}%' ) ";
}
}
if(!$sidx)
$sidx =1;
$table_field_name=stripcslashes($_GET['field_name']);
$details_array=$_GET['details_array'];
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name_value=explode('grid_',$_GET['searchField']);
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
$pos = strpos($_GET['searchField'], "grid_d");
if ($pos === false) {
$field_name=$field_name_value[1];}
else
{ $field_name=$_GET['searchField'];}
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
if($get_source_details["ref_module_code"]<>0)
{
$count_id = " select count(*) as count from (select internal_code as id,$table_field_name from $table_name ) a where $field_name $cond$value
";
}
else if ($get_source_details["meta"]=='Meta')
{
$count_id = " select count(*) as count from (select internal_code as id, ".$get_source_details["db_field"]. " as grid_data1,''
as grid_data2 from $table_name group by grid_data1) a where $field_name $cond$value
";
}
else if ($get_source_details["meta"]=='User')
{
$count_id = " select count(*) as count from (select value as grid_data1,'' as grid_data2,internal_code as id
from $table_name where ref_s_user_schema_elements_code={$id} group by value ) a where $field_name $cond$value
";
}
}
else
{
if($get_source_details["ref_module_code"]<>0)
{
$count_id = " select count(*) as count from (select internal_code as id,$table_field_name from $table_name ) a $search_by_user
";
}
else if ($get_source_details["meta"]=='Meta')
{
$count_id = " select count(*) as count from (select internal_code as id, ".$get_source_details["db_field"]. " as grid_data1,''
as grid_data2 from $table_name group by grid_data1) a $search_by_user
";
}
else if ($get_source_details["meta"]=='User')
{
$count_id = " select count(*) as count from (select value as grid_data1,'' as grid_data2,internal_code as id
from $table_name where ref_s_user_schema_elements_code={$id} group by value ) a $search_by_user
";
}
}
//echo $count_id;
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
if($get_source_details["ref_module_code"]<>0)
{
$SQL = " select * from (select internal_code as id,$table_field_name from $table_name ) a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start , $limit";
}
else if ($get_source_details["meta"]=='Meta')
{
$SQL = " select * from (select internal_code as id, ".$get_source_details["db_field"]. " as grid_data1,''
as grid_data2 from $table_name group by grid_data1) a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start , $limit";
}
else if ($get_source_details["meta"]=='User')
{
$SQL = " select * from (select value as grid_data1,'' as grid_data2,internal_code as id
from $table_name where ref_s_user_schema_elements_code={$id} group by value ) a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start , $limit";
}
}
else
{
if($get_source_details["ref_module_code"]<>0)
{
$SQL = " select * from (select internal_code as id,$table_field_name from $table_name ) a $search_by_user
ORDER BY $sidx $sord LIMIT $start , $limit";
}
else if ($get_source_details["meta"]=='Meta')
{
$SQL = " select * from (select internal_code as id, ".$get_source_details["db_field"]. " as grid_data1,''
as grid_data2 from $table_name group by grid_data1) a $search_by_user
ORDER BY $sidx $sord LIMIT $start , $limit";
}
else if ($get_source_details["meta"]=='User')
{
$SQL = " select * from (select value as grid_data1,'' as grid_data2,internal_code as id
from $table_name where ref_s_user_schema_elements_code={$id} group by value ) a $search_by_user
ORDER BY $sidx $sord LIMIT $start , $limit";
}
}
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$val='';
$responce->rows[$key]['id']=$value[id];
$l=0;
foreach($value as $key1 =>$value1)
{
if($key1!='id'){
$val[$l]=$value[$key1];
$l++;
}
}
$responce->rows[$key]['cell']=($val);
}
echo $json->encode($responce);
}
function displayFormulaMappingDetails($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (select map_at as grid_map_at ,map_value ,
formula_name as grid_formula_name
from emp_formula_map efm inner join formula_header fh
on efm.ref_formula_code=fh.internal_code
left join module_meta_columns mtc on mtc.module_id=ref_module_code)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from (select map_at as grid_map_at ,map_value ,
formula_name as grid_formula_name
from emp_formula_map efm inner join formula_header fh
on efm.ref_formula_code=fh.internal_code
left join module_meta_columns mtc on mtc.module_id=ref_module_code)a ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select efm.internal_code as id,map_at as grid_map_at ,map_value as grid_map_value,
formula_name as grid_formula_name
from emp_formula_map efm inner join formula_header fh
on efm.ref_formula_code=fh.internal_code
left join module_meta_columns mtc on mtc.module_id=ref_module_code )
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select efm.internal_code as id,map_at as grid_map_at ,map_value as grid_map_value,
formula_name as grid_formula_name
from emp_formula_map efm inner join formula_header fh
on efm.ref_formula_code=fh.internal_code
left join module_meta_columns mtc on mtc.module_id=ref_module_code
ORDER BY $sidx $sord LIMIT $start , $limit";
} // echo $SQL ;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_map_at],$value[grid_map_value],$value[grid_formula_name] );
}
// return the formated data
echo $json->encode($responce);
}
function deleteFormulaMappingDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$delete_eles="delete from emp_formula_map where internal_code in ( {$lstr_ids} )";
$lobj_rs = $aobj_context->mobj_db->Execute($delete_eles);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function showGridForSalarySetup($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$search_by_user = trim($_GET['search_by_user_map']);
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
if(!empty($search_by_user))
{
$table_field_name=stripcslashes($_GET['field_name']);
if(strpos($table_field_name,",")===false)
{
$search_by_user= " where grid_data1 like '%{$search_by_user}%' ";
}
else
{
$search_by_user= " where (grid_data1 like '%{$search_by_user}%' or grid_data2 like '%{$search_by_user}%' or concat(grid_data2,'-',grid_data1) like '%{$search_by_user}%' or concat(grid_data1,'-',grid_data2) like '%{$search_by_user}%' ) ";
}
}
/* $get_table_name_ele_name="select concat('module_',sus.internal_code) as table_name,db_field from s_user_schema sus
inner join s_user_schema_elements suse on suse.ref_s_user_schema_code=sus.internal_code
where module_name='Employee' and name in('Emp Code','Name');"; */
$get_table_name_ele_name="select table_name,field_name1,field_id1,field_name2,field_id2 from module_meta_columns
where module_name='Employee'" ;
$lobj_get_table_name_ele_name = $aobj_context->mobj_db->GetRow($get_table_name_ele_name);
if($lobj_get_table_name_ele_name[field_id2]=='')
{
$field_id2="' '";
}
else
$field_id2=$lobj_get_table_name_ele_name[field_id2];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
".$field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name].") a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
".$field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name].") a $search_by_user";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
".$field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name].")
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select * from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
". $field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name]."
ORDER BY $sidx $sord LIMIT $start , $limit ) a $search_by_user";
}
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[ grid_data1],$value[grid_data2] );
}
// return the formated data
echo $json->encode($responce);
}
function deleteFormulaSalarySetup($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$delete_eles="delete from emp_formula_map where internal_code in ( {$lstr_ids} )";
$lobj_rs = $aobj_context->mobj_db->Execute($delete_eles);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function displaySalarySetupHeader($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$ref_emp_code = $_GET['emp_id'];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
$check_type="select * from
(select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name in('name','Type') order by name)a
union
select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Component Type'
and name in('Component type')";
$lobj_check_type = $aobj_context->mobj_db->GetAll($check_type);
$get_comp_qry="(select c.internal_code as ref_component_code,{$lobj_check_type[0][field_name]} as component,{$lobj_check_type[2][field_name]} as type
from {$lobj_check_type[0][table_name]} c inner join {$lobj_check_type[2][table_name]} d on
d.internal_code={$lobj_check_type [1][field_name]} )";
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (select ssh.internal_code as id,component as grid_ref_source_component,
source_value as grid_source_value,DATE_FORMAT(effective_date,'%d/%m/%Y') as effective_date
from salary_setup_header ssh inner join
$get_comp_qry a on a.ref_component_code=ssh.ref_source_component
where ref_emp_code=$ref_emp_code)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from (select ssh.internal_code as id,component as grid_ref_source_component,
source_value as grid_source_value,DATE_FORMAT(effective_date,'%d/%m/%Y') as effective_date
from salary_setup_header ssh inner join
$get_comp_qry a on a.ref_component_code=ssh.ref_source_component
where ref_emp_code=$ref_emp_code )a ";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select ssh.internal_code as id,component as grid_ref_source_component,
source_value as grid_source_value,DATE_FORMAT(effective_date,'%d/%m/%Y') as effective_date
from salary_setup_header ssh inner join
$get_comp_qry a on a.ref_component_code=ssh.ref_source_component
where ref_emp_code=$ref_emp_code)
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = " select ssh.internal_code as id,component as grid_ref_source_component,
source_value as grid_source_value,DATE_FORMAT(effective_date,'%d/%m/%Y') as effective_date
from salary_setup_header ssh inner join
$get_comp_qry a on a.ref_component_code=ssh.ref_source_component
where ref_emp_code=$ref_emp_code
ORDER BY $sidx $sord LIMIT $start , $limit";
}
//echo $SQL;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_ref_source_component],$value[grid_source_value],$value[effective_date] );
}
// return the formated data
echo $json->encode($responce);
}
function deleteSalarySetupHeader($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$delete_eles="delete from salary_setup_header where internal_code in ( {$lstr_ids} )";
$lobj_rs = $aobj_context->mobj_db->Execute($delete_eles);
$delete_details="delete from salary_setup_result where ref_salary_setup_header_code in ( {$lstr_ids} )";
$lobj_rs = $aobj_context->mobj_db->Execute($delete_details);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
function showEmployeeGridForIncometaxMaster($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
$search_by_user = trim($_GET['search_by_user_map']);
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
if(!empty($search_by_user))
{
$table_field_name=stripcslashes($_GET['field_name']);
if(strpos($table_field_name,",")===false)
{
$search_by_user= " where grid_data1 like '%{$search_by_user}%' ";
}
else
{
$search_by_user= " where (grid_data1 like '%{$search_by_user}%' or grid_data2 like '%{$search_by_user}%' or concat(grid_data2,'-',grid_data1) like '%{$search_by_user}%' or concat(grid_data1,'-',grid_data2) like '%{$search_by_user}%' ) ";
}
}
/* $get_table_name_ele_name="select concat('module_',sus.internal_code) as table_name,db_field from s_user_schema sus
inner join s_user_schema_elements suse on suse.ref_s_user_schema_code=sus.internal_code
where module_name='Employee' and name in('Emp Code','Name');"; */
$get_table_name_ele_name="select table_name,field_name1,field_id1,field_name2,field_id2 from module_meta_columns
where module_name='Employee'" ;
$lobj_get_table_name_ele_name = $aobj_context->mobj_db->GetRow($get_table_name_ele_name);
if($lobj_get_table_name_ele_name[field_id2]=='')
{
$field_id2="' '";
}
else
$field_id2=$lobj_get_table_name_ele_name[field_id2];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
".$field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name].") a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
".$field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name].") a $search_by_user";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
".$field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name].")
a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select * from (select internal_code as id,".$lobj_get_table_name_ele_name[field_id1]." as grid_data1,
". $field_id2." as grid_data2 from
".$lobj_get_table_name_ele_name[table_name]."
ORDER BY $sidx $sord LIMIT $start , $limit ) a $search_by_user";
}
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[ grid_data1],$value[grid_data2] );
}
// return the formated data
echo $json->encode($responce);
}
//module setup
function display_module_setup_grid($aobj_context)
{
include_once("/JSON.php");
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name=$_GET['searchField'];
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
if(!$sidx)
$sidx =1;
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from(
select Code as id,Code as grid_m_code,Name as grid_m_name,FMODULE as grid_module_code,Value as grid_module_value
from markentrycodition)a
where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count
from markentrycodition";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from (select Code as id,Code as grid_m_code,Name as grid_m_name,FMODULE as grid_module_code,Value as grid_module_value
from markentrycodition)a
where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
}
else
{
$SQL = "select Code as id,Code as grid_m_code,Name as grid_m_name,FMODULE as grid_module_code,Value as grid_module_value
from markentrycodition
ORDER BY $sidx $sord LIMIT $start , $limit";
} //echo $SQL ;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
//$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs = $aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$responce->rows[$key]['id']=$value[id];
$responce->rows[$key]['cell']=array($value[grid_m_code],$value[grid_m_name],$value[grid_module_code],$value[grid_module_value]);
}
// return the formated data
echo $json->encode($responce);
}
function delete_module_setup_grid($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_ids = $aobj_context->mobj_data["id"];
$lstr_qry = "delete
from markentrycodition
where Code in (".$lstr_ids.")";
// echo $lstr_qry
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
if($lobj_rs)
{
$rdata="Deleted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{ $rdata="Deletion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure");
return $rdata;
}
}
//JIJO UPDAED ON 01/08/2011.
function QpPopup($aobj_context)
{
session_start();
$college_code = $_SESSION['collcode'];
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('FQPCODE','QPSUBJECT','QPMAXMARK');
$display_obj->display_qry = "SELECT FQPCODE as id,FQPCODE,FSUBNAME as QPSUBJECT,FMAXMARKS as QPMAXMARK
FROM masqp
where 1=1";
//echo $display_obj->display_qry; die();
$display_obj->DisplayDetailsInGrid();
}
function OpenQpSubjectPopup($aobj_context)
{
session_start();
$college_code = $_SESSION['collcode'];
include_once($aobj_context->main_src.'/src/display_details_in_grid_custom.php');
$display_obj=new display_details_in_grid($aobj_context);
$display_obj->table_cols=array('FQPCODE','FSUBCODE','FSSUBNAME');
$display_obj->display_qry = "select FQPCODE as id,FQPCODE,FSUBCODE,FSSUBNAME
from subject
where TRIM(FQPCODE)<>''
and FTHEORY='T'
and FINTASS<>'T'
and FRETAIN<>'T' ";
//echo $display_obj->display_qry; die();
$display_obj->DisplayDetailsInGrid();
}
?>
|