Advertisement
Guest User

functions.php

a guest
Jan 26th, 2017
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 90.73 KB | None | 0 0
  1. <?php
  2. /*
  3.  WARNING: DO NOT edit this file under any circumstances.
  4.  Please do all PHP modifications via the Custom Code admin menu.
  5. */
  6.  
  7. /**
  8.  * This file calls the init.php file for both Genesis and Prose.
  9.  *
  10.  * It initializes the Genesis framework, and loads the Prose library as well.
  11.  *
  12.  * This file is a core Prose file and should not be edited.
  13.  *
  14.  * @author   StudioPress
  15.  * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
  16.  * @link     http://www.studiopress.com/themes/genesis
  17.  */
  18.  
  19. /** Start the engine */
  20. require_once( get_template_directory() . '/lib/init.php' );
  21. require_once( get_stylesheet_directory() . '/lib/init.php' );
  22.  
  23. prose_create_custom_php();
  24.  
  25. if (!current_user_can('delete_others_pages'))
  26. {
  27.     show_admin_bar(false);
  28. }
  29.  
  30. /* Sent Quiz Results */
  31. add_filter( 'qmn_end_results', 'sendQuizResults', 10, 3 );
  32. function sendQuizResults( $content, $options, $results )
  33. {
  34.     if($results["quiz_id"] == 2 && $results["total_score"] >= 80)
  35.     {
  36.         // MySQL Server Setup
  37.         $servername = "127.0.0.1";
  38.         $username = "root";
  39.         $password = "admin4sql!";
  40.         $databasename = "employee_database";
  41.  
  42.         //Create a connection to the server
  43.         $conn = new mysqli($servername, $username, $password, $databasename);
  44.  
  45.         //Check Connection
  46.         if($conn->connect_error)
  47.         {
  48.             die("Connection Failed: " . $conn->connect_error);
  49.         }
  50.            
  51.         //Get the User Object
  52.         $curUser = get_userdata($results["user_id"]);
  53.        
  54.         //Get Employee ID Number
  55.         $sql = "SELECT employeeID from employees WHERE username='$curUser->user_login'";
  56.         $result = $conn->query($sql);
  57.         $row = $result->fetch_assoc();
  58.         $empID = $row['employeeID'];
  59.         $totalScore = $results["total_score"];
  60.        
  61.         $sql = "INSERT INTO employee_quizes (empID, quizID, totalScore) VALUES ('$empID', 1, '$totalScore'); ";
  62.         $result = $conn->query($sql);
  63.     }
  64.  
  65. return $content;
  66.  
  67. }
  68.  
  69.  
  70. /* Remove Termination Entry Data */
  71. add_action( 'gform_after_submission_60', 'remove_form_entry' );
  72. function remove_form_entry( $entry )
  73. {
  74.     if(strcasecmp($entry['3'], 'Termination') == 0)
  75.     {
  76.         GFAPI::delete_entry($entry['id']);
  77.     }
  78. }
  79.  
  80. /* Update Provider Wait Time */
  81. add_action('gform_after_submission_27', 'importTrainingCertificates', 10, 2);
  82. function importTrainingCertificates($entry, $form)
  83. {
  84.     //$postURL = 'http://requestb.in/19x8l3r1';
  85.     $postURL = 'http://intranet/employeedb/importTrainingCertificates.php';
  86.    
  87.     $body = array(
  88.         'email' => $entry['5'],
  89.         'trainingType' => $entry['2']);
  90.        
  91.     $request = new WP_Http();
  92.     $response = $request->post($postURL, array('body' => $body));
  93. }
  94.  
  95. /* Send MDM Email Upon Approval */
  96. add_action('gravityflow_workflow_complete', 'mdmAgreementComplete', 10, 3);
  97. function mdmAgreementComplete( $entry_id, $form, $final_status )
  98. {
  99.     $entry = GFAPI::get_entry( $entry_id );
  100.     if(7 == $form['id'] && strcasecmp($final_status, 'approved') == 0)
  101.     {
  102.         $method = rgar($entry, '13');
  103.        
  104.         if(strcasecmp($method, 'E-Mail') == 0)
  105.         {
  106.             /* Grab Data From From */
  107.             $email = rgar($entry, '14');
  108.            
  109.             /* Configure Recipient Settings */
  110.             $to = $email;
  111.             $subject = 'SacENT MDM';
  112.             $headers = 'From: Helpdesk <support@sacent.com>' . "\r\n";
  113.             $headers .= 'Content-type: text/html;';
  114.  
  115.             /* Build Message to send */
  116.             $message = "http://sacent.co/MDMEnroll <br />";
  117.         }
  118.         else
  119.         {
  120.             /* Sanatize Cell Phone Number*/
  121.             $cellPhone = rgar($entry, '7');
  122.             $cellPhone = str_replace('(', '', $cellPhone);
  123.             $cellPhone = str_replace(')', '', $cellPhone);
  124.             $cellPhone = str_replace(' ', '', $cellPhone);
  125.             $cellPhone = str_replace('-', '', $cellPhone);
  126.            
  127.             /* Get Mobile Carrier Information */
  128.             $mobileCarrier = rgar($entry, '5');
  129.             if(strcasecmp($mobileCarrier, 'other') == 0)
  130.             {
  131.                 $mobileCarrier = rgar($entry, '9');
  132.                 /* Remove any unwanted characters */
  133.                 $mobileCarrier = str_replace('@', '', $mobileCarrier);
  134.                 $mobileCarrier = str_replace('0', '', $mobileCarrier);
  135.                 $mobileCarrier = str_replace('1', '', $mobileCarrier);
  136.                 $mobileCarrier = str_replace('2', '', $mobileCarrier);
  137.                 $mobileCarrier = str_replace('3', '', $mobileCarrier);
  138.                 $mobileCarrier = str_replace('4', '', $mobileCarrier);
  139.                 $mobileCarrier = str_replace('5', '', $mobileCarrier);
  140.                 $mobileCarrier = str_replace('6', '', $mobileCarrier);
  141.                 $mobileCarrier = str_replace('7', '', $mobileCarrier);
  142.                 $mobileCarrier = str_replace('8', '', $mobileCarrier);
  143.                 $mobileCarrier = str_replace('9', '', $mobileCarrier);
  144.             }
  145.            
  146.             /* Configure Recipient Settings */
  147.             $to = $cellPhone . '@' . $mobileCarrier;
  148.             $subject = 'SacENT MDM';
  149.             $headers = 'From: Helpdesk <support@sacent.com>' . "\r\n";
  150.             $headers .= 'Content-type: text/html;';
  151.            
  152.             /* Build Message to send */
  153.             //$message = "THIS TEST";
  154.             $message = "http://www.sacent.co/MDMEnroll      ";
  155.             //$message = "Cell Phone: " . $cellPhone . "<br />";
  156.             //$message .= "Mobile Carrier: " . $mobileCarrier . "<br />";
  157.         }
  158.            
  159.         mail($to, $subject, $message, $headers);
  160.     }
  161. }
  162.  
  163. /* Send Order Info*/
  164. add_action('gform_after_submission_52', 'storeOrderInfo', 10, 2);
  165. function storeOrderInfo($entry, $form)
  166. {
  167.     $firstName = $entry['1.3'];
  168.     $lastName = $entry['1.6'];
  169.     $email = $entry['3'];
  170.     $vendor = $entry['5'];
  171.     $location = $entry['8'];
  172.     $items = $entry['4'];
  173.     $orderNum = $entry['15'];
  174.     $otherVendor = $entry['6'];
  175.     $otherVendorWeb = $entry['9'];
  176.    
  177.     //$postURL = 'https://hookb.in/KlOM3B4l';
  178.     $postURL = 'http://intranet/employeedb/poReqForm.php';
  179.     $body = array(
  180.         'firstName' => $firstName,
  181.         'lastName' => $lastName,
  182.         'email' => $email,
  183.         'vendor' => $vendor,
  184.         'location' => $location,
  185.         'items' => $items,
  186.         'orderNum' => $orderNum,
  187.         'otherVendor' => $otherVendor,
  188.         'otherVendorWeb' => $otherVendorWeb);
  189.        
  190.     $request = new WP_Http();
  191.     $response = $request->post($postURL, array('body' => $body));
  192. }
  193.  
  194. add_filter( 'gform_pre_render_52', 'populateVendors' );
  195. add_filter( 'gform_pre_validation_52', 'populateVendors' );
  196. add_filter( 'gform_pre_submission_filter_52', 'populateVendors' );
  197. add_filter( 'gform_admin_pre_render_52', 'populateVendors' );
  198. function populateVendors( $form )
  199. {
  200.  
  201.     foreach ( $form['fields'] as &$field )
  202.     {
  203.         if ($field->id == 5)
  204.         {
  205.             /* MySQL Server Setup */
  206.             $servername = "127.0.0.1";
  207.             $username = "root";
  208.             $password = "admin4sql!";
  209.             $databasename = "sent_purchaseorders";
  210.  
  211.             /* Create a connection to the server */
  212.             $conn = new mysqli($servername, $username, $password, $databasename);
  213.  
  214.             /* Check Connection */
  215.             if($conn->connect_error)
  216.             {
  217.                 die("Connection Failed: " . $conn->connect_error);
  218.             }
  219.            
  220.             $sql = "SELECT * FROM vendors;";
  221.             $result = $conn->query($sql);
  222.             $choices = array();
  223.             if($result->num_rows > 0)
  224.             {
  225.                 while($row = $result->fetch_assoc())
  226.                 {
  227.                     if(strcasecmp($row['id'], '3') == 0)
  228.                     {
  229.                         continue;
  230.                     }
  231.                     $choices[] = array('text' => $row['name'], 'value' => $row['id']);
  232.                 }
  233.             }
  234.            
  235.             $choices[] = array('text' => 'Other', 'value' => '3');
  236.             $field->placeholder = 'Select a Vendor';
  237.             $field->choices = $choices;
  238.         }
  239.     }
  240.  
  241.     return $form;
  242. }
  243.  
  244. /* Update PO Number */
  245. add_action('gravityflow_step_complete', 'poReqForm', 10, 4);
  246. function poReqForm($step_id, $entry_id, $form_id, $status)
  247. {
  248.     $entry = GFAPI::get_entry( $entry_id );
  249.  
  250.     /* MySQL Server Setup */
  251.     $servername = "127.0.0.1";
  252.     $username = "root";
  253.     $password = "admin4sql!";
  254.     $databasename = "sent_purchaseorders";
  255.    
  256.     /* Create a connection to the server */
  257.     $conn = new mysqli($servername, $username, $password, $databasename);
  258.  
  259.     /* Check Connection */
  260.     if($conn->connect_error)
  261.     {
  262.         die("Connection Failed: " . $conn->connect_error);
  263.     }
  264.    
  265.     if($step_id == 135)
  266.     {
  267.         $orderNum = $entry['15'];
  268.         $poNum = $entry['16'];
  269.        
  270.         $sql = "UPDATE orders SET purchaseOrder='$poNum' WHERE orderID='$orderNum';";
  271.         $conn->query($sql);
  272.     }
  273.     elseif($step_id == 134)
  274.     {  
  275.         if(strcasecmp($status, 'approved') == 0)
  276.         {
  277.             $orderStatus = 2;
  278.         }
  279.         else
  280.         {
  281.             $orderStatus = 1;
  282.         }
  283.        
  284.         $orderNum = $entry['15'];
  285.        
  286.         $sql = "UPDATE orders SET status='$orderStatus' WHERE orderID='$orderNum';";
  287.         $conn->query($sql);
  288.     }
  289. }
  290.  
  291. /* Update Provider Wait Time */
  292. add_action('gform_after_submission_46', 'update_provider_waittime', 10, 2);
  293. function update_provider_waittime($entry, $form)
  294. {
  295.     $office = $entry['1'];
  296.     $doctorExpoUS = $entry['2'];
  297.     $doctorExpoDS = $entry['3'];
  298.     $doctorFAO = $entry['4'];
  299.     $doctorFOL = $entry['5'];
  300.     $doctorLOD = $entry['6'];
  301.     $doctorROS = $entry['7'];
  302.     $doctorRSA = $entry['8'];
  303.     $doctorSCK = $entry['9'];
  304.     $status = $entry['10'];
  305.    
  306.     //$postURL = 'http://requestb.in/1huoz1c1';
  307.     $postURL = 'http://intranet/employeedb/schedule/updateDocsWebhook.php';
  308.    
  309.     $body = array(
  310.         'office' => $office,
  311.         'doctorExpoUS' => $doctorExpoUS,
  312.         'doctorExpoDS' => $doctorExpoDS,
  313.         'doctorFAO' => $doctorFAO,
  314.         'doctorFOL' => $doctorFOL,
  315.         'doctorLOD' => $doctorLOD,
  316.         'doctorROS' => $doctorROS,
  317.         'doctorRSA' => $doctorRSA,
  318.         'doctorSCK' => $doctorSCK,
  319.         'status' => $status);
  320.        
  321.     $request = new WP_Http();
  322.     $response = $request->post($postURL, array('body' => $body));
  323. }
  324.  
  325. /* Update Indemand SOP Table */
  326. add_action('gform_after_submission_50', 'updateIndemandSOP', 10, 2);
  327. function updateIndemandSOP($entry, $form)
  328. {
  329.     $current_user = wp_get_current_user();
  330.    
  331.     //$postURL = 'http://requestb.in/1fubc671';
  332.     $postURL = 'http://intranet/employeedb/updateSOP.php';
  333.    
  334.     $body = array(
  335.         'email' => $current_user->user_email,
  336.         'sopID' => '1');
  337.        
  338.     $request = new WP_Http();
  339.     $response = $request->post($postURL, array('body' => $body));
  340. }
  341.  
  342. add_action('gform_confirmation_65', 'updateCallReminderSOP', 10, 4);
  343. function updateCallReminderSOP($confirmation, $form, $entry, $ajax)
  344. {
  345.     $current_user = wp_get_current_user();
  346.    
  347.     /* MySQL Server Setup */
  348.     $servername = "127.0.0.1";
  349.     $username = "root";
  350.     $password = "admin4sql!";
  351.     $databasename = "employee_database";
  352.    
  353.     /* Create a connection to the server */
  354.     $conn = new mysqli($servername, $username, $password, $databasename);
  355.  
  356.     /* Check Connection */
  357.     if($conn->connect_error)
  358.     {
  359.         die("Connection Failed: " . $conn->connect_error);
  360.     }
  361.    
  362.     $sqlSelect = "SELECT employeeID FROM employees WHERE email='$current_user->user_email';";
  363.     $result = $conn->query($sqlSelect);
  364.    
  365.     if($result->num_rows > 0)
  366.     {
  367.         while($row = $result->fetch_assoc())
  368.         {
  369.             $employeeID = $row['employeeID'];
  370.         }
  371.        
  372.         $sqlInsert = "INSERT INTO employee_sops (sop_id, emp_id) VALUES (5, $employeeID);";
  373.         $result = $conn->query($sqlInsert);
  374.     }
  375.    
  376.     return $confirmation;
  377. }
  378.  
  379. /* Block Forms From Fake Users */
  380. add_filter( "gform_pre_render", "block_user_render_form", 100, 1 );
  381. function block_user_render_form($form)
  382. {
  383.     $user = wp_get_current_user();
  384.     if(!current_user_can('ckeditor_ckfinder_access'))
  385.     {
  386.         echo '<p> You are logged in as ' . $user->display_name . '. Please use the TS Line or a Fat Client to access this form.';
  387.         return null;
  388.     }
  389.  
  390.     return $form;
  391. }
  392.  
  393. /* Change Webhook Keys */
  394. add_filter( 'gravityflow_webhook_args', 'sh_filter_gravityflow_webhook_args', 10, 3 );
  395. function sh_filter_gravityflow_webhook_args( $args, $entry, $current_step )
  396. {
  397.     //Get Created by User
  398.     $submitUser = new WP_User( $entry['created_by'] );
  399.     $approveUser = wp_get_current_user();
  400.    
  401.     //Get Current Status
  402.     $status = $entry['workflow_step_status_71'];
  403.    
  404.     // Key => Value
  405.     if($args['method'] == 'POST')
  406.     {
  407.         $args['body'] = array( 'requestDate' => $entry['1'],
  408.                                 'requestHours' => $entry['2'],
  409.                                 'requestOffice' => $entry['7'],
  410.                                 'requestReason' => $entry['6'],
  411.                                 'requestSentDate' => $entry['15'],
  412.                                 'submitUser' => $submitUser->display_name,
  413.                                 'approveUser' => $approveUser->display_name,
  414.                                 'workflowStatus' => $status);
  415.     }
  416.    
  417.     return $args;
  418. }
  419.  
  420.  
  421. /* Emergency Contact Form */
  422. add_filter('gform_pre_render', 'add_readonly_script');
  423. function add_readonly_script($form)
  424. {
  425.     ?>
  426.    
  427.     <script type="text/javascript">
  428.         jQuery(document).ready(function(){
  429.             jQuery("li.gf_readonly input").attr("readonly","readonly");
  430.         });
  431.     </script>
  432.    
  433.     <?php
  434.     return $form;
  435. }
  436.  
  437. //Custom Merge Tag for Workflow Status
  438. add_action( 'gform_admin_pre_render', 'add_merge_tags' );
  439. function add_merge_tags($form)
  440. {
  441.     ?>
  442.     <script type="text/javascript">
  443.         gform.addFilter('gform_merge_tags', 'add_merge_tags');
  444.         function add_merge_tags(mergeTags, elementId, hideAllFields, excludeFieldTypes, isPrepop, option){
  445.             mergeTags["custom"].tags.push({ tag: '{workflow_status}', label: 'Workflow Status' });
  446.             mergeTags["other"].tags.push({ tag: '{hostname}', label: 'Hostname' });
  447.             mergeTags["other"].tags.push({tag: '{curtime}', label: 'Current Time'});
  448.            
  449.             return mergeTags;
  450.         }
  451.     </script>
  452.     <?php
  453.     return $form;
  454. }
  455.  
  456. /* Change Mileage List Field Column 1 to a Date Field */
  457. add_filter( 'gform_column_input_content_32_4_1', 'changeColumn1ToDateSup', 10, 6 );
  458. function changeColumn1ToDateSup( $input, $input_info, $field, $text, $value, $form_id )
  459. {
  460.     //build field name, must match List field syntax to be processed correctly
  461.     $input_field_name = 'input_' . $field->id . '[]';
  462.     $tabindex = GFCommon::get_tabindex();
  463.     $new_input = '<input type="date" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  464.     return $new_input;
  465. }
  466.  
  467. /* Change Mileage List Field Column 4 to a Number Field */
  468. add_filter( 'gform_column_input_content_32_4_4', 'changeColumn4ToNumberSup', 10, 6 );
  469. function changeColumn4ToNumberSup( $input, $input_info, $field, $text, $value, $form_id )
  470. {
  471.     //build field name, must match List field syntax to be processed correctly
  472.     $input_field_name = 'input_' . $field->id . '[]';
  473.     $tabindex = GFCommon::get_tabindex();
  474.     $new_input = '<input type="number" step="any" min="0" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  475.     return $new_input;
  476. }
  477.  
  478.  
  479. /************************************/
  480. /*          Mileage Form            */
  481. /************************************/
  482. /* Change Mileage List Field Column 1 to a Date Field*/
  483. add_filter( 'gform_column_input_content_17_4_1', 'changeColumn1ToDate', 10, 6 );
  484. function changeColumn1ToDate( $input, $input_info, $field, $text, $value, $form_id )
  485. {
  486.     //build field name, must match List field syntax to be processed correctly
  487.     $input_field_name = 'input_' . $field->id . '[]';
  488.     $tabindex = GFCommon::get_tabindex();
  489.     $new_input = '<input type="date" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  490.     return $new_input;
  491. }
  492.  
  493. /* Change Mileage List Field Column 4 to a Number Field */
  494. add_filter( 'gform_column_input_content_17_4_4', 'changeColumn4ToNumber', 10, 6 );
  495. function changeColumn4ToNumber( $input, $input_info, $field, $text, $value, $form_id )
  496. {
  497.     //build field name, must match List field syntax to be processed correctly
  498.     $input_field_name = 'input_' . $field->id . '[]';
  499.     $tabindex = GFCommon::get_tabindex();
  500.     $new_input = '<input type="number" step="any" min="0" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  501.     return $new_input;
  502. }
  503.  
  504. /* Change Expense List Field Column 1 to a Date Field */
  505. add_filter( 'gform_column_input_content_30_9_1', 'changeColumn1ToDateForExpense', 10, 6 );
  506. function changeColumn1ToDateForExpense( $input, $input_info, $field, $text, $value, $form_id )
  507. {
  508.     //build field name, must match List field syntax to be processed correctly
  509.     $input_field_name = 'input_' . $field->id . '[]';
  510.     $tabindex = GFCommon::get_tabindex();
  511.     $new_input = '<input type="date" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  512.     return $new_input;
  513. }
  514.  
  515. /* Change Expense List Field Column 2 to a Number Field */
  516. add_filter( 'gform_column_input_content_30_9_3', 'changeColumn2ToNumber', 10, 6 );
  517. function changeColumn2ToNumber( $input, $input_info, $field, $text, $value, $form_id )
  518. {
  519.     //build field name, must match List field syntax to be processed correctly
  520.     $input_field_name = 'input_' . $field->id . '[]';
  521.     $tabindex = GFCommon::get_tabindex();
  522.     $new_input = '<input type="number" step="any" min="0" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  523.     return $new_input;
  524. }
  525.  
  526. /* Change GF Patient Pictures */
  527. add_filter( 'gform_upload_path_54', 'change_upload_path_54', 10, 2 );
  528. function change_upload_path_54($path_info, $form_id)
  529. {
  530.     $year = date("Y");
  531.     $month = date("m");
  532.     $day = date("d");
  533.    
  534.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/traunerLetter/' . $year . '/' . $month . '/' . $day . '/';
  535.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/traunerLetter/' . $year . '/' . $month . '/' . $day . '/';
  536.     return $path_info;
  537. }
  538.  
  539. /* Change GF Upload Path for Mileage Coordinators */
  540. add_filter( 'gform_upload_path_32', 'change_upload_path_32', 10, 2 );
  541. function change_upload_path_32( $path_info, $form_id )
  542. {
  543.     $current_user = wp_get_current_user();
  544.     $year = date("Y");
  545.     $month = date("m");
  546.     $day = date("d");
  547.    
  548.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/mileage/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  549.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/mileage/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  550.     return $path_info;
  551. }
  552.  
  553. /* Change GF Upload Path for Direct Deposit */
  554. add_filter( 'gform_upload_path_25', 'change_upload_path_25', 10, 2 );
  555. function change_upload_path_25( $path_info, $form_id )
  556. {
  557.     $year = date("Y");
  558.     $month = date("m");
  559.     $day = date("d");
  560.     $current_user = wp_get_current_user();
  561.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/directDeposit/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  562.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/directDeposit/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  563.     return $path_info;
  564. }
  565.  
  566. /* Change GF Upload Path for Expense */
  567. add_filter( 'gform_upload_path_30', 'change_upload_path_30', 10, 2 );
  568. function change_upload_path_30( $path_info, $form_id )
  569. {
  570.     $year = date("Y");
  571.     $month = date("m");
  572.     $day = date("d");
  573.     $current_user = wp_get_current_user();
  574.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/expense/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  575.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/expense/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  576.     return $path_info;
  577. }
  578.  
  579. /* Change GF Upload Path for Expense */
  580. add_filter( 'gform_upload_path_33', 'change_upload_path_33', 10, 2 );
  581. function change_upload_path_33( $path_info, $form_id )
  582. {
  583.     $year = date("Y");
  584.     $month = date("m");
  585.     $day = date("d");
  586.     $current_user = wp_get_current_user();
  587.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/expense/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  588.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/expense/' . $year . '/' . $month . '/' . $day . '/' . $current_user->user_login . '/';
  589.     return $path_info;
  590. }
  591.  
  592. /* Change GF Upload Path for Training Upload */
  593. add_filter( 'gform_upload_path_27', 'gform_upload_path_27', 10, 2 );
  594. function change_upload_path_27( $path_info, $form_id )
  595. {
  596.     $year = date("Y");
  597.     $month = date("m");
  598.     $day = date("d");
  599.     $current_user = wp_get_current_user();
  600.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/training/' . $year . '/' . $current_user->user_login . '/';
  601.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/training/' . $year . '/' . $current_user->user_login . '/';
  602.     return $path_info;
  603. }
  604.  
  605. /* Change GF Upload Path for Maintenance */
  606. add_filter( 'gform_upload_path_37', 'change_upload_path_37', 10, 2 );
  607. function change_upload_path_37($path_info, $form_id)
  608. {
  609.     $year = date("Y");
  610.     $month = date("m");
  611.     $day = date("d");
  612.     $path_info['path'] = 'E:\inetpub\wwwroot\wordpress/wp-content/uploads/gravity_forms/maintenance/' . $year . '/' . $month . '/' . $day . '/';
  613.     $path_info['url'] = 'http://intranet/wp-content/uploads/gravity_forms/maintenance/' . $year . '/' . $month . '/' . $day . '/';
  614.     return $path_info;
  615. }
  616.  
  617. //List Field Columns
  618. add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value ) {
  619.     if ( $field->type == 'list' && $merge_tag != 'all_fields' && is_numeric( $modifier ) ) {
  620.         // count the actual number of columns
  621.         $choices      = $field->choices;
  622.         $column_count = count( $choices );
  623.  
  624.         if ( $column_count > 1 ) {
  625.             // subtract 1 from column number as the choices array is zero based
  626.             $column_num = $modifier - 1;
  627.  
  628.             // get the column label so we can use that as the key to the multi-column values
  629.             $column = rgars( $choices, "{$column_num}/text" );
  630.  
  631.             // get the list fields values from the $entry
  632.             $values        = unserialize( $raw_value );
  633.             $column_values = array();
  634.  
  635.             foreach ( $values as $value ) {
  636.                 $column_values[] = rgar( $value, $column );
  637.             }
  638.  
  639.             $value = GFCommon::implode_non_blank('<br><hr>', $column_values);
  640.         }
  641.     }
  642.  
  643.     return $value;
  644. }, 10, 5 );
  645.  
  646. //Change Values of Custom Merge Tags
  647. add_filter( 'gform_replace_merge_tags', 'replace_status', 10, 7 );
  648. function replace_status( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format )
  649. {
  650.    
  651.     $custom_merge_tag = '{workflow_status}';
  652.    
  653.     if ( strpos( $text, $custom_merge_tag ) === false ) {
  654.         return $text;
  655.     }
  656.    
  657.     $text = str_replace( $custom_merge_tag, $entry['workflow_final_status'], $text );
  658.    
  659.     return $text;
  660. }
  661.  
  662. add_filter( 'gform_replace_merge_tags', 'replace_time', 10, 7 );
  663. function replace_time( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format )
  664. {
  665.     $custom_merge_tag = '{curtime}';
  666.    
  667.     if ( strpos( $text, $custom_merge_tag ) === false )
  668.     {
  669.         return $text;
  670.     }
  671.    
  672.     date_default_timezone_set('America/Los_Angeles');
  673.     $time = date('H:i');
  674.     $text = str_replace( $custom_merge_tag, $time, $text );
  675.    
  676.     return $text;
  677. }
  678.  
  679. add_filter( 'gform_replace_merge_tags', 'replace_hostname', 10, 7 );
  680. function replace_hostname( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format )
  681. {
  682.    
  683.     $custom_merge_tag = '{hostname}';
  684.    
  685.     if ( strpos( $text, $custom_merge_tag ) === false ) {
  686.         return $text;
  687.     }
  688.    
  689.     $ipaddress = '';
  690.     if (getenv('HTTP_CLIENT_IP'))
  691.         $ipaddress = getenv('HTTP_CLIENT_IP');
  692.     else if(getenv('HTTP_X_FORWARDED_FOR'))
  693.         $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
  694.     else if(getenv('HTTP_X_FORWARDED'))
  695.         $ipaddress = getenv('HTTP_X_FORWARDED');
  696.     else if(getenv('HTTP_FORWARDED_FOR'))
  697.         $ipaddress = getenv('HTTP_FORWARDED_FOR');
  698.     else if(getenv('HTTP_FORWARDED'))
  699.        $ipaddress = getenv('HTTP_FORWARDED');
  700.     else if(getenv('REMOTE_ADDR'))
  701.         $ipaddress = getenv('REMOTE_ADDR');
  702.     else
  703.         $ipaddress = 'UNKNOWN';
  704.    
  705.     $fqdn = gethostbyaddr($ipaddress);
  706.     $fqdnExp = explode('.', $fqdn);
  707.    
  708.     $hostname = array(
  709.                         'host'=> $fqdnExp[0],
  710.                         'domain'=> $fqdnExp[1],
  711.                         'scope'=> $fqdnExp[2]);
  712.                        
  713.     if(stripos($hostname['host'], 'termserv') === FALSE)
  714.     {
  715.         $text = str_replace( $custom_merge_tag, $hostname['host'], $text );
  716.     }
  717.     else
  718.     {
  719.         $text = str_replace( $custom_merge_tag, '', $text );
  720.     }
  721.    
  722.     return $text;
  723. }
  724.  
  725. /* Uniform Order Webhook */
  726. add_action('gform_after_submission_41', 'createOrderForms', 10, 2);
  727. function createOrderForms($entry, $form)
  728. {
  729.     /* Set Form Info */
  730.     $uniformTopsFID = 4;
  731.     $uniformBottomsFID = 8;
  732.     $frontOfficeUniformFID = 22;
  733.    
  734.     /* Get Location Info */
  735.     $location = rgar($entry, '3');
  736.     $department = rgar($entry, '21');
  737.    
  738.     //$postURL = 'http://requestb.in/zpmft8zp';
  739.     $postURL = 'http://intranet/employeedb/orderFormCreation.php';
  740.     $body = array(
  741.         'uniformTops' => $entry[$uniformTopsFID],
  742.         'uniformBottoms' => $entry[$uniformBottomsFID],
  743.         'frontOfficeOrder' => $entry[$frontOfficeUniformFID],
  744.         'location' => $location,
  745.         'department' => $department);
  746.        
  747.     $request = new WP_Http();
  748.     $response = $request->post($postURL, array('body' => $body));
  749. }
  750.  
  751. /* Change path of Gravity flow PDF's */
  752. add_filter( 'gravityflowpdf_file_path', 'sh_gravityflowpdf_file_path', 10, 2 );
  753. function sh_gravityflowpdf_file_path( $path, $entry_id ) {
  754.     $entry = GFAPI::get_entry( $entry_id );
  755.     $form = GFAPI::get_form( $entry['form_id'] );
  756.    
  757.     if($entry['form_id'] == 42)
  758.     {
  759.         $FirstName = rgar($entry, '3.3');
  760.         $LastName = rgar($entry, '3.6');
  761.         $physicianFirstName = rgar($entry, '15.3');
  762.         $physicianLastName = rgar($entry, '15.6');
  763.         $path = gravity_flow_pdf()->get_destination_folder() . $FirstName . $physicianFirstName . ' ' . $LastName . $physicianLastName . ' - ' . $form['title'] . ' - ' . $entry_id . '.pdf';
  764.        
  765.     }
  766.     else
  767.     {
  768.         $entry_creator = new WP_User( $entry['created_by'] );
  769.         $path = gravity_flow_pdf()->get_destination_folder() . $entry_creator->display_name . ' - ' . $form['title'] . ' - ' . $entry_id . '.pdf';
  770.     }
  771.    
  772.     return $path;
  773. }
  774.  
  775. /* Change Number of List field rows */
  776. /**
  777.  * Gravity Wiz // Gravity Forms // Set Number of List Field Rows by Field Value
  778.  *
  779.  * Add/remove list field rows automatically based on the value entered in the specified field. Removes the add/remove
  780.  * that normally buttons next to List field rows.
  781.  *
  782.  * @version   1.0
  783.  * @author    David Smith <david@gravitywiz.com>
  784.  * @license   GPL-2.0+
  785.  * @link      http://gravitywiz.com/2012/06/03/set-number-of-list-field-rows-by-field-value/
  786.  */
  787. class GWAutoListFieldRows {
  788.  
  789.     private static $_is_script_output;
  790.  
  791.     function __construct( $args )
  792.     {
  793.  
  794.         $this->_args = wp_parse_args( $args, array(
  795.             'form_id'       => false,
  796.             'input_html_id' => false,
  797.             'list_field_id' => false
  798.         ) );
  799.  
  800.         extract( $this->_args ); // gives us $form_id, $input_html_id, and $list_field_id
  801.  
  802.         if( ! $form_id || ! $input_html_id || ! $list_field_id )
  803.             return;
  804.  
  805.         add_filter( 'gform_pre_render_' . $form_id, array( $this, 'pre_render' ) );
  806.  
  807.     }
  808.  
  809.     function pre_render( $form ) {
  810.         ?>
  811.  
  812.         <style type="text/css"> #field_<?php echo $form['id']; ?>_<?php echo $this->_args['list_field_id']; ?> .gfield_list_icons { display: none; } </style>
  813.  
  814.         <?php
  815.  
  816.         add_filter( 'gform_register_init_scripts', array( $this, 'register_init_script' ) );
  817.  
  818.         if( ! self::$_is_script_output )
  819.             $this->output_script();
  820.  
  821.         return $form;
  822.     }
  823.  
  824.     function register_init_script( $form ) {
  825.  
  826.         // remove this function from the filter otherwise it will be called for every other form on the page
  827.         remove_filter( 'gform_register_init_scripts', array( $this, 'register_init_script' ) );
  828.  
  829.         $args = array(
  830.             'formId'      => $this->_args['form_id'],
  831.             'listFieldId' => $this->_args['list_field_id'],
  832.             'inputHtmlId' => $this->_args['input_html_id']
  833.         );
  834.  
  835.         $script = "new gwalfr(" . json_encode( $args ) . ");";
  836.         $key = implode( '_', $args );
  837.  
  838.         GFFormDisplay::add_init_script( $form['id'], 'gwalfr_' . $key , GFFormDisplay::ON_PAGE_RENDER, $script );
  839.  
  840.     }
  841.  
  842.     function output_script() {
  843.         ?>
  844.  
  845.         <script type="text/javascript">
  846.  
  847.             window.gwalfr;
  848.  
  849.             (function($){
  850.  
  851.                 gwalfr = function( args ) {
  852.  
  853.                     this.formId      = args.formId,
  854.                         this.listFieldId = args.listFieldId,
  855.                         this.inputHtmlId = args.inputHtmlId;
  856.  
  857.                     this.init = function() {
  858.  
  859.                         var gwalfr = this,
  860.                             triggerInput = $( this.inputHtmlId );
  861.  
  862.                         // update rows on page load
  863.                         this.updateListItems( triggerInput, this.listFieldId, this.formId );
  864.  
  865.                         // update rows when field value changes
  866.                         triggerInput.change(function(){
  867.                             gwalfr.updateListItems( $(this), gwalfr.listFieldId, gwalfr.formId );
  868.                         });
  869.  
  870.                     }
  871.  
  872.                     this.updateListItems = function( elem, listFieldId, formId ) {
  873.  
  874.                         var listField = $( '#field_' + formId + '_' + listFieldId ),
  875.                             count = parseInt( elem.val() );
  876.                         rowCount = listField.find( 'table.gfield_list tbody tr' ).length,
  877.                             diff = count - rowCount;
  878.  
  879.                         if( diff > 0 ) {
  880.                             for( var i = 0; i < diff; i++ ) {
  881.                                 listField.find( '.add_list_item:last' ).click();
  882.                             }
  883.                         } else {
  884.  
  885.                             // make sure we never delete all rows
  886.                             if( rowCount + diff == 0 )
  887.                                 diff++;
  888.  
  889.                             for( var i = diff; i < 0; i++ ) {
  890.                                 listField.find( '.delete_list_item:last' ).click();
  891.                             }
  892.  
  893.                         }
  894.                     }
  895.  
  896.                     this.init();
  897.  
  898.                 }
  899.  
  900.             })(jQuery);
  901.  
  902.         </script>
  903.  
  904.         <?php
  905.     }
  906.  
  907. }
  908.  
  909. /* Mileage form Dynamic rows */
  910. new GWAutoListFieldRows( array(
  911.     'form_id' => 17,
  912.     'list_field_id' => 4,
  913.     'input_html_id' => '#input_17_18'
  914. ) );
  915.  
  916. /* Expense form Dynamic rows */
  917. new GWAutoListFieldRows( array(
  918.     'form_id' => 30,
  919.     'list_field_id' => 9,
  920.     'input_html_id' => '#input_30_16'
  921. ) );
  922.  
  923. /* Expense form Dynamic rows */
  924. new GWAutoListFieldRows( array(
  925.     'form_id' => 32,
  926.     'list_field_id' => 4,
  927.     'input_html_id' => '#input_32_18'
  928. ) );
  929.  
  930. /* Expense form Dynamic rows */
  931. new GWAutoListFieldRows( array(
  932.     'form_id' => 33,
  933.     'list_field_id' => 9,
  934.     'input_html_id' => '#input_33_16'
  935. ) );
  936.  
  937. /* Order form Dynamic rows */
  938. new GWAutoListFieldRows( array(
  939.     'form_id' => 41,
  940.     'list_field_id' => 4,
  941.     'input_html_id' => '#input_41_5'
  942. ) );
  943.  
  944. /* Order form Dynamic rows */
  945. new GWAutoListFieldRows( array(
  946.     'form_id' => 41,
  947.     'list_field_id' => 8,
  948.     'input_html_id' => '#input_41_9'
  949. ) );
  950.  
  951. /* Order form Dynamic rows */
  952. new GWAutoListFieldRows( array(
  953.     'form_id' => 41,
  954.     'list_field_id' => 22,
  955.     'input_html_id' => '#input_41_23'
  956. ) );
  957.  
  958. /* Office Supplies Order form Dynamic rows */
  959. new GWAutoListFieldRows( array(
  960.     'form_id' => 52,
  961.     'list_field_id' => 4,
  962.     'input_html_id' => '#input_52_11'
  963. ));
  964.  
  965. /* Scrub Uniform Tops Order Form Custom Code */
  966. /* Scrub Top Quantity */
  967. add_filter( 'gform_column_input_content_41_4_4', 'changeColumn4ToNumberOrder', 10, 6 );
  968. function changeColumn4ToNumberOrder( $input, $input_info, $field, $text, $value, $form_id )
  969. {
  970.     //build field name, must match List field syntax to be processed correctly
  971.     $input_field_name = 'input_' . $field->id . '[]';
  972.     $tabindex = GFCommon::get_tabindex();
  973.     $new_input = '<input type="number" step="any" min="1" max="10" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  974.     return $new_input;
  975. }
  976.  
  977. /* Scrub Top Size */
  978. add_filter( 'gform_column_input_content_41_4_1', 'changeColumn1ToDropOrder', 10, 6 );
  979. function changeColumn1ToDropOrder( $input, $input_info, $field, $text, $value, $form_id )
  980. {
  981.     //build field name, must match List field syntax to be processed correctly
  982.     $input_field_name = 'input_' . $field->id . '[]';
  983.     $tabindex = GFCommon::get_tabindex();  
  984.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  985.                         <option value="' . $value . '">' . $value . '</option>
  986.                         <option value="XS">Xtra Small</option>
  987.                         <option value="Small">Small</option>
  988.                         <option value="Medium">Medium</option>
  989.                         <option value="Large">Large</option>
  990.                         <option value="XL">XL</option>
  991.                         <option value="2XL">2XL</option>
  992.                         <option value="3XL">3XL</option>
  993.                         <option value="4XL">4XL</option>
  994.                     </select>';
  995.     return $new_input;
  996. }
  997.  
  998. /*Scrub Top Style */
  999. add_filter( 'gform_column_input_content_41_4_2', 'changeColumn2ToDropOrder', 10, 6 );
  1000. function changeColumn2ToDropOrder( $input, $input_info, $field, $text, $value, $form_id )
  1001. {
  1002.     //build field name, must match List field syntax to be processed correctly
  1003.     $input_field_name = 'input_' . $field->id . '[]';
  1004.     $tabindex = GFCommon::get_tabindex();  
  1005.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1006.                         <option value="' . $value . '">' . $value . '</option>
  1007.                         <option value="086706D">Womens V-Neck</option>
  1008.                         <option value="4876">Mens V-Neck</option>
  1009.                         <option value="86306D">Lab Coat (White Only)</option>
  1010.                         <option value="FleeceJacket">Fleece Jacket (Black Only)</option>
  1011.                     </select>';
  1012.     return $new_input;
  1013. }
  1014.  
  1015. /* Scrub Top Color */
  1016. add_filter( 'gform_column_input_content_41_4_3', 'changeColumn3ToDropOrder', 10, 6 );
  1017. function changeColumn3ToDropOrder( $input, $input_info, $field, $text, $value, $form_id )
  1018. {
  1019.     //build field name, must match List field syntax to be processed correctly
  1020.     $input_field_name = 'input_' . $field->id . '[]';
  1021.     $tabindex = GFCommon::get_tabindex();  
  1022.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1023.                         <option value="' . $value . '">' . $value . '</option>
  1024.                         <option value="Pewter">Pewter</option>
  1025.                         <option value="Maroon">Maroon (Surgery Only)</option>
  1026.                         <option value="Black">Black</option>
  1027.                         <option value="Black">White</option>
  1028.                     </select>';
  1029.     return $new_input;
  1030. }
  1031.  
  1032.  
  1033. /* Scrub Uniform Bottoms Order Form */
  1034.  
  1035. /* Scrub Pant Quantity */
  1036. add_filter( 'gform_column_input_content_41_8_4', 'scrubBottomFormCol4', 10, 6 );
  1037. function scrubBottomFormCol4( $input, $input_info, $field, $text, $value, $form_id )
  1038. {
  1039.     //build field name, must match List field syntax to be processed correctly
  1040.     $input_field_name = 'input_' . $field->id . '[]';
  1041.     $tabindex = GFCommon::get_tabindex();
  1042.     $new_input = '<input type="number" step="any" min="1" max="10" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  1043.     return $new_input;
  1044. }
  1045.  
  1046. /* Scrub Pants Size */
  1047. add_filter( 'gform_column_input_content_41_8_1', 'scrubBottomFormCol1', 10, 6 );
  1048. function scrubBottomFormCol1( $input, $input_info, $field, $text, $value, $form_id )
  1049. {
  1050.     //build field name, must match List field syntax to be processed correctly
  1051.     $input_field_name = 'input_' . $field->id . '[]';
  1052.     $tabindex = GFCommon::get_tabindex();  
  1053.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1054.                         <option value="' . $value . '">' . $value . '</option>
  1055.                         <option value="XS">Xtra Small</option>
  1056.                         <option value="Small">Small</option>
  1057.                         <option value="SmallTall">Small Tall</option>
  1058.                         <option value="Medium">Medium</option>
  1059.                         <option value="MediumTall">Medium Tall</option>
  1060.                         <option value="LargeTall">Large Tall</option>
  1061.                         <option value="XL">XL</option>
  1062.                         <option value="XLT">XL Tall</option>
  1063.                         <option value="2XL">2XL</option>
  1064.                         <option value="2XLT">2XL Tall</option>
  1065.                         <option value="3XL">3XL</option>
  1066.                         <option value="3XLT">3XL Tall</option>
  1067.                         <option value="4XL">4XL</option>
  1068.                         <option value="4XLT">4XL Tall</option>
  1069.                     </select>';
  1070.     return $new_input;
  1071. }
  1072.  
  1073. /* Scrub Pants Style */
  1074. add_filter( 'gform_column_input_content_41_8_2', 'scrubBottomFormCol2', 10, 6 );
  1075. function scrubBottomFormCol2( $input, $input_info, $field, $text, $value, $form_id )
  1076. {
  1077.     //build field name, must match List field syntax to be processed correctly
  1078.     $input_field_name = 'input_' . $field->id . '[]';
  1079.     $tabindex = GFCommon::get_tabindex();  
  1080.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1081.                         <option value="' . $value . '">' . $value . '</option>
  1082.                         <option value="86206D">Womens Half Draw & Half Elastic</option>
  1083.                         <option value="86106D">Womens Full Elastic</option>
  1084.                         <option value="4000">Mens Scrub Pants</option>
  1085.                     </select>';
  1086.     return $new_input;
  1087. }
  1088.  
  1089. /* Scrub bottom Colors */
  1090. add_filter( 'gform_column_input_content_41_8_3', 'scrubBottomFormCol3', 10, 6 );
  1091. function scrubBottomFormCol3( $input, $input_info, $field, $text, $value, $form_id )
  1092. {
  1093.     //build field name, must match List field syntax to be processed correctly
  1094.     $input_field_name = 'input_' . $field->id . '[]';
  1095.     $tabindex = GFCommon::get_tabindex();  
  1096.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1097.                         <option value="' . $value . '">' . $value . '</option>
  1098.                         <option value="Pewter">Pewter</option>
  1099.                         <option value="Maroon">Maroon (Surgery Only)</option>
  1100.                         <option value="Black">Black</option>
  1101.                     </select>';
  1102.     return $new_input;
  1103. }
  1104.  
  1105. /* Front Office Uniforms */
  1106.  
  1107. /* Shirt Quantity */
  1108. add_filter( 'gform_column_input_content_41_22_4', 'foBottomFormCol4', 10, 6 );
  1109. function foBottomFormCol4( $input, $input_info, $field, $text, $value, $form_id )
  1110. {
  1111.     //build field name, must match List field syntax to be processed correctly
  1112.     $input_field_name = 'input_' . $field->id . '[]';
  1113.     $tabindex = GFCommon::get_tabindex();
  1114.     $new_input = '<input type="number" step="any" min="1" max="10" name="' . $input_field_name . '" value="' . $value . '" ' . $tabindex . ' />';
  1115.     return $new_input;
  1116. }
  1117.  
  1118. /* Shirt Size */
  1119. add_filter( 'gform_column_input_content_41_22_1', 'foBottomFormCol1', 10, 6 );
  1120. function foBottomFormCol1( $input, $input_info, $field, $text, $value, $form_id )
  1121. {
  1122.     //build field name, must match List field syntax to be processed correctly
  1123.     $input_field_name = 'input_' . $field->id . '[]';
  1124.     $tabindex = GFCommon::get_tabindex();  
  1125.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1126.                         <option value="' . $value . '">' . $value . '</option>
  1127.                         <option value="" disabled>Jacket & Cardigan</option>
  1128.                         <option value="Small">Small</option>
  1129.                         <option value="Medium">Medium</option>
  1130.                         <option value="Large">Large</option>
  1131.                         <option value="XL">Xtra Large</option>
  1132.                         <option value="" disabled>Petite</option>
  1133.                         <option value="Petite 00">00</option>
  1134.                         <option value="Petite 0">0</option>
  1135.                         <option value="Petite 1">1</option>
  1136.                         <option value="Petite 2">2</option>
  1137.                         <option value="Petite 3">3</option>
  1138.                         <option value="Petite 4">4</option>
  1139.                         <option value="Petite 5">5</option>
  1140.                         <option value="Petite 6">6</option>
  1141.                         <option value="Petite 7">7</option>
  1142.                         <option value="Petite 8">8</option>
  1143.                         <option value="Petite 9">9</option>
  1144.                         <option value="Petite 10">10</option>
  1145.                         <option value="Petite 11">11</option>
  1146.                         <option value="Petite 12">12</option>
  1147.                         <option value="Petite 13">13</option>
  1148.                         <option value="Petite 14">14</option>
  1149.                         <option value="Petite 15">15</option>
  1150.                         <option value="Petite 16">16</option>
  1151.                         <option value="" disabled>Regular</option>
  1152.                         <option value="Regular 2">2</option>
  1153.                         <option value="Regular 3">3</option>
  1154.                         <option value="Regular 4">4</option>
  1155.                         <option value="Regular 5">5</option>
  1156.                         <option value="Regular 6">6</option>
  1157.                         <option value="Regular 7">7</option>
  1158.                         <option value="Regular 8">8</option>
  1159.                         <option value="Regular 9">9</option>
  1160.                         <option value="Regular 10">10</option>
  1161.                         <option value="Regular 11">11</option>
  1162.                         <option value="Regular 12">12</option>
  1163.                         <option value="Regular 13">13</option>
  1164.                         <option value="Regular 14">14</option>
  1165.                         <option value="Regular 15">15</option>
  1166.                         <option value="Regular 16">16</option>
  1167.                         <option value="Regular 17">17</option>
  1168.                         <option value="Regular 18">18</option>
  1169.                         <option value="" disabled>Tall</option>
  1170.                         <option value="Tall 8">8</option>
  1171.                         <option value="Tall 9">9</option>
  1172.                         <option value="Tall 10">10</option>
  1173.                         <option value="Tall 11">11</option>
  1174.                         <option value="Tall 12">12</option>
  1175.                         <option value="Tall 13">13</option>
  1176.                         <option value="Tall 14">14</option>
  1177.                         <option value="Tall 15">15</option>
  1178.                         <option value="Tall 16">16</option>
  1179.                         <option value="Tall 17">17</option>
  1180.                         <option value="Tall 18">18</option>
  1181.                         <option value="Tall 19">19</option>
  1182.                         <option value="Tall 20">20</option>
  1183.                         <option value="" disabled>Womens</option>
  1184.                         <option value="Womens 18W">18W</option>
  1185.                         <option value="Womens 19W">19W</option>
  1186.                         <option value="Womens 20W">20W</option>
  1187.                         <option value="Womens 21W">21W</option>
  1188.                         <option value="Womens 22W">22W</option>
  1189.                         <option value="Womens 23W">23W</option>
  1190.                         <option value="Womens 24W">24W</option>
  1191.                         <option value="Womens 25W">25W</option>
  1192.                         <option value="Womens 26W">26W</option>
  1193.                         <option value="Womens 27W">27W</option>
  1194.                         <option value="Womens 28W">28W</option>
  1195.                         <option value="Womens 29W">29W</option>
  1196.                         <option value="Womens 30W">30W</option>
  1197.                         <option value="Womens 31W">31W</option>
  1198.                         <option value="Womens 32W">32W</option>
  1199.                         <option value="Womens 33W">33W</option>
  1200.                         <option value="Womens 34W">34W</option>
  1201.                     </select>';
  1202.     return $new_input;
  1203. }
  1204.  
  1205. /* Shirt Style */
  1206. add_filter( 'gform_column_input_content_41_22_2', 'foBottomFormCol2', 10, 6 );
  1207. function foBottomFormCol2( $input, $input_info, $field, $text, $value, $form_id )
  1208. {
  1209.     //build field name, must match List field syntax to be processed correctly
  1210.     $input_field_name = 'input_' . $field->id . '[]';
  1211.     $tabindex = GFCommon::get_tabindex();  
  1212.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1213.                         <option value="' . $value . '">' . $value . '</option>
  1214.                         <option value="3/4 Sleeve">3/4 Sleeve</option>
  1215.                         <option value="Long Sleeve">Long Sleeve</option>
  1216.                         <option value="Long Sleeve V-Neck Cardigan">Long Sleeve V-Neck Cardigan (small-XL)</option>
  1217.                         <option value="Polo">Polo</option>
  1218.                         <option value="Fleece Jacket">Fleece Jacket (Black Only, small-XL)</option>
  1219.                     </select>';
  1220.     return $new_input;
  1221. }
  1222.  
  1223. /* Shirt Color */
  1224. add_filter( 'gform_column_input_content_41_22_3', 'foBottomFormCol3', 10, 6 );
  1225. function foBottomFormCol3( $input, $input_info, $field, $text, $value, $form_id )
  1226. {
  1227.     //build field name, must match List field syntax to be processed correctly
  1228.     $input_field_name = 'input_' . $field->id . '[]';
  1229.     $tabindex = GFCommon::get_tabindex();  
  1230.     $new_input =    '<select name="' . $input_field_name . '" ' . $tabindex . '>
  1231.                         <option value="' . $value . '">' . $value . '</option>
  1232.                         <option value="Blue">Dark Cobalt Blue</option>
  1233.                         <option value="Red">Rich Red</option>
  1234.                         <option value="Purple">Prism Purple</option>
  1235.                         <option value="Burgundy">Burgundy</option>
  1236.                         <option value="Black">Black</option>
  1237.                     </select>';
  1238.     return $new_input;
  1239. }
  1240.  
  1241. /**
  1242. * Better Pre-submission Confirmation
  1243. * http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/
  1244. */
  1245. class GWPreviewConfirmation {
  1246.  
  1247.     private static $lead;
  1248.  
  1249.     public static function init() {
  1250.         add_filter( 'gform_pre_render', array( __class__, 'replace_merge_tags' ) );
  1251.     }
  1252.  
  1253.     public static function replace_merge_tags( $form ) {
  1254.  
  1255.         $current_page = isset(GFFormDisplay::$submission[$form['id']]) ? GFFormDisplay::$submission[$form['id']]['page_number'] : 1;
  1256.         $fields = array();
  1257.  
  1258.         // get all HTML fields on the current page
  1259.         foreach($form['fields'] as &$field) {
  1260.  
  1261.             // skip all fields on the first page
  1262.             if(rgar($field, 'pageNumber') <= 1)
  1263.                 continue;
  1264.  
  1265.             $default_value = rgar($field, 'defaultValue');
  1266.             preg_match_all('/{.+}/', $default_value, $matches, PREG_SET_ORDER);
  1267.             if(!empty($matches)) {
  1268.                 // if default value needs to be replaced but is not on current page, wait until on the current page to replace it
  1269.                 if(rgar($field, 'pageNumber') != $current_page) {
  1270.                     $field['defaultValue'] = '';
  1271.                 } else {
  1272.                     $field['defaultValue'] = self::preview_replace_variables($default_value, $form);
  1273.                 }
  1274.             }
  1275.  
  1276.             // only run 'content' filter for fields on the current page
  1277.             if(rgar($field, 'pageNumber') != $current_page)
  1278.                 continue;
  1279.  
  1280.             $html_content = rgar($field, 'content');
  1281.             preg_match_all('/{.+}/', $html_content, $matches, PREG_SET_ORDER);
  1282.             if(!empty($matches)) {
  1283.                 $field['content'] = self::preview_replace_variables($html_content, $form);
  1284.             }
  1285.  
  1286.         }
  1287.  
  1288.         return $form;
  1289.     }
  1290.  
  1291.     /**
  1292.     * Adds special support for file upload, post image and multi input merge tags.
  1293.     */
  1294.     public static function preview_special_merge_tags($value, $input_id, $merge_tag, $field) {
  1295.        
  1296.         // added to prevent overriding :noadmin filter (and other filters that remove fields)
  1297.         if( ! $value )
  1298.             return $value;
  1299.        
  1300.         $input_type = RGFormsModel::get_input_type($field);
  1301.        
  1302.         $is_upload_field = in_array( $input_type, array('post_image', 'fileupload') );
  1303.         $is_multi_input = is_array( rgar($field, 'inputs') );
  1304.         $is_input = intval( $input_id ) != $input_id;
  1305.        
  1306.         if( !$is_upload_field && !$is_multi_input )
  1307.             return $value;
  1308.  
  1309.         // if is individual input of multi-input field, return just that input value
  1310.         if( $is_input )
  1311.             return $value;
  1312.            
  1313.         $form = RGFormsModel::get_form_meta($field['formId']);
  1314.         $lead = self::create_lead($form);
  1315.         $currency = GFCommon::get_currency();
  1316.  
  1317.         if(is_array(rgar($field, 'inputs'))) {
  1318.             $value = RGFormsModel::get_lead_field_value($lead, $field);
  1319.             return GFCommon::get_lead_field_display($field, $value, $currency);
  1320.         }
  1321.  
  1322.         switch($input_type) {
  1323.         case 'fileupload':
  1324.             $value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead);
  1325.             $value = self::preview_image_display($field, $form, $value);
  1326.             break;
  1327.         default:
  1328.             $value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead);
  1329.             $value = GFCommon::get_lead_field_display($field, $value, $currency);
  1330.             break;
  1331.         }
  1332.  
  1333.         return $value;
  1334.     }
  1335.  
  1336.     public static function preview_image_value($input_name, $field, $form, $lead) {
  1337.  
  1338.         $field_id = $field['id'];
  1339.         $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
  1340.         $source = RGFormsModel::get_upload_url($form['id']) . "/tmp/" . $file_info["temp_filename"];
  1341.  
  1342.         if(!$file_info)
  1343.             return '';
  1344.  
  1345.         switch(RGFormsModel::get_input_type($field)){
  1346.  
  1347.             case "post_image":
  1348.                 list(,$image_title, $image_caption, $image_description) = explode("|:|", $lead[$field['id']]);
  1349.                 $value = !empty($source) ? $source . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
  1350.                 break;
  1351.  
  1352.             case "fileupload" :
  1353.                 $value = $source;
  1354.                 break;
  1355.  
  1356.         }
  1357.  
  1358.         return $value;
  1359.     }
  1360.  
  1361.     public static function preview_image_display($field, $form, $value) {
  1362.  
  1363.         // need to get the tmp $file_info to retrieve real uploaded filename, otherwise will display ugly tmp name
  1364.         $input_name = "input_" . str_replace('.', '_', $field['id']);
  1365.         $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
  1366.  
  1367.         $file_path = $value;
  1368.         if(!empty($file_path)){
  1369.             $file_path = esc_attr(str_replace(" ", "%20", $file_path));
  1370.             $value = "<a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $file_info['uploaded_filename'] . "</a>";
  1371.         }
  1372.         return $value;
  1373.  
  1374.     }
  1375.  
  1376.     /**
  1377.     * Retrieves $lead object from class if it has already been created; otherwise creates a new $lead object.
  1378.     */
  1379.     public static function create_lead( $form ) {
  1380.        
  1381.         if( empty( self::$lead ) ) {
  1382.             self::$lead = GFFormsModel::create_lead( $form );
  1383.             self::clear_field_value_cache( $form );
  1384.         }
  1385.        
  1386.         return self::$lead;
  1387.     }
  1388.  
  1389.     public static function preview_replace_variables( $content, $form ) {
  1390.  
  1391.         $lead = self::create_lead($form);
  1392.  
  1393.         // add filter that will handle getting temporary URLs for file uploads and post image fields (removed below)
  1394.         // beware, the RGFormsModel::create_lead() function also triggers the gform_merge_tag_filter at some point and will
  1395.         // result in an infinite loop if not called first above
  1396.         add_filter('gform_merge_tag_filter', array('GWPreviewConfirmation', 'preview_special_merge_tags'), 10, 4);
  1397.  
  1398.         $content = GFCommon::replace_variables($content, $form, $lead, false, false, false);
  1399.  
  1400.         // remove filter so this function is not applied after preview functionality is complete
  1401.         remove_filter('gform_merge_tag_filter', array('GWPreviewConfirmation', 'preview_special_merge_tags'));
  1402.  
  1403.         return $content;
  1404.     }
  1405.    
  1406.     public static function clear_field_value_cache( $form ) {
  1407.        
  1408.         if( ! class_exists( 'GFCache' ) )
  1409.             return;
  1410.            
  1411.         foreach( $form['fields'] as &$field ) {
  1412.             if( GFFormsModel::get_input_type( $field ) == 'total' )
  1413.                 GFCache::delete( 'GFFormsModel::get_lead_field_value__' . $field['id'] );
  1414.         }
  1415.        
  1416.     }
  1417.  
  1418. }
  1419.  
  1420. GWPreviewConfirmation::init();
  1421.  
  1422.  
  1423. /* Start */
  1424.  
  1425. add_filter("gform_field_value_groppoMorningHours", "gmh");
  1426. function gmh($value)
  1427. {
  1428.     /* MySQL Server Setup */
  1429.     $servername = "127.0.0.1";
  1430.     $username = "root";
  1431.     $password = "admin4sql!";
  1432.     $databasename = "sent_schedules";
  1433.  
  1434.     /* Create a connection to the server */
  1435.     $conn = new mysqli($servername, $username, $password, $databasename);
  1436.  
  1437.     /* Check Connection */
  1438.     if($conn->connect_error)
  1439.     {
  1440.         die("Connection Failed: " . $conn->connect_error);
  1441.     }
  1442.     $sql = "SELECT * FROM dailyschedule WHERE id=1;";
  1443.     $result = $conn->query($sql);
  1444.     if($result->num_rows > 0)
  1445.     {
  1446.         while($row = $result->fetch_assoc())
  1447.         {
  1448.             return $row['am'];
  1449.         }
  1450.     }
  1451. }
  1452.  
  1453. add_filter("gform_field_value_groppoMorningLocation", "gml");
  1454. function gml($value)
  1455. {
  1456.     /* MySQL Server Setup */
  1457.     $servername = "127.0.0.1";
  1458.     $username = "root";
  1459.     $password = "admin4sql!";
  1460.     $databasename = "sent_schedules";
  1461.  
  1462.     /* Create a connection to the server */
  1463.     $conn = new mysqli($servername, $username, $password, $databasename);
  1464.  
  1465.     /* Check Connection */
  1466.     if($conn->connect_error)
  1467.     {
  1468.         die("Connection Failed: " . $conn->connect_error);
  1469.     }
  1470.     $sql = "SELECT * FROM dailyschedule WHERE id=1;";
  1471.     $result = $conn->query($sql);
  1472.     if($result->num_rows > 0)
  1473.     {
  1474.         while($row = $result->fetch_assoc())
  1475.         {
  1476.             return $row['amLocation'];
  1477.         }
  1478.     }
  1479. }
  1480.  
  1481. add_filter("gform_field_value_groppoAfternoonHours", "gah");
  1482. function gah($value)
  1483. {
  1484.     /* MySQL Server Setup */
  1485.     $servername = "127.0.0.1";
  1486.     $username = "root";
  1487.     $password = "admin4sql!";
  1488.     $databasename = "sent_schedules";
  1489.  
  1490.     /* Create a connection to the server */
  1491.     $conn = new mysqli($servername, $username, $password, $databasename);
  1492.  
  1493.     /* Check Connection */
  1494.     if($conn->connect_error)
  1495.     {
  1496.         die("Connection Failed: " . $conn->connect_error);
  1497.     }
  1498.     $sql = "SELECT * FROM dailyschedule WHERE id=1;";
  1499.     $result = $conn->query($sql);
  1500.     if($result->num_rows > 0)
  1501.     {
  1502.         while($row = $result->fetch_assoc())
  1503.         {
  1504.             return $row['pm'];
  1505.         }
  1506.     }
  1507. }
  1508.  
  1509. add_filter("gform_field_value_groppoAfternoonLocation", "gal");
  1510. function gal($value)
  1511. {
  1512.     /* MySQL Server Setup */
  1513.     $servername = "127.0.0.1";
  1514.     $username = "root";
  1515.     $password = "admin4sql!";
  1516.     $databasename = "sent_schedules";
  1517.  
  1518.     /* Create a connection to the server */
  1519.     $conn = new mysqli($servername, $username, $password, $databasename);
  1520.  
  1521.     /* Check Connection */
  1522.     if($conn->connect_error)
  1523.     {
  1524.         die("Connection Failed: " . $conn->connect_error);
  1525.     }
  1526.     $sql = "SELECT * FROM dailyschedule WHERE id=1;";
  1527.     $result = $conn->query($sql);
  1528.     if($result->num_rows > 0)
  1529.     {
  1530.         while($row = $result->fetch_assoc())
  1531.         {
  1532.             return $row['pmLocation'];
  1533.         }
  1534.     }
  1535. }
  1536.  
  1537.  
  1538. add_filter("gform_field_value_bernsteinMorningHours", "bmh");
  1539. function bmh($value)
  1540. {
  1541.     /* MySQL Server Setup */
  1542.     $servername = "127.0.0.1";
  1543.     $username = "root";
  1544.     $password = "admin4sql!";
  1545.     $databasename = "sent_schedules";
  1546.  
  1547.     /* Create a connection to the server */
  1548.     $conn = new mysqli($servername, $username, $password, $databasename);
  1549.  
  1550.     /* Check Connection */
  1551.     if($conn->connect_error)
  1552.     {
  1553.         die("Connection Failed: " . $conn->connect_error);
  1554.     }
  1555.     $sql = "SELECT * FROM dailyschedule WHERE id=2;";
  1556.     $result = $conn->query($sql);
  1557.     if($result->num_rows > 0)
  1558.     {
  1559.         while($row = $result->fetch_assoc())
  1560.         {
  1561.             return $row['am'];
  1562.         }
  1563.     }
  1564. }
  1565.  
  1566. add_filter("gform_field_value_bernsteinMorningLocation", "bml");
  1567. function bml($value)
  1568. {
  1569.     /* MySQL Server Setup */
  1570.     $servername = "127.0.0.1";
  1571.     $username = "root";
  1572.     $password = "admin4sql!";
  1573.     $databasename = "sent_schedules";
  1574.  
  1575.     /* Create a connection to the server */
  1576.     $conn = new mysqli($servername, $username, $password, $databasename);
  1577.  
  1578.     /* Check Connection */
  1579.     if($conn->connect_error)
  1580.     {
  1581.         die("Connection Failed: " . $conn->connect_error);
  1582.     }
  1583.     $sql = "SELECT * FROM dailyschedule WHERE id=2;";
  1584.     $result = $conn->query($sql);
  1585.     if($result->num_rows > 0)
  1586.     {
  1587.         while($row = $result->fetch_assoc())
  1588.         {
  1589.             return $row['amLocation'];
  1590.         }
  1591.     }
  1592. }
  1593.  
  1594. add_filter("gform_field_value_bernsteinAfternoonHours", "bah");
  1595. function bah($value)
  1596. {
  1597.     /* MySQL Server Setup */
  1598.     $servername = "127.0.0.1";
  1599.     $username = "root";
  1600.     $password = "admin4sql!";
  1601.     $databasename = "sent_schedules";
  1602.  
  1603.     /* Create a connection to the server */
  1604.     $conn = new mysqli($servername, $username, $password, $databasename);
  1605.  
  1606.     /* Check Connection */
  1607.     if($conn->connect_error)
  1608.     {
  1609.         die("Connection Failed: " . $conn->connect_error);
  1610.     }
  1611.     $sql = "SELECT * FROM dailyschedule WHERE id=2;";
  1612.     $result = $conn->query($sql);
  1613.     if($result->num_rows > 0)
  1614.     {
  1615.         while($row = $result->fetch_assoc())
  1616.         {
  1617.             return $row['pm'];
  1618.         }
  1619.     }
  1620. }
  1621.  
  1622. add_filter("gform_field_value_bernsteinAfternoonLocation", "bal");
  1623. function bal($value)
  1624. {
  1625.     /* MySQL Server Setup */
  1626.     $servername = "127.0.0.1";
  1627.     $username = "root";
  1628.     $password = "admin4sql!";
  1629.     $databasename = "sent_schedules";
  1630.  
  1631.     /* Create a connection to the server */
  1632.     $conn = new mysqli($servername, $username, $password, $databasename);
  1633.  
  1634.     /* Check Connection */
  1635.     if($conn->connect_error)
  1636.     {
  1637.         die("Connection Failed: " . $conn->connect_error);
  1638.     }
  1639.     $sql = "SELECT * FROM dailyschedule WHERE id=2;";
  1640.     $result = $conn->query($sql);
  1641.     if($result->num_rows > 0)
  1642.     {
  1643.         while($row = $result->fetch_assoc())
  1644.         {
  1645.             return $row['pmLocation'];
  1646.         }
  1647.     }
  1648. }
  1649.  
  1650.  
  1651. add_filter("gform_field_value_goldfarbMorningHours", "gomh");
  1652. function gomh($value)
  1653. {
  1654.     /* MySQL Server Setup */
  1655.     $servername = "127.0.0.1";
  1656.     $username = "root";
  1657.     $password = "admin4sql!";
  1658.     $databasename = "sent_schedules";
  1659.  
  1660.     /* Create a connection to the server */
  1661.     $conn = new mysqli($servername, $username, $password, $databasename);
  1662.  
  1663.     /* Check Connection */
  1664.     if($conn->connect_error)
  1665.     {
  1666.         die("Connection Failed: " . $conn->connect_error);
  1667.     }
  1668.     $sql = "SELECT * FROM dailyschedule WHERE id=3;";
  1669.     $result = $conn->query($sql);
  1670.     if($result->num_rows > 0)
  1671.     {
  1672.         while($row = $result->fetch_assoc())
  1673.         {
  1674.             return $row['am'];
  1675.         }
  1676.     }
  1677. }
  1678.  
  1679. add_filter("gform_field_value_goldfarbMorningLocation", "goml");
  1680. function goml($value)
  1681. {
  1682.     /* MySQL Server Setup */
  1683.     $servername = "127.0.0.1";
  1684.     $username = "root";
  1685.     $password = "admin4sql!";
  1686.     $databasename = "sent_schedules";
  1687.  
  1688.     /* Create a connection to the server */
  1689.     $conn = new mysqli($servername, $username, $password, $databasename);
  1690.  
  1691.     /* Check Connection */
  1692.     if($conn->connect_error)
  1693.     {
  1694.         die("Connection Failed: " . $conn->connect_error);
  1695.     }
  1696.     $sql = "SELECT * FROM dailyschedule WHERE id=3;";
  1697.     $result = $conn->query($sql);
  1698.     if($result->num_rows > 0)
  1699.     {
  1700.         while($row = $result->fetch_assoc())
  1701.         {
  1702.             return $row['amLocation'];
  1703.         }
  1704.     }
  1705. }
  1706.  
  1707. add_filter("gform_field_value_goldfarbAfternoonHours", "goah");
  1708. function goah($value)
  1709. {
  1710.     /* MySQL Server Setup */
  1711.     $servername = "127.0.0.1";
  1712.     $username = "root";
  1713.     $password = "admin4sql!";
  1714.     $databasename = "sent_schedules";
  1715.  
  1716.     /* Create a connection to the server */
  1717.     $conn = new mysqli($servername, $username, $password, $databasename);
  1718.  
  1719.     /* Check Connection */
  1720.     if($conn->connect_error)
  1721.     {
  1722.         die("Connection Failed: " . $conn->connect_error);
  1723.     }
  1724.     $sql = "SELECT * FROM dailyschedule WHERE id=3;";
  1725.     $result = $conn->query($sql);
  1726.     if($result->num_rows > 0)
  1727.     {
  1728.         while($row = $result->fetch_assoc())
  1729.         {
  1730.             return $row['pm'];
  1731.         }
  1732.     }
  1733. }
  1734.  
  1735. add_filter("gform_field_value_goldfarbAfternoonLocation", "goal");
  1736. function goal($value)
  1737. {
  1738.     /* MySQL Server Setup */
  1739.     $servername = "127.0.0.1";
  1740.     $username = "root";
  1741.     $password = "admin4sql!";
  1742.     $databasename = "sent_schedules";
  1743.  
  1744.     /* Create a connection to the server */
  1745.     $conn = new mysqli($servername, $username, $password, $databasename);
  1746.  
  1747.     /* Check Connection */
  1748.     if($conn->connect_error)
  1749.     {
  1750.         die("Connection Failed: " . $conn->connect_error);
  1751.     }
  1752.     $sql = "SELECT * FROM dailyschedule WHERE id=3;";
  1753.     $result = $conn->query($sql);
  1754.     if($result->num_rows > 0)
  1755.     {
  1756.         while($row = $result->fetch_assoc())
  1757.         {
  1758.             return $row['pmLocation'];
  1759.         }
  1760.     }
  1761. }
  1762.  
  1763.  
  1764. add_filter("gform_field_value_clutterMorningHours", "clmh");
  1765. function clmh($value)
  1766. {
  1767.     /* MySQL Server Setup */
  1768.     $servername = "127.0.0.1";
  1769.     $username = "root";
  1770.     $password = "admin4sql!";
  1771.     $databasename = "sent_schedules";
  1772.  
  1773.     /* Create a connection to the server */
  1774.     $conn = new mysqli($servername, $username, $password, $databasename);
  1775.  
  1776.     /* Check Connection */
  1777.     if($conn->connect_error)
  1778.     {
  1779.         die("Connection Failed: " . $conn->connect_error);
  1780.     }
  1781.     $sql = "SELECT * FROM dailyschedule WHERE id=4;";
  1782.     $result = $conn->query($sql);
  1783.     if($result->num_rows > 0)
  1784.     {
  1785.         while($row = $result->fetch_assoc())
  1786.         {
  1787.             return $row['am'];
  1788.         }
  1789.     }
  1790. }
  1791.  
  1792. add_filter("gform_field_value_clutterMorningLocation", "clml");
  1793. function clml($value)
  1794. {
  1795.     /* MySQL Server Setup */
  1796.     $servername = "127.0.0.1";
  1797.     $username = "root";
  1798.     $password = "admin4sql!";
  1799.     $databasename = "sent_schedules";
  1800.  
  1801.     /* Create a connection to the server */
  1802.     $conn = new mysqli($servername, $username, $password, $databasename);
  1803.  
  1804.     /* Check Connection */
  1805.     if($conn->connect_error)
  1806.     {
  1807.         die("Connection Failed: " . $conn->connect_error);
  1808.     }
  1809.     $sql = "SELECT * FROM dailyschedule WHERE id=4;";
  1810.     $result = $conn->query($sql);
  1811.     if($result->num_rows > 0)
  1812.     {
  1813.         while($row = $result->fetch_assoc())
  1814.         {
  1815.             return $row['amLocation'];
  1816.         }
  1817.     }
  1818. }
  1819.  
  1820. add_filter("gform_field_value_clutterAfternoonHours", "clah");
  1821. function clah($value)
  1822. {
  1823.     /* MySQL Server Setup */
  1824.     $servername = "127.0.0.1";
  1825.     $username = "root";
  1826.     $password = "admin4sql!";
  1827.     $databasename = "sent_schedules";
  1828.  
  1829.     /* Create a connection to the server */
  1830.     $conn = new mysqli($servername, $username, $password, $databasename);
  1831.  
  1832.     /* Check Connection */
  1833.     if($conn->connect_error)
  1834.     {
  1835.         die("Connection Failed: " . $conn->connect_error);
  1836.     }
  1837.     $sql = "SELECT * FROM dailyschedule WHERE id=4;";
  1838.     $result = $conn->query($sql);
  1839.     if($result->num_rows > 0)
  1840.     {
  1841.         while($row = $result->fetch_assoc())
  1842.         {
  1843.             return $row['pm'];
  1844.         }
  1845.     }
  1846. }
  1847.  
  1848. add_filter("gform_field_value_clutterAfternoonLocation", "clal");
  1849. function clal($value)
  1850. {
  1851.     /* MySQL Server Setup */
  1852.     $servername = "127.0.0.1";
  1853.     $username = "root";
  1854.     $password = "admin4sql!";
  1855.     $databasename = "sent_schedules";
  1856.  
  1857.     /* Create a connection to the server */
  1858.     $conn = new mysqli($servername, $username, $password, $databasename);
  1859.  
  1860.     /* Check Connection */
  1861.     if($conn->connect_error)
  1862.     {
  1863.         die("Connection Failed: " . $conn->connect_error);
  1864.     }
  1865.     $sql = "SELECT * FROM dailyschedule WHERE id=4;";
  1866.     $result = $conn->query($sql);
  1867.     if($result->num_rows > 0)
  1868.     {
  1869.         while($row = $result->fetch_assoc())
  1870.         {
  1871.             return $row['pmLocation'];
  1872.         }
  1873.     }
  1874. }
  1875.  
  1876.  
  1877. add_filter("gform_field_value_cathMorningHours", "camh");
  1878. function camh($value)
  1879. {
  1880.     /* MySQL Server Setup */
  1881.     $servername = "127.0.0.1";
  1882.     $username = "root";
  1883.     $password = "admin4sql!";
  1884.     $databasename = "sent_schedules";
  1885.  
  1886.     /* Create a connection to the server */
  1887.     $conn = new mysqli($servername, $username, $password, $databasename);
  1888.  
  1889.     /* Check Connection */
  1890.     if($conn->connect_error)
  1891.     {
  1892.         die("Connection Failed: " . $conn->connect_error);
  1893.     }
  1894.     $sql = "SELECT * FROM dailyschedule WHERE id=5;";
  1895.     $result = $conn->query($sql);
  1896.     if($result->num_rows > 0)
  1897.     {
  1898.         while($row = $result->fetch_assoc())
  1899.         {
  1900.             return $row['am'];
  1901.         }
  1902.     }
  1903. }
  1904.  
  1905. add_filter("gform_field_value_cathMorningLocation", "caml");
  1906. function caml($value)
  1907. {
  1908.     /* MySQL Server Setup */
  1909.     $servername = "127.0.0.1";
  1910.     $username = "root";
  1911.     $password = "admin4sql!";
  1912.     $databasename = "sent_schedules";
  1913.  
  1914.     /* Create a connection to the server */
  1915.     $conn = new mysqli($servername, $username, $password, $databasename);
  1916.  
  1917.     /* Check Connection */
  1918.     if($conn->connect_error)
  1919.     {
  1920.         die("Connection Failed: " . $conn->connect_error);
  1921.     }
  1922.     $sql = "SELECT * FROM dailyschedule WHERE id=5;";
  1923.     $result = $conn->query($sql);
  1924.     if($result->num_rows > 0)
  1925.     {
  1926.         while($row = $result->fetch_assoc())
  1927.         {
  1928.             return $row['amLocation'];
  1929.         }
  1930.     }
  1931. }
  1932.  
  1933. add_filter("gform_field_value_cathAfternoonHours", "caah");
  1934. function caah($value)
  1935. {
  1936.     /* MySQL Server Setup */
  1937.     $servername = "127.0.0.1";
  1938.     $username = "root";
  1939.     $password = "admin4sql!";
  1940.     $databasename = "sent_schedules";
  1941.  
  1942.     /* Create a connection to the server */
  1943.     $conn = new mysqli($servername, $username, $password, $databasename);
  1944.  
  1945.     /* Check Connection */
  1946.     if($conn->connect_error)
  1947.     {
  1948.         die("Connection Failed: " . $conn->connect_error);
  1949.     }
  1950.     $sql = "SELECT * FROM dailyschedule WHERE id=5;";
  1951.     $result = $conn->query($sql);
  1952.     if($result->num_rows > 0)
  1953.     {
  1954.         while($row = $result->fetch_assoc())
  1955.         {
  1956.             return $row['pm'];
  1957.         }
  1958.     }
  1959. }
  1960.  
  1961. add_filter("gform_field_value_cathAfternoonLocation", "caal");
  1962. function caal($value)
  1963. {
  1964.     /* MySQL Server Setup */
  1965.     $servername = "127.0.0.1";
  1966.     $username = "root";
  1967.     $password = "admin4sql!";
  1968.     $databasename = "sent_schedules";
  1969.  
  1970.     /* Create a connection to the server */
  1971.     $conn = new mysqli($servername, $username, $password, $databasename);
  1972.  
  1973.     /* Check Connection */
  1974.     if($conn->connect_error)
  1975.     {
  1976.         die("Connection Failed: " . $conn->connect_error);
  1977.     }
  1978.     $sql = "SELECT * FROM dailyschedule WHERE id=5;";
  1979.     $result = $conn->query($sql);
  1980.     if($result->num_rows > 0)
  1981.     {
  1982.         while($row = $result->fetch_assoc())
  1983.         {
  1984.             return $row['pmLocation'];
  1985.         }
  1986.     }
  1987. }
  1988.  
  1989.  
  1990. add_filter("gform_field_value_areenMorningHours", "amh");
  1991. function amh($value)
  1992. {
  1993.     /* MySQL Server Setup */
  1994.     $servername = "127.0.0.1";
  1995.     $username = "root";
  1996.     $password = "admin4sql!";
  1997.     $databasename = "sent_schedules";
  1998.  
  1999.     /* Create a connection to the server */
  2000.     $conn = new mysqli($servername, $username, $password, $databasename);
  2001.  
  2002.     /* Check Connection */
  2003.     if($conn->connect_error)
  2004.     {
  2005.         die("Connection Failed: " . $conn->connect_error);
  2006.     }
  2007.     $sql = "SELECT * FROM dailyschedule WHERE id=6;";
  2008.     $result = $conn->query($sql);
  2009.     if($result->num_rows > 0)
  2010.     {
  2011.         while($row = $result->fetch_assoc())
  2012.         {
  2013.             return $row['am'];
  2014.         }
  2015.     }
  2016. }
  2017.  
  2018. add_filter("gform_field_value_areenMorningLocation", "aml");
  2019. function aml($value)
  2020. {
  2021.     /* MySQL Server Setup */
  2022.     $servername = "127.0.0.1";
  2023.     $username = "root";
  2024.     $password = "admin4sql!";
  2025.     $databasename = "sent_schedules";
  2026.  
  2027.     /* Create a connection to the server */
  2028.     $conn = new mysqli($servername, $username, $password, $databasename);
  2029.  
  2030.     /* Check Connection */
  2031.     if($conn->connect_error)
  2032.     {
  2033.         die("Connection Failed: " . $conn->connect_error);
  2034.     }
  2035.     $sql = "SELECT * FROM dailyschedule WHERE id=6;";
  2036.     $result = $conn->query($sql);
  2037.     if($result->num_rows > 0)
  2038.     {
  2039.         while($row = $result->fetch_assoc())
  2040.         {
  2041.             return $row['amLocation'];
  2042.         }
  2043.     }
  2044. }
  2045.  
  2046. add_filter("gform_field_value_areenAfternoonHours", "afh");
  2047. function afh($value)
  2048. {
  2049.     /* MySQL Server Setup */
  2050.     $servername = "127.0.0.1";
  2051.     $username = "root";
  2052.     $password = "admin4sql!";
  2053.     $databasename = "sent_schedules";
  2054.  
  2055.     /* Create a connection to the server */
  2056.     $conn = new mysqli($servername, $username, $password, $databasename);
  2057.  
  2058.     /* Check Connection */
  2059.     if($conn->connect_error)
  2060.     {
  2061.         die("Connection Failed: " . $conn->connect_error);
  2062.     }
  2063.     $sql = "SELECT * FROM dailyschedule WHERE id=6;";
  2064.     $result = $conn->query($sql);
  2065.     if($result->num_rows > 0)
  2066.     {
  2067.         while($row = $result->fetch_assoc())
  2068.         {
  2069.             return $row['pm'];
  2070.         }
  2071.     }
  2072. }
  2073.  
  2074. add_filter("gform_field_value_areenAfternoonLocation", "afl");
  2075. function afl($value)
  2076. {
  2077.     /* MySQL Server Setup */
  2078.     $servername = "127.0.0.1";
  2079.     $username = "root";
  2080.     $password = "admin4sql!";
  2081.     $databasename = "sent_schedules";
  2082.  
  2083.     /* Create a connection to the server */
  2084.     $conn = new mysqli($servername, $username, $password, $databasename);
  2085.  
  2086.     /* Check Connection */
  2087.     if($conn->connect_error)
  2088.     {
  2089.         die("Connection Failed: " . $conn->connect_error);
  2090.     }
  2091.     $sql = "SELECT * FROM dailyschedule WHERE id=6;";
  2092.     $result = $conn->query($sql);
  2093.     if($result->num_rows > 0)
  2094.     {
  2095.         while($row = $result->fetch_assoc())
  2096.         {
  2097.             return $row['pmLocation'];
  2098.         }
  2099.     }
  2100. }
  2101.  
  2102.  
  2103. add_filter("gform_field_value_traunerMorningHours", "tmh");
  2104. function tmh($value)
  2105. {
  2106.     /* MySQL Server Setup */
  2107.     $servername = "127.0.0.1";
  2108.     $username = "root";
  2109.     $password = "admin4sql!";
  2110.     $databasename = "sent_schedules";
  2111.  
  2112.     /* Create a connection to the server */
  2113.     $conn = new mysqli($servername, $username, $password, $databasename);
  2114.  
  2115.     /* Check Connection */
  2116.     if($conn->connect_error)
  2117.     {
  2118.         die("Connection Failed: " . $conn->connect_error);
  2119.     }
  2120.     $sql = "SELECT * FROM dailyschedule WHERE id=7;";
  2121.     $result = $conn->query($sql);
  2122.     if($result->num_rows > 0)
  2123.     {
  2124.         while($row = $result->fetch_assoc())
  2125.         {
  2126.             return $row['am'];
  2127.         }
  2128.     }
  2129. }
  2130.  
  2131. add_filter("gform_field_value_traunerMorningLocation", "tml");
  2132. function tml($value)
  2133. {
  2134.     /* MySQL Server Setup */
  2135.     $servername = "127.0.0.1";
  2136.     $username = "root";
  2137.     $password = "admin4sql!";
  2138.     $databasename = "sent_schedules";
  2139.  
  2140.     /* Create a connection to the server */
  2141.     $conn = new mysqli($servername, $username, $password, $databasename);
  2142.  
  2143.     /* Check Connection */
  2144.     if($conn->connect_error)
  2145.     {
  2146.         die("Connection Failed: " . $conn->connect_error);
  2147.     }
  2148.     $sql = "SELECT * FROM dailyschedule WHERE id=7;";
  2149.     $result = $conn->query($sql);
  2150.     if($result->num_rows > 0)
  2151.     {
  2152.         while($row = $result->fetch_assoc())
  2153.         {
  2154.             return $row['amLocation'];
  2155.         }
  2156.     }
  2157. }
  2158.  
  2159. add_filter("gform_field_value_traunerAfternoonHours", "tah");
  2160. function tah($value)
  2161. {
  2162.     /* MySQL Server Setup */
  2163.     $servername = "127.0.0.1";
  2164.     $username = "root";
  2165.     $password = "admin4sql!";
  2166.     $databasename = "sent_schedules";
  2167.  
  2168.     /* Create a connection to the server */
  2169.     $conn = new mysqli($servername, $username, $password, $databasename);
  2170.  
  2171.     /* Check Connection */
  2172.     if($conn->connect_error)
  2173.     {
  2174.         die("Connection Failed: " . $conn->connect_error);
  2175.     }
  2176.     $sql = "SELECT * FROM dailyschedule WHERE id=7;";
  2177.     $result = $conn->query($sql);
  2178.     if($result->num_rows > 0)
  2179.     {
  2180.         while($row = $result->fetch_assoc())
  2181.         {
  2182.             return $row['pm'];
  2183.         }
  2184.     }
  2185. }
  2186.  
  2187. add_filter("gform_field_value_traunerAfternoonLocation", "tal");
  2188. function tal($value)
  2189. {
  2190.     /* MySQL Server Setup */
  2191.     $servername = "127.0.0.1";
  2192.     $username = "root";
  2193.     $password = "admin4sql!";
  2194.     $databasename = "sent_schedules";
  2195.  
  2196.     /* Create a connection to the server */
  2197.     $conn = new mysqli($servername, $username, $password, $databasename);
  2198.  
  2199.     /* Check Connection */
  2200.     if($conn->connect_error)
  2201.     {
  2202.         die("Connection Failed: " . $conn->connect_error);
  2203.     }
  2204.     $sql = "SELECT * FROM dailyschedule WHERE id=7;";
  2205.     $result = $conn->query($sql);
  2206.     if($result->num_rows > 0)
  2207.     {
  2208.         while($row = $result->fetch_assoc())
  2209.         {
  2210.             return $row['pmLocation'];
  2211.         }
  2212.     }
  2213. }
  2214.  
  2215.  
  2216. add_filter("gform_field_value_mckennanMorningHours", "mmh");
  2217. function mmh($value)
  2218. {
  2219.     /* MySQL Server Setup */
  2220.     $servername = "127.0.0.1";
  2221.     $username = "root";
  2222.     $password = "admin4sql!";
  2223.     $databasename = "sent_schedules";
  2224.  
  2225.     /* Create a connection to the server */
  2226.     $conn = new mysqli($servername, $username, $password, $databasename);
  2227.  
  2228.     /* Check Connection */
  2229.     if($conn->connect_error)
  2230.     {
  2231.         die("Connection Failed: " . $conn->connect_error);
  2232.     }
  2233.     $sql = "SELECT * FROM dailyschedule WHERE id=8;";
  2234.     $result = $conn->query($sql);
  2235.     if($result->num_rows > 0)
  2236.     {
  2237.         while($row = $result->fetch_assoc())
  2238.         {
  2239.             return $row['am'];
  2240.         }
  2241.     }
  2242. }
  2243.  
  2244. add_filter("gform_field_value_mckennanMorningLocation", "mml");
  2245. function mml($value)
  2246. {
  2247.     /* MySQL Server Setup */
  2248.     $servername = "127.0.0.1";
  2249.     $username = "root";
  2250.     $password = "admin4sql!";
  2251.     $databasename = "sent_schedules";
  2252.  
  2253.     /* Create a connection to the server */
  2254.     $conn = new mysqli($servername, $username, $password, $databasename);
  2255.  
  2256.     /* Check Connection */
  2257.     if($conn->connect_error)
  2258.     {
  2259.         die("Connection Failed: " . $conn->connect_error);
  2260.     }
  2261.     $sql = "SELECT * FROM dailyschedule WHERE id=8;";
  2262.     $result = $conn->query($sql);
  2263.     if($result->num_rows > 0)
  2264.     {
  2265.         while($row = $result->fetch_assoc())
  2266.         {
  2267.             return $row['amLocation'];
  2268.         }
  2269.     }
  2270. }
  2271.  
  2272. add_filter("gform_field_value_mckennanAfternoonHours", "mah");
  2273. function mah($value)
  2274. {
  2275.     /* MySQL Server Setup */
  2276.     $servername = "127.0.0.1";
  2277.     $username = "root";
  2278.     $password = "admin4sql!";
  2279.     $databasename = "sent_schedules";
  2280.  
  2281.     /* Create a connection to the server */
  2282.     $conn = new mysqli($servername, $username, $password, $databasename);
  2283.  
  2284.     /* Check Connection */
  2285.     if($conn->connect_error)
  2286.     {
  2287.         die("Connection Failed: " . $conn->connect_error);
  2288.     }
  2289.     $sql = "SELECT * FROM dailyschedule WHERE id=8;";
  2290.     $result = $conn->query($sql);
  2291.     if($result->num_rows > 0)
  2292.     {
  2293.         while($row = $result->fetch_assoc())
  2294.         {
  2295.             return $row['pm'];
  2296.         }
  2297.     }
  2298. }
  2299.  
  2300. add_filter("gform_field_value_mckennanAfternoonLocation", "mal");
  2301. function mal($value)
  2302. {
  2303.     /* MySQL Server Setup */
  2304.     $servername = "127.0.0.1";
  2305.     $username = "root";
  2306.     $password = "admin4sql!";
  2307.     $databasename = "sent_schedules";
  2308.  
  2309.     /* Create a connection to the server */
  2310.     $conn = new mysqli($servername, $username, $password, $databasename);
  2311.  
  2312.     /* Check Connection */
  2313.     if($conn->connect_error)
  2314.     {
  2315.         die("Connection Failed: " . $conn->connect_error);
  2316.     }
  2317.     $sql = "SELECT * FROM dailyschedule WHERE id=8;";
  2318.     $result = $conn->query($sql);
  2319.     if($result->num_rows > 0)
  2320.     {
  2321.         while($row = $result->fetch_assoc())
  2322.         {
  2323.             return $row['pmLocation'];
  2324.         }
  2325.     }
  2326. }
  2327.  
  2328.  
  2329. add_filter("gform_field_value_evansMorningHours", "emh");
  2330. function emh($value)
  2331. {
  2332.     /* MySQL Server Setup */
  2333.     $servername = "127.0.0.1";
  2334.     $username = "root";
  2335.     $password = "admin4sql!";
  2336.     $databasename = "sent_schedules";
  2337.  
  2338.     /* Create a connection to the server */
  2339.     $conn = new mysqli($servername, $username, $password, $databasename);
  2340.  
  2341.     /* Check Connection */
  2342.     if($conn->connect_error)
  2343.     {
  2344.         die("Connection Failed: " . $conn->connect_error);
  2345.     }
  2346.     $sql = "SELECT * FROM dailyschedule WHERE id=9;";
  2347.     $result = $conn->query($sql);
  2348.     if($result->num_rows > 0)
  2349.     {
  2350.         while($row = $result->fetch_assoc())
  2351.         {
  2352.             return $row['am'];
  2353.         }
  2354.     }
  2355. }
  2356.  
  2357. add_filter("gform_field_value_evansMorningLocation", "eml");
  2358. function eml($value)
  2359. {
  2360.     /* MySQL Server Setup */
  2361.     $servername = "127.0.0.1";
  2362.     $username = "root";
  2363.     $password = "admin4sql!";
  2364.     $databasename = "sent_schedules";
  2365.  
  2366.     /* Create a connection to the server */
  2367.     $conn = new mysqli($servername, $username, $password, $databasename);
  2368.  
  2369.     /* Check Connection */
  2370.     if($conn->connect_error)
  2371.     {
  2372.         die("Connection Failed: " . $conn->connect_error);
  2373.     }
  2374.     $sql = "SELECT * FROM dailyschedule WHERE id=9;";
  2375.     $result = $conn->query($sql);
  2376.     if($result->num_rows > 0)
  2377.     {
  2378.         while($row = $result->fetch_assoc())
  2379.         {
  2380.             return $row['amLocation'];
  2381.         }
  2382.     }
  2383. }
  2384.  
  2385. add_filter("gform_field_value_evansAfternoonHours", "eah");
  2386. function eah($value)
  2387. {
  2388.     /* MySQL Server Setup */
  2389.     $servername = "127.0.0.1";
  2390.     $username = "root";
  2391.     $password = "admin4sql!";
  2392.     $databasename = "sent_schedules";
  2393.  
  2394.     /* Create a connection to the server */
  2395.     $conn = new mysqli($servername, $username, $password, $databasename);
  2396.  
  2397.     /* Check Connection */
  2398.     if($conn->connect_error)
  2399.     {
  2400.         die("Connection Failed: " . $conn->connect_error);
  2401.     }
  2402.     $sql = "SELECT * FROM dailyschedule WHERE id=9;";
  2403.     $result = $conn->query($sql);
  2404.     if($result->num_rows > 0)
  2405.     {
  2406.         while($row = $result->fetch_assoc())
  2407.         {
  2408.             return $row['pm'];
  2409.         }
  2410.     }
  2411. }
  2412.  
  2413. add_filter("gform_field_value_evansAfternoonLocation", "eal");
  2414. function eal($value)
  2415. {
  2416.     /* MySQL Server Setup */
  2417.     $servername = "127.0.0.1";
  2418.     $username = "root";
  2419.     $password = "admin4sql!";
  2420.     $databasename = "sent_schedules";
  2421.  
  2422.     /* Create a connection to the server */
  2423.     $conn = new mysqli($servername, $username, $password, $databasename);
  2424.  
  2425.     /* Check Connection */
  2426.     if($conn->connect_error)
  2427.     {
  2428.         die("Connection Failed: " . $conn->connect_error);
  2429.     }
  2430.     $sql = "SELECT * FROM dailyschedule WHERE id=9;";
  2431.     $result = $conn->query($sql);
  2432.     if($result->num_rows > 0)
  2433.     {
  2434.         while($row = $result->fetch_assoc())
  2435.         {
  2436.             return $row['pmLocation'];
  2437.         }
  2438.     }
  2439. }
  2440.  
  2441.  
  2442. add_filter("gform_field_value_lenzMorningHours", "lmh");
  2443. function lmh($value)
  2444. {
  2445.     /* MySQL Server Setup */
  2446.     $servername = "127.0.0.1";
  2447.     $username = "root";
  2448.     $password = "admin4sql!";
  2449.     $databasename = "sent_schedules";
  2450.  
  2451.     /* Create a connection to the server */
  2452.     $conn = new mysqli($servername, $username, $password, $databasename);
  2453.  
  2454.     /* Check Connection */
  2455.     if($conn->connect_error)
  2456.     {
  2457.         die("Connection Failed: " . $conn->connect_error);
  2458.     }
  2459.     $sql = "SELECT * FROM dailyschedule WHERE id=10;";
  2460.     $result = $conn->query($sql);
  2461.     if($result->num_rows > 0)
  2462.     {
  2463.         while($row = $result->fetch_assoc())
  2464.         {
  2465.             return $row['am'];
  2466.         }
  2467.     }
  2468. }
  2469.  
  2470. add_filter("gform_field_value_lenzMorningLocation", "lml");
  2471. function lml($value)
  2472. {
  2473.     /* MySQL Server Setup */
  2474.     $servername = "127.0.0.1";
  2475.     $username = "root";
  2476.     $password = "admin4sql!";
  2477.     $databasename = "sent_schedules";
  2478.  
  2479.     /* Create a connection to the server */
  2480.     $conn = new mysqli($servername, $username, $password, $databasename);
  2481.  
  2482.     /* Check Connection */
  2483.     if($conn->connect_error)
  2484.     {
  2485.         die("Connection Failed: " . $conn->connect_error);
  2486.     }
  2487.     $sql = "SELECT * FROM dailyschedule WHERE id=10;";
  2488.     $result = $conn->query($sql);
  2489.     if($result->num_rows > 0)
  2490.     {
  2491.         while($row = $result->fetch_assoc())
  2492.         {
  2493.             return $row['amLocation'];
  2494.         }
  2495.     }
  2496. }
  2497.  
  2498. add_filter("gform_field_value_lenzAfternoonHours", "lah");
  2499. function lah($value)
  2500. {
  2501.     /* MySQL Server Setup */
  2502.     $servername = "127.0.0.1";
  2503.     $username = "root";
  2504.     $password = "admin4sql!";
  2505.     $databasename = "sent_schedules";
  2506.  
  2507.     /* Create a connection to the server */
  2508.     $conn = new mysqli($servername, $username, $password, $databasename);
  2509.  
  2510.     /* Check Connection */
  2511.     if($conn->connect_error)
  2512.     {
  2513.         die("Connection Failed: " . $conn->connect_error);
  2514.     }
  2515.     $sql = "SELECT * FROM dailyschedule WHERE id=10;";
  2516.     $result = $conn->query($sql);
  2517.     if($result->num_rows > 0)
  2518.     {
  2519.         while($row = $result->fetch_assoc())
  2520.         {
  2521.             return $row['pm'];
  2522.         }
  2523.     }
  2524. }
  2525.  
  2526. add_filter("gform_field_value_lenzAfternoonLocation", "lal");
  2527. function lal($value)
  2528. {
  2529.     /* MySQL Server Setup */
  2530.     $servername = "127.0.0.1";
  2531.     $username = "root";
  2532.     $password = "admin4sql!";
  2533.     $databasename = "sent_schedules";
  2534.  
  2535.     /* Create a connection to the server */
  2536.     $conn = new mysqli($servername, $username, $password, $databasename);
  2537.  
  2538.     /* Check Connection */
  2539.     if($conn->connect_error)
  2540.     {
  2541.         die("Connection Failed: " . $conn->connect_error);
  2542.     }
  2543.     $sql = "SELECT * FROM dailyschedule WHERE id=10;";
  2544.     $result = $conn->query($sql);
  2545.     if($result->num_rows > 0)
  2546.     {
  2547.         while($row = $result->fetch_assoc())
  2548.         {
  2549.             return $row['pmLocation'];
  2550.         }
  2551.     }
  2552. }
  2553.  
  2554. add_filter("gform_field_value_sentcall", "sentcall");
  2555. function sentcall($value)
  2556. {
  2557.     /* MySQL Server Setup */
  2558.     $servername = "127.0.0.1";
  2559.     $username = "root";
  2560.     $password = "admin4sql!";
  2561.     $databasename = "sent_schedules";
  2562.  
  2563.     /* Create a connection to the server */
  2564.     $conn = new mysqli($servername, $username, $password, $databasename);
  2565.  
  2566.     /* Check Connection */
  2567.     if($conn->connect_error)
  2568.     {
  2569.         die("Connection Failed: " . $conn->connect_error);
  2570.     }
  2571.     $sql = "SELECT * FROM dailyschedule WHERE id=11;";
  2572.     $result = $conn->query($sql);
  2573.     if($result->num_rows > 0)
  2574.     {
  2575.         while($row = $result->fetch_assoc())
  2576.         {
  2577.             return $row['amLocation'];
  2578.         }
  2579.     }
  2580. }
  2581.  
  2582. add_filter("gform_field_value_mandocall", "mandocall");
  2583. function mandocall($value)
  2584. {
  2585.     /* MySQL Server Setup */
  2586.     $servername = "127.0.0.1";
  2587.     $username = "root";
  2588.     $password = "admin4sql!";
  2589.     $databasename = "sent_schedules";
  2590.  
  2591.     /* Create a connection to the server */
  2592.     $conn = new mysqli($servername, $username, $password, $databasename);
  2593.  
  2594.     /* Check Connection */
  2595.     if($conn->connect_error)
  2596.     {
  2597.         die("Connection Failed: " . $conn->connect_error);
  2598.     }
  2599.     $sql = "SELECT * FROM dailyschedule WHERE id=12;";
  2600.     $result = $conn->query($sql);
  2601.     if($result->num_rows > 0)
  2602.     {
  2603.         while($row = $result->fetch_assoc())
  2604.         {
  2605.             return $row['amLocation'];
  2606.         }
  2607.     }
  2608. }
  2609.  
  2610. add_filter("gform_field_value_expTriage", "expTriage");
  2611. function expTriage($value)
  2612. {
  2613.     /* MySQL Server Setup */
  2614.     $servername = "127.0.0.1";
  2615.     $username = "root";
  2616.     $password = "admin4sql!";
  2617.     $databasename = "sent_schedules";
  2618.  
  2619.     /* Create a connection to the server */
  2620.     $conn = new mysqli($servername, $username, $password, $databasename);
  2621.  
  2622.     /* Check Connection */
  2623.     if($conn->connect_error)
  2624.     {
  2625.         die("Connection Failed: " . $conn->connect_error);
  2626.     }
  2627.     $sql = "SELECT * FROM dailyschedule WHERE id=13;";
  2628.     $result = $conn->query($sql);
  2629.     if($result->num_rows > 0)
  2630.     {
  2631.         while($row = $result->fetch_assoc())
  2632.         {
  2633.             return $row['pmLocation'];
  2634.         }
  2635.     }
  2636. }
  2637.  
  2638. add_filter("gform_field_value_sckTriageam", "sckTriageam");
  2639. function sckTriageam($value)
  2640. {
  2641.     /* MySQL Server Setup */
  2642.     $servername = "127.0.0.1";
  2643.     $username = "root";
  2644.     $password = "admin4sql!";
  2645.     $databasename = "sent_schedules";
  2646.  
  2647.     /* Create a connection to the server */
  2648.     $conn = new mysqli($servername, $username, $password, $databasename);
  2649.  
  2650.     /* Check Connection */
  2651.     if($conn->connect_error)
  2652.     {
  2653.         die("Connection Failed: " . $conn->connect_error);
  2654.     }
  2655.     $sql = "SELECT * FROM dailyschedule WHERE id=14;";
  2656.     $result = $conn->query($sql);
  2657.     if($result->num_rows > 0)
  2658.     {
  2659.         while($row = $result->fetch_assoc())
  2660.         {
  2661.             return $row['amLocation'];
  2662.         }
  2663.     }
  2664. }
  2665.  
  2666. add_filter("gform_field_value_sckTriagepm", "sckTriagepm");
  2667. function sckTriagepm($value)
  2668. {
  2669.     /* MySQL Server Setup */
  2670.     $servername = "127.0.0.1";
  2671.     $username = "root";
  2672.     $password = "admin4sql!";
  2673.     $databasename = "sent_schedules";
  2674.  
  2675.     /* Create a connection to the server */
  2676.     $conn = new mysqli($servername, $username, $password, $databasename);
  2677.  
  2678.     /* Check Connection */
  2679.     if($conn->connect_error)
  2680.     {
  2681.         die("Connection Failed: " . $conn->connect_error);
  2682.     }
  2683.     $sql = "SELECT * FROM dailyschedule WHERE id=14;";
  2684.     $result = $conn->query($sql);
  2685.     if($result->num_rows > 0)
  2686.     {
  2687.         while($row = $result->fetch_assoc())
  2688.         {
  2689.             return $row['pmLocation'];
  2690.         }
  2691.     }
  2692. }
  2693.  
  2694. /* Send Order Info*/
  2695. add_action('gform_after_submission_61', 'updateDailySchedule', 10, 2);
  2696. function updateDailySchedule($entry, $form)
  2697. {
  2698.     $sentCall = $entry['52'];
  2699.     $mandoCall = $entry['53'];
  2700.     $expTriage = $entry['54'];
  2701.     $sckTriageam = $entry['55'];
  2702.     $sckTriagepm = $entry['56'];
  2703.    
  2704.     $groppoMorningHours = $entry['2'];
  2705.     $groppoMorningLocation = $entry['3'];
  2706.     $groppoAfternoonHours = $entry['4'];
  2707.     $groppoAfternoonLocation = $entry['5'];
  2708.  
  2709.     $bernsteinMorningHours = $entry['7'];
  2710.     $bernsteinMorningLocation = $entry['8'];
  2711.     $bernsteinAfternoonHours = $entry['9'];
  2712.     $bernsteinAfternoonLocation = $entry['10'];
  2713.  
  2714.     $goldfarbMorningHours = $entry['12'];
  2715.     $goldfarbMorningLocation = $entry['13'];
  2716.     $goldfarbAfternoonHours = $entry['14'];
  2717.     $goldfarbAfternoonLocation = $entry['15'];
  2718.  
  2719.     $clutterMorningHours = $entry['17'];
  2720.     $clutterMorningLocation = $entry['18'];
  2721.     $clutterAfternoonHours = $entry['19'];
  2722.     $clutterAfternoonLocation = $entry['20'];
  2723.  
  2724.     $cathMorningHours = $entry['22'];
  2725.     $cathMorningLocation = $entry['23'];
  2726.     $cathAfternoonHours = $entry['24'];
  2727.     $cathAfternoonLocation = $entry['25'];
  2728.  
  2729.     $areenMorningHours = $entry['27'];
  2730.     $areenMorningLocation = $entry['28'];
  2731.     $areenAfternoonHours = $entry['29'];
  2732.     $areenAfternoonLocation = $entry['30'];
  2733.  
  2734.     $traunerMorningHours = $entry['32'];
  2735.     $traunerMorningLocation = $entry['33'];
  2736.     $traunerAfternoonHours = $entry['34'];
  2737.     $traunerAfternoonLocation = $entry['35'];
  2738.  
  2739.     $mckennanMorningHours = $entry['37'];
  2740.     $mckennanMorningLocation = $entry['38'];
  2741.     $mckennanAfternoonHours = $entry['39'];
  2742.     $mckennanAfternoonLocation = $entry['40'];
  2743.  
  2744.     $evansMorningHours = $entry['42'];
  2745.     $evansMorningLocation = $entry['43'];
  2746.     $evansAfternoonHours = $entry['44'];
  2747.     $evansAfternoonLocation = $entry['45'];
  2748.  
  2749.     $lenzMorningHours = $entry['47'];
  2750.     $lenzMorningLocation = $entry['48'];
  2751.     $lenzAfternoonHours = $entry['49'];
  2752.     $lenzAfternoonLocation = $entry['50'];
  2753.    
  2754.    
  2755.     $sqlGrop = "UPDATE dailyschedule SET am='$groppoMorningHours', pm='$groppoAfternoonHours', amLocation='$groppoMorningLocation', pmLocation='$groppoAfternoonLocation' WHERE id=1";
  2756.     $sqlBern = "UPDATE dailyschedule SET am='$bernsteinMorningHours', pm='$bernsteinAfternoonHours', amLocation='$bernsteinMorningLocation', pmLocation='$bernsteinAfternoonLocation' WHERE id=2";
  2757.     $sqlGold = "UPDATE dailyschedule SET am='$goldfarbMorningHours', pm='$goldfarbAfternoonHours', amLocation='$goldfarbMorningLocation', pmLocation='$goldfarbAfternoonLocation' WHERE id=3";
  2758.     $sqlClut = "UPDATE dailyschedule SET am='$clutterMorningHours', pm='$clutterAfternoonHours', amLocation='$clutterMorningLocation', pmLocation='$clutterAfternoonLocation' WHERE id=4";
  2759.     $sqlCath = "UPDATE dailyschedule SET am='$cathMorningHours', pm='$cathAfternoonHours', amLocation='$cathMorningLocation', pmLocation='$cathAfternoonLocation' WHERE id=5";
  2760.     $sqlAreen = "UPDATE dailyschedule SET am='$areenMorningHours', pm='$areenAfternoonHours', amLocation='$areenMorningLocation', pmLocation=' $areenAfternoonLocation' WHERE id=6";
  2761.     $sqlTrau = "UPDATE dailyschedule SET am='$traunerMorningHours', pm='$traunerAfternoonHours', amLocation='$traunerMorningLocation', pmLocation='$traunerAfternoonLocation' WHERE id=7";
  2762.     $sqlMck = "UPDATE dailyschedule SET am='$mckennanMorningHours', pm='$mckennanAfternoonHours', amLocation='$mckennanMorningLocation', pmLocation='$mckennanAfternoonLocation' WHERE id=8";
  2763.     $sqlEvans = "UPDATE dailyschedule SET am='$evansMorningHours', pm='$evansAfternoonHours', amLocation='$evansMorningLocation', pmLocation='$evansAfternoonLocation' WHERE id=9";
  2764.     $sqlLenz = "UPDATE dailyschedule SET am='$lenzMorningHours', pm='$lenzAfternoonHours', amLocation='$lenzMorningLocation', pmLocation='$lenzAfternoonLocation' WHERE id=10";
  2765.    
  2766.     $sqlSENT = "UPDATE dailyschedule SET amLocation='$sentCall' WHERE id=11";
  2767.     $sqlMando = "UPDATE dailyschedule SET amLocation='$mandoCall' WHERE id=12";
  2768.     $sqlExpo = "UPDATE dailyschedule SET amLocation='$expTriage' WHERE id=13";
  2769.     $sqlSck = "UPDATE dailyschedule SET amLocation='$sckTriageam', pmLocation='$sckTriagepm' WHERE id=14";
  2770.    
  2771.     /* MySQL Server Setup */
  2772.     $servername = "127.0.0.1";
  2773.     $username = "root";
  2774.     $password = "admin4sql!";
  2775.     $databasename = "sent_schedules";
  2776.  
  2777.     /* Create a connection to the server */
  2778.     $conn = new mysqli($servername, $username, $password, $databasename);
  2779.  
  2780.     /* Check Connection */
  2781.     if($conn->connect_error)
  2782.     {
  2783.         die("Connection Failed: " . $conn->connect_error);
  2784.     }
  2785.    
  2786.     $result = $conn->query($sqlGrop);
  2787.     $result = $conn->query($sqlBern);
  2788.     $result = $conn->query($sqlGold);
  2789.     $result = $conn->query($sqlClut);
  2790.     $result = $conn->query($sqlCath);
  2791.     $result = $conn->query($sqlAreen);
  2792.     $result = $conn->query($sqlTrau);
  2793.     $result = $conn->query($sqlMck);
  2794.     $result = $conn->query($sqlEvans);
  2795.     $result = $conn->query($sqlLenz);
  2796.    
  2797.     $result = $conn->query($sqlSENT);
  2798.     $result = $conn->query($sqlMando);
  2799.     $result = $conn->query($sqlExpo);
  2800.     $result = $conn->query($sqlSck);
  2801. }
  2802.  
  2803. add_filter( 'gform_pre_render_62', 'populateEmployees' );
  2804. add_filter( 'gform_pre_validation_62', 'populateEmployees' );
  2805. add_filter( 'gform_pre_submission_filter_62', 'populateEmployees' );
  2806. add_filter( 'gform_admin_pre_render_62', 'populateEmployees' );
  2807. function populateEmployees($form)
  2808. {
  2809.  
  2810.     foreach ($form['fields'] as &$field)
  2811.     {
  2812.         if ($field->id == 1)
  2813.         {
  2814.             /* MySQL Server Setup */
  2815.             $servername = "127.0.0.1";
  2816.             $username = "root";
  2817.             $password = "admin4sql!";
  2818.             $databasename = "employee_database";
  2819.  
  2820.             /* Create a connection to the server */
  2821.             $conn = new mysqli($servername, $username, $password, $databasename);
  2822.  
  2823.             /* Check Connection */
  2824.             if($conn->connect_error)
  2825.             {
  2826.                 die("Connection Failed: " . $conn->connect_error);
  2827.             }
  2828.            
  2829.             $sql = "SELECT CONCAT(firstName, ' ', lastName) AS fullname FROM employees WHERE isdisabled=0 ORDER BY fullname ASC;";
  2830.             $result = $conn->query($sql);
  2831.             $choices = array();
  2832.             if($result->num_rows > 0)
  2833.             {
  2834.                 while($row = $result->fetch_assoc())
  2835.                 {
  2836.                     $choices[] = array('text' => $row['fullname'], 'value' => $row['id']);
  2837.                 }
  2838.             }
  2839.             $field->placeholder = 'Select an Employee';
  2840.             $field->choices = $choices;
  2841.         }
  2842.     }
  2843.  
  2844.     return $form;
  2845. }
  2846.  
  2847. add_action('gform_after_submission_62', 'updateOutLate', 10, 2);
  2848. function updateOutLate($entry, $form)
  2849. {
  2850.     /* MySQL Server Setup */
  2851.     $servername = "127.0.0.1";
  2852.     $username = "root";
  2853.     $password = "admin4sql!";
  2854.     $databasename = "sent_schedules";
  2855.  
  2856.     /* Create a connection to the server */
  2857.     $conn = new mysqli($servername, $username, $password, $databasename);
  2858.    
  2859.     $emp = $entry['1'];
  2860.     $status = $entry['2'];
  2861.     $loc = $entry['3'];
  2862.    
  2863.     if(strcasecmp($status, 'Off-Site') == 0 || strcasecmp($status, 'Triage') == 0)
  2864.     {
  2865.         $sql = "INSERT INTO outlate (name, status, location) VALUES ('$emp', '$status', '$loc');";
  2866.     }
  2867.     else
  2868.     {
  2869.         $sql = "INSERT INTO outlate (name, status) VALUES ('$emp', '$status');";
  2870.     }
  2871.     $result = $conn->query($sql);
  2872. }
  2873.  
  2874. /* Finish*/
  2875.  
  2876. add_filter("gform_field_value_order_number", "getOrderNum");
  2877. function getOrderNum($value)
  2878. {
  2879.     /* MySQL Server Setup */
  2880.     $servername = "127.0.0.1";
  2881.     $username = "root";
  2882.     $password = "admin4sql!";
  2883.     $databasename = "sent_purchaseorders";
  2884.  
  2885.     /* Create a connection to the server */
  2886.     $conn = new mysqli($servername, $username, $password, $databasename);
  2887.  
  2888.     /* Check Connection */
  2889.     if($conn->connect_error)
  2890.     {
  2891.         die("Connection Failed: " . $conn->connect_error);
  2892.     }
  2893.    
  2894.     //$sql = "SELECT orderID FROM orders ORDER BY orderID DESC LIMIT 1;";
  2895.     $sql = "SELECT `AUTO_INCREMENT` FROM  INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'sent_purchaseorders' AND TABLE_NAME = 'orders'";
  2896.     $result = $conn->query($sql);
  2897.     if($result->num_rows > 0)
  2898.     {
  2899.         while($row = $result->fetch_assoc())
  2900.         {
  2901.             return $row['AUTO_INCREMENT'];
  2902.         }
  2903.     }
  2904.     else
  2905.     {
  2906.         return 1;
  2907.     }
  2908. }
  2909.  
  2910. /* Change values of field on Entry Form */
  2911. add_filter( 'gform_entry_field_value', 'category_names', 10, 4 );
  2912. function category_names($value, $field, $lead, $form)
  2913. {
  2914.     if($form['id'] == 52)
  2915.     {  
  2916.         if($field->id == 5) // Vendor Field
  2917.         {
  2918.             if($value != 3)
  2919.             {
  2920.                 /* MySQL Server Setup */
  2921.                 $servername = "127.0.0.1";
  2922.                 $username = "root";
  2923.                 $password = "admin4sql!";
  2924.                 $databasename = "sent_purchaseorders";
  2925.                
  2926.                 /* Create a connection to the server */
  2927.                 $conn = new mysqli($servername, $username, $password, $databasename);
  2928.  
  2929.                 /* Check Connection */
  2930.                 if($conn->connect_error)
  2931.                 {
  2932.                     die("Connection Failed: " . $conn->connect_error);
  2933.                 }
  2934.  
  2935.                 $sqlField = "SELECT name FROM vendors WHERE id='$value';";
  2936.                 $result = $conn->query($sqlField);
  2937.                 if($result->num_rows > 0)
  2938.                 {
  2939.                     while($row = $result->fetch_assoc())
  2940.                     {
  2941.                         $newValue = $row['name'];
  2942.                     }
  2943.                 }
  2944.                
  2945.                 return $newValue;
  2946.             }
  2947.            
  2948.             $newValue = 'Other';
  2949.             return $newValue;
  2950.         }
  2951.         elseif($field->id == 8) // Location Field
  2952.         {
  2953.             $locations = array(
  2954.                     1 => "Expo",
  2955.                     2 => "Fair Oaks ENT",
  2956.                     3 => "Fair Oaks Allergy",
  2957.                     4 => "Folsom ENT",
  2958.                     5 => "Folsom Allergy",
  2959.                     6 => "Jackson",
  2960.                     7 => "Lodi",
  2961.                     8 => "Roseville ENT",
  2962.                     9 => "Roseville Allergy",
  2963.                     10 => "Stockton",
  2964.                     11 => "Tracy");
  2965.                    
  2966.             $newValue = $locations[$value];
  2967.            
  2968.             return $newValue;
  2969.         }
  2970.     }
  2971.     return $value;
  2972. }
  2973.  
  2974. add_filter( 'wp_get_nav_menu_items', 'custom_nav_menu_items', 20, 2 );
  2975. function custom_nav_menu_items($items, $menu)
  2976. {
  2977.     // only add item to a specific menu
  2978.     $curUser = wp_get_current_user();
  2979.    
  2980.     if ($menu->slug == 'links')
  2981.     {      
  2982.         if($curUser->user_login == 'btempleton' || $curUser->user_login == 'devans' || $curUser->user_login == 'egroppo' || $curUser->user_login == 'cgroves' || $curUser->user_login == 'jdudley' || $curUser->user_login == 'kxm' || $curUser->user_login == 'mcardenas' || $curUser->user_login == 'pghafari' || $curUser->user_login == 'palfaro' || $curUser->user_login == 'rareen' || $curUser->user_login == 'ksurrit' || $curUser->user_login == 'valentina' || $curUser->user_login == 'amcpeters' || $curUser->user_login == 'dclutter' || $curUser->user_login == 'aeppler' || $curUser->user_login == 'jgandy' || $curUser->user_login == 'sclark' || $curUser->user_login == 'cbrown' || $curUser->user_login == 'nortegon' || $curUser->user_login == 'salmond' || $curUser->user_login == 'dfountain')
  2983.         {
  2984.             $top = _custom_nav_menu_item( 'PO Requests', '#', 10 );
  2985.             $items[] = $top;
  2986.             $items[] = _custom_nav_menu_item('Office Supllies',  'http://intranet/human-resources/forms/office-supply-orders/', 11, $top->ID);
  2987.             //$items[] = _custom_nav_menu_item('Medical Supplies',  'http://intranet/human-resources/forms/office-supply-orders/', 12, $top->ID);
  2988.         }
  2989.        
  2990.         if(current_user_can('gravityforms_edit_entry_notes'))//Only Admin's + Supervisors have access
  2991.         {
  2992.             $top = _custom_nav_menu_item( 'Coordinators', '#', 12 );
  2993.            
  2994.             if($curUser->user_login == 'btempleton' || $curUser->user_login == 'cgroves' || $curUser->user_login == 'jdudley' || $curUser->user_login == 'pghafari' || $curUser->user_login == 'palfaro' || $curUser->user_login == 'obonard' || $curUser->user_login == 'dfountain' || $curUser->user_login == 'asperling')
  2995.             {
  2996.                 $items[] = $top;$items[] = _custom_nav_menu_item('Employee Database', 'http://intranet/employeedb/', 13, $top->ID);
  2997.             }
  2998.            
  2999.             $items[] = $top;$items[] = _custom_nav_menu_item('Update Employee Status', 'http://intranet/human-resources/employee-status-update/', 14, $top->ID);
  3000.         }
  3001.     }
  3002.    
  3003.    
  3004.     if ($menu->slug == 'main')
  3005.     {
  3006.         $top = _custom_nav_menu_item('Schedules', '#', 43);
  3007.         $items[] = $top;
  3008.         $items[] = _custom_nav_menu_item('Out/Late List', 'http://intranet/out-late/', 44, $top->ID);
  3009.         $items[] = _custom_nav_menu_item('Daily Schedule', 'http://intranet/daily-doctor-schedule/', 45, $top->ID);
  3010.        
  3011.         if(current_user_can('gravityforms_edit_entry_notes'))//Only Admin's + Supervisors have access
  3012.         {
  3013.             $items[] = _custom_nav_menu_item('Update Out/Late', 'http://intranet/out-late-form/', 46, $top->ID);
  3014.             $items[] = _custom_nav_menu_item('Update Daily Schedule', 'http://intranet/departments/medical-assistant/daily-schedule-form/', 47, $top->ID);
  3015.         }
  3016.     }
  3017.  
  3018.     return $items;
  3019. }
  3020.  
  3021. /**
  3022.  * Simple helper function for make menu item objects
  3023.  *
  3024.  * @param $title      - menu item title
  3025.  * @param $url        - menu item url
  3026.  * @param $order      - where the item should appear in the menu
  3027.  * @param int $parent - the item's parent item
  3028.  * @return \stdClass
  3029.  */
  3030. function _custom_nav_menu_item( $title, $url, $order, $parent = 0 ){
  3031.   $item = new stdClass();
  3032.   $item->ID = 1000000 + $order + parent;
  3033.   $item->db_id = $item->ID;
  3034.   $item->title = $title;
  3035.   $item->url = $url;
  3036.   $item->menu_order = $order;
  3037.   $item->menu_item_parent = $parent;
  3038.   $item->type = '';
  3039.   $item->object = '';
  3040.   $item->object_id = '';
  3041.   $item->classes = array();
  3042.   $item->target = '';
  3043.   $item->attr_title = '';
  3044.   $item->description = '';
  3045.   $item->xfn = '';
  3046.   $item->status = '';
  3047.   return $item;
  3048. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement