示例#1
0
 public function GetHistoryCalls($model, $userID)
 {
     $checkUserrole = Common::UserRoles($userID);
     $ServiceResponse = new ServiceResponse();
     $LastIndex = 0;
     $PageSize = 10;
     $LastIndex = !empty($model->LastID) ? $model->LastID : $LastIndex;
     $PageSize = !empty($model->PageSize) ? $model->PageSize : $PageSize;
     $where = '1=1';
     if (!empty($model->SearchText)) {
         $where = "( and Script Like '%" . $model->SearchText . "%' OR InitiatingPrice Like '%" . $model->SearchText . "%' OR T1 Like '%" . $model->SearchText . "%' OR T2 Like '%" . $model->SearchText . "%' OR SL Like '%" . $model->SearchText . "%')";
     }
     if ($checkUserrole->RoleID == Constants::$RoleAdmin) {
         $vwCallListEntity = vwCallListEntity::orderBy('UpdatedDate', Constants::$SortIndexDESC)->where("SegmentID", $model->SegmentID)->where('IsOpen', Constants::$Value_False)->whereRaw($where)->skip($LastIndex)->take($PageSize)->get();
     } else {
         $calIDs = DB::table('usercalls')->where('UserID', $userID)->lists('CallID');
         if ($calIDs && count($calIDs) > 0) {
             $vwCallListEntity = vwCallListEntity::orderBy('UpdatedDate', Constants::$SortIndexDESC)->where("SegmentID", $model->SegmentID)->where('IsOpen', Constants::$Value_False)->whereRaw($where)->whereIn('CallID', $calIDs)->skip($LastIndex)->take($PageSize)->get();
         } else {
             $vwCallListEntity = array();
         }
     }
     if (count($vwCallListEntity) > 0) {
         foreach ($vwCallListEntity as $vwCallList) {
             $vwCallList->T1 = $vwCallList->T1 . '';
             $vwCallList->T2 = $vwCallList->T2 . '';
             $vwCallList->SL = $vwCallList->SL . '';
             $vwCallList->InitiatingPrice = $vwCallList->InitiatingPrice . '';
             $vwCallList->ResultID = $vwCallList->ResultID + 0;
             $vwCallList->ResultName = $vwCallList->ResultName . '';
             $vwCallList->ResultDescription = $vwCallList->ResultDescription ? $vwCallList->ResultDescription : '';
             $vwCallList->ScriptName = $vwCallList->Script . '' . (!empty($vwCallList->Contract) ? ' (' . $vwCallList->Contract . ')' : '') . (!empty($vwCallList->SubSection) ? ' (' . $vwCallList->SubSection . ')' : '');
             $vwCallList->Image = $vwCallList->Image ? asset(Constants::$Path_ScriptImages . $vwCallList->ScriptID . '/' . rawurlencode($vwCallList->Image)) : '';
             $vwCallList->CreatedDate = date_format(date_create($vwCallList->CreatedDate), Constants::$DefaultDisplayDateTimeFormat);
         }
     }
     $ServiceResponse->Data = array("CallList" => $vwCallListEntity);
     $ServiceResponse->IsSuccess = TRUE;
     return $ServiceResponse;
 }