From 320fe741cb639c90fc517b9a65f32fac49607c2f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 8 Jul 2012 22:43:06 +0200 Subject: [PATCH 1/9] Fix: avoid warning with php 5.4 and strict mode --- htdocs/comm/action/class/actioncomm.class.php | 6 +++ .../default/tpl/contactcard_edit.tpl.php | 3 +- htdocs/contact/fiche.php | 3 +- htdocs/core/ajax/ajaxdirpreview.php | 18 +++---- htdocs/core/ajax/ajaxdirtree.php | 2 +- htdocs/core/boxes/box_activity.php | 2 +- htdocs/core/class/html.form.class.php | 9 ++-- htdocs/core/lib/functions.lib.php | 16 +++---- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/security.lib.php | 8 +++- htdocs/main.inc.php | 47 ++++++++++--------- htdocs/product/class/product.class.php | 1 + htdocs/product/class/service.class.php | 2 +- htdocs/product/fiche.php | 36 +++++++------- htdocs/product/index.php | 6 +-- htdocs/societe/class/address.class.php | 32 ++++++------- htdocs/user/class/user.class.php | 3 ++ 17 files changed, 108 insertions(+), 88 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c982bfbcdbd..ed54057f962 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -287,19 +287,25 @@ class ActionComm extends CommonObject $this->note = $obj->note; $this->percentage = $obj->percentage; + $this->author = (object) array(); $this->author->id = $obj->fk_user_author; $this->author->firstname = $obj->firstname; $this->author->lastname = $obj->lastname; + $this->usermod = (object) array(); $this->usermod->id = $obj->fk_user_mod; + $this->usertodo = (object) array(); $this->usertodo->id = $obj->fk_user_action; + $this->userdone = (object) array(); $this->userdone->id = $obj->fk_user_done; $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->societe = (object) array(); $this->societe->id = $obj->fk_soc; + $this->contact = (object) array(); $this->contact->id = $obj->fk_contact; $this->fk_project = $obj->fk_project; diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index c8629f185e8..c4b48767f2f 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -133,12 +133,13 @@ echo $this->control->tpl['ajax_selectcountry']; +control->tpl['contact_element'])) { ?> control->tpl['contact_element'] as $element) { ?> - + trans("DolibarrLogin"); ?> diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4c47d13805c..7487bf6d06f 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -540,10 +540,11 @@ else print ''; print ''; print ''; - print ''; print ''; print ''; print ''; + if (! empty($backtopage)) print ''; + print ''; // Ref diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 05f667be112..4205c9c24ac 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -45,15 +45,15 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call $module=GETPOST("module"); $urlsource=GETPOST("urlsource"); - $sortfield = GETPOST("sortfield",'alpha'); - $sortorder = GETPOST("sortorder",'alpha'); - $page = GETPOST("page",'int'); - if ($page == -1) { $page = 0; } - $offset = $conf->liste_limit * $page; - $pageprev = $page - 1; - $pagenext = $page + 1; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="name"; + $sortfield = GETPOST("sortfield",'alpha'); + $sortorder = GETPOST("sortorder",'alpha'); + $page = GETPOST("page",'int'); + if ($page == -1) { $page = 0; } + $offset = $conf->liste_limit * $page; + $pageprev = $page - 1; + $pagenext = $page + 1; + if (! $sortorder) $sortorder="ASC"; + if (! $sortfield) $sortfield="name"; $upload_dir = dirname(str_replace("../","/", $conf->ecm->dir_output.'/'.$file)); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index b33161a0d55..60952f4961f 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -72,7 +72,7 @@ if ($modulepart == 'ecm') * View */ -top_httphead(); +top_httphead(); $userstatic=new User($db); $form=new Form($db); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index c437a9f2fdf..d26f4f8fdfc 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -85,7 +85,7 @@ class box_activity extends ModeleBoxes if ($result) { $num = $db->num_rows($result); - $now=gmmktime(); + $now=dol_now(); $i = 0; while ($i < $num) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 63a31c85483..42a6119c611 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -91,7 +91,7 @@ class Form if ($perm) { $tmp=explode(':',$typeofdata); - $ret.= '
'; + $ret.= '
'; $ret.= $langs->trans($text); $ret.= '
'."\n"; } @@ -267,7 +267,8 @@ class Form if (preg_match('/^(string|email|numeric)/',$inputType)) { $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; + $inputType=$tmp[0]; + if (! empty($tmp[1])) $inputOption=$tmp[1]; if (! empty($tmp[2])) $savemethod=$tmp[2]; } else if (preg_match('/^datepicker/',$inputType)) @@ -2237,8 +2238,8 @@ class Form { foreach ($formquestion as $key => $input) { - array_push($inputok,$input['name']); - if ($input['inputko'] == 1) array_push($inputko,$input['name']); + if (isset($input['name'])) array_push($inputok,$input['name']); + if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko,$input['name']); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 455758b6148..4503d8e9192 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -821,12 +821,12 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e // This part of code should not be used. dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' - $syear = $reg[1]; - $smonth = $reg[2]; - $sday = $reg[3]; - $shour = $reg[4]; - $smin = $reg[5]; - $ssec = $reg[6]; + $syear = (! empty($reg[1]) ? $reg[1] : ''); + $smonth = (! empty($reg[2]) ? $reg[2] : ''); + $sday = (! empty($reg[3]) ? $reg[3] : ''); + $shour = (! empty($reg[4]) ? $reg[4] : ''); + $smin = (! empty($reg[5]) ? $reg[5] : ''); + $ssec = (! empty($reg[6]) ? $reg[6] : ''); $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); @@ -966,7 +966,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) else $localtz = new DateTimeZone('UTC'); $dt = new DateTime(null,$localtz); $dt->setDate($year,$month,$day); - $dt->setTime($hour,$minute,$second); + $dt->setTime((int) $hour, (int) $minute, (int) $second); $date=$dt->getTimestamp(); } else @@ -3852,7 +3852,7 @@ function picto_from_langcode($codelang) */ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add') { - if (is_array($conf->tabs_modules[$type])) + if (isset($conf->tabs_modules[$type]) && is_array($conf->tabs_modules[$type])) { foreach ($conf->tabs_modules[$type] as $value) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e13c7dbdc64..d811a3edfd1 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -123,7 +123,7 @@ function product_prepare_head($object, $user) // More tabs from canvas - if (is_array($object->onglets)) + if (isset($object->onglets) && is_array($object->onglets)) { foreach ($object->onglets as $onglet) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b1047350a89..95cdb171a1d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -115,10 +115,14 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature if ($dbt_select != 'rowid') $objectid = "'".$objectid."'"; // More features to check - $features = explode("&",$features); + if (! empty($features)) { + $features = explode("&", $features); + } // More parameters - list($dbtablename, $sharedelement) = explode('&', $dbtablename); + if (! empty($dbtablename)) { + list($dbtablename, $sharedelement) = explode('&', $dbtablename); + } // Check read permission from module // TODO Replace "feature" param into caller by first level of permission diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 31f22ef81b6..2936da5720d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -669,7 +669,7 @@ if (! defined('NOREQUIRETRAN')) } // Use php template engine -if ($conf->global->MAIN_USE_TEMPLATE_ENGINE && ! defined('NOTEMPLATEENGINE')) +if (! empty($conf->global->MAIN_USE_TEMPLATE_ENGINE) && ! defined('NOTEMPLATEENGINE')) { require_once(DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php'); @@ -893,14 +893,17 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; print ''."\n"; // CSS forced by modules (relative url starting with /) - $dircss=(array) $conf->modules_parts['css']; - foreach($dircss as $key => $cssfile) + if (isset($conf->modules_parts['css'])) { - // cssfile is a relative path - print ''."\n"; + $dircss=(array) $conf->modules_parts['css']; + foreach($dircss as $key => $cssfile) + { + // cssfile is a relative path + print ''."\n"; + } } // CSS forced by page in top_htmlhead call (relative url starting with /) if (is_array($arrayofcss)) @@ -1207,7 +1210,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print "\n".''."\n"; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '
'."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; print '
'."\n"; @@ -1241,7 +1244,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $loginhtmltext.='
'.$langs->trans("IPAddress").': '.$_SERVER["REMOTE_ADDR"]; $loginhtmltext.='
'; $loginhtmltext.='
'.$langs->trans("Connection").''; - if ($conf->global->MAIN_MODULE_MULTICOMPANY) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; $loginhtmltext.='
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; @@ -1253,7 +1256,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (! empty($_SESSION["disablemodules"])) $loginhtmltext.='
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); $appli='Dolibarr'; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; // Link info $logouttext=''; @@ -1281,7 +1284,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'; - if (! is_object($form)) $form=new Form($db); + $form=new Form($db); $toprightmenu.=$form->textwithtooltip('',$loginhtmltext,2,1,$logintext,'',1); @@ -1308,11 +1311,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'."\n"; print "\n"; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n"; print "\n"; - if (! $conf->use_javascript_ajax || ! $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ''; + if (empty($conf->use_javascript_ajax) || empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'; } @@ -1347,32 +1350,32 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me } $hookmanager->initHooks(array('searchform','leftblock')); - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'
'."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".'
'."\n"; else print '
'; print "\n"; @@ -1527,7 +1530,7 @@ function main_area($title='') { global $conf, $langs; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) { print '
'."\n"; print '
'; print "\n"; // Define $searchform - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname'); } - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); } - if ((($conf->product->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire)) - && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE) + if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) + && ! empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE)) { $langs->load("products"); $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/liste.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); } - if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) + if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_ADHERENT) && $user->rights->adherent->lire) { $langs->load("members"); $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall'); @@ -1504,7 +1507,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $leftblock=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $leftblock; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ' '."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; else print '
'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fe6fa3395a9..409a0f775b0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2423,6 +2423,7 @@ class Product extends CommonObject while ($i < $num) { $row = $this->db->fetch_object($result); + $this->stock_warehouse[$row->fk_entrepot] = (object) array(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp; $this->stock_reel+=$row->reel; diff --git a/htdocs/product/class/service.class.php b/htdocs/product/class/service.class.php index a2780e88b91..8d12267ea0b 100644 --- a/htdocs/product/class/service.class.php +++ b/htdocs/product/class/service.class.php @@ -66,7 +66,7 @@ class Service extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= " AND p.fk_product_type = 1"; $resql=$this->db->query($sql); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 11121edf567..03d6dad9356 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -668,7 +668,7 @@ $helpurl=''; if (GETPOST("type") == '0') $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; if (GETPOST("type") == '1') $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; -llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl); +llxHeader('',$langs->trans("CardProduct".GETPOST("type")),$helpurl); $form = new Form($db); $formproduct = new FormProduct($db); @@ -1047,7 +1047,7 @@ else dol_fiche_head($head, 'card', $titre, 0, $picto); $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); - $showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire; + $showbarcode=(! empty($conf->barcode->enabled) && $user->rights->barcode->lire); // En mode visu print '
'; @@ -1137,13 +1137,13 @@ else } // Accountancy sell code - print ''; // Accountancy buy code - print ''; // Status (to sell) @@ -1179,7 +1179,7 @@ else { $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); } - print $langs->trans($dur[$object->duration_unit])." "; + print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print ''; } @@ -1302,11 +1302,11 @@ if ($action == '' || $action == 'view') { if ($user->rights->produit->creer || $user->rights->service->creer) { - if ($object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; + if (isset($object->no_button_edit) && $object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; - if ($object->no_button_copy <> 1) + if (isset($object->no_button_copy) && $object->no_button_copy <> 1) { - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ''.$langs->trans('ToClone').''."\n"; print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); @@ -1322,9 +1322,9 @@ if ($action == '' || $action == 'view') if (($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer)) { - if (! $object_is_used && $object->no_button_delete <> 1) + if (! $object_is_used && isset($object->no_button_delete) && $object->no_button_delete <> 1) { - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ''.$langs->trans('Delete').''."\n"; print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); @@ -1357,7 +1357,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print '
'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer); + print '
'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').''; + print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print '
'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer); + print '
'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').''; + print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print '
'; // Propals - if($conf->propal->enabled && $user->rights->propale->creer) + if (! empty($conf->propal->enabled) && $user->rights->propale->creer) { $propal = new Propal($db); @@ -1413,7 +1413,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print ''; @@ -1474,7 +1474,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } // Commande - if($conf->commande->enabled && $user->rights->commande->creer) + if (! empty($conf->commande->enabled) && $user->rights->commande->creer) { $commande = new Commande($db); @@ -1530,7 +1530,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print ''; @@ -1592,7 +1592,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } // Factures - if ($conf->facture->enabled && $user->rights->facture->creer) + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { print ''; @@ -1743,6 +1743,6 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/index.php b/htdocs/product/index.php index bfd666fad2b..8703283e460 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 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 @@ -74,7 +74,7 @@ print '
'; print ''.$langs->trans("ReductionShort"); print '%'; - print " ".$object->stock_proposition; + if (isset($object->stock_proposition)) print " ".$object->stock_proposition; print ''; print ''; print ''; print ''.$langs->trans("ReductionShort"); print '%'; - print " ".$object->stock_proposition; + if (isset($object->stock_proposition)) print " ".$object->stock_proposition; print ''; print ''; print '
'; print $langs->trans("AddToMyBills").'
'; * Zone recherche produit/service */ $rowspan=2; -if ($conf->barcode->enabled) $rowspan++; +if (! empty($conf->barcode->enabled)) $rowspan++; print '
'; print ''; print ''; @@ -83,7 +83,7 @@ print ''; print "'; print ''; -if ($conf->barcode->enabled) +if (! empty($conf->barcode->enabled)) { print "'; diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index f1a0815b4c7..a8360e52968 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -86,7 +86,7 @@ class Address if ($result >= 0) { $now=dol_now(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) "; $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate($now).", '".$user->id."')"; @@ -188,7 +188,7 @@ class Address if ($result >= 0) { dol_syslog(get_class($this)."::Update verify ok"); - + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_address"; @@ -203,7 +203,7 @@ class Address $sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null"); if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; $sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $id ."'"; - + dol_syslog(get_class($this)."::Update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -216,7 +216,7 @@ class Address { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - + $this->error=$langs->trans("ErrorDuplicateField",$this->name); $result=-1; } @@ -302,7 +302,7 @@ class Address $line->phone = $objp->tel; $line->fax = $objp->fax; $line->note = $objp->note; - + // deprecated $line->cp = $line->zip; $line->ville = $line->town; @@ -381,14 +381,14 @@ class Address $this->phone = $obj->tel; $this->fax = $obj->fax; $this->note = $obj->note; - + // deprecated - $line->cp = $line->zip; - $line->ville = $line->town; - $line->pays_id = $line->country_id; - $line->pays_code = $line->country_code; - $line->pays = $line->country; - $line->tel = $line->phone; + $this->cp = $this->zip; + $this->ville = $this->town; + $this->pays_id = $this->country_id; + $this->pays_code = $this->country_code; + $this->pays = $this->country; + $this->tel = $this->phone; $result = 1; } @@ -435,7 +435,7 @@ class Address print $this->db->error() . '
' . $sql; } } - + /** * Return name of address with link (and eventually picto) * Use $this->id, $this->label, $this->socid @@ -447,12 +447,12 @@ class Address function getNomUrl($withpicto=0,$option='') { global $langs; - + $result=''; - + $lien = ''; $lienfin=''; - + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label,'address').$lienfin.' '); $result.=$lien.$this->label.$lienfin; return $result; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index d0ee57086e0..f3cad67cd4a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -578,8 +578,11 @@ class User extends CommonObject if ($perms) { + if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error + if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if ($subperms) { + if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); $this->rights->$module->$perms->$subperms = 1; } else From 887f210618c0547020fb56470a89b176a822505d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 8 Jul 2012 23:22:22 +0200 Subject: [PATCH 2/9] Fix: avoid warning with php 5.4 and strict mode --- htdocs/comm/action/class/actioncomm.class.php | 7 +++ .../default/tpl/contactcard_edit.tpl.php | 3 +- htdocs/contact/fiche.php | 3 +- htdocs/core/ajax/ajaxdirpreview.php | 18 +++---- htdocs/core/ajax/ajaxdirtree.php | 2 +- htdocs/core/boxes/box_activity.php | 2 +- htdocs/core/class/html.form.class.php | 9 ++-- htdocs/core/lib/functions.lib.php | 16 +++---- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/security.lib.php | 8 +++- .../fourn/class/fournisseur.facture.class.php | 44 ++++++++--------- htdocs/main.inc.php | 47 ++++++++++--------- htdocs/product/class/product.class.php | 1 + htdocs/product/class/service.class.php | 2 +- htdocs/product/fiche.php | 36 +++++++------- htdocs/product/index.php | 6 +-- htdocs/projet/class/task.class.php | 27 ++++++----- htdocs/societe/class/address.class.php | 32 ++++++------- htdocs/user/class/user.class.php | 3 ++ htdocs/user/class/usergroup.class.php | 3 ++ htdocs/user/clicktodial.php | 2 +- 21 files changed, 150 insertions(+), 123 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c982bfbcdbd..1d9612271cf 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -86,6 +86,13 @@ class ActionComm extends CommonObject function ActionComm($db) { $this->db = $db; + + $this->author = (object) array(); + $this->usermod = (object) array(); + $this->usertodo = (object) array(); + $this->userdone = (object) array(); + $this->societe = (object) array(); + $this->contact = (object) array(); } /** diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index c8629f185e8..c4b48767f2f 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -133,12 +133,13 @@ echo $this->control->tpl['ajax_selectcountry']; +control->tpl['contact_element'])) { ?> control->tpl['contact_element'] as $element) { ?> - + diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4c47d13805c..7487bf6d06f 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -540,10 +540,11 @@ else print ''; print ''; print ''; - print ''; print ''; print ''; print ''; + if (! empty($backtopage)) print ''; + print '
'.$langs->trans("Search").'
"; print $langs->trans("Ref").':
"; print $langs->trans("BarCode").':
trans("DolibarrLogin"); ?>
'; // Ref diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 05f667be112..4205c9c24ac 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -45,15 +45,15 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call $module=GETPOST("module"); $urlsource=GETPOST("urlsource"); - $sortfield = GETPOST("sortfield",'alpha'); - $sortorder = GETPOST("sortorder",'alpha'); - $page = GETPOST("page",'int'); - if ($page == -1) { $page = 0; } - $offset = $conf->liste_limit * $page; - $pageprev = $page - 1; - $pagenext = $page + 1; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="name"; + $sortfield = GETPOST("sortfield",'alpha'); + $sortorder = GETPOST("sortorder",'alpha'); + $page = GETPOST("page",'int'); + if ($page == -1) { $page = 0; } + $offset = $conf->liste_limit * $page; + $pageprev = $page - 1; + $pagenext = $page + 1; + if (! $sortorder) $sortorder="ASC"; + if (! $sortfield) $sortfield="name"; $upload_dir = dirname(str_replace("../","/", $conf->ecm->dir_output.'/'.$file)); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index b33161a0d55..60952f4961f 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -72,7 +72,7 @@ if ($modulepart == 'ecm') * View */ -top_httphead(); +top_httphead(); $userstatic=new User($db); $form=new Form($db); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index c437a9f2fdf..d26f4f8fdfc 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -85,7 +85,7 @@ class box_activity extends ModeleBoxes if ($result) { $num = $db->num_rows($result); - $now=gmmktime(); + $now=dol_now(); $i = 0; while ($i < $num) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 63a31c85483..42a6119c611 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -91,7 +91,7 @@ class Form if ($perm) { $tmp=explode(':',$typeofdata); - $ret.= '
'; + $ret.= '
'; $ret.= $langs->trans($text); $ret.= '
'."\n"; } @@ -267,7 +267,8 @@ class Form if (preg_match('/^(string|email|numeric)/',$inputType)) { $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; + $inputType=$tmp[0]; + if (! empty($tmp[1])) $inputOption=$tmp[1]; if (! empty($tmp[2])) $savemethod=$tmp[2]; } else if (preg_match('/^datepicker/',$inputType)) @@ -2237,8 +2238,8 @@ class Form { foreach ($formquestion as $key => $input) { - array_push($inputok,$input['name']); - if ($input['inputko'] == 1) array_push($inputko,$input['name']); + if (isset($input['name'])) array_push($inputok,$input['name']); + if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko,$input['name']); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 455758b6148..4503d8e9192 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -821,12 +821,12 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e // This part of code should not be used. dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' - $syear = $reg[1]; - $smonth = $reg[2]; - $sday = $reg[3]; - $shour = $reg[4]; - $smin = $reg[5]; - $ssec = $reg[6]; + $syear = (! empty($reg[1]) ? $reg[1] : ''); + $smonth = (! empty($reg[2]) ? $reg[2] : ''); + $sday = (! empty($reg[3]) ? $reg[3] : ''); + $shour = (! empty($reg[4]) ? $reg[4] : ''); + $smin = (! empty($reg[5]) ? $reg[5] : ''); + $ssec = (! empty($reg[6]) ? $reg[6] : ''); $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); @@ -966,7 +966,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) else $localtz = new DateTimeZone('UTC'); $dt = new DateTime(null,$localtz); $dt->setDate($year,$month,$day); - $dt->setTime($hour,$minute,$second); + $dt->setTime((int) $hour, (int) $minute, (int) $second); $date=$dt->getTimestamp(); } else @@ -3852,7 +3852,7 @@ function picto_from_langcode($codelang) */ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add') { - if (is_array($conf->tabs_modules[$type])) + if (isset($conf->tabs_modules[$type]) && is_array($conf->tabs_modules[$type])) { foreach ($conf->tabs_modules[$type] as $value) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e13c7dbdc64..d811a3edfd1 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -123,7 +123,7 @@ function product_prepare_head($object, $user) // More tabs from canvas - if (is_array($object->onglets)) + if (isset($object->onglets) && is_array($object->onglets)) { foreach ($object->onglets as $onglet) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b1047350a89..95cdb171a1d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -115,10 +115,14 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature if ($dbt_select != 'rowid') $objectid = "'".$objectid."'"; // More features to check - $features = explode("&",$features); + if (! empty($features)) { + $features = explode("&", $features); + } // More parameters - list($dbtablename, $sharedelement) = explode('&', $dbtablename); + if (! empty($dbtablename)) { + list($dbtablename, $sharedelement) = explode('&', $dbtablename); + } // Check read permission from module // TODO Replace "feature" param into caller by first level of permission diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6cdaa631da9..45f3bf03bdc 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -405,27 +405,29 @@ class FactureFournisseur extends Facture while ($i < $num_rows) { $obj = $this->db->fetch_object($resql_rows); - $this->lines[$i]->rowid = $obj->rowid; - $this->lines[$i]->description = $obj->description; - $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated - $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference - //$this->lines[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit - $this->lines[$i]->libelle = $obj->label; // Label du produit - $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit - $this->lines[$i]->pu_ht = $obj->pu_ht; - $this->lines[$i]->pu_ttc = $obj->pu_ttc; - $this->lines[$i]->tva_tx = $obj->tva_tx; - $this->lines[$i]->localtax1_tx = $obj->localtax1_tx; - $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; - $this->lines[$i]->qty = $obj->qty; - $this->lines[$i]->tva = $obj->tva; - $this->lines[$i]->total_ht = $obj->total_ht; - $this->lines[$i]->total_tva = $obj->total_tva; - $this->lines[$i]->total_localtax1 = $obj->total_localtax1; - $this->lines[$i]->total_localtax2 = $obj->total_localtax2; - $this->lines[$i]->total_ttc = $obj->total_ttc; - $this->lines[$i]->fk_product = $obj->fk_product; - $this->lines[$i]->product_type = $obj->product_type; + + $this->lines[$i] = (object) array(); + $this->lines[$i]->rowid = $obj->rowid; + $this->lines[$i]->description = $obj->description; + $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated + $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference + //$this->lines[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit + $this->lines[$i]->libelle = $obj->label; // Label du produit + $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit + $this->lines[$i]->pu_ht = $obj->pu_ht; + $this->lines[$i]->pu_ttc = $obj->pu_ttc; + $this->lines[$i]->tva_tx = $obj->tva_tx; + $this->lines[$i]->localtax1_tx = $obj->localtax1_tx; + $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; + $this->lines[$i]->qty = $obj->qty; + $this->lines[$i]->tva = $obj->tva; + $this->lines[$i]->total_ht = $obj->total_ht; + $this->lines[$i]->total_tva = $obj->total_tva; + $this->lines[$i]->total_localtax1 = $obj->total_localtax1; + $this->lines[$i]->total_localtax2 = $obj->total_localtax2; + $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->fk_product = $obj->fk_product; + $this->lines[$i]->product_type = $obj->product_type; $i++; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 31f22ef81b6..2936da5720d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -669,7 +669,7 @@ if (! defined('NOREQUIRETRAN')) } // Use php template engine -if ($conf->global->MAIN_USE_TEMPLATE_ENGINE && ! defined('NOTEMPLATEENGINE')) +if (! empty($conf->global->MAIN_USE_TEMPLATE_ENGINE) && ! defined('NOTEMPLATEENGINE')) { require_once(DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php'); @@ -893,14 +893,17 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; print ''."\n"; // CSS forced by modules (relative url starting with /) - $dircss=(array) $conf->modules_parts['css']; - foreach($dircss as $key => $cssfile) + if (isset($conf->modules_parts['css'])) { - // cssfile is a relative path - print ''."\n"; + $dircss=(array) $conf->modules_parts['css']; + foreach($dircss as $key => $cssfile) + { + // cssfile is a relative path + print ''."\n"; + } } // CSS forced by page in top_htmlhead call (relative url starting with /) if (is_array($arrayofcss)) @@ -1207,7 +1210,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print "\n".''."\n"; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '
'."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; print '
'."\n"; @@ -1241,7 +1244,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $loginhtmltext.='
'.$langs->trans("IPAddress").': '.$_SERVER["REMOTE_ADDR"]; $loginhtmltext.='
'; $loginhtmltext.='
'.$langs->trans("Connection").''; - if ($conf->global->MAIN_MODULE_MULTICOMPANY) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; $loginhtmltext.='
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; @@ -1253,7 +1256,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (! empty($_SESSION["disablemodules"])) $loginhtmltext.='
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); $appli='Dolibarr'; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; // Link info $logouttext=''; @@ -1281,7 +1284,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'; - if (! is_object($form)) $form=new Form($db); + $form=new Form($db); $toprightmenu.=$form->textwithtooltip('',$loginhtmltext,2,1,$logintext,'',1); @@ -1308,11 +1311,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'."\n"; print "\n"; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n"; print "\n"; - if (! $conf->use_javascript_ajax || ! $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ''; + if (empty($conf->use_javascript_ajax) || empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'; } @@ -1347,32 +1350,32 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me } $hookmanager->initHooks(array('searchform','leftblock')); - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'
'."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".'
'."\n"; else print '
'; print "\n"; @@ -1527,7 +1530,7 @@ function main_area($title='') { global $conf, $langs; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) { print '
'."\n"; print '
'; print "\n"; // Define $searchform - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname'); } - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); } - if ((($conf->product->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire)) - && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE) + if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) + && ! empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE)) { $langs->load("products"); $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/liste.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); } - if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) + if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_ADHERENT) && $user->rights->adherent->lire) { $langs->load("members"); $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall'); @@ -1504,7 +1507,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $leftblock=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $leftblock; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ' '."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; else print '
'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fe6fa3395a9..409a0f775b0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2423,6 +2423,7 @@ class Product extends CommonObject while ($i < $num) { $row = $this->db->fetch_object($result); + $this->stock_warehouse[$row->fk_entrepot] = (object) array(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp; $this->stock_reel+=$row->reel; diff --git a/htdocs/product/class/service.class.php b/htdocs/product/class/service.class.php index a2780e88b91..8d12267ea0b 100644 --- a/htdocs/product/class/service.class.php +++ b/htdocs/product/class/service.class.php @@ -66,7 +66,7 @@ class Service extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= " AND p.fk_product_type = 1"; $resql=$this->db->query($sql); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 11121edf567..03d6dad9356 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -668,7 +668,7 @@ $helpurl=''; if (GETPOST("type") == '0') $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; if (GETPOST("type") == '1') $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; -llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl); +llxHeader('',$langs->trans("CardProduct".GETPOST("type")),$helpurl); $form = new Form($db); $formproduct = new FormProduct($db); @@ -1047,7 +1047,7 @@ else dol_fiche_head($head, 'card', $titre, 0, $picto); $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); - $showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire; + $showbarcode=(! empty($conf->barcode->enabled) && $user->rights->barcode->lire); // En mode visu print '
'; @@ -1137,13 +1137,13 @@ else } // Accountancy sell code - print ''; // Accountancy buy code - print ''; // Status (to sell) @@ -1179,7 +1179,7 @@ else { $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); } - print $langs->trans($dur[$object->duration_unit])." "; + print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print ''; } @@ -1302,11 +1302,11 @@ if ($action == '' || $action == 'view') { if ($user->rights->produit->creer || $user->rights->service->creer) { - if ($object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; + if (isset($object->no_button_edit) && $object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; - if ($object->no_button_copy <> 1) + if (isset($object->no_button_copy) && $object->no_button_copy <> 1) { - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ''.$langs->trans('ToClone').''."\n"; print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); @@ -1322,9 +1322,9 @@ if ($action == '' || $action == 'view') if (($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer)) { - if (! $object_is_used && $object->no_button_delete <> 1) + if (! $object_is_used && isset($object->no_button_delete) && $object->no_button_delete <> 1) { - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ''.$langs->trans('Delete').''."\n"; print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); @@ -1357,7 +1357,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print '
'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer); + print '
'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').''; + print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print '
'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer); + print '
'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').''; + print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print '
'; // Propals - if($conf->propal->enabled && $user->rights->propale->creer) + if (! empty($conf->propal->enabled) && $user->rights->propale->creer) { $propal = new Propal($db); @@ -1413,7 +1413,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print ''; @@ -1474,7 +1474,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } // Commande - if($conf->commande->enabled && $user->rights->commande->creer) + if (! empty($conf->commande->enabled) && $user->rights->commande->creer) { $commande = new Commande($db); @@ -1530,7 +1530,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print ''; @@ -1592,7 +1592,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } // Factures - if ($conf->facture->enabled && $user->rights->facture->creer) + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { print ''; @@ -1743,6 +1743,6 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/index.php b/htdocs/product/index.php index bfd666fad2b..8703283e460 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 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 @@ -74,7 +74,7 @@ print ''; // MultiPrix -if ($conf->global->PRODUIT_MULTIPRICES) +if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - if ($socid) + if (! empty($socid)) { $soc = new Societe($db); $soc->id = $socid; @@ -272,8 +272,9 @@ print "
'; print ''.$langs->trans("ReductionShort"); print '%'; - print " ".$object->stock_proposition; + if (isset($object->stock_proposition)) print " ".$object->stock_proposition; print ''; print ''; print ''; print ''.$langs->trans("ReductionShort"); print '%'; - print " ".$object->stock_proposition; + if (isset($object->stock_proposition)) print " ".$object->stock_proposition; print ''; print ''; print '
'; print $langs->trans("AddToMyBills").'
'; * Zone recherche produit/service */ $rowspan=2; -if ($conf->barcode->enabled) $rowspan++; +if (! empty($conf->barcode->enabled)) $rowspan++; print ''; print ''; print ''; @@ -83,7 +83,7 @@ print ''; print "'; print ''; -if ($conf->barcode->enabled) +if (! empty($conf->barcode->enabled)) { print "'; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ab6a5a6840c..c69a15b2c50 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -552,19 +552,20 @@ class Task extends CommonObject if (! $error) { - $tasks[$i]->id = $obj->taskid; - $tasks[$i]->ref = $obj->taskid; - $tasks[$i]->fk_project = $obj->projectid; - $tasks[$i]->projectref = $obj->ref; - $tasks[$i]->projectlabel = $obj->plabel; - $tasks[$i]->label = $obj->label; - $tasks[$i]->description = $obj->description; - $tasks[$i]->fk_parent = $obj->fk_task_parent; - $tasks[$i]->duration = $obj->duration_effective; - $tasks[$i]->progress = $obj->progress; - $tasks[$i]->public = $obj->public; - $tasks[$i]->date_start = $this->db->jdate($obj->date_start); - $tasks[$i]->date_end = $this->db->jdate($obj->date_end); + $tasks[$i] = (object) array(); + $tasks[$i]->id = $obj->taskid; + $tasks[$i]->ref = $obj->taskid; + $tasks[$i]->fk_project = $obj->projectid; + $tasks[$i]->projectref = $obj->ref; + $tasks[$i]->projectlabel = $obj->plabel; + $tasks[$i]->label = $obj->label; + $tasks[$i]->description = $obj->description; + $tasks[$i]->fk_parent = $obj->fk_task_parent; + $tasks[$i]->duration = $obj->duration_effective; + $tasks[$i]->progress = $obj->progress; + $tasks[$i]->public = $obj->public; + $tasks[$i]->date_start = $this->db->jdate($obj->date_start); + $tasks[$i]->date_end = $this->db->jdate($obj->date_end); } $i++; diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index f1a0815b4c7..a8360e52968 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -86,7 +86,7 @@ class Address if ($result >= 0) { $now=dol_now(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) "; $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate($now).", '".$user->id."')"; @@ -188,7 +188,7 @@ class Address if ($result >= 0) { dol_syslog(get_class($this)."::Update verify ok"); - + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_address"; @@ -203,7 +203,7 @@ class Address $sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null"); if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; $sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $id ."'"; - + dol_syslog(get_class($this)."::Update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -216,7 +216,7 @@ class Address { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - + $this->error=$langs->trans("ErrorDuplicateField",$this->name); $result=-1; } @@ -302,7 +302,7 @@ class Address $line->phone = $objp->tel; $line->fax = $objp->fax; $line->note = $objp->note; - + // deprecated $line->cp = $line->zip; $line->ville = $line->town; @@ -381,14 +381,14 @@ class Address $this->phone = $obj->tel; $this->fax = $obj->fax; $this->note = $obj->note; - + // deprecated - $line->cp = $line->zip; - $line->ville = $line->town; - $line->pays_id = $line->country_id; - $line->pays_code = $line->country_code; - $line->pays = $line->country; - $line->tel = $line->phone; + $this->cp = $this->zip; + $this->ville = $this->town; + $this->pays_id = $this->country_id; + $this->pays_code = $this->country_code; + $this->pays = $this->country; + $this->tel = $this->phone; $result = 1; } @@ -435,7 +435,7 @@ class Address print $this->db->error() . '
' . $sql; } } - + /** * Return name of address with link (and eventually picto) * Use $this->id, $this->label, $this->socid @@ -447,12 +447,12 @@ class Address function getNomUrl($withpicto=0,$option='') { global $langs; - + $result=''; - + $lien = ''; $lienfin=''; - + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label,'address').$lienfin.' '); $result.=$lien.$this->label.$lienfin; return $result; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index d0ee57086e0..f3cad67cd4a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -578,8 +578,11 @@ class User extends CommonObject if ($perms) { + if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error + if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if ($subperms) { + if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); $this->rights->$module->$perms->$subperms = 1; } else diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 5903d7e35c3..91f3c895bca 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -470,8 +470,11 @@ class UserGroup extends CommonObject if ($perms) { + if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error + if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if ($subperms) { + if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); $this->rights->$module->$perms->$subperms = 1; } else diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 797a1950d86..606dda9c780 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -38,7 +38,7 @@ if ($user->id == $id) // A user can always read its own card { $feature2=''; } -$result = restrictedArea($user, $feature, $id, '&user', $feature2); +$result = restrictedArea($user, 'user', $id, '&user', $feature2); /* From 7fe53c4dcf62e43b3b709f4a8a5827c5cdd5cd89 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 8 Jul 2012 23:26:28 +0200 Subject: [PATCH 3/9] Fix: object already defined in constructor --- htdocs/comm/action/class/actioncomm.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 481845aec9e..1d9612271cf 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -294,25 +294,19 @@ class ActionComm extends CommonObject $this->note = $obj->note; $this->percentage = $obj->percentage; - $this->author = (object) array(); $this->author->id = $obj->fk_user_author; $this->author->firstname = $obj->firstname; $this->author->lastname = $obj->lastname; - $this->usermod = (object) array(); $this->usermod->id = $obj->fk_user_mod; - $this->usertodo = (object) array(); $this->usertodo->id = $obj->fk_user_action; - $this->userdone = (object) array(); $this->userdone->id = $obj->fk_user_done; $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->societe = (object) array(); $this->societe->id = $obj->fk_soc; - $this->contact = (object) array(); $this->contact->id = $obj->fk_contact; $this->fk_project = $obj->fk_project; From cd7bf41ae0dc7de278e2ed5e622881c97233418b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Jul 2012 10:08:56 +0200 Subject: [PATCH 4/9] Fix: php 5.4 strict mode warning --- htdocs/compta/bank/pre.inc.php | 2 +- .../deplacement/class/deplacement.class.php | 19 +++--- htdocs/compta/index.php | 6 +- htdocs/core/class/commonobject.class.php | 7 +- htdocs/core/lib/files.lib.php | 3 + htdocs/core/menus/standard/eldy.lib.php | 66 +++++++++---------- htdocs/filefunc.inc.php | 4 +- 7 files changed, 59 insertions(+), 48 deletions(-) diff --git a/htdocs/compta/bank/pre.inc.php b/htdocs/compta/bank/pre.inc.php index 166d3c142e8..9fcd7646e8b 100644 --- a/htdocs/compta/bank/pre.inc.php +++ b/htdocs/compta/bank/pre.inc.php @@ -74,7 +74,7 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 { $objp = $db->fetch_object($resql); $menu->add('/compta/bank/fiche.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); - if ($objp->rappro && $objp->courant != 2 && ! $objp->clos) // If not cash account and not closed and can be reconciliate + if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { $menu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 8b24f22f2cd..f6639252735 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -52,6 +52,9 @@ class Deplacement extends CommonObject var $fk_project; var $extraparams=array(); + var $statuts=array(); + var $statuts_short=array(); + /** * Constructor * @@ -231,7 +234,7 @@ class Deplacement extends CommonObject $this->note_private = $obj->note; $this->note_public = $obj->note_public; $this->fk_project = $obj->fk_projet; - + $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; @@ -308,19 +311,19 @@ class Deplacement extends CommonObject } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); - if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); + if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); + if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); } if ($mode == 4) { - //if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); + //if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); + if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); + if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); } if ($mode == 5) { - if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); - if ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); + if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); + if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); } } diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 6bcef4cd7c7..41fa2b33be0 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -563,13 +563,13 @@ if ($conf->don->enabled && $user->rights->societe->lire) // Last trips and expenses -if ($conf->deplacement->enabled && $user->rights->deplacement->lire) +if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) { include_once(DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'); $langs->load("boxes"); - $sql = "SELECT u.rowid as uid, u.name, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km"; + $sql = "SELECT u.rowid as uid, u.name, u.firstname, d.fk_statut, d.rowid, d.dated as date, d.tms as dm, d.km"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user"; @@ -923,7 +923,7 @@ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) { $facstatic=new FactureFournisseur($db); - $sql = "SELECT ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc,"; + $sql = "SELECT ff.rowid, ff.facnumber, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc, ff.paye,"; $sql.= " s.nom, s.rowid as socid,"; $sql.= " sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 53a1964406a..aa0c71dbd45 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -36,6 +36,11 @@ abstract class CommonObject public $errors; public $canvas; // Contains canvas name if it is + public $lastname; + public $firstname; + public $name; + public $nom; + public $civility_id; // No constructor as it is an abstract class @@ -66,7 +71,7 @@ abstract class CommonObject } // If order not defined, we use the setup - if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION); + if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)); if ($nameorder) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 06234ddb42c..8c70885adae 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -64,7 +64,10 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil if ($dir = opendir($newpath)) { + $filedate=''; + $filesize=''; $file_list = array(); + while (false !== ($file = readdir($dir))) { if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in utf8 in memory diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f4f30fe415b..7a815d95af4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -897,7 +897,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $langs->load("companies"); // Customers invoices - if ($conf->facture->enabled) + if (! empty($conf->facture->enabled)) { $langs->load("bills"); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); @@ -911,7 +911,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),1,$user->rights->facture->lire); - if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) + if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { $newmenu->add("/compta/paiement/avalider.php?leftmenu=customers_bills_payments",$langs->trans("MenuToValid"),2,$user->rights->facture->lire); } @@ -921,13 +921,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Suppliers - if ($conf->societe->enabled && $conf->fournisseur->enabled) + if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) { - if ($conf->facture->enabled) + if (! empty($conf->facture->enabled)) { $langs->load("bills"); $newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); - if ($user->societe_id == 0) + if (isset($user->societe_id) && $user->societe_id == 0) { $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); } @@ -939,17 +939,17 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Orders - if ($conf->commande->enabled) + if (! empty($conf->commande->enabled)) { $langs->load("orders"); - if ($conf->facture->enabled) $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=3", $langs->trans("MenuOrdersToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); + if (! empty($conf->facture->enabled)) $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=3", $langs->trans("MenuOrdersToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); // if ($leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); - if ($conf->global->MAIN_FEATURES_LEVEL > 1) + if (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 1) if ($leftmenu=="orders") $newmenu->add("/commande/customer.php", $langs->trans("GenerateBill"), 1, $user->rights->commande->lire); } // Donations - if ($conf->don->enabled) + if (! empty($conf->don->enabled)) { $langs->load("donations"); $newmenu->add("/compta/dons/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations'); @@ -959,7 +959,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Trips and expenses - if ($conf->deplacement->enabled) + if (! empty($conf->deplacement->enabled)) { $langs->load("trips"); $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=accountancy", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses'); @@ -969,7 +969,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Taxes and social contributions - if ($conf->tax->enabled) + if (! empty($conf->tax->enabled)) { $newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy",$langs->trans("MenuTaxAndDividends"), 0, $user->rights->tax->charges->lire, '', $mainmenu, 'tax'); if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire); @@ -986,7 +986,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) global $mysoc; //Local Taxes - if($mysoc->country_code=='ES' && $mysoc->localtax2_assuj=="1") + if($mysoc->country_code=='ES' && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj=="1")) { if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&mainmenu=accountancy",$langs->transcountry("LT2",$mysoc->country_code),1,$user->rights->tax->charges->lire); if (preg_match('/^tax/i',$leftmenu)) $newmenu->add("/compta/localtax/fiche.php?leftmenu=tax_vat&action=create",$langs->trans("NewPayment"),2,$user->rights->tax->charges->creer); @@ -1000,7 +1000,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Compta simple - if ($conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION) + if (! empty($conf->comptabilite->enabled) && ! empty($conf->global->FACTURE_VENTILATION)) { $newmenu->add("/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Dispatch"),0,$user->rights->compta->ventilation->lire, '', $mainmenu, 'ventil'); if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/liste.php",$langs->trans("ToDispatch"),1,$user->rights->compta->ventilation->lire); @@ -1014,13 +1014,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Compta expert - if ($conf->accounting->enabled) + if (! empty($conf->accounting->enabled)) { } // Rapports - if ($conf->comptabilite->enabled || $conf->accounting->enabled) + if (! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled)) { $langs->load("compta"); @@ -1064,7 +1064,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $langs->load("bills"); // Bank-Caisse - if ($conf->banque->enabled) + if (! empty($conf->banque->enabled)) { $newmenu->add("/compta/bank/index.php?leftmenu=bank&mainmenu=bank",$langs->trans("MenuBankCash"),0,$user->rights->banque->lire, '', $mainmenu, 'bank'); @@ -1078,7 +1078,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Prelevements - if ($conf->prelevement->enabled) + if (! empty($conf->prelevement->enabled)) { $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank",$langs->trans("StandingOrders"),0,$user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); @@ -1096,7 +1096,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Gestion cheques - if ($conf->facture->enabled && $conf->banque->enabled) + if (! empty($conf->facture->enabled) && ! empty($conf->banque->enabled)) { $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank",$langs->trans("MenuChequeDeposits"),0,$user->rights->banque->cheque, '', $mainmenu, 'checks'); $newmenu->add("/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new&mainmenu=bank",$langs->trans("NewChequeDeposit"),1,$user->rights->banque->cheque); @@ -1111,7 +1111,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) if ($mainmenu == 'products') { // Products - if ($conf->product->enabled) + if (! empty($conf->product->enabled)) { $newmenu->add("/product/index.php?leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product'); if ($user->societe_id == 0) @@ -1130,7 +1130,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Services - if ($conf->service->enabled) + if (! empty($conf->service->enabled)) { $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service'); if ($user->societe_id == 0) @@ -1145,7 +1145,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Categories - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); @@ -1157,7 +1157,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Stocks - if ($conf->stock->enabled) + if (! empty($conf->stock->enabled)) { $langs->load("stocks"); $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Stocks"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); @@ -1168,7 +1168,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // Expeditions - if ($conf->expedition->enabled) + if (! empty($conf->expedition->enabled)) { $langs->load("sendings"); $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings'); @@ -1187,7 +1187,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) { $langs->load("suppliers"); - if ($conf->societe->enabled && $conf->fournisseur->enabled) + if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) { $newmenu->add("/fourn/index.php?leftmenu=suppliers", $langs->trans("Suppliers"), 0, $user->rights->societe->lire && $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers'); @@ -1201,12 +1201,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/fourn/stats.php",$langs->trans("Statistics"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire); } - if ($conf->facture->enabled) + if (! empty($conf->facture->enabled)) { $langs->load("bills"); $newmenu->add("/fourn/facture/index.php?leftmenu=orders", $langs->trans("Bills"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'orders'); - if ($user->societe_id == 0) + if (isset($user->societe_id) && $user->societe_id == 0) { $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer); } @@ -1214,7 +1214,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire); } - if ($conf->fournisseur->enabled) + if (! empty($conf->fournisseur->enabled)) { $langs->load("orders"); $newmenu->add("/fourn/commande/index.php?leftmenu=suppliers",$langs->trans("Orders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'suppliers'); @@ -1222,11 +1222,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/fourn/commande/liste.php?leftmenu=suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire); } - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=1", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); - if ($user->societe_id == 0) + if (isset($user->societe_id) && $user->societe_id == 0) { $newmenu->add("/categories/fiche.php?action=create&type=1", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); } @@ -1240,7 +1240,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) */ if ($mainmenu == 'project') { - if ($conf->projet->enabled) + if (! empty($conf->projet->enabled)) { $langs->load("projects"); @@ -1305,7 +1305,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) */ if ($mainmenu == 'members') { - if ($conf->adherent->enabled) + if (! empty($conf->adherent->enabled)) { $langs->load("members"); $langs->load("compta"); @@ -1326,11 +1326,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/adherents/stats/index.php?leftmenu=members",$langs->trans("MenuMembersStats"),1,$user->rights->adherent->lire); - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=3", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); - if ($user->societe_id == 0) + if (isset($user->societe_id) && $user->societe_id == 0) { $newmenu->add("/categories/fiche.php?action=create&type=3", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); } diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 2256aaea066..fe1aa8282b9 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -54,8 +54,8 @@ if (! defined('LOG_DEBUG')) } // Force PHP error_reporting setup (Dolibarr may report warning without this) -error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); -//error_reporting(E_ALL | E_STRICT); +//error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); +error_reporting(E_ALL | E_STRICT); // End of common declaration part if (defined('DOL_INC_FOR_VERSION_ERROR')) return; From 1842fd30586880488621074a01f9d5edf049f002 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Jul 2012 10:10:21 +0200 Subject: [PATCH 5/9] Fix: restore parameters --- htdocs/filefunc.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index fe1aa8282b9..2256aaea066 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -54,8 +54,8 @@ if (! defined('LOG_DEBUG')) } // Force PHP error_reporting setup (Dolibarr may report warning without this) -//error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); -error_reporting(E_ALL | E_STRICT); +error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); +//error_reporting(E_ALL | E_STRICT); // End of common declaration part if (defined('DOL_INC_FOR_VERSION_ERROR')) return; From 1f98c2cfc4f58e6adf02ac05f2ba19677a5141b1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Jul 2012 10:24:33 +0200 Subject: [PATCH 6/9] Fix: add possibility to use strict mode for debugging --- htdocs/filefunc.inc.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 2256aaea066..ffa61de2c9c 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -53,10 +53,6 @@ if (! defined('LOG_DEBUG')) } } -// Force PHP error_reporting setup (Dolibarr may report warning without this) -error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); -//error_reporting(E_ALL | E_STRICT); - // End of common declaration part if (defined('DOL_INC_FOR_VERSION_ERROR')) return; @@ -78,6 +74,17 @@ if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not do header("Location: install/index.php"); exit; } + +// Force PHP error_reporting setup (Dolibarr may report warning without this) +if (! empty($dolibarr_strict_mode)) +{ + error_reporting(E_ALL | E_STRICT); +} +else +{ + error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); +} + // Disable php display errors if (! empty($dolibarr_main_prod)) ini_set('display_errors','Off'); From 66b2f630ac6549639a19ebcbd85a8b68601942e3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Jul 2012 12:31:21 +0200 Subject: [PATCH 7/9] Fix: big avoid strict mode errors --- htdocs/categories/categorie.php | 6 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/index.php | 12 +- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/dolgraph.class.php | 4 +- htdocs/core/lib/agenda.lib.php | 16 +-- htdocs/core/lib/security.lib.php | 10 +- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/main.inc.php | 4 + htdocs/product/class/product.class.php | 24 ++-- htdocs/product/composition/fiche.php | 28 +++-- htdocs/product/document.php | 9 +- htdocs/product/fournisseurs.php | 2 +- htdocs/product/photos.php | 48 ++++---- htdocs/product/price.php | 11 +- htdocs/product/stats/facture.php | 4 +- htdocs/product/stats/fiche.php | 4 +- htdocs/product/traduction.php | 107 ++++++++++-------- htdocs/societe/index.php | 17 ++- htdocs/theme/eldy/style.css.php | 4 +- htdocs/user/class/user.class.php | 12 +- htdocs/user/class/usergroup.class.php | 6 +- 22 files changed, 179 insertions(+), 155 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 4a7ceaf36c3..75082eaf140 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -58,20 +58,20 @@ if ($id || $ref) $dbtablename = 'product'; $fieldid = isset($ref)?'ref':'rowid'; } - if ($type == 1) { + elseif ($type == 1) { $elementtype = 'fournisseur'; $objecttype = 'societe&categorie'; $objectid = isset($id)?$id:(isset($socid)?$socid:''); $fieldid = 'rowid'; } - if ($type == 2) { + elseif ($type == 2) { $elementtype = 'societe'; $objecttype = 'societe&categorie'; $objectid = isset($id)?$id:(isset($socid)?$socid:''); $dbtablename = '&societe'; $fieldid = 'rowid'; } - if ($type == 3) { + elseif ($type == 3) { $elementtype = 'member'; $objecttype = 'adherent&categorie'; $objectid = isset($id)?$id:(isset($ref)?$ref:''); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index fccc9c68ce2..c0f92cc9288 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -776,7 +776,7 @@ class Categorie // Process all childs on several levels of this category $protection++; 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) { // Protection when a category has itself as a child (should not happen) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 9c587c2df69..b1913cef72b 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -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->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); -if (!$user->rights->societe->lire) -accessforbidden(); +if (! $user->rights->societe->lire) accessforbidden(); $langs->load("commercial"); // Securite acces client -$socid=''; -if ($_GET["socid"]) { $socid=$_GET["socid"]; } -if ($user->societe_id > 0) +$socid=GETPOST('socid','int'); +if (isset($user->societe_id) && $user->societe_id > 0) { $action = ''; $socid = $user->societe_id; @@ -180,7 +178,7 @@ if ($conf->propal->enabled && $user->rights->propal->lire) print ''; print ''; $i++; - $total += $obj->price; + $total += $obj->total_ht; } if ($total>0) { @@ -282,7 +280,7 @@ if ($conf->societe->enabled && $user->rights->societe->lire) { $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"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 2, 3)"; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 2428c57a531..2841baa79f0 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -189,7 +189,7 @@ class Conf { $modulename=strtolower($reg[1]); 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->modules[]=$modulename; // Add this module in list of enabled modules } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 91b9e8ec78b..68571f50066 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -88,7 +88,7 @@ class DolGraph global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; // 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'; @@ -850,7 +850,7 @@ class DolGraph $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] == '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++; } $this->_stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n"; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 9b2ece03540..c12074faea7 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -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.'/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.= " s.nom as sname, s.rowid, s.client"; $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c,"; @@ -226,13 +226,13 @@ function show_array_actions_to_do($max=5) print ''; + { + $customerstatic->id=$obj->rowid; + $customerstatic->name=$obj->sname; + $customerstatic->client=$obj->client; + print $customerstatic->getNomUrl(1,'',16); + } + print ''; $datep=$db->jdate($obj->dp); $datep2=$db->jdate($obj->dp2); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 95cdb171a1d..f3b4c9a052b 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -115,14 +115,12 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature if ($dbt_select != 'rowid') $objectid = "'".$objectid."'"; // More features to check - if (! empty($features)) { - $features = explode("&", $features); - } + $features = explode("&", $features); // More parameters - if (! empty($dbtablename)) { - list($dbtablename, $sharedelement) = explode('&', $dbtablename); - } + $params = explode('&', $dbtablename); + $dbtablename=(! empty($params[0]) ? $params[0] : ''); + $sharedelement=(! empty($params[1]) ? $params[1] : ''); // Check read permission from module // TODO Replace "feature" param into caller by first level of permission diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index c00ec226cb6..4fbb595c6f8 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -293,7 +293,7 @@ class ProductFournisseur extends Product global $conf; $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.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2936da5720d..5ae9909408b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1569,6 +1569,10 @@ function main_area($title='') */ function getHelpParamFor($helppagename,$langs) { + $helpbaseurl=''; + $helppage=''; + $mode=''; + if (preg_match('/^http/i',$helppagename)) { // If complete URL diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 409a0f775b0..196cfcfc264 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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($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; $img=""; - $this->fetch($desc_pere[0]); + $this->fetch($id); $this->load_stock(); if ($this->stock_warehouse[1]->real < $this->seuil_stock_alerte) { @@ -2007,13 +2011,13 @@ class Product extends CommonObject (".$desc_pere[1].")", $desc_pere[0], // Id product -*/ 'id'=>$desc_pere[0], // Id product - 'nb'=>$desc_pere[1], // Nb of units that compose parent product - 'nb_total'=>$desc_pere[1]*$multiply, // Nb of units for all nb of product +*/ 'id'=>$id, // Id product + 'nb'=>$nb, // Nb of units that compose parent product + 'nb_total'=>$nb*$multiply, // Nb of units for all nb of product 'stock'=>$this->stock_warehouse[1]->real, // Stock 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert '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 @@ -2023,13 +2027,13 @@ class Product extends CommonObject $this->res[]= array( /* $compl_path.$nom_pere." (".$desc_pere[1].")", $desc_pere[0], // Id product -*/ 'id'=>$desc_pere[0], // Id product - 'nb'=>$desc_pere[1], // Nb of units that compose parent product - 'nb_total'=>$desc_pere[1], // Nb of units for all nb of product +*/ 'id'=>$id, // Id product + 'nb'=>$nb, // Nb of units that compose parent product + 'nb_total'=>$nb, // Nb of units for all nb of product 'stock'=>$this->stock_warehouse[1]->real, // Stock 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert '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 ); } } diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php index 650c99a6fcb..3b24ca48227 100644 --- a/htdocs/product/composition/fiche.php +++ b/htdocs/product/composition/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2011 Juanjo Menent * @@ -35,24 +35,22 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); $langs->load("bills"); $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 -if (isset($_GET["id"]) || isset($_GET["ref"])) -{ - $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); -} -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); +if (! empty($user->societe_id)) $socid=$user->societe_id; +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); +$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); $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); $productid=0; if ($id || $ref) diff --git a/htdocs/product/document.php b/htdocs/product/document.php index a3547f6bedc..4e63ec969bd 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -44,7 +44,7 @@ $confirm=GETPOST('confirm','alpha'); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); 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 $sortfield = GETPOST("sortfield",'alpha'); @@ -72,7 +72,7 @@ $modulepart='produit'; * 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) { @@ -121,9 +121,8 @@ llxHeader("","",$langs->trans("CardProduct".$object->type)); if ($object->id) { - if ( $error_msg ) - { - echo '
'.$error_msg.'

'; + if (! empty($mesg)) { + dol_htmloutput_mesg($mesg); } if ($action=='delete') diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 0194d896f82..27a27cb98c1 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -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 = ''; Header("Location: fournisseurs.php?id=".$_GET["id"]); diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index eeaebbc448e..20cacf3045d 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -57,7 +57,7 @@ if ($id > 0 || ! empty($ref)) * 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']); } @@ -82,7 +82,7 @@ $form = new Form($db); if ($object->id) { llxHeader("","",$langs->trans("CardProduct".$object->type)); - + /* * En mode visu */ @@ -90,56 +90,56 @@ if ($object->id) $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==1?'service':'product'); dol_fiche_head($head, 'photos', $titre, 0, $picto); - + /* * 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); if ($ret == 'html') print '
'; } - + print($mesg); - + print '
'.$langs->trans("Search").'
"; print $langs->trans("Ref").':
"; print $langs->trans("BarCode").':'.price($obj->total_ht).'
'; if ($obj->rowid > 0) - { - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; - print $customerstatic->getNomUrl(1,'',16); - } - print ' ".($desc_pere[1]*$multiply)."   ".$this->stock_entrepot[1]." ".$img."
'; - + // Reference print ''; print ''; print ''; - + // Libelle print ''; print ''; - + // Status (to sell) print ''; - + // Status (to buy) print ''; - + print "
'.$langs->trans("Ref").''; print $form->showrefnav($object,'ref','',1,'ref'); print '
'.$langs->trans("Label").''.$object->libelle.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; print $object->getLibStatut(2,0); print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; print $object->getLibStatut(2,1); print '
\n"; - + print "\n"; - - - + + + /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ - + print "\n
\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)) { @@ -152,9 +152,9 @@ if ($object->id) print $langs->trans("AddPhoto").''; } } - + print "\n
\n"; - + /* * Add a photo */ @@ -164,18 +164,18 @@ if ($object->id) $formfile=new FormFile($db); $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans("AddPhoto"),1); } - + // Affiche photos if ($action != 'ajout_photo') { $nbphoto=0; $nbbyrow=5; - + $maxWidth = 160; $maxHeight = 120; - + print $object->show_photos($dir,1,1000,$nbbyrow,1,1); - + if ($object->nbphoto < 1) { print '
'; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index c6045df5920..8bfaae435e6 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -144,9 +144,9 @@ if ($isphoto) print '
\n"; print "\n"; - -dol_htmloutput_mesg($mesg); +if (! empty($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.= " WHERE fk_product = ".$object->id; $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 .= $db->plimit(); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 55fcf93dd04..c3d698a20fb 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -35,10 +35,12 @@ $langs->load("products"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); +$socid=''; +if (! empty($user->societe_id)) $socid=$user->societe_id; + // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); $mesg = ''; diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php index 24b1444ddcc..b65c5df965c 100644 --- a/htdocs/product/stats/fiche.php +++ b/htdocs/product/stats/fiche.php @@ -40,10 +40,12 @@ $mode = (GETPOST('mode') ? GETPOST('mode') : 'byunit'); $error = 0; $mesg = ''; +$socid=''; +if (! empty($user->societe_id)) $socid=$user->societe_id; + // Security check $fieldvalue = (! empty($id) ? $id : $ref); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index d1e2608e1c7..eea25aceee9 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -35,6 +35,8 @@ $langs->load("languages"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); +$action=GETPOST('action','alpha'); +$cancel=GETPOST('cancel','alpha'); // Security check $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 -if ($_POST["cancel"] == $langs->trans("Cancel")) +if ($cancel == $langs->trans("Cancel")) { - $_GET["action"] = ''; + $action = ''; } // Validation de l'ajout -if ($_POST["action"] == 'vadd' && -$_POST["cancel"] != $langs->trans("Cancel") && +if ($action == 'vadd' && +$cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); - $product->fetch($_POST["id"]); + $product->fetch($id); $current_lang = $langs->getDefaultLang(); // update de l'objet @@ -79,22 +81,22 @@ $_POST["cancel"] != $langs->trans("Cancel") && // sauvegarde en base if ( $product->setMultiLangs() > 0 ) { - $_GET["action"] = ''; + $action = ''; } else { - $_GET["action"] = 'add'; - $mesg = $product->mesg_error; + $action = 'add'; + $mesg = '
'.$product->error.'
'; } } // Validation de l'edition -if ($_POST["action"] == 'vedit' && -$_POST["cancel"] != $langs->trans("Cancel") && +if ($action == 'vedit' && +$cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); - $product->fetch($_POST["id"]); + $product->fetch($id); $current_lang = $langs->getDefaultLang(); 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 ) { - $_GET["action"] = ''; + $action = ''; } else { - $_GET["action"] = 'edit'; - $mesg = $product->mesg_error; + $action = 'edit'; + $mesg = '
'.$product->error.'
'; } } $product = new Product($db); -if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); -if ($_GET["id"]) $result = $product->fetch($_GET["id"]); +$result = $product->fetch($id,$ref); /* @@ -143,7 +144,9 @@ $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'translation', $titre, 0, $picto); -if ($mesg) print '
'.$mesg.'
'; +if (! empty($mesg)) { + dol_htmloutput_mesg($mesg); +} print ''; @@ -155,30 +158,33 @@ print ''; print ''; print '
'; -if ($_GET["action"] == 'edit') +if ($action == 'edit') { print ''; print ''; print ''; - print ''; + print ''; - foreach ( $product->multilangs as $key => $value) + if (! empty($product->multilangs)) { - print "
".$langs->trans('Language_'.$key)." :
"; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80); - $doleditor->Create(); - print '
'.$langs->trans('Note').''; - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80); - $doleditor->Create(); - print '
'; + foreach ($product->multilangs as $key => $value) + { + print "
".$langs->trans('Language_'.$key)." :
"; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80); + $doleditor->Create(); + print '
'.$langs->trans('Note').''; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],'',160,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80); + $doleditor->Create(); + print '
'; + } } print '
'; @@ -191,18 +197,21 @@ if ($_GET["action"] == 'edit') else { $cnt_trans = 0; - foreach ( $product->multilangs as $key => $value) + if (! empty($product->multilangs)) { - $cnt_trans++; - $s=picto_from_langcode($key); - print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).":
"; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('Label').''.$product->multilangs[$key]["libelle"].'
'.$langs->trans('Description').''.$product->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$product->multilangs[$key]["note"].'
'; + foreach ($product->multilangs as $key => $value) + { + $cnt_trans++; + $s=picto_from_langcode($key); + print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).":
"; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Label').''.$product->multilangs[$key]["libelle"].'
'.$langs->trans('Description').''.$product->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$product->multilangs[$key]["note"].'
'; + } } - if (!$cnt_trans ) print '
'. $langs->trans('NoTranslation'); + if (! $cnt_trans) print '
'. $langs->trans('NoTranslation'); } print "\n"; @@ -216,7 +225,7 @@ print "\n"; print "\n
\n"; -if ($_GET["action"] == '') +if ($action == '') if ($user->rights->produit->creer || $user->rights->service->creer) { print ''.$langs->trans("Add").''; @@ -230,7 +239,7 @@ print "\n
\n"; * 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 '
'; print ''; @@ -264,5 +273,7 @@ if ($_GET["action"] == 'add' && ($user->rights->produit->creer || $user->rights- print '
'; } + llxFooter(); -?> +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index dd0e7717164..c1c7d6c205e 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -75,7 +75,12 @@ print "

"; /* * Statistics area */ -$third = array(); +$third = array( + 'customer' => 0, + 'prospect' => 0, + 'supplier' => 0, + 'other' =>0 +); $total=0; $sql = "SELECT s.rowid, s.client, s.fournisseur"; @@ -92,10 +97,10 @@ if ($result) while ($objp = $db->fetch_object($result)) { $found=0; - if ($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 ($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) && 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_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; } + if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } + if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } if ($found) $total++; } } @@ -103,7 +108,7 @@ else dol_print_error($db); print ''; print ''; -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 ''; // Barcode - if ($conf->barcode->enabled) + if (! empty($conf->barcode->enabled)) { $var=!$var; print ''; @@ -715,7 +717,7 @@ else print ''; $var=!$var; - print ''; + print ''; print '
'.$langs->trans("Statistics").'
'; $dataseries=array(); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b2b4941a695..326da714425 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -143,7 +143,9 @@ $fontsizesmaller =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty( // Set text color to black or white $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; if ($tmpval < 340) $colortextmain='FFFFFF'; else $colortextmain='101010'; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f3cad67cd4a..fe6650d4203 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -531,11 +531,11 @@ class User extends CommonObject if ($perms) { - if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error - if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); + if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error + if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array(); 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; } else @@ -578,11 +578,11 @@ class User extends CommonObject if ($perms) { - if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error - if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); + if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error + if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array(); 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; } else diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 91f3c895bca..48b388bd971 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -470,11 +470,11 @@ class UserGroup extends CommonObject if ($perms) { - if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error - if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); + if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error + if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array(); 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; } else From 7fac86a5af2f1d745d7291b676a1a1402e78b003 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Jul 2012 12:54:27 +0200 Subject: [PATCH 8/9] Fix: avoid warnings --- htdocs/admin/company.php | 38 ++++++++++++++++++++++++++------------ htdocs/admin/modules.php | 4 ++-- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 1cb0eb49773..a1f3d8773b7 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -39,7 +39,9 @@ $action=GETPOST('action'); $langs->load("admin"); $langs->load("companies"); -if (!$user->admin) accessforbidden(); +if (! $user->admin) accessforbidden(); + +$message=''; /* @@ -683,7 +685,7 @@ else print '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '
'.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
'.$langs->trans("Note").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '
'.$langs->trans("Note").'' . (! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '
'; @@ -746,10 +748,12 @@ else { $var=!$var; print ''.$langs->transcountry("ProfId1",$mysoc->country_code).''; - if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-') + if (! empty($conf->global->MAIN_INFO_SIREN)) { print $conf->global->MAIN_INFO_SIREN; - if ($conf->global->MAIN_INFO_SIREN && $mysoc->country_code == 'FR') print '   '.$langs->trans("Check").''; + if ($mysoc->country_code == 'FR') print '   '.$langs->trans("Check").''; + } else { + print ' '; } print ''; } @@ -759,9 +763,11 @@ else { $var=!$var; print ''.$langs->transcountry("ProfId2",$mysoc->country_code).''; - if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-') + if (! empty($conf->global->MAIN_INFO_SIRET)) { print $conf->global->MAIN_INFO_SIRET; + } else { + print ' '; } print ''; } @@ -771,9 +777,11 @@ else { $var=!$var; print ''.$langs->transcountry("ProfId3",$mysoc->country_code).''; - if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-') + if (! empty($conf->global->MAIN_INFO_APE)) { print $conf->global->MAIN_INFO_APE; + } else { + print ' '; } print ''; } @@ -783,9 +791,11 @@ else { $var=!$var; print ''.$langs->transcountry("ProfId4",$mysoc->country_code).''; - if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-') + if (! empty($conf->global->MAIN_INFO_RCS)) { print $conf->global->MAIN_INFO_RCS; + } else { + print ' '; } print ''; } @@ -795,9 +805,11 @@ else { $var=!$var; print ''.$langs->transcountry("ProfId5",$mysoc->country_code).''; - if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-') + if (! empty($conf->global->MAIN_INFO_PROFID5)) { print $conf->global->MAIN_INFO_PROFID5; + } else { + print ' '; } print ''; } @@ -807,9 +819,11 @@ else { $var=!$var; print ''.$langs->transcountry("ProfId6",$mysoc->country_code).''; - if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-') + if (! empty($conf->global->MAIN_INFO_PROFID6)) { print $conf->global->MAIN_INFO_PROFID6; + } else { + print ' '; } print ''; } @@ -818,7 +832,7 @@ else $var=!$var; print ''.$langs->trans("VATIntra").''; print ''; - if ($conf->global->MAIN_INFO_TVAINTRA) + if (! empty($conf->global->MAIN_INFO_TVAINTRA)) { $s=''; $s.=$conf->global->MAIN_INFO_TVAINTRA; @@ -826,7 +840,7 @@ else if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.='   '; - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print "\n"; print '