Jump to content

Adamhumbug

Members
  • Posts

    585
  • Joined

  • Last visited

Everything posted by Adamhumbug

  1. 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.
  2. 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.
  3. oh, and i thought it was going to be complicated. Thanks
  4. 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.
  5. Ill have a play around with it and see where i get to. Thanks all.
  6. I am always looking to get better and i get most of my tips from here - i will bare that in mind. I do have another question on the answer that has been given for this question. I have the following to generate my HTML - based on the info provided in the answer. if in the second for each loop i want to access one of the $items which i dont iterate through until the third for each - how would i go about doing that. foreach ($results as $client => $jobs){ foreach($jobs as $j => $items){ foreach($items as $item){ } } } Basically, one of the $items has a status and i want to change the colour of the table row that is created depending on this - but the table rows are created in the second for each.
  7. Thanks again all - will keep this handy for the next array that blows my mind!
  8. Just seen this - sorry it took a while to reply. I have tried: $res = $pdo->query("SELECT client.company_name , job.name as jobName , version , currency , job.internal_ref , kit_delivery , kit_return , quote_status_id from quote inner join client on quote.client_id = client.id inner join job on quote.job_id = job.id "); $data = $res->fetchAll(PDO::FETCH_GROUP); $result = []; foreach($data as $u){ $result[$u['jobName']][$u['internal_ref']] = array_slice($u, 2); } echo '<pre>' . print_r($result, 1) . '</pre>'; but i am getting "invalid array key" on jobName and internal_ref
  9. This is what i get for var export array - i hope i have used it correctly. array ( 'Test_Co' => array ( 'Big Event Co' => array ( 0 => array ( 'jobName' => 'TEST TC', 'version' => 0, 'currency' => '1', 'internal_ref' => '00000', 'kit_delivery' => '2023-08-01', 'kit_return' => '2023-08-03', 'quote_status_id' => 1, ), ), 'Test Co' => array ( 0 => array ( 'jobName' => 'Test', 'version' => 0, 'currency' => '1', 'internal_ref' => '123', 'kit_delivery' => '2023-08-01', 'kit_return' => '2023-08-02', 'quote_status_id' => 1, ), 1 => array ( 'jobName' => 'Second Job', 'version' => 0, 'currency' => '2', 'internal_ref' => 'ref', 'kit_delivery' => '2023-08-16', 'kit_return' => '2023-08-25', 'quote_status_id' => 1, ), ), ), )
  10. I have added some more info to be selected just for ease. Thank you Barry - always appreciated
  11. Hi All, Arrays kill me - struggle to understand how to build them. Could anyone please help explain or point me to some good clear reading on how to build a multidemntional array with a select statement. here is the statement for reference SELECT client.company_name, job.name as jobName, version, currency, job.internal_ref, kit_delivery, kit_return, quote_status_id from quote inner join client on quote.client_id = client.id inner join job on quote.job_id = job.id and here is the output I appreciate this is one record so not great for the explanation but i am trying to make an array 2 levels deep. 1st level would be the client name "test co" and the second level would be the jobName "test" everything else would be the next level. I know this is not difficult but i just cannot get my head around it. I am getting data out of the current arrays fine with the following foreach ($quotes as $quote => $items) { $out .= $quote; foreach ($items as $item) { $out .= $item['jobName']; } }
  12. So dont "include/includes..." in each function, but when calling the function use "callingFunction($pdo, $otherThing)"? Ok sounds good.
  13. I have rewritten the function and done exactly this. Closer looking and there were several problems with it. All of your pointers have got me to the bottom of it - thanks all.
  14. HI All, I have a php function. function removeItemFromQuote($itemId) { include 'includes/dbconn.php'; $sql = "DELETE from quote_items where id = :itemId"; $stmt = $pdo->prepare($sql); $stmt->execute([ ":itemId" => $itemId ]); $sql2 = "SELECT id, amount_charged_each, quantity, chargable_units from quote_items where quote_id = :qId"; $stmt2 = $pdo -> prepare($sql2); $stmt2 -> execute([ ':id' => $_GET['quoteId'] ]); $total = 0; while($row = $stmt2 -> fetch()){ $total += floatval($row['amount_charged_each']) * floatval($row['quantity']) * floatval($row['chargable_units']); } $sql3 = "UPDATE quote SET total_value = :total_value where id = :id"; $stmt3 = $pdo -> prepare($sql3); $stmt3 -> execute([ ':total_value' => $total, ':id' => $_GET['quoteId'] ]); } The first part is running, the item is being deleted. The second and third dont seem to be working, certainly the total_value column is not being updated. I am not seeing any errors and i have this at the top of the page calling the function and in my functions file. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); Is there something obvious that i am doing wrong?
  15. I enjoyed this - ill try this one. Thanks for the detailed explanation though.
  16. I have a php function that creates a chunk of html including a onclick call. The onclick function curerntly just console.logs what has been passed in. I am getting a "uncaught SyntaxError: missing ) after argument list" error and i cant for the life of me figure out why. $out .="<tr class='align-middle custom-lc' onclick='triggerClientContextMenu($cId, $coName)'> <td> <div class='companyName'>$coName</div> ...... </td> </tr>"; When i inspect what is being put on the page i see <tr class="align-middle custom-lc" onclick="triggerClientContextMenu(1, Company Name)"> <td> <div class="companyName">Company Name</div> all looks good to me asside from the error in the console. Annoyingly, the error in the console doesnt take me to a useful line of code just to the <!DOCTYPE html>. when i remove this onclick from the PHP, i dont get any errors and everything runs fine. Any pointers?
  17. Hi All, I took on board your feedback here and basically rewrote the whole statement. I would share my resultant code but the whole query is now very different. I appreiciate your pointers and assistance as always.
  18. I have a function that lists out all items that should appear on a quote - i know the sql is correct as when i was using a whille($stmt -> fetch()...... everything worked fine. I am now building an array so that i can display it by a certain value but i am only getting 2 results output and there should be 16. $row = $stmt -> fetchAll(); foreach($row as $item){ if(isset($data[$item['sectionName']])){ $data[$item['sectionName']] = []; } $data[$item['sectionName']][]= ["itemName" =>$item['name'], "quantity" => $item['quantity']]; } foreach($data as $section => $items){ $out.= "<br/>".$section."<br/>"; foreach($items as $i){ $out.= "-".$i['itemName']; } } Below are the rows i am expecting to see. This is what is being output using $out = "<pre>".print_r($data,1)."</pre>";
  19. Apologies, i am using JQuery. $weeks = Math.floor($days/7) + ($days%7 >= 3 ? 1 : 0); The above is working beautifully.
  20. Ah, this is a PHP function? I am in JS at the mo
  21. Sorry my testing was wrong here - i am gettin intdiv is undefined. Looking into it - will report back once tested properly.
×
×
  • 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.