Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "configsmaltiigm.php";
- error_reporting(E_ALL);
- $order_field='id';
- $order_type='desc';
- $data=array();
- $url="smaltiigm.perpus.id/images/docs/";
- $urlpdf="smaltiigm.perpus.id/repository/";
- $sql="select biblio_id id,title, publish_year, notes, call_number, isbn_issn, file_att, image from biblio
- order by {$order_field} {$order_type}";
- $cek_kode=mysqli_query($konek, $sql);
- //$cek_kode=mysqli_query($konek, "desc biblio");
- //$cek= //mysqli_num_rows($cek_kode);
- $cek= @mysqli_num_rows($cek_kode);
- //die($cek.'|0000');
- if (!$cek_kode||$cek==0)
- {
- echo "EROR, Coba tunggu atu perbaiki kodingan";
- }
- else
- {
- $total=0;
- $data=array();
- while ($hasil=mysqli_fetch_array($cek_kode, MYSQLI_ASSOC))
- {
- $hasil['url_gbr']=$url.$hasil['image'];
- //author
- $sql="SELECT a.author_id,a.author_name, a.author_year, a.auth_list, a.authority_type
- FROM `biblio_author` ba join mst_author a
- on ba.author_id=a.author_id where ba.biblio_id=".$hasil['id'];
- $aSql=array($sql);
- $res=mysqli_query($konek,$sql);
- $ar=array();
- while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
- {
- $ar[]=$row;
- }
- $hasil['author']=$ar;
- $hasil['url_gbr']=$url.$hasil['image'];
- //TOPIC
- $sql="SELECT t.auth_list, t.topic, t.topic_type,t.topic_id
- FROM `biblio_topic` bt join mst_topic t
- on bt.topic_id=t.topic_id where bt.biblio_id=".$hasil['id'];
- $aSql[]=$sql;
- $res=mysqli_query($konek,$sql);
- $ar=array();;
- while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
- {
- $ar[]=$row;
- }
- $hasil['topic']=$ar;
- //files
- $sql="SELECT t.file_id, t.file_title, t.file_name,t.mime_type
- FROM `biblio_attachment` ba join files t
- on ba.file_id=t.file_id where ba.biblio_id=".$hasil['id'];
- $aSql[]=$sql;
- $res=mysqli_query($konek,$sql);
- $ar=array();;
- $pdf='';
- while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
- {
- if(trim($row['mime_type'])=='application/pdf'){
- $pdf=$row['file_name'];
- }
- $ar[]=$row;
- }
- $hasil['files']=$ar;
- $sql="select i.item_code, i.location_id,l.loan_date,l.due_date
- from item i left join loan l on i.item_code=l.item_code where
- biblio_id='{$hasil['id']}'";
- $aSql[]=$sql;
- $res=mysqli_query($konek,$sql);
- $ar=array();
- $nStock=0;
- while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
- {
- if($row['due_date']>date("Y-m-d")){
- //stock tidak ada
- }else{
- $nStock++;
- }
- $ar[]=$row;
- }
- $hasil['stocks']=$ar;
- $hasil['stock_avaiable']=$nStock;
- //$hasil['sql']=$aSql;
- if(!isset($hasil['file_name'])){
- $hasil['file_name']='';
- }
- if($hasil['file_name']!=""){
- $hasil['url_pdf']= $urlpdf.$hasil['file_name'];
- }elseif(trim($pdf)!=''){
- $hasil['url_pdf']= $urlpdf.$pdf;
- }else{
- $hasil['url_pdf']=false;
- }
- //$hasil['url_pdf_1']=$pdf;
- $aNotes=explode(".",$hasil['notes']);
- $notes='';
- $max=count($aNotes)>3?3:count($aNotes);
- for($i=0;$i<$max;$i++){
- $notes.=$aNotes[$i].".";
- }
- if(count($aNotes)>3){
- $notes.="..";
- }
- if(strlen($notes)>100){
- $notes=substr(strip_tags($notes), 0, 100)."...";
- }
- $hasil['notes']=strip_tags($notes);
- $data[]=$hasil;
- $total++;
- //echo '<pre>'.print_r($hasil,1);die;
- }
- $result=array(
- 'data'=>$data,
- 'total'=>$total
- );
- $final=json_encode($result);
- echo json_encode ($result);
- //echo '<pre>xxx';print_r($result);
- die;
- //echo substr($title,10);
- //echo json_encode ($data);
- //echo substr($title,10);
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement