fwprabowo

Untitled

Oct 29th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <?php
  2. include "config.php";
  3.  
  4. $data=array();
  5. $url="http://jadiperpusdigital.xyz/images/docs/";
  6. $urlpdf="http://jadiperpusdigital.xyz/repository/";
  7.  
  8. $cek_kode=mysqli_query($konek, "select biblio_id id,title, publish_year, notes, call_number, isbn_issn, file_att, image from biblio");
  9. //$cek_kode=mysqli_query($konek, "desc biblio");
  10. $cek=mysqli_num_rows($cek_kode);
  11. if ($cek==0){
  12. echo "EROR, Coba tunggu atu perbaiki kodingan";
  13. }
  14. else
  15. {
  16. $total=0;
  17. while ($hasil=mysqli_fetch_array($cek_kode, MYSQLI_ASSOC))
  18. {
  19. $hasil['url_gbr']=$url.$hasil['image'];
  20. //author
  21. $sql="SELECT a.author_id,a.author_name, a.author_year, a.auth_list, a.authority_type
  22. FROM `biblio_author` ba join mst_author a
  23. on ba.author_id=a.author_id where ba.biblio_id=".$hasil['id'];
  24. $aSql=[$sql];
  25. $res=mysqli_query($konek,$sql);
  26. $ar=[];
  27. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  28. {
  29. $ar[]=$row;
  30. }
  31. $hasil['author']=$ar;
  32.  
  33. $hasil['url_gbr']=$url.$hasil['image'];
  34. //TOPIC
  35. $sql="SELECT t.auth_list, t.topic, t.topic_type,t.topic_id
  36. FROM `biblio_topic` bt join mst_topic t
  37. on bt.topic_id=t.topic_id where bt.biblio_id=".$hasil['id'];
  38. $aSql[]=$sql;
  39. $res=mysqli_query($konek,$sql);
  40. $ar=[];
  41. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  42. {
  43. $ar[]=$row;
  44. }
  45. $hasil['topic']=$ar;
  46. //files
  47. $sql="SELECT t.file_id, t.file_title, t.file_name,t.mime_type
  48. FROM `biblio_attachment` ba join files t
  49. on ba.file_id=t.file_id where ba.biblio_id=".$hasil['id'];
  50. $aSql[]=$sql;
  51. $res=mysqli_query($konek,$sql);
  52. $ar=[];
  53. $pdf='';
  54. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  55. {
  56. if(trim($row['mime_type'])=='application/pdf'){
  57. $pdf=$row['file_name'];
  58. }
  59. $ar[]=$row;
  60. }
  61. $hasil['files']=$ar;
  62.  
  63. $sql="select i.item_code, i.location_id,l.loan_date,l.due_date
  64. from item i left join loan l on i.item_code=l.item_code where
  65. biblio_id='{$hasil['id']}'";
  66. $aSql[]=$sql;
  67. $res=mysqli_query($konek,$sql);
  68. $ar=[];$nStock=0;
  69. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  70. {
  71. if($row['due_date']>date("Y-m-d")){
  72. //stock tidak ada
  73. }else{
  74. $nStock++;
  75. }
  76. $ar[]=$row;
  77. }
  78. $hasil['stocks']=$ar;
  79. $hasil['stock_avaiable']=$nStock;
  80.  
  81. //$hasil['sql']=$aSql;
  82. if($hasil['file_name']!=""){
  83. $hasil['url_pdf']= $urlpdf.$hasil['file_name'];
  84. }elseif(trim($pdf)!=''){
  85. $hasil['url_pdf']= $urlpdf.$pdf;
  86. }else{
  87. $hasil['url_pdf']=false;
  88. }
  89. //$hasil['url_pdf_1']=$pdf;
  90. $data[]=$hasil;
  91. $total++;
  92. }
  93.  
  94.  
  95. $result=[
  96. 'data'=>$data,
  97. 'total'=>$total
  98. ];
  99. $final=json_encode($result);
  100. //echo '<pre>xxx';print_r($result);die();
  101. echo json_encode ($result);
  102. //echo substr($title,10);
  103. //echo json_encode ($data);
  104. //echo substr($title,10);
  105. }
Add Comment
Please, Sign In to add comment