New : allow to edit social contribution amount
This commit is contained in:
parent
2547d96ffd
commit
db4bbf46fc
@ -77,8 +77,10 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
|
|||||||
// Add social contribution
|
// Add social contribution
|
||||||
if ($action == 'add' && $user->rights->tax->charges->creer)
|
if ($action == 'add' && $user->rights->tax->charges->creer)
|
||||||
{
|
{
|
||||||
$dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
$dateech=@dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
|
||||||
$dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
$dateperiod=@dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
|
||||||
|
$amount=GETPOST('amount');
|
||||||
|
$actioncode=GETPOST('actioncode');
|
||||||
if (! $dateech)
|
if (! $dateech)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
|
||||||
@ -89,12 +91,12 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
|||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
elseif (! $_POST["actioncode"] > 0)
|
elseif (! $actioncode > 0)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")), 'errors');
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
elseif (! $_POST["amount"])
|
elseif (empty($amount))
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors');
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
@ -103,11 +105,11 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
|||||||
{
|
{
|
||||||
$chargesociales=new ChargeSociales($db);
|
$chargesociales=new ChargeSociales($db);
|
||||||
|
|
||||||
$chargesociales->type=$_POST["actioncode"];
|
$chargesociales->type=$actioncode;
|
||||||
$chargesociales->lib=$_POST["label"];
|
$chargesociales->lib=GETPOST('label');
|
||||||
$chargesociales->date_ech=$dateech;
|
$chargesociales->date_ech=$dateech;
|
||||||
$chargesociales->periode=$dateperiod;
|
$chargesociales->periode=$dateperiod;
|
||||||
$chargesociales->amount=$_POST["amount"];
|
$chargesociales->amount=price2num($amount);
|
||||||
|
|
||||||
$id=$chargesociales->create($user);
|
$id=$chargesociales->create($user);
|
||||||
if ($id <= 0)
|
if ($id <= 0)
|
||||||
@ -120,32 +122,39 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
|||||||
|
|
||||||
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
||||||
{
|
{
|
||||||
$dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
|
||||||
$dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
|
||||||
if (! $dateech)
|
$amount=GETPOST('amount');
|
||||||
{
|
if (! $dateech)
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
|
{
|
||||||
$action = 'edit';
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
|
||||||
}
|
$action = 'edit';
|
||||||
elseif (! $dateperiod)
|
}
|
||||||
{
|
elseif (! $dateperiod)
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
|
{
|
||||||
$action = 'edit';
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
|
||||||
}
|
$action = 'edit';
|
||||||
|
}
|
||||||
|
elseif (empty($amount))
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors');
|
||||||
|
$action = 'edit';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$chargesociales=new ChargeSociales($db);
|
$chargesociales=new ChargeSociales($db);
|
||||||
$result=$chargesociales->fetch($_GET["id"]);
|
$result=$chargesociales->fetch($id);
|
||||||
|
|
||||||
$chargesociales->lib=$_POST["label"];
|
$chargesociales->lib=GETPOST('label');
|
||||||
$chargesociales->date_ech=$dateech;
|
$chargesociales->date_ech=$dateech;
|
||||||
$chargesociales->periode=$dateperiod;
|
$chargesociales->periode=$dateperiod;
|
||||||
|
$chargesociales->amount=price2num($amount);
|
||||||
|
|
||||||
$result=$chargesociales->update($user);
|
$result=$chargesociales->update($user);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
setEventMessage($chargesociales->error, 'errors');
|
setEventMessage($chargesociales->error, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +446,15 @@ if ($id > 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
if ($action == 'edit')
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
|
||||||
|
print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
|
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
|
||||||
|
|||||||
@ -266,7 +266,8 @@ class ChargeSociales extends CommonObject
|
|||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
|
||||||
$sql.= " SET libelle='".$this->db->escape($this->lib)."',";
|
$sql.= " SET libelle='".$this->db->escape($this->lib)."',";
|
||||||
$sql.= " date_ech='".$this->db->idate($this->date_ech)."',";
|
$sql.= " date_ech='".$this->db->idate($this->date_ech)."',";
|
||||||
$sql.= " periode='".$this->db->idate($this->periode)."'";
|
$sql.= " periode='".$this->db->idate($this->periode)."',";
|
||||||
|
$sql.= " amount='".price2num($this->amount,'MT')."'";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user