PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/pages/web-form-edit.php

https://bitbucket.org/14rego/cman
PHP | 378 lines | 335 code | 29 blank | 14 comment | 71 complexity | cf9c12adcbe604e615b85b103f969271 MD5 | raw file
  1. <?php
  2. $f_id = $sql->secure_Esc($_GET['id']);
  3. $dup_id = $sql->secure_Esc($_GET['dup']);
  4. if ($f_id=='new' || $f_id=='') {
  5. echo '<h1>New Form';
  6. $f_id='new';
  7. $f_notify_to = 'regan.campbell@softkeinc.com';
  8. if ($dup_id>0) {
  9. $row = $sql->fetch("SELECT * FROM site_forms WHERE id = $dup_id;");
  10. if ($row != NULL) {
  11. $f_code = $row['code'].'_'.$datim->nowish();
  12. $f_dsc = $row['dsc'];
  13. $f_cat = $row['cat'];
  14. $f_status = $row['status'];
  15. $f_stamp = $row['stamp'];
  16. $f_disp = $row['disp'];
  17. $f_css_class = $row['css_class'];
  18. $f_act = $row['act'];
  19. $f_fyle = $row['fyle'];
  20. $f_msg_email = $row['msg_email'];
  21. $f_msg_confirm = $row['msg_confirm'];
  22. $f_redir = $row['redir'];
  23. $f_notify_to = $row['notify_to'];
  24. $f_notify_bcc = $row['notify_bcc'];
  25. $f_title_text = $row['title_text'];
  26. $f_title_bg = $row['title_bg'];
  27. $f_title_color = $row['title_color'];
  28. $f_subtitle = $row['subtitle'];
  29. $f_directions = $row['directions'];
  30. $f_fine_print = $row['fine_print'];
  31. $f_submit_typ = $row['submit_typ'];
  32. $f_submit_dsc = $row['submit_dsc'];
  33. $f_submit_img = $row['submit_img'];
  34. $directory = $softek->product_Name('Softek', $f_cat);
  35. echo ' based on <em>'.$row['code'].'</em>';
  36. }
  37. }
  38. echo '</h1>';
  39. if ($row != NULL) { echo '<p class="error">All questions and options will be copied exactly, except what you change here. You will have a chance to edit them next.</p>'; }
  40. } else {
  41. $row = $sql->fetch("SELECT * FROM site_forms WHERE id = $f_id;");
  42. if ($row != NULL) {
  43. $f_code = $row['code'];
  44. $f_dsc = $row['dsc'];
  45. $f_cat = $row['cat'];
  46. $f_status = $row['status'];
  47. $f_stamp = $row['stamp'];
  48. $f_disp = $row['disp'];
  49. $f_css_class = $row['css_class'];
  50. $f_act = $row['act'];
  51. $f_fyle = $row['fyle'];
  52. $f_msg_email = $row['msg_email'];
  53. $f_msg_confirm = $row['msg_confirm'];
  54. $f_redir = $row['redir'];
  55. $f_notify_to = $row['notify_to'];
  56. $f_notify_bcc = $row['notify_bcc'];
  57. $f_title_text = $row['title_text'];
  58. $f_title_bg = $row['title_bg'];
  59. $f_title_color = $row['title_color'];
  60. $f_subtitle = $row['subtitle'];
  61. $f_directions = $row['directions'];
  62. $f_fine_print = $row['fine_print'];
  63. $f_submit_typ = $row['submit_typ'];
  64. $f_submit_dsc = $row['submit_dsc'];
  65. $f_submit_img = $row['submit_img'];
  66. $directory = $softek->product_Name('Softek', $f_cat);
  67. echo '<h1>Edit Web Form</h1>';
  68. } else {
  69. echo '<p class="error">There was a problem accessing your form.</p>';
  70. }
  71. } ?>
  72. <form id="form-edit-web-form" enctype="multipart/form-data" method="post">
  73. <input type="hidden" id="form_id" name="form_id" value="<?php echo $f_id; ?>" />
  74. <input type="hidden" id="form_dup" name="form_dup" value="<?php echo $dup_id; ?>" />
  75. <ul class="form">
  76. <li><label>Color Scheme</label>
  77. <select name="form_cat">
  78. <option value="SSI" <?php if (empty($f_cat) || $f_cat == 'SSI') echo 'selected = "selected"'; ?>>Softek</option>
  79. <option value="ILM" <?php if ($f_cat == 'ILM') echo 'selected = "selected"'; ?>>Illuminate</option>
  80. <option value="OTK" <?php if ($f_cat == 'OTK') echo 'selected = "selected"'; ?>>OnTrack</option>
  81. </select>
  82. </li>
  83. <li><label>Code</label><input type="text" id="form_code" name="form_code" value="<?php echo $f_code; ?>" /></li>
  84. <li><h6 class="helper">This <span class="error">unique</span> code will be filtered for a-Z_0-9.</h6></li>
  85. <li><label>Form Display</label>
  86. <select name="form_disp">
  87. <option value="page" <?php if (empty($f_disp) || $f_disp == 'page') echo 'selected = "selected"'; ?>>On page only</option>
  88. <option value="dialog" <?php if ($f_disp == 'dialog') echo 'selected = "selected"'; ?>>By dialog only</option>
  89. <option value="either" <?php if ($f_disp == 'either') echo 'selected = "selected"'; ?>>Either is allowed</option>
  90. </select>
  91. </li>
  92. <li><label>CSS Class</label><input type="text" id="form_css_class" name="form_css_class" value="<?php echo $f_css_class; ?>" /></li>
  93. <li><h6 class="helper error">If the scheme and code match a live web page URL (and the Form Display <br />is not set to &ldquo;By dialog only&rdquo;), the form will display on the page automatically <br />(in a <<!--BREAK-->div> with the appropriate CSS Class).</h6></li>
  94. <li><label>Internal Description</label><input type="text" id="form_dsc" name="form_dsc" value="<?php echo $f_dsc; ?>" /></li>
  95. <li><label>Form Action</label>
  96. <select name="form_act">
  97. <option value="contact" <?php if (empty($f_act) || $f_act == 'contact') echo 'selected = "selected"'; ?>>Just notify Softek</option>
  98. <option value="download" <?php if ($f_act == 'download') echo 'selected = "selected"'; ?>>User downloads a file</option>
  99. <option value="email" <?php if ($f_act == 'email') echo 'selected = "selected"'; ?>>Email user</option>
  100. <option value="choose" <?php if ($f_act == 'choose') echo 'selected = "selected"'; ?>>The user decides to download or receive a link by email</option>
  101. <option value="redirect" <?php if ($f_act == 'redirect') echo 'selected = "selected"'; ?>>Redirect user to another page</option>
  102. </select>
  103. <li><h6 class="helper">All form submissions will send a notification of some sort to a Softek employee.</h6></li>
  104. </li>
  105. <li><label>Notification Email</label><input type="text" id="form_notify_to" name="form_notify_to" value="<?php echo $f_notify_to; ?>" /></li>
  106. <li><h6 class="helper">
  107. When someone fills out the form, this person will be notified.<br />
  108. This address also serves as the &ldquo;From&rdquo; address for any emails to the user.<br />
  109. <b>Only one</b> address both allowed and required.
  110. </h6></li>
  111. <li><label>Notification BCCs</label><input type="text" id="form_notify_bcc" name="form_notify_bcc" value="<?php echo $f_notify_bcc; ?>" /></li>
  112. <li><h6 class="helper">Emails should be separated by a comma with no spaces, if necessary</h6></li>
  113. <li><label>File Download</label>
  114. <select name="form_fyle"><?php
  115. echo '<option value="none"'; if (empty($f_fyle) || $f_fyle == 'none') echo 'selected = "selected"'; echo '>[ none ]</option>';
  116. $fyle = glob($root.'/resources/downloads/*.{doc,pdf,txt,rtf,jpg,png,xls,ppt}', GLOB_BRACE);
  117. foreach ($fyle as $key) {
  118. $actual_file = substr($key, 46);
  119. echo '<option value="'.$actual_file.'">'.$actual_file.'</option>';
  120. } ?>
  121. </select>
  122. </li>
  123. <li><label>Confirmation</label>
  124. <textarea name="form_msg_confirm" cols="75" rows="3"><?php echo $f_msg_confirm; ?></textarea>
  125. </li>
  126. <li><h6 class="helper">The message the user receives on the page after filling out the form</h6></li>
  127. <li><label>Email Message</label>
  128. <textarea name="form_msg_email" cols="75" rows="3"><?php echo $f_msg_email; ?></textarea>
  129. </li>
  130. <li><h6 class="helper">The message the user should receive via email, if applicable</h6></li>
  131. <li><label>Redirect Address</label><input type="text" id="form_redir" name="form_redir" value="<?php echo $f_redir; ?>" /></li>
  132. <li><h6 class="helper">Must set Form Action to redirect.</h6></li>
  133. <li><label>Form Status</label>
  134. <select name="form_status">
  135. <option value="live" <?php if (empty($f_status) || $f_status == 'live') echo 'selected = "selected"'; ?>>Live</option>
  136. <option value="draft" <?php if ($f_status == 'draft') echo 'selected = "selected"'; ?>>Draft</option>
  137. <option value="archive" <?php if ($f_status == 'archive') echo 'selected = "selected"'; ?>>Archive</option>
  138. </select>
  139. </li>
  140. </ul>
  141. <hr />
  142. <ul class="form">
  143. <li><label>Title Bar Text</label><input type="text" name="form_title_text" value="<?php echo $f_title_text; ?>" /></li>
  144. <li><label>Title Background</label><input type="radio" name="form_title_bg" value="default" <?php if (empty($f_title_bg) || $f_title_bg == 'default') echo 'checked="checked"'; ?> /> Default</li>
  145. </ul>
  146. <ul class="icon-list"><?php
  147. $images = array();
  148. $icons = glob($root.'/resources/images/head*.{jpg,gif,png}', GLOB_BRACE);
  149. foreach ($icons as $key) {
  150. $tag = strstr($key, 'head', false);
  151. array_push($images, $tag);
  152. }
  153. $mob = glob($root.'/resources/images/mob-header*.{jpg,gif,png}', GLOB_BRACE);
  154. foreach ($mob as $key) {
  155. $tag = strstr($key, 'mob-header', false);
  156. array_push($images, $tag);
  157. }
  158. $bg = glob($root.'/resources/images/bg*.{jpg,gif,png}', GLOB_BRACE);
  159. foreach ($bg as $key) {
  160. $tag = strstr($key, 'bg', false);
  161. array_push($images, $tag);
  162. }
  163. foreach ($images as $image) {
  164. echo '<li><input type="radio" name="form_title_bg" value="'.$image.'"';
  165. if ($f_title_bg == $image) echo ' checked="checked"';
  166. echo '> <img src="/resources/images/'.$image.'" title="'.$image.'" /></li>';
  167. }
  168. ?>
  169. </ul>
  170. <ul class="form" style="clear: left;">
  171. <li><h6 class="helper">Images from /resources/images/ folder beginning with &ldquo;head&rdquo; or &ldquo;bg&rdquo;<br />It will not look stretched, will repeat, and be centered in the title area.</h6></li>
  172. <li><label>Title Text Color</label><input type="text" name="form_title_color" value="<?php echo $f_title_color; ?>" /></li>
  173. <li><h6 class="helper">Acceptable: color (red, blue, etc.) or hex (#C300000)</h6></li>
  174. <li><label>Subtitle</label><input type="text" name="form_subtitle" value="<?php echo $f_subtitle; ?>" /></li>
  175. <li><label>Directions<br />(just text)</label>
  176. <textarea name="form_directions" cols="75" rows="3"><?php echo $f_directions; ?></textarea>
  177. </li>
  178. <li><label>Fine Print<br />(just text)</label>
  179. <textarea name="form_fine_print" cols="75" rows="5"><?php echo $f_fine_print; ?></textarea>
  180. <br /><?php include($root.'/manage/common/html-basics.php'); ?>
  181. </li>
  182. <li><h6 class="helper">The end of the fine print will always read, &ldquo;<span class="error">*</span>All starred fields required.&rdquo;</h6></li>
  183. <li><label>Submit Button Type</label>
  184. <select name="form_submit_typ">
  185. <option value="link" <?php if (empty($f_submit_typ) || $f_submit_typ == 'link') echo 'selected = "selected"'; ?>>Stylized Button</option>
  186. <option value="image" <?php if ($f_submit_typ == 'image') echo 'selected = "selected"'; ?>>Image</option>
  187. <option value="button" <?php if ($f_submit_typ == 'button') echo 'selected = "selected"'; ?>>Regular, inconspicuous button</option>
  188. </select>
  189. </li>
  190. <li><label>Button Image</label><input type="radio" name="form_submit_img" value="none" <?php if (empty($n_submit_img) || $n_submit_img == 'none') echo 'checked="checked"'; ?> /> None</li>
  191. </ul>
  192. <ul class="icon-list"><?php
  193. $images = array();
  194. $icons = glob($root.'/resources/images/btn*.{jpg,gif,png}', GLOB_BRACE);
  195. foreach ($icons as $key) {
  196. $tag = strstr($key, 'btn', false);
  197. array_push($images, $tag);
  198. }
  199. foreach ($images as $image) {
  200. echo '<li><input type="radio" name="form_submit_img" value="'.$image.'"';
  201. if ($f_submit_img == $image) echo ' checked="checked"';
  202. echo '> <img src="/resources/images/'.$image.'" title="'.$image.'" /></li>';
  203. }
  204. ?>
  205. </ul>
  206. <ul class="form" style="clear: left;">
  207. <li><label>Submit Button Text</label><input type="text" name="form_submit_dsc" value="<?php echo $f_submit_dsc; ?>" /></li>
  208. <li><h6 class="helper">You need Submit Text even if you use an image.</h6></li>
  209. <?php if ($f_id!='new') { ?>
  210. <li><label>Last updated</label><?php echo $datim->date_Mdyt($f_stamp).' <a href="#see-update-log" class="dialog-view-log" rel="'.$f_id.'" name="site_forms">Log</a>'; ?></li>
  211. <?php } ?>
  212. <li><a name="previews"></a><a id="button-save-main-form" class="notice auto-save" href="#save" name="web-form" title="form">Save Form Details</a></li>
  213. </ul>
  214. <input type="hidden" id="req1" value="code" alt="a code" />
  215. <input type="hidden" id="req2" value="form_notify_to" alt="a notification address" />
  216. </form>
  217. <?php
  218. if ($f_id!='new') {
  219. echo '<br class="clearLeft" /><br /><hr />'.
  220. '<h3>Preview <a href="/manage/edit-web-form/'.$f_id.'#previews" class="notice">reload</a> Save first!</h3>'.
  221. '<p>Preview colors, fonts and spacing are not exact. Do a page test.</p>'.
  222. '<div class="floatLeft" style="padding-right:10px;">';
  223. $format->pretend_Dialog($f_submit_dsc, 375, 2, 'beg');
  224. echo $mail->build_Form($f_cat, $f_code, 'dialog-test', 'no-class');
  225. $format->pretend_Dialog($f_submit_dsc, 375, 2, 'end');
  226. echo '</div><div class="floatLeft">';
  227. $mail->build_Form($f_cat, $f_code, 'page-test', 'no-class');
  228. echo '</div><br class="clearLeft" /><br /><hr />';
  229. } ?>
  230. <style>
  231. .ui-widget button,
  232. .ui-widget .ui-button,
  233. .ui-button,
  234. button.ui-state-default,
  235. a.noticeMe,
  236. input.noticeMe,
  237. .notice-button,
  238. .notice-button:link,
  239. .notice-button:visited,
  240. .notice-button:hover,
  241. .notice-button:active {
  242. background: url(/resources/images/carrat_40.png) center -6px no-repeat;
  243. cursor: pointer;
  244. padding: 4px 8px;
  245. border: 2px solid #0066CC;
  246. -moz-border-radius: 4px;
  247. -webkit-border-radius: 4px;
  248. -khtml-border-radius: 4px;
  249. border-radius: 4px;
  250. font-size: 12px !important;
  251. line-height: 15px;
  252. font-weight: normal;
  253. color: #FFCC33;
  254. text-decoration: none;
  255. }
  256. .notice-button.go,
  257. .notice-button.go:link,
  258. .notice-button.go:visited,
  259. .notice-button.go:hover,
  260. .notice-button.go:active {
  261. padding: 5px 35px 5px 8px;
  262. border: none;
  263. display: inline-block;
  264. margin: 5px 0;
  265. text-align: left;
  266. }
  267. input.notice-button.go,
  268. input.notice-button.go:hover {
  269. padding: 0px 35px 0 8px;
  270. height: 25px;
  271. }
  272. #sftk .notice-button { background-position: center -6px; color: #FFCC33; border-color: #0066CC; }
  273. #sftk .notice-button:hover { background-position: center -46px; color: #FFFFFF; }
  274. #sftk .notice-button.go { background-position: right -0px; }
  275. #sftk .notice-button.go:hover { background-position: right -40px; }
  276. #lmnt .notice-button { background-position: center -86px; color: #FFCC33; border-color: #063D9A; }
  277. #lmnt .notice-button:hover { background-position: center -126px; color: #FFFFFF; }
  278. #lmnt .notice-button.go { background-position: right -80px; }
  279. #lmnt .notice-button.go:hover { background-position: right -120px; }
  280. #ntrk .notice-button { background-position: center -166px; color: #FFCC33; border-color: #990000; }
  281. #ntrk .notice-button:hover { background-position: center -206px; color: #FFFFFF; border-color: #FF6600; }
  282. #ntrk .notice-button.go { background-position: right -160px; }
  283. #ntrk .notice-button.go:hover { background-position: right -200px; }
  284. /* vv JQUERY UI OVERRRIDE vv */
  285. .ui-state-highlight,
  286. .ui-widget-header .ui-state-highlight,
  287. .ui-widget-content .ui-state-highlight { background: url(/resources/images/content-highlight_act.jpg) center center repeat-x; }
  288. .ui-widget-header .ui-icon.ui-icon-circle-triangle-e { background: url(/resources/images/16-next.png) no-repeat scroll -2px -22px transparent; }
  289. .ui-widget-header .ui-icon.ui-icon-circle-triangle-w { background: url(/resources/images/16-prev.png) no-repeat scroll -2px -22px transparent; }
  290. .ui-widget-header .ui-icon.ui-icon-closethick { background: url(/resources/images/16-close.png) no-repeat scroll -2px -22px transparent; }
  291. .ui-widget-header .ui-icon.ui-icon-closethick:hover { background-position: -2px -2px; }
  292. .ui-widget-content .ui-icon.ui-icon-alert { background: url(/resources/images/16-alert.png) no-repeat scroll 0px -60px transparent; }
  293. .ui-datepicker table { font-size: 1em; }
  294. .ui-dialog-titlebar,
  295. .ui-datepicker-header {
  296. background: none;
  297. border: none;
  298. height: 10px;
  299. margin: 0;
  300. position: relative;
  301. }
  302. .ui-dialog .ui-dialog-titlebar { padding: .2em 0 0 0; }
  303. .ui-dialog-title,
  304. .ui-datepicker-title {
  305. font-family: Verdana, sans-serif;
  306. font-weight: bold;
  307. font-size: 1.5em;
  308. line-height: 16px;
  309. }
  310. .ui-dialog-title { display: none; }
  311. .ui-button-text-only,
  312. .ui-button-text {
  313. padding: 0px;
  314. }
  315. .ui-widget #button-send-contact { display: none; }
  316. .ui-widget p { margin: 0; }
  317. .ui-dialog .ui-dialog-content { padding: 0 10px; }
  318. /* ^^ JQUERY UI OVERRRIDE ^^ */
  319. ul.icon-list {
  320. margin: 0;
  321. padding: 0;
  322. margin-left: 125px;
  323. width: 40%;
  324. }
  325. ul.icon-list li {
  326. background-color: #CCC;
  327. float: left;
  328. width: 260px;
  329. margin: 3px;
  330. padding: 2px;
  331. list-style: none;
  332. }
  333. ul.icon-list li img {
  334. width: 220px;
  335. height: 40px;
  336. }
  337. </style>
  338. <?php if ($f_id!='new'){ ?>
  339. <div id="holder-notes-rows"></div>
  340. <div id="holder-web-form-questions-rows"></div>
  341. <div id="dialog-edit-web-form-question"></div>
  342. <div id="dialog-edit-web-form-option"></div>
  343. <?php } ?>
  344. <script>
  345. $(function() {
  346. $.resetDefaults('notes-rows', 'form');
  347. $.resetDefaults('web-form-questions-rows', 'form');
  348. });
  349. </script>