';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
$object->thirdparty->fetch($socid);
// Thirdparty
diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php
index 1fba506e910..256039fa96f 100644
--- a/htdocs/contact/vcard.php
+++ b/htdocs/contact/vcard.php
@@ -44,7 +44,6 @@ if ($result <= 0) {
exit;
}
-$physicalperson = 1;
$company = new Societe($db);
if ($contact->socid) {
@@ -107,7 +106,7 @@ if ($company->id) {
}
// Si contact lie a un tiers non de type "particulier"
- if ($contact->typent_code != 'TE_PRIVATE') {
+ if ($company->typent_code != 'TE_PRIVATE') {
$v->setOrg($company->name);
}
}
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 1e8da8a9a81..8dbcde19d0d 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -3135,8 +3135,7 @@ class ContratLigne extends CommonObjectLine
$this->db->begin();
- $this->oldcopy = new ContratLigne($this->db);
- $this->oldcopy->fetch($this->id);
+ $this->oldcopy = dol_clone($this);
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 54573f92c7a..79291aacdf0 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -31,6 +31,7 @@
*/
use OAuth\Common\Storage\DoliStorage;
+use OAuth\Common\Consumer\Credentials;
/**
* Class to send emails (with attachments or not)
* Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto);
@@ -981,8 +982,31 @@ class CMailFile
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
$storage = new DoliStorage($db, $conf);
+
try {
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ $expire = false;
+ // Is token expired or will token expire in the next 30 seconds
+ if (is_object($tokenobj)) {
+ $expire = ($tokenobj->getEndOfLife() !== -9002 && $tokenobj->getEndOfLife() !== -9001 && time() > ($tokenobj->getEndOfLife() - 30));
+ }
+ // Token expired so we refresh it
+ if (is_object($tokenobj) && $expire) {
+ $credentials = new Credentials(
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_ID'),
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_SECRET'),
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_URLAUTHORIZE')
+ );
+ $serviceFactory = new \OAuth\ServiceFactory();
+ $oauthname = explode('-', $OAUTH_SERVICENAME);
+ // ex service is Google-Emails we need only the first part Google
+ $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
+ // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
+ $refreshtoken = $tokenobj->getRefreshToken();
+ $tokenobj = $apiService->refreshAccessToken($tokenobj);
+ $tokenobj->setRefreshToken($refreshtoken);
+ $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
+ }
if (is_object($tokenobj)) {
$this->transport->setAuthMode('XOAUTH2');
$this->transport->setPassword($tokenobj->getAccessToken());
diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php
index 937ca6f7875..960d2ac4744 100644
--- a/htdocs/core/class/comment.class.php
+++ b/htdocs/core/class/comment.class.php
@@ -71,19 +71,19 @@ class Comment extends CommonObject
public $fk_user_modif;
/**
- * @var int Entity
+ * @var int Entity
*/
public $entity;
/**
- * @var string import key
+ * @var string Import key
*/
public $import_key;
public $comments = array();
/**
- * @var Comment Object oldcopy
+ * @var Comment Object oldcopy
*/
public $oldcopy;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index aead087a9bc..eaba8121505 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -141,7 +141,7 @@ abstract class CommonObject
public $linkedObjectsFullLoaded = array();
/**
- * @var Object To store a cloned copy of object before to edit it and keep track of old properties
+ * @var CommonObject To store a cloned copy of object before to edit it and keep track of old properties
*/
public $oldcopy;
@@ -3512,7 +3512,7 @@ abstract class CommonObject
*
* @param int $exclspec >0 = Exclude special product (product_type=9)
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode Total of rounding, '1'=Force mode Rounding of total
- * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
+ * @param int $nodatabaseupdate 1=Do not update database total fields of the main object. Update only properties in memory. Can be used to save SQL when this method is called several times, so we can do it only once at end.
* @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data).
* @return int <0 if KO, >0 if OK
*/
@@ -3558,10 +3558,6 @@ abstract class CommonObject
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- if ($roundingadjust == '-1') {
- $roundingadjust = 'auto'; // For backward compatibility
- }
-
$forcedroundingmode = $roundingadjust;
if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) {
$forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
@@ -3573,7 +3569,7 @@ abstract class CommonObject
$multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1;
- // Define constants to find lines to sum
+ // Define constants to find lines to sum (field name int the table_element_line not into table_element)
$fieldtva = 'total_tva';
$fieldlocaltax1 = 'total_localtax1';
$fieldlocaltax2 = 'total_localtax2';
@@ -3609,6 +3605,7 @@ abstract class CommonObject
$sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used
dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
+
$resql = $this->db->query($sql);
if ($resql) {
$this->total_ht = 0;
@@ -3637,14 +3634,26 @@ abstract class CommonObject
$localtax_array = array($obj->localtax1_type, $obj->localtax1_tx, $obj->localtax2_type, $obj->localtax2_tx);
$tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
- $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price adn unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT.
+ $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price and unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT.
$diff_on_current_total = price2num($obj->total_ttc - $obj->total_ht - $obj->total_tva - $obj->total_localtax1 - $obj->total_localtax2, 'MT', 1);
- //var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' =? '.$obj->total_ttc);
+ //var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' => '.$obj->total_ttc);
//var_dump($diff_when_using_price_ht.' '.$diff_on_current_total);
- if ($diff_when_using_price_ht && $diff_on_current_total) {
+ if ($diff_on_current_total) {
+ // This should not happen, we should always have in table: total_ttc = total_ht + total_vat + total_localtax1 + total_localtax2
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
- dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
+ dol_syslog('We found unconsistent data into detailed line (diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (ht=".$obj->total_ht." vat=".$obj->total_tva." tax1=".$obj->total_localtax1." tax2=".$obj->total_localtax2." ttc=".$obj->total_ttc."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
+ $resqlfix = $this->db->query($sqlfix);
+ if (!$resqlfix) {
+ dol_print_error($this->db, 'Failed to update line');
+ }
+ $obj->total_tva = $tmpcal[1];
+ $obj->total_ttc = $tmpcal[2];
+ } elseif ($diff_when_using_price_ht && $roundingadjust == '0') {
+ // After calculation from HT, total is consistent but we have found a difference between VAT part in calculation and into database and
+ // we ask to force the use of rounding on line (like done on calculation) so we force update of line
+ $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
+ dol_syslog('We found a line with different rounding data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix = $this->db->query($sqlfix);
if (!$resqlfix) {
dol_print_error($this->db, 'Failed to update line');
@@ -3725,7 +3734,7 @@ abstract class CommonObject
$this->db->free($resql);
- // Now update global field total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_*
+ // Now update global fields total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_* of main object
$fieldht = 'total_ht';
$fieldtva = 'tva';
$fieldlocaltax1 = 'localtax1';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 17b8c50aff3..ef269b78d13 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5034,7 +5034,7 @@ class Form
$more .= '
global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common';
+ $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT;
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$mode;
if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled)
//$head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc);
diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php
index a7a6c048a4d..c2c9309cd44 100644
--- a/htdocs/core/modules/modEventOrganization.class.php
+++ b/htdocs/core/modules/modEventOrganization.class.php
@@ -56,7 +56,7 @@ class modEventOrganization extends DolibarrModules
$this->description = "EventOrganizationDescription";
$this->descriptionlong = "EventOrganizationDescriptionLong";
- $this->version = 'experimental';
+ $this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where EVENTORGANIZATION is value of property name of module in uppercase)
diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php
index 964558de8df..391f5b435d7 100644
--- a/htdocs/core/modules/printing/printgcp.modules.php
+++ b/htdocs/core/modules/printing/printgcp.modules.php
@@ -137,7 +137,6 @@ class printing_printgcp extends PrintingDriver
$this->errors[] = $e->getMessage();
$token_ok = false;
}
- //var_dump($this->errors);exit;
$expire = false;
// Is token expired or will token expire in the next 30 seconds
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 029c5651a32..b832bceb822 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -533,7 +533,7 @@ class Fichinter extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
if (!$error) {
- $this->oldcopy = clone $this;
+ $this->oldcopy = dol_clone($this);
}
if (!$error) {
@@ -1422,7 +1422,7 @@ class Fichinter extends CommonObject
}
if (!$error) {
- $this->oldcopy = clone $this;
+ $this->oldcopy = dol_clone($this);
$this->ref_client = $ref_client;
}
diff --git a/htdocs/install/doctemplates/websites/website_template-style01.png b/htdocs/install/doctemplates/websites/website_template-style01.png
new file mode 100644
index 00000000000..4e409583f92
Binary files /dev/null and b/htdocs/install/doctemplates/websites/website_template-style01.png differ
diff --git a/htdocs/install/doctemplates/websites/website_template-style01.zip b/htdocs/install/doctemplates/websites/website_template-style01.zip
new file mode 100644
index 00000000000..12c001b5d7f
Binary files /dev/null and b/htdocs/install/doctemplates/websites/website_template-style01.zip differ
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 8be37bd0f9a..46cb61ff3f0 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -326,8 +326,8 @@ FTPPassiveMode=Passive mode
ChooseAFTPEntryIntoMenu=Choose a FTP/SFTP site from the menu...
FailedToGetFile=Failed to get files %s
ErrorFTPNodisconnect=Error to disconnect FTP/SFTP server
-FileWasUpload=File
%s was upload
-FTPFailedToUploadFile=Failed to upload file
%s.
+FileWasUpload=File
%s was uploaded
+FTPFailedToUploadFile=Failed to upload the file
%s.
AddFolder=Create folder
-FileWasCreateFolder=Folder
%s was create
+FileWasCreateFolder=Folder
%s has been created
FTPFailedToCreateFolder=Failed to create folder
%s.
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index 59a23e65d9b..3d5a57e91d3 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -150,3 +150,4 @@ ErrorFaviconSize=Favicon must be sized 16x16, 32x32 or 64x64
FaviconTooltip=Upload an image which needs to be a png (16x16, 32x32 or 64x64)
NextContainer=Next page/container
PreviousContainer=Previous page/container
+WebsiteMustBeDisabled=The website must have the status "Disabled"
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index fde8c453a2e..acdb88da9f5 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1051,9 +1051,7 @@ class Product extends CommonObject
if ($result >= 0) {
if (empty($this->oldcopy)) {
- $org = new self($this->db);
- $org->fetch($this->id);
- $this->oldcopy = $org;
+ $this->oldcopy = dol_clone($this);
}
// Test if batch management is activated on existing product
@@ -1929,7 +1927,7 @@ class Product extends CommonObject
global $conf;
$result = 0;
- // We do a first seach with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref)
+ // We do a first search with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref)
$sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,";
$sql .= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression,";
$sql .= " pfp.default_vat_code,";
diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php
index 0e0f8883f99..3b169055bfa 100644
--- a/htdocs/product/stock/class/productlot.class.php
+++ b/htdocs/product/stock/class/productlot.class.php
@@ -388,9 +388,7 @@ class Productlot extends CommonObject
// Put here code to add a control on parameters values
if (empty($this->oldcopy)) {
- $org = new self($this->db);
- $org->fetch($this->id);
- $this->oldcopy = $org;
+ $this->oldcopy = dol_clone($this);
}
// Update request
diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php
index bafed2c54eb..87502734f8e 100644
--- a/htdocs/public/members/new.php
+++ b/htdocs/public/members/new.php
@@ -257,7 +257,7 @@ if (empty($reshook) && $action == 'add') {
$public = GETPOSTISSET('public') ? 1 : 0;
if (!$error) {
- // email a peu pres correct et le login n'existe pas
+ // E-mail looks OK and login does not exist
$adh = new Adherent($db);
$adh->statut = -1;
$adh->public = $public;
@@ -378,6 +378,16 @@ if (empty($reshook) && $action == 'add') {
}
}
+ // Auto-create thirdparty on member creation
+ if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) {
+ $company = new Societe($db);
+ $result = $company->create_from_member($adh);
+ if ($result < 0) {
+ $error++;
+ $errmsg .= join('
', $company->errors);
+ }
+ }
+
if (!empty($backtopage)) {
$urlback = $backtopage;
} elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php
index da99b2f2e97..2188d3b0a23 100644
--- a/htdocs/resource/class/dolresource.class.php
+++ b/htdocs/resource/class/dolresource.class.php
@@ -263,9 +263,7 @@ class Dolresource extends CommonObject
}
if (empty($this->oldcopy)) {
- $org = new self($this->db);
- $org->fetch($this->id);
- $this->oldcopy = $org;
+ $this->oldcopy = dol_clone($this);
}
// Update request
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 105178e3d65..26415a63332 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -4024,12 +4024,25 @@ class Societe extends CommonObject
global $conf, $user, $langs;
dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
+ $fullname = $member->getFullName($langs);
- $name = $socname ? $socname : $member->societe;
- if (empty($name)) {
- $name = $member->getFullName($langs);
+ if ($member->morphy == 'mor') {
+ if (empty($socname)) {
+ $socname = $member->company? $member->company : $member->societe;
+ }
+ if (!empty($fullname) && empty($socalias)) {
+ $socalias = $fullname;
+ }
+ } elseif (empty($socname) && $member->morphy == 'phy') {
+ if (empty($socname)) {
+ $socname = $fullname;
+ }
+ if (!empty($member->company) && empty($socalias)) {
+ $socalias = $member->company;
+ }
}
+ $name = $socname;
$alias = $socalias ? $socalias : '';
// Positionne parametres
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 6253d9b86b2..3ef3e2bd737 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -1358,7 +1358,7 @@ if ($action == 'create') {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$objectsrc->remise_absolue = $remise_absolue;
$objectsrc->remise_percent = $remise_percent;
- $objectsrc->update_price(1, - 1, 1);
+ $objectsrc->update_price(1, 'auto', 1);
}
print "\n";
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 3657ca7f4b6..c3948126b3f 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -564,6 +564,27 @@ if (empty($reshook)) {
$line = array('description' => $prod->description, 'price' => $price, 'tva_tx' => $tva_tx, 'locatax1_tx' => $localtax1_tx, 'locatax2_tx' => $localtax2_tx, 'remise_percent' => $customer->remise_percent, 'price_ttc' => $price_ttc, 'array_options' => $array_options);
+ /* setup of margin calculation */
+ if (isset($conf->global->MARGIN_TYPE)) {
+ if ($conf->global->MARGIN_TYPE == 'pmp' && ! empty($prod->pmp)) {
+ $line['fk_fournprice'] = null;
+ $line['pa_ht'] = $prod->pmp;
+ } elseif ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($prod->cost_price)) {
+ $line['fk_fournprice'] = null;
+ $line['pa_ht'] = $prod->cost_price;
+ } else {
+ // default is fournprice
+ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
+ $pf = new ProductFournisseur($db);
+ if ($pf->find_min_price_product_fournisseur($idproduct, $qty) > 0) {
+ $line['fk_fournprice'] = $pf->product_fourn_price_id;
+ $line['pa_ht'] = $pf->fourn_unitprice_with_discount;
+ if ($pf->fourn_charges > 0)
+ $line['pa_ht'] += $pf->fourn_charges / $pf->fourn_qty;
+ }
+ }
+ }
+
// complete line by hook
$parameters = array('prod' => $prod, 'line' => $line);
$reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
@@ -575,7 +596,7 @@ if (empty($reshook)) {
$line = $hookmanager->resArray;
}
- $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $line['array_options'], 100, '', null, 0);
+ $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', $line['fk_fournprice'], $line['pa_ht'], '', $line['array_options'], 100, '', null, 0);
}
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php
index 24ca8cc782b..af6a4f79d71 100644
--- a/htdocs/takepos/pay.php
+++ b/htdocs/takepos/pay.php
@@ -130,7 +130,7 @@ if ($invoiceid > 0) {
if ($invoice->type != $invoice::TYPE_CREDIT_NOTE) {
if (empty($conf->global->$keyforstripeterminalbank)) { ?>
const config = {simulated: global->STRIPE_TERMINAL_SIMULATED)) { ?> true false
- global->STRIPE_LOCATION)) { ?>, location: 'global->STRIPE_LOCATION; ?>'}
+ global->STRIPE_LOCATION)) { ?>, location: 'global->STRIPE_LOCATION; ?>'}
terminal.discoverReaders(config).then(function(discoverResult) {
if (discoverResult.error) {
console.log('Failed to discover: ', discoverResult.error);
@@ -141,7 +141,7 @@ if ($invoiceid > 0) {
// cashier here and let them select which to connect to (see below).
selectedReader = discoverResult.discoveredReaders[0];
//console.log('terminal.discoverReaders', selectedReader); // only active for development
-
+
terminal.connectReader(selectedReader).then(function(connectResult) {
if (connectResult.error) {
document.getElementById("card-present-alert").innerHTML = '
'+connectResult.error.message+'
';
@@ -160,7 +160,7 @@ if ($invoiceid > 0) {
terminal.connectReader(getSelectedReader($conf->global->$keyforstripeterminalbank, $stripeacc, $servicestatus)); ?>).then(function(connectResult) {
if (connectResult.error) {
- document.getElementById("card-present-alert").innerHTML = '
'+connectResult.error.message+'
';
+ document.getElementById("card-present-alert").innerHTML = '
'+connectResult.error.message+'
';
console.log('Failed to connect: ', connectResult.error);
} else {
document.getElementById("card-present-alert").innerHTML = '';
@@ -388,7 +388,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) {
global->STRIPE_TERMINAL_SIMULATED)) { ?>
terminal.setSimulatorConfiguration({testCardNumber: 'global->STRIPE_TERMINAL_SIMULATED; ?>'});
- document.getElementById("card-present-alert").innerHTML = '
trans('PaymentSendToStripeTerminal'); ?>
';
+ document.getElementById("card-present-alert").innerHTML = '
trans('PaymentSendToStripeTerminal'); ?>
';
terminal.collectPaymentMethod(client_secret).then(function(result) {
if (result.error) {
// Placeholder for handling result.error
@@ -398,7 +398,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) {
console.log('terminal.collectPaymentMethod', result.paymentIntent);
terminal.processPayment(result.paymentIntent).then(function(result) {
if (result.error) {
- document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
';
+ document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
';
console.log(result.error)
} else if (result.paymentIntent) {
paymentIntentId = result.paymentIntent.id;
@@ -409,7 +409,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) {
document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
';
console.log("error when capturing paymentIntent", result.error);
} else {
- document.getElementById("card-present-alert").innerHTML = '
trans('PaymentValidated'); ?>
';
+ document.getElementById("card-present-alert").innerHTML = '
trans('PaymentValidated'); ?>
';
console.log("Capture paymentIntent successfull "+paymentIntentId);
parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() {
if (amountpayed > || amountpayed == || amountpayed==0 ) {
@@ -423,7 +423,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) {
});
}
- });
+ });
}
});
}
@@ -669,6 +669,14 @@ if ($conf->global->TAKEPOS_DELAYED_PAYMENT) {
print '
';
}
?>
+
+executeHooks('completePayment', $parameters, $invoice);
+print $hookmanager->resPrint;
+?>
+