diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index e31b43f5a43..71f6a28a7cd 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1653,7 +1653,7 @@ if (empty($reshook)) {
// Actions to build doc
$upload_dir = !empty($conf->propal->multidir_output[$object->entity])?$conf->propal->multidir_output[$object->entity]:$conf->propal->dir_output;
$permissiontoadd = $usercancreate;
- include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql
index 64ede43cf9f..80b2f3be0b5 100644
--- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql
+++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql
@@ -411,3 +411,4 @@ CREATE TABLE llx_c_invoice_subtype (
ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code);
+ALTER TABLE llx_societe_rib ADD COLUMN last_main_doc varchar(255) AFTER currency_code;
diff --git a/htdocs/install/mysql/tables/llx_societe_rib.sql b/htdocs/install/mysql/tables/llx_societe_rib.sql
index a798f6ac594..ea264e7d169 100644
--- a/htdocs/install/mysql/tables/llx_societe_rib.sql
+++ b/htdocs/install/mysql/tables/llx_societe_rib.sql
@@ -47,12 +47,14 @@ create table llx_societe_rib
fk_country integer,
currency_code varchar(3),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
+
-- For BAN direct debit feature
rum varchar(32), -- RUM value to use for SEPA generation
date_rum date, -- Date of mandate
frstrecur varchar(16) default 'FRST', -- 'FRST' or 'RECUR'
- --For credit card
+ -- For credit card
last_four varchar(4), -- last 4
card_type varchar(255), -- card type 'VISA', 'MC' , ...
cvn varchar(255),
@@ -60,7 +62,7 @@ create table llx_societe_rib
exp_date_year INTEGER,
country_code varchar(10),
- --For Paypal
+ -- For Paypal
approved INTEGER DEFAULT 0,
email varchar(255),
ending_date date,
@@ -69,7 +71,7 @@ create table llx_societe_rib
starting_date date,
total_amount_of_all_payments double(24,8),
- --For Stripe
+ -- For Stripe
stripe_card_ref varchar(128), -- 'card_...'
stripe_account varchar(128), -- 'pk_live_...'
diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php
index 532f6ff4a59..b0457815b14 100644
--- a/htdocs/public/onlinesign/newonlinesign.php
+++ b/htdocs/public/onlinesign/newonlinesign.php
@@ -56,7 +56,6 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
// Load translation files
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "members", "paybox", "propal", "commercial"));
-
// Security check
// No check on module enabled. Done later according to $validpaymentmethod
@@ -139,10 +138,11 @@ if ($source == 'proposal') {
} elseif ($source == 'societe_rib') {
$securekeyseed = getDolGlobalString('SOCIETE_RIB_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
+var_dump($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY);
if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, '0')) {
httponly_accessforbidden('Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref), 403, 1);
}
-
+var_dump('truc');
if ($source == 'proposal') {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object = new Propal($db);
@@ -532,24 +532,24 @@ if ($source == 'proposal') {
$result = $object->fetch_thirdparty();
// Proposer
- print '
| '.$langs->trans("Proposer");
+ print ' |
| ' . $langs->trans("Proposer");
print ' | ';
print img_picto('', 'company', 'class="pictofixedwidth"');
- print ''.$creditor.'';
- print '';
- print ' |
'."\n";
+ print '' . $creditor . '';
+ print '';
+ print '' . "\n";
// Target
- print '| '.$langs->trans("ThirdParty");
+ print ' |
| ' . $langs->trans("ThirdParty");
print ' | ';
print img_picto('', 'company', 'class="pictofixedwidth"');
- print ''.$object->thirdparty->name.'';
- print ' |
'."\n";
+ print '' . $object->thirdparty->name . '';
+ print '' . "\n";
// Object
- $text = ''.$langs->trans("Signature".dol_ucfirst($source)."Ref", $object->ref).'';
- print '| '.$langs->trans("Designation");
- print ' | '.$text;
+ $text = '' . $langs->trans("Signature" . dol_ucfirst($source) . "Ref", $object->ref) . '';
+ print ' |
| ' . $langs->trans("Designation");
+ print ' | ' . $text;
$last_main_doc_file = $object->last_main_doc;
@@ -560,10 +560,12 @@ if ($source == 'proposal') {
// It seems document has never been generated, or was generated and then deleted.
// So we try to regenerate it with its default template.
$defaulttemplate = 'sepamandate';
- $object->thirdparty->generateDocument($defaulttemplate, $langs);
+ //$result = $companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
+ $result = $object->thirdparty->generateDocument($defaulttemplate, $langs);
}
$directdownloadlink = $object->thirdparty->getLastMainDocLink($source);
+ var_dump($directdownloadlink);
if ($directdownloadlink) {
print ' ';
print img_mime($object->last_main_doc, '');
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index 7598e9a0838..20703af9437 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -33,33 +33,107 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
*/
class CompanyBankAccount extends Account
{
- public $socid;
-
/**
- * @var string ID to identify managed object
+ * @var string ID to identify managed object.
*/
public $element = 'societe_rib';
/**
- * @var string Name of table without prefix where object is stored
+ * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
*/
public $table_element = 'societe_rib';
- /** @var bool $default_rib 1 = this object is the third party's default bank information */
- public $default_rib;
-
/**
- * Value 'FRST' or 'RCUR' (For SEPA mandate). Warning, in database, we store 'RECUR'.
+ * '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 Universal 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' and 'helplist' 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)
*
- * @var string
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
- public $frstrecur;
- public $rum;
- public $date_rum;
-
- public $stripe_card_ref; // ID of BAN into an external payment system
- public $stripe_account; // Account of the external payment system
+ // 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'=>-1,),
+ 'type' => array('type'=>'varchar(32)', 'label'=>'Type', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-1,),
+ 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
+ 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>-1,),
+ 'label' => array('type'=>'varchar(200)', 'label'=>'Label', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1', 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax150',),
+ 'bank' => array('type'=>'varchar(255)', 'label'=>'Bank', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'code_banque' => array('type'=>'varchar(128)', 'label'=>'Codebanque', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'code_guichet' => array('type'=>'varchar(6)', 'label'=>'Codeguichet', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'number' => array('type'=>'varchar(255)', 'label'=>'Number', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'cle_rib' => array('type'=>'varchar(5)', 'label'=>'Clerib', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'bic' => array('type'=>'varchar(20)', 'label'=>'Bic', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'iban_prefix' => array('type'=>'varchar(34)', 'label'=>'Ibanprefix', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'domiciliation' => array('type'=>'varchar(255)', 'label'=>'Domiciliation', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'proprio' => array('type'=>'varchar(60)', 'label'=>'Proprio', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'owner_address' => array('type'=>'varchar(255)', 'label'=>'Owneraddress', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'default_rib' => array('type'=>'smallint(6)', 'label'=>'Defaultrib', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'state_id' => array('type'=>'integer', 'label'=>'Stateid', 'enabled'=>'1', 'position'=>95, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'fk_country' => array('type'=>'integer', 'label'=>'Fkcountry', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1', 'css'=>'maxwidth500 widthcentpercentminusxx',),
+ 'currency_code' => array('type'=>'varchar(3)', 'label'=>'Currencycode', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'rum' => array('type'=>'varchar(32)', 'label'=>'Rum', 'enabled'=>'1', 'position'=>110, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'date_rum' => array('type'=>'date', 'label'=>'Daterum', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'frstrecur' => array('type'=>'varchar(16)', 'label'=>'Frstrecur', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2, 'alwayseditable'=>'1',),
+ 'last_four' => array('type'=>'varchar(4)', 'label'=>'Lastfour', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'card_type' => array('type'=>'varchar(255)', 'label'=>'Cardtype', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'cvn' => array('type'=>'varchar(255)', 'label'=>'Cvn', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'exp_date_month' => array('type'=>'integer', 'label'=>'Expdatemonth', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'exp_date_year' => array('type'=>'integer', 'label'=>'Expdateyear', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'country_code' => array('type'=>'varchar(10)', 'label'=>'Countrycode', 'enabled'=>'1', 'position'=>155, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'approved' => array('type'=>'integer', 'label'=>'Approved', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'enabled'=>'1', 'position'=>165, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'ending_date' => array('type'=>'date', 'label'=>'Endingdate', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'max_total_amount_of_all_payments' => array('type'=>'double(24,8)', 'label'=>'Maxtotalamountofallpayments', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'preapproval_key' => array('type'=>'varchar(255)', 'label'=>'Preapprovalkey', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'starting_date' => array('type'=>'date', 'label'=>'Startingdate', 'enabled'=>'1', 'position'=>185, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'total_amount_of_all_payments' => array('type'=>'double(24,8)', 'label'=>'Totalamountofallpayments', 'enabled'=>'1', 'position'=>190, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'stripe_card_ref' => array('type'=>'varchar(128)', 'label'=>'Stripecardref', 'enabled'=>'1', 'position'=>195, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'comment' => array('type'=>'varchar(255)', 'label'=>'Comment', 'enabled'=>'1', 'position'=>205, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'ipaddress' => array('type'=>'varchar(68)', 'label'=>'Ipaddress', 'enabled'=>'1', 'position'=>210, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'stripe_account' => array('type'=>'varchar(128)', 'label'=>'Stripeaccount', 'enabled'=>'1', 'position'=>215, 'notnull'=>0, 'visible'=>-1, 'alwayseditable'=>'1',),
+ 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'position'=>230),
+ );
+ public $id;
+ public $type;
+ public $fk_soc;
/**
* Date creation record (datec)
@@ -67,6 +141,65 @@ class CompanyBankAccount extends Account
* @var integer
*/
public $datec;
+ public $label;
+ public $bank;
+ public $code_banque;
+ public $code_guichet;
+ public $number;
+ public $cle_rib;
+ public $bic;
+ public $iban_prefix;
+ public $domiciliation;
+ public $proprio;
+ public $owner_address;
+
+ /**
+ * @var bool $default_rib 1 = this object is the third party's default bank information
+ */
+ public $default_rib;
+ public $state_id;
+ public $fk_country;
+ public $currency_code;
+ public $rum;
+ public $date_rum;
+
+ /**
+ * Value 'FRST' or 'RCUR' (For SEPA mandate). Warning, in database, we store 'RECUR'.
+ *
+ * @var string
+ */
+ public $frstrecur;
+ public $import_key;
+ public $last_four;
+ public $card_type;
+ public $cvn;
+ public $exp_date_month;
+ public $exp_date_year;
+ public $country_code;
+ public $approved;
+ public $email;
+ public $ending_date;
+ public $max_total_amount_of_all_payments;
+ public $preapproval_key;
+ public $starting_date;
+ public $total_amount_of_all_payments;
+
+ /**
+ * ID of BAN into an external payment system
+ *
+ * @var string
+ */
+ public $stripe_card_ref;
+ public $status;
+ public $comment;
+ public $ipaddress;
+
+ /**
+ * Account of the external payment system
+ *
+ * @var string
+ */
+ public $stripe_account;
/**
* Date modification record (tms)
@@ -82,6 +215,8 @@ class CompanyBankAccount extends Account
*/
const TRIGGER_PREFIX = 'COMPANY_RIB';
+ protected $update_main_doc_field;
+
/**
* Constructor
@@ -93,9 +228,11 @@ class CompanyBankAccount extends Account
$this->db = $db;
$this->socid = 0;
- $this->solde = 0;
$this->error_number = 0;
$this->default_rib = 0;
+ $this->type = "ban";
+
+ $this->update_main_doc_field = 1;
}
@@ -119,6 +256,10 @@ class CompanyBankAccount extends Account
return -1;
}
+ if (empty($this->datec)) {
+ $this->datec=$now;
+ }
+
// Correct ->default_rib to not set the new account as default, if there is already 1. We want to be sure to have always 1 default for type = 'ban'.
// If we really want the new bank account to be the default, we must set it by calling setDefault() after creation.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".((int) $this->socid)." AND default_rib = 1 AND type = 'ban'";
@@ -137,7 +278,7 @@ class CompanyBankAccount extends Account
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
- $sql .= " VALUES (".((int) $this->socid).", 'ban', '".$this->db->idate($now)."')";
+ $sql .= " VALUES (".((int) $this->socid).", '".$this->type."', '".$this->db->idate($this->datec)."')";
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->affected_rows($resql)) {
|