Fix: miscellaneous not initialized vars

This commit is contained in:
Laurent Destailleur
2012-02-07 18:48:50 +01:00
parent d686c52b63
commit 104a4532b9
14 changed files with 44 additions and 26 deletions

View File

@@ -179,7 +179,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes')
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
if ($result >= 0) if ($result >= 0)
{ {
@@ -360,7 +360,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
} }
else else
@@ -437,7 +437,7 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
} }
} }
@@ -1098,7 +1098,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
unset($_POST['qty']); unset($_POST['qty']);
unset($_POST['type']); unset($_POST['type']);
@@ -1200,7 +1200,7 @@ if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save']
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
} }
} }
} }
@@ -1229,7 +1229,7 @@ if ($action == 'up' && $user->rights->facture->creer)
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']); Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
exit; exit;
@@ -1251,7 +1251,7 @@ if ($action == 'down' && $user->rights->facture->creer)
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']); Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
exit; exit;
@@ -1485,7 +1485,7 @@ if (GETPOST('action') == 'builddoc') // En get ou en post
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);
@@ -3057,7 +3057,7 @@ else
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$result=facture_pdf_create($db, $object, '', $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); $result=facture_pdf_create($db, $object, $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);

View File

@@ -1188,7 +1188,7 @@ class Facture extends CommonObject
} }
else else
{ {
$this->error=$this->db->error()." sql=".$sql; $this->error=$this->db->lasterror()." sql=".$sql;
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -6; return -6;
@@ -1196,7 +1196,7 @@ class Facture extends CommonObject
} }
else else
{ {
$this->error=$this->db->error()." sql=".$sql; $this->error=$this->db->lasterror()." sql=".$sql;
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -4; return -4;
@@ -1204,7 +1204,7 @@ class Facture extends CommonObject
} }
else else
{ {
$this->error=$this->db->error()." sql=".$sql; $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;

View File

@@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights-
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs, $hookmanager); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
} }
Header('Location: fiche.php?id='.$paiement->id); Header('Location: fiche.php?id='.$paiement->id);

View File

@@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs, $hookmanager); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
} }
Header('Location: fiche.php?id='.$paiement->id); Header('Location: fiche.php?id='.$paiement->id);

View File

@@ -1811,6 +1811,8 @@ abstract class CommonObject
{ {
global $langs; global $langs;
$error=0;
if (count($this->array_options) > 0) if (count($this->array_options) > 0)
{ {
// Check parameters // Check parameters

View File

@@ -1050,7 +1050,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir
{ {
$date=adodb_mktime($hour,$minute,$second,$month,$day,$year,$isdst,$gm); $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,$gm);
} }
else else
{ {

View File

@@ -112,7 +112,7 @@ function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
else else
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
dol_print_error($db,"facture_pdf_create Error: ".$obj->error); dol_print_error($db,"chequereceipt_pdf_create Error: ".$obj->error);
return -1; return -1;
} }

View File

@@ -205,7 +205,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);
$obj->message = $message; //$obj->message = $message;
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.

View File

@@ -130,11 +130,10 @@ abstract class ModeleNumRefFactures
/** /**
* Create a document onto disk accordign to template module. * Create a document onto disk according to template module.
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param Object $object Object invoice * @param Object $object Object invoice
* @param string $message message
* @param string $modele Force template to use ('' to not force) * @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction * @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines * @param int $hidedetails Hide details of lines
@@ -143,7 +142,7 @@ abstract class ModeleNumRefFactures
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@@ -204,7 +203,6 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);
$obj->message = $message;
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.

View File

@@ -155,7 +155,7 @@ class modWorkflow extends DolibarrModules
$sql = array(); $sql = array();
return $this->_init($sql,$option); return $this->_init($sql,$options);
} }
/** /**

View File

@@ -195,7 +195,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);
$obj->message = $message; //$obj->message = $message;
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.

View File

@@ -303,6 +303,24 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
// Et si on affiche dates de validite, on ajoute encore une ligne
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
{
$nblineFollowDesc += 4;
}
}
else // If it's last line
{
$nblineFollowDesc = 0;
}
// Test if a new page is required // Test if a new page is required
if ($pagenb == 1) if ($pagenb == 1)
{ {

View File

@@ -270,7 +270,7 @@ if ( $resql=$db->query($sql) )
} }
} }
print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n"; print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n";
$result=facture_pdf_create($db, $fac, '', $newmodel?$newmodel:$fac->modelpdf, $outputlangs); $result=facture_pdf_create($db, $fac, $newmodel?$newmodel:$fac->modelpdf, $outputlangs);
// Add file into files array // Add file into files array
$files[] = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; $files[] = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';

View File

@@ -162,14 +162,14 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
// Crabe // Crabe
$localobject->modelpdf='crabe'; $localobject->modelpdf='crabe';
$result=facture_pdf_create($db, $localobject, '', $localobject->modelpdf, $langs); $result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
// Oursin // Oursin
$localobject->modelpdf='oursin'; $localobject->modelpdf='oursin';
$result=facture_pdf_create($db, $localobject, '', $localobject->modelpdf, $langs); $result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";