Update work on donation
This commit is contained in:
parent
4e83952485
commit
e6d9d18f25
@ -32,7 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||||
if (! empty($conf->projet->enabled)) {
|
if (! empty($conf->projet->enabled))
|
||||||
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
}
|
}
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
@ -99,7 +100,7 @@ if ($action == 'update')
|
|||||||
$object->email = GETPOST("email");
|
$object->email = GETPOST("email");
|
||||||
$object->date = $donation_date;
|
$object->date = $donation_date;
|
||||||
$object->public = GETPOST("public");
|
$object->public = GETPOST("public");
|
||||||
$object->fk_project = GETPOST("projectid");
|
$object->fk_project = GETPOST("fk_project");
|
||||||
$object->note_private= GETPOST("note_private");
|
$object->note_private= GETPOST("note_private");
|
||||||
$object->note_public = GETPOST("note_public");
|
$object->note_public = GETPOST("note_public");
|
||||||
|
|
||||||
@ -334,9 +335,8 @@ if ($action == 'create')
|
|||||||
|
|
||||||
$formproject=new FormProjets($db);
|
$formproject=new FormProjets($db);
|
||||||
|
|
||||||
// Si module projet actif
|
|
||||||
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
||||||
$formproject->select_projects('',GETPOST("projectid"),"projectid");
|
$formproject->select_projects(-1, GETPOST("fk_project"),'fk_project', 0, 1, 0, 1);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ if (! empty($id) && $action == 'edit')
|
|||||||
|
|
||||||
$langs->load('projects');
|
$langs->load('projects');
|
||||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||||
$formproject->select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid');
|
$formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 1, 0, 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,10 @@ if (! empty($id) && $action != 'edit')
|
|||||||
// Project
|
// Project
|
||||||
if (! empty($conf->projet->enabled))
|
if (! empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
print "<tr>".'<td>'.$langs->trans("Project").'</td><td>'.$object->projet.'</td></tr>';
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans("Project").'</td>';
|
||||||
|
print '<td>'.$object->projet.'</td>';
|
||||||
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
@ -567,22 +570,6 @@ if (! empty($id) && $action != 'edit')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// Classify paid
|
|
||||||
if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))
|
|
||||||
|| ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid">'.$langs->trans('ClassifyPaid').'</a></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit payment
|
|
||||||
if ($object->statut == 1 && $object->paid == 0 && ((price2num($object->amount) > 0 && round($remaintopay) > 0)) && $user->rights->don->creer)
|
|
||||||
{
|
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/dons/payment.php?rowid='.$object->id.'&action=create">'.$langs->trans("DoPayment").'</a></div>';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Classify 'paid'
|
// Classify 'paid'
|
||||||
if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
|
if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
|
||||||
{
|
{
|
||||||
@ -625,6 +612,5 @@ if (! empty($id) && $action != 'edit')
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
@ -332,7 +332,7 @@ class Don extends CommonObject
|
|||||||
// $sql.= ", country"; -- Deprecated
|
// $sql.= ", country"; -- Deprecated
|
||||||
$sql.= ", fk_country";
|
$sql.= ", fk_country";
|
||||||
$sql.= ", public";
|
$sql.= ", public";
|
||||||
$sql.= ", fk_don_projet";
|
$sql.= ", fk_project";
|
||||||
$sql.= ", note_private";
|
$sql.= ", note_private";
|
||||||
$sql.= ", note_public";
|
$sql.= ", note_public";
|
||||||
$sql.= ", fk_user_author";
|
$sql.= ", fk_user_author";
|
||||||
@ -415,7 +415,7 @@ class Don extends CommonObject
|
|||||||
$sql .= ",town='".$this->db->escape($this->town)."'";
|
$sql .= ",town='".$this->db->escape($this->town)."'";
|
||||||
$sql .= ",fk_country = ".$this->country_id;
|
$sql .= ",fk_country = ".$this->country_id;
|
||||||
$sql .= ",public=".$this->public;
|
$sql .= ",public=".$this->public;
|
||||||
$sql .= ",fk_don_projet=".($this->fk_project>0?$this->fk_project:'null');
|
$sql .= ",fk_project=".($this->fk_project>0?$this->fk_project:'null');
|
||||||
$sql .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
|
$sql .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
|
||||||
$sql .= ",note_public=".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
|
$sql .= ",note_public=".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
|
||||||
$sql .= ",datedon='".$this->db->idate($this->date)."'";
|
$sql .= ",datedon='".$this->db->idate($this->date)."'";
|
||||||
@ -498,11 +498,11 @@ class Don extends CommonObject
|
|||||||
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
|
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
|
||||||
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
|
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
|
||||||
$sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
|
$sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
|
||||||
$sql.= " d.phone_mobile, d.fk_don_projet,";
|
$sql.= " d.phone_mobile, d.fk_project,";
|
||||||
$sql.= " p.title as project_label,";
|
$sql.= " p.title as project_label,";
|
||||||
$sql.= " c.code as country_code, c.label as country";
|
$sql.= " c.code as country_code, c.label as country";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
|
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_don_projet";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_project";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
|
||||||
$sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity;
|
$sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity;
|
||||||
@ -535,8 +535,8 @@ class Don extends CommonObject
|
|||||||
$this->email = $obj->email;
|
$this->email = $obj->email;
|
||||||
$this->phone = $obj->phone;
|
$this->phone = $obj->phone;
|
||||||
$this->phone_mobile = $obj->phone_mobile;
|
$this->phone_mobile = $obj->phone_mobile;
|
||||||
$this->projet = $obj->project_label;
|
$this->project = $obj->project_label;
|
||||||
$this->fk_project = $obj->fk_don_projet;
|
$this->fk_project = $obj->fk_project;
|
||||||
$this->public = $obj->public;
|
$this->public = $obj->public;
|
||||||
$this->modepaymentid = $obj->fk_payment;
|
$this->modepaymentid = $obj->fk_payment;
|
||||||
$this->modepayment = $obj->libelle;
|
$this->modepayment = $obj->libelle;
|
||||||
|
|||||||
@ -33,6 +33,7 @@ class PaymentDonation extends CommonObject
|
|||||||
public $table_element='payment_donation'; //!< Name of table without prefix where object is stored
|
public $table_element='payment_donation'; //!< Name of table without prefix where object is stored
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
|
var $rowid;
|
||||||
var $ref;
|
var $ref;
|
||||||
|
|
||||||
var $fk_donation;
|
var $fk_donation;
|
||||||
@ -74,7 +75,7 @@ class PaymentDonation extends CommonObject
|
|||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (! $this->datepaye)
|
if (! $this->datepaid)
|
||||||
{
|
{
|
||||||
$this->error='ErrorBadValueForParameterCreatePaymentDonation';
|
$this->error='ErrorBadValueForParameterCreatePaymentDonation';
|
||||||
return -1;
|
return -1;
|
||||||
@ -110,7 +111,7 @@ class PaymentDonation extends CommonObject
|
|||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,";
|
||||||
$sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
|
$sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
|
||||||
$sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
$sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||||
$sql.= " '".$this->db->idate($this->datepaye)."',";
|
$sql.= " '".$this->db->idate($this->datepaid)."',";
|
||||||
$sql.= " ".$totalamount.",";
|
$sql.= " ".$totalamount.",";
|
||||||
$sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
|
$sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
|
||||||
$sql.= " 0)";
|
$sql.= " 0)";
|
||||||
@ -485,7 +486,7 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
// Insert payment into llx_bank
|
// Insert payment into llx_bank
|
||||||
$bank_line_id = $acc->addline(
|
$bank_line_id = $acc->addline(
|
||||||
$this->datepaye,
|
$this->datepaid,
|
||||||
$this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
|
$this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
|
||||||
$label,
|
$label,
|
||||||
$total,
|
$total,
|
||||||
@ -496,7 +497,7 @@ class PaymentDonation extends CommonObject
|
|||||||
$emetteur_banque
|
$emetteur_banque
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mise a jour fk_bank dans llx_paiement.
|
// Update fk_bank in llx_paiement.
|
||||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0)
|
||||||
{
|
{
|
||||||
@ -509,7 +510,7 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
// Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
|
// Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
|
||||||
$url='';
|
$url='';
|
||||||
if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id=';
|
if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/compta/dons/card.php?rowid=';
|
||||||
if ($url)
|
if ($url)
|
||||||
{
|
{
|
||||||
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
||||||
@ -520,15 +521,15 @@ class PaymentDonation extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
|
// Add link 'thirdparty' in bank_url between donation and bank transaction (for each donation concerned by payment)
|
||||||
$linkaddedforthirdparty=array();
|
$linkaddedforthirdparty=array();
|
||||||
foreach ($this->amounts as $key => $value)
|
foreach ($this->amounts as $key => $value)
|
||||||
{
|
{
|
||||||
if ($mode == 'payment_sc')
|
if ($mode == 'payment_donation')
|
||||||
{
|
{
|
||||||
$socialcontrib = new ChargeSociales($this->db);
|
$don = new Don($this->db);
|
||||||
$socialcontrib->fetch($key);
|
$don->fetch($key);
|
||||||
$result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc');
|
$result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/compta/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'sc');
|
||||||
if ($result <= 0) dol_print_error($this->db);
|
if ($result <= 0) dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,14 +55,14 @@ if ($action == 'add_payment')
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||||
|
|
||||||
if (! $_POST["paymenttype"] > 0)
|
if (! $_POST["paymenttype"] > 0)
|
||||||
{
|
{
|
||||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if ($datepaye == '')
|
if ($datepaid == '')
|
||||||
{
|
{
|
||||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
|
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
|
||||||
$error++;
|
$error++;
|
||||||
@ -100,7 +100,7 @@ if ($action == 'add_payment')
|
|||||||
// Create a line of payments
|
// Create a line of payments
|
||||||
$payment = new PaymentDonation($db);
|
$payment = new PaymentDonation($db);
|
||||||
$payment->chid = $chid;
|
$payment->chid = $chid;
|
||||||
$payment->datepaye = $datepaye;
|
$payment->datepaid = $datepaid;
|
||||||
$payment->amounts = $amounts; // Tableau de montant
|
$payment->amounts = $amounts; // Tableau de montant
|
||||||
$payment->paymenttype = $_POST["paymenttype"];
|
$payment->paymenttype = $_POST["paymenttype"];
|
||||||
$payment->num_payment = $_POST["num_payment"];
|
$payment->num_payment = $_POST["num_payment"];
|
||||||
@ -202,8 +202,8 @@ if (GETPOST("action") == 'create')
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||||
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||||
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
|
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaid):0;
|
||||||
$form->select_date($datepayment,'','','','',"add_payment",1,1);
|
$form->select_date($datepayment,'','','','',"add_payment",1,1);
|
||||||
print "</td>";
|
print "</td>";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -214,9 +214,9 @@ if (GETPOST("action") == 'create')
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
print '<td class="fieldrequired">'.$langs->trans('AccountToCredit').'</td>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$don->accountid, "accountid", 0, '',1); // Show opend bank account list
|
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$don->accountid, "accountid", 0, '',1); // Show open bank account list
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Number
|
// Number
|
||||||
|
|||||||
@ -375,6 +375,7 @@ ALTER TABLE llx_societe_extrafields ADD UNIQUE INDEX uk_societe_extrafields (fk_
|
|||||||
ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL after country;
|
ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL after country;
|
||||||
ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer;
|
ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer;
|
||||||
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
|
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
|
||||||
|
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_project integer NULL;
|
||||||
|
|
||||||
create table llx_payment_donation
|
create table llx_payment_donation
|
||||||
(
|
(
|
||||||
|
|||||||
@ -44,7 +44,7 @@ create table llx_don
|
|||||||
phone varchar(24),
|
phone varchar(24),
|
||||||
phone_mobile varchar(24),
|
phone_mobile varchar(24),
|
||||||
public smallint DEFAULT 1 NOT NULL, -- le don est-il public (0,1)
|
public smallint DEFAULT 1 NOT NULL, -- le don est-il public (0,1)
|
||||||
fk_don_projet integer NULL, -- projet auquel est fait le don
|
fk_project integer NULL, -- projet auquel est fait le don
|
||||||
fk_user_author integer NOT NULL,
|
fk_user_author integer NOT NULL,
|
||||||
fk_user_valid integer NULL,
|
fk_user_valid integer NULL,
|
||||||
note_private text,
|
note_private text,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user