Jump to content

DeX

Members
  • Posts

    258
  • Joined

  • Last visited

Posts posted by DeX

  1. Ubuntu probably means you're using Apache for the web server. (Or is it nginx?) Can you edit the virtualhost configuration? Are you using .htaccess files?

     

    And you should verify the caching thing I assumed first. Open up your browser's developer tools, look for a "network"-type thing that shows page requests, make sure it's enabled or activated or whatever so that it's working, then load up a page from the intranet site. The tool should then show you information about each page that was requested, including the Javascript and CSS files. Pick one of those. Somewhere in the details will be a list of the request and response headers - what are they?

    I'm using Apache2.

    I can edit anything I like.

    I am using .htaccess for some URL rewriting.

     

    Here is what I got:

    Request URL:https://development.xxxxxxxx.com/javascript/home.js?version=2
    Request Method:GET
    Status Code:200 OK (from cache)
    Remote Address:208.118.xxx.xx:443
    Response Headers
    Accept-Ranges:bytes
    Content-Encoding:gzip
    Content-Length:11536
    Content-Type:application/javascript
    Date:Mon, 19 Dec 2016 19:02:39 GMT
    ETag:"1a262-543cb2754e292-gzip"
    Last-Modified:Fri, 16 Dec 2016 18:58:20 GMT
    Server:Apache/2.4.18 (Ubuntu)
    Vary:Accept-Encoding
    Request Headers
    Provisional headers are shown
    Accept:*/*
    Referer:https://development.xxxxxxx.com/home.php?quote=58534
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
    Query String Parameters
    view source
    view URL encoded
    version:2
    

    I put version 2 at the end attempting to fool it into thinking it was a new file.

  2. Makes sense. If you're getting cheaper hosting by using shared hosting then your trade-off is that you're sharing it with others and your times are going to be affected. If you want faster mailing then you can pay more for dedicated hosting or you can offload your mailing to a third party script like MailChimp. The choice is really yours, if your client wants faster mail but doesn't want to pay up for it then they can't have it both ways.

  3. Caching is set by something. Generally the server, since that's the one handling the files, but if you're passing these files through PHP code first (for some weird reason) then you'd have to be explicitly doing something about caching in there.

     

    If you didn't do anything then the server is likely using Expires: it instructs the browser to not even attempt to redownload the resource until some specific time has passed. That works well... up until you change the resource, so all in all it doesn't work well.

     

    What web server are you using? Are you the one who manages it?

    Yes, it's a rather expensive Dell server running a pile of virtual machines, one of them being my Ubuntu web server I'm using for this. It sounds like I can change a setting on the server each time I do a deployment.

  4. Fix your caching so that it correctly indicates when and when not to refresh a resource.

     

    How does it work right now? Maybe there's a site you can point us to?

    It's an internal portal so you would need a login to see it. Is the caching set in the code? I'm not managing the caching at all currently, I just have the JavaScript functions and I use them. If managing the cache in the code is something I can do then I'll research that and figure out how to set it up. I didn't even know that was possible.

  5. I don't want my users to be able to load all PDF on my system so I verify them with a token and then load their PDF like so:

    if ($location)
        {
            header('Content-Type: application/pdf');
            readfile($location);
        }
    

    The problem is when they right click it to save, it tries to save as pdf-loader.php instead of the quote-123.pdf filename. They're trying to save them as the quote numbers so they are easily matched up with each customer quote and they're not the most savvy computer users. Even when using the Chrome menus to select SAVE, it still tries to save the same way.

  6. Been checking it out all day, looks like GIT has the advantage of being able to make commits offline since every user has a local repository. Then you have a separate set of commit commands where you can commit your local repository up to the main server copy. This introduces increased complexity though, so many beginner or single user systems are going to work better with Subversion.

    I've decided to stick with Subversion.

  7. Right now I do all my PHP edits in NetBeans and when I save a file, it automatically uploads it to the development server so I can test. If everything tests correctly, I copy it to production via FTP.

     

    I would like to start using Subversion but don't want to lose the convenience of the automatic uploads when saving the file. I would like this process:

    - saving in Netbeans automatically uploads file to development server for testing

    - if all testing works out, I commit the changes

    - if I have done enough commits for a new version release, wrap everything up to be copied to production. The previous company I worked at used tags for this and each tag was named with a version number.

     

    I make such frequent small edits to make something work that I would hate to have to go to the command line and commit with a message in order to get something up to the development server in order to test. Does it already work like this or am I using it outside the normal usage?

     

    If I do this, where would I hold my repository? In the actual /var/www/website directory with all the development files? Outside that directory somewhere?

     

    Thanks a lot.

  8. re: post #13. i would say the answer is yes. but you should work out how you are going to do this for each case.

     

     

    Actually it appears you may have answered me here already. I'll give the user an option to enter either a direct item or an indirect item and that way I can use Javascript to present them with the options for creating the rules. Man, I'm really excited about this!

  9. ^^^ i'll have to digest that before replying fully.

     

    lastly, i'm assuming that you have the direct bom stored in a database table. once you have these rules stored in a database table, for at least the unit_rules, you can produce the indirect bom entirely in one sql query (join the bom table with the rules table using the direct item id, sum the - bom quantity times the multiplier plus the offset, and group by the indirect item id). you may be able to also apply the group_rules in the same query, but that's more thinking than i want to do on this subject.

     

    Much more of this is making sense now, so I'm going to start creating database tables today and setting things up to accept the new items. Looking at your last paragraph you mention having all of the direct BOM in the database already, does this mean they need to be added for each user input item already and the user is unable to add a new direct BOM and assign it to the input themselves?

     

    For example, once all of this is set up, the user may want to add a welcome mat for each building and the sales guy can directly select the quantity on each building they quote, they don't depend on anything else except the direct quantity input. If the guy chooses 3, there are 3 mats. The administrator would add a new direct BOM item for the mat but how does the system know the quantity is attached to that specific input box? Normally the rules would specify the ID of another BOM item this depends on but in this case it doesn't depend on another item with ID, it depends on a specific input. How would the rule look in this case? Would I need a selector when they create the item for them to select if it references another item or a specific input?

     

    I feel like this is going to click for me any minute now, I'm so close.

  10. re: post #13. i would say the answer is yes. but you should work out how you are going to do this for each case.

     

    some example cases -

     

    1) adding a new direct item that uses no indirect items - enter the information about the new direct item and save it, ignoring anything else that might be present on the page to support example cases #2 - #4.

     

    for example, an entry floor mat that will just be laid on the floor.

     

    2) adding a new direct item that uses an existing indirect item - enter and save the new direct item information per example #1, but make use of a search/select interface on the page to choose from existing indirect items.

     

    for example, an entry floor mat that will use double-sided sticky tape to hold it in place. after entering and saving the new floor mat information, display any existing indirect items that reference the chosen direct item (there will be none since this direct item has just been inserted/created) and use the search/select interface to display existing tapes/adhesives (whatever you are using to categorize items.) and select (checkboxes or perhaps just by entering the unit multiplier/offset data) which indirect item(s) are to be used with this direct item. after entering any multiplier values, save the new rules for this indirect item to the existing rules that may already exist for it.

     

    3) adding or editing indirect items for an existing direct item. same as the second part for example case #2. rather than entering and saving the information for a new direct item, just select an existing direct item. the edit page would display the direct item that has been selected, any existing indirect items that reference the chosen direct item (so you can edit the rules, including deleting rules) and the search/select interface to let you add more indirect items for the chosen direct item.

     

    4) adding a new indirect item. near the search/select interface, if there isn't a suitable existing indirect item, have entry form fields to add a new indirect item, that once added can be selected for the current chosen direct item.

     

    Wow this is great, thank you.

     

    1. This makes total sense, and to build on your point, would I assign the quantity of floor mats to one of the user inputs? I'm assuming that's the very definition of a direct input, is that it uses only the direct inputs and not any other indirect BOM items.

     

    2. I'm not quite sure what you mean by search / select interface, do you mean a drop down box of items from the database? I already have all items in the database so the drop down box is what I had initially thought I would use. Then the user would add a multiplier, an offset and can then add a second or third for the same item if that item is used with multiple other indirect BOM items. Look at me, I'm learning so much from you! It appears that you're associating the tape to the mat in the user interface from the mat side, is this correct? What I mean is it appears you're editing the mat details and adding all of the indirect BOM items that are included when a mat is added. Up until this point I had assumed you would go into the tape and add all direct / indirect BOM items that would have tape associated with them which is essentially backwards from how it appears you're doing it. Am I confused?

     

    3. Again it appears you're editing the items that get included when editing a top level direct item. This would mean you go into MAT and edit all the lower level indirect items it uses. Is this more correct than going into TAPE and editing all the higher level direct items that would include tape? I want to make sure I don't have it backwards, same confusion as point 2.

     

    4. Are you saying I should allow the user to add a new indirect item while adding a different indirect item? Up until now I was assuming I would only add a single indirect item at a time and then add another indirect item that used that first item. I think it would clean up the interface a lot but want to be sure I'm not removing some functionality that would help with something else.

    Oh wait, maybe I understand it now that I read it again. Are you talking about when setting a rule on an item that uses an indirect item, this is how the indirect item entry would work? I see that, so the user wants to create a rule using an item that doesn't exist yet so they would need some sort of interface to add the indirect item and then use it in the rule they were creating for an existing item.

     

    the id in the $unit_rules[...] would be the item id of a direct item. since i don't know how you are entering/specifying what would trigger the scissor lift due to the building height, i suggested a general purpose way of having a "building height adder" item, which would be a direct item that a person can pick and add to the direct bom. if you already have an item that will always be present on a bom that does this, you would use it's id in the rule.

     

     

    not sure if i follow, but for at least the direct bom, these are items that are selected by a human. they should only be stored in the database bom table if they have been selected for a project/building. if you are initially inserting ALL available items into the bom table, this is creating more work, increasing data storage requirements, probably takes more code, and may be where some of your performance problems are at.

     

    1. Aha, I get it now! I had thought I was using the current item ID here that we were currently editing. No that's not right, you're saying I should be using the ID of the item that this item relies on and for which the rule is being created. For example when editing tape, you would put the mat ID here and set your multiplier and offset to calculate the quantity of tape per mat. Thanks.

     

    2. So if the user wants to add a floor mat for every 30 feet of building length, how do I populate the drop down list of all direct inputs they can set the rule on? They would need to choose building_length from the drop down and then it would set the rule on that input. Do I just hard code the options they would have in this drop down? I was thinking of putting them all into the database so that the drop down would be populated automatically, then they can also add new inputs on which new direct items can rely.

     

    Thanks a lot for this, this will probably help a lot of people searching for this solution in the future.

  11.  

     

    for any cases like this, i would add a line item to the BOM, 'building height adder' that the rules in the the scissor lift quantity calculation would use -  $unit_rules[building_height_adder_item_id_goes_here] = array('mult'=>0,'offset'=>1);. then if the building height adder is on the BOM, the scissor lift quantity calculation would result in 1 scissors lift rental.

     

     Two questions about this.

     

    1. You had the rule ID as building_height_adder_item_id but should this be the actual item's ID instead? Should it be the database ID of the scissor lift and not an arbitrary height adder item id? I'm probably not explaining this properly but I was under the assumption that that spot is reserved for all item ID in the database and not the ID of something else so if we're trying to calculate quantities of scissor lifts, it would be the scissor lift ID in that spot.

     

    2. In the last line you state it will show as 1 (because of the offset) if the scissor lift is in the BOM. I'm confused by this because I thought all items would always be in the BOM for every building, the rules would just get a quantity of 0 or more based on the rules associated with that item ID. If the item is not needed for that building (insulation in a non-insulated building), then it calculates a quantity of 0 based on the rules. Is there another part where I'm only adding materials to the BOM if required, based on additional rules?

  12. the data-driven rule based logic is only to replace the hard-coded logic you have now, for determining the derived quantity of dependent items, based on the primary/direct entered item. if you don't have any hard-coded logic calculating the quantity now, there would not be any rules needed. you probably don't have the item in your switch/case statement either.

     

    you have a direct bom, of the items that are selected by people and an indirect/derived bom, of items that this thread is trying to calculate. it's only the indirect/derived items that will have rules defined for them.

    Okay so in order to allow the user to enter a new item and give them the ability to add it to the direct BOM or the indirect BOM, I would need to give them a list of available inputs in order to tie the multiplier to for the quantity calculations. That means I would need to build the quote inputs from the database. I would also need to give them the ability to add a new input in case they're adding a direct BOM material which relies on an input that doesn't exist yet.

     

    Am I correct? I'm very excited to get this going, just want to make sure I'm attacking it correctly before I begin. Thanks a lot.

  13. Another slight addendum, what about for items that do not rely on quantities of other items but rely solely on inputs from the salesman? I see the rules in these examples are for multipliers and offsets used in conjunction with quantities of other existing items but what about things like gable vents which have a quantity input by the sales person on the quote? The quantity of these items is simply the exact number input by the salesman. Nothing more.

     

    Most importantly I don't see how the interface would work for this. The input fields are hard coded on the input page, I don't have a list in the database. So for the interface to allow the user to add a new product into the system and base it on a salesman input, that would be quite difficult. I would need to shift all inputs to the database and categorize / order them for how they would display relative to one another.

  14. To test what you're receiving on your ajax.php page, you can print it out with the following somewhere on the page:

    print_r($_POST);
    

    To test and see if your database insert is working at all, try replacing the POST variables with static entries. Once you narrow down where the error is, work on it from there.

  15. creating a new entry would be fairly straight forward -

     

    1) enter the name and select the category for the new item. inserting this into the product/item table would assign an item id to it. the item id would be used in any related data and logic.

     

    2) if the new item is used by other unit items or categories of items, you would need a way of searching/listing and selecting (checkboxes) which of the existing items/categories it goes with. the category id or item id of the selected item would become the $unit_rules key/index. you would enter any multiplier/offset or other values you determine you may need. any group rules you have define would have a way of selecting just the possible choices. if at all possible, i would avoid allowing any arbitrary logic/tests to be entered.

     

    i'll have to give some thought to the Sliding Tec Screws case.

     

    Well today is the day I actually start implementing this change in the code and I'm scanning which items I can apply this to and which I can't. I keep focusing on the ones that check to see if the item (door or window) is customer supplied or not and how that would translate. You mentioned above that I could use a multiplier of 1 or 0 to accomplish this but would this be better than separating the customer supplied doors and non-customer supplied doors into 2 separate items?

     

    Here is one I'm specifically dealing with right now:

    
                        case (self::sideWallBeam) :
                            for ($i = 0; $i < count(json_decode($this->overheadQuantities, true)); $i++)
                                if (strtolower($this->getOverheadDoorLocations($i)) == strtolower("Side Wall"))
                                    $quantities[] = $this->getOverheadDoorQuantities($i);
    
                            for ($i = 0; $i < count(json_decode($this->slidingQuantities, true)); $i++)
                                if (strtolower($this->getSlidingDoorLocations($i)) == strtolower("Side Wall"))
                                    $quantities[] = $this->getSlidingDoorQuantities($i);
                            break;
    

    The salesman enters two 10x12 overhead doors, another 3 10x10 overhead doors and finally a single 10x12 sliding door when doing the quote. For each group of overhead doors, I check to see if that door location is side-wall or end-wall (chosen by salesman) and then add side-wall beams accordingly. My main confusion here resides with the number of options available when adding these doors. They can be customer supplied, end-wall, side-wall and also insulated / non-insulated. Various items depend on each of these attributes when determining if they are required for building the building. Thanks again.

  16. JSON might be useful if the inputs vary a lot - like there isn't a consistent structure every time you prompt for particular details regarding an item. Make sure to validate it on the next page so that someone can't tamper with the data before submitting the form.

     

    The normal answer is to use arrays, which could also help here but probably isn't the only thing you need.

    <input type="hidden" name="whatever[]" value="1">
    <input type="hidden" name="whatever[]" value="2">
    <input type="hidden" name="whatever[]" value="3">
    and $_POST["whatever"] is an array.

     

    When adding doors, it is always a set number of inputs and they're always the same. The same options are available for every door. Then there are different input options for windows but they're always the same for each window. Then the same for a few other items with a total of about 10 different items like this.

  17. I have a quoting system that some of you may be familiar with from my previous questions, this is another piece of it I'm trying to clean up.

    The user can add a door or window to the quote and can also associate options with the item. For example, they can add the door, then supply the type of opening mechanism (chain, motor....), then how many windows are in the door, then which storey the door will be installed on. Then they can add another door if they wish.

     

    Currently I'm using a jQuery popup like a lightbox (Bootstrap modal dialog) to ask the user all of the proper questions about the door, then when they click the button to save the door, I'm serializing all of the inputs from that lightbox and assigning them to a hidden variable farther down the page. No matter how many doors they add, it all gets serialized into a JSON array into that hidden variable and that variable is submitted to the next page to be saved to the database when the user saves the quote.

     

    I know of no other way of transferring all of this data to the next page other than collecting, serializing and submitting as a JSON array. Am I doing it correctly? Thanks.

  18. Actually that code should be this.

    <div class="row paginate">
       <div class="col-12">
          <nav>
             <?php
                // loop through 5 page numbers
                for ($i = 1; $i < 6; $i++)
                {
                   // output initial links and set the page number in a URI variable
                   echo '<a href ="index.php?page=' . $i . '"';
                   // check URI variable to see if it iss equal to our current iteration count
                   if ($_GET['page'] == $i)
                      echo ' class = "active" ';
                   // output end of link
                   echo '>' . $i . '</a>';
                }
             ?>
          </nav>
       </div>
    </div>
    
  19. <div class="row paginate">
       <div class="col-12">
          <nav>
             <?php
                // loop through 5 page numbers
                for ($i = 1; $i < 6; $i++)
                {
                   // output initial links and set the page number in a URI variable
                   echo '<a href ="index.php?page=' . $i . '";
                   // check URI variable to see if it iss equal to our current iteration count
                   if ($_GET['page'] == $i)
                      echo ' class = "active" ';
                   // output end of link
                   echo '>' . $i . '</a>';
                }
             ?>
          </nav>
       </div>
    </div>
    

    Untested but here is how you would build the pages dynamically. Eventually I would have the photo links in a database and I would look into using mod_rewrite with a .htaccess file so you can have the following:

    .../photos/2
    

    instead of:

    .../index.php?page=2
    
×
×
  • 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.