Advertisement
fwprabowo

kodular

Nov 6th, 2020
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. <?php
  2. include "configsmaltiigm.php";
  3. error_reporting(E_ALL);
  4. $order_field='id';
  5. $order_type='desc';
  6. $data=array();
  7. $url="smaltiigm.perpus.id/images/docs/";
  8. $urlpdf="smaltiigm.perpus.id/repository/";
  9.  
  10. $sql="select biblio_id id,title, publish_year, notes, call_number, isbn_issn, file_att, image from biblio
  11. order by {$order_field} {$order_type}";
  12. $cek_kode=mysqli_query($konek, $sql);
  13. //$cek_kode=mysqli_query($konek, "desc biblio");
  14.  
  15. //$cek= //mysqli_num_rows($cek_kode);
  16. $cek= @mysqli_num_rows($cek_kode);
  17.  
  18. //die($cek.'|0000');
  19. if (!$cek_kode||$cek==0)
  20. {
  21. echo "EROR, Coba tunggu atu perbaiki kodingan";
  22. }
  23. else
  24. {
  25.  
  26. $total=0;
  27. $data=array();
  28. while ($hasil=mysqli_fetch_array($cek_kode, MYSQLI_ASSOC))
  29. {
  30. $hasil['url_gbr']=$url.$hasil['image'];
  31. //author
  32. $sql="SELECT a.author_id,a.author_name, a.author_year, a.auth_list, a.authority_type
  33. FROM `biblio_author` ba join mst_author a
  34. on ba.author_id=a.author_id where ba.biblio_id=".$hasil['id'];
  35. $aSql=array($sql);
  36. $res=mysqli_query($konek,$sql);
  37. $ar=array();
  38.  
  39. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  40. {
  41. $ar[]=$row;
  42. }
  43. $hasil['author']=$ar;
  44.  
  45. $hasil['url_gbr']=$url.$hasil['image'];
  46. //TOPIC
  47. $sql="SELECT t.auth_list, t.topic, t.topic_type,t.topic_id
  48. FROM `biblio_topic` bt join mst_topic t
  49. on bt.topic_id=t.topic_id where bt.biblio_id=".$hasil['id'];
  50. $aSql[]=$sql;
  51. $res=mysqli_query($konek,$sql);
  52. $ar=array();;
  53. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  54. {
  55. $ar[]=$row;
  56. }
  57. $hasil['topic']=$ar;
  58. //files
  59. $sql="SELECT t.file_id, t.file_title, t.file_name,t.mime_type
  60. FROM `biblio_attachment` ba join files t
  61. on ba.file_id=t.file_id where ba.biblio_id=".$hasil['id'];
  62. $aSql[]=$sql;
  63. $res=mysqli_query($konek,$sql);
  64. $ar=array();;
  65. $pdf='';
  66. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  67. {
  68. if(trim($row['mime_type'])=='application/pdf'){
  69. $pdf=$row['file_name'];
  70. }
  71. $ar[]=$row;
  72. }
  73. $hasil['files']=$ar;
  74.  
  75. $sql="select i.item_code, i.location_id,l.loan_date,l.due_date
  76. from item i left join loan l on i.item_code=l.item_code where
  77. biblio_id='{$hasil['id']}'";
  78. $aSql[]=$sql;
  79. $res=mysqli_query($konek,$sql);
  80. $ar=array();
  81. $nStock=0;
  82. while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
  83. {
  84. if($row['due_date']>date("Y-m-d")){
  85. //stock tidak ada
  86. }else{
  87. $nStock++;
  88. }
  89. $ar[]=$row;
  90. }
  91. $hasil['stocks']=$ar;
  92. $hasil['stock_avaiable']=$nStock;
  93.  
  94. //$hasil['sql']=$aSql;
  95. if(!isset($hasil['file_name'])){
  96. $hasil['file_name']='';
  97.  
  98. }
  99. if($hasil['file_name']!=""){
  100. $hasil['url_pdf']= $urlpdf.$hasil['file_name'];
  101. }elseif(trim($pdf)!=''){
  102. $hasil['url_pdf']= $urlpdf.$pdf;
  103. }else{
  104. $hasil['url_pdf']=false;
  105. }
  106. //$hasil['url_pdf_1']=$pdf;
  107. $aNotes=explode(".",$hasil['notes']);
  108. $notes='';
  109. $max=count($aNotes)>3?3:count($aNotes);
  110. for($i=0;$i<$max;$i++){
  111. $notes.=$aNotes[$i].".";
  112. }
  113.  
  114. if(count($aNotes)>3){
  115. $notes.="..";
  116. }
  117. if(strlen($notes)>100){
  118. $notes=substr(strip_tags($notes), 0, 100)."...";
  119.  
  120. }
  121.  
  122. $hasil['notes']=strip_tags($notes);
  123. $data[]=$hasil;
  124. $total++;
  125. //echo '<pre>'.print_r($hasil,1);die;
  126. }
  127.  
  128.  
  129. $result=array(
  130. 'data'=>$data,
  131. 'total'=>$total
  132. );
  133. $final=json_encode($result);
  134.  
  135.  
  136. echo json_encode ($result);
  137. //echo '<pre>xxx';print_r($result);
  138. die;
  139. //echo substr($title,10);
  140. //echo json_encode ($data);
  141. //echo substr($title,10);
  142. }
  143. /*
  144.  
  145.  
  146. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement