function addCompanyDetails()
{
    $userID = trim($_REQUEST['userID']);
    $companyName = trim($_REQUEST['companyName']);
    //Get Request From Device
    $companyTanNo = trim($_REQUEST['companyTanNo']);
    $companyPanNo = trim($_REQUEST['companyPanNo']);
    $companyAddress = trim($_REQUEST['companyAddress']);
    $rm = new Response_Methods();
    if ($companyName == "" || $companyTanNo == "" || $companyPanNo == "" || $companyAddress == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getList = array();
        $getFieldValue['login_user_id'] = $userID;
        $getFieldValue['company_name'] = $companyName;
        $getFieldValue['company_tan_no'] = $companyTanNo;
        $getFieldValue['company_pan_no'] = $companyPanNo;
        $getFieldValue['company_address'] = $companyAddress;
        $getFieldValue['company_created_date'] = $createdDate;
        $lastInsertId = $rm->insert_record($getFieldValue, 'company_details_t');
        if (!empty($lastInsertId)) {
            $result = $rm->companyRegisterSuccessJson($lastInsertId);
            return $result;
        } else {
            $result = $rm->companyRegisterFailJson();
            return $result;
        }
    }
}
예제 #2
0
function likePost()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $USERID = trim($_POST['userId']);
            //Get Request From Device
            $POSTID = trim($_POST['postId']);
            //Get Request From Device
            $getArrayList = array();
            if ($USERID == "" || $POSTID == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                $checkLike = $rm->checkAlreadyLiked($USERID, $POSTID);
                if ($checkLike > 0) {
                    $result = $rm->alreadyLiked();
                    return $result;
                }
                date_default_timezone_set('Asia/Calcutta');
                $user_owner_id = $rm->idToValue('user_id_fk', 'news_feeds_t', 'post_id', $POSTID);
                //getting user owner id
                $createdDate = date('Y-m-d H:i:s');
                $getInsertFieldValue['user_id_fk'] = $USERID;
                $getInsertFieldValue['post_id_fk'] = $POSTID;
                $getInsertFieldValue['user_owner_id_fk'] = $user_owner_id;
                $getInsertFieldValue['likeDate_f'] = $createdDate;
                $lastInserted_user_id = $rm->insert_record($getInsertFieldValue, 'likes_t');
                if (!empty($lastInserted_user_id)) {
                    $sqlLikeCountUpdate = "update news_feeds_t set like_count_f= like_count_f+1 where post_id={$POSTID}";
                    mysql_query($sqlLikeCountUpdate, $GLOBALS['link']);
                    $deviceId = $rm->idToValue('device_id_f', 'user_details_t', 'user_id', $user_owner_id);
                    //getting deviceId
                    if ($deviceId != '') {
                        $message = "You have received a like on your post.";
                        $rm->sendPushNotification($deviceId, $message);
                    }
                    $result = $rm->getParticularPost($POSTID, $USERID);
                    return $result;
                } else {
                    $result = $rm->likeUnSuccessful();
                    return $result;
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
예제 #3
0
function addFriendRequest()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $userId = trim($_POST['userId']);
            $friendId = trim($_POST['friendId']);
            if ($userId == "" || $friendId == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                if ($userId == $friendId) {
                    $result = $rm->friendRequestFailforSameUser();
                    return $result;
                } else {
                    $checkFriend = $rm->checkExistingFriendShip($userId, $friendId);
                    if ($checkFriend > 0) {
                        $result = $rm->friendshipAlreadyExists();
                        return $result;
                    }
                    date_default_timezone_set('Asia/Calcutta');
                    $createdDate = date('Y-m-d H:i:s');
                    $getList = array();
                    //preparing list and inserting values in friends_t table
                    $getInsertFieldValue['friend_one'] = $userId;
                    $getInsertFieldValue['friend_two'] = $friendId;
                    $getInsertFieldValue['created_date_f'] = $createdDate;
                    $lastInserted_friend_id = $rm->insert_record($getInsertFieldValue, 'friends_t');
                    if (!empty($lastInserted_friend_id)) {
                        $deviceId = $rm->idToValue('device_id_f', 'user_details_t', 'user_id', $friendId);
                        //getting deviceId
                        if ($deviceId) {
                            $message = "You have received a friend request in petbesties.";
                            $rm->sendPushNotification($deviceId, $message);
                        }
                        $result = $rm->friendRequestSuccess();
                        return $result;
                    } else {
                        $result = $rm->friendRequestFail();
                        return $result;
                    }
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
function updateRequestStatus()
{
    $userRequestID = trim($_REQUEST['user_request_id']);
    $requestStatus = trim($_REQUEST['status']);
    $lastInserted_payment_id = 0;
    $rm = new Response_Methods();
    if ($userRequestID == "" || $requestStatus == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        if ($requestStatus == 'Accepted') {
            $fromBankID = $rm->idToValue('payment_from_bank_id', 'user_requests_t', 'user_request_id', $userRequestID);
            $toBankID = $rm->idToValue('payment_to_bank_id', 'user_requests_t', 'user_request_id', $userRequestID);
            $amount = $rm->idToValue('amount', 'user_requests_t', 'user_request_id', $userRequestID);
            $fromBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $fromBankID);
            $toBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $toBankID);
            if ($fromBankBalance < $amount) {
                $result = $rm->insufficient_balance();
                return $result;
            } else {
                if ($fromBankID != $toBankID) {
                    $fromBankBalance = $fromBankBalance - $amount;
                    $toBankBalance = $toBankBalance + $amount;
                }
                $updateFromBankBalance['initial_bank_balance'] = $fromBankBalance;
                $affectedRowsFrom = $rm->update_record($updateFromBankBalance, 'bank_details_t', 'bank_id', $fromBankID);
                $updateToBankBalance['initial_bank_balance'] = $toBankBalance;
                $affectedRowsTo = $rm->update_record($updateToBankBalance, 'bank_details_t', 'bank_id', $toBankID);
                $getInsertFieldValue['amount'] = $amount;
                $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
                $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
                $getInsertFieldValue['user_request_id'] = $userRequestID;
                $lastInserted_payment_id = $rm->insert_record($getInsertFieldValue, 'payment_details_t');
                $login_user_id = $rm->idToValue('login_user_id', 'user_requests_t', 'user_request_id', $userRequestID);
                $gcm_regid = $rm->getUserGCMREGID($login_user_id);
                if ($gcm_regid != "" || $gcm_regid != "NA") {
                    $gcm = new GCM();
                    $registatoin_ids = array($gcm_regid);
                    $msg = "Request " . $requestStatus;
                    $message = array("Response" => $msg);
                    $resultPush = $gcm->send_notification($registatoin_ids, $message);
                }
                $getRegisterFieldValue['status'] = $requestStatus;
                $affectedRows = $rm->update_record($getRegisterFieldValue, 'user_requests_t', 'user_request_id', $userRequestID);
                if ($affectedRows >= 0) {
                    $result = $rm->requestStatusSuccess($lastInserted_payment_id);
                    return $result;
                } else {
                    $result = $rm->requestStatusFail();
                    return $result;
                }
            }
        }
    }
}
function addComment()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            date_default_timezone_set('Asia/Calcutta');
            $comment = $rm->cleanData($_POST['comment']);
            //Get Request From Device
            $userId = $rm->cleanData($_POST['userId']);
            $postId = $rm->cleanData($_POST['postId']);
            $createdDate = date('Y-m-d H:i:s');
            $getArrayList = array();
            //echo $ENCRYPTEDPWD = md5($PASSWORD);
            //echo $ENCRYPTEDPWD = base64_decode($PASSWORD);
            //$ENCRYPTEDPWD=$PASSWORD;
            if ($comment == "" || $userId == "" || $postId == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                $user_owner_id = $rm->idToValue('user_id_fk', 'news_feeds_t', 'post_id', $postId);
                $getInsertFieldValue['comment_text_f'] = $comment;
                $getInsertFieldValue['user_id_fk'] = $userId;
                $getInsertFieldValue['post_id_fk'] = $postId;
                $getInsertFieldValue['comment_Date'] = $createdDate;
                $getInsertFieldValue['user_owner_id_fk'] = $user_owner_id;
                $lastInsertedCommentId = $rm->insert_record($getInsertFieldValue, 'comments_t');
                if ($lastInsertedCommentId) {
                    $deviceId = $rm->idToValue('device_id_f', 'user_details_t', 'user_id', $user_owner_id);
                    //getting deviceId
                    if ($deviceId != '') {
                        $message = "You have received a comment on your post.";
                        $rm->sendPushNotification($deviceId, $message);
                    }
                    $result = $rm->addCommentSuccessJson($postId);
                    return $result;
                } else {
                    $result = $rm->addCommentFailJson();
                    return $result;
                }
            }
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
function followFriend()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $userId = trim($_POST['userId']);
            $friendId = trim($_POST['friendId']);
            if ($userId == "" || $friendId == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                if ($userId == $friendId) {
                    $result = $rm->friendFollowSame();
                    return $result;
                } else {
                    date_default_timezone_set('Asia/Calcutta');
                    $createdDate = date('Y-m-d H:i:s');
                    $getList = array();
                    $checkFollow = $rm->checkExistingFollow($userId, $friendId);
                    if ($checkFollow > 0) {
                        $result = $rm->followAlreadyExists();
                        return $result;
                    }
                    //preparing list and inserting values in friends_t table
                    $getInsertFieldValue['follower_user_id_fk'] = $userId;
                    $getInsertFieldValue['following_user_id_fk'] = $friendId;
                    $getInsertFieldValue['follow_date_f'] = $createdDate;
                    $lastInserted_follow_id = $rm->insert_record($getInsertFieldValue, 'follow_t');
                    if (!empty($lastInserted_follow_id)) {
                        $result = $rm->makeFollowSuccess($userId, $friendId);
                        return $result;
                    } else {
                        $result = $rm->makeFollowFail();
                        return $result;
                    }
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
예제 #7
0
function addUserRequest()
{
    //$companyId = $_REQUEST['companyId'];
    $login_user_id = trim($_REQUEST['userID']);
    $fromBankID = trim($_REQUEST['fromBankID']);
    $toBankID = trim($_REQUEST['toBankID']);
    //$paymentDate = trim($_REQUEST['paymentDate']);
    //$paymentReason = trim($_REQUEST['paymentReason']);
    $amount = trim($_REQUEST['amount']);
    $paymentType = trim($_REQUEST['paymentType']);
    $rm = new Response_Methods();
    if ($login_user_id == "" || $fromBankID == "" || $amount == "" || $paymentType == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getList = array();
        //inserting payment details
        $getInsertFieldValue['login_user_id'] = $login_user_id;
        $companyID = $rm->idToValue('company_id', 'user_details_t', 'login_user_id', $login_user_id);
        $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
        $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
        //$getInsertFieldValue['payment_date']=$paymentDate;
        //$getInsertFieldValue['payment_reason']=$paymentReason;
        $getInsertFieldValue['amount'] = $amount;
        $getInsertFieldValue['payment_type'] = $paymentType;
        $getInsertFieldValue['request_created_date'] = $createdDate;
        $getInsertFieldValue['company_id'] = $companyID;
        $lastInserted_user_request_id = $rm->insert_record($getInsertFieldValue, 'user_requests_t');
        if (!empty($lastInserted_user_request_id)) {
            //Do Transactions by updating bank current balance
            /* Sending Push Notification to Admin */
            $gcm_regid = $rm->getUserGCMREGID(2);
            if ($gcm_regid != "" || $gcm_regid != "NA") {
                $gcm = new GCM();
                $registatoin_ids = array($gcm_regid);
                $msg = "User Payment Request Made. Please Check";
                $message = array("Response" => $msg);
                $resultPush = $gcm->send_notification($registatoin_ids, $message);
            }
            $result = $rm->userRequestSuccessJson($lastInserted_user_request_id);
            return $result;
        } else {
            $result = $rm->userRequestFailJson();
            return $result;
        }
    }
}
예제 #8
0
function addBankDetails()
{
    echo 'test';
    //$companyId = $_REQUEST['companyId'];
    $companyID = trim($_REQUEST['companyID']);
    $custName = trim($_REQUEST['custName']);
    $accNumber = trim($_REQUEST['accNumber']);
    $bankName = trim($_REQUEST['bankName']);
    /*
    $bankAddress = trim($_REQUEST['bankAddress']);		
    if(isset($_REQUEST['micr']))
    $micr = trim($_REQUEST['micr']);
    else
    $micr = "NA";
    */
    $ifsc = trim($_REQUEST['ifsc']);
    $accType = trim($_REQUEST['accType']);
    $initialBalance = trim($_REQUEST['initialBalance']);
    //$Mobile = $_REQUEST['Phone'];
    $rm = new Response_Methods();
    if ($companyID == "" || $custName == "" || $accNumber == "" || $bankName == "" || $ifsc == "" || $accType == "" || $initialBalance == "") {
        //$sendMail=$rm->sendMailPasswordDetails($adminEmail,'test14521','sdfwd45487','Asif Anwar');
        $result = $rm->fields_validation();
        return $result;
    } else {
        $status = 0;
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        /*
        			$result=$rm->getListDetails('user_id','user_fname','user_details_t');
        			if(mysql_num_rows($result)>0)
        				{
        					while($row=mysql_fetch_array($result))
        					{
        						echo $row['0'].' '.$row['1'];
        						echo '<br/>';
        					}
        				}
        
        				
        			//sample codes check for class Functions
        			
        			$result=$rm->getSpecificDetails(6,'user_details_t','user_id');	
        			if(mysql_num_rows($result)>0)
        				{
        					while($row=mysql_fetch_array($result))
        					{
        						echo $row['0'].' '.$row['1'];
        						echo '<br/>';
        					}
        				}
        */
        $getList = array();
        $getInsertFieldValue['company_id'] = $companyID;
        $getInsertFieldValue['account_holder_name'] = $custName;
        $getInsertFieldValue['account_number'] = $accNumber;
        $getInsertFieldValue['bank_name'] = $bankName;
        //$getInsertFieldValue['bank_address']=$bankAddress;
        $getInsertFieldValue['bank_ifsc'] = $ifsc;
        //$getInsertFieldValue['bank_micr']=$micr;
        $getInsertFieldValue['account_type'] = $accType;
        $getInsertFieldValue['initial_bank_balance'] = $initialBalance;
        $getInsertFieldValue['bank_created_date'] = $createdDate;
        $lastInserted_bank_id = $rm->insert_record($getInsertFieldValue, 'bank_details_t');
        if (!empty($lastInserted_bank_id)) {
            $result = $rm->bankRegisterSuccessJson($lastInserted_bank_id);
            return $result;
        } else {
            $result = $rm->bankRegisterFailJson();
            return $result;
        }
    }
}
function addNewsFeeds()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $userId = trim($_POST['userId']);
            $post_image = trim($_POST['post_image']);
            $post_description = $rm->cleanData(trim($_POST['post_description']));
            $location_lat = $rm->cleanData(trim($_POST['location_lat']));
            $location_lang = $rm->cleanData(trim($_POST['location_lang']));
            if ($userId == "" || $post_description == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                date_default_timezone_set('Asia/Calcutta');
                $createdDate = date('Y-m-d H:i:s');
                $getList = array();
                //preparing list and inserting values in news_feed_table table
                $getInsertFieldValue['user_id_fk'] = $userId;
                //$getInsertFieldValue['post_image_f']=$post_image;
                $getInsertFieldValue['post_description_f'] = $post_description;
                $getInsertFieldValue['location_lang_f'] = $location_lang;
                $getInsertFieldValue['location_lat_f'] = $location_lat;
                $getInsertFieldValue['post_date_f'] = $createdDate;
                $lastInserted_post_id = $rm->insert_record($getInsertFieldValue, 'news_feeds_t');
                if (!empty($lastInserted_post_id)) {
                    $IMAGEURLBASEURL = BASEURL . '/images/';
                    $userImageBaseURL = "images/{$username}";
                    $username = $rm->idToValue('user_name_f', 'user_details_t', 'user_id', $userId);
                    $userImageBaseURL = "images/{$username}";
                    if (!is_dir($userImageBaseURL)) {
                        //mkdir - tells that need to create a directory
                        mkdir($userImageBaseURL);
                        mkdir($userImageBaseURL . '/profile_pics/');
                        mkdir($userImageBaseURL . '/post_photos/');
                    }
                    $rand = rand(00, 99999);
                    $img = 'data:image/png;base64,' . $post_image . '';
                    $img = str_replace('data:image/png;base64,', '', $img);
                    $img = str_replace(' ', '+', $img);
                    $data = base64_decode($img);
                    $image = 'post_photos' . $rand . '.png';
                    file_put_contents($userImageBaseURL . '/post_photos/' . $image, $data);
                    //file_put_contents($userImageBaseURL.'/profile_pics/'.$image, $data);
                    $IMAGEURL = $IMAGEURLBASEURL . $username . '/post_photos/' . $image;
                    $dimensions = $rm->getImageDimensions($data);
                    $getUpdatePostPic['image_width_f'] = $dimensions["width"];
                    $getUpdatePostPic['image_height_f'] = $dimensions["height"];
                    $thumbNames = $rm->createThumbs($data, $userImageBaseURL, $image, 'news_feed_post');
                    $getUpdatePostPic['thumb1'] = $thumbNames[0]['filename'];
                    $getUpdatePostPic['thumb2'] = $thumbNames[1]['filename'];
                    $getUpdatePostPic['thumb3'] = $thumbNames[2]['filename'];
                    $getUpdatePostPic['thumb4'] = $thumbNames[3]['filename'];
                    $getUpdatePostPic['thumb5'] = $thumbNames[4]['filename'];
                    $getUpdatePostPic['ipad_portrait_width'] = $thumbNames[3]['width'];
                    $getUpdatePostPic['ipad_portrait_height'] = $thumbNames[3]['height'];
                    $getUpdatePostPic['ipad_landscape_width'] = $thumbNames[4]['width'];
                    $getUpdatePostPic['ipad_landscape_height'] = $thumbNames[4]['height'];
                    $getUpdatePostPic['post_image_f'] = $IMAGEURL;
                    $updateResult = $rm->update_record($getUpdatePostPic, 'news_feeds_t', 'post_id', $lastInserted_post_id);
                    //$result=$rm->getPosts($userId);
                    $result = $rm->postCreationSuccessJson();
                    return $result;
                } else {
                    $result = $rm->postCreationFailJson();
                    return $result;
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
예제 #10
0
function signUpProfile()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $username = $rm->cleanData(trim($_POST['username']));
            $password = $rm->cleanData(trim($_POST['password']));
            $email = trim($_POST['email']);
            $deviceId = trim($_POST['deviceId']);
            $petType = $rm->cleanData(trim($_POST['petType']));
            $petBio = $rm->cleanData(trim($_POST['petBio']));
            $petName = $rm->cleanData(trim($_POST['petName']));
            $petDob = trim($_POST['petDob']);
            $petSpecies = $rm->cleanData(trim($_POST['petSpecies']));
            $notifyEvents = $rm->cleanData(trim($_POST['notifyEvents']));
            $profileId = $rm->rand_str(16, 4);
            if ($username == "" || $password == "" || $email == "" || $petType == "" || $petBio == "" || $petName == "" || $petDob == "" || $petSpecies == "" || $notifyEvents == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                $checkUser = $rm->checkUserValidation($username, 'user_name_f');
                $checkEmail = $rm->checkUserValidation($email, 'email_f');
                if ($checkUser == 0) {
                    $result = $rm->userExistJson();
                    return $result;
                }
                if ($checkEmail == 0) {
                    $result = $rm->emailExistJson();
                    return $result;
                }
                $status = 0;
                date_default_timezone_set('Asia/Calcutta');
                $createdDate = date('Y-m-d H:i:s');
                $getList = array();
                //preparing list and inserting values in user_details table
                $getInsertFieldValue['user_name_f'] = $username;
                $getInsertFieldValue['email_f'] = $email;
                $getInsertFieldValue['device_id_f'] = $deviceId;
                $getInsertFieldValue['profile_id_f'] = $profileId;
                $getInsertFieldValue['join_date_f'] = $createdDate;
                $getInsertFieldValue['pet_type_f'] = $petType;
                $getInsertFieldValue['pet_name_f'] = $petName;
                $getInsertFieldValue['pet_dob_f'] = $petDob;
                $getInsertFieldValue['description_f'] = $petBio;
                $getInsertFieldValue['species_f'] = $petSpecies;
                $getInsertFieldValue['notify_events_f'] = $notifyEvents;
                $lastInserted_user_id = $rm->insert_record($getInsertFieldValue, 'user_details_t');
                if (!empty($lastInserted_user_id)) {
                    //preparing list and inserting values in login table
                    $getInsertLoginDetails['password_f'] = $password;
                    $getInsertLoginDetails['user_name_f'] = $username;
                    $getInsertLoginDetails['user_id_fk'] = $lastInserted_user_id;
                    $lastInserted_login_id = $rm->insert_record($getInsertLoginDetails, 'login_t');
                    if (empty($lastInserted_login_id)) {
                        $rm->delete('user_details_t', 'user_id', $lastInserted_user_id);
                        $result = $rm->userRegisterFailJson();
                        return $result;
                    }
                    //preparing list and inserting values in friends table
                    $getInsertFriendDetails['friend_one'] = $lastInserted_user_id;
                    $getInsertFriendDetails['friend_two'] = $lastInserted_user_id;
                    $getInsertFriendDetails['created_date_f'] = $createdDate;
                    $getInsertFriendDetails['status'] = 2;
                    $lastInserted_friend_id = $rm->insert_record($getInsertFriendDetails, 'friends_t');
                    if (empty($lastInserted_friend_id)) {
                        $rm->delete('login_t', 'login_id', $lastInserted_login_id);
                        $rm->delete('user_details_t', 'user_id', $lastInserted_user_id);
                        $result = $rm->userRegisterFailJson();
                        return $result;
                    }
                    $IMAGEURLBASEURL = BASEURL . '/images/';
                    $userImageBaseURL = "images/{$username}";
                    if (!is_dir($userImageBaseURL)) {
                        //mkdir - tells that need to create a directory
                        mkdir($userImageBaseURL);
                        mkdir($userImageBaseURL . '/profile_pics/');
                        mkdir($userImageBaseURL . '/post_photos/');
                    }
                    $rand = rand(00, 99999);
                    if (isset($_POST['profile_pic']) and $_POST['profile_pic'] != "") {
                        $profile_pic = trim($_POST['profile_pic']);
                        //blob image data
                        $img = 'data:image/png;base64,' . $profile_pic . '';
                        $img = str_replace('data:image/png;base64,', '', $img);
                        $img = str_replace(' ', '+', $img);
                        $data = base64_decode($img);
                        $image = 'petbestie_user_' . $rand . '.png';
                        file_put_contents($userImageBaseURL . '/profile_pics/' . $image, $data);
                        //file_put_contents($userImageBaseURL.'/profile_pics/'.$image, $data);
                        $IMAGEURL = $IMAGEURLBASEURL . $username . '/profile_pics/' . $image;
                        $getUpdateProfilePic['profile_pic_f'] = $IMAGEURL;
                    } else {
                        $getUpdateProfilePic['profile_pic_f'] = "null";
                    }
                    $updateResult = $rm->update_record($getUpdateProfilePic, 'user_details_t', 'user_id', $lastInserted_user_id);
                    $result = $rm->userRegisterSuccessJson($lastInserted_user_id);
                    return $result;
                } else {
                    $result = $rm->userRegisterFailJson();
                    return $result;
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
예제 #11
0
function addUserDetails()
{
    //$companyId = $_REQUEST['companyId'];
    $userFname = trim($_REQUEST['userFname']);
    $userLname = trim($_REQUEST['userLname']);
    $age = trim($_REQUEST['age']);
    $sex = trim($_REQUEST['sex']);
    $emailId = trim($_REQUEST['emailId']);
    $address = trim($_REQUEST['address']);
    $userType = trim($_REQUEST['userType']);
    $companyID = trim($_REQUEST['companyID']);
    /*
    
    		$userImage = trim($_REQUEST['image']);
    $userImage = trim($_REQUEST['image']['name']);
    */
    $adminId = $_REQUEST['adminId'];
    //$adminId='e-002';// need to be send in request..for time being using hardcoded values.
    $fullName = $userFname . ' ' . $userLname;
    //$Mobile = $_REQUEST['Phone'];
    $rm = new Response_Methods();
    if ($userFname == "" || $userLname == "" || $age == "" || $sex == "" || $emailId == "" || $address == "" || $userType == "") {
        //$sendMail=$rm->sendMailPasswordDetails($adminEmail,'test14521','sdfwd45487','Asif Anwar');
        $result = $rm->fields_validation();
        return $result;
    } else {
        $status = 0;
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        //$max_login_id=$rm->getMaxID('login_t','login_user_id');
        $passWord_Ran = substr(md5(rand(0, 1000000)), 0, 8);
        //$ENCRYPTEDPWD = base64_encode($passWord_Ran);
        $ENCRYPTEDPWD = $passWord_Ran;
        $getList = array();
        //$getFieldValue['emp_id']=$userName;
        $getInsertFieldValue['password'] = $ENCRYPTEDPWD;
        $getInsertFieldValue['usertype'] = $userType;
        $lastInserted_login_user_id = $rm->insert_record($getInsertFieldValue, 'login_t');
        if (!empty($lastInserted_login_user_id)) {
            $threeDigitID = str_pad($lastInserted_login_user_id, 3, "0", STR_PAD_LEFT);
            $userName = "******" . $threeDigitID;
            $sqlUpdate = "update login_t set emp_id='{$userName}' where login_user_id={$lastInserted_login_user_id}";
            mysql_query($sqlUpdate, $GLOBALS['link']);
            //$PROFILE_PICTURE = $userData['profilePicture']['name'];
            /*
            $filTemLoc = $_FILES['image']['tmp_name'];
            $moveresult = move_uploaded_file($filTemLoc,"userPics/".$userImage);
            
            $getRegisterFieldValue['user_image']=$userImage;
            
            user image code commented
            */
            $getRegisterFieldValue['user_fname'] = $userFname;
            $getRegisterFieldValue['user_lname'] = $userLname;
            $getRegisterFieldValue['user_age'] = $age;
            $getRegisterFieldValue['user_sex'] = $sex;
            $getRegisterFieldValue['user_email_id'] = $emailId;
            $getRegisterFieldValue['user_address'] = $address;
            $getRegisterFieldValue['login_user_id'] = $lastInserted_login_user_id;
            $getRegisterFieldValue['company_id'] = $companyID;
            $getRegisterFieldValue['user_created_date'] = $createdDate;
            $lastInserted_user_id = $rm->insert_record($getRegisterFieldValue, 'user_details_t');
            if (!empty($lastInserted_user_id)) {
                if ($adminId) {
                    $adminEmail = $rm->getAdminEmailID($adminId);
                    //$adminEmail="*****@*****.**";
                    //die();
                    $sendMail = $rm->sendMailPasswordDetails($adminEmail, $userName, $passWord_Ran, $fullName);
                }
                $result = $rm->userRegisterSuccessJson($lastInserted_user_id);
                return $result;
            } else {
                $result = $rm->userRegisterFailJson();
                return $result;
            }
        } else {
            $result = $rm->userRegisterFailJson();
            return $result;
        }
    }
}
예제 #12
0
function addPaymentDetails()
{
    //$companyId = $_REQUEST['companyId'];
    $companyID = trim($_REQUEST['companyID']);
    $fromBankID = trim($_REQUEST['fromBankID']);
    $toBankID = trim($_REQUEST['toBankID']);
    //$paymentDate = trim($_REQUEST['paymentDate']);
    $paymentReason = trim($_REQUEST['paymentReason']);
    $amount = trim($_REQUEST['amount']);
    $paymentType = trim($_REQUEST['paymentType']);
    $userType = trim($_REQUEST['userType']);
    $userID = trim($_REQUEST['userID']);
    $user_request_id = trim($_REQUEST['user_request_id']);
    $payment_id = trim($_REQUEST['payment_id']);
    // in case of user
    $affectedRowsPayment = -1;
    $rm = new Response_Methods();
    if ($companyID == "" || $fromBankID == "" || $paymentReason == "" || $amount == "" || $paymentType == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getList = array();
        $mailData["paymentDetails"] = array();
        //inserting payment details
        $getInsertFieldValue['company_id'] = $companyID;
        $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
        $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
        //$getInsertFieldValue['payment_date']=$paymentDate;
        $getInsertFieldValue['payment_reason'] = $paymentReason;
        $getInsertFieldValue['login_user_id'] = $userID;
        $getInsertFieldValue['amount'] = $amount;
        $getInsertFieldValue['payment_type'] = $paymentType;
        $getInsertFieldValue['payment_created_date'] = $createdDate;
        $checkRecords = mysql_query("SELECT user_request_id FROM user_requests_t WHERE user_request_id='{$user_request_id}'");
        $checkRecords = mysql_num_rows($checkRecords);
        if ($userType == 'Admin') {
            $checkRecords = 1;
        }
        if ($checkRecords > 0) {
            if (strtolower($userType) == "user") {
                $affectedRowsPayment = $rm->update_record($getInsertFieldValue, 'payment_details_t', 'payment_id', $payment_id);
            } else {
                if (strtolower($userType) == "admin") {
                    $lastInserted_payment_id = $rm->insert_record($getInsertFieldValue, 'payment_details_t');
                }
            }
            $mailData = $getInsertFieldValue;
            $mailData['userID'] = $userID;
            //array_push($mailData["paymentDetails"], $getInsertFieldValue);
            if (!empty($lastInserted_payment_id)) {
                //Do Transactions by updating banks current balance
                $fromBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $fromBankID);
                $toBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $toBankID);
                if ($fromBankBalance < $amount) {
                    $result = $rm->insufficient_balance();
                    return $result;
                }
                if ($fromBankID != $toBankID) {
                    $fromBankBalance = $fromBankBalance - $amount;
                    $toBankBalance = $toBankBalance + $amount;
                }
                $updateFromBankBalance['initial_bank_balance'] = $fromBankBalance;
                $affectedRowsFrom = $rm->update_record($updateFromBankBalance, 'bank_details_t', 'bank_id', $fromBankID);
                $updateToBankBalance['initial_bank_balance'] = $toBankBalance;
                $affectedRowsTo = $rm->update_record($updateToBankBalance, 'bank_details_t', 'bank_id', $toBankID);
            }
            //check payment type and insert details accordingly(cheque/net)
            if (strtolower($paymentType) == "cheque") {
                //insert cheque details
                $mailData["chequeDetails"] = array();
                if (!empty($lastInserted_payment_id)) {
                    $payment_id_inserted = $lastInserted_payment_id;
                } else {
                    $payment_id_inserted = $payment_id;
                }
                $getChequeDetails['payment_id'] = $payment_id_inserted;
                $getChequeDetails['cheque_number'] = trim($_REQUEST['chequeNo']);
                $getChequeDetails['cheque_date'] = trim($_REQUEST['chequeDate']);
                $getChequeDetails['to_whom_issued'] = trim($_REQUEST['chequeIssued']);
                //$getChequeDetails['cheque_amount']=trim($_REQUEST['chequeAmount']);
                $getChequeDetails['cheque_amount'] = $amount;
                $getChequeDetails['cheque_created_date'] = $createdDate;
                $lastInserted_cheque_id = $rm->insert_record($getChequeDetails, 'cheque_details_t');
                array_push($mailData["chequeDetails"], $getChequeDetails);
            } else {
                if (strtolower($paymentType) == "net") {
                    //insert NET Banking Details
                    $mailData["netDetails"] = array();
                    if (!empty($lastInserted_payment_id)) {
                        $payment_id_inserted = $lastInserted_payment_id;
                    } else {
                        $payment_id_inserted = $payment_id;
                    }
                    $getNetBankingDetails['payment_id'] = $payment_id_inserted;
                    //$getNetBankingDetails['type']=trim($_REQUEST['netBankingType']);
                    $getNetBankingDetails['nbd_created_date'] = $createdDate;
                    $lastInserted_cheque_id = $rm->insert_record($getNetBankingDetails, 'net_banking_details_t');
                    array_push($mailData["netDetails"], $getNetBankingDetails);
                    //print_r($getNetBankingDetails);
                }
            }
            if (strtolower($userType) == "user") {
                $adminId = 1;
                if ($adminId != 0) {
                    $adminEmail = $rm->getAdminEmailID($adminId);
                    //print_r($mailData);;
                    $sendMail = $rm->sendTransactionDetails($adminEmail, $mailData);
                }
            }
            if (strtolower($userType) == "user" && $affectedRowsPayment >= 0) {
                $result = $rm->paymentRegisterSuccessJson($payment_id);
                $sqlUpdate = "update user_requests_t set status='Paid' where user_request_id={$user_request_id}";
                mysql_query($sqlUpdate, $GLOBALS['link']);
                return $result;
            } else {
                if (strtolower($userType) == "admin" && !empty($lastInserted_payment_id)) {
                    $result = $rm->paymentRegisterSuccessJson($lastInserted_payment_id);
                    $sqlUpdate = "update user_requests_t set status='Paid' where user_request_id={$user_request_id}";
                    mysql_query($sqlUpdate, $GLOBALS['link']);
                    return $result;
                }
            }
            if (empty($lastInserted_payment_id) && strtolower($userType) == "admin") {
                $result = $rm->paymentRegisterFailJson();
                return $result;
            }
            if ($affectedRowsPayment < 0 && strtolower($userType) == "user") {
                $result = $rm->paymentRegisterFailJson();
                return $result;
            }
        } else {
            $errorCode = "2";
            $errorMsg = "User Request Not Exist";
            $newData = "{\"data\":{\"Error_Code\":\"" . $errorCode . "\",\"Error_Msg\":\"" . $errorMsg . "\"}}";
            //Json Format Response
            return $newData;
        }
    }
}
function addPaymentDetails()
{
    //$companyId = $_REQUEST['companyId'];
    $companyID = trim($_REQUEST['companyID']);
    $fromBankID = trim($_REQUEST['fromBankID']);
    $toBankID = trim($_REQUEST['toBankID']);
    //$paymentDate = trim($_REQUEST['paymentDate']);
    $paymentReason = trim($_REQUEST['paymentReason']);
    $amount = trim($_REQUEST['amount']);
    $paymentType = trim($_REQUEST['paymentType']);
    $rm = new Response_Methods();
    if ($companyID == "" || $fromBankID == "" || $toBankID == "" || $paymentReason == "" || $amount == "" || $paymentType == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getList = array();
        //inserting payment details
        $getInsertFieldValue['company_id'] = $companyID;
        $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
        $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
        //$getInsertFieldValue['payment_date']=$paymentDate;
        $getInsertFieldValue['payment_reason'] = $paymentReason;
        $getInsertFieldValue['amount'] = $amount;
        $getInsertFieldValue['payment_type'] = $paymentType;
        $getInsertFieldValue['payment_created_date'] = $createdDate;
        $lastInserted_payment_id = $rm->insert_record($getInsertFieldValue, 'payment_details_t');
        if (!empty($lastInserted_payment_id)) {
            //Do Transactions by updating bank current balance
            $fromBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $fromBankID);
            $toBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $toBankID);
            if ($fromBankID != $toBankID) {
                $fromBankBalance = $fromBankBalance - $amount;
                $toBankBalance = $toBankBalance + $amount;
            }
            $updateFromBankBalance['initial_bank_balance'] = $fromBankBalance;
            $affectedRowsFrom = $rm->update_record($updateFromBankBalance, 'bank_details_t', 'bank_id', $fromBankID);
            $updateToBankBalance['initial_bank_balance'] = $toBankBalance;
            $affectedRowsTo = $rm->update_record($updateToBankBalance, 'bank_details_t', 'bank_id', $toBankID);
            //check payment type and insert details accordingly(cheque/net)
            if (strtolower($paymentType) == "cheque") {
                //insert cheque details
                //echo 'test';
                $getChequeDetails['payment_id'] = $lastInserted_payment_id;
                $getChequeDetails['cheque_number'] = trim($_REQUEST['chequeNo']);
                $getChequeDetails['cheque_date'] = trim($_REQUEST['chequeDate']);
                $getChequeDetails['to_whom_issued'] = trim($_REQUEST['chequeIssued']);
                //$getChequeDetails['cheque_amount']=trim($_REQUEST['chequeAmount']);
                $getChequeDetails['cheque_amount'] = $amount;
                $getChequeDetails['cheque_created_date'] = $createdDate;
                $lastInserted_cheque_id = $rm->insert_record($getChequeDetails, 'cheque_details_t');
            } else {
                if (strtolower($paymentType) == "net") {
                    //insert NET Banking Details
                    $getNetBankingDetails['payment_id'] = $lastInserted_payment_id;
                    $getNetBankingDetails['type'] = trim($_REQUEST['netBankingType']);
                    $getNetBankingDetails['nbd_created_date'] = $createdDate;
                    $lastInserted_cheque_id = $rm->insert_record($getNetBankingDetails, 'net_banking_details_t');
                }
            }
            $result = $rm->paymentRegisterSuccessJson($lastInserted_payment_id);
            return $result;
        } else {
            $result = $rm->paymentRegisterFailJson();
            return $result;
        }
    }
}