Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //webform
- // Print out the progress bar at the top of the page
- print drupal_render($form['progressbar']);
- // Print out the preview message if on the preview page.
- if (isset($form['preview_message'])) {
- print '<div class="messages warning">';
- print drupal_render($form['preview_message']);
- print '</div>';
- }
- // Print out the main part of the form.
- // Feel free to break this up and move the pieces within the array.
- print drupal_render($form['submitted']);
- // Always print out the entire $form. This renders the remaining pieces of the
- // form that haven't yet been rendered above (buttons, hidden elements, etc).
- print drupal_render_children($form);
- $node = $form['#node'];
- $sid = $form_state['values']['details']['sid'] ? (int) $form_state['values']['details']['sid'] : NULL;
- if (!$sid) {
- // Create a new submission object.
- $submission = (object) array(
- 'nid' => $node->nid,
- 'uid' => $form_state['values']['details']['uid'],
- 'data' => webform_submission_data($node, $form_state['values']['submitted']),
- );
- if (isset($_POST['submitted[approved]'])) {
- if (isset($_POST['op'])) {
- if ($sid > 0 || $sid != NULL) {
- $stored_procedure = "call GetAPITUData($sid)";
- $stored_procedure_res = db_query($stored_procedure)->fetchAssoc();
- drupal_add_js('Drupal.behaviors.post1 = function($stored_procedure_res) { load(); }', 'file');
- }
- }
- }
- };
- ?>
- var authToken;
- var savedAlertId;
- (function ($) {
- Drupal.behaviors.post1 = {
- attach: function (tudata) {
- var loginData = {
- grant_type: 'password',
- username: 'test',
- password: 'hooha'};
- $.ajax({
- type: 'POST',
- url: 'https://webapp.mysite.com/oauth/token',
- data: loginData,
- success: function (data) {
- authToken = data.access_token;
- var tudata1 = {
- // Provide when updating
- id: 0,
- description: 'this is another',
- alertTypeId: 1,
- // Optional; will default to date/time of upload
- reportedOn: '1/26/2016',
- // Optional
- expiresOn: '2/13/2016',
- latitude: -14,
- longitude: 126,
- shouldShowOnMap: true,
- shouldPushToUsers: false,
- source: 2
- };
- $.ajax ({
- type: 'POST',
- url: 'https://webapp.mysite.com/api/Alerts/AlertsApi/CreateOrUpdate',
- headers: {
- Authorization: 'Bearer ' + authToken
- },
- data: tudata1,
- success: function (data) {
- savedAlertId = data;
- console.debug('mydata:' + headers);
- },
- error: function(xhr, status, headers) {
- var response = $.parseJSON(xhr.responseText);
- console.debug('responseText: ' + response.status);
- }
- });
- }
- });
- return savedAlertId;
- }
- }
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement