/** * @return mixed */ public static function sort($array = null) { $instance = new Self($array); if (true === is_array($array)) { $instance->set($array); } return $instance->doSort()->toArray(); }
/** * Busca uma doula existente no banco de dados * @param int $id * @return Doula */ public static function buscarPorId($id) { $doula = new Self(); $obj = $doula->ver(tbl_doulas, $id); if ($id !== $obj->id) { return false; } $this->hydrate((array) $doula); return $doula; }
/** * Models a collection media object for media feeds * * @param type $mediaObject * @param type $mediaObjectType * @param type $mediaObjectId * * return void; */ public static function mediaObject(&$mediaObject, $collection) { //If the media object is not a collection! skip it //1.Load the collection! if (!is_object($collection) && is_a($collection, Entity::class)) { $thisModel = new Self(); $attachment = $thisModel->loadObjectByURI($collection); } //If the media object is not a collection! skip it $objectTypeshaystack = array("collection"); if (!in_array($collection->getObjectType(), $objectTypeshaystack)) { return; } //Nothing to do here if we can't deal with it! $collectionObject = new Media\Collection(); //2.Get all the elements in the collection, limit 5 if more than 5 //3.Trigger their timeline display $collectionObject->set("objectType", "collection"); $collectionObject->set("uri", $collection->getObjectURI()); //Now lets populate our collection with Items $collectionItems = $collection->getPropertyValue("collection_items"); $collectionItemize = explode(",", $collectionItems); $collectionObject->set("totalItems", count($collectionItemize)); if (is_array($collectionItemize) && !empty($collectionItemize)) { $items = array(); foreach ($collectionItemize as $item) { $itemObject = Media\MediaLink::getNew(); //@TODO Will probably need to query for objectType of items in collection? //@TODO Also this will help in removing objects from collections that have previously been deleted $itemObjectEntity = $thisModel->load->model("attachment", "system")->loadObjectByURI($item); //Load the item with the attachment to get all its properties //Now check object_id exists; //If not delete the object all together; //Also check if attachments_src is defined and exsits; //If attachments id does not exists, delete the item from this collection; $itemObjectURL = !empty($item) ? "/system/object/{$item}/" : "http://placeskull.com/100/100/999999"; $itemObject->set("url", $itemObjectURL); $itemObject->set("uri", $item); $itemObject->set("height", null); $itemObject->set("width", null); $itemObject->set("type", $itemObjectEntity->getPropertyValue("attachment_type")); $itemObject->set("name", $itemObjectEntity->getPropertyValue("attachment_name")); $items[] = $itemObject::getArray(); unset($itemObject); } $collectionObject->set("items", $items); } //Now set the collection Object as the media Object $mediaObject = $collectionObject; unset($collection); unset($collectionObject); //All done return true; }
/** * @param $string * @param [$string] * @return @response */ public static function store($module, $action) { $audit = new Self(); $audit->module = $module; $audit->action = $action; $audit->ip = Request::getClientIp(); $audit->user = self::getUser(); $audit->created_at = Carbon::now(); $audit->updated_at = Carbon::now(); $audit->save(); }
public static function view_data(Request $request, Post $post) { $instance = new Self(); $per_page = session('per_page') ? session('per_page') : config('constants.per_page'); $post = Post::with('user.votes')->with('subreddit.moderators')->with('comments')->where('id', $post->id)->first(); $comment = $post->comments; $user = User::where('id', '=', Auth::id())->get(); $check = $post->subreddit->moderators->where('user_id', Auth::id())->first(); $isModerator = $check ? true : false; $result['per_page'] = $per_page; $result['comments'] = $instance->comment_list($per_page, $request, $post, $comment, $user, $isModerator); $result['total_comments'] = $instance->total_comments($post); return $result; }
/** * 登录日志 * @param [type] $type [description] * @param [type] $user [description] * @return [type] [description] */ public static function login($type, $user) { $related_id = $user->id; switch ($type) { case 'employee': $action_type_id = 1; $ins_type_id = 6; $memo = '员工登录'; break; case 'agency': $action_type_id = 2; $ins_type_id = 5; $memo = '代理商登录'; break; case 'department': $action_type_id = 3; $ins_type_id = 4; $memo = '科室登录'; break; default: break; } $memo = $memo . '-' . username(); Self::add_log($action_type_id, $ins_type_id, $related_id, $memo); }
public static function details(Request $request) { //Note this is piggybacking on regular event controller functions, beware of changing them!! $eid = $request->eid; $event = Event::getEvent($eid); $invites = Self::getInvitesFromEid($eid); $all_poll_options = Self::getPollOptionsFromEid($eid); $itemslist = Event::getEventItems($eid); $userRSVP = Invite::getUserRSVP($eid); $items = []; $item_users = []; $ticketcost = (string) $event['ticketprice']; if (!strpos($ticketcost, '.')) { $ticketcost = $ticketcost . ".00"; } foreach ($itemslist as $item) { array_push($items, $item); if ($item->uid != 0) { $tmpUser = User::getById($item->uid); array_push($item_users, $tmpUser); } } $chat_messages = MessageController::getMessagesFromEid($eid); return response()->json(compact('event', 'all_poll_options', 'items', 'invites', 'chat_messages', 'item_users', 'userRSVP', 'ticketcost')); }
public static function process($numWords, $numNums, $numChars) { //read in the words from the file on a single line $word = file("wordList.txt"); //convert it to a 2 dimensional array. Index [0][n] is line 1 $result = array_map(function ($v) { return explode(" ", $v); }, file("wordList.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); //create password with selected number of words. $pWord = ""; for ($g = 0; $g < $numWords; $g++) { $temp = $result[0][rand(0, count($result[0]))]; $pWord = $pWord . $temp; } //clean out any special characters that may be in the file $pWord = Self::clean($pWord); //add characters for ($f = 0; $f < $numChars; $f++) { $pWord = $pWord . chr(rand(33, 45)); } //add numbers for ($e = 0; $e < $numNums; $e++) { $pWord = $pWord . rand(0, 9); } return $pWord; }
public function getOrder($user_id) { $query = Self::find()->select('*')->from('fin_order as order')->leftjoin('fin_student as student', 'order.user_id = student.user_id')->where(['order.merchant_id' => $user_id]); $pages = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $order = $query->offset($pages->offset)->limit($pages->limit)->Asarray()->all(); return ['order' => $order, 'pages' => $pages]; }
public static function getCountry(array $country) { foreach ($country as $key => $value) { # code... switch($value) { case 'India': Self::$con="in"; return Self::$con; break; case 'US': Self::$con="us"; return Self::$con; break; case 'UK': Self::$con="uk"; return Self::$con; break; case 'Hong Kong': Self::$con="hk"; return Self::$con; break; case 'Turkey': Self::$con="tr"; return Self::$con; break; } } }
public static function searchResult() { require_once 'Search.model.php'; require_once 'Upload.model.php'; require_once 'User.model.php'; $data = array(); if (isset($_POST['searchProduct'])) { $searchProduct = $_POST['searchField']; $category = $_POST['category']; $state = $_POST['state']; $sort = $_POST['sort']; $query = SearchModel::searchQuery($searchProduct, $category, $state, $sort); try { $searchresult = SearchModel::getSearchResult($searchProduct, $category, $state, $sort); $data['template'] = 'searchResult.html'; $data['products'] = $searchresult; $data['states'] = UserModel::getStates(); $data['categories'] = UploadModel::getCategories(); } catch (Exception $e) { $data['error'] = $e->getMessage(); $data['template'] = 'error.html'; $data['states'] = UserModel::getStates(); $data['categories'] = UploadModel::getCategories(); } } else { $searchCheck = Self::searchCheck(); $data['redirect'] = 'error.html'; } return $data; }
function picked_stocks($code) { //grab informatino from database. $movements = $this->movement->selected($code); $stocks = $this->stocks->selected($code); //set table layout and view foreach ($stocks as $stock) { $stockarr[] = $this->parser->parse('Stocks/stock_table', (array) $stock, true); } $parms = array('table_open' => '<table class="stocks">'); $this->table->set_template($parms); //generate html elements $rows = $this->table->make_columns($stockarr, 1); $this->data['stocktable'] = $this->table->generate($rows); foreach ($movements as $moves) { $movementarr[] = $this->parser->parse('Stocks/movement_table', (array) $moves, true); } $parm = array('table_open' => '<table class ="movements">'); $this->table->set_template($parm); $rows_movement = $this->table->make_columns($movementarr, 1); $this->data['movementtable'] = $this->table->generate($rows_movement); //generate drop down menu and tables $this->data['pageselect'] = Self::populate_options(); $this->data['pagebody'] = 'Stocks/stockview'; $this->render(); }
public static function postprocess($sessions, $groupparams, $user, $yachs, $sport, $period) { $olmapdetails->startpoints = $sessions; $olmapdetails->extent = Self::fullextent($period); $olmapdetails->sessions_sport = Self::getsports($period); return $olmapdetails; }
public function sel_detail($user_id) { $query = Self::find()->select('*')->from('fin_detail')->where(['user_id' => $user_id]); $pages = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $detail = $query->offset($pages->offset)->limit($pages->limit)->Asarray()->all(); return ['detail' => $detail, 'pages' => $pages]; }
public static function getSelectors() { foreach (Self::All() as $item) { $returnArray[$item->id] = $item->getName(); } return $returnArray; }
public static function CurrenyRatesUpdate() { ini_set('max_execution_time', 150000); ini_set("memory_limit", "128M"); $max_date_sql = "select MAX(day) day from currency_rates"; $max_date_res = Yii::app()->db->createCommand($max_date_sql)->queryAll(true); //var_dump($max_date_res[0]["day"]); //exit; $start_date = date($max_date_res[0]["day"]); // date("2000-01-01"); // date('Y-m-d', strtotime('-1 years')); $start_date = strtotime($start_date); $start_date = strtotime("+1 day", $start_date); $start_date = date('Y-m-d', $start_date); $currencies = ['EUR', 'JPY', 'GBP', 'AUD', 'CHF', 'CAD', 'MXN', 'CNY', 'CNH', 'NZD', 'SEK', 'RUB', 'DKK', 'NOK', 'HKD', 'SGD', 'TRY', 'KRW', 'ZAR', 'BRL', 'INR']; while (strtotime($start_date) <= strtotime("now")) { $existing_rate = CurrencyRates::model()->findByAttributes(['day' => $start_date]); if (count($existing_rate) == 0) { $currency_rates = new CurrencyRates(); $currency_rates->day = $start_date; foreach ($currencies as $cur) { $currency_rates->{$cur} = 1; $Url = "http://currencies.apps.grandtrunk.net/getrate/" . $start_date . "/" . $cur . "/USD"; $get_rate = Self::url_get_contents($Url); if ($get_rate >= 0) { $currency_rates->{$cur} = $get_rate; } } $currency_rates->save(); } ///+one day// $start_date = strtotime($start_date); $start_date = strtotime("+1 day", $start_date); $start_date = date('Y-m-d', $start_date); } }
public static function getLignes() { // Récupère la configuration du délais du cache, sinon deux heures par défaut Config::get('cache.arretsCacheDelay') ? $cacheDelay = Config::get('cache.arretsCacheDelay') : ($cacheDelay = 120); $search = Input::get('search'); $lignes = Self::remember($cacheDelay)->where('libelleLigne', 'like', '%' . $search . '%')->orWhere('idLigne', '=', $search)->groupBy('numero')->lists('libelleLigne', 'numero'); return Response::json($lignes); }
/** * Retourne un JSON contenant les arrêts */ public static function getArrets() { // Récupère la configuration du délais du cache, sinon deux heures par défaut Config::get('cache.arretsCacheDelay') ? $cacheDelay = Config::get('cache.arretsCacheDelay') : ($cacheDelay = 120); $search = Input::get('search'); $arrets = Self::remember($cacheDelay)->where('nomArret', 'like', '%' . $search . '%')->distinct('nomArret')->lists('nomArret'); return Response::json($arrets); }
public function ToCheckbox($para) { $para = Self::idName($para); if ($para['status']) { return self::_Todo($para, 'checkbox'); } else { return $para['msg']; } }
public static function availableProperties() { $properties = Self::all(); $result = []; foreach ($properties as $property) { $result[$property->id] = $property->description; } return $result; }
/** * Show a list of all available tenants * @return [array] list of tenants */ public static function availableTenants() { $tenants = Self::all(); $result = []; foreach ($tenants as $tenant) { $result[$tenant->id] = $tenant->name; } return $result; }
static function getDefault($payment_types) { $def = Self::find($payment_types, 'payment_type_is_default', 1); if (isset($def)) { return $def; } else { return $payment_types[0]; } }
/** * Reads the details of the LaCarte matching the * passed name. * * @access public * @param string $laCarte * @return array * @since 1.0.0 * @version 1.0.0 */ public static function getALaCarteDetails($aLaCarteID) { if (!is_numeric($aLaCarteID)) { $query = DB::table('vendor_locations')->where('slug', $aLaCarteID)->select('id')->first(); if ($query) { $aLaCarteID = $query->id; } else { $arrData['status'] = Config::get('constants.API_SUCCESS'); $arrData['no_result_msg'] = 'No matching values found.'; $arrData['data'] = array(); $arrData['total_count'] = 0; return $arrDatas; } } //Checking the bookmark status of the product $data['access_token'] = $_SERVER['HTTP_X_WOW_TOKEN']; $userID = UserDevices::getUserDetailsByAccessToken($data['access_token']); $bookmark = DB::table('user_bookmarks as ub')->where('user_id', '=', $userID)->where('vendor_location_id', '=', $aLaCarteID)->select('id', 'type')->first(); //array to store the matching result $arrData = array(); //query to read the details of the A-La-Carte $queryResult = DB::table(DB::raw('vendor_locations as vl'))->join('vendors', 'vendors.id', '=', 'vl.vendor_id')->join(DB::raw('vendor_location_attributes_text as vlat'), 'vlat.vendor_location_id', '=', 'vl.id')->join(DB::raw('vendor_attributes as va'), 'va.id', '=', 'vlat.vendor_attribute_id')->leftjoin(DB::raw('vendor_locations_curator_map as vlcm'), 'vlcm.vendor_location_id', '=', 'vl.id')->leftjoin('curators', 'curators.id', '=', 'vlcm.curator_id')->join(DB::raw('vendor_location_address as vla'), 'vla.vendor_location_id', '=', 'vl.id')->join(DB::raw('locations as loc1'), 'loc1.id', '=', 'vla.area_id')->join(DB::raw('locations as loc2'), 'loc2.id', '=', 'vla.city_id')->join(DB::raw('locations as loc3'), 'loc3.id', '=', 'vla.state_id')->join(DB::raw('locations as loc4'), 'loc4.id', '=', 'vla.country_id')->join('locations as loc5', 'loc5.id', '=', 'vl.location_id')->leftJoin(DB::raw('media_resized_new as m2'), 'm2.id', '=', 'curators.media_id')->leftJoin(DB::raw('vendor_location_attributes_integer as vlai'), 'vlai.vendor_location_id', '=', 'vl.id')->leftJoin(DB::raw('vendor_attributes as va2'), 'va2.id', '=', 'vlai.vendor_attribute_id')->where('vl.id', $aLaCarteID)->where('vl.a_la_carte', '=', 1)->where('vl.status', 'Active')->where('va2.alias', 'reward_points_per_reservation')->groupBy('vl.id')->select('vl.id as vl_id', 'vl.vendor_id', 'vla.address', 'vla.pin_code', 'vla.latitude', 'vla.longitude', 'vendors.name as title', DB::raw('MAX(IF(va.alias = "restaurant_info", vlat.attribute_value, "")) AS resturant_info'), DB::raw('MAX(IF(va.alias = "short_description", vlat.attribute_value, "")) AS short_description'), DB::raw('MAX(IF(va.alias = "terms_and_conditions", vlat.attribute_value, "")) AS terms_conditions'), DB::raw('MAX(IF(va.alias = "menu_picks", vlat.attribute_value, "")) AS menu_picks'), DB::raw('MAX(IF(va.alias = "expert_tips", vlat.attribute_value, "")) AS expert_tips'), DB::raw('MAX(IF(va.alias = "special_offer_title", vlat.attribute_value, "")) AS special_offer_title'), DB::raw('MAX(IF(va.alias = "special_offer_desc", vlat.attribute_value, "")) AS special_offer_desc'), 'loc1.name as area', 'loc1.id as area_id', 'loc2.name as city', 'loc3.name as state_name', 'loc4.name as country', 'loc5.name as locality', 'curators.name as curator_name', 'curators.bio as curator_bio', 'curators.designation as designation', 'vl.pricing_level', 'vlai.attribute_value as reward_point', 'm2.file as curator_image', 'vl.location_id as vl_location_id', 'vlcm.curator_tips', 'vla.city_id', 'vl.slug')->first(); if ($queryResult) { //reading the review ratings $arrReview = Review::findRatingByVendorLocation(array($queryResult->vl_id)); //reading vendor-cuisine $arrVendorCuisine = Self::getVendorLocationCuisine(array($queryResult->vl_id)); //reading the similar vendors $arrSimilarVendor = Self::getSimilarALaCarte(array('location_id' => $queryResult->area_id, 'pricing_level' => $queryResult->pricing_level, 'city_id' => $queryResult->city_id)); $arrSimilarAlacarteFilters = $arrSimilarVendor; //print_r($filters); die("hmm"); $arrResultAlacarte = Self::fetchListings($arrSimilarAlacarteFilters); //print_r($arrResult); die("hmm"); //initializing the values for experience if (Self::isExperienceAvailable($queryResult->vl_id)) { $experienceAvailable = 'true'; $experienceURL = URL::to('/') . '/experience/' . $aLaCarteID; } else { $experienceAvailable = 'false'; $experienceURL = ''; } //getting the images $arrImage = self::getVendorImages($queryResult->vl_id); //formatting the array for the data $arrData['data'] = array('type' => 'A-La-Carte Details', 'id' => $queryResult->vl_id, 'title' => $queryResult->title, 'resturant_information' => empty($queryResult->resturant_info) ? "" : $queryResult->resturant_info, 'short_description' => empty($queryResult->short_description) ? "" : $queryResult->short_description, 'terms_and_condition' => empty($queryResult->terms_conditions) ? "" : $queryResult->terms_conditions, 'special_offer_title' => empty($queryResult->special_offer_title) ? "" : $queryResult->special_offer_title, 'special_offer_desc' => empty($queryResult->special_offer_desc) ? "" : $queryResult->special_offer_desc, 'pricing' => $queryResult->pricing_level, 'image' => $arrImage, 'rating' => array_key_exists($queryResult->vl_id, $arrReview) ? $arrReview[$queryResult->vl_id]['averageRating'] : 0, 'review_count' => array_key_exists($queryResult->vl_id, $arrReview) ? $arrReview[$queryResult->vl_id]['totalRating'] : 0, 'cuisine' => array_key_exists($queryResult->vl_id, $arrVendorCuisine) ? $arrVendorCuisine[$queryResult->vl_id] : array(), 'experience_available' => $experienceAvailable, 'experience_url' => $experienceURL, 'location_address' => array("address_line" => $queryResult->address, "locality" => $queryResult->locality, "area" => $queryResult->area, "city" => $queryResult->city, "pincode" => $queryResult->pin_code, "state" => $queryResult->state_name, "country" => $queryResult->country, "latitude" => $queryResult->latitude, "longitude" => $queryResult->longitude), 'curator_information' => array('curator_name' => is_null($queryResult->curator_name) ? "" : $queryResult->curator_name, 'curator_bio' => is_null($queryResult->curator_bio) ? "" : $queryResult->curator_bio, 'curator_image' => is_null($queryResult->curator_image) ? "" : Config::get('constants.API_MOBILE_IMAGE_URL') . $queryResult->curator_image, 'curator_designation' => is_null($queryResult->designation) ? "" : $queryResult->designation, 'suggestions' => is_null($queryResult->curator_tips) ? "" : $queryResult->curator_tips), 'menu_pick' => is_null($queryResult->menu_picks) ? "" : $queryResult->menu_picks, 'similar_option' => $arrSimilarAlacarteFilters, 'similar_option' => $arrResultAlacarte, 'reward_point' => is_null($queryResult->reward_point) ? 0 : $queryResult->reward_point, 'expert_tips' => is_null($queryResult->expert_tips) ? "" : $queryResult->expert_tips, 'slug' => $queryResult->slug, 'bookmark_status' => is_null($bookmark) ? 0 : 1); //reading the review details $arrData['data']['review_detail'] = Review::getVendorLocationRatingDetails($queryResult->vl_id); //reading the locations $arrData['data']['other_location'] = self::getVendorLocation($queryResult->vendor_id, $queryResult->vl_location_id); //setting the value of status $arrData['status'] = Config::get('constants.API_SUCCESS'); } else { $arrData['status'] = Config::get('constants.API_ERROR'); $arrData['no_result_msg'] = 'No matching values found.'; } return $arrData; }
/** * Regresa el valor deL MONTO MOVIDO * EL PRECIO UNITARIO LO SACA DEL INVENTARIO , PUED DSER (+) (-), TODO EXSPRESADO EN MONEDA BASE , CONVIERTE AUTOAMTICAMENTE * observe que paraq anulaciones de vales idkardex <> null ; NO SE REALIZA LA CONVERSION ESTA DEMAS , TODO ES IGUAL AL KARDEX ORIGINAL * EN OTRO CASO CADA QUE ANULAN UN VALE , estarian perdiendo por tipo de cambio */ public function getMonto($idkardex = NULL) { $conversionmoneda = yii::app()->tipocambio->getcambio($this->alkardex_alinventario->almacen->codmon, yii::app()->settings->get('general', 'general_monedadef')); if (is_null($idkardex)) { return $this->alkardex_alinventario->punit * $conversionmoneda * $this->cantidadbase(); } else { return Self::model()->findByPk($idkardex)->preciounit * $conversionmoneda * $this->cantidadbase(); } }
/** * */ public static function readAll() { $results = Self::all(); #formatting the result to json $arrData = array(); foreach ($results as $result) { $arrData['data'][] = array('id' => $result->id, 'name' => $result->option); } return $arrData; }
/** * Insert a row in the characters table * * @throws StatusCodeException 500 if was not inserted * * @param DatabaseConnection database class instance * @param array $character character attributes without id * @return string ID of character inserted */ public static function insert(DatabaseConnection $db, $character) { $success = $db->query('INSERT INTO characters(name, description, type, dead, stage, hp) VALUES(:name, :description, :type, :dead, :stage, :hp);', $character); $id = Self::lastID($db); if (!$success) { throw new StatusCodeException(500); } return $id; }
/** * 删除设置选项 * * @param $option_name * * @return boolean */ public static function del($option_name) { $option = Self::where('name', $option_name)->first(); if (!$option) { return false; } //不存在该设置选项 $option->delete(); return true; }
public function clearTemp() { $files = glob('fileStorage/temp/*'); foreach ($files as $file) { if (is_file($file)) { unlink($file); } } return Self::getFolderSize("fileStorage/temp/"); }
/** * Reads the booking time range limits details based on * pass parameters. * * @static true * @access public * @param array $arrData * @return array * @since 1.0.0 */ public static function checkBookingTimeRangeLimits($arrData) { $queryResult = Self::where('product_vendor_location_id', $arrData['vendorLocationID'])->where('day', $arrData['reservationDay'])->orWhere('date', $arrData['reservationDate'])->get(); //array to save the details $arrData = array(); foreach ($queryResult as $row) { $arrData[] = array('id' => $row->id, 'product_vendor_location_id' => $row->product_vendor_loction_id, 'limit_by' => $row->limit_by, 'day' => $row->day, 'date' => $row->date, 'start_time' => $row->start_time, 'end_time' => $row->end_time, 'max_covers_limit' => $row->max_covers_limit, 'max_tables_limit' => $row->max_tables_limit); } return $arrData; }
private static function referentTracker($keywords, $referents) { $match = []; foreach ($referents as $key => $referent) { $lastTweets = Twitter::getUserTimeline(['screen_name' => $referent->account, 'count' => 100, 'format' => 'json']); $keyfound = Self::keywordFinder($lastTweets, $keywords); array_push($match, $keyfound); } return $match; }