Update for fk_country
This commit is contained in:
parent
ca0c68a8e2
commit
e157d8b8d2
@ -182,9 +182,11 @@ class Establishment extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function fetch($id)
|
function fetch($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, name, address, zip, town, status";
|
$sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id,";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."establishment";
|
$sql.= ' c.code as country_code, c.label as country';
|
||||||
$sql.= " WHERE rowid = ".$id;
|
$sql.= " FROM ".MAIN_DB_PREFIX."establishment as e";
|
||||||
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON e.fk_country = c.rowid';
|
||||||
|
$sql.= " WHERE e.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -199,6 +201,10 @@ class Establishment extends CommonObject
|
|||||||
$this->town = $obj->town;
|
$this->town = $obj->town;
|
||||||
$this->status = $obj->status;
|
$this->status = $obj->status;
|
||||||
|
|
||||||
|
$this->country_id = $obj->country_id;
|
||||||
|
$this->country_code = $obj->country_code;
|
||||||
|
$this->country = $obj->country;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -357,4 +363,22 @@ class Establishment extends CommonObject
|
|||||||
if ($withpicto != 2) $result.=$link.$this->name.$linkend;
|
if ($withpicto != 2) $result.=$link.$this->name.$linkend;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return account country code
|
||||||
|
*
|
||||||
|
* @return string country code
|
||||||
|
*/
|
||||||
|
function getCountryCode()
|
||||||
|
{
|
||||||
|
global $mysoc;
|
||||||
|
|
||||||
|
// We return country code of bank account
|
||||||
|
if (! empty($this->country_code)) return $this->country_code;
|
||||||
|
|
||||||
|
// We return country code of managed company
|
||||||
|
if (! empty($mysoc->country_code)) return $mysoc->country_code;
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,8 +84,6 @@ else if ($action == 'add')
|
|||||||
$object->address = GETPOST('address', 'alpha');
|
$object->address = GETPOST('address', 'alpha');
|
||||||
$object->zip = GETPOST('zipcode', 'alpha');
|
$object->zip = GETPOST('zipcode', 'alpha');
|
||||||
$object->town = GETPOST('town', 'alpha');
|
$object->town = GETPOST('town', 'alpha');
|
||||||
$object->country_id = GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
|
|
||||||
$object->country_id = $object->country_id?$object->country_id:$mysoc->country_id;
|
|
||||||
$object->country_id = $_POST["country_id"];
|
$object->country_id = $_POST["country_id"];
|
||||||
$object->status = GETPOST('status','int');
|
$object->status = GETPOST('status','int');
|
||||||
$object->fk_user_author = $user->id;
|
$object->fk_user_author = $user->id;
|
||||||
@ -135,7 +133,7 @@ else if ($action == 'update')
|
|||||||
$object->address = GETPOST('address', 'alpha');
|
$object->address = GETPOST('address', 'alpha');
|
||||||
$object->zip = GETPOST('zipcode', 'alpha');
|
$object->zip = GETPOST('zipcode', 'alpha');
|
||||||
$object->town = GETPOST('town', 'alpha');
|
$object->town = GETPOST('town', 'alpha');
|
||||||
$object->country_id = GETPOST('country_id', 'int');
|
$object->country_id = $_POST["country_id"];
|
||||||
$object->fk_user_mod = $user->id;
|
$object->fk_user_mod = $user->id;
|
||||||
|
|
||||||
$result = $object->update();
|
$result = $object->update();
|
||||||
@ -364,7 +362,14 @@ else if ($id)
|
|||||||
// Country
|
// Country
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans("Country").'</td>';
|
print '<td>'.$langs->trans("Country").'</td>';
|
||||||
print '<td colspan="2">'.getCountry($object->fk_country,1).'</td>';
|
print '<td colspan="2">';
|
||||||
|
if ($object->country_id > 0)
|
||||||
|
{
|
||||||
|
$img=picto_from_langcode($object->country_code);
|
||||||
|
print $img?$img.' ':'';
|
||||||
|
print getCountry($object->getCountryCode(),0,$db);
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user