master_id = $context['master_id']; $this->workflow_id = $context['workflow_id']; $this->id = $context['id']; $this->form_type = $context['form_type']; $this->db_name = $context['db_name']; } public function set() { global $database; $id = $this->id; $workflow_id = $this->workflow_id; $this->task_departments = array(); $this->task_groups = array(); $this->approve_groups = array(); $this->approve_departments = array(); $results = common_workflow::get_details($workflow_id); //$this->master_id = $results['master_id']; if((!empty($id)) && (!isset($_POST['Submit']))) { $results = common_task_templates::get_details($id); $this->id = $results['id']; $this->name = $results['name']; $this->description = $results['description']; $this->status = $results['status']; $this->creator = $results['creator']; $this->date_created = $results['date_created']; $this->submitter = $results['submitter']; $this->date_submitted = $results['date_submitted']; $this->allow_approval = $results['allow_approval']; foreach($results['groups'] AS $key => $group) $this->task_groups[] = $key; foreach($results['departments'] AS $key => $department) $this->task_departments[] = $key; foreach($results['approve_groups'] AS $key => $group) $this->approve_groups[] = $key; foreach($results['approve_departments'] AS $key => $department) $this->approve_departments[] = $key; $this->task_stage = $results['stage']; $this->trigger = $results['trigger']; $this->forward_to = $results['forward_to']; $results = common_workflow::get_details($results['workflow_id']); //$this->master_id = $results['master_id']; } if($_POST['Submit'] == "Save") { $this->name = $_POST['task_name']; $this->description = $_POST['task_description']; $this->task_departments = (count($_POST['task_departments']) == 0) ? array() : $_POST['task_departments']; $this->task_groups = (count($_POST['task_groups']) == 0) ? array() : $_POST['task_groups']; $this->approve_departments = (count($_POST['approve_departments']) == 0) ? array() : $_POST['approve_departments']; $this->approve_groups = (count($_POST['approve_groups']) == 0) ? array() : $_POST['approve_groups']; $this->task_stage = $_POST['task_stage']; $this->trigger = $_POST['task_trigger']; $this->forward_to = $_POST['task_forward_to']; $this->allow_approval = $_POST['allow_approval']; } $this->config['task_forward_to'] = array("id"=> $id,"value"=> $this->forward_to, "input_name" => "task_forward_to", "name" => "Forward to","rule" => "numeric"); $this->config['task_stage'] = array("id"=> $id,"value"=> $this->task_stage, "input_name" => "task_stage", "name" => "Stage","rule" => "required|numeric"); $this->config['task_trigger'] = array("id"=> $id,"value"=> $this->trigger, "input_name" => "task_trigger", "name" => "Trigger","rule" => "required|numeric"); $this->config['task_name'] = array("id"=> $id,"value"=> $this->name, "input_name" => "task_name", "name" => "Task Name","rule" => "required"); $this->config['task_description'] = array("id"=> $id,"value"=> $this->description, "input_name" => "task_description", "name" => "Description","rule" => "required"); self::run_validation(); } public function run_validation() { $tid = $this->tid; $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; $this->validation['task_forward_to'] = validation::$static_function($this->config['task_forward_to']); $this->validation['task_stage'] = validation::$static_function($this->config['task_stage']); $this->validation['task_trigger'] = validation::$static_function($this->config['task_trigger']); $this->validation['task_name'] = validation::$static_function($this->config['task_name']); $this->validation['task_description'] = validation::$static_function($this->config['task_description']); $this->reasons = validation::formalise($this->validation); } public function form() { global $database; $form_type = $this->form_type; $table_class = (empty($form_type)) ? "tab_form" : "tab_form_ajax"; $config = $this->config; $validation = $this->validation; $options = array("class" => "medium"); $select_options = array("class" => "medium"); if(empty($form_type)) { ?>
Task Name: