Commit e0060f11 authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

FEAT #6431 delete left join on res_attachments in res_view_letterbox

parent 074cc3d5
......@@ -89,7 +89,7 @@ array_push(
"contact_firstname", "contact_lastname", "contact_society", "user_lastname",
"user_firstname", "priority", "creation_date", "admission_date", "subject",
"process_limit_date", "entity_label", "dest_user", "category_id", "type_label",
"exp_user_id", "count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "viewed", "address_id"
"address_id", "exp_user_id", "doc_custom_n1 as count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "viewed"
);
if ($core_tools->is_module_loaded("cases") == true) {
......@@ -168,7 +168,7 @@ $extension_icon = '';
if($selectedTemplate <> 'none') $extension_icon = "_big";
$db = new Database();
$addressId = 0;
//Result Array
for ($i=0;$i<count($tab);$i++) {
......@@ -227,6 +227,10 @@ for ($i=0;$i<count($tab);$i++) {
$tab[$i][$j]['hasNotes'] = $stmt->fetchObject();
$tab[$i][$j]['res_multi_contacts'] = $_SESSION['mlb_search_current_res_id'];
}
if ($tab[$i][$j][$value]=="address_id") {
$addressId = $tab[$i][$j]["value"];
$tab[$i][$j]["show"] = false;
}
if ($tab[$i][$j][$value]=="creation_date") {
$tab[$i][$j]["value"]=$core_tools->format_date_db($tab[$i][$j]["value"], false, '', true);
......@@ -349,9 +353,9 @@ for ($i=0;$i<count($tab);$i++) {
}
if ($tab[$i][$j][$value]=="exp_user_id") {
if (empty($contact_lastname) && empty($contact_firstname) && empty($user_lastname) && empty($user_firstname) && !empty($tab[$i][25]['value'])) {
if (empty($contact_lastname) && empty($contact_firstname) && empty($user_lastname) && empty($user_firstname) && !empty($addressId)) {
$query = "SELECT ca.firstname, ca.lastname FROM contact_addresses ca WHERE ca.id = ?";
$arrayPDO = array($tab[$i][25]['value']);
$arrayPDO = array($addressId);
$stmt2 = $db->query($query, $arrayPDO);
$return_contact = $stmt2->fetchObject();
......
......@@ -89,7 +89,7 @@ array_push(
"contact_firstname", "contact_lastname", "contact_society", "user_lastname",
"user_firstname", "priority", "creation_date", "admission_date", "subject",
"process_limit_date", "entity_label", "dest_user", "category_id", "type_label",
"exp_user_id", "count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "address_id","filename"
"address_id", "exp_user_id", "doc_custom_n1 as count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "filename"
);
if ($core_tools->is_module_loaded("cases") == true) {
......@@ -149,7 +149,6 @@ $_SESSION['current_basket']['last_query']['where'] = $where;
$_SESSION['current_basket']['last_query']['arrayPDO'] = $arrayPDO;
$_SESSION['current_basket']['last_query']['orderstr'] = $orderstr;
//$request->show(); exit;
//Templates
$defaultTemplate = 'documents_list_with_attachments';
$selectedTemplate = $list->getTemplate();
......@@ -170,7 +169,7 @@ if($selectedTemplate <> 'none') $extension_icon = "_big";
$db = new Database();
//Result Array
$addressId = 0;
$tabI = count($tab);
for ($i=0;$i<$tabI;$i++) {
......@@ -229,6 +228,10 @@ for ($i=0;$i<$tabI;$i++) {
$tab[$i][$j]['hasNotes'] = $stmt->fetchObject();
$tab[$i][$j]['res_multi_contacts'] = $_SESSION['mlb_search_current_res_id'];
}
if ($tab[$i][$j][$value]=="address_id") {
$addressId = $tab[$i][$j]["value"];
$tab[$i][$j]["show"] = false;
}
if ($tab[$i][$j][$value]=="creation_date") {
$tab[$i][$j]["value"]=$core_tools->format_date_db($tab[$i][$j]["value"], false, '', true);
......@@ -338,9 +341,9 @@ for ($i=0;$i<$tabI;$i++) {
}
if ($tab[$i][$j][$value]=="exp_user_id") {
if (empty($contact_lastname) && empty($contact_firstname) && empty($user_lastname) && empty($user_firstname) && !empty($tab[$i][24]['value'])) {
if (empty($contact_lastname) && empty($contact_firstname) && empty($user_lastname) && empty($user_firstname) && !empty($addressId)) {
$query = "SELECT ca.firstname, ca.lastname FROM contact_addresses ca WHERE ca.id = ?";
$arrayPDO = array($tab[$i][24]['value']);
$arrayPDO = array($addressId);
$stmt2 = $db->query($query, $arrayPDO);
$return_contact = $stmt2->fetchObject();
......
......@@ -229,12 +229,11 @@ if($mode == 'normal') {
array_push($select[$view], "res_id", "res_id as is_labeled", "alt_identifier", "priority", "status", "subject", "category_id as category_img",
"contact_firstname", "contact_lastname", "contact_society",
"user_lastname", "user_firstname", "category_id", "dest_user", "type_label",
"creation_date", "entity_label", "address_id", "exp_user_id", "count_attachment", "is_multicontacts","filename");
"creation_date", "entity_label", "address_id", "exp_user_id", "doc_custom_n1 as count_attachment", "is_multicontacts","filename");
//Cases
if($core_tools->is_module_loaded("cases") == true) {
array_push($select[$view], "case_id", "case_label", "case_description");
}
//Folder
if ($core_tools->is_module_loaded("folder")) {
array_push($select[$view], "folders_system_id", "folder_name");
......@@ -769,7 +768,7 @@ if($mode == 'normal') {
$tab[$i][$j]["value_export"] = $tab[$i][$j]['value'];
$tab[$i][$j]["value"] = $contact->get_contact_information_from_view($_SESSION['mlb_search_current_category_id'], $contact_lastname, $contact_firstname, $contact_society, $user_lastname, $user_firstname);
$tab[$i][$j]["order"]=false;
}
}
}
}
......
......@@ -89,7 +89,7 @@ array_push(
"contact_firstname", "contact_lastname", "contact_society", "user_lastname",
"user_firstname", "priority", "creation_date", 'modification_date', "admission_date", "subject",
"process_limit_date", 'recommendation_limit_date', "entity_label", "dest_user", "category_id", "type_label",
"exp_user_id", "count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "address_id"
"exp_user_id", "doc_custom_n1 as count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "address_id"
);
if ($core_tools->is_module_loaded("cases") == true) {
......
......@@ -281,16 +281,6 @@ if (isset($_REQUEST['id']) && !empty($_REQUEST['id']))
$tab[$i][$j]["value"] = $tab[$i][$j]['value'];
$tab[$i][$j]["order"]="category_id";
}
if($tab[$i][$j][$value]=="count_attachment")
{
$tab[$i][$j]["label"]=_ATTACHMENTS;
$tab[$i][$j]["size"]="12";
$tab[$i][$j]["label_align"]="left";
$tab[$i][$j]["align"]="left";
$tab[$i][$j]["valign"]="bottom";
$tab[$i][$j]["show"]=false;
$tab[$i][$j]["order"]='count_attachment';
}
if($tab[$i][$j][$value]=="case_id" && $core_tools->is_module_loaded("cases") == true)
{
$tab[$i][$j]["label"]=_CASE_NUM;
......
......@@ -100,7 +100,7 @@ abstract class visa_Abstract extends Database
"contact_firstname", "contact_lastname", "contact_society", "user_lastname",
"user_firstname", "priority", "creation_date", "admission_date", "subject",
"process_limit_date", "entity_label", "dest_user", "category_id", "type_label",
"exp_user_id", "count_attachment", "alt_identifier","is_multicontacts", "locker_user_id", "locker_time");
"exp_user_id", "doc_custom_n1 as count_attachment", "alt_identifier","is_multicontacts", "locker_user_id", "locker_time");
$where_tab = array();
......
......@@ -89,7 +89,7 @@ array_push(
"contact_firstname", "contact_lastname", "contact_society", "user_lastname",
"user_firstname", "priority", "creation_date", 'modification_date', "admission_date", "subject",
"process_limit_date", 'recommendation_limit_date', "entity_label", "dest_user", "category_id", "type_label",
"exp_user_id", "count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "address_id", "res_id as signatory_user"
"exp_user_id", "doc_custom_n1 as count_attachment", "alt_identifier", "is_multicontacts", "locker_user_id", "locker_time", "address_id", "res_id as signatory_user"
);
if ($core_tools->is_module_loaded("cases") == true) {
......
......@@ -2581,10 +2581,8 @@ CREATE VIEW res_view_business AS
en.entity_label,
cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
cont.society AS contact_society, list.item_id AS dest_user_from_listinstance, list.viewed,
r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment
r.is_frozen as res_is_frozen
FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_business r
LEFT JOIN (SELECT res_attachments.res_id_master, coll_id, count(res_attachments.res_id_master) AS count_attachment
FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master, coll_id) att ON (r.res_id = att.res_id_master and att.coll_id = 'business_coll')
LEFT JOIN entities en ON ((r.destination)::text = (en.entity_id)::text)
LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id))
LEFT JOIN business_coll_ext busi ON (busi.res_id = r.res_id)
......@@ -2598,100 +2596,196 @@ CREATE VIEW res_view_business AS
-- view for letterbox
-- r.date_current_use,
DROP VIEW IF EXISTS res_view_letterbox;
CREATE VIEW res_view_letterbox AS
SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id, r.policy_id, r.cycle_id,
d.description AS type_label, d.doctypes_first_level_id,
dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
d.doctypes_second_level_id, dsl.doctypes_second_level_label,
dsl.css_style as doctype_second_level_style, r.format, r.typist,
r.creation_date, r.modification_date, r.relation, r.docserver_id, r.folders_system_id,
f.folder_id, f.destination as folder_destination, f.is_frozen as folder_is_frozen, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize,
r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
r.custom_f5 AS doc_custom_f5, f.foldertype_id, ft.foldertype_label,
f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
f.status AS fold_status, f.subject AS fold_subject,
f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
f.creation_date AS fold_creation_date, r.initiator, r.destination,
r.dest_user, r.confidentiality, mlb.category_id, mlb.exp_contact_id, mlb.exp_user_id,
mlb.dest_user_id, mlb.dest_contact_id, mlb.address_id, mlb.nature_id, mlb.alt_identifier,
mlb.admission_date, mlb.answer_type_bitmask, mlb.other_answer_desc,
mlb.sve_start_date, mlb.sve_identifier,
mlb.process_limit_date, mlb.recommendation_limit_date, mlb.closing_date, mlb.alarm1_date, mlb.alarm2_date,
mlb.flag_notif, mlb.flag_alarm1, mlb.flag_alarm2, mlb.is_multicontacts, r.video_user, r.video_time,
r.video_batch, r.subject, r.identifier, r.title, r.priority, mlb.process_notes,
r.locker_user_id, r.locker_time,
ca.case_id, ca.case_label, ca.case_description, en.entity_label, en.entity_type AS entityType,
cont.contact_id AS contact_id,
cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
cont.society AS contact_society, u.lastname AS user_lastname,
u.firstname AS user_firstname, list.item_id AS dest_user_from_listinstance, list.viewed,
r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment
FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl,
(((((((((((ar_batch a RIGHT JOIN res_letterbox r ON ((r.arbatch_id = a.arbatch_id)))
LEFT JOIN (SELECT res_attachments.res_id_master, count(res_attachments.res_id_master) AS count_attachment
FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master) att ON (r.res_id = att.res_id_master))
LEFT JOIN entities en ON (((r.destination)::text = (en.entity_id)::text)))
LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id)))
LEFT JOIN cases_res cr ON ((r.res_id = cr.res_id)))
LEFT JOIN mlb_coll_ext mlb ON ((mlb.res_id = r.res_id)))
LEFT JOIN foldertypes ft ON (((f.foldertype_id = ft.foldertype_id)
AND ((f.status)::text <> 'DEL'::text))))
LEFT JOIN cases ca ON ((cr.case_id = ca.case_id)))
LEFT JOIN contacts_v2 cont ON (((mlb.exp_contact_id = cont.contact_id)
OR (mlb.dest_contact_id = cont.contact_id))))
LEFT JOIN users u ON ((((mlb.exp_user_id)::text = (u.user_id)::text)
OR ((mlb.dest_user_id)::text = (u.user_id)::text))))
LEFT JOIN listinstance list ON (((r.res_id = list.res_id)
AND ((list.item_mode)::text = 'dest'::text))))
WHERE (((r.type_id = d.type_id) AND
(d.doctypes_first_level_id = dfl.doctypes_first_level_id))
AND (d.doctypes_second_level_id = dsl.doctypes_second_level_id));
--view for postindexing
DROP VIEW IF EXISTS view_postindexing;
CREATE VIEW view_postindexing AS
SELECT res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text AS user_name, res_view_letterbox.video_batch, res_view_letterbox.video_time, count(res_view_letterbox.res_id) AS count_documents, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text AS folder_full_label, folders.video_status
FROM res_view_letterbox
LEFT JOIN users ON res_view_letterbox.video_user::text = users.user_id::text
LEFT JOIN folders ON folders.folders_system_id = res_view_letterbox.folders_system_id
WHERE res_view_letterbox.video_batch IS NOT NULL
GROUP BY res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text, res_view_letterbox.video_batch, res_view_letterbox.video_time, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text, folders.video_status;
CREATE OR REPLACE VIEW res_view_letterbox AS
SELECT r.tablename,
r.is_multi_docservers,
r.res_id,
r.type_id,
r.policy_id,
r.cycle_id,
d.description AS type_label,
d.doctypes_first_level_id,
dfl.doctypes_first_level_label,
dfl.css_style AS doctype_first_level_style,
d.doctypes_second_level_id,
dsl.doctypes_second_level_label,
dsl.css_style AS doctype_second_level_style,
r.format,
r.typist,
r.creation_date,
r.modification_date,
r.relation,
r.docserver_id,
r.folders_system_id,
f.folder_id,
f.destination AS folder_destination,
f.is_frozen AS folder_is_frozen,
r.path,
r.filename,
r.fingerprint,
r.offset_doc,
r.filesize,
r.status,
r.work_batch,
r.arbatch_id,
r.arbox_id,
r.page_count,
r.is_paper,
r.doc_date,
r.scan_date,
r.scan_user,
r.scan_location,
r.scan_wkstation,
r.scan_batch,
r.doc_language,
r.description,
r.source,
r.author,
r.reference_number,
r.custom_t1 AS doc_custom_t1,
r.custom_t2 AS doc_custom_t2,
r.custom_t3 AS doc_custom_t3,
r.custom_t4 AS doc_custom_t4,
r.custom_t5 AS doc_custom_t5,
r.custom_t6 AS doc_custom_t6,
r.custom_t7 AS doc_custom_t7,
r.custom_t8 AS doc_custom_t8,
r.custom_t9 AS doc_custom_t9,
r.custom_t10 AS doc_custom_t10,
r.custom_t11 AS doc_custom_t11,
r.custom_t12 AS doc_custom_t12,
r.custom_t13 AS doc_custom_t13,
r.custom_t14 AS doc_custom_t14,
r.custom_t15 AS doc_custom_t15,
r.custom_d1 AS doc_custom_d1,
r.custom_d2 AS doc_custom_d2,
r.custom_d3 AS doc_custom_d3,
r.custom_d4 AS doc_custom_d4,
r.custom_d5 AS doc_custom_d5,
r.custom_d6 AS doc_custom_d6,
r.custom_d7 AS doc_custom_d7,
r.custom_d8 AS doc_custom_d8,
r.custom_d9 AS doc_custom_d9,
r.custom_d10 AS doc_custom_d10,
r.custom_n1 AS doc_custom_n1,
r.custom_n2 AS doc_custom_n2,
r.custom_n3 AS doc_custom_n3,
r.custom_n4 AS doc_custom_n4,
r.custom_n5 AS doc_custom_n5,
r.custom_f1 AS doc_custom_f1,
r.custom_f2 AS doc_custom_f2,
r.custom_f3 AS doc_custom_f3,
r.custom_f4 AS doc_custom_f4,
r.custom_f5 AS doc_custom_f5,
f.foldertype_id,
ft.foldertype_label,
f.custom_t1 AS fold_custom_t1,
f.custom_t2 AS fold_custom_t2,
f.custom_t3 AS fold_custom_t3,
f.custom_t4 AS fold_custom_t4,
f.custom_t5 AS fold_custom_t5,
f.custom_t6 AS fold_custom_t6,
f.custom_t7 AS fold_custom_t7,
f.custom_t8 AS fold_custom_t8,
f.custom_t9 AS fold_custom_t9,
f.custom_t10 AS fold_custom_t10,
f.custom_t11 AS fold_custom_t11,
f.custom_t12 AS fold_custom_t12,
f.custom_t13 AS fold_custom_t13,
f.custom_t14 AS fold_custom_t14,
f.custom_t15 AS fold_custom_t15,
f.custom_d1 AS fold_custom_d1,
f.custom_d2 AS fold_custom_d2,
f.custom_d3 AS fold_custom_d3,
f.custom_d4 AS fold_custom_d4,
f.custom_d5 AS fold_custom_d5,
f.custom_d6 AS fold_custom_d6,
f.custom_d7 AS fold_custom_d7,
f.custom_d8 AS fold_custom_d8,
f.custom_d9 AS fold_custom_d9,
f.custom_d10 AS fold_custom_d10,
f.custom_n1 AS fold_custom_n1,
f.custom_n2 AS fold_custom_n2,
f.custom_n3 AS fold_custom_n3,
f.custom_n4 AS fold_custom_n4,
f.custom_n5 AS fold_custom_n5,
f.custom_f1 AS fold_custom_f1,
f.custom_f2 AS fold_custom_f2,
f.custom_f3 AS fold_custom_f3,
f.custom_f4 AS fold_custom_f4,
f.custom_f5 AS fold_custom_f5,
f.is_complete AS fold_complete,
f.status AS fold_status,
f.subject AS fold_subject,
f.parent_id AS fold_parent_id,
f.folder_level,
f.folder_name,
f.creation_date AS fold_creation_date,
r.initiator,
r.destination,
r.dest_user,
r.confidentiality,
mlb.category_id,
mlb.exp_contact_id,
mlb.exp_user_id,
mlb.dest_user_id,
mlb.dest_contact_id,
mlb.address_id,
mlb.nature_id,
mlb.alt_identifier,
mlb.admission_date,
mlb.answer_type_bitmask,
mlb.other_answer_desc,
mlb.sve_start_date,
mlb.sve_identifier,
mlb.process_limit_date,
mlb.recommendation_limit_date,
mlb.closing_date,
mlb.alarm1_date,
mlb.alarm2_date,
mlb.flag_notif,
mlb.flag_alarm1,
mlb.flag_alarm2,
mlb.is_multicontacts,
r.video_user,
r.video_time,
r.video_batch,
r.subject,
r.identifier,
r.title,
r.priority,
mlb.process_notes,
r.locker_user_id,
r.locker_time,
ca.case_id,
ca.case_label,
ca.case_description,
en.entity_label,
en.entity_type AS entitytype,
cont.contact_id,
cont.firstname AS contact_firstname,
cont.lastname AS contact_lastname,
cont.society AS contact_society,
u.lastname AS user_lastname,
u.firstname AS user_firstname,
list.item_id AS dest_user_from_listinstance,
list.viewed,
r.is_frozen AS res_is_frozen
FROM doctypes d,
doctypes_first_level dfl,
doctypes_second_level dsl,
res_letterbox r
LEFT JOIN entities en ON r.destination::text = en.entity_id::text
LEFT JOIN folders f ON r.folders_system_id = f.folders_system_id
LEFT JOIN cases_res cr ON r.res_id = cr.res_id
LEFT JOIN mlb_coll_ext mlb ON mlb.res_id = r.res_id
LEFT JOIN foldertypes ft ON f.foldertype_id = ft.foldertype_id AND f.status::text <> 'DEL'::text
LEFT JOIN cases ca ON cr.case_id = ca.case_id
LEFT JOIN contacts_v2 cont ON mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id
LEFT JOIN users u ON mlb.exp_user_id::text = u.user_id::text OR mlb.dest_user_id::text = u.user_id::text
LEFT JOIN listinstance list ON r.res_id = list.res_id AND list.item_mode::text = 'dest'::text
WHERE r.type_id = d.type_id AND d.doctypes_first_level_id = dfl.doctypes_first_level_id AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
--views for autofoldering
-- Resource view used to fill af_target, we exclude from res_x the branches already in af_target table
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment