templates/forms/classified/choose-ad.html.twig line 1

Open in your IDE?
  1. <!-- Modal -->
  2. <div id="modal1" class="center-modal modal fade" role="dialog">
  3.   <div class="modal-dialog">
  4.     <!-- Modal content-->
  5.   <style media="screen">
  6.   /* these changes need to be propagated into the site.css  */
  7.     .close {
  8.       top: 0;
  9.       right: 0;
  10.       color: #a41822;
  11.       position: absolute;
  12.       font-size: 61px;
  13.       height: 58px;
  14.       line-height: 0;
  15.     } 
  16.     .close:hover,
  17.     .close:focus {
  18.       color: #a41822;
  19.       text-decoration: none;
  20.       cursor: pointer;
  21.       -webkit-text-stroke: 1px #a41822;
  22.       outline: unset;
  23.     }
  24.       @media only screen and (max-width: 700px){
  25.         .modal{
  26.           padding: unset;
  27.         }
  28.         .modal-content {
  29.           width: 100%;
  30.           height:auto;
  31.         }
  32.         .close{
  33.           color: #a41822;
  34.           position: absolute;
  35.           font-size: 61px;
  36.           top: -37px;
  37.           right: 5px;
  38.           line-height: unset;
  39.         }
  40.       }
  41.   </style>
  42.     <div class="modal-content">
  43.       
  44.       <div class="modal-header">
  45.       <button type="button" class="close" data-dismiss="modal">&times;</button>
  46.         <center>
  47.             <a href="/rcs-club-sign-up"><img src="https://www.rooferscoffeeshop.com/uploads/media/2019/04/rcs-r-club.png" style="width:450px; align: center;" loading='lazy'></a>
  48.             Join R-Club to save up to 50% on your classified ads!  
  49.         </center>
  50.       </div>
  51.     </div>
  52.   </div>
  53. </div>
  54. {# TODO: test this #}
  55. {#
  56. {% if purchaseItem is not empty %}
  57. {% set temp = purchaseItem.getContent() %}
  58. <div class="alert alert-info clearfix">
  59.     <div class="float-right">
  60.         <button 
  61.             type="submit" 
  62.             name="action"
  63.             value="discard"
  64.             class="btn btn-link p-0"
  65.         ><i class="fa fa-close"></i> Discard</button> or 
  66.         <button
  67.             type="submit"
  68.             class="btn btn-link p-0"
  69.             name="action"
  70.             value="add_to_cart"
  71.         ><i class="fa fa-shopping-cart"></i> Save and create new</button>
  72.     </div>
  73.     
  74.     <i class="fa fa-info"></i>
  75.         You are currently editing
  76.     {% if temp is not empty %}
  77.         your listing: <strong>{{ temp.getTitle() }}</strong>
  78.     {% else %}
  79.         a previous listing.
  80.     {% endif %}
  81. </div>
  82. {% endif %}
  83. #}
  84. {#
  85. <button
  86.     type="submit"
  87.     class="btn btn-secondary float-right"
  88. >Continue to Create Your AD <i class="fa fa-angle-double-right"></i></button>
  89. <h4>Choose a Package</h4>
  90. <p><strong>Purchase Packages:</strong></p>
  91. {% for p in products %}
  92. <div>
  93. <label class="btn-block m-0">
  94.     <table class="table m-0">
  95.     <tr>
  96.         <td style="width: 1px;">
  97.             <input 
  98.                 type="radio" 
  99.                 name="product[product_id]" 
  100.                 value="{{ p.getId() }}"
  101.                 {% if product is not empty %}
  102.                 
  103.                 {{ (product.getId() == p.getId()) ? 'checked' : '' }}
  104.                 {% endif %}
  105.                 required
  106.             />
  107.         </td>
  108.         <td>
  109.             {{ p.getTitle() }}<br />
  110.             <strong>{{ p.getFullPrice() }}</strong>
  111.             {{ p.getDescription() }}
  112.         </td>
  113.     </tr>
  114.     </table>
  115. </label>
  116. </div>
  117. {% endfor %}
  118. <hr />
  119. <p><strong>SW &mdash; Region 1 Southwest Edition, includes:</strong><br />
  120. Southern California, Southern Nevada, Arizona, Texas, New Mexico, Oklahoma and Hawaii.
  121. </p>
  122. <p><strong>NW &mdash; Region 2 Northwest Edition, includes:</strong><br />
  123. Wyoming, Montana, Idaho, Oregon, Washington, Alaska, Northern California, Northern Nevada, Utah and Colorado
  124. </p>
  125. <p><strong>SE &mdash; Region 3 SouthEast Edition, includes:</strong><br />
  126. North Carolina, Tennessee, Florida, Georgia, South Carolina, Alabama, Mississippi, Louisiana and Arkansas
  127. </p>
  128. <p><strong>MW &mdash; Region 4 Midwest Edition includes:</strong><br />
  129. Minnesota, Iowa, Illinois, Wisconsin, Michigan, Indiana, Nebraska, South Dakota, North Dakota, Ohio, Kentucky, Kansas and Missouri.
  130. </p>
  131. <p><strong>NE &mdash; Region 5 Northeast includes:</strong><br />
  132. Pennsylvania, Delaware, Virginia, West Virginia, Maryland, Washington D.C., Connecticut, New Hampshire, New York, Maine, Massachussetts, Vermont, New Jersey, Rhode Island.
  133. </p>
  134. #}
  135. {% if not app.user or (not app.user.isMember() and not app.user.isAdmin()) %}
  136.     <button id="not-member" type="button" class="button" style="display: none;" data-toggle="modal" data-target="#modal1">View</button>
  137.     <script>
  138.         setTimeout(function() { document.getElementById("not-member").click(); }, 3000);
  139.     </script>
  140. {% endif %}
  141. <style>
  142.   .classified-options {
  143.     border: 1px solid #ccc;
  144.     border-radius: 6px;
  145.     padding:20px;
  146.   }
  147.   .classified-options h3 {
  148.     color: #A6252A;
  149.   }
  150.   .btn-classified {
  151.     color: black;
  152.     border: 1px solid #ccc;
  153.     border-radius: 6px;
  154.     width: 100%;
  155.   }
  156.   .cbtn-wrapper {
  157.     padding: 5px;
  158.   }
  159.   .btn-check {
  160.     position: absolute;
  161.     clip: rect(0,0,0,0);
  162.     pointer-events: none;
  163.   }
  164.   .btn-check:checked ~ .btn-classified {
  165.     color: #fff;
  166.     background-color: #A6252A;
  167.   }
  168.   .top-highlight {
  169.     position: absolute;
  170.     font-size: 12px;
  171.     top: -14px;
  172.     background-color: #A6252A;
  173.     color: white;
  174.     width: 96%;
  175.     border-top-right-radius: 6px;
  176.     border-top-left-radius: 6px;
  177.     padding-left: 70px;
  178.     text-transform: uppercase;
  179.     border: 1px solid #ccc;
  180.   }
  181.   
  182. </style>
  183. {# TODO: pull these from database #}
  184. {% set durations = [
  185.   {'id': 1, 'text': '30 Days'},
  186.   {'id': 2, 'text': '60 Days'},
  187.   {'id': 3, 'text': '90 Days'}
  188. ] %}
  189. {% set graphics = [
  190.   {'id': 4, 'text': 'Image'},
  191.   {'id': 5, 'text': 'Video'},
  192.   {'id': 22, 'text': 'Featured'}
  193. ] %}
  194. {% set sites = [
  195.   {'id': 20, 'text': 'RoofersCoffeeShop'},
  196.   {'id': 21, 'text': 'MetalCoffeeShop'},
  197.   {'id': 23, 'text': 'CoatingsCoffeeShop'}
  198. ] %}
  199. {% set regions = [
  200.   {'id': 6, 'text': 'All Regions'},
  201.   {'id': 7, 'text': 'Northeast'},
  202.   {'id': 8, 'text': 'Southeast'},
  203.   {'id': 9, 'text': 'Midwest'},
  204.   {'id': 10, 'text': 'Northwest'},
  205.   {'id': 11, 'text': 'Southwest'},
  206.   {'id': 12, 'text': 'Canada: Alberta'},
  207.   {'id': 13, 'text': 'Canada: British Columbia'},
  208.   {'id': 14, 'text': 'Canada: Manitoba'},
  209.   {'id': 15, 'text': 'Canada: Newfoundland'},
  210.   {'id': 16, 'text': 'Canada: Ontario'},
  211.   {'id': 17, 'text': 'Canada: Prince Edward Island, Nova Scotia, New Brunswick'},
  212.   {'id': 18, 'text': 'Canada: Quebec'},
  213.   {'id': 19, 'text': 'Canada: Saskatchewan'}
  214.   
  215. ] %}
  216. <form id="classified-form">
  217. <div class="classified-options">
  218.   <div class="row">
  219.     <div class="col-lg-6">
  220.       <h3>Duration</h3>
  221.       <div class="row">
  222.         {% for duration in durations %}
  223.           <div class="col-6 cbtn-wrapper">
  224.             <input type="radio" class="btn-check" name="duration" autocomplete="off" value="{{duration.id}}" required>
  225.             {% if duration.text == '60 Days' %}
  226.               <label class="top-highlight">Most Popular</label>
  227.             {% endif %}
  228.             <label class="btn btn-classified">{{duration.text}}</label>
  229.             </input>
  230.           </div>
  231.         {% endfor %}
  232.       </div>
  233.     </div>
  234.     <div class="col-lg-6">
  235.       <h3>Graphics</h3>
  236.       <div class="row">
  237.         {% for graphic in graphics %}
  238.           <div class="col-6 cbtn-wrapper">
  239.             <input type="radio" class="btn-check" name="graphic" autocomplete="off" value="{{graphic.id}}">
  240.             <label class="btn btn-classified">{{graphic.text}}
  241.               {% if graphic.text == "Featured" %}
  242.                 <span class="rtooltip"> <i class="fa fa-question-circle"></i>
  243.                   <div class="rtooltiptext" style="font-size:14px;">
  244.                     Featured classified listings include a video or image, are posted on RoofersCoffeeShop's Twitter, and are highlighted at the top of our classifieds page.
  245.                     <br><br>
  246.                     Selecting this option will automatically select "All Regions" below.
  247.                     <br>
  248.                   </div>
  249.                 </span>
  250.               {% endif %}
  251.             </label>
  252.             </input>
  253.           </div>
  254.         {% endfor %}
  255.       </div>
  256.     </div>
  257.     <div class="col-lg-12 mt-4">
  258.       <h3>Sites</h3>
  259.       <div id="sites-row" class="row">
  260.         {% for site in sites %}
  261.           <div class="col-lg-3 col-6 cbtn-wrapper">
  262.             <input type="checkbox" class="btn-check" name="sites[]" autocomplete="off" value="{{site.id}}" {#required#}>
  263.             <label class="btn btn-classified">{{site.text}}</label>
  264.             </input>
  265.           </div>
  266.         {% endfor %}
  267.       </div>
  268.     </div>
  269.     
  270.     <div class="col-lg-12 mt-4">
  271.       <h3 style="margin-bottom:20px;">Region</h3>
  272.       <div id="regions-row" class="row">
  273.         {% for region in regions %}
  274.           {#<div class="col-3 cbtn-wrapper"><button class="btn btn-classified">{{region}}</button></div>#}
  275.           <div class="col-lg-3 col-6 cbtn-wrapper">
  276.             {% if region.text == 'All Regions' %}
  277.               <label class="top-highlight">Best Value</label>
  278.             {% endif %}
  279.             <input type="checkbox" class="btn-check" name="regions[]" autocomplete="off" value="{{region.id}}">
  280.             <label class="btn btn-classified" {% if region.text|length > 35 %} style="line-height:15px; padding:5px;" {% endif %}>{{region.text}}</label>
  281.             </input>
  282.           </div>
  283.         {% endfor %}
  284.       </div>
  285.     </div>
  286.   </div>
  287. </div>
  288. <div style="padding-top:10px;" class="row">
  289.   <div class="col-3">
  290.     <h2 style="color:#A6252A;">PRICE: $<span id="total-classified-price">30</span></h2>
  291.     <input type="hidden" id="total-price-input" name="total-price-input" value="30"/>
  292.   </div>
  293.   <div class="col-9">
  294.     <button type="submit" class="btn btn-primary" style="color: #fff; background-color: #A6252A;border-radius:6px;">Continue to Create Your Ad</button>
  295.   </div>
  296. </div>
  297. </form>
  298. <script>
  299. (function($){
  300.     $(function(){
  301.     
  302.     $(".btn-classified").click(function (e) {
  303.       var checkBox = $(this).parent().find(".btn-check");
  304.       var checkedVal = checkBox.prop("checked");
  305.       if(checkBox.parent().parent().attr('id') == "regions-row") {
  306.         
  307.         var disabled = false;
  308.         
  309.         $("input[name='graphic']").each(function (index, obj) {
  310.           if($(this).prop("checked") && $(this).val() == 22) {
  311.             disabled = true;
  312.           }
  313.         });
  314.         if(!disabled) {
  315.           checkBox.prop("checked", !checkBox.prop("checked"));
  316.           checkedVal = checkBox.prop("checked");
  317.           if(checkBox.val() == 6 && checkedVal) { // All Regions
  318.             $(this).parent().parent().find(".btn-check").prop("checked", false);
  319.             checkBox.prop("checked", checkedVal);
  320.           }
  321.           else if(checkedVal) {
  322.             $(this).parent().parent().find(":input[value=6]").prop("checked", false);
  323.           }
  324.         }
  325.         
  326.         
  327.       }
  328.       else {
  329.         checkBox.prop("checked", !checkBox.prop("checked"));
  330.         checkedVal = checkBox.prop("checked");
  331.       }
  332.       // If featured: force "All Regions" to be selected
  333.       if(checkBox.val() == 22 && checkedVal) { // Featured
  334.         $("#regions-row .btn-check").each(function (index, obj) {
  335.             $(this).prop("checked", $(this).val() == 6);
  336.         });
  337.         $(this).parent().parent().find(".btn-check").prop("checked", false);
  338.         checkBox.prop("checked", checkedVal);
  339.       }
  340.       var months = 1;
  341.       var totalPrice = 30;
  342.       $("input[name='duration']").each(function (index, obj) {
  343.         if($(this).prop("checked")) {
  344.           switch($(this).val()) {
  345.             case '2':
  346.               totalPrice += 30;
  347.               months = 2;
  348.               break;
  349.             case '3':
  350.               totalPrice += 60;
  351.               months = 3;
  352.               break;
  353.           }
  354.         }
  355.       });
  356.       var featured = false;
  357.       $("input[name='graphic']").each(function (index, obj) {
  358.         if($(this).prop("checked")) {
  359.           switch($(this).val()) {
  360.             case '4':
  361.               totalPrice += 25;
  362.               break;
  363.             case '5':
  364.               totalPrice += 75;
  365.               break;
  366.             case '22':
  367.               totalPrice = (months * 175); //Total price for featured is $175 per month (for one site)
  368.               featured = true;
  369.               break;
  370.           }
  371.         }
  372.       });
  373.       var firstRegion = true;
  374.       $("input[name='regions[]']").each(function (index, obj) {
  375.         if($(this).prop("checked")) {
  376.           if($(this).val() == 6) { // All Regions
  377.             if(!featured) { //All regions included with Featured
  378.               totalPrice += 50;
  379.             }
  380.           }
  381.           else if(firstRegion) {
  382.             firstRegion = false;
  383.           }
  384.           else {
  385.             totalPrice += 10;
  386.           }
  387.         }
  388.       });
  389.       var firstSite = true;
  390.       $("input[name='sites[]']").each(function (index, obj) {
  391.         if($(this).prop("checked")) {
  392.           if(firstSite) {
  393.             firstSite = false;
  394.           }
  395.           else {
  396.             totalPrice += 50;
  397.           }
  398.         }
  399.       });
  400.       
  401.       $("#total-classified-price").text(totalPrice);
  402.       $("#total-price-input").val(totalPrice);
  403.       
  404.     });
  405.     
  406.     //$("#classified-form").submit(function(e) {
  407.     $("form").submit(function(e) { // TODO: Only specific form
  408.       if($("input[name='sites[]']:checked").length == 0) {
  409.         e.preventDefault();
  410.         alert("Please select at least one site to continue.");
  411.       }
  412.       else if($("input[name='regions[]']:checked").length == 0) {
  413.         e.preventDefault();
  414.         alert("Please select at least one region to continue.");
  415.       }
  416.       
  417.     });
  418.     
  419.         
  420.     });
  421. }(jQuery));
  422. </script>