From bb67c95c3d1cbd91c8732455eebf08ed337f48e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Apr 2012 20:08:08 +0200 Subject: [PATCH] Uniformize code --- htdocs/compta/bank/bankid_fr.php | 57 +++++++++---------- htdocs/compta/bank/fiche.php | 7 +-- htdocs/core/lib/pdf.lib.php | 51 +++++++++-------- .../modules/facture/doc/pdf_crabe.modules.php | 22 +++---- 4 files changed, 68 insertions(+), 69 deletions(-) diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php index 63ea7faf7f4..f9b337f1686 100644 --- a/htdocs/compta/bank/bankid_fr.php +++ b/htdocs/compta/bank/bankid_fr.php @@ -31,6 +31,9 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); $langs->load("banks"); $langs->load("bills"); +$action=GETPOST('action'); +$id=GETPOST('id'); + // Security check if (isset($_GET["id"]) || isset($_GET["ref"])) { @@ -44,11 +47,12 @@ $result=restrictedArea($user,'banque',$id,'bank_account','','',$fieldid); /* * Actions */ -if ($_POST["action"] == 'update' && ! $_POST["cancel"]) + +if ($action == 'update' && ! $_POST["cancel"]) { // Modification - $account = new Account($db, $_POST["id"]); - $account->fetch($_POST["id"]); + $account = new Account($db); + $account->fetch($id); $account->bank = trim($_POST["bank"]); $account->code_banque = trim($_POST["code_banque"]); @@ -74,12 +78,12 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) else { $message='
'.$account->error.'
'; - $_GET["action"]='edit'; // Force chargement page edition + $action='edit'; // Force chargement page edition } } } -if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) +if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) { // Modification $account = new Account($db, $_GET["id"]); @@ -104,12 +108,12 @@ $form = new Form($db); /* */ /* ************************************************************************** */ -if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') +if (($_GET["id"] || $_GET["ref"]) && $action != 'edit') { $account = new Account($db); if ($_GET["id"]) { - $result=$account->fetch($_GET["id"]); + $result=$account->fetch($id); } if ($_GET["ref"]) { @@ -117,28 +121,17 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') $_GET["id"]=$account->id; } - /* - * Affichage onglets - */ // Onglets $head=bank_prepare_head($account); dol_fiche_head($head, 'bankid', $langs->trans("FinancialAccount"),0,'account'); - /* - * Confirmation de la suppression - */ - if ($_GET["action"] == 'delete') + // Confirmation de la suppression + if ($action == 'delete') { $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$account->id,$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete"); if ($ret == 'html') print '
'; } - // Check BBAN - if (! checkBanForAccount($account)) - { - print '
'.$langs->trans("RIBControlError").'

'; - } - print ''; @@ -235,13 +228,20 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') print '
'; + + // Check BBAN + if (! checkBanForAccount($account)) + { + print '
'.$langs->trans("RIBControlError").'
'; + } + print "\n\n"; /* - * Barre d'actions - * - */ + * Barre d'actions + */ + print '
'; if ($user->rights->banque->configurer) @@ -259,15 +259,15 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') /* */ /* ************************************************************************** */ -if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configurer) +if ($_GET["id"] && $action == 'edit' && $user->rights->banque->configurer) { - $account = new Account($db, $_GET["id"]); - $account->fetch($_GET["id"]); + $account = new Account($db); + $account->fetch($id); print_fiche_titre($langs->trans("EditFinancialAccount")); print "
"; - if ($message) { print "$message
\n"; } + dol_htmloutput_mesg($message); print '
'; print ''; @@ -381,8 +381,7 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure } +llxFooter(); $db->close(); - -llxFooter(); ?> diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 90f4c73dddf..7dec4bfd2dd 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copytight (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -135,9 +135,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $account->currency_code = trim($_POST["account_currency_code"]); - $account->fk_departement = $_POST["account_departement_id"]; - $account->fk_pays = $_POST["account_country_id"]; - + $account->state_id = $_POST["account_departement_id"]; + $account->country_id = $_POST["account_country_id"]; $account->min_allowed = $_POST["account_min_allowed"]; $account->min_desired = $_POST["account_min_desired"]; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2914d5feaa9..b1a2b92f9af 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -343,17 +343,18 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) /** - * Show bank informations for PDF generation + * Show bank informations for PDF generation * - * @param PDF &$pdf Object PDF - * @param Translate $outputlangs Object lang - * @param int $curx X - * @param int $cury Y - * @param Account $account Bank account object - * @param int $onlynumber Output only number - * @return void + * @param PDF &$pdf Object PDF + * @param Translate $outputlangs Object lang + * @param int $curx X + * @param int $cury Y + * @param Account $account Bank account object + * @param int $onlynumber Output only number + * @param int $default_font_size Default font size + * @return void */ -function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) +function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10) { global $mysoc, $conf; @@ -361,7 +362,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) if (empty($onlynumber)) { - $pdf->SetFont('','B',8); + $pdf->SetFont('','B',$default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); $cury+=4; } @@ -378,9 +379,9 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) if (empty($onlynumber)) { - $pdf->SetFont('','',6); + $pdf->SetFont('','',$default_font_size - 4); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); $cury+=3; } @@ -404,10 +405,10 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) // Bank code $tmplength=18; $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0); $pdf->SetXY($curx, $cury+1); $curx+=$tmplength; - $pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); } if ($val == 'desk') @@ -415,10 +416,10 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) // Desk $tmplength=18; $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0); $pdf->SetXY($curx, $cury+1); $curx+=$tmplength; - $pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); } if ($val == 'number') @@ -426,10 +427,10 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) // Number $tmplength=24; $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0); $pdf->SetXY($curx, $cury+1); $curx+=$tmplength; - $pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); } if ($val == 'key') @@ -437,10 +438,10 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) // Key $tmplength=13; $pdf->SetXY($curx, $cury+5); - $pdf->SetFont('','',8);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0); + $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0); $pdf->SetXY($curx, $cury+1); $curx+=$tmplength; - $pdf->SetFont('','B',6);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); + $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+8); } } @@ -452,12 +453,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) { $pdf->SetFont('','B',6); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); $cury+=3; $pdf->SetFont('','B',6); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); $cury+=3; } @@ -473,7 +474,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) { $pdf->SetXY($curx, $cury); $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); - $pdf->MultiCell(90, 3, $val, 0, 'L', 0); + $pdf->MultiCell(100, 3, $val, 0, 'L', 0); $nboflines=dol_nboflines_bis($val,120); //print $nboflines;exit; $cury+=($nboflines*2)+2; @@ -481,9 +482,9 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0) else if (! $usedetailedbban) $cury+=1; $pdf->SetXY($curx, $cury); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities($ibankey).': ' . $outputlangs->convToOutputCharset($account->iban), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $outputlangs->convToOutputCharset($account->iban), 0, 'L', 0); $pdf->SetXY($curx, $cury+3); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); return $pdf->getY(); } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 29438a05af7..56d12802efb 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -241,8 +241,8 @@ class pdf_crabe extends ModelePDFFactures // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); -//print $pdf->getStringHeight(200,'SPECIMEN',false,false); -//print "$this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1";exit; + //print $pdf->getStringHeight(200,'SPECIMEN',false,false); + //print "$this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1";exit; $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); $tab_height = $tab_height - $height_note; @@ -655,25 +655,25 @@ class pdf_crabe extends ModelePDFFactures $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); + $pdf->SetFont('','B', $default_font_size - 3); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); $posy=$pdf->GetY()+1; $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); + $pdf->SetFont('','', $default_font_size - 3); + $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); $posy=$pdf->GetY()+2; } if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->name).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); + $pdf->SetFont('','B', $default_font_size - 3); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->name).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); $posy=$pdf->GetY()+1; $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); + $pdf->SetFont('','', $default_font_size - 3); + $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy=$pdf->GetY()+2; } } @@ -690,7 +690,7 @@ class pdf_crabe extends ModelePDFFactures $curx=$this->marge_gauche; $cury=$posy; - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); $posy+=2; }