Change to uniformize code of PDF generators

This commit is contained in:
Laurent Destailleur 2009-01-29 12:39:52 +00:00
parent 5d2d005e13
commit 5de23dcc59
10 changed files with 153 additions and 106 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>

View File

@ -2071,6 +2071,7 @@ class Commande extends CommonObject
$ligne->total_tva=19.6; $ligne->total_tva=19.6;
$prodid = rand(1, $num_prods); $prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid]; $ligne->produit_id=$prodids[$prodid];
$ligne->fk_product=$prodids[$prodid];
$this->lignes[$xnbp]=$ligne; $this->lignes[$xnbp]=$ligne;
$xnbp++; $xnbp++;
} }

View File

@ -48,8 +48,9 @@ class Expedition extends CommonObject
var $modelpdf; var $modelpdf;
var $origin; var $origin;
var $origin_id; var $origin_id;
var $lignes;
var $meths; var $meths;
/** /**
* Initialisation * Initialisation
* *
@ -748,10 +749,12 @@ class Expedition extends CommonObject
$ligne->qty=10; $ligne->qty=10;
$ligne->qty_asked=5; $ligne->qty_asked=5;
$ligne->qty_shipped=4; $ligne->qty_shipped=4;
$prodid = rand(1, $num_prods); $ligne->fk_product=$this->commande->lignes[$xnbp]->fk_product;
$ligne->fk_product=$prodids[$prodid];
$this->lignes[]=$ligne;
$xnbp++; $xnbp++;
} }
} }
/* /*
Fetch deliveries method and return an array Fetch deliveries method and return an array

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -181,7 +181,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
//Initialisation des coordonn<EFBFBD>es //Initialisation des coordonnees
$tab_top = 53; $tab_top = 53;
$tab_height = 70; $tab_height = 70;
$pdf->SetFillColor(240,240,240); $pdf->SetFillColor(240,240,240);
@ -193,30 +193,33 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
//Generation du tableau //Generation du tableau
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
//Recuperation des produits de la commande. //Recuperation des produits de la commande.
$this->expe->commande->fetch_lines(1); if ($this->expe->ref != 'SPECIMEN') $this->expe->commande->fetch_lines(1);
$Produits = $this->expe->commande->lignes; $Produits = $this->expe->commande->lignes;
$nblignes = sizeof($Produits); $nblignes = sizeof($Produits);
for ($i = 0 ; $i < $nblignes ; $i++){ for ($i = 0 ; $i < $nblignes ; $i++){
//Generation du produit //Generation du produit
$Prod = new Product($this->db); $Prod = new Product($this->db);
$Prod->fetch($Produits[$i]->fk_product); $Prod->fetch($Produits[$i]->fk_product);
//Creation des cases <EFBFBD> cocher //Creation des cases a cocher
$pdf->rect(10+3, $curY+1, 3, 3); $pdf->rect(10+3, $curY+1, 3, 3);
$pdf->rect(20+3, $curY+1, 3, 3); $pdf->rect(20+3, $curY+1, 3, 3);
//Insertion de la reference du produit //Insertion de la reference du produit
$pdf->SetXY (30, $curY ); $pdf->SetXY (30, $curY );
$pdf->SetFont('Arial','B', 7); $pdf->SetFont('Arial','B', 7);
$pdf->MultiCell(20, 5, $Prod->ref, 0, 'L', 0); $pdf->MultiCell(24, 5, $outputlangs->convToOutputCharset($Prod->ref), 0, 'L', 0);
//Insertion du libelle //Insertion du libelle
$pdf->SetFont('Arial','', 7); $pdf->SetFont('Arial','', 7);
$pdf->SetXY (50, $curY ); $pdf->SetXY (50, $curY );
$pdf->MultiCell(90, 5, $Prod->libelle, 0, 'L', 0); $pdf->MultiCell(90, 5, $outputlangs->convToOutputCharset($Prod->libelle), 0, 'L', 0);
//Insertion de la quantite command<EFBFBD>e //Insertion de la quantite commandee
$pdf->SetFont('Arial','', 7); $pdf->SetFont('Arial','', 7);
$pdf->SetXY (140, $curY ); $pdf->SetXY (140, $curY );
$pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_asked, 0, 'C', 0); $pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_asked, 0, 'C', 0);
//Insertion de la quantite <EFBFBD> envoyer //Insertion de la quantite a envoyer
$pdf->SetFont('Arial','', 7); $pdf->SetFont('Arial','', 7);
$pdf->SetXY (170, $curY ); $pdf->SetXY (170, $curY );
$pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_shipped, 0, 'C', 0); $pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_shipped, 0, 'C', 0);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -66,7 +66,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'<27>tait pas d<>fini if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'<27>tait pas d<>fini
} }
/* /**
* \param pdf Objet PDF * \param pdf Objet PDF
* \param exp Objet expedition * \param exp Objet expedition
* \param showadress 0=non, 1=oui * \param showadress 0=non, 1=oui
@ -189,7 +189,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $this->exp, $outputlangs); $this->_pagehead($pdf, $this->exp, 1, $outputlangs);
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -216,7 +216,8 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$curY = $this->tableau_top + 4; $curY = $this->tableau_top + 4;
$pdf->writeHTMLCell(30, 3, 170, $curY, $outputlangs->trans("QtyToShip"), 0, 0); $pdf->writeHTMLCell(30, 3, 170, $curY, $outputlangs->trans("QtyToShip"), 0, 0);
$this->expe->fetch_lines(); if ($this->expe->ref != 'SPECIMEN') $this->expe->fetch_lines();
for ($i = 0 ; $i < sizeof($this->expe->lignes) ; $i++) for ($i = 0 ; $i < sizeof($this->expe->lignes) ; $i++)
{ {
$curY = $this->tableau_top + 14 + ($i * 7); $curY = $this->tableau_top + 14 + ($i * 7);

View File

@ -120,7 +120,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -136,7 +139,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -160,7 +166,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn,$info,$user); $result=$ldap->delete($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -177,7 +186,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -192,7 +204,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -207,7 +222,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn,$info,$user); $result=$ldap->delete($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -225,7 +243,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -241,7 +262,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }
@ -257,8 +281,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn,$info,$user); $result=$ldap->delete($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
@ -275,8 +302,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user); $result=$ldap->add($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
elseif ($action == 'MEMBER_VALIDATE') elseif ($action == 'MEMBER_VALIDATE')
@ -294,8 +324,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
} }
@ -318,8 +351,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
} }
@ -335,8 +371,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
elseif ($action == 'MEMBER_NEW_PASSWORD') elseif ($action == 'MEMBER_NEW_PASSWORD')
@ -354,8 +393,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
} }
@ -374,8 +416,11 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user); $result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
return $result; {
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
} }
} }
} }
@ -391,7 +436,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info); $dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn,$info,$user); $result=$ldap->delete($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error; if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result; return $result;
} }
} }

View File

@ -505,12 +505,13 @@ class Ldap
if ($result) if ($result)
{ {
dolibarr_syslog("Ldap::add successfull"); dolibarr_syslog("Ldap::add successfull", LOG_DEBUG);
return 1; return 1;
} }
else else
{ {
dolibarr_syslog("Ldap::add failed"); $this->error=@ldap_error($this->connection);
dolibarr_syslog("Ldap::add failed: ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 <EFBFBD>ric Seigne <erics@rycks.com> * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be> * Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be>
@ -74,17 +74,6 @@ function llxHeader($head = "")
} }
} }
if (! empty($conf->compta->enabled) || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$menu->add(DOL_URL_ROOT."/compta/index.php", $langs->trans("MenuFinancial"));
if ($user->rights->facture->lire) {
$langs->load("bills");
$menu->add_submenu(DOL_URL_ROOT."/compta/facture.php", $langs->trans("Bills"));
}
}
if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
{ {
$langs->trans("interventions"); $langs->trans("interventions");

View File

@ -46,6 +46,7 @@ class User extends CommonObject
{ {
var $db; var $db;
var $error; var $error;
var $errors=array();
var $element='user'; var $element='user';
var $table_element='user'; var $table_element='user';

View File

@ -176,7 +176,7 @@ if ($_POST["action"] == 'add' && $canadduser)
{ {
$langs->load("errors"); $langs->load("errors");
$db->rollback(); $db->rollback();
$message='<div class="error">'.$langs->trans($edituser->error).'</div>'; $message='<div class="error">'.join('<br>',$edituser->errors).'</div>';
$action="create"; // Go back to create page $action="create"; // Go back to create page
} }