From: <tu...@us...> - 2018-02-18 02:30:44
|
Revision: 7975 http://sourceforge.net/p/web-erp/reponame/7975 Author: turbopt Date: 2018-02-18 02:30:38 +0000 (Sun, 18 Feb 2018) Log Message: ----------- PaulT: PO_SelectOSPurchOrder.php: Derived from Tim's code: add default current dates. (there may not yet be any purchorders records) / PaulT: do not show the order list table when there are no records to show. (avoids a table heading output without any associated row data) Modified Paths: -------------- trunk/PO_SelectOSPurchOrder.php trunk/doc/Change.log Modified: trunk/PO_SelectOSPurchOrder.php =================================================================== --- trunk/PO_SelectOSPurchOrder.php 2018-02-18 01:25:58 UTC (rev 7974) +++ trunk/PO_SelectOSPurchOrder.php 2018-02-18 02:30:38 UTC (rev 7975) @@ -156,8 +156,13 @@ FROM purchorders"; $DateResult = DB_query($DateSQL); $DateRow = DB_fetch_array($DateResult); - $DateFrom = $DateRow['fromdate']; - $DateTo = $DateRow['todate']; + if ($DateRow['fromdate'] != null) { + $DateFrom = $DateRow['fromdate']; + $DateTo = $DateRow['todate']; + } else { + $DateFrom = date('Y-m-d'); + $DateTo = date('Y-m-d'); + } } else { $DateFrom = FormatDateForSQL($_POST['DateFrom']); $DateTo = FormatDateForSQL($_POST['DateTo']); @@ -581,96 +586,98 @@ $ErrMsg = _('No orders were returned by the SQL because'); $PurchOrdersResult = DB_query($SQL, $ErrMsg); - /*show a table of the orders returned by the SQL */ + if (DB_num_rows($PurchOrdersResult) > 0) { + /*show a table of the orders returned by the SQL */ - echo '<table cellpadding="2" width="97%" class="selection">'; + echo '<table cellpadding="2" width="97%" class="selection">'; - if (isset($_POST['PODetails'])) { - $BalHead = '<th class="ascending">' . _('Balance') .' (' . _('Stock ID') . '--' . _('Quantity') . ' )</th>'; - } else { - $BalHead = ''; - } - echo '<tr> - <th class="ascending">' . _('Order #') . '</th> - <th class="ascending">' . _('Order Date') . '</th> - <th class="ascending">' . _('Delivery Date') . '</th> - <th class="ascending">' . _('Initiated by') . '</th> - <th class="ascending">' . _('Supplier') . '</th> - ' . $BalHead . ' - <th class="ascending">' . _('Currency') . '</th>'; - - if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { - echo '<th class="ascending">' . _('Order Total') . '</th>'; - } - echo '<th class="ascending">' . _('Status') . '</th> - <th>' . _('Print') . '</th> - <th>' . _('Receive') . '</th> - </tr>'; - $j = 1; - - while ($myrow = DB_fetch_array($PurchOrdersResult)) { - $Bal = ''; if (isset($_POST['PODetails'])) { - //lets retrieve the PO balance here to make it a standard sql query. - $BalSql = "SELECT itemcode, quantityord - quantityrecd as balance FROM purchorderdetails WHERE orderno = '" . $myrow['orderno'] . "'"; - $ErrMsg = _('Failed to retrieve purchorder details'); - $BalResult = DB_query($BalSql,$ErrMsg); - if (DB_num_rows($BalResult)>0) { - while ($BalRow = DB_fetch_array($BalResult)) { - $Bal .= '<br/>' . $BalRow['itemcode'] . ' -- ' . $BalRow['balance']; - } - } - } - if (isset($_POST['PODetails'])) { - $BalRow = '<td width="250" style="word-break:break-all">' . $Bal . '</td>'; + $BalHead = '<th class="ascending">' . _('Balance') .' (' . _('Stock ID') . '--' . _('Quantity') . ' )</th>'; } else { - $BalRow = ''; + $BalHead = ''; } + echo '<tr> + <th class="ascending">' . _('Order #') . '</th> + <th class="ascending">' . _('Order Date') . '</th> + <th class="ascending">' . _('Delivery Date') . '</th> + <th class="ascending">' . _('Initiated by') . '</th> + <th class="ascending">' . _('Supplier') . '</th> + ' . $BalHead . ' + <th class="ascending">' . _('Currency') . '</th>'; - $ModifyPage = $RootPath . '/PO_Header.php?ModifyOrderNumber=' . $myrow['orderno']; - if ($myrow['status'] == 'Printed') { - $ReceiveOrder = '<a href="' . $RootPath . '/GoodsReceived.php?PONumber=' . $myrow['orderno'] . '">' . _('Receive') . '</a>'; - } else { - $ReceiveOrder = ''; + if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { + echo '<th class="ascending">' . _('Order Total') . '</th>'; } - if ($myrow['status'] == 'Authorised' AND $myrow['allowprint'] == 1) { - $PrintPurchOrder = '<a target="_blank" href="' . $RootPath . '/PO_PDFPurchOrder.php?OrderNo=' . $myrow['orderno'] . '">' . _('Print') . '</a>'; - } elseif ($myrow['status'] == 'Authorisied' AND $myrow['allowprint'] == 0) { - $PrintPurchOrder = _('Printed'); - } elseif ($myrow['status'] == 'Printed') { - $PrintPurchOrder = '<a target="_blank" href="' . $RootPath . '/PO_PDFPurchOrder.php?OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=2"> - ' . _('Print Copy') . '</a>'; - } else { - $PrintPurchOrder = _('N/A'); - } + echo '<th class="ascending">' . _('Status') . '</th> + <th>' . _('Print') . '</th> + <th>' . _('Receive') . '</th> + </tr>'; + $j = 1; + while ($myrow = DB_fetch_array($PurchOrdersResult)) { + $Bal = ''; + if (isset($_POST['PODetails'])) { + //lets retrieve the PO balance here to make it a standard sql query. + $BalSql = "SELECT itemcode, quantityord - quantityrecd as balance FROM purchorderdetails WHERE orderno = '" . $myrow['orderno'] . "'"; + $ErrMsg = _('Failed to retrieve purchorder details'); + $BalResult = DB_query($BalSql,$ErrMsg); + if (DB_num_rows($BalResult)>0) { + while ($BalRow = DB_fetch_array($BalResult)) { + $Bal .= '<br/>' . $BalRow['itemcode'] . ' -- ' . $BalRow['balance']; + } + } + } + if (isset($_POST['PODetails'])) { + $BalRow = '<td width="250" style="word-break:break-all">' . $Bal . '</td>'; + } else { + $BalRow = ''; + } - $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); - $FormatedDeliveryDate = ConvertSQLDate($myrow['deliverydate']); - $FormatedOrderValue = locale_number_format($myrow['ordervalue'], $myrow['currdecimalplaces']); - $sql = "SELECT realname FROM www_users WHERE userid='" . $myrow['initiator'] . "'"; - $UserResult = DB_query($sql); - $MyUserRow = DB_fetch_array($UserResult); - $InitiatorName = $MyUserRow['realname']; + $ModifyPage = $RootPath . '/PO_Header.php?ModifyOrderNumber=' . $myrow['orderno']; + if ($myrow['status'] == 'Printed') { + $ReceiveOrder = '<a href="' . $RootPath . '/GoodsReceived.php?PONumber=' . $myrow['orderno'] . '">' . _('Receive') . '</a>'; + } else { + $ReceiveOrder = ''; + } + if ($myrow['status'] == 'Authorised' AND $myrow['allowprint'] == 1) { + $PrintPurchOrder = '<a target="_blank" href="' . $RootPath . '/PO_PDFPurchOrder.php?OrderNo=' . $myrow['orderno'] . '">' . _('Print') . '</a>'; + } elseif ($myrow['status'] == 'Authorisied' AND $myrow['allowprint'] == 0) { + $PrintPurchOrder = _('Printed'); + } elseif ($myrow['status'] == 'Printed') { + $PrintPurchOrder = '<a target="_blank" href="' . $RootPath . '/PO_PDFPurchOrder.php?OrderNo=' . $myrow['orderno'] . '&realorderno=' . $myrow['realorderno'] . '&ViewingOnly=2"> + ' . _('Print Copy') . '</a>'; + } else { + $PrintPurchOrder = _('N/A'); + } - echo '<tr class="striped_row"> - <td><a href="' . $ModifyPage . '">' . $myrow['orderno'] . '</a></td> - <td>' . $FormatedOrderDate . '</td> - <td>' . $FormatedDeliveryDate . '</td> - <td>' . $InitiatorName . '</td> - <td>' . $myrow['suppname'] . '</td> - ' . $BalRow . ' - <td>' . $myrow['currcode'] . '</td>'; - if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { - echo '<td class="number">' . $FormatedOrderValue . '</td>'; - } - echo '<td>' . _($myrow['status']) . '</td> - <td>' . $PrintPurchOrder . '</td> - <td>' . $ReceiveOrder . '</td> - </tr>'; - } //end of while loop around purchase orders retrieved - echo '</table>'; + $FormatedOrderDate = ConvertSQLDate($myrow['orddate']); + $FormatedDeliveryDate = ConvertSQLDate($myrow['deliverydate']); + $FormatedOrderValue = locale_number_format($myrow['ordervalue'], $myrow['currdecimalplaces']); + $sql = "SELECT realname FROM www_users WHERE userid='" . $myrow['initiator'] . "'"; + $UserResult = DB_query($sql); + $MyUserRow = DB_fetch_array($UserResult); + $InitiatorName = $MyUserRow['realname']; + + echo '<tr class="striped_row"> + <td><a href="' . $ModifyPage . '">' . $myrow['orderno'] . '</a></td> + <td>' . $FormatedOrderDate . '</td> + <td>' . $FormatedDeliveryDate . '</td> + <td>' . $InitiatorName . '</td> + <td>' . $myrow['suppname'] . '</td> + ' . $BalRow . ' + <td>' . $myrow['currcode'] . '</td>'; + if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { + echo '<td class="number">' . $FormatedOrderValue . '</td>'; + } + echo '<td>' . _($myrow['status']) . '</td> + <td>' . $PrintPurchOrder . '</td> + <td>' . $ReceiveOrder . '</td> + </tr>'; + } //end of while loop around purchase orders retrieved + + echo '</table>'; + } } echo '</div> </form>'; Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2018-02-18 01:25:58 UTC (rev 7974) +++ trunk/doc/Change.log 2018-02-18 02:30:38 UTC (rev 7975) @@ -1,5 +1,6 @@ webERP Change Log +17/2/18 PaulT: PO_SelectOSPurchOrder.php: Derived from Tim's code: add default current dates. (there may not yet be any purchorders records) / PaulT: do not show the order list table when there are no records to show. (avoids a table heading output without any associated row data) 17/2/18 Tim (PaulT commit): MiscFunctions.js: Set the calendar click and change handlers to reference the localStorage DateFormat instead of the element's "alt" attribute value. (Know that this update requires the localStorage change applied with commit 7973) 17/2/18 PaulT: header.php: Set the DOCTYPE to html5 declaration format, update the meta tag with Content-Type info, and add localStorage with DateFormat and Theme for upcoming changes to table column sorting and calendar handling improvements. 17/2/18 PaulT: CustomerAllocations.php: Minor code shuffle to fix view page source message "Start tag 'div' seen in 'table'" reported in Firefox. |