Welcome Guest, Not a member yet? Register   Sign In
Multiple Store s - always included parameter
#1

[eluser]Angilo[/eluser]
Hi all,

I and my organization are going to use CI as our framework. Simply because it's fast, stable, and the Model - View - Controller.

We have several stores, which should be managable within 1 system (our previous system did, but did not support MVC). All stores are located within 1 database, this is the best way. We did an evalution before to determine this.

The issue is, there are store manager and district managers, district managers should be able to view the district but also each individual store.
This means there should be a "Store Switch". If you have any other ideas, just throw it out!

In the previous system, there was a store switch (get form) and in the url and form builder, there was a function that included the storeID.

How should or can we do this with CI?

For example:
Previous system:
http://domain.com/system/index.php?page=sales&storeID=4

CI:
http://domain.com/system/index.php/sales/listing/ ???

We also use ExtJS.

Thanks for your advice!
#2

[eluser]WanWizard[/eluser]
Normally you solve this in the database, where you have a stores table and a districts table, and a field in the stores table with the district id (assuming a one-to-many relationship here).
Then you could easily list all stores belonging to a specific district.

what I then normally do is:
Code:
if ( the user is a district manager )
{
    show a selection list of stores in the district
}
else
}
    if ( the user is a store manager )
   {
        we know the store, auto select it
   }
   else
   {
        this user has no business here
   }
}
#3

[eluser]Angilo[/eluser]
[quote author="WanWizard" date="1276611498"]Normally you solve this in the database, where you have a stores table and a districts table, and a field in the stores table with the district id (assuming a one-to-many relationship here).
Then you could easily list all stores belonging to a specific district.[/quote]

I think there is no such thing as "normally". But indeed, the process you describe is the process we are using.

Besides, that is actually not the question. But I'd like to thank you for your input.

Let me explain further...

Every store has his own configuration, layout, etc. Every district manager can select (in their panel) whether they want to view default layout, or store layout. But let's assume in this example the district manager views every store layout. A simple reason why a district manager would do this, is to see if there is any performance lack due to the choosen stores layout...

A district manager should be able to view every individual store as the store manager sees his store, a simple reason, is the reason I gave above.

For these reasons (and I can think of many more) a district manager should be able to switch stores. When a district manager switches the store, the sales, purchase, rma, etc should load. But when he would like to view the sales, he should stay in the same store, if he loads the purchase page, he should stay in the same store, unless specified different of course.

My question is, how can I pass the parameter in CI? Manual to the url and in the function of a controller is not an option, since we are using ExtJS and have tons of functions in 1 controller...
#4

[eluser]WanWizard[/eluser]
When developing applications, after the analysis stage you end up with a normalized database design. Which would contain the two tables as I described. Hence 'normally'.

So the question is actually about URI usage?

To avoid the word 'normally' again, it is customary (better?) to use variable/value pairs in the URI: http://www.example.org/var1/value1/var2/...ar3/value3. Which you convert to an array for processing using $this->usi->uri_to_assoc().
#5

[eluser]Angilo[/eluser]
[quote author="WanWizard" date="1276613367"]When developing applications, after the analysis stage you end up with a normalized database design. Which would contain the two tables as I described. Hence 'normally'.[/quote]

I agree. But in my opinion each project requires a new analysis stage, therefor I would not use the word "normally". But I do understand what you mean, and indeed, our normalized database design has the two tables as you described.

[quote author="WanWizard" date="1276613367"]So the question is actually about URI usage?

To avoid the word 'normally' again, it is customary (better?) to use variable/value pairs in the URI: http://www.example.org/var1/value1/var2/...ar3/value3. Which you convert to an array for processing using $this->usi->uri_to_assoc().[/quote]

More or less, yes. The reason I did not ask the question specifically is because I'd like to gather some input from other people, how they would handle such a situation.

And oh, I did not interpret your post as an offense and did not mean my post to be an offense. I really appreciate your view and help.

Since we are discussing this anyway, how would you handle it, now you know what a district manager needs?

Again, thank you for your input.
#6

[eluser]WanWizard[/eluser]
I didn't see it as an offense, just wanted to clarify things (I'm no native English speaker, so somethings nuances in the way things are phrased are lost on me Smile ).

It's a bit difficult to give you advise, as I don't know the structure of your site, the controller and methods you use, and what other parameters you need to use.

But I would just use "/store/12" to indicate that I want to see things from a 'store 12' point of view. For all functions I would use different URI variables, p.e. '/store/12/sales/10' would show the sales info from store 10 in the layout of store 12. Make sense?
Don't forget to validate if the user has access to that store ID. If not, you can either ignore the parameter (you know the store id that is associated with a store manager), or issue an error message.
#7

[eluser]Angilo[/eluser]
[quote author="WanWizard" date="1276614447"]I didn't see it as an offense, just wanted to clarify things (I'm no native English speaker, so somethings nuances in the way things are phrased are lost on me Smile ).

It's a bit difficult to give you advise, as I don't know the structure of your site, the controller and methods you use, and what other parameters you need to use.

But I would just use "/store/12" to indicate that I want to see things from a 'store 12' point of view. For all functions I would use different URI variables, p.e. '/store/12/sales/10' would show the sales info from store 10 in the layout of store 12. Make sense?
Don't forget to validate if the user has access to that store ID. If not, you can either ignore the parameter (you know the store id that is associated with a store manager), or issue an error message.[/quote]

That's an option aswell, but wouldn't CI see "/store/12" as a controller?
#8

[eluser]WanWizard[/eluser]
You have to prefix that with 'controller/method', I was only talking about passing variables, as I don't know your sites structure.

You can also store the store_id in the session. Retrieve it when the user logs in, if the user is a district manager, give the option to select another store in the district. This way you don't have to pass variables in the URI, the selected store is always available.




Theme © iAndrew 2016 - Forum software by © MyBB