function orph_callback_search_wanted(&$data, $base, $file, $type, $lvl, $opts) { if ($type == 'd') { return true; // recurse all directories, but we don't store namespaces } if (!preg_match("/.*\\.txt\$/", $file)) { // Ignore everything but TXT return true; } // search the body of the file for links // dae mod // orph_Check_InternalLinks(&$data,$base,$file,$type,$lvl,$opts); $this->orph_Check_InternalLinks($data, $base, $file, $type, $lvl, $opts); $eventData = array('data' => &$data, 'file' => $file); trigger_event('PLUGIN_ORPHANS_WANTED_PROCESS_PAGE', $eventData); // get id of this file $id = pathID($file); //check ACL if (auth_quickaclcheck($id) < AUTH_READ) { return false; } // try to avoid making duplicate entries for forms and pages $item =& $data["{$id}"]; if (isset($item)) { // This item already has a member in the array // Note that the file search found it $item['exists'] = true; } else { // Create a new entry $data["{$id}"] = array('exists' => true, 'links' => 0); } return true; }
function addApproval() { global $USERINFO; global $ID; global $INFO; if (!$INFO['exists']) { msg($this->getLang('cannot approve a non-existing revision'), -1); return; } $approvalRevision = $this->helper->getRevision(); $approvals = $this->helper->getApprovals(); if (!isset($approvals[$approvalRevision])) { $approvals[$approvalRevision] = array(); } $approvals[$approvalRevision][$INFO['client']] = array($INFO['client'], $_SERVER['REMOTE_USER'], $USERINFO['mail'], time()); $success = p_set_metadata($ID, array('approval' => $approvals), true, true); if ($success) { msg($this->getLang('version approved'), 1); $data = array(); $data['rev'] = $approvalRevision; $data['id'] = $ID; $data['approver'] = $_SERVER['REMOTE_USER']; $data['approver_info'] = $USERINFO; if ($this->getConf('send_mail_on_approve') && $this->helper->isRevisionApproved($approvalRevision)) { /** @var action_plugin_publish_mail $mail */ $mail = plugin_load('action', 'publish_mail'); $mail->send_approve_mail(); } trigger_event('PLUGIN_PUBLISH_APPROVE', $data); } else { msg($this->getLang('cannot approve error'), -1); } send_redirect(wl($ID, array('rev' => $this->helper->getRevision()), true, '&')); }
public function process() { $assignment_id = $this->input->post('assignment_id'); $assignment = $this->assignment_model->get($assignment_id); $unit = $this->unit_model->get($assignment->unit_id); $order = (object) $this->order_model->get_values($assignment->order_id); $form_data = $this->get_form_data($this->input->post('unit_type_id'), $assignment_id, $this->input->post(), true); $order_type = $this->order_model->get_type_string($order->order_type_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'unit_serial', 'param' => $assignment_id, 'module' => 'miniant')); foreach ($form_data['required'] as $field => $description) { $this->form_validation->set_rules($field, $description, 'trim|required'); } $success = $this->form_validation->run(); if (!$success) { add_message('The form could not be submitted. Please check the errors below', 'danger'); return $this->index($assignment_id); } $unit_id = $this->unit_model->merge_if_serial_exists($form_data['fields'], $assignment_id); if ($unit_id != $assignment->unit_id) { add_message('The serial number you entered matches an existing unit. Please review the details below and answer the questions at the bottom of the form', 'warning'); } trigger_event('unit_serial_entered', 'assignment', $assignment_id, false, 'miniant'); redirect($this->workflow_manager->get_next_url()); }
public function process($assignment_id) { $assignment = (object) $this->assignment_model->get_values($assignment_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => 'installation', 'stage' => 'installation_checklist', 'param' => $assignment_id, 'module' => 'miniant')); trigger_event('installation_tasks_completed', 'assignment', $assignment_id, false, 'miniant'); redirect($this->workflow_manager->get_next_url()); }
function p_close() { $this->doc .= $this->_getLink() . '</p>' . DOKU_LF; if (preg_match('/<p[^>]*>\\s*<!--PN-->.*?(?:<\\/p>)$/', $this->doc)) { $this->PNitemCount--; } else { $eventdata = array('doc' => &$this->doc, 'pid' => $this->_getID()); trigger_event('PLUGIN_PURPLENUMBERS_P_CLOSED', $eventdata); } }
public function create() { $client_id = $this->input->post('client_id'); $address_id = $this->input->post('address_id'); $call_date = human_to_unix($this->input->post('call_date')); $params = compact('client_id', 'call_date', 'address_id'); $order_id = $this->order_model->add($params); trigger_event('create_order', 'order', $order_id, false, 'miniant'); send_json_data(array('order_id' => $order_id)); }
/** * public method to determine whether the cache can be used * * to assist in centralisation of event triggering and calculation of cache statistics, * don't override this function override _useCache() * * @param array $depends array of cache dependencies, support dependecies: * 'age' => max age of the cache in seconds * 'files' => cache must be younger than mtime of each file * (nb. dependency passes if file doesn't exist) * * @return bool true if cache can be used, false otherwise */ public function useCache($depends = array()) { $this->depends = $depends; $this->_addDependencies(); if ($this->_event) { return $this->_stats(trigger_event($this->_event, $this, array($this, '_useCache'))); } else { return $this->_stats($this->_useCache()); } }
public function set_task_status() { $status = $this->input->post('status'); $task_id = $this->input->post('repair_task_id'); $task = $this->repair_task_model->get($task_id); $assignment = $this->assignment_model->get_from_cache($task->assignment_id); $this->repair_task_model->update_task($status, $task_id); if (!$status) { trigger_event('repair_tasks_completed', 'order', $assignment->order_id, true, 'miniant'); } send_json_message('The task was successfully updated'); }
public function process($assignment_id) { // TODO Make sure all required tasks were completed $assignment = $this->assignment_model->get_values($assignment_id); $order = (object) $this->order_model->get_values($assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'postjob_checklist', 'param' => $assignment_id, 'module' => 'miniant')); $next_page_url = $this->workflow_manager->get_next_url(); trigger_event('post-job_complete', 'order', $order->id, false, 'miniant'); redirect($next_page_url); }
public function process_edit() { $technician_time_hours = $this->input->post('technician_time_hours') * 60 * 60; $technician_time_minutes = $this->input->post('technician_time_minutes') * 60; $technician_time = $technician_time_hours + $technician_time_minutes; $invoice_tenancy_id = $this->input->post('invoice_tenancy_id'); $order_id = $this->input->post('order_id'); $abbreviations = $this->input->post('abbreviations'); $this->invoice_tenancy_model->update_abbreviations($invoice_tenancy_id, $abbreviations); $this->invoice_tenancy_model->edit($invoice_tenancy_id, compact('technician_time')); trigger_event('reviewed', 'invoice_tenancies', $invoice_tenancy_id, false, 'miniant'); add_message('Invoice updated'); redirect(base_url() . 'miniant/orders/documents/index/html/' . $order_id); }
public function process() { $assignment_id = $this->input->post('assignment_id'); $order_id = $this->input->post('order_id'); $assignment = $this->assignment_model->get($assignment_id); $order = $this->order_model->get($order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'office_notes', 'param' => $assignment_id, 'module' => 'miniant')); if (user_has_role($this->session->userdata('user_id'), 'Technician')) { trigger_event('office_notes_sighted', 'order', $order_id, false, 'miniant'); } redirect($this->workflow_manager->get_next_url()); }
public function process($assignment_id) { $assignment = $this->assignment_model->get_values($assignment_id); $order = (object) $this->order_model->get_values($assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); if (!$this->files_exist_in_upload_folder($assignment_id) && in_array($order_type, array('Breakdown'))) { add_message('Please upload at least one photo', 'warning'); return $this->index($assignment_id); } $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'unit_photos', 'param' => $assignment_id, 'extra_param' => $type, 'module' => 'miniant')); add_message('Equipment photos were successfully recorded'); trigger_event('unit_photos_uploaded', 'assignment', $assignment_id, false, 'miniant'); redirect($this->workflow_manager->get_next_url()); }
function _finalize() { $this->CallWriter->finalise(); if ($this->status['section']) { $last_call = end($this->calls); array_push($this->calls, array('section_close', array(), $last_call[2])); } if ($this->rewriteBlocks) { $B = new Doku_Handler_Block(); $this->calls = $B->process($this->calls); } trigger_event('PARSER_HANDLER_DONE', $this); array_unshift($this->calls, array('document_start', array(), 0)); $last_call = end($this->calls); array_push($this->calls, array('document_end', array(), $last_call[2])); }
public function get_next_url() { $next_url = parent::get_next_url(); $ci = get_instance(); if (strstr($next_url, 'job_list')) { $assignment_id = $this->current_param; $assignment = $ci->assignment_model->get($assignment_id); $technician_id = $ci->session->userdata('user_id'); $order_technician = $ci->order_technician_model->get(array('order_id' => $assignment->order_id, 'technician_id' => $technician_id), true); $is_technician = user_has_role($ci->session->userdata('user_id'), 'Technician'); if ($is_technician) { trigger_event('is_complete', 'order_technician', $order_technician->id, false, 'miniant'); } } return $next_url; }
/** * Version of the indexer taking into consideration the external tokenizer. * The indexer is only compatible with data written by the same version. * * @triggers INDEXER_VERSION_GET * Plugins that modify what gets indexed should hook this event and * add their version info to the event data like so: * $data[$plugin_name] = $plugin_version; * * @author Tom N Harris <*****@*****.**> * @author Michael Hamann <*****@*****.**> */ function idx_get_version() { static $indexer_version = null; if ($indexer_version == null) { $version = INDEXER_VERSION; // DokuWiki version is included for the convenience of plugins $data = array('dokuwiki' => $version); trigger_event('INDEXER_VERSION_GET', $data, null, false); unset($data['dokuwiki']); // this needs to be first ksort($data); foreach ($data as $plugin => $vers) { $version .= '+' . $plugin . '=' . $vers; } $indexer_version = $version; } return $indexer_version; }
public function test_trigger_event() { $this->load_orders(); $this->load_events(); $this->load_statuses(); $this->load_status_events(); $this->load_document_statuses(); $sr_id = $this->_ci->order_model->add(array()); trigger_event('create_order', 'order', $sr_id); $sr_statuses = $this->_ci->order_model->get_statuses($sr_id); $this->_assert_equals(1, count($sr_statuses)); $this->_assert_equals('DRAFT', reset($sr_statuses)); $sr_statuses = $this->_ci->order_model->get_statuses($sr_id, false); $this->_assert_equals('DRAFT', reset($sr_statuses)->name); trigger_event('allocate_to_technician', 'order', $sr_id); $sr_statuses = $this->_ci->order_model->get_statuses($sr_id); $this->_assert_equals(1, count($sr_statuses)); $this->_assert_equals('ALLOCATED', reset($sr_statuses)); }
function _finalize() { $this->CallWriter->finalise(); if ($this->status['section']) { $last_call = end($this->calls); array_push($this->calls, array('section_close', array(), $last_call[2])); if ($this->status['section_edit_start'] > 1) { // ignore last edit section if there is only one header array_push($this->calls, array('section_edit', array($this->status['section_edit_start'], 0, $this->status['section_edit_level'], $this->status['section_edit_title']), $last_call[2])); } } if ($this->rewriteBlocks) { $B =& new Doku_Handler_Block(); $this->calls = $B->process($this->calls); } trigger_event('PARSER_HANDLER_DONE', $this); array_unshift($this->calls, array('document_start', array(), 0)); $last_call = end($this->calls); array_push($this->calls, array('document_end', array(), $last_call[2])); }
function test_nested_events() { global $EVENT_HANDLER; $firstcount = 0; $secondcount = 0; $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null, function () use(&$firstcount) { $firstcount++; if ($firstcount == 1) { $param = array(); trigger_event('NESTED_EVENT', $param); } }); $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null, function () use(&$secondcount) { $secondcount++; }); $param = array(); trigger_event('NESTED_EVENT', $param); $this->assertEquals(2, $firstcount); $this->assertEquals(2, $secondcount); }
private function show() { global $REV; global $ID; $path = wikiFN($ID); if (file_exists($path) || $REV) { return FALSE; } ob_start(); echo '<h1>Page "' . noNS($ID) . '" Does Not Exist</h1>' . DOKU_LF; echo '<ul><li>Create a:</li>' . DOKU_LF; echo '<ul>' . DOKU_LF; echo '<li><a href="' . wl($ID, array('do' => 'create', 'type' => 'source')) . '">' . 'source file</a></li>' . DOKU_LF; echo '<li><a href="' . wl($ID, array('do' => 'create', 'type' => 'generated')) . '">' . 'generated file</a></li>' . DOKU_LF; echo '<li><a href="' . wl($ID, array('do' => 'edit')) . '">' . 'plain wiki page</a></li>' . DOKU_LF; echo '</ul>' . DOKU_LF; echo '<li>Manage <a href="' . wl($ID, array('do' => 'manage_files')) . '">other files</a></li>' . DOKU_LF; echo '</ul>' . DOKU_LF; trigger_event('TPL_CONTENT_DISPLAY', $html_output, 'ptln'); return TRUE; }
public function process($assignment_id, $type) { $assignment = $this->assignment_model->get_values($assignment_id); $order = (object) $this->order_model->get_values($assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); // $workflows_for_which_photo_are_required = array('Breakdown'); $workflows_for_which_photo_are_required = array(''); if (!$this->files_exist_in_upload_folder($assignment_id, $type) && $type == 'pre-job' && in_array($order_type, $workflows_for_which_photo_are_required)) { add_message('Please upload at least one photo', 'warning'); return $this->index($assignment_id); } $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'photos', 'param' => $assignment_id, 'extra_param' => $type, 'module' => 'miniant')); if ($type == 'pre-job') { trigger_event('prejobsite_photos_uploaded', 'order', $order->id, false, 'miniant'); } else { trigger_event('postjobsite_photos_uploaded', 'order', $order->id, false, 'miniant'); } add_message('Photos were successfully recorded'); redirect($this->workflow_manager->get_next_url()); }
public function process() { require_capability('orders:editunitdetails'); $postdata = $this->input->post(); $order = (object) $this->order_model->get_values($postdata['order_id']); $order_type = $this->order_model->get_type_string($order->order_type_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'location_diagram', 'param' => $postdata['assignment_id'], 'module' => 'miniant')); if (empty($postdata['location_token'])) { add_message('Please enter a location reference # for this unit (like 1 or A)', 'danger'); return $this->index($postdata['assignment_id']); } else { if (empty($order->location_diagram_id)) { add_message('Please draw a location diagram for this job site', 'danger'); return $this->index($postdata['assignment_id']); } else { $this->assignment_model->edit($postdata['assignment_id'], array('location_token' => $postdata['location_token'])); add_message('The location reference # for this unit was successfully recorded', 'success'); } } trigger_event('location_info_recorded', 'assignment', $postdata['assignment_id'], false, 'miniant'); redirect($this->workflow_manager->get_next_url()); }
/** * Initialize the auth system. * * This function is automatically called at the end of init.php * * This used to be the main() of the auth.php * * @todo backend loading maybe should be handled by the class autoloader * @todo maybe split into multiple functions at the XXX marked positions * @triggers AUTH_LOGIN_CHECK * @return bool */ function auth_setup() { global $conf; /* @var auth_basic $auth */ global $auth; /* @var Input $INPUT */ global $INPUT; global $AUTH_ACL; global $lang; $AUTH_ACL = array(); if (!$conf['useacl']) { return false; } // load the the backend auth functions and instantiate the auth object XXX if (@file_exists(DOKU_INC . 'inc/auth/' . $conf['authtype'] . '.class.php')) { require_once DOKU_INC . 'inc/auth/basic.class.php'; require_once DOKU_INC . 'inc/auth/' . $conf['authtype'] . '.class.php'; $auth_class = "auth_" . $conf['authtype']; if (class_exists($auth_class)) { $auth = new $auth_class(); if ($auth->success == false) { // degrade to unauthenticated user unset($auth); auth_logoff(); msg($lang['authtempfail'], -1); } } else { nice_die($lang['authmodfailed']); } } else { nice_die($lang['authmodfailed']); } if (!isset($auth) || !$auth) { return false; } // do the login either by cookie or provided credentials XXX $INPUT->set('http_credentials', false); if (!$conf['rememberme']) { $INPUT->set('r', false); } // handle renamed HTTP_AUTHORIZATION variable (can happen when a fix like // the one presented at // http://www.besthostratings.com/articles/http-auth-php-cgi.html is used // for enabling HTTP authentication with CGI/SuExec) if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) { $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; } // streamline HTTP auth credentials (IIS/rewrite -> mod_php) if (isset($_SERVER['HTTP_AUTHORIZATION'])) { list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); } // if no credentials were given try to use HTTP auth (for SSO) if (!$INPUT->str('u') && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])) { $INPUT->set('u', $_SERVER['PHP_AUTH_USER']); $INPUT->set('p', $_SERVER['PHP_AUTH_PW']); $INPUT->set('http_credentials', true); } // apply cleaning $INPUT->set('u', $auth->cleanUser($INPUT->str('u'))); if ($INPUT->str('authtok')) { // when an authentication token is given, trust the session auth_validateToken($INPUT->str('authtok')); } elseif (!is_null($auth) && $auth->canDo('external')) { // external trust mechanism in place $auth->trustExternal($INPUT->str('u'), $INPUT->str('p'), $INPUT->bool('r')); } else { $evdata = array('user' => $INPUT->str('u'), 'password' => $INPUT->str('p'), 'sticky' => $INPUT->bool('r'), 'silent' => $INPUT->bool('http_credentials')); trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper'); } //load ACL into a global array XXX $AUTH_ACL = auth_loadACL(); return true; }
/** * Quicksearch for pagenames * * By default it only matches the pagename and ignores the * namespace. This can be changed with the second parameter. * The third parameter allows to search in titles as well. * * The function always returns titles as well * * @triggers SEARCH_QUERY_PAGELOOKUP * @author Andreas Gohr <*****@*****.**> * @author Adrian Lang <*****@*****.**> */ function ft_pageLookup($id, $in_ns = false, $in_title = false) { $data = compact('id', 'in_ns', 'in_title'); $data['has_titles'] = true; // for plugin backward compatibility check return trigger_event('SEARCH_QUERY_PAGELOOKUP', $data, '_ft_pageLookup'); }
protected function _add_plugin_usage_data(&$data) { $pluginsData = array(); trigger_event('PLUGIN_POPULARITY_DATA_SETUP', $pluginsData); foreach ($pluginsData as $plugin => $d) { if (is_array($d)) { foreach ($d as $key => $value) { $data['plugin_' . $plugin . '_' . $key] = $value; } } else { $data['plugin_' . $plugin] = $d; } } }
/** * Output a Doku_Form object. * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT * * @author Tom N Harris <*****@*****.**> */ function html_form($name, &$form) { // Safety check in case the caller forgets. $form->endFieldset(); trigger_event('HTML_' . strtoupper($name) . 'FORM_OUTPUT', $form, 'html_form_output', false); }
/** * Renders a list of instruction to the specified output mode * * In the $info array is information from the renderer returned * * @author Harry Fuecks <*****@*****.**> * @author Andreas Gohr <*****@*****.**> */ function p_render($mode, $instructions, &$info) { if (is_null($instructions)) { return ''; } $Renderer =& p_get_renderer($mode); if (is_null($Renderer)) { return null; } $Renderer->reset(); $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); $Renderer->acronyms = getAcronyms(); $Renderer->interwiki = getInterwiki(); // Loop through the instructions foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } //set info array $info = $Renderer->info; // Post process and return the output $data = array($mode, &$Renderer->doc); trigger_event('RENDERER_CONTENT_POSTPROCESS', $data); return $Renderer->doc; }
/** * UTF-8 autoencoding replacement for PHPs mail function * * Email address fields (To, From, Cc, Bcc can contain a textpart and an address * like this: 'Andreas Gohr <*****@*****.**>' - the text part is encoded * automatically. You can seperate receivers by commas. * * @param string $to Receiver of the mail (multiple seperated by commas) * @param string $subject Mailsubject * @param string $body Messagebody * @param string $from Sender address * @param string $cc CarbonCopy receiver (multiple seperated by commas) * @param string $bcc BlindCarbonCopy receiver (multiple seperated by commas) * @param string $headers Additional Headers (seperated by MAILHEADER_EOL * @param string $params Additonal Sendmail params (passed to mail()) * * @author Andreas Gohr <*****@*****.**> * @see mail() */ function mail_send($to, $subject, $body, $from = '', $cc = '', $bcc = '', $headers = null, $params = null) { $message = compact('to', 'subject', 'body', 'from', 'cc', 'bcc', 'headers', 'params'); return trigger_event('MAIL_MESSAGE_SEND', $message, '_mail_send_action'); }
private function getCustomCallPlugins() { if ($this->pluginCustomCalls === null) { $data = array(); trigger_event('RPC_CALL_ADD', $data); $this->pluginCustomCalls = $data; } return $this->pluginCustomCalls; }
/** * Prints the image with a link to the full sized version * * Only allowed in: detail.php * * @triggers TPL_IMG_DISPLAY * @param $maxwidth int - maximal width of the image * @param $maxheight int - maximal height of the image * @param $link bool - link to the orginal size? * @param $params array - additional image attributes * @return mixed Result of TPL_IMG_DISPLAY */ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { global $IMG; global $INPUT; $w = tpl_img_getTag('File.Width'); $h = tpl_img_getTag('File.Height'); //resize to given max values $ratio = 1; if ($w >= $h) { if ($maxwidth && $w >= $maxwidth) { $ratio = $maxwidth / $w; } elseif ($maxheight && $h > $maxheight) { $ratio = $maxheight / $h; } } else { if ($maxheight && $h >= $maxheight) { $ratio = $maxheight / $h; } elseif ($maxwidth && $w > $maxwidth) { $ratio = $maxwidth / $w; } } if ($ratio) { $w = floor($ratio * $w); $h = floor($ratio * $h); } //prepare URLs $url = ml($IMG, array('cache' => $INPUT->str('cache')), true, '&'); $src = ml($IMG, array('cache' => $INPUT->str('cache'), 'w' => $w, 'h' => $h), true, '&'); //prepare attributes $alt = tpl_img_getTag('Simple.Title'); if (is_null($params)) { $p = array(); } else { $p = $params; } if ($w) { $p['width'] = $w; } if ($h) { $p['height'] = $h; } $p['class'] = 'img_detail'; if ($alt) { $p['alt'] = $alt; $p['title'] = $alt; } else { $p['alt'] = ''; } $p['src'] = $src; $data = array('url' => $link ? $url : null, 'params' => $p); return trigger_event('TPL_IMG_DISPLAY', $data, '_tpl_img_action', true); }
public function process() { require_capability('orders:editunitdetails'); $this->load->model('signature_model'); $assignment = $this->assignment_model->get($this->input->post('assignment_id')); $order = $this->order_model->get($assignment->order_id); $technician_id = $this->session->userdata('user_id'); $tenancy_id = $this->input->post('tenancy_id'); $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true); $order_type = $this->order_model->get_type_string($order->order_type_id); $units = $this->get_units($assignment->id, $technician_id, $order->senior_technician_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'signature', 'param' => $assignment->id, 'module' => 'miniant')); $errors = false; $signature = new stdClass(); $signature->first_name = $this->input->post('first_name_' . $tenancy_id); $signature->last_name = $this->input->post('last_name_' . $tenancy_id); $signature->signature_text = $this->input->post('client_signature_' . $tenancy_id); $signature->type_id = $this->signature_model->get_type_id('Invoice tenancy'); $signature->signature_date = time(); if (empty($signature->first_name)) { add_message('Please enter the customer\'s first name before submitting the form', 'danger'); $errors = true; } if (empty($signature->last_name)) { add_message('Please enter the customer\'s last name before submitting the form', 'danger'); $errors = true; } if (empty($signature->signature_text)) { add_message('Please obtain the customer\'s signature before submitting the form', 'danger'); $errors = true; } if ($errors) { return $this->index($assignment->id); } if (!($invoice = $this->invoice_model->get(array('order_id' => $assignment->order_id), true))) { $invoice = new stdClass(); $invoice->order_id = $assignment->order_id; if (!($invoice->id = $this->invoice_model->add($invoice))) { add_message('Could not record the invoice!', 'danger'); return $this->index($assignment->id); } } if (!($invoice_tenancy = $this->invoice_tenancy_model->get(array('invoice_id' => $invoice->id, 'tenancy_id' => $tenancy_id), true))) { $invoice_tenancy = new stdClass(); $invoice_tenancy->invoice_id = $invoice->id; $invoice_tenancy->tenancy_id = $tenancy_id; $invoice_tenancy->system_time = 0; $invoice_tenancy->id = $this->invoice_tenancy_model->add($invoice_tenancy); } $invoice_tenancy->parts_used = array(); if (empty($invoice_tenancy->signature_id)) { if ($signature->id = $this->signature_model->add($signature)) { $this->invoice_tenancy_model->edit($invoice_tenancy->id, array('signature_id' => $signature->id)); } else { add_message('Could not record the signature!', 'danger'); return $this->index($assignment->id); } } // Create SQ if needed, for each assignment that has the WAITING FOR APPROVAL status foreach ($units as $unit) { if ($this->assignment_model->has_statuses($unit->assignment_id, array('REQUIRED PARTS RECORDED', 'SQ APPROVED', 'AWAITING REVIEW'), 'AND')) { $new_servicequote = new stdClass(); $new_servicequote->order_id = $unit->assignment->order_id; $new_servicequote->diagnostic_id = $unit->assignment->diagnostic_id; if (!$this->servicequote_model->get((array) $new_servicequote)) { $this->servicequote_model->add($new_servicequote); } } if ($unit->tenancy_id == $tenancy_id) { $invoice_tenancy->parts_used += $this->part_model->get_parts_used_during_diagnostic($unit->assignment_id); $invoice_tenancy->system_time += $this->order_model->get_total_time($unit->assignment->order_id); } } foreach ($invoice_tenancy->parts_used as $part) { $params = array('invoice_tenancy_id' => $invoice_tenancy->id, 'part_id' => $part->id); if (!$this->invoice_tenancy_part_model->get($params)) { $this->invoice_tenancy_part_model->add($params); } } trigger_event('signed_by_client', 'invoice_tenancy', $invoice_tenancy->id, false, 'miniant'); if ($this->order_model->are_all_tenancies_signed($order->id)) { trigger_event('is_complete', 'order_technician', $order_technician->id, false, 'miniant'); $this->order_time_model->finish_time($assignment->order_id, $technician_id); if ($this->order_technician_model->has_statuses($order_technician->id, array('COMPLETE', 'SIGNED BY CLIENT'), 'AND')) { trigger_event('diagnostics_completed', 'order', $assignment->order_id, false, 'miniant'); add_message('The client signature was recorded, the invoice was generated and will be reviewed shortly by Accounts'); redirect($this->workflow_manager->get_next_url()); } } else { add_message('Please obtain a signature for all the tenancies', 'warning'); return $this->index($assignment->id); } }