ok
Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/www/subamangala/admin/api/waste-files/ |
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/www/subamangala/admin/api/waste-files/api.php |
<?php ob_start(); session_start(); include"../config/config.php"; if($_POST['type']=="get-follow-up-info"){ $id = $_POST['follow_up_id']; $statement = $pdo->prepare("SELECT *,(select name from tbl_user where id=fu.created_by) as created_by_name, (select name from tbl_user where id=fu.updated_by) as updated_by_name, (select name from tbl_user where id=fu.fetched_by) as fetched_by_name, (select name from tbl_user where id=fu.allocated_to) as allocated_to_name, (select course_name from tbl_course where id=fu.course_id) as course_name ,(select name from tbl_mode_of_source where id=fu.mode_of_source_id) as mode_of_source_name ,(select count(id) from tbl_follow_up_tracking where follow_up_id=fu.id) as total_follow_up_count ,(select date from tbl_follow_up_tracking where id=(select max(id) from tbl_follow_up_tracking where follow_up_id=fu.id)) as last_follow_up_date ,(select next_follow_up_date from tbl_follow_up_tracking where id=(select max(id) from tbl_follow_up_tracking where follow_up_id=fu.id)) as next_follow_up_date ,(select remark from tbl_follow_up_tracking where id=(select max(id) from tbl_follow_up_tracking where follow_up_id=fu.id)) as remark ,(select tbl_category.category_name from tbl_follow_up_tracking inner join tbl_category on tbl_follow_up_tracking.category_id=tbl_category.id where tbl_follow_up_tracking.id=(select max(id) from tbl_follow_up_tracking where follow_up_id=fu.id)) as category_name FROM `tbl_follow_up` fu where fu.id=$id"); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $return_arr = array(); if($totalData>0){ $follow_up = array(); $return_arr['error']=0; $return_arr['message']="data retrived"; foreach( $query as $row ) { if($row['last_follow_up_date']!=''){$row['last_follow_up_date']=date('d-m-Y', strtotime($row["last_follow_up_date"]));} if($row['next_follow_up_date']!='' && $row['next_follow_up_date']!="0000-00-00"){$row['next_follow_up_date']=date('d-m-Y', strtotime($row["next_follow_up_date"]));} if($row['next_follow_up_date']=="0000-00-00"){$row['next_follow_up_date']="";} $follow_up[] = $row; } $return_arr['data']=$follow_up; $statement = $pdo->prepare("SELECT *,(select name from tbl_user where id=fut.spoken_by) as spoken_by_name,(select name from tbl_user where id=fut.created_by) as added_by_name,(select category_name from tbl_category where id=fut.category_id) as category_name FROM `tbl_follow_up_tracking` fut where fut.follow_up_id=".$id); $statement->execute(); $tracking_data = $statement->fetchAll(PDO::FETCH_ASSOC); $tracking_totalData = $statement->rowCount(); $follow_up_tracking = array(); if($totalData>0){ foreach( $tracking_data as $row ) { if($row['next_follow_up_date']=="0000-00-00"){ $row['next_follow_up_date']="";} if($row['date']!=''){$row['date']=date('d-m-Y', strtotime($row["date"]));} if($row['next_follow_up_date']!=''){$row['next_follow_up_date']=date('d-m-Y', strtotime($row["next_follow_up_date"]));} $follow_up_tracking[] = $row; } $return_arr['tracking _data']=$follow_up_tracking; }else{ $return_arr['tracking _data']=$follow_up_tracking; } }else{ $return_arr['error']=1; $return_arr['message']="follow up id invalid"; } echo json_encode($return_arr); } if($_POST['type']=="insert_followup_history"){ $return_arr = array(); try{ // $sql="INSERT INTO `tbl_follow_up_tracking`(`follow_up_id`, `spoken_by`, `category_id`, `remark`, `date`, `next_follow_up_date`,`created_by`) VALUES (".$_POST['id'].",".$_POST['spoken_by'].",".$_POST['category'].",".$_POST['remark'].",".$_POST['date'].",".$_POST['next_follow_up_date'].",".$_SESSION['thought_flow']['id'].")"; // error_log($sql); if($_POST['next_follow_up_date']==""){ $_POST['next_follow_up_date'] = "0000-00-00";} if($_POST['remark']==""){ $_POST['remark'] = "";} $statement = $pdo->prepare("INSERT INTO `tbl_follow_up_tracking`(`follow_up_id`, `spoken_by`, `category_id`, `remark`, `date`, `next_follow_up_date`,`created_by`) VALUES (?,?,?,?,?,?,?)"); $result=$statement->execute(array($_POST['id'],$_POST['spoken_by'],$_POST['category'],$_POST['remark'],$_POST['date'],$_POST['next_follow_up_date'],$_SESSION['thought_flow']['id'])); if($result){ $statement = $pdo->prepare("UPDATE tbl_follow_up SET follow_up_status=? WHERE id=?"); $result=$statement->execute(array($_POST['follow_up_status'],$_POST['id'])); $return_arr['error']=0; $return_arr['message']="Success"; }else{ $return_arr['error']=1; $return_arr['message']="follow up id invalid"; } echo json_encode($return_arr); }catch(Exception $e){ $return_arr['error']=1; $return_arr['message']="something went wrong"; echo json_encode($return_arr); } } if($_POST['type']=="update_followup_history"){ $return_arr = array(); try{ if($_POST['next_follow_up_date']==""){ $_POST['next_follow_up_date'] = "0000-00-00";} if($_POST['remark']==""){ $_POST['remark'] = "";} $statement = $pdo->prepare("UPDATE `tbl_follow_up_tracking` SET spoken_by=?, category_id=?, remark=?, date=?, next_follow_up_date=?,updated_by=? WHERE id=?"); $result=$statement->execute(array($_POST['spoken_by'],$_POST['category'],$_POST['remark'],$_POST['date'],$_POST['next_follow_up_date'],$_SESSION['thought_flow']['id'],$_POST['id'])); if($result){ $statement = $pdo->prepare("UPDATE tbl_follow_up SET follow_up_status=? WHERE id=?"); $result=$statement->execute(array($_POST['follow_up_status'],$_POST['ids'])); $return_arr['error']=0; $return_arr['message']="Success"; }else{ $return_arr['error']=1; $return_arr['message']="follow up id invalid"; } echo json_encode($return_arr); }catch(Exception $e){ $return_arr['error']=1; $return_arr['message']="something went wrong"; echo json_encode($return_arr); } } if($_POST['type']=="get-lead-info"){ $id = $_POST['lead_id']; $statement = $pdo->prepare("SELECT * ,(select name from tbl_user where id=l.lead_by) as lead_by ,(select course_name from tbl_course where id=l.course_id) as course_name ,(select COALESCE(sum(amount), 0) from tbl_payment where lead_id=l.id) as paid_amount ,(select course_name from tbl_course where id=l.course_id) as course_name ,(select name from tbl_mode_of_source where id=l.mode) as mode_of_source_name ,(select branch_name from tbl_branch where id=l.branch_id) as branch_name FROM `tbl_lead` l where l.id=$id"); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $return_arr = array(); if($totalData>0){ $follow_up = array(); $return_arr['error']=0; $return_arr['message']="data retrived"; foreach( $query as $row ) { if($row['doj']!=''){$row['doj']=date('d-m-Y', strtotime($row["doj"]));} $row["pending_fees"]=$row["total_fees"]-$row["paid_amount"]; if($row["total_fees"]<=$row["paid_amount"]){ $row['payment_status'] ="<span class='btn btn-success btn-xs' onclick='followupModel(".$row["id"].");'><i class='fa fa-check'></i> Fully Paid</span>";}else if($row["total_fees"]>=$row["paid_amount"] && $row["paid_amount"] >0){$row['payment_status'] ="<span onclick='followupModel(".$row["id"].");' class='btn btn-warning btn-xs'><i class='fa fa-spinner'></i> Patially Paid</span>";} else{$row['payment_status'] ="<span onclick='followupModel(".$row["id"].");' class='btn btn-danger btn-xs'><i class='fa fa-times'></i> Un-Paid</span>";} $follow_up[] = $row; } $return_arr['data']=$follow_up; $statement = $pdo->prepare("select *,(select name from tbl_user where id=tbl_payment.received_by) as received_by_name from tbl_payment where lead_id=".$id); $statement->execute(); $tracking_data = $statement->fetchAll(PDO::FETCH_ASSOC); $tracking_totalData = $statement->rowCount(); $follow_up_tracking = array(); if($totalData>0){ foreach( $tracking_data as $row ) { if($row['date']=="0000-00-00"){ $row['date']="";} if($row['date']!=''){$row['date']=date('d-m-Y', strtotime($row["date"]));} $follow_up_tracking[] = $row; } $return_arr['payment_data']=$follow_up_tracking; }else{ $return_arr['payment_data']=$follow_up_tracking; } }else{ $return_arr['error']=1; $return_arr['message']="follow up id invalid"; } echo json_encode($return_arr); } if($_POST['type']=="insert_lead_payment"){ $return_arr = array(); try{ // $sql="INSERT INTO `tbl_follow_up_tracking`(`follow_up_id`, `spoken_by`, `category_id`, `remark`, `date`, `next_follow_up_date`,`created_by`) VALUES (".$_POST['id'].",".$_POST['spoken_by'].",".$_POST['category'].",".$_POST['remark'].",".$_POST['date'].",".$_POST['next_follow_up_date'].",".$_SESSION['thought_flow']['id'].")"; // error_log($sql); if($_POST['next_due_date']==""){ $_POST['next_due_date'] = "0000-00-00";} if($_POST['remark']==""){ $_POST['remark'] = "";} $statement = $pdo->prepare("INSERT INTO `tbl_payment`(`lead_id`, `amount`, `payment_type`, `date`, `remark`, `received_by`) VALUES (?,?,?,?,?,?)"); $result=$statement->execute(array($_POST['id'],$_POST['payment_received_amount'],$_POST['payment_type'],$_POST['payment_received_date'],$_POST['remark'],$_POST['received_by'])); if($result){ /* $statement = $pdo->prepare("UPDATE tbl_follow_up SET follow_up_status=? WHERE id=?"); $result=$statement->execute(array($_POST['follow_up_status'],$_POST['id']));*/ $return_arr['error']=0; $return_arr['message']="Success"; }else{ $return_arr['error']=1; $return_arr['message']="follow up id invalid"; } echo json_encode($return_arr); }catch(Exception $e){ $return_arr['error']=1; $return_arr['message']="something went wrong"; echo json_encode($return_arr); } } if($_POST['type']=="update_payment_history"){ $return_arr = array(); try{ if($_POST['next_due_up_date']==""){ $_POST['next_due_up_date'] = "0000-00-00";} if($_POST['remark']==""){ $_POST['remark'] = "";} $statement = $pdo->prepare("UPDATE `tbl_payment` SET received_by=?, amount=?, remark=?, date=?,payment_type=? WHERE id=?"); $result=$statement->execute(array($_POST['received_by'],$_POST['received_amount'],$_POST['remark'],$_POST['date'],$_POST['update_payment_type'],$_POST['id'])); if($result){ $return_arr['error']=0; $return_arr['message']="Success"; }else{ $return_arr['error']=1; $return_arr['message']="follow up id invalid"; } echo json_encode($return_arr); }catch(Exception $e){ $return_arr['error']=1; $return_arr['message']="something went wrong"; echo json_encode($return_arr); } } if($_POST['type']=="get-follow-up-update-info"){ $id = $_POST['follow_up_id']; $statement = $pdo->prepare("SELECT *,(select follow_up_status from tbl_follow_up where id=tbl_follow_up_tracking.follow_up_id) as follow_up_status FROM `tbl_follow_up_tracking` where id=".$id); $statement->execute(); $s="SELECT *,(select follow_up_status from tbl_follow_up where id=tbl_follow_up_tracking.follow_up_id) as follow_up_status FROM `tbl_follow_up_tracking` where id=".$id; error_log($s); $tracking_data = $statement->fetchAll(PDO::FETCH_ASSOC); $tracking_totalData = $statement->rowCount(); if($tracking_totalData>0){ $data='<div class="row"><form action="" id="follow_up_history_update" enctype="multipart/form-data" method="post" accept-charset="utf-8"><div class="col-md-6"><div class="form-group"><label class="required" for="category">Date</label> <input type="hidden" name="update_id" value="'.$id.'" class="form-control tip" id="follow_up_update_ids" required="required" readonly /><input type="hidden" name="updated_follow_up_id" value="'.$tracking_data[0]['follow_up_id'].'" class="form-control tip" id="updated_follow_up_id" required="required" readonly /><input type="date" name="update_date" value="'.$tracking_data[0]['date'].'" class="form-control tip" id="update_date" required="required" /></div></div><div class="col-md-6"><div class="form-group"><label class="required" for="email">Spoken By</label><select name="update_spoken_by" class="form-control select2" style="width:100%" id="update_spoken_by" required>'; $statement = $pdo->prepare("SELECT *,(select branch_name from tbl_branch where id=tbl_user.branch_id) as branch_name FROM `tbl_user` where status=1"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { if($tracking_data[0]['spoken_by']==$result["id"]){ $data.='<option value="'.$result["id"].'" selected>'.$result['name'].'- ('.$result['branch_name'].')</option>'; }else{ $data.='<option value="'.$result["id"].'">'.$result['name'].'- ('.$result['branch_name'].')</option>'; } } $data.='</select> </div></div><div class="col-md-6"><div class="form-group"><label class="required" for="email">Category</label><select name="update_category" class="form-control select2" style="width:100%" id="update_category" required>'; $statement = $pdo->prepare("SELECT * FROM `tbl_category` where status=1"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { if($tracking_data[0]['category_id']==$result["id"]){ $data.='<option value="'.$result["id"].'" selected>'.$result['category_name'].'</option>'; }else{ $data.='<option value="'.$result["id"].'">'.$result['category_name'].'</option>'; } } $data.='</select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="optional" for="category">Next Follow Up Date</label> <input type="date" name="update_next_follow_up_date" value="'.$tracking_data[0]['next_follow_up_date'].'" class="form-control tip" id="update_next_follow_up_date" /> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="optional" for="category">Remark</label> <textarea class="form-control tip" name="update_remark" id="update_remark" rows="3">'.$tracking_data[0]['remark'].$tracking_data[0]['follow_up_status'].'</textarea> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="required" for="email">Follow Up Status</label> <select name="update_follow_up_status" class="form-control select2" style="width:100%" id="update_follow_up_status" required>'; $data.='<option value="2"'; if($tracking_data[0]['follow_up_status']==2){ $data.=' selected ';} $data.='>In-process</option>'; $data.='<option value="3"'; if($tracking_data[0]['follow_up_status']==3){ $data.=' selected ';} $data.='>Close or Lost</option>'; $data.='<option value="4"'; if($tracking_data[0]['follow_up_status']==4){ $data.=' selected ';} $data.='>Lead</option>'; $data.='</select> </div> </div> </div> <center> <button class="btn btn-success" name="update_follow_history" onclick="update_follow_up_history_form()" id="update_follow_up_history_data">Update</button></center> </form> </div>'; }else{ echo "center>Something Went Wrong</center>"; } /* $return_arr['error']=0; $return_arr['data']=$data; */ echo $data; } if($_POST['type']=="get-lead-payment-update-info"){ $id = $_POST['id']; $statement = $pdo->prepare("SELECT *,(select total_fees from tbl_lead where id=tbl_payment.lead_id limit 1) as follow_up_status FROM `tbl_payment` where id=".$id); $statement->execute(); $lead_payment_data = $statement->fetchAll(PDO::FETCH_ASSOC); $lead_payment_totalData = $statement->rowCount(); if($lead_payment_totalData>0){ $data='<div class="row"><form action="" id="lead_payment_history_update" enctype="multipart/form-data" method="post" accept-charset="utf-8"><div class="col-md-6"><div class="form-group"><label class="required" for="category">Payment Received Date</label> <input type="hidden" name="update_payment_id" value="'.$id.'" class="form-control tip" id="update_payment_id" required="required" readonly /><input type="hidden" name="updated_lead_id" value="'.$lead_payment_data[0]['lead_id'].'" class="form-control tip" id="updated_lead_id" required="required" readonly /><input type="date" name="update_date" value="'.$lead_payment_data[0]['date'].'" class="form-control tip" id="update_date" required="required" /></div></div>'; $data.='<div class="col-md-6"> <div class="form-group"> <label class="required" for="category">Payment Received Amount</label> <input type="number" name="payment_received_amount" min="1" value="'.$lead_payment_data[0]['amount'].'" class="form-control tip" id="payment_received_amount" required="required" /> </div> </div>'; $data.='<div class="col-md-6"><div class="form-group"><label class="required" for="email">Received By</label><select name="update_received_by" class="form-control select2" style="width:100%" id="update_received_by" required>'; $statement = $pdo->prepare("SELECT *,(select branch_name from tbl_branch where id=tbl_user.branch_id) as branch_name FROM `tbl_user` where status=1"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { if($lead_payment_data[0]['received_by']==$result["id"]){ $data.='<option value="'.$result["id"].'" selected>'.$result['name'].'- ('.$result['branch_name'].')</option>'; }else{ $data.='<option value="'.$result["id"].'">'.$result['name'].'- ('.$result['branch_name'].')</option>'; } } $data.='</select> </div></div> <div class="col-md-6"> <div class="form-group"> <label class="optional" for="category">Next Due Date</label> <input type="date" name="update_next_follow_up_date" value="'.$lead_payment_data[0]['date'].'" class="form-control tip" id="update_next_due_date" /> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="optional" for="category">Remark</label> <textarea class="form-control tip" name="update_remark" id="update_remark" rows="3">'.$lead_payment_data[0]['remark'].'</textarea> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="required" for="email">Payment Received Type</label> <select name="update_follow_up_status" class="form-control select2" style="width:100%" id="update_payment_type" required>'; $data.='<option value="Cash"'; if($lead_payment_data[0]['payment_type']=='Cash'){ $data.=' selected ';} $data.='>Cash</option>'; $data.='<option value="Card"'; if($lead_payment_data[0]['payment_type']=='Card'){ $data.=' selected ';} $data.='>Card</option>'; $data.='<option value="UPI Payment"'; if($lead_payment_data[0]['payment_type']=='UPI Payment'){ $data.=' selected ';} $data.='>UPI Payment</option>'; $data.='<option value="Account Transfer"'; if($lead_payment_data[0]['payment_type']=='Account Transfer'){ $data.=' selected ';} $data.='>Account Transfer</option>'; $data.='<option value="Others"'; if($lead_payment_data[0]['payment_type']=='Others'){ $data.=' selected ';} $data.='>Others</option>'; $data.='</select> </div> </div> </div> <center> <button class="btn btn-success" name="update_payment_history" onclick="update_lead_payment_history_form()" id="update_follow_up_history_data">Update</button></center> </form> </div>'; }else{ echo "center>Something Went Wrong</center>"; } /* $return_arr['error']=0; $return_arr['data']=$data; */ echo $data; } ?>