add trigger update and delete on expense report det
add class name on card.php expensereport
This commit is contained in:
parent
038033f0ec
commit
732b1ab548
@ -2265,7 +2265,7 @@ if ($action == 'create') {
|
|||||||
print $numline;
|
print $numline;
|
||||||
print '</td>';
|
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 '<a href="" class="commonlink auploadnewfilenow reposition">'.$langs->trans("UploadANewFileNow");
|
||||||
print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly');
|
print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
@ -2387,6 +2387,7 @@ if ($action == 'create') {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -2501,19 +2502,19 @@ if ($action == 'create') {
|
|||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
|
|
||||||
// Select date
|
// Select date
|
||||||
print '<td class="center">';
|
print '<td class="center inputdate">';
|
||||||
print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1);
|
print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Select project
|
// Select project
|
||||||
if (!empty($conf->projet->enabled)) {
|
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');
|
$formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select type
|
// Select type
|
||||||
print '<td class="center">';
|
print '<td class="center inputtype">';
|
||||||
print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1);
|
print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
@ -2525,12 +2526,12 @@ if ($action == 'create') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add comments
|
// 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 '<textarea class="flat_ndf centpercent" name="comments" rows="'.ROWS_2.'">'.dol_escape_htmltag($comments, 0, 1).'</textarea>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Select VAT
|
// Select VAT
|
||||||
print '<td class="right">';
|
print '<td class="right inputvat">';
|
||||||
$defaultvat = -1;
|
$defaultvat = -1;
|
||||||
if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
|
if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
|
||||||
$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none';
|
$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none';
|
||||||
@ -2539,17 +2540,17 @@ if ($action == 'create') {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Unit price net
|
// 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 '<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag($value_unit_ht).'"'.$taxlessUnitPriceDisabled.' />';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Unit price with tax
|
// 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 '<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag($value_unit).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Quantity
|
// 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 '<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>';
|
print '</td>';
|
||||||
|
|
||||||
@ -2561,7 +2562,7 @@ if ($action == 'create') {
|
|||||||
print '<td class="right"></td>';
|
print '<td class="right"></td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center inputbuttons">';
|
||||||
print $form->buttonsSaveCancel("Add", '', '', 1);
|
print $form->buttonsSaveCancel("Add", '', '', 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
|||||||
@ -2063,7 +2063,7 @@ class ExpenseReport extends CommonObject
|
|||||||
* @param int $fk_ecm_files Id of ECM file to link to this expensereport line
|
* @param int $fk_ecm_files Id of ECM file to link to this expensereport line
|
||||||
* @return int <0 if KO, >0 if OK
|
* @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;
|
global $user, $mysoc;
|
||||||
|
|
||||||
@ -2153,9 +2153,19 @@ class ExpenseReport extends CommonObject
|
|||||||
|
|
||||||
$this->applyOffset();
|
$this->applyOffset();
|
||||||
$this->checkRules();
|
$this->checkRules();
|
||||||
|
$error = 0;
|
||||||
$result = $this->line->update($user);
|
$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();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@ -2174,16 +2184,29 @@ class ExpenseReport extends CommonObject
|
|||||||
* @param User $fuser User
|
* @param User $fuser User
|
||||||
* @return int <0 if KO, >0 if OK
|
* @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();
|
$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);
|
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::deleteline sql=".$sql);
|
dol_syslog(get_class($this)."::deleteline sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (!$result) {
|
|
||||||
|
if (!$result || $error > 0 ) {
|
||||||
$this->error = $this->db->error();
|
$this->error = $this->db->error();
|
||||||
dol_syslog(get_class($this)."::deleteline Error ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::deleteline Error ".$this->error, LOG_ERR);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user