. */ /** * @brief Action : indexing a file * * Open a modal box to displays the indexing form, make the form checks and loads the result in database. Used by the core (manage_action.php page). * * @file * @author Claire Figueras * @date $date$ * @version $Revision$ * @ingroup apps */ /** * $confirm bool false */ $confirm = false; /** * $etapes array Contains only one etap : form */ $etapes = array('form'); /** * $frm_width Width of the modal (empty) */ $frm_width=''; /** * $frm_height Height of the modal (empty) */ $frm_height = ''; /** * $mode_form Mode of the modal : fullscreen */ $mode_form = 'fullscreen'; //$_SESSION['validStep'] = "ko"; include('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'definition_mail_categories.php'); /** * Returns the indexing form text * * @param $values Array Not used here * @param $path_manage_action String Path to the PHP file called in Ajax * @param $id_action String Action identifier * @param $table String Table * @param $module String Origin of the action * @param $coll_id String Collection identifier * @param $mode String Action mode 'mass' or 'page' * @return String The form content text **/ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode ) { if (preg_match("/MSIE 6.0/", $_SERVER["HTTP_USER_AGENT"])) { $browser_ie = true; $display_value = 'block'; } elseif(preg_match('/msie/i', $_SERVER["HTTP_USER_AGENT"]) && !preg_match('/opera/i', $_SERVER["HTTP_USER_AGENT"]) ) { $browser_ie = true; $display_value = 'block'; } else { $browser_ie = false; $display_value = 'table-row'; } $_SESSION['req'] = "action"; $res_id = $values[0]; $frm_str = ''; require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); require_once("modules".DIRECTORY_SEPARATOR."basket".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_modules_tools.php"); require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_business_app_tools.php"); require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_types.php"); $type = new types(); $sec =new security(); $b = new basket(); $core_tools =new core_tools(); $business = new business_app_tools(); if($_SESSION['features']['show_types_tree'] == 'true') { $doctypes = $type->getArrayStructTypes($coll_id); } else { $doctypes = $type->getArrayTypes($coll_id); } $today = date('d-m-Y'); $tmp = $business->get_titles(); $titles = $tmp['titles']; $default_title = $tmp['default_title']; if($core_tools->is_module_loaded('entities')) { $services = array(); $db = new dbquery(); $db->connect(); if(!empty($_SESSION['user']['redirect_groupbasket'][$_SESSION['current_basket']['id']][$id_action]['entities'])) { $db->query("select entity_id, entity_label, short_label from ".$_SESSION['tablename']['ent_entities']." where entity_id in (".$_SESSION['user']['redirect_groupbasket'][$_SESSION['current_basket']['id']][$id_action]['entities'].") and enabled= 'Y' order by entity_label"); while($res = $db->fetch_object()) { array_push($services, array( 'ID' => $res->entity_id, 'LABEL' => $db->show_string($res->entity_label), 'SHORT_LABEL' => $db->show_string($res->short_label))); } } } if($core_tools->is_module_loaded('physical_archive')) { $boxes = array(); $db = new dbquery(); $db->connect(); $db->query("select arbox_id, title from ".$_SESSION['tablename']['ar_boxes']." where status = 'NEW' order by title"); while($res = $db->fetch_object()) { array_push($boxes, array( 'ID' => $res->arbox_id, 'LABEL' => $db->show_string($res->title))); } } $frm_str .= '
'; $frm_str .= ''; $frm_str .= '
'; $frm_str .= ''; /*** Frame to display the doc ***/ $frm_str .= '
'; $frm_str .= ''; $frm_str .= ''; //$frm_str .= ''; if($_SESSION['origin'] == "scan") { $frm_str .= ''; } else { $frm_str .= ''; } if($core_tools->is_module_loaded('webtwain') && $_SESSION['user']['services']['scan'] === true) //Ajout yck { //$frm_str .= ''; $frm_str .= $core_tools->execute_modules_services($_SESSION['modules_services'], 'index_mlb', 'frame', 'scan', 'webtwain' ); $str_js = 'resize_frame_process(\'modal_'.$id_action.'\', \'scan_iframe\', true, true);'; } $frm_str .= '
'; /*** Extra javascript ***/ $frm_str .= ''; return addslashes($frm_str); } /** * Checks the action form * * @param $form_id String Identifier of the form to check * @param $values Array Values of the form * @return Bool true if no error, false otherwise **/ function check_form($form_id,$values) { //print_r($values); $_SESSION['action_error'] = ''; if(count($values) < 1 || empty($form_id)) { $_SESSION['action_error'] = _FORM_ERROR; return false; } else { //print_r($values); $attach = get_value_fields($values, 'attach'); $coll_id = get_value_fields($values, 'coll_id'); if(!$attach) { $cat_id = get_value_fields($values, 'category_id'); if(!$cat_id) { $_SESSION['action_error'] = _CATEGORY.' '._IS_EMPTY; return false; } $no_error = process_category_check($cat_id, $values); if($no_error == false) { //$_SESSION['action_error'] .= _ERROR_CATEGORY; return false; } if($_SESSION['upfile']['format'] <> 'maarch') { require_once('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_indexing_searching_app.php'); $is = new indexing_searching_app(); $state = $is->is_filetype_allowed($_SESSION['upfile']['format']); if(!$state) { $_SESSION['action_error'].= '
'.$_SESSION['upfile']['format']._FILETYPE.' '._NOT_ALLOWED; return false; } } } else { $title = get_value_fields($values, 'attach_title'); if(!$title || empty($title)) { $_SESSION['action_error'] .= _TITLE.' '._IS_EMPTY.'
'; } $id_doc = get_value_fields($values, 'res_id'); if(!$id_doc || empty($id_doc)) { $_SESSION['action_error'] .= _NUM_GED.' '._IS_EMPTY.'
'; } if(!empty($_SESSION['action_error'])) { return false; } } return check_docserver($coll_id); } } /** * Makes all the checks on the docserver * * @param $cat_id String Collection identifier * @return Bool true if no error, false otherwise **/ function check_docserver($coll_id) { if(isset($_SESSION['indexing']['path_template']) && !empty($_SESSION['indexing']['path_template']) && isset($_SESSION['indexing']['destination_dir']) && !empty($_SESSION['indexing']['destination_dir']) && isset($_SESSION['indexing']['docserver_id']) && !empty($_SESSION['indexing']['docserver_id']) && isset($_SESSION['indexing']['file_destination_name']) && !empty($_SESSION['indexing']['file_destination_name'])) { $_SESSION['action_error'] = _CHECK_FORM_OK; return true; } require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_docserver.php"); $core_tools =new core_tools(); // Gets the available docserver for the collection $docserver = new docserver($_SESSION['tablename']['docservers'], $coll_id,$_SESSION["config"]["lang"]); $error = $docserver->get_error(); if(!empty($error)) { $_SESSION['action_error'] = _DOCSERVER_ERROR.' : '.$error; return false; } if($core_tools->is_module_loaded('templates') && $_SESSION['upfile']['format'] == "maarch") { if(!isset($_SESSION['template_content']) || empty($_SESSION['template_content'])) { $_SESSION['action_error'] = _TEMPLATE.' '._IS_EMPTY; return false; } $path_tmp = $_SESSION['config']['tmppath'].DIRECTORY_SEPARATOR."tmp_file_".$_SESSION['user']['UserId'].".maarch"; $myfile = fopen($path_tmp, "w"); if(!$myfile) { $_SESSION['action_error'] .= _FILE_OPEN_ERROR.'.
'; return false; } fwrite($myfile, $_SESSION['template_content']); fclose($myfile); $_SESSION['upfile']['size'] = filesize($path_tmp); } // Checks the size of the docserver $new_size = $docserver->check_size($_SESSION['upfile']['size'], $_SESSION["config"]["lang"]); if($new_size == 0) { $_SESSION['action_error'] = _DOCSERVER_ERROR.' : '.$docserver->get_error(); return false; } /* if($_SESSION['origin'] == "scan") { $tmp = 'modules/indexing_searching'.DIRECTORY_SEPARATOR.'tmp/'; } else { */ $tmp = $_SESSION['config']['tmppath']; //} $d = dir($tmp); $path_tmp = $d->path; if($_SESSION['origin'] == "scan") { $new_file_name = "tmp_file_".$_SESSION['upfile']['md5'].'.'.strtolower($_SESSION['upfile']['format']); } else { $new_file_name = "tmp_file_".$_SESSION['user']['UserId'].'.'.strtolower($_SESSION['upfile']['format']); } //tmp directory browsing while($entry = $d->read()) { if ($entry == $new_file_name ) { $tmp_source_copy = $path_tmp.$entry; $the_file = $entry; break; } } //Directory closing $d->close(); // Get the new filename $docinfo = $docserver->filename(); if($docserver->get_error() == "txt_error_when_sending_file") { $_SESSION['action_error'] = _FILE_SEND_ERROR; return false; } $destination_rept = $docinfo['destination_rept']; $file_destination_name = $docinfo['file_destination_name']; $docserver_id = $docserver->get_id(); $file_path = $destination_rept.$file_destination_name.".".$_SESSION['upfile']['format']; $tmp_source_copy = str_replace("\\\\","\\",$tmp_source_copy); // Tests the existence of the file if(file_exists( $destination_rept.$file_destination_name.".".$_SESSION['upfile']['format'])) { $_SESSION['action_error'].= _FILE_ALREADY_EXISTS.". "._MORE_INFOS." : ".$_SESSION['config']['adminname']."."; return false; } // Copy the file in the docserver $cp = copy($tmp_source_copy , $destination_rept.$file_destination_name.".".$_SESSION['upfile']['format']); $file_name = $entry; if($cp == false) { $_SESSION['action_error'] .= _DOCSERVER_COPY_ERROR; return false; } else { //Delete tmp file on the tmp directory $delete = unlink($tmp_source_copy); if ($delete == false) { $_SESSION['action_error'] .= _TMP_FILE_DEL_ERROR; return false; } } $_SESSION['indexing']['path_template'] = $docserver->get_path(); $destination_rept = substr($destination_rept,strlen($_SESSION['indexing']['path_template']),4); $_SESSION['indexing']['destination_dir'] = str_replace(DIRECTORY_SEPARATOR,'#',$destination_rept); $docserver->set_size($new_size, $_SESSION['tablename']['docservers']); $_SESSION['indexing']['docserver_id'] = $docserver_id; $_SESSION['indexing']['file_destination_name'] = $file_destination_name; $_SESSION['action_error'] = _CHECK_FORM_OK; return true; } /** * Checks the values of the action form for a given category * * @param $cat_id String Category identifier * @param $values Array Values of the form to check * @return Bool true if no error, false otherwise **/ function process_category_check($cat_id, $values) { // print_r($values); $core = new core_tools(); // If No category : Error if(!isset($_ENV['categories'][$cat_id])) { $_SESSION['action_error'] = _CATEGORY.' '._UNKNOWN.': '.$cat_id; return false; } // Simple cases for($i=0; $iget_indexes( $type_id,$coll_id, 'minimal'); $val_indexes = array(); for($i=0; $icheck_indexes($type_id, $coll_id,$val_indexes ); if(!$test_type) { $_SESSION['action_error'] .= $_SESSION['error']; $_SESSION['error'] = ''; return false; } ///////////////////////// Other cases // Process limit Date $_SESSION['store_process_limit_date'] = ""; if(isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date'])) { $process_limit_date_use_yes = get_value_fields($values, 'process_limit_date_use_yes'); $process_limit_date_use_no = get_value_fields($values, 'process_limit_date_use_no'); if($process_limit_date_use_yes == 'yes') { $_SESSION['store_process_limit_date'] = "ok"; $process_limit_date = get_value_fields($values, 'process_limit_date'); if(trim($process_limit_date) == "" || preg_match($_ENV['date_pattern'], $process_limit_date)== 0) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['label']." "._WRONG_FORMAT.""; return false; } } elseif($process_limit_date_use_no == 'no') { $_SESSION['store_process_limit_date'] = "ko"; } } // Contact if(isset($_ENV['categories'][$cat_id]['other_cases']['contact'])) { $contact_type = get_value_fields($values, 'type_contact_external'); if(!$contact_type) { $contact_type = get_value_fields($values, 'type_contact_internal'); } if(!$contact_type) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['type_contact']['label']." "._MANDATORY.""; return false; } $contact = get_value_fields($values, 'contact'); if($_ENV['categories'][$cat_id]['other_cases']['contact']['mandatory'] == true) { if(empty($contact)) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['contact']['label'].' '._IS_EMPTY; return false; } } if(!empty($contact) ) { if($contact_type == 'external' && preg_match('/\([0-9]+\)$/', $contact) == 0) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['contact']['label']." "._WRONG_FORMAT.".
"._USE_AUTOCOMPLETION; return false; } elseif($contact_type == 'internal' && preg_match('/\((\s|\d|\h|\w)+\)$/i', $contact) == 0) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['contact']['label']." "._WRONG_FORMAT.".
"._USE_AUTOCOMPLETION; return false; } } } if($core->is_module_loaded('entities')) { // Diffusion list if(isset($_ENV['categories'][$cat_id]['other_cases']['diff_list']) && $_ENV['categories'][$cat_id]['other_cases']['diff_list']['mandatory'] == true) { if(empty($_SESSION['indexing']['diff_list']['dest']['user_id']) || !isset($_SESSION['indexing']['diff_list']['dest']['user_id'])) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['diff_list']['label']." "._MANDATORY.""; return false; } } } if($core->is_module_loaded('folder')) { $db = new dbquery(); $db->connect(); $market = get_value_fields($values, 'market'); $project_id = ''; $market_id = ''; if(isset($_ENV['categories'][$cat_id]['other_cases']['market']) && $_ENV['categories'][$cat_id]['other_cases']['market']['mandatory'] == true) { if(empty($market)) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['market']['label'].' '._IS_EMPTY; return false; } } if(!empty($market) ) { if(!preg_match('/\([0-9]+\)$/', $market)) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['market']['label']." "._WRONG_FORMAT.""; return false; } $market_id = str_replace(')', '', substr($market, strrpos($market,'(')+1)); $db->query("select folders_system_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$market_id); if($db->nb_result() == 0) { $_SESSION['action_error'] = _MARKET.' '.$market_id.' '._UNKNOWN; return false; } } $project = get_value_fields($values, 'project'); if(isset($_ENV['categories'][$cat_id]['other_cases']['project']) && $_ENV['categories'][$cat_id]['other_cases']['project']['mandatory'] == true) { if(empty($project)) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['project']['label'].' '._IS_EMPTY; return false; } } if(!empty($project) ) { if(!preg_match('/\([0-9]+\)$/', $project)) { $_SESSION['action_error'] = $_ENV['categories'][$cat_id]['other_cases']['project']['label']." "._WRONG_FORMAT.""; return false; } $project_id = str_replace(')', '', substr($project, strrpos($project,'(')+1)); $db->query("select folders_system_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$project_id); if($db->nb_result() == 0) { $_SESSION['action_error'] = _MARKET.' '.$project_id.' '._UNKNOWN; return false; } } if(!empty($project_id) && !empty($market_id)) { $db->query("select folders_system_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$market_id." and parent_id = ".$project_id); if($db->nb_result() == 0) { $_SESSION['action_error'] = _INCOMPATIBILITY_MARKET_PROJECT; return false; } } if(!empty($type_id ) && (!empty($project_id) || !empty($market_id))) { $foldertype_id = ''; if(!empty($market_id)) { $db->query("select foldertype_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$market_id); } else //!empty($project_id) { $db->query("select foldertype_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$project_id); } $res = $db->fetch_object(); $foldertype_id = $res->foldertype_id; $db->query("select fdl.foldertype_id from ".$_SESSION['tablename']['fold_foldertypes_doctypes_level1']." fdl, ".$_SESSION['tablename']['doctypes']." d where d.doctypes_first_level_id = fdl.doctypes_first_level_id and fdl.foldertype_id = ".$foldertype_id." and d.type_id = ".$type_id); if($db->nb_result() == 0) { $_SESSION['action_error'] .= _ERROR_COMPATIBILITY_FOLDER; return false; } } } if($core->is_module_loaded('physical_archive')) { // Arbox id $box_id = get_value_fields($values, 'arbox_id'); if(isset($_ENV['categories'][$cat_id]['other_cases']['arbox_id']) && $_ENV['categories'][$cat_id]['other_cases']['arbox_id']['mandatory'] == true) { if($box_id == false) { $_SESSION['action_error'] = _NO_BOX_SELECTED.' '; return false; } } if($box_id != false && preg_match('/^[0-9]+$/', $box_id)) { require_once('modules'.DIRECTORY_SEPARATOR.'physical_archive'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'); $physical_archive = new physical_archive(); $pa_return_value = $physical_archive->load_box_db($box_id, $cat_id, $_SESSION['user']['UserId']); if ($pa_return_value == false) { $_SESSION['action_error'] = _ERROR_TO_INDEX_NEW_BATCH_WITH_PHYSICAL_ARCHIVE; return false; } } } //For specific case => chrono number $chrono_out = get_value_fields($values, 'chrono_number'); if(isset($_ENV['categories'][$cat_id]['other_cases']['chrono_number']) && $_ENV['categories'][$cat_id]['other_cases']['arbox_id']['mandatory'] == true) { if($chrono_out == false) { $_SESSION['action_error'] = _NO_CHRONO_NUMBER_DEFINED.' '; return false; } } if($chrono_out != false && preg_match('/^[0-9]+$/', $chrono_out)) { require_once('modules'.DIRECTORY_SEPARATOR.'physical_archive'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'); $physical_archive = new physical_archive(); $pa_return_value = $physical_archive->load_box_db($box_id, $cat_id, $_SESSION['user']['UserId']); if ($pa_return_value == false) { $_SESSION['action_error'] = _ERROR_TO_INDEX_NEW_BATCH_WITH_PHYSICAL_ARCHIVE; return false; } } return true; } /** * Get the value of a given field in the values returned by the form * * @param $values Array Values of the form to check * @param $field String the field * @return String the value, false if the field is not found **/ function get_value_fields($values, $field) { for($i=0; $iretrieve_table_from_coll($coll_id); $ind_coll = $sec->get_ind_collection($coll_id); $table_ext = $_SESSION['collections'][$ind_coll]['extensions'][0]; $query_ext_fields = '('; $query_ext_values = '('; $resource = new resource(); $_SESSION['data'] = array(); // Load in the $_SESSION['data'] minimal indexes array_push($_SESSION['data'], array('column' => "typist", 'value' => $_SESSION['user']['UserId'], 'type' => "string")); array_push($_SESSION['data'], array('column' => "docserver_id", 'value' => $_SESSION['indexing']['docserver_id'], 'type' => "string")); array_push($_SESSION['data'], array('column' => "format", 'value' => $_SESSION['upfile']['format'], 'type' => "string")); array_push($_SESSION['data'], array('column' => "status", 'value' => 'NEW', 'type' => "string")); array_push($_SESSION['data'], array('column' => "offset_doc", 'value' => ' ', 'type' => "string")); array_push($_SESSION['data'], array('column' => "logical_adr", 'value' => ' ', 'type' => "string")); if($_SESSION['origin'] == "scan") { array_push($_SESSION['data'], array('column' => "scan_user", 'value' => $_SESSION['user']['UserId'], 'type' => "string")); array_push($_SESSION['data'], array('column' => "scan_date", 'value' => $req->current_datetime(), 'type' => "function")); } $attach = get_value_fields($values_form, 'attach'); if($attach == false) { $cat_id = get_value_fields($values_form, 'category_id'); $query_ext_fields .= 'category_id,' ; $query_ext_values .= "'".$cat_id."'," ; $_SESSION['origin'] = ""; // Specific indexes : values from the form // Simple cases for($i=0; $i 'none') { if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'res') { array_push($_SESSION['data'], array('column' => $values_form[$i]['ID'], 'value' => $values_form[$i]['VALUE'], 'type' => "integer")); } else if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'coll_ext') { $query_ext_fields .= $values_form[$i]['ID'].','; $query_ext_values .= $values_form[$i]['VALUE'].','; } } else if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['type_field'] == 'string' && $_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] <> 'none') { if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'res') { array_push($_SESSION['data'], array('column' => $values_form[$i]['ID'], 'value' => $db->protect_string_db($values_form[$i]['VALUE']), 'type' => "string")); } else if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'coll_ext') { $query_ext_fields .= $values_form[$i]['ID'].','; $query_ext_values .= "'".$db->protect_string_db($values_form[$i]['VALUE'])."',"; } } else if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['type_field'] == 'date' && $_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] <> 'none') { if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'res') { array_push($_SESSION['data'], array('column' => $values_form[$i]['ID'], 'value' => $db->format_date_db($values_form[$i]['VALUE']), 'type' => "date")); } else if($_ENV['categories'][$cat_id][$values_form[$i]['ID']]['table'] == 'coll_ext') { $query_ext_fields .= $values_form[$i]['ID'].','; $query_ext_values .= "'".$db->format_date_db($values_form[$i]['VALUE'])."',"; } } } ///// Manages the complementary indexes depending on the doctype require_once('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php'); $type = new types(); $type_id = get_value_fields($values_form, 'type_id'); $indexes = $type->get_indexes( $type_id,$coll_id, 'minimal'); $val_indexes = array(); for($i=0; $ifill_data_array($type_id, $coll_id, $val_indexes, $_SESSION['data']); ///////////////////////// Other cases // Process limit Date if(isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date'])) { $process_limit_date = get_value_fields($values_form, 'process_limit_date'); if($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['table'] == 'res') { array_push($_SESSION['data'], array('column' => 'process_limit_date', 'value' => $db->format_date_db($process_limit_date), 'type' => "date")); } else if($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']['table'] == 'coll_ext') { if($_SESSION['store_process_limit_date'] == "ok") { $query_ext_fields .= 'process_limit_date,'; $query_ext_values .= "'".$db->format_date_db($process_limit_date)."',"; } $_SESSION['store_process_limit_date'] = ""; } } // Contact if(isset($_ENV['categories'][$cat_id]['other_cases']['contact'])) { $contact = get_value_fields($values_form, 'contact'); $contact_type = get_value_fields($values_form, 'type_contact_external'); if(!$contact_type) { $contact_type = get_value_fields($values_form, 'type_contact_internal'); } //echo 'contact '.$contact.', type '.$contact_type; $contact_id = str_replace(')', '', substr($contact, strrpos($contact,'(')+1)); if($contact_type == 'internal') { if($cat_id == 'incoming') { $query_ext_fields .= 'exp_user_id,'; $query_ext_values .= "'".$db->protect_string_db($contact_id)."',"; } else if($cat_id == 'outgoing' || $cat_id == 'internal') { $query_ext_fields .= 'dest_user_id,'; $query_ext_values .= "'".$db->protect_string_db($contact_id)."',"; } } elseif($contact_type == 'external') { if($cat_id == 'incoming') { $query_ext_fields .= 'exp_contact_id,'; $query_ext_values .= $contact_id.","; } else if($cat_id == 'outgoing' || $cat_id == 'internal') { $query_ext_fields .= 'dest_contact_id,'; $query_ext_values .= $contact_id.","; } } } if($core->is_module_loaded('folder')) { $market = get_value_fields($values_form, 'market'); $folder_id = ''; if(!empty($market)) { $folder_id = str_replace(')', '', substr($market, strrpos($market,'(')+1)); } else { $project = get_value_fields($values_form, 'project'); $folder_id = str_replace(')', '', substr($project, strrpos($project,'(')+1)); } if(!empty($folder_id)) { array_push($_SESSION['data'], array('column' => 'folders_system_id', 'value' => $folder_id, 'type' => "integer")); } } if($core->is_module_loaded('entities')) { // Diffusion list $load_list_diff = false; if(isset($_ENV['categories'][$cat_id]['other_cases']['diff_list']) ) { if(!empty($_SESSION['indexing']['diff_list']['dest']['user_id']) && isset($_SESSION['indexing']['diff_list']['dest']['user_id'])) { array_push($_SESSION['data'], array('column' => 'dest_user', 'value' => $db->protect_string_db($_SESSION['indexing']['diff_list']['dest']['user_id']), 'type' => "string")); } $load_list_diff = true; } } if($core->is_module_loaded('physical_archive')) { // Arbox_id + Arbatch_id $box_id = get_value_fields($values_form, 'arbox_id'); array_push($_SESSION['data'], array('column' => 'arbox_id', 'value' => $box_id, 'type' => "integer")); require_once('modules'.DIRECTORY_SEPARATOR.'physical_archive'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'); $physical_archive = new physical_archive(); $pa_return_value = $physical_archive->load_box_db($box_id, $cat_id, $_SESSION['user']['UserId']); array_push($_SESSION['data'], array('column' => 'arbatch_id', 'value' => $pa_return_value, 'type' => "integer")); } //print_r($_SESSION['data']); $res_id = $resource->load_into_db($table ,$_SESSION['indexing']['destination_dir'], $_SESSION['indexing']['file_destination_name'].".".$_SESSION['upfile']['format'], $_SESSION['indexing']['path_template'], $_SESSION['indexing']['docserver_id'], $_SESSION['data'], $_SESSION['config']['databasetype']); //echo 'load '.$res_id. " "; if($res_id <> false) { //Create chrono number //###### $c_box_id = get_value_fields($values_form, 'arbox_id'); $c_type_id = get_value_fields($values_form, 'type_id'); $c_entity = get_value_fields($values_form, 'destination'); $c_chrono_out = get_value_fields($values_form, 'chrono_number'); require_once("apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_chrono.php"); $chrono_x = new chrono(); $my_vars = array("entity_id"=>$c_entity, "arbox_id"=>$c_box_id, "type_id"=>$c_type_id, "category_id"=>$cat_id); $my_form = array("chrono_out" => $c_chrono_out); $my_chrono = $chrono_x->generate_chrono($cat_id, $my_vars, $my_form); $query_ext_fields .= 'alt_identifier,'; $query_ext_values .= "'".$db->protect_string_db($my_chrono)."',"; //###### // echo $res_id. " "; $query_ext_fields = preg_replace('/,$/', ',res_id)', $query_ext_fields); $query_ext_values = preg_replace('/,$/', ','.$res_id.')', $query_ext_values); // echo $res_id. " "; $query_ext = " insert into ".$table_ext." ".$query_ext_fields.' values '.$query_ext_values ; // echo $query_ext; $db->connect(); $db->query($query_ext); if($core->is_module_loaded('folder') && !empty($folder_id) && $_SESSION['history']['folderup']) { // echo 'folder '.$res_id. " "; require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['fold_folders'], $folder_id, "UP", _DOC_NUM.$res_id._ADDED_TO_FOLDER, $_SESSION['config']['databasetype'],'apps'); } //$db->show(); if($core->is_module_loaded('entities')) { // echo 'entities '.$res_id. " "; if($load_list_diff) { require_once('modules'.DIRECTORY_SEPARATOR.'entities'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_manage_listdiff.php'); $diff_list = new diffusion_list(); $params = array('mode'=> 'listinstance', 'table' => $_SESSION['tablename']['ent_listinstance'], 'coll_id' => $coll_id, 'res_id' => $res_id, 'user_id' => $_SESSION['user']['UserId']); $diff_list->load_list_db($_SESSION['indexing']['diff_list'], $params); } // echo 'entities '.$res_id. " "; } } else { $_SESSION['action_error'] = _ERROR_RES_ID; return false; } //$_SESSION['indexing'] = array(); unset($_SESSION['upfile']); unset($_SESSION['data']); $_SESSION['action_error'] = _NEW_DOC_ADDED; $_SESSION['indexation'] = true; return array('result' => $res_id.'#', 'history_msg' => '', 'page_result' =>$_SESSION['config']['businessappurl'].'index.php?page=details&dir=indexing_searching&coll_id='.$coll_id.'&id='.$res_id); } else { $title = get_value_fields($values_form, 'attach_title'); $id_doc = get_value_fields($values_form, 'res_id'); array_push($_SESSION['data'], array('column' => "title", 'value' => $db->protect_string_db($title), 'type' => "string")); array_push($_SESSION['data'], array('column' => "res_id_master", 'value' => $id_doc, 'type' => "integer")); array_push($_SESSION['data'], array('column' => "coll_id", 'value' => $db->protect_string_db($coll_id), 'type' => "string")); $res_id = $resource->load_into_db($_SESSION['tablename']['attach_res_attachments'],$_SESSION['indexing']['destination_dir'], $_SESSION['indexing']['file_destination_name'].".".$_SESSION['upfile']['format'], $_SESSION['indexing']['path_template'], $_SESSION['indexing']['docserver_id'], $_SESSION['data'], $_SESSION['config']['databasetype']); if($res_id == false) { $_SESSION['action_error'] = _ERROR_RES_ID; return false; } else { unset($_SESSION['upfile']); unset($_SESSION['data']); $_SESSION['action_error'] = _NEW_ATTACH_ADDED; $_SESSION['indexation'] = true; $msg = ''; if($_SESSION['history']['attachadd'] == "true") { $msg = ucfirst(_DOC_NUM).$res_id.' '._ATTACH_TO_DOC_NUM.$id_doc; } return array('result' => $id_doc.'#', 'history_msg' => $msg, 'page_result' =>$_SESSION['config']['businessappurl'].'index.php?page=details&dir=indexing_searching&coll_id='.$coll_id.'&id='.$id_doc, 'table_dest' => $_SESSION['tablename']['attach_res_attachments'] ); } } } ?>