Skip to content

Commit

Permalink
adn: create multiple duplicates; minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer-ilias committed Jan 8, 2024
1 parent c1cdc44 commit 31cad1a
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Customizing/global/lang/ilias_de.lang.local
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ adn#:#adn_card_missing_photo_info#:#Bitte ordnen Sie der/dem Sachkundigen ein Au
adn#:#adn_card_plc_success#:#Die Einstellungen zum Kartendruck-Service konnten erfolgreich validiert werden.
adn#:#adn_card_his_success#:#Die Einstellungen zum HID "Trusted Tag Service" konnten erfolgreich validiert werden.
adn#:#adn_card_plc_con_failed#:#Die Verbindung zum Kartendruck-Service konnte nicht aufgebaut werden. Bitte überprüfen Sie die Einstellungen.
adn#:#adn_certificate_status_all#:#-Alle-
adn#:#adn_certificate_status_0#:#Druckauftrag übermittelt
adn#:#adn_certificate_status_1#:#Druckauftrag bestätigt
adn#:#adn_certificate_status_2#:#Druck in Bearbeitung
Expand All @@ -870,3 +871,6 @@ adn#:#adn_card_order_status#:#Status der Druckaufträge der Sachkundigen-Karten
adn#:#adn_card_order_status_desc#:#Liest den Status der Druckaufträge über den Druck-Webservice aus.
adn#:#adn_card_plc_proxy#:#Proxy
adn#:#adn_card_plc_proxy_info#:#Optionaler "Proxy Host : Port" falls der Aufruf der Druckservice-Url über einen Proxy erfolgen muss.
adn#:#adn_card_create_duplicates#:#Ersatzausfertigungen erstellen
adn#:#adn_card_create_duplicates_sure#:#Sind Sie sicher, dass Sie für die folgenden Sachkundigen Ersatzausfertigungen austellen möchten?
adn#:#adn_duplicates_created#:#Für die ausgewählten Sachkundigen wurden Ersatzausfertigungen bestellt.
2 changes: 1 addition & 1 deletion Services/ADN/AD/classes/class.adnCardAdministrationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected function validatePlcSettings() : void
protected function showToolbar()
{
$this->toolbar->setFormAction($this->ctrl->getFormAction($this));
if ($this->settings->hasNfCSettings()) {
if ($this->settings->hasPlcSettings()) {
$validation_button = $this->ui_factory->button()->standard(
$this->lng->txt('adn_card_plc_button_validation'),
$this->ctrl->getLinkTarget($this, 'validatePlcSettings')
Expand Down
87 changes: 87 additions & 0 deletions Services/ADN/CP/classes/class.adnCertificateGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public function executeCommand()
case "extendCertificate":
case "saveExtension":
case "duplicateCertificate":
case 'createDuplicates':
case "saveDuplicate":
case 'saveDuplicates':
case "generateInvoice":
case "saveInvoice":
case "edit":
Expand Down Expand Up @@ -184,6 +186,18 @@ protected function showCard()
$card = new ilTemplate('tpl.checkcard_inline.html', true, true, 'Services/ADN/Card');

$certificate = new adnCertificate((int) $_GET['ct_id']);
if ($certificate->getDuplicateDates() !== []) {
$dates = [];
foreach ($certificate->getDuplicateDates() as $dt) {
$dates[] = ilDatePresentation::formatDate($dt);
}
$card->setVariable(
'DUPLICATE_CREATED_ON',
$lng->txt('adn_duplicated_on') . ' ' . implode(', ', $dates)
);
}


$professional = new adnCertifiedProfessional($certificate->getCertifiedProfessionalId());

$card->setVariable('TXT_BESCHEINIGUNGSNUMMER', $certificate->getFullCertificateNumber());
Expand Down Expand Up @@ -886,6 +900,79 @@ public function duplicateCertificate(ilPropertyFormGUI $a_form = null)
$tpl->setContent($form->getHTML());
}

public function createDuplicates() : void
{
global $DIC;

$ctrl = $DIC->ctrl();
$lng = $DIC->language();
$tpl = $DIC->ui()->mainTemplate();

$ct_ids = $DIC->http()->request()->getParsedBody()['ct_ids'] ?? [];
if ($ct_ids === []) {
ilUtil::sendFailure($DIC->language()->txt('select_one'), true);
$DIC->ctrl()->redirect($this, 'listCertificates');
}

$confirmation_gui = new ilConfirmationGUI();
$confirmation_gui->setFormAction($ctrl->getFormAction($this));
$confirmation_gui->setHeaderText($lng->txt('adn_card_create_duplicates_sure'));
$confirmation_gui->setCancel($lng->txt('cancel'), 'listCertificates');
$confirmation_gui->setConfirm($lng->txt('adn_card_create_duplicates'), 'saveDuplicates');

foreach ($ct_ids as $certificate_id) {
$certificate = new adnCertificate($certificate_id);
$professional = new adnCertifiedProfessional($certificate->getCertifiedProfessionalId());

$confirmation_gui->addItem(
'ct_ids[]',
$certificate_id,
$certificate->getFullCertificateNumber(). ': ' .
$professional->getLastName() . ', ' . $professional->getFirstName()
);
}
$tpl->setContent($confirmation_gui->getHTML());

}

protected function saveDuplicates()
{
global $DIC;

$ctrl = $DIC->ctrl();
$lng = $DIC->language();
$tpl = $DIC->ui()->mainTemplate();

$ct_ids = $DIC->http()->request()->getParsedBody()['ct_ids'] ?? [];
if ($ct_ids === []) {
ilUtil::sendFailure($DIC->language()->txt('select_one'), true);
$DIC->ctrl()->redirect($this, 'listCertificates');
}

foreach ($ct_ids as $certificate_id) {
$certificate = new adnCertificate($certificate_id);
$has_uuid = $certificate->getUuid() !== '';
if (!$has_uuid) {
$certificate->initUuid();
}
$order = new adnCardCertificateOrderHandler();
try {
$candidate = new adnCertifiedProfessional($certificate->getCertifiedProfessionalId());
$response = $order->send($order->initOrder($candidate, $certificate, true));
} catch (Exception $e) {
if ($has_uuid) {
$certificate->setUuid('');
ilUtil::sendFailure($e->getMessage(), true);
$ctrl->redirect($this, 'listCertificates');
}
}
$certificate->createDuplicate(new ilDate(time(), IL_CAL_UNIX));
$certificate->update();
}
ilUtil::sendSuccess($lng->txt('adn_duplicates_created'));
$ctrl->redirect($this, 'listCertificates');
}

/**
* Save duplicate
*/
Expand Down
48 changes: 47 additions & 1 deletion Services/ADN/CP/classes/class.adnCertificateTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class adnCertificateTableGUI extends ilTable2GUI
// [object] certified professional
protected $cp;

protected $is_admin = false;

/**
* Constructor
*
Expand All @@ -30,7 +32,7 @@ class adnCertificateTableGUI extends ilTable2GUI
*/
public function __construct($a_parent_obj, $a_parent_cmd, $a_cp_id = 0)
{
global $ilCtrl, $lng;
global $ilCtrl, $lng, $DIC;

$this->setId("adn_tbl_crt");

Expand All @@ -45,6 +47,11 @@ public function __construct($a_parent_obj, $a_parent_cmd, $a_cp_id = 0)
// title
if ($this->cp_id == 0) {
$this->setTitle($lng->txt("adn_certificates"));
// adn-patch admin role can create multiple duplicates
$this->is_admin = $DIC->rbac()->review()->isAssigned(
$DIC->user()->getId(),
SYSTEM_ROLE_ID
);
} else {
$this->setTitle($lng->txt("adn_certificates") . ": " .
$this->cp->getLastname() . ", " . $this->cp->getFirstname());
Expand All @@ -55,6 +62,9 @@ public function __construct($a_parent_obj, $a_parent_cmd, $a_cp_id = 0)
$this->user_wmo = adnUser::lookupWmoId();

// table columns
if ($this->is_admin) {
$this->addColumn('', 'cp_id');
}
$this->addColumn($this->lng->txt("adn_number"), "full_nr");
$this->addColumn($this->lng->txt("adn_last_name"), "last_name");
$this->addColumn($this->lng->txt("adn_first_name"), "first_name");
Expand All @@ -73,6 +83,11 @@ public function __construct($a_parent_obj, $a_parent_cmd, $a_cp_id = 0)
$this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
$this->setRowTemplate("tpl.certificates_row.html", "Services/ADN/CP");

if ($this->is_admin) {
$this->enable('select_all');
$this->setSelectAllCheckbox('ct_ids');
$this->addMultiCommand('createDuplicates', $this->lng->txt('adn_card_create_duplicates'));
}
$this->importData();
}

Expand All @@ -86,6 +101,9 @@ protected function importData()
if ($this->cp_id == 0) {
$this->initFilter();
$cert_filter = $this->filter;
if (($cert_filter['card_status'] ?? false) !== false) {
$cert_filter['card_status'] -= 1;
}
} else {
$cert_filter = array("cp_professional_id" => $this->cp_id);
$include_invalids = true;
Expand Down Expand Up @@ -137,6 +155,22 @@ public function initFilter()
);
$first_name->readFromSession();
$this->filter["first_name"] = $first_name->getValue();

$card_status = $this->addFilterItemByMetaType(
'card_status',
self::FILTER_SELECT,
false,
$this->lng->txt('adn_certificate_status')
);
$card_status->setOptions([
0 => $this->lng->txt('adn_certificate_status_all'),
1 => $this->lng->txt('adn_certificate_status_0'),
2 => $this->lng->txt('adn_certificate_status_1'),
3 => $this->lng->txt('adn_certificate_status_2'),
4 => $this->lng->txt('adn_certificate_status_3')
]);
$card_status->readFromSession();
$this->filter['card_status'] = $card_status->getValue();
}

/**
Expand All @@ -152,6 +186,18 @@ protected function fillRow($a_set)
$ilCtrl->setParameter($this->parent_obj, "ct_id", $a_set["id"]);

$cert = new adnCertificate($a_set['id']);
if (
$this->is_admin === true &&
$this->cp_id == 0 &&
$a_set['status'] == adnCertificate::STATUS_VALID &&
$a_set['issued_by_wmo'] == $this->user_wmo
) {
$this->tpl->setVariable('CT_ID', $a_set['id']);
} elseif ($this->is_admin) {
$this->tpl->setCurrentBlock('no_check');
$this->tpl->setVariable('NO_CHECKBOX', '');
$this->tpl->parseCurrentBlock();
}

// details
$this->tpl->setCurrentBlock("action");
Expand Down
10 changes: 10 additions & 0 deletions Services/ADN/CP/templates/default/tpl.certificates_row.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<tr class="{CSS_ROW}">
<!-- BEGIN admin_multi -->
<td class="std small">
<!-- BEGIN with_check -->
<input type="checkbox" name="ct_ids[]" value="{CT_ID}" />
<!-- END with_check -->
<!-- BEGIN no_check -->
{NO_CHECKBOX}
<!-- END no_check -->
</td>
<!-- END admin_multi -->
<td class="std small">
{VAL_NUMBER}
</td>
Expand Down
1 change: 1 addition & 0 deletions Services/ADN/Card/templates/default/less/card.less
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
display: flex;
width: 100%;
width: -moz-available;
width: -ms-available;
position: absolute;
bottom: 0;
.PrimaryLogo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<div class="PageLayout">
<!-- BEGIN duplicate_info -->
{DUPLICATE_CREATED_ON}
<!-- END duplicate_info -->

<div class="PageLayout">
<!-- BEGIN has_card -->
<div class="Card">
<div class="CardHeader">
Expand Down
5 changes: 5 additions & 0 deletions Services/ADN/ES/classes/class.adnCertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ public static function getAllCertificates(
")";
}

if (isset($a_filter['card_status']) && $a_filter['card_status'] !== false) {
$where[] = '( ct.card_status = ' . $ilDB->quote($a_filter['card_status'], ilDBConstants::T_INTEGER) .' AND ' .
'ct.uuid IS NOT NULL ) ';
}

// filter only one professional
if (isset($a_filter["cp_professional_id"]) && $a_filter["cp_professional_id"] > 0) {
$where[] = "ct.cp_professional_id = " .
Expand Down

0 comments on commit 31cad1a

Please sign in to comment.