Fix for situation invoice (exclude credit not when searching last
invoice to use)
This commit is contained in:
parent
84ec747109
commit
47465f4108
@ -3146,10 +3146,10 @@ if ($action == 'create')
|
|||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
|
|
||||||
// Next situation invoice
|
// 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">';
|
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'))
|
if ($opt == ('<option value ="0" selected>'.$langs->trans('NoSituations').'</option>') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande'))
|
||||||
$tmp .= ' disabled';
|
$tmp .= ' disabled';
|
||||||
$tmp .= '> ';
|
$tmp .= '> ';
|
||||||
|
|||||||
@ -3804,14 +3804,15 @@ class Form
|
|||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture';
|
||||||
$sql .= ' WHERE entity IN ('.getEntity('invoice').')';
|
$sql .= ' WHERE entity IN ('.getEntity('invoice').')';
|
||||||
$sql .= ' AND situation_counter>=1';
|
$sql .= ' AND situation_counter>=1';
|
||||||
|
$sql .= ' AND fk_soc = '.(int) $socid;
|
||||||
|
$sql .= ' AND type <> 2';
|
||||||
$sql .= ' ORDER by situation_cycle_ref, situation_counter desc';
|
$sql .= ' ORDER by situation_cycle_ref, situation_counter desc';
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||||
// Last seen cycle
|
// Last seen cycle
|
||||||
$ref = 0;
|
$ref = 0;
|
||||||
while ($obj = $this->db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
//Same company ?
|
|
||||||
if ($socid == $obj->fk_soc) {
|
|
||||||
//Same cycle ?
|
//Same cycle ?
|
||||||
if ($obj->situation_cycle_ref != $ref) {
|
if ($obj->situation_cycle_ref != $ref) {
|
||||||
// Just seen this cycle
|
// Just seen this cycle
|
||||||
@ -3830,7 +3831,6 @@ class Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR);
|
dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user