FIX Can't edit replacement invoice
FIX Status of invoice when making a replacement invoice
This commit is contained in:
parent
1cf3408f5b
commit
51456741d9
@ -3131,10 +3131,10 @@ if ($action == 'create')
|
|||||||
foreach ($facids as $facparam)
|
foreach ($facids as $facparam)
|
||||||
{
|
{
|
||||||
$options .= '<option value="'.$facparam ['id'].'"';
|
$options .= '<option value="'.$facparam ['id'].'"';
|
||||||
if ($facparam ['id'] == $_POST['fac_replacement'])
|
if ($facparam['id'] == $_POST['fac_replacement'])
|
||||||
$options .= ' selected';
|
$options .= ' selected';
|
||||||
$options .= '>'.$facparam ['ref'];
|
$options .= '>'.$facparam['ref'];
|
||||||
$options .= ' ('.$facturestatic->LibStatut(0, $facparam ['status']).')';
|
$options .= ' ('.$facturestatic->LibStatut($facparam['paid'], $facparam['status'], 0, $facparam['alreadypaid']).')';
|
||||||
$options .= '</option>';
|
$options .= '</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3937,17 +3937,19 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
$sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut,";
|
$sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut as status, f.paye as paid,";
|
||||||
$sql .= " ff.rowid as rowidnext";
|
$sql .= " ff.rowid as rowidnext";
|
||||||
|
//$sql .= ", SUM(pf.amount) as alreadypaid";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
|
||||||
$sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))";
|
$sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))";
|
||||||
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
||||||
$sql .= " AND f.paye = 0"; // Pas classee payee completement
|
$sql .= " AND f.paye = 0"; // Not paid completely
|
||||||
$sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
|
$sql .= " AND pf.fk_paiement IS NULL"; // No payment already done
|
||||||
$sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
|
$sql .= " AND ff.fk_statut IS NULL"; // Return true if it is not a replacement invoice
|
||||||
if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid;
|
if ($socid > 0) $sql .= " AND f.fk_soc = ".((int) $socid);
|
||||||
|
//$sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.paye, ff.rowid";
|
||||||
$sql .= " ORDER BY f.ref";
|
$sql .= " ORDER BY f.ref";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG);
|
dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG);
|
||||||
@ -3956,9 +3958,13 @@ class Facture extends CommonInvoice
|
|||||||
{
|
{
|
||||||
while ($obj = $this->db->fetch_object($resql))
|
while ($obj = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$return[$obj->rowid] = array('id' => $obj->rowid,
|
$return[$obj->rowid] = array(
|
||||||
|
'id' => $obj->rowid,
|
||||||
'ref' => $obj->ref,
|
'ref' => $obj->ref,
|
||||||
'status' => $obj->fk_statut);
|
'status' => $obj->status,
|
||||||
|
'paid' => $obj->paid,
|
||||||
|
'alreadypaid' => 0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//print_r($return);
|
//print_r($return);
|
||||||
return $return;
|
return $return;
|
||||||
|
|||||||
@ -109,9 +109,16 @@ $coldisplay++;
|
|||||||
$reshook = $hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action);
|
$reshook = $hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$situationinvoicelinewithparent = 0;
|
||||||
|
if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
|
||||||
|
if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
|
||||||
|
// Set constant to disallow editing during a situation cycle
|
||||||
|
$situationinvoicelinewithparent = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do not allow editing during a situation cycle
|
// Do not allow editing during a situation cycle
|
||||||
if ($line->fk_prev_id == null)
|
if (!$situationinvoicelinewithparent) {
|
||||||
{
|
|
||||||
// editor wysiwyg
|
// editor wysiwyg
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
$nbrows = ROWS_2;
|
$nbrows = ROWS_2;
|
||||||
@ -149,7 +156,7 @@ $coldisplay++;
|
|||||||
}
|
}
|
||||||
|
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
if ($line->fk_prev_id == null) {
|
if (!$situationinvoicelinewithparent) {
|
||||||
print '<td class="right">'.$form->load_tva('tva_tx', $line->tva_tx.($line->vat_src_code ? (' ('.$line->vat_src_code.')') : ''), $seller, $buyer, 0, $line->info_bits, $line->product_type, false, 1).'</td>';
|
print '<td class="right">'.$form->load_tva('tva_tx', $line->tva_tx.($line->vat_src_code ? (' ('.$line->vat_src_code.')') : ''), $seller, $buyer, 0, $line->info_bits, $line->product_type, false, 1).'</td>';
|
||||||
} else {
|
} else {
|
||||||
print '<td class="right"><input size="1" type="text" class="flat right" name="tva_tx" value="'.price($line->tva_tx).'" readonly />%</td>';
|
print '<td class="right"><input size="1" type="text" class="flat right" name="tva_tx" value="'.price($line->tva_tx).'" readonly />%</td>';
|
||||||
@ -157,7 +164,9 @@ $coldisplay++;
|
|||||||
|
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
print '<td class="right"><input type="text" class="flat right" size="5" id="price_ht" name="price_ht" value="'.(isset($line->pu_ht) ?price($line->pu_ht, 0, '', 0) : price($line->subprice, 0, '', 0)).'"';
|
print '<td class="right"><input type="text" class="flat right" size="5" id="price_ht" name="price_ht" value="'.(isset($line->pu_ht) ?price($line->pu_ht, 0, '', 0) : price($line->subprice, 0, '', 0)).'"';
|
||||||
if ($line->fk_prev_id != null) print ' readonly';
|
if ($situationinvoicelinewithparent) {
|
||||||
|
print ' readonly';
|
||||||
|
}
|
||||||
print '></td>';
|
print '></td>';
|
||||||
|
|
||||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
|
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
|
||||||
@ -176,12 +185,14 @@ $coldisplay++;
|
|||||||
<td class="right">
|
<td class="right">
|
||||||
<?php $coldisplay++;
|
<?php $coldisplay++;
|
||||||
if (($line->info_bits & 2) != 2) {
|
if (($line->info_bits & 2) != 2) {
|
||||||
// I comment this because it shows info even when not required
|
// I comment warning of stock because it shows the info even when it should not.
|
||||||
// for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
|
// for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
|
||||||
// must also not be output for most entities (proposal, intervention, ...)
|
// must also not be output for most entities (proposal, intervention, ...)
|
||||||
//if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
|
//if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
|
||||||
print '<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.$line->qty.'"';
|
print '<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.$line->qty.'"';
|
||||||
if ($line->fk_prev_id != null) print ' readonly';
|
if ($situationinvoicelinewithparent) { // Do not allow editing during a situation cycle
|
||||||
|
print ' readonly';
|
||||||
|
}
|
||||||
print '>';
|
print '>';
|
||||||
} else { ?>
|
} else { ?>
|
||||||
|
|
||||||
@ -202,7 +213,9 @@ $coldisplay++;
|
|||||||
<?php $coldisplay++;
|
<?php $coldisplay++;
|
||||||
if (($line->info_bits & 2) != 2) {
|
if (($line->info_bits & 2) != 2) {
|
||||||
print '<input size="1" type="text" class="flat right" name="remise_percent" id="remise_percent" value="'.$line->remise_percent.'"';
|
print '<input size="1" type="text" class="flat right" name="remise_percent" id="remise_percent" value="'.$line->remise_percent.'"';
|
||||||
if ($line->fk_prev_id != null) print ' readonly';
|
if ($situationinvoicelinewithparent) {
|
||||||
|
print ' readonly';
|
||||||
|
}
|
||||||
print '>%';
|
print '>%';
|
||||||
} else { ?>
|
} else { ?>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user