Skip to content
Snippets Groups Projects
Verified Commit aa643fcd authored by Damien's avatar Damien
Browse files

FEAT #8657 Chrono

parent df8ff6e9
No related branches found
No related tags found
No related merge requests found
......@@ -1949,6 +1949,7 @@ function initSenderRecipientAutocomplete() {
templateValue: "{{otherInfo}}",
minLength: 3,
dynamic: true,
filter: false,
source: {
ajax: function (query) {
return {
......
......@@ -371,6 +371,17 @@ class ExportFunctions
$this->object_export->{$this->pos}->get_tags = implode(' ## ', $arr_tags);
}
public function get_contact_type($libelle, $res_id)
{
$db = new Database();
$query = 'SELECT ct.label from contacts_v2 cont LEFT JOIN mlb_coll_ext mlb ON (mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id) LEFT JOIN contact_types ct ON ct.id = cont.contact_type WHERE mlb.res_id = ?';
$stmt = $db->query($query, array($res_id));
$result = $stmt->fetchObject();
$this->object_export->{$this->pos}->get_contact_type = $result->label;
}
public function get_contact_civility($libelle, $res_id)
{
$db = new Database();
......
......@@ -183,40 +183,41 @@ class StoreController
ValidatorModel::stringType($aArgs, ['docserver_id', 'filename', 'format', 'path', 'fingerprint', 'status']);
ValidatorModel::intVal($aArgs, ['filesize']);
$typistFound = false;
$processLimitDateFound = false;
foreach ($aArgs as $key => $value) {
if ($key == 'typist') {
$typistFound = true;
} elseif ($key == 'process_limit_date') {
$processLimitDateFound = true;
} elseif ($key == 'exp_contact_id' && !is_numeric($value)) {
$mail = explode('<', str_replace('>', '', $value));
$contact = ContactModel::getByEmail(['email' => $mail[count($mail) - 1], 'select' => ['contacts_v2.contact_id']]);
if (!empty($contact['contact_id'])) {
$aArgs['exp_contact_id'] = $contact['contact_id'];
} else {
$aArgs['exp_contact_id'] = 0;
}
} elseif ($key == 'address_id' && !is_numeric($value)) {
$mail = explode('<', str_replace('>', '', $value));
$contact = ContactModel::getByEmail(['email' => $mail[count($mail) - 1], 'select' => ['contact_addresses.id']]);
if (!empty($contact['id'])) {
$aArgs['address_id'] = $contact['id'];
} else {
$aArgs['address_id'] = 0;
}
}
if (empty($aArgs['typist'])) {
$aArgs['typist'] = 'auto';
}
if (!$typistFound) {
$aArgs['typist'] = 'auto';
unset($aArgs['alt_identifier']);
if (!empty($aArgs['chrono'])) {
$aArgs['alt_identifier'] = ChronoModel::getChrono(['id' => $aArgs['category_id'], 'entityId' => $aArgs['destination'], 'typeId' => $aArgs['type_id']]);
}
if (!$processLimitDateFound) {
unset($aArgs['chrono']);
if (empty($aArgs['process_limit_date'])) {
$processLimitDate = ResModel::getStoredProcessLimitDate(['typeId' => $aArgs['type_id'], 'admissionDate' => $aArgs['admission_date']]);
$aArgs['process_limit_date'] = $processLimitDate;
}
if (!empty($aArgs['exp_contact_id']) && !is_numeric($aArgs['exp_contact_id'])) {
$mail = explode('<', str_replace('>', '', $aArgs['exp_contact_id']));
$contact = ContactModel::getByEmail(['email' => $mail[count($mail) - 1], 'select' => ['contacts_v2.contact_id']]);
if (!empty($contact['contact_id'])) {
$aArgs['exp_contact_id'] = $contact['contact_id'];
} else {
$aArgs['exp_contact_id'] = 0;
}
}
if (!empty($aArgs['address_id']) && !is_numeric($aArgs['address_id'])) {
$mail = explode('<', str_replace('>', '', $aArgs['address_id']));
$contact = ContactModel::getByEmail(['email' => $mail[count($mail) - 1], 'select' => ['contact_addresses.id']]);
if (!empty($contact['id'])) {
$aArgs['address_id'] = $contact['id'];
} else {
$aArgs['address_id'] = 0;
}
}
$aArgs['creation_date'] = 'CURRENT_TIMESTAMP';
return $aArgs;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment