Advertisement
fazeela

done

Apr 3rd, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.33 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $url='http://192.168.2.21:8080/WisManOnlineCenter_1.0/services/trial/getOrganizationHierarchy';
  4.         $ch=curl_init();
  5.         curl_setopt($ch, CURLOPT_URL, $url);
  6.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  7.         curl_setopt($ch, CURLOPT_POST, true);
  8.         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($useridofuser));
  9.         curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
  10.         $response=  curl_exec($ch);
  11.        echo('\n'."Server response : \n \n".$response);
  12.         curl_close($ch);
  13.         //parsing the json response from server
  14.         $jsonde="$response";
  15.         $_SESSION['json']=$jsonde;
  16. $org = array();
  17. $loc = array();
  18. $bui = array();
  19. $items = json_decode($response);
  20. foreach( $items as $each ){
  21. $loc[]=$each->location[0]->name;
  22. $bui[]=$each->location[0]->building[0];
  23. $org[]=$each->name;
  24. }
  25. ?>
  26.  
  27. <html>
  28. <head>
  29. <title>Login Form</title>
  30. <script>
  31.     function validate()
  32. {
  33.     var vusername=trim(document.theForm.username.value);
  34.     var vpassword=trim(document.theForm.password.value);
  35.     var vpassword1=trim(document.theForm.password1.value);
  36.     var vemail=trim(document.theForm.email.value);
  37.     var vdepartment=trim(document.theForm.department.value);
  38.     var vfirstname=trim(document.theForm.firstname.value);
  39.     var vlastname=trim(document.theForm.lastname.value);
  40.     var vlandphone=trim(document.theForm.landphone.value);
  41.     var vmobile=trim(document.theForm.mobile.value);
  42.     var vexpirydate=trim(document.theForm.expirydate.value);
  43.     var vimage=trim(document.theForm.image.value);
  44.     var vopcode=trim(document.theForm.opcode.value);
  45.    
  46.       if(vusername=="")
  47.     {
  48.         alert("User Name Field is Empty");
  49.         document.theForm.username.focus();
  50.         return false;
  51.     }
  52.     else if(vpassword=="")
  53.     {
  54.         alert("Password Field is Empty");
  55.         document.theForm.password.focus();
  56.         return false;
  57.     }
  58.     else if(vpassword1=="")
  59.     {
  60.         alert("Confirm Password Field is Empty");
  61.         document.theForm.password1.focus();
  62.         return false;
  63.     }
  64.     else if(vemail=="")
  65.     {
  66.         alert("Email Field is Empty");
  67.         document.theForm.email.focus();
  68.         return false;
  69.    }
  70.    else if(vdepartment=="")
  71.    {
  72.         alert("Department Field is Empty");
  73.         document.theForm.department.focus();
  74.         return false;
  75.    }
  76.    else if(vfirstname=="")
  77.    {
  78.         alert("First Name Field is Empty");
  79.         document.theForm.firstname.focus();
  80.         return false;
  81.    }
  82.    else if(vlastname=="")
  83.    {
  84.         alert("Last Name Field is Empty");
  85.         document.theForm.lastname.focus();
  86.         return false;
  87.    }
  88.    else if(vlandphone=="")
  89.    {
  90.         alert("Land Phone Field is Empty");
  91.         document.theForm.landphone.focus();
  92.         return false;
  93.    }  
  94.    else if(vmobile=="")
  95.    {
  96.         alert("Mobile Field is Empty");
  97.         document.theForm.mobile.focus();
  98.         return false;
  99.    }
  100.    else if(vexpirydate=="")
  101.    {
  102.         alert("Expiry Date Field is Empty");
  103.         document.theForm.expirydate.focus();
  104.         return false;
  105.    }
  106.    else if(vimage=="")
  107.    {
  108.         alert("Image Field is Empty");
  109.         document.theForm.image.focus();
  110.         return false;
  111.    }
  112.    else if(vopcode=="")
  113.    {
  114.         alert("Opcode Field is Empty");
  115.         document.theForm.opcode.focus();
  116.         return false;
  117.    }
  118. }
  119.  
  120. function trim(s) {
  121.     return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
  122. }
  123.     function onKeyPressBlockNumbers(e)
  124. {
  125.     var key = window.event ? e.keyCode : e.which;
  126.     var keychar = String.fromCharCode(key);
  127.     reg = /\d/;
  128.     return !reg.test(keychar);
  129. }
  130.  function isNumberKey(evt)
  131.       {
  132.          var charCode = (evt.which) ? evt.which : event.keyCode
  133.          if (charCode > 31 && (charCode < 48 || charCode > 57))
  134.             return false;
  135.  
  136.          return true;
  137.       }
  138.      
  139.     function run() {
  140.     document.getElementById("srt").value = document.getElementById("Ultra").value;
  141. }
  142.  
  143. function up() {
  144.  
  145.     //if (document.getElementById("srt").value != "") {
  146.         var dop = document.getElementById("srt").value;
  147.     //}
  148.     pop(dop);
  149.  
  150. }
  151.  
  152. function pop(val) {
  153.     alert(val);
  154. }
  155.  
  156. </script>
  157. </head>
  158. <body><center>
  159.         <div style="margin-top:10px">  
  160.         <h3>ADD OPERATOR</h3>
  161.         </div>
  162.             <form name="theForm" method="post" action="addoperator.php" enctype="multipart/form-data" onSubmit="return validate();">
  163.              <table border="0" >
  164.              <tr><td>Username</td>
  165.               <td><input type="text" name="username" onkeypress="return onKeyPressBlockNumbers(event);"></td></tr>
  166.                     <tr><td>Password</td>
  167.                         <td><input name="password" type="password"></td></tr>
  168.                     <tr><td>Confirm Password</td>
  169.                         <td><input name="password1" type="password"></td></tr>
  170.                     <tr><td>Email</td>
  171.                         <td><input name="email" type="email"></td></tr>
  172.                     <tr><td>Organisation Name</td>
  173.                         <td>
  174.                         <select style="width: 155px" name="category_id" id="category_id">
  175.                         <option value="">Select</option>
  176.                         <?php foreach($org as $key=>$val){?>
  177.                         <option value="<?php echo $val; ?>"><?php echo $val;?></option>
  178. <?php
  179. }
  180. ?>                      </select></td></tr>
  181.                     <tr><td>Location</td>
  182.                         <td>
  183.                          <select style="width: 155px" name="category_id1" id="category_id1">
  184.                          <option value="">Select</option>
  185.                          <?php foreach($loc as $key=>$val){?>
  186.                          <option value="<?php echo $val; ?>"><?php echo $val; ?></option>
  187. <?php
  188. }
  189. ?>
  190.                          </select></td></tr>
  191.                     <tr><td>Building</td>
  192.                         <td>
  193.                         <select style="width: 155px" name="category_id2" id="category_id2">
  194.                         <option value="">Select</option>
  195.                         <?php foreach($bui as $key=>$val){?>
  196.                         <option value="<?php echo $val; ?>"><?php echo $val; ?></option>
  197. <?php
  198. }
  199. ?>
  200.                         </select></td></tr>
  201.                     <tr><td>Department</td>
  202.                         <td><select style="width:155px" name="department" id="department">
  203.                                 <option>Select</option>
  204.                                 <option>default</option>
  205.                             </select></td></tr>
  206. <?php
  207. $oneYearOn = date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 7300 day"));
  208. //echo $oneYearOn;
  209. $oneYearOn1=date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 40day"));
  210. //echo $oneYearOn1;
  211. ?>
  212.   <tr><td>Sub Category</td>
  213.   <td>
  214.       <select style="width:155px" name="subcategory" id="Ultra" onchange="run()">
  215.      <option value="0">Select</option>
  216.      <option value="<?=$oneYearOn?>">Employee</option>
  217.      <option value="<?=$oneYearOn1?>">Temporary</option>
  218. </select>  
  219.   </td>
  220.   </tr> <tr><td>First Name</td>
  221.                         <td><input name="firstname" type="text" onkeypress="return onKeyPressBlockNumbers(event);"></td></tr>
  222.                     <tr><td>Last Name</td>
  223.                         <td><input name="lastname" type="text" onkeypress="return onKeyPressBlockNumbers(event);"></td></tr>
  224.                     <tr><td>Land Phone</td>
  225.                         <td><input name="landphone" type="number" onkeypress="return isNumberKey(event)"></td></tr>
  226.                     <tr><td>Mobile</td>
  227.                         <td><input name="mobile" type="number" onkeypress="return isNumberKey(event)"></td></tr>
  228.                     <tr><td>Expiry date</td>
  229.                         <td><input name="expirydate" type="text" id="srt"><br></td></tr>
  230.                     <tr><td>Opcode</td>
  231.                         <td><input name="opcode" type="text" onkeypress="return isNumberKey(event)"></td></tr>
  232.                     <tr><td>Image</td>
  233.                         <td><input type="file" name="file" id="file"></td>
  234.                     <tr><td><input type="submit" name="submit" value="Submit"></td></tr>
  235.                 </table>
  236.             </form>
  237.         </center>
  238. </body>
  239. </html>
  240.  
  241.  
  242.  
  243. <html>
  244. <body>
  245.  
  246.  
  247.  
  248.  
  249. </form>
  250.  
  251. </body>
  252. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement