diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d7ac591755a..b7cfb8272d1 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3146,10 +3146,10 @@ if ($action == 'create') print ''; // Next situation invoice - $opt = $form->selectSituationInvoices(GETPOST('originid'), $socid); + $opt = $form->selectSituationInvoices(GETPOST('originid', 'int'), $socid); print '
'; - $tmp = ''.$langs->trans('NoSituations').'') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) $tmp .= ' disabled'; $tmp .= '> '; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d7e46922f56..622ffb1d127 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3804,27 +3804,27 @@ class Form $sql .= ' FROM '.MAIN_DB_PREFIX.'facture'; $sql .= ' WHERE entity IN ('.getEntity('invoice').')'; $sql .= ' AND situation_counter>=1'; + $sql .= ' AND fk_soc = '.(int) $socid; + $sql .= ' AND type <> 2'; $sql .= ' ORDER by situation_cycle_ref, situation_counter desc'; $resql = $this->db->query($sql); + if ($resql && $this->db->num_rows($resql) > 0) { // Last seen cycle $ref = 0; while ($obj = $this->db->fetch_object($resql)) { - //Same company ? - if ($socid == $obj->fk_soc) { - //Same cycle ? - if ($obj->situation_cycle_ref != $ref) { - // Just seen this cycle - $ref = $obj->situation_cycle_ref; - //not final ? - if ($obj->situation_final != 1) { - //Not prov? - if (substr($obj->ref, 1, 4) != 'PROV') { - if ($selected == $obj->rowid) { - $opt .= ''; - } else { - $opt .= ''; - } + //Same cycle ? + if ($obj->situation_cycle_ref != $ref) { + // Just seen this cycle + $ref = $obj->situation_cycle_ref; + //not final ? + if ($obj->situation_final != 1) { + //Not prov? + if (substr($obj->ref, 1, 4) != 'PROV') { + if ($selected == $obj->rowid) { + $opt .= ''; + } else { + $opt .= ''; } } }