Guest User

Untitled

a guest
Jun 18th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.40 KB | None | 0 0
  1. <?php
  2.  
  3. /* Template Name: Careers form */
  4. ob_start();
  5.  
  6. get_header();
  7.  
  8. get_template_part( 'page-templates/vacancy-filter');
  9.  
  10. if ( have_posts() ) : while ( have_posts() ) : the_post();
  11.  
  12. // $_GET['v'] vervanger voor url rewrite
  13. $real_publication_id = $wp_query->query_vars['v'];
  14.  
  15. $result = overviewdetail($real_publication_id); // selectie van boven.
  16.  
  17. $publication_id = $vacancys = $result["CRPublication"];
  18. $vacancy_id = $vacancys["toVacancy"]["CRVacancy"]["@attributes"]["id"];
  19.  
  20. $i = 0;
  21.  
  22. $checked_male = '';
  23. $checked_woman = '';
  24.  
  25. ?>
  26.  
  27. <section class="content container vervolg">
  28.  
  29. <?
  30. // Check if Vacancy exists
  31. if($vacancys["@attributes"]["id"] == $real_publication_id): ?>
  32.  
  33.  
  34. <h1 class="h2"><?php echo($vacancys["titleInformation"])?></h1>
  35. <noscript>
  36. This content is not available for non-javascript browsers. Please enable JavaScript in you browser.<br><br>
  37. </noscript>
  38. <div class="row">
  39.  
  40. <div class="col-sm-8" id="formdiv" style="display:none">
  41.  
  42. <?php if($_SERVER["REQUEST_METHOD"] == "POST") {
  43.  
  44. if(isset($_FILES)) {
  45.  
  46. for($i=0; $i<count($_FILES['upload']['name']); $i++) {
  47.  
  48. /* switch ($i) {
  49. case 0:
  50. $file = 'CV';
  51. break;
  52. case 1:
  53. $file = 'Photo';
  54. break;
  55. case 2:
  56. $file = 'Additional File';
  57. break;
  58. default:
  59. $file = '';
  60. break;
  61. }
  62. */
  63.  
  64. //$allowed_ext= array('doc','pdf','docx','zip','rtf');
  65. $tmpFilePath = $_FILES['upload']['tmp_name'][$i];
  66. //$file_name = $_FILES['upload']["name"][$i];
  67. $file_tmp = explode(".", $_FILES['upload']["name"][$i]);
  68. //$file_ext = strtolower( end(explode('.',$file_name)));
  69. //$file_size=$_FILES['upload']['size'][$i];
  70. $newFilePath = $_SERVER['DOCUMENT_ROOT'] . '/user_tmp/';
  71.  
  72. $errors=array();
  73.  
  74. /* if(!$_FILES['upload']["name"][$i]) {
  75. $errors[] = $file . ' is required. <br>';
  76.  
  77. }else {
  78. if(in_array($file_ext,$allowed_ext) === false)
  79. {
  80. $errors[] = $file . ': File extension not allowed. Please try docx, doc or PDF';
  81. }
  82. if($file_size > 2334344)
  83. {
  84. $errors[] = 'File size must be under 2mb<br>';
  85. }
  86. } */
  87.  
  88. //print_r($errors);
  89. if (!empty($errors)) {
  90.  
  91. foreach($errors as $error) {
  92. echo '<li class="errors">' . $error , '</li>';
  93. }
  94.  
  95. } else {
  96.  
  97. if ($tmpFilePath != ""){
  98.  
  99. if(
  100. $_POST['firstName'] &&
  101. $_POST['lastName']) {
  102. if($i == 0) {
  103. $newfilename[$i] = getUrlFriendlyString($vacancys["titleInformation"]).'-'.$_POST['firstName'].'-'.$_POST['lastName'].'-cv.' . end($file_tmp);
  104. } elseif($i == 1) {
  105. $newfilename[$i] = getUrlFriendlyString($vacancys["titleInformation"]).'-'.$_POST['firstName'].'-'.$_POST['lastName'].'-motivation.' . end($file_tmp);
  106. } elseif($i == 2) {
  107. $newfilename[$i] = getUrlFriendlyString($vacancys["titleInformation"]).'-'.$_POST['firstName'].'-'.$_POST['lastName'].'-foto.' . end($file_tmp);
  108. }
  109. } else {
  110. $newfilename[$i] = $_FILES['upload']["name"][$i];
  111. }
  112.  
  113. $fileContents[$i] = file_get_contents($tmpFilePath);
  114. $fileContents[$i] = base64_encode($fileContents[$i]);
  115.  
  116. //move_uploaded_file($tmpFilePath, $newFilePath.$newfilename[$i]);
  117.  
  118. $_SESSION['firstName'] = $_POST['firstName'];
  119. $_SESSION['gender'] = $_POST['gender'];
  120.  
  121. if(isset($_SESSION['gender'])) { if($_SESSION['gender'] == '2541') { $checked_male = 'checked="checked"'; } else { $checked_woman = 'checked="checked"'; } }
  122.  
  123. // Setup variables for post Array
  124. $p_Cv = $newfilename[0];
  125. $p_Photo = $newfilename[1];
  126. $p_AdditionalFile = $newfilename[2];
  127. $p_Cv_FileContents = $fileContents[0];
  128. $p_Photo_FileContents = $fileContents[1];
  129. $p_AdditionalFile_FileContents = $fileContents[2];
  130. $p_Vacancy = getUrlFriendlyString($vacancys["titleInformation"]);
  131.  
  132.  
  133. }
  134. } // END ERROR CHECK
  135. } // END FOREACH
  136.  
  137. $postArray = array(
  138. 'toGenderNode' => $_POST['gender'],
  139. 'firstName' => $_POST['firstName'],
  140. 'lastName' => $_POST['lastName'],
  141. 'lastNamePrefix' => $_POST['lastNamePrefix'],
  142. 'initials' => $_POST['initials'],
  143. 'suffix' => $_POST['suffix'],
  144. 'title' => $_POST['title'],
  145. 'birthDate' => $_POST['birthDate']. ' 00:00:00',
  146. 'fullAddress' => $_POST['fullAddress'],
  147. 'homeNumber' => $_POST['homeNumber'],
  148. 'homeNumberSuffix' => $_POST['homeNumberSuffix'],
  149. 'homePostalCode' => $_POST['homePostalCode'],
  150. 'homeCity' => $_POST['homeCity'],
  151. 'emailAddress' => $_POST['emailAddress'],
  152. 'phoneNumber' => $_POST['phoneNumber'],
  153. 'phoneNumberBusiness' => $_POST['phoneNumberBusiness'],
  154. 'motivation' => $_POST['motivation'],
  155. 'toCountryNode' => $_POST['country'],
  156. 'toSourceNode' => $_POST['source'],
  157. 'Nationality' => $_POST['country'],
  158. 'privacy' => $_POST['privacy'],
  159. '70_file' => $p_Cv,
  160. '4429_file' => $p_AdditionalFile,
  161. '9006_file' => $p_Photo,
  162. '70_contents' => $p_Cv_FileContents,
  163. '4429_contents' => $p_AdditionalFile_FileContents,
  164. '9006_contents' => $p_Photo_FileContents,
  165. 'vacancy_id' => $vacancy_id,
  166. 'publication_id'=> $real_publication_id
  167. );
  168.  
  169. //print_r($postArray);
  170. // Function to Load data into the Api Function
  171. $result = emailvancansy($postArray);
  172.  
  173. // echo '<pre>';
  174. // print_r($postArray);
  175. // echo '</pre>';
  176.  
  177. // $wpdb->insert( 'alls_privacy_requests', array
  178. // (
  179. // 'p_content' => $_POST['privacy'],
  180. // 'p_email' => $_POST['emailAddress'],
  181. // 'p_name' => $_POST['lastName']
  182. // ),
  183. // array( '%s','%s' ) );
  184.  
  185.  
  186. $body = json_decode($result['body']);
  187. if (isset($body->errors) && $body->errors == true) {
  188. $msg = '<div class="errorwrapper bottommarge">Your request is already in our system. <a href="mailto:recruitment@allseas.com">Please contact us</a> for further information.</div>';
  189. } else {
  190. $msg = '<div class="succeswrapper bottommarge">We have received your application for this vacancy. Our Recruitment Department is currently reviewing applications. Please contact us for further information.</div><script type="text/javascript">
  191. ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
  192. p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
  193. };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
  194. n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d6unz3nsyh8vw.cloudfront.net/3SFv8DuWrRsddehY9xMi45LjA.js","snowplow"));
  195.  
  196. window.snowplow(\'newTracker\', \'co\', "com-vonq-main.collector.snplow.net", {
  197. platform: \'web\',
  198. post: true,
  199. contexts: {
  200. webPage: true,
  201. performanceTiming: true
  202. }
  203. });
  204.  
  205. window.snowplow(\'trackSelfDescribingEvent\', {
  206. schema: \'iglu:com.vonq/step_view/jsonschema/1-2-0\',
  207. data: {
  208. label : "application-success",
  209. // Set this field to a unique id or hash that identifies the job in customer\'s system.
  210. // Required for websites that don\'t have a uniquely identifying absoulte job URL to match with a campaign
  211. customerReferenceId: "",
  212. entity : "ac8ad763-fd70-43b6-b337-eb3474c8a2e7"
  213. }
  214. });
  215.  
  216.  
  217. window.snowplow(\'trackSelfDescribingEvent\',{schema:\'iglu:com.vonq/applicant_conversion/jsonschema/1-0-0\',data:{label:"application-success"}});
  218. window.snowplow(\'enableActivityTracking\',10,10);
  219. window.snowplow(\'trackPageView\');
  220. </script>';
  221. }
  222. //print_r($postArray);
  223.  
  224. if(empty($errors)){echo $msg;}
  225.  
  226. } // END FILES
  227.  
  228. } // END POST
  229. else{?>
  230. <script type="text/javascript">
  231. ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
  232. p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
  233. };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
  234. n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//d6unz3nsyh8vw.cloudfront.net/3SFv8DuWrRsddehY9xMi45LjA.js","snowplow"));
  235.  
  236. window.snowplow('newTracker', 'co', "com-vonq-main.collector.snplow.net", {
  237. platform: 'web',
  238. post: true,
  239. contexts: {
  240. webPage: true,
  241. performanceTiming: true
  242. }
  243. });
  244.  
  245. window.snowplow('trackSelfDescribingEvent', {
  246. schema: 'iglu:com.vonq/step_view/jsonschema/1-2-0',
  247. data: {
  248. label : "application-form",
  249. // Set this field to a unique id or hash that identifies the job in customer's system.
  250. // Required for websites that don't have a uniquely identifying absoulte job URL to match with a campaign
  251. customerReferenceId: "",
  252. entity : "ac8ad763-fd70-43b6-b337-eb3474c8a2e7"
  253. }
  254. });
  255.  
  256. (function () {
  257. var vqParam=(location.search.split('_vq=')[1]||'').split('&')[0];
  258. if (vqParam.length) {
  259. try {
  260. var vqString = window.atob(vqParam);
  261. var vqObj = JSON.parse(vqString);
  262. window.snowplow('trackSelfDescribingEvent', {
  263. schema: 'iglu:com.vonq/cta/jsonschema/1-0-1',
  264. data: vqObj
  265. });
  266. } catch (e) {/* Do nothing, invalid input */ };
  267. }
  268. }());
  269.  
  270. window.snowplow('enableActivityTracking',10,10);
  271. window.snowplow('trackPageView');
  272.  
  273. </script>
  274. <?php }
  275.  
  276. ?>
  277. <div class="error_box"></div>
  278. <?php require('Browser.php');
  279.  
  280. $browser = new Browser;
  281.  
  282. //if($browser->getBrowser() == 'Chrome'):
  283.  
  284. // if($_SERVER['REMOTE_ADDR'] != '92.66.166.46') {
  285. // echo 'The form is temporarily not available. Please use the emailadress: recruitment@allseas.com';
  286.  
  287. // } else {
  288.  
  289. ?>
  290. <form class="resume" name="applyform" method="POST" action="" enctype="multipart/form-data" >
  291. <script>
  292.  
  293. /*jQuery(document).ready(function(){
  294. function truncate(n, len) {
  295. var ext = n.substring(n.lastIndexOf(".") + 1, n.length).toLowerCase();
  296. var filename = n.replace('.' + ext,'');
  297. if(filename.length <= len) {
  298. return n;
  299. }
  300. filename = filename.substr(0, len) + (n.length > len ? '[...]' : '');
  301. return filename + '.' + ext;
  302. };
  303.  
  304. $("[type=file]").on("change", function(){
  305. var file = this.files[0].name;
  306. file = truncate(file, 10)
  307. var dflt = $(this).attr("placeholder");
  308. if($(this).val()!=""){
  309. $(this).next().text(file);
  310. } else {
  311. $(this).next().text(dflt);
  312. }
  313. });
  314. });
  315. */
  316. </script>
  317. <script>
  318. $(function() {
  319. $( "#datepicker" ).datepicker({changeMonth: true,changeYear: true, yearRange: "-100:+0"});
  320. });
  321. </script>
  322. <div class="radiowrap">
  323. <input type="radio" name="gender" value='2541' id="male" <?php echo $checked_male ?> required><label for="male">Male</label>
  324. <input type="radio" name="gender" value='2542' id="female" <?php echo $checked_woman ?> required><label for="female">Female</label>
  325. </div>
  326. <input type="hidden" name="vacancy_id" value="<?php echo $vacancy_id ?>" />
  327. <input type="hidden" name="publication_id" value="<?php echo $real_publication_id ?>" />
  328. <input type="text" name='firstName' required value='' placeholder="First name *">
  329. <input type="text" name='lastName' required value='' placeholder="Last name *">
  330. <input type="text" name='birthDate' value='' placeholder="Date of birth" id="datepicker" >
  331. <span class="select-icon half" style="margin-right: 0">
  332. <select name="Nationality" required>
  333. <option disabled selected style="display:none;" value="">Nationality *</option>
  334. <option value="">-- select one --</option>
  335. <?php echo getNationalities(); ?>
  336. </select>
  337. </span>
  338. <input type="email" name='emailAddress' required value='' placeholder="Email address *" >
  339. <input type="tel" name='phoneNumber' value=''required placeholder="Phone number *" >
  340.  
  341. <div class="filewrap">
  342. <span>Resume (CV) *</span> <input name='upload[]' accept=".doc, .docx, .pdf" required type="file" id="resume" placeholder="Select file" class="bestandje">
  343. <span id="file_error"></span>
  344. </div>
  345. <div class="filewrap">
  346. <span>Motivation *</span> <input name='upload[]' type="file" id="addfile" required placeholder="Select file">
  347. <span id="addfile_error"></span>
  348. </div>
  349.  
  350. <div class="filewrap">
  351. <span>Photo</span> <input name='upload[]' accept="image/*" type="file" id="photo" placeholder="Select file">
  352. <span id="photo_error"></span>
  353. </div>
  354. <span class="select-icon">
  355. <select name="source" id="">
  356. <option disabled selected style="display: none"; value="">How did you hear about this vacancy?</option>
  357. <?php echo getSources(); ?>
  358. </select>
  359. </span>
  360. <!-- <input type="hidden" name="vacancy_id" value="<?php echo $vacancy_id ?>" />
  361. <input type="hidden" name="publication_id" value="<?php echo $real_publication_id ?>" />
  362. <input type="text" name='title' value='' placeholder="Title">
  363. <input type="text" name='initials' value='' placeholder="Initials">
  364. <input type="text" name='suffix' value='' placeholder="Suffix">
  365. <input type="text" name='lastName' required value='' placeholder="Last name *">
  366. <input type="text" name='firstName' required value='' placeholder="First name *">
  367. <input type="text" name='lastNamePrefix' value='' placeholder="Last name prefix">
  368. <input type="text" name='birthDate' required value='' placeholder="Date of birth *" id="datepicker" >
  369. <input type="text" name='fullAddress' required value='' placeholder="Full address *">
  370. <input type="text" name='homeNumber' required value='' placeholder="Home number *" >
  371. <input type="text" name='homeNumberSuffix' value='' placeholder="Home number suffix">
  372. <input type="text" name='homePostalCode' required value='' placeholder="Zip code *" >
  373. <input type="text" name='homeCity' required value='' placeholder="City *">
  374. <input type="email" name='emailAddress' required value='' placeholder="Email address *" >
  375. <input type="tel" name='phoneNumber' value=''required placeholder="Phone number private *" >
  376. <input type="tel" name='phoneNumberBusiness' value='' placeholder="Phone number work">
  377. <textarea name='motivation' required placeholder="Motivation *"></textarea>
  378.  
  379. <span class="select-icon">
  380. <select name="country" required>
  381. <option disabled selected style="display:none;" value="">Select country *</option>
  382. <?php echo getCountries(); ?>
  383. </select>
  384. </span>
  385. <span class="select-icon">
  386. <select name="Nationality" required>
  387. <option disabled selected style="display:none;" value="">Nationality *</option>
  388. <option value="">-- select one --</option>
  389. <?php echo getNationalities(); ?>
  390. </select>
  391. </span>
  392. <div class="filewrap">
  393. <span>Resume (CV) *</span> <input name='upload[]' accept=".doc, .docx, .pdf" required type="file" id="resume" placeholder="Select file" class="bestandje">
  394. <span id="file_error"></span>
  395. </div>
  396. <div class="filewrap">
  397. <span>Photo</span> <input name='upload[]' accept="image/*" type="file" id="photo" placeholder="Select file">
  398. <label for="resume">Select file</label><span id="photo_error"></span>
  399. </div>
  400. <div class="filewrap">
  401. <span>Additional file</span> <input name='upload[]' type="file" id="addfile" placeholder="Select file">
  402. <label for="resume">Select file</label><span id="addfile_error"></span>
  403. </div> -->
  404. <div class="radiowrap">
  405. <p> By clicking β€œyes”, you consent to Allseas storing your personal data for up to one year after the end of the application procedure,
  406. in order for us to consider whether your profile matches other job opportunities within Allseas.<br><br>
  407. By clicking β€œno”, your personal data will be deleted within four weeks after the conclusion of the application procedure.
  408. For further information, please read our <a href="<?php echo site_url();?>/privacy" target="_blank">Privacy Policy</a></p>
  409.  
  410. <input type="radio" name="privacy" value='yes' id="yes" required><label for="yes">Yes</label>
  411. <input type="radio" name="privacy" value='no' id="no" required><label for="no">No</label>
  412.  
  413. <button type="submit" class="button red">Send application</button>
  414.  
  415. <p style="clear:both;">In our <a target="_blank" href="https://allseas.com/applying-for-a-job-at-allseas/">application procedure</a>, you can read what to expect when you apply for a job at Allseas.</p>
  416.  
  417. </div>
  418.  
  419. </form>
  420. <?php //}
  421.  
  422. //else: ?>
  423. <!-- <div class="error_box_browser">The form is currently not available in your browser. Please use Google Chrome to apply for this vacancy.</div> -->
  424. <?php //endif; ?>
  425. </div>
  426. <div class="col-sm-4">
  427. <div class="shadow">
  428. <table class="vacancydetail">
  429. <tr>
  430. <td width="40%">Field:</td>
  431. <td><?php echo($vacancys["toVacancy"]["CRVacancy"]["toProductTypeNode"]["CRDataNode"]["value"])?></td>
  432. </tr>
  433. <tr>
  434. <td>Discipline:</td>
  435. <td><?php echo($vacancys["toVacancy"]["CRVacancy"]["toCompany"]["CRCompany"]["name"])?></td>
  436.  
  437. </tr>
  438. <tr>
  439. <td>Location:</td>
  440. <td><?php echo($vacancys["workLocation"])?></td>
  441. </tr>
  442. <tr>
  443. <td>Workweek:</td>
  444. <td><?php echo($vacancys["toVacancy"]["CRVacancy"]["hoursPerWeek"])?> hours</td>
  445. </tr>
  446. </table>
  447.  
  448. <i>Or call us at <a href="tel:+31 15 2681800">+31 15 2681800</a></i>
  449. <div class="linkwrap">
  450.  
  451. <a href="//www.linkedin.com/shareArticle?mini=true&amp;url=<?php echo site_url() ?>/vacancy/<?php echo $real_publication_id; ?>&amp;title=<?php echo($vacancys["titleInformation"])?>" onclick="window.open('http://www.linkedin.com/shareArticle?mini=true&amp;url=<?php echo site_url() ?>/vacancy/<?php echo $real_publication_id; ?>&amp;title=<?php echo($vacancys["titleInformation"])?>','LinkedIn', 'width=600,height=475,scrollbars=no,toolbar=no,location=no'); return false" alt="LinkedIn" class="symbol linkedin">
  452. <img src="<?php echo get_template_directory_uri()?>/images/icon-linkedin.png" alt="LinkedIn">
  453. </a>
  454. <a href="mailto:<[emailaddress]>?subject=Allseas Vacancy: <?php echo($vacancys["titleInformation"])?>&body=Hi, I found this vacancy and thought you might like it: <?php echo site_url() ?>/vacancy/<?php echo $real_publication_id; ?>"><img src="<?php echo get_template_directory_uri()?>/images/icon-mail.png" alt="E-mail"></a>
  455. </div>
  456. </div>
  457. </div>
  458. <? else: ?>
  459. <h1 class="h2">This vacancy does not exists</h1>
  460. <div class="row">
  461. <div class="col-sm-12 bottommarge">
  462. Please use the red filter to find vacancies.
  463. </div>
  464. </row>
  465. <? endif; ?>
  466. </div>
  467. </section>
  468.  
  469. <script>
  470.  
  471. document.getElementById("formdiv").style.display = "block";
  472.  
  473. $(".resume").validate({
  474. invalidHandler: function(event, validator) {
  475. var errors = validator.numberOfInvalids();
  476. if (errors) {
  477. $(".error_box").show();
  478. }else{
  479. $(".error_box").hide();
  480. }
  481. },
  482. errorLabelContainer: $(".error_box"),
  483. rules: {
  484. homeNumber: {
  485. required: true,
  486. number: true,
  487. maxlength: 9
  488. },
  489. homeNumberSuffix: {
  490. required: false,
  491. maxlength: 9
  492. }
  493. },
  494. messages: {
  495. required: "test",
  496. gender: "Please select your gender.",
  497. lastName: "Please fill in your last name.",
  498. firstName: "Please fill in your first name.",
  499. birthDate: "Please fill in your date of birth.",
  500. fullAddress: "Please fill in your full address.",
  501. homeNumber: {required:"Please fill in your home number.",number:"Your House Number contains only numbers",maxlength:"Your House Number must contain not more than 9 characters."},
  502. homeNumberSuffix: {required:"Please fill in your home number.",maxlength:"Your House Number must contain not more than 9 characters."},
  503. homePostalCode: "Please fill in your zip code.",
  504. homeCity: "Please fill in your city.",
  505. emailAddress: {
  506. required: "Please fill in your email address.",
  507. email: "Please fill in a valid email address."
  508. },
  509. phoneNumber: {
  510. required: "Please fill in your work phone number.",
  511. tel: "Please fill in a valid work phone number."
  512. },
  513. motivation: "Please fill in your motivation.",
  514. country: "Please select your country.",
  515. Nationality: "Please select your nationality.",
  516. 'upload[]': "Please upload your resume."
  517. }
  518. });
  519.  
  520. /*$("input[type='file']").each(function(){
  521. $(this).rules("add", {
  522. required:true,
  523. filesize: 33,
  524. accept: "png|jpe?g|gif",
  525. messages: {
  526. filesize: "Only jpeg, jpg or png images",
  527. accept: "Only jpeg, jpg or png images"
  528. }
  529. });
  530. });*/
  531.  
  532.  
  533. $('#resume').bind('change', function () {
  534. document.getElementById('file_error').innerHTML = '';
  535. var ext = $(this).val().split('.').pop().toLowerCase();
  536. if($.inArray(ext, ['doc','docx','pdf']) == -1 || this.files[0].size>2334344) {
  537. if(this.files[0].size>2334344){document.getElementById('file_error').innerHTML = "File size is too large. Max is 2MB. <br />";}
  538. if($.inArray(ext, ['doc','docx','pdf']) == -1){document.getElementById('file_error').innerHTML = document.getElementById('file_error').innerHTML + "Invalid filetype. The following filetypes are allowed: .doc, .docx, .pdf";}
  539. document.getElementById('file_error').style.display = 'block';
  540. this.value = null;
  541. }else {
  542. document.getElementById('file_error').style.display = 'none';
  543. }
  544. });
  545.  
  546. $('#photo').bind('change', function () {
  547. document.getElementById('photo_error').innerHTML = '';
  548. var ext = $(this).val().split('.').pop().toLowerCase();
  549. if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1 || this.files[0].size>2334344) {
  550. if(this.files[0].size>2334344){document.getElementById('photo_error').innerHTML = "File size is too large. Max is 2MB. <br />";}
  551. if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1){document.getElementById('photo_error').innerHTML = document.getElementById('photo_error').innerHTML + "Invalid filetype. The following filetypes are allowed: .jpg, .jpeg, .png, .gif";}
  552. document.getElementById('photo_error').style.display = 'block';
  553. this.value = null;
  554. }else {
  555. document.getElementById('file_error').style.display = 'none';
  556. }
  557. });
  558.  
  559. $('#addfile').bind('change', function () {
  560. document.getElementById('addfile_error').innerHTML = '';
  561. if(this.files[0].size>2334344) {
  562. document.getElementById('addfile_error').innerHTML = "File size is too large. Max is 2MB.";
  563. document.getElementById('addfile_error').style.display = 'block';
  564. this.value = null;
  565. }else {
  566. document.getElementById('file_error').style.display = 'none';
  567. }
  568. });
  569.  
  570. </script>
  571. <?php
  572.  
  573. /*
  574.  
  575. if(isset($_FILES['file']['tmp_name']))
  576. {
  577. // Number of uploaded files
  578. $num_files = count($_FILES['file']['tmp_name']);
  579.  
  580. print $num_files;
  581.  
  582.  
  583. for($i=0; $i < $num_files;$i++)
  584. {
  585. // check if there is a file in the array
  586. if(!is_uploaded_file($_FILES['file']['tmp_name'][$i]))
  587. {
  588. $messages[] = 'No file uploaded';
  589. }
  590. else
  591. {
  592. // copy the file to the specified dir
  593. if(@copy($_FILES['file']['tmp_name'][$i], $_SERVER['DOCUMENT_ROOT'] . '/user_tmp/'.$_FILES['file']['name'][$i]))
  594. {
  595.  
  596. $messages[] = $_FILES['file']['name'][$i].' uploaded';
  597. }
  598. else
  599. {
  600.  
  601. $messages[] = 'Uploading '.$_FILES['file']['name'][$i].' Failed';
  602. }
  603. }
  604. }
  605. }
  606.  
  607. */
  608.  
  609. endwhile; endif;
  610. get_template_part('page-templates/ajaxFilter'); ?>
  611.  
  612.  
  613. <?php get_footer(); ?>
Add Comment
Please, Sign In to add comment