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

This commit is contained in:
Laurent Destailleur 2021-06-13 16:16:17 +02:00
commit 172f1b5260
6 changed files with 46 additions and 18 deletions

View File

@ -4250,7 +4250,7 @@ class Facture extends CommonInvoice
$generic_facture->statut = $obj->fk_statut;
$response->nbtodo++;
$response->total += $obj->total;
$response->total += $obj->total_ht;
if ($generic_facture->hasDelay()) {
$response->nbtodolate++;

View File

@ -48,7 +48,7 @@ class ModelePDFCards
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public function liste_modeles($db, $maxfilenamelength = 0)
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;

View File

@ -120,8 +120,36 @@ class modFacture extends DolibarrModules
$arraydate = dol_getdate(dol_now());
$datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array(
0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart),
1=>array('label'=>'SendEmailsRemindersOnInvoiceDueDate', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture.class.php', 'objectname'=>'Facture', 'method'=>'sendEmailsRemindersOnInvoiceDueDate', 'parameters'=>"10,all,EmailTemplateCode", 'comment'=>'Send an emails when the unpaid invoices reach a due date + n days = today. First param is the offset n of days, second parameter is "all" or a payment mode code, last paramater is the code of email template to use (an email template with EmailTemplateCode must exists. the version in the language of the thirdparty will be used in priority).', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart),
0 => array(
'label'=>'RecurringInvoices',
'jobtype'=>'method',
'class'=>'compta/facture/class/facture-rec.class.php',
'objectname'=>'FactureRec',
'method'=>'createRecurringInvoices',
'parameters'=>'',
'comment'=>'Generate recurring invoices',
'frequency'=>1,
'unitfrequency'=>3600 * 24,
'priority'=>50,
'status'=>1,
'test'=>'$conf->facture->enabled',
'datestart'=>$datestart
),
1 => array(
'label'=>'SendEmailsRemindersOnInvoiceDueDate',
'jobtype'=>'method',
'class'=>'compta/facture/class/facture.class.php',
'objectname'=>'Facture',
'method'=>'sendEmailsRemindersOnInvoiceDueDate',
'parameters'=>"10,all,EmailTemplateCode",
'comment'=>'Send an emails when the unpaid invoices reach a due date + n days = today. First param is the offset n of days, second parameter is "all" or a payment mode code, last paramater is the code of email template to use (an email template with EmailTemplateCode must exists. the version in the language of the thirdparty will be used in priority).',
'frequency'=>1,
'unitfrequency'=>3600 * 24,
'priority'=>50,
'status'=>0,
'test'=>'$conf->facture->enabled',
'datestart'=>$datestart
),
);
// Permissions

View File

@ -2691,14 +2691,14 @@ class Product extends CommonObject
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
$sql .= " WHERE ";
$sql .= " b.entity IN (".getEntity('bom').")";
$sql .= " AND b.fk_product =".$this->id;
$sql .= " AND b.fk_product =".((int) $this->id);
$sql .= " GROUP BY b.rowid";
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
$this->stats_bom['nb_toproduce'] = $obj->nb_toproduce ? $obj->nb_toproduce : 0;
$this->stats_bom['qty_toproduce'] = $obj->qty_toproduce ? price2num($obj->qty_toproduce) : 0;
$this->stats_bom['nb_toproduce'] = !empty($obj->nb_toproduce) ? $obj->nb_toproduce : 0;
$this->stats_bom['qty_toproduce'] = !empty($obj->qty_toproduce) ? price2num($obj->qty_toproduce) : 0;
} else {
$this->error = $this->db->error();
$error++;
@ -2710,13 +2710,13 @@ class Product extends CommonObject
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
$sql .= " WHERE ";
$sql .= " b.entity IN (".getEntity('bom').")";
$sql .= " AND bl.fk_product =".$this->id;
$sql .= " AND bl.fk_product =".((int) $this->id);
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
$this->stats_bom['nb_toconsume'] = $obj->nb_toconsume ? $obj->nb_toconsume : 0;
$this->stats_bom['qty_toconsume'] = $obj->qty_toconsume ? price2num($obj->qty_toconsume) : 0;
$this->stats_bom['nb_toconsume'] = !empty($obj->nb_toconsume) ? $obj->nb_toconsume : 0;
$this->stats_bom['qty_toconsume'] = !empty($obj->qty_toconsume) ? price2num($obj->qty_toconsume) : 0;
} else {
$this->error = $this->db->error();
$error++;

View File

@ -1265,8 +1265,8 @@ if ($resql) {
$product_static->id = $obj->rowid;
$product_static->ref = $obj->ref;
$product_static->ref_fourn = $obj->ref_supplier; // deprecated
$product_static->ref_supplier = $obj->ref_supplier;
$product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated
$product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier;
$product_static->label = $obj->label;
$product_static->finished = $obj->finished;
$product_static->type = $obj->fk_product_type;

View File

@ -765,19 +765,19 @@ foreach ($object->fields as $key => $val) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
if ($key == 'type_code') {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
$formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
$formTicket->selectTypesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
print '</td>';
} elseif ($key == 'category_code') {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
$formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
$formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
print '</td>';
} elseif ($key == 'severity_code') {
print '<td class="liste_titre center'.($cssforfield ? ' '.$cssforfield : '').'">';
$formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
$formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
print '</td>';
} elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth125'));
print $form->select_dolusers((empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth125'));
print '</td>';
} elseif ($key == 'fk_statut') {
$arrayofstatus = array();
@ -791,7 +791,7 @@ foreach ($object->fields as $key => $val) {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
//var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key]));
$selectedarray = null;
if ($search[$key]) {
if (!empty($search[$key])) {
$selectedarray = array_values($search[$key]);
}
print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth100 maxwidth150', 1, 0, '', '', '');
@ -832,7 +832,7 @@ foreach ($object->fields as $key => $val) {
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
}
print '</td>';
}