diff --git a/modules/attachments/get_chrono_attachment.php b/modules/attachments/get_chrono_attachment.php index c7f2fee6f98c00b607a45837d92197f256008bf2..ffc80ca055e9518ae3119960c16885a0c217d2cf 100755 --- a/modules/attachments/get_chrono_attachment.php +++ b/modules/attachments/get_chrono_attachment.php @@ -17,17 +17,11 @@ require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_secur $core = new core_tools(); $core->test_user(); $db = new Database(); -$sec = new security(); -$view = $sec->retrieve_view_from_coll_id($_SESSION['collection_id_choice']); -if(empty($view)) -{ - $view = $sec->retrieve_table_from_coll($_SESSION['collection_id_choice']); -} $index = $_REQUEST['index']; //RETRIEVE CATEGORY OF DOCUMENT -$stmt = $db->query("SELECT category_id FROM ".$view." WHERE res_id = ? ", array($_SESSION['doc_id'])); +$stmt = $db->query("SELECT category_id FROM mlb_coll_ext WHERE res_id = ? ", array($_SESSION['doc_id'])); $resMaster = $stmt->fetchObject(); $category_id = $resMaster->category_id; @@ -35,11 +29,10 @@ $nb_attachment = 0; // Check if reponse project was already attached to this outgoing document. if ($category_id == "outgoing") { - $stmt = $db->query("SELECT res_id FROM res_view_attachments WHERE res_id_master = ? and (attachment_type = 'response_project' or attachment_type = 'outgoing_mail') and status <> 'DEL' and status <> 'OBS'" - ,array($_SESSION['doc_id'])); + $stmt = $db->query("SELECT res_id FROM res_view_attachments WHERE res_id_master = ? and (attachment_type = 'response_project' or attachment_type = 'outgoing_mail') and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id'])); $nb_attachment = $stmt->rowCount(); } -if ($category_id == "incoming" || $category_id == 'attachment' || ($category_id == "outgoing" && $nb_attachment > 0) || (isset($_POST['type_id']) && $_POST['type_id'] == 'attachment')){ +if ($category_id == "incoming" || $category_id == 'attachment' || ($category_id == "outgoing" && $nb_attachment > 0) || (isset($_POST['type_id']) && $_POST['type_id'] == 'attachment')) { if (isset($_SESSION['save_chrono_number']) && $_SESSION['save_chrono_number'][$index] <> "") { echo "{status: 1, chronoNB: '".$_SESSION['save_chrono_number'][$index]."'}"; } else { @@ -54,9 +47,8 @@ if ($category_id == "incoming" || $category_id == 'attachment' || ($category_id $_SESSION['save_chrono_number'][$index] = $myChrono; echo "{status: 1, chronoNB: '".functions::xssafe($myChrono)."'}"; } -} else if ($category_id == "outgoing" && $nb_attachment == 0) { +} elseif ($category_id == "outgoing" && $nb_attachment == 0) { $stmt = $db->query("SELECT alt_identifier FROM ".$view." WHERE res_id = ?", array($_SESSION['doc_id'])); $chronoMaster = $stmt->fetchObject(); echo "{status: 1, chronoNB: '".functions::xssafe($chronoMaster->alt_identifier)."'}"; } - diff --git a/modules/attachments/get_other_chrono_attachment.php b/modules/attachments/get_other_chrono_attachment.php index 802c4c9357f7f769845e61dc4d2240dafebce1ef..0f86865b2bccb94d723fa101a87345cc1b34ed95 100755 --- a/modules/attachments/get_other_chrono_attachment.php +++ b/modules/attachments/get_other_chrono_attachment.php @@ -1,25 +1,10 @@ <?php -/* -* Copyright 2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - /** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. +* * @brief Other chrono for attachments * * Open a modal box to displays the indexing form, make the form checks and loads @@ -32,47 +17,40 @@ * @ingroup apps */ - require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php'; - require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_chrono.php'; - require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); +require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php'; +require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] + . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_chrono.php'; +require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); - $core = new core_tools(); - $core->test_user(); - $db = new Database(); - $sec = new security(); +$core = new core_tools(); +$core->test_user(); +$db = new Database(); - $array_attachment_types_get_chrono = "'".implode("','", $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']])."'"; - $stmt = $db->query("SELECT distinct identifier FROM res_view_attachments WHERE res_id_master = ? and attachment_type IN (".$array_attachment_types_get_chrono.") and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id'])); - - $listIdentifier = array(); +$array_attachment_types_get_chrono = "'".implode("','", $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']])."'"; +$stmt = $db->query("SELECT distinct identifier FROM res_view_attachments WHERE res_id_master = ? and attachment_type IN (".$array_attachment_types_get_chrono.") and status <> 'DEL' and status <> 'OBS'", array($_SESSION['doc_id'])); - while ($res = $stmt->fetchObject()) { - array_push($listIdentifier,$res->identifier); - } +$listIdentifier = array(); - $view = $sec->retrieve_view_from_coll_id($_SESSION['collection_id_choice']); - if(empty($view)) - { - $view = $sec->retrieve_table_from_coll($_SESSION['collection_id_choice']); - } +while ($res = $stmt->fetchObject()) { + array_push($listIdentifier, $res->identifier); +} - $stmt = $db->query("SELECT category_id, alt_identifier FROM ".$view." WHERE res_id = ? ", array($_SESSION['doc_id'])); - $res = $stmt->fetchObject(); +$stmt = $db->query("SELECT category_id, alt_identifier FROM mlb_coll_ext WHERE res_id = ? ", array($_SESSION['doc_id'])); +$res = $stmt->fetchObject(); - $category_id = $res->category_id; +$category_id = $res->category_id; - if ($category_id == "outgoing" && $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']] == "response_project") { - array_push($listIdentifier,$res->alt_identifier); - } +if ($category_id == "outgoing" && $_SESSION['attachment_types_get_chrono'][$_REQUEST['type_id']] == "response_project") { + array_push($listIdentifier, $res->alt_identifier); +} - $countIdentifier = count($listIdentifier); - $listChrono .= '<option value="">Sélectionner le numéro chrono</option>'; +$countIdentifier = count($listIdentifier); +$listChrono .= '<option value="">Sélectionner le numéro chrono</option>'; - for ($cptsIdentifier = 0;$cptsIdentifier < $countIdentifier;$cptsIdentifier++) { - $listChrono .= '<option value="'.functions::show_string($listIdentifier[$cptsIdentifier]).'">' - . functions::show_string($listIdentifier[$cptsIdentifier]) - . '</option>'; - } +for ($cptsIdentifier = 0; $cptsIdentifier < $countIdentifier; $cptsIdentifier++) { + $listChrono .= '<option value="'.functions::show_string($listIdentifier[$cptsIdentifier]).'">' + . functions::show_string($listIdentifier[$cptsIdentifier]) + . '</option>'; +} - echo "{status: 1, chronoList: '".$listChrono."'}"; +echo "{status: 1, chronoList: '".$listChrono."'}";