Fixes #101 Large sites and SaleMaker vs Specials

<a href='#crh-start'></a><a href='#crh-data-%7B%22processed%22%3A%20%5B%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14975938%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976094%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976131%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976132%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976179%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976289%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23issuecomment-49110288%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977133%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977137%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977142%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14979117%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14979935%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14980861%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14981143%22%5D%2C%20%22comments%22%3A%20%7B%22General%20Comment%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23issuecomment-49110288%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A27%3A54Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%5D%2C%20%22title%22%3A%20%22General%20Comment%22%7D%2C%20%22Pull%20c372c4e582835802349dcec1e63571d5c15d6d15%20admin/specials.php%20321%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14975938%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%60%3Cb%3ETESTING%20ONLY%20WORKS%20ON%20MANUFACTURER%2010%3C/b%3E%60%20in%202%20places%3F%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A15%3A37Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Debug%20code%20now%20removed%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A21%3A48Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1992427%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/ajeh%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL697-752%22%7D%2C%20%22Pull%20e82ba64c9d2bb1e97c48fb064ce39a343109c194%20admin/specials.php%20120%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976179%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22ship%20vs%20skip%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A23%3A40Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20c372c4e582835802349dcec1e63571d5c15d6d15%20admin/specials.php%20231%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976132%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22same%20as%20227%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A21%3A49Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20b41046c2cc6f73ce47b04f4dea660d7e80b8a236%20admin/specials.php%20256%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977142%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Another%20unnecessary%20%60else%60%5Cr%5Cn%60%60%60php%5Cr%5Cn//%20do%20not%20show%20products%20when%20setting%20global%20additions%20or%20deletions%5Cr%5Cnif%20%28%24action%20%3D%3D%20%27%27%29%20%7B%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T01%3A01%3A12Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL543-554%22%7D%2C%20%22Pull%20b41046c2cc6f73ce47b04f4dea660d7e80b8a236%20admin/specials.php%20169%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977137%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Another%20unnecessary%20%60else%60%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%21%24check_special-%3EEOF%20%26%26%20%21%24skip_specials%29%20%7B%5Cr%5Cn%20%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T01%3A01%3A05Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22Still%20need%20the%20%60continue%60%20though.%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%21%24chk_special-%3EEOF%20%26%26%20%21%24skip_specials%29%20%7B%5Cr%5Cn%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%20else%20%7B%5Cr%5Cn%20%20continue%3B%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T02%3A44%3A49Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Unfortunately%2C%20neither%20of%20those%20ideas%20can%20work.%5Cr%5Cn%5Cr%5CnThe%20point%20of%20the%20%60continue%60%20is%20to%20break%20out%20of%20the%20loop%2C%20and%20not%20run%20the%20rest%20of%20the%20code.%20The%20%60else%60%20is%20to%20make%20the%20rest%20of%20the%20code%20%28do%20the%20insert%29%20execute.%5Cr%5Cn%22%2C%20%22created_at%22%3A%20%222014-07-16T03%3A32%3A21Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1992427%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/ajeh%22%7D%7D%2C%20%7B%22body%22%3A%20%22What%20are%20we%20trying%20to%20accomplish%3F%20%28It%27s%20not%20just%20about%20using%20%60else%60.%29%20%20For%20instance%2C%20if%20%60%24skip_specials%20%3D%3D%20true%60%20should%20we%20check%20for%20any%20specials%3F%20%20Perhaps%20I%20don%27t%20understand%20the%20purpose%20of%20%60%24skip_specials%60.%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%24skip_specials%29%20%7B%5Cr%5Cn%20%20continue%3B%5Cr%5Cn%7D%5Cr%5Cn%24products_id%20%3D%20zen_db_prepare_input%28%24new_specials_products_id%29%3B%5Cr%5Cn%24check_special_query%20%3D%20%5C%22SELECT%20products_id%20from%20%5C%22%20.%20TABLE_SPECIALS%20.%20%5C%22%20WHERE%20products_id%20%3D%20%27%5C%22%20.%20%24products_id%20.%20%5C%22%27%5C%22%3B%5Cr%5Cn%24check_special%20%3D%20%24db-%3EExecute%28%24check_special_query%29%3B%5Cr%5Cnif%20%28%21%24check_special-%3EEOF%29%20%7B%5Cr%5Cn%20%20%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T04%3A27%3A10Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22Remember%3A%20code%20review%20is%20not%20just%20syntax%20review.%20Gotta%20take%20the%20larger%20context%20into%20the%20picture.%5Cr%5CnThis%20larger%20block%20of%20code%20is%20for%20doing%20a%20mass-insert%20of%20records%20to%20put%20products%20on%20special%20based%20on%20being%20in%20a%20specified%20category.%5Cr%5Cn%5Cr%5CnThe%20couple%20lines%20under%20scrutiny%20here%20are%20doing%3A%5Cr%5Cn%60%60%60%5Cr%5Cngiven%20that%20%28there%27s%20an%20existing%20special%20in%20the%20db%29%20%7B%5Cr%5Cn%20%20if%20%28we%27re%20supposed%20to%20leave%20existing%20specials%20alone%2C%20instead%20of%20replacing%20them%20with%20a%20new%20special%29%20%7B%5Cr%5Cn%20%20%20%20%20then%20jump%20to%20the%20next%20record%20%28continue%29%5Cr%5Cn%20%20else%20%5Cr%5Cn%20%20%20%20%20since%20there%27s%20an%20existing%20record%2C%20we%20need%20to%20delete%20it%20%28so%20we%20can%20replace%20it%20with%20a%20new%20one%20below%29%5Cr%5Cn%20%20%7D%20%5Cr%5Cn%7D%5Cr%5Cn...%20and%20now%20that%20we%27ve%20cleaned%20up%20the%20existing%20record%2C%20we%20proceed%20with%20%5Cr%5Cnthe%20rest%20of%20the%20following%20steps%20to%20insert%20the%20requested%20new%20record.%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T04%3A46%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20b41046c2cc6f73ce47b04f4dea660d7e80b8a236%20admin/specials.php%2028%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977133%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Please%20condense%20these.%20%20The%20%60else%60%20statements%20are%20%5Bnot%20necessary%5D%28http%3A//c2.com/cgi/wiki%3FElseConsideredSmelly%29.%20%20%28also%20other%20similar%20occurrences%20below%29%5Cr%5Cn%60%60%60php%5Cr%5Cn%24skip_specials%20%3D%20%28%24_POST%5B%27skip_specials%27%5D%20%3D%3D%20%27skip_specials_yes%27%29%3B%5Cr%5Cn//%20etc.%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T01%3A00%3A57Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20c372c4e582835802349dcec1e63571d5c15d6d15%20admin/specials.php%20162%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976094%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22ship_specials%20vs%20skip_specials%3F%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A20%3A27Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Typo%20fixed%20on%20all%204%20lines%20fixed%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A26%3A53Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1992427%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/ajeh%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%7D%7D'></a>
<a href='https://www.codereviewhub.com/'><img src='http://www.codereviewhub.com/site/github-bar.png' height=40></a>
- [x] <a href='#crh-comment-Pull c372c4e582835802349dcec1e63571d5c15d6d15 admin/specials.php 321'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14975938'>File: admin/specials.php:L697-752</a></b>
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> `<b>TESTING ONLY WORKS ON MANUFACTURER 10</b>` in 2 places?
- <a href='https://github.com/ajeh'><img border=0 src='https://avatars.githubusercontent.com/u/1992427?size=16' height=16 width=16'></a> Debug code now removed
- [x] <a href='#crh-comment-Pull c372c4e582835802349dcec1e63571d5c15d6d15 admin/specials.php 162'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14976094'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> ship_specials vs skip_specials?
- <a href='https://github.com/ajeh'><img border=0 src='https://avatars.githubusercontent.com/u/1992427?size=16' height=16 width=16'></a> Typo fixed on all 4 lines fixed
- [x] <a href='#crh-comment-Pull c372c4e582835802349dcec1e63571d5c15d6d15 admin/specials.php 231'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14976132'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> same as 227
- [x] <a href='#crh-comment-Pull e82ba64c9d2bb1e97c48fb064ce39a343109c194 admin/specials.php 120'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14976179'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> ship vs skip
- [ ] <a href='#crh-comment-Pull b41046c2cc6f73ce47b04f4dea660d7e80b8a236 admin/specials.php 28'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14977133'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Please condense these.  The `else` statements are [not necessary](http://c2.com/cgi/wiki?ElseConsideredSmelly).  (also other similar occurrences below)
```php
$skip_specials = ($_POST['skip_specials'] == 'skip_specials_yes');
// etc.
```
- [ ] <a href='#crh-comment-Pull b41046c2cc6f73ce47b04f4dea660d7e80b8a236 admin/specials.php 169'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14977137'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Another unnecessary `else`
```php
if (!$check_special->EOF && !$skip_specials) {
$db->Execute(...
}
```
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> Still need the `continue` though.
```php
if (!$chk_special->EOF && !$skip_specials) {
$db->Execute(...
} else {
continue;
}
```
- <a href='https://github.com/ajeh'><img border=0 src='https://avatars.githubusercontent.com/u/1992427?size=16' height=16 width=16'></a> Unfortunately, neither of those ideas can work.
The point of the `continue` is to break out of the loop, and not run the rest of the code. The `else` is to make the rest of the code (do the insert) execute.
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> What are we trying to accomplish? (It's not just about using `else`.)  For instance, if `$skip_specials == true` should we check for any specials?  Perhaps I don't understand the purpose of `$skip_specials`.
```php
if ($skip_specials) {
continue;
}
$products_id = zen_db_prepare_input($new_specials_products_id);
$check_special_query = "SELECT products_id from " . TABLE_SPECIALS . " WHERE products_id = '" . $products_id . "'";
$check_special = $db->Execute($check_special_query);
if (!$check_special->EOF) {
$db->Execute(...
}
```
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> Remember: code review is not just syntax review. Gotta take the larger context into the picture.
This larger block of code is for doing a mass-insert of records to put products on special based on being in a specified category.
The couple lines under scrutiny here are doing:
```
given that (there's an existing special in the db) {
if (we're supposed to leave existing specials alone, instead of replacing them with a new special) {
then jump to the next record (continue)
else
since there's an existing record, we need to delete it (so we can replace it with a new one below)
}
}
... and now that we've cleaned up the existing record, we proceed with
the rest of the following steps to insert the requested new record.
```
- [ ] <a href='#crh-comment-Pull b41046c2cc6f73ce47b04f4dea660d7e80b8a236 admin/specials.php 256'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14977142'>File: admin/specials.php:L543-554</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Another unnecessary `else`
```php
// do not show products when setting global additions or deletions
if ($action == '') {
```


<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/102?mark_as_completed=1'><img src='http://www.codereviewhub.com/site/github-mark-as-completed.png' height=26></a>&nbsp;<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/102?approve=1'><img src='http://www.codereviewhub.com/site/github-approve.png' height=26></a>&nbsp;<a href='https://github.com/zencart/zc-v1-series/pull/102'><img src='http://www.codereviewhub.com/site/github-refresh.png' height=26></a>
<a href='#crh-end'></a>
Right, what I'm getting at is beyond syntax.  If `$skip_specials == true`, there's nothing else that needs to be done.  So, the entire loop can be skipped;  no delete, no insert, just skip specials altogether.