diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index dd6451537db..9610836254b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -69,11 +69,21 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_file($commande) > 0) + if ($obj->write_file($commande,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); return; } + else + { + $mesg='
'.$obj->error.'
'; + dolibarr_syslog($obj->error, LOG_ERR); + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + dolibarr_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } diff --git a/htdocs/admin/dons.php b/htdocs/admin/dons.php index d7e3e416bfa..5d0cd279915 100644 --- a/htdocs/admin/dons.php +++ b/htdocs/admin/dons.php @@ -55,11 +55,21 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_file($don) > 0) + if ($obj->write_file($don,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=don&file=SPECIMEN.html"); return; } + else + { + $mesg='
'.$obj->error.'
'; + dolibarr_syslog($obj->error, LOG_ERR); + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + dolibarr_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 94272857bff..73025cf4443 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -78,10 +78,16 @@ if ($_GET["action"] == 'specimen') header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); return; } + else + { + $mesg='
'.$obj->error.'
'; + dolibarr_syslog($obj->error, LOG_ERR); + } } else { $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + dolibarr_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index af698d89fad..7a83fbf3ba6 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -78,10 +78,16 @@ if ($_GET["action"] == 'specimen') header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf"); return; } + else + { + $mesg='
'.$obj->error.'
'; + dolibarr_syslog($obj->error, LOG_ERR); + } } else { $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + dolibarr_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 82ffcc01716..18ddd79ee44 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -21,11 +21,11 @@ */ /** - \file htdocs/admin/fournisseur.php - \ingroup fournisseur - \brief Page d'administration-configuration du module Fournisseur - \version $Id$ -*/ + \file htdocs/admin/fournisseur.php + \ingroup fournisseur + \brief Page d'administration-configuration du module Fournisseur + \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); @@ -38,108 +38,114 @@ $langs->load("other"); $langs->load("orders"); if (!$user->admin) - accessforbidden(); +accessforbidden(); /* * Actions */ - + if ($_POST["action"] == 'updateMask') { $maskconstorder=$_POST['maskconstorder']; $maskorder=$_POST['maskorder']; if ($maskconstorder) dolibarr_set_const($db,$maskconstorder,$maskorder); } - + if ($_GET["action"] == 'specimen') { - $modele=$_GET["module"]; - - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - - // Charge le modele - $dir = DOL_DOCUMENT_ROOT . "/includes/modules/supplier_order/pdf/"; - $file = "pdf_".$modele.".modules.php"; - if (file_exists($dir.$file)) - { - $classname = "pdf_".$modele; - require_once($dir.$file); - - $obj = new $classname($db); - - if ($obj->write_file($commande,$langs) > 0) + $modele=$_GET["module"]; + + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + + // Charge le modele + $dir = DOL_DOCUMENT_ROOT . "/includes/modules/supplier_order/pdf/"; + $file = "pdf_".$modele.".modules.php"; + if (file_exists($dir.$file)) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); - return; + $classname = "pdf_".$modele; + require_once($dir.$file); + + $obj = new $classname($db); + + if ($obj->write_file($commande,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); + return; + } + else + { + $mesg='
'.$obj->error.'
'; + dolibarr_syslog($obj->error, LOG_ERR); + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + dolibarr_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } - } - else - { - $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; - } } if ($_GET["action"] == 'set') { - $type='supplier_order'; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type) VALUES ('".$_GET["value"]."','".$type."')"; - if ($db->query($sql)) - { - - } + $type='supplier_order'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type) VALUES ('".$_GET["value"]."','".$type."')"; + if ($db->query($sql)) + { + + } } if ($_GET["action"] == 'del') { - $type='supplier_order'; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'"; - if ($db->query($sql)) - { - - } + $type='supplier_order'; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; + $sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'"; + if ($db->query($sql)) + { + + } } if ($_GET["action"] == 'setdoc') { $db->begin(); - - if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$_GET["value"])) - { - $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $_GET["value"]; - } - // On active le modele - $type='supplier_order'; - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'"; - $result1=$db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')"; - $result2=$db->query($sql); - if ($result1 && $result2) - { + if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$_GET["value"])) + { + $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $_GET["value"]; + } + + // On active le modele + $type='supplier_order'; + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; + $sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'"; + $result1=$db->query($sql_del); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')"; + $result2=$db->query($sql); + if ($result1 && $result2) + { $db->commit(); - } - else - { - $db->rollback(); - } + } + else + { + $db->rollback(); + } } if ($_GET["action"] == 'setmod') { - // \todo Verifier si module numerotation choisi peut etre activ� - // par appel methode canBeActivated + // \todo Verifier si module numerotation choisi peut etre activ� + // par appel methode canBeActivated dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$_GET["value"]); } if ($_POST["action"] == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user,$_POST["cat"]); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user,$_POST["cat"]); } // d�fini les constantes du mod�le orchidee @@ -183,55 +189,55 @@ clearstatcache(); $handle = opendir($dir); if ($handle) { - $var=true; - - while (($file = readdir($handle))!==false) - { - if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, strlen($file)-3, 3) == 'php') - { - $file = substr($file, 0, strlen($file)-4); + $var=true; - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/supplier_order/".$file.".php"); + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, strlen($file)-4); - $module = new $file; + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/supplier_order/".$file.".php"); + + $module = new $file; if ($module->isEnabled()) { - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - - $var=!$var; - print ''.$module->nom."\n"; - print $module->info(); - print ''; - - // Examples - print ''.$module->getExample()."\n"; - - print ''; - if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file") - { - print img_tick($langs->trans("Activated")); - } - else - { - print ''.$langs->trans("Activate").''; - } - print ''; - - $commande=new CommandeFournisseur($db); - $commande->initAsSpecimen(); - + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + $var=!$var; + print ''.$module->nom."\n"; + print $module->info(); + print ''; + + // Examples + print ''.$module->getExample()."\n"; + + print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file") + { + print img_tick($langs->trans("Activated")); + } + else + { + print ''.$langs->trans("Activate").''; + } + print ''; + + $commande=new CommandeFournisseur($db); + $commande->initAsSpecimen(); + // Info $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $facture->type=0; - $nextval=$module->getNextValue($mysoc,$commande); + $nextval=$module->getNextValue($mysoc,$commande); if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval { $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) + if ($nextval) { $htmltooltip.=$nextval.'
'; } @@ -240,16 +246,16 @@ if ($handle) $htmltooltip.=$langs->trans($module->error).'
'; } } - - print ''; - print $html->textwithhelp('',$htmltooltip,1,0); - print ''; - - print ''; + + print ''; + print $html->textwithhelp('',$htmltooltip,1,0); + print ''; + + print ''; } - } - } - closedir($handle); + } + } + closedir($handle); } print '
'; @@ -302,120 +308,120 @@ $handle=opendir($dir); $var=true; while (($file = readdir($handle))!==false) { - if (eregi('\.modules\.php$',$file) && substr($file,0,4) == 'pdf_') - { - $name = substr($file, 4, strlen($file) -16); - $classname = substr($file, 0, strlen($file) -12); - - $var=!$var; - print "\n $name"; - print "\n \n"; - require_once($dir.$file); - $module = new $classname($db); - print $module->description; - print "\n"; - - // Activ� - if (in_array($name, $def)) + if (eregi('\.modules\.php$',$file) && substr($file,0,4) == 'pdf_') { + $name = substr($file, 4, strlen($file) -16); + $classname = substr($file, 0, strlen($file) -12); + + $var=!$var; + print "\n $name"; + print "\n \n"; + require_once($dir.$file); + $module = new $classname($db); + print $module->description; + print "\n"; + + // Activ� + if (in_array($name, $def)) + { print "\n"; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") - { - print ''; - print img_tick($langs->trans("Disable")); - print ''; - } + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") + { + print ''; + print img_tick($langs->trans("Disable")); + print ''; + } else - { - print img_tick($langs->trans("Enabled")); - } + { + print img_tick($langs->trans("Enabled")); + } print ""; - } - else - { + } + else + { print "\n"; print ''.$langs->trans("Activate").''; print ""; - } - - // Defaut - print ""; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") - { + } + + // Defaut + print ""; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") + { print img_tick($langs->trans("Default")); - } - else - { + } + else + { print ''.$langs->trans("Default").''; + } + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").': '.$module->page_largeur; + $htmltooltip.='
'.$langs->trans("Height").': '.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg); + print ''; + print $html->textwithhelp('',$htmltooltip,1,0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"),'order').''; + print ''; + + print "\n"; } - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").': '.$module->page_largeur; - $htmltooltip.='
'.$langs->trans("Height").': '.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg); - print ''; - print $html->textwithhelp('',$htmltooltip,1,0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"),'order').''; - print ''; - - print "\n"; - } } closedir($handle); print '
'; /* Obsolete. Les categories de fournisseurs sont gerees dans la table llx_categories -sur le meme principe que les categories clients et produits + sur le meme principe que les categories clients et produits -print_titre($langs->trans("Categories")); + print_titre($langs->trans("Categories")); -$sql = "SELECT rowid, label"; -$sql.= " FROM ".MAIN_DB_PREFIX."fournisseur_categorie"; -$sql.= " ORDER BY label ASC"; + $sql = "SELECT rowid, label"; + $sql.= " FROM ".MAIN_DB_PREFIX."fournisseur_categorie"; + $sql.= " ORDER BY label ASC"; -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - - print '
'; - print ''; - print '\n"; - $var=True; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - print ""; - print '\n"; + print '
'; - print $langs->trans("Num").''.$langs->trans("Name"); - print "
  '; - print ''; - print "
'; + print ''; + print '\n"; + $var=True; - while ($obj = $db->fetch_object($resql)) - { - $var=!$var; - print "\n"; - print ''; - print ''; - print "\n"; - } - print "
'; + print $langs->trans("Num").''.$langs->trans("Name"); + print "
'.$obj->rowid.''.stripslashes($obj->label).'
\n"; + print " "; + print ' '; + print ''; + print "\n"; - $db->free($resql); -} -else -{ - dolibarr_print_error($db); -} -*/ + while ($obj = $db->fetch_object($resql)) + { + $var=!$var; + print "\n"; + print ''.$obj->rowid.''; + print ''.stripslashes($obj->label).''; + print "\n"; + } + print "\n"; + + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + */ llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 97ed374d7f4..da2ba63f5b2 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -70,11 +70,21 @@ if ($_GET["action"] == 'specimen') $module = new $classname($db); - if ($module->write_file($propal) > 0) + if ($module->write_file($propal,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf"); return; } + else + { + $mesg='
'.$module->error.'
'; + dolibarr_syslog($module->error, LOG_ERR); + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + dolibarr_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } diff --git a/htdocs/comm/action/rapport/rapport.pdf.php b/htdocs/comm/action/rapport/rapport.pdf.php index b28e23fb469..e40a14de321 100644 --- a/htdocs/comm/action/rapport/rapport.pdf.php +++ b/htdocs/comm/action/rapport/rapport.pdf.php @@ -77,7 +77,7 @@ class CommActionRapport if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/comm/pre.inc.php b/htdocs/comm/pre.inc.php index 80240768cfd..c0840bfc0aa 100644 --- a/htdocs/comm/pre.inc.php +++ b/htdocs/comm/pre.inc.php @@ -15,15 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/comm/pre.inc.php \ingroup commercial \brief Fichier de gestion du menu gauche de l'espace commercial - \version $Revision$ + \version $Id$ */ require("../main.inc.php"); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e9c92e231ec..6e92b9fa32b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -22,10 +22,10 @@ */ /** - \file htdocs/comm/propal.php - \ingroup propale - \brief Page liste des propales (vision commercial) - \version $Id$ + * \file htdocs/comm/propal.php + * \ingroup propale + * \brief Page liste des propales (vision commercial) + * \version $Id$ */ require("./pre.inc.php"); diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index c6fb0d1697e..60bb9d2fd21 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -18,10 +18,10 @@ */ /** - \file htdocs/commande/index.php - \ingroup commande - \brief Page acceuil espace commandes - \version $Id$ + * \file htdocs/commande/index.php + * \ingroup commande + * \brief Page acceuil espace commandes + * \version $Id$ */ require("./pre.inc.php"); @@ -42,6 +42,11 @@ if ($user->societe_id > 0) } + +/* + * View + */ + $commandestatic=new Commande($db); $html = new Form($db); $formfile = new FormFile($db); diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index 071a4867304..bb57a2225bc 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -18,11 +18,11 @@ */ /** - \file htdocs/compta/paiement/cheque/fiche.php - \ingroup facture - \brief Onglet paiement cheque - \version $Id$ -*/ + \file htdocs/compta/paiement/cheque/fiche.php + \ingroup facture + \brief Onglet paiement cheque + \version $Id$ + */ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); @@ -55,82 +55,82 @@ $offset = $limit * $page ; */ if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banque->cheque) -{ - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->Create($user, $_GET["accountid"]); - if ($result > 0) - { - Header("Location: fiche.php?id=".$remisecheque->id); - exit; - } - else - { - $mesg='
'.$remisecheque->error.'
'; - } +{ + $remisecheque = new RemiseCheque($db); + $result = $remisecheque->Create($user, $_GET["accountid"]); + if ($result > 0) + { + Header("Location: fiche.php?id=".$remisecheque->id); + exit; + } + else + { + $mesg='
'.$remisecheque->error.'
'; + } } if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque) -{ - $remisecheque = new RemiseCheque($db); - $remisecheque->id = $_GET["id"]; - $result = $remisecheque->RemoveCheck($_GET["lineid"]); - if ($result === 0) - { - Header("Location: fiche.php?id=".$remisecheque->id); - exit; - } - else - { - $mesg='
'.$paiement->error.'
'; - } +{ + $remisecheque = new RemiseCheque($db); + $remisecheque->id = $_GET["id"]; + $result = $remisecheque->RemoveCheck($_GET["lineid"]); + if ($result === 0) + { + Header("Location: fiche.php?id=".$remisecheque->id); + exit; + } + else + { + $mesg='
'.$paiement->error.'
'; + } } if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->banque) { - $remisecheque = new RemiseCheque($db); - $remisecheque->id = $_GET["id"]; - $result = $remisecheque->Delete(); - if ($result == 0) - { - Header("Location: index.php"); - exit; - } - else - { - $mesg='
'.$paiement->error.'
'; - } + $remisecheque = new RemiseCheque($db); + $remisecheque->id = $_GET["id"]; + $result = $remisecheque->Delete(); + if ($result == 0) + { + Header("Location: index.php"); + exit; + } + else + { + $mesg='
'.$paiement->error.'
'; + } } if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->banque) { - $remisecheque = new RemiseCheque($db); - $remisecheque->Fetch($_GET["id"]); - $result = $remisecheque->Validate($user); - if ($result == 0) - { - Header("Location: fiche.php?id=".$remisecheque->id); - exit; - } - else - { - $mesg='
'.$paiement->error.'
'; - } + $remisecheque = new RemiseCheque($db); + $remisecheque->Fetch($_GET["id"]); + $result = $remisecheque->Validate($user); + if ($result == 0) + { + Header("Location: fiche.php?id=".$remisecheque->id); + exit; + } + else + { + $mesg='
'.$paiement->error.'
'; + } } if ($_POST['action'] == 'builddoc' && $user->rights->banque) { - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->Fetch($_GET["id"]); - if ($result == 0) - { - $result = $remisecheque->GeneratePdf($_POST["model"]); - Header("Location: fiche.php?id=".$remisecheque->id); - exit; - } - else - { - $mesg='
'.$paiement->error.'
'; - } + $remisecheque = new RemiseCheque($db); + $result = $remisecheque->Fetch($_GET["id"]); + if ($result == 0) + { + $result = $remisecheque->GeneratePdf($_POST["model"], $langs); + Header("Location: fiche.php?id=".$remisecheque->id); + exit; + } + else + { + $mesg='
'.$paiement->error.'
'; + } } @@ -145,13 +145,13 @@ $formfile = new FormFile($db); if ($_GET['action'] == 'new') { - $h=0; - $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?action=new'; - $head[$h][1] = $langs->trans("MenuChequeDeposits"); - $hselected = $h; - $h++; + $h=0; + $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?action=new'; + $head[$h][1] = $langs->trans("MenuChequeDeposits"); + $hselected = $h; + $h++; - dolibarr_fiche_head($head, $hselected, $langs->trans("Cheques")); + dolibarr_fiche_head($head, $hselected, $langs->trans("Cheques")); } else { @@ -165,8 +165,8 @@ else $result = $remisecheque->Fetch('',$_GET["ref"]); } - - + + $h=0; $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?id='.$remisecheque->id; $head[$h][1] = $langs->trans("CheckReceipt"); @@ -174,13 +174,13 @@ else $h++; // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$remisecheque->id; // $head[$h][1] = $langs->trans("Info"); - // $h++; + // $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Cheques")); /* - * Confirmation de la suppression du bordereau - */ + * Confirmation de la suppression du bordereau + */ if ($_GET['action'] == 'delete') { $html->form_confirm('fiche.php?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), 'Etes-vous sûr de vouloir supprimer ce bordereau ?', 'confirm_delete'); @@ -188,8 +188,8 @@ else } /* - * Confirmation de la validation du bordereau - */ + * Confirmation de la validation du bordereau + */ if ($_GET['action'] == 'valide') { $facid = $_GET['facid']; @@ -205,13 +205,13 @@ if ($_GET['action'] == 'new') { $accounts = array(); $lines = array(); - + $now=time(); - + print ''; print ''; print '
'.$langs->trans('Date').''.dolibarr_print_date($now,'day').'

'; - + $sql = "SELECT ba.rowid as bid, ".$db->pdate("b.dateo")." as date,"; $sql.= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b "; @@ -219,7 +219,7 @@ if ($_GET['action'] == 'new') $sql.= " WHERE b.fk_type = 'CHQ' AND b.fk_account = ba.rowid"; $sql.= " AND b.fk_bordereau = 0 AND b.amount > 0"; $sql.= " ORDER BY b.emetteur ASC, b.rowid ASC"; - + $resql = $db->query($sql); if ($resql) { @@ -237,10 +237,10 @@ if ($_GET['action'] == 'new') if ($i == 0) { - print $langs->trans("NoWaitingChecks").'
'; + print $langs->trans("NoWaitingChecks").'
'; } } - + foreach ($accounts as $bid => $account_label) { $num = $db->num_rows($resql); @@ -253,16 +253,16 @@ if ($_GET['action'] == 'new') print ''.$langs->trans("Bank")."\n"; print ''.$langs->trans("Amount")."\n"; print "\n"; - + $var=true; - + foreach ($lines[$bid] as $lid => $value) { $var=!$var; - + $account_id = $objp->bid; $accounts[$objp->bid] += 1; - + print ""; print ''.dolibarr_print_date($value["date"],'day').''; print ''.$value["numero"]."\n"; @@ -273,7 +273,7 @@ if ($_GET['action'] == 'new') $i++; } print ""; - + print '
'; if ($user->rights->banque->cheque) { @@ -292,13 +292,13 @@ else $paymentstatic=new Paiement($db); $accountlinestatic=new AccountLine($db); $accountstatic=new Account($db); - + $accountstatic->id=$remisecheque->account_id; $accountstatic->label=$remisecheque->account_label; print ''; print '"; @@ -310,7 +310,7 @@ else print $accountstatic->getNomUrl(1); print ''; - // Nb of cheques + // Nb of cheques print ''; @@ -321,7 +321,7 @@ else print '
'.$langs->trans('Ref').''; - + print $html->showrefnav($remisecheque,'ref','', 1, 'number'); print "
'.$langs->trans('NbOfCheques').''; print $remisecheque->nbcheque; print '

'; - + // Liste des cheques $sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,"; $sql.= " ".$db->pdate("b.dateo")." as date,".$db->pdate("b.datec")." as datec, b.banque,"; @@ -400,12 +400,12 @@ print '
'; if ($_GET['action'] != 'new') { - if ($remisecheque->statut == 1) - { - $dir = DOL_DATA_ROOT.'/compta/bordereau/'.get_exdir($remisecheque->number); - $gen = array('Blochet'); - $formfile->show_documents("remisecheque","",$dir,'',$gen,0); - } + if ($remisecheque->statut == 1) + { + $dir = DOL_DATA_ROOT.'/compta/bordereau/'.get_exdir($remisecheque->number); + $gen = array('Blochet'); + $formfile->show_documents("remisecheque","",$dir,'',$gen,0); + } } /* @@ -416,18 +416,18 @@ print '
'; if ($user->societe_id == 0 && sizeof($accounts) == 1 && $_GET['action'] == 'new') { - print ''.$langs->trans('NewCheckReceipt').''; + print ''.$langs->trans('NewCheckReceipt').''; } if ($user->societe_id == 0 && $remisecheque->statut == 0 && $_GET['action'] == '') { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } if ($user->societe_id == 0 && $remisecheque->statut == 0 && $_GET['action'] == '') { - print ''.$langs->trans('Delete').''; - + print ''.$langs->trans('Delete').''; + } print '
'; diff --git a/htdocs/compta/paiement/cheque/pdf/README b/htdocs/compta/paiement/cheque/pdf/README deleted file mode 100644 index 4b6ffd37a90..00000000000 --- a/htdocs/compta/paiement/cheque/pdf/README +++ /dev/null @@ -1,59 +0,0 @@ -Liste des termes a employer - -http://fr.wikipedia.org/wiki/Charpente - -dans la section termes utilisés : - -Utilisé -======= - Blochet - -Libre : -======= - Aisselier - Arbalétrier ou poutre - Arêtier - - Chevêtre - Chevron - Chevron ou faux comble - Comble - Comble à surcroît - Comble brisé dit à la Mansart - Contrefiche - Coyer - Coyau - Dé - Échantignole - Enrayure - Entrait moisé - Entrait ou Tirant - Entrait retroussé ou faux entrait - Faîtage - Faîte - Faux-entrait - Ferme - Ferme à une pente ou appentis - Gousset - Hourdis - Jambe de force - Jambe de force moisée - Jambette - Lien de faîtage - Lierne ou sous faîte - Linçoir - Moise - Noue - Panne - Panne faîtière - Pignon - Poinçon - Portée - Poutre - Sablière - Solive - Solive boiteuse - Solive d'enchevêtrure - Sous faîte - Trémie - diff --git a/htdocs/compta/paiement/cheque/remisecheque.class.php b/htdocs/compta/paiement/cheque/remisecheque.class.php index 5bddea51926..0b0f1c76097 100644 --- a/htdocs/compta/paiement/cheque/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/remisecheque.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007 Laurent Destailleur +/* Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007-2008 Laurent Destailleur * * 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 @@ -15,31 +15,28 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** - \file htdocs/compta/paiement/cheque/remisecheque.class.php - \ingroup compta - \brief Fichier de la classe des bordereau de remise de cheque - \version $Revision$ -*/ + * \file htdocs/compta/paiement/cheque/remisecheque.class.php + * \ingroup compta + * \brief Fichier de la classe des bordereau de remise de cheque + * \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); /** - \class RemiseCheque - \brief Classe permettant la gestion des remises de cheque -*/ - + * \class RemiseCheque + * \brief Classe permettant la gestion des remises de cheque + */ class RemiseCheque extends CommonObject { var $db; var $error; - var $element='chequereceipt'; - var $table_element='bordereau_cheque'; + var $element='chequereceipt'; + var $table_element='bordereau_cheque'; var $id; var $num; @@ -48,23 +45,22 @@ class RemiseCheque extends CommonObject var $errno; /** - * \brief Constructeur de la classe - * \param DB handler accès base de données - * \param id id compte (0 par defaut) - */ - function RemiseCheque($DB,$langs='') - { - $this->db = $DB; - $this->langs = $langs; - $this->next_id = 0; - $this->previous_id = 0; - } + * \brief Constructeur de la classe + * \param DB handler accès base de données + * \param id id compte (0 par defaut) + */ + function RemiseCheque($DB) + { + $this->db = $DB; + $this->next_id = 0; + $this->previous_id = 0; + } /** \brief Load record \param id Id record \param ref Ref record - */ + */ function Fetch($id,$ref='') { $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author,bc.fk_bank_account,bc.amount,bc.number,bc.statut,bc.nbcheque"; @@ -116,7 +112,7 @@ class RemiseCheque extends CommonObject \param user Utilisateur qui effectue l'operation \param account_id Compte bancaire concerne \return int <0 if KO, >0 if OK - */ + */ function Create($user, $account_id) { $this->errno = 0; @@ -126,7 +122,7 @@ class RemiseCheque extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."bordereau_cheque (datec, date_bordereau, fk_user_author, fk_bank_account, amount, number, nbcheque)"; $sql.= " VALUES (".$this->db->idate(mktime()).",".$this->db->idate(mktime()).",".$user->id.",".$account_id.",0,0,0)"; - + dolibarr_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ( $resql ) @@ -143,14 +139,14 @@ class RemiseCheque extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; $sql.= " SET number='(PROV".$this->id.")'"; $sql.= " WHERE rowid='".$this->id."';"; - + dolibarr_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) - { + { $this->errno = -1025; dolibarr_syslog("RemiseCheque::Create ERREUR UPDATE ($this->errno)", LOG_ERR); - } + } } if ($this->id > 0 && $this->errno == 0) @@ -186,11 +182,11 @@ class RemiseCheque extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; $sql.= " SET fk_bordereau = ".$this->id; $sql.= " WHERE rowid = ".$lineid; - + dolibarr_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) - { + { $this->errno = -18; dolibarr_syslog("RemiseCheque::Create Error update bank ($this->errno)", LOG_ERR); } @@ -200,7 +196,7 @@ class RemiseCheque extends CommonObject if ($this->id > 0 && $this->errno == 0) { if ($this->UpdateAmount() <> 0) - { + { $this->errno = -1027; dolibarr_syslog("RemiseCheque::Create ERREUR ($this->errno)"); } @@ -212,7 +208,7 @@ class RemiseCheque extends CommonObject $this->error=$this->db->lasterror(); dolibarr_syslog("RemiseCheque::Create Erreur $result INSERT Mysql"); } - + if ($this->errno == 0) { @@ -225,346 +221,360 @@ class RemiseCheque extends CommonObject dolibarr_syslog("RemiseCheque::Create ROLLBACK ($this->errno)"); return $this->errno; } - + } - /** - \brief Supprime la remise en base - \param user utilisateur qui effectue l'operation - */ - function Delete($user='') - { - $this->errno = 0; - $this->db->begin(); + /** + \brief Supprime la remise en base + \param user utilisateur qui effectue l'operation + */ + function Delete($user='') + { + $this->errno = 0; + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " WHERE rowid = $this->id;"; - - $resql = $this->db->query($sql); - if ( $resql ) - { - $num = $this->db->affected_rows($resql); - - if ($num <> 1) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql .= " WHERE rowid = $this->id;"; + + $resql = $this->db->query($sql); + if ( $resql ) + { + $num = $this->db->affected_rows($resql); + + if ($num <> 1) { - $this->errno = -2; - dolibarr_syslog("Remisecheque::Delete Erreur Lecture ID ($this->errno)"); + $this->errno = -2; + dolibarr_syslog("Remisecheque::Delete Erreur Lecture ID ($this->errno)"); } - if ( $this->errno === 0) + if ( $this->errno === 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET fk_bordereau=0"; - $sql.= " WHERE fk_bordereau='".$this->id."';"; - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errno = -1028; - dolibarr_syslog("RemiseCheque::Delete ERREUR UPDATE ($this->errno)"); - } + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET fk_bordereau=0"; + $sql.= " WHERE fk_bordereau='".$this->id."';"; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errno = -1028; + dolibarr_syslog("RemiseCheque::Delete ERREUR UPDATE ($this->errno)"); + } } - } + } - if ($this->errno === 0) - { - $this->db->commit(); - } - else - { - $this->db->rollback(); - dolibarr_syslog("RemiseCheque::Delete ROLLBACK ($this->errno)"); - } - - return $this->errno; - } - - /** - * \brief Validate receipt - * \param user User - */ - function Validate($user) - { - $this->errno = 0; - $this->db->begin(); + if ($this->errno === 0) + { + $this->db->commit(); + } + else + { + $this->db->rollback(); + dolibarr_syslog("RemiseCheque::Delete ROLLBACK ($this->errno)"); + } - $num=$this->getNextNumber(); - - if ($this->errno === 0) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " SET statut=1, number='".$num."'"; - $sql .= " WHERE rowid = $this->id AND statut=0;"; + return $this->errno; + } - $resql = $this->db->query($sql); - if ( $resql ) - { - $num = $this->db->affected_rows($resql); + /** + * \brief Validate receipt + * \param user User + */ + function Validate($user) + { + $this->errno = 0; + $this->db->begin(); - if ($num == 1) - { - $this->statut = 1; - } - else - { - $this->errno = -1029; - dolibarr_syslog("Remisecheque::Validate Erreur UPDATE ($this->errno)"); - } - } - else - { - $this->errno = -1033; - dolibarr_syslog("Remisecheque::Validate Erreur UPDATE ($this->errno)"); - } - } + $num=$this->getNextNumber(); + + if ($this->errno === 0) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " SET statut=1, number='".$num."'"; + $sql .= " WHERE rowid = $this->id AND statut=0;"; - if ($this->errno === 0) - { - $this->GeneratePdf(); - } + $resql = $this->db->query($sql); + if ( $resql ) + { + $num = $this->db->affected_rows($resql); - if ($this->errno === 0) - { - $this->db->commit(); - } - else - { - $this->db->rollback(); - dolibarr_syslog("RemiseCheque::Validate ".$this->errno, LOG_ERR); - } + if ($num == 1) + { + $this->statut = 1; + } + else + { + $this->errno = -1029; + dolibarr_syslog("Remisecheque::Validate Erreur UPDATE ($this->errno)"); + } + } + else + { + $this->errno = -1033; + dolibarr_syslog("Remisecheque::Validate Erreur UPDATE ($this->errno)"); + } + } - return $this->errno; - } + if ($this->errno === 0) + { + $this->GeneratePdf(); + } + + if ($this->errno === 0) + { + $this->db->commit(); + } + else + { + $this->db->rollback(); + dolibarr_syslog("RemiseCheque::Validate ".$this->errno, LOG_ERR); + } + + return $this->errno; + } - /** - * Old module for cheque receipt numbering - * - * @return string - */ - function getNextNumber() - { - $num=0; - - // We use +0 to convert varchar to number - $sql = "SELECT MAX(number+0) FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - $num = $row[0]; - $this->db->free($resql); - } - else - { - $this->errno = -1034; - dolibarr_syslog("Remisecheque::Validate Erreur SELECT ($this->errno)"); - } - - $num++; - - return $num; - } - - /** - * \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord - * \param user Objet user - * \return int <0 si ko, >0 si ok - */ - function load_board($user) - { - global $conf; - - if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + /** + * Old module for cheque receipt numbering + * + * @return string + */ + function getNextNumber() + { + $num=0; - $this->nbtodo=$this->nbtodolate=0; + // We use +0 to convert varchar to number + $sql = "SELECT MAX(number+0) FROM ".MAIN_DB_PREFIX."bordereau_cheque"; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + $num = $row[0]; + $this->db->free($resql); + } + else + { + $this->errno = -1034; + dolibarr_syslog("Remisecheque::Validate Erreur SELECT ($this->errno)"); + } + + $num++; + + return $num; + } + + /** + * \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord + * \param user Objet user + * \return int <0 si ko, >0 si ok + */ + function load_board($user) + { + global $conf; + + if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe + + $this->nbtodo=$this->nbtodolate=0; $sql = "SELECT b.rowid,".$this->db->pdate("b.datev")." as datefin"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE b.fk_type = 'CHQ' AND b.fk_bordereau = 0"; $sql.= " AND b.amount > 0"; - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { - $this->nbtodo++; - if ($obj->datefin < (time() - $conf->bank->cheque->warning_delay)) $this->nbtodolate++; - } - return 1; - } - else - { - dolibarr_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } - } - - - /** - \brief Génère le fichier PDF - \param model Nom du modele - \return int <0 si KO, 0 si OK - \TODO Finir la gestion multi modèle - */ - function GeneratePdf($model='Blochet') - { - require_once(DOL_DOCUMENT_ROOT ."/compta/bank/account.class.php"); - require_once(DOL_DOCUMENT_ROOT ."/compta/paiement/cheque/pdf/pdf_blochet.class.php"); + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nbtodo++; + if ($obj->datefin < (time() - $conf->bank->cheque->warning_delay)) $this->nbtodolate++; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } - $result = $this->Fetch($this->id); - $pdf = new BordereauChequeBlochet($db); + /** + * \brief Génère le fichier PDF + * \param model Nom du modele + * \return int <0 si KO, 0 si OK + */ + function GeneratePdf($model='blochet', $outputlangs) + { + require_once(DOL_DOCUMENT_ROOT ."/compta/bank/account.class.php"); + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/cheque/pdf/pdf_".$model.".class.php"); - $sql = "SELECT b.banque, b.emetteur, b.amount, b.num_chq "; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba "; - $sql.= " , ".MAIN_DB_PREFIX."bordereau_cheque as bc"; - $sql.= " WHERE b.fk_account = ba.rowid AND b.fk_bordereau = bc.rowid"; - $sql.= " AND bc.rowid = ".$this->id; - $sql.= " ORDER BY b.emetteur ASC, b.rowid ASC;"; + $result = $this->Fetch($this->id); - $result = $this->db->query($sql); - - if ($result) - { - $i = 0; - while ( $objp = $this->db->fetch_object($result) ) - { - $pdf->lines[$i]->bank_chq = $objp->banque; - $pdf->lines[$i]->emetteur_chq = $objp->emetteur; - $pdf->lines[$i]->amount_chq = $objp->amount; - $pdf->lines[$i]->num_chq = $objp->num_chq; - $i++; - } - } - $pdf->nbcheque = $this->nbcheque; - $pdf->number = $this->number; - $pdf->amount = $this->amount; - $pdf->date = $this->date_bordereau; + $class='BordereauCheque'.ucfirst($model); + $pdf = new $class($db); - $account = new Account($this->db); - $account->fetch($this->account_id); + $sql = "SELECT b.banque, b.emetteur, b.amount, b.num_chq "; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba "; + $sql.= " , ".MAIN_DB_PREFIX."bordereau_cheque as bc"; + $sql.= " WHERE b.fk_account = ba.rowid AND b.fk_bordereau = bc.rowid"; + $sql.= " AND bc.rowid = ".$this->id; + $sql.= " ORDER BY b.emetteur ASC, b.rowid ASC;"; - $pdf->account = &$account; - - $pdf->write_file(DOL_DATA_ROOT.'/compta/bordereau', $this->number ); - } + $result = $this->db->query($sql); - /** - \brief Mets a jour le montant total - \return int, 0 en cas de succes - */ - function UpdateAmount() - { - $this->errno = 0; - $this->db->begin(); - $total = 0; - $nb = 0; - $sql = "SELECT amount "; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_bordereau = $this->id;"; - - $resql = $this->db->query($sql); - if ( $resql ) - { - while ( $row = $this->db->fetch_row($resql) ) + if ($result) + { + $i = 0; + while ( $objp = $this->db->fetch_object($result) ) + { + $pdf->lines[$i]->bank_chq = $objp->banque; + $pdf->lines[$i]->emetteur_chq = $objp->emetteur; + $pdf->lines[$i]->amount_chq = $objp->amount; + $pdf->lines[$i]->num_chq = $objp->num_chq; + $i++; + } + } + $pdf->nbcheque = $this->nbcheque; + $pdf->number = $this->number; + $pdf->amount = $this->amount; + $pdf->date = $this->date_bordereau; + + $account = new Account($this->db); + $account->fetch($this->account_id); + + $pdf->account = &$account; + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($pdf->write_file(DOL_DATA_ROOT.'/compta/bordereau', $this->number, $outputlangs) > 0) + { + $outputlangs->charset_output=$sav_charset_output; + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dolibarr_syslog("Error"); + dolibarr_print_error($db,$pdf->pdferror()); + return 0; + } + } + + /** + \brief Mets a jour le montant total + \return int, 0 en cas de succes + */ + function UpdateAmount() + { + $this->errno = 0; + $this->db->begin(); + $total = 0; + $nb = 0; + $sql = "SELECT amount "; + $sql.= " FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_bordereau = $this->id;"; + + $resql = $this->db->query($sql); + if ( $resql ) + { + while ( $row = $this->db->fetch_row($resql) ) { - $total += $row[0]; - $nb++; + $total += $row[0]; + $nb++; } - - $this->db->free($resql); - $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " SET amount='".price2num($total)."'"; - $sql.= " ,nbcheque=".$nb; - $sql.= " WHERE rowid='".$this->id."';"; - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errno = -1030; - dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR UPDATE ($this->errno)"); - } - } - else - { - $this->errno = -1031; - dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR SELECT ($this->errno)"); - } + $this->db->free($resql); - if ($this->errno === 0) - { - $this->db->commit(); - } - else - { - $this->db->rollback(); - dolibarr_syslog("RemiseCheque::UpdateAmount ROLLBACK ($this->errno)"); - } - - return $this->errno; - } - - /** - \brief Insère la remise en base - \param user utilisateur qui effectue l'operation - \param account_id Compte bancaire concerne - */ - function RemoveCheck($account_id) - { - $this->errno = 0; - - if ($this->id > 0) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET fk_bordereau = 0 "; - $sql.= " WHERE rowid = '".$account_id."' AND fk_bordereau='".$this->id."';"; - $resql = $this->db->query($sql); - if ($resql) + $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " SET amount='".price2num($total)."'"; + $sql.= " ,nbcheque=".$nb; + $sql.= " WHERE rowid='".$this->id."';"; + $resql = $this->db->query($sql); + if (!$resql) { - $this->UpdateAmount(); + $this->errno = -1030; + dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR UPDATE ($this->errno)"); } - else + } + else + { + $this->errno = -1031; + dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR SELECT ($this->errno)"); + } + + if ($this->errno === 0) + { + $this->db->commit(); + } + else + { + $this->db->rollback(); + dolibarr_syslog("RemiseCheque::UpdateAmount ROLLBACK ($this->errno)"); + } + + return $this->errno; + } + + /** + \brief Insère la remise en base + \param user utilisateur qui effectue l'operation + \param account_id Compte bancaire concerne + */ + function RemoveCheck($account_id) + { + $this->errno = 0; + + if ($this->id > 0) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql.= " SET fk_bordereau = 0 "; + $sql.= " WHERE rowid = '".$account_id."' AND fk_bordereau='".$this->id."';"; + $resql = $this->db->query($sql); + if ($resql) { - $this->errno = -1032; - dolibarr_syslog("RemiseCheque::RemoveCheck ERREUR UPDATE ($this->errno)"); - } - } - return 0; - } - /** - \brief Charge les propriétés ref_previous et ref_next - \return int <0 si ko, 0 si ok - */ - function load_previous_next_id() - { - $this->errno = 0; + $this->UpdateAmount(); + } + else + { + $this->errno = -1032; + dolibarr_syslog("RemiseCheque::RemoveCheck ERREUR UPDATE ($this->errno)"); + } + } + return 0; + } + /** + \brief Charge les propriétés ref_previous et ref_next + \return int <0 si ko, 0 si ok + */ + function load_previous_next_id() + { + $this->errno = 0; - $sql = "SELECT MAX(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " WHERE rowid < '".$this->id."'"; + $sql = "SELECT MAX(rowid)"; + $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " WHERE rowid < '".$this->id."'"; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->errno = -1035; - } - $row = $this->db->fetch_row($result); - $this->previous_id = $row[0]; - - $sql = "SELECT MIN(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " WHERE rowid > '".$this->id."'"; - $result = $this->db->query($sql) ; - if (! $result) - { - $this->errno = -1035; - } - $row = $this->db->fetch_row($result); - $this->next_id = $row[0]; - - return $this->errno; - } + $result = $this->db->query($sql) ; + if (! $result) + { + $this->errno = -1035; + } + $row = $this->db->fetch_row($result); + $this->previous_id = $row[0]; + + $sql = "SELECT MIN(rowid)"; + $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; + $sql.= " WHERE rowid > '".$this->id."'"; + $result = $this->db->query($sql) ; + if (! $result) + { + $this->errno = -1035; + } + $row = $this->db->fetch_row($result); + $this->next_id = $row[0]; + + return $this->errno; + } /** @@ -576,7 +586,7 @@ class RemiseCheque extends CommonObject function getNomUrl($withpicto=0,$option='') { global $langs; // TODO Renvoyer le libellé anglais et faire traduction a affichage - + $result=''; $number=$this->number; @@ -591,21 +601,21 @@ class RemiseCheque extends CommonObject } /** - * \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée) - * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto - * \return string Libelle - */ + * \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée) + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto + * \return string Libelle + */ function getLibStatut($mode=0) { return $this->LibStatut($this->statut,$mode); } - + /** - * \brief Renvoi le libellé d'un statut donne - * \param status Statut - * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto - * \return string Libellé du statut - */ + * \brief Renvoi le libellé d'un statut donne + * \param status Statut + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto + * \return string Libellé du statut + */ function LibStatut($status,$mode=0) { global $langs; // TODO Renvoyer le libellé anglais et faire traduction a affichage @@ -642,6 +652,6 @@ class RemiseCheque extends CommonObject } return $langs->trans('Unknown'); } - + } ?> diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index d8f0e8f7f49..559430767e3 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -18,29 +18,29 @@ * * $Id$ */ - + /** - \file htdocs/compta/paiement/rapport.php - \ingroup facture - \brief Rapports de paiements - \version $Revision$ -*/ + \file htdocs/compta/paiement/rapport.php + \ingroup facture + \brief Rapports de paiements + \version $Revision$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/rapport/pdf_paiement.class.php"); // Sécurité accés if (! $user->rights->facture->lire) - accessforbidden(); +accessforbidden(); $dir = $conf->compta->dir_output.'/payments'; $socid=0; -if ($user->societe_id > 0) +if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; - $dir = DOL_DATA_ROOT.'/private/'.$user->id.'/compta'; + $action = ''; + $socid = $user->societe_id; + $dir = DOL_DATA_ROOT.'/private/'.$user->id.'/compta'; } $year = $_GET["year"]; @@ -51,12 +51,27 @@ if (! $year) { $year=date("Y"); } */ if ($_POST["action"] == 'gen') { - $rap = new pdf_paiement($db); - $rap->write_file($dir, $_POST["remonth"], $_POST["reyear"]); - - $year = $_POST["reyear"]; + $rap = new pdf_paiement($db); + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0) + { + $outputlangs->charset_output=$sav_charset_output; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dolibarr_syslog("Erreur dans commande_pdf_create"); + dolibarr_print_error($db,$obj->pdferror()); + } + + $year = $_POST["reyear"]; } + + llxHeader(); /* @@ -71,32 +86,32 @@ print '
'; print ''; $cmonth = date("n", time()); $syear = date("Y", time()); - + print '"; print '\n"; print ''; @@ -109,46 +124,46 @@ clearstatcache(); $found=0; if (is_dir($dir)) { - $handle=opendir($dir); - while (($file = readdir($handle))!==false) - { - if (is_dir($dir.'/'.$file) && ! eregi('^\.',$file)) + $handle=opendir($dir); + while (($file = readdir($handle))!==false) { + if (is_dir($dir.'/'.$file) && ! eregi('^\.',$file)) + { $found=1; print ''.$file.' '; + } } - } } if ($year) { - if (is_dir($dir.'/'.$year)) - { - $handle=opendir($dir.'/'.$year); - - if ($found) print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=true; - while (($file = readdir($handle))!==false) + if (is_dir($dir.'/'.$year)) { + $handle=opendir($dir.'/'.$year); + + if ($found) print '
'; + print '
'; + print '
'.$langs->trans("Reporting").''.$langs->trans("Size").''.$langs->trans("Date").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + while (($file = readdir($handle))!==false) + { if (eregi('^payment',$file)) - { - $var=!$var; - $tfile = $dir . '/'.$year.'/'.$file; - $relativepath = $year.'/'.$file; - print "".''; - print ''; - print ''; - } + { + $var=!$var; + $tfile = $dir . '/'.$year.'/'.$file; + $relativepath = $year.'/'.$file; + print "".''; + print ''; + print ''; + } + } + print '
'.$langs->trans("Reporting").''.$langs->trans("Size").''.$langs->trans("Date").'
'.img_pdf().' '.$file.''.filesize($tfile). ' '.$langs->trans("Bytes").''.dolibarr_print_date(filemtime($tfile),"dayhour").'
'.img_pdf().' '.$file.''.filesize($tfile). ' '.$langs->trans("Bytes").''.dolibarr_print_date(filemtime($tfile),"dayhour").'
'; } - print ''; - } } $db->close(); diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 0b83d591b23..359b1889fec 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -62,11 +62,14 @@ $staticcontratligne=new ContratLigne($db); * View */ +$now=mktime(); + $form=new Form($db); llxHeader(); -$sql = "SELECT s.rowid as socid, s.nom, c.rowid as cid,"; +$sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,"; +$sql.= " s.rowid as socid, s.nom,"; $sql.= " cd.rowid, cd.description, cd.statut, p.rowid as pid, p.label as label,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_ouverture_prevue,"; @@ -165,14 +168,19 @@ if ($resql) print "\n"; print '
'; - $now=mktime(); $var=True; while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); $var=!$var; print ""; - print ''.img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.''; + print ''; + $contractstatic=new Contrat($db); + $contractstatic->id=$obj->cid; + $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; + print $contractstatic->getNomUrl(1); + //''.img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.''; + print ''; print ''; if ($obj->pid) { @@ -202,9 +210,17 @@ if ($resql) else print '    '; print ''; print ''; - print ''; - print $staticcontratligne->LibStatut($obj->statut,5); - print ''; + if ($obj->cstatut == 0) + { + print $contractstatic->LibStatut(0,5); + } + else + { + print ''; + print $staticcontratligne->LibStatut($obj->statut,5); + print ''; + } + print ''; print "\n"; $i++; } diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index b0f3d7c1f72..7512f100550 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -18,11 +18,11 @@ */ /** - \file htdocs/fourn/commande/index.php - \ingroup commande - \brief Page accueil commandes fournisseurs - \version $Revision$ -*/ + * \file htdocs/fourn/commande/index.php + * \ingroup commande + * \brief Page accueil commandes fournisseurs + * \version $Revision$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); @@ -40,6 +40,7 @@ $result = restrictedArea($user, 'commande_fournisseur', $orderid,''); llxHeader('',$langs->trans("SuppliersOrdersArea")); $commande = new CommandeFournisseur($db); +$userstatic=new User($db); print_barre_liste($langs->trans("SuppliersOrdersArea"), $page, "index.php", "", $sortfield, $sortorder, '', $num); @@ -64,7 +65,9 @@ if ($resql) $i = 0; print ''; - print ''; + + print ''; + print ''; print "\n"; $var=True; @@ -75,8 +78,7 @@ if ($resql) print ""; print ''; - print ''; - print ''; + print ''; print "\n"; $i++; @@ -93,11 +95,11 @@ else print '
'.$langs->trans("Status").''.$langs->trans("Nb").' 
'.$langs->trans("Status").''.$langs->trans("Nb").'
'.$commande->statuts[$row[1]].''.$row[0].''.$commande->LibStatut($row[1],3).''.$row[0].' '.$commande->LibStatut($row[1],3).'
'; -$sql = "SELECT u.name, u.firstname"; -$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; -$sql .= " , ".MAIN_DB_PREFIX."user_rights as ur"; -$sql .= " WHERE u.rowid = ur.fk_user"; -$sql .= " AND ur.fk_id = 184"; +$sql = "SELECT u.rowid, u.name, u.firstname"; +$sql.= " FROM ".MAIN_DB_PREFIX."user as u,"; +$sql.= " ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; +$sql.= " WHERE u.rowid = ur.fk_user AND ur.fk_id = rd.id"; +$sql.= " AND module='fournisseur' AND perms='commande' AND subperms='approuver'"; $resql = $db->query($sql); if ($resql) @@ -106,17 +108,22 @@ if ($resql) $i = 0; print ''; - print ''; + print ''; print "\n"; $var=True; while ($i < $num) { - $row = $db->fetch_row($resql); + $obj = $db->fetch_object($resql); $var=!$var; print ""; - print ''; + print ''; print "\n"; $i++; } diff --git a/htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php similarity index 74% rename from htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php rename to htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php index 5c3497b8de2..7d364de8af8 100644 --- a/htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php @@ -15,30 +15,31 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ */ /** \file htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php \ingroup banque \brief Fichier de la classe permettant de g�n�rer les bordereau de remise de cheque - \version $Revision$ + \version $Id$ */ +require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php'); + /** - \class BordereauChequeBlochet - \brief Classe permettant de g�n�rer les bordereau de remise de cheque + * \class BordereauChequeBlochet + * \brief Classe permettant de g�n�rer les bordereau de remise de cheque */ - -class BordereauChequeBlochet +class BordereauChequeBlochet extends FPDF { + var $error=''; + var $emetteur; // Objet societe qui emet /** - \brief Constructeur + * \brief Constructeur */ function BordereauChequeBlochet($db) { @@ -49,7 +50,6 @@ class BordereauChequeBlochet $this->db = $db; $this->name = "blochet"; - $this->description = $langs->transnoentities("CheckReceipt"); $this->tab_top = 60; @@ -68,29 +68,36 @@ class BordereauChequeBlochet $this->tab_height = 200; //$this->line_height * $this->line_per_page; } - + /** + * \brief Renvoi le dernier message d'erreur de création de propale + */ + function pdferror() + { + return $this->error; + } + /** \brief Generate Header \param pdf pdf object \param page current page number \param pages number of pages */ - function Header(&$pdf, $page, $pages) + function Header(&$pdf, $page, $pages, $outputlangs) { global $langs; - $title = $this->description; + $title = $outputlangs->transnoentities("CheckReceipt"); $pdf->SetFont('Arial','B',10); $pdf->Text(10, 10, $title); $pdf->SetFont('Arial','',10); - $pdf->Text(10, 19, $langs->transnoentities("Numero")); + $pdf->Text(10, 19, $outputlangs->transnoentities("Numero")); $pdf->SetFont('Arial','',10); - $pdf->Text(10, 27, $langs->transnoentities("Date") ); + $pdf->Text(10, 27, $outputlangs->transnoentities("Date") ); $pdf->SetFont('Arial','',10); - $pdf->Text(10, 35, $langs->transnoentities("Owner")); + $pdf->Text(10, 35, $outputlangs->transnoentities("Owner")); $pdf->SetFont('Arial','B',10); $pdf->Text(32, 35, $this->account->proprio); @@ -103,7 +110,7 @@ class BordereauChequeBlochet $pdf->SetFont('Arial','',10); - $pdf->Text(10, 43, "Compte"); + $pdf->Text(10, 43, $outputlangs->transnoentities("Account")); $pdf->SetFont('Arial','B',10); $pdf->Text(32, 43, $this->account->code_banque); @@ -112,7 +119,7 @@ class BordereauChequeBlochet $pdf->Text(104, 43, $this->account->cle_rib); $pdf->SetFont('Arial','',10); - $pdf->Text(114, 19, "Signature"); + $pdf->Text(114, 19, $outputlangs->transnoentities("Sign")); $pdf->Rect(9, 47, 192, 7); $pdf->line(55, 47, 55, 54); @@ -120,7 +127,7 @@ class BordereauChequeBlochet $pdf->line(170, 47, 170, 54); $pdf->SetFont('Arial','',10); - $pdf->Text(10, 52, "Nombre de ch�que"); + $pdf->Text(10, 52, $outputlangs->transnoentities("ChequeNumber")); $pdf->SetFont('Arial','B',10); $pdf->Text(57, 52, $this->nbcheque); @@ -134,16 +141,16 @@ class BordereauChequeBlochet // Tableau $pdf->SetFont('Arial','',8); - $pdf->Text(11,$this->tab_top + 6,$langs->transnoentities("Num")); + $pdf->Text(11,$this->tab_top + 6,$outputlangs->transnoentities("Num")); $pdf->line(30, $this->tab_top, 30, $this->tab_top + $this->tab_height + 10); - $pdf->Text(31,$this->tab_top + 6,$langs->transnoentities("Bank")); + $pdf->Text(31,$this->tab_top + 6,$outputlangs->transnoentities("Bank")); $pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10); - $pdf->Text(101, $this->tab_top + 6, $langs->transnoentities("CheckTransmitter")); + $pdf->Text(101, $this->tab_top + 6, $outputlangs->transnoentities("CheckTransmitter")); $pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10); $pdf->SetXY (180, $this->tab_top); - $pdf->MultiCell(20, 10, $langs->transnoentities("Amount"), 0, 'R'); + $pdf->MultiCell(20, 10, $outputlangs->transnoentities("Amount"), 0, 'R'); $pdf->line(9, $this->tab_top + 10, 201, $this->tab_top + 10 ); $pdf->Rect(9, $this->tab_top, 192, $this->tab_height + 10); @@ -162,7 +169,7 @@ class BordereauChequeBlochet } - function Body(&$pdf, $page) + function Body(&$pdf, $page, $outputlangs) { // x=10 - Num // x=30 - Banque @@ -191,15 +198,27 @@ class BordereauChequeBlochet $yp = $yp + $this->line_height; } } + /** - \brief Fonction g�n�rant le rapport sur le disque - \param _dir repertoire - \param month mois du rapport - \param year annee du rapport - */ - function write_file($_dir, $number) + * \brief Fonction generant le rapport sur le disque + * \param _dir Directory + * \param number Number + * \param outputlangs Lang output object + */ + function write_file($_dir, $number, $outputlangs) { - global $langs; + global $user,$conf,$langs,$mysoc; + + if (! is_object($outputlangs)) $outputlangs=$langs; + // Force output charset to ISO, because, FPDF expect text encoded in ISO + $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("products"); + + $outputlangs->setPhpLang(); $dir = $_dir . "/".get_exdir($number); @@ -252,9 +271,9 @@ class BordereauChequeBlochet $pdf->AddPage(); - $this->Header($pdf, 1, $pages); + $this->Header($pdf, 1, $pages, $outputlangs); - $this->Body($pdf, 1); + $this->Body($pdf, 1, $outputlangs); $pdf->Output($_file); if (! empty($conf->global->MAIN_UMASK)) diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index 4b2031749d8..e531bd3bf62 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -161,10 +161,10 @@ class ModeleNumRefCommandes \brief Crée un bon de commande sur disque en fonction d'un modèle \param db objet base de donnée \param id id de la propale à créer - \param modele force le modele à utiliser ('' par defaut) + \param modele force le modele à utiliser ('' to not force) \param outputlangs objet lang a utiliser pour traduction */ -function commande_pdf_create($db, $id, $modele='', $outputlangs='') +function commande_pdf_create($db, $id, $modele, $outputlangs) { global $conf,$langs; $langs->load("orders"); @@ -203,14 +203,19 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='') $obj = new $classname($db); + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($id, $outputlangs) > 0) { + $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview commande_delete_preview($db, $id); return 1; } else { + $outputlangs->charset_output=$sav_charset_output; dolibarr_syslog("Erreur dans commande_pdf_create"); dolibarr_print_error($db,$obj->pdferror()); return 0; diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index 0802f23c140..d179cdfaffa 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -90,7 +90,7 @@ class pdf_edison extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 52115ee08e1..b0f133e3f86 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -110,7 +110,7 @@ class pdf_einstein extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/dons/modules_don.php b/htdocs/includes/modules/dons/modules_don.php index e635789e662..51361fbe9ac 100644 --- a/htdocs/includes/modules/dons/modules_don.php +++ b/htdocs/includes/modules/dons/modules_don.php @@ -159,7 +159,7 @@ class ModeleNumRefDons \param outputlangs objet lang a utiliser pour traduction \return int 0 si KO, 1 si OK */ -function don_create($db, $id, $message='', $modele='', $outputlangs='') +function don_create($db, $id, $message, $modele, $outputlangs) { global $conf, $langs; $langs->load("bills"); @@ -192,19 +192,23 @@ function don_create($db, $id, $message='', $modele='', $outputlangs='') $obj->message = $message; - if ( $obj->write_file($id,$outputlangs) > 0) + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($obj->write_file($id,$outputlangs) > 0) { // Succès de la création de la facture. On génère le fichier meta don_meta_create($db, $id); - // et on supprime l'image correspondant au preview don_delete_preview($db, $id); + $outputlangs->charset_output=$sav_charset_output; return 1; } else { - dolibarr_syslog("Erreur dans don_create"); + $outputlangs->charset_output=$sav_charset_output; + dolibarr_syslog("Erreur dans don_create"); dolibarr_print_error($db,$obj->pdferror()); return 0; } diff --git a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php index 28dd9c9d13b..e97933517cb 100644 --- a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php +++ b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php @@ -88,10 +88,10 @@ class ModelePdfExpedition extends DolibarrPdfBarCode \brief Cree un bon d'expedition sur disque \param db objet base de donnee \param id id de la expedition a creer - \param modele force le modele a utiliser ('' par defaut) + \param modele force le modele a utiliser ('' to not force) \param outputlangs objet lang a utiliser pour traduction */ -function expedition_pdf_create($db, $id, $modele='', $outputlangs='') +function expedition_pdf_create($db, $id, $modele, $outputlangs) { global $conf,$langs; $langs->load("sendings"); @@ -134,14 +134,19 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='') $result=$expedition->fetch($id); $result=$expedition->fetch_object($expedition->origin); - if ($obj->write_file($expedition, $langs) > 0) + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($obj->write_file($expedition, $langs) > 0) { + $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview -// expedition_delete_preview($db, $id); + //expedition_delete_preview($db, $id); return 1; } else { + $outputlangs->charset_output=$sav_charset_output; dolibarr_syslog("Erreur dans expedition_pdf_create"); dolibarr_print_error($db,$obj->pdferror()); return 0; diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php index e5315309228..a9c9f8de2fe 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php @@ -80,7 +80,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php index 565e4284d24..5571a4ecd46 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -122,7 +122,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/export/modules_export.php b/htdocs/includes/modules/export/modules_export.php index 4da9d54adcb..5ae3ce2dada 100644 --- a/htdocs/includes/modules/export/modules_export.php +++ b/htdocs/includes/modules/export/modules_export.php @@ -19,160 +19,160 @@ */ /** - \file htdocs/includes/modules/export/modules_export.php - \ingroup export - \brief Fichier contenant la classe mère de generation des exports - \version $Id$ -*/ + \file htdocs/includes/modules/export/modules_export.php + \ingroup export + \brief Fichier contenant la classe mère de generation des exports + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php'); /** - \class ModeleExports - \brief Classe mère des modèles de format d'export -*/ + \class ModeleExports + \brief Classe mère des modèles de format d'export + */ class ModeleExports { - var $error=''; - - var $driverlabel; - var $driverversion; + var $error=''; - var $libabel; - var $libversion; + var $driverlabel; + var $driverversion; - - /** - * \brief Constructeur - */ - function ModeleExports() - { - } - - /** - * \brief Charge en memoire et renvoie la liste des modèles actifs - * \param db Handler de base - */ - function liste_modeles($db) - { - dolibarr_syslog("ModeleExport::loadFormat"); + var $libabel; + var $libversion; - $dir=DOL_DOCUMENT_ROOT."/includes/modules/export/"; - $handle=opendir($dir); - // Recherche des fichiers drivers exports disponibles - $var=True; - $i=0; - while (($file = readdir($handle))!==false) - { - if (eregi("^export_(.*)\.modules\.php",$file,$reg)) - { - $moduleid=$reg[1]; - - // Chargement de la classe - $file = $dir."/export_".$moduleid.".modules.php"; - $classname = "Export".ucfirst($moduleid); - - require_once($file); - $module = new $classname($db); + /** + * \brief Constructeur + */ + function ModeleExports() + { + } - // Driver properties - $this->driverlabel[$module->id]=$module->getDriverLabel(); - $this->driverversion[$module->id]=$module->getDriverVersion(); - // If use an external lib - $this->liblabel[$module->id]=$module->getLibLabel(); - $this->libversion[$module->id]=$module->getLibVersion(); - - $i++; - } - } - - return array_keys($this->driverlabel); - } + /** + * \brief Charge en memoire et renvoie la liste des modèles actifs + * \param db Handler de base + */ + function liste_modeles($db) + { + dolibarr_syslog("ModeleExport::loadFormat"); - - /** - * \brief Renvoi libelle d'un driver export - */ - function getDriverLabel($key) - { - return $this->driverlabel[$key]; - } + $dir=DOL_DOCUMENT_ROOT."/includes/modules/export/"; + $handle=opendir($dir); - /** - * \brief Renvoi version d'un driver export - */ - function getDriverVersion($key) - { - return $this->driverversion[$key]; - } + // Recherche des fichiers drivers exports disponibles + $var=True; + $i=0; + while (($file = readdir($handle))!==false) + { + if (eregi("^export_(.*)\.modules\.php",$file,$reg)) + { + $moduleid=$reg[1]; - /** - * \brief Renvoi libelle de librairie externe du driver - */ - function getLibLabel($key) - { - return $this->liblabel[$key]; - } + // Chargement de la classe + $file = $dir."/export_".$moduleid.".modules.php"; + $classname = "Export".ucfirst($moduleid); - /** - * \brief Renvoi version de librairie externe du driver - */ - function getLibVersion($key) - { - return $this->libversion[$key]; - } + require_once($file); + $module = new $classname($db); + + // Driver properties + $this->driverlabel[$module->id]=$module->getDriverLabel(); + $this->driverversion[$module->id]=$module->getDriverVersion(); + // If use an external lib + $this->liblabel[$module->id]=$module->getLibLabel(); + $this->libversion[$module->id]=$module->getLibVersion(); + + $i++; + } + } + + return array_keys($this->driverlabel); + } + + + /** + * \brief Renvoi libelle d'un driver export + */ + function getDriverLabel($key) + { + return $this->driverlabel[$key]; + } + + /** + * \brief Renvoi version d'un driver export + */ + function getDriverVersion($key) + { + return $this->driverversion[$key]; + } + + /** + * \brief Renvoi libelle de librairie externe du driver + */ + function getLibLabel($key) + { + return $this->liblabel[$key]; + } + + /** + * \brief Renvoi version de librairie externe du driver + */ + function getLibVersion($key) + { + return $this->libversion[$key]; + } - /** - * \brief Lance la generation du fichier - * \remarks Les tableaux array_export_xxx sont déjà chargées pour le bon datatoexport - * aussi le parametre datatoexport est inutilisé - */ - function build_file($model, $datatoexport, $array_selected) - { - global $langs; + /** + * \brief Lance la generation du fichier + * \remarks Les tableaux array_export_xxx sont déjà chargées pour le bon datatoexport + * aussi le parametre datatoexport est inutilisé + */ + function build_file($model, $datatoexport, $array_selected) + { + global $langs; - dolibarr_syslog("Export::build_file $model, $datatoexport, $array_selected"); - - // Creation de la classe d'export du model ExportXXX - $dir = DOL_DOCUMENT_ROOT . "/includes/modules/export/"; - $file = "export_".$model.".modules.php"; - $classname = "Export".$model; - require_once($dir.$file); - $obj = new $classname($db); - - // Execute requete export - $sql=$this->array_export_sql[0]; - $resql = $this->db->query($sql); - if ($resql) - { - // Genere en-tete - $obj->write_header(); - - // Genere ligne de titre - $obj->write_title(); + dolibarr_syslog("Export::build_file $model, $datatoexport, $array_selected"); + + // Creation de la classe d'export du model ExportXXX + $dir = DOL_DOCUMENT_ROOT . "/includes/modules/export/"; + $file = "export_".$model.".modules.php"; + $classname = "Export".$model; + require_once($dir.$file); + $obj = new $classname($db); + + // Execute requete export + $sql=$this->array_export_sql[0]; + $resql = $this->db->query($sql); + if ($resql) + { + // Genere en-tete + $obj->write_header(); + + // Genere ligne de titre + $obj->write_title(); + + while ($objp = $this->db->fetch_object($resql)) + { + $var=!$var; + $obj->write_record($objp,$array_selected); + } + + // Genere en-tete + $obj->write_footer(); + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("Error: sql=$sql ".$this->error); + return -1; + } + } - while ($objp = $this->db->fetch_object($resql)) - { - $var=!$var; - $obj->write_record($objp,$array_selected); - } - - // Genere en-tete - $obj->write_footer(); - } - else - { - $this->error=$this->db->error(); - dolibarr_syslog("Error: sql=$sql ".$this->error); - return -1; - } - } - } diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index 0d906bc656b..5254db3bf00 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -162,11 +162,11 @@ class ModeleNumRefFactures \param db objet base de donnee \param id id de la facture a creer \param message message - \param modele force le modele a utiliser ('' par defaut) + \param modele force le modele a utiliser ('' to not force) \param outputlangs objet lang a utiliser pour traduction \return int <0 si KO, >0 si OK */ -function facture_pdf_create($db, $id, $message='', $modele='', $outputlangs='') +function facture_pdf_create($db, $id, $message, $modele, $outputlangs) { global $conf,$langs; $langs->load("bills"); @@ -197,19 +197,23 @@ function facture_pdf_create($db, $id, $message='', $modele='', $outputlangs='') $obj = new $classname($db); $obj->message = $message; + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($id, $outputlangs) > 0) { // Success in building document. We build meta file. facture_meta_create($db, $id); - // et on supprime l'image correspondant au preview facture_delete_preview($db, $id); + $outputlangs->charset_output=$sav_charset_output; return 1; } else { - dolibarr_print_error('',"facture_pdf_create Error: ".$obj->error); + $outputlangs->charset_output=$sav_charset_output; + dolibarr_print_error($db,"facture_pdf_create Error: ".$obj->error); return -1; } diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 88453639ac2..fdd4c9d8846 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -111,7 +111,7 @@ class pdf_crabe extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/facture/pdf_huitre.modules.php b/htdocs/includes/modules/facture/pdf_huitre.modules.php index a1a41068a5d..d81195f2581 100644 --- a/htdocs/includes/modules/facture/pdf_huitre.modules.php +++ b/htdocs/includes/modules/facture/pdf_huitre.modules.php @@ -95,7 +95,7 @@ class pdf_huitre extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php index 159ccdff005..ddfb56a8fe8 100644 --- a/htdocs/includes/modules/facture/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php @@ -99,7 +99,7 @@ class pdf_oursin extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 52a062ff3ce..b8dcca22c35 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -18,133 +18,133 @@ * or see http://www.gnu.org/ */ -/** - \file htdocs/includes/modules/fichinter/modules_fichinter.php - \ingroup ficheinter - \brief Fichier contenant la classe mère de generation des fiches interventions en PDF - et la classe mère de numérotation des fiches interventions - \version $Id$ -*/ +/** + \file htdocs/includes/modules/fichinter/modules_fichinter.php + \ingroup ficheinter + \brief Fichier contenant la classe mère de generation des fiches interventions en PDF + et la classe mère de numérotation des fiches interventions + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php'); /** - \class ModelePDFFicheinter - \brief Classe mère des modèles de fiche intervention -*/ + \class ModelePDFFicheinter + \brief Classe mère des modèles de fiche intervention + */ class ModelePDFFicheinter extends FPDF { - var $error=''; + var $error=''; - /** - \brief Constructeur - */ - function ModelePDFFicheinter() - { - - } + /** + \brief Constructeur + */ + function ModelePDFFicheinter() + { - /** - \brief Renvoi le dernier message d'erreur de création de fiche intervention - */ - function pdferror() - { - return $this->error; - } + } - /** - * \brief Renvoi la liste des modèles actifs - */ - function liste_modeles($db) - { - $type='ficheinter'; - $liste=array(); - $sql ="SELECT nom as id, nom as lib"; - $sql.=" FROM ".MAIN_DB_PREFIX."document_model"; - $sql.=" WHERE type = '".$type."'"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $liste[$row[0]]=$row[1]; - $i++; - } - } - else - { - return -1; - } - return $liste; - } + /** + \brief Renvoi le dernier message d'erreur de création de fiche intervention + */ + function pdferror() + { + return $this->error; + } + + /** + * \brief Renvoi la liste des modèles actifs + */ + function liste_modeles($db) + { + $type='ficheinter'; + $liste=array(); + $sql ="SELECT nom as id, nom as lib"; + $sql.=" FROM ".MAIN_DB_PREFIX."document_model"; + $sql.=" WHERE type = '".$type."'"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $liste[$row[0]]=$row[1]; + $i++; + } + } + else + { + return -1; + } + return $liste; + } } /** - \class ModeleNumRefFicheinter - \brief Classe mère des modèles de numérotation des références de fiches d'intervention -*/ + \class ModeleNumRefFicheinter + \brief Classe mère des modèles de numérotation des références de fiches d'intervention + */ class ModeleNumRefFicheinter { - var $error=''; + var $error=''; /** \brief Return if a module can be used or not - * \return boolean true if module can be used - */ + * \return boolean true if module can be used + */ function isEnabled() { return true; } - /** \brief Renvoi la description par defaut du modele de numérotation - * \return string Texte descripif - */ - function info() - { - global $langs; - $langs->load("ficheinter"); - return $langs->trans("NoDescription"); - } + /** \brief Renvoi la description par defaut du modele de numérotation + * \return string Texte descripif + */ + function info() + { + global $langs; + $langs->load("ficheinter"); + return $langs->trans("NoDescription"); + } - /** \brief Renvoi un exemple de numérotation - * \return string Example - */ - function getExample() - { - global $langs; - $langs->load("ficheinter"); - return $langs->trans("NoExample"); - } + /** \brief Renvoi un exemple de numérotation + * \return string Example + */ + function getExample() + { + global $langs; + $langs->load("ficheinter"); + return $langs->trans("NoExample"); + } - /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de - * de conflits qui empechera cette numérotation de fonctionner. - * \return boolean false si conflit, true si ok - */ - function canBeActivated() - { - return true; - } + /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numérotation de fonctionner. + * \return boolean false si conflit, true si ok + */ + function canBeActivated() + { + return true; + } - /** \brief Renvoi prochaine valeur attribuée - * \return string Valeur - */ - function getNextValue() - { - global $langs; - return $langs->trans("NotAvailable"); - } + /** \brief Renvoi prochaine valeur attribuée + * \return string Valeur + */ + function getNextValue() + { + global $langs; + return $langs->trans("NotAvailable"); + } /** \brief Renvoi version du module numerotation - * \return string Valeur - */ + * \return string Valeur + */ function getVersion() { global $langs; @@ -154,25 +154,25 @@ class ModeleNumRefFicheinter if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); if ($this->version == 'dolibarr') return DOL_VERSION; return $langs->trans("NotAvailable"); - } + } } /** - \brief Crée une fiche intervention sur disque en fonction du modèle de FICHEINTER_ADDON_PDF - \param db objet base de donnée - \param object Object fichinter - \param modele force le modele à utiliser ('' par defaut) - \param outputlangs objet lang a utiliser pour traduction - \return int 0 si KO, 1 si OK -*/ + \brief Crée une fiche intervention sur disque en fonction du modèle de FICHEINTER_ADDON_PDF + \param db objet base de donnée + \param object Object fichinter + \param modele force le modele à utiliser ('' par defaut) + \param outputlangs objet lang a utiliser pour traduction + \return int 0 si KO, 1 si OK + */ function fichinter_create($db, $object, $modele='', $outputlangs='') { global $conf,$langs; $langs->load("ficheinter"); - + $dir = DOL_DOCUMENT_ROOT."/includes/modules/fichinter/"; - + // Positionne modele sur le nom du modele de facture à utiliser if (! strlen($modele)) { @@ -187,23 +187,29 @@ function fichinter_create($db, $object, $modele='', $outputlangs='') return 0; } } - + // Charge le modele $file = "pdf_".$modele.".modules.php"; if (file_exists($dir.$file)) { $classname = "pdf_".$modele; require_once($dir.$file); - + $obj = new $classname($db); - + dolibarr_syslog("fichinter_create build PDF", LOG_DEBUG); + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($object,$outputlangs) > 0) { + $outputlangs->charset_output=$sav_charset_output; return 1; } else { + $outputlangs->charset_output=$sav_charset_output; dolibarr_print_error($db,$obj->pdferror()); return 0; } @@ -216,53 +222,53 @@ function fichinter_create($db, $object, $modele='', $outputlangs='') } /** - \brief Supprime l'image de prévisualitation, pour le cas de régénération de propal - \param db objet base de donnée - \param propalid id de la propal à effacer - \param propalref référence de la propal si besoin -*/ + \brief Supprime l'image de prévisualitation, pour le cas de régénération de propal + \param db objet base de donnée + \param propalid id de la propal à effacer + \param propalref référence de la propal si besoin + */ function fichinter_delete_preview($db, $fichinterid, $fichinterref='') { global $langs,$conf; - - if (!$fichinterref) - { - $fichinter = new Fichinter($db,"",$fichinterid); - $fichinter->fetch($fichinterid); - $fichinterref = $fichinter->ref; - } - - if ($conf->fichinter->dir_output) - { - $fichinterref = sanitizeFileName($fichinterref); - $dir = $conf->fichinter->dir_output . "/" . $fichinterref ; - $file = $dir . "/" . $fichinterref . ".pdf.png"; - $multiple = $file . "."; - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! unlink($file) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$file); - return 0; - } - } - else - { - for ($i = 0; $i < 20; $i++) - { - $preview = $multiple.$i; - if ( file_exists( $preview ) && is_writable( $preview ) ) - { - if ( ! unlink($preview) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); - return 0; - } - } - } - } - } + if (!$fichinterref) + { + $fichinter = new Fichinter($db,"",$fichinterid); + $fichinter->fetch($fichinterid); + $fichinterref = $fichinter->ref; + } + + if ($conf->fichinter->dir_output) + { + $fichinterref = sanitizeFileName($fichinterref); + $dir = $conf->fichinter->dir_output . "/" . $fichinterref ; + $file = $dir . "/" . $fichinterref . ".pdf.png"; + $multiple = $file . "."; + + if ( file_exists( $file ) && is_writable( $file ) ) + { + if ( ! unlink($file) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$file); + return 0; + } + } + else + { + for ($i = 0; $i < 20; $i++) + { + $preview = $multiple.$i; + if ( file_exists( $preview ) && is_writable( $preview ) ) + { + if ( ! unlink($preview) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$preview); + return 0; + } + } + } + } + } } ?> diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index 8b65218bf16..8c35e5973f0 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -84,7 +84,7 @@ class pdf_soleil extends ModelePDFFicheinter if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/livraison/modules_livraison.php b/htdocs/includes/modules/livraison/modules_livraison.php index b271284e16f..cd39194e984 100644 --- a/htdocs/includes/modules/livraison/modules_livraison.php +++ b/htdocs/includes/modules/livraison/modules_livraison.php @@ -155,7 +155,14 @@ class ModeleNumRefDeliveryOrder - +/** + * \brief Create object on disk + * \param db objet base de donnée + * \param deliveryid id object + * \param modele force le modele à utiliser ('' to not force) + * \param outputlangs objet lang a utiliser pour traduction + * \return int 0 si KO, 1 si OK + */ function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='') { global $langs; @@ -185,14 +192,20 @@ function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='' $obj = new $classname($db); + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($deliveryid,$outputlangs) > 0) { // on supprime l'image correspondant au preview delivery_order_delete_preview($db, $deliveryid); + + $outputlangs->charset_output=$sav_charset_output; return 1; } else { + $outputlangs->charset_output=$sav_charset_output; dolibarr_syslog("Erreur dans delivery_order_pdf_create"); dolibarr_print_error($db,$obj->pdferror()); return 0; diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index c7eed14cd2d..f55c8e90d38 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -91,7 +91,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("bills"); diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index 9a36269732a..85632e7e66d 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -114,7 +114,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 3fc026ba8aa..220db03958c 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -156,11 +156,11 @@ class ModeleNumRefPropales \brief Crée une propale sur disque en fonction du modèle de PROPALE_ADDON_PDF \param db objet base de donnée \param id id de la propale à créer - \param modele force le modele à utiliser ('' par defaut) + \param modele force le modele à utiliser ('' to not force) \param outputlangs objet lang a utiliser pour traduction \return int 0 si KO, 1 si OK */ -function propale_pdf_create($db, $id, $modele='', $outputlangs='') +function propale_pdf_create($db, $id, $modele, $outputlangs) { global $langs; $langs->load("propale"); @@ -200,15 +200,20 @@ function propale_pdf_create($db, $id, $modele='', $outputlangs='') $obj = new $classname($db); + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($id, $outputlangs) > 0) { + $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview propale_delete_preview($db, $id); return 1; } else { - dolibarr_syslog("Erreur dans propale_pdf_create"); + $outputlangs->charset_output=$sav_charset_output; + dolibarr_syslog("modules_propale::propale_pdf_create error"); dolibarr_print_error($db,$obj->pdferror()); return 0; } diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index cf47312de9f..febd4c3cbd0 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -20,11 +20,11 @@ */ /** - \file htdocs/includes/modules/propale/pdf_propale_azur.modules.php - \ingroup propale - \brief Fichier de la classe permettant de générer les propales au modèle Azur - \author Laurent Destailleur - \version $Id$ + * \file htdocs/includes/modules/propale/pdf_propale_azur.modules.php + * \ingroup propale + * \brief Fichier de la classe permettant de générer les propales au modèle Azur + * \author Laurent Destailleur + * \version $Id$ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); @@ -33,8 +33,8 @@ require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_propale_azur - \brief Classe permettant de générer les propales au modèle Azur + * \class pdf_propale_azur + * \brief Classe permettant de générer les propales au modèle Azur */ class pdf_propale_azur extends ModelePDFPropales @@ -43,8 +43,8 @@ class pdf_propale_azur extends ModelePDFPropales /** - \brief Constructeur - \param db Handler accès base de donnée + * \brief Constructeur + * \param db Handler accès base de donnée */ function pdf_propale_azur($db) { @@ -99,19 +99,20 @@ class pdf_propale_azur extends ModelePDFPropales } /** - \brief Fonction générant la propale sur le disque - \param propale Objet propal à générer (ou id si ancienne methode) - \param outputlangs Lang object for output language - \return int 1=ok, 0=ko - */ - function write_file($propale,$outputlangs='') + * \brief Fonction générant la propale sur le disque + * \param propale Objet propal à générer (ou id si ancienne methode) + * \param outputlangs Lang object for output language + * \return int 1=ok, 0=ko + */ + function write_file($propale,$outputlangs) { global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because FPDF expect text to be encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; - + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='ISO-8859-1'; + $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); @@ -400,6 +401,7 @@ class pdf_propale_azur extends ModelePDFPropales if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); + $outputlangs->charset_output=$sav_charset_output; $langs->setPhpLang(); // On restaure langue session return 1; // Pas d'erreur } diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index 01d1a07095e..8efb6b202e6 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -49,7 +49,7 @@ class pdf_propale_jaune extends ModelePDFPropales $langs->load("main"); $langs->load("bills"); - + $this->db = $db; $this->name = "jaune"; $this->description = $langs->trans('DocModelJauneDescription'); @@ -94,9 +94,10 @@ class pdf_propale_jaune extends ModelePDFPropales global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; - // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; - + // Force output charset to ISO, because FPDF expect text to be encoded in ISO + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='ISO-8859-1'; + $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); @@ -156,15 +157,15 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->Open(); $pdf->AddPage(); - + $pdf->SetTitle($propale->ref); - $pdf->SetSubject("Proposition commerciale"); + $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($user->fullname); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetAutoPageBreak(1,0); - + // Tete de page $this->_pagehead($pdf, $propale, $outputlangs); @@ -227,7 +228,7 @@ class pdf_propale_jaune extends ModelePDFPropales } } - $this->_tableau($pdf, $tab_top, $tab_height, $nexY); + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); /* * */ @@ -270,16 +271,16 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->Close(); $pdf->Output($file); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + $langs->setPhpLang(); // On restaure langue session return 1; } } } - function _tableau(&$pdf, $tab_top, $tab_height, $nexY) + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) { global $langs,$conf; $langs->load("main"); @@ -288,26 +289,26 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->SetFont('Arial','',11); $pdf->SetXY(10,$tab_top); - $pdf->MultiCell(20,10,$langs->transnoentities("Ref"),0,'C',1); + $pdf->MultiCell(20,10,$outputlangs->transnoentities("Ref"),0,'C',1); $pdf->SetXY(30,$tab_top); - $pdf->MultiCell(102,10,$langs->transnoentities("Designation"),0,'L',1); + $pdf->MultiCell(102,10,$outputlangs->transnoentities("Designation"),0,'L',1); $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); $pdf->SetXY(132,$tab_top); - $pdf->MultiCell(12, 10,$langs->transnoentities("VAT"),0,'C',1); + $pdf->MultiCell(12, 10,$outputlangs->transnoentities("VAT"),0,'C',1); $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); $pdf->SetXY(144,$tab_top); - $pdf->MultiCell(10,10,$langs->transnoentities("Qty"),0,'C',1); + $pdf->MultiCell(10,10,$outputlangs->transnoentities("Qty"),0,'C',1); $pdf->line(154, $tab_top, 154, $tab_top + $tab_height); $pdf->SetXY(154,$tab_top); - $pdf->MultiCell(22,10,$langs->transnoentities("PriceU"),0,'R',1); + $pdf->MultiCell(22,10,$outputlangs->transnoentities("PriceU"),0,'R',1); $pdf->line(176, $tab_top, 176, $tab_top + $tab_height); $pdf->SetXY(176,$tab_top); - $pdf->MultiCell(24,10,$langs->transnoentities("Total"),0,'R',1); + $pdf->MultiCell(24,10,$outputlangs->transnoentities("Total"),0,'R',1); $pdf->Rect(10, $tab_top, 190, $tab_height); @@ -315,6 +316,7 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->SetFont('Arial','',10); } + function _pagehead(&$pdf, $propale, $outputlangs) { //Affiche le filigrane brouillon - Print Draft Watermark @@ -356,20 +358,20 @@ class pdf_propale_jaune extends ModelePDFPropales { $pdf->SetX(12); $pdf->SetFont('Arial','',10); - $pdf->MultiCell(76, 5, "T�l : ".FAC_PDF_TEL); + $pdf->MultiCell(76, 5, $outputlangs->trans("Tel")." : ".FAC_PDF_TEL); } if (defined("MAIN_INFO_SIREN")) { $pdf->SetX(12); $pdf->SetFont('Arial','',10); - $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN); + $pdf->MultiCell(76, 5, $outputlangs->trans("SIREN")." : ".MAIN_INFO_SIREN); } $pdf->rect(10, 40, 80, 40); $pdf->SetXY(10,5); $pdf->SetFont('Arial','B',16); $pdf->SetTextColor(0,0,200); - $pdf->MultiCell(200, 20, "PROPOSITION COMMERCIALE", '' , 'C'); + $pdf->MultiCell(200, 20, $outputlangs->transnoentities("CommercialProposal"), '' , 'C'); /* * Adresse Client diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php index 4eb44775eae..ebc0d57b312 100644 --- a/htdocs/includes/modules/rapport/pdf_paiement.class.php +++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php @@ -43,7 +43,6 @@ class pdf_paiement extends FPDF $langs->load("bills"); $this->db = $db; - $this->description = $langs->transnoentities("ListOfCustomerPayments"); // Dimension page pour format A4 $this->type = 'pdf'; @@ -62,43 +61,45 @@ class pdf_paiement extends FPDF $this->tab_height = 230; //$this->line_height * $this->line_per_page; } + /** \brief Generate Header \param pdf pdf object \param page current page number \param pages number of pages -*/ - function Header(&$pdf, $page, $pages) + */ + function Header(&$pdf, $page, $pages, $outputlangs) { global $langs; - $title=$this->description.' - '.dolibarr_print_date(dolibarr_mktime(0,0,0,$this->month,1,$this->year),"%B %Y"); + $title=$outputlangs->transnoentities("ListOfCustomerPayments"); + $title.=' - '.dolibarr_print_date(dolibarr_mktime(0,0,0,$this->month,1,$this->year),"%B %Y"); $pdf->SetFont('Arial','B',12); $pdf->Text(76, 10, $title); $pdf->SetFont('Arial','B',12); - $pdf->Text(11, 16, $langs->transnoentities("Date")." : ".dolibarr_print_date(time(),"day")); + $pdf->Text(11, 16, $outputlangs->transnoentities("Date")." : ".dolibarr_print_date(time(),"day")); $pdf->SetFont('Arial','',12); - $pdf->Text(11, 22, $langs->transnoentities("Page")." : ".$page); + $pdf->Text(11, 22, $outputlangs->transnoentities("Page")." : ".$page); $pdf->SetFont('Arial','',12); $pdf->Text(11,$this->tab_top + 6,'Date'); $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); - $pdf->Text(42, $this->tab_top + 6, $langs->transnoentities("PaymentMode")); + $pdf->Text(42, $this->tab_top + 6, $outputlangs->transnoentities("PaymentMode")); $pdf->line(80, $this->tab_top, 80, $this->tab_top + $this->tab_height + 10); - $pdf->Text(82, $this->tab_top + 6, $langs->transnoentities("Invoice")); + $pdf->Text(82, $this->tab_top + 6, $outputlangs->transnoentities("Invoice")); $pdf->line(120, $this->tab_top, 120, $this->tab_top + $this->tab_height + 10); - $pdf->Text(122, $this->tab_top + 6, $langs->transnoentities("AmountInvoice")); + $pdf->Text(122, $this->tab_top + 6, $outputlangs->transnoentities("AmountInvoice")); $pdf->line(160, $this->tab_top, 160, $this->tab_top + $this->tab_height + 10); $pdf->SetXY (160, $this->tab_top); - $pdf->MultiCell(40, 10, $langs->transnoentities("AmountPayment"), 0, 'R'); + $pdf->MultiCell(40, 10, $outputlangs->transnoentities("AmountPayment"), 0, 'R'); $pdf->line(10, $this->tab_top + 10, 200, $this->tab_top + 10 ); @@ -106,7 +107,7 @@ class pdf_paiement extends FPDF } - function Body(&$pdf, $page, $lines) + function Body(&$pdf, $page, $lines, $outputlangs) { $pdf->SetFont('Arial','', 9); $oldprowid = 0; @@ -163,13 +164,13 @@ class pdf_paiement extends FPDF \param month mois du rapport \param year annee du rapport */ - function write_file($_dir, $month, $year, $outputlangs='') + function write_file($_dir, $month, $year, $outputlangs) { global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because FPDF expect text to be encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->setPhpLang(); @@ -274,9 +275,9 @@ class pdf_paiement extends FPDF $pdf->AddPage(); - $this->Header($pdf, 1, $pages); + $this->Header($pdf, 1, $pages, $outputlangs); - $this->Body($pdf, 1, $lines); + $this->Body($pdf, 1, $lines, $outputlangs); $pdf->Output($_file); if (! empty($conf->global->MAIN_UMASK)) diff --git a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php index ce2d794f6fb..aaf9bbbb94a 100644 --- a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php @@ -31,115 +31,115 @@ require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdfi/fpdi_protection.php'); /** - \class ModelePDFSuppliersorders - \brief Classe mère des modèles de commandes fournisseurs -*/ + \class ModelePDFSuppliersorders + \brief Classe mère des modèles de commandes fournisseurs + */ class ModelePDFSuppliersOrders extends FPDF { - var $error=''; + var $error=''; - /** - \brief Renvoi le dernier message d'erreur de création de PDF de commande - */ - function pdferror() - { - return $this->error; - } + /** + \brief Renvoi le dernier message d'erreur de création de PDF de commande + */ + function pdferror() + { + return $this->error; + } - /** - * \brief Renvoi la liste des modèles actifs - */ - function liste_modeles($db) - { - $type='supplier_order'; - $liste=array(); - $sql ="SELECT nom as id, nom as lib"; - $sql.=" FROM ".MAIN_DB_PREFIX."document_model"; - $sql.=" WHERE type = '".$type."'"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $liste[$row[0]]=$row[1]; - $i++; - } - } - else - { - $this->error=$db->error(); - return -1; - } - return $liste; - } + /** + * \brief Renvoi la liste des modèles actifs + */ + function liste_modeles($db) + { + $type='supplier_order'; + $liste=array(); + $sql ="SELECT nom as id, nom as lib"; + $sql.=" FROM ".MAIN_DB_PREFIX."document_model"; + $sql.=" WHERE type = '".$type."'"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $liste[$row[0]]=$row[1]; + $i++; + } + } + else + { + $this->error=$db->error(); + return -1; + } + return $liste; + } } /** - \class ModeleNumRefSuppliersOrders - \brief Classe mère des modèles de numérotation des références de commandes fournisseurs -*/ + \class ModeleNumRefSuppliersOrders + \brief Classe mère des modèles de numérotation des références de commandes fournisseurs + */ class ModeleNumRefSuppliersOrders { - var $error=''; + var $error=''; /** \brief Return if a module can be used or not - * \return boolean true if module can be used - */ + * \return boolean true if module can be used + */ function isEnabled() { return true; } /** \brief Renvoi la description par defaut du modele de numérotation - * \return string Texte descripif - */ - function info() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoDescription"); - } + * \return string Texte descripif + */ + function info() + { + global $langs; + $langs->load("orders"); + return $langs->trans("NoDescription"); + } - /** \brief Renvoi un exemple de numérotation - * \return string Example - */ - function getExample() - { - global $langs; - $langs->load("orders"); - return $langs->trans("NoExample"); - } + /** \brief Renvoi un exemple de numérotation + * \return string Example + */ + function getExample() + { + global $langs; + $langs->load("orders"); + return $langs->trans("NoExample"); + } - /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de - * de conflits qui empechera cette numérotation de fonctionner. - * \return boolean false si conflit, true si ok - */ - function canBeActivated() - { - return true; - } + /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numérotation de fonctionner. + * \return boolean false si conflit, true si ok + */ + function canBeActivated() + { + return true; + } + + /** \brief Renvoi prochaine valeur attribuée + * \return string Valeur + */ + function getNextValue() + { + global $langs; + return $langs->trans("NotAvailable"); + } - /** \brief Renvoi prochaine valeur attribuée - * \return string Valeur - */ - function getNextValue() - { - global $langs; - return $langs->trans("NotAvailable"); - } - /** \brief Renvoi version du module numerotation - * \return string Valeur - */ + * \return string Valeur + */ function getVersion() { global $langs; @@ -153,77 +153,91 @@ class ModeleNumRefSuppliersOrders } -function supplier_order_pdf_create($db, $comid, $modele='',$outputlangs='') +/** + * \brief Create object on disk + * \param db objet base de donnée + * \param deliveryid id object + * \param modele force le modele à utiliser ('' to not force) + * \param outputlangs objet lang a utiliser pour traduction + * \return int 0 si KO, 1 si OK + */ +function supplier_order_pdf_create($db, $comid, $modele,$outputlangs) { - global $langs; - $langs->load("suppliers"); - - $dir = DOL_DOCUMENT_ROOT."//includes/modules/supplier_order/pdf/"; + global $langs; + $langs->load("suppliers"); - // Positionne modele sur le nom du modele de commande fournisseur à utiliser - if (! strlen($modele)) - { - if (defined("COMMANDE_SUPPLIER_ADDON_PDF") && COMMANDE_SUPPLIER_ADDON_PDF) - { - $modele = COMMANDE_SUPPLIER_ADDON_PDF; - } - else - { - print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_PDF_NotDefined"); - return 0; - } - } - // Charge le modele - $file = "pdf_".$modele.".modules.php"; - if (file_exists($dir.$file)) - { - $classname = "pdf_".$modele; - require_once($dir.$file); - - $obj = new $classname($db); + $dir = DOL_DOCUMENT_ROOT."//includes/modules/supplier_order/pdf/"; - if ($obj->write_file($comid,$outputlangs) > 0) - { - // on supprime l'image correspondant au preview - supplier_order_delete_preview($db, $comid); - return 1; - } - else - { - dolibarr_syslog("Erreur dans supplier_order_pdf_create"); - dolibarr_print_error($db,$obj->pdferror()); - return 0; - } - } - else - { - print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file); - return 0; - } + // Positionne modele sur le nom du modele de commande fournisseur à utiliser + if (! strlen($modele)) + { + if (defined("COMMANDE_SUPPLIER_ADDON_PDF") && COMMANDE_SUPPLIER_ADDON_PDF) + { + $modele = COMMANDE_SUPPLIER_ADDON_PDF; + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_PDF_NotDefined"); + return 0; + } + } + // Charge le modele + $file = "pdf_".$modele.".modules.php"; + if (file_exists($dir.$file)) + { + $classname = "pdf_".$modele; + require_once($dir.$file); + + $obj = new $classname($db); + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($obj->write_file($comid,$outputlangs) > 0) + { + // on supprime l'image correspondant au preview + supplier_order_delete_preview($db, $comid); + + $outputlangs->charset_output=$sav_charset_output; + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dolibarr_syslog("Erreur dans supplier_order_pdf_create"); + dolibarr_print_error($db,$obj->pdferror()); + return 0; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file); + return 0; + } } function supplier_order_delete_preview($db, $propalid) { - global $langs,$conf; + global $langs,$conf; - $comfourn = new CommandeFournisseur($db,"",$propalid); - $comfourn->fetch($propalid); - $client = new Societe($db); - $client->fetch($comfourn->socid); + $comfourn = new CommandeFournisseur($db,"",$propalid); + $comfourn->fetch($propalid); + $client = new Societe($db); + $client->fetch($comfourn->socid); - if ($conf->fournisseur->commande->dir_output) - { - $comfournref = sanitizeFileName($comfourn->ref); - $dir = $conf->commande->dir_output . "/" . $comfournref ; - $file = $dir . "/" . $comfournref . ".pdf.png"; + if ($conf->fournisseur->commande->dir_output) + { + $comfournref = sanitizeFileName($comfourn->ref); + $dir = $conf->commande->dir_output . "/" . $comfournref ; + $file = $dir . "/" . $comfournref . ".pdf.png"; - if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! unlink($file) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$file); - return 0; - } - } - } + if ( file_exists( $file ) && is_writable( $file ) ) + { + if ( ! unlink($file) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$file); + return 0; + } + } + } } ?> diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php index 26e2709eb1b..f292a950310 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -112,7 +112,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (! is_object($outputlangs)) $outputlangs=$langs; // Force output charset to ISO, because, FPDF expect text encoded in ISO - $outputlangs->charset_output=$outputlangs->character_set_client='ISO-8859-1'; + $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index 92837a271e2..4807dea90d9 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -156,7 +156,7 @@ if ($_POST["action"] == "set") $requestnb++; if ($conf->character_set_client == "UTF-8") { - $buffer=utf8_encode ($buffer); + $buffer=utf8_encode($buffer); } dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG); @@ -268,7 +268,7 @@ if ($_POST["action"] == "set") $requestnb++; if ($conf->character_set_client == "UTF-8") { - $buffer=utf8_encode ($buffer); + $buffer=utf8_encode($buffer); } dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG); diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index fdc6120fdba..360cf00d961 100755 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -97,6 +97,7 @@ OrderMode=Order method AuthorRequest=Request author UseCustomerContactAsOrderRecipientIfExist=Use customer contact address if defined instead of third party address as order recipient address RunningOrders=Orders on process +UserWithApproveOrderGrant=Useres granted with "approve orders" permission. Error_COMMANDE_SUPPLIER_ADDON_NotDefined=Constant COMMANDE_SUPPLIER_ADDON not defined Error_COMMANDE_ADDON_NotDefined=Constant COMMANDE_ADDON not defined diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index 5a422f8fcc8..6feac50bbda 100755 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -97,6 +97,7 @@ OrderMode=M AuthorRequest=Auteur/Demandeur UseCustomerContactAsOrderRecipientIfExist=Utiliser adresse contact suivi client si défini plutot que adresse tiers comme destinataire des commandes RunningOrders=Commandes en cours +UserWithApproveOrderGrant=Utilisateurs habilités à approuver les commandes Error_COMMANDE_SUPPLIER_ADDON_NotDefined=Constante COMMANDE_SUPPLIER_ADDON non définie Error_COMMANDE_ADDON_NotDefined=Constante COMMANDE_ADDON non définie diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f4b0c92d9d8..d5b65f28963 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -788,8 +788,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { print "\n"; - print $langs->lang_header(); - print $head; + print "\n"; // Affiche meta print ''."\n"; // Evite indexation par robots diff --git a/htdocs/translate.class.php b/htdocs/translate.class.php index f8dea38d4a2..f1fb92d6957 100644 --- a/htdocs/translate.class.php +++ b/htdocs/translate.class.php @@ -456,17 +456,6 @@ class Translate { return $langs_available; } - /** - * \brief Exp�die le header correct et retourne le d�but de la page html - * [en] Send header and return a string of html start page - * \return string html header avec charset - */ - function lang_header() - { - $texte = "\n"; - return $texte; - } - /** * \brief Renvoi si le fichier $filename existe dans la version de la langue courante ou alternative
Personnes habilitées à approuver les commandes
'.$langs->trans("UserWithApproveOrderGrant").'
'.$row[1].' '.$row[0].''; + $userstatic->id=$obj->rowid; + $userstatic->nom=$obj->name; + $userstatic->prenom=$obj->firstname; + print $userstatic->getNomUrl(1); + print '