Skip to content

Commit

Permalink
Merge pull request #335 from evarisk-theo/add_company_stamp_and_logo
Browse files Browse the repository at this point in the history
#319 #332 [CompletionCertificate] fix: company logo & stamp
  • Loading branch information
evarisk-theo authored Jun 26, 2023
2 parents 7e7e93e + d2d0f22 commit 1ca3669
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';

require_once __DIR__ . '/modules_trainingsessiondocument.php';
require_once __DIR__ . '/mod_attendancesheetdocument_standard.php';
Expand Down Expand Up @@ -296,12 +297,7 @@ public function write_file(SessionDocument $objectDocument, Translate $outputlan
}

$tmparray['mycompany_name'] = $conf->global->MAIN_INFO_SOCIETE_NOM;
$tmparray['address'] = $conf->global->MAIN_INFO_SOCIETE_ADDRESS;
$tmparray['declaration_number'] = $conf->global->MAIN_INFO_SOCIETE_TRAINING_ORGANIZATION_NUMBER;
$tmparray['society_phone'] = $conf->global->MAIN_INFO_SOCIETE_TEL;
$tmparray['society_siret'] = $conf->global->MAIN_INFO_SIRET;
$tmparray['society_mail'] = $conf->global->MAIN_INFO_SOCIETE_MAIL;
$tmparray['society_website'] = $conf->global->MAIN_INFO_SOCIETE_WEB;

if (!empty($object->fk_contrat)) {
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';

require_once __DIR__ . '/modules_trainingsessiondocument.php';
require_once __DIR__ . '/mod_completioncertificatedocument_standard.php';
Expand Down Expand Up @@ -285,8 +286,8 @@ public function write_file(SessionDocument $objectDocument, Translate $outputlan

//Define substitution array
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
// $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_soc['mycompany_logo'] = preg_replace('/_small/', '_mini', $array_soc['mycompany_logo']);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_soc['mycompany_logo'] = preg_replace('/_small/', '_mini', $array_soc['mycompany_logo']);

$tmparray = array_merge($substitutionarray, $array_soc);
complete_substitutions_array($tmparray, $outputlangs, $object);
Expand All @@ -296,9 +297,9 @@ public function write_file(SessionDocument $objectDocument, Translate $outputlan
$usertmp = new User($this->db);
$result = $usertmp->fetch($conf->global->DOLIMEET_SESSION_TRAINER_RESPONSIBLE);
if ($result > 0) {
$tmparray['company_owner_fullname'] = $usertmp->firstname . ' ' . strtoupper($usertmp->lastname);
$tmparray['mycompany_owner_fullname'] = $usertmp->firstname . ' ' . strtoupper($usertmp->lastname);
} else {
$tmparray['company_owner_fullname'] = '';
$tmparray['mycompany_owner_fullname'] = '';
}

if (!empty($object->fk_contrat)) {
Expand Down Expand Up @@ -347,24 +348,29 @@ public function write_file(SessionDocument $objectDocument, Translate $outputlan
$result = $signatory->fetchSignatory('UserSignature', $conf->global->DOLIMEET_SESSION_TRAINER_RESPONSIBLE, 'user');
if(is_array($result) && !empty($result)) {
$signatory = array_shift($result);
$user = new User($db);
$user->fetch($signatory->element_id);
$tmparray['mycompany_owner_job'] = $user->job;
} else {
$tmparray['mycompany_owner_job'] = '';
}

if (dol_strlen($signatory->signature) > 0 && $signatory->signature != $langs->transnoentities('FileGenerated')) {
if ($moreparam['specimen'] == 0 || ($moreparam['specimen'] == 1 && $conf->global->DOLIMEET_SHOW_SIGNATURE_SPECIMEN == 1)) {
$encodedImage = explode(',', $signatory->signature)[1];
$decodedImage = base64_decode($encodedImage);
file_put_contents($tempdir . 'signature.png', $decodedImage);
$tmparray['company_owner_signature'] = $tempdir . 'signature.png';
$tmparray['mycompany_owner_signature'] = $tempdir . 'signature.png';
}
} else {
$tmparray['company_owner_signature'] = '';
$tmparray['mycompany_owner_signature'] = '';
}

$tmparray['date_creation'] = dol_print_date(dol_now(), 'dayhour', 'tzuser');

foreach ($tmparray as $key => $value) {
try {
if ($key == 'company_owner_signature') { // Image
if ($key == 'mycompany_owner_signature') { // Image
if (file_exists($value)) {
$list = getimagesize($value);
$newWidth = 350;
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions langs/fr_FR/dolimeet.lang
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ TypeContact_contrat_external_TRAINEE = Stagiaire
# Data - Donnée
AttendanceSheetDocument = Feuille de présence
AttendanceSheetDocuments = feuilles de présence
attendancesheetdocument = feuille de présence
attendancesheetdocument = feuille de presence
attendancesheetdocument.odt = Feuille de présence
DisplayAttendanceAbsentInSignature = Affiche la présence absent dans le champ signature de la feuille de présence
DisplayAttendanceAbsentInSignatureDescription = Affiche la présence absent si la personne est absente et qu'elle n'a pas signé
CompletionCertificateDocument = Certificat de réalisation
CompletionCertificateDocuments = certificats de réalisation
completioncertificatedocument = certificat de réalisation
completioncertificatedocument = certificat de realisation
completioncertificatedocument.odt = Certificat de réalisation


Expand Down

0 comments on commit 1ca3669

Please sign in to comment.