Advertisement
Guest User

Untitled

a guest
Jul 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_REQUEST['total']))
  4. $total = $_REQUEST['total'];
  5. else
  6. $total = "";
  7.  
  8. if(isset($_REQUEST['Rid']))
  9. $Rid = $_REQUEST['Rid'];
  10.  
  11. error_reporting(E_ALL ^ E_DEPRECATED);
  12. require('fpdf.php');
  13. $d=date('d_m_Y');
  14.  
  15.  
  16. $servername = "localhost";
  17. $username = "root";
  18. $password = "";
  19. $dbname= "DOWNTOWN";
  20. date_default_timezone_set('Asia/Manila');
  21. $timedate = date("h:i:s A");
  22. $p_date =date("Y-m-d");
  23.  
  24. // Create connection
  25. $conn = new mysqli($servername, $username, $password , $dbname);
  26.  
  27. // Check connection
  28. if ($conn->connect_error) {
  29. die("Connection failed: " . $conn->connect_error);
  30. }
  31.  
  32.  
  33. $sql = "SELECT allinvty3.*, barcode.* , sample.*, sum(barcode.qty) as icount ,
  34.  
  35. count(barcode.itemcode) - (sample.tqty) as total1
  36. from barcode
  37.  
  38.  
  39.  
  40. LEFT JOIN sample on barcode.itemcode = sample.in_code
  41. INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code
  42. where sample.refnumber='".$Rid."' and barcode.refnumber='".$Rid."' group by barcode.itemcode";
  43. $result = $conn->query($sql);
  44. while($row = $result->fetch_assoc()) {
  45. $date1 =$row['datereceived'];
  46. $qty =$row['tqty'];
  47. $icount =$row['icount'];
  48.  
  49.  
  50. }
  51.  
  52.  
  53.  
  54.  
  55. class PDF extends FPDF
  56. {
  57.  
  58. function Header()
  59. {
  60. $this->SetFont('Helvetica','',25);
  61. $this->SetFontSize(40);
  62. //Move to the right
  63. $this->Cell(80);
  64. //Line break
  65. $this->Ln();
  66. }
  67.  
  68. //Page footer
  69. function Footer()
  70. {
  71.  
  72. }
  73.  
  74. //Load data
  75. function LoadData($file)
  76. {
  77. //Read file lines
  78. $lines=file($file);
  79. $data=array();
  80. foreach($lines as $line)
  81. $data[]=explode(';',chop($line));
  82. return $data;
  83. }
  84.  
  85. //Simple table
  86. function BasicTable($header,$data)
  87. {
  88.  
  89. $this->SetFillColor(255,255,255);
  90. //$this->SetDrawColor(255, 0, 0);
  91. $w=array(38,21,90,7,12,7);
  92.  
  93.  
  94. //Header
  95. $this->SetFont('Arial','B',7);
  96. for($i=0;$i<count($header);$i++)
  97. $this->Cell($w[$i],7,$header[$i],1,0,'L',true);
  98. $this->Ln();
  99.  
  100. //Data
  101.  
  102. $this->SetFont('Arial','',7);
  103. foreach ($data as $eachResult)
  104. { //width
  105. $this->Cell(10);
  106. $this->Cell(38,6,$eachResult["ecr_desc"],1);
  107. $this->Cell(21,6,$eachResult["itemcode"],1);
  108. $this->Cell(90,6,$eachResult["ite_desc"],1);
  109. $this->Cell(7,6,$eachResult["tqty"],1);
  110. $this->Cell(12,6,$eachResult["icount"],1);
  111.  
  112.  
  113.  
  114. $this->Cell(7,6,$eachResult["total1"],1);
  115. $this->Ln();
  116.  
  117. }
  118. }
  119.  
  120. //Better table
  121. }
  122.  
  123.  
  124.  
  125. $pdf=new PDF();
  126.  
  127.  
  128.  
  129. $header=array('Model','Code','Desc','XFR','ACTUAL', 'DIFF');
  130. //Data loading
  131. //*** Load MySQL Data ***//
  132. $objConnect = mysql_connect("localhost","root","") or die("Error:Please check your database username & password");
  133. $objDB = mysql_select_db("DOWNTOWN");
  134. $strSQL = "SELECT allinvty3.*, barcode.* , sample.*, sum(barcode.qty) as icount , sum(barcode.qty ) - (sample.tqty) as total1 from barcode
  135. INNER JOIN sample on barcode.itemcode = sample.in_code
  136. INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code
  137. where sample.refnumber='".$Rid."' and barcode.refnumber='".$Rid."' group by barcode.itemcode";
  138. $objQuery = mysql_query($strSQL);
  139. $resultData = array();
  140. for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
  141. $result = mysql_fetch_array($objQuery);
  142. array_push($resultData,$result);
  143. }
  144.  
  145.  
  146.  
  147. //************************//
  148.  
  149.  
  150. //*** Table 1 ***//
  151. $pdf->AddPage();
  152.  
  153. $pdf->SetFont('Helvetica','',14);
  154. $pdf->Cell(75);
  155. $pdf->Write(5, 'Stock Receiving');
  156.  
  157. $pdf->Ln();
  158.  
  159. $pdf->Cell(22);
  160. $pdf->SetFontSize(8);
  161. $pdf->Cell(57);
  162. $result=mysql_query("select date_format(now(), '%W, %M %d, %Y') as date");
  163. while( $row=mysql_fetch_array($result) )
  164. {
  165. $pdf->Write(5,$row['date']);
  166. }
  167. $pdf->Ln();
  168.  
  169. //count total numbers of visitors
  170. $sql= "SELECT allinvty3.*, barcode.* , sample.*, sum(barcode.qty) as icount from barcode
  171. INNER JOIN sample on barcode.itemcode = sample.in_code
  172. INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code
  173. where sample.refnumber='".$Rid."' and barcode.refnumber='".$Rid."' ";
  174.  
  175. $result = $conn->query($sql);
  176. while($row = $result->fetch_assoc()) {
  177.  
  178.  
  179. $icount= $row['icount'];
  180. $date= $row['datereceived'];
  181. }
  182.  
  183.  
  184. $pdf->Cell(0);
  185. $pdf->Write(3, ' REFERENCE NUMBER: '.$Rid.'');
  186.  
  187. $pdf->Ln();
  188.  
  189. $pdf->Cell(0);
  190. $pdf->Write(2, ' DATE RECEIVED: '.$date.'');
  191.  
  192. $pdf->Ln();
  193.  
  194.  
  195. $pdf->Cell(0);
  196. $pdf->Write(2, ' TOTAL ITEM: '.$icount.'');
  197.  
  198. $pdf->Ln();
  199. $pdf->Ln(5);
  200.  
  201. $pdf->Ln(0);
  202. $pdf->Cell(10);
  203. $pdf->BasicTable($header,$resultData);
  204. //forme();
  205. //$pdf->Output("$d.pdf","F");
  206. $pdf->Output();
  207.  
  208. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement