mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix payment of registration of event
This commit is contained in:
parent
5fa62f25fa
commit
2810315dc5
|
|
@ -108,6 +108,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1,),
|
||||
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'),
|
||||
'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',),
|
||||
'fk_invoice' => array('type'=>'integer:Facture:compta/facture/class/facture.class.php', 'label'=>'Invoice', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>-1, 'index'=>0, 'picto'=>'bill', 'css'=>'tdoverflowmax150 maxwidth500'),
|
||||
'amount' => array('type'=>'price', 'label'=>'AmountPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>3,),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>3,),
|
||||
|
|
@ -126,6 +127,7 @@ class ConferenceOrBoothAttendee extends CommonObject
|
|||
public $fk_actioncomm;
|
||||
public $email;
|
||||
public $date_subscription;
|
||||
public $fk_invoice;
|
||||
public $amount;
|
||||
public $note_public;
|
||||
public $note_private;
|
||||
|
|
|
|||
|
|
@ -403,6 +403,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
|
|||
fk_soc integer,
|
||||
fk_actioncomm integer,
|
||||
fk_project integer NOT NULL,
|
||||
fk_invoice integer NULL,
|
||||
email varchar(100),
|
||||
date_subscription datetime,
|
||||
amount double DEFAULT NULL,
|
||||
|
|
@ -422,6 +423,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
|
|||
-- VPGSQL8.2 ALTER TABLE llx_eventorganization_conferenceorboothattendee ALTER COLUMN fk_actioncomm DROP NOT NULL;
|
||||
|
||||
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_project integer NOT NULL;
|
||||
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN fk_invoice integer NULL;
|
||||
|
||||
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid);
|
||||
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref);
|
||||
|
|
|
|||
|
|
@ -470,34 +470,41 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
|
|||
$errmsg .= $productforinvoicerow->error;
|
||||
} else {
|
||||
$facture = new Facture($db);
|
||||
$facture->type = Facture::TYPE_STANDARD;
|
||||
$facture->socid = $thirdparty->id;
|
||||
$facture->paye = 0;
|
||||
$facture->date = dol_now();
|
||||
$facture->cond_reglement_id = $confattendee->cond_reglement_id;
|
||||
$facture->fk_project = $project->id;
|
||||
if (empty($confattendee->fk_invoice)) {
|
||||
$facture->type = Facture::TYPE_STANDARD;
|
||||
$facture->socid = $thirdparty->id;
|
||||
$facture->paye = 0;
|
||||
$facture->date = dol_now();
|
||||
$facture->cond_reglement_id = $confattendee->cond_reglement_id;
|
||||
$facture->fk_project = $project->id;
|
||||
$facture->status = Facture::STATUS_DRAFT;
|
||||
|
||||
if (empty($facture->cond_reglement_id)) {
|
||||
$paymenttermstatic = new PaymentTerm($confattendee->db);
|
||||
$facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
|
||||
if (empty($facture->cond_reglement_id)) {
|
||||
$error++;
|
||||
$confattendee->error = 'ErrorNoPaymentTermRECEPFound';
|
||||
$confattendee->errors[] = $confattendee->error;
|
||||
$paymenttermstatic = new PaymentTerm($confattendee->db);
|
||||
$facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
|
||||
if (empty($facture->cond_reglement_id)) {
|
||||
$error++;
|
||||
$confattendee->error = 'ErrorNoPaymentTermRECEPFound';
|
||||
$confattendee->errors[] = $confattendee->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
$resultfacture = $facture->create($user);
|
||||
if ($resultfacture <= 0) {
|
||||
$confattendee->error = $facture->error;
|
||||
$confattendee->errors = $facture->errors;
|
||||
$error++;
|
||||
$resultfacture = $facture->create($user);
|
||||
if ($resultfacture <= 0) {
|
||||
$confattendee->error = $facture->error;
|
||||
$confattendee->errors = $facture->errors;
|
||||
$error++;
|
||||
} else {
|
||||
$confattendee->fk_invoice = $resultfacture;
|
||||
$confattendee->update($user);
|
||||
}
|
||||
} else {
|
||||
$facture->fetch($confattendee->fk_invoice);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!$error) {
|
||||
// Add link between invoice and the attendee registration
|
||||
/*if (!$error) {
|
||||
$facture->add_object_linked($confattendee->element, $confattendee->id);
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ if (!$action) {
|
|||
|
||||
if ($source == 'organizedeventregistration') {
|
||||
// Finding the Attendee
|
||||
$attendee = new ConferenceOrBoothAttendee($db);
|
||||
|
||||
$invoiceid = GETPOST('ref', 'int');
|
||||
$invoice = new Facture($db);
|
||||
|
||||
|
|
@ -123,14 +125,28 @@ if ($source == 'organizedeventregistration') {
|
|||
if ($resultinvoice <= 0) {
|
||||
setEventMessages(null, $invoice->errors, "errors");
|
||||
} else {
|
||||
/*
|
||||
$attendeeid = 0;
|
||||
|
||||
$invoice->fetchObjectLinked();
|
||||
$linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee'];
|
||||
|
||||
if (is_array($linkedAttendees)) {
|
||||
$linkedAttendees = array_values($linkedAttendees);
|
||||
$attendeeid = $linkedAttendees[0];
|
||||
}*/
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."eventorganization_conferenceorboothattendee";
|
||||
$sql .= " WHERE fk_invoice = ".((int) $invoiceid);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$attendeeid = $obj->rowid;
|
||||
}
|
||||
}
|
||||
|
||||
$attendee = new ConferenceOrBoothAttendee($db);
|
||||
$resultattendee = $attendee->fetch($linkedAttendees[0]);
|
||||
if ($attendeeid > 0) {
|
||||
$resultattendee = $attendee->fetch($attendeeid);
|
||||
|
||||
if ($resultattendee <= 0) {
|
||||
setEventMessages(null, $attendee->errors, "errors");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user