示例#1
0
 function saveWorkManager($data)
 {
     $data['work_title'] = "System generated";
     $data['work_desc'] = $data['desc'];
     $dbh = $this->get_connection();
     if ($dbh) {
         $dateTime = new \DateTime();
         $created_date = $modified_date = $dateTime->format("Y-m-d H:i:s");
         $login_user_id = $_SESSION['userinfo']->id;
         $workdate = '';
         if ($data['work_date'] != '' || !empty($data['work_date'])) {
             $workdate = date('Y-m-d H:i:s', strtotime($data['work_date']));
         }
         $show = 1;
         $approved = 2;
         $work_insert_query = "INSERT INTO " . self::TAB_WORK . "(" . self::TAB_WORK_USER_ID . ", " . self::TAB_WORK_TITLE . ", " . self::TAB_WORK_DESCRIPTION . ", " . self::TAB_WORK_CREATED_BY . ", " . self::TAB_WORK_REQUEST_FOR . ", " . self::TAB_WORK_CREATED_DATE . ", " . self::TAB_WORK_MODIFIED_DATE . ", " . self::TAB_WORK_WORK_DATE . ")\n\t\t\t\tVALUES(:user_id,:work_title,:work_description,:created_by,:request_for,:created_date,:modified_date,:work_date)";
         $work_insert = $dbh->prepare($work_insert_query);
         $work_insert->execute(array(':user_id' => $data['user_id'], ':work_title' => $data['work_title'], ':work_description' => $data['work_desc'], ':created_by' => $login_user_id, ':request_for' => $data['rating'], ':created_date' => $created_date, ':modified_date' => $modified_date, ':work_date' => $workdate));
         $work_last_insert = $dbh->lastInsertId();
         $request_insert_query = "INSERT INTO " . self::TAB_REQUEST . "(" . self::TAB_REQUEST_FROM_ID . ", " . self::TAB_REQUEST_TO_ID . ", " . self::TAB_REQUEST_STATUS . ", " . self::TAB_REQUEST_WORK_ID . ", " . self::TAB_REQUEST_CREATED_DATE . ", " . self::TAB_REQUEST_MODIFIED_DATE . ", " . self::TAB_REQUEST_SHOW . ")\n\t\t\t\t\t VALUES(:from_id,:to_id,:status,:work_id,:created_date,:modified_date,:show_request)";
         $request_insert = $dbh->prepare($request_insert_query);
         $request_insert->execute(array(':from_id' => $login_user_id, ':to_id' => $data['user_id'], ':status' => $approved, ':work_id' => $work_last_insert, ':created_date' => $created_date, ':modified_date' => $modified_date, ':show_request' => $show));
         $request_last_insert = $dbh->lastInsertId();
         $rating_insert_query = "INSERT INTO " . self::TAB_RATING . "(" . self::TAB_RATING_REQUEST_ID . ", " . self::TAB_RATING_WORK_ID . ", " . self::TAB_RATING_USER_ID . ", " . self::TAB_RATING_RATING . ", " . self::TAB_RATING_GIVEN_BY . ", " . self::TAB_RATING_CREATED_DATE . ", " . self::TAB_RATING_MODIFIED_DATE . ", " . self::TAB_RATING_SHOW_RATING . ")\n\t\t\t\t\t VALUES(:request_id,:work_id,:user_id,:rating,:given_by,:created_date,:modified_date,:show_rating)";
         $rating_insert = $dbh->prepare($rating_insert_query);
         $rating_insert->execute(array(':request_id' => $request_last_insert, ':work_id' => $work_last_insert, ':user_id' => $data['user_id'], ':rating' => $data['rating'], ':given_by' => $login_user_id, ':created_date' => $created_date, ':modified_date' => $modified_date, ':show_rating' => $show));
         if (isset($data['comment']) && !empty($data['comment'])) {
             $comment_insert_query = "INSERT INTO " . self::TAB_COMMENT . "(" . self::TAB_COMMENT_REQUEST_ID . ", " . self::TAB_COMMENT_TEXT . ", " . self::TAB_COMMENT_BY_ID . ", " . self::TAB_COMMENT_CREATED_DATE . ", " . self::TAB_COMMENT_MODIFIED_DATE . ")\n\t\t\t\t\t VALUES(:request_id,:comment_text,:by_id,:created_date,:modified_date)";
             $comment_insert = $dbh->prepare($comment_insert_query);
             $comment_insert->execute(array(':request_id' => $request_last_insert, ':comment_text' => $data['comment'], ':by_id' => $login_user_id, ':created_date' => $created_date, ':modified_date' => $modified_date));
         }
         if (isset($data['action']) && $data['action'] == 'btn_click') {
             notifyAwardOne($data);
         }
         return true;
     }
 }
示例#2
0
 function rate_team_mem_plus($data)
 {
     $dbh = $this->get_connection();
     if ($dbh) {
         $dateTime = new \DateTime();
         $created_date = $modified_date = $dateTime->format("Y-m-d H:i:s");
         $login_user_id = $_SESSION['userinfo']->id;
         $data['comment'] = $data['work_desc'];
         $data['user_id'] = $data['for_id'];
         $work_insert_query = "INSERT INTO " . self::TAB_WORK . "(" . self::TAB_WORK_USER_ID . ", " . self::TAB_WORK_TITLE . ", " . self::TAB_WORK_DESCRIPTION . ", " . self::TAB_WORK_CREATED_BY . ", " . self::TAB_WORK_FOR_ID . ", " . self::TAB_WORK_REQUEST_FOR . ", " . self::TAB_WORK_CREATED_DATE . ", " . self::TAB_WORK_MODIFIED_DATE . ", " . self::TAB_WORK_WORK_DATE . ")\n                                                                VALUES(:user_id,:work_title,:work_description,:created_by,:for_id,:request_for,:created_date,:modified_date,:work_date)";
         $work_insert = $dbh->prepare($work_insert_query);
         $work_insert->execute(array(':user_id' => $data['user_id'], ':work_title' => $data['work_title'], ':work_description' => $data['work_desc'], ':created_by' => $login_user_id, ':request_for' => '1', ':for_id' => $data['for_id'], ':created_date' => $created_date, ':modified_date' => $modified_date, ':work_date' => ''));
         $work_last_insert = $dbh->lastInsertId();
         $request_insert_query = "INSERT INTO " . self::TAB_REQUEST . "(" . self::TAB_REQUEST_FROM_ID . ", " . self::TAB_REQUEST_TO_ID . ", " . self::TAB_REQUEST_STATUS . ", " . self::TAB_REQUEST_WORK_ID . ", " . self::TAB_REQUEST_CREATED_DATE . ", " . self::TAB_REQUEST_MODIFIED_DATE . ", " . self::TAB_REQUEST_SHOW . ")\n                                                                         VALUES(:from_id,:to_id,:status,:work_id,:created_date,:modified_date,:show_request)";
         $request_insert = $dbh->prepare($request_insert_query);
         $request_insert->execute(array(':from_id' => $login_user_id, ':to_id' => $data['user_id'], ':status' => '2', ':work_id' => $work_last_insert, ':created_date' => $created_date, ':modified_date' => $modified_date, ':show_request' => '1'));
         $request_last_insert = $dbh->lastInsertId();
         $rating_insert_query = "INSERT INTO " . self::TAB_RATING . "(" . self::TAB_RATING_REQUEST_ID . "," . self::TAB_RATING_WORK_ID . ", " . self::TAB_RATING_USER_ID . ", " . self::TAB_RATING_RATING . ", " . self::TAB_RATING_GIVEN_BY . ", " . self::TAB_RATING_CREATED_DATE . ", " . self::TAB_RATING_MODIFIED_DATE . ", " . self::TAB_RATING_SHOW_RATING . ")\n                                                                         VALUES(:request_id,:work_id,:user_id,:rating,:given_by,:created_date,:modified_date,:show_rating)";
         $rating_insert = $dbh->prepare($rating_insert_query);
         $rating_insert->execute(array('request_id' => $request_last_insert, ':work_id' => $work_last_insert, ':user_id' => $data['for_id'], ':rating' => '1', ':given_by' => $login_user_id, ':created_date' => $created_date, ':modified_date' => $modified_date, ':show_rating' => '2'));
         if (!empty($data)) {
             notifyAwardOne($data);
         }
     }
     return true;
 }