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

This commit is contained in:
Laurent Destailleur 2022-05-24 16:28:32 +02:00
commit ab40634dcb
14 changed files with 52 additions and 35 deletions

View File

@ -1857,7 +1857,7 @@ class BookKeeping extends CommonObject
$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;

View File

@ -121,7 +121,7 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->
$usercancreateorder = $user->rights->commande->creer;
$usercancreateinvoice = $user->rights->facture->creer;
$usercancreatecontract = $user->rights->contrat->creer;
$usercancreateintervention = $user->rights->ficheinter->creer;
$usercancreateintervention = empty($conf->ficheinter->enabled) ? 0 : $user->rights->ficheinter->creer;
$usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php

View File

@ -2525,7 +2525,7 @@ if ($action == 'create' && $usercancreate) {
}
// Create intervention
if ($conf->ficheinter->enabled) {
if (!empty($conf->ficheinter->enabled)) {
$langs->load("interventions");
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {

View File

@ -131,7 +131,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes
}
foreach ($listofoppcode as $rowid => $code) {
$dataseries[] = array(
'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_category', 'code', 'label', $code),
'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_type', 'code', 'label', $code),
'data' => (empty($data[$code]) ? 0 : $data[$code])
);
}

View File

@ -152,7 +152,7 @@ class box_graph_ticket_by_severity extends ModeleBoxes
}
foreach ($listofoppcode as $rowid => $code) {
$dataseries[] = array(
'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_category', 'code', 'label', $code),
'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_severity', 'code', 'label', $code),
'data' => (empty($data[$code]) ? 0 : $data[$code])
);
}

View File

@ -6760,7 +6760,7 @@ abstract class CommonObject
$out .= '</select>';
} elseif ($type == 'checkbox') {
$value_arr = explode(',', $value);
$out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
$out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, $morecss, 0, '100%');
} elseif ($type == 'radio') {
$out = '';
foreach ($param['options'] as $keyopt => $val) {
@ -7503,14 +7503,16 @@ abstract class CommonObject
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring);
}
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(12, 0, 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
$datekey = $keyprefix.'options_'.$key.$keysuffix;
$value = (GETPOSTISSET($datekey)) ? dol_mktime(12, 0, 0, GETPOST($datekey.'month', 'int', 3), GETPOST($datekey.'day', 'int', 3), GETPOST($datekey.'year', 'int', 3)) : $datenotinstring;
}
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime'))) {
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring);
}
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."sec", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3), 'tzuserrel') : $datenotinstring;
$timekey = $keyprefix.'options_'.$key.$keysuffix;
$value = (GETPOSTISSET($timekey)) ? dol_mktime(GETPOST($timekey.'hour', 'int', 3), GETPOST($timekey.'min', 'int', 3), GETPOST($timekey.'sec', 'int', 3), GETPOST($timekey.'month', 'int', 3), GETPOST($timekey.'day', 'int', 3), GETPOST($timekey.'year', 'int', 3), 'tzuserrel') : $datenotinstring;
}
// Convert float submited string into real php numeric (value in memory must be a php numeric)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) {
@ -7518,7 +7520,7 @@ abstract class CommonObject
}
// HTML, text, select, integer and varchar: take into account default value in database if in create mode
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int'))) {
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int', 'boolean'))) {
if ($action == 'create') {
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? $value : $extrafields->attributes[$this->table_element]['default'][$key];
}

View File

@ -2154,7 +2154,7 @@ function dol_bc($var, $moreclass = '')
*/
function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0, $extralangcode = '')
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$ret = '';
$countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
@ -2220,6 +2220,14 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
$langs->load("dict");
$ret .= (empty($object->country_code) ? '' : ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)));
}
if ($hookmanager) {
$parameters = array('withcountry' => $withcountry, 'sep' => $sep, 'outputlangs' => $outputlangs,'mode' => $mode, 'extralangcode' => $extralangcode);
$reshook = $hookmanager->executeHooks('formatAddress', $parameters, $object);
if ($reshook > 0) {
$ret = '';
}
$ret .= $hookmanager->resPrint;
}
return $ret;
}

View File

@ -423,7 +423,7 @@ class modRecruitment extends DolibarrModules
$sql = array();
// Document template
$moduledir = 'mymodule';
$moduledir = 'recruitment';
$myTmpObjects = array();
$myTmpObjects['RecruitmentJobPosition'] = array('includerefgeneration'=>1, 'includedocgeneration'=>1);
@ -431,10 +431,10 @@ class modRecruitment extends DolibarrModules
if ($myTmpObjectKey == 'MyObject') {
continue;
}
if ($myTmpObjectArray['includerefgeneration']) {
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
$dirodt = DOL_DATA_ROOT.'/doctemplates/mymodule';
$dest = $dirodt.'/template_myobjects.odt';
if ($myTmpObjectArray['includedocgeneration']) {
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_recruitmentjobposition.odt';
$dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir;
$dest = $dirodt.'/template_recruitmentjobposition.odt';
if (file_exists($src) && !file_exists($dest)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -450,8 +450,6 @@ class modRecruitment extends DolibarrModules
$sql = array_merge($sql, array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")",
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")"
));
}
}

View File

@ -523,9 +523,9 @@ class pdf_squille extends ModelePdfReception
while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
if ($pagenb == 1) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
@ -534,9 +534,9 @@ class pdf_squille extends ModelePdfReception
}
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
if ($pagenb == 1) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
@ -550,10 +550,10 @@ class pdf_squille extends ModelePdfReception
// Show square
if ($pagenb == 1) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
@ -719,9 +719,10 @@ class pdf_squille extends ModelePdfReception
* @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @param Object|NULL $object Object reception to generate
* @return void
*/
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
{
global $conf;
@ -767,7 +768,18 @@ class pdf_squille extends ModelePdfReception
$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C');
$statusreceived = Reception::STATUS_CLOSED;
if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
$statusreceived = Reception::STATUS_VALIDATED;
}
if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
$statusreceived = Reception::STATUS_CLOSED;
}
if ($object && $object->statut < $statusreceived) {
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyToReceive'), '', 'C');
} else {
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyReceived'), '', 'C');
}
}
if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {

View File

@ -166,7 +166,7 @@ if ($action == 'add') {
// on récupère les enregistrements
$object->fetch($id);
$res = $object->fetch_lines();
// on transfert les données de l'un vers l'autre
if ($object->socid > 0) {
$newinter->socid = $object->socid;
@ -178,6 +178,7 @@ if ($action == 'add') {
$newinter->entity = $object->entity;
$newinter->duree = $object->duree;
$newinter->datei = $object->date;
$newinter->description = $object->description;
$newinter->note_private = $object->note_private;
@ -194,7 +195,7 @@ if ($action == 'add') {
if ($newfichinterid > 0) {
// Now we add line of details
foreach ($object->lines as $line) {
$newinter->addline($user, $newfichinterid, $line->desc, '', $line->duree, '');
$newinter->addline($user, $newfichinterid, $line->desc, $line->datei, $line->duree, '');
}
// on update le nombre d'inter crée à partir du modèle
@ -743,7 +744,7 @@ if ($action == 'create') {
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=createfrommodel&token='.newToken().'';
print '&socid='.$object->thirdparty->id.'&id='.$object->id.'">';
print $langs->trans("CreateFichInter").'</a></div>';
print $langs->trans("AddIntervention").'</a></div>';
}
if ($user->rights->ficheinter->supprimer) {

View File

@ -1347,7 +1347,6 @@ class Fichinter extends CommonObject
$line->fetch_optionals();
$this->lines[$i] = $line;
$i++;
}
$this->db->free($resql);

View File

@ -349,7 +349,7 @@ class FichinterRec extends Fichinter
{
// phpcs:enable
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, ';
$sql .= ' l.price, l.qty, l.tva_tx, l.remise, l.remise_percent, l.subprice, l.duree, ';
$sql .= ' l.price, l.qty, l.tva_tx, l.remise, l.remise_percent, l.subprice, l.duree, l.date, ';
$sql .= ' l.total_ht, l.total_tva, l.total_ttc,';
$sql .= ' l.rang, l.special_code,';
$sql .= ' l.fk_unit, p.ref as product_ref, p.fk_product_type as fk_product_type,';
@ -366,7 +366,6 @@ class FichinterRec extends Fichinter
while ($i < $num) {
$objp = $this->db->fetch_object($result);
$line = new FichinterLigne($this->db);
$line->id = $objp->rowid;
$line->label = $objp->custom_label; // Label line
$line->desc = $objp->description; // Description line
@ -386,8 +385,6 @@ class FichinterRec extends Fichinter
$line->fk_product = $objp->fk_product;
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
$line->date_start = $objp->date_start;
$line->date_end = $objp->date_end;
$line->info_bits = $objp->info_bits;
$line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva;

View File

@ -51,7 +51,7 @@ abstract class ModelePDFRecruitmentCandidature extends CommonDocGenerator
// phpcs:enable
global $conf;
$type = 'recruitmentjobposition';
$type = 'recruitmentjobcandidature';
$list = array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -1047,7 +1047,7 @@ if ($action == 'create' || $action == 'presend') {
print '</tr>';
// Timing (Duration sum of linked fichinter)
if ($conf->ficheinter->enabled) {
if (!empty($conf->ficheinter->enabled)) {
$object->fetchObjectLinked();
$num = count($object->linkedObjects);
$timing = 0;