X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fcarnet%2Fcontacts.pdf.inc.php;h=fa284fc2735c43ce8973b4d1f7601d7ae187cf67;hb=790d989ab075a69f0a76645544cc5257d3ee2b8a;hp=616030e4b605e2d55aaf2702138ce20fd262b936;hpb=714f5437ddf637fc9514709a4bb07c6c5eb71542;p=platal.git diff --git a/modules/carnet/contacts.pdf.inc.php b/modules/carnet/contacts.pdf.inc.php index 616030e..fa284fc 100644 --- a/modules/carnet/contacts.pdf.inc.php +++ b/modules/carnet/contacts.pdf.inc.php @@ -1,6 +1,6 @@ text) { return; } $l = "adresse\n"; - if ($a['current']) { + if ($a->hasFlag('current')) { $l .= 'actuelle'; - } elseif ($a['secondary']) { + } elseif ($a->hasFlag('secondary')) { $l .= 'secondaire'; } else { $l .= 'principale'; } - $r = utf8_decode($a['text']); -/* $r = trim("$r\n".$a['adr1']); - $r = trim("$r\n".$a['adr2']); - $r = trim("$r\n".$a['adr3']); - $r = trim("$r\n".trim($a['postcode'].' '.$a['city'])); -*/ - $this->TableRow($l, $r); -/* - if (!empty($a['tels'])) { - foreach ($a['tels'] as $tel) { - if (!empty($tel['tel'])) { - $this->TableRow(utf8_decode($tel['tel_type']), $tel['tel'], 'Mono'); - } - } - }*/ + $this->TableRow($l, utf8_decode($a->text)); + + foreach ($a->phones() as $phone) { + $this->TableRow(utf8_decode($phone->displayType()), + utf8_decode($phone->display), 'Mono'); + } } private function AddressPro($a) { - return; - - if ($a['entreprise']) { - $this->TableRow('Entreprise', $a['entreprise']); - } - - if ($a['adr1'] || $a['adr2'] || $a['adr3'] || $a['postcode'] || $a['city']) { - $r = ''; - $r = trim("$r\n".$a['adr1']); - $r = trim("$r\n".$a['adr2']); - $r = trim("$r\n".$a['adr3']); - $r = trim("$r\n".trim($a['postcode'].' '.$a['city'])); - $this->TableRow('adresse pro', $r); + if ($a->company) { + $this->TableRow('Entreprise', utf8_decode($a->company->name)); } - - if ($a['tel']) { - $this->TableRow(utf8_decode('Téléphone'), $a['tel'], 'Mono'); + if ($a->address()) { + $this->TableRow('adresse pro', utf8_decode($a->address()->text)); } - if ($a['fax']) { - $this->TableRow('Fax', $a['fax'], 'Mono'); + foreach ($a->phones() as $phone) { + $this->TableRow(utf8_decode($phone->displayType()), + utf8_decode($phone->display), 'Mono'); } } @@ -283,19 +263,15 @@ class ContactsPDF extends FPDF $ok = false; if ($wp) { - $res = XDB::query("SELECT * FROM photo WHERE attachmime IN ('jpeg', 'png') AND uid={?}", - $profile->pid); - if ($i = $res->numRows()) { + $photo = $profile->getPhoto(false, true); + if ($photo) { $old2 = clone $self; - $photo = $res->fetchOneAssoc(); - $width = $photo['x'] * 20/$photo['y']; - $GLOBALS['p' . $profile->pid] = $photo['attach']; - + $width = $photo->width() * 20 / $photo->height(); $_x = $self->getX(); $_y = $self->getY(); $self->Cell(0, 20, '', '', 0, '', 1); error_reporting(0); - $self->Image("var://p" . $profile->pid, $_x, $_y, $width, 20, $photo['attachmime']); + $self->Image($photo->path(), $_x, $_y, $width, 20, $photo->mimeType()); error_reporting($self->report); if ($self->error) { @@ -303,7 +279,7 @@ class ContactsPDF extends FPDF } else { $self->setX($_x); $self->Cell($width, 20, '', "T"); - $h = 20 / $self->wordwrap($nom, 90-$width); + $h = 20 / $self->wordwrap($nom, 90 - $width); $self->MultiCell(0, $h, $nom, 'T', 'C'); $ok = true; } @@ -318,19 +294,13 @@ class ContactsPDF extends FPDF $self->TableRow('mobile', utf8_decode($profile->mobile), 'Mono'); } - $it = $profile->getAddresses(Profile::ADDRESS_ALL); + $it = $profile->iterAddresses(Profile::ADDRESS_ALL); while ($a = $it->next()) { - foreach ($a as &$value) { - $value = utf8_decode($value); - } $self->Space(); $self->Address($a); } - $it = $profile->getAddresses(Profile::ADDRESS_PRO); - while ($a = $it->next()) { - foreach ($a as &$value) { - $value = utf8_decode($value); - } + $it = $profile->getJobs(Profile::JOBS_CURRENT); + foreach ($it as $a) { $self->Space(); $self->AddressPro($a); }