function expand(Environment $env, $code) { $walker = new Walker(); $forms = buildForms($code); return array_map(function ($form) use($walker, $env) { return $walker->expand($env, $form); }, $forms); }
/** * @test * @dataProvider provideExpand */ public function expand($expected, $sexpr, array $macros = []) { $walker = new Walker(); $env = Environment::standard(); foreach ($macros as $name => $pair) { list($argsSexpr, $bodySexpr) = $pair; $macroArgs = $this->parseSexpr($argsSexpr); $macroBody = $this->parseSexpr($bodySexpr); $env[$name] = new SpecialOp\MacroOp($macroArgs, $macroBody); } $form = $this->parseSexpr($sexpr); $expanded = $walker->expand($env, $form); $this->assertEquals($expected, $expanded->getAst()); }
public function forgot_password() { $type = Input::get('type'); $email = Input::get('email'); if ($type == 1) { // Walker $walker_data = Walker::where('email', $email)->first(); if ($walker_data) { $walker = Walker::find($walker_data->id); $new_password = time(); $new_password .= rand(); $new_password = sha1($new_password); $new_password = substr($new_password, 0, 8); $walker->password = Hash::make($new_password); $walker->save(); // send email $settings = Settings::where('key', 'email_forgot_password')->first(); $pattern = $settings->value; $pattern = str_replace('%password%', $new_password, $pattern); $subject = "Your New Password"; email_notification($walker->id, 'walker', $pattern, $subject); $response_array = array(); $response_array['success'] = true; $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } else { $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425); $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } } else { $owner_data = Owner::where('email', $email)->first(); if ($owner_data) { $owner = Owner::find($owner_data->id); $new_password = time(); $new_password .= rand(); $new_password = sha1($new_password); $new_password = substr($new_password, 0, 8); $owner->password = Hash::make($new_password); $owner->save(); $settings = Settings::where('key', 'email_forgot_password')->first(); $pattern = $settings->value; $pattern = str_replace('%password%', $new_password, $pattern); $subject = "Your New Password"; email_notification($owner->id, 'owner', $pattern, $subject); $response_array = array(); $response_array['success'] = true; $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } else { $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425); $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } } }
/** * Traverse elements to create list from elements. * * Display one element if the element doesn't have any children otherwise, * display the element and its children. Will only traverse up to the max. * depth and no ignore elements under that depth. It is possible to set the. * max depth to include all depths, see walk() method. * * This method shouldn't be called directly, use the walk() method instead. * * @since 2.5.0 * * @param object $element Data object * @param array $children_elements List of elements to continue traversing. * @param int $max_depth Max depth to traverse. * @param int $depth Depth of current element. * @param array $args * @param string $output Passed by reference. Used to append additional content. * @return null Null on failure with no changes to parameters. */ public function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { if (!$element || 0 === $element->count && !empty($args[0]['hide_empty'])) { return; } parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); }
public function walk() { $walked = []; //walk know pathes foreach ($this->map->paths(['where' => ['path', $this->curPath]]) as $path) { if (isset($this->data[$path->item])) { if ($path->type == 'container') { //create walker for container $walker = new Walker(); $walker->migration = $this->migration; $walker->map = $this->map; $walker->data =& $this->data[$path->item]; $walker->curPath = $this->curPath . $path->item . '/'; $walker->mapPath = $path; $walker->mapPathParent = $this->mapPath; $walker->migtarionLog = $this->migtarionLog; $walker->walk(); } elseif ($path->type == 'object') { //start parse path data $this->startObjectParse($path->object_id, $this->data[$path->item]); } } $walked[$path->item] = true; } //check unparsed paths foreach ($this->data as $key => &$data) { //skip parsed and attribtes if ($key == '@attributes' || !empty($walked[$key])) { continue; } //search object for parse $object = Migration\Object::get([['code', $key], ['migration_id', $this->migration->id]]); if ($object) { //parse as object $this->startObjectParse($object, $data); } else { //create new map path for configure unknown path $this->mapPath = new Migration\Map\Path(); $this->mapPath->parent_id = $this->mapPathParent ? $this->mapPathParent->id : 0; $this->mapPath->path = $this->curPath; $this->mapPath->item = $key; $this->mapPath->migration_map_id = $this->map->id; $this->mapPath->save(); } } }
function walk($elements, $args = array()) { $output = ''; $args = wp_parse_args($args, array('value' => 'slug', 'name' => 'lang_choice')); if (!empty($args['flag'])) { $current = wp_list_filter($elements, array($args['value'] => $args['selected'])); $lang = reset($current); $output = sprintf('<span class="pll-select-flag">%s</span>', empty($lang->flag) ? esc_html($lang->slug) : $lang->flag); } $output .= sprintf('<select name="%1$s" %2$s%3$s%4$s>' . "\n" . '%5$s' . "\n" . '</select>' . "\n", $name = esc_attr($args['name']), isset($args['id']) && !$args['id'] ? '' : ' id="' . (empty($args['id']) ? $name : esc_attr($args['id'])) . '"', empty($args['class']) ? '' : ' class="' . esc_attr($args['class']) . '"', empty($args['disabled']) ? '' : ' disabled="disabled"', parent::walk($elements, -1, $args)); return $output; }
/** * Perform several checks and fill the class values * * @param string $element The current menu item * @param int $children_elements The element childrens * @param array $max_depth * @param array $depth * @param array $args * @param array $output */ function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { if ($depth === 0) { // CHECK IF MENU IS ACTIVE $this->mm_active = get_post_meta($element->ID, '_menu_item_zn_mega_menu_enable', true); // COUNT ALL MEGA MENU CHILDRENS if ($this->mm_active && !empty($children_elements[$element->ID])) { $this->childrens_count = count($children_elements[$element->ID]); } } // DO THE NORMAL display_element(); return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); }
/** * Taken from WordPress's Walker_Comment::display_element() * * This function is designed to enhance Walker::display_element() to * display children of higher nesting levels than selected inline on * the highest depth level displayed. This prevents them being orphaned * at the end of the comment list. * * Example: max_depth = 2, with 5 levels of nested content. * 1 * 1.1 * 1.1.1 * 1.1.1.1 * 1.1.1.1.1 * 1.1.2 * 1.1.2.1 * 2 * 2.2 * * @see Walker_Comment::display_element() * @see Walker::display_element() * @see wp_list_comments() */ public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { if (!$element) { return; } $id_field = $this->db_fields['id']; $id = $element->{$id_field}; parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); // If we're at the max depth, and the current element still has children, loop over those and display them at this level // This is to prevent them being orphaned to the end of the list. if ($max_depth <= $depth + 1 && isset($children_elements[$id])) { foreach ($children_elements[$id] as $child) { $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output); } unset($children_elements[$id]); } }
function walk(&$a) { $this->line = ''; $this->lastHash = 0; try { parent::walk($a); } catch (\Exception $e) { } $this->depthLimited = $this->objectsDepth = array(); '' !== $this->line && $this->dumpLine(0); if (isset($e)) { throw $e; } $lines = implode("\n", $this->lines); $this->lines = array(); return $lines; }
/** * This modifies the default display_element() function to "flatten" any replies that exceed the max_depth. * * This function is taken from the Walker_Comment class in WordPress core. * * @see Walker::display_element() * * @param object $element Data object. * @param array $children_elements List of elements to continue traversing. * @param int $max_depth Max depth to traverse. * @param int $depth Depth of current element. * @param array $args An array of arguments. @see wp_list_comments() * @param string $output Passed by reference. Used to append additional content. * @return null Null on failure with no changes to parameters. */ function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { // Do nothing if $element is false... if (!$element) { return; } $id_field = $this->db_fields['id']; $id = $element->{$id_field}; // Run the standard display_element() function now... parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); // If we're at the max depth, and the current element still has children, loop over those and display them at // this level. This is to prevent them being orphaned to the end of the comment list. if ($max_depth <= $depth + 1 && isset($children_elements[$id])) { foreach ($children_elements[$id] as $child) { $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output); } unset($children_elements[$id]); } }
function end_lvl(&$output, $depth = 0, $args = array()) { global $subnaviditeration; global $topnav_dropdown_desc_values; global $topnav_dropdown_desc_values_defaults; // If we are at a parent element, output this code to end the div.w-row (includes description and picture in dropdown) // This sprintf function can probably be used in the future to put in the correct description and image. if (0 == $depth) { ${$subnaviditeration} = settype($subnaviditeration, 'integer'); $text = $topnav_dropdown_desc_values[$subnaviditeration]['topnav_dropdown_desc_text'] ? $topnav_dropdown_desc_values[$subnaviditeration]['topnav_dropdown_desc_text'] : $topnav_dropdown_desc_values_defaults['topnav_dropdown_desc_text_default']; // if false $imgURL = $topnav_dropdown_desc_values[$subnaviditeration]['topnav_dropdown_desc_img']['url'] ? $topnav_dropdown_desc_values[$subnaviditeration]['topnav_dropdown_desc_img']['image_src']['medium'][0] : $topnav_dropdown_desc_values_defaults['topnav_dropdown_desc_img_default']['url']; $output .= sprintf("\n</ul>\n\t\t\t\n</div>\n\t\t\t\n<div class='w-col w-col-6 w-col-small-6'>\n\t\t\t\n<p class='dropdown-p'>%s</p>\n\t\t\t\n</div>\n\t\t\t\n<div class='w-col w-col-3 w-col-small-3'><img class='dropdown-img' src='%s'>\n\t\t\t\n</div>\n\t\t\t\n</div>", $text, $imgURL); } // Increments subnaviditeration so that the next button triggers the next w.row $subnaviditeration++; //I'm not sure what this does, but it was in the code I copied and I don't want to break it. :) parent::end_lvl($output, $depth, $args); }
/** * Execute the console command. * * @return mixed */ public function fire() { $this->info('Working'); $date1 = date('Y-m-d h:i:s'); $this->info($date1); $date = date_create($date1); $msgtime = $date->add(new DateInterval('P0Y0M0DT0H30M0S'))->format('Y-m-d H:i:s'); $requests = Requests::where('later', 1)->where('is_started', 0)->where('request_start_time', '<=', $msgtime)->get(); if ($requests->count() > 0) { $this->info('hola'); foreach ($requests as $request) { $provider = Walker::where('id', $request->confirmed_walker)->first(); $owner = Owner::where('id', $request->owner_id)->first(); $message = "You have a ride scheduled in 30 mins from now. Client name is {$owner->first_name} {$owner->last_name} and phone no. is {$owner->phone}"; $this->info($request->id); $this->info($message); send_notifications($provider->id, 'provider', 'Ride in 30 min', $message); $request->later = 0; $request->save(); } } }
public function userTripDetail() { $id = Request::segment(3); $owner_id = Session::get('user_id'); $request = Requests::find($id); if ($request->owner_id == $owner_id) { $locations = WalkLocation::where('request_id', $id)->orderBy('id')->get(); $start = WalkLocation::where('request_id', $id)->orderBy('id')->first(); $end = WalkLocation::where('request_id', $id)->orderBy('id', 'desc')->first(); $map = "https://maps-api-ssl.google.com/maps/api/staticmap?size=249x249&style=feature:landscape|visibility:off&style=feature:poi|visibility:off&style=feature:transit|visibility:off&style=feature:road.highway|element:geometry|lightness:39&style=feature:road.local|element:geometry|gamma:1.45&style=feature:road|element:labels|gamma:1.22&style=feature:administrative|visibility:off&style=feature:administrative.locality|visibility:on&style=feature:landscape.natural|visibility:on&scale=2&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-start@2x.png|{$start->latitude},{$start->longitude}&markers=shadow:false|scale:2|icon:http://d1a3f4spazzrp4.cloudfront.net/receipt-new/marker-finish@2x.png|{$end->latitude},{$end->longitude}&path=color:0x2dbae4ff|weight:4"; foreach ($locations as $location) { $map .= "|{$location->latitude},{$location->longitude}"; } $start_location = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng={$start->latitude},{$start->longitude}"), TRUE); $start_address = $start_location['results'][0]['formatted_address']; $end_location = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng={$end->latitude},{$end->longitude}"), TRUE); $end_address = $end_location['results'][0]['formatted_address']; $walker = Walker::find($request->confirmed_walker); $walker_review = WalkerReview::where('request_id', $id)->first(); if ($walker_review) { $rating = round($walker_review->rating); } else { $rating = 0; } return View::make('web.userTripDetail')->with('title', 'My Trips')->with('request', $request)->with('start_address', $start_address)->with('end_address', $end_address)->with('start', $start)->with('end', $end)->with('map_url', $map)->with('walker', $walker)->with('rating', $rating); } else { echo "false"; } }
/** * render item * @param object $element * @param array $children_elements * @param int $max_depth * @param int $depth * @param array $args * @param string $output * @return null|void */ public function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { $display = true; //default //add current menu item $this->menu_items[$element->term_id] = array('has_sub' => false, 'title' => $element->name); $current =& $this->menu_items[$element->term_id]; /* // Check if element as a 'current element' class $current_element_markers = array( 'current-cat', 'current-item', 'current-cat-ancestor','current-cat-parent' ); $current_class = array_intersect( $current_element_markers, (array)$element->classes ); // If element has a 'current' class, it is an ancestor of the current element $ancestor_of_current = !empty($current_class);*/ $children = get_term_children($element->term_id, $element->taxonomy); $current['has_sub'] = !empty($children); //display terms belong to current post if (!empty($this->args['mydata']['categories_by_current_post']) && isset($this->args['mydata']['enable_categories_by_current_post'])) { $display = false; $id = $element->term_id; if (in_array($id, $this->post_term_ids)) { // the current term is in the list $display = true; } elseif (isset($children_elements[$id])) { // the current term has children foreach ($children_elements[$id] as $child) { if (in_array($child->term_id, $this->post_term_ids)) { // one of the term's children is in the list $display = true; // can stop searching now break; } } } } if ($display) { parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); } }
/** * Traverse elements to create list from elements. * * Calls parent function in wp-includes/class-wp-walker.php */ function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { if (!$element) { return; } //Add indicators for top level menu items with submenus $id_field = $this->db_fields['id']; if ($depth == 0 && !empty($children_elements[$element->{$id_field}])) { $element->classes[] = 'mega-with-sub'; } if (!empty($children_elements[$element->{$id_field}])) { $element->classes[] = 'item-parent'; } Walker::display_element($element, $children_elements, $max_depth, $depth, $args, $output); }
public function schedule_request() { $time = date("Y-m-d H:i:s"); $query = "SELECT id,owner_id,current_walker,TIMESTAMPDIFF(SECOND,request_start_time, '{$time}') as diff from request where status = 0 and is_cancelled = 0"; $results = DB::select(DB::raw($query)); foreach ($results as $result) { $settings = Settings::where('key', 'provider_timeout')->first(); $timeout = $settings->value; if ($result->diff >= $timeout) { // Archiving Old Walker RequestMeta::where('request_id', '=', $result->id)->where('walker_id', '=', $result->current_walker)->update(array('status' => 2)); $request_meta = RequestMeta::where('request_id', '=', $result->id)->where('status', '=', 0)->orderBy('created_at')->first(); // update request if (isset($request_meta->walker_id)) { // assign new walker Requests::where('id', '=', $result->id)->update(array('current_walker' => $request_meta->walker_id, 'request_start_time' => date("Y-m-d H:i:s"))); // Send Notification $walker = Walker::find($request_meta->walker_id); $owner_data = Owner::find($result->owner_id); $msg_array = array(); $msg_array['request_id'] = $result->id; $msg_array['id'] = $request_meta->walker_id; if ($walker) { $msg_array['token'] = $walker->token; } $msg_array['client_profile'] = array(); $msg_array['client_profile']['name'] = $owner_data->first_name . " " . $owner_data->last_name; $msg_array['client_profile']['picture'] = $owner_data->picture; $msg_array['client_profile']['bio'] = $owner_data->bio; $msg_array['client_profile']['address'] = $owner_data->address; $msg_array['client_profile']['phone'] = $owner_data->phone; $title = "New Request"; $message = $msg_array; send_notifications($request_meta->walker_id, "walker", $title, $message); } else { // request ended Requests::where('id', '=', $result->id)->update(array('current_walker' => 0, 'status' => 1)); $settings = Settings::where('key', 'sms_request_unanswered')->first(); $pattern = $settings->value; $pattern = str_replace('%id%', $result->id, $pattern); sms_notification(1, 'admin', $pattern); // send email $settings = Settings::where('key', 'email_request_unanswered')->first(); $pattern = $settings->value; $pattern = str_replace('%id%', $result->id, $pattern); $pattern = str_replace('%url%', web_url() . "/admin/request/map/" . $result->id, $pattern); $subject = "New Request Unansweres"; email_notification(1, 'admin', $pattern, $subject); } } } }
public function create_manual_request() { $latitude = Input::get('latitude'); $longitude = Input::get('longitude'); $d_latitude = Input::get('d_latitude'); $d_longitude = Input::get('d_longitude'); $type = Input::get('type'); $provider = Input::get('provider'); $user_id = Session::get('user_id'); $time = date("Y-m-d H:i:s"); $provider_details = Walker::where('id', '=', $provider)->first(); $user = Owner::where('id', '=', $user_id)->first(); $request = new Requests(); $request->owner_id = $user_id; $request->request_start_time = $time; $request->confirmed_walker = $provider; if ($d_longitude != '' && $d_latitude != '') { $request->D_latitude = $d_latitude; $request->D_longitude = $d_longitude; } $request->current_walker = $provider; $request->status = 1; $request->save(); $reqid = $request->id; $request_service = new RequestServices(); $request_service->type = $type; $request_service->request_id = $request->id; $request_service->save(); $owner = Owner::find($user_id); $owner->latitude = $latitude; $owner->longitude = $longitude; $owner->save(); $walkerlocation = new WalkLocation(); $walkerlocation->request_id = $request->id; $walkerlocation->distance = 0.0; $walkerlocation->latitude = $latitude; $walkerlocation->longitude = $longitude; $walkerlocation->save(); if ($request->save()) { $current_request = Requests::where('id', '=', $reqid)->first(); return Redirect::to('/user/request-trip'); } }
public function check_banking() { $token = Input::get('token'); $walker_id = Input::get('id'); $is_admin = $this->isAdmin($token); if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) { // check for token validity if (is_token_active($walker_data->token_expiry) || $is_admin) { // do $default_banking = Config::get('app.default_payment'); $resp = array(); $resp['default_banking'] = $default_banking; $walker = Walker::where('id', $walker_id)->first(); if ($walker->merchant_id != NULL) { $resp['walker']['merchant_id'] = $walker->merchant_id; } $response_array = array('success' => true, 'details' => $resp); $response_code = 200; } } $response = Response::json($response_array, $response_code); return $response; }
public function forgot_password() { $type = Input::get('type'); $email = Input::get('email'); if ($type == 1) { // Walker $walker_data = Walker::where('email', $email)->first(); if ($walker_data) { $walker = Walker::find($walker_data->id); $new_password = time(); $new_password .= rand(); $new_password = sha1($new_password); $new_password = substr($new_password, 0, 8); $walker->password = Hash::make($new_password); $walker->save(); /* $subject = "Your New Password"; $email_data = array(); $email_data['password'] = $new_password; send_email($walker->id, 'walker', $email_data, $subject, 'forgotpassword'); */ $settings = Settings::where('key', 'admin_email_address')->first(); $admin_email = $settings->value; $login_url = web_url() . "/provider/signin"; $pattern = array('name' => $walker->first_name . " " . $walker->last_name, 'admin_eamil' => $admin_email, 'new_password' => $new_password, 'login_url' => $login_url); $subject = "Your New Password"; email_notification($walker->id, 'walker', $pattern, $subject, 'forgot_password', "imp"); $response_array = array(); $response_array['success'] = true; $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } else { $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425); $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } } else { $owner_data = Owner::where('email', $email)->first(); if ($owner_data) { $owner = Owner::find($owner_data->id); $new_password = time(); $new_password .= rand(); $new_password = sha1($new_password); $new_password = substr($new_password, 0, 8); $owner->password = Hash::make($new_password); $owner->save(); /* $subject = "Your New Password"; $email_data = array(); $email_data['password'] = $new_password; send_email($owner->id, 'owner', $email_data, $subject, 'forgotpassword'); */ $settings = Settings::where('key', 'admin_email_address')->first(); $admin_email = $settings->value; $login_url = web_url() . "/user/signin"; $pattern = array('name' => $owner->first_name . " " . $owner->last_name, 'admin_eamil' => $admin_email, 'new_password' => $new_password, 'login_url' => $login_url); $subject = "Your New Password"; email_notification($owner->id, 'owner', $pattern, $subject, 'forgot_password', "imp"); $response_array = array(); $response_array['success'] = true; $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } else { $response_array = array('success' => false, 'error' => 'This Email is not Registered', 'error_code' => 425); $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } } }
/** * @since bbPress (r4944) */ public function display_element($element = false, &$children_elements = array(), $max_depth = 0, $depth = 0, $args = array(), &$output = '') { if (empty($element)) { return; } // Get element's id $id_field = $this->db_fields['id']; $id = $element->{$id_field}; // Display element parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); // If we're at the max depth and the current element still has children, loop over those // and display them at this level to prevent them being orphaned to the end of the list. if ($max_depth <= (int) $depth + 1 && isset($children_elements[$id])) { foreach ($children_elements[$id] as $child) { $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output); } unset($children_elements[$id]); } }
public function payment_details() { $braintree_environment = Config::get('app.braintree_environment'); $braintree_merchant_id = Config::get('app.braintree_merchant_id'); $braintree_public_key = Config::get('app.braintree_public_key'); $braintree_private_key = Config::get('app.braintree_private_key'); $braintree_cse = Config::get('app.braintree_cse'); $twillo_account_sid = Config::get('app.twillo_account_sid'); $twillo_auth_token = Config::get('app.twillo_auth_token'); $twillo_number = Config::get('app.twillo_number'); $stripe_publishable_key = Config::get('app.stripe_publishable_key'); $default_payment = Config::get('app.default_payment'); $stripe_secret_key = Config::get('app.stripe_secret_key'); $mail_driver = Config::get('mail.mail_driver'); $email_name = Config::get('mail.from.name'); $email_address = Config::get('mail.from.address'); $mandrill_secret = Config::get('services.mandrill_secret'); $install = array('braintree_environment' => $braintree_environment, 'braintree_merchant_id' => $braintree_merchant_id, 'braintree_public_key' => $braintree_public_key, 'braintree_private_key' => $braintree_private_key, 'braintree_cse' => $braintree_cse, 'twillo_account_sid' => $twillo_account_sid, 'twillo_auth_token' => $twillo_auth_token, 'twillo_number' => $twillo_number, 'stripe_publishable_key' => $stripe_publishable_key, 'stripe_secret_key' => $stripe_secret_key, 'mail_driver' => $mail_driver, 'email_address' => $email_address, 'email_name' => $email_name, 'mandrill_secret' => $mandrill_secret, 'default_payment' => $default_payment); $start_date = Input::get('start_date'); $end_date = Input::get('end_date'); $submit = Input::get('submit'); $walker_id = Input::get('walker_id'); $owner_id = Input::get('owner_id'); $status = Input::get('status'); $start_time = date("Y-m-d H:i:s", strtotime($start_date)); $end_time = date("Y-m-d H:i:s", strtotime($end_date)); $start_date = date("Y-m-d", strtotime($start_date)); $end_date = date("Y-m-d", strtotime($end_date)); $query = DB::table('request')->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_type', 'walker.type', '=', 'walker_type.id'); if (Input::get('start_date') && Input::get('end_date')) { $query = $query->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time); } if (Input::get('walker_id') && Input::get('walker_id') != 0) { $query = $query->where('request.confirmed_walker', '=', $walker_id); } if (Input::get('owner_id') && Input::get('owner_id') != 0) { $query = $query->where('request.owner_id', '=', $owner_id); } if (Input::get('status') && Input::get('status') != 0) { if ($status == 1) { $query = $query->where('request.is_completed', '=', 1); } else { $query = $query->where('request.is_cancelled', '=', 1); } } else { $query = $query->where(function ($que) { $que->where('request.is_completed', '=', 1)->orWhere('request.is_cancelled', '=', 1); }); } /* $walks = $query->select('request.request_start_time', 'walker_type.name as type', 'request.ledger_payment', 'request.card_payment', 'owner.first_name as owner_first_name', 'owner.last_name as owner_last_name', 'walker.first_name as walker_first_name', 'walker.last_name as walker_last_name', 'owner.id as owner_id', 'walker.id as walker_id', 'request.id as id', 'request.created_at as date', 'request.*', 'request.is_walker_arrived', 'request.payment_mode', 'request.is_completed', 'request.is_paid', 'request.is_walker_started', 'request.confirmed_walker' , 'request.status', 'request.time', 'request.distance', 'request.total', 'request.is_cancelled'); $walks = $walks->paginate(10); */ $walks = $query->select('request.request_start_time', 'walker_type.name as type', 'request.ledger_payment', 'request.card_payment', 'owner.first_name as owner_first_name', 'owner.last_name as owner_last_name', 'walker.first_name as walker_first_name', 'walker.last_name as walker_last_name', 'owner.id as owner_id', 'walker.id as walker_id', 'request.id as id', 'request.created_at as date', 'request.is_started', 'request.is_walker_arrived', 'request.payment_mode', 'request.is_completed', 'request.is_paid', 'request.is_walker_started', 'request.confirmed_walker', 'request.promo_id', 'request.promo_code', 'request.status', 'request.time', 'request.distance', 'request.total', 'request.is_cancelled', 'request.promo_payment'); $walks = $walks->orderBy('id', 'DESC')->paginate(10); $query = DB::table('request')->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_type', 'walker.type', '=', 'walker_type.id'); if (Input::get('start_date') && Input::get('end_date')) { $query = $query->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time); } if (Input::get('walker_id') && Input::get('walker_id') != 0) { $query = $query->where('request.confirmed_walker', '=', $walker_id); } if (Input::get('owner_id') && Input::get('owner_id') != 0) { $query = $query->where('request.owner_id', '=', $owner_id); } $completed_rides = $query->where('request.is_completed', 1)->count(); $query = DB::table('request')->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_type', 'walker.type', '=', 'walker_type.id'); if (Input::get('start_date') && Input::get('end_date')) { $query = $query->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time); } if (Input::get('walker_id') && Input::get('walker_id') != 0) { $query = $query->where('request.confirmed_walker', '=', $walker_id); } if (Input::get('owner_id') && Input::get('owner_id') != 0) { $query = $query->where('request.owner_id', '=', $owner_id); } $cancelled_rides = $query->where('request.is_cancelled', 1)->count(); $query = DB::table('request')->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_type', 'walker.type', '=', 'walker_type.id'); if (Input::get('start_date') && Input::get('end_date')) { $query = $query->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time); } if (Input::get('walker_id') && Input::get('walker_id') != 0) { $query = $query->where('request.confirmed_walker', '=', $walker_id); } if (Input::get('owner_id') && Input::get('owner_id') != 0) { $query = $query->where('request.owner_id', '=', $owner_id); } $card_payment = $query->where('request.is_completed', 1)->sum('request.card_payment'); $query = DB::table('request')->leftJoin('owner', 'request.owner_id', '=', 'owner.id')->leftJoin('walker', 'request.confirmed_walker', '=', 'walker.id')->leftJoin('walker_type', 'walker.type', '=', 'walker_type.id'); if (Input::get('start_date') && Input::get('end_date')) { $query = $query->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time); } if (Input::get('walker_id') && Input::get('walker_id') != 0) { $query = $query->where('request.confirmed_walker', '=', $walker_id); } if (Input::get('owner_id') && Input::get('owner_id') != 0) { $query = $query->where('request.owner_id', '=', $owner_id); } $credit_payment = $query->where('request.is_completed', 1)->sum('request.ledger_payment'); $cash_payment = $query->where('request.payment_mode', 1)->sum('request.total'); if (Input::get('submit') && Input::get('submit') == 'Download_Report') { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=data.csv'); $handle = fopen('php://output', 'w'); $settings = Settings::where('key', 'default_distance_unit')->first(); $unit = $settings->value; if ($unit == 0) { $unit_set = 'kms'; } elseif ($unit == 1) { $unit_set = 'miles'; } fputcsv($handle, array('ID', 'Date', 'Type of Service', 'Provider', 'Owner', 'Distance (' . $unit_set . ')', 'Time (Minutes)', 'Payment Mode', 'Earning', 'Referral Bonus', 'Promotional Bonus', 'Card Payment')); foreach ($walks as $request) { $pay_mode = "Card Payment"; if ($request->payment_mode == 1) { $pay_mode = "Cash Payment"; } fputcsv($handle, array($request->id, date('l, F d Y h:i A', strtotime($request->request_start_time)), $request->type, $request->walker_first_name . " " . $request->walker_last_name, $request->owner_first_name . " " . $request->owner_last_name, sprintf2($request->distance, 2), sprintf2($request->time, 2), $pay_mode, sprintf2($request->total, 2), sprintf2($request->ledger_payment, 2), sprintf2($request->promo_payment, 2), sprintf2($request->card_payment, 2))); } fputcsv($handle, array()); fputcsv($handle, array()); fputcsv($handle, array('Total Trips', $completed_rides + $cancelled_rides)); fputcsv($handle, array('Completed Trips', $completed_rides)); fputcsv($handle, array('Cancelled Trips', $cancelled_rides)); fputcsv($handle, array('Total Payments', sprintf2($credit_payment + $card_payment, 2))); fputcsv($handle, array('Card Payment', sprintf2($card_payment, 2))); fputcsv($handle, array('Credit Payment', $credit_payment)); fclose($handle); $headers = array('Content-Type' => 'text/csv'); } else { /* $currency_selected = Keywords::where('alias', 'Currency')->first(); $currency_sel = $currency_selected->keyword; */ $currency_sel = Config::get('app.generic_keywords.Currency'); $walkers = Walker::paginate(10); $owners = Owner::paginate(10); $payment_default = ucfirst(Config::get('app.default_payment')); $title = ucwords(trans('customize.payment_details')); /* 'Payments' */ return View::make('payment')->with('title', $title)->with('page', 'payments')->with('walks', $walks)->with('owners', $owners)->with('walkers', $walkers)->with('completed_rides', $completed_rides)->with('cancelled_rides', $cancelled_rides)->with('card_payment', $card_payment)->with('install', $install)->with('currency_sel', $currency_sel)->with('cash_payment', $cash_payment)->with('credit_payment', $credit_payment)->with('payment_default', $payment_default); } }
public function eta() { $secret = Input::get('secret'); $token = Input::get('token'); $owner_id = Input::get('id'); $validator = Validator::make(array('secret' => $secret, 'token' => $token, 'owner_id' => $owner_id), array('secret' => 'required|integer', 'token' => 'required', 'owner_id' => 'required|integer')); if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $is_admin = $this->isAdmin($token); if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) { // check for token validity if (is_token_active($owner_data->token_expiry) || $is_admin) { // Do necessary operations $request = Requests::where('security_key', $secret)->first(); if ($request) { if ($request->is_started == 0) { $walker = Walker::find($request->confirmed_walker); $distance = 0; } else { $walker = WalkLocation::where('request_id', $request->id)->orderBy('created_at', 'desc')->first(); $distance = WalkLocation::where('request_id', $request->id)->max('distance'); } $settings = Settings::where('key', 'default_distance_unit')->first(); $unit = $settings->value; if ($unit == 0) { $unit_set = 'kms'; } elseif ($unit == 1) { $unit_set = 'miles'; } $distance = convert($distance, $unit); $response_array = array('success' => true, 'latitude' => $walker->latitude, 'longitude' => $walker->longitude, 'destination_latitude' => $request->D_latitude, 'destination longitude' => $request->D_longitude, 'distance' => (string) $distance, 'unit' => $unit_set); $response_code = 200; } else { $response_array = array('success' => false, 'error' => 'Request ID Not Found', 'error_code' => 408); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); $response_code = 200; } } else { if ($is_admin) { /* $var = Keywords::where('id', 2)->first(); $response_array = array('success' => false, 'error' => '' . $var->keyword . ' ID not Found', 'error_code' => 410); */ $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.User') . ' ID not Found', 'error_code' => 410); } else { $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406); } $response_code = 200; } } $response = Response::json($response_array, $response_code); return $response; }
/** * Overrides Walker:walk to set depth argument * * @since 1.2 * * @param array $elements elements to display * @param array $args * @return string */ function walk($elements, $args = array()) { return parent::walk($elements, -1, $args); }
public function payment_type() { $token = Input::get('token'); $owner_id = Input::get('id'); $request_id = Input::get('request_id'); $cash_or_card = Input::get('cash_or_card'); $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'cash_or_card' => $cash_or_card, 'request_id' => $request_id), array('token' => 'required', 'owner_id' => 'required|integer', 'cash_or_card' => 'required', 'request_id' => 'required')); if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $payments = array(); /* $payments['none'] = ""; */ $def_card = 0; $is_admin = $this->isAdmin($token); if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) { // check for token validity if (is_token_active($owner_data->token_expiry) || $is_admin) { if ($cash_or_card != 1) { $card_count = Payment::where('owner_id', '=', $owner_id)->count(); if ($card_count <= 0) { $response_array = array('success' => false, 'error' => "Please add card first for payment.", 'error_code' => 417); $response_code = 200; $response = Response::json($response_array, $response_code); return $response; } } // Do necessary operations $owner = Owner::find($owner_id); $payment_data = Payment::where('owner_id', $owner_id)->orderBy('is_default', 'DESC')->get(); foreach ($payment_data as $data1) { $default = $data1->is_default; if ($default == 1) { $def_card = $data1->id; $data['is_default_text'] = "default"; } else { $data['is_default_text'] = "not_default"; } $data['id'] = $data1->id; $data['owner_id'] = $data1->owner_id; $data['customer_id'] = $data1->customer_id; $data['last_four'] = $data1->last_four; $data['card_token'] = $data1->card_token; $data['card_type'] = $data1->card_type; $data['card_id'] = $data1->card_token; $data['is_default'] = $default; array_push($payments, $data); } if ($request = Requests::find($request_id)) { $request->payment_mode = $cash_or_card; $request->save(); $walker = Walker::where('id', $request->confirmed_walker)->first(); if ($walker) { $msg_array = array(); $msg_array['unique_id'] = 3; $response_array = array('success' => true, 'id' => $owner->id, 'first_name' => $owner->first_name, 'last_name' => $owner->last_name, 'phone' => $owner->phone, 'email' => $owner->email, 'picture' => $owner->picture, 'bio' => $owner->bio, 'address' => $owner->address, 'state' => $owner->state, 'country' => $owner->country, 'zipcode' => $owner->zipcode, 'login_by' => $owner->login_by, 'social_unique_id' => $owner->social_unique_id, 'device_token' => $owner->device_token, 'device_type' => $owner->device_type, 'token' => $owner->token, 'default_card_id' => $def_card, 'payment_type' => $request->payment_mode, 'is_referee' => $owner->is_referee, 'promo_count' => $owner->promo_count, 'payments' => $payments); $response_array['unique_id'] = 3; $response_code = 200; $msg_array['owner_data'] = $response_array; $title = "Payment Type Change"; $message = $msg_array; if ($request->confirmed_walker == $request->current_walker) { send_notifications($request->confirmed_walker, "walker", $title, $message); } } else { $response_array = array('success' => false, 'error' => 'Driver Not Found', 'error_code' => 408); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Request ID Not Found', 'error_code' => 408); $response_code = 200; } } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); $response_code = 200; } } else { if ($is_admin) { $response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410); } else { $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406); } $response_code = 200; } } $response = Response::json($response_array, $response_code); return $response; }
public function walk($elements, $max_depth = 0) { $this->all_elements_count = count($elements); return str_replace('[categories-list]', parent::walk($elements, $max_depth), $this->list_container()); }
public function update_profile() { $token = Input::get('token'); $walker_id = Input::get('id'); $first_name = Input::get('first_name'); $last_name = Input::get('last_name'); $email = Input::get('email'); $phone = Input::get('phone'); $password = Input::get('password'); $picture = Input::file('picture'); $bio = Input::get('bio'); $address = Input::get('address'); $state = Input::get('state'); $country = Input::get('country'); $zipcode = Input::get('zipcode'); $validator = Validator::make(array('token' => $token, 'walker_id' => $walker_id, 'email' => $email, 'picture' => $picture, 'zipcode' => $zipcode), array('token' => 'required', 'walker_id' => 'required|integer', 'email' => 'email', 'picture' => 'mimes:jpeg,bmp,png', 'zipcode' => 'integer')); if ($validator->fails()) { $error_messages = $validator->messages()->all(); $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages); $response_code = 200; } else { $is_admin = $this->isAdmin($token); if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) { // check for token validity if (is_token_active($walker_data->token_expiry) || $is_admin) { $walker = Walker::find($walker_id); if ($first_name) { $walker->first_name = $first_name; } if ($last_name) { $walker->last_name = $last_name; } if ($email) { $walker->email = $email; } if ($phone) { $walker->phone = $phone; } if ($bio) { $walker->bio = $bio; } if ($address) { $walker->address = $address; } if ($state) { $walker->state = $state; } if ($country) { $walker->country = $country; } if ($zipcode) { $walker->zipcode = $zipcode; } if ($password) { $walker->password = Hash::make($password); } if (Input::hasFile('picture')) { // upload image $file_name = time(); $file_name .= rand(); $file_name = sha1($file_name); $ext = Input::file('picture')->getClientOriginalExtension(); Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext); $local_url = $file_name . "." . $ext; // Upload to S3 if (Config::get('app.s3_bucket') != "") { $s3 = App::make('aws')->get('s3'); $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url)); $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read')); $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name); } else { $s3_url = asset_url() . '/uploads/' . $local_url; } $walker->picture = $s3_url; } $walker->save(); $response_array = array('success' => true, 'id' => $walker->id, 'first_name' => $walker->first_name, 'last_name' => $walker->last_name, 'phone' => $walker->phone, 'email' => $walker->email, 'picture' => $walker->picture, 'bio' => $walker->bio, 'address' => $walker->address, 'state' => $walker->state, 'country' => $walker->country, 'zipcode' => $walker->zipcode, 'login_by' => $walker->login_by, 'social_unique_id' => $walker->social_unique_id, 'device_token' => $walker->device_token, 'device_type' => $walker->device_type, 'token' => $walker->token, 'type' => $walker->type); $response_code = 200; } else { $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405); $response_code = 200; } } else { if ($is_admin) { $response_array = array('success' => false, 'error' => 'Walker ID not Found', 'error_code' => 410); } else { $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406); } $response_code = 200; } } $response = Response::json($response_array, $response_code); return $response; }
function send_notifications($id, $type, $title, $message, $is_imp = NULL) { Log::info('push notification'); $settings = Settings::where('key', 'push_notification')->first(); $push_notification = $settings->value; if ($type == 'walker') { $user = Walker::find($id); } else { $user = Owner::find($id); } if ($push_notification == 1 || $is_imp == "imp") { if ($user->device_type == 'ios') { /* WARNING:- you can't pass devicetoken as string in GCM or IOS push * you have to pass array of devicetoken even thow it's only one device's token. */ /* send_ios_push("E146C7DCCA5EBD49803278B3EE0C1825EF0FA6D6F0B1632A19F783CB02B2617B",$title,$message,$type); */ send_ios_push($user->device_token, $title, $message, $type); } else { $message = json_encode($message); send_android_push($user->device_token, $title, $message); } } }
function walk($elements, $args = array()) { return sprintf('<select name="%1$s" %2$s%3$s>' . "\n" . '%4$s' . "\n" . '</select>' . "\n", $name = empty($args['name']) ? 'lang_choice' : esc_attr($args['name']), isset($args['id']) && !$args['id'] ? '' : ' id="' . (empty($args['id']) ? $name : esc_attr($args['id'])) . '"', empty($args['class']) ? '' : ' class="' . esc_attr($args['class']) . '"', parent::walk($elements, -1, $args)); }
public function providerS_bankingSubmit() { $id = Input::get('id'); Log::info('id = ' . print_r($id, true)); Stripe::setApiKey(Config::get('app.stripe_secret_key')); $token_id = Input::get('stripeToken'); Log::info('token_id = ' . print_r($token_id, true)); // Create a Recipient try { $recipient = Stripe_Recipient::create(array("name" => Input::get('first_name') . " " . Input::get('last_name'), "type" => Input::get('type'), "bank_account" => $token_id, "email" => Input::get('email'))); Log::info('recipient = ' . print_r($recipient, true)); $pro = Walker::where('id', Input::get('id'))->first(); $pro->merchant_id = $recipient->id; $pro->account_id = $recipient->active_account->id; $pro->last_4 = $recipient->active_account->last4; $pro->save(); Log::info('recipient added = ' . print_r($recipient, true)); } catch (Exception $e) { //Log::info('Error in Stripe = ' . print_r($e, true)); return Redirect::route("banking_provider_mobile", $id); } return Redirect::to("/"); }
function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) { // check, whether there are children for the given ID and append it to the element with a (new) ID $element->has_children = isset($children_elements[$element->ID]) && !empty($children_elements[$element->ID]); return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); }