';
print '| ';
@@ -202,7 +202,7 @@ else
* Draft orders
*/
-if ($conf->fournisseur->enabled)
+if (! empty($conf->fournisseur->enabled))
{
$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
@@ -211,7 +211,7 @@ if ($conf->fournisseur->enabled)
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut = 0";
- if ($socid) $sql.= " AND c.fk_soc = ".$socid;
+ if (! empty($socid)) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql=$db->query($sql);
@@ -307,7 +307,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
//$sql.= " AND c.fk_statut > 2";
-if ($socid) $sql .= " AND c.fk_soc = ".$socid;
+if (! empty($socid)) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.tms DESC";
$sql.= $db->plimit($max, 0);
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 9c052738ea5..d902e507bd3 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -42,6 +42,7 @@ $langs->load('suppliers');
$langs->load('companies');
$mesg='';
+$errors=array();
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
$action = GETPOST("action");
$confirm = GETPOST("confirm");
@@ -52,7 +53,8 @@ $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty(
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
// Security check
-if ($user->societe_id) $socid=$user->societe_id;
+$socid='';
+if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
@@ -404,7 +406,7 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
// Modification d'une ligne
elseif ($action == 'update_line')
{
- if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
+ if (GETPOST('etat') == '1' && ! GETPOST('cancel')) // si on valide la modification
{
$object->fetch($id);
$object->fetch_thirdparty();
@@ -420,7 +422,7 @@ elseif ($action == 'update_line')
$price_base_type='TTC';
}
- if ($_POST['idprod'])
+ if (GETPOST('idprod'))
{
$prod = new Product($db);
$prod->fetch($_POST['idprod']);
@@ -440,7 +442,7 @@ elseif ($action == 'update_line')
$localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty);
$localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty);
- $result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type);
+ $result=$object->updateline(GETPOST('lineid'), $label, $pu, GETPOST('tauxtva'), $localtax1tx, $localtax2tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type);
if ($result >= 0)
{
unset($_POST['label']);
@@ -607,7 +609,7 @@ elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
}
// Add file in email form
-if ($_POST['addfile'])
+if (GETPOST('addfile'))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@@ -1277,13 +1279,13 @@ else
// Ref
print ' |
| '.$langs->trans("Ref").' | ';
- print $form->showrefnav($object,'id','',1,'rowid','ref',$morehtmlref);
+ print $form->showrefnav($object,'id','',1,'rowid','ref');
print ' | ';
print "
\n";
// Ref supplier
- print '| '.$form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).' | ';
- print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
+ print ' |
| '.$form->editfieldkey("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).' | ';
+ print $form->editfieldval("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
print ' |
';
// Third party
@@ -1322,7 +1324,7 @@ else
}
print ')';
}
- if ($facidnext > 0)
+ if (isset($facidnext) && $facidnext > 0)
{
$facthatreplace=new FactureFournisseur($db);
$facthatreplace->fetch($facidnext);
@@ -1548,11 +1550,21 @@ else
}
// Show product and description
- $type=$object->lines[$i]->product_type?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type;
+ $type=(! empty($object->lines[$i]->product_type)?$object->lines[$i]->product_type:(! empty($object->lines[$i]->fk_product_type)?$object->lines[$i]->fk_product_type:0));
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
- if (! empty($object->lines[$i]->date_start)) $type=1;
- if (! empty($object->lines[$i]->date_end)) $type=1;
+ $date_start='';
+ $date_end='';
+ if (! empty($object->lines[$i]->date_start))
+ {
+ $date_start=$object->lines[$i]->date_start;
+ $type=1;
+ }
+ if (! empty($object->lines[$i]->date_end))
+ {
+ $date_end=$object->lines[$i]->date_end;
+ $type=1;
+ }
$var=!$var;
@@ -1632,7 +1644,7 @@ else
print $form->textwithtooltip($text,$description,3,'','',$i);
// Show range
- print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
+ print_date_range($date_start,$date_end);
// Add description in form
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($object->lines[$i]->description && $object->lines[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($object->lines[$i]->description):'';
@@ -1646,7 +1658,7 @@ else
print $text.' '.nl2br($object->lines[$i]->description);
// Show range
- print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
+ print_date_range($date_start,$date_end);
}
print '';
@@ -1723,7 +1735,7 @@ else
print '';
print '';
- print $form->load_tva('tauxtva',($_POST["tauxtva"]?$_POST["tauxtva"]:-1),$societe,$mysoc);
+ print $form->load_tva('tauxtva',(GETPOST('tauxtva')?GETPOST('tauxtva'):-1),$societe,$mysoc);
print ' | ';
print '';
print '';
@@ -1740,7 +1752,7 @@ else
print '';
// Ajout de produits/services predefinis
- if ($conf->product->enabled || $conf->service->enabled)
+ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
print ' | ';
print '| ';
@@ -1766,11 +1778,11 @@ else
$var=! $var;
print ' |
';
print '';
- $form->select_produits_fournisseurs($object->socid,'','idprodfournprice','',$filtre);
+ $form->select_produits_fournisseurs($object->socid,'','idprodfournprice');
if (is_object($hookmanager))
{
- $parameters=array('filtre'=>$filtre,'htmlname'=>'idprodfournprice');
+ $parameters=array('htmlname'=>'idprodfournprice');
echo $hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
}
@@ -1882,9 +1894,10 @@ else
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
$genallowed=$user->rights->fournisseur->facture->creer;
$delallowed=$user->rights->fournisseur->facture->supprimer;
+ $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:'');
print ' ';
- print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$societe->default_lang);
+ print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,0,0,'','','',$societe->default_lang);
$somethingshown=$formfile->numoffiles;
/*
diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php
index dd49c55faca..709f2079bcf 100644
--- a/htdocs/fourn/facture/impayees.php
+++ b/htdocs/fourn/facture/impayees.php
@@ -3,7 +3,7 @@
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012-2012 Vinicius Nogueira
+ * Copyright (C) 2012 Vinicius Nogueira
* Copyright (C) 2012 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
@@ -104,9 +104,9 @@ if ($user->rights->fournisseur->facture->lire)
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
- if ($_GET["filtre"])
+ if (GETPOST('filtre'))
{
- $filtrearr = explode(",", $_GET["filtre"]);
+ $filtrearr = explode(",", GETPOST('filtre'));
foreach ($filtrearr as $fil)
{
$filt = explode(":", $fil);
@@ -116,16 +116,16 @@ if ($user->rights->fournisseur->facture->lire)
if ($search_ref)
{
- $sql .= " AND f.rowid like '%".$search_ref."%'";
+ $sql .= " AND f.rowid LIKE '%".$search_ref."%'";
}
if ($search_ref_supplier)
{
- $sql .= " AND f.facnumber like '%".$search_ref_supplier."%'";
+ $sql .= " AND f.facnumber LIKE '%".$search_ref_supplier."%'";
}
if ($search_societe)
{
- $sql .= " AND s.nom like '%".$search_societe."%'";
+ $sql .= " AND s.nom LIKE '%".$search_societe."%'";
}
if ($search_montant_ht)
@@ -138,9 +138,9 @@ if ($user->rights->fournisseur->facture->lire)
$sql .= " AND f.total_ttc = '".$search_montant_ttc."'";
}
- if (dol_strlen($_POST["sf_ref"]) > 0)
+ if (dol_strlen(GETPOST('sf_re')) > 0)
{
- $sql .= " AND f.facnumber like '%".$_POST["sf_ref"]."%'";
+ $sql .= " AND f.facnumber LIKE '%".GETPOST('sf_re')."%'";
}
$sql.= " GROUP BY f.facnumber, f.rowid, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut, s.rowid, s.nom";
@@ -162,16 +162,16 @@ if ($user->rights->fournisseur->facture->lire)
$param ='';
if ($socid) $param.="&socid=".$socid;
-
+
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_ref_supplier) $param.='&search_ref_supplier='.urlencode($search_ref_supplier);
if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht);
if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
-
+
$param.=($option?"&option=".$option:"");
- if ($late) $param.='&late='.urlencode($late);
- $urlsource.=str_replace('&','&',$param);
+ if (! empty($late)) $param.='&late='.urlencode($late);
+ $urlsource=str_replace('&','&',$param);
$titre=($socid?$langs->trans("BillsSuppliersUnpaidForCompany",$soc->nom):$langs->trans("BillsSuppliersUnpaid"));
diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php
index 9b6ff5cb080..a6e7631fe6e 100644
--- a/htdocs/fourn/facture/index.php
+++ b/htdocs/fourn/facture/index.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2005-2012 Regis Houssin
*
* 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
@@ -112,9 +112,9 @@ if ($socid)
{
$sql .= " AND s.rowid = ".$socid;
}
-if ($_GET["filtre"])
+if (GETPOST('filtre'))
{
- $filtrearr = explode(",", $_GET["filtre"]);
+ $filtrearr = explode(",", GETPOST('filtre'));
foreach ($filtrearr as $fil)
{
$filt = explode(":", $fil);
@@ -124,11 +124,11 @@ if ($_GET["filtre"])
if (GETPOST("search_ref"))
{
- $sql .= " AND fac.rowid like '%".$db->escape(GETPOST("search_ref"))."%'";
+ $sql .= " AND fac.rowid LIKE '%".$db->escape(GETPOST("search_ref"))."%'";
}
if (GETPOST("search_ref_supplier"))
{
- $sql .= " AND fac.facnumber like '%".$db->escape(GETPOST("search_ref_supplier"))."%'";
+ $sql .= " AND fac.facnumber LIKE '%".$db->escape(GETPOST("search_ref_supplier"))."%'";
}
if ($month > 0)
{
@@ -143,12 +143,12 @@ else if ($year > 0)
}
if (GETPOST("search_libelle"))
{
- $sql .= " AND fac.libelle like '%".$db->escape(GETPOST("search_libelle"))."%'";
+ $sql .= " AND fac.libelle LIKE '%".$db->escape(GETPOST("search_libelle"))."%'";
}
if (GETPOST("search_societe"))
{
- $sql .= " AND s.nom like '%".$db->escape(GETPOST("search_societe"))."%'";
+ $sql .= " AND s.nom LIKE '%".$db->escape(GETPOST("search_societe"))."%'";
}
if (GETPOST("search_montant_ht"))
@@ -268,7 +268,8 @@ if ($resql)
// Affiche statut de la facture
print '';
// TODO le montant deja paye objp->am n'est pas definie
- print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am);
+ //print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am);
+ print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5);
print ' | ';
print " |
\n";
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 212e6f5db83..ec79fb6b1dc 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -262,7 +262,7 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
// Set default language (must be after the setValues of $conf)
if (! defined('NOREQUIRETRAN'))
{
- $langs->setDefaultLang($conf->global->MAIN_LANG_DEFAULT);
+ $langs->setDefaultLang((! empty($conf->global->MAIN_LANG_DEFAULT)?$conf->global->MAIN_LANG_DEFAULT:''));
}
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');