master_id = $context['master_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; $master_id = $this->master_id; $this->tasks = array(); $this->departments = array(); $this->groups = array(); if(!empty($id)) { $results = common_workflow::get_details($id); $this->id = $results['id']; $this->type = $results['table']; $this->name = $results['name']; $this->description = $results['description']; $this->status = $results['status']; $this->stage = $results['stage']; $this->creator = $results['creator']; $this->date_created = $results['date_created']; $this->submitter = $results['submitter']; $this->date_submitted = $results['date_submitted']; $this->yes_dir = $results['yes_dir']; $this->no_dir = $results['no_dir']; $this->master_id = $results['master_id']; $this->concurrent = $results['concurrent']; $this->main_trigger = $results['main_trigger']; $this->tasks = $results['tasks']; foreach($results['groups'] AS $key => $group) $this->groups[] = $key; foreach($results['departments'] AS $key => $department) $this->departments[] = $key; } if($_POST['Submit'] == "Save") { $this->name = $_POST['name']; $this->description = $_POST['description']; $this->type = $_POST['type']; $this->stage = $_POST['stage']; $this->departments = (count($_POST['departments']) == 0) ? array() : $_POST['departments']; $this->groups = (count($_POST['groups']) == 0) ? array() : $_POST['groups']; $this->yes_dir = $_POST['yes_dir']; $this->no_dir = $_POST['no_dir']; $this->concurrent = $_POST['concurrent']; $this->main_trigger = $_POST['main_trigger']; foreach($_POST AS $key => $value) { $key_arr = explode("_",$key); if($key_arr[0] == "task") { $task_template_id = $key_arr[1]; $this->tasks[] = common_task_templates::get_details($task_template_id); } } } $this->config['main_trigger'] = array("id"=> $id,"value"=> $this->main_trigger, "input_name" => "main_trigger", "name" => "Main Trigger","rule" => ""); $this->config['type'] = array("id"=> $id,"value"=> $this->type, "input_name" => "type", "name" => "Type","rule" => "required"); $this->config['stage'] = array("id"=> $id,"value"=> $this->stage, "input_name" => "stage", "name" => "Stage","rule" => "required|numeric"); $this->config['name'] = array("id"=> $id,"value"=> $this->name, "input_name" => "name", "name" => "Task Name","rule" => "required"); $this->config['description'] = array("id"=> $id,"value"=> $this->description, "input_name" => "description", "name" => "Description","rule" => "required"); $this->config['concurrent'] = array("id"=> $id,"value"=> $this->concurrent, "input_name" => "concurrent", "name" => "Concurency","rule" => "required"); $this->config['yes_dir'] = array("id"=> $id,"value"=> $this->yes_dir, "input_name" => "yes_dir", "name" => "If Yes","rule" => "numeric"); $this->config['no_dir'] = array("id"=> $id,"value"=> $this->no_dir, "input_name" => "no_dir", "name" => "If No","rule" => "numeric"); self::run_validation(); } public function run_validation() { if(empty($this->id)) $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; else $static_function = "validate"; $this->validation['main_trigger'] = validation::$static_function($this->config['main_trigger']); $this->validation['type'] = validation::$static_function($this->config['type']); $this->validation['stage'] = validation::$static_function($this->config['stage']); $this->validation['name'] = validation::$static_function($this->config['name']); $this->validation['description'] = validation::$static_function($this->config['description']); $this->validation['concurrent'] = validation::$static_function($this->config['concurrent']); $this->validation['yes_dir'] = validation::$static_function($this->config['yes_dir']); $this->validation['no_dir'] = validation::$static_function($this->config['no_dir']); $this->reasons = validation::formalise($this->validation); } public function form() { global $database; $id = $this->id; $master_id = $this->master_id; $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"); ?>
Type: "quotes","name" => "Quote"); $types['results'][] = array("id" => "jobs","name" => "Jobs"); $types['chosen'] = $this->type; $options_select = ""; echo forms::input_select($config['type'],$validation['type'],$types,$options_select, false); ?>
   
Action Name: