1<?php 2// MRPReschedules.php - Report of purchase orders and work orders that MRP determines should be 3// rescheduled. 4 5include('includes/session.php'); 6 7if ( !DB_table_exists('mrprequirements') ) { 8 $Title='MRP error'; 9 include('includes/header.php'); 10 echo '<br />'; 11 prnMsg( _('The MRP calculation must be run before you can run this report') . '<br />' . 12 _('To run the MRP calculation click').' ' . '<a href="'.$RootPath .'/MRP.php">' . _('here') . '</a>', 'error'); 13 include('includes/footer.php'); 14 exit; 15} 16if (isset($_POST['PrintPDF'])) { 17 18 include('includes/PDFStarter.php'); 19 $pdf->addInfo('Title',_('MRP Reschedule Report')); 20 $pdf->addInfo('Subject',_('MRP Reschedules')); 21 $FontSize=9; 22 $PageNumber=1; 23 $line_height=12; 24 25/*Find mrpsupplies records where the duedate is not the same as the mrpdate */ 26 $selecttype = " "; 27 if ($_POST['Selection'] != 'All') { 28 $selecttype = " AND ordertype = '" . $_POST['Selection'] . "'"; 29 } 30 $sql = "SELECT mrpsupplies.*, 31 stockmaster.description, 32 stockmaster.decimalplaces 33 FROM mrpsupplies,stockmaster 34 WHERE mrpsupplies.part = stockmaster.stockid AND duedate <> mrpdate 35 $selecttype 36 ORDER BY mrpsupplies.part"; 37 $result = DB_query($sql,'','',false,true); 38 39 if (DB_error_no() !=0) { 40 $Title = _('MRP Reschedules') . ' - ' . _('Problem Report'); 41 include('includes/header.php'); 42 prnMsg( _('The MRP reschedules could not be retrieved by the SQL because') . ' ' . DB_error_msg(),'error'); 43 echo '<br /><a href="' .$RootPath .'/index.php">' . _('Back to the menu') . '</a>'; 44 if ($debug==1){ 45 echo '<br />' . $sql; 46 } 47 include('includes/footer.php'); 48 exit; 49 } 50 51 if (DB_num_rows($result) == 0) { 52 $Title = _('MRP Reschedules') . ' - ' . _('Problem Report'); 53 include('includes/header.php'); 54 prnMsg( _('No MRP reschedule retrieved'), 'warn'); 55 echo '<br /><a href="' .$RootPath .'/index.php">' . _('Back to the menu') . '</a>'; 56 if ($debug==1){ 57 echo '<br />' . $sql; 58 } 59 include('includes/footer.php'); 60 exit; 61 } 62 63 PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, 64 $Right_Margin); 65 $Tot_Val=0; 66 $fill = false; 67 $pdf->SetFillColor(224,235,255); 68 While ($myrow = DB_fetch_array($result)){ 69 70 $YPos -=$line_height; 71 $FontSize=8; 72 73 $FormatedDueDate = ConvertSQLDate($myrow['duedate']); 74 $FormatedMRPDate = ConvertSQLDate($myrow['mrpdate']); 75 if ($myrow['mrpdate'] == '2050-12-31') { 76 $FormatedMRPDate = 'Cancel'; 77 } 78 79 // Use to alternate between lines with transparent and painted background 80 if ($_POST['Fill'] == 'yes'){ 81 $fill=!$fill; 82 } 83 84 // Parameters for addTextWrap are defined in /includes/class.pdf.php 85 // 1) X position 2) Y position 3) Width 86 // 4) Height 5) Text 6) Alignment 7) Border 8) Fill - True to use SetFillColor 87 // and False to set to transparent 88 $pdf->addTextWrap($Left_Margin,$YPos,90,$FontSize,$myrow['part'],'',0,$fill); 89 $pdf->addTextWrap(130,$YPos,200,$FontSize,$myrow['description'],'',0,$fill); 90 $pdf->addTextWrap(330,$YPos,50,$FontSize,$myrow['orderno'],'right',0,$fill); 91 $pdf->addTextWrap(380,$YPos,30,$FontSize,$myrow['ordertype'],'right',0,$fill); 92 $pdf->addTextWrap(410,$YPos,50,$FontSize,locale_number_format($myrow['supplyquantity'], $myrow['decimalplaces']),'right',0,$fill); 93 $pdf->addTextWrap(460,$YPos,55,$FontSize,$FormatedDueDate,'right',0,$fill); 94 $pdf->addTextWrap(515,$YPos,50,$FontSize,$FormatedMRPDate,'right',0,$fill); 95 96 if ($YPos < $Bottom_Margin + $line_height){ 97 PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, 98 $Right_Margin); 99 } 100 101 } /*end while loop */ 102 103 $FontSize =10; 104 $YPos -= (2*$line_height); 105 106 if ($YPos < $Bottom_Margin + $line_height){ 107 PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, 108 $Right_Margin); 109 } 110 111 $pdf->OutputD($_SESSION['DatabaseName'] . '_MRPReschedules_' . date('Y-m-d').'.pdf'); 112 $pdf->__destruct(); 113 114} else { /*The option to print PDF was not hit so display form */ 115 116 $Title=_('MRP Reschedule Reporting'); 117 include('includes/header.php'); 118 119 echo '<p class="page_title_text"> 120 <img src="'.$RootPath.'/css/'.$Theme.'/images/inventory.png" title="' 121 . _('Stock') . '" alt="" />' . ' ' . $Title . ' 122 </p>'; 123 124 echo '<br /> 125 <br /> 126 <form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post"> 127 <div> 128 <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> 129 <table class="selection"> 130 <tr> 131 <td>' . _('Print Option') . ':</td> 132 <td><select name="Fill"> 133 <option selected="selected" value="yes">' . _('Print With Alternating Highlighted Lines') . '</option> 134 <option value="no">' . _('Plain Print') . '</option> 135 </select></td> 136 </tr> 137 <tr> 138 <td>' . _('Selection') . ':</td> 139 <td><select name="Selection"> 140 <option selected="selected" value="All">' . _('All') . '</option> 141 <option value="WO">' . _('Work Orders Only') . '</option> 142 <option value="PO">' . _('Purchase Orders Only') . '</option> 143 </select></td> 144 </tr> 145 </table> 146 <br /> 147 <div class="centre"> 148 <input type="submit" name="PrintPDF" value="' . _('Print PDF') . '" /> 149 </div> 150 </div> 151 </form>'; 152 153 include('includes/footer.php'); 154 155} /*end of else not PrintPDF */ 156 157 158function PrintHeader(&$pdf,&$YPos,&$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, 159 $Page_Width,$Right_Margin) { 160 161$line_height=12; 162/*PDF page header for MRP Reschedule report */ 163if ($PageNumber>1){ 164 $pdf->newPage(); 165} 166 167$FontSize=9; 168$YPos= $Page_Height-$Top_Margin; 169 170$pdf->addTextWrap($Left_Margin,$YPos,300,$FontSize,$_SESSION['CompanyRecord']['coyname']); 171 172$YPos -=$line_height; 173 174$pdf->addTextWrap($Left_Margin,$YPos,300,$FontSize,_('MRP Reschedule Report')); 175$pdf->addTextWrap($Page_Width-$Right_Margin-115,$YPos,160,$FontSize,_('Printed') . ': ' . 176 Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber); 177$YPos -=$line_height; 178$pdf->addTextWrap($Left_Margin,$YPos,70,$FontSize,_('Selection:')); 179$pdf->addTextWrap(90,$YPos,15,$FontSize,$_POST['Selection']); 180 181$YPos -=(2*$line_height); 182 183/*set up the headings */ 184$Xpos = $Left_Margin+1; 185 186$pdf->addTextWrap($Xpos,$YPos,135,$FontSize,_('Part Number'), 'left'); 187$pdf->addTextWrap(135,$YPos,195,$FontSize,_('Description'), 'left'); 188$pdf->addTextWrap(330,$YPos,50,$FontSize,_('Order No.'), 'right'); 189$pdf->addTextWrap(380,$YPos,35,$FontSize,_('Type'), 'right'); 190$pdf->addTextWrap(415,$YPos,45,$FontSize,_('Quantity'), 'right'); 191$pdf->addTextWrap(460,$YPos,55,$FontSize,_('Order Date'), 'right'); 192$pdf->addTextWrap(515,$YPos,50,$FontSize,_('MRP Date'), 'right'); 193 194$FontSize=8; 195$YPos =$YPos - (2*$line_height); 196$PageNumber++; 197} // End of PrintHeader function 198?> 199