From: <dai...@us...> - 2017-03-11 01:52:19
|
Revision: 7738 http://sourceforge.net/p/web-erp/reponame/7738 Author: daintree Date: 2017-03-11 01:52:17 +0000 (Sat, 11 Mar 2017) Log Message: ----------- committed for Tim - not sure why he didnt commit it himself - improvment to selectorderitems.php to allow import of order line items from a CSV Modified Paths: -------------- trunk/SelectOrderItems.php trunk/doc/Change.log Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2017-03-07 18:01:30 UTC (rev 7737) +++ trunk/SelectOrderItems.php 2017-03-11 01:52:17 UTC (rev 7738) @@ -33,6 +33,35 @@ } } +if (isset($_POST['UploadFile'])) { + if (isset($_FILES['CSVFile']) and $_FILES['CSVFile']['name']) { + //check file info + $FileName = $_FILES['CSVFile']['name']; + $TempName = $_FILES['CSVFile']['tmp_name']; + $FileSize = $_FILES['CSVFile']['size']; + //get file handle + $FileHandle = fopen($TempName, 'r'); + $Row = 0; + $InsertNum = 0; + while (($FileRow = fgetcsv($FileHandle, 10000, ",")) !== False) { + /* Check the stock code exists */ + ++$Row; + $SQL = "SELECT stockid FROM stockmaster WHERE stockid='" . $FileRow[0] . "'"; + $Result = DB_query($SQL); + if (DB_num_rows($Result) > 0) { + $NewItemArray[$FileRow[0]] = filter_number_format($FileRow[1]); + ++$InsertNum; + } + } + } + $_POST['SelectingOrderItems'] = 1; + if (sizeof($NewItemArray) == 0) { + prnMsg(_('There are no items that can be imported'), 'error'); + } else { + prnMsg($InsertNum . ' ' . _('of') . ' ' . $Row . ' ' . _('rows have been added to the order'), 'info'); + } +} + if (isset($_GET['NewItem'])){ $NewItem = trim($_GET['NewItem']); } @@ -802,7 +831,7 @@ #Always do the stuff below if not looking for a customerid - echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?identifier='.$identifier . '" id="SelectParts" method="post">'; + echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?identifier='.$identifier . '" id="SelectParts" method="post" enctype="multipart/form-data">'; echo '<div>'; echo '<input name="FormID" type="hidden" value="' . $_SESSION['FormID'] . '" />'; @@ -1623,10 +1652,19 @@ echo '<td style="text-align:center" colspan="1"><input tabindex="6" type="submit" name="ChangeCustomer" value="' . _('Change Customer') . '" /></td> <td style="text-align:center" colspan="1"><input tabindex="7" type="submit" name="SelectAsset" value="' . _('Fixed Asset Disposal') . '" /></td>'; } + echo '<tr> + <td colspan="10"> + <div class="centre"> + <h2>' . _('Or') . '</h2> + ' . _('Upload items from csv file') . '<input tabindex="5" type="file" name="CSVFile" /> + <input tabindex="5" type="submit" name="UploadFile" value="' . _('Upload File') . '" /> + </div> + </td>'; echo '</tr> </table> <br /> </div>'; + echo '<div class="page_help_text">' . _('The csv file should have exactly 2 columns, part code and quantity.') . '</div>'; if (isset($SearchResult)) { echo '<br />'; echo '<div class="page_help_text">' . _('Select an item by entering the quantity required. Click Order when ready.') . '</div>'; Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2017-03-07 18:01:30 UTC (rev 7737) +++ trunk/doc/Change.log 2017-03-11 01:52:17 UTC (rev 7738) @@ -1,5 +1,7 @@ webERP Change Log + +11/3/17 Tim - committed by Phil: allow sales order item lines to be imported from a csv consisting of lines of item code, quantity 07/03/17 TurboPT: (by Tim in forums) BankAccounts.php: Add quotes to variable in query. 27/02/17 TurboPT: SpecialOrder.php add identifier to delete link; DefineSpecialOrderClass.php remove the "&" with parameter to function remove_from_order(). 26/02/17 TurboPT: CopyBOM.php fixed insert SQL had duplicate digitals field |