diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 520fba66ce1..81a331add8a 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -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; } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 9d9eebae245..5ffef81e4c0 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2265,7 +2265,7 @@ if ($action == 'create') { print $numline; print ''; - print ''; + print ' '; print ''.$langs->trans("UploadANewFileNow"); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; @@ -2493,6 +2493,8 @@ if ($action == 'create') { print ''; print ''; print ''; + print ''; + print ''; print ''; print ''; @@ -2501,19 +2503,19 @@ if ($action == 'create') { print ''; // Select date - print ''; + print ''; print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1); print ''; // Select project if (!empty($conf->projet->enabled)) { - print ''; + print ''; $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; } // Select type - print ''; + print ''; print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1); print ''; @@ -2525,12 +2527,12 @@ if ($action == 'create') { } // Add comments - print ''; + print ''; print ''; print ''; // Select VAT - print ''; + print ''; $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 ''; // Unit price net - print ''; + print ''; print ''; print ''; // Unit price with tax - print ''; + print ''; print ''; print ''; // Quantity - print ''; + print ''; print ''; // We must be able to enter decimal qty print ''; @@ -2561,7 +2563,7 @@ if ($action == 'create') { print ''; } - print ''; + print ''; print $form->buttonsSaveCancel("Add", '', '', 1); print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f2f0b7dbf0d..18fe225599b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -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();