Merge pull request #8181 from ATM-Nicolas/new_charges_sociales_trigger

NEW Call to trigger on social contribution creation
This commit is contained in:
Laurent Destailleur 2018-02-14 20:49:31 +01:00 committed by GitHub
commit f8f4d5caac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View File

@ -156,6 +156,7 @@ class ChargeSociales extends CommonObject
function create($user)
{
global $conf;
$error=0;
$now=dol_now();
@ -191,8 +192,17 @@ class ChargeSociales extends CommonObject
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales");
//dol_syslog("ChargesSociales::create this->id=".$this->id);
$this->db->commit();
return $this->id;
$result=$this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE',$user);
if ($result < 0) $error++;
if(empty($error)) {
$this->db->commit();
return $this->id;
}
else {
$this->db->rollback();
return -1*$error;
}
}
else
{

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -50,10 +51,22 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td>
<td align="center"><?php echo dol_print_date($objectlink->date_contrat,'day'); ?></td>
<td align="right"><?php // var_dump($objectlink->total_ttc); ?></td>
<td align="right"><?php
// Price of contract is not shown by default because a contract is a list of service with
// start and end date that change with time andd that may be different that the period of reference for price.
// So price of a contract does often means nothing. Prices is on the different invoices done on same contract.
if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE))
{
$totalcontrat = 0;
foreach ($objectlink->lines as $linecontrat) {
$totalcontrat = $totalcontrat + $linecontrat->total_ht;
$total = $total + $linecontrat->total_ht;
}
echo price($totalcontrat);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(7); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
</tr>
<?php } ?>
<!-- END PHP TEMPLATE -->
<!-- END PHP TEMPLATE -->