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
/* 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 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
@ -323,10 +323,10 @@ if(is_dir($dir))
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;module='.$name.'&amp;moduleid='.$module->id.'">'.$langs->trans("Default").'</a>';
}
print '</td>';
// Info
print '<td>&nbsp;</td>';
print '</tr>';
}
}

View File

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

View File

@ -48,8 +48,9 @@ class Expedition extends CommonObject
var $modelpdf;
var $origin;
var $origin_id;
var $lignes;
var $meths;
/**
* Initialisation
*
@ -76,7 +77,7 @@ class Expedition extends CommonObject
function create($user)
{
global $conf;
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
$error = 0;
/* On positionne en mode brouillon l'expedition */
@ -145,7 +146,7 @@ class Expedition extends CommonObject
}
}
}
if (! $error)
{
$this->db->commit();
@ -238,7 +239,7 @@ class Expedition extends CommonObject
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->socid = $obj->socid;
@ -262,10 +263,10 @@ class Expedition extends CommonObject
$this->trueDepth = $obj->size;
$this->depth_units = $obj->size_units;
// A denormalized value
// A denormalized value
$this->trueSize = $obj->size."x".$obj->width."x".$obj->height;
$this->size_units = $obj->size_units;
if ($conf->commande->enabled)
{
$this->origin = "commande";
@ -274,16 +275,16 @@ class Expedition extends CommonObject
{
$this->origin = "propal";
}
$this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1;
$this->lignes = array();
$file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id,2) . "/" . $this->id.".pdf";
$this->pdf_filename = $file;
/*
* Lignes
*/
@ -292,7 +293,7 @@ class Expedition extends CommonObject
{
return -3;
}
return 1;
}
else
@ -399,7 +400,7 @@ class Expedition extends CommonObject
return -2;
}
}
// On efface le répertoire de pdf provisoire
$expeditionref = sanitizeFileName($provref);
if ($conf->expedition->dir_output)
@ -421,7 +422,7 @@ class Expedition extends CommonObject
}
}
}
}
else
{
@ -530,7 +531,7 @@ class Expedition extends CommonObject
if ( $this->db->query($sql) )
{
$this->db->commit();
// On efface le répertoire de pdf provisoire
$expref = sanitizeFileName($this->ref);
if ($conf->expedition->dir_output)
@ -748,10 +749,12 @@ class Expedition extends CommonObject
$ligne->qty=10;
$ligne->qty_asked=5;
$ligne->qty_shipped=4;
$prodid = rand(1, $num_prods);
$ligne->fk_product=$prodids[$prodid];
$ligne->fk_product=$this->commande->lignes[$xnbp]->fk_product;
$this->lignes[]=$ligne;
$xnbp++;
}
}
/*
Fetch deliveries method and return an array
@ -773,7 +776,7 @@ class Expedition extends CommonObject
}
}
}
/*
Get id of default expedition method
*/
@ -794,7 +797,7 @@ class Expedition extends CommonObject
}
}
}
/*
Get tracking url status
*/

View File

@ -1,6 +1,6 @@
<?php
/* 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>
*
* 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->SetTextColor(0,0,0);
//Initialisation des coordonn<EFBFBD>es
//Initialisation des coordonnees
$tab_top = 53;
$tab_height = 70;
$pdf->SetFillColor(240,240,240);
@ -193,30 +193,33 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$nexY = $pdf->GetY();
//Generation du tableau
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
//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;
$nblignes = sizeof($Produits);
for ($i = 0 ; $i < $nblignes ; $i++){
//Generation du produit
$Prod = new Product($this->db);
$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(20+3, $curY+1, 3, 3);
//Insertion de la reference du produit
$pdf->SetXY (30, $curY );
$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
$pdf->SetFont('Arial','', 7);
$pdf->SetXY (50, $curY );
$pdf->MultiCell(90, 5, $Prod->libelle, 0, 'L', 0);
//Insertion de la quantite command<EFBFBD>e
$pdf->MultiCell(90, 5, $outputlangs->convToOutputCharset($Prod->libelle), 0, 'L', 0);
//Insertion de la quantite commandee
$pdf->SetFont('Arial','', 7);
$pdf->SetXY (140, $curY );
$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->SetXY (170, $curY );
$pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_shipped, 0, 'C', 0);

View File

@ -1,6 +1,6 @@
<?php
/* 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
* 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
}
/*
/**
* \param pdf Objet PDF
* \param exp Objet expedition
* \param showadress 0=non, 1=oui
@ -189,7 +189,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $this->exp, $outputlangs);
$this->_pagehead($pdf, $this->exp, 1, $outputlangs);
$pdf->SetFont('Arial','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0);
@ -216,7 +216,8 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$curY = $this->tableau_top + 4;
$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++)
{
$curY = $this->tableau_top + 14 + ($i * 7);

View File

@ -36,7 +36,7 @@ class InterfaceLdapsynchro
var $db;
var $error;
/**
* \brief Constructeur.
* \param DB Handler d'accès base
@ -44,13 +44,13 @@ class InterfaceLdapsynchro
function InterfaceLdapsynchro($DB)
{
$this->db = $DB ;
$this->name = eregi_replace('Interface','',get_class($this));
$this->family = "ldap";
$this->description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
}
/**
* \brief Renvoi nom du lot de triggers
* \return string Nom du lot de triggers
@ -59,7 +59,7 @@ class InterfaceLdapsynchro
{
return $this->name;
}
/**
* \brief Renvoi descriptif du lot de triggers
* \return string Descriptif du lot de triggers
@ -83,7 +83,7 @@ class InterfaceLdapsynchro
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/**
* \brief Fonction appelée lors du déclenchement d'un évènement Dolibarr.
* D'autres fonctions run_trigger peuvent etre présentes dans includes/triggers
@ -98,15 +98,15 @@ class InterfaceLdapsynchro
{
// Mettre ici le code à exécuter en réaction de l'action
// Les données de l'action sont stockées dans $object
if (! $conf->ldap->enabled) return 0; // Module non actif
if (! function_exists('ldap_connect'))
{
dolibarr_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
return 0;
return 0;
}
// Users
if ($action == 'USER_CREATE')
{
@ -118,9 +118,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -134,9 +137,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -158,9 +164,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -175,9 +184,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -190,9 +202,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -205,13 +220,16 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
// Contacts
elseif ($action == 'CONTACT_CREATE')
{
@ -223,9 +241,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -239,9 +260,12 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$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;
}
}
@ -252,13 +276,16 @@ class InterfaceLdapsynchro
{
$ldap=new Ldap();
$ldap->connect_bind();
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->delete($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
@ -270,13 +297,16 @@ class InterfaceLdapsynchro
{
$ldap=new Ldap();
$ldap->connect_bind();
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->add($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
elseif ($action == 'MEMBER_VALIDATE')
@ -292,10 +322,13 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
}
@ -316,10 +349,13 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
}
@ -333,10 +369,13 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
elseif ($action == 'MEMBER_NEW_PASSWORD')
@ -352,10 +391,13 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
}
@ -372,10 +414,13 @@ class InterfaceLdapsynchro
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user);
if ($result < 0) $this->error=$langs->trans("ErrorLDAP")." ".$ldap->error;
return $result;
if ($result < 0)
{
$this->error="ErrorLDAP"." ".$ldap->error;
}
return $result;
}
}
}
@ -391,7 +436,10 @@ class InterfaceLdapsynchro
$dn=$object->_load_ldap_dn($info);
$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;
}
}

View File

@ -505,12 +505,13 @@ class Ldap
if ($result)
{
dolibarr_syslog("Ldap::add successfull");
dolibarr_syslog("Ldap::add successfull", LOG_DEBUG);
return 1;
}
else
{
dolibarr_syslog("Ldap::add failed");
$this->error=@ldap_error($this->connection);
dolibarr_syslog("Ldap::add failed: ".$this->error, LOG_ERR);
return -1;
}
}
@ -723,7 +724,7 @@ class Ldap
{
$keyattributelower=strtolower($attributeArray[$j]);
//print " Param ".$attributeArray[$j]."=".$info[$i][$keyattributelower][0]."<br>\n";
//permet de récupérer le SID avec Active Directory
if ($this->serverType == "activedirectory" && $keyattributelower == "objectsid")
{
@ -763,7 +764,7 @@ class Ldap
{
$criteria = '('.$this->getUserIdentifier().'='.$ldapUser.')';
$justthese = array("objectsid");
// if the directory is AD, then bind first with the search user first
if ($this->serverType == "activedirectory")
{
@ -776,7 +777,7 @@ class Ldap
while ($i <= 2)
{
$ldapSearchResult = @ldap_search($this->connection, $searchDN, $criteria, $justthese);
if (!$ldapSearchResult)
{
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
@ -810,7 +811,7 @@ class Ldap
return '?';
}
}
/**
* Returns the textual SID
* Indispensable pour Active Directory
@ -827,7 +828,7 @@ class Ldap
}
return $result;
}
/**
* \brief Fonction de recherche avec filtre
@ -892,7 +893,7 @@ class Ldap
while ($i <= 2)
{
$this->result = @ldap_search($this->connection, $searchDN, $filter);
if ($this->result)
{
$result = @ldap_get_entries($this->connection, $this->result);
@ -903,7 +904,7 @@ class Ldap
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
return -1;
}
if (!$result)
{
// Si pas de résultat on cherche dans le domaine
@ -943,7 +944,7 @@ class Ldap
}
if (!$this->name && !$this->login) $this->pwdlastset = -1;
$this->badpwdtime = $this->convert_time($this->convToOutputCharset($result[0]["badpasswordtime"][0],$this->ldapcharset));
// FQDN domain
$domain = eregi_replace('dc=','',$this->domain);
$domain = eregi_replace(',','.',$domain);
@ -1098,7 +1099,7 @@ class Ldap
return $unixTimeStamp;
}
/**
* \brief Convert a string into output/memory charset
* \param str String to convert

View File

@ -1,6 +1,6 @@
<?php
/* 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 Benoit Mortier <benoit.mortier@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)
{
$langs->trans("interventions");

View File

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

View File

@ -176,7 +176,7 @@ if ($_POST["action"] == 'add' && $canadduser)
{
$langs->load("errors");
$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
}