Fix for situation invoice (exclude credit not when searching last

invoice to use)
This commit is contained in:
Laurent Destailleur 2020-05-25 00:20:00 +02:00
parent 84ec747109
commit 47465f4108
2 changed files with 17 additions and 17 deletions

View File

@ -3146,10 +3146,10 @@ if ($action == 'create')
print '</div></div>';
// Next situation invoice
$opt = $form->selectSituationInvoices(GETPOST('originid'), $socid);
$opt = $form->selectSituationInvoices(GETPOST('originid', 'int'), $socid);
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp = '<input type="radio" name="type" value="5"'.(GETPOST('type') == 5 && GETPOST('originid') ? ' checked' : '');
$tmp = '<input type="radio" name="type" value="5"'.(GETPOST('type') == 5 && GETPOST('originid', 'int') ? ' checked' : '');
if ($opt == ('<option value ="0" selected>'.$langs->trans('NoSituations').'</option>') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande'))
$tmp .= ' disabled';
$tmp .= '> ';

View File

@ -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 .= '<option value="'.$obj->rowid.'" selected>'.$obj->ref.'</option>';
} else {
$opt .= '<option value="'.$obj->rowid.'">'.$obj->ref.'</option>';
}
//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 .= '<option value="'.$obj->rowid.'" selected>'.$obj->ref.'</option>';
} else {
$opt .= '<option value="'.$obj->rowid.'">'.$obj->ref.'</option>';
}
}
}