26 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $element =
'companypaymentmode';
43 public $table_element =
'societe_rib';
49 public $ismultientitymanaged =
'fk_soc@societe';
54 public $isextrafieldmanaged = 0;
59 public $picto =
'generic';
62 const STATUS_ENABLED = 1;
63 const STATUS_CANCELED = 0;
87 public $fields = array(
88 'rowid' =>array(
'type'=>
'integer',
'label'=>
'Rowid',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>10),
89 'fk_soc' =>array(
'type'=>
'integer',
'label'=>
'Fk soc',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>15),
90 'label' =>array(
'type'=>
'varchar(30)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-2,
'position'=>30),
91 'bank' =>array(
'type'=>
'varchar(255)',
'label'=>
'Bank',
'enabled'=>1,
'visible'=>-2,
'position'=>35),
92 'code_banque' =>array(
'type'=>
'varchar(128)',
'label'=>
'Code banque',
'enabled'=>1,
'visible'=>-2,
'position'=>40),
93 'code_guichet' =>array(
'type'=>
'varchar(6)',
'label'=>
'Code guichet',
'enabled'=>1,
'visible'=>-2,
'position'=>45),
94 'number' =>array(
'type'=>
'varchar(255)',
'label'=>
'Number',
'enabled'=>1,
'visible'=>-2,
'position'=>50),
95 'cle_rib' =>array(
'type'=>
'varchar(5)',
'label'=>
'Cle rib',
'enabled'=>1,
'visible'=>-2,
'position'=>55),
96 'bic' =>array(
'type'=>
'varchar(20)',
'label'=>
'Bic',
'enabled'=>1,
'visible'=>-2,
'position'=>60),
97 'iban_prefix' =>array(
'type'=>
'varchar(34)',
'label'=>
'Iban prefix',
'enabled'=>1,
'visible'=>-2,
'position'=>65),
98 'domiciliation' =>array(
'type'=>
'varchar(255)',
'label'=>
'Domiciliation',
'enabled'=>1,
'visible'=>-2,
'position'=>70),
99 'proprio' =>array(
'type'=>
'varchar(60)',
'label'=>
'Proprio',
'enabled'=>1,
'visible'=>-2,
'position'=>75),
100 'owner_address' =>array(
'type'=>
'text',
'label'=>
'Owner address',
'enabled'=>1,
'visible'=>-2,
'position'=>80),
101 'default_rib' =>array(
'type'=>
'tinyint(4)',
'label'=>
'Default rib',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>85),
102 'rum' =>array(
'type'=>
'varchar(32)',
'label'=>
'Rum',
'enabled'=>1,
'visible'=>-2,
'position'=>90),
103 'date_rum' =>array(
'type'=>
'date',
'label'=>
'Date rum',
'enabled'=>1,
'visible'=>-2,
'position'=>95),
104 'frstrecur' =>array(
'type'=>
'varchar(16)',
'label'=>
'Frstrecur',
'enabled'=>1,
'visible'=>-2,
'position'=>100),
105 'type' =>array(
'type'=>
'varchar(32)',
'label'=>
'Type',
'enabled'=>1,
'visible'=>-2,
'position'=>110),
106 'last_four' =>array(
'type'=>
'varchar(4)',
'label'=>
'Last four',
'enabled'=>1,
'visible'=>-2,
'position'=>115),
107 'card_type' =>array(
'type'=>
'varchar(255)',
'label'=>
'Card type',
'enabled'=>1,
'visible'=>-2,
'position'=>120),
108 'cvn' =>array(
'type'=>
'varchar(255)',
'label'=>
'Cvn',
'enabled'=>1,
'visible'=>-2,
'position'=>125),
109 'exp_date_month' =>array(
'type'=>
'integer',
'label'=>
'Exp date month',
'enabled'=>1,
'visible'=>-2,
'position'=>130),
110 'exp_date_year' =>array(
'type'=>
'integer',
'label'=>
'Exp date year',
'enabled'=>1,
'visible'=>-2,
'position'=>135),
111 'country_code' =>array(
'type'=>
'varchar(10)',
'label'=>
'Country code',
'enabled'=>1,
'visible'=>-2,
'position'=>140),
112 'approved' =>array(
'type'=>
'integer',
'label'=>
'Approved',
'enabled'=>1,
'visible'=>-2,
'position'=>145),
113 'email' =>array(
'type'=>
'varchar(255)',
'label'=>
'Email',
'enabled'=>1,
'visible'=>-2,
'position'=>150),
114 'max_total_amount_of_all_payments' =>array(
'type'=>
'double(24,8)',
'label'=>
'Max total amount of all payments',
'enabled'=>1,
'visible'=>-2,
'position'=>155),
115 'preapproval_key' =>array(
'type'=>
'varchar(255)',
'label'=>
'Preapproval key',
'enabled'=>1,
'visible'=>-2,
'position'=>160),
116 'total_amount_of_all_payments' =>array(
'type'=>
'double(24,8)',
'label'=>
'Total amount of all payments',
'enabled'=>1,
'visible'=>-2,
'position'=>165),
117 'stripe_card_ref' =>array(
'type'=>
'varchar(128)',
'label'=>
'Stripe card ref',
'enabled'=>1,
'visible'=>-2,
'position'=>170),
118 'stripe_account' =>array(
'type'=>
'varchar(128)',
'label'=>
'Stripe account',
'enabled'=>1,
'visible'=>-2,
'position'=>171),
119 'status' =>array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>175),
120 'starting_date' =>array(
'type'=>
'date',
'label'=>
'Starting date',
'enabled'=>1,
'visible'=>-2,
'position'=>180),
121 'ending_date' =>array(
'type'=>
'date',
'label'=>
'Ending date',
'enabled'=>1,
'visible'=>-2,
'position'=>185),
122 'datec' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'position'=>20),
123 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'Tms',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>25),
124 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'Import key',
'enabled'=>1,
'visible'=>-2,
'position'=>105),
145 public $code_guichet;
150 public $domiciliation;
152 public $owner_address;
161 public $exp_date_month;
162 public $exp_date_year;
163 public $country_code;
166 public $max_total_amount_of_all_payments;
167 public $preapproval_key;
168 public $total_amount_of_all_payments;
169 public $stripe_card_ref;
170 public $stripe_account;
177 public $starting_date;
235 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
236 $this->fields[
'rowid'][
'visible'] = 0;
238 if (empty($conf->multicompany->enabled) && isset($this->fields[
'entity'])) {
239 $this->fields[
'entity'][
'enabled'] = 0;
266 global $hookmanager, $langs;
271 $object =
new self($this->db);
276 $object->fetchCommon($fromid);
279 unset($object->fk_user_creat);
280 unset($object->import_key);
283 $object->ref =
"copy_of_".$object->ref;
284 $object->title = $langs->trans(
"CopyOf").
" ".$object->title;
288 $object->context[
'createfromclone'] =
'createfromclone';
289 $result = $object->createCommon($user);
292 $this->error = $object->error;
293 $this->errors = $object->errors;
296 unset($object->context[
'createfromclone']);
303 $this->
db->rollback();
318 public function fetch($id, $ref =
null, $socid = 0, $type =
'', $morewhere =
'')
321 $morewhere .=
" AND fk_soc = ".((int) $socid).
" AND default_rib = 1";
324 $morewhere .=
" AND type = '".$this->db->escape($type).
"'";
327 $result = $this->
fetchCommon($id, $ref, $morewhere);
330 $this->iban = $this->iban_prefix;
369 public function delete(
User $user, $notrigger =
false)
384 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
386 global $db, $conf, $langs;
387 global $dolibarr_main_authentication, $dolibarr_main_demo;
390 if (!empty($conf->dol_no_mouse_hover)) {
397 $label =
'<u>'.$langs->trans(
"CompanyPaymentMode").
'</u>';
399 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
403 if ($option !=
'nolink') {
405 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
406 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
407 $add_save_lastsearch_values = 1;
409 if ($add_save_lastsearch_values) {
410 $url .=
'&save_lastsearch_values=1';
415 if (empty($notooltip)) {
416 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
417 $label = $langs->trans(
"ShowCompanyPaymentMode");
418 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
420 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
421 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
423 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
426 $linkstart =
'<a href="'.$url.
'"';
427 $linkstart .= $linkclose.
'>';
430 $result .= $linkstart;
432 $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);
434 if ($withpicto != 2) {
435 $result .= $this->ref;
452 $sql1 =
"SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX.
"societe_rib";
453 $sql1 .=
" WHERE rowid = ".($id ? $id : $this->id);
455 dol_syslog(get_class($this).
'::setAsDefault', LOG_DEBUG);
456 $result1 = $this->
db->query($sql1);
458 if ($this->
db->num_rows($result1) == 0) {
461 $obj = $this->
db->fetch_object($result1);
464 if (empty($alltypes)) {
470 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib SET default_rib = 0, tms = tms";
471 $sql2 .=
" WHERE default_rib <> 0 AND fk_soc = ".((int) $obj->fk_soc);
473 $sql2 .=
" AND type = '".$this->db->escape($type).
"'";
475 dol_syslog(get_class($this).
'::setAsDefault', LOG_DEBUG);
476 $result2 = $this->
db->query($sql2);
478 $sql3 =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib SET default_rib = 1";
479 $sql3 .=
" WHERE rowid = ".((int) $obj->id);
481 $sql3 .=
" AND type = '".$this->db->escape($type).
"'";
483 dol_syslog(get_class($this).
'::setAsDefault', LOG_DEBUG);
484 $result3 = $this->
db->query($sql3);
486 if (!$result2 || !$result3) {
488 $this->
db->rollback();
509 return $this->
LibStatut($this->status, $mode);
523 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
526 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
527 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
528 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
529 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
532 $statusType =
'status5';
533 if ($status == self::STATUS_ENABLED) {
534 $statusType =
'status4';
537 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
548 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
549 $sql .=
' fk_user_creat, fk_user_modif';
550 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
551 $sql .=
' WHERE t.rowid = '.((int) $id);
552 $result = $this->
db->query($sql);
554 if ($this->
db->num_rows($result)) {
555 $obj = $this->
db->fetch_object($result);
556 $this->
id = $obj->rowid;
558 $this->user_creation_id = $obj->fk_user_creat;
559 $this->user_modification_id = $obj->fk_user_modif;
560 $this->date_creation = $this->
db->jdate($obj->datec);
561 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
564 $this->
db->free($result);