/inc/app/siteinvoice/forms/settings/index.php

https://github.com/durand54/sitellite · PHP · 160 lines · 151 code · 9 blank · 0 comment · 4 complexity · c1c1ff06e23b12dd2e3303bcfe2e28a3 MD5 · raw file

  1. <?php
  2. if (! is_writeable ('inc/app/siteinvoice/conf/properties.php')) {
  3. page_title ('Error');
  4. echo '<p>Unable to write to the inc/app/siteinvoice/conf/properties.php file. Please adjust your filesystem permissions and try again.</p>';
  5. return;
  6. }
  7. if (is_file ('inc/app/siteinvoice/conf/properties.old.php') && ! is_writeable ('inc/app/siteinvoice/conf/properties.old.php')) {
  8. page_title ('Error');
  9. echo '<p>Unable to write to the inc/app/siteinvoice/conf/properties.old.php file. Please adjust your filesystem permissions and try again.</p>';
  10. return;
  11. }
  12. if (! is_writeable ('inc/app/siteinvoice/conf')) {
  13. page_title ('Error');
  14. echo '<p>Unable to write to the inc/app/siteinvoice/conf folder. Please adjust your filesystem permissions and try again.</p>';
  15. return;
  16. }
  17. class SiteinvoiceSettingsForm extends MailForm {
  18. var $_template = '<{split}?php
  19. /**
  20. * This is the email address to send invoices from, as well as to receive
  21. * blind carbon copies of the invoices and 90-day "no payment" notices.
  22. * This should be a working email address that can receive replies
  23. * regarding invoices that have been sent out.
  24. */
  25. appconf_set (\'company_email\', \'{company_email}\');
  26. /**
  27. * This is the name that will appear in the From header to clients.
  28. */
  29. appconf_set (\'company_email_name\', \'{company_email_name}\');
  30. /**
  31. * The full company name as it should be displayed in the invoices.
  32. */
  33. appconf_set (\'company_name\', \'{company_name}\');
  34. /**
  35. * The company address as it should be displayed in the invoices. This
  36. * must stay on a single line.
  37. */
  38. appconf_set (\'company_address\', \'{company_address}\');
  39. /**
  40. * The company phone number as it should be displayed in the invoices.
  41. */
  42. appconf_set (\'company_phone\', \'{company_phone}\');
  43. /**
  44. * The company web site as it should be displayed in the invoices.
  45. * Note: Do not include the http:// prefix, as it will break the link
  46. * in the invoice.
  47. */
  48. appconf_set (\'company_website\', \'{company_website}\');
  49. /**
  50. * This is an optional list of email addresses to blind carbon copy on
  51. * message notices.
  52. */
  53. appconf_set (\'bcc_list\', \'{bcc_list}\');
  54. /**
  55. * Any extra information that should be displayed in the invoices. This
  56. * will appear right-aligned underneath the invoice total. This field
  57. * is often used for tax information and interest notices.
  58. */
  59. appconf_set (\'extra_info\', \'{extra_info}\');
  60. /**
  61. * Here you can customize the taxes to your region. Taxes are specified
  62. * as an array with the keys being the tax name (ie. GST, VAT, etc.) and
  63. * the value being the decimal value to multiple the subtotal by to
  64. * determine the tax amount. For example, if the tax is 7%, then the
  65. * value would be 0.07
  66. */
  67. appconf_set (\'taxes\', array (
  68. {loop obj[taxes]}
  69. \'{loop/_key}\' => {loop/_value},
  70. {end loop}
  71. ));
  72. /**
  73. * Here you can set the subject lines for each of the reminders. If you
  74. * don\'t wish to have a reminder sent for one of these, simply set the
  75. * value to false. Note that %s in the value will be replaced with the
  76. * invoice ID number.
  77. */
  78. appconf_set (\'reminders\', array (
  79. {loop obj[reminders]}
  80. {loop/_key} => \'{loop/_value}\',
  81. {end loop}
  82. ));
  83. /**
  84. * This is the default currency to use as a base for currency conversions.
  85. */
  86. appconf_set (\'default_currency\', \'{default_currency}\');
  87. /**
  88. * This is the list of currencies to display.
  89. */
  90. appconf_set (\'currencies\', array (
  91. {loop obj[currencies]}
  92. \'{loop/_value}\',
  93. {end loop}
  94. ));
  95. /**
  96. * This is a Paypal ID to allow people to pay you via Paypal directly from
  97. * the invoice emails.
  98. */
  99. appconf_set (\'paypal_id\', \'{paypal_id}\');
  100. ?{split}>';
  101. function SiteinvoiceSettingsForm () {
  102. parent::MailForm (__FILE__);
  103. page_title ('SiteInvoice - Settings');
  104. $this->widgets['company_name']->setDefault (appconf ('company_name'));
  105. $this->widgets['company_email']->setDefault (appconf ('company_email'));
  106. $this->widgets['company_email_name']->setDefault (appconf ('company_email_name'));
  107. $this->widgets['company_website']->setDefault (appconf ('company_website'));
  108. $this->widgets['company_phone']->setDefault (appconf ('company_phone'));
  109. $this->widgets['company_address']->setDefault (appconf ('company_address'));
  110. $this->widgets['bcc_list']->setDefault (appconf ('bcc_list'));
  111. $this->widgets['extra_info']->setDefault (appconf ('extra_info'));
  112. $taxes = appconf ('taxes');
  113. foreach ($taxes as $k => $v) {
  114. $taxes[$k] = $v * 100;
  115. }
  116. $this->widgets['taxes']->setDefault ($taxes);
  117. $this->widgets['reminders']->setDefault (appconf ('reminders'));
  118. $this->widgets['default_currency']->setDefault (appconf ('default_currency'));
  119. $this->widgets['currencies']->setDefault (join (', ', appconf ('currencies')));
  120. $this->widgets['paypal_id']->setDefault (appconf ('paypal_id'));
  121. }
  122. function onSubmit ($vals) {
  123. loader_import ('saf.File');
  124. foreach ($vals['taxes'] as $k => $v) {
  125. $vals['taxes'][$k] = $v / 100;
  126. }
  127. $vals['currencies'] = preg_split ('/, ?/', $vals['currencies']);
  128. file_overwrite ('inc/app/siteinvoice/conf/properties.old.php', join ('', file ('inc/app/siteinvoice/conf/properties.php')));
  129. file_overwrite ('inc/app/siteinvoice/conf/properties.php', template_simple ($this->_template, $vals));
  130. umask (0000);
  131. @chmod ('inc/app/siteinvoice/conf/properties.old.php', 0777);
  132. @chmod ('inc/app/siteinvoice/conf/properties.php', 0777);
  133. page_title ('SiteInvoice - Settings Saved');
  134. echo '<p><a href="' . site_prefix () . '/index/siteinvoice-app">Continue</a></p>';
  135. }
  136. }
  137. ?>