diff --git a/htdocs/lib/databases/mssql.lib.php b/htdocs/lib/databases/mssql.lib.php
index 31a6d7a82f4..f97ca4d8314 100644
--- a/htdocs/lib/databases/mssql.lib.php
+++ b/htdocs/lib/databases/mssql.lib.php
@@ -573,11 +573,16 @@ class DoliDb
*/
function last_insert_id($tab)
{
- return query("SELECT @@identity ");
-
- //return mssql_insert_id($this->db);
- }
-
+ $res = $this->query("SELECT @@IDENTITY as id");
+ if ($data = $this->fetch_array($res))
+ {
+ return $data["id"];
+ }
+ else
+ {
+ return -1;
+ }
+ }
// Next function are not required. Only minor features use them.
diff --git a/htdocs/soc.php b/htdocs/soc.php
index e66b8c2d5a6..f5c24ecc199 100644
--- a/htdocs/soc.php
+++ b/htdocs/soc.php
@@ -489,10 +489,10 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
print '';
print '
| '.$langs->trans("Type").' | '."\n";
- $form->select_array("typent_id",$soc->typent_array(1), $soc->typent_id);
+ $form->select_array("typent_id",$soc->typent_array(0), $soc->typent_id);
print ' | ';
print ''.$langs->trans("Staff").' | ';
- $form->select_array("effectif_id",$soc->effectif_array(1), $soc->effectif_id);
+ $form->select_array("effectif_id",$soc->effectif_array(0), $soc->effectif_id);
print ' |
';
// Assujeti TVA
@@ -828,10 +828,10 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
print '';
print '| '.$langs->trans("Type").' | ';
- $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id);
+ $form->select_array("typent_id",$soc->typent_array(0), $soc->typent_id);
print ' | ';
print ''.$langs->trans("Staff").' | ';
- $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
+ $form->select_array("effectif_id",$soc->effectif_array(0), $soc->effectif_id);
print ' |
';
print '| ';
diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php
index 0c1f5d4ec3b..930d028b3cd 100644
--- a/htdocs/societe.class.php
+++ b/htdocs/societe.class.php
@@ -1356,28 +1356,28 @@ class Societe
*/
function effectif_array($mode=0)
{
- $effs = array();
+ $effs = array();
- $sql = "SELECT id, code, libelle";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
- $sql .= " ORDER BY id ASC";
- if ($this->db->query($sql))
+ $sql = "SELECT id, code, libelle";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif";
+ $sql .= " ORDER BY id ASC";
+ if ($this->db->query($sql))
+ {
+ $num = $this->db->num_rows();
+ $i = 0;
+
+ while ($i < $num)
{
- $num = $this->db->num_rows();
- $i = 0;
+ $objp = $this->db->fetch_object();
+ if (! $mode) $key=$objp->id;
+ else $key=$objp->code;
- while ($i < $num)
- {
- $objp = $this->db->fetch_object();
- if (! $mode) $key=$objp->id;
- else $key=$objp->code;
-
- $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
- $i++;
- }
- $this->db->free();
+ $effs[$key] = $objp->libelle!='-'?$objp->libelle:'';
+ $i++;
}
- return $effs;
+ $this->db->free();
+ }
+ return $effs;
}
/**
|