public function process() { if ('save_faq_product' == $_REQUEST['_process']) { if (!module_faq::can_i('edit', 'FAQ')) { die('No perms to save faq.'); } if (isset($_POST['envato_item_ids'])) { $_POST['envato_item_ids'] = implode('|', $_POST['envato_item_ids']); } $faq_product_id = update_insert('faq_product_id', $_REQUEST['faq_product_id'], 'faq_product', $_POST); if (isset($_REQUEST['butt_del'])) { // deleting ticket type all together if (module_form::confirm_delete('customer_id', _l("Really delete FAQ Product?"), self::link_open_faq_product($_REQUEST['faq_product_id']))) { delete_from_db('faq_product', 'faq_product_id', $_REQUEST['faq_product_id']); set_message('FAQ Product deleted successfully.'); redirect_browser($this->link_open_faq_product(false)); } } set_message('FAQ Product saved successfully'); redirect_browser($this->link_open_faq_product($faq_product_id)); } else { if ('save_faq' == $_REQUEST['_process']) { if (!module_faq::can_i('edit', 'FAQ')) { die('No perms to save faq.'); } if (isset($_REQUEST['new_product_name']) && strlen(trim($_REQUEST['new_product_name']))) { $faq_product_id = update_insert('faq_product_id', false, 'faq_product', array('name' => trim($_REQUEST['new_product_name']))); if (!isset($_REQUEST['faq_product_ids'])) { $_REQUEST['faq_product_ids'] = array(); } $_REQUEST['faq_product_ids'][] = $faq_product_id; } $faq_id = update_insert('faq_id', $_REQUEST['faq_id'], 'faq', $_POST); delete_from_db('faq_product_rel', 'faq_id', $faq_id); if (isset($_REQUEST['faq_product_ids']) && is_array($_REQUEST['faq_product_ids'])) { foreach ($_REQUEST['faq_product_ids'] as $faq_product_id) { if ((int) $faq_product_id > 0) { $sql = "INSERT INTO `" . _DB_PREFIX . "faq_product_rel` SET faq_id = " . (int) $faq_id . ", faq_product_id = " . (int) $faq_product_id; query($sql); } } } if (isset($_REQUEST['butt_del'])) { // deleting ticket type all together if (module_form::confirm_delete('customer_id', _l("Really delete FAQ item?"), self::link_open($_REQUEST['faq_id']))) { delete_from_db('faq', 'faq_id', $_REQUEST['faq_id']); delete_from_db('faq_product_rel', 'faq_id', $_REQUEST['faq_id']); set_message('FAQ deleted successfully.'); redirect_browser($this->link_open(false)); } } set_message('FAQ saved successfully'); redirect_browser($this->link_open($faq_id)); } } }
public function process() { $errors = array(); if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['report_id']) { $data = self::get_report($_REQUEST['report_id']); if (module_form::confirm_delete('report_id', "Really delete " . _l('Report') . ": " . $data['name'], self::link_open($_REQUEST['report_id']))) { $this->delete_report($_REQUEST['report_id']); set_message(_l('Report') . " deleted successfully"); redirect_browser(self::link_open(false)); } } else { if ("save_report" == $_REQUEST['_process']) { $report_id = $this->save_report($_REQUEST['report_id'], $_POST); $_REQUEST['_redirect'] = $this->link_open($report_id); set_message(_l('Report') . " saved successfully"); } } if (!count($errors)) { redirect_browser($_REQUEST['_redirect']); exit; } print_error($errors, true); }
<input type="hidden" name="<?php echo $use_master_key; ?> " value="<?php echo $search[$use_master_key]; ?> "> <?php } ?> <?php $search_bar = array('elements' => array('name' => array('title' => _l('Contact Name, Email or Phone Number:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : '', 'size' => 30)))); echo module_form::search_bar($search_bar); /** START TABLE LAYOUT **/ $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['name'] = array('title' => 'Name', 'callback' => function ($user) { echo module_user::link_open_contact($user['user_id'], true, $user); if ($user['is_primary'] == $user['user_id']) { echo ' *'; } }, 'cell_class' => 'row_action'); $columns['phone'] = array('title' => 'Phone Number', 'callback' => function ($user) { module_user::print_contact_summary($user['user_id'], 'html', array('phone|mobile')); }); $columns['email'] = array('title' => 'Email Address', 'callback' => function ($user) { module_user::print_contact_summary($user['user_id'], 'html', array('email')); });
</a> </li> <?php } unset($menu_holder); unset($menu_type); unset($current_link); unset($menu_allow_nesting); ?> <?php if (isset($show_quick_search) && $show_quick_search) { ?> <?php if (module_security::getcred() && module_security::can_user(module_security::get_loggedin_id(), 'Show Quick Search') && $display_mode != 'mobile') { if (module_config::c('global_search_focus', 1) == 1) { module_form::set_default_field('ajax_search_text'); } ?> <li> <div id="quick_search_box"> <div id="quick_search_placeholder"><div><?php _e('Quick Search:'); ?> </div></div> <input type="text" name="quick_search" id="ajax_search_text" size="10" value=""> <div id="ajax_search_result"></div> </div> </li> <?php } handle_hook('top_menu_end');
?> </td> <td><?php $headers = unserialize($n['headers']); if (isset($headers['to']) && is_array($headers['to'])) { foreach ($headers['to'] as $to) { echo $to['email'] . ' '; } } ?> </td> <td><?php echo module_user::link_open($n['create_user_id'], true); ?> </td> </tr> <?php } ?> </tbody> </table> <div style="min-height: 10px;"> <?php echo $pagination['page_numbers'] > 1 ? $pagination['links'] : ''; ?> </div> </div> <?php $fieldset_data['elements_before'] = ob_get_clean(); echo module_form::generate_fieldset($fieldset_data);
function get_form_element($element, $viewing_revision = false, $data_record = array()) { $has_write_access = !$viewing_revision; // convert our data field to an element. $element['name'] = isset($element['name']) && !empty($element['name']) ? $element['name'] : 'data_field[' . $element['data_field_id'] . ']'; $element['id'] = 'data_field_' . $element['data_field_id'] . ''; $element['type'] = $element['field_type']; if (!isset($element['value'])) { $element['value'] = ''; } if (!$has_write_access) { //$element['disabled'] = 'disabled'; $element['class'] = 'data_field_view'; } $highlight = false; $this->ajax_edit = false; $input_name = $element['name']; if (!$input_name) { return false; } if (isset($element['id']) && $element['id']) { $input_id = $element['id']; } else { $element['id'] = $input_name; $input_id = $input_name; } //if(!$value && isset($_REQUEST[$input_name]))$value = $_REQUEST[$input_name]; if (!$element['value']) { $element['value'] = $element['default']; } if (!is_array($element['value'])) { //$value=htmlspecialchars($value); } if (!isset($element['class'])) { $element['class'] = ''; } $attr = $attr_other = ''; if ($has_write_access) { if ($element['type'] == 'radio' || $element['type'] == 'checkbox_list') { // hacky! if ($element['required']) { $attr_other .= ' class="form_field form_field_required"'; } else { $attr_other .= ' class="form_field"'; } } else { $element['class'] .= " form_field"; if ($element['required']) { $element['class'] .= " form_field_required"; } } switch ($element['type']) { case 'date': $element['class'] .= " date_field"; if (!isset($element['size']) || !$element['size']) { $element['size'] = 8; } if (strtolower($element['value']) == 'now') { $element['value'] = print_date(time()); } break; case 'datetime': $element['class'] .= " date_time_field"; if (!isset($element['size']) || !$element['size']) { $element['size'] = 12; } if (strtolower($element['value']) == 'now') { $element['value'] = print_date(time(), true); } break; } } switch ($element['type']) { case 'checkbox_list': case 'radio': $element['attributes'] = array(); foreach (explode("\n", trim($element['field_data'])) as $line) { $line = trim($line); if (preg_match('/^attributes=/', $line)) { $line = preg_replace('/^attributes=/', '', $line); $element['attributes'] = explode("|", $line); break; } } break; case 'select': if (!isset($element['attributes']) || !is_array($element['attributes']) || !count($element['attributes'])) { $element['attributes'] = array(); foreach (explode("\n", trim($element['field_data'])) as $line) { $line = trim($line); if (preg_match('/^attributes=/', $line)) { $line = preg_replace('/^attributes=/', '', $line); if (preg_match('#hook:([\\w_]+)$#', $line, $matches)) { // see if we get anything back from this hook. $attributes = array(); $attributes = hook_filter_var($matches[1], $attributes, $element); if (is_array($attributes)) { $element['attributes'] = $attributes; } else { $element['attributes'] = array('Unable to call hook: ' . $matches[1]); } } else { $element['attributes'] = explode("|", $line); } break; } } } break; } if (!isset($element['style'])) { $element['style'] = ''; } // we have to apply some custom width/height styles if they exist. $width = $height = false; foreach (explode("\n", trim($element['field_data'])) as $line) { $line = trim($line); if (preg_match('/^width=/', $line)) { $line = preg_replace('/^width=/', '', $line); $width = (int) $line; } if (preg_match('/^height=/', $line)) { $line = preg_replace('/^height=/', '', $line); $height = (int) $line; } } if (!$height && $height < _MIN_INPUT_HEIGHT) { $height = _MIN_INPUT_HEIGHT; } switch ($element['type']) { case 'text': case 'date': case 'datetime': if ($width) { $element['style'] .= 'width:' . $width . 'px; '; } break; case 'radio': if ($width) { $attr_other .= ' style="width:' . $width . 'px; "'; } break; case 'textarea': case 'textbox': if ($width) { $element['style'] .= 'width:' . $width . 'px; '; } if ($has_write_access && $height) { $element['style'] .= 'height:' . $height . 'px; '; } break; } if (isset($element['width'])) { unset($element['width']); } if (isset($element['height'])) { unset($element['height']); } if (isset($element['multiple']) && $element['multiple']) { $element['multiple'] = true; // pass 'multiple' through to the UCM form builder which should handle everything $value_unserialize = @unserialize($element['value']); if (is_array($value_unserialize)) { $element['values'] = $value_unserialize; // 'values' is used in the UCM field generation tool } $element['name'] = $element['name'] . '[]'; } else { $element['multiple'] = false; } if (!$has_write_access && $element['multiple'] && isset($element['values']) && is_array($element['values'])) { $element['value'] = $element['values']; } if (is_array($element['value']) && count($element['value'])) { $all_values = $element['value']; } else { $all_values = array($element['value']); } if ($element['type'] == 'checkbox_list') { $test = @unserialize($element['value']); if (is_array($test) && count($test)) { $all_values = array($test); } else { $all_values = array($element['value']); } } if ($element['type'] == "cancel" && !isset($element['onclick'])) { $element['onclick'] = "history.go(-1);"; } if ($highlight) { $element['class'] .= " form_field_highlight"; } /*if(!$has_write_access){ $element['class'] .= ' form_disabled'; }*/ $attribute_keys = array('class', 'disabled', 'onclick', 'onfocus', 'onmouseup', 'onmousedown', 'onchange', 'size', 'cols', 'rows', 'width', 'style'); foreach ($element as $key => $val) { if (!is_array($val) && !trim($val)) { continue; } if (in_array(strtolower($key), $attribute_keys)) { if (in_array(strtolower($key), array('size', 'cols', 'rows', 'width', 'height')) && (int) $val == 0) { continue; } $attr .= ' ' . $key . '="' . $val . '"'; } } // check for default values, these are cleared when submitting the form if ($element['default']) { $has_default = true; } $real_input_id = $input_id; $real_input_name = $input_name; ob_start(); foreach ($all_values as $value_key => $value) { if (!$has_write_access) { // disabled. if (isset($width) && $width && $element['type'] != 'encrypted') { echo '<span ' . $attr; echo ' style="width:' . $width . 'px;"'; echo '> '; } // display value differently depending on value type. switch ($element['type']) { case 'checkbox_list': $other = ''; if (is_array($value)) { if (isset($value['other_val'])) { $other = $value['other_val']; unset($value['other_val']); } echo implode(', ', array_keys($value)); } echo ' ' . $other; break; case 'select': if (isset($element['attributes'])) { $attributes = $element['attributes']; } else { $attributes = array(); } if (isset($attributes[0])) { $new_attributes = array(); foreach ($attributes as $aid => $a) { $new_attributes[$aid + 1] = $a; } $attributes = $new_attributes; } if (isset($attributes[$value])) { echo $attributes[$value]; } break; case 'textarea': case 'textbox': echo nl2br(htmlspecialchars($value)); break; case 'file': if ($value) { $file_data = @unserialize($value); $file_link = 'includes/plugin_data/upload/' . $file_data['file']; if (is_file($file_link)) { $download_link = self::link_public_file_download($data_record['data_record_id'], $data_record['data_type_id'], $element['data_field_group_id'], $element['data_field_id']); echo '<a href="' . $download_link . '" target="_blank">' . $file_data['name'] . '</a>'; } else { echo 'File Not Found'; } } break; case 'wysiwyg': echo module_security::purify_html($value); break; case 'encrypted': if (class_exists('module_encrypt', false)) { ob_start(); $element['type'] = 'text'; module_form::generate_form_element($element); $enc_html = ob_get_clean(); echo module_encrypt::parse_html_input('custom_data', $enc_html, false); } break; case 'created_date_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'); break; case 'created_date': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'); break; case 'created_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'); break; case 'updated_date_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A')); break; case 'updated_date': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A')); break; case 'updated_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A')); break; case 'created_by': echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'); break; case 'updated_by': echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A')); break; case 'url': echo '<a href="' . htmlspecialchars($value) . '" target="_blank">' . htmlspecialchars($value) . '</a>'; break; default: echo htmlspecialchars($value); break; } if (isset($width) && $width && $element['type'] != 'encrypted') { echo ' </span>'; } } else { // update for UCM: use the ucm form generator if (isset($element['default']) && $element['default'] && !$element['value']) { $element['value'] = $element['default']; } switch ($element['type']) { case 'wysiwyg': $element['options']['inline'] = false; module_form::generate_form_element($element); break; case "radio": $has_val = false; foreach ($element['attributes'] as $attribute) { $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute); ?> <span class="field_radio"> <input type="radio" name="<?php echo $input_name; ?> " id="<?php echo $this_input_id; ?> " value="<?php echo htmlspecialchars($attribute); ?> "<?php if ($attribute == $value || strtolower($attribute) == 'other' && !$has_val) { // assumes "OTHER" is always last... fix with a separate loop before hand checking all vals if (strtolower($attribute) != 'other') { $has_val = true; } echo " checked"; } echo ' ' . $attr; if (strtolower($attribute) == 'other') { echo ' onmouseup="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; echo ' onchange="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; } ?> > <label for="<?php echo $this_input_id; ?> "><?php echo $attribute; ?> </label> <?php if (strtolower($attribute) == 'other') { ?> <span class="data_field_input"> <input type="text" name="other_<?php echo $input_name; ?> " id="other_<?php echo $this_input_id; ?> " value="<?php if (!$has_val) { echo htmlspecialchars($value); } ?> " onchange="$('input[type=radio]',$(this).parent())[0].checked = true;" <?php echo $attr . $attr_other; ?> > </span> <?php } ?> </span> <?php } break; case "checkbox_list": $has_val = false; if (!is_array($value)) { $value = array(); } foreach ($element['attributes'] as $attribute) { $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute); ?> <span class="field_radio"> <input type="checkbox" name="<?php echo $input_name; ?> [<?php echo htmlspecialchars($attribute); ?> ]" id="<?php echo $this_input_id; ?> " value="1"<?php if (isset($value[$attribute])) { if (strtolower($attribute) != 'other') { $has_val = true; } echo " checked"; } echo ' ' . $attr; if (strtolower($attribute) == 'other') { echo ' onmouseup="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; echo ' onchange="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"'; } ?> > <label for="<?php echo $this_input_id; ?> "><?php echo $attribute; ?> </label> <?php if (strtolower($attribute) == 'other') { ?> <span class="data_field_input"> <input type="text" name="<?php echo $input_name; ?> [other_val]" id="other_<?php echo $this_input_id; ?> " value="<?php echo isset($value['other_val']) ? htmlspecialchars($value['other_val']) : ''; ?> " onchange="$('input[type=radio]',$(this).parent())[0].checked = true;" <?php echo $attr . $attr_other; ?> > </span> <?php } ?> </span> <?php } break; case "file": $this->has_files = true; ?> <input type="file" name="<?php echo $input_name; ?> " id="<?php echo $input_id; ?> " value="<?php echo $value; ?> "<?php echo $attr; ?> > <?php break; case 'select': $attributes = isset($element['attributes']) ? $element['attributes'] : array(); if (isset($attributes[0])) { $new_attributes = array(); foreach ($attributes as $aid => $a) { $new_attributes[$aid + 1] = $a; } $attributes = $new_attributes; } $element['options'] = $attributes; module_form::generate_form_element($element); break; case 'encrypted': if (class_exists('module_encrypt', false)) { ob_start(); $element['type'] = 'text'; module_form::generate_form_element($element); $enc_html = ob_get_clean(); echo module_encrypt::parse_html_input('custom_data', $enc_html); } break; case 'created_date_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'); break; case 'created_date': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'); break; case 'created_time': echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'); break; case 'updated_date_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A')); break; case 'updated_date': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A')); break; case 'updated_time': echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A')); break; case 'created_by': echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'); break; case 'updated_by': echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A')); break; case 'url': $element['type'] = 'text'; module_form::generate_form_element($element); break; default: module_form::generate_form_element($element); } if (isset($element['after_link']) && $element['after_link']) { if (preg_match('/^https?:\\/\\//', $value) || ($have_www = preg_match('/^www\\./', $value) || ($have_www = preg_match('/\\.com/', $value) && !preg_match('/\\w@\\w/', $value)))) { // we have a url if ($have_www) { $value = "http://" . $value; } ?> <a href="<?php echo $value; ?> " target="_blank">»</a> <?php } if (preg_match('/\\w@\\w/', $value)) { ?> <a href="mailto:<?php echo $value; ?> ">»</a> <?php } } } // editable echo ' '; } // foreach all values //${$element_id} = ob_get_clean(); // we just print the html for now return ob_get_clean(); }
public static function print_search_bar($owner_table, $options = array()) { // let the themes override this search bar function. if (self::can_i('view', 'Extra Fields')) { $result = hook_handle_callback('extra_fields_search_bar', $owner_table, $options); if (is_array($result)) { // has been handed by a theme. echo current($result); } else { $defaults = self::get_defaults($owner_table); $searchable_fields = array(); foreach ($defaults as $default) { if (isset($default['searchable']) && $default['searchable']) { $searchable_fields[$default['key']] = $default; } } foreach ($searchable_fields as $searchable_field) { ?> <td class="search_title"> <?php echo htmlspecialchars($searchable_field['key']); ?> : </td> <td class="search_input"> <?php module_form::generate_form_element(array('type' => 'text', 'name' => 'search[extra_fields][' . htmlspecialchars($searchable_field['key']) . ']')); ?> </td> <?php } } } }
public function process() { $errors = array(); if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['quote_id']) { $data = self::get_quote($_REQUEST['quote_id']); if (module_form::confirm_delete('quote_id', "Really delete quote: " . $data['name'], self::link_open($_REQUEST['quote_id']))) { $this->delete_quote($_REQUEST['quote_id']); set_message("quote deleted successfully"); redirect_browser($this->link_open(false)); } } else { if ("ajax_quote_list" == $_REQUEST['_process']) { $customer_id = isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : 0; $res = module_quote::get_quotes(array('customer_id' => $customer_id)); $options = array(); foreach ($res as $row) { $options[$row['quote_id']] = $row['name']; } echo json_encode($options); exit; } else { if ("ajax_create_invoice" == $_REQUEST['_process']) { $quote_id = (int) $_REQUEST['quote_id']; $quote = self::get_quote($quote_id, true); $quote_tasks = self::get_tasks($quote_id); if (!$quote || $quote['quote_id'] != $quote_id) { exit; } // no permissions. if (!module_invoice::can_i('create', 'Invoices')) { exit; } // no permissions ob_start(); ?> <p><?php _e('Please select which tasks to generate an invoice for:'); ?> </p> <ul> <?php foreach ($quote['uninvoiced_quote_task_ids'] as $quote_task_id) { if (isset($quote_tasks[$quote_task_id])) { ?> <li> <input type="checkbox" id="invoice_create_task_<?php echo $quote_task_id; ?> " data-taskid="<?php echo $quote_task_id; ?> " class="invoice_create_task" name="invoice_quote_task_id[<?php echo $quote_task_id; ?> ]" value="1" <?php echo $quote_tasks[$quote_task_id]['fully_completed'] ? 'checked' : ''; ?> > <label for="invoice_create_task_<?php echo $quote_task_id; ?> "> (#<?php echo $quote_tasks[$quote_task_id]['task_order']; ?> ) <?php echo htmlspecialchars($quote_tasks[$quote_task_id]['description']); ?> </label> </li> <?php } } ?> </ul> <?php $html = ob_get_clean(); echo $html; exit; } else { if ("ajax_task" == $_REQUEST['_process']) { // we are requesting editing a task. $quote_id = (int) $_REQUEST['quote_id']; $quote = self::get_quote($quote_id, true); $quote_tasks = self::get_tasks($quote_id); if (!$quote || $quote['quote_id'] != $quote_id) { exit; } // no permissions. if (!self::can_i('edit', 'Quote Tasks')) { exit; } // no permissions if (isset($_REQUEST['toggle_completed'])) { $quote_task_id = (int) $_REQUEST['quote_task_id']; $task_data = $quote_tasks[$quote_task_id]; $result = array(); if ($task_data && $task_data['quote_id'] == $quote_id) { if ($task_data['invoiced'] && $task_data['fully_completed']) { // dont allow to 'uncompleted' fully completed invoice tasks } else { // it is editable. $task_data['fully_completed_t'] = 1; $task_data['fully_completed'] = $task_data['fully_completed'] ? 0 : 1; // save a single quote task $this->save_quote_tasks($quote_id, array('quote_task' => array($quote_task_id => $task_data))); $result['success'] = 1; $result['quote_id'] = $quote_id; $result['quote_task_id'] = $quote_task_id; } } echo json_encode($result); exit; } else { if (isset($_REQUEST['update_task_order'])) { // updating the task orders for this task.. $task_order = (array) $_REQUEST['task_order']; foreach ($task_order as $quote_task_id => $new_order) { if ((int) $new_order > 0 && isset($quote_tasks[$quote_task_id])) { update_insert('quote_task_id', $quote_task_id, 'quote_task', array('task_order' => (int) $new_order)); } } echo 'done'; } else { $quote_task_id = (int) $_REQUEST['quote_task_id']; $task_data = $quote_tasks[$quote_task_id]; $task_editable = true; // todo - load this select box in via javascript from existing one on page. $staff_members = module_user::get_staff_members(); $staff_member_rel = array(); foreach ($staff_members as $staff_member) { $staff_member_rel[$staff_member['user_id']] = $staff_member['name']; } // new different formats for quote data. $task_data['manual_task_type_real'] = $task_data['manual_task_type']; if ((!isset($task_data['manual_task_type']) || $task_data['manual_task_type'] < 0) && isset($quote['default_task_type'])) { // use the quote task type $task_data['manual_task_type'] = $quote['default_task_type']; } if (isset($_REQUEST['get_preview'])) { $after_quote_task_id = $quote_task_id; // this will put it right back where it started. $previous_quote_task_id = 0; $quote_tasks = self::get_tasks($quote_id); foreach ($quote_tasks as $k => $v) { // find out where this new task position is! if ($k == $quote_task_id) { $after_quote_task_id = $previous_quote_task_id; break; } $previous_quote_task_id = $k; } $create_invoice_button = ''; //if($quote['total_amount_invoicable'] > 0 && module_invoice::can_i('create','Invoices')){ if (count($quote['uninvoiced_quote_task_ids']) && module_invoice::can_i('create', 'Invoices')) { //href="'.module_invoice::link_generate('new',array('arguments'=>array( 'quote_id' => $quote_id, ))).'" $create_invoice_button = '<a class="submit_button save_button uibutton quote_generate_invoice_button" onclick="return ucm.quote.generate_invoice();">' . _l('Create Invoice') . '</a>'; } $result = array('quote_task_id' => $quote_task_id, 'after_quote_task_id' => $after_quote_task_id, 'html' => self::generate_task_preview($quote_id, $quote, $quote_task_id, $task_data), 'summary_html' => self::generate_quote_summary($quote_id, $quote), 'create_invoice_button' => $create_invoice_button); echo json_encode($result); } else { $show_task_numbers = module_config::c('quote_show_task_numbers', 1) && $quote['auto_task_numbers'] != 2; ob_start(); include 'pages/ajax_task_edit.php'; $result = array('quote_task_id' => $quote_task_id, 'hours' => isset($_REQUEST['hours']) ? (double) $_REQUEST['hours'] : 0, 'html' => ob_get_clean()); echo json_encode($result); } } } exit; } else { if ("save_quote" == $_REQUEST['_process']) { $save_status = $this->save_quote($_REQUEST['quote_id'], $_POST); $quote_id = isset($save_status['quote_id']) ? $save_status['quote_id'] : false; if (!$quote_id) { set_error('Failed to save quote'); redirect_browser(module_quote::link_open(false)); } // look for the new tasks flag. if (isset($_REQUEST['default_task_list_id']) && isset($_REQUEST['default_tasks_action'])) { switch ($_REQUEST['default_tasks_action']) { case 'insert_default': if ((int) $_REQUEST['default_task_list_id'] > 0) { $default = self::get_default_task($_REQUEST['default_task_list_id']); $task_data = $default['task_data']; $new_task_data = array('quote_task' => array()); foreach ($task_data as $task) { $task['quote_id'] = $quote_id; $new_task_data['quote_task'][] = $task; } $this->save_quote_tasks($quote_id, $new_task_data); } break; case 'save_default': $new_default_name = trim($_REQUEST['default_task_list_id']); if ($new_default_name != '') { // time to save it! $task_data = self::get_tasks($quote_id); $cached_task_data = array(); foreach ($task_data as $task) { unset($task['quote_task_id']); unset($task['date_done']); unset($task['invoice_id']); unset($task['task_order']); unset($task['create_user_id']); unset($task['update_user_id']); unset($task['date_created']); unset($task['date_updated']); $task['saved_time'] = time(); $cached_task_data[] = $task; /*$cached_task_data[] = array( 'hours' => $task['hours'], 'amount' => $task['amount'], 'billable' => $task['billable'], 'fully_completed' => $task['fully_completed'], 'description' => $task['description'], 'long_description' => $task['long_description'], 'date_due' => $task['date_due'], 'user_id' => $task['user_id'], 'approval_required' => $task['approval_required'], 'task_order' => $task['task_order'], 'saved_time' => time(), );*/ } self::save_default_tasks((int) $_REQUEST['default_task_list_id'], $new_default_name, $cached_task_data); unset($task_data); } break; } } if (isset($_REQUEST['save_ajax_task'])) { // do everything via ajax. trickery! if ($quote_id <= 0) { die('Shouldnt happen'); } //$result = $this->save_quote_tasks( $quote_id, $_POST ); $result = isset($save_status['task_result']) ? $save_status['task_result'] : false; $quote_data = self::get_quote($quote_id, false); $new_status = self::update_quote_completion_status($quote_id); $new_status = addcslashes(htmlspecialchars($new_status), "'"); //module_cache::clear_cache(); $new_quote_data = self::get_quote($quote_id, false); if ($quote_id != $_REQUEST['quote_id']) { ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($quote_id); ?> &added=true'; </script> <?php exit; } // we now have to edit the parent DOM to reflect these changes. // what were we doing? adding a new task? editing an existing task? switch ($result['status']) { case 'created': // we added a new task. // add a new task to the bottom (OR MID WAY!) through the task list. if ((int) $result['quote_task_id'] > 0) { ?> <script type="text/javascript"> parent.refresh_task_preview(<?php echo (int) $result['quote_task_id']; ?> ); parent.clear_create_form(); parent.ucm.add_message('<?php _e('New task created successfully'); ?> '); parent.ucm.display_messages(true); <?php if ($quote_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change(); <?php } ?> <?php if ($new_quote_data['date_approved'] != $quote_data['date_approved']) { ?> parent.jQuery('#date_approved').val('<?php echo print_date($new_quote_data['date_approved']); ?> ').change(); <?php } ?> </script> <?php } else { set_error('New task creation failed.'); ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($quote_id); ?> &added=true'; </script> <?php } break; case 'deleted': // we deleted a task. set_message('Task removed successfully'); ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($quote_id); ?> '; <?php if ($quote_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change(); <?php } ?> </script> <?php break; case 'error': set_error('Something happened while trying to save a task. Unknown error.'); // something happened, refresh the parent browser frame ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($quote_id); ?> '; </script> <?php break; case 'edited': // we changed a task (ie: completed?); // update this task above. if ((int) $result['quote_task_id'] > 0) { ?> <script type="text/javascript"> parent.canceledittask(); //parent.refresh_task_preview(<?php echo (int) $result['quote_task_id']; ?> ); parent.ucm.add_message('<?php _e('Task saved successfully'); ?> '); parent.ucm.display_messages(true); <?php if ($quote_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change(); <?php } ?> <?php if ($new_quote_data['date_approved'] != $quote_data['date_approved']) { ?> parent.jQuery('#date_approved').val('<?php echo print_date($new_quote_data['date_approved']); ?> ').change(); <?php } ?> </script> <?php } else { ?> <script type="text/javascript"> parent.canceledittask(); parent.ucm.add_error('<?php _e('Unable to save task'); ?> '); parent.ucm.display_messages(true); <?php if ($quote_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change(); <?php } ?> </script> <?php } break; default: ?> <script type="text/javascript"> parent.ucm.add_error('<?php _e('Unable to save task. Please check required fields.'); ?> '); parent.ucm.display_messages(true); </script> <?php break; } exit; } if (isset($_REQUEST['butt_print']) && $_REQUEST['butt_print']) { redirect_browser(module_quote::link_public_print($quote_id)); } if (isset($_REQUEST['butt_email']) && $_REQUEST['butt_email']) { redirect_browser(module_quote::link_generate($quote_id, array('arguments' => array('email' => 1)))); } if (isset($_REQUEST['butt_duplicate']) && $_REQUEST['butt_duplicate'] && module_quote::can_i('create', 'Quotes')) { $new_quote_id = module_quote::duplicate_quote($quote_id); set_message('Quote duplicated successfully'); redirect_browser(module_quote::link_generate($new_quote_id)); } set_message("Quote saved successfully"); //redirect_browser($this->link_open($quote_id)); redirect_browser(isset($_REQUEST['_redirect']) && !empty($_REQUEST['_redirect']) ? $_REQUEST['_redirect'] : $this->link_open($quote_id)); } } } } } if (!count($errors)) { redirect_browser($_REQUEST['_redirect']); exit; } print_error($errors, true); }
public function process() { $errors = array(); if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['job_id']) { $data = self::get_job($_REQUEST['job_id']); if (module_form::confirm_delete('job_id', _l("Really delete job: %s", $data['name']), self::link_open($_REQUEST['job_id']))) { $this->delete_job($_REQUEST['job_id']); set_message("job deleted successfully"); redirect_browser($this->link_open(false)); } } else { if ("ajax_job_list" == $_REQUEST['_process']) { $customer_id = isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : 0; $res = module_job::get_jobs(array('customer_id' => $customer_id)); $options = array(); foreach ($res as $row) { $options[$row['job_id']] = $row['name']; } echo json_encode($options); exit; } else { if ("ajax_create_invoice" == $_REQUEST['_process']) { $job_id = (int) $_REQUEST['job_id']; $job = self::get_job($job_id, true); $job_tasks = self::get_tasks($job_id); if (!$job || $job['job_id'] != $job_id) { exit; } // no permissions. if (!module_invoice::can_i('create', 'Invoices')) { exit; } // no permissions ob_start(); ?> <p><?php _e('Please select which tasks to generate an invoice for:'); ?> </p> <ul> <?php foreach ($job['uninvoiced_task_ids'] as $task_id) { if (isset($job_tasks[$task_id])) { ?> <li> <input type="checkbox" id="invoice_create_task_<?php echo $task_id; ?> " data-taskid="<?php echo $task_id; ?> " class="invoice_create_task" name="invoice_task_id[<?php echo $task_id; ?> ]" value="1" <?php echo $job_tasks[$task_id]['fully_completed'] ? 'checked' : ''; ?> > <label for="invoice_create_task_<?php echo $task_id; ?> "> (#<?php echo $job_tasks[$task_id]['task_order']; ?> ) <?php echo htmlspecialchars($job_tasks[$task_id]['description']); ?> </label> </li> <?php } } ?> </ul> <?php $html = ob_get_clean(); echo $html; exit; } else { if ("ajax_task" == $_REQUEST['_process']) { // we are requesting editing a task. $job_id = (int) $_REQUEST['job_id']; $job = self::get_job($job_id, true); $job_tasks = self::get_tasks($job_id); if (!$job || $job['job_id'] != $job_id) { exit; } // no permissions. if (!self::can_i('edit', 'Job Tasks')) { exit; } // no permissions if (isset($_REQUEST['toggle_completed'])) { $task_id = (int) $_REQUEST['task_id']; $task_data = $job_tasks[$task_id]; $result = array(); if ($task_data && $task_data['job_id'] == $job_id) { if ($task_data['invoiced'] && $task_data['fully_completed']) { // dont allow to 'uncompleted' fully completed invoice tasks } else { // it is editable. $task_data['fully_completed_t'] = 1; $task_data['fully_completed'] = $task_data['fully_completed'] ? 0 : 1; // save a single job task $this->save_job_tasks($job_id, array('job_task' => array($task_id => $task_data))); $result['success'] = 1; $result['job_id'] = $job_id; $result['task_id'] = $task_id; $result['message'] = $task_data['fully_completed'] ? _l('Task marked as complete') : _l('Task marked as incomplete'); $email_status = self::send_job_task_email($job_id, $result['task_id'], 'toggle'); if ($email_status !== false) { $result['message'] .= is_array($email_status) && isset($email_status['message']) ? $email_status['message'] : _l(' and email sent to customer'); } } } echo json_encode($result); exit; } else { if (isset($_REQUEST['delete_task_log_id']) && (int) $_REQUEST['delete_task_log_id'] > 0) { $task_id = (int) $_REQUEST['task_id']; $task_log_id = (int) $_REQUEST['delete_task_log_id']; $sql = "DELETE FROM `" . _DB_PREFIX . "task_log` WHERE task_id = '{$task_id}' AND task_log_id = '{$task_log_id}' LIMIT 1"; query($sql); echo 'done'; } else { if (isset($_REQUEST['update_task_order'])) { // updating the task orders for this task.. $task_order = (array) $_REQUEST['task_order']; foreach ($task_order as $task_id => $new_order) { if ((int) $new_order > 0 && isset($job_tasks[$task_id])) { update_insert('task_id', $task_id, 'task', array('task_order' => (int) $new_order)); } } echo 'done'; } else { $task_id = (int) $_REQUEST['task_id']; $task_data = $job_tasks[$task_id]; $task_editable = !$task_data['invoiced']; $job_task_creation_permissions = module_job::get_job_task_creation_permissions(); // todo - load this select box in via javascript from existing one on page. $staff_members = module_user::get_staff_members(); $staff_member_rel = array(); foreach ($staff_members as $staff_member) { $staff_member_rel[$staff_member['user_id']] = $staff_member['name']; } // new different formats for job data. $task_data['manual_task_type_real'] = $task_data['manual_task_type']; if ((!isset($task_data['manual_task_type']) || $task_data['manual_task_type'] < 0) && isset($job['default_task_type'])) { // use the job task type $task_data['manual_task_type'] = $job['default_task_type']; } $percentage = self::get_percentage($task_data); if (isset($_REQUEST['get_preview'])) { $after_task_id = $task_id; // this will put it right back where it started. $previous_task_id = 0; $job_tasks = self::get_tasks($job_id); $show_hours_summary = false; foreach ($job_tasks as $k => $v) { if ($v['manual_task_type'] < 0) { $job_tasks[$k]['manual_task_type'] = $job['default_task_type']; } if ($job_tasks[$k]['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT) { $show_hours_summary = true; } } foreach ($job_tasks as $k => $v) { // find out where this new task position is! if ($k == $task_id) { $after_task_id = $previous_task_id; break; } $previous_task_id = $k; } $create_invoice_button = ''; //if($job['total_amount_invoicable'] > 0 && module_invoice::can_i('create','Invoices')){ if (count($job['uninvoiced_task_ids']) && module_invoice::can_i('create', 'Invoices')) { //href="'.module_invoice::link_generate('new',array('arguments'=>array( 'job_id' => $job_id, ))).'" $create_invoice_button = '<a class="submit_button save_button uibutton job_generate_invoice_button" onclick="return ucm.job.generate_invoice();">' . _l('Create Invoice') . '</a>'; } $result = array('task_id' => $task_id, 'after_task_id' => $after_task_id, 'html' => self::generate_task_preview($job_id, $job, $task_id, $task_data), 'summary_html' => self::generate_job_summary($job_id, $job, $show_hours_summary), 'create_invoice_button' => $create_invoice_button); echo json_encode($result); } else { $show_task_numbers = module_config::c('job_show_task_numbers', 1) && $job['auto_task_numbers'] != 2; ob_start(); include 'pages/ajax_task_edit.php'; $result = array('task_id' => $task_id, 'hours' => isset($_REQUEST['hours']) ? (double) $_REQUEST['hours'] : 0, 'html' => ob_get_clean()); echo json_encode($result); } } } } exit; } else { if ("save_job_tasks_ajax" == $_REQUEST['_process']) { // do everything via ajax. trickery! // dont bother saving the job. it's already created. $job_id = (int) $_REQUEST['job_id']; $job_data = self::get_job($job_id); if (!$job_id || !$job_data || $job_data['job_id'] != $job_id) { set_error('Permission denied'); exit; } $result = $this->save_job_tasks($job_id, $_POST); $job_data = self::get_job($job_id, false); //if(!$job_data || $job_data['job_id'] != $job_id) $new_status = self::update_job_completion_status($job_id); $new_status = addcslashes(htmlspecialchars($new_status), "'"); //module_cache::clear_cache(); $new_job_data = self::get_job($job_id, false); // we now have to edit the parent DOM to reflect these changes. // what were we doing? adding a new task? editing an existing task? switch ($result['status']) { case 'created': // we added a new task. // add a new task to the bottom (OR MID WAY!) through the task list. if ((int) $result['task_id'] > 0) { // support for job task completion email. $email_status = self::send_job_task_email($job_id, $result['task_id'], 'created'); ?> <script type="text/javascript"> parent.refresh_task_preview(<?php echo (int) $result['task_id']; ?> ); parent.clear_create_form(); parent.ucm.add_message('<?php _e('New task created successfully'); echo is_array($email_status) && isset($email_status['message']) ? $email_status['message'] : ($email_status ? _l(' and email sent to customer') : ''); ?> '); parent.ucm.display_messages(true); <?php if ($job_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change();<?php } ?> <?php if ($new_job_data['date_completed'] != $job_data['date_completed']) { ?> parent.jQuery('#date_completed').val('<?php echo print_date($new_job_data['date_completed']); ?> ').change();<?php } ?> </script> <?php } else { set_error('New task creation failed.'); ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($_REQUEST['job_id']); ?> &added=true'; </script> <?php } break; case 'deleted': // we deleted a task. set_message('Task removed successfully'); ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($_REQUEST['job_id']); ?> '; <?php if ($job_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change();<?php } ?> </script> <?php break; case 'error': set_error('Something happened while trying to save a task. Unknown error.'); // something happened, refresh the parent browser frame ?> <script type="text/javascript"> top.location.href = '<?php echo $this->link_open($_REQUEST['job_id']); ?> '; </script> <?php break; case 'edited': // we changed a task (ie: completed?); // update this task above. if ((int) $result['task_id'] > 0) { $email_status = self::send_job_task_email($job_id, $result['task_id'], 'edited'); ?> <script type="text/javascript"> parent.canceledittask(); //parent.refresh_task_preview(<?php echo (int) $result['task_id']; ?> ); parent.ucm.add_message('<?php _e('Task saved successfully'); echo is_array($email_status) && isset($email_status['message']) ? $email_status['message'] : ($email_status ? _l(' and email sent to customer') : ''); ?> '); parent.ucm.display_messages(true); <?php if ($job_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change();<?php } ?> <?php if ($new_job_data['date_completed'] != $job_data['date_completed']) { ?> parent.jQuery('#date_completed').val('<?php echo print_date($new_job_data['date_completed']); ?> ').change();<?php } ?> </script> <?php } else { ?> <script type="text/javascript"> parent.canceledittask(); parent.ucm.add_error('<?php _e('Unable to save task'); ?> '); parent.ucm.display_messages(true); <?php if ($job_data['status'] != $new_status) { ?> parent.jQuery('#status').val('<?php echo $new_status; ?> ').change();<?php } ?> </script> <?php } break; default: ?> <script type="text/javascript"> parent.ucm.add_error('<?php _e('Unable to save task. Please check required fields.'); ?> '); parent.ucm.display_messages(true); </script> <?php break; } exit; } else { if ("save_job" == $_REQUEST['_process']) { $job_id = (int) $_REQUEST['job_id']; if ((int) $job_id > 0) { $original_job_data = self::get_job($job_id, false); if (!$original_job_data || $original_job_data['job_id'] != $job_id) { $original_job_data = array(); $job_id = false; } } else { $original_job_data = array(); $job_id = false; } // check create permissions. if (!$job_id && !self::can_i('create', 'Jobs')) { // user not allowed to create jobs. set_error('Unable to create new Jobs'); redirect_browser(self::link_open(false)); } else { if ($job_id && !self::can_i('edit', 'Jobs')) { // user not allowed to create jobs. set_error('Unable to edit Jobs'); redirect_browser(self::link_open(false)); } } $job_id = $this->save_job($job_id, $_POST); // look for the new tasks flag. if (isset($_REQUEST['default_task_list_id']) && isset($_REQUEST['default_tasks_action'])) { switch ($_REQUEST['default_tasks_action']) { case 'insert_default': if ((int) $_REQUEST['default_task_list_id'] > 0) { $default = self::get_default_task($_REQUEST['default_task_list_id']); $task_data = $default['task_data']; $new_task_data = array('job_task' => array()); foreach ($task_data as $task) { $task['job_id'] = $job_id; if ($task['date_due'] && $task['date_due'] != '0000-00-00') { $diff_time = strtotime($task['date_due']) - $task['saved_time']; $task['date_due'] = date('Y-m-d', time() + $diff_time); } $new_task_data['job_task'][] = $task; } $this->save_job_tasks($job_id, $new_task_data); } break; case 'save_default': $new_default_name = trim($_REQUEST['default_task_list_id']); if ($new_default_name != '') { // time to save it! $task_data = self::get_tasks($job_id); $cached_task_data = array(); foreach ($task_data as $task) { unset($task['task_id']); unset($task['date_done']); unset($task['invoice_id']); unset($task['task_order']); unset($task['create_user_id']); unset($task['update_user_id']); unset($task['date_created']); unset($task['date_updated']); $task['saved_time'] = time(); $cached_task_data[] = $task; /*$cached_task_data[] = array( 'hours' => $task['hours'], 'amount' => $task['amount'], 'billable' => $task['billable'], 'fully_completed' => $task['fully_completed'], 'description' => $task['description'], 'long_description' => $task['long_description'], 'date_due' => $task['date_due'], 'user_id' => $task['user_id'], 'approval_required' => $task['approval_required'], 'task_order' => $task['task_order'], 'saved_time' => time(), );*/ } self::save_default_tasks((int) $_REQUEST['default_task_list_id'], $new_default_name, $cached_task_data); unset($task_data); } break; } } // check if we are generating any renewals if (isset($_REQUEST['generate_renewal']) && $_REQUEST['generate_renewal'] > 0) { $new_job_id = $this->renew_job($job_id); set_message("Job renewed successfully"); redirect_browser($this->link_open($new_job_id)); } if (isset($_REQUEST['butt_create_deposit']) && isset($_REQUEST['job_deposit']) && $_REQUEST['job_deposit'] > 0) { if (strpos($_REQUEST['job_deposit'], '%') !== false) { $job_data = module_job::get_job($job_id); $percent = (int) str_replace('%', '', $_REQUEST['job_deposit']); $_REQUEST['job_deposit'] = number_out($job_data['total_amount'] * ($percent / 100)); } // create an invoice for this job. $url = module_invoice::link_generate('new', array('arguments' => array('job_id' => $job_id, 'as_deposit' => 1, 'amount_due' => number_in($_REQUEST['job_deposit']), 'description' => str_replace('{JOB_NAME}', $_POST['name'], module_config::c('job_deposit_text', 'Deposit for job: {JOB_NAME}'))))); redirect_browser($url); } set_message("Job saved successfully"); redirect_browser(isset($_REQUEST['_redirect']) && !empty($_REQUEST['_redirect']) ? $_REQUEST['_redirect'] : $this->link_open($job_id)); } } } } } } if (!count($errors)) { redirect_browser($_REQUEST['_redirect']); exit; } print_error($errors, true); }
public function process() { if ('language_reset' == $_REQUEST['_process'] && $_REQUEST['really'] == 'yes') { if (!module_form::check_secure_key()) { return; } // delete all language words and translations $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE 1"; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "language_translation` WHERE 1"; query($sql); set_message('Translation reset successfully'); redirect_browser($_SERVER['REQUEST_URI']); } if ('remove_duplicates' == $_REQUEST['_process'] && isset($_REQUEST['duplicate_ids'])) { if (!module_form::check_secure_key()) { return; } $duplicate_ids = json_decode($_REQUEST['duplicate_ids'], true); foreach ($duplicate_ids as $duplicate_id) { $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE language_word_id = '" . (int) $duplicate_id . "' LIMIT 1"; query($sql); } set_message('Translation errors removed successfully'); redirect_browser($_SERVER['REQUEST_URI']); } else { if ('language_duplicate_remove' == $_REQUEST['_process'] && $_REQUEST['really'] == 'yep') { if (!module_form::check_secure_key()) { return; } // delete all language words and translations $sql = "SELECT `word`, COUNT(*) as cc FROM `" . _DB_PREFIX . "language_word` GROUP BY `word` HAVING cc > 1"; $res = qa($sql); foreach ($res as $r) { if ($r['word'] && $r['cc'] > 1) { // remove duplicates. $sql = "SELECT * FROM `" . _DB_PREFIX . "language_word` WHERE `word` = '" . mysql_real_escape_string($r['word']) . "' "; $duplicates = qa($sql); // doing this due to incorrect collate in earlier version of UCM $words_casesensitive = array(); foreach ($duplicates as $duplicate) { $words_casesensitive[$duplicate['word']][$duplicate['language_word_id']] = $duplicate['language_word_id']; } //print_r($words_casesensitive);exit; foreach ($words_casesensitive as $word => $duplicate_ids) { if (count($duplicate_ids) > 1) { $first = false; foreach ($duplicate_ids as $language_word_id) { if ($first === false) { $first = $language_word_id; } else { if ($first) { // remove this one and replace any translations with the first one. $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE language_word_id = '" . (int) $language_word_id . "' LIMIT 1"; query($sql); $sql = "UPDATE `" . _DB_PREFIX . "language_translation` SET language_word_id = '" . (int) $first . "' WHERE language_word_id = '" . (int) $language_word_id . "'"; query($sql); } } } } } } } $sql = "DELETE FROM `" . _DB_PREFIX . "language_word` WHERE `word` LIKE 'SQL Error%'"; query($sql); // merge languages - error if case of language changes, keeps creating new language entries - eg FR fr $sql = "SELECT `language_id`, `language_code`, COUNT(*) as cc FROM `" . _DB_PREFIX . "language` GROUP BY `language_code`"; $res = query($sql); while ($row = mysql_fetch_assoc($res)) { if ($row['cc'] > 1) { // merge these! $sql = "SELECT language_id FROM `" . _DB_PREFIX . "language` WHERE `language_code` = '" . mysql_real_escape_string($row['language_code']) . "' AND language_id != " . (int) $row['language_id'] . ""; $to_merge = query($sql); while ($merge = mysql_fetch_assoc($to_merge)) { $sql = "UPDATE `" . _DB_PREFIX . "language_translation` SET language_id = " . (int) $row['language_id'] . " WHERE language_id = " . (int) $merge['language_id'] . ""; query($sql); // remove any that didn't update correctly (duplicate entries) $sql = "DELETE FROM `" . _DB_PREFIX . "language_translation` WHERE language_id = " . (int) $merge['language_id'] . ""; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "language` WHERE language_id = " . (int) $merge['language_id'] . " LIMIT 1"; query($sql); } } } set_message('Translation duplicates removed successfully'); redirect_browser($_SERVER['REQUEST_URI']); } } if ('save_language_translation' == $_REQUEST['_process']) { if (!module_form::check_secure_key()) { return; } if (!module_config::can_i('view', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_config::can_i('edit', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_language::can_i('edit', 'Language')) { redirect_browser(_BASE_HREF); } $language_id = (int) $_REQUEST['language_id']; $language = module_language::get_language($language_id); if (!$language_id || !$language || $language['language_id'] != $language_id) { $language_id = false; $language = array(); } $language_id = update_insert('language_id', $language_id, 'language', $_POST); if (isset($_POST['translation']) && is_array($_POST['translation'])) { // save these values to the translation table for this particular langauge. foreach ($_POST['translation'] as $language_word_id => $translation) { if (_DEMO_MODE) { if (!isset($_SESSION['temp_translation'])) { $_SESSION['temp_translation'] = array(); } if (!isset($_SESSION['temp_translation'][$language_id])) { $_SESSION['temp_translation'][$language_id] = array(); } $_SESSION['temp_translation'][$language_id][$language_word_id] = $translation; } else { if (strlen($translation)) { $sql = "REPLACE INTO `" . _DB_PREFIX . "language_translation` SET `language_id` = " . (int) $language_id . ", "; $sql .= "`language_word_id` = " . (int) $language_word_id . ", `translation` = '" . mysql_real_escape_string($translation) . "'"; query($sql); } else { $sql = "DELETE FROM `" . _DB_PREFIX . "language_translation` WHERE `language_id` = " . (int) $language_id . " AND "; $sql .= "`language_word_id` = " . (int) $language_word_id . ""; query($sql); } } } } if (isset($_REQUEST['check_duplicates'])) { // redirect to duplicate check page. redirect_browser($_SERVER['REQUEST_URI'] . '&check_duplicates'); } else { set_message('Translation saved successfully'); redirect_browser(str_replace('language_id', 'done', $_SERVER['REQUEST_URI'])); } } }
$(this).change(function(){ link_it( $(this)[0].checked ? $(this).val() : false ); }); $(this).mouseup(function(){ link_it( $(this)[0].checked ? $(this).val() : false ); }); }); }); </script> <form action="" method="post" id="quick_add_form"> <input type="hidden" name="_process" value="quick_save_finance"> <input type="hidden" name="finance_id" value="new"> <?php module_form::set_default_field('new_transaction_name'); $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['sort_date'] = array('title' => 'Date', 'callback' => function (&$finance) { if (!isset($finance['transaction_date'])) { return false; } // loop over all finance records and print the values out, only if they differ. // only print dates if they differ from the others. $dates = array(); //$links = array(); $dates[print_date($finance['transaction_date'])] = true; //$links[$finance['url']]=!trim($finance['name']) ? 'N/A' : htmlspecialchars($finance['name']); if ($finance['finance_record']) { if (isset($finance['finance_record']['linked_finances'])) { foreach ($finance['finance_record']['linked_finances'] as $f) {
public static function display_pagination_hook() { if (isset(self::$pagination_options['fields'])) { $owner_table = (string) self::$pagination_options['fields']['owner_table']; global $plugins; if (isset($plugins[$owner_table]) && isset(self::$pagination_options['fields']['title']) && self::$pagination_options['fields']['title']) { $can_view = $plugins[$owner_table]->can_i('view', self::$pagination_options['fields']['title']); if (!$can_view) { return ''; } /*$can_edit = $plugins[$owner_table]->can_i('edit',self::$pagination_options['fields']['title']); $can_create = $plugins[$owner_table]->can_i('create',self::$pagination_options['fields']['title']); $can_delete = $plugins[$owner_table]->can_i('delete',self::$pagination_options['fields']['title']);*/ } ?> <span> <a href="#" onclick="if($('#group_popdown').css('display')=='inline' || $('#group_popdown').css('display')=='block') $('#group_popdown').css('display','none'); else $('#group_popdown').css('display','inline'); return false;"><?php _e('(group)'); ?> </a> <span id="group_popdown" style="position: absolute; width: 200px; display: none; background: #EFEFEF; margin-left: -210px; margin-top: 30px; border: 1px solid #CCC; text-align: left; padding: 6px; z-index: 3;"> <strong><?php _e('Add all these results to a group:'); ?> </strong><br/> <?php $groups = self::get_groups(trim((string) self::$pagination_options['fields']['owner_table'])); if (!count($groups)) { _e('Sorry, no groups exist. Please create a group first.'); } else { foreach ($groups as $group) { $group_id = $group['group_id']; ?> <input type="checkbox" class="add_to_group" name="add_to_group[<?php echo $group['group_id']; ?> ]" id="groupchk<?php echo $group_id; ?> " value="yes"> <label for="groupchk<?php echo $group_id; ?> "><?php echo htmlspecialchars($group['name']); ?> </label> <br/> <?php } ?> <input type="hidden" name="add_group_go" id="add_group_go" value=""> <input type="button" name="add_group_button" id="add_group_button" value="<?php _e('Add to group'); ?> "> <script type="text/javascript"> $(function(){ $('#add_group_button').click(function(){ $('#add_group_go').val('yes'); // todo: if no form, create one them submit. $('#add_group_go').parents('form')[0].submit(); }); }); </script> <?php } ?> </span> </span> <?php } if (isset(self::$pagination_options['bulk_actions']) && count(self::$pagination_options['bulk_actions'])) { ?> <span> <a href="#" onclick="if($('#bulk_popdown').css('display')=='inline' || $('#bulk_popdown').css('display')=='block') $('#bulk_popdown').css('display','none'); else $('#bulk_popdown').css('display','inline'); return false;"><?php _e('(bulk actions)'); ?> </a> <span id="bulk_popdown" style="position: absolute; width: 200px; display: none; background: #EFEFEF; margin-left: -210px; margin-top: 30px; border: 1px solid #CCC; text-align: left; padding: 6px; z-index: 3;"> <strong><?php _e('Bulk actions:'); ?> </strong><br/> <?php foreach (self::$pagination_options['bulk_actions'] as $bulk_action_id => $bulk_action_data) { switch ($bulk_action_data['type']) { case 'delete': ?> <input type="checkbox" class="bulk_action" name="bulk_action[<?php echo $bulk_action_id; ?> ]" id="bulkchk<?php echo $bulk_action_id; ?> " value="yes"> <label for="bulkchk<?php echo $bulk_action_id; ?> "><?php _e($bulk_action_data['label']); ?> </label> <br/> <?php break; case 'form': ?> <input type="checkbox" class="bulk_action" name="bulk_action[<?php echo $bulk_action_id; ?> ]" id="bulkchk<?php echo $bulk_action_id; ?> " value="yes"> <label for="bulkchk<?php echo $bulk_action_id; ?> "><?php _e($bulk_action_data['label']); ?> </label> <?php if (isset($bulk_action_data['elements'])) { foreach ($bulk_action_data['elements'] as $element) { module_form::generate_form_element($element); } } ?> <br/> <?php break; default: ?> <input type="checkbox" class="bulk_action" name="bulk_action[<?php echo $bulk_action_id; ?> ]" id="bulkchk<?php echo $bulk_action_id; ?> " value="yes"> <label for="bulkchk<?php echo $bulk_action_id; ?> "><?php _e($bulk_action_data['label']); ?> </label> <br/> <?php break; } ?> <?php } ?> <input type="hidden" name="bulk_action_go" id="bulk_action_go" value=""> <input type="button" name="bulk_action_button" id="bulk_action_button" value="<?php _e('Perform Bulk Actions'); ?> "> <script type="text/javascript"> $(function(){ $('#bulk_action_button').click(function(){ $('#bulk_action_go').val('yes'); // todo: if no form, create one them submit. $('#bulk_action_go').parents('form')[0].submit(); }); }); </script> </span> </span> <?php } }
?> " /> <input type="hidden" name="total_tax_name" value="<?php echo htmlspecialchars($invoice['total_tax_name']); ?> " /> <input type="hidden" name="hourly_rate" value="<?php echo htmlspecialchars($invoice['hourly_rate']); ?> " /> <?php $fields = array('fields' => array('name' => 'Name')); module_form::set_required($fields); module_form::prevent_exit(array('valid_exits' => array('.submit_button', '.save_invoice_item', '.save_invoice_payment', '.delete', '.apply_discount'))); ?> <table cellpadding="10" width="100%"> <tbody> <tr> <td valign="top" width="35%"> <h3><?php echo _l('%sCredit Note Details', !$invoice_id ? _l('New ') : ''); ?> (BETA!)</h3> <table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tableclass_full">
function metis_generate_form_actions($callback, $options) { $defaults = array('type' => 'action_bar', 'class' => 'action_bar', 'elements' => array()); $options = array_merge($defaults, $options); //todo - hook in here for themes. ob_start(); ?> <div class="action_bar_duplicate <?php echo $options['class']; ?> "> <?php foreach ($options['elements'] as $element) { if (is_array($element) && !is_array(current($element))) { $element = array($element); } $element['fields'] = $element; ?> <span class="action"> <?php if (isset($element['fields'])) { ?> <span class="action_element"> <?php if (is_array($element['fields'])) { foreach ($element['fields'] as $dataid => $field) { if (is_array($field)) { // treat this as a call to the form generate option switch ($field['type']) { case 'save_button': $field['type'] = 'submit'; $field['class'] = (isset($field['class']) ? $field['class'] . ' ' : '') . 'submit_button btn btn-success'; break; case 'submit': $field['type'] = 'submit'; $field['class'] = (isset($field['class']) ? $field['class'] . ' ' : '') . 'submit_button btn btn-default'; break; case 'delete_button': $field['type'] = 'submit'; $field['class'] = (isset($field['class']) ? $field['class'] . ' ' : '') . 'submit_button btn btn-danger'; break; case 'button': $field['type'] = 'button'; $field['class'] = (isset($field['class']) ? $field['class'] . ' ' : '') . 'submit_button btn btn-default'; break; } module_form::generate_form_element($field); echo ' '; } else { echo $field . ' '; } } } else { echo $element['fields']; } ?> </span> <?php } ?> </span> <?php } ?> </div> <?php return ob_get_clean(); }
</td> <td colspan="<?php echo $colspan; ?> " valign="top"> <?php if (module_invoice::can_i('view', 'Invoices')) { ?> <div> <?php _e('Task Type:'); ?> <?php $types = module_job::get_task_types(); $types['-1'] = _l('Default (%s)', $types[$job['default_task_type']]); module_form::generate_form_element(array('type' => 'select', 'name' => 'job_task[' . $task_id . '][manual_task_type]', 'id' => 'manual_task_type_' . $task_id, 'options' => $types, 'blank' => false, 'value' => $task_data['manual_task_type_real'])); ?> </div> <?php } ?> <div> <?php if ($task_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT && (module_config::c('job_task_log_all_hours', 1) || $task_data[$hours_prefix . 'hours'] != 0)) { if (function_exists('decimal_time_out')) { $completed_value = decimal_time_out($task_data['completed']); $hours_value = decimal_time_out($task_data[$hours_prefix . 'hours']); } else { $completed_value = number_out($task_data['completed'], true); $hours_value = number_out($task_data[$hours_prefix . 'hours'], true); }
public function process() { if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['subscription_id']) { $data = self::get_subscription($_REQUEST['subscription_id']); if (module_form::confirm_delete('subscription_id', "Really delete subscription: " . $data['name'], self::link_open($_REQUEST['subscription_id']))) { $this->delete_subscription($_REQUEST['subscription_id']); set_message("Subscription deleted successfully"); redirect_browser(self::link_open(false)); } } else { if ("save_subscription" == $_REQUEST['_process']) { $subscription_id = $this->save_subscription($_REQUEST['subscription_id'], $_POST); set_message("Subscription saved successfully"); redirect_browser(self::link_open($subscription_id)); } } }
* Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ $module->page_title = _l('Template Edit'); //print_heading('Newsletter Editor'); $newsletter_template_id = isset($_REQUEST['newsletter_template_id']) ? (int) $_REQUEST['newsletter_template_id'] : false; $newsletter_template = module_newsletter::get_newsletter_template($newsletter_template_id); ?> <form action="" method="post"> <input type="hidden" name="_process" value="save_newsletter_template"> <?php module_form::set_required(array('fields' => array('newsletter_template_name' => 'Name'))); module_form::prevent_exit(array('valid_exits' => array('.submit_button', '.valid_exit'))); ?> <table width="100%" cellpadding="5"> <tbody> <tr> <td valign="top"> <h3><?php echo _l('Newsletter Template Details'); ?> </h3> <table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form"> <tbody> <tr> <th class="width1">
public function process() { /*if('save_data_access_popup' == $_REQUEST['_process']){ // saving data access for specieid user id. // get user id from post. // todo - make this secure, check current user has permissions to access security :) // dodgy dave. $user_id = (int)$_REQUEST['user_id']; if($user_id && $_REQUEST['access_level']){ $sql = "UPDATE `"._DB_PREFIX."security_access` SET `access_level` = '".(int)$_REQUEST['access_level']."' WHERE user_id = '".$user_id."' LIMIT 1"; query($sql); } if($user_id && is_array($_REQUEST['data_access'])){ $sql = "UPDATE `"._DB_PREFIX."security_access` SET `data_access` = '".mysql_real_escape_string(serialize($_REQUEST['data_access']))."' WHERE user_id = '".$user_id."' LIMIT 1"; query($sql); } }else */ if ('save_security_role' == $_REQUEST['_process']) { if (!module_config::can_i('edit', 'Settings')) { redirect_browser(_BASE_HREF); } if (!module_security::can_i('edit', 'Security Roles', 'Security')) { redirect_browser('/'); } if (isset($_REQUEST['butt_del']) && module_security::can_i('delete', 'Security Roles', 'Security')) { $security_role_id = (int) $_REQUEST['security_role_id']; $role = self::get_security_role($security_role_id); if ($role && $security_role_id == $role['security_role_id']) { if (module_form::confirm_delete('security_role_id', "Really delete security role: " . $role['name'], self::link_open_role($security_role_id))) { $sql = "DELETE FROM `" . _DB_PREFIX . "security_role_perm` WHERE security_role_id = '" . (int) $security_role_id . "'"; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "user_role` WHERE security_role_id = '" . (int) $security_role_id . "'"; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "security_role` WHERE security_role_id = '" . (int) $security_role_id . "'"; query($sql); } } set_message('Role deleted successfully.'); redirect_browser($this->link_open_role(false)); } $security_role_id = update_insert('security_role_id', $_REQUEST['security_role_id'], 'security_role', $_POST); // todo - deleting. if ($security_role_id) { $sql = "DELETE FROM `" . _DB_PREFIX . "security_role_perm` WHERE security_role_id = '" . (int) $security_role_id . "'"; query($sql); if (isset($_REQUEST['load_defaults']) && strlen($_REQUEST['load_defaults']) > 0 && ($defaults = json_decode($_REQUEST['load_defaults'], true))) { //$export_json[$available_permission['category'].'|'.$available_permission['module'].'|'.$available_permission['name'].'|'.$available_permission['description']][] = $permission; foreach ($defaults as $key => $permissions) { list($category, $module, $name, $description) = explode('|', $key); $existing = get_single('security_permission', array('name', 'category', 'description', 'module'), array($name, $category, $description, $module)); $security_permission_id = false; $available_perms = array(); if ($existing) { $security_permission_id = $existing['security_permission_id']; $available_perms = @unserialize($existing['available_perms']); if (!is_array($available_perms)) { $available_perms = array(); } } if (!$security_permission_id) { $security_permission_id = update_insert('security_permission_id', 'new', 'security_permission', array('name' => $name, 'category' => $category, 'module' => $module, 'description' => $description)); } $save_perms = false; foreach (self::$available_permissions as $permission) { if (in_array($permission, $permissions)) { // the script is asking for this available permission. // check if it exists in the db as an option if (!isset($available_perms[$permission])) { // time to add it to the db so we can configure this in the future. $available_perms[$permission] = true; $save_perms = true; } } } if ($save_perms && $security_permission_id) { update_insert('security_permission_id', $security_permission_id, 'security_permission', array('available_perms' => serialize($available_perms))); } if ($security_permission_id) { $actions = array(); foreach (self::$available_permissions as $permission) { if (in_array($permission, $permissions)) { $actions[$permission] = 1; } } if (count($actions)) { $sql = "REPLACE INTO `" . _DB_PREFIX . "security_role_perm` SET security_role_id = '" . (int) $security_role_id . "', security_permission_id = '" . (int) $security_permission_id . "' "; foreach ($actions as $permission => $tf) { $sql .= ", `" . mysql_real_escape_string($permission) . "` = 1"; } query($sql); } } } set_message('Defaults loaded successfully.'); } else { if (isset($_REQUEST['permission']) && is_array($_REQUEST['permission'])) { // update permissions for this role. foreach ($_REQUEST['permission'] as $security_permission_id => $permissions) { $actions = array(); foreach (self::$available_permissions as $permission) { if (isset($permissions[$permission]) && $permissions[$permission]) { $actions[$permission] = 1; } } $sql = "REPLACE INTO `" . _DB_PREFIX . "security_role_perm` SET security_role_id = '" . (int) $security_role_id . "', security_permission_id = '" . (int) $security_permission_id . "' "; foreach ($actions as $permission => $tf) { $sql .= ", `" . mysql_real_escape_string($permission) . "` = 1"; } query($sql); } } if (isset($_REQUEST['permission_drop_down']) && is_array($_REQUEST['permission_drop_down'])) { // update permissions for this role. $permission = 'view'; foreach ($_REQUEST['permission_drop_down'] as $security_permission_ids => $selected_security_permission_id) { $ids_to_clear = explode('|', $security_permission_ids); foreach ($ids_to_clear as $id_to_clear) { $id_to_clear = (int) $id_to_clear; if (!$id_to_clear) { continue; } $sql = "DELETE FROM `" . _DB_PREFIX . "security_role_perm` WHERE security_role_id = '" . (int) $security_role_id . "' AND security_permission_id = '" . (int) $id_to_clear . "' "; query($sql); } if ((int) $selected_security_permission_id > 0) { $sql = "REPLACE INTO `" . _DB_PREFIX . "security_role_perm` SET security_role_id = '" . (int) $security_role_id . "', security_permission_id = '" . (int) $selected_security_permission_id . "' "; $sql .= ", `" . mysql_real_escape_string($permission) . "` = 1"; } query($sql); } } set_message('Role saved successfully.'); } redirect_browser($this->link_open_role($security_role_id)); } } }
<input type="file" name="csv"> </td> </tr> <?php if (isset($import_options['options']) && is_array($import_options['options'])) { foreach ($import_options['options'] as $option_id => $option_values) { ?> <tr> <th> <?php echo $option_values['label']; ?> </th> <td> <?php module_form::generate_form_element($option_values['form_element']); ?> </td> </tr> <?php } } ?> <?php if (class_exists('module_group', false) && isset($import_options['group']) && $import_options['group']) { // hack to support multiple groups (for members) if (!is_array($import_options['group'])) { $import_options['group'] = array($import_options['group']); } foreach ($import_options['group'] as $group_option) { ?>
public function process() { if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['company_id'] && self::can_i('delete', 'Company')) { $data = self::get_company($_REQUEST['company_id']); if ($data && $data['company_id'] == $_REQUEST['company_id'] && module_form::confirm_delete('company_id', "Really delete company: " . $data['name'], self::link_open($_REQUEST['company_id']))) { $this->delete_company($_REQUEST['company_id']); set_message("company deleted successfully"); redirect_browser($this->link_open(false)); } } else { if ('save_company' == $_REQUEST['_process'] && self::can_i('edit', 'Company')) { $company_id = update_insert('company_id', $_REQUEST['company_id'], 'company', $_POST); set_message('Company saved successfully'); redirect_browser($this->link_open($company_id)); } } }
public static function bulk_handle_delete() { if (isset($_REQUEST['bulk_action']) && isset($_REQUEST['bulk_action']['delete']) && $_REQUEST['bulk_action']['delete'] == 'yes' && module_form::check_secure_key() && module_invoice::can_i('delete', 'Invoices')) { // confirm deletion of these tickets: $invoice_ids = isset($_REQUEST['invoice_bulk_operation']) && is_array($_REQUEST['invoice_bulk_operation']) ? $_REQUEST['invoice_bulk_operation'] : array(); foreach ($invoice_ids as $invoice_id => $k) { if ($k != 'yes') { unset($invoice_ids[$invoice_id]); } else { $invoice_ids[$invoice_id] = module_invoice::link_open($invoice_id, true); } } if (count($invoice_ids) > 0) { if (module_form::confirm_delete('invoice_id', _l("Really delete invoices: %s", implode(', ', $invoice_ids)), self::link_open(false))) { foreach ($invoice_ids as $invoice_id => $invoice_number) { self::delete_invoice($invoice_id); } set_message(_l("%s invoices deleted successfully", count($invoice_ids))); redirect_browser(self::link_open(false)); } } } }
public function process() { if ("save_facebook" == $_REQUEST['_process']) { $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; $facebook = new ucm_facebook_account($social_facebook_id); if (isset($_POST['butt_del']) && module_social::can_i('delete', 'Facebook', 'Social', 'social')) { if (module_form::confirm_delete('social_facebook_id', "Really delete this Facebook account from the system? All messages will be lost.", self::link_open($_REQUEST['social_facebook_id']))) { $facebook->delete(); set_message("Facebook account deleted successfully"); redirect_browser(self::link_open(false)); } } $facebook->save_data($_POST); $social_facebook_id = $facebook->get('social_facebook_id'); if (isset($_POST['butt_save_connect'])) { $redirect = $this->link_open($social_facebook_id, false, false, 'facebook_account_connect'); } else { set_message('Facebook account saved successfully'); $redirect = $this->link_open($social_facebook_id); } redirect_browser($redirect); exit; } else { if ("send_facebook_message" == $_REQUEST['_process']) { if (module_form::check_secure_key()) { $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; $facebook = new ucm_facebook_account($social_facebook_id); if ($social_facebook_id && $facebook->get('social_facebook_id') == $social_facebook_id) { // queue the message into the facebook_message table // if there's a scheduled date in the past we send it in the past, no date we send straight away, date in the future we leave it in the db table for the cron job to pick up. //print_r($_POST);exit; $send_time = false; // default: now if (isset($_POST['schedule_date']) && isset($_POST['schedule_time']) && !empty($_POST['schedule_date']) && !empty($_POST['schedule_time'])) { $date = $_POST['schedule_date']; $time_hack = $_POST['schedule_time']; $time_hack = str_ireplace('am', '', $time_hack); $time_hack = str_ireplace('pm', '', $time_hack); $bits = explode(':', $time_hack); if (strpos($_POST['schedule_time'], 'pm')) { $bits[0] += 12; } // add the time if it exists $date .= ' ' . implode(':', $bits) . ':00'; $send_time = strtotime(input_date($date, true)); } else { if (isset($_POST['schedule_date']) && !empty($_POST['schedule_date'])) { $send_time = strtotime(input_date($_POST['schedule_date'], true)); } } //echo print_date($send_time,true); //echo '<br>'; //echo date('c',$send_time); //exit; /* @var $available_pages ucm_facebook_page[] */ $available_pages = $facebook->get('pages'); $send_pages = isset($_POST['compose_page_id']) && is_array($_POST['compose_page_id']) ? $_POST['compose_page_id'] : array(); $page_count = 0; if ($send_pages) { foreach ($send_pages as $facebook_page_id => $tf) { if (!$tf) { continue; } // see if this is an available page. if (isset($available_pages[$facebook_page_id])) { // push to db! then send. $facebook_message = new ucm_facebook_message($facebook, $available_pages[$facebook_page_id], false); $facebook_message->create_new(); $facebook_message->update('social_facebook_page_id', $available_pages[$facebook_page_id]->get('social_facebook_page_id')); $facebook_message->update('social_facebook_id', $facebook->get('social_facebook_id')); $facebook_message->update('summary', isset($_POST['message']) ? $_POST['message'] : ''); $facebook_message->update('type', 'pending'); $facebook_message->update('link', isset($_POST['link']) ? $_POST['link'] : ''); $facebook_message->update('data', json_encode($_POST)); $facebook_message->update('user_id', module_security::get_loggedin_id()); // do we send this one now? or schedule it later. $facebook_message->update('status', _SOCIAL_MESSAGE_STATUS_PENDINGSEND); if ($send_time) { // schedule for sending at a different time (now or in the past) $facebook_message->update('last_active', $send_time); } else { // send it now. $facebook_message->update('last_active', 0); } if (isset($_FILES['picture']['tmp_name']) && is_uploaded_file($_FILES['picture']['tmp_name'])) { $facebook_message->add_attachment($_FILES['picture']['tmp_name']); } $facebook_message->send_queued(isset($_POST['debug'])); $page_count++; } else { // log error? } } } set_message(_l('Message delivered successfully to %s Facebook pages', $page_count)); $redirect = $this->link_open_message_view($social_facebook_id); redirect_browser($redirect); } } } else { if ("ajax_facebook_url_info" == $_REQUEST['_process']) { header('Content-type: text/javascript'); $url = isset($_REQUEST['url']) ? $_REQUEST['url'] : false; if (strlen($url) > 4 && preg_match('#https?://#', $url)) { // pass this into graph api debugger to get some information back about the URL $facebook = new ucm_facebook(); $data = $facebook->get_url_info($url); // return the data formatted in json ready to be added into the relevant input boxes. $data['link_picture'] = isset($data['image'][0]['url']) ? $data['image'][0]['url'] : ''; $data['link_name'] = isset($data['title']) ? $data['title'] : ''; $data['link_caption'] = isset($data['caption']) ? $data['caption'] : ''; $data['link_description'] = isset($data['description']) ? $data['description'] : ''; echo json_encode($data); } exit; } else { if ("ajax_social_facebook" == $_REQUEST['_process']) { // ajax functions from wdsocial. copied from the datafeed.php sample files. header('Content-type: text/javascript'); if (module_form::check_secure_key()) { // todo: check user has access to this message. $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; //$facebook = new ucm_facebook_account($social_facebook_id); //if($social_facebook_id && $facebook->get('social_facebook_id') == $social_facebook_id){ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false; $message_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; $facebook_message = new ucm_facebook_message(); $facebook_message->load($message_id); //if($facebook_message->get('social_facebook_id') == $social_facebook_id){ switch ($action) { case "send-message-reply": if (module_social::can_i('create', 'Facebook Comments', 'Social', 'social')) { $return = array(); $message = isset($_POST['message']) && $_POST['message'] ? $_POST['message'] : ''; $facebook_id = isset($_POST['facebook_id']) && $_POST['facebook_id'] ? $_POST['facebook_id'] : false; $debug = isset($_POST['debug']) && $_POST['debug'] ? $_POST['debug'] : false; if ($message) { if ($debug) { ob_start(); } $facebook_message->send_reply($facebook_id, $message, $debug); if ($debug) { $return['message'] = ob_get_clean(); } else { // todo - option to ask the user if they want to archive a message during the send. set_message(_l('Message sent and conversation archived.')); if ($social_facebook_id) { $return['redirect'] = module_social_facebook::link_open_message_view($social_facebook_id); } else { // return to the 'combined' view: } } } echo json_encode($return); } break; case "set-answered": if (module_social::can_i('edit', 'Facebook Comments', 'Social', 'social')) { $facebook_message->update('status', _SOCIAL_MESSAGE_STATUS_ANSWERED); ?> $('.facebook_message_row[data-id=<?php echo $message_id; ?> ]').hide(); <?php } break; case "set-unanswered": if (module_social::can_i('edit', 'Facebook Comments', 'Social', 'social')) { $facebook_message->update('status', _SOCIAL_MESSAGE_STATUS_UNANSWERED); ?> $('.facebook_message_row[data-id=<?php echo $message_id; ?> ]').hide(); <?php } break; } //echo 'The status is '.$facebook_message->get('status'); //} } // } exit; } } } } }
public static function bulk_handle_delete() { if (isset($_REQUEST['bulk_action']) && isset($_REQUEST['bulk_action']['delete']) && $_REQUEST['bulk_action']['delete'] == 'yes' && self::can_i('delete', 'Files')) { // confirm deletion of these files: $file_ids = isset($_REQUEST['bulk_operation']) && is_array($_REQUEST['bulk_operation']) ? $_REQUEST['bulk_operation'] : array(); foreach ($file_ids as $file_id => $k) { if ($k != 'yes') { unset($file_ids[$file_id]); } else { $ucm_file = new ucm_file($file_id); if (!$ucm_file->can_i_access()) { unset($file_ids[$file_id]); } else { $file_data = $ucm_file->get_data(); $file_ids[$file_id] = $file_data['file_name']; } } } if (count($file_ids) > 0) { if (module_form::confirm_delete('file_id', _l("Really delete files: %s", implode(', ', $file_ids)), self::link_open(false))) { foreach ($file_ids as $file_id => $file_number) { $ucm_file = new ucm_file($file_id); $ucm_file->delete(); } set_message(_l("%s files deleted successfully", count($file_ids))); redirect_browser(self::link_open(false)); } } } }
private function _handle_save_template() { // handle post back for save template template. $template_id = (int) $_REQUEST['template_id']; // delete. if (isset($_REQUEST['butt_del']) && self::can_i('delete', 'Templates')) { $template_data = self::get_template($template_id); if (module_form::confirm_delete('template_id', _l("Really delete template: %s", $template_data['template_key']), self::link_open($template_id))) { $this->delete($template_id); // todo: delete company template as well if exists. set_message("Template deleted successfully"); redirect_browser(self::link_open(false)); } } $data = $_POST; $already_saved = false; if ((int) $template_id > 0 && class_exists('module_company', false)) { module_company::template_handle_save($template_id, $data); // we have to redirect to a company specific version of this template // each company template must have a matching parent template id/key. cannot change keys in company unique config. } // write header/footer html based on uploaded images. // pass uploaded images to the file manager plugin. $template_id = update_insert('template_id', $template_id, 'template', $data); // redirect upon save. set_message('Template saved successfully!'); if (isset($_REQUEST['return']) && $_REQUEST['return']) { redirect_browser($_REQUEST['return']); } redirect_browser($this->link_open($template_id)); exit; }
); this.form.submit();"> <p> <?php _e('If you cannot solve this ticket please assign it to someone else in the drop down list.'); ?> </p> </div> <?php $fieldset_data = array('heading' => array('title' => _l('Unassigned Ticket'), 'type' => 'h3'), 'elements_before' => ob_get_clean()); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); } /** TICKET MESSAGES */ if (!$done_messages) { $tickets_in_reverse = module_config::c('ticket_messages_in_reverse', 0); include module_theme::include_ucm('includes/plugin_ticket/pages/ticket_admin_edit_messages.php'); } hook_handle_callback('layout_column_half', 'end'); echo $action_buttons; ?> </form> <?php if (($last_response_from == 'customer' || $last_response_from == 'autoreply') && $ticket['status_id'] != _TICKET_STATUS_RESOLVED_ID) { // don't do this for resolved tickets // only set the default field if the last respose was from the customer. module_form::set_default_field('new_ticket_message'); }
echo 'col-lg-12'; break; } ?> connectedSortable"> <?php uasort($column_widgets, function ($a, $b) { return $a['page_order'] > $b['page_order']; }); foreach ($column_widgets as $column_widget) { if (isset($column_widget['raw']) && $column_widget['raw']) { $widget_html = $column_widget['content']; } else { // wrap it in a widget block: $fieldset_data = array('id' => 'widg_' . $column_widget['sort_id'], 'heading' => array('type' => 'h3', 'title' => $column_widget['title']), 'class' => 'tableclass tableclass_form tableclass_full', 'elements_before' => $column_widget['content']); $widget_html = module_form::generate_fieldset($fieldset_data); unset($fieldset_data); } $widget_html = preg_replace('#^\\s+<\\w+\\s#imsU', '$0 data-sort-id="' . $column_widget['sort_id'] . '"', $widget_html, 1); echo '<!-- asdf -->' . $widget_html; } ?> </section> <?php } ?> </div> <?php } ?>
echo '<strong>{' . htmlspecialchars($key) . '}</strong>'; if ($val && !is_array($val)) { echo ' ' . htmlspecialchars($val); } echo '</li>'; } } else { } ?> </ul> <br/><br/> </td> </tr> </tbody> </table> <?php $fieldset_data = array('heading' => array('type' => 'h2', 'main' => true, 'title' => 'Edit Template'), 'elements_before' => ob_get_clean()); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); $form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('ignore' => !(module_template::can_i('delete', 'Templates') && (int) $template_id > 0), 'type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . $module->link('template', array('template_id' => false)) . "';"))); echo module_form::generate_form_actions($form_actions); ?> </form>
public static function bulk_handle_delete() { if (isset($_REQUEST['bulk_action']) && isset($_REQUEST['bulk_action']['delete']) && $_REQUEST['bulk_action']['delete'] == 'yes') { // confirm deletion of these tickets: $product_ids = isset($_REQUEST['bulk_operation']) && is_array($_REQUEST['bulk_operation']) ? $_REQUEST['bulk_operation'] : array(); foreach ($product_ids as $product_id => $k) { if ($k != 'yes') { unset($product_ids[$product_id]); } else { $product_ids[$product_id] = self::link_open($product_id, true); } } if (count($product_ids) > 0) { if (module_form::confirm_delete('product_id', "Really delete products: " . implode(', ', $product_ids), self::link_open(false))) { foreach ($product_ids as $product_id => $product_number) { self::delete_product($product_id); } set_message(_l("%s products deleted successfully", count($product_ids))); redirect_browser(self::link_open(false)); } } } }
<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_change_request::can_i('delete', 'Change Requests')) { die('no perms'); } $change_request_id = (int) $_REQUEST['change_request_id']; $change_request = module_change_request::get_change_request($change_request_id); if (!$change_request['website_id']) { die('no linked website'); } $website_data = module_website::get_website($change_request['website_id']); if (module_form::confirm_delete('change_request_id', "Really delete Change Request?", module_website::link_open($change_request['website_id']))) { module_change_request::delete_change_request($_REQUEST['change_request_id']); set_message("Change request deleted successfully"); redirect_browser(module_website::link_open($change_request['website_id'])); }
public static function load_wysiwyg() { if (!self::$load_wysiwyg_done) { self::$load_wysiwyg_done = true; ?> <script type="text/javascript" src="<?php echo _BASE_HREF; ?> includes/plugin_form/js/tinymce4.0.11/jquery.tinymce.min.js"></script> <?php } }