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,),
|
'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'),
|
'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',),
|
'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",),
|
'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_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,),
|
'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 $fk_actioncomm;
|
||||||
public $email;
|
public $email;
|
||||||
public $date_subscription;
|
public $date_subscription;
|
||||||
|
public $fk_invoice;
|
||||||
public $amount;
|
public $amount;
|
||||||
public $note_public;
|
public $note_public;
|
||||||
public $note_private;
|
public $note_private;
|
||||||
|
|||||||
@ -403,6 +403,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
|
|||||||
fk_soc integer,
|
fk_soc integer,
|
||||||
fk_actioncomm integer,
|
fk_actioncomm integer,
|
||||||
fk_project integer NOT NULL,
|
fk_project integer NOT NULL,
|
||||||
|
fk_invoice integer NULL,
|
||||||
email varchar(100),
|
email varchar(100),
|
||||||
date_subscription datetime,
|
date_subscription datetime,
|
||||||
amount double DEFAULT NULL,
|
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;
|
-- 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_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_rowid (rowid);
|
||||||
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref);
|
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;
|
$errmsg .= $productforinvoicerow->error;
|
||||||
} else {
|
} else {
|
||||||
$facture = new Facture($db);
|
$facture = new Facture($db);
|
||||||
$facture->type = Facture::TYPE_STANDARD;
|
if (empty($confattendee->fk_invoice)) {
|
||||||
$facture->socid = $thirdparty->id;
|
$facture->type = Facture::TYPE_STANDARD;
|
||||||
$facture->paye = 0;
|
$facture->socid = $thirdparty->id;
|
||||||
$facture->date = dol_now();
|
$facture->paye = 0;
|
||||||
$facture->cond_reglement_id = $confattendee->cond_reglement_id;
|
$facture->date = dol_now();
|
||||||
$facture->fk_project = $project->id;
|
$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)) {
|
if (empty($facture->cond_reglement_id)) {
|
||||||
$error++;
|
$paymenttermstatic = new PaymentTerm($confattendee->db);
|
||||||
$confattendee->error = 'ErrorNoPaymentTermRECEPFound';
|
$facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
|
||||||
$confattendee->errors[] = $confattendee->error;
|
if (empty($facture->cond_reglement_id)) {
|
||||||
|
$error++;
|
||||||
|
$confattendee->error = 'ErrorNoPaymentTermRECEPFound';
|
||||||
|
$confattendee->errors[] = $confattendee->error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
$resultfacture = $facture->create($user);
|
||||||
$resultfacture = $facture->create($user);
|
if ($resultfacture <= 0) {
|
||||||
if ($resultfacture <= 0) {
|
$confattendee->error = $facture->error;
|
||||||
$confattendee->error = $facture->error;
|
$confattendee->errors = $facture->errors;
|
||||||
$confattendee->errors = $facture->errors;
|
$error++;
|
||||||
$error++;
|
} else {
|
||||||
|
$confattendee->fk_invoice = $resultfacture;
|
||||||
|
$confattendee->update($user);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$facture->fetch($confattendee->fk_invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Add link between invoice and the attendee registration
|
||||||
if (!$error) {
|
/*if (!$error) {
|
||||||
$facture->add_object_linked($confattendee->element, $confattendee->id);
|
$facture->add_object_linked($confattendee->element, $confattendee->id);
|
||||||
}
|
}*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
|
|||||||
@ -115,6 +115,8 @@ if (!$action) {
|
|||||||
|
|
||||||
if ($source == 'organizedeventregistration') {
|
if ($source == 'organizedeventregistration') {
|
||||||
// Finding the Attendee
|
// Finding the Attendee
|
||||||
|
$attendee = new ConferenceOrBoothAttendee($db);
|
||||||
|
|
||||||
$invoiceid = GETPOST('ref', 'int');
|
$invoiceid = GETPOST('ref', 'int');
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
|
|
||||||
@ -123,14 +125,28 @@ if ($source == 'organizedeventregistration') {
|
|||||||
if ($resultinvoice <= 0) {
|
if ($resultinvoice <= 0) {
|
||||||
setEventMessages(null, $invoice->errors, "errors");
|
setEventMessages(null, $invoice->errors, "errors");
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
$attendeeid = 0;
|
||||||
|
|
||||||
$invoice->fetchObjectLinked();
|
$invoice->fetchObjectLinked();
|
||||||
$linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee'];
|
$linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee'];
|
||||||
|
|
||||||
if (is_array($linkedAttendees)) {
|
if (is_array($linkedAttendees)) {
|
||||||
$linkedAttendees = array_values($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);
|
if ($attendeeid > 0) {
|
||||||
$resultattendee = $attendee->fetch($linkedAttendees[0]);
|
$resultattendee = $attendee->fetch($attendeeid);
|
||||||
|
|
||||||
if ($resultattendee <= 0) {
|
if ($resultattendee <= 0) {
|
||||||
setEventMessages(null, $attendee->errors, "errors");
|
setEventMessages(null, $attendee->errors, "errors");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user