function activity_form($activity_id = 0) { global $mysqli; global $backend; if ($activity_id) { $activity = new Activity($activity_id); $form_type = 'update'; } else { $activity = new Activity(); $form_type = 'insert'; } $html = ''; $fields = array('title' => array('var' => 'title', 'label' => 'Activity Title', 'desc' => 'Required. This is the public title of the activity. You may change this later.', 'type' => 'text', 'std' => $activity->title, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'folder' => array('var' => 'folder', 'label' => 'Activity folder', 'desc' => 'Required. Name of the folder to create on the ASHP server. Just enter the name of the folder <strong>without any slashes</strong>.', 'type' => 'text', 'std' => $activity->folder, 'validate' => 'required|alpha_dash', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'url' => array('var' => 'url', 'label' => 'Live Activity URL', 'desc' => 'The full URL of the activity, including <strong>http://</strong><br />You can leave blank to default to http://ashpadvantagemedia.com/ActivityFolder.<br /><span class="text-danger">Remember to use <strong>http://www.ashpadvantagemedia.com</strong> instead of <strong>http://www.ashpadvantage.com</strong>.</span>', 'type' => 'text', 'std' => $activity->url, 'validate' => 'valid_url', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'sponsor' => array('var' => 'sponsor', 'label' => 'Activity Sponsor', 'desc' => 'The sponsor of the activity.', 'type' => 'text', 'std' => $activity->sponsor, 'validate' => '', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'type_id' => array('var' => 'type_id', 'label' => 'Activity Type', 'desc' => 'Select the type of activity.', 'type' => 'select', 'options' => $backend->activity_types, 'std' => $activity->type_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i'), 'live_website' => array('var' => 'live_website', 'label' => 'Live Website Template', 'desc' => 'Choose which template to display on the live site..', 'type' => 'select', 'options' => $backend->website_types, 'std' => $activity->live_website, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'has_live' => array('var' => 'has_live', 'label' => 'Has Live Component', 'desc' => 'Select the live component this activity has.', 'type' => 'radio', 'options' => array('none', 'webcast', 'webinar'), 'std' => $activity->has_live, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'director_id' => array('var' => 'director_id', 'label' => 'Scientific Project Director', 'desc' => '', 'type' => 'select', 'options' => $backend->directors, 'std' => $activity->director_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i'), 'manager_id' => array('var' => 'manager_id', 'label' => 'Project Manager', 'desc' => '', 'type' => 'select', 'options' => $backend->managers, 'std' => $activity->manager_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i'), 'vendor_id' => array('var' => 'vendor_id', 'label' => 'Web Vendor', 'desc' => '', 'type' => 'select', 'options' => $backend->vendors, 'std' => $activity->vendor_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i')); if (isset($_POST['submit'])) { $gump = new GUMP(); foreach ($_POST['form'] as $k => $v) { //update the std value for form output below $fields[$k]['std'] = $v; if (!empty($fields[$k]['validate'])) { $validate[$k] = $fields[$k]['validate']; } if (!empty($fields[$k]['filter'])) { $filter[$k] = $fields[$k]['filter']; } } $error_text = ''; $gump->validation_rules($validate); $gump->filter_rules($filter); $validated_data = $gump->run($_POST['form']); if ($form_type == 'insert' && activity_folder_exists($validated_data['folder'])) { $validated_data = false; $error_text .= 'Folder already exists. Please choose another folder name.<br />'; } if ($validated_data === false) { $errors = $gump->get_readable_errors(false); foreach ($errors as $error) { $error_text .= $error . '<br />'; } echo edgimo_error($error_text); } else { if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } if ($validated_data['url'] == '') { $validated_data['url'] = 'http://ashpadvantagemedia.com/' . $validated_data['folder']; } if ($form_type == 'update') { $query = $mysqli->prepare("UPDATE ashp_activities SET title=?, url=?, folder=?, sponsor=?, type_id=?, director_id=?, manager_id=?, vendor_id=?, live_website=?, has_live=? WHERE activity_id=?"); $query->bind_param('ssssiiiiiss', $validated_data['title'], $validated_data['url'], $validated_data['folder'], $validated_data['sponsor'], $validated_data['type_id'], $validated_data['director_id'], $validated_data['manager_id'], $validated_data['vendor_id'], $validated_data['live_website'], $validated_data['has_live'], $activity_id); echo edgimo_success('Activity details have been updated.'); $query->execute(); $query->close(); echo '<script>edgimo_redirect("edit.php?table=ashp_activities&id=' . $activity_id . '");</script>'; } if ($form_type == 'insert') { $query = $mysqli->prepare("INSERT INTO ashp_activities (title, url, folder, sponsor, type_id, director_id, manager_id, vendor_id, live_website, has_live) VALUES (?,?,?,?,?,?,?,?,?,?)"); $query->bind_param('ssssiiiiss', $validated_data['title'], $validated_data['url'], $validated_data['folder'], $validated_data['sponsor'], $validated_data['type_id'], $validated_data['director_id'], $validated_data['manager_id'], $validated_data['vendor_id'], $validated_data['live_website'], $validated_data['has_live']); $query->execute(); $query->close(); $activity_id = $mysqli->query("SELECT activity_id FROM ashp_activities WHERE title = '{$validated_data['title']}'"); $vars = $activity_id->fetch_array(MYSQLI_ASSOC); $activity_id = $vars['activity_id']; $insert_fields = array_merge($backend->get_fields(0, $validated_data['has_live']), $backend->get_fields($validated_data['type_id'], $validated_data['has_live'])); foreach ($insert_fields as $field) { if (strstr($field['copy'], '{{LIVE_OPTIONS}}')) { $field['copy'] = live_options_replace($field['copy'], $validated_data['has_live']); } $query = $mysqli->prepare("INSERT INTO ashp_activity_content (activity_id, field_id, heading, copy, field_type, hook_name) VALUES (?,?,?,?,?,?)"); $query->bind_param('iissss', $activity_id, $field['field_id'], $field['heading'], $field['copy'], $field['field_type'], $field['hook_name']); $query->execute(); $query->close(); } create_site($validated_data['folder'], $activity_id); echo edgimo_success('New activity created.'); echo '<script>edgimo_redirect("edit.php?table=ashp_activities&id=' . $activity_id . '");</script>'; } } } $html .= '<form class="form-horizontal" role="form" method="post">'; foreach ($fields as $field) { isset($errors) && array_key_exists($field['var'], $errors) ? $error = 'has-error' : ($error = ''); $html .= '<div class="form-group ' . $error . '">'; switch ($field['type']) { case 'text': if (!isset($type)) { $type = 'text'; } $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="' . $type . '" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> </div>'; break; case 'select': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <select class="form-control" name="form[' . $field['var'] . ']">'; foreach ($field['options'] as $option) { $field['std'] == $option[0] ? $selected = 'selected' : ($selected = ''); $html .= '<option ' . $selected . ' value="' . $option[0] . '">' . $option[1] . '</option>'; } $html .= '</select> </div>'; break; case 'radio': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> '; foreach ($field['options'] as $option) { $field['std'] == $option ? $checked = 'checked' : ($checked = ''); $html .= ' <div class="radio-inline"> <label> <input type="radio" name="form[' . $field['var'] . ']" value="' . $option . '" ' . $checked . '> ' . ucfirst($option) . ' </label> </div>'; } $html .= ' </div>'; break; } $html .= ' <div class="col-lg-4"> <p class="description">' . $field['desc'] . '</p> </div> </div>'; } $html .= ' <hr> <div class="form-group"> <div class="col-lg-6 col-lg-offset-2"> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </div> </div> </form> '; return $html; }
$headings = $mysqli->query("SELECT field_id, heading FROM ashp_fields WHERE activity_type = 0 OR activity_type = {$activity->type_id}"); while ($vars = $headings->fetch_array(MYSQLI_ASSOC)) { $update = $mysqli->query("UPDATE ashp_activity_content SET heading='{$vars['heading']}' WHERE activity_id = {$activity_id} AND field_id = {$vars['field_id']}"); } } if (isset($_POST['action']) && $_POST['action'] == 'regenerate_all') { $activity_id = $_GET['activity']; $activity = new Activity($activity_id); $insert_fields = array_merge($backend->get_fields(0, $activity->has_live), $backend->get_fields($activity->type_id, $activity->has_live)); $query = $mysqli->prepare("DELETE FROM ashp_activity_content WHERE activity_id = ?"); $query->bind_param('i', $activity_id); $query->execute(); $query->close(); foreach ($insert_fields as $field) { if (strstr($field['copy'], '{{LIVE_OPTIONS}}')) { $field['copy'] = live_options_replace($field['copy'], $activity->has_live); } $query = $mysqli->prepare("INSERT INTO ashp_activity_content (activity_id, field_id, heading, copy, field_type, hook_name) VALUES (?,?,?,?,?,?)"); $query->bind_param('iissss', $activity_id, $field['field_id'], $field['heading'], $field['copy'], $field['field_type'], $field['hook_name']); $query->execute(); $query->close(); } } unset($_GET); } ?> <div class="main"> <div class="row"> <?php
function using_stock_copy($field_id, $activity_id, $type_id, $has_live) { global $mysqli; $query = "SELECT copy, has_stock_copy FROM ashp_fields WHERE field_id = {$field_id}"; $result = $mysqli->query($query); $stock = $result->fetch_array(MYSQLI_ASSOC); $stock_copy = live_options_replace($stock['copy'], $has_live); $query = "SELECT copy FROM ashp_activity_content WHERE field_id = {$field_id} AND activity_id = {$activity_id}"; $result = $mysqli->query($query); $activity = $result->fetch_array(MYSQLI_ASSOC); $activity_copy = live_options_replace($activity['copy'], $has_live); if ($stock_copy == $activity_copy && $stock['has_stock_copy'] == 'yes') { return true; } return false; }
function activity_content_form($id) { global $user; global $backend; global $mysqli; if (isset($_GET['blast'])) { if (!$user->is_allowed('send_email_blast')) { echo edgimo_error('Your user role is not allowed to send an email blast.'); } else { if ($_GET['blast'] == 'true') { $time = time(); $query = "SELECT reminder_sent FROM ashp_activities WHERE activity_id = {$id} AND reminder_sent = 0"; $result = $mysqli->query($query); if ($mysqli->affected_rows > 0) { send_email_blast($id); $query = "UPDATE ashp_activities SET reminder_sent={$time} WHERE activity_id = {$id}"; $result = $mysqli->query($query); } } if ($_GET['blast'] == 'reset') { echo edgimo_success('Reminder email reset.'); $query = "UPDATE ashp_activities SET reminder_sent=0 WHERE activity_id = {$id}"; $result = $mysqli->query($query); } } unset($_GET['blast']); } if (isset($_POST['template_change'])) { $live_website = $_POST['template_change']; $query = $mysqli->prepare("UPDATE ashp_activities SET live_website=? WHERE activity_id=?"); $query->bind_param('si', $live_website, $id); echo edgimo_success('Template has been changed.'); $query->execute(); $query->close(); } if (isset($_POST['notes_submit'])) { $notes = htmlspecialchars($_POST['notes']); $query = $mysqli->prepare("UPDATE ashp_activities SET notes=? WHERE activity_id=?"); $query->bind_param('si', $notes, $id); echo edgimo_success('Activity notes have been updated.'); $query->execute(); $query->close(); } if (isset($_POST['activity_submit'])) { if (!empty($_FILES)) { $site_folder = get_site_folder($id); foreach ($_FILES['form']['name'] as $file_id => $file_name) { $uploaded_files[$file_id] = $file_name['copy']; } foreach ($_FILES['form']['tmp_name'] as $file_id => $tmp_name) { if ($_FILES['form']['tmp_name'][$file_id]['copy'] != '') { if (move_uploaded_file($_FILES['form']['tmp_name'][$file_id]['copy'], '../' . $site_folder . '/files/' . $uploaded_files[$file_id])) { echo edgimo_success("File uploaded as " . $site_folder . '/files/' . $uploaded_files[$file_id] . "."); $_POST['form'][$file_id]['copy'] = 'files/' . $uploaded_files[$file_id]; } else { echo edgimo_error("Sorry, there was a problem uploading your file."); } } else { $_POST['form'][$file_id]['copy'] = get_activity_copy_by_id($id, $file_id); } } } foreach ($_POST['form'] as $k => $v) { $temp = nl2br($_POST['form'][$k]['copy']); $_POST['form'][$k]['copy'] = $temp; $query = $mysqli->prepare("UPDATE ashp_activity_content SET heading=?, copy=? WHERE field_id=? AND activity_id=?"); $query->bind_param('ssii', $_POST['form'][$k]['heading'], $_POST['form'][$k]['copy'], $k, $id); $query->execute(); $query->close(); } echo edgimo_success('Activity details have been updated.'); } if ($user->is_allowed('edit_ashp_activities')) { $disabled = ''; $submit = ' <div class="form-group"> <button type="submit" class="btn btn-primary" name="activity_submit">Update Activity Copy</button> </div>'; } else { $disabled = 'disabled'; echo edgimo_error('You may view the activity settings, but your user role (' . $user->role . ') is not allowed to make edits.'); $submit = ''; } $activity = new Activity($id); echo ' <h2 class="activity-title">' . $activity->title . '</h2> <form class="form notes_change" method="post"> <label for="notes">Notes For Web Vendor</label> <div class="form-group"> <textarea class="form-control" name="notes">' . $activity->notes . '</textarea> </div> <div class="form-group"><input type="submit" name="notes_submit" value="Update Notes" class="btn btn-xs btn-info"></div> </form> <h3>General Info</h3> <p class="description">Below is the general info about this activity. Click Edit General Info to change information.</p> <p><a href="edit.php?table=activity_settings&id=' . $id . '" class="btn btn-sm btn-info">Edit General Info</a> <a href="' . $activity->url . '" target="_blank" class="btn btn-sm btn-default">View Live Site</a></p> <p class="hidden web-vendor"><a target="_blank" href="http://ashpadvantagemedia.com/' . $activity->folder . '/cheatsheet.php" class="btn btn-sm btn-default">View Cheatsheet</a></p> <table class="table"> <tr> <td>Live Template</td> <td> <form class="form template_change" method="post"> <div class="form-group"> <select class="form-control input-sm" id="template_change" name="template_change">'; foreach ($backend->website_types as $option) { $activity->live_website == $option[0] ? $selected = 'selected' : ($selected = ''); echo '<option ' . $selected . ' value="' . $option[0] . '">' . $option[1] . '</option>'; } echo '</select> </div> </form> </td> </tr> <tr> <td>Sponsor</td> <td>' . $activity->sponsor . '</td> </tr> <tr> <td>Scientific Project Director</td> <td>' . get_user_name($activity->director_id) . '</td> </tr> <tr> <td>Project Manager</td> <td>' . get_user_name($activity->manager_id) . '</td> </tr> <tr> <td>Web Vendor</td> <td>' . get_user_name($activity->vendor_id) . '</td> </tr> </table> <h3>Preview Templates</h3> <p class="description">Click on a template button to preview the site. Dark blue indicates current template.</p>'; foreach ($backend->website_types as $option) { $activity->live_website == $option[0] ? $selected = 'btn-primary' : ($selected = 'btn-info'); echo '<a target="_blank" class="btn ' . $selected . ' btn-sm" href="' . $activity->url . '?preview=' . $option[0] . '">' . $option[1] . '</a> '; } echo ' <hr> <h3 class="toggle">Email List <small>Click to view/hide</small></h3>'; $table = 'ashp_email_list'; $fields = array('last_name', 'first_name', 'email', 'city', 'state', 'submitted'); $sort = 'last_name'; $order = 'ASC'; $edit = false; $where = "WHERE activity_id = {$id}"; $email_list = dashboard_table($table, $fields, $sort, $order, $edit, $where); if ($email_list) { echo '<div class="toggle-target">' . $email_list . '</div>'; echo '<a class="btn btn-success btn-xs" href="edit.php?table=ashp_activities&id=' . $id . '&download=true">Download as CSV</a>'; } else { echo '<p>No email signups yet.</p>'; } echo ' <hr> <h3 class="toggle">Reminder List <small>Click to view/hide</small></h3>'; $table = 'ashp_reminder_list'; $fields = array('name', 'email', 'message', 'submitted'); $sort = 'submitted'; $order = 'ASC'; $edit = false; $where = "WHERE activity_id = {$id}"; $reminder_list = dashboard_table($table, $fields, $sort, $order, $edit, $where); if ($reminder_list) { echo '<div class="toggle-target">' . $reminder_list . '</div>'; if ($activity->reminder_sent == 0) { echo '<p class="text-warning">Reminder has not been sent yet for this activity</p>'; if ($user->is_allowed('send_email_blast')) { echo '<p><a onclick="return confirm(\'This will send a mass email to all email addresses listed in the table. Continue?\');" href="edit.php?table=ashp_activities&id=' . $id . '&blast=true" class="btn btn-warning btn-xs">Send Email Blast</a></p>'; } } else { echo '<p class="text-success">Reminder sent on ' . date('F j, Y', $activity->reminder_sent) . '.</p>'; if ($user->is_allowed('send_email_blast')) { echo '<p><a href="edit.php?table=ashp_activities&id=' . $id . '&blast=reset" class="btn btn-success btn-xs">Reset Email Blast</a></p>'; } } } else { echo '<p>No reminder signups yet.</p>'; } ?> <hr> <h3>Activity Copy</h3> <?php $fields = $activity->get_activity_content(); $fields = $activity->sort_fields($fields); $descriptions = array('general' => 'Information in the general tab is used for the Midyear Symposia pre- and post-pages, MCM webinar registration page, and the On-demand MCM Archive overview page.', 'midyear' => 'Information in the midyear tab is used for the Midyear Symposia pre- and post-pages.', 'virtual' => 'Information in the fields below will be used (as appropriate) on the Midyear Virtual Activity (webinar, webcast) overview page.', 'enduring' => 'Information in the fields below will be used (as appropriate) on the post-Midyear landing page that links to the enduring activities.', 'webinar1' => 'Information in Webinar tab will be used to create webinars not related to the Midyear Activity.', 'webinar2' => 'Information in Webinar tab will be used to create webinars not related to the Midyear Activity.', 'webinar3' => 'Information in Webinar tab will be used to create webinars not related to the Midyear Activity.'); ?> <form enctype="multipart/form-data" class="form" role="form" method="post" id="activity-content-form"> <ul class="nav nav-tabs" role="tablist"> <li class="active"><a href="#general" role="tab" data-toggle="tab">General</a></li> <li><a href="#midyear" role="tab" data-toggle="tab">Midyear</a></li> <li><a href="#enduring" role="tab" data-toggle="tab">Enduring</a></li> <li><a href="#webinar1" role="tab" data-toggle="tab">Webinar 1</a></li> </ul> <div class="tab-content"> <?php foreach ($fields as $tab_group => $value) { $tab_group == 'general' ? $active = 'active' : ($active = ''); echo ' <div class="tab-pane ' . $active . '" id="' . $tab_group . '"> <p class="tab-description">' . $descriptions[$tab_group] . '</p>'; foreach ($fields[$tab_group] as $group_order => $value) { foreach ($fields[$tab_group][$group_order] as $group_name => $value) { echo ' <h3 class="field-group-heading">' . $group_name . '</h3> <div class="field-group">'; foreach ($fields[$tab_group][$group_order][$group_name] as $field_order => $value) { foreach ($fields[$tab_group][$group_order][$group_name][$field_order] as $field) { $has_stock = has_stock_copy($field['field_id']); $using_stock = using_stock_copy($field['field_id'], $id, $activity->type_id, $activity->has_live); $button = ''; $collapse = ''; if ($using_stock) { $button = ' <p class="text-info"><em>This field is using stock copy.</em></p> <p><a class="btn btn-default btn-info btn-xs" data-toggle="collapse" data-target=".collapse-' . $field['field_id'] . '">Customize Stock Copy</a></p>'; $collapse = 'collapse collapse-' . $field['field_id']; } if ($has_stock && !$using_stock) { $button = ' <p class="text-warning"><em>This field is using customized stock copy.</em></p> <p><a class="btn btn-default btn-warning btn-xs revert-stock" data-id="' . $field['field_id'] . '">Revert to Original Stock Copy</a></p>'; $collapse = ''; } echo ' <div class="field-wrap row"> <p class="meta description hidden web-vendor">Field ID: ' . $field['field_id'] . '</p>'; if ($field['heading'] != $group_name) { echo '<h4 class="field-group-subheading">' . $field['heading'] . '</h4>'; } if (in_array($field['field_id'], $backend->editable_headings)) { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][heading]">Heading</label> <input ' . $disabled . ' class="form-control input input-bold" type="text" name="form[' . $field['field_id'] . '][heading]" value="' . $field['heading'] . '"> </div> </div> '; } else { echo '<input type="hidden" ' . $disabled . ' name="form[' . $field['field_id'] . '][heading]" value="' . $field['heading'] . '">'; } if (!$using_stock && $has_stock) { echo ' <div class="hidden-stock" data-id="' . $field['field_id'] . '"> ' . trim(live_options_replace(get_stock_copy($field['field_id']), $activity->has_live)) . ' </div>'; } switch ($field['field_type']) { case 'wysiwyg': if ($using_stock) { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <div class="well form-control-static">' . $field['copy'] . '</div> </div> </div> '; } echo ' <div class="col-lg-12"> ' . $button . ' <div class="form-group ' . $collapse . '"> <textarea id="wysiwyg-' . $field['field_id'] . '" ' . $disabled . ' class="wysiwyg" name="form[' . $field['field_id'] . '][copy]">' . $field['copy'] . '</textarea> </div> </div> '; break; case 'textarea': if ($using_stock) { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <div class="well form-control-static">' . $field['copy'] . '</div> </div> </div> '; } echo ' <div class="col-lg-12"> ' . $button . ' <div class="form-group ' . $collapse . '"> <textarea class="basic" name="form[' . $field['field_id'] . '][copy]">' . str_replace('<br />', "", $field['copy']) . '</textarea> </div> </div> '; break; case 'text': if ($using_stock) { echo ' <div class="col-lg-8"> <div class="form-group"> <div class="well form-control-static">' . $field['copy'] . '</div> </div> </div> '; } echo ' <div class="col-lg-8"> ' . $button . ' <div class="form-group ' . $collapse . '"> <input id="input-' . $field['field_id'] . '" ' . $disabled . ' class="form-control input-sm" type="text" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> '; break; case 'date': case 'time': $field['field_type'] == 'date' ? $class = 'date' : ($class = 'time'); $field['field_type'] == 'date' ? $size = 'col-lg-6' : ($size = 'col-lg-3'); echo ' <div class="' . $size . '"> <div class="form-group"> <input ' . $disabled . ' class="form-control input-sm ' . $class . '" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> '; break; case 'select': echo ' <div class="col-lg-4"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][copy]">Select</label> <select class="form-control" name="form[' . $field['field_id'] . '][copy]">'; echo '<option value="0" selected>-- Choose Faculty Member --</option>'; foreach ($backend->faculty_list as $faculty) { $field['copy'] == $faculty['faculty_id'] ? $selected = 'selected' : ($selected = ''); echo '<option value="' . $faculty['faculty_id'] . '" ' . $selected . '>' . $faculty['faculty_name'] . '</option>'; } echo ' </select> </div> </div> '; break; case 'file': echo ' <div class="col-lg-4"> <div class="form-group"> <input class="form-control" type="file" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> <p class="form-control-static"> <strong>Currently</strong>: <a href="../' . $activity->folder . '/' . $field['copy'] . '" target="_blank">' . $field['copy'] . '</a> </p> </div> </div>'; break; case 'objectives_intro': $obj_copy = get_stock_copy($field['field_id']); $field['copy'] == $obj_copy ? $knowledge = 'checked' : ($knowledge = ''); $field['copy'] == str_replace('knowledge', 'application', $obj_copy) ? $application = 'checked' : ($application = ''); $application == '' && $knowledge == '' ? $custom = 'checked' : ($custom = ''); echo ' <div class="hidden"> <span id="knowledge-copy">' . $obj_copy . '</span> <span id="application-copy">' . str_replace('knowledge', 'application', $obj_copy) . '</span> </div> <div class="col-lg-8"> <div class="form-group"> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro-' . $field['field_id'] . '" id="knowledge" value="knowledge" ' . $knowledge . '> Knowledge based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro-' . $field['field_id'] . '" id="application" value="application" ' . $application . '> Application based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro-' . $field['field_id'] . '" id="custom" value="custom" ' . $custom . '> Custom </label> </div> </div> </div> <div class="col-lg-8"> <div class="form-group" id="objectives_intro-' . $field['field_id'] . '"> <input id="input-' . $field['field_id'] . '" class="form-control input-sm" type="text" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> '; break; } echo ' </div>'; } } echo '</div>'; } } echo ' </div>'; } ?> </div> <?php /* $first = ''; $section_toggle = 'hook-midyear'; foreach( $backend->groups as $group_name => $group_field_id ){ $heading_displayed = false; foreach( $fields as $field ){ if ( !in_array($field['field_id'], $backend->groups[$group_name]) ){ continue; } $has_stock = has_stock_copy( $field['field_id'] ); $using_stock = using_stock_copy( $field['field_id'], $id, $activity->type_id, $activity->has_live ); $button = ''; $collapse = ''; if ( $using_stock ){ $button = ' <p class="text-info"><em>This field is using stock copy.</em></p> <p><a class="btn btn-default btn-info btn-xs" data-toggle="collapse" data-target=".collapse-'.$field['field_id'].'">Customize Stock Copy</a></p>'; $collapse = 'collapse collapse-'.$field['field_id']; } if ( $has_stock && !$using_stock){ $button = ' <p class="text-warning"><em>This field is using customized stock copy.</em></p> <p><a class="btn btn-default btn-warning btn-xs revert-stock" data-id="'.$field['field_id'].'">Revert to Original Stock Copy</a></p>'; $collapse = ''; } if ( $group_name == 'Enduring Summary Statement' ){ $section_toggle = 'hook-enduring'; } if ( !$heading_displayed ){ echo $first . '<h3 class="field-group-heading '.$section_toggle.'">'.$group_name.'</h3> <div class="field-group '.$section_toggle.'">'; $heading_displayed = true; $first = '</div>'; } echo ' <div class="field-wrap row"> <p class="meta description hidden web-vendor">Field ID: '.$field['field_id'].'</p>'; if ( $field['heading'] != $group_name ){ echo '<h4 class="field-group-subheading">'.$field['heading'].'</h4>'; } if ( in_array($field['field_id'], $backend->editable_headings) ){ echo' <div class="col-lg-12"> <div class="form-group"> <label for="form['.$field['field_id'].'][heading]">Heading</label> <input '.$disabled.' class="form-control input input-bold" type="text" name="form['.$field['field_id'].'][heading]" value="'.$field['heading'].'"> </div> </div> '; } else{ echo '<input type="hidden" '.$disabled.' name="form['.$field['field_id'].'][heading]" value="'.$field['heading'].'">'; } if ( !$using_stock && $has_stock ){ echo ' <div class="hidden-stock" data-id="'.$field['field_id'].'"> '.trim( live_options_replace( get_stock_copy($field['field_id']), $activity->has_live ) ).' </div>'; } switch ( $field['field_type'] ){ case 'wysiwyg' : if ( $using_stock ){ echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form['.$field['field_id'].'][copy]">Copy</label> <div class="well form-control-static">'.$field['copy'].'</div> </div> </div> '; } echo ' <div class="col-lg-12"> '.$button.' <div class="form-group '.$collapse.'"> <textarea id="wysiwyg-'.$field['field_id'].'" '.$disabled.' class="wysiwyg" name="form['.$field['field_id'].'][copy]">'.$field['copy'].'</textarea> </div> </div> '; break; case 'textarea' : if ( $using_stock ){ echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form['.$field['field_id'].'][copy]">Copy</label> <div class="well form-control-static">'.$field['copy'].'</div> </div> </div> '; } echo ' <div class="col-lg-12"> '.$button.' <div class="form-group '.$collapse.'"> <textarea class="basic" name="form['.$field['field_id'].'][copy]">'.str_replace('<br />',"",$field['copy']).'</textarea> </div> </div> '; break; case 'text' : if ( $using_stock ){ echo ' <div class="col-lg-8"> <div class="form-group"> <div class="well form-control-static">'.$field['copy'].'</div> </div> </div> '; } echo ' <div class="col-lg-8"> '.$button.' <div class="form-group '.$collapse.'"> <input id="input-'.$field['field_id'].'" '.$disabled.' class="form-control input-sm" type="text" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> </div> </div> '; break; case 'date' : case 'time' : $field['field_type'] == 'date' ? $class = 'date' : $class = 'time'; $field['field_type'] == 'date' ? $size = 'col-lg-6' : $size = 'col-lg-3'; echo ' <div class="'.$size.'"> <div class="form-group"> <input '.$disabled.' class="form-control input-sm '.$class.'" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> </div> </div> '; break; case 'select' : echo ' <div class="col-lg-4"> <div class="form-group"> <label for="form['.$field['field_id'].'][copy]">Select</label> <select class="form-control" name="form['.$field['field_id'].'][copy]">'; echo '<option value="0" selected>-- Choose Faculty Member --</option>'; foreach ($backend->faculty_list as $faculty) { $field['copy'] == $faculty['faculty_id'] ? $selected = 'selected' : $selected = ''; echo '<option value="'.$faculty['faculty_id'].'" '.$selected.'>'.$faculty['faculty_name'].'</option>'; } echo' </select> </div> </div> '; break; case 'file' : echo ' <div class="col-lg-4"> <div class="form-group"> <input class="form-control" type="file" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> <p class="form-control-static"> <strong>Currently</strong>: <a href="../' . $activity->folder . '/' . $field['copy'] .'" target="_blank">'.$field['copy'].'</a> </p> </div> </div>'; break; case 'objectives_intro' : $obj_copy = get_stock_copy( $field['field_id'] ); $field['copy'] == $obj_copy ? $knowledge = 'checked' : $knowledge = ''; $field['copy'] == str_replace('knowledge', 'application', $obj_copy ) ? $application = 'checked' : $application = ''; $application == '' && $knowledge == '' ? $custom = 'checked' : $custom = ''; echo ' <div class="hidden"> <span id="knowledge-copy">'.$obj_copy.'</span> <span id="application-copy">'.str_replace('knowledge', 'application', $obj_copy ).'</span> </div> <div class="col-lg-8"> <div class="form-group"> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro" id="knowledge" value="knowledge" '.$knowledge.'> Knowledge based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro" id="application" value="application" '.$application.'> Application based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro" id="custom" value="custom" '.$custom.'> Custom </label> </div> </div> </div> <div class="col-lg-8"> <div class="form-group" id="objectives_intro"> <input id="input-'.$field['field_id'].'" class="form-control input-sm" type="text" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> </div> </div> '; break; } echo ' </div>'; } } */ echo '<hr>'; echo $submit; echo '</form>'; }