Jump to content

DeX

Members
  • Posts

    258
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Calgary, Alberta
  • Age
    37

DeX's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

3

Community Answers

  1. I'm not sure if I phrased that question properly but I'll give an example: I have a User class and I have a Car class. I have users on a website and they own cars. So if I want to get all users from the database, I use the User class to do that fetch and the same if I want to get all cars from the database. My question is when I want to get all cars owned by a specific person. Should I do something this? $user = new User(123); $carsOwnedByUser = $user->getCars(); Or should I do something like this? $carsOwnedByUser = \CarNameSpace\getCars(123); In the first one I have a function in the User class to get all of their cars and in the second one I have a function in the Car class that gets cars when you pass in a user ID. Is one more proper than the other? Each one will return an array of Car objects. Thanks a lot.
  2. I have models for all of my database objects. For instance, I have a User class and in that class I have functions like so: getFirstName() getLastName() getAddress() And of course I have setters for each as well. My question is whether I should also have some helper functions inside this model for something like getFullName() which will return a concatenation of getFirstName() and getLastName() or if we should simply concatenate the data every time we want to display it on each page. So we will be displaying the user's name on the top of each page, in their account profile and maybe some other places of this portal type system. Is it proper object oriented programming to use helper functions like this? Should they go into the controller? Should we create separate logic namespaces for each model to control this logic? Another example would be if I wanted to get the most recent user that signed up, where would this function go? In the user model? In the controller? Thanks.
  3. Should I be able to reference any model from any other model? Currently only the controller can access any model it wants information from but once you get into the model, you can't communicate with other models. The situation I have right now is a settings page I have where it lists all the items from a table in the database and allows you to modify them or add new ones. So I have a settings model that retrieves all items from that table and the view displays them on the page. I have another model for another page that actually uses these table items and again I need to get all the items from that table in this model. Do I have the same function in both models? Do I move them to a common model that's shared? Do I just choose one and reference them from there?
  4. I have been attempting to implement this for the last little while and am pretty well stuck with it. I am trying to rewrite all product quantity calculations using the multiplier / offset method posted earlier but I just can't get all of them to fall into that format. The white caulking works fine but then I have much more complex quantity calculations. A simple one I'm having trouble with is 2x4x16 lumber. These are used end-to-end all the way down both sides of the building. So the quantity calculation is: buildingLength / lengthOfBoard (16) And then you multiple by 2 for both sides (or loop through again) and then round up. There isn't really a multiplier here since you're dividing, so how would that work? A much more complicated example is for 2x8x16 lumber which is like so: for ($i = 0; $i < count(json_decode($this->slidingQuantities, true)); $i++) $quantity += $this->getSlidingDoorWidths($i) * 2 / 16 * $this->getSlidingDoorQuantities($i); The salesman can add as many sliding doors to the building as he wants, so he could add 1 set of 2 10x12 doors and then another single 10x10 door to the other side. That's 3 total doors with different dimensions so the code has to loop through each group to calculate the quantity of 2x8x16. Essentially it is: - for each group of doors entered - individual door width times 2 (to line both sides of the door) - divided by 16 which is the length of the board, this will add 1 board every 16 feet because they're end-to-end on both sides of the door - multiplied by number of doors in that group because in our example the salesman added 2 doors of identical dimensions in the first group This example isn't as easy as a simple multiplier / offset calculation so I'm totally lost how I would allow the user to enter this material into the system and set a quantity calculation for it themselves. And if you want to see the ENTIRE quantity calculation for 2x8x16, here it is as we're using it right now. The piece I posted above is only a small part inside this: case (self::lumber2x8x16) : $quantity = 0; if ($this->getPostSize() == { $quantity += ceil( ceil( ( $this->getBuildingWidth() / $this->getGablePostSpacing() - 3 ) * 2 ) + ceil( ( $this->getTotalQuantityWindows(true) + $this->getTotalQuantityManDoors(true) ) * 22 / 16 ) + $this->getTotalOverheadDoorWidths() / 16 ); for ($i = 0; $i < count(json_decode($this->overheadQuantities, true)); $i++) $quantity += ($this->getBuildingHeight() - $this->getOverheadDoorHeights($i) + 2) * $this->getOverheadDoorWidths($i) * $this->getOverheadDoorQuantities($i) / 4 / 16; // for each door } for ($i = 0; $i < count(json_decode($this->slidingQuantities, true)); $i++) $quantity += $this->getSlidingDoorWidths($i) * 2 / 16 * $this->getSlidingDoorQuantities($i); for ($i = 0; $i < count(json_decode($this->biFoldQuantities, true)); $i++) $quantity += $this->getBiFoldDoorWidths($i) / 16 * $this->getBiFoldDoorQuantities($i); if ($this->getEveBoardLength() == 16 || $this->getEveBoardLength() == 15) { $count = 0; if ($this->hasSoffit()) $quantity += ceil((($this->getLengthGableSoffit() / 12) + ($this->getLengthEveSoffit() / 12)) / $this->getEveBoardLength()) + 1; $quantity += $this->getBuildingLength() * 2 / $this->getEveBoardLength(); foreach (json_decode($this->kickWallLengths, true) as $length) { if ($this->isKickWallEve($count)) { if ($this->getKickWallHeights($count) == 4) $quantity += ceil($this->getKickWallLengths($count) / $this->getEveBoardLength()) * ($this->isKickWallInsulated($count) ? 7 : 6); else if ($this->getKickWallHeights($count) == 6) $quantity += ceil($this->getKickWallLengths($count) / $this->getEveBoardLength()) * ($this->isKickWallInsulated($count) ? 10 : 9); else if ($this->getKickWallHeights($count) == $quantity += ceil($this->getKickWallLengths($count) / $this->getEveBoardLength()) * ($this->isKickWallInsulated($count) ? 13 : 12); } $count++; } } if ($this->getGableBoardLength() == 16 || $this->getGableBoardLength() == 15) { $count = 0; foreach (json_decode($this->kickWallLengths, true) as $length) { if ($this->isKickWallGable($count)) { if ($this->getKickWallHeights($count) == 4) $quantity += ceil($this->getKickWallLengths($count) / $this->getGableBoardLength()) * ($this->isKickWallInsulated($count) ? 7 : 6); else if ($this->getKickWallHeights($count) == 6) $quantity += ceil($this->getKickWallLengths($count) / $this->getGableBoardLength()) * ($this->isKickWallInsulated($count) ? 10 : 9); else if ($this->getKickWallHeights($count) == $quantity += ceil($this->getKickWallLengths($count) / $this->getGableBoardLength()) * ($this->isKickWallInsulated($count) ? 13 : 12); } $count++; } } if ($this->hasPermaPosts()) $quantity += 4 + $this->getTotalQuantityDoors() * 2; $quantities[] = $quantity < 0 ? 0 : ceil($quantity); break;
  5. I have actually been coding this up for the last 2 months and am now starting on the rules for each product and category in the system. Right now I have a very simple price calculator with categories and products using multipliers and offsets as suggested: - final price -- lumber x 1 + 0 --- tenFoot2x4 -- metal x 1 + 0 -- labour x 1 + 0 So the final price is comprised of all lumber, metal and labour combined, and lumber is made up of a single product, a 10' piece of 2x4. I'm assuming for simplicity that this product is only added to the building if the building is insulated, how would I account for this? I have multipliers and offsets but what about conditions such as this? Do I add an additional rule to the product group which has a multiplier of 0 if the user input of "insulated" is false? So then it would be: - 2x4 quantity = lengthOfBuilding x 1 + 0; After applying all these rules for the quantity I then do a group quantity calculation: - 2x4 group quantity = 2x4 quantity x insulatedValue + 0; ...where insulatedValue is 1 or 0 based on whether the checkbox is checked.
  6. I have a quoting system and the user (administrator level) has the ability to add or remove the inputs it requests of the salesman when doing the quote. There are a few locked inputs which can't be modified but otherwise if the user wants to collect which colour socks the customer has on, they are free to do that by adding an input to require it when doing the quote. Because of this, I'm currently taking all inputs on the page and throwing them into a match table in the database when each quote is saved. I'm also taking the locked quote-specific inputs and putting those into corresponding spots in another QUOTE table with just information about the quote. This would include the width / length / height of the structure and the date it was quoted. I would also use the ID of the row from this insert as the quote ID which would be placed on the printed quote as a reference number. I'm also taking locked customer-specific data and entering that into a CUSTOMER table and using the auto generated ID of this row as the customer ID. The issue I'm having is I'm now duplicating some of the inputs in multiple tables and I'm wondering if I should just keep them all in the match table with all the other inputs and just let the model retrieve them from there when needed. I would then use the same ID for the quote and the customer ID in this case. What do you think?
  7. That makes sense, I have implemented it that way now, thanks. Should I have separate controllers? Right now I call one controller for everything and it decides which model needs to handle the request. What if I separate them and the quote controller needs data from the user controller?
  8. I'm wondering if I should initialize every view so I can reference any one I want or if I should just have a main view file that I reference and that accesses the correct view file I need. The exact scenario I'm dealing with is a situation where I have a number of inputs at the top of the screen and each input has a keyup function which runs a JavaScript function to display the updated quote. It goes as so: - JavaScript function (Ajax call) - API file receives the Ajax call and requests the quote from the view I have multiple view files and one of them is for the quote. Because it's from an Ajax call I can't just include the quote view on the page itself, it needs to be referenced from the API file and so do all of the other views needed by the API.
  9. That makes sense, I will do it that way. What about for a development environment? Should I keep a separate database for that or use the same database in the same manner? I find now when I add a new item for sale into the system, it has to be added to all environments.
  10. Separate table prefixes or a company ID for each row in every table?
  11. I have a quoting tool being used by a few companies and would like to turn it into a Software As A Service (SAAS) for the new redesign. I'm wondering what is the best way to go about this so I have some questions: 1. Should I be using a completely separate database for each new customer? How would I create a new MySQL database and tables in PHP? Just run the full SQL script in one shot after they have paid? 2. Should I use table prefixes for each customer? I don't think this is a good idea because it bypasses any sort of caching my database would be doing for queries. 3. Should I use the same database for all and just have a company_id field to state which company the data is for? For a little more information, right now I have 2 users and might gain 1 every month or two I'm guessing. Employees would be logging in to create the quotes and customers of that company would be logging in to view their quotes.
  12. So that makes sense, are you saying I would build a quote object that contains all information I could want about the quote and then just specify what I want from that object in various places on the page? So for instance I would show $quote['id'] in a few places, then show the $quote['price'] where it needs to go and keep using it that way?
  13. I'm ready to start looking into this but I did change something so I'm wondering if I even need to look into anything. We switched it to use port 587 in the client application. Is this sufficient or do I still need to ensure it's actually getting encrypted? And just to make sure I have everything explained, it's using Gmail's SMTP server to send the mail over port 587.
  14. This seems a little out of my league but I'm going to attempt to break it down. 1. I'm using the Gmail SMTP server to send the email so is it possible to even send encrypted mail over port 25 with them? 2. Does the SSL get initiated by the client program initiating the email (our POS) or is the SSL controlled by the email server (Gmail)? I'm basically wondering if this program has the ability to force SSL and Gmail just accepts it, or does the program queue up the email and Gmail decides whether it is encrypted based on the port used? 3. In order to check if it's encrypted you mentioned checking the configuration and traffic. I'm not quite sure how to check this, can I see the outgoing data somehow? 4. If I use port 587 will Gmail automatically encrypt it or do I trust our client software will do the encryption? I'm a software guy, not too much of an expert on email servers and transfer protocols. Thanks a lot.
  15. I'm not sure if this is the correct area for this question and it's not really code related but I wasn't sure which forum website was best to ask this. One of my clients is doing a huge switch of their entire point of sale (POS) system and they're paying some company in the states a huge amount of money to provide the system and do the switch. We're configuring the desktop application to be able to automatically send out customer invoices or receipts and it needs email credentials in order to authenticate to some SMTP server of our choice. I set it up on the dummy Gmail account that I use for all of the printers in the building but for reasons unknown to me this application is for some reason failing to send email over port 465 through the Gmail SMTP server. I've already made all the necessary changes in the Gmail web portal to allow external applications to access email and the printers can access it without issue. However when I switch this application to port 25 it works so I have a few questions regarding this: 1. Is it safe to continue allowing a POS to send customer receipts over port 25? Can we be sued for breaking some sort of privacy law? 2. Next to the port setting in the POS application there is a checkbox to use SSL. It allows us to check this, independent of the port selected. Is it possible to use SSL over port 25?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.