diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 6cb7613bf06..f486a64dac1 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -108,4 +108,5 @@ SubscriptionOk = Your subscription to this conference has been validated # # Payment page # +Attendee = Participant PaymentConferenceAttendee = Paiement de participation à une conférence \ No newline at end of file diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index a7f68a7ddab..ade545c23c7 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -68,6 +68,7 @@ require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Init vars @@ -189,6 +190,7 @@ function llxFooterVierge() /* * Actions */ +global $mysoc; $parameters = array(); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -302,16 +304,48 @@ if (empty($reshook) && $action == 'add') { $errmsg .= $productforinvoicerow->error; } else { $facture = new Facture($db); - $facture->type = 0; + $facture->type = Facture::TYPE_STANDARD; $facture->socid = $thirdparty->id; $facture->paye = 0; - // @todo complete - //$baseprice = $productforinvoicerow-> - $facture->total_ht = 10; - $facture->total_vat = $productforinvoicerow->tva_tx*10; - $facture->total_ttc = $facture->total_ht + $facture->total_ttc; $facture->date = dol_now(); + $facture->cond_reglement_id = $confattendee->cond_reglement_id; + 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; + } + } + $resultfacture = $facture->create($user); + if ($resultfacture <= 0) { + $confattendee->error = $facture->error; + $confattendee->errors = $facture->errors; + $error++; + } + } + + if (!$error) { + // Add line to draft invoice + $idprodsubscription = 0; + if (!empty($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { + $idprodsubscription = $conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION; + } + + $vattouse = get_default_tva($mysoc, $thirdparty, $idprodsubscription); + + $result = $facture->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1); + if ($result <= 0) { + $confattendee->error = $confattendee->error; + $confattendee->errors = $confattendee->errors; + $error++; + } + var_dump('a'); + $resultfacture = $facture->create($user); + var_dump('b'); + var_dump($resultfacture); if ($resultfacture < 0) { $error++; $errmsg .= $facture->error; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index d4bf295db10..546a7ee0e11 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1804,7 +1804,7 @@ if ($source == 'conferencesubscription') { print ''."\n"; // Debitor - print ''.$langs->trans("Member"); + print ''.$langs->trans("Attendee"); print ''; print $thirdparty->name; print '';