From: <rc...@us...> - 2014-12-27 18:29:12
|
Revision: 7043 http://sourceforge.net/p/web-erp/reponame/7043 Author: rchacon Date: 2014-12-27 18:28:36 +0000 (Sat, 27 Dec 2014) Log Message: ----------- In AutomaticTranslationDescriptions.php, add comment for the SVN repository automatically updates the revision number, add $ViewTopic and $BookMark, and else if no translation. Add info to manual. Modified Paths: -------------- trunk/AutomaticTranslationDescriptions.php trunk/doc/Change.log trunk/doc/Manual/ManualSpecialUtilities.html trunk/includes/MainMenuLinksArray.php Modified: trunk/AutomaticTranslationDescriptions.php =================================================================== --- trunk/AutomaticTranslationDescriptions.php 2014-12-27 16:12:40 UTC (rev 7042) +++ trunk/AutomaticTranslationDescriptions.php 2014-12-27 18:28:36 UTC (rev 7043) @@ -1,110 +1,123 @@ -<?php - -include ('includes/session.inc'); -$Title = _('Automatic Translation - Descriptions'); -include ('includes/header.inc'); -include ('includes/GoogleTranslator.php'); - -$SourceLanguage=mb_substr($_SESSION['Language'],0,2); - -// Select items and classify them -$SQL = "SELECT stockmaster.stockid, - description, - longdescription, - language_id, - descriptiontranslation, - longdescriptiontranslation - FROM stockmaster, stockdescriptiontranslations - WHERE stockmaster.stockid = stockdescriptiontranslations.stockid - AND (descriptiontranslation = '' - OR longdescriptiontranslation = '') - ORDER BY stockmaster.stockid, - language_id"; -$result = DB_query($SQL); - -if (DB_num_rows($result) != 0){ - echo '<p class="page_title_text" align="center"><strong>' . _('Description Automatic Translation for empty translations') . '</strong></p>'; - echo '<div>'; - echo '<table class="selection">'; - $TableHeader = '<tr> - <th>' . _('#') . '</th> - <th>' . _('Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('To') . '</th> - <th>' . _('Translated') . '</th> - </tr>'; - echo $TableHeader; - $k = 0; //row colour counter - $i = 0; - while ($myrow = DB_fetch_array($result)) { - - if ($myrow['descriptiontranslation'] == ''){ - $TargetLanguage=mb_substr($myrow['language_id'],0,2); - $TranslatedText = translate_via_google_translator($myrow['description'],$TargetLanguage,$SourceLanguage); - - $sql = "UPDATE stockdescriptiontranslations " . - "SET descriptiontranslation='" . $TranslatedText . "', " . - "needsrevision= '1' " . - "WHERE stockid='" . $myrow['stockid'] . "' AND (language_id='" . $myrow['language_id'] . "')"; - $update = DB_query($sql, $ErrMsg, $DbgMsg, true); - - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - echo '<tr class="OddTableRows">'; - $k++; - } - $i++; - printf('<td class="number">%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - </tr>', - $i, - $myrow['stockid'], - $myrow['description'], - $myrow['language_id'], - $TranslatedText - ); - } - if ($myrow['longdescriptiontranslation'] == ''){ - $TargetLanguage=mb_substr($myrow['language_id'],0,2); - $TranslatedText = translate_via_google_translator($myrow['longdescription'],$TargetLanguage,$SourceLanguage); - - $sql = "UPDATE stockdescriptiontranslations " . - "SET longdescriptiontranslation='" . $TranslatedText . "', " . - "needsrevision= '1' " . - "WHERE stockid='" . $myrow['stockid'] . "' AND (language_id='" . $myrow['language_id'] . "')"; - $update = DB_query($sql, $ErrMsg, $DbgMsg, true); - - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - echo '<tr class="OddTableRows">'; - $k++; - } - $i++; - printf('<td class="number">%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - </tr>', - $i, - $myrow['stockid'], - $myrow['longdescription'], - $myrow['language_id'], - $TranslatedText - ); - } - } - echo '</table> - </div>'; - prnMsg("Number of translated descriptions via Google API: " . locale_number_format($i)); -} - -include ('includes/footer.inc'); -?> \ No newline at end of file +<?php +/* $Id: AutomaticTranslationDescriptions.php 7037 2014-12-22 14:45:20Z tehonu $ */ + +include ('includes/session.inc'); +$Title = _('Translate Item Descriptions'); +$ViewTopic = 'SpecialUtilities'; // Filename in ManualContents.php's TOC. +$BookMark = 'Z_TranslateItemDescriptions'; // Anchor's id in the manual's html document. +include ('includes/header.inc'); + +include ('includes/GoogleTranslator.php'); + +$SourceLanguage=mb_substr($_SESSION['Language'],0,2); + +// Select items and classify them +$SQL = "SELECT stockmaster.stockid, + description, + longdescription, + language_id, + descriptiontranslation, + longdescriptiontranslation + FROM stockmaster, stockdescriptiontranslations + WHERE stockmaster.stockid = stockdescriptiontranslations.stockid + AND (descriptiontranslation = '' + OR longdescriptiontranslation = '') + ORDER BY stockmaster.stockid, + language_id"; +$result = DB_query($SQL); + +if(DB_num_rows($result) != 0) { + echo '<p class="page_title_text" align="center"><strong>' . _('Description Automatic Translation for empty translations') . '</strong></p>'; + echo '<div>'; + echo '<table class="selection">'; + $TableHeader = '<tr> + <th>' . _('#') . '</th> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('To') . '</th> + <th>' . _('Translated') . '</th> + </tr>'; + echo $TableHeader; + $k = 0; //row colour counter + $i = 0; + while ($myrow = DB_fetch_array($result)) { + + if ($myrow['descriptiontranslation'] == ''){ + $TargetLanguage=mb_substr($myrow['language_id'],0,2); + $TranslatedText = translate_via_google_translator($myrow['description'],$TargetLanguage,$SourceLanguage); + + $sql = "UPDATE stockdescriptiontranslations " . + "SET descriptiontranslation='" . $TranslatedText . "', " . + "needsrevision= '1' " . + "WHERE stockid='" . $myrow['stockid'] . "' AND (language_id='" . $myrow['language_id'] . "')"; + $update = DB_query($sql, $ErrMsg, $DbgMsg, true); + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + $i++; + printf('<td class="number">%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + </tr>', + $i, + $myrow['stockid'], + $myrow['description'], + $myrow['language_id'], + $TranslatedText + ); + } + if ($myrow['longdescriptiontranslation'] == ''){ + $TargetLanguage=mb_substr($myrow['language_id'],0,2); + $TranslatedText = translate_via_google_translator($myrow['longdescription'],$TargetLanguage,$SourceLanguage); + + $sql = "UPDATE stockdescriptiontranslations " . + "SET longdescriptiontranslation='" . $TranslatedText . "', " . + "needsrevision= '1' " . + "WHERE stockid='" . $myrow['stockid'] . "' AND (language_id='" . $myrow['language_id'] . "')"; + $update = DB_query($sql, $ErrMsg, $DbgMsg, true); + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + $i++; + printf('<td class="number">%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + </tr>', + $i, + $myrow['stockid'], + $myrow['longdescription'], + $myrow['language_id'], + $TranslatedText + ); + } + } + echo '</table> + </div>'; + prnMsg("Number of translated descriptions via Google API: " . locale_number_format($i)); +} else { + +echo '<p class="page_title_text"><img alt="" src="' . $RootPath . '/css/' . $Theme . + '/images/maintenance.png" title="' . + _('No item description was automatically translated') . '" />' . ' ' . + _('No item description was automatically translated') . '</p>'; + +// Add error message for "Google Translator API Key" empty. + +} + +include ('includes/footer.inc'); +?> Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2014-12-27 16:12:40 UTC (rev 7042) +++ trunk/doc/Change.log 2014-12-27 18:28:36 UTC (rev 7043) @@ -1,5 +1,6 @@ webERP Change Log +27/12/14 RChacon: In AutomaticTranslationDescriptions.php, add comment for the SVN repository automatically updates the revision number, add $ViewTopic and $BookMark, and else if no translation. Add info to manual. 27/12/14 RChacon: Set boolean field needrevision to tiny integer with a maximum display width of 1, signed and not null. Add comments to sql file. 20/12/14 Exson: Make COGSGLPostings.php, SalesGLPostings.php SQL strict mode compatible. 20/12/14 Exson: Remove item from weberpchina.sql Modified: trunk/doc/Manual/ManualSpecialUtilities.html =================================================================== --- trunk/doc/Manual/ManualSpecialUtilities.html 2014-12-27 16:12:40 UTC (rev 7042) +++ trunk/doc/Manual/ManualSpecialUtilities.html 2014-12-27 18:28:36 UTC (rev 7043) @@ -4,22 +4,61 @@ <p>The Utility menu is a separate module so access can be turned off to hide these utility script links by turning off the Utilities module in user settings. All utlity pages are prefixed with a Z_.</p> -<h2>Re-Apply Standard Costs to Sales Analysis</h2> +<h2><a id="Z_ChangeCustomerCode">Change A Customer Code</a></h2> -<p>This utility allows a period to be selected for which the current standard cost is applied to the quantities recorded in the sales analysis as sold to re-calculate the cost of goods sold.</p> +<p>This page requires the entry of an existing customer code and the new customer code. The system checks to see the new code entered doesn't already exist and that the code entered for the existing customer does exist. If all is well then the customer code data is changed in all tables throughout the system that refer to the customer code. Due to the extensive changes taking place throughout the database this utility should not be run during normal operating hours when others are using the system.</p> -<p>It is important to realise that this will destroy the integrity of the matching general ledger journals created at the time of invoicing and that the GL cost of sales will no longer match with the sales analysis cost of sales.</p> +<h2><a id="Z_ChangeCustomerCode">Change A Customer Code</a></h2> -<p>However, occasionally incorrect cost data that has made a monkey of the sales analysis and general ledger can only be rectified by running this utility.</p> +<p>.</p> -<h2>Change A Customer Code</h2> +<h2><a id="Z_ChangeBranchCode">Change A Customer Branch Code</a></h2> -<p>This page requires the entry of an existing customer code and the new customer code. The system checks to see the new code entered doesn't already exist and that the code entered for the existing customer does exist. If all is well then the customer code data is changed in all tables throughout the system that refer to the customer code. Due to the extensive changes taking place throughout the database this utility should not be run during normal operating hours when others are using the system.</p> +<p>.</p> +<h2><a id="Z_ChangeSupplierCode">Change A Supplier Code</a></h2> + +<p>.</p> + +<h2><a id="Z_ChangeStockCategory">Change A Stock Category Code</a></h2> + +<p>.</p> + <h2><a id="Z_ChangeStockCode">Change An Inventory Item Code</a></h2> <p>This page requires the entry of an existing stock code and the new stock code. The system checks to see the new code entered doesn't already exist and that the code entered for the existing item does exist. If all is well then the stock code data is changed in all tables through-out the system. Sales analysis, stock movements, stock locations, Bills of Material, parent and component items, sales order details and purchase order details as well as the Stock Master, pricing and shipment charges. Due to the extensive changes taking place throughout the database this utility should not be run during normal operating hours, when others are using the system.</p> +<p>.</p> + +<h2><a id="Z_ChangeGLAccountCode">Change A GL Account Code</a></h2> + +<p>.</p> + +<h2><a id="Z_ChangeLocationCode">Change A Location Code</a></h2> + +<p>.</p> + +<h2><a id="Z_TranslateItemDescriptions">Translate Item Descriptions</a></h2> + +<p> +This utility uses the Google Translator API to automatically translate item descriptions (short and long part descriptions).</p> + +<p>It translates from the item description in the default language (It was set up in $DefaultLanguage in config) to the languages to maintain translations for item descriptions (They were set up in <u>Main Menu</u> > <u>Setup</u> > General Setup Options > <u>System Parameters</u> > General Settings).</p> + +<p>It requieres a Google Translator API Key (more info in <a href="https://cloud.google.com/translate/" target=_blank">https://cloud.google.com/translate/</a>) to allow automatic translations.</p> + +<h2><a id="Z_BottomUpCosts">Update costs for all BOM items, from the bottom up</a></h2> + +<p>.</p> + +<h2><a id="Z_ReApplyCostToSA">Re-apply costs to Sales Analysis</a></h2> + +<p>This utility allows a period to be selected for which the current standard cost is applied to the quantities recorded in the sales analysis as sold to re-calculate the cost of goods sold.</p> + +<p>It is important to realise that this will destroy the integrity of the matching general ledger journals created at the time of invoicing and that the GL cost of sales will no longer match with the sales analysis cost of sales.</p> + +<p>However, occasionally incorrect cost data that has made a monkey of the sales analysis and general ledger can only be rectified by running this utility.</p> + <h2>Make Stock Locations</h2> <p>If the inventory database is imported from some other system, the stock location records can be created for all locations currently defined by running the script Z_MakeStockLocns.php. Inventory items will not appear on searches during entry of sales orders until their corresponding inventory locations records exist.</p> Modified: trunk/includes/MainMenuLinksArray.php =================================================================== --- trunk/includes/MainMenuLinksArray.php 2014-12-27 16:12:40 UTC (rev 7042) +++ trunk/includes/MainMenuLinksArray.php 2014-12-27 18:28:36 UTC (rev 7043) @@ -550,7 +550,7 @@ _('Change An Inventory Item Code'), _('Change A GL Account Code'), _('Change A Location Code'), - _('Automatic Translation - Item descriptions'), + _('Translate Item Descriptions'), _('Update costs for all BOM items, from the bottom up'), _('Re-apply costs to Sales Analysis'), _('Delete sales transactions'), |