13require_once DOL_DOCUMENT_ROOT.
'/core/modules/salaries/modules_salary.php';
14require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
15require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
16require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
18 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
20require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
68 public $posxdeduction;
82 $langs->loadLangs(array(
"main",
"companies",
"bills",
"salaries",
"projects"));
85 $this->
name =
"standard_salary";
86 $this->
description = $langs->trans(
"StandardSalaryDocModel");
91 $this->page_largeur = $formatarray[
'width'];
92 $this->page_hauteur = $formatarray[
'height'];
93 $this->format = array($this->page_largeur, $this->page_hauteur);
100 $this->posxdesc = $this->marge_gauche;
101 $this->posxearning = $this->page_largeur - $this->marge_droite - 80;
102 $this->posxdeduction = $this->page_largeur - $this->marge_droite - 40;
119 public function writeFile(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
121 global
$conf, $langs;
123 $outputlangs = is_object($outputlangs) ? $outputlangs : $langs;
125 $outputlangs->charset_output =
'ISO-8859-1';
128 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"salaries"));
130 if (!
$conf->salaries->dir_output) {
131 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SALARIES_OUTPUTDIR");
136 $dir =
$conf->salaries->dir_output .
"/" . $objref;
137 $file = $dir .
"/" . $objref .
".pdf";
141 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
146 if (is_writable($dir)) {
148 $pdf->setAutoPageBreak(
true, 0);
150 if (class_exists(
'TCPDF')) {
151 $pdf->setPrintHeader(
false);
152 $pdf->setPrintFooter(
false);
163 $pdf->Output($file,
'F');
166 $this->result = array(
'fullpath' => $file);
170 $this->error = $langs->trans(
"ErrorDirIsNotWritable", $dir);
192 $posy = $this->marge_haute;
193 $posx = $this->page_largeur - $this->marge_droite - 100;
195 $pdf->SetXY($this->marge_gauche, $posy);
198 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
199 if ($this->emetteur->logo && is_readable($logo)) {
201 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
203 $pdf->SetFont(
'',
'B', $default_font_size + 2);
204 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
206 $yafterleft = $pdf->GetY();
209 $pdf->SetFont(
'',
'', $default_font_size);
210 $pdf->SetXY($this->marge_gauche, $yafterleft + 1);
212 $yafterleft = $pdf->GetY();
216 $pdf->SetFont(
'',
'B', $default_font_size + 4);
217 $pdf->SetXY($posx, $posy);
218 $pdf->SetTextColor(0, 0, 60);
219 $pdf->MultiCell(100, 5, $outputlangs->transnoentities(
"SalarySlip") .
' ' . $outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
221 $posy = $pdf->GetY() + 8;
224 $employee =
new User($this->db);
227 if (!empty(
$object->fk_user)) {
229 } elseif (!empty(
$object->fk_user_author)) {
230 $fk_user =
$object->fk_user_author;
233 if ($fk_user > 0 && $employee->fetch($fk_user) > 0) {
234 $pdf->SetFont(
'',
'', $default_font_size);
235 $pdf->SetXY($posx, $posy);
237 $text = $employee->getFullName($outputlangs) .
"\n";
239 if (!empty($employee->job)) {
240 $text .= $employee->job .
"\n";
242 if (!empty($employee->address)) {
243 $text .= $employee->address .
"\n";
245 if (!empty($employee->zip) || !empty($employee->town)) {
246 $text .= trim($employee->zip .
' ' . $employee->town) .
"\n";
248 if (!empty($employee->email)) {
249 $text .= $employee->email;
251 $yafterright = $pdf->GetY();
253 $yafterright = $posy;
258 $pdf->SetY(max($yafterleft, $yafterright) + 8);
261 $pdf->SetFont(
'',
'B', $default_font_size - 1);
262 $pdf->SetTextColor(0, 0, 0);
268 if (!empty($employee->id)) {
269 $info_array[$outputlangs->transnoentitiesnoconv(
"Employee")]
270 = $employee->getFullName($outputlangs);
272 if (!empty($employee->job)) {
273 $info_array[$outputlangs->transnoentitiesnoconv(
"Job")]
277 if (!empty($employee->email)) {
278 $info_array[$outputlangs->transnoentitiesnoconv(
"Email")]
284 $payment_date =
$object->datesp;
285 $info_array[$outputlangs->transnoentitiesnoconv(
"DatePayment")] =
dol_print_date($payment_date,
'day');
287 if (
$object->type_payment && !empty(
$object->type_payment_code)) {
288 $info_array[$outputlangs->transnoentitiesnoconv(
"PaymentMode")] = $outputlangs->trans(
"PaymentType".
$object->type_payment_code);
291 if (!empty(
$object->num_payment)) {
292 $info_array[$outputlangs->transnoentitiesnoconv(
"Numero")] =
$object->num_payment;
295 $project =
new Project($this->db);
296 if ($project->fetch(
$object->fk_project) > 0) {
297 $info_array[$outputlangs->transnoentitiesnoconv(
"Project")] = $project->ref;
303 foreach ($info_array as $label => $value) {
304 $pdf->SetFont(
'',
'B', $default_font_size - 1);
305 $pdf->Cell($col1_width, 5, $label .
" :", 0, 0,
'L');
306 $pdf->SetFont(
'',
'', $default_font_size - 1);
307 $pdf->MultiCell(0, 5, $value, 0,
'L');
324 $tab_top = $pdf->GetY();
327 $curY = $tab_top + 7;
330 $pdf->SetFont(
'',
'', $default_font_size);
331 $pdf->SetXY($this->posxdesc, $curY);
332 $pdf->MultiCell($this->posxearning - $this->posxdesc, 5, $outputlangs->convToOutputCharset(
$object->label));
333 $y_after_label = $pdf->GetY();
335 $pdf->SetXY($this->posxearning, $curY);
336 $pdf->MultiCell($this->posxdeduction - $this->posxearning, 5,
price(
$object->amount, 0, $outputlangs, 1), 0,
'R');
342 $total_deductions = 0.00;
345 if (!empty(
$object->note_public)) {
346 $pdf->SetY($y_after_label + 5);
347 $pdf->SetFont(
'',
'B', $default_font_size - 1);
348 $pdf->Cell(0, 5, $outputlangs->transnoentitiesnoconv(
"Note"), 0, 1,
'L');
349 $pdf->SetFont(
'',
'', $default_font_size - 1);
350 $pdf->writeHTMLCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 5, $this->marge_gauche, $pdf->GetY(),
$object->note_public,
'B', 1);
354 $net_pay = $gross_pay - $total_deductions;
355 $totals_y_pos = $this->page_hauteur - $this->marge_basse - 30;
356 $pdf->SetY(max($pdf->GetY() + 5, $totals_y_pos));
358 $pdf->SetFont(
'',
'', $default_font_size);
359 $pdf->SetX($this->posxearning - 30);
360 $pdf->Cell(40, 5, $outputlangs->transnoentitiesnoconv(
"TotalEarnings") .
" :", 0, 0,
'R');
361 $pdf->Cell(30, 5,
price($gross_pay, 0, $outputlangs, 1), 0, 1,
'R');
363 $pdf->SetX($this->posxearning - 30);
364 $pdf->Cell(40, 5, $outputlangs->transnoentitiesnoconv(
"TotalDeductions") .
" :", 0, 0,
'R');
365 $pdf->Cell(30, 5,
price($total_deductions, 0, $outputlangs, 1), 0, 1,
'R');
367 $pdf->SetLineStyle(array(
'width' => 0.3,
'color' => array(0, 0, 0)));
368 $pdf->Line($this->posxearning - 30, $pdf->GetY(), $this->page_largeur - $this->marge_droite, $pdf->GetY());
371 $pdf->SetFont(
'',
'B', $default_font_size + 1);
372 $pdf->SetX($this->posxearning - 30);
373 $pdf->Cell(40, 6, $outputlangs->transnoentitiesnoconv(
"NetPaid") .
" :", 0, 0,
'R');
374 $pdf->Cell(30, 6,
price($net_pay, 0, $outputlangs, 1), 0, 1,
'R');
390 $pdf->SetXY($this->posxdesc, $tab_top);
391 $pdf->SetFont(
'',
'B', $default_font_size - 1);
392 $pdf->SetFillColor(240, 240, 240);
393 $pdf->SetTextColor(0, 0, 0);
395 $pdf->Cell($this->posxearning - $this->posxdesc, 7, $outputlangs->transnoentitiesnoconv(
"Description"), 0, 0,
'L',
true);
396 $pdf->Cell($this->posxdeduction - $this->posxearning, 7, $outputlangs->transnoentitiesnoconv(
"Earnings"), 0, 0,
'R',
true);
397 $pdf->Cell($this->page_largeur - $this->marge_droite - $this->posxdeduction, 7, $outputlangs->transnoentitiesnoconv(
"Deductions"), 0, 1,
'R',
true);
399 $pdf->SetDrawColor(128, 128, 128);
400 $pdf->Line($this->marge_gauche, $tab_top + 7, $this->page_largeur - $this->marge_droite, $tab_top + 7);
414 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
415 pdf_pagefoot($pdf, $outputlangs,
'SALARY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur,
$object, $showdetails);
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage Dolibarr database access.
Base class for Salary PDF document models.
Class to manage projects.
Class to manage Dolibarr users.
Class to build a standard salary slip PDF.
body(&$pdf, $object, $outputlangs)
Show the lines of the salary slip.
writeFile($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build the salary slip document.
tableauHeader(&$pdf, $tab_top, $outputlangs)
Show table header.
__construct(\DoliDB $db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs)
Show footer of page.
_pagehead(&$pdf, $object, $outputlangs, $showaddress=1)
Show top header of page.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_is_dir($folder)
Test if filename is a directory.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_pagefoot($pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
$conf db name
Only used if Module[ID]Name translation string is not found.