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

develop
This commit is contained in:
Laurent Destailleur 2022-03-31 16:26:36 +02:00
commit ea8bc86c9f
3 changed files with 50 additions and 24 deletions

View File

@ -966,7 +966,7 @@ class DoliDBMysqli extends DoliDB
public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name)
{
// phpcs:enable
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'";
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'";
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
$resql = $this->query($sql);
if (!$resql) {
@ -979,14 +979,14 @@ class DoliDBMysqli extends DoliDB
}
// Redo with localhost forced (sometimes user is created on %)
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost'";
$sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'@'localhost' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'";
$resql = $this->query($sql);
$sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'";
$sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."'";
dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log
$resql = $this->query($sql);
if (!$resql) {
$this->error = "Connected user not allowed to GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '*****'";
$this->error = "Connected user not allowed to GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."'";
return -1;
}

View File

@ -2265,7 +2265,7 @@ if ($action == 'create') {
print $numline;
print '</td>';
print '<td colspan="'.($colspan - 1).'" class="liste_titre">';
print '<td colspan="'.($colspan - 1).'" class="liste_titre"> ';
print '<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans("UploadANewFileNow");
print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly');
print '</a>';
@ -2493,6 +2493,8 @@ if ($action == 'create') {
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '</tr>';
print '<tr class="oddeven nohover">';
@ -2501,19 +2503,19 @@ if ($action == 'create') {
print '<td></td>';
// Select date
print '<td class="center">';
print '<td class="center inputdate">';
print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1);
print '</td>';
// Select project
if (!empty($conf->projet->enabled)) {
print '<td>';
print '<td class="inputproject">';
$formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
print '</td>';
}
// Select type
print '<td class="center">';
print '<td class="center inputtype">';
print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1);
print '</td>';
@ -2525,12 +2527,12 @@ if ($action == 'create') {
}
// Add comments
print '<td>';
print '<td class="inputcomment">';
print '<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.'">'.dol_escape_htmltag($comments, 0, 1).'</textarea>';
print '</td>';
// Select VAT
print '<td class="right">';
print '<td class="right inputvat">';
$defaultvat = -1;
if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none';
@ -2539,17 +2541,17 @@ if ($action == 'create') {
print '</td>';
// Unit price net
print '<td class="right">';
print '<td class="right inputpricenet">';
print '<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag($value_unit_ht).'"'.$taxlessUnitPriceDisabled.' />';
print '</td>';
// Unit price with tax
print '<td class="right">';
print '<td class="right inputtax">';
print '<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag($value_unit).'">';
print '</td>';
// Quantity
print '<td class="right">';
print '<td class="right inputqty">';
print '<input type="text" min="0" class="right maxwidth50" name="qty" value="'.dol_escape_htmltag($qty ? $qty : 1).'">'; // We must be able to enter decimal qty
print '</td>';
@ -2561,7 +2563,7 @@ if ($action == 'create') {
print '<td class="right"></td>';
}
print '<td class="center">';
print '<td class="center inputbuttons">';
print $form->buttonsSaveCancel("Add", '', '', 1);
print '</td>';

View File

@ -2048,7 +2048,7 @@ class ExpenseReport extends CommonObject
}
/**
* Update an expense report line
* Update an expense report line.
*
* @param int $rowid Line to edit
* @param int $type_fees_id Type payment
@ -2061,9 +2061,10 @@ class ExpenseReport extends CommonObject
* @param int $expensereport_id Expense report id
* @param int $fk_c_exp_tax_cat Id of category of car
* @param int $fk_ecm_files Id of ECM file to link to this expensereport line
* @param int $notrigger 1=No trigger
* @return int <0 if KO, >0 if OK
*/
public function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id, $fk_c_exp_tax_cat = 0, $fk_ecm_files = 0)
public function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id, $fk_c_exp_tax_cat = 0, $fk_ecm_files = 0, $notrigger = 0)
{
global $user, $mysoc;
@ -2153,9 +2154,19 @@ class ExpenseReport extends CommonObject
$this->applyOffset();
$this->checkRules();
$error = 0;
$result = $this->line->update($user);
if ($result > 0) {
if ($result > 0 && !$notrigger) {
// Call triggers
$result = $this->call_trigger('EXPENSE_REPORT_DET_UPDATE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if ($result > 0 && $error == 0) {
$this->db->commit();
return 1;
} else {
@ -2170,20 +2181,33 @@ class ExpenseReport extends CommonObject
/**
* deleteline
*
* @param int $rowid Row id
* @param User $fuser User
* @return int <0 if KO, >0 if OK
* @param int $rowid Row id
* @param User $fuser User
* @param int $notrigger 1=No trigger
* @return int <0 if KO, >0 if OK
*/
public function deleteline($rowid, $fuser = '')
public function deleteline($rowid, $fuser = '', $notrigger = 0)
{
$error=0;
$this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line;
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger('EXPENSE_REPORT_DET_DELETE', $fuser);
if ($result < 0) {
$error++;
}
// End call triggers
}
$sql = ' DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql .= ' WHERE rowid = '.((int) $rowid);
dol_syslog(get_class($this)."::deleteline sql=".$sql);
$result = $this->db->query($sql);
if (!$result) {
if (!$result || $error > 0 ) {
$this->error = $this->db->error();
dol_syslog(get_class($this)."::deleteline Error ".$this->error, LOG_ERR);
$this->db->rollback();