You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

515 lines
21 KiB

  1. {% extends "base.html" %}
  2. {% load compress staticfiles hc_extras %}
  3. {% block title %}Account Settings - {% site_name %}{% endblock %}
  4. {% block content %}
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <h1 class="settings-title">Settings</h1>
  8. </div>
  9. </div>
  10. <div class="row">
  11. <div class="col-sm-3">
  12. <ul class="nav nav-pills nav-stacked">
  13. <li><a href="{% url 'hc-profile' %}">Account</a></li>
  14. <li class="active"><a href="{% url 'hc-billing' %}">Billing</a></li>
  15. <li><a href="{% url 'hc-notifications' %}">Email Reports</a></li>
  16. <li><a href="{% url 'hc-badges' %}">Badges</a></li>
  17. </ul>
  18. </div>
  19. <div class="col-sm-9 col-md-9">
  20. {% if messages %}
  21. <div class="alert alert-danger">
  22. <p>
  23. <strong>We're sorry!</strong> There was a problem setting
  24. up the subscription. Response from payment gateway:</p>
  25. {% for message in messages %}
  26. <p class="error-message">{{ message }}</p>
  27. {% endfor %}
  28. </div>
  29. {% endif %}
  30. <div class="row">
  31. <div class="col-sm-6">
  32. <div class="panel panel-{{ set_plan_status }}">
  33. <div class="panel-body settings-block">
  34. <h2>Billing Plan</h2>
  35. <table class="table">
  36. <tr>
  37. <td>Current Plan</td>
  38. <td>
  39. {% if sub is None or sub.plan_id == "" %}
  40. Free
  41. {% else %}
  42. {{ sub.plan_name }}
  43. {% endif %}
  44. </td>
  45. </tr>
  46. {% if sub.plan_id %}
  47. <tr>
  48. <td>Next Payment</td>
  49. <td id="next-billing-date">
  50. <span class="loading">loading…</span>
  51. </td>
  52. </tr>
  53. {% endif %}
  54. <tr>
  55. <td>Checks Used</td>
  56. <td {% if num_checks >= profile.check_limit %} class="at-limit" {% endif %}>
  57. <span>{{ num_checks }} of {{ profile.check_limit }}</span>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td>Team Size</td>
  62. <td {% if team_size >= profile.team_limit %} class="at-limit" {% endif %}>
  63. <span>
  64. {{ team_size }} of
  65. {% if profile.team_limit == 500 %}
  66. unlimited
  67. {% else %}
  68. {{ team_max }}
  69. {% endif %}
  70. </span>
  71. </td>
  72. </tr>
  73. </table>
  74. <button
  75. data-toggle="modal"
  76. data-target="#change-billing-plan-modal"
  77. class="btn btn-default pull-right">
  78. Change Billing Plan
  79. </button>
  80. </div>
  81. {% if set_plan_status == "success" %}
  82. <div class="panel-footer">
  83. Your billing plan has been updated!
  84. </div>
  85. {% endif %}
  86. </div>
  87. <div class="panel panel-{{ payment_method_status }}">
  88. <div class="panel-body settings-block">
  89. <h2>Payment Method</h2>
  90. {% if sub.payment_method_token %}
  91. <p id="payment-method">
  92. <span class="loading">loading…</span>
  93. </p>
  94. {% else %}
  95. <p id="payment-method-missing" class="billing-empty">Not set</p>
  96. {% endif %}
  97. <button
  98. id="update-payment-method"
  99. class="btn btn-default pull-right">
  100. Change Payment Method</button>
  101. </div>
  102. {% if payment_method_status == "success" %}
  103. <div class="panel-footer">
  104. Your payment method has been updated!
  105. </div>
  106. {% endif %}
  107. </div>
  108. </div>
  109. <div class="col-sm-6">
  110. <div class="panel panel-{{ address_status }}">
  111. <div class="panel-body settings-block">
  112. <h2>Billing Details</h2>
  113. {% if sub.address_id %}
  114. <div id="billing-address">
  115. <span class="loading">loading…</span>
  116. </div>
  117. {% else %}
  118. <p id="billing-address-missing" class="billing-empty">
  119. Not set
  120. </p>
  121. {% endif %}
  122. <button
  123. data-toggle="modal"
  124. data-target="#billing-address-modal"
  125. class="btn btn-default pull-right">
  126. Change Billing Details
  127. </button>
  128. </div>
  129. {% if address_status == "success" %}
  130. <div class="panel-footer">
  131. Your billing details have been updated!
  132. </div>
  133. {% endif %}
  134. </div>
  135. </div>
  136. </div>
  137. <div class="panel panel-{{ send_invoices_status }}">
  138. <div class="panel-body settings-block">
  139. <h2>Invoices to Email</h2>
  140. <p id="invoice-emailing-status">
  141. {% if sub.send_invoices %}
  142. Send the invoice to
  143. {{ sub.invoice_email|default:request.user.email }}
  144. each time my payment method is successfully charged.
  145. {% else %}
  146. Do not email invoices to me.
  147. {% endif %}
  148. </p>
  149. <button
  150. data-toggle="modal"
  151. data-target="#invoice-emailing-modal"
  152. class="btn btn-default pull-right">
  153. Change Preference
  154. </button>
  155. </div>
  156. {% if send_invoices_status == "success" %}
  157. <div class="panel-footer">
  158. Your preferences have been updated!
  159. </div>
  160. {% endif %}
  161. </div>
  162. <div class="panel panel-default">
  163. <div class="panel-body settings-block">
  164. <h2>Billing History</h2>
  165. <div id="billing-history">
  166. <span class="loading">loading…</span>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. <div id="change-billing-plan-modal" class="modal">
  173. <div class="modal-dialog">
  174. {% if sub.payment_method_token and sub.address_id %}
  175. <form method="post" class="form-horizontal" action="{% url 'hc-set-plan' %}">
  176. {% csrf_token %}
  177. <div class="modal-content">
  178. <div class="modal-header">
  179. <button type="button" class="close" data-dismiss="modal">&times;</button>
  180. <h4 class="remove-check-title">Change Billing Plan</h4>
  181. </div>
  182. <div class="modal-body">
  183. <h2>Free <small>20 checks, 3 team members</small></h2>
  184. <label class="radio-container">
  185. <input
  186. type="radio"
  187. name="plan_id"
  188. value=""
  189. {% if sub.plan_id == "" %} checked {% endif %}>
  190. <span class="radiomark"></span>
  191. Enjoy free service.
  192. </label>
  193. <h2>Standard <small>100 checks, 10 team members</small></h2>
  194. <label class="radio-container">
  195. <input
  196. type="radio"
  197. name="plan_id"
  198. value="P20"
  199. {% if sub.plan_id == "P20" %} checked {% endif %}>
  200. <span class="radiomark"></span>
  201. Monthly, $20 / month
  202. </label>
  203. <label class="radio-container">
  204. <input
  205. type="radio"
  206. name="plan_id"
  207. value="Y192"
  208. {% if sub.plan_id == "Y192" %} checked {% endif %}>
  209. <span class="radiomark"></span>
  210. Annual, $192 / year (20% off monthly)
  211. </label>
  212. <h2>Plus <small>1000 checks, unlimited team members</small></h2>
  213. <label class="radio-container">
  214. <input
  215. type="radio"
  216. name="plan_id"
  217. value="P80"
  218. {% if sub.plan_id == "P80" %} checked {% endif %}>
  219. <span class="radiomark"></span>
  220. Monthly, $80/month
  221. </label>
  222. <label class="radio-container">
  223. <input
  224. type="radio"
  225. name="plan_id"
  226. value="Y768"
  227. {% if sub.plan_id == "Y768" %} checked {% endif %}>
  228. <span class="radiomark"></span>
  229. Annual, $768/year (20% off monthly)
  230. </label>
  231. <div class="alert alert-warning">
  232. <strong>No proration.</strong> We currently do not
  233. support proration when changing billing plans.
  234. Changing the plan starts a new billing cycle
  235. and charges your payment method.
  236. </div>
  237. </div>
  238. <div class="modal-footer">
  239. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  240. <button type="submit" class="btn btn-primary">
  241. Change Billing Plan
  242. </button>
  243. </div>
  244. </div>
  245. </form>
  246. {% else %}
  247. <div class="modal-content">
  248. <div class="modal-header">
  249. <button type="button" class="close" data-dismiss="modal">&times;</button>
  250. <h4>Some details are missing…</h4>
  251. </div>
  252. <div class="modal-body">
  253. {% if not sub.payment_method_token %}
  254. <div id="no-payment-method">
  255. <h4>No payment method.</h4>
  256. <p>Please add a payment method before changing the billing
  257. plan.
  258. </p>
  259. </div>
  260. {% endif %}
  261. {% if not sub.address_id %}
  262. <div id="no-billing-address">
  263. <h4>Country not specified.</h4>
  264. <p>For tax accounting purposes, please specify
  265. your <strong>Country</strong> in the "Billing Details"
  266. section.
  267. </p>
  268. <p>
  269. Optionally, add your
  270. <strong>company name</strong>, <strong>address</strong>
  271. and <strong>VAT ID</strong>
  272. to have them displayed on invoices.
  273. </p>
  274. </div>
  275. {% endif %}
  276. </div>
  277. <div class="modal-footer">
  278. <button type="button" class="btn btn-default" data-dismiss="modal">OK</button>
  279. </div>
  280. </div>
  281. {% endif %}
  282. </div>
  283. </div>
  284. <div id="payment-method-modal" class="modal pm-modal">
  285. <div class="modal-dialog">
  286. <form id="payment-form" method="post" action="{% url 'hc-payment-method' %}">
  287. {% csrf_token %}
  288. <input id="pmm-nonce" type="hidden" name="payment_method_nonce" />
  289. <div class="modal-content">
  290. <div class="modal-header">
  291. <button type="button" class="close" data-dismiss="modal">&times;</button>
  292. <h4>Payment Method</h4>
  293. </div>
  294. <div class="modal-body">
  295. <div id="dropin"></div>
  296. </div>
  297. <div class="modal-footer">
  298. <button type="button" class="btn btn-default" data-dismiss="modal">
  299. Cancel
  300. </button>
  301. <button id="payment-form-submit" type="button" class="btn btn-primary" disabled>
  302. Confirm Payment Method
  303. </button>
  304. </div>
  305. </div>
  306. </form>
  307. </div>
  308. </div>
  309. <div id="billing-address-modal" class="modal">
  310. <div class="modal-dialog">
  311. <form action="{% url 'hc-billing-address' %}" method="post">
  312. {% csrf_token %}
  313. <div class="modal-content">
  314. <div class="modal-header">
  315. <button type="button" class="close" data-dismiss="modal">&times;</button>
  316. <h4>Billing Details</h4>
  317. </div>
  318. <div class="modal-body">
  319. <div class="row">
  320. <div class="col-sm-8">
  321. <div class="form-group">
  322. <label for="company">
  323. Company
  324. </label>
  325. <input
  326. id="company"
  327. name="company"
  328. type="text"
  329. class="form-control" />
  330. </div>
  331. </div>
  332. <div class="col-sm-4">
  333. <div class="form-group">
  334. <label for="extended_address">
  335. VAT ID
  336. </label>
  337. <input
  338. id="extended_address"
  339. name="extended_address"
  340. type="text"
  341. class="form-control" />
  342. </div>
  343. </div>
  344. <div class="col-sm-12">
  345. <div class="form-group">
  346. <label for="company">Street Address</label>
  347. <input
  348. id="street_address"
  349. name="street_address"
  350. type="text"
  351. class="form-control" />
  352. </div>
  353. </div>
  354. <div class="col-sm-6">
  355. <label for="locality">
  356. City
  357. </label>
  358. <div class="form-group">
  359. <input
  360. id="locality"
  361. name="locality"
  362. type="text"
  363. class="form-control" />
  364. </div>
  365. </div>
  366. <div class="col-sm-6">
  367. <div class="form-group">
  368. <label for="region">
  369. State / Region
  370. </label>
  371. <input
  372. id="region"
  373. name="region"
  374. type="text"
  375. class="form-control" />
  376. </div>
  377. </div>
  378. <div class="col-sm-6">
  379. <div class="form-group">
  380. <label for="postal_Code">
  381. Postal Code
  382. </label>
  383. <input
  384. id="postal_code"
  385. name="postal_code"
  386. type="text"
  387. class="form-control" />
  388. </div>
  389. </div>
  390. <div class="col-sm-6">
  391. <div class="form-group">
  392. <label for="country_code_alpha2">
  393. Country
  394. </label>
  395. <select id="country_code_alpha2" class="form-control" name="country_code_alpha2">
  396. {% include "payments/countries.html" %}
  397. </select>
  398. </div>
  399. </div>
  400. </div>
  401. </div>
  402. <div class="modal-footer">
  403. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  404. <button type="submit" class="btn btn-primary">Save</button>
  405. </div>
  406. </div>
  407. </form>
  408. </div>
  409. </div>
  410. <div id="invoice-emailing-modal" class="modal pm-modal">
  411. <div class="modal-dialog">
  412. <form method="post">
  413. {% csrf_token %}
  414. <div class="modal-content">
  415. <div class="modal-header">
  416. <button type="button" class="close" data-dismiss="modal">&times;</button>
  417. <h4>Invoices to Email</h4>
  418. </div>
  419. <div class="modal-body">
  420. <label class="radio-container">
  421. <input
  422. type="radio"
  423. name="send_invoices"
  424. value="0"
  425. {% if not sub.send_invoices %} checked {% endif %}>
  426. <span class="radiomark"></span>
  427. Do not email invoices to me
  428. </label>
  429. <label class="radio-container">
  430. <input
  431. type="radio"
  432. name="send_invoices"
  433. value="1"
  434. {% if sub.send_invoices and not sub.invoice_email %} checked {% endif %}>
  435. <span class="radiomark"></span>
  436. Send invoices to {{ profile.user.email }}
  437. </label>
  438. <label class="radio-container">
  439. <input
  440. type="radio"
  441. name="send_invoices"
  442. value="2"
  443. {% if sub.send_invoices and sub.invoice_email %} checked {% endif %}>
  444. <span class="radiomark"></span>
  445. Send invoices to this email address:
  446. </label>
  447. <input
  448. id="invoice-email"
  449. name="invoice_email"
  450. placeholder="[email protected]"
  451. value="{{ sub.invoice_email }}"
  452. type="email"
  453. class="form-control" />
  454. </div>
  455. <div class="modal-footer">
  456. <button type="button" class="btn btn-default" data-dismiss="modal">
  457. Cancel
  458. </button>
  459. <button type="submit" class="btn btn-primary">
  460. Save Changes
  461. </button>
  462. </div>
  463. </div>
  464. </form>
  465. </div>
  466. </div>
  467. {% endblock %}
  468. {% block scripts %}
  469. <script src="https://js.braintreegateway.com/web/dropin/1.8.0/js/dropin.min.js"></script>
  470. {% compress js %}
  471. <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
  472. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  473. <script src="{% static 'js/billing.js' %}"></script>
  474. {% endcompress %}
  475. {% endblock %}