Add country to resource
This commit is contained in:
parent
5a2fe13958
commit
6428c2157c
@ -574,3 +574,7 @@ ALTER TABLE llx_societe MODIFY COLUMN capital double(24,8);
|
|||||||
ALTER TABLE llx_tva MODIFY COLUMN amount double(24,8);
|
ALTER TABLE llx_tva MODIFY COLUMN amount double(24,8);
|
||||||
ALTER TABLE llx_subscription MODIFY COLUMN subscription double(24,8);
|
ALTER TABLE llx_subscription MODIFY COLUMN subscription double(24,8);
|
||||||
|
|
||||||
|
ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL;
|
||||||
|
ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country);
|
||||||
|
ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid);
|
||||||
|
|
||||||
|
|||||||
@ -18,3 +18,6 @@
|
|||||||
ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity);
|
ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity);
|
||||||
|
|
||||||
ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
|
ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
|
||||||
|
|
||||||
|
ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country);
|
||||||
|
ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid);
|
||||||
|
|||||||
1
htdocs/install/mysql/tables/llx_resource.sql
Executable file → Normal file
1
htdocs/install/mysql/tables/llx_resource.sql
Executable file → Normal file
@ -33,5 +33,6 @@ CREATE TABLE llx_resource
|
|||||||
note_private text,
|
note_private text,
|
||||||
import_key varchar(14),
|
import_key varchar(14),
|
||||||
extraparams varchar(255), -- for stock other parameters with json format
|
extraparams varchar(255), -- for stock other parameters with json format
|
||||||
|
fk_country integer DEFAULT NULL, -- Optional id of original country
|
||||||
tms timestamp
|
tms timestamp
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
// Load traductions files requiredby by page
|
// Load traductions files requiredby by page
|
||||||
@ -48,6 +49,7 @@ $ref = GETPOST('ref','alpha');
|
|||||||
$description = GETPOST('description');
|
$description = GETPOST('description');
|
||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm');
|
||||||
$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
|
$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
|
||||||
|
$country_id = GETPOST('country_id', 'int');
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
if ($user->socid > 0)
|
if ($user->socid > 0)
|
||||||
@ -111,6 +113,7 @@ if (empty($reshook))
|
|||||||
$object->ref = $ref;
|
$object->ref = $ref;
|
||||||
$object->description = $description;
|
$object->description = $description;
|
||||||
$object->fk_code_type_resource = $fk_code_type_resource;
|
$object->fk_code_type_resource = $fk_code_type_resource;
|
||||||
|
$object->country_id = $country_id;
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
@ -157,6 +160,7 @@ if (empty($reshook))
|
|||||||
$object->ref = $ref;
|
$object->ref = $ref;
|
||||||
$object->description = $description;
|
$object->description = $description;
|
||||||
$object->fk_code_type_resource = $fk_code_type_resource;
|
$object->fk_code_type_resource = $fk_code_type_resource;
|
||||||
|
$object->country_id = $country_id;
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
@ -271,6 +275,12 @@ if ($action == 'create' || $object->fetch($id) > 0)
|
|||||||
$doleditor->Create();
|
$doleditor->Create();
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Origin country
|
||||||
|
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
|
||||||
|
print $form->select_country($object->country_id,'country_id');
|
||||||
|
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('objectsrc' => $objectsrc);
|
$parameters=array('objectsrc' => $objectsrc);
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
@ -345,6 +355,14 @@ if ($action == 'create' || $object->fetch($id) > 0)
|
|||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Origin country code
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans("CountryOrigin").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print getCountry($object->country_id,0,$db);
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
@ -73,6 +73,7 @@ class Dolresource extends CommonObject
|
|||||||
|
|
||||||
if (isset($this->ref)) $this->ref=trim($this->ref);
|
if (isset($this->ref)) $this->ref=trim($this->ref);
|
||||||
if (isset($this->description)) $this->description=trim($this->description);
|
if (isset($this->description)) $this->description=trim($this->description);
|
||||||
|
if (!is_numeric($this->country_id)) $this->country_id = 0;
|
||||||
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
|
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
|
||||||
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
|
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
|
||||||
if (isset($this->note_private)) $this->note_private=trim($this->note_private);
|
if (isset($this->note_private)) $this->note_private=trim($this->note_private);
|
||||||
@ -84,6 +85,7 @@ class Dolresource extends CommonObject
|
|||||||
$sql.= "entity,";
|
$sql.= "entity,";
|
||||||
$sql.= "ref,";
|
$sql.= "ref,";
|
||||||
$sql.= "description,";
|
$sql.= "description,";
|
||||||
|
$sql.= "fk_country,";
|
||||||
$sql.= "fk_code_type_resource,";
|
$sql.= "fk_code_type_resource,";
|
||||||
$sql.= "note_public,";
|
$sql.= "note_public,";
|
||||||
$sql.= "note_private";
|
$sql.= "note_private";
|
||||||
@ -93,6 +95,7 @@ class Dolresource extends CommonObject
|
|||||||
$sql.= $conf->entity.", ";
|
$sql.= $conf->entity.", ";
|
||||||
$sql.= " ".(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").",";
|
$sql.= " ".(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").",";
|
||||||
$sql.= " ".(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").",";
|
$sql.= " ".(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").",";
|
||||||
|
$sql.= " ".($this->country_id > 0 ? $this->country_id : 'null').",";
|
||||||
$sql.= " ".(! isset($this->fk_code_type_resource)?'NULL':"'".$this->db->escape($this->fk_code_type_resource)."'").",";
|
$sql.= " ".(! isset($this->fk_code_type_resource)?'NULL':"'".$this->db->escape($this->fk_code_type_resource)."'").",";
|
||||||
$sql.= " ".(! isset($this->note_public)?'NULL':"'".$this->db->escape($this->note_public)."'").",";
|
$sql.= " ".(! isset($this->note_public)?'NULL':"'".$this->db->escape($this->note_public)."'").",";
|
||||||
$sql.= " ".(! isset($this->note_private)?'NULL':"'".$this->db->escape($this->note_private)."'");
|
$sql.= " ".(! isset($this->note_private)?'NULL':"'".$this->db->escape($this->note_private)."'");
|
||||||
@ -181,6 +184,7 @@ class Dolresource extends CommonObject
|
|||||||
$sql.= " t.entity,";
|
$sql.= " t.entity,";
|
||||||
$sql.= " t.ref,";
|
$sql.= " t.ref,";
|
||||||
$sql.= " t.description,";
|
$sql.= " t.description,";
|
||||||
|
$sql.= " t.fk_country,";
|
||||||
$sql.= " t.fk_code_type_resource,";
|
$sql.= " t.fk_code_type_resource,";
|
||||||
$sql.= " t.note_public,";
|
$sql.= " t.note_public,";
|
||||||
$sql.= " t.note_private,";
|
$sql.= " t.note_private,";
|
||||||
@ -203,6 +207,7 @@ class Dolresource extends CommonObject
|
|||||||
$this->entity = $obj->entity;
|
$this->entity = $obj->entity;
|
||||||
$this->ref = $obj->ref;
|
$this->ref = $obj->ref;
|
||||||
$this->description = $obj->description;
|
$this->description = $obj->description;
|
||||||
|
$this->country_id = $obj->fk_country;
|
||||||
$this->fk_code_type_resource = $obj->fk_code_type_resource;
|
$this->fk_code_type_resource = $obj->fk_code_type_resource;
|
||||||
$this->note_public = $obj->note_public;
|
$this->note_public = $obj->note_public;
|
||||||
$this->note_private = $obj->note_private;
|
$this->note_private = $obj->note_private;
|
||||||
@ -228,6 +233,7 @@ class Dolresource extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update object into database
|
* Update object into database
|
||||||
*
|
*
|
||||||
@ -244,6 +250,7 @@ class Dolresource extends CommonObject
|
|||||||
if (isset($this->ref)) $this->ref=trim($this->ref);
|
if (isset($this->ref)) $this->ref=trim($this->ref);
|
||||||
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
|
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
|
||||||
if (isset($this->description)) $this->description=trim($this->description);
|
if (isset($this->description)) $this->description=trim($this->description);
|
||||||
|
if (!is_numeric($this->country_id)) $this->country_id = 0;
|
||||||
|
|
||||||
if (empty($this->oldcopy))
|
if (empty($this->oldcopy))
|
||||||
{
|
{
|
||||||
@ -256,6 +263,7 @@ class Dolresource extends CommonObject
|
|||||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
|
||||||
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
|
||||||
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
||||||
|
$sql.= " fk_country=".($this->country_id > 0 ? $this->country_id :"null").",";
|
||||||
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
|
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
|
||||||
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null')."";
|
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null')."";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
@ -555,6 +563,7 @@ class Dolresource extends CommonObject
|
|||||||
$line->id = $obj->rowid;
|
$line->id = $obj->rowid;
|
||||||
$line->ref = $obj->ref;
|
$line->ref = $obj->ref;
|
||||||
$line->description = $obj->description;
|
$line->description = $obj->description;
|
||||||
|
$line->country_id = $obj->fk_country;
|
||||||
$line->fk_code_type_resource = $obj->fk_code_type_resource;
|
$line->fk_code_type_resource = $obj->fk_code_type_resource;
|
||||||
$line->type_label = $obj->type_label;
|
$line->type_label = $obj->type_label;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user