27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $element =
'companypaymentmode';
44 public $table_element =
'societe_rib';
49 public $picto =
'generic';
52 const STATUS_ENABLED = 1;
53 const STATUS_CANCELED = 0;
77 public $fields = array(
78 'rowid' => array(
'type' =>
'integer',
'label' =>
'Rowid',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 10),
79 'fk_soc' => array(
'type' =>
'integer',
'label' =>
'Fk soc',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15),
80 'label' => array(
'type' =>
'varchar(30)',
'label' =>
'Label',
'enabled' => 1,
'visible' => -2,
'position' => 30),
81 'bank' => array(
'type' =>
'varchar(255)',
'label' =>
'Bank',
'enabled' => 1,
'visible' => -2,
'position' => 35),
82 'code_banque' => array(
'type' =>
'varchar(128)',
'label' =>
'Code banque',
'enabled' => 1,
'visible' => -2,
'position' => 40),
83 'code_guichet' => array(
'type' =>
'varchar(6)',
'label' =>
'Code guichet',
'enabled' => 1,
'visible' => -2,
'position' => 45),
84 'number' => array(
'type' =>
'varchar(255)',
'label' =>
'Number',
'enabled' => 1,
'visible' => -2,
'position' => 50),
85 'cle_rib' => array(
'type' =>
'varchar(5)',
'label' =>
'Cle rib',
'enabled' => 1,
'visible' => -2,
'position' => 55),
86 'bic' => array(
'type' =>
'varchar(20)',
'label' =>
'Bic',
'enabled' => 1,
'visible' => -2,
'position' => 60),
87 'iban_prefix' => array(
'type' =>
'varchar(34)',
'label' =>
'Iban prefix',
'enabled' => 1,
'visible' => -2,
'position' => 65),
88 'domiciliation' => array(
'type' =>
'varchar(255)',
'label' =>
'Domiciliation',
'enabled' => 1,
'visible' => -2,
'position' => 70),
89 'proprio' => array(
'type' =>
'varchar(60)',
'label' =>
'Proprio',
'enabled' => 1,
'visible' => -2,
'position' => 75),
90 'owner_address' => array(
'type' =>
'text',
'label' =>
'Owner address',
'enabled' => 1,
'visible' => -2,
'position' => 80),
91 'default_rib' => array(
'type' =>
'tinyint(4)',
'label' =>
'Default rib',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 85),
92 'rum' => array(
'type' =>
'varchar(32)',
'label' =>
'Rum',
'enabled' => 1,
'visible' => -2,
'position' => 90),
93 'date_rum' => array(
'type' =>
'date',
'label' =>
'Date rum',
'enabled' => 1,
'visible' => -2,
'position' => 95),
94 'frstrecur' => array(
'type' =>
'varchar(16)',
'label' =>
'Frstrecur',
'enabled' => 1,
'visible' => -2,
'position' => 100),
95 'type' => array(
'type' =>
'varchar(32)',
'label' =>
'Type',
'enabled' => 1,
'visible' => -2,
'position' => 110),
96 'last_four' => array(
'type' =>
'varchar(4)',
'label' =>
'Last four',
'enabled' => 1,
'visible' => -2,
'position' => 115),
97 'card_type' => array(
'type' =>
'varchar(255)',
'label' =>
'Card type',
'enabled' => 1,
'visible' => -2,
'position' => 120),
98 'cvn' => array(
'type' =>
'varchar(255)',
'label' =>
'Cvn',
'enabled' => 1,
'visible' => -2,
'position' => 125),
99 'exp_date_month' => array(
'type' =>
'integer',
'label' =>
'Exp date month',
'enabled' => 1,
'visible' => -2,
'position' => 130),
100 'exp_date_year' => array(
'type' =>
'integer',
'label' =>
'Exp date year',
'enabled' => 1,
'visible' => -2,
'position' => 135),
101 'country_code' => array(
'type' =>
'varchar(10)',
'label' =>
'Country code',
'enabled' => 1,
'visible' => -2,
'position' => 140),
102 'approved' => array(
'type' =>
'integer',
'label' =>
'Approved',
'enabled' => 1,
'visible' => -2,
'position' => 145),
103 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => -2,
'position' => 150),
104 'max_total_amount_of_all_payments' => array(
'type' =>
'double(24,8)',
'label' =>
'Max total amount of all payments',
'enabled' => 1,
'visible' => -2,
'position' => 155),
105 'preapproval_key' => array(
'type' =>
'varchar(255)',
'label' =>
'Preapproval key',
'enabled' => 1,
'visible' => -2,
'position' => 160),
106 'total_amount_of_all_payments' => array(
'type' =>
'double(24,8)',
'label' =>
'Total amount of all payments',
'enabled' => 1,
'visible' => -2,
'position' => 165),
107 'stripe_card_ref' => array(
'type' =>
'varchar(128)',
'label' =>
'ExternalSystemID',
'enabled' => 1,
'visible' => -2,
'position' => 170,
'help' =>
'IDOfPaymentInAnExternalSystem'),
108 'stripe_account' => array(
'type' =>
'varchar(128)',
'label' =>
'ExternalSystemCustomerAccount',
'enabled' => 1,
'visible' => -2,
'position' => 171,
'help' =>
'IDOfCustomerInAnExternalSystem'),
109 'ext_payment_site' => array(
'type' =>
'varchar(128)',
'label' =>
'ExternalSystem',
'enabled' => 1,
'visible' => -2,
'position' => 172,
'help' =>
'NameOfExternalSystem'),
110 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 175),
111 'starting_date' => array(
'type' =>
'date',
'label' =>
'Starting date',
'enabled' => 1,
'visible' => -2,
'position' => 180),
112 'ending_date' => array(
'type' =>
'date',
'label' =>
'Ending date',
'enabled' => 1,
'visible' => -2,
'position' => 185),
113 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'position' => 20),
114 'tms' => array(
'type' =>
'timestamp',
'label' =>
'Tms',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 25),
115 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'Import key',
'enabled' => 1,
'visible' => -2,
'position' => 105),
145 public $code_guichet;
175 public $domiciliation;
196 public $owner_address;
233 public $exp_date_month;
237 public $exp_date_year;
241 public $country_code;
253 public $max_total_amount_of_all_payments;
257 public $preapproval_key;
261 public $total_amount_of_all_payments;
265 public $stripe_card_ref;
269 public $stripe_account;
273 public $ext_payment_site;
283 public $starting_date;
314 $this->ismultientitymanaged =
'fk_soc@societe';
315 $this->isextrafieldmanaged = 0;
318 $this->fields[
'rowid'][
'visible'] = 0;
320 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
321 $this->fields[
'entity'][
'enabled'] = 0;
348 global $hookmanager, $langs;
365 $object->ref =
"copy_of_".$object->ref;
369 $object->context[
'createfromclone'] =
'createfromclone';
370 $result =
$object->createCommon($user);
374 $this->errors =
$object->errors;
377 unset(
$object->context[
'createfromclone']);
384 $this->db->rollback();
399 public function fetch($id, $ref =
null, $socid = 0, $type =
'', $morewhere =
'')
402 $morewhere .=
" AND fk_soc = ".((int) $socid).
" AND default_rib = 1";
405 $morewhere .=
" AND type = '".$this->db->escape($type).
"'";
408 $result = $this->
fetchCommon($id, $ref, $morewhere);
410 $this->iban_prefix =
dolDecrypt($this->iban_prefix);
413 $this->iban = $this->iban_prefix;
414 $this->date_modification = $this->tms;
453 public function delete(
User $user, $notrigger = 0)
468 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
470 global $db,
$conf, $langs;
471 global $dolibarr_main_authentication, $dolibarr_main_demo;
474 if (!empty(
$conf->dol_no_mouse_hover)) {
481 $label =
'<u>'.$langs->trans(
"CompanyPaymentMode").
'</u>';
483 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
487 if ($option !=
'nolink') {
489 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
490 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
491 $add_save_lastsearch_values = 1;
493 if ($add_save_lastsearch_values) {
494 $url .=
'&save_lastsearch_values=1';
499 if (empty($notooltip)) {
501 $label = $langs->trans(
"ShowCompanyPaymentMode");
502 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
504 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
505 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
507 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
510 $linkstart =
'<a href="'.$url.
'"';
511 $linkstart .= $linkclose.
'>';
514 $result .= $linkstart;
516 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
518 if ($withpicto != 2) {
519 $result .= $this->ref;
536 $sql1 =
"SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX.
"societe_rib";
537 $sql1 .=
" WHERE rowid = ".((int) ($id ? $id : $this->id));
539 dol_syslog(get_class($this).
'::setAsDefault', LOG_DEBUG);
540 $result1 = $this->db->query($sql1);
542 if ($this->db->num_rows($result1) == 0) {
545 $obj = $this->db->fetch_object($result1);
548 if (empty($alltypes)) {
554 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib SET default_rib = 0, tms = tms";
555 $sql2 .=
" WHERE default_rib <> 0 AND fk_soc = ".((int) $obj->fk_soc);
557 $sql2 .=
" AND type = '".$this->db->escape($type).
"'";
559 dol_syslog(get_class($this).
'::setAsDefault', LOG_DEBUG);
560 $result2 = $this->db->query($sql2);
562 $sql3 =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib SET default_rib = 1";
563 $sql3 .=
" WHERE rowid = ".((int) $obj->id);
565 $sql3 .=
" AND type = '".$this->db->escape($type).
"'";
567 dol_syslog(get_class($this).
'::setAsDefault', LOG_DEBUG);
568 $result3 = $this->db->query($sql3);
570 if (!$result2 || !$result3) {
572 $this->db->rollback();
607 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
610 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
611 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
612 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
613 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
616 $statusType =
'status5';
617 if ($status == self::STATUS_ENABLED) {
618 $statusType =
'status4';
621 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
632 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
633 $sql .=
' fk_user_creat, fk_user_modif';
634 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
635 $sql .=
' WHERE t.rowid = '.((int) $id);
636 $result = $this->db->query($sql);
638 if ($this->db->num_rows($result)) {
639 $obj = $this->db->fetch_object($result);
641 $this->
id = $obj->rowid;
643 $this->user_creation_id = $obj->fk_user_creat;
644 $this->user_modification_id = $obj->fk_user_modif;
645 $this->date_creation = $this->db->jdate($obj->datec);
646 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
649 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class for CompanyPaymentMode.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Load object lines in memory from the database.
info($id)
Load the info information in the object.
setAsDefault($id=0, $alltypes=0)
Set a Payment mode as Default.
getLibStatut($mode=0)
Return label of the status.
__construct(DoliDB $db)
Constructor.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetch($id, $ref=null, $socid=0, $type='', $morewhere='')
Load object in memory from the database.
LibStatut($status, $mode=0)
Return the status.
createFromClone(User $user, $fromid)
Clone and object into another one.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.