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

This commit is contained in:
Laurent Destailleur 2021-03-01 19:42:10 +01:00
commit 5e4b18ca4d
5 changed files with 76 additions and 21 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -70,6 +70,8 @@ class PaymentVarious extends CommonObject
public $amount; public $amount;
public $type_payment; public $type_payment;
public $num_payment; public $num_payment;
public $chqemetteur;
public $chqbank;
public $category_transaction; public $category_transaction;
/** /**
@ -424,7 +426,7 @@ class PaymentVarious extends CommonObject
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
return -6; return -6;
} }
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) if (!empty($conf->banque->enabled) && (empty($this->type_payment)))
{ {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7; return -7;
@ -499,8 +501,8 @@ class PaymentVarious extends CommonObject
$this->num_payment, $this->num_payment,
($this->category_transaction > 0 ? $this->category_transaction : 0), ($this->category_transaction > 0 ? $this->category_transaction : 0),
$user, $user,
'', $this->chqemetteur,
'', $this->chqbank,
'', '',
$this->datev $this->datev
); );

View File

@ -49,7 +49,7 @@ $accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0;
$label = GETPOST("label", "alpha"); $label = GETPOST("label", "alpha");
$sens = GETPOST("sens", "int"); $sens = GETPOST("sens", "int");
$amount = price2num(GETPOST("amount", "alpha")); $amount = price2num(GETPOST("amount", "alpha"));
$paymenttype = GETPOST("paymenttype", "int"); $paymenttype = GETPOST("paymenttype", "aZ09");
$accountancy_code = GETPOST("accountancy_code", "alpha"); $accountancy_code = GETPOST("accountancy_code", "alpha");
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
if (!empty($conf->accounting->enabled) && !empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { if (!empty($conf->accounting->enabled) && !empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
@ -113,8 +113,10 @@ if (empty($reshook))
$object->amount = price2num(GETPOST("amount", 'alpha')); $object->amount = price2num(GETPOST("amount", 'alpha'));
$object->label = GETPOST("label", 'restricthtml'); $object->label = GETPOST("label", 'restricthtml');
$object->note = GETPOST("note", 'restricthtml'); $object->note = GETPOST("note", 'restricthtml');
$object->type_payment = GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0; $object->type_payment = dol_getIdFromCode($db, GETPOST('paymenttype'), 'c_paiement', 'code', 'id', 1);
$object->num_payment = GETPOST("num_payment", 'alpha'); $object->num_payment = GETPOST("num_payment", 'alpha');
$object->chqemetteur = GETPOST("chqemetteur", 'alpha');
$object->chqbank = GETPOST("chqbank", 'alpha');
$object->fk_user_author = $user->id; $object->fk_user_author = $user->id;
$object->category_transaction = GETPOST("category_transaction", 'alpha'); $object->category_transaction = GETPOST("category_transaction", 'alpha');
@ -345,6 +347,43 @@ foreach ($bankcateg->fetchAll() as $bankcategory) {
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create')
{ {
// Update fields properties in realtime
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
setPaymentType();
$("#selectpaymenttype").change(function() {
setPaymentType();
});
function setPaymentType()
{
var code = $("#selectpaymenttype option:selected").val();
if (code == \'CHQ\' || code == \'VIR\')
{
if (code == \'CHQ\')
{
$(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
}
if ($(\'#fieldchqemetteur\').val() == \'\')
{
var emetteur = jQuery(\'#thirdpartylabel\').val();
$(\'#fieldchqemetteur\').val(emetteur);
}
}
else
{
$(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
$(\'#fieldchqemetteur\').val(\'\');
}
}
';
print ' });'."\n";
print ' </script>'."\n";
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
@ -390,20 +429,28 @@ if ($action == 'create')
} }
// Type payment // Type payment
print '<tr><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>'; $form->select_types_paiements($paymenttype, 'paymenttype', '', 2);
$form->select_types_paiements($paymenttype, "paymenttype"); print "</td>\n";
print '</td></tr>'; print '</tr>';
// Number // Number
if (!empty($conf->banque->enabled)) print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
{ print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
// Number print '</label></td>';
print '<tr><td><label for="num_payment">'.$langs->trans('Numero'); print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</label></td>'; // Check transmitter
print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n"; print '<tr><td class="'.(GETPOST('paymenttype') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn"><label for="fieldchqemetteur">'.$langs->trans('CheckTransmitter');
} print ' <em>('.$langs->trans("ChequeMaker").')</em>';
print '</label></td>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="30" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
// Bank name
print '<tr><td><label for="chqbank">'.$langs->trans('Bank');
print ' <em>('.$langs->trans("ChequeBank").')</em>';
print '</label></td>';
print '<td><input id="chqbank" name="chqbank" size="30" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
// Accountancy account // Accountancy account
if (!empty($conf->accounting->enabled)) { if (!empty($conf->accounting->enabled)) {

View File

@ -7133,7 +7133,7 @@ class Form
'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
'contrat'=>array('enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract', 'contrat'=>array('enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract',
'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'),
'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'),
@ -7206,7 +7206,12 @@ class Form
print '</td>'; print '</td>';
print '<td class="center">'.$objp->ref.'</td>'; print '<td class="center">'.$objp->ref.'</td>';
print '<td>'.$objp->ref_client.'</td>'; print '<td>'.$objp->ref_client.'</td>';
print '<td class="right">'.price($objp->total_ht).'</td>'; print '<td class="right">';
if ($possiblelink[label] == 'LinkToContract') {
$form = new Form($db);
print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' ';
}
print price($objp->total_ht).'</td>';
print '<td>'.$objp->name.'</td>'; print '<td>'.$objp->name.'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;

View File

@ -1115,3 +1115,4 @@ EventReminder=Event Reminder
UpdateForAllLines=Update for all lines UpdateForAllLines=Update for all lines
OnHold=On hold OnHold=On hold
Civility=Civility Civility=Civility
InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration.

View File

@ -362,7 +362,7 @@ foreach ($search as $key => $val)
} }
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
//if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2); if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2);
if ($search_date_start) $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'"; if ($search_date_start) $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'";
if ($search_date_end) $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'"; if ($search_date_end) $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'";
if ($search_dateread_start) $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'"; if ($search_dateread_start) $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'";