mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 15:42:29 +01:00
Qual: Clean code
Perf: Country id+code is now stored into MAIN_INFO_SOCIETE_PAYS instead of only id. This avoid a select to finf country code at each request.
This commit is contained in:
@@ -881,7 +881,7 @@ if ($action == 'create')
|
||||
$adh->fk_departement = $_POST["departement_id"];
|
||||
|
||||
// We set pays_id, pays_code and label for the selected country
|
||||
$adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
$adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||
if ($adh->pays_id)
|
||||
{
|
||||
$sql = "SELECT rowid, code, libelle";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -193,7 +193,7 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
}
|
||||
|
||||
// On positionne pays_id, pays_code et libelle du pays choisi
|
||||
$address->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
$address->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||
if ($address->pays_id)
|
||||
{
|
||||
$sql = "SELECT code, libelle";
|
||||
@@ -296,7 +296,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
$address->address = $_POST["address"];
|
||||
$address->zip = $_POST["zip"];
|
||||
$address->ville = $_POST["ville"];
|
||||
$address->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
$address->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||
$address->tel = $_POST["tel"];
|
||||
$address->fax = $_POST["fax"];
|
||||
$address->note = $_POST["note"];
|
||||
|
||||
@@ -276,7 +276,7 @@ if ($user->rights->societe->contact->creer)
|
||||
$contact->fk_departement = $_POST["departement_id"];
|
||||
|
||||
// We set pays_id, pays_code and label for the selected country
|
||||
$contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
$contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||
if ($contact->fk_pays)
|
||||
{
|
||||
$sql = "SELECT code, libelle";
|
||||
|
||||
@@ -228,7 +228,7 @@ class FormCompany
|
||||
// Affiche la rupture si on est en mode liste multipays
|
||||
if (! $pays_code && $obj->code_pays)
|
||||
{
|
||||
print '<option value="-1">----- '.$obj->libelle_pays." -----</option>\n";
|
||||
print '<option value="-1" disabled="true">----- '.$obj->libelle_pays." -----</option>\n";
|
||||
$pays=$obj->libelle_pays;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,6 @@ function getCountry($id,$withcode=0)
|
||||
{
|
||||
global $db,$langs;
|
||||
|
||||
// TODO Optimize: Try to translate and make SQL request only if it fails
|
||||
$sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
|
||||
if (is_numeric($id)) $sql.= " WHERE rowid=".$id;
|
||||
else $sql.= " WHERE code='".$id."'";
|
||||
|
||||
@@ -244,6 +244,19 @@ function dol_mimetype($file,$default='application/octet-stream',$shortmime=0)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if filename is a directory
|
||||
* \param folder Name of folder
|
||||
* \return boolean True if it's a directory, False if not found
|
||||
*/
|
||||
function dol_is_dir($folder)
|
||||
{
|
||||
$newfolder=dol_osencode($folder);
|
||||
if (is_dir($newfolder)) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if a folder is empty
|
||||
* \param folder Name of folder
|
||||
|
||||
@@ -569,6 +569,17 @@ function getIntegerInString(str,i,minlength,maxlength)
|
||||
}
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Purpose: Clean string to have it url encoded
|
||||
Input: s
|
||||
Author: Laurent Destailleur
|
||||
Licence: GPL
|
||||
==================================================================*/
|
||||
function urlencode(s) {
|
||||
return s.replace(/\+/gi,'%2B');
|
||||
}
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Purpose: Show a popup HTML page.
|
||||
Input: url,title
|
||||
@@ -767,3 +778,5 @@ function uncheckBox(boxId) {
|
||||
elementId.checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -669,9 +669,6 @@ dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]);
|
||||
//Another call for easy debugg
|
||||
//dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST));
|
||||
|
||||
// For backward compatibility
|
||||
if (! defined('MAIN_INFO_SOCIETE_PAYS')) define('MAIN_INFO_SOCIETE_PAYS','1');
|
||||
|
||||
// Load main languages files
|
||||
if (! defined('NOREQUIRETRAN'))
|
||||
{
|
||||
|
||||
@@ -362,7 +362,7 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
|
||||
}
|
||||
else // For backward compatibility
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');
|
||||
$pays_code=getCountry($pays_id,2); // This need a SQL request, but it's the old feature
|
||||
$pays_label=getCountry($pays_id,0); // This need a SQL request, but it's the old feature
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
$soc->default_lang=$_POST["default_lang"];
|
||||
|
||||
// We set pays_id, pays_code and label for the selected country
|
||||
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||
if ($soc->pays_id)
|
||||
{
|
||||
$sql = "SELECT code, libelle";
|
||||
@@ -802,7 +802,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
$soc->address=$_POST["adresse"];
|
||||
$soc->cp=$_POST["cp"];
|
||||
$soc->ville=$_POST["ville"];
|
||||
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
|
||||
$soc->departement_id=$_POST["departement_id"];
|
||||
$soc->tel=$_POST["tel"];
|
||||
$soc->fax=$_POST["fax"];
|
||||
|
||||
Reference in New Issue
Block a user