Skip to content
Snippets Groups Projects
Commit 90315f9b authored by Henri Queneau's avatar Henri Queneau
Browse files

FEAT #5289 note template

parent 34c4aa27
No related branches found
No related tags found
No related merge requests found
...@@ -87,11 +87,44 @@ if (isset($datasources['contact'][0]['other_data']) && $datasources['contact'][0 ...@@ -87,11 +87,44 @@ if (isset($datasources['contact'][0]['other_data']) && $datasources['contact'][0
// Notes // Notes
$datasources['notes'] = array(); $datasources['notes'] = array();
$stmt = $dbDatasource->query("SELECT notes.*, users.firstname, users.lastname FROM notes left join users on notes.user_id = users.user_id WHERE coll_id = ? AND identifier = ? ", array($coll_id, $res_id)); $stmt = $dbDatasource->query("SELECT notes.*, users.firstname, users.lastname FROM notes left join users on notes.user_id = users.user_id WHERE coll_id = ? AND identifier = ?", array($coll_id, $res_id));
while($note = $stmt->fetch(PDO::FETCH_ASSOC)) {
$datasources['notes'][] = $note; $countNote = 1;
while ($notes = $stmt->fetchObject()) {
$datasources['notes'][0]['note_text' . $countNote] = $notes->note_text;
$datasources['notes'][0]['date_note' . $countNote] = $notes->date_note;
$countNote++;
} }
$stmt = $dbDatasource->query("SELECT * FROM listinstance WHERE res_id = ? AND difflist_type = ? ORDER BY sequence ASC", [$doc['res_id'], 'VISA_CIRCUIT']);
$datasources['visa']= [];
$countVisa = 1;
while ($visa = $stmt->fetchObject()) {
$stmt2 = $dbDatasource->query("SELECT * FROM users WHERE user_id = ? ", [$visa->item_id]);
$visaContact = $stmt2->fetchObject();
$stmt3 = $dbDatasource->query("SELECT en.entity_id, en.entity_label FROM entities en, users_entities ue WHERE ue.user_id = ? AND primary_entity = ? AND ue.entity_id = en.entity_id", [$visa->item_id, 'Y']);
$visaEntity = $stmt3->fetchObject();
if ($visaContact) {
if ($visa->item_mode == 'sign') {
$datasources['visa'][0]['firstnameSign'] = $visaContact->firstname;
$datasources['visa'][0]['lastnameSign'] = $visaContact->lastname;
$datasources['visa'][0]['entitySign'] = str_replace($visaEntity->entity_id . ': ', '', $visaEntity->entity_label);
} else {
$datasources['visa'][0]['firstname' . $countVisa] = $visaContact->firstname;
$datasources['visa'][0]['lastname' . $countVisa] = $visaContact->lastname;
$datasources['visa'][0]['entity' . $countVisa] = str_replace($visaEntity->entity_id . ': ', '', $visaEntity->entity_label);
$countVisa++;
}
}
}
//sleep(10);
// Attachments // Attachments
$datasources['attachments'] = array(); $datasources['attachments'] = array();
$myAttachment['chrono'] = $chronoAttachment; $myAttachment['chrono'] = $chronoAttachment;
...@@ -152,7 +185,7 @@ while ($avis = $stmt->fetchObject()) { ...@@ -152,7 +185,7 @@ while ($avis = $stmt->fetchObject()) {
$stmt2 = $dbDatasource->query("SELECT * FROM users WHERE user_id = ? ", [$avis->item_id]); $stmt2 = $dbDatasource->query("SELECT * FROM users WHERE user_id = ? ", [$avis->item_id]);
$avisContact = $stmt2->fetchObject(); $avisContact = $stmt2->fetchObject();
$stmt3 = $dbDatasource->query("SELECT en.entity_id, en.entity_label FROM entities en, users_entities ue WHERE ue.user_id = ? AND primary_entity = ? AND ue.entity_id = en.entity_id", [$avis->item_id, 'Y']); $stmt3 = $dbDatasource->query("SELECT en.entity_id, en.entity_label FROM entities en, users_entities ue WHERE ue.user_id = ? AND primary_entity = ? AND ue.entity_id = en.entity_id", [$avis->item_id, 'Y']);
$stmt4 = $dbDatasource->query("SELECT note_text FROM notes WHERE user_id = ? AND identifier = ? AND note_text LIKE ? ORDER BY date_note ASC", [$avis->item_id, $doc['res_id'], '[Avis n°%']); $stmt4 = $dbDatasource->query("SELECT note_text, date_note FROM notes WHERE user_id = ? AND identifier = ? AND note_text LIKE ? ORDER BY date_note ASC", [$avis->item_id, $doc['res_id'], '[Avis n°%']);
$avisEntity = $stmt3->fetchObject(); $avisEntity = $stmt3->fetchObject();
$avisContent = $stmt4->fetchObject(); $avisContent = $stmt4->fetchObject();
...@@ -163,6 +196,7 @@ while ($avis = $stmt->fetchObject()) { ...@@ -163,6 +196,7 @@ while ($avis = $stmt->fetchObject()) {
$datasources['avis'][0]['entity'.$i] = str_replace($avisEntity->entity_id . ': ', '', $avisEntity->entity_label); $datasources['avis'][0]['entity'.$i] = str_replace($avisEntity->entity_id . ': ', '', $avisEntity->entity_label);
if($avisContent){ if($avisContent){
$datasources['avis'][0]['note'.$i] = $avisContent->note_text; $datasources['avis'][0]['note'.$i] = $avisContent->note_text;
$datasources['avis'][0]['date_note'.$i] = $avisContent->note_text;
} }
} }
......
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