Skip to content

Commit

Permalink
Merge pull request #1350 from evarisk-theo/add_edit_next_control_date
Browse files Browse the repository at this point in the history
#1338 [Control] add: edit next control date
  • Loading branch information
nicolas-eoxia authored Jul 5, 2023
2 parents 929676d + f8e2afe commit 94c1083
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion class/control.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Control extends SaturneObject
'date_creation' => ['type' => 'datetime', 'label' => 'ControlDate', 'enabled' => 1, 'position' => 40, 'notnull' => 1, 'visible' => 5, 'positioncard' => 10],
'tms' => ['type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => 0],
'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 0, 'index' => 0],
'next_control_date' => ['type' => 'datetime', 'label' => 'NextControlDate', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 5],
'next_control_date' => ['type' => 'date', 'label' => 'NextControlDate', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 5],
'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 5, 'index' => 1, 'default' => 0, 'arrayofkeyval' => ['0' => 'Draft', 1 => 'Validated', '2' => 'Locked']],
'note_public' => ['type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 0],
'note_private' => ['type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0],
Expand Down
3 changes: 2 additions & 1 deletion langs/fr_FR/dolismq.lang
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ ControlReminderFrequencyDescription = Choisir la fréquence de rappel d'év
ControlReminderType = Type de rappel d'évènement de contrôle
ControlReminderTypeDescription = Choisir le type de rappel d'évènement de contrôle <br> (par défaut : navigateur)
controlled = contrôlé(e)

NextControlDateUpdated = La date de prochain contrôle a été mise à jour
ErrorUpdatingNextControlDate = La date de prochain contrôle n'a pas pu être mise à jour


#
Expand Down
41 changes: 40 additions & 1 deletion view/control/control_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,24 @@
exit;
}

if ($action == 'save_next_control_date') {
$day = GETPOST('reday');
$month = GETPOST('remonth');
$year = GETPOST('reyear');

$object->next_control_date = dol_mktime(0, 0, 0, $month, $day, $year);

$result = $object->update($user);

if ($result > 0) {
setEventMessages($langs->trans('NextControlDateUpdated'), []);
} else {
setEventMessages($langs->trans('ErrorUpdatingNextControlDate'), [], 'errors');
}
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $id);
exit;
}

// Actions builddoc, forcebuilddoc, remove_file.
require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php';

Expand Down Expand Up @@ -682,6 +700,28 @@

include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';

if ($action != 'edit_next_control_date') :
?>
<script>
let pencil = ' <a href="'+ window.location.href + '&action=edit_next_control_date' +'" <span class="fas fa-pencil-alt" style="color: #ccc"></span></a>'
$('.valuefield.fieldname_next_control_date').append(pencil)
</script>
<?php
else :
$dateSelector = '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">';
$dateSelector .= '<input hidden name="action" value="save_next_control_date">';
$dateSelector .= '<input hidden name="token" value="'. newToken() .'">';
$dateSelector .= $form->selectDate($object->next_control_date, 're', 0, 0, 1, '', 1, 1);
$dateSelector .= '<button type="submit" class="butAction" id="saveNextControlDate"> <i class="fas fa-save"></i>' . ' ' . $langs->trans('Save') . '</button type=submit>';
$dateSelector .= '</form>';
?>
<script>
$('.valuefield.fieldname_next_control_date').html(<?php echo json_encode($dateSelector) ?>)
$('.valuefield.fieldname_next_control_date').append(<?php echo json_encode($saveButton) ?>)
</script>
<?php
endif;

// Categories
if ($conf->categorie->enabled) {
print '<tr><td class="valignmiddle">' . $langs->trans('Categories') . '</td>';
Expand Down Expand Up @@ -714,7 +754,6 @@
print '</tr>';
}


$object->fetchObjectLinked('', '', $object->id, 'dolismq_control', 'OR', 1, 'sourcetype', 0);

foreach($elementArray as $linkableElementType => $linkableElement) {
Expand Down

0 comments on commit 94c1083

Please sign in to comment.