Jump to content
MakeWebGames

Shops item stock - as requested (Not Tested)


radio_active

Recommended Posts

Well Joss someone requested this so i decided to whip something up, but note i have not tested it.

Files to edit and or replace: itembuy.php && shops.php

SQL: 1 Alter SQL

Cron 1 cron edit.

itembuy.php you can either replace with this:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

Or add these to your own (probably safer).

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

Now shops.php

Im not posting all the edits because they are annoying so you can just have this one which is not tested also, lol

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

That has a little add on aswell, person in forums posted ages back, just a javascript total amount quantifer.

 

SQL

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

CRON: Add to whatever cron you see fit. Id do the day or week cron.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

And thats it.

 

Post all errors, do not post the same error twice though. (If you use it that is)

I will test it all out tomorrow and maybe even add it to my site.

 

Enjoy :-)

EDIT: Forgot to add the quantity to the tables when viewing items in shops, oops

Link to comment
Share on other sites

Re: [MCcode v2] Item Stock as requestsed (Not Tested)

From what I can already see your going to want to change the staff_shops.php page. Its going to give an error when adding new items to shops. Something along the lines of Column count doesn't match as the error.

Edit://

You can always find $db->query("INSERT INTO shopitems VALUES('',{$_POST['shop']},{$_POST['item']})");

in staff_shops.php and replace with

$db->query("INSERT INTO shopitems VALUES('',{$_POST['shop']},{$_POST['item'], ''})");

then put in a quantity manually.

 

or

in staff_shops.php find $db->query("INSERT INTO shopitems VALUES('',{$_POST['shop']},{$_POST['item']})");

and replace with $db->query("INSERT INTO shopitems VALUES('',{$_POST['shop']},{$_POST['item']},{$_POST['qty']})");

then find Item: ".item_dropdown($c,"item")."

 

and underneath add <input type='text' size='5' name='qty' value='0' id='qty' />

 

so you can place in a quantity and not have to do it manually.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

ishmell, if your selecting only the fields needed in your queries eg

$g = $db->query("insert into shops (shopname,shopdesc) values ($_POST['name'],$_POST['desc']");

It wont spill and error, the SQL has a default which if you wish you can set to 100 meaning when you add an item, the stock will be 100 when added, or you can add it and wait for it to be updated, however...

If your using SELECT *

then it will spill out the Column count Doesn't match blah blah.... =)

BUt thanks for pointing it out for other people who use SELECT *

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

You would want to replace that with what you said if it has a default, if it has no default then you would want to put '0' in that last part... :-)

EDIT: Gave a better example

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

Ok well I decided to try out the mod. In shops.php when trying to click a shop it does not show the shops id in the end of the url so the url looks liek this when the shop is clicked...

http://streetsrising.iiistudios.com/shops.php?shop= <<< shop id missing.

Then if I put in an id and go to the shop I get this error o.o

QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.itmtypename FROM shopitems si ' at line 4

Query was SELECT si.sitemID,sitemSHOP,sitemITEMID,sitemQTY, i.itmid,itmname,itmdesc,itmbuyprice,itmsellprice,itmtype it.itmtypename FROM shopitems si LEFT JOIN items i ON si.sitemITEMID = i.itmid LEFT JOIN itemtypes it ON i.itmtype = it.itmtypeid WHERE si.sitemSHOP = ('1') ORDER BY i.itmtype ASC, i.itmbuyprice ASC, i.itmname ASC

Not trying to be a pest, just testing the mod out for you.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

Thanks, i need a test...

in shops.php put this in it replacing the current one (about 10 lines down)

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

If it still doesnt show, just put this there

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

and then replace the $qtwo query with this, was missing a , on the selects.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Then report back xD

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

ok well I got this on shops.php

Parse error: syntax error, unexpected T_INT_CAST in /home/blackshe/public_html/streetsrising/shops.php on line 9

line 9: $_GET['shop'] = abs(int)$_GET['shop']);

^^ neither of ur methods worked for the shop ID because i just got that same error o.o

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

lol weird it still wont show shop id.

But this time when I place in shop id in the url...it comes up just the table is a little wack. The quantity and buy seems to be combined lol. And the buy text field is to big you may want to set a size for it. And there is a random item price underneath all that which I think is the javascript price add-on for it changes when I change the buy number. So you may want to look over the table. I can post a screen if you want. :-D

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

Okay i have woken up now, im awake and i found the errors...

Replace with these

itembuy.php

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

and

shops.php

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

I just tested that, so it works... If you find any problems, post error.

AND FOR THE CRON, USE THIS INSTEAD, THIS WILL ONLY UPDATE STOCKS AT 0.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

ENJOY

 

This would be so much easier if i could edit the first post.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

One more edit..

Open staff_shops.php

replace the "function new_stock_form()" and "function new_stock_submit()" with

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

This works perfectly and I thank you for doing this. I am most grateful for your work. +1

Thankyou, it was a good idea!

Edit: Forgot a ) on the query.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

Optional Addition:

When users sell items it updates the stock. So if a user sells 10 medical kits, the shops medical kit supplies will increase by 10.

Open itemsell.php

Add

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Under the item_add...

or just use this.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

I think that just about covers it.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

 

We need to add the updated staff_shops.php as well

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

I updates the Add item to shop function..

 

One more edit..

Open staff_shops.php

replace the "function new_stock_form()" and "function new_stock_submit()" with

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

This works perfectly and I thank you for doing this. I am most grateful for your work. +1

Thankyou, it was a good idea!

Edit: Forgot a ) on the query.

But that was only one function which is that was needed it think.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

 

Can you explain the following in a bit more detail please?

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

Its an if else function;

( condition ) ? 'true' : 'false' ;

So the condition first checks if the GET['ID'] is set, then it checks if the value of GET['ID'] is numerical.

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

 

Can you explain the following in a bit more detail please?

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Its an if else function;

( condition ) ? 'true' : 'false' ;

So the condition first checks if the GET['ID'] is set, then it checks if the value of GET['ID'] is numerical.

ereg basically checks to see if a string contains specific chars for example if $blah doesn't contrain a-z which is a b c .. and so on then it will fail

that's really a crap explanation but if you have been awake for 25 hours then you attempt better

i use eregi for such things like email checking and stuff like that

and for the smart ass people yes i know it says ereg in the string i was just trying to show a example ...

if you have a problem write me a letter or shut up

Link to comment
Share on other sites

Re: [MCcode v2] Shops item stock - as requested (Not Tested)

i didn't deny that was the case i was just adding to the explanation...

seems you have a issue with me rather than my post's i suggest you keep your personal feelings out of other peoples posts.

and i was explaining the obvious which you did not do therefore i did add to your explanation...

get over yourself for-real your just getting annoying

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...