Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into 14.0

Conflicts:
	htdocs/compta/facture/card.php
	htdocs/compta/facture/class/facture.class.php
	htdocs/core/tpl/objectline_edit.tpl.php
This commit is contained in:
Laurent Destailleur 2021-06-30 15:06:16 +02:00
commit 7c2121c439
3 changed files with 32 additions and 18 deletions

View File

@ -3296,11 +3296,11 @@ if ($action == 'create') {
if (is_array($facids)) {
foreach ($facids as $facparam) {
$options .= '<option value="'.$facparam ['id'].'"';
if ($facparam ['id'] == $_POST['fac_replacement']) {
if ($facparam['id'] == GETPOST('fac_replacement', 'int')) {
$options .= ' selected';
}
$options .= '>'.$facparam ['ref'];
$options .= ' ('.$facturestatic->LibStatut(0, $facparam ['status']).')';
$options .= '>'.$facparam['ref'];
$options .= ' ('.$facturestatic->LibStatut($facparam['paid'], $facparam['status'], 0, $facparam['alreadypaid']).')';
$options .= '</option>';
}
}

View File

@ -4090,8 +4090,8 @@ class Facture extends CommonInvoice
* Invoices matching the following rules are returned:
* (Status validated or abandonned for a reason 'other') + not payed + no payment at all + not already replaced
*
* @param int $socid Id thirdparty
* @return array|int Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1)
* @param int $socid Id thirdparty
* @return array|int Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1)
*/
public function list_replacable_invoices($socid = 0)
{
@ -4100,28 +4100,34 @@ class Facture extends CommonInvoice
$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 .= ", SUM(pf.amount) as alreadypaid";
$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."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 .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND f.paye = 0"; // Pas classee payee completement
$sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
$sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
$sql .= " AND f.paye = 0"; // Not paid completely
$sql .= " AND pf.fk_paiement IS NULL"; // No payment already done
$sql .= " AND ff.fk_statut IS NULL"; // Return true if it is not a replacement invoice
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";
dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$return[$obj->rowid] = array('id' => $obj->rowid,
'ref' => $obj->ref,
'status' => $obj->fk_statut);
$return[$obj->rowid] = array(
'id' => $obj->rowid,
'ref' => $obj->ref,
'status' => $obj->status,
'paid' => $obj->paid,
'alreadypaid' => 0
);
}
//print_r($return);
return $return;

View File

@ -130,8 +130,16 @@ $coldisplay++;
$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
if ($line->fk_prev_id == null) {
if (!$situationinvoicelinewithparent) {
// editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows = ROWS_2;
@ -181,7 +189,7 @@ $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>';
} else {
print '<td class="right"><input size="1" type="text" class="flat right" name="tva_tx" value="'.price($line->tva_tx).'" readonly />%</td>';
@ -189,7 +197,7 @@ $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)).'"';
if ($line->fk_prev_id != null) {
if ($situationinvoicelinewithparent) {
print ' readonly';
}
print '></td>';
@ -211,12 +219,12 @@ $coldisplay++;
<td class="right">
<?php $coldisplay++;
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
// 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;"')." ";
print '<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.$line->qty.'"';
if ($line->fk_prev_id != null) {
if ($situationinvoicelinewithparent) { // Do not allow editing during a situation cycle
print ' readonly';
}
print '>';
@ -249,7 +257,7 @@ $coldisplay++;
<?php $coldisplay++;
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.'"';
if ($line->fk_prev_id != null) {
if ($situationinvoicelinewithparent) {
print ' readonly';
}
print '>%';