diff --git a/dev/iso-normes/address_format.txt b/dev/iso-normes/address_format.txt new file mode 100755 index 00000000000..cc3b23285c8 --- /dev/null +++ b/dev/iso-normes/address_format.txt @@ -0,0 +1 @@ +http://bitboost.com/ref/international-address-formats.html#Formats \ No newline at end of file diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index b7a69dddd26..a2b4ae4d909 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -30,10 +30,16 @@ $langs->load("admin"); if (! $user->admin) accessforbidden(); -$action = GETPOST('action'); -$debug = GETPOST('debug'); +$rowid=GETPOST('rowid','int'); +$entity=GETPOST('entity','int'); +$action=GETPOST('action'); +$update=GETPOST('update'); +$delete=GETPOST('delete'); +$debug=GETPOST('debug'); +$consts=GETPOST('const'); $typeconst=array('yesno','texte','chaine'); +$mesg=''; /* @@ -64,11 +70,11 @@ if ($action == 'add') } } -if (($_POST["const"] && isset($_POST["update"]) && $_POST["update"] == $langs->trans("Modify"))) +if (! empty($consts) && $update == $langs->trans("Modify")) { - foreach($_POST["const"] as $const) + foreach($consts as $const) { - if ($const["check"]) + if (! empty($const["check"])) { if (dolibarr_set_const($db, $const["name"],$const["value"],$const["type"],1,$const["note"],$const["entity"]) < 0) { @@ -79,11 +85,11 @@ if (($_POST["const"] && isset($_POST["update"]) && $_POST["update"] == $langs->t } // Delete several lines at once -if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("Delete")) +if (! empty($consts) && $delete == $langs->trans("Delete")) { - foreach($_POST["const"] as $const) + foreach($consts as $const) { - if ($const["check"]) // Is checkbox checked + if (! empty($const["check"])) // Is checkbox checked { if (dolibarr_del_const($db, $const["rowid"], -1) < 0) { @@ -96,7 +102,7 @@ if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("De // Delete line from delete picto if ($action == 'delete') { - if (dolibarr_del_const($db, $_GET["rowid"], $_GET["entity"]) < 0) + if (dolibarr_del_const($db, $rowid, $entity) < 0) { dol_print_error($db); } @@ -136,7 +142,7 @@ print_fiche_titre($langs->trans("OtherSetup"),'','setup'); print $langs->trans("ConstDesc")."
\n"; print "
\n"; -if ($mesg) print $mesg; +dol_htmloutput_mesg($mesg); print ''; print ''; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 1150949c7c6..0acfed506b2 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Simon Tosser - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,31 +27,93 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); $langs->load("admin"); -$langs->load("orders"); -$langs->load("propal"); -$langs->load("contracts"); -$langs->load("bills"); -$langs->load("banks"); if (! $user->admin) accessforbidden(); $action=GETPOST('action','alpha'); +$modules=array( + 'agenda' => array( + array( + 'code' => 'MAIN_DELAY_ACTIONS_TODO', + 'img' => 'action' + ) + ), + 'propal' => array( + array( + 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE', + 'img' => 'propal' + ), + array( + 'code' => 'MAIN_DELAY_PROPALS_TO_BILL', + 'img' => 'propal' + ) + ), + 'commande' => array( + array( + 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS', + 'img' => 'order' + ) + ), + 'facture' => array( + array( + 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED', + 'img' => 'bill' + ) + ), + 'fournisseur' => array( + array( + 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS', + 'img' => 'order' + ), + array( + 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY', + 'img' => 'bill' + ) + ), + 'service' => array( + array( + 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES', + 'img' => 'service' + ), + array( + 'code' => 'MAIN_DELAY_RUNNING_SERVICES', + 'img' => 'service' + ) + ), + 'banque' => array( + array( + 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE', + 'img' => 'account' + ), + array( + 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT', + 'img' => 'account' + ) + ), + 'adherent' => array( + array( + 'code' => 'MAIN_DELAY_MEMBERS', + 'img' => 'user' + ) + ), +); + if ($action == 'update') { - //Conversion des jours en secondes - if ($_POST["ActionsToDo"]) dolibarr_set_const($db, "MAIN_DELAY_ACTIONS_TODO",$_POST["ActionsToDo"],'chaine',0,'',$conf->entity); - if ($_POST["OrdersToProcess"]) dolibarr_set_const($db, "MAIN_DELAY_ORDERS_TO_PROCESS",$_POST["OrdersToProcess"],'chaine',0,'',$conf->entity); - if ($_POST["SuppliersOrdersToProcess"]) dolibarr_set_const($db, "MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS",$_POST["SuppliersOrdersToProcess"],'chaine',0,'',$conf->entity); - if ($_POST["PropalsToClose"]) dolibarr_set_const($db, "MAIN_DELAY_PROPALS_TO_CLOSE",$_POST["PropalsToClose"],'chaine',0,'',$conf->entity); - if ($_POST["PropalsToBill"]) dolibarr_set_const($db, "MAIN_DELAY_PROPALS_TO_BILL",$_POST["PropalsToBill"],'chaine',0,'',$conf->entity); - if ($_POST["BoardNotActivatedServices"]) dolibarr_set_const($db, "MAIN_DELAY_NOT_ACTIVATED_SERVICES",$_POST["BoardNotActivatedServices"],'chaine',0,'',$conf->entity); - if ($_POST["BoardRunningServices"]) dolibarr_set_const($db, "MAIN_DELAY_RUNNING_SERVICES",$_POST["BoardRunningServices"],'chaine',0,'',$conf->entity); - if ($_POST["CustomerBillsUnpaid"]) dolibarr_set_const($db, "MAIN_DELAY_CUSTOMER_BILLS_UNPAYED",$_POST["CustomerBillsUnpaid"],'chaine',0,'',$conf->entity); - if ($_POST["SupplierBillsToPay"]) dolibarr_set_const($db, "MAIN_DELAY_SUPPLIER_BILLS_TO_PAY",$_POST["SupplierBillsToPay"],'chaine',0,'',$conf->entity); - if ($_POST["TransactionsToConciliate"]) dolibarr_set_const($db, "MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE",$_POST["TransactionsToConciliate"],'chaine',0,'',$conf->entity); - if ($_POST["ChequesToDeposit"]) dolibarr_set_const($db, "MAIN_DELAY_CHEQUES_TO_DEPOSIT",$_POST["ChequesToDeposit"],'chaine',0,'',$conf->entity); - if ($_POST["Members"]) dolibarr_set_const($db, "MAIN_DELAY_MEMBERS",$_POST["Members"],'chaine',0,'',$conf->entity); + foreach($modules as $module => $delays) + { + if (! empty($conf->$module->enabled)) + { + foreach($delays as $delay) + { + if (GETPOST($delay['code'])) + { + dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity); + } + } + } + } dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity); } @@ -72,10 +134,9 @@ print "
\n"; $form = new Form($db); $countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($action == 'edit') { - print '
'; + print ''; print ''; print ''; $var=true; @@ -83,99 +144,20 @@ if ($action == 'edit') print '
'; print ''; - // - if (! empty($conf->agenda->enabled)) + foreach($modules as $module => $delays) { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->commande->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->fournisseur->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->propal->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->propal->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->service->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->service->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->facture->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->fournisseur->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->banque->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; - $var=!$var; - print ''; - print ''; - print ''; - } - if (! empty($conf->adherent->enabled)) - { - $var=!$var; - print ''; - print ''; - print ''; + if (! empty($conf->$module->enabled)) + { + foreach($delays as $delay) + { + $var=!$var; + $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + print ''; + print ''; + print ''; + } + } } print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'.img_object('','action').''.$langs->trans("DelaysOfToleranceActionsToDo").''; - print ' ' . $langs->trans("days") . '
'.img_object('','order').''.$langs->trans("DelaysOfToleranceOrdersToProcess").''; - print ' ' . $langs->trans("days") . '
'.img_object('','order').''.$langs->trans("DelaysOfToleranceSuppliersOrdersToProcess").''; - print ' ' . $langs->trans("days") . '
'.img_object('','propal').''.$langs->trans("DelaysOfTolerancePropalsToClose").''; - print ' ' . $langs->trans("days") . '
'.img_object('','propal').''.$langs->trans("DelaysOfTolerancePropalsToBill").''; - print ' ' . $langs->trans("days") . '
'.img_object('','service').''.$langs->trans("DelaysOfToleranceNotActivatedServices").''; - print ' ' . $langs->trans("days") . '
'.img_object('','service').''.$langs->trans("DelaysOfToleranceRunningServices").''; - print ' ' . $langs->trans("days") . '
'.img_object('','bill').''.$langs->trans("DelaysOfToleranceCustomerBillsUnpaid").''; - print ' ' . $langs->trans("days") . '
'.img_object('','bill').''.$langs->trans("DelaysOfToleranceSupplierBillsToPay").''; - print ' ' . $langs->trans("days") . '
'.img_object('','account').''.$langs->trans("DelaysOfToleranceTransactionsToConciliate").''; - print ' ' . $langs->trans("days") . '
'.img_object('','account').''.$langs->trans("DelaysOfToleranceChequesToDeposit").''; - print ' ' . $langs->trans("days") . '
'.img_object('','user').''.$langs->trans("DelaysOfToleranceMembers").''; - print ' ' . $langs->trans("days") . '
'.img_object('',$delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; + print ' '.$langs->trans("days").'
'; @@ -209,98 +191,20 @@ else print ''.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").''; $var=true; - $var=!$var; - - if (! empty($conf->agenda->enabled)) + foreach($modules as $module => $delays) { - print ''; - print ''.img_object('','action').''; - print ''.$langs->trans("DelaysOfToleranceActionsToDo").'' . ($conf->global->MAIN_DELAY_ACTIONS_TODO+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->commande->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','order').''; - print ''.$langs->trans("DelaysOfToleranceOrdersToProcess").'' . ($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->fournisseur->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','order').''; - print ''.$langs->trans("DelaysOfToleranceSuppliersOrdersToProcess").'' . ($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->propal->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','propal').''; - print ''.$langs->trans("DelaysOfTolerancePropalsToClose").'' . ($conf->global->MAIN_DELAY_PROPALS_TO_CLOSE+0). ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->propal->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','propal').''; - print ''.$langs->trans("DelaysOfTolerancePropalsToBill").'' . ($conf->global->MAIN_DELAY_PROPALS_TO_BILL+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->service->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','service').''; - print ''.$langs->trans("DelaysOfToleranceNotActivatedServices").'' . ($conf->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->service->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','service').''; - print ''.$langs->trans("DelaysOfToleranceRunningServices").'' . ($conf->global->MAIN_DELAY_RUNNING_SERVICES+0). ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->facture->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','bill').''; - print ''.$langs->trans("DelaysOfToleranceCustomerBillsUnpaid").'' . ($conf->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->fournisseur->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','bill').''; - print ''.$langs->trans("DelaysOfToleranceSupplierBillsToPay").'' . ($conf->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->banque->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','account').''; - print ''.$langs->trans("DelaysOfToleranceTransactionsToConciliate").'' . ($conf->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE+0) . ' ' . $langs->trans("days") . ''; - - $var=!$var; - print ''; - print ''.img_object('','account').''; - print ''.$langs->trans("DelaysOfToleranceChequesToDeposit").'' . ($conf->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT+0) . ' ' . $langs->trans("days") . ''; - } - - if (! empty($conf->adherent->enabled)) - { - $var=!$var; - print ''; - print ''.img_object('','user').''; - print ''.$langs->trans("DelaysOfToleranceMembers").'' . ($conf->global->MAIN_DELAY_MEMBERS+0) . ' ' . $langs->trans("days") . ''; + if (! empty($conf->$module->enabled)) + { + foreach($delays as $delay) + { + $var=!$var; + $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + print ''; + print ''.img_object('',$delay['img']).''; + print ''.$langs->trans('Delays_'.$delay['code']).''; + print ''.$value.' '.$langs->trans("days").''; + } + } } print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 71ec16150b6..13864a37183 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2011 Philippe Grand * Copyright (C) 2011 Remy Younes @@ -279,24 +279,24 @@ $tabcond[1] = true; $tabcond[2] = true; $tabcond[3] = true; $tabcond[4] = true; -$tabcond[5] = $conf->societe->enabled||$conf->adherent->enabled; -$tabcond[6] = $conf->agenda->enabled; -$tabcond[7] = $conf->tax->enabled; -$tabcond[8] = $conf->societe->enabled; +$tabcond[5] = (! empty($conf->societe->enabled) || ! empty($conf->adherent->enabled)); +$tabcond[6] = ! empty($conf->agenda->enabled); +$tabcond[7] = ! empty($conf->tax->enabled); +$tabcond[8] = ! empty($conf->societe->enabled); $tabcond[9] = true; $tabcond[10]= true; $tabcond[11]= true; -$tabcond[12]= $conf->commande->enabled||$conf->propal->enabled||$conf->facture->enabled||$conf->fournisseur->enabled; -$tabcond[13]= $conf->commande->enabled||$conf->propal->enabled||$conf->facture->enabled||$conf->fournisseur->enabled; -$tabcond[14]= $conf->product->enabled&&$conf->ecotax->enabled; +$tabcond[12]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); +$tabcond[13]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); +$tabcond[14]= (! empty($conf->product->enabled) && ! empty($conf->ecotax->enabled)); $tabcond[15]= true; -$tabcond[16]= $conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS); -$tabcond[17]= $conf->deplacement->enabled; -$tabcond[18]= $conf->expedition->enabled; -$tabcond[19]= $conf->societe->enabled; -$tabcond[20]= $conf->fournisseur->enabled; -$tabcond[21]= $conf->propal->enabled; -$tabcond[22]= $conf->commande->enabled||$conf->propal->enabled; +$tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); +$tabcond[17]= ! empty($conf->deplacement->enabled); +$tabcond[18]= ! empty($conf->expedition->enabled); +$tabcond[19]= ! empty($conf->societe->enabled); +$tabcond[20]= ! empty($conf->fournisseur->enabled); +$tabcond[21]= ! empty($conf->propal->enabled); +$tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); // List of help for fields $tabhelp=array(); @@ -347,7 +347,7 @@ if ($id == 11) "facture"=>$langs->trans("Bill"), "facture_fourn"=>$langs->trans("SupplierBill"), "fichinter"=>$langs->trans("InterventionCard")); - if ($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES) $elementList["societe"]=$langs->trans("ThirdParty"); + if (! empty($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES)) $elementList["societe"]=$langs->trans("ThirdParty"); $sourceList = array("internal"=>$langs->trans("Internal"), "external"=>$langs->trans("External")); } @@ -356,7 +356,7 @@ $msg=''; // Actions ajout ou modification d'une entree dans un dictionnaire de donnee -if ($_POST["actionadd"] || $_POST["actionmodify"]) +if (GETPOST('actionadd') || GETPOST('actionmodify')) { $listfield=explode(',',$tabfield[$id]); $listfieldinsert=explode(',',$tabfieldinsert[$id]); @@ -401,7 +401,7 @@ if ($_POST["actionadd"] || $_POST["actionmodify"]) } // Si verif ok et action add, on ajoute la ligne - if ($ok && $_POST["actionadd"]) + if ($ok && GETPOST('actionadd')) { if ($tabrowid[$id]) { @@ -466,7 +466,7 @@ if ($_POST["actionadd"] || $_POST["actionmodify"]) } // Si verif ok et action modify, on modifie la ligne - if ($ok && $_POST["actionmodify"]) + if ($ok && GETPOST('actionmodify')) { if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } @@ -509,7 +509,7 @@ if ($_POST["actionadd"] || $_POST["actionmodify"]) $_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition } -if ($_POST["actioncancel"]) +if (GETPOST('actioncancel')) { $_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition } @@ -619,7 +619,7 @@ if ($id) // Complete requete recherche valeurs avec critere de tri $sql=$tabsql[$id]; - if ($_GET["sortfield"]) + if (GETPOST('sortfield')) { // If sort order is "pays", we use pays_code instead if ($_GET["sortfield"] == 'pays') $_GET["sortfield"]='pays_code'; @@ -687,7 +687,7 @@ if ($id) if ($valuetoshow != '') { print ''; - if (preg_match('/http:/i',$tabhelp[$id][$value])) print ''.$valuetoshow.''; + if (! empty($tabhelp[$id][$value]) && preg_match('/http:/i',$tabhelp[$id][$value])) print ''.$valuetoshow.''; else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; print ''; @@ -704,7 +704,7 @@ if ($id) $obj=''; // If data was already input, we define them in obj to populate input fields. - if ($_POST["actionadd"]) + if (GETPOST('actionadd')) { foreach ($fieldlist as $key=>$val) { @@ -795,7 +795,7 @@ if ($id) //print_r($obj); print ""; - if ($action == 'edit' && ($rowid == ($obj->rowid?$obj->rowid:$obj->code))) + if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) { print ''; print ''; @@ -810,7 +810,7 @@ if ($id) if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id]); - print ' '; + print ' '; print ' '; } else @@ -866,7 +866,7 @@ if ($id) $key=$langs->trans("Action".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; } - else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') { + else if (! empty($obj->code_iso) && $fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') { $key=$langs->trans("Currency".strtoupper($obj->code_iso)); $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso))?$key:$obj->$fieldlist[$field]; } @@ -926,18 +926,18 @@ if ($id) if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable=0; if (isset($obj->code) && $obj->code == 'RECEP') $iserasable=0; if (isset($obj->code) && $obj->code == 'EF0') $iserasable=0; - if ($obj->type && $obj->type == 'system') $iserasable=0; + if (isset($obj->type) && $obj->type == 'system') $iserasable=0; - if ($iserasable) print ''.$actl[$obj->active].''; + if ($iserasable) print ''.$actl[$obj->active].''; else print $langs->trans("AlwaysActive"); print ""; // Modify link - if ($iserasable) print 'rowid?$obj->rowid:$obj->code).'">'.img_edit().''; + if ($iserasable) print 'rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'">'.img_edit().''; else print ' '; // Delete link - if ($iserasable) print ''.img_delete().''; + if ($iserasable) print ''.img_delete().''; else print ' '; print "\n"; @@ -971,7 +971,7 @@ else foreach ($taborder as $i) { - if ($tabname[$i] && empty($tabcond[$i])) continue; + if (isset($tabname[$i]) && empty($tabcond[$i])) continue; if ($i) { @@ -1011,9 +1011,9 @@ else print '
'; -$db->close(); llxFooter(); +$db->close(); /** @@ -1039,7 +1039,7 @@ function fieldList($fieldlist,$obj='',$tabname='') if ($fieldlist[$field] == 'pays') { if (in_array('region_id',$fieldlist)) { print ' '; continue; } // For region page, we do not show the country input print ''; - print $form->select_country(($obj->pays_code?$obj->pays_code:$obj->pays),'pays'); + print $form->select_country((! empty($obj->pays_code)?$obj->pays_code:(! empty($obj->pays)?$obj->pays:'')),'pays'); print ''; } elseif ($fieldlist[$field] == 'pays_id') { @@ -1052,7 +1052,7 @@ function fieldList($fieldlist,$obj='',$tabname='') print ''; } elseif ($fieldlist[$field] == 'region_id') { - $region_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0; + $region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); print ''; } elseif ($fieldlist[$field] == 'lang') { @@ -1064,14 +1064,14 @@ function fieldList($fieldlist,$obj='',$tabname='') elseif ($fieldlist[$field] == 'element') { print ''; - print $form->selectarray('element', $elementList,$obj->$fieldlist[$field]); + print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print ''; } // La source de l'element (pour les type de contact).' elseif ($fieldlist[$field] == 'source') { print ''; - print $form->selectarray('source', $sourceList,$obj->$fieldlist[$field]); + print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); print ''; } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") @@ -1082,30 +1082,30 @@ function fieldList($fieldlist,$obj='',$tabname='') } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') { print ''; - print $form->selectyesno($fieldlist[$field],$obj->$fieldlist[$field],1); + print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); print ''; } elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { - print ''; + print ''; } elseif ($fieldlist[$field] == 'libelle_facture') { - print ''; + print ''; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { - print ''; + print ''; } - elseif ($fieldlist[$field] == 'code') { - print ''; + elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { + print ''; } elseif ($fieldlist[$field]=='unit') { print ''; - print $form->selectarray('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1); + print $form->selectarray('unit',array('mm','cm','point','inch'),(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),0,0,1); print ''; } else { print ''; - print ''; + print ''; print ''; } } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 29c1912c696..897e91a8c0a 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009-2011 Regis Houssin + * Copyright (C) 2009-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 @@ -32,7 +32,7 @@ $langs->load("mails"); $langs->load("other"); $langs->load("errors"); -if (!$user->admin) accessforbidden(); +if (! $user->admin) accessforbidden(); $substitutionarrayfortest=array( '__LOGIN__' => $user->login, @@ -46,6 +46,7 @@ $substitutionarrayfortest=array( complete_substitutions_array($substitutionarrayfortest, $langs); $action=GETPOST('action'); +$message=''; /* @@ -75,7 +76,7 @@ if ($action == 'update' && empty($_POST["cancel"])) /* * Add file in email form */ -if ($_POST['addfile'] || $_POST['addfilehtml']) +if (GETPOST('addfile') || GETPOST('addfilehtml')) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -163,7 +164,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml'])) /* * Cancel */ -if (($action == 'send' || $action == 'sendhtml') && $_POST['cancel']) +if (($action == 'send' || $action == 'sendhtml') && GETPOST('cancel')) { $message=''; } @@ -171,7 +172,7 @@ if (($action == 'send' || $action == 'sendhtml') && $_POST['cancel']) /* * Send mail */ -if (($action == 'send' || $action == 'sendhtml') && ! $_POST['addfile'] && ! $_POST['addfilehtml'] && ! $_POST["removedfile"] && ! $_POST['cancel']) +if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GETPOST('addfilehtml') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { $error=0; @@ -378,22 +379,23 @@ if ($action == 'edit') } else { + $mainserver = (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:''); $smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); else print $langs->trans("MAIN_MAIL_SMTP_SERVER",$smtpserver); print ''; // SuperAdministrator access only - if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) { - print ''; - print ''; + print ''; + print ''; } else { - $text = $conf->global->MAIN_MAIL_SMTP_SERVER ? $conf->global->MAIN_MAIL_SMTP_SERVER : $smtpserver; + $text = ! empty($mainserver) ? $mainserver : $smtpserver; $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text,$htmltext,1,'superadmin'); - print ''; + print ''; } } print ''; @@ -409,60 +411,63 @@ if ($action == 'edit') } else { + $mainport = (! empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ''); $smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); else print $langs->trans("MAIN_MAIL_SMTP_PORT",$smtpport); print ''; // SuperAdministrator access only - if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) { - print ''; - print ''; + print ''; + print ''; } else { - $text = $conf->global->MAIN_MAIL_SMTP_PORT ? $conf->global->MAIN_MAIL_SMTP_PORT : $smtpport; + $text = (! empty($mainport) ? $mainport : $smtpport); $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text,$htmltext,1,'superadmin'); - print ''; + print ''; } } print ''; // ID - if ($conf->use_javascript_ajax || $conf->global->MAIN_MAIL_SENDMODE == 'smtps') + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps')) { $var=!$var; + $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:''); print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").''; // SuperAdministrator access only - if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID,$htmltext,1,'superadmin'); - print ''; + print ''; } print ''; } // PW - if ($conf->use_javascript_ajax || $conf->global->MAIN_MAIL_SENDMODE == 'smtps') + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps')) { $var=!$var; + $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:''); print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''; // SuperAdministrator access only - if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW,$htmltext,1,'superadmin'); - print ''; + print ''; } print ''; } @@ -470,11 +475,11 @@ if ($action == 'edit') // TLS $var=!$var; print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; - if ($conf->use_javascript_ajax || $conf->global->MAIN_MAIL_SENDMODE == 'smtps') + if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps')) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_TLS',$conf->global->MAIN_MAIL_EMAIL_TLS,1); + print $form->selectyesno('MAIN_MAIL_EMAIL_TLS',(! empty($conf->global->MAIN_MAIL_EMAIL_TLS)?$conf->global->MAIN_MAIL_EMAIL_TLS:0),1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -488,19 +493,19 @@ if ($action == 'edit') // From $var=!$var; print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; - print ''; // From $var=!$var; print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; - print ''; // Autocopy to $var=!$var; print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; - print ''; print ''; @@ -538,36 +543,36 @@ else // Server $var=!$var; - if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").''; } else { - print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER",ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_SMTP_SERVER.''; + print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER",ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:'').''; } // Port $var=!$var; - if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").''; } else { - print ''.$langs->trans("MAIN_MAIL_SMTP_PORT",ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_SMTP_PORT.''; + print ''.$langs->trans("MAIN_MAIL_SMTP_PORT",ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:'').''; } // SMTPS ID $var=!$var; - if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') + if (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps') { print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.''; } // SMTPS PW $var=!$var; - if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') + if (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps') { print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW).''; } @@ -575,7 +580,7 @@ else // TLS $var=!$var; print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; - if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') + if (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'smtps') { if (function_exists('openssl_open')) { @@ -594,21 +599,29 @@ else $var=!$var; print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; print ''.$conf->global->MAIN_MAIL_EMAIL_FROM; - if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); + if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); print ''; // Errors To $var=!$var; print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; print ''.$conf->global->MAIN_MAIL_ERRORS_TO; - if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); + if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print ''; // Autocopy to $var=!$var; print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; - print ''.$conf->global->MAIN_MAIL_AUTOCOPY_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && ! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + print ''; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) + { + print $conf->global->MAIN_MAIL_AUTOCOPY_TO; + if (! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + } + else + { + print ' '; + } print ''; print ''; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index c23310571e9..aebb05abed9 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -33,8 +33,7 @@ $langs->load("admin"); $langs->load("members"); $langs->load("users"); -if (!$user->admin) -accessforbidden(); +if (! $user->admin) accessforbidden(); /* * Action @@ -115,11 +114,8 @@ else print ''; print ''; -print '
'; - -$db->close(); - -print '
'; +print '

'; llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 5ee0ae1c95b..d33fac9299a 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004-2011 Laurent Destailleur +/* Copyright (C) 2001-2002 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * 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 @@ -34,14 +35,16 @@ $langs->load("companies"); $langs->load("donations"); $langs->load("bills"); -$id=GETPOST('rowid')?GETPOST('rowid'):GETPOST('id','int'); -$action=GETPOST('action'); +$id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int'); +$action=GETPOST('action','alpha'); +$cancel=GETPOST('cancel'); +$amount=GETPOST('amount'); $mesg=""; $mesgs=array(); $don = new Don($db); -$donation_date=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); +$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); // Security check $result = restrictedArea($user, 'don', $id); @@ -53,9 +56,9 @@ $result = restrictedArea($user, 'don', $id); if ($action == 'update') { - if (! empty($_POST['cancel'])) + if (! empty($cancel)) { - Header("Location: fiche.php?rowid=".$_POST["rowid"]); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -68,7 +71,7 @@ if ($action == 'update') $error++; } - if (! $_POST["amount"] > 0) + if (empty($amount)) { $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); $action = "create"; @@ -77,8 +80,7 @@ if ($action == 'update') if (! $error) { - $don->id = $_POST["rowid"]; - $don->fetch($_POST["rowid"]); + $don->fetch($id); $don->prenom = $_POST["prenom"]; $don->nom = $_POST["nom"]; @@ -100,7 +102,7 @@ if ($action == 'update') if ($don->update($user) > 0) { - Header("Location: fiche.php?rowid=".$don->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$don->id); exit; } } @@ -108,7 +110,7 @@ if ($action == 'update') if ($action == 'add') { - if (! empty($_POST['cancel'])) + if (! empty($cancel)) { Header("Location: index.php"); exit; @@ -119,14 +121,14 @@ if ($action == 'add') if (empty($donation_date)) { $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); - $_GET["action"] = "create"; + $action = "create"; $error++; } - if (! $_POST["amount"] > 0) + if (empty($amount)) { $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); - $_GET["action"] = "create"; + $action = "create"; $error++; } @@ -160,48 +162,47 @@ if ($action == 'add') if ($action == 'delete') { - $don->delete($_GET["rowid"]); + $don->delete($id); Header("Location: liste.php"); exit; } if ($action == 'commentaire') { - $don->fetch($_POST["rowid"]); + $don->fetch($id); $don->update_note($_POST["commentaire"]); - $_GET["rowid"] = $_POST["rowid"]; } if ($action == 'valid_promesse') { - if ($don->valid_promesse($_GET["rowid"], $user->id) >= 0) + if ($don->valid_promesse($id, $user->id) >= 0) { - Header("Location: fiche.php?rowid=".$_GET["rowid"]); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else $mesg=$don->error; } if ($action == 'set_cancel') { - if ($don->set_cancel($_GET["rowid"]) >= 0) + if ($don->set_cancel($id) >= 0) { - Header("Location: fiche.php?rowid=".$_GET["rowid"]); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else $mesg=$don->error; } if ($action == 'set_paid') { - if ($don->set_paye($_GET["rowid"], $modepaiement) >= 0) + if ($don->set_paye($id, $modepaiement) >= 0) { - Header("Location: fiche.php?rowid=".$_GET["rowid"]); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else $mesg=$don->error; } if ($action == 'set_encaisse') { - if ($don->set_encaisse($_GET["rowid"]) >= 0) + if ($don->set_encaisse($id) >= 0) { - Header("Location: fiche.php?rowid=".$_GET["rowid"]); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else $mesg=$don->error; @@ -213,7 +214,7 @@ if ($action == 'set_encaisse') if ($action == 'builddoc') { $donation = new Don($db); - $donation->fetch($_GET['rowid']); + $donation->fetch($id); if ($_REQUEST['model']) { @@ -238,7 +239,7 @@ if ($action == 'builddoc') } else { - Header('Location: '.$_SERVER["PHP_SELF"].'?rowid='.$donation->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$donation->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } @@ -332,12 +333,12 @@ if ($action == 'create') /* */ /* ************************************************************ */ -if ($id && $_GET["action"] == 'edit') +if (! empty($id) && $action == 'edit') { $don->fetch($id); $h=0; - $head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"]; + $head[$h][0] = $_SERVER['PHP_SELF']."?id=".$don->id; $head[$h][1] = $langs->trans("Card"); $hselected=$h; $h++; @@ -401,11 +402,11 @@ if ($id && $_GET["action"] == 'edit') print "".''.$langs->trans("Status").''.$don->getLibStatut(4).''; // Project - if ($conf->projet->enabled) + if (! empty($conf->projet->enabled)) { $langs->load('projects'); print ''.$langs->trans('Project').''; - select_projects($soc->id, isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project, 'projectid'); + select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid'); print ''; } @@ -425,12 +426,12 @@ if ($id && $_GET["action"] == 'edit') /* Fiche don en mode visu */ /* */ /* ************************************************************ */ -if ($id && $action != 'edit') +if (! empty($id) && $action != 'edit') { $result=$don->fetch($id); $h=0; - $head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"]; + $head[$h][0] = $_SERVER['PHP_SELF']."?id=".$don->id; $head[$h][1] = $langs->trans("Card"); $hselected=$h; $h++; @@ -565,8 +566,6 @@ if ($id && $action != 'edit') } - -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/dons/index.php b/htdocs/compta/dons/index.php index e72f49b9cb3..39de537cd3e 100644 --- a/htdocs/compta/dons/index.php +++ b/htdocs/compta/dons/index.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004-2012 Laurent Destailleur +/* Copyright (C) 2001-2002 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Laurent Destailleur + * 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 @@ -27,7 +28,8 @@ require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php"); $langs->load("donations"); -if (!$user->rights->don->lire) accessforbidden(); +// Security check +$result = restrictedArea($user, 'don'); $donation_static=new Don($db); @@ -48,17 +50,19 @@ $donstatic=new Don($db); $help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Subvenciones'; llxHeader('',$langs->trans("Donations"),$help_url); +$nb=array(); +$somme=array(); + $sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " GROUP BY d.fk_statut"; $sql.= " ORDER BY d.fk_statut"; $result = $db->query($sql); - if ($result) { + $i = 0; $num = $db->num_rows($result); - $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); @@ -107,17 +111,19 @@ print ''.$langs->trans("Total").''; print ''.$langs->trans("Average").''; print ''; +$total=0; +$totalnb=0; $var=true; foreach ($listofstatus as $status) { $var=!$var; print ""; print ''.$donstatic->LibStatut($status,4).''; - print ''.$nb[$status].''; - print ''.($nb[$status]?price($somme[$status],'MT'):' ').''; - print ''.($nb[$status]?price(price2num($somme[$status]/$nb[$status],'MT')):' ').''; - $totalnb += $nb[$status]; - $total += $somme[$status]; + print ''.(! empty($nb[$status])?$nb[$status]:' ').''; + print ''.(! empty($nb[$status])?price($somme[$status],'MT'):' ').''; + print ''.(! empty($nb[$status])?price(price2num($somme[$status]/$nb[$status],'MT')):' ').''; + $totalnb += (! empty($nb[$status])?$nb[$status]:0); + $total += (! empty($somme[$status])?$somme[$status]:0); print ""; } diff --git a/htdocs/compta/dons/liste.php b/htdocs/compta/dons/liste.php index 14be56fdba6..f3ede273760 100644 --- a/htdocs/compta/dons/liste.php +++ b/htdocs/compta/dons/liste.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004-2011 Laurent Destailleur +/* Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * 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 @@ -24,7 +25,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); +if (! empty($conf->projet->enabled)) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); $langs->load("companies"); $langs->load("donations"); @@ -83,10 +84,10 @@ if (trim($search_name) != '') $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); -$result = $db->query($sql); -if ($result) +$resql = $db->query($sql); +if ($resql) { - $num = $db->num_rows($result); + $num = $db->num_rows($resql); $i = 0; $param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"; @@ -110,7 +111,7 @@ if ($result) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"d.societe","&page=$page&statut=$statut","","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"d.nom","&page=$page&statut=$statut","","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"d.datedon","&page=$page&statut=$statut","",'align="center"',$sortfield,$sortorder); - if ($conf->projet->enabled) + if (! empty($conf->projet->enabled)) { $langs->load("projects"); print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_don_projet","&page=$page&statut=$statut","","",$sortfield,$sortorder); @@ -133,7 +134,7 @@ if ($result) print ''; print ' '; print ''; - if ($conf->projet->enabled) + if (! empty($conf->projet->enabled)) { print ''; print ' '; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ac5c2afde9e..5ff20189268 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -38,8 +38,8 @@ require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); -if ($conf->projet->enabled) +if (! empty($conf->commande->enabled)) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); +if (! empty($conf->projet->enabled)) { require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); @@ -52,6 +52,9 @@ $langs->load('companies'); $langs->load('products'); $langs->load('main'); +$mesg=''; +$errors=array(); + if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message']; $sall=trim(GETPOST('sall')); @@ -82,7 +85,7 @@ $result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid); // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; -$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; +$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); $object=new Facture($db); @@ -1286,7 +1289,7 @@ else if ($action == 'down' && $user->rights->facture->creer) /* * Add file in email form */ -if ($_POST['addfile']) +if (GETPOST('addfile')) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -2372,7 +2375,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; print '
'.$langs->trans('Company').''; - if ($conf->global->FACTURE_CHANGE_THIRDPARTY && $action != 'editthirdparty' && $object->brouillon && $user->rights->facture->creer) + if (! empty($conf->global->FACTURE_CHANGE_THIRDPARTY) && $action != 'editthirdparty' && $object->brouillon && $user->rights->facture->creer) print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'
'; print ''; @@ -3017,7 +3020,7 @@ else if ($id > 0 || ! empty($ref)) } } - if ($conf->global->FACTURE_SHOW_SEND_REMINDER) // For backward compatibility + if (! empty($conf->global->FACTURE_SHOW_SEND_REMINDER)) // For backward compatibility { if (($object->statut == 1 || $object->statut == 2) && $resteapayer > 0) { diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index dafb75b4e04..fb8711d7c12 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-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 @@ -227,9 +227,10 @@ abstract class ActionsContactCardCommon * Set content of ->tpl array, to use into template * * @param string &$action Type of action + * @param int $id Id * @return string HTML output */ - function assign_values(&$action) + function assign_values(&$action, $id) { global $conf, $langs, $user, $canvas; global $form, $formcompany, $objsoc; @@ -273,7 +274,7 @@ abstract class ActionsContactCardCommon $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civilite_id); // Predefined with third party - if ($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) { if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index ed186b92348..1cb87732ddc 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011 Laurent Destailleur +/* Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,15 +38,15 @@ class ActionsContactCardDefault extends ActionsContactCardCommon /** * Constructor * - * @param DoliDB $DB Handler acces base de donnees + * @param DoliDB $db Handler acces base de donnees * @param string $dirmodule Name of directory of module * @param string $targetmodule Name of directory of module where canvas is stored * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) */ - function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) + function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { - $this->db = $DB; + $this->db = $db; $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; @@ -86,7 +86,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $ret = $this->getObject($id); - parent::assign_values($action); + parent::assign_values($action, $id); $this->tpl['title'] = $this->getTitle($action); $this->tpl['error'] = $this->error; @@ -102,7 +102,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['showend']=dol_get_fiche_end(); $objsoc = new Societe($db); - $objsoc->fetch($this->object->fk_soc); + $objsoc->fetch($this->object->socid); $this->tpl['actionstodo']=show_actions_todo($conf,$langs,$db,$objsoc,$this->object,1); diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index c4b48767f2f..34b077eac9b 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -40,7 +40,7 @@ echo $this->control->tpl['ajax_selectcountry']; -control->tpl['company_id']) { ?> +control->tpl['company_id'])) { ?> diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index fe878bf95f0..53f29e5397e 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-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 @@ -26,8 +26,8 @@ $contact = $GLOBALS['objcanvas']->control->object; dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?> -control->tpl['action_create_user']) echo $this->control->tpl['action_create_user']; ?> -control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> +control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; ?> +control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 58356a5f386..d9b69e35fcf 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2004 Rodolphe Quiedeville * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005-2008 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Raphael Bertrand (Resultic) * @@ -534,7 +534,6 @@ class Contact extends CommonObject $this->mail = $obj->email; $this->birthday = $this->db->jdate($obj->birthday); - $this->birthday_alert = $obj->birthday_alert; $this->note = $obj->note; $this->default_lang = $obj->default_lang; $this->user_id = $obj->user_id; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 7487bf6d06f..b13f960e9de 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -50,7 +50,8 @@ $object = new Contact($db); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); -$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$objcanvas=null; +$canvas = (! empty($object->canvas)?$object->canvas:GETPOST("canvas")); if (! empty($canvas)) { require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b6723bb6623..d71dcc44225 100755 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -31,7 +31,7 @@ $langs->load("companies"); $langs->load("suppliers"); // Security check -$contactid = isset($_GET["id"])?$_GET["id"]:''; +$contactid = GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $contactid,''); @@ -54,6 +54,8 @@ $sall=GETPOST("contactname"); $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); +$userid=GETPOST('userid'); +$begin=GETPOST('begin'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; @@ -86,9 +88,9 @@ else if ($type == "o") if ($view == 'phone') { $text=" (Vue Telephones)"; } if ($view == 'mail') { $text=" (Vue EMail)"; } if ($view == 'recent') { $text=" (Recents)"; } -$titre.= " $text"; +if (! empty($text)) $titre.= " $text"; -if ($_POST["button_removefilter"]) +if (GETPOST('button_removefilter')) { $search_nom=""; $search_prenom=""; @@ -129,9 +131,9 @@ if (!$user->rights->societe->client->voir && !$socid) //restriction { $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)"; } -if ($_GET["userid"]) // propre au commercial +if ($userid) // propre au commercial { - $sql .= " AND p.fk_user_creat=".$_GET["userid"]; + $sql .= " AND p.fk_user_creat=".$userid; } // Filter to exclude not owned private contacts @@ -205,7 +207,7 @@ if ($sall) { $sql .= " AND (p.name LIKE '%".$db->escape($sall)."%' OR p.firstname LIKE '%".$db->escape($sall)."%' OR p.email LIKE '%".$db->escape($sall)."%')"; } -if ($socid) +if (! empty($socid)) { $sql .= " AND s.rowid = ".$socid; } @@ -235,8 +237,7 @@ if ($result) { $contactstatic=new Contact($db); - $begin=$_GET["begin"]; - $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($_GET["userid"]).'&contactname='.urlencode($sall); + $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_nom='.urlencode($search_nom).'&search_prenom='.urlencode($search_prenom).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); @@ -408,7 +409,7 @@ if ($result) print ''; - if ($num > $limit) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '&begin='.$begin.'&view='.$view.'&userid='.$_GET["userid"], $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + if ($num > $limit) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '&begin='.$begin.'&view='.$view.'&userid='.$userid, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); $db->free($result); } @@ -419,7 +420,7 @@ else print '
'; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 8cf299ec133..26a3b90ea59 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -131,7 +131,7 @@ if ($action == 'edit') print ''; print '
'; } @@ -193,7 +193,7 @@ else // Date To Birth print ''; - if ($object->birthday != '') + if (! empty($object->birthday)) { include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); @@ -225,7 +225,6 @@ else dol_fiche_end(); - if ($action != 'edit') { // Barre d'actions diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aa0c71dbd45..a41aee430b8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -772,13 +772,13 @@ abstract class CommonObject $sql = "SELECT MAX(te.".$fieldid.")"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te"; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id; if (! empty($filter)) $sql.=" AND ".$filter; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity - if ($this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; //print $sql."
"; $result = $this->db->query($sql); @@ -793,13 +793,13 @@ abstract class CommonObject $sql = "SELECT MIN(te.".$fieldid.")"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te"; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id; if (! empty($filter)) $sql.=" AND ".$filter; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity - if ($this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null //print $sql."
"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 42a6119c611..53ab7a49ddc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2151,21 +2151,23 @@ class Form $inputok=array(); $inputko=array(); - if (is_array($formquestion) && count($formquestion) > 0) + if (is_array($formquestion) && ! empty($formquestion)) { $more.='
'.$langs->trans("Alert").': '; - if ($object->birthday_alert) + if (! empty($object->birthday_alert)) { print '
'."\n"; - $more.=''."\n"; + $more.=''."\n"; foreach ($formquestion as $key => $input) { - if (is_array($input)) + if (is_array($input) && ! empty($input)) { + $size=(! empty($input['size'])?' size="'.$input['size'].'"':''); + if ($input['type'] == 'text') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'password') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'select') { @@ -3087,8 +3089,9 @@ class Form if ($d) { // Show date with popup - if ($conf->use_javascript_ajax && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) + if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) { + $formated_date=''; //print "e".$set_time." t ".$conf->format_date_short; if (strval($set_time) != '' && $set_time != -1) { @@ -3690,7 +3693,7 @@ class Form } else { - if ($conf->gravatar->enabled && $email) + if (! empty($conf->gravatar->enabled) && $email) { global $dolibarr_main_url_root; $ret.=''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index c6c84229d5e..979fb0ab5db 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -435,7 +435,7 @@ class FormFile $out.= ''; // Execute hooks - $parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id'],'modulepart'=>$modulepart); + $parameters=array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart); if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters,$GLOBALS['object']); } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b31d36406f5..55d7628ab19 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -245,7 +245,7 @@ class FormMail $out.= '
'.$formquestion['text'].'
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'."\n"; // Substitution array - if ($this->withsubstit) + if (! empty($this->withsubstit)) { $out.= ''; $out.= ''; @@ -549,7 +549,7 @@ class FormMail } // Message - if ($this->withbody) + if (! empty($this->withbody)) { $defaultmessage=""; @@ -617,7 +617,7 @@ class FormMail $out.= "\n"; } - if ($this->withform) + if (! empty($this->withform)) { $out.= '
'; $help=""; @@ -258,9 +258,9 @@ class FormMail } // From - if ($this->withfrom) + if (! empty($this->withfrom)) { - if ($this->withfromreadonly) + if (! empty($this->withfromreadonly)) { $out.= ''; $out.= ''; @@ -302,7 +302,7 @@ class FormMail } // Replyto - if ($this->withreplyto) + if (! empty($this->withreplyto)) { if ($this->withreplytoreadonly) { @@ -314,7 +314,7 @@ class FormMail } // Errorsto - if ($this->witherrorsto) + if (! empty($this->witherrorsto)) { //if (! $this->errorstomail) $this->errorstomail=$this->frommail; $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); @@ -334,7 +334,7 @@ class FormMail } // To - if ($this->withto || is_array($this->withto)) + if (! empty($this->withto) || is_array($this->withto)) { $out.= '
'; if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); @@ -375,16 +375,16 @@ class FormMail } else { - if ($this->withtofree) + if (! empty($this->withtofree)) { $out.= 'withto) :"").'" />'; } - if (is_array($this->withto)) + if (! empty($this->withto) && is_array($this->withto)) { - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); } - if ($this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. { $liste=array(); $soc=new Societe($this->db); @@ -401,7 +401,7 @@ class FormMail } // CC - if ($this->withtocc || is_array($this->withtocc)) + if (! empty($this->withtocc) || is_array($this->withtocc)) { $out.= '
'; $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); @@ -413,12 +413,12 @@ class FormMail else { $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (is_array($this->withto)) + if (! empty($this->withto) && is_array($this->withto)) { $out.= " ".$langs->trans("or")." "; $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); } - if ($this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. { $liste=array(); $soc=new Societe($this->db); @@ -435,24 +435,24 @@ class FormMail } // CCC - if ($this->withtoccc || is_array($this->withtoccc)) + if (! empty($this->withtoccc) || is_array($this->withtoccc)) { $out.= '
'; $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out.= ''; - if ($this->withtocccreadonly) + if (! empty($this->withtocccreadonly)) { $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; } else { $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (is_array($this->withto)) + if (! empty($this->withto) && is_array($this->withto)) { $out.= " ".$langs->trans("or")." "; $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); } - if ($this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. { $liste=array(); $soc=new Societe($this->db); @@ -470,11 +470,11 @@ class FormMail } // Ask delivery receipt - if ($this->withdeliveryreceipt) + if (! empty($this->withdeliveryreceipt)) { $out.= '
'.$langs->trans("DeliveryReceipt").''; - if ($this->withdeliveryreceiptreadonly) + if (! empty($this->withdeliveryreceiptreadonly)) { $out.= yn($this->withdeliveryreceipt); } @@ -487,7 +487,7 @@ class FormMail } // Topic - if ($this->withtopic) + if (! empty($this->withtopic)) { $this->withtopic=make_substitutions($this->withtopic,$this->substit); @@ -507,7 +507,7 @@ class FormMail } // Attached files - if ($this->withfile) + if (! empty($this->withfile)) { $out.= '
'.$langs->trans("MailFile").'
'; $out.= 'withform) $out.= ''."\n"; + if (! empty($this->withform)) $out.= ''."\n"; $out.= "\n"; return $out; diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index f433374f83c..1eec9ff53be 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -207,19 +207,19 @@ function ajax_dialog($title,$message,$w=350,$h=150) */ function ajax_combobox($htmlname, $event=array()) { - $msg.= '