Uniformize code

This commit is contained in:
Laurent Destailleur 2012-04-02 20:08:08 +02:00
parent 84057d46cc
commit bb67c95c3d
4 changed files with 68 additions and 69 deletions

View File

@ -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='<div class="error">'.$account->error.'</div>';
$_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 '<br>';
}
// Check BBAN
if (! checkBanForAccount($account))
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div><br>';
}
print '<table class="border" width="100%">';
@ -235,13 +228,20 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
print '</table>';
// Check BBAN
if (! checkBanForAccount($account))
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div>';
}
print "\n</div>\n";
/*
* Barre d'actions
*
*/
* Barre d'actions
*/
print '<div class="tabsAction">';
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 "<br>";
if ($message) { print "$message<br>\n"; }
dol_htmloutput_mesg($message);
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$account->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -381,8 +381,7 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
}
llxFooter();
$db->close();
llxFooter();
?>

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* 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"];

View File

@ -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();
}

View File

@ -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;
}