Jump to content

unplugged_web

Members
  • Posts

    897
  • Joined

  • Last visited

Everything posted by unplugged_web

  1. I've tried to changing this: public function getExpiryDate() { $ops = $this->getRecurringOrderProducts(); $date = $this->getGoLiveDate(); $date->add(new DateInterval('P'.$ops[0]->getContractLength().'M')); $date->sub(new DateInterval('P1D')); return $date; } to this: public function getExpiryDate() { if($this->getRecurringOrderProducts()==-1) { $date = $this->getGoLiveDate();} if($this->getRecurringOrderProducts()==1) { $ops = $this->getRecurringOrderProducts(); $date = $this->getGoLiveDate(); $date->add(new DateInterval('P'.$ops[0]->getContractLength().'M')); $date->sub(new DateInterval('P1D')); return $date;} } but it then doesn't work and instead of working out the expiry date for recurring products it just has today's date rather than the date that should be being working out from this line $date->add(new DateInterval('P'.$ops[0]->getContractLength().'M')); $date->sub(new DateInterval('P1D'));
  2. I'm trying to use this on a site built with Silex but whenever I try to change it it messes everything else up or doesn't work at all. I've attached the whole code {% extends "form_select2_new.twig" %}{% block extra_css_scripts %} {{ parent() }} <link href="/css/datepicker.css" rel="stylesheet" media="screen"><style>form > .form-group { clear:left }.form-group > .form-group { clear:left }.form-group > .form-group > .form-group { clear:none }.form-group > .form-group label,form > .form-group > .form-group > label { display:block; }form > .form-group:nth-child(5) > .form-group:first-of-type .form-group label { display:block;}form > .form-group > .form-group .form-group { float:left; width: 16.2%;}form > .form-group > .form-group .form-group.remove_product { width: 2%; text-align:right; padding-top:30px;}form > .form-group:nth-child(5) > .form-group:first-of-type .remove_product { padding-top:35px;}</style>{% endblock %}{% block extra_js_scripts %} {{ parent() }} <script src="/js/bootstrap-datepicker.js"></script>{% endblock %}{% block inline_script %} {{ parent() }} $('#order_order_date').attr('placeholder', 'dd/mm/yy').datepicker({format:'dd/mm/yy',weekStart:1}); var products = $('.form-group label:contains("Order products")').parent(), add_product_button = ' <a href="#" id="add_product"><span class="glyphicon glyphicon-plus"></span> Add product</a>', remove_product_button = '<div class="form-group remove_product"><a href="#" class="glyphicon glyphicon-remove"></a></div>'; products.children().first().append(add_product_button); $('form').on('click', '#add_product', function(e) { e.preventDefault(); var prototype = $('#new_product_form').data('prototype'), index = $('form > .form-group > .form-group').length; var new_product_form = $('<div class="form-group"></div>').append(prototype.replace(/__name__/g, index)); $( remove_product_button ).appendTo( new_product_form ); products.append(new_product_form); $('select[id^="order_order_products_'+index+'"]').select2(); }); $('form').on('change', 'select[id$="product_id"]', function (e) { var product_line = $(this).parent().parent(), unit_price = $('input[id$="unit_price"]', product_line), invoice_bill = $('select[id$="invoice_bill"]', product_line); $.getJSON('/product/'+$(this).val(), function (json) { unit_price.val(json.SalePrice); invoice_bill.val(json.PriceType?'B':'I').change(); $('#order_bill_description').val( $('#order_bill_description').val()+"n"+json.BillDescription); $('#order_notes').val( $('#order_notes').val()+"n"+json.InternalDescription); $('#order_notes').val( $('#order_notes').val()+"n"+json.WholesalerName); }); }); $('label:contains("Contract length")').parent().after(remove_product_button); $('form').on('click', '.remove_product a', function(e) { e.preventDefault(); $(this).parent().parent().remove(); }); $('#delivery_address_options').insertBefore('#order_delivery_address'); $('#delivery_address_options input:radio').on('change', function() { var oda = $('#order_delivery_address'), oda_value = oda.val(); if ($(this).val()=='c') { $.getJSON('/customer/view/'+$('#order_customer_id').val(), function (data) { var address = [data.Name, data.Address, data.City+' '+data.County, data.Postcode]; oda.val(oda_value+"n"+address.join("n")); }); } if ($(this).val()=='s') { var site_id = $('#order_customer_site_id').val(); if(site_id) { $.getJSON('/customer_site/view/'+site_id, function (data) { var address = [data.Name, data.Address, data.City+' '+data.County, data.Postcode]; oda.val(oda_value+"n"+address.join("n")); }); } else if(site_id==-1) { oda.val($('#order_customer_site_address').val()+"n"+$('#order_customer_site_city').val()+"n"+$('#order_customer_site_postcode').val()); } } }); $('#order_customer_site_name, #order_customer_site_address, #order_customer_site_city, #order_customer_site_postcode').parent().hide(); $('#order_customer_site_id').on('change', function(e) { e.preventDefault(); if($(this).val()==-1) { $('#order_customer_site_name, #order_customer_site_address, #order_customer_site_city, #order_customer_site_postcode').parent().show(); } else { $('#order_customer_site_name, #order_customer_site_address, #order_customer_site_city, #order_customer_site_postcode').parent().hide(); } }); $('#order_customer_contact_name, #order_customer_contact_email').parent().hide(); $('#order_customer_contact_id').on('change', function(e) { e.preventDefault(); if($(this).val()==-1) { $('#order_customer_contact_name, #order_customer_contact_email').parent().show(); } else { $('#order_customer_contact_name, #order_customer_contact_email').parent().hide(); } }); $('#order_delivery_option_box').insertBefore('#order_delivery_price'); function updateText(src){ if(src.checked) document.getElementById('order_delivery_price').value = src.value;}{% endblock %}{% block body %} <div id="new_product_form" data-prototype="{{ form_widget(form.order_products.vars.prototype)|e }}"></div> {{ parent() }} <div id="delivery_address_options"> <label class="radio-inline"> <input type="radio" name="delivery_address_option" value="c" id="dao_customer">Customer </label> <label class="radio-inline"> <input type="radio" name="delivery_address_option" value="s" id="dao_customer_site">Customer Site</label> <label class="radio-inline"> <input type="radio" name="delivery_address_option" value="0" id="dao_custom">Custom </label> </div> <div id="order_delivery_option_box"> <label class="radio-inline"> <input type="radio" name="delivery_price_option" value="15.00" id="dpo_pre" onClick='updateText(this);'>Pre 12</label> <label class="radio-inline"> <input type="radio" name="delivery_price_option" value="8.00" id="dpo_next">Next Day</label> <label class="radio-inline"> <input type="radio" name="delivery_price_option" value=" " id="dpo_custom">Custom </label></select></div>{% endblock %}
  3. I've had a look at that but I'm not sure if it's the right thing though - what I want to do is if the product is a Bill (recurring products are an invoice) then it just skips that part of the code.
  4. I came across this [link]http://jsfiddle.net/LbLHc/4/[/link] but would love to be able to use it with radio buttons instead. Does anybody know how to do this?
  5. How do I do that? I want it to still generate the pdf but without the date if a product isn't recurring
  6. I'm working on a site that generates a certificate (a pdf file) when somebody places an order. There are two types of products that can be ordered, one is a one off product the other has a recurring fee for 12 months, 24 months or 36 months. If somebody orders a products with a recurring fee then the pdf file is generated no problems. But if the product is a one off product then the pdf isn't generated. I've been throughout the error log and it says: and Line 189 is: $date->add(new DateInterval('P'.$ops[0]->getContractLength().'M')); with the whole function being: public function getExpiryDate() { $ops = $this->getRecurringOrderProducts(); $date = $this->getGoLiveDate(); $date->add(new DateInterval('P'.$ops[0]->getContractLength().'M')); $date->sub(new DateInterval('P1D')); return $date; } public function getDeliveryOptionValue() { return self::$delivery_options[ $this->getDeliveryOption() ]; } public function getRecurringOrderProducts() { $products = array(); foreach($this->getOrderProducts() as $op) { if($op->getProduct()->isRecurring()) { $products[] = $op; } } return $products; } What I don't know how to do those is change the code so that if the product is a one off then skips that part and just sets the ExpiryDate as never. I'd be grateful for any help with this. By the way I didn't build the site but its written with Silex (something I've never used before) Thank you
  7. I did try that, but ended up with an error say:
  8. I've got a website I'm working on that has a field that I want to populate depending on the results of another field. So if somebody selects Morning the it auto fills the next box with 6, if they select Afternoon it auto fills 12 and if they select custom then they can fill in whatever they want. At the moment I've got the first field populated like this: ->add('day', 'choice', array( 'choices' => Order::$time_day, )) ->add('period'); and the array is: static public $time_day = array(1=>"Morning", 2=>"Afternoon", 0=>"custom"); The time_day is stored int he database as 1, 2 or 0 so I can't change that, but I tried changing it to this: ->add('day', 'choice', array( 'choices' => Order::$time_day, )) ->add('period', 'textarea', array( 'choices' => Order::$day_period, )); with the array being: static public $time_day = array(1=>"Morning", 2=>"Afternoon", 0=>"Night");$day_period = array(1=>"6", 2=>"12", 0=>""); but it didn't work
  9. I'm not having any trouble getting the results it's more making sure somebody uploads a file before it's submitted.
  10. No I don't get any errors at all. It just submits the form regardless of whether there's a photo or not.
  11. I've got a form that requires people to upload a photo of themselves. I'm using this to get the photo: <input type="file" name="photo" id="photo" /> and this to validate it but it's still allowing people to send the form without a photo. All of the other validation works it's just the photo part. <script type="text/javascript"> function validate_form(){ var f = document.getElementById('fname'); var l = document.getElementById('lname'); var e = document.getElementById('email'); var p = document.getElementById('phone'); var ph = document.getElementById('photo'); var fAlert = "Please enter your first name"; var lAlert = "Please enter your last name"; var eAlert = "Please enter a valid email address"; var pAlert = "Please enter a contact number"; var phAlert = "Please provide a recent photo"; var em; if (!f.value) { alert (fAlert); return false; } if (!l.value) { alert (lAlert); return false; } if (!e.value) { alert (eAlert); return false; } em = e.value.match(/[@.]/g); if ((!em) || (em.length < 2)) { alert (eAlert); return false; } if (!p.value) { alert (pAlert); return false; } if (!ph.value) { alert (phAlert); return false; } return true; } </script> Thanks
  12. Sorry I think I made a mistake in the original post, the target needs to be like this: I've tried doing it like this but it doesn't work:
  13. I'm trying to get a file to upload to a folder depending on which is different depending on what option the user has selected. The folder name is sent in the $designer variable but I'm not sure how to add it to code I've got. $pic = $_FILES['photo']['name'];$target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/' . basename( $_FILES['photo']['name']);$temp_name = $_FILES['photo']['tmp_name'];$type = $_FILES["photo"]["type"]; I tried adding it to the target line so that it was like this: $target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/$designer/' . basename( $_FILES['photo']['name']); But all I got was an error saying that the folder wasn't there. If I try adding it without the $designer variable then it submits okay but I do need it to be in a different folder depending on the option selected. Thanks
  14. Thanks, that's what I was thinking too - PayPal would be better for them
  15. Sorry I don't quick understand what you mean. Do you mean that the bank my client has an account with will give me all of the information I need?
  16. I've recently been asked to build a shop website that people can purchase through. Originally the client was happy with just PayPal but now they've said they want to have the ability to pay direct by credit card. I've never done anything like this and don't know how to do so. How would I go about doing this? Thanks
  17. I've been able to get the js file to be uploaded the to same domain as that the request is coming from, but it's still not working. If I save the results as a json file and test it on the same server as the site it works, but if I change where the results are coming from and then upload it all to the same server it still doesn't work. When I try this the only line that changes is this one: call("https://www.domain.com/passkey", { JL: 0 },
  18. I have a url (on a separate server with a different domain name) that gives me various parameters I need. I've managed to get the results, but for some reason it doesn't show any results at all in IE and I'm not sure why. It works in every other browser, but just not IE. I've checked the console and there's no errors at all, I've also used jslint.com to check the js code and that's all fine too. While I'm testing this I've removed everything else in the file so that there's nothing that can conflict with it. This is what I'm using to get the results. I have a separate js file that contains this: /*jshint -W061 */function call(url, parameters, callback) { "use strict"; $.ajax({ type: 'POST', url: url, data: parameters, success: function(data) { callback(data); }, cache: false } );} function loadJackpots() { "use strict"; call("https://www.domain.com/passkey", { JL: 0 }, function(data) { var divIdentifier, obj = eval('(' + data + ')'); $.each(obj.JL, function() { divIdentifier = ""; switch (this.gameID) { case 2: divIdentifier = "#snap"; break; case 5: divIdentifier = "#dominos"; break; case 1000: divIdentifier = "#chess1"; break; case 1001: divIdentifier = "#chess2"; break; case 1002: divIdentifier = "#chess3"; break; } if (this.gameID >= 1000) { switch (this.stakeID) { case 4: divIdentifier += "_50c"; break; case 5: divIdentifier += "_1d"; break; case 7: divIdentifier += "_2d"; break; case 9: divIdentifier += "_2d"; break; } } if (this.gameID === 1000) { switch (this.subID) { case 0: divIdentifier += "_1"; break; case 1: divIdentifier += "_2"; break; case 2: divIdentifier += "_3"; break; } } $(divIdentifier).html("$" + this.jackpot); }); } );} I use this to actually load the values: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script type="text/javascript"> $(function() { loadJackpots(); }); </script> And to display the results I'm using this: <div id="chess1"><div id="chess1_50c">$1466.85</div><div id="chess1_1d">$1641.11</div><div id="chess1_2d">$378.04</div></div> <div id="chess3"><div id="chess3_50c">$303.86</div><div id="chess3_1d">$523.02</div><div id="chess3_2d">$1473.72</div></div> </div><div style="float: left; margin: 194px 0 0 185px;"><div id="chess2_1"><div id="chess2_50c_1">$195.26</div><div id="chess2_1d_1">$154.37</div><div id="chess2_2d_1">$193.76</div></div><div id="chess2_2"><div id="chess2_50c_2">$146.84</div><div id="chess2_1d_2">$119.58</div><div id="chess2_2d_2">$145.86</div></div><div id="chess2_3"><div id="chess2_50c_3">$2.96</div><div id="chess2_1d_3">$19.25</div><div id="chess2_2d_3">$121.89</div></div> </div></div><div style="height: 80px;"><div id="snap"><div id="snap_jp">$862.16</div></div> <div id="dominos"><div id="dominos_jp">$2823.18</div></div> I've also tried this but to no avail, it just gave me an error saying obj is undefined: <div id="dominos"><div id="dominos_jp">$2823.18</div><script language="javascript">document.getElementById("dominos_jp").HTML=obj.JL[1].jackpot</script></div> I'd be really grateful for any help with this as I've tried everything to get it sorted, but no matter what I do it just won't work in IE. I read something about Ajax doesn't allow cross domain requests but I don't know how to rectify this - the values come from a url that is on another domain and I can't change that.
  19. I don't get any console errors at all and have now removed all references to document.write but it still isn't showing anything.This is now what I've got to display the results. Again it works in all browsers except for IE and there's no errors at all. <div style="float: right; margin: 2px 149px 0 0;"><div id="Jo"><div id="Jo_0"></div><div id="Jo_2"></div><div id="Jo_3"></div></div> <div class="clear"></div> <div id="Fred"><div id="Fred_0"></div><div id="Fred_1"></div><div id="Fred_2"></div></div> <div class="clear"></div></div><div style="float: left; margin: 194px 0 0 185px;"><div id="Sue"><div id="Sue_0_1h"></div><div id="Sue_0_2h"></div><div id="Sue_0_3h"></div></div> <div id="Sue"><div id="Sue_1_1h"></div><div id="Sue_1_2h"></div><div id="Sue_1_3h"></div></div> <div id="Sue"><div id="Sue_3_1h"></div><div id="Sue_3_2h"></div><div id="Sue_3_3h"></div></div> <div class="clear"></div></div></div><div style="height: 80px;"> <div id="Chris_0"><div id="Chris"></div></div> <div class="clear"></div> <div id="John_0"><div id="John"></div></div> <div class="clear"></div></div>
  20. I've managed to get the results, but for some reason it doesn't show any results at all in IE and I'm not sure why. It works in every other browser, but just not IE. This is what I'm using to get the results. The <head> section had this: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script><script src="js/users.js" type="text/javascript"></script> <script type="text/javascript"> var imagesURL = localSt.iUrl(); function call(url, parameters, callback) { var localTimeout = 10000; $("#loader").show(); $.ajax({ type: 'POST', url: url, data: parameters, timeout: localTimeout, success: function(data) { $("#loader").hide(); var obj = eval('(' + data + ')'); if (obj.ER) { var header = ""; var msg = "Sorry there seems to be a communication error (" + obj.ER + ").<br/>Please log in again."; //Error detail may be in PU if (obj.ER == "103") { header = obj.PU.HD; msg = obj.PU.BD; } else if (obj.ER == "1007") { //authentcation failed header = obj.PU.HD; msg = obj.PU.BD; } $(this).attr("disabled", false); showMessage(header, msg); } else { if (obj.PU) { var msg = ""; var header = "" if (obj.PU.HD) { header = obj.PU.HD; } showMessage(header, obj.PU.BD, function() { callback(data); }); } else { callback(data); } } } }); } function loadtotals() { call("https://my.domain.com/server/passkey.ashx", { JL: 0 }, function(data) { var divIdentifier; var obj = eval('(' + data + ')'); $.each(obj.JL, function() { divIdentifier = ""; //keys: userID,currentID,lifetimeID,total switch (this.userID) { case 2: divIdentifier = "#Jo"; break; case 5: divIdentifier = "#Fred"; break; case 1000: divIdentifier = "#Sue"; break; case 1001: divIdentifier = "#Chris"; break; case 1002: divIdentifier = "#John"; break; } if (this.userID >= 1000) { switch (this.lifetimeID) { case 4: divIdentifier += "_0"; break; case 5: divIdentifier += "_2"; break; case 7: case 9: divIdentifier += "_3"; break; } } if (this.userID == 1000) { switch (this.currentID) { case 0: divIdentifier += "_1h"; break; case 1: divIdentifier += "_2h"; break; case 2: divIdentifier += "_3h"; break; } } $(divIdentifier).html("£" + this.total); }); } ); } function showApp() { $("#loader").hide(); } $(document).ready(function() { if (navigator.userAgent.match(/Android/i)) { $("body").addClass("android"); } if (navigator.userAgent.indexOf("iPhone OS") > -1) { if (navigator.userAgent.indexOf("Version/5.1") > -1) { $("body").addClass("iphone4"); } $("body").addClass("iphone"); } $("a").click(function(event) { event.preventDefault(); parent.$("#newuserID").val(0); window.location = $(this).attr("href"); }); loadtotals(); showApp(); }); </script> And within the <body> section I'm displaying the results by using this: <div style="float: right; margin: 2px 149px 0 0;"><script type="text/javascript">document.write('<div id="Jo">');</script><div id="Jo_0"></div><div id="Jo_2"></div><div id="Jo_3"></div></div> <div class="clear"></div> <script type="text/javascript">document.write('<div id="Fred">');</script><div id="Fred_0"></div><div id="Fred_1"></div><div id="Fred_2"></div></div> <div class="clear"></div> </div><div style="float: left; margin: 194px 0 0 185px;"><script type="text/javascript">document.write('<div id="Sue">');</script><div id="Sue_0_1h"></div><div id="Sue_0_2h"></div><div id="Sue_0_3h"></div></div><script type="text/javascript">document.write('<div id="Sue">');</script><div id="Sue_1_1h"></div><div id="Sue_1_2h"></div><div id="Sue_1_3h"></div></div><script type="text/javascript">document.write('<div id="Sue">');</script><div id="Sue_3_1h"></div><div id="Sue_3_2h"></div><div id="Sue_3_3h"></div></div> <div class="clear"></div> </div></div><div style="height: 80px;"><script type="text/javascript">document.write('<div id="Chris_0">');</script><div id="Chris"></div></div> <div class="clear"></div> <script type="text/javascript">document.write('<div id="John_0">');</script><div id="John"></div></div> <div class="clear"></div></div>
  21. Is it possible then to get the results into a database? I can then get just the results I need if everything is stored in it's own field?
  22. No, unfortunately I have no control over that page at all.
  23. Sorry I don't understand? I couldn't post the real url because it contains the password to get the details, but when I got to the url it prints this:
  24. Thanks I tried that, but it didn't work. I've now got this: <script>window.onload = function() {document.getElementById('out').innerHTML = '';process();}var currents=window.location.href.toString('https://www.domain.com/password/users.aspx')function process() {var clean = currents.replace(/\[/g,'');var arr = clean.split(']');for (var i=0 ; i<arr.length-1 ; i++) {var temp = arr[i].split(',');document.getElementById('out').innerHTML += '<span class="hdr">Name:</span> '+ temp[0];document.getElementById('out').innerHTML += ' <span class="hdr">Initial Value:</span> '+ temp[1];document.getElementById('out').innerHTML += ' <span class="hdr">Total Value:</span> '+ temp[2] +'<br/>';}}</script> Then within the actual page I've got: <div id="out"></div> but it doesn't show anything at all. I tried putting some random text in the 'out' div to make sure it was showing and it was but it's not showing the values.
  25. Thanks, that's exactly what I need, but can I do that when I don't have any control over what's printed at all? All I have is a url that gives me the values?
×
×
  • Create New...