select bank and payment mode for social contrib
This commit is contained in:
parent
e08ac03618
commit
77071ca515
@ -166,10 +166,12 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
||||
|
||||
// Social contributions
|
||||
$sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr";
|
||||
$sql3.= ", cs.fk_account";
|
||||
$sql3.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id";
|
||||
$sql3.= " WHERE cs.entity = ".$conf->entity;
|
||||
$sql3.= " AND cs.paye = 0"; // Not paid
|
||||
$sql3.= " AND (cs.fk_account IN (0, ".$acct->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution
|
||||
$sql3.= " ORDER BY dlr ASC";
|
||||
|
||||
$error=0;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
@ -159,6 +160,8 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
$charge = new ChargeSociales($db);
|
||||
$charge->fetch($chid);
|
||||
$charge->accountid=$charge->fk_account?$charge->fk_account:$charge->accountid;
|
||||
$charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype;
|
||||
|
||||
$total = $charge->amount;
|
||||
|
||||
@ -178,16 +181,16 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
dol_fiche_head('', '');
|
||||
|
||||
print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("SocialContribution")."</td>";
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("SocialContribution")."</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid.'">'.$chid.'</a></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Type")."</td><td colspan=\"2\">".$charge->type_libelle."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Period")."</td><td colspan=\"2\">".dol_print_date($charge->periode,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$charge->lib."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("DateDue")."</td><td colspan=\"2\">".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Amount")."</td><td colspan=\"2\">".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid.'">'.$chid.'</a></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Type")."</td><td>".$charge->type_libelle."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->lib."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
$sql = "SELECT sum(p.amount) as total";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
|
||||
@ -199,28 +202,28 @@ if ($_GET["action"] == 'create')
|
||||
$sumpaid = $obj->total;
|
||||
$db->free();
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td colspan="2">'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("RemainderToPay").'</td><td colspan="2">'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print "<td colspan=\"3\">".$langs->trans("Payment").'</td>';
|
||||
print "<td colspan=\"2\">".$langs->trans("Payment").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
|
||||
$form->select_date($datepayment,'','','','',"add_payment",1,1);
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
$form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype");
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
||||
print '<td colspan="2">';
|
||||
print '<td>';
|
||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list
|
||||
print '</td></tr>';
|
||||
|
||||
@ -228,11 +231,11 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td colspan="2"><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
|
||||
print '<td><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top">'.$langs->trans("Comments").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '<td valign="top"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
@ -71,6 +72,23 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) {
|
||||
}
|
||||
}
|
||||
|
||||
// payment mode
|
||||
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// bank account
|
||||
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
|
||||
$object->fetch($id);
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Delete social contribution
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||
{
|
||||
@ -127,6 +145,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
|
||||
$object->date_ech=$dateech;
|
||||
$object->periode=$dateperiod;
|
||||
$object->amount=$amount;
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
|
||||
$id=$object->create($user);
|
||||
if ($id <= 0)
|
||||
@ -290,6 +310,17 @@ if ($action == 'create')
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="6" name="amount" class="flat" value="'.GETPOST('amount').'"></td>';
|
||||
print '</tr>';
|
||||
// Payment Mode
|
||||
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
|
||||
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
|
||||
print '</td></tr>';
|
||||
// Bank Account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
|
||||
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Date due
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
@ -313,7 +344,7 @@ if ($action == 'create')
|
||||
|
||||
/* *************************************************************************** */
|
||||
/* */
|
||||
/* Mode fiche */
|
||||
/* Card Mode */
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
if ($id > 0)
|
||||
@ -382,7 +413,8 @@ if ($id > 0)
|
||||
// Type
|
||||
print "<tr><td>".$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
|
||||
|
||||
$rowspan=5;
|
||||
$rowspan=6;
|
||||
if (! empty($conf->banque->enabled)) $rowspan++;
|
||||
print '<td rowspan="'.$rowspan.'" valign="top">';
|
||||
|
||||
/*
|
||||
@ -422,8 +454,8 @@ if ($id > 0)
|
||||
print "<tr ".$bc[$var]."><td>";
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
||||
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
|
||||
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
|
||||
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
|
||||
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
|
||||
print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->currency)."</td>\n";
|
||||
print "</tr>";
|
||||
$totalpaye += $objp->amount;
|
||||
@ -432,12 +464,12 @@ if ($id > 0)
|
||||
|
||||
if ($object->paye == 0)
|
||||
{
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
|
||||
$resteapayer = $object->amount - $totalpaye;
|
||||
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
@ -486,6 +518,42 @@ if ($id > 0)
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
}
|
||||
|
||||
// Mode of payment
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($action != 'editmode')
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editmode') {
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
|
||||
} else {
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank Account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editbankaccount') {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
|
||||
} else {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
|
||||
|
||||
@ -500,7 +568,7 @@ if ($id > 0)
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($action == 'edit') print "</form>\n";
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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
|
||||
@ -49,6 +50,7 @@ class ChargeSociales extends CommonObject
|
||||
var $date_creation;
|
||||
var $date_modification;
|
||||
var $date_validation;
|
||||
var $fk_account;
|
||||
|
||||
|
||||
/**
|
||||
@ -71,13 +73,16 @@ class ChargeSociales extends CommonObject
|
||||
*/
|
||||
function fetch($id, $ref='')
|
||||
{
|
||||
$sql = "SELECT cs.rowid, cs.date_ech,";
|
||||
$sql.= " cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, cs.periode, cs.import_key,";
|
||||
$sql.= " c.libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs, ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||
$sql.= " WHERE cs.fk_type = c.id";
|
||||
if ($ref) $sql.= " AND cs.rowid = ".$ref;
|
||||
else $sql.= " AND cs.rowid = ".$id;
|
||||
$sql = "SELECT cs.rowid, cs.date_ech";
|
||||
$sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, cs.periode, cs.import_key";
|
||||
$sql.= ", cs.fk_account, cs.fk_mode_reglement";
|
||||
$sql.= ", c.libelle";
|
||||
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id';
|
||||
if ($ref) $sql.= " WHERE cs.rowid = ".$ref;
|
||||
else $sql.= " WHERE cs.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -93,6 +98,10 @@ class ChargeSociales extends CommonObject
|
||||
$this->lib = $obj->lib;
|
||||
$this->type = $obj->fk_type;
|
||||
$this->type_libelle = $obj->libelle;
|
||||
$this->fk_account = $obj->fk_account;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->mode_reglement_code = $obj->mode_reglement_code;
|
||||
$this->mode_reglement = $obj->mode_reglement_libelle;
|
||||
$this->amount = $obj->amount;
|
||||
$this->paye = $obj->paye;
|
||||
$this->periode = $this->db->jdate($obj->periode);
|
||||
@ -155,8 +164,11 @@ class ChargeSociales extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount, entity)";
|
||||
$sql.= " VALUES (".$this->type.",'".$this->db->escape($this->lib)."',";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, entity)";
|
||||
$sql.= " VALUES (".$this->type;
|
||||
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
|
||||
$sql.= ", ".($this->mode_reglement_id>0?"'".$this->mode_reglement_id."'":"NULL");
|
||||
$sql.= ", '".$this->db->escape($this->lib)."',";
|
||||
$sql.= " '".$this->db->idate($this->date_ech)."','".$this->db->idate($this->periode)."',";
|
||||
$sql.= " '".price2num($newamount)."',";
|
||||
$sql.= " ".$conf->entity;
|
||||
@ -216,7 +228,7 @@ class ChargeSociales extends CommonObject
|
||||
// Delete payments
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge where fk_charge='".$this->id."'";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge='".$this->id."'";
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
@ -228,7 +240,7 @@ class ChargeSociales extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$this->id."'";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid='".$this->id."'";
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user