public function build_current_procedure_form($podname, $record_id, $record_author) { global $jomiz_dms_settings; global $current_user; $workflow_data = array(); $workflow_data['status'] = ""; $workflow_data['current_step_owner'] = ""; $result = ""; $last_sender_id = -1; if (is_array($record_author)) { $record_author = $record_author["ID"]; } $workflow_data_of_record = dms_workflow::get_workflow_data_of_record($podname, $record_id); $workflow_data_to_display = dms_workflow::display_workflow_data($workflow_data_of_record, $last_sender_id); $workflow_data_to_display = "<br/><div class='row'><div class='col-xs-12'><div id='workflow-data-of-this-record'>{$workflow_data_to_display}</div></div></div>"; $no_procedures_message = '<br/><div class="row"><div class="col-xs-12"><div class="alert alert-info" role="alert">No actions waiting you in the current time.</div></div></div>'; if ($workflow_data_of_record->total() == 0 && $record_author != $current_user->ID) { $workflow_data['status'] = "document-is-free"; $workflow_data['current_step_owner'] = $record_author; $workflow_data['form-to-display'] = $workflow_data_to_display . $no_procedures_message; return $workflow_data; } elseif ($workflow_data_of_record->total() == 0) { $workflow_data['status'] = "document-is-free"; $workflow_data['current_step_owner'] = $record_author; //Get the First Step $params = array(); //$params["join"] = "INNER JOIN $this->podsrel_tablename ON ($this->podsrel_tablename.item_id = t.id AND $this->podsrel_tablename.field_id = $jomiz_dms_settings->dms_workflow_groups_field_id)"; $params["where"] = "pod_name = '{$podname}' AND procedure_type = 'start' AND groups.members.id = {$current_user->ID}"; $current_workflow_steps = pods("jomiz_dms_workflow", $params); if ($current_workflow_steps->total() == 0) { $workflow_data['form-to-display'] = $no_procedures_message; return $workflow_data; } while ($current_workflow_steps->fetch()) { $result = $this->workflow_form_template($current_workflow_steps, $podname, $record_id, $last_sender_id); } } else { $workflow_data['status'] = "document-sealed-to-user"; $workflow_data['current_step_owner'] = -1; //Get the First Step $params = array(); $params["where"] = "pod_name = '{$podname}' AND record_id = {$record_id} AND is_last_step_performed = 1 AND recipient_user.ID = {$current_user->ID}"; $workflow_record_data = pods("jomiz_dms_data_workflow", $params); while ($workflow_record_data->fetch()) { $workflow_id = -1; $workflow_data['current_step_owner'] = $workflow_record_data->field("recipient_user.ID"); if ($workflow_record_data->field("chosen_option_direction") == "next") { $workflow_id = $workflow_record_data->field("workflow_code.procedure_after.id"); } elseif ($workflow_record_data->field("chosen_option_direction") == "back") { $workflow_id = $workflow_record_data->field("workflow_code.procedure_before.id"); } settype($workflow_id, "integer"); $last_sender_id = -1; // Find Last Sender ID $last_sender_params = array(); $last_sender_params['where'] = "pod_name = '{$podname}' AND record_id = {$record_id} AND recipient_user.ID = {$current_user->ID}"; $last_sender_params['limit'] = 1; $last_sender_params['orderby'] = "t.id"; $last_sender_pod = pods("jomiz_dms_data_workflow", $last_sender_params); while ($last_sender_pod->fetch()) { $last_sender_id = $last_sender_pod->field("sender_user.ID"); } if ($workflow_id > 0) { $current_workflow_steps = pods("jomiz_dms_workflow", array("where" => "t.id = {$workflow_id}")); $result = $this->workflow_form_template($current_workflow_steps, $podname, $record_id, $last_sender_id); } } } $workflow_data['form-to-display'] = $workflow_data_to_display . $result; return $workflow_data; }
echo "<div>Error: No Operation.</div>"; return; } switch ($operation) { case 'filter-control': echo dms_api::gui_filter_control(); break; case 'filter-pod': echo dms_api::gui_filter_pod(); break; case 'add-workflow-step': echo dms_api::workflow_save(); break; case 'get-workflow-data-of-record': $last_sender_id = -1; echo dms_workflow::display_workflow_data(null, $last_sender_id); break; case 'upload_file': echo dms_attachments::upload_attachment(); break; case 'get_data': echo dms_api::data_general_pod(); break; case 'attachment-listing': echo dms_attachments::build_table_for_api(); break; case 'delete-attachment': echo dms_attachments::delete_attachment(); break; case 'debug': echo do_debug_problem();