Jump to content

unplugged_web

Members
  • Posts

    897
  • Joined

  • Last visited

Everything posted by unplugged_web

  1. I'm trying to get estimated delivery dates for various products but rather than working it out for each product it adds the previous delivery time onto the next product before working it out. This is what I've got so far public function getDeliveryDate() { $ndd = $this->getPhysicalOrderProducts(); $arrive = $this->getPostDate(); $arrive->add(new DateInterval('P'.$ndd[0]->getDeliveryTime().'D')); return $arrive; } I want it get a product, add the DeliveryTime to PostDate then return that as $date I then want it to go on to the next product and do the same thing. At the moment what's happening is it's getting the date, adding the delivery time. Then with the next date it's adding the previous delivery time to the result of $date from the previous product. Is there anyway to get it to recalculate it from fresh for every product?
  2. I thought I'd post the solution incase anybody else had the similar problem. I changed the twig file to this: <ul> {% for op in products %} <li>{{ entry.getExpiryDate|date("d/m/Y") }}</li> {% endfor %} </ul> and it now works perfectly. BTW twig is the file format that Silex uses.
  3. I've managed to get it to display only recurring products but the problem now is that no matter how many recurring products the pdf only displays one. I've changed the code to this: public function generatePdfCertificate($app) { $products = $this->getRecurringOrderProducts(); if (count($products) > 0) { $filename = $this->getPdfCertificateFilename($app); if (!file_exists($filename)) { // Generate HTML $html = $app['twig']->render('order/pdfcertificate.twig', array( 'entry' => $this, 'products' => $products, 'content_height' => intval( (8*100*count($products))/95 )+1, 'domain' => $app['config']['domain'], )); // Generate PDF $snappy = new Pdf($app['wkhtmltox_bin']); $snappy->setOption('orientation', 'landscape'); $snappy->generateFromHtml(utf8_decode($html), $filename); } } } and in the twig file I changed it to this: {% for op in products %} but now it shows only one product. Is there a way of looping through the 'generatePdfCertificate' function? Maybe some way of using 'foreach'? I did try it myself but couldn't get it to work so don't know if I got something wrong? This is what I tried, but it didn't show anything. public function generatePdfCertificate($app) { $products = $this->getRecurringOrderProducts(); if (count($products) > 0) { foreach($products as $products) $filename = $this->getPdfCertificateFilename($app); if (!file_exists($filename)) { // Generate HTML $html = $app['twig']->render('order/pdfcertificate.twig', array( 'entry' => $this, 'products' => $products, 'content_height' => intval( (8*100*count($products))/95 )+1, 'domain' => $app['config']['domain'], )); // Generate PDF $snappy = new Pdf($app['wkhtmltox_bin']); $snappy->setOption('orientation', 'landscape'); $snappy->generateFromHtml(utf8_decode($html), $filename); } } } I've also checked the $products to make sure it's showing the right content (I used var_dump($products) to do that) and it is getting the right type of product but only one of them
  4. I changed it to this and it now works: $date = $request->get('form')['event_date']; $ts = strtotime(str_replace('/', '-', $date));$dd->setEventDate(date('Y-m-d',$ts));
  5. I'm really sorry but how do I get it to just not add one off products then? I've tried so may different ways and either they don't work or just throw up errors
  6. I'm trying to build a calendar of sorts where people can add in their own events. Most of it works except for the date field always uses today's date. I've got this: public function saveAction(Request $request, Application $app) { $event = $request->get('form')['event']; if ($event) { $dd = Cb2bLatestEventsQuery::create() ->filterByEvent($event) ->findOneOrCreate(); $dd->setEventDate(date('Y-m-d')); $dd->setEvent($event); $dd->save(); } return $app->redirect('/latest_events'); } but it uses today's date. I've tried changing it to this: public function saveAction(Request $request, Application $app) { $event = $request->get('form')['event']; if ($event) { $dd = Cb2bLatestEventsQuery::create() ->filterByEvent($event) ->findOneOrCreate(); $dd->setEventDate(get('form')['event_date']); $dd->setEvent($event); $dd->save(); } return $app->redirect('/latest_events'); } which gives this error: line 57 is: $dd->setEventDate(get('form')['event_date']); and this: public function saveAction(Request $request, Application $app) { $event = $request->get('form')['event'] $event_date = $request->get('form')['event_date']; if ($event) { $dd = Cb2bLatestEventsQuery::create() ->filterByEvent($event) // ->filterByDate(array('date'=>event_date('Y-m-d 00:00'), 'date'=>event_date('Y-m-d 23:59'))) ->findOneOrCreate(); $dd->setEventDate(array($event_date); $dd->setEvent($event); $dd->save(); } return $app->redirect('/latest_events'); } but this gives me the error: Line 52 is: $event_date = $request->get('form')['event_date']; I've tried so many different ways of but no matter what I do it either throws up an error or inserts today's date. The form where people add the events looks like this: <form method="post" id="events"> <div class="form-group"><label for="form_event_date" class="required control-label">Event date</label><input type="text" id="form_event_date" name="form[event_date]" required="required" class="form-control"></div><div class="form-group"><label for="form_event" class="required control-label">Event</label><textarea id="form_event" name="form[event]" required="required" class="form-control"></textarea></div><input type="hidden" id="form__token" name="form[_token]" class="form-control" value="292270f1fedc80a05e8f4607a90bf00dd4857a30"> <div class="form-group"> <button type="submit" class="btn btn-success">Save</button> </div></form>
  7. What I really want to do is send the new date results. So if somebody changes the date I want to form to send those new dates.
  8. I did try and although it worked on that page it didn't work on the site I'm working on. At the moment I've got the form like this: <form method="post" id="report_filter"> <div class="form-group"><label for="form_date_from" class="required control-label">Date from</label><input type="text" id="form_date_from" name="form[date_from]" required="required" class="form-control" value="02/07/14" ></div><div class="form-group"><label for="form_date_to" class="required control-label">Date to</label><input type="text" id="form_date_to" name="form[date_to]" required="required" class="form-control" value="03/07/14" ></div><input type="hidden" id="form__token" name="form[_token]" class="form-control" value="9ec20eed7ca26764be0c40c3ea7b2fcc2eb5910f" > <div class="form-group"> <button type="submit" class="btn btn-default" onSubmit="return validate_form()"><i class="glyphicon glyphicon-search"></i> Filter</button> </div></form> and the function here: function validate_form(){ var f = document.getElementById('form_date_from').value; var t = document.getElementById('form_date_to').value; var fAlert = "Please enter a from date."; var tAlert = "Please enter a to date."; var em; if (!f.value) { alert (fAlert); return false; } if (!t.value) { alert (tAlert); return false; } return true; } but I'm still having to click filter again after the page has refreshed for the correct results to show. I want the dates to update before the form is sent so that when the database query is sent it's getting the dates shown on the screen.
  9. That's what I tried but that just gave me a blank page when the order contained both recurring and non recurring products. It's fine if it does that when there's just non recurring products but not when there's both
  10. Sorry I think I misunderstood the code, I only wanted it to disappear when somebody clicks okay, and then not reappear until the cookie has expired. Sorry I don't think I explained it very well.
  11. Yes that does update after you've submitted the form but I'm trying to get it to update before the form is submitted. It's being used on a page where people can search within a date range, they select the dates (using this method) then click submit to show the results within that range - but at the moment for it to work they're having to click the button after after its loaded and I'd like to stop that from happening
  12. Sorry I've just noticed with this that the popup box disappears if you refresh the page and that the buttons don't work. Am I doing something wrong somewhere?
  13. I did try to do what you said but then I get a blank page if the order has a non recurring product. My job is actually as a straight HTML developer but I do have a limited knowledge of PHP. This is is built using Silex and before I'd started my job I'd never even heard of it. I did this based on what you showed me before, but as I say if the only contains a non recurring product (whether it's only a non recurring product or a mix of both) then the page is blank: public function getRecurringOrderProducts() { $products = array(); foreach($this->getOrderProducts() as $op) { if($op->getProduct()->isRecurring()) { $products[] = $op; }else {exit;} } return $products; }
  14. Sorry not everything I wrote ended up in the post - that'll teach me to type it in a text document then paste it in. I'm trying to get this to change the actual value so when somebody submits the form it has the correct dates. At the moment it updates it on the screen but in the source code the value doesn't change.
  15. I appreciate that but I don't even know where to start with changing this so that if a product isn't recurring it sets liveable to false. Everything I try returns an error saying that there's no value. function isLiveable() { $liveable = true; if ($this->getGoLiveDate()) return false; foreach($this->getOrderProducts() as $op) { if($op->getProduct()->needCli() && (strtolower($op->getCLI())=='tbc')) { $liveable = false; } } return $liveable; }
  16. I'm really sorry and I'm sure I'm being a pain but my boss has now just said that she doesn't want to certificate to so on recurring products but I'm not sure how to do that. I think I need to change this part: public function generateGoLiveCertificate($app) { $filename = $this->getGoLiveCertificateFilename($app); if (!file_exists($filename)) { // Generate HTML $html = $app['twig']->render('order/golivecertificate.twig', array( 'entry' => $this, 'products' => $products=$this->getRecurringOrderProducts(), 'content_height' => intval( (8*100*count($products))/95 )+1, 'domain' => $app['config']['domain'], )); // Generate PDF $snappy = new Pdf($app['wkhtmltox_bin']); $snappy->setOption('orientation', 'landscape'); $snappy->generateFromHtml(utf8_decode($html), $filename); } } The getRecurringOrderProducts array is this: public function getRecurringOrderProducts() { $products = array(); foreach($this->getOrderProducts() as $op) { if($op->getProduct()->isRecurring()) { $products[] = $op; } } return $products; } I did try changing it based on what you'd said before, but only got errors saying there were no products. The other part I need to do is add a false value here if the product isn't recurring: function isLiveable() { $liveable = true; if ($this->getGoLiveDate()) return false; foreach($this->getOrderProducts() as $op) { if($op->getProduct()->needCli() && (strtolower($op->getCLI())=='tbc')) { $liveable = false; } } return $liveable; } Thank you so much for helping me with this. I only started the job a couple of weeks ago and am trying to fix somebody else's code in a framework I've need used before.
  17. I came across this http://www.eyecon.ro/bootstrap-datepicker I've be grateful if anybody has any suggestions
  18. Brilliant thank you - that's exactly what I'm after. Is it possible to use my own pop up box though? SO I could have a company logo or link on it?
  19. I've just come across this: http://wipeoutmedia.com/wordpress-plugins/css-javascript-toolbox/confirmation-alert-box-with-cookie/ which I would love to do but it's for WordPress. I've tried to get it to work on my site but it's not working, does anybody know of any others that will work outside of WordPress? Thanks
  20. Thank you that's perfect. I didn't quite understand what you meant before but definitely do now. Thank you
  21. I'm using Chrome which said did say it supported. It does work and does download the file but rather than being export.csv when it's downloaded its just called download
  22. I'm trying to add a button to a page that has the ability to download a table as a CSV file. I came across this http://jsfiddle.net/terryyounghk/KPEGU/ and it's exactly what I'm after but when I try to use it it downloads a file called 'download' that doesn't appear to be a CSV file. This is the table <div id="report"><table class="table table-striped table-bordered table-hover"> <thead> <tr><th>Customer</th> <th>Subsite</th> <th>Product details</th> <th>Bill description</th> <th>Notes</th> <th>Order date</th> <th>Ticket #</th> <th>Go Live date</th> </tr></thead> <tbody> <tr> <td> <a href="mailto:user@email.com">User</a> @ <a href="/customer/2">website Limited</a> </td> <td>User's Office</td> <td> <ul> <li>CityLink Next Day Shipping 10.00 x 1</li> </ul> </td> <td>Next Day Courier</td> <td>CityLink Next Day ShippingCityLink</td> <td>18/06/14</td> <td><a href="https://subdomain.zendesk.com/agent/#/tickets/205" target="_blank">#205</a></td> <td>19/06/14</td> <td> </td> </tr> </tbody></table></div> and I've attached the file that's downloaded as a zip file because it couldn't let me upload this otherwise download.zip
  23. I'm sorry to be so dumb but how do I do that? I've only just started in this job and am trying to sort out somebody else's code. There's a lot of their code that I've already sorted but this is something I'm really stuck on and don't seem to be getting anywhere. I really appreciate you helping with this.
×
×
  • Create New...