Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5. include("db.php");
  6.  
  7.  
  8. // $docnr = $_POST['docnr'];
  9. // $action = $_POST['action'];
  10.  
  11.  
  12. // $docnr = $_POST['docnr'];
  13. // $action = $_POST['action'];
  14.  
  15. $docnr = 6438403;
  16. $action = 'receptie';
  17. // $data = date("Y-m-d H:i:s", strtotime('+1 hour'));
  18. if($action && $action == 'receptie')
  19. {
  20. $details = array();
  21. $defect = array();
  22.  
  23. $tsql = "select
  24. w.id,
  25. w.series,
  26. w.lengthnet,
  27. w.diameternet,
  28. w.cubagenet,
  29. ISNULL(w.loadingpoint,'') as loadingpoint,
  30. ISNULL(n.cmrnumber,'') as cmrnumber,
  31. ISNULL(n.trailnumber,'') as trailnumber,
  32. ISNULL(n.carnumber,'') as carnumber,
  33. ISNULL(t.name,'') as transporter
  34.  
  35.  
  36. from wood w
  37.  
  38. left join notice n
  39. on w.idnotice = n.id
  40. left join Transporter t
  41. on t.id = n.idtransporter
  42.  
  43. where n.docnr = '$docnr'";
  44. $stmt = sqlsrv_query($conn, $tsql);
  45. $row=array();
  46. while ($row = sqlsrv_fetch_array($stmt)) {
  47.  
  48. $series = $row['series'];
  49.  
  50. $id = $row['id'];
  51. $tsql1 = "select
  52. ISNULL(DefectType.alias,'') as alias,
  53. ISNULL(Defect.length,'') as length
  54. from Defect
  55. inner join DefectType
  56. on Defect.iddefecttype = DefectType.id
  57. where idwood = $id";
  58. // echo $tsql1."</br>";
  59. $stmt1 = sqlsrv_query($conn, $tsql1);
  60. $row1[] = sqlsrv_fetch_array($stmt1);
  61. sqlsrv_free_stmt($stmt1);
  62. }
  63. $defect = array();
  64. if(!empty($series))
  65. {
  66. // var_dump($row1);
  67. // die();
  68. //
  69. if(!empty($row1)){
  70. // echo "Prima data";
  71. // $row1= array($row1);
  72. // var_dump($row1);
  73. // die();
  74. foreach ($row1 as $key=> $value) {
  75. $defect[]=array('alias' => $row1[$key]['alias'],
  76. 'length'=>$row1[$key]['length'],
  77.  
  78. );
  79. // array_push($defect, array("alias"=>$row1[$key]['alias'],"length"=>$row1[$key]['length']));
  80. }
  81. // var_dump($defect);
  82. // die();
  83. }
  84.  
  85. array_push($details, array("series"=>$row['series'],"diameternet"=>$row['diameternet'],"lengthnet"=>round($row['lengthnet'],2),"cubagenet"=>round($row['cubagenet'],2), "loadingpoint"=>$row['loadingpoint'],"cmrnumber"=>$row['cmrnumber'],"trailnumber"=>$row['trailnumber'],"transporter"=>round($row['transporter'],2),"defect"=>$defect));
  86.  
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. echo json_encode($details);
  96. sqlsrv_free_stmt($stmt);
  97. sqlsrv_close( $conn);
  98.  
  99. //WLOG($verificare);
  100. //WLOG($tsql);
  101.  
  102. //FUNCTION WLOG($MESSAGE){
  103. //
  104. // $D=DATE("Y-M-D H:I:S");
  105. // FILE_PUT_CONTENTS("RECEPTIE.TXT", "\N $D ".$MESSAGE, FILE_APPEND);
  106. //
  107. //}
  108.  
  109. }
  110.  
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement