Enhance skeleton

Add code_iso3 into array
This commit is contained in:
Laurent Destailleur 2014-08-13 19:19:36 +02:00
parent 6727385765
commit 454cb1cbf8
2 changed files with 41 additions and 22 deletions

View File

@ -70,17 +70,38 @@ if ($user->societe_id > 0)
if ($action == 'add')
{
$error=0;
$object=new Skeleton_Class($db);
$object->prop1=$_POST["field1"];
$object->prop2=$_POST["field2"];
$result=$object->create($user);
if ($result > 0)
/* object_prop_getpost_prop */
$object->prop1=GETPOST("field1");
$object->prop2=GETPOST("field2");
if (empty($object->ref))
{
// Creation OK
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors');
}
if (! $error)
{
// Creation KO
$mesg=$object->error;
$result=$object->create($user);
if ($result > 0)
{
// Creation OK
header("Location: ".dol_buildpath('/mymodule/list.php',1));
exit;
}
{
// Creation KO
if (! empty($object->errors)) setEventMessage($object->errors, 'errors');
else setEventMessage($object->error, 'errors');
$action='create';
}
}
else
{
$action='create';
}
}
@ -145,21 +166,18 @@ if ($action == 'list')
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
while ($i < $num)
{
while ($i < $num)
$obj = $db->fetch_object($resql);
if ($obj)
{
$obj = $db->fetch_object($resql);
if ($obj)
{
// You can use here results
print '<tr><td>';
print $obj->field1;
print $obj->field2;
print '</td></tr>';
}
$i++;
// You can use here results
print '<tr><td>';
print $obj->field1;
print $obj->field2;
print '</td></tr>';
}
$i++;
}
}
else

View File

@ -481,7 +481,7 @@ class Form
$countryArray=array();
$label=array();
$sql = "SELECT rowid, code as code_iso, libelle as label";
$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE active = 1";
//$sql.= " ORDER BY code ASC";
@ -502,6 +502,7 @@ class Form
$obj = $this->db->fetch_object($resql);
$countryArray[$i]['rowid'] = $obj->rowid;
$countryArray[$i]['code_iso'] = $obj->code_iso;
$countryArray[$i]['code_iso3'] = $obj->code_iso3;
$countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$label[$i] = dol_string_unaccent($countryArray[$i]['label']);
$i++;
@ -512,7 +513,7 @@ class Form
foreach ($countryArray as $row)
{
//print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].'<br>';
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) )
if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) )
{
$foundselected=true;
$out.= '<option value="'.$row['rowid'].'" selected="selected">';
@ -683,7 +684,7 @@ class Form
* @param int $forcecombo Force to use combo box
* @return string Return select box for thirdparty.
*/
function select_thirdparty($selected='', $htmlname='productid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0)
function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0)
{
global $langs,$conf;