Jump to content

Adamhumbug

Members
  • Posts

    581
  • Joined

  • Last visited

Everything posted by Adamhumbug

  1. I had a function that had some html returned in it. As i had to apply some conditions that would have needed me to duplicate the chunk of code, i have moved it into a function of its own that is called where i would have output the html. The function returning the HTML is doing so: function showAddNewItemPanel(){ return <<<HTML <div class='card mb-4' id='addNewQuoteItems'> <div class='card-header'><strong>Add New Item</strong></div> <div class='card-body'> <div class='p-3'> <form method='post' class='row g-3' id='newItemForm'> <div class='col-md-5'> <label for='itemId' class='form-label'>Item Name</label> <select type='text' class='form-control' id='itemId' name='itemId' disabled> <option value=''>Please Select...</option> <?= selectAllItemsBySection() ?> </select> </div> <div class='col-md-1'> <label for='quantity' class='form-label'>Quantity</label> <input type='text' class='form-control text-center' id='quantity' name='quantity' disabled> </div> <div class='col-md-3'> <label for='startDate' class='form-label'>Start Date</label> <input type='date' class='form-control' id='startDate' name='startDate' disabled> </div> <div class='col-md-3'> <label for='endDate' class='form-label'>End Date</label> <input type='date' class='form-control' id='endDate' name='endDate' disabled> </div> <div class='col-md-12'> <label for='notes' class='form-label'>Notes</label> <textarea class='form-control' id='notes' name='notes' rows='3' disabled></textarea> </div> <hr> <div class='col-md-5'> <label for='pricePerItemDisplay' class='form-label'>Price Per Item</label> <input type='text' class='form-control' id='pricePerItemDisplay' disabled> </div> <div class='col-md-4'> <label for='chargableUnitsDisplay' class='form-label' id='chargableUnitsLabel'>Weeks</label> <input type='text' class='form-control' id='chargableUnitsDisplay' name='chargableUnitsDisplay' disabled> </div> <div class='col-md-3'> <label for='itemTotal' class='form-label'>Item Total</label> <input type='text' class='form-control' id='itemTotal' name='itemTotal' disabled> </div> <div class='col-md-12'> <div class='btn btn-primary' id='addNewItem' name='addNewItem' disabled>Save</div> </div> <input type='hidden' name='pricePerItem' id='pricePerItem'> <input type='hidden' name='chargableUnits' id='chargableUnits'> <input type='hidden' name='quoteTotal' id='quoteTotal'> </form> </div> </div> </div> HTML; } The issue that i have is that the php function that is in there is now not showing its results and not creating the options for the select. - <?= selectAllItemsBySection() ?> Is there something that i have ommitted here? I have tried the method shown above and also returning not using heredoc.
  2. Ill do my best to provide this going forward.
  3. Can i ask how you would prefer me to show the content of my databases. Would it be better for me to give you the create code or is there another way of me showing my data in a way that is more helpful. I use this forum a lot and i try and take all advice onboard but i dont know what would be preferable when it comes to sharing my table structure.
  4. Hi All, I have a table that contains jobs and another that contains quotes and another that contains clients. I have a query: I want to select all jobs for a certain client (that part i can do), i also want to know if these jobs have quotes attached to them. I have the following: SELECT distinct job.id, job.name, job.internal_ref, venue, start_date, end_date, quote.quote_status_id, quote.id as quoteId from job left join quote on job.id = quote.job_id where job.client_id = :clientId But this will create a row for each job per quote that is attached to it as well as showing all jobs that dont have quotes - so no good. If i inner join rather than left joining the quote table, i only get rows for jobs with quotes and again another job row per quote. All i want to know is per job, if there is at least 1 quote attached. My table structure is.
  5. Hold the phone i think i got it. $(function() { $.contextMenu({ selector: '.context-menu-one', build: function($triggerElement, e){ $el = $triggerElement.data('stuff') return { callback: function(){ }, items: { menuItem: {name: $el} } }; } }); }); Thanks you all so much for your feedback here and puttiung up with my rambling.
  6. I got this far: $(function() { $.contextMenu({ selector: '.context-menu-one', build: function($triggerElement, e){ return { callback: function(){}, items: { menuItem: {name: "My on demand menu item"} } }; } }); }); The above works $(function() { $.contextMenu({ selector: '.context-menu-one', build: function($triggerElement, e){ return { callback: function(){ $el = "SOMETHING" }, items: { menuItem: {name: $el} } }; } }); }); The above doesnt. I am assuming that i am making the function wrong.
  7. I am really having a hard time with this and im sorry to ask - i know the idea here is not to get other to write your code. @kicken - i dont suppose you have an example or would have the time to fomulate one - understand if not. Appreciate you all anyway!
  8. It might be me - it is likely me - but i cannot see anything about how to dynamically populate the items in the list. I think it is my lack of understanding of their terminology. Ill keep looking but if anyone has used this or similar before and has any pointers that would be really handy.
  9. It is updating the link buttons value which led me to think that i would be able to get somewhere with it. Think you might be right though - this does look like a better option. Thanks Again
  10. Hi All, I have been reading about scope and how variables are scoped to functions etc... I have the following script that creates a context menu and i am trying to set "linkText" to = linkText set in the click function. $('.custom-lc').click(function() { $link = $(this).data('link') linkText = $(this).data('link') }) var contextMenu = $('.custom-lc').contextMenu(); contextMenu.button = mouseButton.LEFT; contextMenu.menu().addItem("linkTextVarToGoHere", function() { contextMenu.onclick = function() { window.location.href = $link } }); contextMenu.init(); The issue that i have is that if i put all of the rest of the code inside the click function, it generates another contect menu for each click rather than modifying the first one. The code that i have posted here works just fine apart from i am not able to set the text value in the addItem function. Any pointers on the best way to pass a variable into this function would be appreciated as i have managed to pass the $link into the window.location.href and that works. This is the context menu that i am using for reference - https://www.jqueryscript.net/menu/context-menu-material.html
  11. In the end i created a script that did what i wanted. $('.section').each(function() { var $el = $(this); var bottom = $el.position().top + $el.outerHeight(true); if (bottom > 950) { $('#pageContent2').append($el) } }) It grabs any element that appears below the page end and moved it into the next page. I am very sure this is a hack and not the cleanest solution, but it does do what i need. As always, i am greatful for your feedback and pointers.
  12. Yeah thats pretty much the long and short of it. Ill have a play around with it all and see where i get to.
  13. This is the current layout. <div class="printContainer"> <div class="a4"> <div class="coverPageImage"> <img src="img/Cover Page.jpg" alt="" style='width:100%;'> <div class="coverPageContent"> <?= getCoverPageContent($pdo, $_GET['quoteId']) ?> </div> </div> </div> <div class="a4"> <div class="headerSection"> <img class="headerImage" src="img/header.png" alt=""> </div> <div class="pageContent"> <div class="title"> This is the title </div> <hr> <div class="vat"> All prices are exlusive of vat </div> <div class="mainContent"> <div class="container-fluid"> <?= getAllItemsInQuoteForPrint($pdo, $_GET['quoteId'])?> </div> </div> </div> <div class="footerSection"> <img class="footerImg" src="img/footer.png" alt=""> </div> </div> </div>
  14. correct - sorry i should have been more clear.
  15. looking at this right now as a potential. https://jsfiddle.net/hnxrLav8/6/ https://stackoverflow.com/questions/32333656/move-overflowed-elements-to-another-div
  16. Basically i am creating a page with no content apart from what i want to be in the pdf - so it opens in a new tab and is a cover page with dynamic title - that page is easy as the content will never overflow. For every page i have a div (called .a4) which i use to make sure the page is the right size to be printed into pdf. For page 2 onwards i also have divs with the a4 class to constrain the size. On page 2 it is very possible that the content will overflow and be longer than the a4 size - i really cant see a good way to break this onto a new page as i have positioned header and footer images. I would need to have one div that spanned more than one page and head margin from the top and bottom of every page that it is on. Pretty sure i cannot do that. I may have to look for another solution ... but im so close to this working. Trying to avoid the wasted time.
  17. I did have a go with FPDF a couple of years ago and didnt get very far so i thought i would look for another option. What i have so far looks good when Printed to PDF asside from the fact that it wraps half way through a line of text.
  18. Agreed, that is why i am creating a page that prints into PDF, can be mailed around and that document printed.
  19. My reason for doing this is we need to be able to print it on paper and it needs a cover page as well as headers and footers.
  20. it is html yes - i didnt commit to learning fpdf as i need a header and footer and there is a lot of style involved.
  21. Hi All, I am creating a quote builder that has a display page showing all of the items that are in the quote. This has some divs that are a4 size representing the pages (this will be printed into pdf) When the content is longer than the container, how would i break this onto a new page (it would then be in a new div). I am not sure what language this would be so apologies if this is more likely JS than PHP.
  22. oh, and i thought it was going to be complicated. Thanks
  23. Hi All, I am looking for some suggestions here on a good way to order items. I have a table that has an id, name and display order columns. I am looking for suggestions on the best way (in a ui) to set the display order of each item without having the same value as any other item. So the items table looks like this. Item Name - Display Order Item 1. - 1 Item 2. - 2 Item 3. - 3 I want to be able to change the display order and automatically rearrange everything else. I can think of many crude ways to change the order but none that would update the rest. I want to be able to add Item 4 and it have display order 2 - item2 and item3 would have their display orders increased to move down. As always, appreciate your input.
×
×
  • 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.