Fix: big avoid strict mode errors

This commit is contained in:
Regis Houssin 2012-07-09 12:31:21 +02:00
parent 1f98c2cfc4
commit 66b2f630ac
22 changed files with 179 additions and 155 deletions

View File

@ -58,20 +58,20 @@ if ($id || $ref)
$dbtablename = 'product'; $dbtablename = 'product';
$fieldid = isset($ref)?'ref':'rowid'; $fieldid = isset($ref)?'ref':'rowid';
} }
if ($type == 1) { elseif ($type == 1) {
$elementtype = 'fournisseur'; $elementtype = 'fournisseur';
$objecttype = 'societe&categorie'; $objecttype = 'societe&categorie';
$objectid = isset($id)?$id:(isset($socid)?$socid:''); $objectid = isset($id)?$id:(isset($socid)?$socid:'');
$fieldid = 'rowid'; $fieldid = 'rowid';
} }
if ($type == 2) { elseif ($type == 2) {
$elementtype = 'societe'; $elementtype = 'societe';
$objecttype = 'societe&categorie'; $objecttype = 'societe&categorie';
$objectid = isset($id)?$id:(isset($socid)?$socid:''); $objectid = isset($id)?$id:(isset($socid)?$socid:'');
$dbtablename = '&societe'; $dbtablename = '&societe';
$fieldid = 'rowid'; $fieldid = 'rowid';
} }
if ($type == 3) { elseif ($type == 3) {
$elementtype = 'member'; $elementtype = 'member';
$objecttype = 'adherent&categorie'; $objecttype = 'adherent&categorie';
$objectid = isset($id)?$id:(isset($ref)?$ref:''); $objectid = isset($id)?$id:(isset($ref)?$ref:'');

View File

@ -776,7 +776,7 @@ class Categorie
// Process all childs on several levels of this category // Process all childs on several levels of this category
$protection++; $protection++;
if ($protection > 10) return; // On ne traite pas plus de 10 niveaux de profondeurs if ($protection > 10) return; // On ne traite pas plus de 10 niveaux de profondeurs
if (! is_array($this->cats[$id_categ]['id_children'])) return; if (empty($this->cats[$id_categ]['id_children'])) return;
foreach($this->cats[$id_categ]['id_children'] as $key => $idchild) foreach($this->cats[$id_categ]['id_children'] as $key => $idchild)
{ {
// Protection when a category has itself as a child (should not happen) // Protection when a category has itself as a child (should not happen)

View File

@ -31,15 +31,13 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
if (!$user->rights->societe->lire) if (! $user->rights->societe->lire) accessforbidden();
accessforbidden();
$langs->load("commercial"); $langs->load("commercial");
// Securite acces client // Securite acces client
$socid=''; $socid=GETPOST('socid','int');
if ($_GET["socid"]) { $socid=$_GET["socid"]; } if (isset($user->societe_id) && $user->societe_id > 0)
if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
@ -180,7 +178,7 @@ if ($conf->propal->enabled && $user->rights->propal->lire)
print '</td>'; print '</td>';
print '<td align="right" nowrap="nowrap">'.price($obj->total_ht).'</td></tr>'; print '<td align="right" nowrap="nowrap">'.price($obj->total_ht).'</td></tr>';
$i++; $i++;
$total += $obj->price; $total += $obj->total_ht;
} }
if ($total>0) if ($total>0)
{ {
@ -282,7 +280,7 @@ if ($conf->societe->enabled && $user->rights->societe->lire)
{ {
$langs->load("boxes"); $langs->load("boxes");
$sql = "SELECT s.rowid, s.nom as name, s.client, s.datec,s.tms"; $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.client IN (1, 2, 3)"; $sql.= " WHERE s.client IN (1, 2, 3)";

View File

@ -189,7 +189,7 @@ class Conf
{ {
$modulename=strtolower($reg[1]); $modulename=strtolower($reg[1]);
if ($modulename == 'propale') $modulename='propal'; if ($modulename == 'propale') $modulename='propal';
if (! is_object($this->$modulename)) $this->$modulename=(object) array(); if (! isset($this->$modulename) || ! is_object($this->$modulename)) $this->$modulename=(object) array();
$this->$modulename->enabled=true; $this->$modulename->enabled=true;
$this->modules[]=$modulename; // Add this module in list of enabled modules $this->modules[]=$modulename; // Add this module in list of enabled modules
} }

View File

@ -88,7 +88,7 @@ class DolGraph
global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet;
// To use old feature // To use old feature
if ($conf->global->MAIN_GRAPH_LIBRARY == 'artichow') if (isset($conf->global->MAIN_GRAPH_LIBRARY) && $conf->global->MAIN_GRAPH_LIBRARY == 'artichow')
{ {
$this->_library='artichow'; $this->_library='artichow';
@ -850,7 +850,7 @@ class DolGraph
$this->_stringtoshow.='{ '; $this->_stringtoshow.='{ ';
if (! isset($this->type[$i]) || $this->type[$i] == 'bars') $this->_stringtoshow.='bars: { show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; if (! isset($this->type[$i]) || $this->type[$i] == 'bars') $this->_stringtoshow.='bars: { show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, ';
if (isset($this->type[$i]) && $this->type[$i] == 'lines') $this->_stringtoshow.='lines: { show: true, fill: false }, '; if (isset($this->type[$i]) && $this->type[$i] == 'lines') $this->_stringtoshow.='lines: { show: true, fill: false }, ';
$this->_stringtoshow.='color: "#'.$color.'", label: "'.dol_escape_js($this->Legend[$i]).'", data: d'.$i.' }'; $this->_stringtoshow.='color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }';
$i++; $i++;
} }
$this->_stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n"; $this->_stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n";

View File

@ -178,7 +178,7 @@ function show_array_actions_to_do($max=5)
include_once(DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'); include_once(DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php');
include_once(DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'); include_once(DOL_DOCUMENT_ROOT.'/societe/class/client.class.php');
$sql = "SELECT a.id, a.label, a.datep as dp, a.fk_user_author, a.percent,"; $sql = "SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent,";
$sql.= " c.code, c.libelle,"; $sql.= " c.code, c.libelle,";
$sql.= " s.nom as sname, s.rowid, s.client"; $sql.= " s.nom as sname, s.rowid, s.client";
$sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c,"; $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c,";
@ -226,13 +226,13 @@ function show_array_actions_to_do($max=5)
print '<td>'; print '<td>';
if ($obj->rowid > 0) if ($obj->rowid > 0)
{ {
$customerstatic->id=$obj->rowid; $customerstatic->id=$obj->rowid;
$customerstatic->name=$obj->sname; $customerstatic->name=$obj->sname;
$customerstatic->client=$obj->client; $customerstatic->client=$obj->client;
print $customerstatic->getNomUrl(1,'',16); print $customerstatic->getNomUrl(1,'',16);
} }
print '</td>'; print '</td>';
$datep=$db->jdate($obj->dp); $datep=$db->jdate($obj->dp);
$datep2=$db->jdate($obj->dp2); $datep2=$db->jdate($obj->dp2);

View File

@ -115,14 +115,12 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
if ($dbt_select != 'rowid') $objectid = "'".$objectid."'"; if ($dbt_select != 'rowid') $objectid = "'".$objectid."'";
// More features to check // More features to check
if (! empty($features)) { $features = explode("&", $features);
$features = explode("&", $features);
}
// More parameters // More parameters
if (! empty($dbtablename)) { $params = explode('&', $dbtablename);
list($dbtablename, $sharedelement) = explode('&', $dbtablename); $dbtablename=(! empty($params[0]) ? $params[0] : '');
} $sharedelement=(! empty($params[1]) ? $params[1] : '');
// Check read permission from module // Check read permission from module
// TODO Replace "feature" param into caller by first level of permission // TODO Replace "feature" param into caller by first level of permission

View File

@ -293,7 +293,7 @@ class ProductFournisseur extends Product
global $conf; global $conf;
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.fk_availability"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.fk_availability";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."societe as s";

View File

@ -1569,6 +1569,10 @@ function main_area($title='')
*/ */
function getHelpParamFor($helppagename,$langs) function getHelpParamFor($helppagename,$langs)
{ {
$helpbaseurl='';
$helppage='';
$mode='';
if (preg_match('/^http/i',$helppagename)) if (preg_match('/^http/i',$helppagename))
{ {
// If complete URL // If complete URL

View File

@ -1991,11 +1991,15 @@ class Product extends CommonObject
{ {
if (is_array($desc_pere)) // If this parent desc is an array, this is an array of childs if (is_array($desc_pere)) // If this parent desc is an array, this is an array of childs
{ {
if($multiply) $id=(! empty($desc_pere[0]) ? $desc_pere[0] :'');
$nb=(! empty($desc_pere[1]) ? $desc_pere[1] :'');
$type=(! empty($desc_pere[2]) ? $desc_pere[2] :'');
if ($multiply)
{ {
//print "XXX ".$desc_pere[1]." multiply=".$multiply; //print "XXX ".$desc_pere[1]." multiply=".$multiply;
$img=""; $img="";
$this->fetch($desc_pere[0]); $this->fetch($id);
$this->load_stock(); $this->load_stock();
if ($this->stock_warehouse[1]->real < $this->seuil_stock_alerte) if ($this->stock_warehouse[1]->real < $this->seuil_stock_alerte)
{ {
@ -2007,13 +2011,13 @@ class Product extends CommonObject
</a> (".$desc_pere[1].")</td><td align=\"center\"> ".($desc_pere[1]*$multiply)."</td><td>&nbsp</td><td>&nbsp</td> </a> (".$desc_pere[1].")</td><td align=\"center\"> ".($desc_pere[1]*$multiply)."</td><td>&nbsp</td><td>&nbsp</td>
<td align=\"center\">".$this->stock_entrepot[1]." ".$img."</td></tr>", <td align=\"center\">".$this->stock_entrepot[1]." ".$img."</td></tr>",
$desc_pere[0], // Id product $desc_pere[0], // Id product
*/ 'id'=>$desc_pere[0], // Id product */ 'id'=>$id, // Id product
'nb'=>$desc_pere[1], // Nb of units that compose parent product 'nb'=>$nb, // Nb of units that compose parent product
'nb_total'=>$desc_pere[1]*$multiply, // Nb of units for all nb of product 'nb_total'=>$nb*$multiply, // Nb of units for all nb of product
'stock'=>$this->stock_warehouse[1]->real, // Stock 'stock'=>$this->stock_warehouse[1]->real, // Stock
'stock_alert'=>$this->seuil_stock_alerte, // Stock alert 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert
'fullpath' => $compl_path.$nom_pere, // Label 'fullpath' => $compl_path.$nom_pere, // Label
'type'=>$desc_pere[2] // Nb of units that compose parent product 'type'=>$type // Nb of units that compose parent product
); );
} }
else else
@ -2023,13 +2027,13 @@ class Product extends CommonObject
$this->res[]= array( $this->res[]= array(
/* $compl_path.$nom_pere." (".$desc_pere[1].")", /* $compl_path.$nom_pere." (".$desc_pere[1].")",
$desc_pere[0], // Id product $desc_pere[0], // Id product
*/ 'id'=>$desc_pere[0], // Id product */ 'id'=>$id, // Id product
'nb'=>$desc_pere[1], // Nb of units that compose parent product 'nb'=>$nb, // Nb of units that compose parent product
'nb_total'=>$desc_pere[1], // Nb of units for all nb of product 'nb_total'=>$nb, // Nb of units for all nb of product
'stock'=>$this->stock_warehouse[1]->real, // Stock 'stock'=>$this->stock_warehouse[1]->real, // Stock
'stock_alert'=>$this->seuil_stock_alerte, // Stock alert 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert
'fullpath' => $compl_path.$nom_pere, // Label 'fullpath' => $compl_path.$nom_pere, // Label
'type'=>$desc_pere[2] // Nb of units that compose parent product 'type'=>$type // Nb of units that compose parent product
); );
} }
} }

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
@ -35,24 +35,22 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$id=GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$cancel=GETPOST('cancel','alpha');
$key=GETPOST('key');
$catMere=GETPOST('catMere');
// Security check // Security check
if (isset($_GET["id"]) || isset($_GET["ref"])) if (! empty($user->societe_id)) $socid=$user->societe_id;
{ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
} $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
$mesg = ''; $mesg = '';
$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
$ref=isset($_GET["ref"])?$_GET["ref"]:$_POST["ref"];
$key=isset($_GET["key"])?$_GET["key"]:$_POST["key"];
$catMere=isset($_GET["catMere"])?$_GET["catMere"]:$_POST["catMere"];
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
$cancel=isset($_GET["cancel"])?$_GET["cancel"]:$_POST["cancel"];
$product = new Product($db); $product = new Product($db);
$productid=0; $productid=0;
if ($id || $ref) if ($id || $ref)

View File

@ -44,7 +44,7 @@ $confirm=GETPOST('confirm','alpha');
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service',$fielvalue,'product&product','','',$fieldtype); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);
// Get parameters // Get parameters
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
@ -72,7 +72,7 @@ $modulepart='produit';
* Action envoie fichier * Action envoie fichier
*/ */
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
if (dol_mkdir($upload_dir) >= 0) if (dol_mkdir($upload_dir) >= 0)
{ {
@ -121,9 +121,8 @@ llxHeader("","",$langs->trans("CardProduct".$object->type));
if ($object->id) if ($object->id)
{ {
if ( $error_msg ) if (! empty($mesg)) {
{ dol_htmloutput_mesg($mesg);
echo '<div class="error">'.$error_msg.'</div><br>';
} }
if ($action=='delete') if ($action=='delete')

View File

@ -171,7 +171,7 @@ if ($action == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel"))
} }
} }
if ($_POST["cancel"] == $langs->trans("Cancel")) if (GETPOST('cancel') == $langs->trans("Cancel"))
{ {
$action = ''; $action = '';
Header("Location: fournisseurs.php?id=".$_GET["id"]); Header("Location: fournisseurs.php?id=".$_GET["id"]);

View File

@ -57,7 +57,7 @@ if ($id > 0 || ! empty($ref))
* Actions * Actions
*/ */
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
if ($object->id) $result = $object->add_photo($dir, $_FILES['userfile']); if ($object->id) $result = $object->add_photo($dir, $_FILES['userfile']);
} }
@ -94,7 +94,7 @@ if ($object->id)
/* /*
* Confirmation de la suppression de photo * Confirmation de la suppression de photo
*/ */
if ($_GET['action'] == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
@ -139,7 +139,7 @@ if ($object->id)
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer))
{ {
if (! empty($conf->global->MAIN_UPLOAD_DOC)) if (! empty($conf->global->MAIN_UPLOAD_DOC))
{ {

View File

@ -144,9 +144,9 @@ if ($isphoto)
print '</tr>'; print '</tr>';
// MultiPrix // MultiPrix
if ($conf->global->PRODUIT_MULTIPRICES) if (! empty($conf->global->PRODUIT_MULTIPRICES))
{ {
if ($socid) if (! empty($socid))
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->id = $socid; $soc->id = $socid;
@ -272,8 +272,9 @@ print "</table>\n";
print "</div>\n"; print "</div>\n";
if (! empty($mesg)) {
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
}
/* ************************************************************************** */ /* ************************************************************************** */
@ -431,7 +432,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product_price as p,";
$sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE fk_product = ".$object->id; $sql.= " WHERE fk_product = ".$object->id;
$sql.= " AND p.fk_user_author = u.rowid"; $sql.= " AND p.fk_user_author = u.rowid";
if ($socid && $conf->global->PRODUIT_MULTIPRICES) $sql.= " AND p.price_level = ".$soc->price_level; if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND p.price_level = ".$soc->price_level;
$sql.= " ORDER BY p.date_price DESC, p.price_level ASC"; $sql.= " ORDER BY p.date_price DESC, p.price_level ASC";
//$sql .= $db->plimit(); //$sql .= $db->plimit();

View File

@ -35,10 +35,12 @@ $langs->load("products");
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$socid='';
if (! empty($user->societe_id)) $socid=$user->societe_id;
// Security check // Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);
$mesg = ''; $mesg = '';

View File

@ -40,10 +40,12 @@ $mode = (GETPOST('mode') ? GETPOST('mode') : 'byunit');
$error = 0; $error = 0;
$mesg = ''; $mesg = '';
$socid='';
if (! empty($user->societe_id)) $socid=$user->societe_id;
// Security check // Security check
$fieldvalue = (! empty($id) ? $id : $ref); $fieldvalue = (! empty($id) ? $id : $ref);
$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);

View File

@ -35,6 +35,8 @@ $langs->load("languages");
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action=GETPOST('action','alpha');
$cancel=GETPOST('cancel','alpha');
// Security check // Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
@ -48,18 +50,18 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','',
*/ */
// retour a l'affichage des traduction si annulation // retour a l'affichage des traduction si annulation
if ($_POST["cancel"] == $langs->trans("Cancel")) if ($cancel == $langs->trans("Cancel"))
{ {
$_GET["action"] = ''; $action = '';
} }
// Validation de l'ajout // Validation de l'ajout
if ($_POST["action"] == 'vadd' && if ($action == 'vadd' &&
$_POST["cancel"] != $langs->trans("Cancel") && $cancel != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer)) ($user->rights->produit->creer || $user->rights->service->creer))
{ {
$product = new Product($db); $product = new Product($db);
$product->fetch($_POST["id"]); $product->fetch($id);
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
// update de l'objet // update de l'objet
@ -79,22 +81,22 @@ $_POST["cancel"] != $langs->trans("Cancel") &&
// sauvegarde en base // sauvegarde en base
if ( $product->setMultiLangs() > 0 ) if ( $product->setMultiLangs() > 0 )
{ {
$_GET["action"] = ''; $action = '';
} }
else else
{ {
$_GET["action"] = 'add'; $action = 'add';
$mesg = $product->mesg_error; $mesg = '<div class="error">'.$product->error.'</div>';
} }
} }
// Validation de l'edition // Validation de l'edition
if ($_POST["action"] == 'vedit' && if ($action == 'vedit' &&
$_POST["cancel"] != $langs->trans("Cancel") && $cancel != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer)) ($user->rights->produit->creer || $user->rights->service->creer))
{ {
$product = new Product($db); $product = new Product($db);
$product->fetch($_POST["id"]); $product->fetch($id);
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet
@ -115,18 +117,17 @@ $_POST["cancel"] != $langs->trans("Cancel") &&
if ( $product->setMultiLangs() > 0 ) if ( $product->setMultiLangs() > 0 )
{ {
$_GET["action"] = ''; $action = '';
} }
else else
{ {
$_GET["action"] = 'edit'; $action = 'edit';
$mesg = $product->mesg_error; $mesg = '<div class="error">'.$product->error.'</div>';
} }
} }
$product = new Product($db); $product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); $result = $product->fetch($id,$ref);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
/* /*
@ -143,7 +144,9 @@ $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product'); $picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'translation', $titre, 0, $picto); dol_fiche_head($head, 'translation', $titre, 0, $picto);
if ($mesg) print '<div class="error">'.$mesg.'</div>'; if (! empty($mesg)) {
dol_htmloutput_mesg($mesg);
}
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -155,30 +158,33 @@ print '</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
if ($_GET["action"] == 'edit') if ($action == 'edit')
{ {
print '<form action="" method="POST">'; print '<form action="" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vedit">'; print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">'; print '<input type="hidden" name="id" value="'.$product->id.'">';
foreach ( $product->multilangs as $key => $value) if (! empty($product->multilangs))
{ {
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>"; foreach ($product->multilangs as $key => $value)
print '<table class="border" width="100%">'; {
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$product->multilangs[$key]["libelle"].'"></td></tr>'; print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>'; print '<table class="border" width="100%">';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$product->multilangs[$key]["libelle"].'"></td></tr>';
$doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80); print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
$doleditor->Create(); require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
print '</td></tr>'; $doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>'; $doleditor->Create();
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); print '</td></tr>';
$doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80); print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>';
$doleditor->Create(); require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
print '</td></tr>'; $doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
print '</tr>'; $doleditor->Create();
print '</table>'; print '</td></tr>';
print '</tr>';
print '</table>';
}
} }
print '<br><center>'; print '<br><center>';
@ -191,18 +197,21 @@ if ($_GET["action"] == 'edit')
else else
{ {
$cnt_trans = 0; $cnt_trans = 0;
foreach ( $product->multilangs as $key => $value) if (! empty($product->multilangs))
{ {
$cnt_trans++; foreach ($product->multilangs as $key => $value)
$s=picto_from_langcode($key); {
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b><br>"; $cnt_trans++;
print '<table class="border" width="100%">'; $s=picto_from_langcode($key);
print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$product->multilangs[$key]["libelle"].'</td></tr>'; print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b><br>";
print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$product->multilangs[$key]["description"].'</td></tr>'; print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$product->multilangs[$key]["note"].'</td></tr>'; print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$product->multilangs[$key]["libelle"].'</td></tr>';
print '</table>'; print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$product->multilangs[$key]["description"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$product->multilangs[$key]["note"].'</td></tr>';
print '</table>';
}
} }
if (!$cnt_trans ) print '<br>'. $langs->trans('NoTranslation'); if (! $cnt_trans) print '<br>'. $langs->trans('NoTranslation');
} }
print "</div>\n"; print "</div>\n";
@ -216,7 +225,7 @@ print "</div>\n";
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '') if ($action == '')
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=add&id='.$product->id.'">'.$langs->trans("Add").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=add&id='.$product->id.'">'.$langs->trans("Add").'</a>';
@ -230,7 +239,7 @@ print "\n</div>\n";
* Form to add a new translation * Form to add a new translation
*/ */
if ($_GET["action"] == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
{ {
print '<br>'; print '<br>';
print '<form action="" method="post">'; print '<form action="" method="post">';
@ -264,5 +273,7 @@ if ($_GET["action"] == 'add' && ($user->rights->produit->creer || $user->rights-
print '<br>'; print '<br>';
} }
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -75,7 +75,12 @@ print "</table></form><br>";
/* /*
* Statistics area * Statistics area
*/ */
$third = array(); $third = array(
'customer' => 0,
'prospect' => 0,
'supplier' => 0,
'other' =>0
);
$total=0; $total=0;
$sql = "SELECT s.rowid, s.client, s.fournisseur"; $sql = "SELECT s.rowid, s.client, s.fournisseur";
@ -92,10 +97,10 @@ if ($result)
while ($objp = $db->fetch_object($result)) while ($objp = $db->fetch_object($result))
{ {
$found=0; $found=0;
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; }
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; } if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; }
if ($conf->fournisseur->enabled && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; }
if ($conf->societe->enabled && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; }
if ($found) $total++; if ($found) $total++;
} }
} }
@ -103,7 +108,7 @@ else dol_print_error($db);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
if ($conf->use_javascript_ajax && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2))
{ {
print '<tr><td align="center">'; print '<tr><td align="center">';
$dataseries=array(); $dataseries=array();

View File

@ -143,7 +143,9 @@ $fontsizesmaller =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty(
// Set text color to black or white // Set text color to black or white
$tmppart=explode(',',$colorback1); $tmppart=explode(',',$colorback1);
$tmpval=$tmppart[1]+$tmppart[2]+$tmppart[3]; $tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '');
$tmpval+=(! empty($tmppart[2]) ? $tmppart[2] : '');
$tmpval+=(! empty($tmppart[3]) ? $tmppart[3] : '');
//print $tmpval; //print $tmpval;
if ($tmpval < 340) $colortextmain='FFFFFF'; if ($tmpval < 340) $colortextmain='FFFFFF';
else $colortextmain='101010'; else $colortextmain='101010';

View File

@ -531,11 +531,11 @@ class User extends CommonObject
if ($perms) if ($perms)
{ {
if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error
if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array();
if ($subperms) if ($subperms)
{ {
if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array();
$this->rights->$module->$perms->$subperms = 1; $this->rights->$module->$perms->$subperms = 1;
} }
else else
@ -578,11 +578,11 @@ class User extends CommonObject
if ($perms) if ($perms)
{ {
if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error
if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array();
if ($subperms) if ($subperms)
{ {
if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array();
$this->rights->$module->$perms->$subperms = 1; $this->rights->$module->$perms->$subperms = 1;
} }
else else

View File

@ -470,11 +470,11 @@ class UserGroup extends CommonObject
if ($perms) if ($perms)
{ {
if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error
if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array();
if ($subperms) if ($subperms)
{ {
if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array();
$this->rights->$module->$perms->$subperms = 1; $this->rights->$module->$perms->$subperms = 1;
} }
else else