Skip to content

Commit 06fafe5

Browse files
committed
use brands table
1 parent ca48c52 commit 06fafe5

2 files changed

Lines changed: 34 additions & 34 deletions

File tree

Brands.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@
9191
}
9292
}
9393

94-
$SQL = "UPDATE manufacturers SET manufacturers_name='" . $_POST['BrandsName'] . "',
95-
manufacturers_url='" . $_POST['BrandsURL'] . "'";
94+
$SQL = "UPDATE brands SET brands_name='" . $_POST['BrandsName'] . "',
95+
brands_url='" . $_POST['BrandsURL'] . "'";
9696
if (isset($_POST['BrandsImage'])){
97-
$SQL .= ", manufacturers_image='" . $_POST['BrandsImage'] . "'";
97+
$SQL .= ", brands_image='" . $_POST['BrandsImage'] . "'";
9898
}
99-
$SQL .= " WHERE manufacturers_id = '" . $SelectedBrand . "'";
99+
$SQL .= " WHERE brands_id = '" . $SelectedBrand . "'";
100100

101101
$ErrMsg = __('An error occurred updating the') . ' ' . $SelectedBrand . ' ' . __('brand record because');
102102

@@ -112,14 +112,14 @@
112112

113113
/*SelectedBrand is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Location form */
114114

115-
$SQL = "INSERT INTO manufacturers (manufacturers_name,
116-
manufacturers_url)
115+
$SQL = "INSERT INTO brands (brands_name,
116+
brands_url)
117117
VALUES ('" . $_POST['BrandsName'] . "',
118118
'" . $_POST['BrandsURL'] . "')";
119119

120120
$ErrMsg = __('An error occurred inserting the new brand record because');
121121
$Result = DB_query($SQL, $ErrMsg);
122-
$LastInsertId = DB_Last_Insert_ID('manufacturers', 'manufacturers_id');
122+
$LastInsertId = DB_Last_Insert_ID('brands', 'brands_id');
123123

124124
if (isset($_FILES['BrandPicture']) AND $_FILES['BrandPicture']['name'] !='') {
125125

@@ -154,9 +154,9 @@
154154
if ($UploadTheFile=='Yes'){
155155
$Result = move_uploaded_file($_FILES['BrandPicture']['tmp_name'], $FileName);
156156
$Message = ($Result)?__('File url') . '<a href="' . $FileName .'">' . $FileName . '</a>' : __('Something is wrong with uploading a file');
157-
DB_query("UPDATE manufacturers
158-
SET manufacturers_image='" . 'BRAND-' . $LastInsertId . "'
159-
WHERE manufacturers_id = '" . $LastInsertId . "'
157+
DB_query("UPDATE brands
158+
SET brands_image='" . 'BRAND-' . $LastInsertId . "'
159+
WHERE brands_id = '" . $LastInsertId . "'
160160
");
161161
}
162162
}
@@ -175,7 +175,7 @@
175175
$CancelDelete = false;
176176

177177
// PREVENT DELETES IF DEPENDENT RECORDS
178-
$SQL= "SELECT COUNT(*) FROM salescatprod WHERE manufacturers_id='". $SelectedBrand . "'";
178+
$SQL= "SELECT COUNT(*) FROM salescatprod WHERE brands_id='". $SelectedBrand . "'";
179179
$Result = DB_query($SQL);
180180
$MyRow = DB_fetch_row($Result);
181181
if ($MyRow[0]>0) {
@@ -186,7 +186,7 @@
186186

187187
if (!$CancelDelete) {
188188

189-
$Result = DB_query("DELETE FROM manufacturers WHERE manufacturers_id='" . $SelectedBrand . "'");
189+
$Result = DB_query("DELETE FROM brands WHERE brands_id='" . $SelectedBrand . "'");
190190
foreach ($SupportedImgExt as $Ext) {
191191
$File = $_SESSION['part_pics_dir'] . '/BRAND-' . $SelectedBrand . '.' . $Ext;
192192
if (file_exists ($File) ) {
@@ -207,11 +207,11 @@
207207
links to delete or edit each. These will call the same page again and allow update/input
208208
or deletion of the records*/
209209

210-
$SQL = "SELECT manufacturers_id,
211-
manufacturers_name,
212-
manufacturers_url,
213-
manufacturers_image
214-
FROM manufacturers";
210+
$SQL = "SELECT brands_id,
211+
brands_name,
212+
brands_url,
213+
brands_image
214+
FROM brands";
215215
$Result = DB_query($SQL);
216216

217217
if (DB_num_rows($Result)==0){
@@ -230,17 +230,17 @@
230230
</tr>';
231231

232232
while ($MyRow = DB_fetch_array($Result)) {
233-
$Glob = (glob($_SESSION['part_pics_dir'] . '/BRAND-' . $MyRow['manufacturers_id'] . '.{' . implode(",", $SupportedImgExt) . '}', GLOB_BRACE));
233+
$Glob = (glob($_SESSION['part_pics_dir'] . '/BRAND-' . $MyRow['brands_id'] . '.{' . implode(",", $SupportedImgExt) . '}', GLOB_BRACE));
234234
$ImageFile = reset($Glob);
235-
$BrandImgLink = GetImageLink($ImageFile, '/BRAND-' . $MyRow['manufacturers_id'], 120, 120, "", "");
235+
$BrandImgLink = GetImageLink($ImageFile, '/BRAND-' . $MyRow['brands_id'], 120, 120, "", "");
236236

237237
echo '<tr class="striped_row">
238-
<td>', $MyRow['manufacturers_id'], '</td>
239-
<td>', $MyRow['manufacturers_name'], '</td>
240-
<td><a target="_blank" href="', $MyRow['manufacturers_url'], '">', $MyRow['manufacturers_url'], '</a></td>
238+
<td>', $MyRow['brands_id'], '</td>
239+
<td>', $MyRow['brands_name'], '</td>
240+
<td><a target="_blank" href="', $MyRow['brands_url'], '">', $MyRow['brands_url'], '</a></td>
241241
<td>', $BrandImgLink, '</td>
242-
<td><a href="', htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?SelectedBrand=', $MyRow['manufacturers_id'], '&amp;edit=1">' . __('Edit') . '</a></td>
243-
<td><a href="', htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?SelectedBrand=', $MyRow['manufacturers_id'], '&amp;delete=1" onclick="return confirm(\'' . __('Are you sure you wish to delete this brand?') . '\');">' . __('Delete') . '</a></td>
242+
<td><a href="', htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?SelectedBrand=', $MyRow['brands_id'], '&amp;edit=1">' . __('Edit') . '</a></td>
243+
<td><a href="', htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?SelectedBrand=', $MyRow['brands_id'], '&amp;delete=1" onclick="return confirm(\'' . __('Are you sure you wish to delete this brand?') . '\');">' . __('Delete') . '</a></td>
244244
</tr>';
245245

246246
}
@@ -264,19 +264,19 @@
264264
echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/supplier.png" Title="' .
265265
__('Brand') . '" alt="" />' . ' ' . $Title . '</p>';
266266

267-
$SQL = "SELECT manufacturers_id,
268-
manufacturers_name,
269-
manufacturers_url,
270-
manufacturers_image
271-
FROM manufacturers
272-
WHERE manufacturers_id='" . $SelectedBrand . "'";
267+
$SQL = "SELECT brands_id,
268+
brands_name,
269+
brands_url,
270+
brands_image
271+
FROM brands
272+
WHERE brands_id='" . $SelectedBrand . "'";
273273

274274
$Result = DB_query($SQL);
275275
$MyRow = DB_fetch_array($Result);
276276

277-
$_POST['BrandsName'] = $MyRow['manufacturers_name'];
278-
$_POST['BrandsURL'] = $MyRow['manufacturers_url'];
279-
$_POST['BrandsImage'] = $MyRow['manufacturers_image'];
277+
$_POST['BrandsName'] = $MyRow['brands_name'];
278+
$_POST['BrandsURL'] = $MyRow['brands_url'];
279+
$_POST['BrandsImage'] = $MyRow['brands_image'];
280280

281281

282282
echo '<input type="hidden" name="SelectedBrand" value="' . $SelectedBrand . '" />';

sql/updates/52.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
// Complete conversion of "Manufacturers" feature to (correctly) "Brands"
3+
// Complete conversion of incorrectly named "Manufacturers" feature to "Brands"
44
// - Reference https://github.com/timschofield/webERP/wiki/PLM-Features-Rename-manufacturers-table
55
// - Resolves https://github.com/timschofield/webERP/issues/678
66
// - assumes Manufacturers.php has been renamed Brands.php before update and ALL references to manufacturers

0 commit comments

Comments
 (0)