本文整理汇总了PHP中send_notifications函数的典型用法代码示例。如果您正苦于以下问题:PHP send_notifications函数的具体用法?PHP send_notifications怎么用?PHP send_notifications使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_notifications函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* 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();
}
}
}
示例2: schedule_request
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);
}
}
}
}
示例3: decline_walker
public function decline_walker()
{
$id = Request::segment(4);
$success = Input::get('success');
$walker = Walker::find($id);
$walker->is_approved = 0;
$txt_approve = "Decline";
if ($walker->is_approved) {
$txt_approve = "Approved";
}
$response_array = array('unique_id' => 5, '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, 'is_approved' => $walker->is_approved, 'is_approved_txt' => $txt_approve);
$title = "You are Decline";
$message = $response_array;
send_notifications($id, "walker", $title, $message, "imp");
/* SMS */
$settings = Settings::where('key', 'sms_walker_decline')->first();
$pattern = $settings->value;
$pattern = str_replace('%name%', $walker->first_name . " " . $walker->last_name, $pattern);
sms_notification($id, 'walker', $pattern);
/* SMS END */
/* EMAIL */
/* $settings = Settings::where('key', 'email_walker_decline')->first();
$pattern = $settings->value;
$pattern = str_replace('%name%', $walker->first_name . " " . $walker->last_name, $pattern); */
$settings = Settings::where('key', 'admin_email_address')->first();
$admin_email = $settings->value;
$pattern = array('walker_name' => $walker->first_name . " " . $walker->last_name, 'admin_eamil' => $admin_email);
$subject = "Welcome " . $walker->first_name . " " . $walker->last_name . " To " . Config::get('app.website_title') . "";
email_notification($id, 'walker', $pattern, $subject, 'walker_decline');
/* EMAIL END */
$walker->save();
/* $pattern = "Hi " . $walker->first_name . ", Your account is deactivated, Please contact admin to Continue";
$subject = "Your Account Deactivated";
email_notification($walker->id, 'walker', $pattern, $subject); */
return Redirect::to("/admin/providers");
}
示例4: testpush
public function testpush()
{
$title = "PBN";
$message = "post added";
$post_id = 1;
$url = "single.html";
Log::info($message);
send_notifications($title, $message, $post_id, $url);
}
示例5: payment_type
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;
}
示例6: array
// Get amounts
if ($_POST['currency'] == 'fiat') {
$amount = $_POST['amount'];
$amount_btc = $amount / $config['exchange_rate'];
} else {
$amount_btc = $_POST['amount'];
$amount = $amount_btc * $config['exchange_rate'];
}
// Generate payment address
$address = $bip32->generate_address($_POST['wallet_id'], $user_row['id']);
DB::query("UPDATE coin_addresses SET is_used = 1 WHERE address = %s", $address);
// Add new invoice
DB::insert('invoices', array('wallet_id' => $_POST['wallet_id'], 'userid' => $user_row['id'], 'currency' => $_POST['currency'], 'amount' => $amount, 'amount_btc' => $amount_btc, 'payment_address' => $address, 'note' => $_POST['note'], 'process_note' => ''));
$invoice_id = DB::insertId();
// Send notifications
send_notifications('invoice_created', $invoice_id);
// User message
$template->add_message("Successfully generated a new pending invoice for user, {$_POST['username']}");
}
// Process invoices
} elseif (isset($_POST['submit']) && $_POST['submit'] == 'Process Checked Invoices') {
// Process
$ids = get_chk('invoice_id');
foreach ($ids as $id) {
if (!$id > 0) {
continue;
}
DB::update('invoices', array('status' => $_POST['status'], 'date_paid' => DB::sqleval('now()'), 'process_note' => $_POST['note']), "id = %d", $id);
}
// User message
$template->add_message("Successfully processed all checked invoices, and marked them as <b>{$_POST['status']}</b>.");
示例7: approve
//.........这里部分代码省略.........
}
/* handle notifications */
if ($mtf->root_msg_id == $mtf->id) {
if (empty($mtf->frm_last_post_date)) {
$mtf->frm_last_post_date = 0;
}
/* send new thread notifications to forum subscribers */
$c = uq('SELECT u.email, u.icq, u.users_opt
FROM phpgw_fud_forum_notify fn
INNER JOIN phpgw_fud_users u ON fn.user_id=u.id
LEFT JOIN phpgw_fud_forum_read r ON r.forum_id=fn.forum_id AND r.user_id=fn.user_id
INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=' . $mtf->forum_id . '
LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=fn.user_id AND g2.resource_id=' . $mtf->forum_id . '
WHERE
fn.forum_id=' . $mtf->forum_id . ' AND fn.user_id!=' . (int) $mtf->poster_id . '
AND (CASE WHEN (r.last_view IS NULL AND (u.last_read=0 OR u.last_read >= ' . $mtf->frm_last_post_date . ')) OR r.last_view > ' . $mtf->frm_last_post_date . ' THEN 1 ELSE 0 END)=1
AND ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 2) > 0');
$notify_type = 'frm';
} else {
/* send new reply notifications to thread subscribers */
$c = uq('SELECT u.email, u.icq, u.users_opt, r.msg_id, u.id
FROM phpgw_fud_thread_notify tn
INNER JOIN phpgw_fud_users u ON tn.user_id=u.id
LEFT JOIN phpgw_fud_read r ON r.thread_id=tn.thread_id AND r.user_id=tn.user_id
INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=' . $mtf->forum_id . '
LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=tn.user_id AND g2.resource_id=' . $mtf->forum_id . '
WHERE
tn.thread_id=' . $mtf->thread_id . ' AND tn.user_id!=' . (int) $mtf->poster_id . '
AND (r.msg_id=' . $mtf->last_post_id . ' OR (r.msg_id IS NULL AND ' . $mtf->post_stamp . ' > u.last_read))
AND ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 2) > 0');
$notify_type = 'thr';
}
while ($r = db_rowarr($c)) {
if ($r[2] & 16) {
$to['EMAIL'] = $r[0];
} else {
$to['ICQ'] = $r[1] . '@pager.icq.com';
}
if (isset($r[4]) && is_null($r[3])) {
$tl[] = $r[4];
}
}
unset($c);
if (isset($tl)) {
/* this allows us to mark the message we are sending notification about as read, so that we do not re-notify the user
* until this message is read.
*/
q('INSERT INTO phpgw_fud_read (thread_id, msg_id, last_view, user_id) SELECT ' . $mtf->thread_id . ', 0, 0, id FROM phpgw_fud_users WHERE id IN(' . implode(',', $tl) . ')');
}
if (isset($to)) {
send_notifications($to, $mtf->id, $mtf->subject, $mtf->alias, $notify_type, $notify_type == 'thr' ? $mtf->thread_id : $mtf->forum_id, $mtf->frm_name, $mtf->forum_id);
}
// Handle Mailing List and/or Newsgroup syncronization.
if (($mtf->nntp_id || $mtf->mlist_id) && !$mtf->mlist_msg_id) {
fud_use('email_msg_format.inc', true);
reverse_fmt($mtf->alias);
$from = $mtf->poster_id ? $mtf->alias . ' <' . $mtf->email . '>' : $GLOBALS['ANON_NICK'] . ' <' . $GLOBALS['NOTIFY_FROM'] . '>';
$body = $mtf->body . ($mtf->msg_opt & 1 && $mtf->sig ? "\n--\n" . $mtf->sig : '');
plain_text($body);
plain_text($subject);
if ($mtf->reply_to) {
$replyto_id = q_singleval('SELECT mlist_msg_id FROM phpgw_fud_msg WHERE id=' . $mtf->reply_to);
} else {
$replyto_id = 0;
}
if ($mtf->attach_cnt) {
$r = uq("SELECT a.id, a.original_name,\n\t\t\t\t\t\tCASE WHEN m.mime_hdr IS NULL THEN 'application/octet-stream' ELSE m.mime_hdr END\n\t\t\t\t\t\tFROM phpgw_fud_attach a\n\t\t\t\t\t\tLEFT JOIN phpgw_fud_mime m ON a.mime_type=m.id\n\t\t\t\t\t\tWHERE a.message_id=" . $mtf->id . " AND a.attach_opt=0");
while ($ent = db_rowarr($r)) {
$attach[$ent[1]] = file_get_contents($GLOBALS['FILE_STORE'] . $ent[0] . '.atch');
if ($mtf->mlist_id) {
$attach_mime[$ent[1]] = $ent[2];
}
}
} else {
$attach_mime = $attach = null;
}
if ($mtf->nntp_id) {
fud_use('nntp.inc', true);
$nntp_adm = db_sab('SELECT * FROM phpgw_fud_nntp WHERE id=' . $mtf->nntp_id);
$nntp = new fud_nntp();
$nntp->server = $nntp_adm->server;
$nntp->newsgroup = $nntp_adm->newsgroup;
$nntp->port = $nntp_adm->port;
$nntp->timeout = $nntp_adm->timeout;
$nntp->nntp_opt = $nntp_adm->nntp_opt;
$nntp->login = $nntp_adm->login;
$nntp->pass = $nntp_adm->pass;
define('sql_p', 'phpgw_fud_');
$lock = $nntp->get_lock();
$nntp->post_message($mtf->subject, $body, $from, $mtf->id, $replyto_id, $attach);
$nntp->close_connection();
$nntp->release_lock($lock);
} else {
fud_use('mlist_post.inc', true);
$GLOBALS['CHARSET'] = 'ISO-8859-15';
$r = db_saq('SELECT name, additional_headers FROM phpgw_fud_mlist WHERE id=' . $mtf->mlist_id);
mail_list_post($r[0], $from, $mtf->subject, $body, $mtf->id, $replyto_id, $attach, $attach_mime, $r[1]);
}
}
}
示例8: handle_submission
/**
* Handle the submission of a FAQ
*
* @since 3.0.0
*/
function handle_submission()
{
//this $post variable is for the PRODUCT
global $post;
//create errors and result arrays
$errors = array();
$result = array();
//put post data into an array
if (isset($_POST['faq_author_name'])) {
$input['faq_author_name'] = sanitize_text_field($_POST['faq_author_name']);
}
if (isset($_POST['faq_author_email'])) {
$input['faq_author_email'] = sanitize_email($_POST['faq_author_email']);
}
if (isset($_POST['faq_content'])) {
$input['faq_content'] = esc_textarea(stripslashes($_POST['faq_content']));
}
//very simple validation for content, name, and email
//TODO - make this validation more stringent
if (empty($input['faq_content'])) {
$errors['faq_content'] = __('Please enter a question!', 'woocommerce-faqs');
}
if (empty($input['faq_author_name'])) {
$errors['faq_author_name'] = __('Please enter your name!', 'woocommerce-faqs');
}
if (empty($input['faq_author_email']) || !empty($input['faq_author_email']) && !is_email($input['faq_author_email'])) {
$errors['faq_author_email'] = __('Please enter a valid email!', 'woocommerce-faqs');
}
$result = handle_antispam();
//if antispam returned a error type result, asker failed antispam check
if ($result['type'] == 'error') {
$errors[] = $result['message'];
}
//passed all checks
if (empty($errors)) {
$post_info = array('post_title' => __('Question for ', 'woocommerce-faqs') . $post->post_title, 'post_content' => wp_strip_all_tags($input['faq_content']), 'post_type' => WOOFAQS_POST_TYPE, 'post_status' => 'pending', 'comment_status' => 'open');
//create the post
$post_id = wp_insert_post($post_info);
//add post meta
update_post_meta($post_id, '_' . WOOFAQS_POST_TYPE . '_product', $post->ID);
update_post_meta($post_id, '_' . WOOFAQS_POST_TYPE . '_author_name', $input['faq_author_name']);
update_post_meta($post_id, '_' . WOOFAQS_POST_TYPE . '_author_email', $input['faq_author_email']);
//data for elsewhere (like the notifications)
$input['product_title'] = $post->post_title;
$input['question_title'] = $post_info['post_title'];
$input['question_content'] = $post_info['post_content'];
$input['post_id'] = absint($post_id);
$input['product_id'] = absint($post->ID);
$input['product_author_id'] = absint($post->post_author);
//result for the form (success)
$result['type'] = 'success';
$result['message'] = __('FAQ Successfully Posted. Your question will be reviewed and answered soon!', 'woocommerce-faqs');
//send the notification to the answerer
send_notifications('answerer', $input);
} else {
//result for the form (error)
$result['type'] = 'error';
$result['errors'] = $errors;
}
return $result;
}
示例9: pre_payment
//.........这里部分代码省略.........
$walker_data['first_name'] = $walker->first_name;
$walker_data['last_name'] = $walker->last_name;
$walker_data['phone'] = $walker->phone;
$walker_data['bio'] = $walker->bio;
$walker_data['picture'] = $walker->picture;
$walker_data['type'] = $walker->type;
$walker_data['rating'] = $walker->rate;
$walker_data['num_rating'] = $walker->rate_count;
$walker_data['car_model'] = $walker->car_model;
$walker_data['car_number'] = $walker->car_number;
/* $walker_data['rating'] = DB::table('review_walker')->where('walker_id', '=', $walker->id)->avg('rating') ? : 0;
$walker_data['num_rating'] = DB::table('review_walker')->where('walker_id', '=', $walker->id)->count(); */
$settings = Settings::where('key', 'default_distance_unit')->first();
$unit = $settings->value;
if ($unit == 0) {
$unit_set = 'kms';
} elseif ($unit == 1) {
$unit_set = 'miles';
}
$bill = array();
if ($request->is_paid == 1) {
$bill['distance'] = (string) convert($request->distance, $unit);
$bill['unit'] = $unit_set;
$bill['time'] = $request->time;
$bill['base_price'] = currency_converted($base_price);
$bill['distance_cost'] = currency_converted($distance_cost);
$bill['time_cost'] = currency_converted($time_cost);
$bill['total'] = currency_converted($request->total);
$bill['is_paid'] = $request->is_paid;
}
$response_array = array('success' => true, 'request_id' => $request_id, 'status' => $request->status, 'confirmed_walker' => $request->confirmed_walker, 'walker' => $walker_data, 'bill' => $bill);
$title = "Payment Has Made";
$message = $response_array;
send_notifications($walker->id, "walker", $title, $message);
$settings = Settings::where('key', 'email_notification')->first();
$condition = $settings->value;
if ($condition == 1) {
/* $settings = Settings::where('key', 'payment_made_client')->first();
$pattern = $settings->value;
$pattern = str_replace('%id%', $request->id, $pattern);
$pattern = str_replace('%amount%', $request->total, $pattern);
$subject = "Payment Charged";
email_notification($walker->id, 'walker', $pattern, $subject); */
$settings = Settings::where('key', 'admin_email_address')->first();
$admin_email = $settings->value;
$pattern = array('admin_eamil' => $admin_email, 'name' => ucwords($walker->first_name . " " . $walker->last_name), 'amount' => $total, 'req_id' => $request_id, 'web_url' => web_url());
$subject = "Payment Done With " . $request_id . "";
email_notification($walker->id, 'walker', $pattern, $subject, 'pre_payment', null);
}
// Send SMS
$owner = Owner::find($request->owner_id);
$settings = Settings::where('key', 'sms_when_provider_completes_job')->first();
$pattern = $settings->value;
$pattern = str_replace('%user%', $owner->first_name . " " . $owner->last_name, $pattern);
$pattern = str_replace('%driver%', $walker->first_name . " " . $walker->last_name, $pattern);
$pattern = str_replace('%driver_mobile%', $walker->phone, $pattern);
$pattern = str_replace('%amount%', $request->total, $pattern);
sms_notification($request->owner_id, 'owner', $pattern);
$email_data = array();
$email_data['name'] = $owner->first_name;
$email_data['emailType'] = 'user';
$email_data['base_price'] = $bill['base_price'];
$email_data['distance'] = $bill['distance'];
$email_data['time'] = $bill['time'];
示例10: user_set_destination
public function user_set_destination()
{
$request_id = Input::get('request_id');
$token = Input::get('token');
$owner_id = Input::get('id');
$dest_lat = Input::get('dest_lat');
$dest_long = Input::get('dest_long');
$validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'owner_id' => $owner_id, 'dest_lat' => $dest_lat, 'dest_long' => $dest_long), array('request_id' => 'required|integer', 'token' => 'required', 'owner_id' => 'required|integer', 'dest_lat' => 'required', 'dest_long' => '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 {
$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
if ($request = Requests::find($request_id)) {
if ($request->owner_id == $owner_data->id) {
Requests::where('id', $request_id)->update(array('D_latitude' => $dest_lat, 'D_longitude' => $dest_long));
if ($request->current_walker) {
$msg_array = array();
$msg_array['request_id'] = $request_id;
$msg_array['unique_id'] = 4;
$last_destination = Requests::find($request_id);
$owner = Owner::find($owner_id);
$request_data = array();
$request_data['owner'] = array();
$request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
$request_data['owner']['picture'] = $owner->picture;
$request_data['owner']['phone'] = $owner->phone;
$request_data['owner']['address'] = $owner->address;
$request_data['owner']['latitude'] = $owner->latitude;
$request_data['owner']['longitude'] = $owner->longitude;
$request_data['owner']['dest_latitude'] = $last_destination->D_latitude;
$request_data['owner']['dest_longitude'] = $last_destination->D_longitude;
$request_data['owner']['rating'] = $owner->rate;
$request_data['owner']['num_rating'] = $owner->rate_count;
$request_data['dog'] = array();
if ($dog = Dog::find($owner->dog_id)) {
$request_data['dog']['name'] = $dog->name;
$request_data['dog']['age'] = $dog->age;
$request_data['dog']['breed'] = $dog->breed;
$request_data['dog']['likes'] = $dog->likes;
$request_data['dog']['picture'] = $dog->image_url;
}
$msg_array['request_data'] = $request_data;
$title = "Set Destination";
$message = $msg_array;
if ($request->confirmed_walker == $request->current_walker) {
send_notifications($request->confirmed_walker, "walker", $title, $message);
}
}
$response_array = array('success' => true, 'error' => "Destination Set Successfully");
$response_code = 200;
} else {
$response_array = array('success' => false, 'error' => 'Request ID doesnot matches with Owner ID', 'error_code' => 407);
$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;
}
示例11: add_input
public function add_input($address, $amount, $txid, $vout, $scriptsig = '', $confirmations = 0, $blocknum = 0)
{
// Initialize
global $config;
// Check mempool
if ($row = DB::queryFirstRow("SELECT * FROM coin_mempool WHERE txid = %s AND vout = %d", $txid, $vout)) {
return false;
}
DB::insert('coin_mempool', array('txid' => $txid, 'vout' => $vout));
// Get address
if (!($addr_row = DB::queryFirstRow("SELECT * FROM coin_addresses WHERE address = %s", $address))) {
return false;
}
$is_confirmed = $confirmations >= $config['btc_minconf'] || $addr_row['is_change_address'] == 1 ? 1 : 0;
// Check for invoice
$product_id = 0;
$invoice_id = 0;
$order_id = 0;
$order_complete = false;
$overpayment = 0;
if ($irow = DB::queryFirstRow("SELECT * FROM invoices WHERE payment_address = %s", $address)) {
$invoice_id = $irow['id'];
// Check for order
} elseif ($prow = DB::queryFirstRow("SELECT * FROM coin_pending_payment WHERE payment_address = %s", $address)) {
$prow['amount_received'] += $amount;
if ($prow['amount_received'] >= $prow['amount_btc']) {
DB::query("UPDATE coin_pending_payment SET status = 'approved', amount_received = amount_received + %d WHERE id = %d", $amount, $prow['id']);
if ($prow['item_id'] > 0) {
$order_complete = true;
}
} else {
DB::query("UPDATE coin_pending_payment SET amount_received = amount_received + %d WHERE id = %d", $amount, $prow['id']);
}
$product_id = $prow['item_id'];
if ($prow['amount_received'] > $prow['amount_btc']) {
$overpayment = $prow['amount_received'] - $prow['amount_btc'];
}
}
// Check if exists
if ($row = DB::queryFirstRow("SELECT * FROM coin_inputs WHERE txid = %s AND vout = %d", $txid, $vout)) {
return false;
}
// Update invoice, if needed
if ($invoice_id > 0) {
$irow['amount_paid'] += $amount;
$updates = array('amount_paid' => $irow['amount_paid']);
if ($irow['amount_paid'] >= $irow['amount_btc']) {
$updates['status'] = 'paid';
$updates['date_paid'] = DB::sqleval('now()');
DB::update('invoices', $updates, "id = %d", $invoice_id);
if ($irow['amount_paid'] > $irow['amount_btc']) {
$overpayment = $irow['amount_paid'] - $irow['amount_btc'];
}
}
// Add order, if needed
} elseif ($order_complete === true) {
DB::insert('orders', array('userid' => $addr_row['userid'], 'product_id' => $product_id, 'amount' => $prow['amount'], 'amount_btc' => $prow['amount_btc']));
$order_id = DB::insertId();
}
// Add to DB
$hash = $txid . ':' . $vout;
DB::insert('coin_inputs', array('userid' => $addr_row['userid'], 'wallet_id' => $addr_row['wallet_id'], 'product_id' => $product_id, 'order_id' => $order_id, 'invoice_id' => $invoice_id, 'is_confirmed' => $is_confirmed, 'is_change' => $addr_row['is_change_address'], 'confirmations' => $confirmations, 'blocknum' => $blocknum, 'address' => $address, 'txid' => $txid, 'vout' => $vout, 'amount' => $amount, 'hash' => $hash));
$input_id = DB::insertId();
// Mark address as used
DB::query("UPDATE coin_addresses SET is_used = 1, total_input = total_input + %d WHERE address = %s", $amount, $address);
// Add overpayment, if needed
if ($overpayment != 0) {
DB::insert('coin_overpayments', array('userid' => $addr_row['userid'], 'input_id' => $input_id, 'amount_btc' => $overpayment));
}
// Add alerts
if ($product_id > 0) {
add_alert('product_purchase', $input_id, $amount);
} elseif ($invoice_id > 0) {
add_alert('invoice_paid', $input_id, $amount);
} elseif ($addr_row['is_change_address'] != 1) {
add_alert('new_deposit', $input_id, $amount);
}
// Process notifications
if ($addr_row['is_change_address'] != 1) {
send_notifications('new_deposit', $input_id);
}
if ($product_id > 0) {
send_notifications('product_purchase', $input_id);
}
if ($invoice_id > 0) {
send_notifications('invoice_paid', $input_id);
}
// Execute hooks, as needed
if ($addr_row['is_change_address'] != 1) {
execute_hooks('new_deposit', $input_id);
}
if ($is_confirmed == 1) {
execute_hooks('confirmed_deposit', $input_id);
}
if ($product_id > 0) {
execute_hooks('product_purchased', $input_id, $product_id);
}
if ($invoice_id > 0) {
execute_hooks('invoice_paid', $input_id);
}
//.........这里部分代码省略.........
示例12: saveUserRequestTrip
//.........这里部分代码省略.........
$owner->longitude = $longitude;
$owner->save();
$user_timezone = $owner->timezone;
$default_timezone = Config::get('app.timezone');
$offset = $this->get_timezone_offset($default_timezone, $user_timezone);
$request = new Requests();
$request->owner_id = $owner_id;
if ($d_longitude != '' && $d_latitude != '') {
$request->D_latitude = $d_latitude;
$request->D_longitude = $d_longitude;
}
$request->request_start_time = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $offset);
$request->save();
$request_service = new RequestServices();
$request_service->type = $type;
$request_service->request_id = $request->id;
$request_service->save();
$i = 0;
$first_walker_id = 0;
foreach ($walkers as $walker) {
$request_meta = new RequestMeta();
$request_meta->request_id = $request->id;
$request_meta->walker_id = $walker->id;
if ($i == 0) {
$first_walker_id = $walker->id;
$i++;
}
$request_meta->save();
}
$req = Requests::find($request->id);
$req->current_walker = $first_walker_id;
$req->confirmed_walker = 0;
$req->payment_mode = $payment_type;
$req->promo_code = $code_id;
$req->save();
$settings = Settings::where('key', 'provider_timeout')->first();
$time_left = $settings->value;
/* $var = Keywords::where('id', 1)->first();
$message = "Your Request is successful. Please wait while we are finding a nearest " . $var->keyword . " for you."; */
$message = "Your Request is successful. Please wait while we are finding a nearest " . Config::get('app.generic_keywords.Provider') . " for you.";
$type = "success";
}
return Redirect::to('/user/request-trip')->with('message', $message)->with('type', $type);
// Send Notification
$walker = Walker::find($first_walker_id);
if ($walker) {
$msg_array = array();
$msg_array['unique_id'] = 1;
$msg_array['request_id'] = $request->id;
$msg_array['time_left_to_respond'] = $time_left;
$owner = Owner::find($owner_id);
$request_data = array();
$request_data['owner'] = array();
$request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
$request_data['owner']['picture'] = $owner->picture;
$request_data['owner']['phone'] = $owner->phone;
$request_data['owner']['address'] = $owner->address;
$request_data['owner']['latitude'] = $owner->latitude;
$request_data['owner']['longitude'] = $owner->longitude;
/* $request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ? : 0; */
$request_data['owner']['rating'] = $owner->rate;
/* $request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count(); */
$request_data['owner']['num_rating'] = $owner->rate_count;
$request_data['dog'] = array();
if ($dog = Dog::find($owner->dog_id)) {
$request_data['dog']['name'] = $dog->name;
$request_data['dog']['age'] = $dog->age;
$request_data['dog']['breed'] = $dog->breed;
$request_data['dog']['likes'] = $dog->likes;
$request_data['dog']['picture'] = $dog->image_url;
}
$msg_array['request_data'] = $request_data;
$title = "New Request";
$message = json_encode($msg_array);
send_notifications($first_walker_id, "walker", $title, $message);
}
// Send SMS
$settings = Settings::where('key', 'sms_request_created')->first();
$pattern = $settings->value;
$pattern = str_replace('%user%', $owner_data->first_name . " " . $owner_data->last_name, $pattern);
$pattern = str_replace('%id%', $request->id, $pattern);
$pattern = str_replace('%user_mobile%', $owner_data->phone, $pattern);
sms_notification(1, 'admin', $pattern);
// send email
/* $settings = Settings::where('key', 'email_new_request')->first();
$pattern = $settings->value;
$pattern = str_replace('%id%', $request->id, $pattern);
$pattern = str_replace('%url%', web_url() . "/admin/request/map/" . $request->id, $pattern);
$subject = "New Request Created";
email_notification(1, 'admin', $pattern, $subject); */
$settings = Settings::where('key', 'admin_email_address')->first();
$admin_email = $settings->value;
$follow_url = web_url() . "/user/signin";
$pattern = array('admin_eamil' => $admin_email, 'trip_id' => $request->id, 'follow_url' => $follow_url);
$subject = "Ride Booking Request";
email_notification(1, 'admin', $pattern, $subject, 'new_request', null);
return Redirect::to('/user/request-trip')->with('message', $message)->with('type', $type);
}
}
示例13: array
continue;
}
// Process transaction, if ok
if ($template->has_errors != 1) {
// Update db
DB::update('coin_sends', array('status' => 'sent', 'txid' => $txid), "id = %d", $_POST['send_id']);
// Mark inputs as spent
$input_ids = explode(",", $_POST['input_ids']);
foreach ($input_ids as $input_id) {
if (!$input_id > 0) {
continue;
}
DB::query("UPDATE coin_inputs SET is_spent = 1, is_locked = 0 WHERE id = %d", $input_id);
}
// Send notifications
send_notifications('funds_sent', $_POST['send_id']);
// Execute hooks
execute_hooks('funds_sent', $_POST['send_id']);
// User message
$template->add_message("Successfully broadcast transaction, TxID {$txid}");
}
}
// Initialize
$bip32 = new bip32();
// Get wallets
$first = true;
$bip32_key_fields = '';
$required_sigs = 0;
$wallet_id = 0;
$wallet_javascript = '';
$wallet_options = '';
示例14: sendPush
public function sendPush($id)
{
$post = Post::find($id);
if ($post) {
$response_array = $post->title;
$title = "PBN";
$message = $post->title;
$post_id = $post->id;
$url = "single.html";
Log::info($message);
send_notifications($title, $message, $post_id, $url);
Log::info("push started");
return Redirect::back()->with('flash_success', tr('push_notification_success'));
} else {
return Redirect::back()->with('flash_error', tr('push_notification_error'));
}
}
示例15: decline_request
public function decline_request()
{
$request_id = Request::segment(4);
$walker_id = Session::get('walker_id');
$request = Requests::find($request_id);
if ($request->current_walker == $walker_id) {
// Archiving Old Walker
RequestMeta::where('request_id', '=', $request_id)->where('walker_id', '=', $walker_id)->update(array('status' => 3));
$request_meta = RequestMeta::where('request_id', '=', $request_id)->where('status', '=', 0)->orderBy('created_at')->first();
// update request
if (isset($request_meta->walker_id)) {
// assign new walker
Requests::where('id', '=', $request_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($request->owner_id);
$msg_array = array();
$msg_array['request_id'] = $request->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', '=', $request_id)->update(array('current_walker' => 0, 'status' => 1));
}
}
return Redirect::to('/provider/trips');
}