function fn_call_requests_addon_install() { // Order statuses $existing_status_id = fn_get_status_id('Y', STATUSES_ORDER); if (!$existing_status_id) { fn_update_status('', array('status' => 'Y', 'is_default' => 'Y', 'description' => __('call_requests.awaiting_call'), 'email_subj' => __('call_requests.awaiting_call'), 'email_header' => __('call_requests.awaiting_call'), 'params' => array('color' => '#cc4125', 'notify' => 'Y', 'notify_department' => 'Y', 'repay' => 'Y', 'inventory' => 'D')), STATUSES_ORDER); } }
function fn_ult_update_status_pre(&$status, &$status_data, &$type, &$lang_code, &$can_continue) { $update_all_vendors = !empty($_REQUEST['update_all_vendors']) ? $_REQUEST['update_all_vendors'] : array(); $data = $status_data; $data['status_id'] = !empty($data['status_id']) ? $data['status_id'] : fn_get_status_id($status, $type); if (!Registry::get('runtime.company_id')) { //if we update both subj and header then we should delete all records. Otherwise we should update necessary fields. if (isset($update_all_vendors['email_subj']) && $update_all_vendors['email_subj'] == 'Y' && isset($update_all_vendors['email_header']) && $update_all_vendors['email_header'] == 'Y') { db_query("DELETE FROM ?:ult_status_descriptions WHERE status_id = ?i AND lang_code = ?s", $data['status_id'], $lang_code); } elseif (isset($update_all_vendors['email_subj']) && $update_all_vendors['email_subj'] == 'Y') { db_query("UPDATE ?:ult_status_descriptions SET email_subj = ?s WHERE status_id = ?i AND lang_code = ?s", $data['email_subj'], $data['status_id'], $lang_code); } elseif (isset($update_all_vendors['email_header']) && $update_all_vendors['email_header'] == 'Y') { db_query("UPDATE ?:ult_status_descriptions SET email_header = ?s WHERE status_id = ?i AND lang_code = ?s", $data['email_header'], $data['status_id'], $lang_code); } } else { // storefronts can't create, only update statuses so status_id is passed in status_data $data['company_id'] = Registry::get('runtime.company_id'); $data['lang_code'] = $lang_code; db_query("REPLACE INTO ?:ult_status_descriptions ?e", $data); $can_continue = false; } }
/** * Deletes status * * @param string $status One-letter status code * @param string $type One-letter status type * @param mixed $is_default True if status is default, false if status is not default, null otherwise * * @return bool True or false depending on whether the status is removed */ function fn_delete_status($status, $type, $is_default = false) { $status_id = fn_get_status_id($status, $type, $is_default); $can_delete = $status_id ? $status : ""; /** * Modifies deleted status parameter * * @param string $status One-letter status code * @param string $type One-letter status type * @param string $can_delete One-letter status code if status can be deleted * @param mixed $is_default True if status is default, false if status is not default, null otherwise * @param int|null $status_id Status identifier */ fn_set_hook('delete_status_pre', $status, $type, $can_delete, $is_default, $status_id); if (!empty($can_delete)) { fn_delete_status_by_id($status_id); } /** * Performs additional actions after status removal * * @param string $status One-letter status code * @param string $type One-letter status type * @param string $can_delete One-letter status code if status can be deleted * @param mixed $is_default True if status is default, false if status is not default, null otherwise * @param int|null $status_id Status identifier */ fn_set_hook('delete_status_post', $status, $type, $can_delete, $is_default, $status_id); return !empty($can_delete) ? true : false; }
/** * Gets parameter value of the status * * @param string $status Status code * @param string $param Parameter name * @param string $type Status type (order type defualt) * @return string Parameter value */ function fn_get_status_param_value($status, $param, $type = STATUSES_ORDER) { $status_id = fn_get_status_id($status, $type); return db_get_field("SELECT value FROM ?:status_data WHERE status_id = ?i AND param = ?s", $status_id, $param); }