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 .
"/salary/" . $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');
168 $this->error = $langs->trans(
"ErrorDirIsNotWritable", $dir);
190 $posy = $this->marge_haute;
191 $posx = $this->page_largeur - $this->marge_droite - 100;
193 $pdf->SetXY($this->marge_gauche, $posy);
196 $logo =
$conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
197 if ($this->emetteur->logo && is_readable($logo)) {
199 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
201 $pdf->SetFont(
'',
'B', $default_font_size + 2);
202 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
204 $yafterleft = $pdf->GetY();
207 $pdf->SetFont(
'',
'', $default_font_size);
208 $pdf->SetXY($this->marge_gauche, $yafterleft + 1);
210 $yafterleft = $pdf->GetY();
214 $pdf->SetFont(
'',
'B', $default_font_size + 4);
215 $pdf->SetXY($posx, $posy);
216 $pdf->SetTextColor(0, 0, 60);
217 $pdf->MultiCell(100, 5, $outputlangs->transnoentities(
"SalarySlip") .
' ' . $outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
219 $posy = $pdf->GetY() + 8;
222 $employee =
new User($this->db);
225 if (!empty(
$object->fk_user)) {
227 } elseif (!empty(
$object->fk_user_author)) {
228 $fk_user =
$object->fk_user_author;
231 if ($fk_user > 0 && $employee->fetch($fk_user) > 0) {
232 $pdf->SetFont(
'',
'', $default_font_size);
233 $pdf->SetXY($posx, $posy);
235 $text = $employee->getFullName($outputlangs) .
"\n";
237 if (!empty($employee->job)) {
238 $text .= $employee->job .
"\n";
240 if (!empty($employee->address)) {
241 $text .= $employee->address .
"\n";
243 if (!empty($employee->zip) || !empty($employee->town)) {
244 $text .= trim($employee->zip .
' ' . $employee->town) .
"\n";
246 if (!empty($employee->email)) {
247 $text .= $employee->email;
249 $yafterright = $pdf->GetY();
251 $yafterright = $posy;
256 $pdf->SetY(max($yafterleft, $yafterright) + 8);
259 $pdf->SetFont(
'',
'B', $default_font_size - 1);
260 $pdf->SetTextColor(0, 0, 0);
266 if (!empty($employee->id)) {
267 $info_array[$outputlangs->transnoentitiesnoconv(
"Employee")]
268 = $employee->getFullName($outputlangs);
270 if (!empty($employee->job)) {
271 $info_array[$outputlangs->transnoentitiesnoconv(
"Job")]
275 if (!empty($employee->email)) {
276 $info_array[$outputlangs->transnoentitiesnoconv(
"Email")]
282 $payment_date =
$object->datesp;
283 $info_array[$outputlangs->transnoentitiesnoconv(
"DatePayment")] =
dol_print_date($payment_date,
'day');
285 if (
$object->type_payment && !empty(
$object->type_payment_code)) {
286 $info_array[$outputlangs->transnoentitiesnoconv(
"PaymentMode")] = $outputlangs->trans(
"PaymentType".
$object->type_payment_code);
289 if (!empty(
$object->num_payment)) {
290 $info_array[$outputlangs->transnoentitiesnoconv(
"Numero")] =
$object->num_payment;
293 $project =
new Project($this->db);
294 if ($project->fetch(
$object->fk_project) > 0) {
295 $info_array[$outputlangs->transnoentitiesnoconv(
"Project")] = $project->ref;
301 foreach ($info_array as $label => $value) {
302 $pdf->SetFont(
'',
'B', $default_font_size - 1);
303 $pdf->Cell($col1_width, 5, $label .
" :", 0, 0,
'L');
304 $pdf->SetFont(
'',
'', $default_font_size - 1);
305 $pdf->MultiCell(0, 5, $value, 0,
'L');
322 $tab_top = $pdf->GetY();
325 $curY = $tab_top + 7;
328 $pdf->SetFont(
'',
'', $default_font_size);
329 $pdf->SetXY($this->posxdesc, $curY);
330 $pdf->MultiCell($this->posxearning - $this->posxdesc, 5, $outputlangs->convToOutputCharset(
$object->label));
331 $y_after_label = $pdf->GetY();
333 $pdf->SetXY($this->posxearning, $curY);
334 $pdf->MultiCell($this->posxdeduction - $this->posxearning, 5,
price(
$object->amount, 0, $outputlangs, 1), 0,
'R');
340 $total_deductions = 0.00;
343 if (!empty(
$object->note_public)) {
344 $pdf->SetY($y_after_label + 5);
345 $pdf->SetFont(
'',
'B', $default_font_size - 1);
346 $pdf->Cell(0, 5, $outputlangs->transnoentitiesnoconv(
"Note"), 0, 1,
'L');
347 $pdf->SetFont(
'',
'', $default_font_size - 1);
348 $pdf->writeHTMLCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 5, $this->marge_gauche, $pdf->GetY(),
$object->note_public,
'B', 1);
352 $net_pay = $gross_pay - $total_deductions;
353 $totals_y_pos = $this->page_hauteur - $this->marge_basse - 30;
354 $pdf->SetY(max($pdf->GetY() + 5, $totals_y_pos));
356 $pdf->SetFont(
'',
'', $default_font_size);
357 $pdf->SetX($this->posxearning - 30);
358 $pdf->Cell(40, 5, $outputlangs->transnoentitiesnoconv(
"TotalEarnings") .
" :", 0, 0,
'R');
359 $pdf->Cell(30, 5,
price($gross_pay, 0, $outputlangs, 1), 0, 1,
'R');
361 $pdf->SetX($this->posxearning - 30);
362 $pdf->Cell(40, 5, $outputlangs->transnoentitiesnoconv(
"TotalDeductions") .
" :", 0, 0,
'R');
363 $pdf->Cell(30, 5,
price($total_deductions, 0, $outputlangs, 1), 0, 1,
'R');
365 $pdf->SetLineStyle(array(
'width' => 0.3,
'color' => array(0, 0, 0)));
366 $pdf->Line($this->posxearning - 30, $pdf->GetY(), $this->page_largeur - $this->marge_droite, $pdf->GetY());
369 $pdf->SetFont(
'',
'B', $default_font_size + 1);
370 $pdf->SetX($this->posxearning - 30);
371 $pdf->Cell(40, 6, $outputlangs->transnoentitiesnoconv(
"NetPaid") .
" :", 0, 0,
'R');
372 $pdf->Cell(30, 6,
price($net_pay, 0, $outputlangs, 1), 0, 1,
'R');
388 $pdf->SetXY($this->posxdesc, $tab_top);
389 $pdf->SetFont(
'',
'B', $default_font_size - 1);
390 $pdf->SetFillColor(240, 240, 240);
391 $pdf->SetTextColor(0, 0, 0);
393 $pdf->Cell($this->posxearning - $this->posxdesc, 7, $outputlangs->transnoentitiesnoconv(
"Description"), 0, 0,
'L',
true);
394 $pdf->Cell($this->posxdeduction - $this->posxearning, 7, $outputlangs->transnoentitiesnoconv(
"Earnings"), 0, 0,
'R',
true);
395 $pdf->Cell($this->page_largeur - $this->marge_droite - $this->posxdeduction, 7, $outputlangs->transnoentitiesnoconv(
"Deductions"), 0, 1,
'R',
true);
397 $pdf->SetDrawColor(128, 128, 128);
398 $pdf->Line($this->marge_gauche, $tab_top + 7, $this->page_largeur - $this->marge_droite, $tab_top + 7);
412 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
413 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
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.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$conf db name
Only used if Module[ID]Name translation string is not found.