diff --git a/ChangeLog b/ChangeLog
index 0fe697ccb6c..43caeb47679 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -243,6 +243,8 @@ Following changes may create regressions for some external modules, but were nec
* Rename the substitution for "project label" instead of "project title" in substitution variables
* You must use "$objectoffield" to manipulate the current object inside the formulare of computed custom extrafields instead of $obj/$object.
* Making a global search is sending the parameter using always the name search_all (instead of sometimes sall and search_all)
+* The property $url_last_version must be public if defined into module descriptor files;
+
diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php
index b122f9b0305..45d649d90d9 100755
--- a/build/generate_filelist_xml.php
+++ b/build/generate_filelist_xml.php
@@ -46,6 +46,7 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
$includecustom=0;
$includeconstants=array();
+$buildzip=0;
if (empty($argv[1])) {
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value] [buildzip=1]\n";
@@ -69,6 +70,9 @@ while ($i < $argc) {
if (!empty($result["includeconstant"])) {
$includeconstants[$i] = $result["includeconstant"];
}
+ if (!empty($result["buildzip"])) {
+ $buildzip=1;
+ }
if (preg_match('/includeconstant=/', strval($argv[$i]))) {
$tmp=explode(':', $result['includeconstant'], 3); // $includeconstant has been set with previous parse_str()
if (count($tmp) != 3) {
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index ff69fbc688b..0fbb2764ae6 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -729,6 +729,7 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements
// Export files then exit
$accountancyexport = new AccountancyExport($db);
+ $formatexport = GETPOST('formatexport', 'int');
$notexportlettering = GETPOST('notexportlettering', 'alpha');
if (!empty($notexportlettering)) {
@@ -745,7 +746,7 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements
$withAttachment = !empty(trim(GETPOST('notifiedexportfull', 'alphanohtml'))) ? 1 : 0;
// Output data on screen or download
- $result = $accountancyexport->export($object->lines, $formatexportset, $withAttachment);
+ $result = $accountancyexport->export($object->lines, $formatexport, $withAttachment);
$error = 0;
if ($result < 0) {
@@ -856,11 +857,13 @@ $formconfirm = '';
if ($action == 'export_file') {
$form_question = array();
- $form_question['notexportlettering'] = array(
- 'name' => 'notexportlettering',
- 'type' => 'other',
- 'label' => '', // TODO Use Selectmodelcsv and show a select combo
- 'value' => $langs->trans('Modelcsv').' : '.$listofformat[$formatexportset].''
+ $form_question['formatexport'] = array(
+ 'name' => 'formatexport',
+ 'type' => 'select',
+ 'label' => $langs->trans('Modelcsv'), // TODO Use Selectmodelcsv and show a select combo
+ 'values' => $listofformat,
+ 'default' => $formatexportset,
+ 'morecss' => 'minwidth200 maxwidth200'
);
$form_question['separator0'] = array('name'=>'separator0', 'type'=>'separator');
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index f2e84e5127a..89a1ed2904d 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -3323,7 +3323,7 @@ class Adherent extends CommonObject
$return .= '
'.$this->getmorphylib('', 2).'';
}
if (method_exists($this, 'getLibStatut')) {
- $return .= '
| '.$langs->trans("Parameters").' | '.$langs->trans("Value").' | '; // With edge and chrome the td overflow is not supported correctly when content is not full text. + //print ' | '; + print ' | ';
if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) {
$userstatic = new User($db);
$res = $userstatic->fetch($obj->fk_user_action);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 46f06614941..5fc0de4c43f 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -3976,7 +3976,7 @@ class Propal extends CommonObject
$return .=' '.$langs->trans("AmountHT").' : '.price($this->total_ht).''; } if (method_exists($this, 'getLibStatut')) { - $return .= ' '.$this->getLibStatut(5).' ';
+ $return .= ''.$this->getLibStatut(3).' ';
}
$return .= '';
$return .= '';
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 89b2a5f31d9..3ee2ad037b5 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1844,10 +1844,10 @@ class Account extends CommonObject
}
if (method_exists($this, 'solde')) {
$return .= ''; - $return .= ''.$langs->trans("Balance").' : '.price($this->solde(1), 0, $langs, 1, -1, -1, $this->currency_code).''; + $return .= ''.$langs->trans("Balance").' : '.price(price2num($this->solde(1), 'MT'), 0, $langs, 1, -1, -1, $this->currency_code).''; } if (method_exists($this, 'getLibStatut')) { - $return .= ' '.$this->getLibStatut(5).' ';
+ $return .= ''.$this->getLibStatut(3).' ';
}
$return .= '';
$return .= '';
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index 668ada03fdb..bc2c2528d07 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -787,7 +787,7 @@ foreach ($accounts as $key => $type) {
if (!empty($arrayfields['balance']['checked'])) {
print ' | '; print ''; - print ''.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).''; + print ''.price(price2num($solde, 'MT'), 0, $langs, 1, -1, -1, $objecttmp->currency_code).''; print ''; print ' | '; if (!$i) { diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 8cc3c93b59c..deb86fba456 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -495,7 +495,7 @@ class CashControl extends CommonObject $return .= '|
| '.$langs->trans("None").' | ||||||
| '.$langs->trans("Amount").' | '.price($object->amount).' | |||||
| '.$langs->trans('Status').' | '; - print ''.$object->getLibStatut(1).' | '; - print '|||||
| '; + // Bank account $labelofbankfield = "BankToReceiveWithdraw"; if ($object->type == 'bank-transfer') { $labelofbankfield = 'BankToPayCreditTransfer'; } - print $langs->trans($labelofbankfield); + //print $langs->trans($labelofbankfield); + $caneditbank = $permissiontoadd; + if ($object->status != $object::STATUS_DRAFT) { + $caneditbank = 0; + } + /* + print ' | |||||
| '; + print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank); print ' | '; print ''; - if ($acc->id > 0) { - print $acc->getNomUrl(1); - } + print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl'); print ' | '; print '||||
';
+ print '
| '; + if ($action == 'editfkbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'fk_bank_account', 0); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'none'); + } + print " | "; + print '||||
| ';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') {
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 70836cb50cf..cbe2eda9533 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -70,13 +70,11 @@ class BonPrelevement extends CommonObject
public $emetteur_bic;
public $emetteur_ics;
- public $date_trans;
public $user_trans;
- public $method_trans;
+ public $user_credit;
public $total;
public $fetched;
- public $statut; // 0-Wait, 1-Trans, 2-Done
public $labelStatus = array();
public $factures = array();
@@ -84,14 +82,6 @@ class BonPrelevement extends CommonObject
public $invoice_in_error = array();
public $thirdparty_in_error = array();
- public $amount;
- public $note;
- public $datec;
-
- public $date_credit;
- public $user_credit;
-
- public $type;
const STATUS_DRAFT = 0;
const STATUS_TRANSFERED = 1;
@@ -99,6 +89,83 @@ class BonPrelevement extends CommonObject
const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
+ /**
+ * 'type' field format:
+ * 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
+ * 'select' (list of values are in 'options'),
+ * 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]',
+ * 'chkbxlst:...',
+ * 'varchar(x)',
+ * 'text', 'text:none', 'html',
+ * 'double(24,8)', 'real', 'price',
+ * 'date', 'datetime', 'timestamp', 'duration',
+ * 'boolean', 'checkbox', 'radio', 'array',
+ * 'mail', 'phone', 'url', 'password', 'ip'
+ * Note: Filter must be a Dolibarr filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'picto' is code of a picto to show before value in forms
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...)
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
+ * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
+ * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
+ * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ * 'validate' is 1 if need to validate with $this->validateField()
+ * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
+ */
+
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields=array(
+ 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,),
+ 'ref' => array('type'=>'varchar(12)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150', 'showoncombobox'=>'1',),
+ 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,),
+ 'amount' => array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,),
+ 'statut' => array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>'1', 'position'=>500, 'notnull'=>0, 'visible'=>-1, 'arrayofkeyval'=>array(0=>'Wait', 1=>'Transfered', 2=>'Credited')),
+ 'credite' => array('type'=>'smallint(6)', 'label'=>'Credite', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,),
+ 'note' => array('type'=>'text', 'label'=>'Note', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,),
+ 'date_trans' => array('type'=>'datetime', 'label'=>'Datetrans', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,),
+ 'method_trans' => array('type'=>'smallint(6)', 'label'=>'Methodtrans', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,),
+ 'fk_user_trans' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkusertrans', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
+ 'date_credit' => array('type'=>'datetime', 'label'=>'Datecredit', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-1,),
+ 'fk_user_credit' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkusercredit', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
+ 'type' => array('type'=>'varchar(16)', 'label'=>'Type', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,),
+ 'fk_bank_account' => array('type'=>'integer', 'label'=>'Fkbankaccount', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx',),
+ );
+ public $rowid;
+ public $ref;
+ public $datec;
+ public $amount;
+ public $statut;
+ public $credite;
+ public $note;
+ public $date_trans;
+ public $method_trans;
+ public $fk_user_trans;
+ public $date_credit;
+ public $fk_user_credit;
+ public $type;
+ public $fk_bank_account;
+ // END MODULEBUILDER PROPERTIES
+
+
+
/**
* Constructor
*
@@ -290,8 +357,6 @@ class BonPrelevement extends CommonObject
*/
public function fetch($rowid, $ref = '')
{
- global $conf;
-
$sql = "SELECT p.rowid, p.ref, p.amount, p.note";
$sql .= ", p.datec as dc";
$sql .= ", p.date_trans as date_trans";
@@ -299,6 +364,7 @@ class BonPrelevement extends CommonObject
$sql .= ", p.date_credit as date_credit";
$sql .= ", p.fk_user_credit";
$sql .= ", p.type";
+ $sql .= ", p.fk_bank_account";
$sql .= ", p.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.entity IN (".getEntity('invoice').")";
@@ -328,6 +394,7 @@ class BonPrelevement extends CommonObject
$this->user_credit = $obj->fk_user_credit;
$this->type = $obj->type;
+ $this->fk_bank_account = $obj->fk_bank_account;
$this->status = $obj->status;
$this->statut = $obj->status; // For backward compatibility
@@ -344,6 +411,18 @@ class BonPrelevement extends CommonObject
}
}
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update(User $user, $notrigger = false)
+ {
+ return $this->updateCommon($user, $notrigger);
+ }
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set direct debit or credit transfer order to "paid" status.
@@ -369,7 +448,7 @@ class BonPrelevement extends CommonObject
$this->db->begin();
- $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons ";
+ $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
$sql .= " SET fk_user_credit = ".$user->id;
$sql .= ", statut = ".self::STATUS_CREDITED;
$sql .= ", date_credit = '".$this->db->idate($date)."'";
@@ -383,8 +462,12 @@ class BonPrelevement extends CommonObject
$subject = $langs->trans("InfoCreditSubject", $this->ref);
$message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour'));
- //Add payment of withdrawal into bank
- $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
+ // Add payment of withdrawal into bank
+ $fk_bank_account = $this->fk_bank_account;
+ if (empty($fk_bank_account)) {
+ $fk_bank_account = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
+ }
+
$facs = array();
$amounts = array();
$amountsperthirdparty = array();
@@ -455,7 +538,7 @@ class BonPrelevement extends CommonObject
$modeforaddpayment = 'payment';
}
- $result = $paiement->addPaymentToBank($user, $modeforaddpayment, '(WithdrawalPayment)', $bankaccount, '', '');
+ $result = $paiement->addPaymentToBank($user, $modeforaddpayment, '(WithdrawalPayment)', $fk_bank_account, '', '');
if ($result < 0) {
$error++;
$this->error = $paiement->error;
@@ -742,17 +825,18 @@ class BonPrelevement extends CommonObject
* - Link the order with the prelevement_demande lines
* TODO delete params banque and agence when not necessary
*
- * @param int $banque dolibarr mysoc bank
- * @param int $agence dolibarr mysoc bank office (guichet)
- * @param string $mode real=do action, simu=test only
- * @param string $format FRST, RCUR or ALL
- * @param string $executiondate Date to execute the transfer
- * @param int $notrigger Disable triggers
- * @param string $type 'direct-debit' or 'bank-transfer'
- * @param int $did ID of an existing payment request. If $did is defined, no entry
- * @return int <0 if KO, No of invoice included into file if OK
+ * @param int $banque dolibarr mysoc bank
+ * @param int $agence dolibarr mysoc bank office (guichet)
+ * @param string $mode real=do action, simu=test only
+ * @param string $format FRST, RCUR or ALL
+ * @param string $executiondate Date to execute the transfer
+ * @param int $notrigger Disable triggers
+ * @param string $type 'direct-debit' or 'bank-transfer'
+ * @param int $did ID of an existing payment request. If $did is defined, no entry
+ * @param int $fk_bank_account Bank account ID the receipt is generated for. Will use the ID into the setup of module Direct Debit or Credit Transfer if 0.
+ * @return int <0 if KO, No of invoice included into file if OK
*/
- public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit', $did = 0)
+ public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit', $did = 0, $fk_bank_account = 0)
{
// phpcs:enable
global $conf, $langs, $user;
@@ -762,6 +846,7 @@ class BonPrelevement extends CommonObject
require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
+ // Check params
if ($type != 'bank-transfer') {
if (empty($format)) {
$this->error = 'ErrorBadParametersForDirectDebitFileCreate';
@@ -769,6 +854,11 @@ class BonPrelevement extends CommonObject
}
}
+ // Clean params
+ if (empty($fk_bank_account)) {
+ $fk_bank_account = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
+ }
+
$error = 0;
$datetimeprev = dol_now('gmt');
@@ -969,12 +1059,13 @@ class BonPrelevement extends CommonObject
// Create withdraw order in database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
- $sql .= "ref, entity, datec, type";
+ $sql .= "ref, entity, datec, type, fk_bank_account";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($ref)."'";
$sql .= ", ".((int) $conf->entity);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", '".($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order')."'";
+ $sql .= ", ".((int) $fk_bank_account);
$sql .= ")";
$resql = $this->db->query($sql);
@@ -1055,12 +1146,8 @@ class BonPrelevement extends CommonObject
$this->date_echeance = $datetimeprev;
$this->reference_remise = $ref;
- $id = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
- if ($type == 'bank-transfer') {
- $id = $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT;
- }
$account = new Account($this->db);
- if ($account->fetch($id) > 0) {
+ if ($account->fetch($fk_bank_account) > 0) {
$this->emetteur_code_banque = $account->code_banque;
$this->emetteur_code_guichet = $account->code_guichet;
$this->emetteur_numero_compte = $account->number;
@@ -1382,16 +1469,22 @@ class BonPrelevement extends CommonObject
* File is generated with name this->filename
*
* @param string $format FRST, RCUR or ALL
- * @param string $executiondate Date to execute transfer
+ * @param int $executiondate Timestamp date to execute transfer
* @param string $type 'direct-debit' or 'bank-transfer'
+ * @param int $fk_bank_account Bank account ID the receipt is generated for. Will use the ID into the setup of module Direct Debit or Credit Transfer if 0.
* @return int >=0 if OK, <0 if KO
*/
- public function generate($format = 'ALL', $executiondate = '', $type = 'direct-debit')
+ public function generate($format = 'ALL', $executiondate = 0, $type = 'direct-debit', $fk_bank_account = 0)
{
global $conf, $langs, $mysoc;
//TODO: Optimize code to read lines in a single function
+ // Clean params
+ if (empty($fk_bank_account)) {
+ $fk_bank_account = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
+ }
+
$result = 0;
dol_syslog(get_class($this)."::generate build file=".$this->filename." type=".$type);
@@ -1486,7 +1579,7 @@ class BonPrelevement extends CommonObject
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
if ($result != -2) {
- $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type);
+ $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format, $type, $fk_bank_account);
}
/**
@@ -2041,31 +2134,36 @@ class BonPrelevement extends CommonObject
* Write sender of request (me).
* Note: The tag PmtInf is opened here but closed into caller
*
- * @param Conf $configuration conf
- * @param int $ladate Date
- * @param int $nombre 0 or 1
- * @param float $total Total
- * @param string $CrLf End of line character
- * @param string $format FRST or RCUR or ALL
- * @param string $type 'direct-debit' or 'bank-transfer'
- * @return string String with SEPA Sender
+ * @param Conf $configuration conf
+ * @param int $ladate Date
+ * @param int $nombre 0 or 1
+ * @param float $total Total
+ * @param string $CrLf End of line character
+ * @param string $format FRST or RCUR or ALL
+ * @param string $type 'direct-debit' or 'bank-transfer'
+ * @param int $fk_bank_account Bank account ID the receipt is generated for. Will use the ID into the setup of module Direct Debit or Credit Transfer if 0.
+ * @return string String with SEPA Sender
* @see EnregEmetteur()
*/
- public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST', $type = 'direct-debit')
+ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST', $type = 'direct-debit', $fk_bank_account = 0)
{
// phpcs:enable
// SEPA INITIALISATION
global $conf;
+ // Clean parameters
$dateTime_YMD = dol_print_date($ladate, '%Y%m%d');
$dateTime_ETAD = dol_print_date($ladate, '%Y-%m-%d');
$dateTime_YMDHMS = dol_print_date($ladate, '%Y-%m-%dT%H:%M:%S');
+ // Clean params
+ if (empty($fk_bank_account)) {
+ $fk_bank_account = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
+ }
+
// Get data of bank account
- //$id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT;
- $id = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
$account = new Account($this->db);
- if ($account->fetch($id) > 0) {
+ if ($account->fetch($fk_bank_account) > 0) {
$this->emetteur_code_banque = $account->code_banque;
$this->emetteur_code_guichet = $account->code_guichet;
$this->emetteur_numero_compte = $account->number;
@@ -2081,8 +2179,7 @@ class BonPrelevement extends CommonObject
// Get pending payments
$sql = "SELECT rowid, ref";
- $sql .= " FROM";
- $sql .= " ".MAIN_DB_PREFIX."prelevement_bons as pb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as pb";
$sql .= " WHERE pb.rowid = ".((int) $this->id);
$resql = $this->db->query($sql);
@@ -2294,10 +2391,10 @@ class BonPrelevement extends CommonObject
}
/**
- * Return status label of object
+ * Return status label of object
*
- * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto
- * @return string Label
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label
*/
public function getLibStatut($mode = 0)
{
@@ -2427,7 +2524,6 @@ class BonPrelevement extends CommonObject
{
global $langs;
-
$return = ' ';
$return .= ' ';
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index cc416d7d530..4c3d26720c3 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -105,7 +105,7 @@ if ($id > 0 || $ref) {
print '';
$return .= ' ';
$return .= ' | |||||
| '.$langs->trans("Date").' | '.dol_print_date($object->datec, 'day').' | ||||
| '.$langs->trans("Amount").' | '.price($object->amount).' | ||||
| '.$langs->trans('CreditDate').' | '; print dol_print_date($object->date_credit, 'day'); print ' | ||||
| '; $labelofbankfield = "BankToReceiveWithdraw"; if ($object->type == 'bank-transfer') { $labelofbankfield = 'BankToPayCreditTransfer'; } - print $langs->trans($labelofbankfield); + + print ' | |||||
| '; + print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield)); print ' | '; print ''; if ($acc->id > 0) { diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index de9eb46631c..7e80874745c 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -100,7 +100,7 @@ if ($id > 0 || $ref) { print ' | ||||
| '.$langs->trans("Date").' | '.dol_print_date($object->datec, 'day').' | ||||
| '.$langs->trans("Amount").' | '.price($object->amount).' | ||||
| '.$langs->trans('CreditDate').' | '; print dol_print_date($object->date_credit, 'day'); print ' | ||||
| '; $labelofbankfield = "BankToReceiveWithdraw"; if ($object->type == 'bank-transfer') { $labelofbankfield = 'BankToPayCreditTransfer'; } - print $langs->trans($labelofbankfield); + + print ' | |||||
| '; + print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield)); print ' | '; print ''; if ($acc->id > 0) { @@ -242,7 +250,7 @@ if ($resql) { $i++; } } else { - print ' | ||||
| '.$langs->trans("None").' | |||||
| '.$langs->trans("None").' | |||||
| '.$langs->trans("Date").' | '.dol_print_date($object->datec, 'day').' | ||||
| '.$langs->trans("Amount").' | '.price($object->amount).' | ||||
| '.$langs->trans('CreditDate').' | '; print dol_print_date($object->date_credit, 'day'); print ' | ||||
| '; $labelofbankfield = "BankToReceiveWithdraw"; if ($object->type == 'bank-transfer') { $labelofbankfield = 'BankToPayCreditTransfer'; } - print $langs->trans($labelofbankfield); + + print ' | ||
| '; + print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield)); print ' | '; print '';
if ($acc->id > 0) {
diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php
index 3619ebfad7a..140f1cffec6 100644
--- a/htdocs/compta/sociales/class/chargesociales.class.php
+++ b/htdocs/compta/sociales/class/chargesociales.class.php
@@ -779,7 +779,7 @@ class ChargeSociales extends CommonObject
$return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).'';
}
if (method_exists($this, 'LibStatut')) {
- $return .= ' '.$this->LibStatut($this->paye, 5, $this->alreadypaid).' ';
+ $return .= ''.$this->getLibStatut(3, $this->alreadypaid).' ';
}
$return .= '';
$return .= '';
diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php
index 2ec1199dd29..220863a0cb2 100644
--- a/htdocs/compta/tva/class/tva.class.php
+++ b/htdocs/compta/tva/class/tva.class.php
@@ -935,7 +935,7 @@ class Tva extends CommonObject
$return .= ''.$langs->trans("DateEnd").' : '.dol_print_date($this->datev).''; } if (method_exists($this, 'LibStatut')) { - $return .= ' '.$this->LibStatut($this->paiementtype, 5, $this->alreadypaid).' ';
+ $return .= ''.$this->getLibStatut(3, $this->alreadypaid).' ';
}
$return .= '';
$return .= '';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index b44d22da312..407eed06921 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -2202,7 +2202,7 @@ class Contact extends CommonObject
$return .= ' : '.$this->LibPubPriv($this->priv).'';
}*/
if (method_exists($this, 'getLibStatut')) {
- $return .= ''.$this->getLibStatut(5).' ';
+ $return .= ''.$this->getLibStatut(3).' ';
}
$return .= '';
$return .= '';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 4c8e50624c2..294c55da4c0 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -942,15 +942,8 @@ if (empty($reshook)) {
$old_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($old_ref);
$new_filedir = $conf->contrat->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
- $files = dol_dir_list($old_filedir);
- if (!empty($files)) {
- if (!is_dir($new_filedir)) {
- dol_mkdir($new_filedir);
- }
- foreach ($files as $file) {
- dol_move($file['fullname'], $new_filedir.'/'.$file['name']);
- }
- }
+ // Rename directory of contract with new name
+ dol_move_dir($old_filedir, $new_filedir);
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index f494bf22ef5..14f5cb62bfa 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -2844,7 +2844,7 @@ class Contrat extends CommonObject
$return .= ''.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat, 'day').''; } if (method_exists($this, 'getLibStatut')) { - $return .= ' '.$this->getLibStatut(5).' ';
+ $return .= ''.$this->getLibStatut(3).' ';
}
$return .= '';
$return .= '';
diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php
index b57e03972f1..379a2e689a3 100644
--- a/htdocs/core/ajax/fileupload.php
+++ b/htdocs/core/ajax/fileupload.php
@@ -45,9 +45,14 @@ error_reporting(E_ALL | E_STRICT);
$fk_element = GETPOST('fk_element', 'int');
$element = GETPOST('element', 'alpha');
-
$upload_handler = new FileUpload(null, $fk_element, $element);
+// Feature not enabled. Warning feature not used and not secured so disabled.
+if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
+ return;
+}
+
+
/*
* View
*/
diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php
index 47a7a2b6f13..ea5c33092ca 100644
--- a/htdocs/core/ajax/onlineSign.php
+++ b/htdocs/core/ajax/onlineSign.php
@@ -59,6 +59,7 @@ $signature = GETPOST('signaturebase64');
$ref = GETPOST('ref', 'aZ09');
$mode = GETPOST('mode', 'aZ09'); // 'proposal', ...
$SECUREKEY = GETPOST("securekey"); // Secure key
+$online_sign_name = GETPOST("onlinesignname") ? GETPOST("onlinesignname") : '';
$error = 0;
$response = "";
@@ -90,7 +91,8 @@ if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed.$type.$ref.(!isModEnable
top_httphead();
if ($action == "importSignature") {
- if (!empty($signature) && $signature[0] == "image/png;base64") {
+ $issignatureok = (!empty($signature) && $signature[0] == "image/png;base64");
+ if ($issignatureok) {
$signature = $signature[1];
$data = base64_decode($signature);
@@ -103,6 +105,10 @@ if ($action == "importSignature") {
$upload_dir = !empty($conf->propal->multidir_output[$object->entity])?$conf->propal->multidir_output[$object->entity]:$conf->propal->dir_output;
$upload_dir .= '/'.dol_sanitizeFileName($object->ref).'/';
+ $default_font_size = pdf_getPDFFontSize($langs); // Must be after pdf_getInstance
+ $default_font = pdf_getPDFFont($langs); // Must be after pdf_getInstance
+ $langs->loadLangs(array("main", "companies"));
+
$date = dol_print_date(dol_now(), "%Y%m%d%H%M%S");
$filename = "signatures/".$date."_signature.png";
if (!is_dir($upload_dir."signatures/")) {
@@ -143,7 +149,6 @@ if ($action == "importSignature") {
$pdf->SetCompression(false);
}
-
//$pdf->Open();
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
@@ -155,7 +160,7 @@ if ($action == "importSignature") {
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tppl);
} catch (Exception $e) {
- dol_syslog("Error when manipulating some PDF by onlineSign: ".$e->getMessage(), LOG_ERR);
+ dol_syslog("Error when manipulating the PDF ".$sourcefile." by onlineSign: ".$e->getMessage(), LOG_ERR);
$response = $e->getMessage();
$error++;
}
@@ -167,7 +172,14 @@ if ($action == "importSignature") {
$yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 60);
$wforimg = $s['w'] - 20 - $xforimgstart;
+ $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4) - 4);
+ $pdf->SetFont($default_font, '', $default_font_size - 1);
+ $pdf->MultiCell($wforimg, 4, $langs->trans("DateSigning").': '.dol_print_date(dol_now(), "daytext", false, $langs, true), 0, 'L');
+ $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4));
+ $pdf->MultiCell($wforimg, 4, $langs->trans("Lastname").': '.$online_sign_name, 0, 'L');
+
$pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
+
//$pdf->Close();
$pdf->Output($newpdffilename, "F");
@@ -187,7 +199,6 @@ if ($action == "importSignature") {
$db->begin();
$online_sign_ip = getUserRemoteIP();
- $online_sign_name = ''; // TODO Ask name on form to sign
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql .= " SET fk_statut = ".((int) $object::STATUS_SIGNED).", note_private = '".$db->escape($object->note_private)."',";
@@ -207,9 +218,6 @@ if ($action == "importSignature") {
}
if (!$error) {
- $db->commit();
- $response = "success";
- setEventMessages("PropalSigned", null, 'warnings');
if (method_exists($object, 'call_trigger')) {
//customer is not a user !?! so could we use same user as validation ?
$user = new User($db);
@@ -218,17 +226,25 @@ if ($action == "importSignature") {
$result = $object->call_trigger('PROPAL_CLOSE_SIGNED', $user);
if ($result < 0) {
$error++;
+ $response = "error in trigger ".$object->error;
+ } else {
+ $response = "success";
}
- $result = $object->call_trigger('PROPAL_CLOSE_SIGNED_WEB', $user);
- if ($result < 0) {
- $error++;
- }
+ } else {
+ $response = "success";
}
} else {
- $db->rollback();
$error++;
$response = "error sql";
}
+
+ if (!$error) {
+ $db->commit();
+ $response = "success";
+ setEventMessages("PropalSigned", null, 'warnings');
+ } else {
+ $db->rollback();
+ }
}
} elseif ($mode == 'contract') {
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 216059a62c2..2635acd7951 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -839,6 +839,10 @@ class CMailFile
$this->error .= "."; $this->error .= $langs->trans("ErrorPhpMailDelivery"); dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); + + if (!empty($conf->global->MAIN_MAIL_DEBUG)) { + $this->save_dump_mail_in_err(); + } } else { dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG); } @@ -903,6 +907,7 @@ class CMailFile if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") { require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array + $keyforsupportedoauth2array = $conf->global->$keyforsmtpoauthservice; if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); @@ -996,6 +1001,10 @@ class CMailFile } dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - ".$this->error, LOG_ERR); $res = false; + + if (!empty($conf->global->MAIN_MAIL_DEBUG)) { + $this->save_dump_mail_in_err(); + } } } } elseif ($this->sendmode == 'swiftmailer') { @@ -1031,6 +1040,7 @@ class CMailFile } if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") { require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array + $keyforsupportedoauth2array = getDolGlobalString($keyforsmtpoauthservice); if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); @@ -1131,6 +1141,10 @@ class CMailFile } dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res = false; + + if (!empty($conf->global->MAIN_MAIL_DEBUG)) { + $this->save_dump_mail_in_err(); + } } else { dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG); } @@ -1218,7 +1232,7 @@ class CMailFile if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir $outputfile = $dolibarr_main_data_root."/dolibarr_mail.log"; - $fp = fopen($outputfile, "w"); + $fp = fopen($outputfile, "w"); // overwrite if ($this->sendmode == 'mail') { fputs($fp, $this->headers); @@ -1235,6 +1249,25 @@ class CMailFile } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Save content if mail is in error + * Used for debugging. + * + * @return void + */ + public function save_dump_mail_in_err() + { + global $dolibarr_main_data_root; + + if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir + $srcfile = $dolibarr_main_data_root."/dolibarr_mail.log"; + $destfile = $dolibarr_main_data_root."/dolibarr_mail.err"; + + dol_move($srcfile, $destfile, 0, 1, 0, 0); + } + } + /** * Correct an uncomplete html string diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 26d90d54fb8..cec7408f1ca 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -80,6 +80,11 @@ abstract class CommonDocGenerator */ public $format; + /** + * @var string pdf, odt, etc + */ + public $type; + public $page_hauteur; public $page_largeur; public $marge_gauche; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 677b7c1017a..34eaf847f2c 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -900,7 +900,7 @@ abstract class CommonInvoice extends CommonObject dol_syslog(get_class($this)."::makeStripeSepaRequest start", LOG_DEBUG); if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) { - // Get the default payment mode for BAN payment + // Get the default payment mode for BAN payment of the third party require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($this->db); // table societe_rib $result = $bac->fetch(0, $this->socid, 1, 'ban'); @@ -974,295 +974,307 @@ abstract class CommonInvoice extends CommonObject $amountstripe = $amountstripe * 100; } + $fk_bank_account = getDolGlobalInt('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'); + if (!($fk_bank_account > 0)) { + $error++; + $errorforinvoice++; + dol_syslog("Error no bank account defined for Stripe payments", LOG_ERR); + $this->errors[] = "Error bank account for Stripe payments not defined into Stripe module"; + } + $this->db->begin(); // Create a prelevement_bon $bon = new BonPrelevement($this->db); - if (empty($obj->fk_prelevement_bons)) { - // This create record into llx_prelevment_bons and update link with llx_prelevement_demande - $nbinvoices = $bon->create(0, 0, 'real', 'ALL', '', 0, 'direct-debit', $did); - if ($nbinvoices <= 0) { + if (!$error) { + if (empty($obj->fk_prelevement_bons)) { + // This create record into llx_prelevment_bons and update link with llx_prelevement_demande + $nbinvoices = $bon->create(0, 0, 'real', 'ALL', '', 0, 'direct-debit', $did, $fk_bank_account); + if ($nbinvoices <= 0) { + $error++; + $errorforinvoice++; + dol_syslog("Error on BonPrelevement creation", LOG_ERR); + $this->errors[] = "Error on BonPrelevement creation"; + } + /* + if (!$error) { + // Update the direct debit payment request of the processed request to save the id of the prelevement_bon + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_demande SET"; + $sql .= " fk_prelevement_bons = ".((int) $bon->id); + $sql .= " WHERE rowid = ".((int) $did); + + $result = $this->db->query($sql); + if ($result < 0) { + $error++; + $this->errors[] = "Error on updateing fk_prelevement_bons to ".$bon->id; + } + } + */ + } else { $error++; $errorforinvoice++; - dol_syslog("Error on BonPrelevement creation", LOG_ERR); - $this->errors[] = "Error on BonPrelevement creation"; + dol_syslog("Error Line already part of a bank payment order", LOG_ERR); + $this->errors[] = "The line is already included into a bank payment order. Delete the bank payment order first."; } - /* - if (!$error) { - // Update the direct debit payment request of the processed request to save the id of the prelevement_bon - $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_demande SET"; - $sql .= " fk_prelevement_bons = ".((int) $bon->id); - $sql .= " WHERE rowid = ".((int) $did); - - $result = $this->db->query($sql); - if ($result < 0) { - $error++; - $this->errors[] = "Error on updateing fk_prelevement_bons to ".$bon->id; - } - } - */ - } else { - $error++; - $errorforinvoice++; - dol_syslog("Error Line already part of a bank payment order", LOG_ERR); - $this->errors[] = "The line is already included into a bank payment order. Delete the bank payment order first."; } - if (!$error && $amountstripe > 0) { - try { - //var_dump($companypaymentmode); - dol_syslog("We will try to pay with companypaymentmodeid=" . $companypaymentmode->id . " stripe_card_ref=" . $companypaymentmode->stripe_card_ref . " mode=" . $companypaymentmode->status, LOG_DEBUG); + if (!$error) { + if ($amountstripe > 0) { + try { + //var_dump($companypaymentmode); + dol_syslog("We will try to pay with companypaymentmodeid=" . $companypaymentmode->id . " stripe_card_ref=" . $companypaymentmode->stripe_card_ref . " mode=" . $companypaymentmode->status, LOG_DEBUG); - $thirdparty = new Societe($this->db); - $resultthirdparty = $thirdparty->fetch($this->socid); + $thirdparty = new Societe($this->db); + $resultthirdparty = $thirdparty->fetch($this->socid); - include_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php - // So it inits or erases the $stripearrayofkeysbyenv - $stripe = new Stripe($this->db); + include_once DOL_DOCUMENT_ROOT . '/stripe/class/stripe.class.php'; // This include the include of htdocs/stripe/config.php + // So it inits or erases the $stripearrayofkeysbyenv + $stripe = new Stripe($this->db); - dol_syslog("makeStripeSepaRequest Current Stripe environment is " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']); + dol_syslog("makeStripeSepaRequest Current Stripe environment is " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']); - $stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus]; - \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); + $stripearrayofkeys = $stripearrayofkeysbyenv[$servicestatus]; + \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); - dol_syslog("makeStripeSepaRequest get stripe connet account", LOG_DEBUG); - $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) - dol_syslog("makeStripeSepaRequest get stripe connect account return " . json_encode($stripeacc), LOG_DEBUG); + dol_syslog("makeStripeSepaRequest get stripe connet account", LOG_DEBUG); + $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) + dol_syslog("makeStripeSepaRequest get stripe connect account return " . json_encode($stripeacc), LOG_DEBUG); - $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0); - if (empty($customer) && !empty($stripe->error)) { - $this->errors[] = $stripe->error; - } + $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0); + if (empty($customer) && !empty($stripe->error)) { + $this->errors[] = $stripe->error; + } - // $nbhoursbetweentries = (empty($conf->global->SELLYOURSAAS_NBHOURSBETWEENTRIES) ? 49 : $conf->global->SELLYOURSAAS_NBHOURSBETWEENTRIES); // Must have more that 48 hours + 1 between each try (so 1 try every 3 daily batch) - // $nbdaysbeforeendoftries = (empty($conf->global->SELLYOURSAAS_NBDAYSBEFOREENDOFTRIES) ? 35 : $conf->global->SELLYOURSAAS_NBDAYSBEFOREENDOFTRIES); - $postactionmessages = []; + // $nbhoursbetweentries = (empty($conf->global->SELLYOURSAAS_NBHOURSBETWEENTRIES) ? 49 : $conf->global->SELLYOURSAAS_NBHOURSBETWEENTRIES); // Must have more that 48 hours + 1 between each try (so 1 try every 3 daily batch) + // $nbdaysbeforeendoftries = (empty($conf->global->SELLYOURSAAS_NBDAYSBEFOREENDOFTRIES) ? 35 : $conf->global->SELLYOURSAAS_NBDAYSBEFOREENDOFTRIES); + $postactionmessages = []; - if ($resultthirdparty > 0 && !empty($customer)) { - if (!$error) { // Payment was not canceled - $sepaMode = false; - $stripecard = null; - if ($companypaymentmode->type == 'ban') { - $sepaMode = true; - // Check into societe_rib if a payment mode for Stripe and ban payment exists - // To make a Stripe SEPA payment request, we must have the payment mode source already saved into societe_rib and retreived with ->sepaStripe - // The payment mode source is created when we create the bank account on Stripe with paymentmodes.php?action=create - $stripecard = $stripe->sepaStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0); - } - - if ($stripecard) { // Can be src_... (for sepa) or pm_... (new card mode). Note that card_... (old card mode) should not happen here. - $FULLTAG = 'DID='.$did.'-INV=' . $this->id . '-CUS=' . $thirdparty->id; - $description = 'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG . ' did='.$did.' ref=' . $this->ref; - - $stripefailurecode = ''; - $stripefailuremessage = ''; - $stripefailuredeclinecode = ''; - - // Using new SCA method - dol_syslog("* Create payment on SEPA " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); - - // Create payment intent and charge payment (confirmnow = true) - $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1, 1, $did); - - $charge = new stdClass(); - - if ($paymentintent->status === 'succeeded' || $paymentintent->status === 'processing') { - $charge->status = 'ok'; - $charge->id = $paymentintent->id; - $charge->customer = $customer->id; - } elseif ($paymentintent->status === 'requires_action') { - //paymentintent->status may be => 'requires_action' (no error in such a case) - dol_syslog(var_export($paymentintent, true), LOG_DEBUG); - - $charge->status = 'failed'; - $charge->customer = $customer->id; - $charge->failure_code = $stripe->code; - $charge->failure_message = $stripe->error; - $charge->failure_declinecode = $stripe->declinecode; - $stripefailurecode = $stripe->code; - $stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL; - $stripefailuredeclinecode = $stripe->declinecode; - } else { - dol_syslog(var_export($paymentintent, true), LOG_DEBUG); - - $charge->status = 'failed'; - $charge->customer = $customer->id; - $charge->failure_code = $stripe->code; - $charge->failure_message = $stripe->error; - $charge->failure_declinecode = $stripe->declinecode; - $stripefailurecode = $stripe->code; - $stripefailuremessage = $stripe->error; - $stripefailuredeclinecode = $stripe->declinecode; + if ($resultthirdparty > 0 && !empty($customer)) { + if (!$error) { // Payment was not canceled + $sepaMode = false; + $stripecard = null; + if ($companypaymentmode->type == 'ban') { + $sepaMode = true; + // Check into societe_rib if a payment mode for Stripe and ban payment exists + // To make a Stripe SEPA payment request, we must have the payment mode source already saved into societe_rib and retreived with ->sepaStripe + // The payment mode source is created when we create the bank account on Stripe with paymentmodes.php?action=create + $stripecard = $stripe->sepaStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0); } - //var_dump("stripefailurecode=".$stripefailurecode." stripefailuremessage=".$stripefailuremessage." stripefailuredeclinecode=".$stripefailuredeclinecode); - //exit; + if ($stripecard) { // Can be src_... (for sepa) or pm_... (new card mode). Note that card_... (old card mode) should not happen here. + $FULLTAG = 'DID='.$did.'-INV=' . $this->id . '-CUS=' . $thirdparty->id; + $description = 'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG . ' did='.$did.' ref=' . $this->ref; + $stripefailurecode = ''; + $stripefailuremessage = ''; + $stripefailuredeclinecode = ''; - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge) || $charge->status == 'failed') { - dol_syslog('Failed to charge payment mode ' . $stripecard->id . ' stripefailurecode=' . $stripefailurecode . ' stripefailuremessage=' . $stripefailuremessage . ' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING); + // Using new SCA method + dol_syslog("* Create payment on SEPA " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); - // Save a stripe payment was in error - $this->stripechargeerror++; + // Create payment intent and charge payment (confirmnow = true) + $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1, 1, $did); - $error++; - $errorforinvoice++; - $errmsg = $langs->trans("FailedToChargeCard"); - if (!empty($charge)) { - if ($stripefailuredeclinecode == 'authentication_required') { - $errauthenticationmessage = $langs->trans("ErrSCAAuthentication"); - $errmsg = $errauthenticationmessage; - } elseif (in_array($stripefailuredeclinecode, ['insufficient_funds', 'generic_decline'])) { - $errmsg .= ': ' . $charge->failure_code; - $errmsg .= ($charge->failure_message ? ' - ' : '') . ' ' . $charge->failure_message; - if (empty($stripefailurecode)) { - $stripefailurecode = $charge->failure_code; - } - if (empty($stripefailuremessage)) { - $stripefailuremessage = $charge->failure_message; - } - } else { - $errmsg .= ': failure_code=' . $charge->failure_code; - $errmsg .= ($charge->failure_message ? ' - ' : '') . ' failure_message=' . $charge->failure_message; - if (empty($stripefailurecode)) { - $stripefailurecode = $charge->failure_code; - } - if (empty($stripefailuremessage)) { - $stripefailuremessage = $charge->failure_message; - } - } + $charge = new stdClass(); + + if ($paymentintent->status === 'succeeded' || $paymentintent->status === 'processing') { + $charge->status = 'ok'; + $charge->id = $paymentintent->id; + $charge->customer = $customer->id; + } elseif ($paymentintent->status === 'requires_action') { + //paymentintent->status may be => 'requires_action' (no error in such a case) + dol_syslog(var_export($paymentintent, true), LOG_DEBUG); + + $charge->status = 'failed'; + $charge->customer = $customer->id; + $charge->failure_code = $stripe->code; + $charge->failure_message = $stripe->error; + $charge->failure_declinecode = $stripe->declinecode; + $stripefailurecode = $stripe->code; + $stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL; + $stripefailuredeclinecode = $stripe->declinecode; } else { - $errmsg .= ': ' . $stripefailurecode . ' - ' . $stripefailuremessage; - $errmsg .= ($stripefailuredeclinecode ? ' - ' . $stripefailuredeclinecode : ''); + dol_syslog(var_export($paymentintent, true), LOG_DEBUG); + + $charge->status = 'failed'; + $charge->customer = $customer->id; + $charge->failure_code = $stripe->code; + $charge->failure_message = $stripe->error; + $charge->failure_declinecode = $stripe->declinecode; + $stripefailurecode = $stripe->code; + $stripefailuremessage = $stripe->error; + $stripefailuredeclinecode = $stripe->declinecode; } - $description = 'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG; - $postactionmessages[] = $errmsg . ' (' . $stripearrayofkeys['publishable_key'] . ')'; - $this->errors[] = $errmsg; + //var_dump("stripefailurecode=".$stripefailurecode." stripefailuremessage=".$stripefailuremessage." stripefailuredeclinecode=".$stripefailuredeclinecode); + //exit; + + + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge) || $charge->status == 'failed') { + dol_syslog('Failed to charge payment mode ' . $stripecard->id . ' stripefailurecode=' . $stripefailurecode . ' stripefailuremessage=' . $stripefailuremessage . ' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING); + + // Save a stripe payment was in error + $this->stripechargeerror++; + + $error++; + $errorforinvoice++; + $errmsg = $langs->trans("FailedToChargeCard"); + if (!empty($charge)) { + if ($stripefailuredeclinecode == 'authentication_required') { + $errauthenticationmessage = $langs->trans("ErrSCAAuthentication"); + $errmsg = $errauthenticationmessage; + } elseif (in_array($stripefailuredeclinecode, ['insufficient_funds', 'generic_decline'])) { + $errmsg .= ': ' . $charge->failure_code; + $errmsg .= ($charge->failure_message ? ' - ' : '') . ' ' . $charge->failure_message; + if (empty($stripefailurecode)) { + $stripefailurecode = $charge->failure_code; + } + if (empty($stripefailuremessage)) { + $stripefailuremessage = $charge->failure_message; + } + } else { + $errmsg .= ': failure_code=' . $charge->failure_code; + $errmsg .= ($charge->failure_message ? ' - ' : '') . ' failure_message=' . $charge->failure_message; + if (empty($stripefailurecode)) { + $stripefailurecode = $charge->failure_code; + } + if (empty($stripefailuremessage)) { + $stripefailuremessage = $charge->failure_message; + } + } + } else { + $errmsg .= ': ' . $stripefailurecode . ' - ' . $stripefailuremessage; + $errmsg .= ($stripefailuredeclinecode ? ' - ' . $stripefailuredeclinecode : ''); + } + + $description = 'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG; + $postactionmessages[] = $errmsg . ' (' . $stripearrayofkeys['publishable_key'] . ')'; + $this->errors[] = $errmsg; + } else { + dol_syslog('Successfuly request direct debit ' . $stripecard->id); + + $postactionmessages[] = 'Success to request direct debit (' . $charge->id . ' with ' . $stripearrayofkeys['publishable_key'] . ')'; + + // Save a stripe payment was done in realy life so later we will be able to force a commit on recorded payments + // even if in batch mode (method doTakePaymentStripe), we will always make all action in one transaction with a forced commit. + $this->stripechargedone++; + + // Default description used for label of event. Will be overwrite by another value later. + $description = 'Stripe payment request OK (' . $charge->id . ') from makeStripeSepaRequest: ' . $FULLTAG; + } + + $object = $this; + + // Track an event + if (empty($charge) || $charge->status == 'failed') { + $actioncode = 'PAYMENT_STRIPE_KO'; + $extraparams = $stripefailurecode; + $extraparams .= (($extraparams && $stripefailuremessage) ? ' - ' : '') . $stripefailuremessage; + $extraparams .= (($extraparams && $stripefailuredeclinecode) ? ' - ' : '') . $stripefailuredeclinecode; + } else { + $actioncode = 'PAYMENT_STRIPE_OK'; + $extraparams = ''; + } } else { - dol_syslog('Successfuly request direct debit ' . $stripecard->id); + $error++; + $errorforinvoice++; + dol_syslog("No direct debit payment method found for this stripe customer " . $customer->id, LOG_WARNING); + $this->errors[] = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id; - $postactionmessages[] = 'Success to request direct debit (' . $charge->id . ' with ' . $stripearrayofkeys['publishable_key'] . ')'; + $description = 'Failed to find or use the payment mode - no credit card defined for the customer account'; + $stripefailurecode = 'BADPAYMENTMODE'; + $stripefailuremessage = 'Failed to find or use the payment mode - no credit card defined for the customer account'; + $postactionmessages[] = $description . ' (' . $stripearrayofkeys['publishable_key'] . ')'; - // Save a stripe payment was done in realy life so later we will be able to force a commit on recorded payments - // even if in batch mode (method doTakePaymentStripe), we will always make all action in one transaction with a forced commit. - $this->stripechargedone++; + $object = $this; - // Default description used for label of event. Will be overwrite by another value later. - $description = 'Stripe payment request OK (' . $charge->id . ') from makeStripeSepaRequest: ' . $FULLTAG; - } - - $object = $this; - - // Track an event - if (empty($charge) || $charge->status == 'failed') { $actioncode = 'PAYMENT_STRIPE_KO'; - $extraparams = $stripefailurecode; - $extraparams .= (($extraparams && $stripefailuremessage) ? ' - ' : '') . $stripefailuremessage; - $extraparams .= (($extraparams && $stripefailuredeclinecode) ? ' - ' : '') . $stripefailuredeclinecode; - } else { - $actioncode = 'PAYMENT_STRIPE_OK'; $extraparams = ''; } } else { - $error++; - $errorforinvoice++; - dol_syslog("No direct debit payment method found for this stripe customer " . $customer->id, LOG_WARNING); - $this->errors[] = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id; - - $description = 'Failed to find or use the payment mode - no credit card defined for the customer account'; - $stripefailurecode = 'BADPAYMENTMODE'; - $stripefailuremessage = 'Failed to find or use the payment mode - no credit card defined for the customer account'; - $postactionmessages[] = $description . ' (' . $stripearrayofkeys['publishable_key'] . ')'; + // If error because payment was canceled for a logical reason, we do nothing (no event added) + $description = ''; + $stripefailurecode = ''; + $stripefailuremessage = ''; $object = $this; - $actioncode = 'PAYMENT_STRIPE_KO'; + $actioncode = ''; $extraparams = ''; } - } else { - // If error because payment was canceled for a logical reason, we do nothing (no event added) - $description = ''; - $stripefailurecode = ''; - $stripefailuremessage = ''; + } else { // Else of the if ($resultthirdparty > 0 && ! empty($customer)) { + if ($resultthirdparty <= 0) { + dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING); + $this->errors[] = 'Failed to load customer for thirdparty_id = ' . $thirdparty->id; + } else { // $customer stripe not found + dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING); + $this->errors[] = 'Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']; + } + $error++; + $errorforinvoice++; + + $description = 'Failed to find or use your payment mode (no payment mode for this customer id)'; + $stripefailurecode = 'BADPAYMENTMODE'; + $stripefailuremessage = 'Failed to find or use your payment mode (no payment mode for this customer id)'; + $postactionmessages = []; $object = $this; - $actioncode = ''; + $actioncode = 'PAYMENT_STRIPE_KO'; $extraparams = ''; } - } else { // Else of the if ($resultthirdparty > 0 && ! empty($customer)) { - if ($resultthirdparty <= 0) { - dol_syslog('SellYourSaasUtils Failed to load customer for thirdparty_id = ' . $thirdparty->id, LOG_WARNING); - $this->errors[] = 'Failed to load customer for thirdparty_id = ' . $thirdparty->id; - } else { // $customer stripe not found - dol_syslog('SellYourSaasUtils Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_WARNING); - $this->errors[] = 'Failed to get Stripe customer id for thirdparty_id = ' . $thirdparty->id . " in mode " . $servicestatus . " in Stripe env " . $stripearrayofkeysbyenv[$servicestatus]['publishable_key']; + + if ($description) { + dol_syslog("* Record event for credit transfer or direct debit request result - " . $description); + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + + // Insert record of payment (success or error) + $actioncomm = new ActionComm($this->db); + + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_' . $actioncode; + $actioncomm->label = $description; + $actioncomm->note_private = join(",\n", $postactionmessages); + $actioncomm->fk_project = $this->fk_project; + $actioncomm->datep = $now; + $actioncomm->datef = $now; + $actioncomm->percentage = -1; // Not applicable + $actioncomm->socid = $thirdparty->id; + $actioncomm->contactid = 0; + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action + // Fields when action is a real email (content is already into note) + /*$actioncomm->email_msgid = $object->email_msgid; + $actioncomm->email_from = $object->email_from; + $actioncomm->email_sender= $object->email_sender; + $actioncomm->email_to = $object->email_to; + $actioncomm->email_tocc = $object->email_tocc; + $actioncomm->email_tobcc = $object->email_tobcc; + $actioncomm->email_subject = $object->email_subject; + $actioncomm->errors_to = $object->errors_to;*/ + $actioncomm->fk_element = $this->id; + $actioncomm->elementtype = $this->element; + $actioncomm->extraparams = dol_trunc($extraparams, 250); + + $actioncomm->create($user); } + + $this->description = $description; + $this->postactionmessages = $postactionmessages; + } catch (Exception $e) { $error++; $errorforinvoice++; - - $description = 'Failed to find or use your payment mode (no payment mode for this customer id)'; - $stripefailurecode = 'BADPAYMENTMODE'; - $stripefailuremessage = 'Failed to find or use your payment mode (no payment mode for this customer id)'; - $postactionmessages = []; - - $object = $this; - - $actioncode = 'PAYMENT_STRIPE_KO'; - $extraparams = ''; + dol_syslog('Error ' . $e->getMessage(), LOG_ERR); + $this->errors[] = 'Error ' . $e->getMessage(); } - - if ($description) { - dol_syslog("* Record event for credit transfer or direct debit request result - " . $description); - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - - // Insert record of payment (success or error) - $actioncomm = new ActionComm($this->db); - - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_' . $actioncode; - $actioncomm->label = $description; - $actioncomm->note_private = join(",\n", $postactionmessages); - $actioncomm->fk_project = $this->fk_project; - $actioncomm->datep = $now; - $actioncomm->datef = $now; - $actioncomm->percentage = -1; // Not applicable - $actioncomm->socid = $thirdparty->id; - $actioncomm->contactid = 0; - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action - // Fields when action is a real email (content is already into note) - /*$actioncomm->email_msgid = $object->email_msgid; - $actioncomm->email_from = $object->email_from; - $actioncomm->email_sender= $object->email_sender; - $actioncomm->email_to = $object->email_to; - $actioncomm->email_tocc = $object->email_tocc; - $actioncomm->email_tobcc = $object->email_tobcc; - $actioncomm->email_subject = $object->email_subject; - $actioncomm->errors_to = $object->errors_to;*/ - $actioncomm->fk_element = $this->id; - $actioncomm->elementtype = $this->element; - $actioncomm->extraparams = dol_trunc($extraparams, 250); - - $actioncomm->create($user); - } - - $this->description = $description; - $this->postactionmessages = $postactionmessages; - } catch (Exception $e) { + } else { // If remain to pay is null $error++; $errorforinvoice++; - dol_syslog('Error ' . $e->getMessage(), LOG_ERR); - $this->errors[] = 'Error ' . $e->getMessage(); + dol_syslog("Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?", LOG_WARNING); + $this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?"; } - } else { // If remain to pay is null - $error++; - $errorforinvoice++; - dol_syslog("Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?", LOG_WARNING); - $this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?"; } // Set status of the order to "Transferred" with method 'api' diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 75662d57f94..763e97a17e4 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -46,6 +46,12 @@ class FileUpload global $db, $conf; global $object; global $hookmanager; + + // Feature not enabled. Warning feature not used and not secured so disabled. + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + $hookmanager->initHooks(array('fileupload')); $this->fk_element = $fk_element; @@ -238,6 +244,10 @@ class FileUpload */ protected function getFileObject($file_name) { + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + $file_path = $this->options['upload_dir'].$file_name; if (is_file($file_path) && $file_name[0] !== '.') { $file = new stdClass(); @@ -278,6 +288,10 @@ class FileUpload { global $maxwidthmini, $maxheightmini; + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + $file_path = $this->options['upload_dir'].$file_name; $new_file_path = $options['upload_dir'].$file_name; @@ -309,6 +323,10 @@ class FileUpload */ protected function validate($uploaded_file, $file, $error, $index) { + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + if ($error) { $file->error = $error; return false; @@ -399,8 +417,8 @@ class FileUpload // Also remove control characters and spaces (\x00..\x20) around the filename: $file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); // Add missing file extension for known image types: - if (strpos($file_name, '.') === false && - preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { + $matches = array(); + if (strpos($file_name, '.') === false && preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { $file_name .= '.'.$matches[1]; } if ($this->options['discard_aborted_uploads']) { @@ -424,6 +442,10 @@ class FileUpload */ protected function handleFileUpload($uploaded_file, $name, $size, $type, $error, $index) { + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + $file = new stdClass(); $file->name = $this->trimFileName($name, $type, $index); $file->mime = dol_mimetype($file->name, '', 2); @@ -470,6 +492,10 @@ class FileUpload */ public function get() { + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + $file_name = isset($_REQUEST['file']) ? basename(stripslashes($_REQUEST['file'])) : null; if ($file_name) { @@ -488,6 +514,10 @@ class FileUpload */ public function post() { + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { return $this->delete(); } @@ -543,6 +573,10 @@ class FileUpload */ public function delete() { + if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) { + return; + } + $file_name = isset($_REQUEST['file']) ? basename(stripslashes($_REQUEST['file'])) : null; $file_path = $this->options['upload_dir'].$file_name; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 74d7e1eaf85..4cb98acbe45 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -94,7 +94,7 @@ class Form * @param string $text Text of label or key to translate * @param string $htmlname Name of select field ('edit' prefix will be added) * @param string $preselected Value to show/edit (not used in this function) - * @param object $object Object + * @param object $object Object (on the page we show) * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker' 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) * @param string $moreparam More param to add on a href URL. @@ -194,7 +194,7 @@ class Form * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field * @param string $value Value to show/edit - * @param object $object Object + * @param object $object Object (that we want to show) * @param boolean $perm Permission to allow button to edit parameter * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value @@ -303,6 +303,8 @@ class Form $arraylist[$tmpkey] = $tmp[1]; } $ret .= $this->selectarray($htmlname, $arraylist, $value); + } elseif (preg_match('/^link/', $typeofdata)) { + // TODO Not yet implemented. See code for extrafields } elseif (preg_match('/^ckeditor/', $typeofdata)) { $tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 695b1ab657b..ef252765ea0 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -41,7 +41,7 @@ class FormCategory extends Form * @param string $showempty 1 or 'string' to add an empty entry * @return string A HTML filter box (Note: selected results can get with GETPOST("search_category_".$type."_list")) */ - public function getFilterBox($type, array $preSelected, $morecss = "minwidth300 widthcentpercentminusx", $searchCategoryProductOperator = -1, $multiselect = 1, $nocateg = 1, $showempty = '') + public function getFilterBox($type, array $preSelected, $morecss = "minwidth300imp widthcentpercentminusx", $searchCategoryProductOperator = -1, $multiselect = 1, $nocateg = 1, $showempty = '') { global $langs, $db; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 91d18049070..e2a1cafcb3d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -908,7 +908,7 @@ class FormCompany extends Form * @param string $morecss More css * @return string HTML string with prof id */ - public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') + public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200') { // phpcs:enable global $conf, $langs, $hookmanager; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index e8187fe7290..c4548657c33 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1431,7 +1431,7 @@ class FormTicket $res = $ticketstat->fetch('', '', $this->track_id); print ' | |
| '; - $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?'checked':'')); + $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : (getDolGlobalInt('TICKETS_MESSAGE_FORCE_MAIL')?'checked':'')); print ' '; print ''; $texttooltip = $langs->trans("TicketMessageSendEmailHelp", '{s1}'); @@ -1463,7 +1463,7 @@ class FormTicket // Subject print ' | ||
| '.$langs->trans('Subject').' | '; - print 'ref.'] '.$langs->trans('TicketNewMessage').'" />'; + print ' | ref.'] '.$langs->trans('TicketNewMessage').'" />'; print ' |