Sindbad~EG File Manager
<?php
class APIController extends BaseController {
//GetUser get
public function GetUser(){
try {
$arr = ['UserId' => 0,'Name' => null,'email' => Null,'IsEvaluator' => '0','is_beta_user'=>0,'membership_no'=>Null];
// APIKey=w347H52d96&email=sridhar@numerotec.com&pwd=sridhar
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$email = Input::get("email");
$pwd = Input::get("pwd");
$users = User::where('email',$email)->get();
foreach ($users as $value) {
if (Hash::check($pwd, $value->password)) {
$user = $value;
break;
}
}
if(isset($user))
{
$um = UsersMembership::where('user_id',$user->user_id)->first();
$eval_count = Mark::where('user_id',$user->user_id)->count();
//$arr = ['UserId' => $user->user_id,'Name' => $user->prefix .'.'. $user->first_name,'email' => $user->email,'IsEvaluator' => '0'];
$arr['UserId'] = $user->user_id;
$arr['Name'] = $user->prefix .'.'. $user->first_name;
$arr['email'] = $user->email;
//$arr['is_beta_user'] = $user->is_beta_user;
$arr['is_beta_user'] = is_null($user->is_beta_user)?0:$user->is_beta_user;
$arr['membership_no'] = $um->membership_no;
$arr['IsEvaluator'] = $eval_count>0?1:0;
}
}
} catch (Exception $e) {
Log::error('ARCController - GetUser : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
public function SendOTPMail(){
// APIKey=w347H52d96&mobile=9952899242
try
{
$msg = "";
$status= "";
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$email = Input::get("email");
$user = User::where("email", "=", $email)->first();
if(isset($user) && intval($user->user_id) > 0)
{
if(isset($user->otp))
{
$otp = $user->otp;
}
else
{
$otp = Helper::randomPassword();// Helper::GenerateAndSendOTP($mobile);
}
$datetime = new Datetime;
$user->otp = $otp;
$user->otp_expired_at = $datetime->modify("+10 minutes");
$subject = $otp."-OTP for AIOS smartphone app, valid upto ".date_format($user->otp_expired_at,"d M Y h:i A");
$email = $user->email;
$isMailSend = Mail::send('emails.mobile_app_opt', array('user' => $user), function($message) use ($subject,$email)
{
$message->subject($subject);
$message->to($email);
$message->cc(CustomClass::$BackupId);
});
$operationStatus = $user->save();
$msg ="An Email with OTP has been sent to your email id. It might take upto a minute to reach you.";
$status="success";
}
else
{
$msg = "Email Id does not exist.";
$status="error";
}
}
}catch (Exception $e) {
Log::error('APIController - SendOTPMail : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json(array('msg'=>$msg,'status'=>$status));
}
public function SendOTP(){
// APIKey=w347H52d96&mobile=9952899242
try
{
$msg = "";
$status= "";
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$mobile = Input::get("mobile");
$user = User::where("mobile", "=", $mobile)->first();
if(isset($user) && intval($user->user_id) > 0)
{
$otp = Helper::randomPassword();// Helper::GenerateAndSendOTP($mobile);
$smsContent = "The OTP to login to the AIOS smartphone app is ".$otp;
$requestID = Helper::GenerateAndSendOTP($mobile, $smsContent,$otp);
$user->otp = $otp;
// $otp = Helper::GenerateAndSendOTP($mobile);
// $user->otp = $otp;
$datetime = new Datetime;
$user->otp_expired_at =$datetime->modify("+10 minutes");
$operationStatus = $user->save();
$msg ="An SMS with OTP has been sent to your mobile. It might take upto a minute to reach you.";
$status="success";
}
else
{
$msg = "Mobile number does not exist.";
$status="error";
}
}
}catch (Exception $e) {
Log::error('APIController - SendOTP : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json(array('msg'=>$msg,'status'=>$status));
}
public function VerifyOTP(){
try
{
$data = "";
$status="";
$msg="";
// APIKey=w347H52d96&mobile=9952899242&otp=2327
$arr = ['UserId' => 0,'Name' => null,'email' => Null,'IsEvaluator' => '0','is_beta_user'=>0,'membership_no'=>Null];
$msg = null;
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$mobile = Input::get("mobile");
$otp = Input::get("otp");
$user = User::where("mobile", "=", $mobile)->first();
$datetime = date("Y-m-d H:i:s");
if(isset($user) && intval($user->user_id) > 0)
{
if($user->otp == $otp)
{
if($datetime <= $user->otp_expired_at)
{
$um = UsersMembership::where('user_id',$user->user_id)->first();
$eval_count = Mark::where('user_id',$user->user_id)->count();
$arr['UserId'] = $user->user_id;
$arr['Name'] = $user->prefix .'.'. $user->first_name;
$arr['email'] = $user->email;
$arr['is_beta_user'] = is_null($user->is_beta_user)?0:$user->is_beta_user;
//$arr['is_beta_user'] = $user->is_beta_user;
$arr['membership_no'] = $um->membership_no;
$arr['IsEvaluator'] = $eval_count>0?1:0;
$data = $arr;
$status= "success";
$msg = "";
}
else
{
$msg ="OTP has expired.Please generate a new one.";
$status="error";
$data ="";
}
}
else
{
$msg = "Invalid OTP";
$status="error";
$data ="";
}
}
else
{
$msg = "Mobile number does not exist.";
$status="error";
$data ="";
}
}
}catch (Exception $e) {
Log::error('APIController - VerifyOTP : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json(array('data'=>$data,'msg'=>$msg,'status'=>$status));
}
public function VerifyMailOTP(){
try
{
$data = "";
$status="";
$msg="";
// APIKey=w347H52d96&mobile=9952899242&otp=2327
$arr = ['UserId' => 0,'Name' => null,'email' => Null,'IsEvaluator' => '0','is_beta_user'=>0,'membership_no'=>Null];
$msg = null;
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$email = Input::get("email");
$otp = Input::get("otp");
$user = User::where("email", "=", $email)->first();
$datetime = date("Y-m-d H:i:s");
if(isset($user) && intval($user->user_id) > 0)
{
if($user->otp == $otp)
{
if($datetime <= $user->otp_expired_at)
{
$um = UsersMembership::where('user_id',$user->user_id)->first();
$eval_count = Mark::where('user_id',$user->user_id)->count();
$user->otp = null;
$user->save();
$arr['UserId'] = $user->user_id;
$arr['Name'] = $user->prefix .'.'. $user->first_name;
$arr['email'] = $user->email;
$arr['is_beta_user'] = is_null($user->is_beta_user)?0:$user->is_beta_user;
//$arr['is_beta_user'] = $user->is_beta_user;
$arr['membership_no'] = $um->membership_no;
$arr['IsEvaluator'] = $eval_count>0?1:0;
$data = $arr;
$status= "success";
$msg = "";
}
else
{
$msg ="OTP has expired.Please generate a new one.";
$status="error";
$data ="";
}
}
else
{
$msg = "Invalid OTP";
$status="error";
$data ="";
}
}
else
{
$msg = "Email Id does not exist.";
$status="error";
$data ="";
}
}
}catch (Exception $e) {
Log::error('APIController - VerifyMailOTP : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json(array('data'=>$data,'msg'=>$msg,'status'=>$status));
}
//SyncAbstract
public function SyncAbstract1(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$ic_count = Input::has("ICCount") ? Input::get("ICCount") :0;
$fp_count = Input::has("FPCount") ? Input::get("FPCount") :0;
$vt_count = Input::has("VTCount") ? Input::get("VTCount") :0;
$gp_count = Input::has("GPCount") ? Input::get("GPCount") :0;
$ka_count = Input::has("KACount") ? Input::get("KACount") :0;
$kaic_count = Input::has("KAICCount") ? Input::get("KAICCount") :0;
$ic_id = Input::has("ICId")?Input::get("ICId"):0;
$fp_id = Input::has("FPId")?Input::get("FPId"):0;
$vt_id = Input::has("VTId")?Input::get("VTId"):0;
$gp_id = Input::has("GPId")?Input::get("GPId"):0;
$ka_id = Input::has("KAId")?Input::get("KAId"):0;
$kaic_id = Input::has("KAICId")?Input::get("KAICId"):0;
//$is_first_time = Input::get("isFirstTime");
$data = DB::select("call usp_MobSync($ic_count,$fp_count,$vt_count,$gp_count,$ka_count,$kaic_count,$ic_id,$fp_id,$vt_id,$gp_id,$ka_id,$kaic_id)");
$arr = $data;
}
} catch (Exception $e) {
Log::error('ARCController - SyncAbstract : '.$e->getMessage());
//echo $e->getMessage();
}
return Response::json($arr);
}
//SyncAbstract
public function SyncAbstract(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$last_sync_at = Input::has("last_sync_at") ? Input::get("last_sync_at") :0;
$data= DB::table('sqlite_eabstract')->where('updated_at', '>', $last_sync_at)->get();
$arr = $data;
}
} catch (Exception $e) {
Log::error('ARCController - SyncAbstract : '.$e->getMessage());
//echo $e->getMessage();
}
return Response::json($arr);
}
// //SyncAgenda
// // old version
// // command by Sridhar On 29 dec 2016 11:24 AM
// public function SyncAgenda(){
// try {
// $arr = [];
// if(CustomClass::$APIKey == Input::get("APIKey"))
// {
// $returnlst = [];
// $insertagenda = [];
// $agenda_ids = [];
// $uId = intval(Input::get("userId"));
// $is_first_time = Input::get("isFirstTime");
// $syncAgendaItem = [];
// $json = file_get_contents('php://input');
// if(!empty($json))
// {
// $syncAgendaItem = json_decode($json);
// }
// Log::info('SyncAgenda : '. $json);
// if($uId>0)
// {
// $webagenda = DB::table('agenda')->where('user_id',$uId)->get();
// if ($syncAgendaItem != null)
// {
// foreach ($syncAgendaItem as $key => $item) {
// $a = [];
// $a['CanDelete'] = 1;
// $a['Id'] = $item->Id;
// $a['Type'] = $item->Type;
// $a['UserId'] = $uId;
// // $a['IsWeb'] = 1;
// // $a['IsDevice'] = 1;
// $result = $this->findAgenda($webagenda,$item->Type,$item->Id);
// if(isset($result))
// {
// //update CanDelete column from table
// $a['CanDelete'] = $result->can_delete;
// array_push($agenda_ids, $result->agenda_id);
// //return agenda
// array_push($returnlst, $a);
// }
// else
// {
// //insert agenda
// array_push($insertagenda,$a);
// //return agenda
// array_push($returnlst, $a);
// }
// }
// }
// if(intval($is_first_time) == 1)
// {
// $data = DB::table('agenda')->where('user_id',$uId)->whereNotIn('agenda_id',$agenda_ids)->get();
// foreach ($data as $key => $item) {
// $a = [];
// $a['CanDelete'] = $item->can_delete;
// $a['Id'] = $item->abs_id;
// $a['Type'] = $item->abs_type;
// $a['UserId'] = $uId;
// //return agenda
// array_push($returnlst, $a);
// }
// }
// else
// {
// DB::table('agenda')->where('user_id',$uId)->where('can_delete',1)->whereNotIn('agenda_id',$agenda_ids)->delete();
// }
// if(count($insertagenda)>0)
// {
// $insert_data = [];
// foreach ($insertagenda as $key => $value) {
// array_push($insert_data, array(
// 'user_id' => $uId
// ,'abs_type' => $value['Type']
// ,'abs_id' =>$value['Id']
// ,'can_delete'=>1));
// }
// DB::table('agenda')->insert($insert_data);
// }
// $arr = $returnlst;
// }
// }
// } catch (Exception $e) {
// Log::error('ARCController - SyncAgenda : '.$e->getMessage());
// //echo $e->getMessage();
// }
// return Response::json($arr);
// }
//SyncAgenda
//New version
// Update by Gowthami On 10 july 2017 11:24
// Last Update by sridhar On 17 Jan 2018 11:15
public function SyncAgenda(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$returnlst = [];
$insertagenda = [];
$agenda_ids = [];
$dbabsids = [];
$mobabsids = [];
$delete_agenda_ids = [];
$uId = intval(Input::get("user_id"));
$is_first_time = Input::get("isFirstTime");
$syncAgendaItem = [];
$json = file_get_contents('php://input');
if(!empty($json))
{
$syncAgendaItem = json_decode($json);
}
Log::info('SyncAgenda is first time : '.$is_first_time);
Log::info('SyncAgenda : '. $json);
if($uId>0)
{
$av_codes = DB::table('authors')->where('user_id',$uId)->whereNotNull('av_code')->get();
$abs_av_codes = [];
foreach ($av_codes as $key => $value) {
$abs_av_codes[$value->abs_id][] = $value->av_code;
}
$webagenda = DB::table('agenda')->where('user_id',$uId)->get();
foreach ($webagenda as $key => $value) {
$abs_id = $value->abs_id;
array_push($dbabsids,$abs_id);
}
if ($syncAgendaItem != null)
{
foreach ($syncAgendaItem as $key => $item) {
$a = [];
$a['can_delete'] = 1;
$a['abs_id'] = $item->abs_id;
$a['user_id'] = $uId;
$a['misc1'] = "";
//$a['misc1'] = (isset($abs_av_codes[$item->abs_id])? implode(', ',$abs_av_codes[$item->abs_id]):'');
array_push($mobabsids,$a['abs_id']);
$result = $this->findAgenda($webagenda,$item->abs_id);
if(isset($result))
{
// if($item->IsDevice == "1")
// {
//update CanDelete column from table
$a['can_delete'] = $result->can_delete;
array_push($agenda_ids, $result->agenda_id);
//return agenda
array_push($returnlst, $a);
// }
// else
// {
// array_push($delete_agenda_ids, $result->agenda_id);
// }
}
else
{
// if($item->IsDevice == "1")
// {
// //insert agenda
array_push($insertagenda,$a);
//return agenda
array_push($returnlst, $a);
// }
}
}
}
$delete_agenda_ids=array_diff($dbabsids,$mobabsids);
Log::info('deleteids : '. json_encode($delete_agenda_ids));
if(count($delete_agenda_ids)>0 && !($is_first_time =="1"))
{
Log::info('iddeleted : '. json_encode($delete_agenda_ids));
DB::table('agenda')->where('user_id',$uId)->where('can_delete',1)->whereIn('abs_id',$delete_agenda_ids)->delete();
}
$data = DB::table('agenda')->where('user_id',$uId)->whereNotIn('agenda_id',$agenda_ids)->get();
Log::info('SyncAgenda Web : '. json_encode($data));
foreach ($data as $key => $item) {
$a = [];
$a['can_delete'] = $item->can_delete;
$a['abs_id'] = $item->abs_id;
$a['user_id'] = $uId;
$a['misc1'] = "";
//$a['misc1'] = (isset($abs_av_codes[$item->abs_id])? implode(', ',$abs_av_codes[$item->abs_id]):'');
//return agenda
array_push($returnlst, $a);
}
if(count($insertagenda)>0)
{
$insert_data = [];
foreach ($insertagenda as $key => $value) {
array_push($insert_data, array(
'user_id' => $uId
,'abs_id' =>$value['abs_id']
,'can_delete'=>1
,'created_at'=>date('Y-m-d H:i:s')
,'updated_at'=>date('Y-m-d H:i:s')));
}
DB::table('agenda')->insert($insert_data);
}
$arr = $returnlst;
}
}
} catch (Exception $e) {
Log::error('ARCController - SyncAgenda : '.$e->getMessage());
//echo $e->getMessage();
}
Log::info('SyncAgenda Return : '. json_encode($arr));
return Response::json($arr);
}
// //SyncFeedback
// public function SyncFeedback(){
// try {
// $arr = [];
// if(CustomClass::$APIKey == Input::get("APIKey"))
// {
// $returnlst = [];
// $insertfeedback = [];
// $feedback_ids = [];
// $uId = intval(Input::get("userId"));
// $syncFeedbackItem = [];
// $json = file_get_contents('php://input');
// if(!empty($json))
// {
// $syncFeedbackItem = json_decode($json);
// }
// Log::info('SyncFeedback : '. $json);
// if($uId>0)
// {
// $webfeedback = DB::table('feedback_app')->where('user_id',$uId)->get();
// if ($syncFeedbackItem != null && count($syncFeedbackItem)>0)
// {
// foreach ($syncFeedbackItem as $key => $item) {
// $a = [];
// $a['AbsType'] = $item->AbsType;
// $a['AbsId'] = $item->AbsId;
// $a['Rating'] = $item->Rating;
// $a['Suggestion'] = $item->Suggestion;
// $a['Notes'] = isset($item->Notes)?$item->Notes:null;
// $a['UserId'] = $uId;
// $a['IsPhysicalPoster'] =isset($item->IsPhysicalPoster)?$item->IsPhysicalPoster:null;
// if(intval(isset($item->IsPhysicalPoster)?$item->IsPhysicalPoster:0) == 1)
// {
// $a['Originality'] = $item->Originality;
// $a['Content'] = $item->Content;
// $a['Presentation'] = $item->Presentation;
// $a['Contribution'] = $item->Contribution;
// }
// else
// {
// $a['Originality'] = null;
// $a['Content'] = null;
// $a['Presentation'] = null;
// $a['Contribution'] = null;
// }
// // $a['IsWeb'] = 1;
// // $a['IsDevice'] = 1;
// $result = $this->findFeedback($webfeedback,$item->AbsType,$item->AbsId);
// if(isset($result))
// {
// // array_push($feedback_ids, $result->feedback_id);
// //return agenda
// //array_push($returnlst, $a);
// }
// else
// {
// //insert agenda
// array_push($insertfeedback,$a);
// //return agenda
// array_push($returnlst, $a);
// }
// }
// }
// // $data = DB::table('feedback_app')->where('user_id',$uId)->whereNotIn('feedback_id',$feedback_ids)->get();
// foreach ($webfeedback as $key => $item) {
// $a = [];
// $a['AbsType'] = $item->abs_type;
// $a['AbsId'] = $item->abs_id;
// $a['Rating'] = $item->over_all;
// $a['Suggestion'] = $item->suggestion;
// $a['Notes'] = $item->notes;
// $a['UserId'] = $uId;
// $a['IsPhysicalPoster'] =$item->is_physical_poster;
// $a['Originality'] = $item->originality;
// $a['Content'] = $item->content;
// $a['Presentation'] = $item->presentation;
// $a['Contribution'] = $item->contribution;
// //return agenda
// array_push($returnlst, $a);
// }
// if(count($insertfeedback)>0)
// {
// $insert_data = [];
// foreach ($insertfeedback as $key => $value) {
// array_push($insert_data,
// array(
// 'over_all' => $value['Rating']
// ,'suggestion' => $value['Suggestion']
// ,'user_id' => $value['UserId']
// ,'submitted_on' => date('Y-m-d H:s:i')
// ,'abs_type' => $value['AbsType']
// ,'abs_id' => $value['AbsId']
// ,'notes' => $value['Notes']
// ,'is_physical_poster' => $value['IsPhysicalPoster']
// ,'originality' => $value['Originality']
// ,'content' => $value['Content']
// ,'presentation' => $value['Presentation']
// ,'contribution' => $value['Contribution']
// ));
// }
// DB::table('feedback_app')->insert($insert_data);
// }
// /*** Call Notification ***/
// try {
// $usersMessages = [];
// $feedbacks = DB::select("call usp_get_feedback_notification(".$uId.")");
// Log::info('get feedbacks count : '. count($feedbacks));
// foreach ($feedbacks as $key => $item) {
// $obj = new stdClass();
// $obj->user_id = $item->user_id;
// if($item->abs_no ==null)
// {
// $obj->message = "Feedback received for ". $item->title .", Go to E-Abstract -> Feedback received.";
// }
// else
// {
// $obj->message = "Feedback received for ". $item->abs_type . $item->abs_no .", Go to E-Abstract -> Feedback received.";
// }
// array_push($usersMessages, $obj);
// }
// } catch (Exception $e) {
// Log::error('ARCController - SyncFeedback get Notification data : '.$e->getMessage());
// echo 'ARCController - SyncFeedback get Notification data : '. $e->getMessage();
// }
// //echo json_encode($usersMessages);
// Log::info('SyncFeedback count : '. count($usersMessages));
// try {
// Helper::sendNotifications($usersMessages, "AIOS - FEEDBACK");
// } catch (Exception $e) {
// echo "SyncFeedback - sendNotifications : " . $e->getMessage();
// Log::error('APIController - SyncFeedback - sendNotifications : '.$e->getMessage());
// }
// // var_dump($res);
// /*** Call Notification ***/
// $arr = $returnlst;
// }
// }
// } catch (Exception $e) {
// Log::error('ARCController - SyncFeedback : '.$e->getMessage());
// echo $e->getMessage();
// }
// return Response::json($arr);
// }
//SyncFeedback
public function SyncFeedback(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$uId = intval(Input::get("user_id"));
$syncFeedbackItem = [];
$json = file_get_contents('php://input');
if(!empty($json))
{
$syncFeedbackItem = json_decode($json);
}
Log::info('SyncFeedback : '. $json);
if($uId>0)
{
if ($syncFeedbackItem != null && count($syncFeedbackItem)>0)
{
foreach ($syncFeedbackItem as $key => $item) {
if($item->feedback_for=="EVALUATION")
{
$fb = Feedback::where('user_id',$uId)->where('abs_type',$item->abs_type)->where('feedback_for',$item->feedback_for)->where('platform_id',CustomClass::$Platform_Mobile)->first();
if($fb == null)
{
$fb = new Feedback();
}
$fb->abs_type = $item->abs_type;
$fb->feedback_for = $item->feedback_for;
$fb->rating = $item->rating;
$fb->suggestions = $item->suggestions;
$fb->user_id = $uId;
$fb->platform_id = CustomClass::$Platform_Mobile;
$fb->save();
}
else
{
$fb = Feedback::where('user_id',$uId)->where('abs_id',$item->abs_id)->where('feedback_for',$item->feedback_for)->where('platform_id',CustomClass:: $Platform_Mobile)->first();
if($fb == null)
{
$fb = new Feedback();
$fb->abs_id = $item->abs_id;
$fb->abs_type = $item->abs_type;
$fb->feedback_for = $item->feedback_for;
$fb->rating = $item->rating;
$fb->suggestions = $item->suggestions;
$fb->user_id = $uId;
$fb->platform_id = CustomClass::$Platform_Mobile;
$fb->save();
}
}
}
}
$arr = Feedback::where('user_id',$uId)->where('platform_id',CustomClass::$Platform_Mobile)->get();
/*** Call Notification ***/
try {
$usersMessages = [];
$userssmsMessages = [];
$usersemailMessages = [];
$feedbacks = DB::select("call usp_get_feedback_notification(".$uId.")");
Log::info('get feedbacks count : '. count($feedbacks));
foreach ($feedbacks as $key => $item) {
//Mobile Notifictions
$obj = new stdClass();
$obj->user_id = $item->user_id;
if($item->abs_no ==null)
{
$obj->message = 'Feedback for '. $item->title .', by '.$item->member_name .', To view visit "Feedback" section in the AIOS app';
}
else
{
$obj->message = 'Feedback for '. $item->abs_type . $item->abs_no .', by '.$item->member_name .', To view visit "Feedback" section in the AIOS app';
}
array_push($usersMessages, $obj);
//SMS Notification
if(!empty($item->author_mobile))
{
$objsms = new stdClass();
$objsms->to = [$item->author_mobile];
if($item->abs_no ==null)
{
$objsms->message = urlencode('Hi, You have received feedback for '. $item->title .' from '.$item->member_name .'. View it on "AIOS" smartphone app. You can download the app from https://goo.gl/LAVIXP');
}
else
{
$objsms->message = urlencode('Hi, You have received feedback for '. $item->abs_type . $item->abs_no .' from '.$item->member_name .'. View it on "AIOS" smartphone app. You can download the app from https://goo.gl/LAVIXP');
}
array_push($userssmsMessages, $objsms);
}
//Email Notification
$objemail = new stdClass();
$objemail->email = $item->author_email;
$objemail->member_name=$item->member_name;
if($item->abs_no ==null)
{
$objemail->session = $item->title;
$objemail->subject = 'Feedback from '.$item->member_name.' on '.$item->title;
}
else
{
$objemail->session = $item->abs_type . $item->abs_no. ' - '.$item->title;
$objemail->subject = 'Feedback from '.$item->member_name.' on '.$item->abs_type . $item->abs_no;
}
array_push($usersemailMessages, $objemail);
}
} catch (Exception $e) {
Log::error('ARCController - SyncFeedback get Notification data : '.$e->getMessage());
echo 'ARCController - SyncFeedback get Notification data : '. $e->getMessage();
}
Log::info('SyncFeedback count : '. count($usersMessages));
if( count($usersMessages)>0)
{
try {
Helper::sendNotifications($usersMessages, "AIOS - FEEDBACK");
} catch (Exception $e) {
echo "SyncFeedback - sendNotifications : " . $e->getMessage();
Log::error('APIController - SyncFeedback - sendNotifications : '.$e->getMessage());
}
}
if( count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "FEEDBACK");
} catch (Exception $e) {
echo "SyncFeedback - sendSMS : " . $e->getMessage();
Log::error('APIController - SyncFeedback - sendSMS : '.$e->getMessage());
}
}
if( count($usersemailMessages)>0)
{
try {
$this->sendEmailFeedback($usersemailMessages);
} catch (Exception $e) {
echo "SyncFeedback - sendEmail : " . $e->getMessage();
Log::error('APIController - SyncFeedback - sendEmail : '.$e->getMessage());
}
}
/*** Call Notification ***/
}
}
}
catch (Exception $e) {
Log::error('APIController - SyncFeedback : '.$e->getMessage());
$arr = [];
}
return Response::json($arr);
}
/*
Author : Sridhar On 19 Jan 2018 10.48
*/
static function sendEmailFeedback($arrObjects)
{
foreach ($arrObjects as $key => $obj) {
if(!empty($obj->email))
{
$isMailSend = Mail::send('emails.notification.feedback', array('session' => $obj->session,'member_name' => $obj->member_name), function($message) use ($obj)
{
$message->subject($obj->subject);
$message->to($obj->email);
$message->cc(CustomClass::$BackupId);
});
}
}
}
public function findAgenda($webagenda,$absId)
{
foreach ($webagenda as $key => $value) {
if($value->abs_id==$absId)
{
return $value;
break;
}
}
return null;
}
public function findFeedback($webfeedback,$absType,$absId)
{
foreach ($webfeedback as $key => $value) {
if($value->abs_type == $absType && $value->abs_id==$absId)
{
return $value;
break;
}
}
return null;
}
public function GetProfile(){
try {
$arr =[];
// $arr = ['UserId' => 0,'Email' => Null,'Prefix'=>null,'Name' => null,'Dob'=>null,'Address1'=>null,'Address2'=>null,'Address3'=>null,'City'=>null,'Country'=>null,'State'=>null,'Pincode'=>0,'Mobile_isd_code'=>null,'Mobile'=>null,'Phone_home'=>null,'Phone_office'=>null,'Asset_id'=>0,'File_name'=>null,'Extension'=>null,'Path'=>null];
// APIKey=w347H52d96&email=sridhar@numerotec.com&pwd=sridhar
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$user_id = Input::get("user_id");
$users = User::where('user_id',$user_id)->get();
foreach ($users as $value) {
$user = $value;
}
if(isset($user))
{
$as = Asset::where('user_id',$user->user_id)->first();
//$arr = ['UserId' => $user->user_id,'Name' => $user->prefix .'.'. $user->first_name,'email' => $user->email,'IsEvaluator' => '0'];
$arr['user_id'] = $user->user_id;
$arr['email'] = $user->email;
$arr['prefix'] = $user->prefix;
$arr['name'] = $user->first_name;
$arr['sur_name'] = $user->sur_name;
$arr['dob'] = $user->dob;
$arr['address1'] = $user->address1;
$arr['address2'] = $user->address2;
$arr['address3'] = $user->address3;
$arr['city'] = $user->city;
$arr['country'] = $user->country;
$arr['state'] = $user->state;
$arr['pincode'] = $user->pincode;
$arr['mobile_isd_code'] = $user->mobile_isd_code;
$arr['mobile'] = $user->mobile;
$arr['phone_home'] = $user->phone_home;
$arr['phone_office'] = $user->phone_office;
if($as != null)
{
$arr['asset_id'] = $as->asset_id;
$arr['file_name'] = $as->file_name;
$arr['extension'] = $as->extension;
$arr['path'] = $as->path;
}
else
{
$arr['asset_id'] = null;
$arr['file_name'] = null;
$arr['extension'] = null;
$arr['path'] = null;
}
}
}
} catch (Exception $e) {
Log::error('ARCController - GetProfile : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
public function UpdateProfile(){
try {
$arr_msg = [];
$arr =[];
$temp='';
// $arr = ['UserId' => 0,'Email' => Null,'Prefix'=>null,'Name' => null,'Dob'=>null,'Address1'=>null,'Address2'=>null,'Address3'=>null,'City'=>null,'Country'=>null,'State'=>null,'Pincode'=>0,'Mobile_isd_code'=>null,'Mobile'=>null,'Phone_home'=>null,'Phone_office'=>null,'Asset_id'=>0,'File_name'=>null,'Extension'=>null,'Path'=>null];
// APIKey=w347H52d96&email=sridhar@numerotec.com&pwd=sridhar
if(CustomClass::$APIKey == Input::get("APIKey"))
{
// http://localhost/aios/public/api/UpdateProfile?userid=2&prefix=S&name=vcbvcb&sur_name=Siva&dob=6/9/1991&address1=sss&address2=sss&address3=sss&city=erode&state_id=3&pincode=675674&country_id=4&mobile_isd_code=91&mobile=9952899242&email=demo@numerotec.com&phone_home=99312&phone_office=532&APIKey=w347H52d96
$user_id = Input::get("user_id");
$users = User::find($user_id);
$users->email = Helper::trimAndTruncate(Input::get('email'),250);
$users->prefix = Helper::trimAndTruncate(Input::get('prefix'),10);
$users->first_name = Helper::trimAndTruncate(Input::get('name'),250);
$users->sur_name = Helper::trimAndTruncate(Input::get('sur_name'),250);
$users->dob = Helper::toDBDate(Helper::trimAndTruncate(Input::get('dob')));
$users->address1 = Helper::trimAndTruncate(Input::get('address1'),250);
$users->address2 = Helper::trimAndTruncate(Input::get('address2'),250);
$users->address3 = Helper::trimAndTruncate(Input::get('address3'),250);
$users->city = Helper::trimAndTruncate(Input::get('city'),250);
$users->state = Input::get('state');
//$user->state = Helper::trimAndTruncate(Input::get('txtState'),250);
$users->country = Input::get('country');
$users->pincode = Helper::trimAndTruncate(Input::get('pincode'),250);
//$user->country = Helper::trimAndTruncate(Input::get('txtCountry'),250);
$users->mobile_isd_code = Helper::trimAndTruncate(Input::get('mobile_isd_code'),5);
$users->mobile = Helper::trimAndTruncate(Input::get('mobile'),15);
$users->phone_home = Helper::trimAndTruncate(Input::get('phone_home'),100);
$users->phone_office= Helper::trimAndTruncate(Input::get('phone_office'),100);
$validator = $this->validatorProfile($users);
if(isset($validator) && !$validator->fails())
{
//$code=1;
if($users->save()){
$assets = [];
$isUpdateImg = false;
$path ="";
//Create directory for the users to hold their documents/attachments
$directoryPath = public_path().'/uploads/'.$users->user_id ;
if(!File::exists($directoryPath))
File::makeDirectory($directoryPath, 0777, true);
//Attachment profile picture
if (Input::hasFile('fileProfile')) {
$file = Input::file('fileProfile');
if(isset($file) && $file->isValid())
{
$extension = $file->getClientOriginalExtension();
$fileName = CustomClass::$ASSET_USAGE_MEMBER_PROFILE_FILENAME;
$fileNameWithExtension = $fileName.'.'.$extension;
$destinationPath = $directoryPath."/".$fileNameWithExtension ;
$path = 'uploads/'.$users->user_id."/".$fileNameWithExtension ;
$file->move($directoryPath, $fileNameWithExtension);
$asset = Asset::where('user_id',$users->user_id)->where('file_name','profile')->first();
if(!isset($asset))
{
$asset = new Asset();
}
$asset->user_id = $users->user_id;
$asset->extension = $extension;
$asset->file_name = $fileName;
$asset->path = $path;
$asset->save();
$isUpdateImg = true;
}
}
}
array_push($arr_msg, array('msg' => 'SUCCESS'));
}
else
{
$code=0;
$requiredCount = 0;
$messages = $validator->messages();
foreach ($messages->all() as $message)
{
array_push($arr_msg, array('msg' => $message));
// if(preg_match('[required]', $message))
// {
// if($requiredCount == 0)
// {
// $temp = $temp .''. $message ."\n";
// $requiredCount++;
// }
// }
// else
// {
// $temp =$temp .''. $message."\n" ;
// }
}
}
}
} catch (Exception $e) {
Log::error('APIController - UpdateProfile : '.$e->getMessage());
array_push($arr_msg, array('msg' => 'ERR_GENERAL'));
// echo $e->getMessage();
}
return Response::json($arr_msg);
}
public function validatorProfile($user)
{
try
{
$inputs = array(
'prefix' => $user->prefix,
'name' => $user->first_name,
'address1' => $user->address1,
'city' => $user->city,
'state' => $user->state,
'pincode' => $user->pincode,
'mobile_isd_code'=> $user->mobile_isd_code,
'mobile' => $user->mobile,
'email' => $user->email
);
$rules = array(
'prefix' => 'required',
'name' => 'required',
'address1' => 'required',
'city' => 'required',
'state' => 'required',
'pincode' => 'required',
'mobile_isd_code'=> 'required',
'mobile' => 'required',
'email' => 'required|email|unique:users,email,'.$user->user_id.',user_id,deleted_at,NULL',
);
$messages = array(
'prefix.required' => 'ERR_REQ_PREFIX',
'name.required' => 'ERR_REQ_NAME',
'address1.required' => 'ERR_REQ_ADDRESS1',
'city.required' => 'ERR_REQ_CITY',
'state.required' => 'ERR_REQ_STATE',
'pincode.required' => 'ERR_REQ_PINCODE',
'mobile_isd_code.required'=> 'ERR_REQ_ISD_CODE',
'mobile.required' => 'ERR_REQ_MOBILE',
'email.required' => 'ERR_REQ_EMAIL',
'email.email' => 'ERR_INVALID_EMAIL',
'email.unique' => 'ERR_EMAIL_EXISTS'
);
return Validator::make($inputs,$rules,$messages);
} catch (Exception $e)
{
Log::error("APIController - validatorProfile ".$e->getMessage());
}
}
/*
Author by gowthami on 13-12-16
url: http://localhost/aios/public/api/GetallFeedback?APIKey=w347H52d96
Purpose:For getting all feedback.
*/
public function GetallFeedback(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$user_id=Input::get('user_id');
$returnlst = [];
$webfeedback = DB::select("call usp_getfeedback('".$user_id."')");
foreach ($webfeedback as $key => $item) {
$a = [];
$a['user_id'] = $item->user_id;
$a['user_name'] = $item->user_name;
$a['feedback_id'] = $item->feedback_id;
$a['title'] = $item->title;
$a['abs_type'] = $item->abs_type;
$a['abs_id'] = $item->abs_id;
$a['abs_no'] = $item->abs_no;
$a['submitted_on'] = $item->submitted_on;
$a['rating'] = $item->over_all;
$a['suggestion'] = $item->suggestion;
$a['notes'] = $item->notes;
$a['is_physical_poster'] = $item->is_physical_poster;
$a['originality'] = $item->originality;
$a['content'] = $item->content;
$a['presentation'] = $item->presentation;
$a['contribution'] = $item->contribution;
//return agenda
array_push($returnlst, $a);
}
$arr = $returnlst;
}
} catch (Exception $e) {
Log::error('APIController - GetallFeedback : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
/*
Author : sridhar On 27 Dec 2017 3.43 PM
usage : get user abstracts feed back from another uses
*/
public function GetUserAbsFeedbacks(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$user_id=Input::get('user_id');
$feedback_for=Input::get('feedback_for');
if(empty($feedback_for))
{
return Response::json($arr);
}
$returnlst = [];
$feedbacks = DB::select("call usp_get_feedback('".$feedback_for."','".$user_id."')");
// foreach ($feedbacks as $key => $item) {
// $a = [];
// $a['user_id'] = $item->user_id;
// $a['user_name'] = $item->user_name;
// $a['feedback_id'] = $item->feedback_id;
// $a['title'] = $item->title;
// $a['abs_type'] = $item->abs_type;
// $a['abs_id'] = $item->abs_id;
// $a['abs_no'] = $item->abs_no;
// $a['submitted_on'] = $item->submitted_on;
// $a['rating'] = $item->over_all;
// $a['suggestion'] = $item->suggestion;
// $a['notes'] = $item->notes;
// $a['is_physical_poster'] = $item->is_physical_poster;
// $a['originality'] = $item->originality;
// $a['content'] = $item->content;
// $a['presentation'] = $item->presentation;
// $a['contribution'] = $item->contribution;
// //return agenda
// array_push($returnlst, $a);
// }
$arr = $feedbacks;
}
} catch (Exception $e) {
Log::error('APIController - GetUserAbsFeedbacks : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
/*Update By Sridhar On 2017 Dec 28*/
public function SyncQueries(){
$arr =[];
try {
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$returnlst = [];
$insertfeedback = [];
$feedback_ids = [];
$uId = intval(Input::get("user_id"));
$syncQueriesItem = [];
$json = file_get_contents('php://input');
if(!empty($json))
{
$syncQueriesItem = json_decode($json);
}
Log::info('SyncQueries : '. $json);
//Log::info('SyncQueries Cnv Json : '. json_encode($syncQueriesItem));
if(count($syncQueriesItem)>0)
{
$insert_data = [];
foreach ($syncQueriesItem as $key => $value) {
array_push($insert_data,
array(
'UserId' => $value->UserId=="<null>"? null: $value->UserId
,'UserName' => $value->UserName=="<null>"? null: $value->UserName
,'Queries' => $value->Queries=="<null>"? null: $value->Queries
,'AbsType' => $value->AbsType=="<null>"? null: $value->AbsType
,'AbsId' => $value->AbsId=="<null>"? null: $value->AbsId
,'ReplyforId' => isset($value->ReplyforId)? ($value->ReplyforId=="<null>"? null: $value->ReplyforId): null
,'RepliedByUserId' => isset($value->RepliedByUserId)? ($value->RepliedByUserId=="<null>"? null: $value->RepliedByUserId) :null
,'RepliedByUserName'=> isset($value->RepliedByUserName)? ($value->RepliedByUserName=="<null>"? null: $value->RepliedByUserName):null
,'created_at' => Helper::currentIndianTime()
));
}
DB::table('Queries')->insert($insert_data);
}
$webfeedback = DB::select("call usp_get_queries('". $uId ."')");
foreach ($webfeedback as $key => $item) {
$a = [];
$a['QueryId'] = $item->QueryId;
$a['UserId'] = $item->UserId;
$a['UserName'] = $item->UserName;
$a['Queries'] = $item->Queries;
$a['AbsType'] = $item->AbsType;
$a['AbsId'] = $item->AbsId;
$a['ReplyforId'] = $item->ReplyforId;
$a['RepliedByUserId'] = $item->RepliedByUserId;
$a['RepliedByUserName'] = $item->RepliedByUserName;
$a['created_at'] = $item->created_at;
//return agenda
array_push($returnlst, $a);
}
/*** Call Notification ***/
try {
$usersMessages = [];
$userssmsMessages = [];
$usersemailMessages = [];
$Queries = [];
$Queries = DB::select("call usp_get_query_notification(".$uId.")");
Log::info('get Queries count : '. count($Queries));
foreach ($Queries as $key => $item) {
$obj = new stdClass();
$obj->user_id = $item->user_id;
if($item->is_reply == 1)
{
if($item->abs_no ==null)
{
$obj->message = 'You have received a response for the query on '. $item->title .'. from '.$item->member_name.', To view / reply visit "Queries" section';
}
else
{
$obj->message = 'You have received a response for the query on '. $item->abs_type . $item->abs_no .'. from '.$item->member_name.', To view / reply visit "Queries" section';
}
}
else
{
if($item->abs_no ==null)
{
$obj->message = 'You have received a query on '. $item->title .' from '. $item->member_name .'. To view & reply visit "Queries" section.';
}
else
{
$obj->message = 'You have received a query on '. $item->abs_type . $item->abs_no .' from '. $item->member_name .'. To view & reply visit "Queries" section.';
}
}
array_push($usersMessages, $obj);
//SMS Notification
if(!empty($item->author_mobile))
{
$objsms = new stdClass();
$objsms->to = [$item->author_mobile];
if($item->is_reply == 1)
{
if($item->abs_no ==null)
{
$objsms->message = urlencode('Hi, You have received a response for the query on '. $item->title .'. from '. $item->member_name .'. To view / reply. visit the "Queries" section on the AIOS Smartphone app. You can download the app from https://goo.gl/LAVIXP');
}
else
{
$objsms->message = urlencode('Hi, You have received a response for the query on '. $item->abs_type . $item->abs_no .'. from '. $item->member_name .'. To view / reply. visit the "Queries" section on the AIOS Smartphone app. You can download the app from https://goo.gl/LAVIXP');
}
}
else
{
if($item->abs_no ==null)
{
$objsms->message = urlencode('Hi, You have received a query on '. $item->title .'.from '.$item->member_name.', To view / reply. visit the "Queries" section on "AIOS" smartphone app. You can download the app from https://goo.gl/LAVIXP');
}
else
{
$objsms->message = urlencode('Hi, You have received a query on '. $item->abs_type . $item->abs_no .'.from '.$item->member_name.', To view / reply. visit the "Queries" section on "AIOS" smartphone app. You can download the app from https://goo.gl/LAVIXP');
}
}
array_push($userssmsMessages, $objsms);
}
//Email Notification
$objemail = new stdClass();
$objemail->email = $item->author_email;
$objemail->member_name=$item->member_name;
$objemail->is_reply=$item->is_reply;
if($item->abs_no ==null)
{
$objemail->session = $item->title;
if($item->is_reply==1)
$objemail->subject = 'Query reply from '.$item->member_name.' on '.$item->title;
else
$objemail->subject = 'Query from '.$item->member_name.' on '.$item->title;
}
else
{
$objemail->session = $item->abs_type . $item->abs_no;
if($item->is_reply==1)
$objemail->subject = 'Query reply from '.$item->member_name.' on '.$item->abs_type . $item->abs_no;
else
$objemail->subject = 'Query from '.$item->member_name.' on '.$item->abs_type . $item->abs_no;
}
array_push($usersemailMessages, $objemail);
}
} catch (Exception $e) {
Log::error('APIController - SyncQueries get Notification data : '.$e->getMessage());
echo 'APIController - SyncQueries get Notification data : '. $e->getMessage();
}
if( count($usersMessages)>0)
{
//echo json_encode($usersMessages);
Log::info('SyncQueries count : '. count($usersMessages));
try {
Helper::sendNotifications($usersMessages, "AIOS - QUERIES");
} catch (Exception $e) {
echo "SyncQueries - sendNotifications : " . $e->getMessage();
Log::error('APIController - SyncQueries - sendNotifications : '.$e->getMessage());
}
}
if( count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "QUERIES");
} catch (Exception $e) {
echo "SyncQueries - sendSMS : " . $e->getMessage();
Log::error('APIController - SyncQueries - sendSMS : '.$e->getMessage());
}
}
if( count($usersemailMessages)>0)
{
try {
$this->sendEmailQuery($usersemailMessages);
} catch (Exception $e) {
echo "SyncQueries - sendEmail : " . $e->getMessage();
Log::error('APIController - SyncQueries - sendEmail : '.$e->getMessage());
}
}
// var_dump($res);
/*** Call Notification ***/
$arr = $returnlst;
}
} catch (Exception $e) {
Log::error('APIController - SyncQueries : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
/*
Author : Sridhar On 22 Jan 2018 1.50
*/
static function sendEmailQuery($arrObjects)
{
foreach ($arrObjects as $key => $obj) {
if(!empty($obj->email))
{
$isMailSend = Mail::send('emails.notification.query', array('is_reply'=> $obj->is_reply,'session' => $obj->session,'member_name' => $obj->member_name), function($message) use ($obj)
{
$message->subject($obj->subject);
$message->to($obj->email);
$message->cc(CustomClass::$BackupId);
});
}
}
}
public function getNews()
{
try {
$returnlst = [];
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$a = [];
$getNews = DB::table('news')->orderBy('dt', 'desc')->get();
foreach ($getNews as $key => $item) {
$a['id'] = $item->id;
$a['dt'] = $item->dt;
$a['content'] = $item->content;
$a['created_at'] = $item->created_at;
$a['updated_at'] = $item->updated_at;
array_push($returnlst, $a);
}
$arr = $returnlst;
}
}
catch (Exception $e) {
Log::error('APIController - getNews : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
public function getAgendaSchedule()
{
try {
//SMS and App Notification variable
$usersMessages = [];
$userssmsMessages = [];
$arr = [];
//General variables
$dt = Helper::toIndianDate(date('Y-m-d H:i:s'));
$time =date('H:i:s',strtotime(Helper::toIndianDateTime(date('Y-m-d H:i:s'))));
//date time set for testing
//$dt ="2019-02-14";
//$time ="09:00:00";
//Call SP
$getAgenda = DB::select("call usp_get_agenda_schedule('".$dt."','".$time."')");
//Loop data
foreach ($getAgenda as $key => $item) {
$date_time_hall1 = Helper::trimAndTruncate($item->starts_by,5) .' Hall '.$item->hall;
$title = $item->title;
$obj = new stdClass();
$obj->user_id = $item->user_id;
if($item->abs_no ==null)
$obj->message = "Your session \"". $title . "\" starts at ". $date_time_hall1 . ". Please report to the hall 15 mins before the session.";
else
$obj->message = "Your session \"". $item->abs_type . $item->abs_no ." - ".$title."\" starts at ". $date_time_hall1 . ". Please report to the hall 15 mins before the session.";
array_push($usersMessages, $obj);
//SMS Notification
if(!empty($item->mobile))
{
$objsms = new stdClass();
$objsms->to = [$item->mobile];
//$objsms->to = ["9952514049"];
if($item->abs_no ==null)
$objsms->message = "Your session \"". $title . "\" starts at ". $date_time_hall1 . ". Please report to the hall 15 mins before the session.";
else
$objsms->message = "Your session \"". $item->abs_type . $item->abs_no ." - ".$title."\" starts at ". $date_time_hall1 . ". Please report to the hall 15 mins before the session.";
array_push($userssmsMessages, $objsms);
}
}
echo json_encode($usersMessages);
Log::info('Agenda count : '. count($usersMessages));
if(count($usersMessages)>0)
{
try {
Helper::sendNotifications($usersMessages, "AIOS - AGENDA");
} catch (Exception $e) {
echo "getAgendaSchedule - sendNotifications : " . $e->getMessage();
Log::error('APIController - getAgendaSchedule - sendNotifications : '.$e->getMessage());
}
}
if(count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "AGENDA");
} catch (Exception $e) {
echo "getAgendaSchedule - sendSMS : " . $e->getMessage();
Log::error('APIController - getAgendaSchedule - sendSMS : '.$e->getMessage());
}
}
}
catch (Exception $e) {
Log::error('APIController - getAgendaSchedule : '.$e->getMessage());
echo $e->getMessage();
}
// return Response::json($arr);
}
/*
Sridhar on 2018-10-25 2:15 PM
Send tomorrow Session sms by users
*/
public function getAgendaScheduleByDate()
{
try {
//Log::info('getAgendaScheduleByDate calling from cron');
//SMS and App Notification variable
$userssmsMessages = [];
$arr = [];
$myTime = '15:00';
if (date('H:i') != date('H:i', strtotime($myTime))) {
return "Time not $myTime";
}
//General variables
$tomorrow = new DateTime('tomorrow');
$dt = $tomorrow->format('Y-m-d');
$time =date('H:i:s',strtotime(Helper::toIndianDateTime(date('Y-m-d H:i:s'))));
//date time set for testing
//$dt ="2019-02-14";
//Call SP
$getAgenda_db = DB::select("call usp_get_agenda_schedule_by_date('".$dt."')");
//var_dump($getAgenda_db);
//exit();
$users_agenda = [];
$user_ids = [];
foreach ($getAgenda_db as $key => $value) {
$users_agenda[$value->user_id][] = $value;
$user_ids[] = $value->user_id;
}
$user_ids = array_unique($user_ids);
foreach ($user_ids as $key => $user_id) {
$user = $users_agenda[$user_id][0];
$name = $user->name;
$mobile = $user->mobile;
$email = $user->email;
$break = "%0a";
$message = "Dear " .$name.",".$break;
$message .= "Your Commitment @ AIOC 2020 On " . date('d/m/Y',strtotime($user->dt)).
$break.$break;
foreach ($users_agenda[$user_id] as $key => $agenda) {
$message .=
Helper::trimAndTruncate($agenda->starts_by,5) .' Hall '.$agenda->hall.$break;
if(empty($agenda->abs_no))
{
$message .= Helper::trimAndTruncate($agenda->title,100).$break;
}
else {
$message .= ($agenda->abs_type != "GP"?$agenda->abs_type . $agenda->abs_no ." - ":""). Helper::trimAndTruncate($agenda->title,100).$break;
}
$message .= "Role(s): ".$agenda->roles.$break.$break;
}
$obj = new stdClass();
//$obj->user_id = $agenda->user_id;
$obj->to = [$agenda->mobile];
//$obj->mobile = "9843846776";
//$obj->to = ["9952514049"];
$obj->message = $message;
array_push($userssmsMessages, $obj);
}
//developer sms
if(count($userssmsMessages)>0)
{
$obj = new stdClass();
//$obj->user_id = 9999;
//$obj->mobile = $item->mobile;
//$obj->mobile = "9843846776";
$obj->to = ["9952514049","9843846776"];
$obj->message = "Agenda Schedule By Date :". $dt ." count :".count($userssmsMessages);
array_push($userssmsMessages, $obj);
}
//echo json_encode($usersMessages);
Log::info('getAgendaScheduleByDate count : '. count($userssmsMessages));
if(count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "AGENDA");
} catch (Exception $e) {
echo "getAgendaSchedule - sendSMS : " . $e->getMessage();
Log::error('APIController - getAgendaSchedule - sendSMS : '.$e->getMessage());
}
}
// var_dump($res);
}
catch (Exception $e) {
Log::error('APIController - getAgendaScheduleByDate : '.$e->getMessage());
echo $e->getMessage();
}
// return Response::json($arr);
}
/********************************* open evaluation ********************************************/
/*
Sridhar On 17 apr 2017 4:12 PM
Check Evaluation by User
Url : /api/v1/0/evaluation/checkt?APIKey=w347H52d96&user_id=4250
Parameter : APIKey, user_id
data type : Post/Get
Out Put :
[
{
"abs_type": "IC",
"user_id": "4250",
"start_date": "2017-04-01 00:00:00",
"end_date": "2017-05-31 23:59:00",
"can_evaluate": "0"
},
{
"abs_type": "FP",
"user_id": "4250",
"start_date": "2017-04-01 00:00:00",
"end_date": "2017-05-31 23:59:00",
"can_evaluate": "0"
},
{
"abs_type": "VT",
"user_id": "4250",
"start_date": "2017-04-01 00:00:00",
"end_date": "2017-05-31 23:59:00",
"can_evaluate": "0"
}
]
*/
public function GetEvaluationCheck(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$user_id = Input::get("user_id");
$arr = Mark::getUserEvaluationSetting($user_id);
}
} catch (Exception $e) {
Log::error('APIController - GetAbstractforEvaluation : '.$e->getMessage());
}
return Response::json($arr);
}
/*
Sridhar On 18 apr 2017 3:33 PM
get Assignment abstract Evaluation by User
Url : api/v1/0/evaluation/assignment?APIKey=w347H52d96&user_id=4250
Parameter : APIKey, user_id
data type : Post/Get
Out Put : [
{
"mark_id": "2",
"abs_id": "33"
},
{
"mark_id": "3",
"abs_id": "57"
}
]
*/
public function GetEvaluationAssignment(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$user_id = Input::get("user_id");
$arr = Mark::getUserEvaluationAssignment($user_id);
}
} catch (Exception $e) {
Log::error('APIController - GetAbstractforEvaluation : '.$e->getMessage());
}
return Response::json($arr);
}
/*
Sridhar On 19 apr 2017 9:44 PM
sync Evaluation abstract marks by User
Url : api/v1/0/evaluation/sync?APIKey=w347H52d96&user_id=4250
Parameter : APIKey, user_id , sync_at
data type : Post
In put : [
{
"mark_id": "5",
"m1": "1",
"m2": "2",
"m3": "2",
"m4": "1",
"m5": "1",
"mark_update_count":"1"
}
]
Out Put : [
{
"mark_id":"5",
"m1":"1",
"m2":"2",
"m3":"2",
"m4":"1",
"m5":"1",
"mark_update_count":"5",
"sync_at":"2017-04-19 14:58:32"
}
]
*/
public function GetEvaluationSync(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$user_id = Input::get("user_id");
$last_sync_at = Input::get("last_sync_at");
$json = file_get_contents('php://input');
Log::info('Evaluation user id : '. $user_id);
Log::info('Evaluation last_sync_at : '. $last_sync_at);
Log::info('get Evaluation json : '. $json);
$evalStatus = Mark::getUserEvaluationSetting($user_id);
$can_eval_abs_type = [];
foreach ($evalStatus as $key => $value) {
if($value->can_evaluate==1)
array_push($can_eval_abs_type,$value->abs_type);
}
$syncMarkItems = [];
if(!empty($json))
{
$syncMarkItems = json_decode($json);
}
if(count($syncMarkItems)>0)
{
$insert_data = [];
foreach ($syncMarkItems as $key => $value) {
if(in_array($value->abs_type, $can_eval_abs_type))
{
$mark = Mark::find($value->mark_id);
if($mark!=null)
{
if($mark->mark_update_count < $value->mark_update_count)
{
$mark->m1 = is_numeric($value->m1)? $value->m1 :null;
$mark->m2 = is_numeric($value->m2)? $value->m2 :null;
$mark->m3 = is_numeric($value->m3)? $value->m3 :null;
$mark->m4 = is_numeric($value->m4)? $value->m4 :null;
$mark->m5 = isset($value->m5)? (is_numeric($value->m5)? $value->m5 :null):null;
$mark->sys_m1 = $mark->m1;
$mark->sys_m2 = $mark->m2;
$mark->sys_m3 = $mark->m3;
$mark->sys_m4 = $mark->m4;
$mark->sys_m5 = $mark->m5;
$mark->comments = $value->comments;
$mark->marks_total = (is_numeric($mark->m1)? $mark->m1 : 0) + (is_numeric($mark->m2)? $mark->m2 : 0) + (is_numeric($mark->m3)? $mark->m3 : 0) + (is_numeric($mark->m4)? $mark->m4 : 0) + (is_numeric($mark->m5)? $mark->m5 : 0);
$mark->sys_marks_total = $mark->marks_total;
$mark->platform_id = CustomClass::$Platform_Mobile;
$mark->mark_update_count = $mark->mark_update_count + 1;
$mark->sync_at = date('Y-m-d H:i:s');
$mark->save();
}
}
}
}
}
if(empty($last_sync_at))
{
$arr = Mark::where('user_id',$user_id)->where('marks_total','>',0)->get(
array('mark_id','m1','m2','m3','m4','m5','marks_total','comments','mark_update_count','sync_at')
);
Log::info('last sync at is empty');
}
else
{
$arr = Mark::where('user_id',$user_id)->where('marks_total','>',0)->where('sync_at','>',$last_sync_at)->get(
array('mark_id','m1','m2','m3','m4','m5','marks_total','comments','mark_update_count','sync_at')
);
Log::info('last sync at is not empty');
}
Log::info('return Evaluation json : '. json_encode($arr));
}
} catch (Exception $e) {
Log::error('APIController - GetEvaluationSync : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
/********************************* end evaluation ********************************************/
/********************************* Preview Room Upload Remember SMS and Mail ********************************************/
public function Getverify(){
try {
$arr = ['id' => 0,'pin' => null,'conference_name' => null,'expiry_date' => null,'current_date'=>null];
// APIKey=w347H52d96&email=sridhar@numerotec.com&pwd=sridhar
// if(CustomClass::$APIKey == Input::get("APIKey"))
// {
$pin = Input::get("pin");
$settings = settings::where('pin', $pin )->first();
if(isset($settings))
{
//$arr = ['UserId' => $user->user_id,'Name' => $user->prefix .'.'. $user->name,'email' => $user->email,'IsEvaluator' => '0'];
$arr['id'] = $settings->id;
$arr['pin'] = $settings->pin;
$arr['conference_name'] = $settings->conference_name;
$arr['expiry_date'] = $settings->expiry_date;
$arr['current_date'] = Helper::currentIndianTime();
}
// }
} catch (Exception $e) {
Log::error('APIController - Getverify : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
public function SyncPreviewRoom(){
try {
$arr =[];
$item =[];
$arrval = [];
$conf_name = Input::get("conf_name");
$json = file_get_contents('php://input');
//$json = Input::get("json");
if(!empty($json))
{
Log::info('Preview sync json : '. $json);
$arrval = json_decode($json);
}
Log::info('Preview sync Count : '. count($arrval));
$usersMessages = [];
$userssmsMessages = [];
$campaign ="PreviewRoom";
foreach ($arrval as $value) {
$users = PreviewRoom::find($value->id);
if(!isset($users->uploaded_at) || empty($users->uploaded_at))
{
$users->uploaded_by = $value->uploaded_by;
$users->comment = $value->comment;
$users->uploaded_at = $value->uploaded_at;
$users->av_code = $value->av_code;
$users->save();
$date_time_hall = date('d/M',strtotime($users->date)) .' ' . date('h:i A',strtotime($users->from_time)) .' Hall '.$users->hall;
$session_no = $users->title;
$obj = new stdClass();
$obj->user_id = $users->user_id;
$obj->message = "Dear ". $users->name .", Your presentation for session \"".$session_no."\" (".$users->av_code .") " .$date_time_hall ." has been uploaded in preview room. Thank you.";
array_push($usersMessages, $obj);
if(!empty($users->mobile))
{
$objsms = new stdClass();
$objsms->to = [$users->mobile];
$objsms->message = "Dear ". $users->name .", Your presentation for session \"".$session_no."\" (".$users->av_code .") " .$date_time_hall ." has been uploaded in preview room. Thank you.";
array_push($userssmsMessages, $objsms);
}
// $obj = new stdClass();
// $obj->mobileno = $users->mobile;
// $obj->msg = "Dear ". $users->name .", Your presentation for session ".$session_no." " .$date_time_hall ." has been uploaded in preview room. Thank you."; ;
// array_push($objSMSs, $obj);
}
}
if( count($usersMessages)>0)
{
try {
Helper::sendNotifications($usersMessages, "AIOS - PREVIEWROOM");
} catch (Exception $e) {
echo "getPreviewRoomUploadReminder - sendNotifications : " . $e->getMessage();
Log::error('APIController - getPreviewRoomUploadReminder - sendNotifications : '.$e->getMessage());
}
}
if(count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "PREVIEWROOM");
} catch (Exception $e) {
echo "getPreviewRoomUploadReminder - sendSMS : " . $e->getMessage();
Log::error('APIController - getPreviewRoomUploadReminder - sendSMS : '.$e->getMessage());
}
}
//Helper::smsBulk($objSMSs,$campaign);
$users = PreviewRoom::where('conf_name',$conf_name)->get();
foreach ($users as $value) {
$item['id'] = is_null($value->id)?'': $value->id;
$item['user_id'] = is_null($value->user_id)?'': $value->user_id;
$item['name'] = is_null($value->name)?'': $value->name;
$item['email'] = is_null($value->email)?'': $value->email;
$item['mobile'] = is_null($value->mobile)?'': $value->mobile;
$item['address'] = is_null($value->address)?'': $value->address;
$item['membership_no']= is_null($value->membership_no)?'': $value->membership_no;
$item['reg_no'] = is_null($value->reg_no)?'': $value->reg_no;
$item['c1'] = is_null($value->c1)?'': $value->c1;
$item['c2'] = is_null($value->c2)?'': $value->c2;
$item['c3'] = is_null($value->c3)?'': $value->c3;
$item['c4'] = is_null($value->c4)?'': $value->c4;
$item['c5'] = is_null($value->c5)?'': $value->c5;
$item['c6'] = is_null($value->c6)?'': $value->c6;
$item['conf_name'] = is_null($value->conf_name)?'': $value->conf_name;
$created_at = $value->created_at;
$item['created_at'] = empty($created_at)?null:$created_at->format('Y-m-d H:i:s');
$item['delegate_type']= is_null($value->delegate_type)?'': $value->delegate_type;
$item['signed_by'] = is_null($value->signed_by)?'': $value->signed_by;
$item['comment'] = is_null($value->comment)?'': $value->comment;
$item['signed_on'] = is_null($value->signed_on)?'': $value->signed_on;
$item['date'] = is_null($value->date)?'': $value->date;
$item['from_time'] = is_null($value->from_time)?'': $value->from_time;
$item['to_time'] = is_null($value->to_time)?'': $value->to_time;
$item['hall'] = is_null($value->hall)?'': $value->hall;
$item['title'] = is_null($value->title)?'': $value->title;
$item['uploaded_by'] = is_null($value->uploaded_by)?'': $value->uploaded_by;
$item['uploaded_at'] = is_null($value->uploaded_at)?'': $value->uploaded_at;
$item['av_code'] = is_null($value->av_code)?'': $value->av_code;
array_push($arr,$item);
}
}
catch (Exception $e) {
Log::error('APIController - SyncPreviewRoom : '.$e->getMessage());
echo $e->getMessage();
}
return Response::json($arr);
}
// public function getPreviewRoomUploadReminder()
// {
// try {
// //SMS and App Notification variable
// $usersMessages = [];
// $userssmsMessages = [];
// $arr = [];
// //General variables
// $dt = Helper::toIndianDate(date('Y-m-d H:i:s'));
// $time =date('H:i:s',strtotime(Helper::toIndianDateTime(date('Y-m-d H:i:s'))));
// //date time set for testing
// $dt ="2018-02-20";
// $time ="07:00:00";
// //Call SP
// $result = DB::select("call usp_get_reminder_for_preview_room_test('".$dt."','".$time."')");
// //Loop data
// foreach ($result as $key => $item) {
// //SMS and App Notification data set
// $date_time_hall = date('d/M',strtotime($item->dt)) .' ' . date('h:i A',strtotime($item->starts_by)) .' Hall '.$item->hall;
// $title = $item->title;
// //$title = Helper::trimAndTruncate($item->title,50);
// //$title .='...';
// $obj = new stdClass();
// $obj->user_id = $item->user_id;
// if($item->abs_no ==null)
// $obj->message = "Pl upload your presentation for session \"". $title ."\" (".$item->av_code .") 3 hours prior to the session in the preview room. For seamless / troublefree presentation, avoid using personal laptops and use the preview room facility.";
// else
// $obj->message = "Pl upload your presentation for session \"". $item->abs_type . $item->abs_no ."\" (".$item->av_code .") 3 hours prior to the session in the preview room. For seamless / troublefree presentation, avoid using personal laptops and use the preview room facility.";
// array_push($usersMessages, $obj);
// //SMS Notification
// if(!empty($item->mobile))
// {
// $objsms = new stdClass();
// $objsms->to = [$item->mobile];
// if($item->abs_no ==null)
// $objsms->message = "Pl upload your presentation for session \"". $title ."\" (".$item->av_code .") 3 hours prior to the session in preview room. Personal laptops are not allowed.";
// else
// $objsms->message = "Pl upload your presentation for session \"". $item->abs_type . $item->abs_no ."\" (".$item->av_code .") 3 hours prior to the session in preview room. Personal laptops are not allowed.";
// array_push($userssmsMessages, $objsms);
// }
// // array_push($usersMessages, $obj);
// }
// //echo json_encode($usersMessages);
// Log::info('Preview Room Reminder count : '. count($usersMessages));
// try {
// Helper::sendNotifications($usersMessages, "AIOS - PREVIEWROOM");
// } catch (Exception $e) {
// echo "getPreviewRoomUploadReminder - sendNotifications : " . $e->getMessage();
// Log::error('APIController - getPreviewRoomUploadReminder - sendNotifications : '.$e->getMessage());
// }
// try {
// Helper::smsBulk_v2($userssmsMessages, "PREVIEWROOM");
// } catch (Exception $e) {
// echo "getPreviewRoomUploadReminder - sendSMS : " . $e->getMessage();
// Log::error('APIController - getPreviewRoomUploadReminder - sendSMS : '.$e->getMessage());
// }
// }
// catch (Exception $e) {
// Log::error('APIController - getPreviewRoomUploadReminder : '.$e->getMessage());
// echo $e->getMessage();
// }
// // return Response::json($arr);
// }
public function getPreviewRoomSchedule()
{
try {
//SMS and App Notification variable
$usersMessages = [];
$userssmsMessages = [];
$arr = [];
//General variables
$dt = Helper::toIndianDate(date('Y-m-d H:i:s'));
$time =date('H:i:s',strtotime(Helper::toIndianDateTime(date('Y-m-d H:i:s'))));
//date time set for testing
// $dt ="2018-02-20";
// $time ="07:00:00";
//Call SP
$result = DB::select("call usp_list_preview_room_schedule('".$dt."','".$time."')");
//Loop data
foreach ($result as $key => $item) {
$date_time_hall = date('d/M',strtotime($item->date)) .' ' . date('h:i A',strtotime($item->from_time)) .' @ Hall '.$item->hall;
$title = $item->title;
//$title = Helper::trimAndTruncate($item->title,50);
//$title .='...';
//app Notification
$obj = new stdClass();
$obj->user_id = $item->user_id;
$obj->message = "Pl upload your presentation for session \"".$title ."\" (".$item->av_code .") ".$date_time_hall.", 3 hours prior to the session in the preview room. For seamless / troublefree presentation, avoid using personal laptops and use the preview room facility.";
array_push($usersMessages, $obj);
//SMS Notification
if(!empty($item->mobile))
{
$objsms = new stdClass();
$objsms->to = [$item->mobile];
$objsms->message = "Pl upload your presentation for session \"".$title ."\" (".$item->av_code .") ".$date_time_hall.", 3 hours prior to the session in the preview room. For seamless / troublefree presentation, avoid using personal laptops and use the preview room facility.";
array_push($userssmsMessages, $objsms);
}
}
//echo json_encode($usersMessages);
Log::info('Preview Room Schedule count : '. count($usersMessages));
if( count($usersMessages)>0)
{
try {
Helper::sendNotifications($usersMessages, "AIOS - PREVIEWROOM");
} catch (Exception $e) {
echo "getPreviewRoomSchedule - sendNotifications : " . $e->getMessage();
Log::error('APIController - getPreviewRoomSchedule - sendNotifications : '.$e->getMessage());
}
}
if(count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "PREVIEWROOM");
} catch (Exception $e) {
echo "getPreviewRoomSchedule - sendSMS : " . $e->getMessage();
Log::error('APIController - getPreviewRoomSchedule - sendSMS : '.$e->getMessage());
}
}
echo "Done.";
// var_dump($res);
}
catch (Exception $e) {
Log::error('APIController - getPreviewRoomSchedule : '.$e->getMessage());
echo $e->getMessage();
}
// return Response::json($arr);
}
public function getPreviewRoomReminder()
{
try {
//SMS and App Notification variable
$usersMessages = [];
$userssmsMessages = [];
$arr = [];
//General variables
$dt = Helper::toIndianDate(date('Y-m-d H:i:s'));
$time =date('H:i:s',strtotime(Helper::toIndianDateTime(date('Y-m-d H:i:s'))));
//date time set for testing
// $dt ="2018-02-20";
// $time ="07:00:00";
//Call SP
$result = DB::select("call usp_list_preview_room_reminder('".$dt."','".$time."')");
//Loop data
foreach ($result as $key => $item) {
$date_time_hall = date('d/M',strtotime($item->date)) .' ' . date('h:i A',strtotime($item->from_time)) .' @ Hall '.$item->hall;
$title = $item->title;
// $title = Helper::trimAndTruncate($item->title,50);
// $title .='...';
$obj = new stdClass();
$obj->user_id = $item->user_id;
$obj->message = "Pl upload your presentation for session \"".$title ."\" (".$item->av_code .") ".$date_time_hall.", 3 hours prior to the session in the preview room. For seamless / troublefree presentation, avoid using personal laptops and use the preview room facility.";
array_push($usersMessages, $obj);
//SMS Notification
if(!empty($item->mobile))
{
$objsms = new stdClass();
$objsms->to = [$item->mobile];
$objsms->message = "Pl upload your presentation for session \"".$title ."\" (".$item->av_code .") ".$date_time_hall.", 3 hours prior to the session in the preview room. For seamless / troublefree presentation, avoid using personal laptops and use the preview room facility.";
array_push($userssmsMessages, $objsms);
}
}
//echo json_encode($usersMessages);
Log::info('Preview Room Reminder count : '. count($usersMessages));
if( count($usersMessages)>0)
{
try {
Helper::sendNotifications($usersMessages, "AIOS - PREVIEWROOM");
} catch (Exception $e) {
echo "getPreviewRoomReminder - sendNotifications : " . $e->getMessage();
Log::error('APIController - getPreviewRoomReminder - sendNotifications : '.$e->getMessage());
}
}
if(count($userssmsMessages)>0)
{
try {
Helper::smsBulk_v2($userssmsMessages, "PREVIEWROOM");
} catch (Exception $e) {
echo "getPreviewRoomReminder - sendSMS : " . $e->getMessage();
Log::error('APIController - getPreviewRoomReminder - sendSMS : '.$e->getMessage());
}
}
echo "Done.";
// var_dump($res);
}
catch (Exception $e) {
Log::error('APIController - getPreviewRoomReminder : '.$e->getMessage());
echo $e->getMessage();
}
// return Response::json($arr);
}
/********************************* end Preview Room Upload Remember SMS and Mail ********************************************/
/*
Sridhar on 2018 Nov 19
get Program Overview Colors
*/
public function getProgramOverviewColors(){
try {
$arr = [];
if(CustomClass::$APIKey == Input::get("APIKey"))
{
$data= DB::table('program_overview_colors')->where('is_visible',1)->get();
$arr = $data;
}
} catch (Exception $e) {
Log::error('ARCController - getProgramOverviewColors : '.$e->getMessage());
//echo $e->getMessage();
}
return Response::json($arr);
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists