Commit a52de619 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT dev initiator list if mult enitities for users + add bonus export functions

parent dae69895
......@@ -699,11 +699,11 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $
/****** RECOMMANDE ******/
$frmStr .= '<tr id="reference_number_tr" style="display:none;">';
$frmStr .= '<td ><label for="reference_number" class="form_title" >' ._MONITORING_NUMBER.'</label></td>';
$frmStr .= '<td><label for="reference_number" class="form_title" >' ._MONITORING_NUMBER.'</label></td>';
$frmStr .= '<td>&nbsp;</td>';
$frmStr .= '<td><input type="text" name="reference_number" id="reference_number"/></td>';
$frmStr .= '</tr>';
$frmStr .= '<td class="indexing_field"><input type="text" name="reference_number" id="reference_number"/></td>';
$frmStr .= '</tr>';
/*** Subject ***/
$frmStr .= '<tr id="subject_tr" style="display:' . $displayValue . ';">';
$frmStr .= '<td><label for="subject" class="form_title" >' . _SUBJECT
......@@ -716,6 +716,26 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $
. 'style="display:inline;"><i class="fa fa-star"></i></span>&nbsp;</td>';
$frmStr .= '</tr>';
/*** Initiator ***/
$frmStr .= '<tr id="initiator_tr" style="display:'
. $displayValue . ';">';
$frmStr .= '<td><label for="intitiator" class="form_title" >'
. _INITIATOR . '</label></td>';
$frmStr .= '<td>&nbsp;</td>';
$frmStr .= '<td class="indexing_field">'
. '<select name="initiator" id="initiator">';
foreach ($_SESSION['user']['entities'] as $entity) {
$frmStr .= '<option value="'.$entity['ENTITY_ID'].'">'.$entity['ENTITY_LABEL'].'</option>';
}
$frmStr .= '</select>'
. '</td>';
$frmStr .= '<td><span class="red_asterisk" '
. 'id="process_limit_date_use_mandatory" style="display:inline;"><i class="fa fa-star"></i>'
. '</span>&nbsp;</td>';
$frmStr .= '</tr>';
$frmStr .= '<script>new Chosen($(\'initiator\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
/*** Entities : department + diffusion list ***/
if ($core->is_module_loaded('entities')) {
$frmStr .= '<tr id="department_tr" style="display:' . $displayValue
......@@ -763,7 +783,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $
$frmStr .= '</tr>';
$frmStr .= '<script>new Chosen($(\'destination\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
}
/*** Process limit date ***/
$frmStr .= '<tr id="process_limit_date_use_tr" style="display:'
. $displayValue . ';">';
......@@ -1482,16 +1502,29 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI
}
//store the initiator entity
if (isset($_SESSION['user']['primaryentity']['id'])) {
$initiator = get_value_fields($formValues, 'initiator');
if(!empty($initiator)){
array_push(
$_SESSION['data'],
array(
'column' => 'initiator',
'value' => $_SESSION['user']['primaryentity']['id'],
'value' => $initiator,
'type' => 'string',
)
);
}else{
if (isset($_SESSION['user']['primaryentity']['id'])) {
array_push(
$_SESSION['data'],
array(
'column' => 'initiator',
'value' => $_SESSION['user']['primaryentity']['id'],
'type' => 'string',
)
);
}
}
$status_id = get_value_fields($formValues, 'status');
if(empty($status_id) || $status_id === "") $status_id = 'BAD';
array_push(
......
......@@ -135,11 +135,12 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module
$data = get_general_data($coll_id, $res_id, 'minimal');
$_SESSION['category_id'] = $data['category_id']['value'];
$view = $sec->retrieve_view_from_coll_id($coll_id);
$stmt = $db->query("SELECT alt_identifier, creation_date FROM " . $view . " WHERE res_id = ?", array($res_id));
$stmt = $db->query("SELECT initiator, alt_identifier, creation_date FROM " . $view . " WHERE res_id = ?", array($res_id));
$resChrono = $stmt->fetchObject();
$chrono_number = explode('/', $resChrono->alt_identifier);
$chrono_number = $chrono_number[1];
$creation_date = functions::format_date_db($resChrono->creation_date, false);
$initiator = $resChrono->initiator;
//LAUNCH DOCLOCKER
$docLockerCustomPath = 'apps/maarch_entreprise/actions/docLocker.php';
......@@ -758,6 +759,33 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module
$frm_str .= '<td><span class="red_asterisk" id="subject_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>';
$frm_str .= '</tr>';
/*** Initiator ***/
$frm_str .= '<tr id="initiator_tr" style="display:'
. $displayValue . ';">';
$frm_str .= '<td><label for="intitiator" class="form_title" >'
. _INITIATOR . '</label></td>';
$frm_str .= '<td>&nbsp;</td>';
$frm_str .= '<td class="indexing_field">'
. '<select name="initiator" id="initiator">';
if($initiator) {
$frm_str .= '<optgroup label="Service initiateur actuel">';
$frm_str .= '<option value="'.$initiator.'">'.$ent->getentitylabel($initiator).'</option>';
$frm_str .= '</optgroup>';
}
$frm_str .= '<optgroup label="Autre(s) service(s) disponible">';
foreach ($_SESSION['user']['entities'] as $entity) {
$frm_str .= '<option value="'.$entity['ENTITY_ID'].'">'.$entity['ENTITY_LABEL'].'</option>';
}
$frm_str .= '</optgroup>';
$frm_str .= '</select>'
. '</td>';
$frm_str .= '<td><span class="red_asterisk" '
. 'id="process_limit_date_use_mandatory" style="display:inline;"><i class="fa fa-star"></i>'
. '</span>&nbsp;</td>';
$frm_str .= '</tr>';
$frm_str .= '<script>new Chosen($(\'initiator\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>';
/*** Entities : department + diffusion list ***/
if ($core_tools->is_module_loaded('entities')) {
$_SESSION['validStep'] = "ok";
......@@ -1370,7 +1398,7 @@ function process_category_check($cat_id, $values)
$_SESSION['action_error'] = "La date du courrier doit être antérieure à la date d'arrivée du courrier ";
return false;
}*/
// Process limit Date
$_SESSION['store_process_limit_date'] = "";
if(isset($_ENV['categories'][$cat_id]['other_cases']['process_limit_date']))
......@@ -1798,7 +1826,19 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $co
}
$load_list_diff = true;
}
}
}
//store the initiator entity
$initiator = get_value_fields($values, 'initiator');
if(!empty($initiator)){
$query_res .= ", initiator = ?";
$arrayPDOres = array_merge($arrayPDOres, array($initiator));
}else{
if (isset($_SESSION['user']['primaryentity']['id'])) {
$query_res .= ", initiator = ?";
$arrayPDOres = array_merge($arrayPDOres, array($_SESSION['user']['primaryentity']['id']));
}
}
$query_res = preg_replace('/set ,/', 'set ', $query_res);
//$query_res = substr($query_res, strpos($query_string, ','));
......
......@@ -482,6 +482,55 @@ class ExportFunctions
}
}
function get_category_label($libelle)
{
$query_status = "SELECT category_id FROM res_view_letterbox r WHERE r.res_id = ##res_id## ";
$db = new Database();
$i=0;
foreach($this->object_export as $line_name => $line_value) {
if ($i == 0) {
$line_value->get_category_label = $libelle;
$i++;
continue;
}
$res_id = $line_value->res_id;
$query = str_replace('##res_id##', '?', $query_status);
$stmt = $db->query($query, array($res_id));
$result = $stmt->fetchObject();
$line_value->get_category_label = $_SESSION['coll_categories']['letterbox_coll'][$result->category_id];
}
}
function get_contact_function($libelle)
{
$query_status = "SELECT c.function FROM mlb_coll_ext r LEFT JOIN contacts_v2 c ON c.contact_id = r.dest_contact_id WHERE r.res_id = ##res_id## ";
$db = new Database();
foreach($this->object_export as $line_name => $line_value) {
if ($i == 0) {
$line_value->get_contact_function = $libelle;
$i++;
continue;
}
$res_id = $line_value->res_id;
$query = str_replace('##res_id##', '?', $query_status);
$stmt = $db->query($query, array($res_id));
$result = $stmt->fetchObject();
$line_value->get_contact_function = $result->function;
}
}
function get_entity_dest_short_label($libelle)
{
......@@ -510,6 +559,34 @@ class ExportFunctions
}
}
function get_entity_initiator_short_label($libelle)
{
$query_status = "SELECT initiator FROM res_view_letterbox r WHERE r.res_id = ##res_id## ";
$db = new Database();
require_once("modules/entities/class/class_manage_entities.php");
$entities = new entity();
$i=0;
foreach($this->object_export as $line_name => $line_value) {
if ($i == 0) {
$line_value->get_entity_initiator_short_label = $libelle;
$i++;
continue;
}
$res_id = $line_value->res_id;
$query = str_replace('##res_id##', '?', $query_status);
$stmt = $db->query($query, array($res_id));
$result = $stmt->fetchObject();
$line_value->get_entity_initiator_short_label = $entities->getentityshortlabel($result->initiator);
}
}
function get_signatory_name($libelle)
{
......
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