Adding NIF verification for Algeria

Adding NIF verification for Algeria and link to validate professional ID via the Ministère des Finances.
This commit is contained in:
ButterflyOfFire 2022-07-07 09:08:08 +01:00 committed by GitHub
parent 1a31704e18
commit 79924afabc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@
* Copyright (C) 2019-2020 Josep Lluís Amador <joseplluis@lliuretic.cat> * Copyright (C) 2019-2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr> * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2022 ButterflyOfFire <butterflyoffire+dolibarr@protonmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -73,18 +74,18 @@ class Societe extends CommonObject
* @var array List of child tables. To test if we can delete object. * @var array List of child tables. To test if we can delete object.
*/ */
protected $childtables = array( protected $childtables = array(
'supplier_proposal' => array('name' => 'SupplierProposal'), "supplier_proposal" => 'SupplierProposal',
'propal' => array('name' => 'Proposal'), "propal" => 'Proposal',
'commande' => array('name' => 'Order'), "commande" => 'Order',
'facture' => array('name' => 'Invoice'), "facture" => 'Invoice',
'facture_rec' => array('name' => 'RecurringInvoiceTemplate'), "facture_rec" => 'RecurringInvoiceTemplate',
'contrat' => array('name' => 'Contract'), "contrat" => 'Contract',
'fichinter' => array('name' => 'Fichinter'), "fichinter" => 'Fichinter',
'facture_fourn' => array('name' => 'SupplierInvoice'), "facture_fourn" => 'SupplierInvoice',
'commande_fournisseur' => array('name' => 'SupplierOrder'), "commande_fournisseur" => 'SupplierOrder',
'projet' => array('name' => 'Project'), "projet" => 'Project',
'expedition' => array('name' => 'Shipment'), "expedition" => 'Shipment',
'prelevement_lignes' => array('name' => 'DirectDebitRecord'), "prelevement_lignes" => 'DirectDebitRecord',
); );
/** /**
@ -92,22 +93,22 @@ class Societe extends CommonObject
* if name like with @ClassName:FilePathClass:ParentFkFieldName' it will call method deleteByParentField (with parentId as parameters) and FieldName to fetch and delete child object * if name like with @ClassName:FilePathClass:ParentFkFieldName' it will call method deleteByParentField (with parentId as parameters) and FieldName to fetch and delete child object
*/ */
protected $childtablesoncascade = array( protected $childtablesoncascade = array(
'societe_prices', "societe_prices",
'societe_address', "societe_address",
'product_fournisseur_price', "product_fournisseur_price",
'product_customer_price_log', "product_customer_price_log",
'product_customer_price', "product_customer_price",
'@Contact:/contact/class/contact.class.php:fk_soc', "@Contact:/contact/class/contact.class.php:fk_soc",
'adherent', "adherent",
'societe_account', "societe_account",
'societe_rib', "societe_rib",
'societe_remise', "societe_remise",
'societe_remise_except', "societe_remise_except",
'societe_commerciaux', "societe_commerciaux",
'categorie', "categorie",
'notify', "notify",
'notify_def', "notify_def",
'actioncomm', "actioncomm",
); );
/** /**
@ -193,8 +194,8 @@ class Societe extends CommonObject
'tva_intra' =>array('type'=>'varchar(20)', 'label'=>'Tva intra', 'enabled'=>1, 'visible'=>-1, 'position'=>210), 'tva_intra' =>array('type'=>'varchar(20)', 'label'=>'Tva intra', 'enabled'=>1, 'visible'=>-1, 'position'=>210),
'capital' =>array('type'=>'double(24,8)', 'label'=>'Capital', 'enabled'=>1, 'visible'=>-1, 'position'=>215), 'capital' =>array('type'=>'double(24,8)', 'label'=>'Capital', 'enabled'=>1, 'visible'=>-1, 'position'=>215),
'fk_stcomm' =>array('type'=>'integer', 'label'=>'CommercialStatus', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220), 'fk_stcomm' =>array('type'=>'integer', 'label'=>'CommercialStatus', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>220),
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>225), 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>225),
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>230), 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>230),
'prefix_comm' =>array('type'=>'varchar(5)', 'label'=>'Prefix comm', 'enabled'=>'$conf->global->SOCIETE_USEPREFIX', 'visible'=>-1, 'position'=>235), 'prefix_comm' =>array('type'=>'varchar(5)', 'label'=>'Prefix comm', 'enabled'=>'$conf->global->SOCIETE_USEPREFIX', 'visible'=>-1, 'position'=>235),
'client' =>array('type'=>'tinyint(4)', 'label'=>'Client', 'enabled'=>1, 'visible'=>-1, 'position'=>240), 'client' =>array('type'=>'tinyint(4)', 'label'=>'Client', 'enabled'=>1, 'visible'=>-1, 'position'=>240),
'fournisseur' =>array('type'=>'tinyint(4)', 'label'=>'Fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>245), 'fournisseur' =>array('type'=>'tinyint(4)', 'label'=>'Fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>245),
@ -209,7 +210,6 @@ class Societe extends CommonObject
//'remise_supplier' =>array('type'=>'double', 'label'=>'SupplierDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>290, 'isameasure'=>1), //'remise_supplier' =>array('type'=>'double', 'label'=>'SupplierDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>290, 'isameasure'=>1),
'mode_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>295), 'mode_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>295),
'cond_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>300), 'cond_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>300),
'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>301),
'mode_reglement_supplier' =>array('type'=>'integer', 'label'=>'Mode reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>305), 'mode_reglement_supplier' =>array('type'=>'integer', 'label'=>'Mode reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>305),
'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>308), 'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>308),
'outstanding_limit' =>array('type'=>'double(24,8)', 'label'=>'OutstandingBill', 'enabled'=>1, 'visible'=>-1, 'position'=>310, 'isameasure'=>1), 'outstanding_limit' =>array('type'=>'double(24,8)', 'label'=>'OutstandingBill', 'enabled'=>1, 'visible'=>-1, 'position'=>310, 'isameasure'=>1),
@ -408,40 +408,18 @@ class Societe extends CommonObject
*/ */
public $idprof1; public $idprof1;
/**
* @var string Professional ID 1
* @deprecated
* @see $idprof1
*/
public $siren;
/** /**
* Professional ID 2 (Ex: Siret in France) * Professional ID 2 (Ex: Siret in France)
* @var string * @var string
*/ */
public $idprof2; public $idprof2;
/**
* @var string Professional ID 2
* @deprecated
* @see $idprof2
*/
public $siret;
/** /**
* Professional ID 3 (Ex: Ape in France) * Professional ID 3 (Ex: Ape in France)
* @var string * @var string
*/ */
public $idprof3; public $idprof3;
/**
* @var string Professional ID 3
* @deprecated
* @see $idprof3
*/
public $ape;
/** /**
* Professional ID 4 (Ex: RCS in France) * Professional ID 4 (Ex: RCS in France)
* @var string * @var string
@ -505,9 +483,6 @@ class Societe extends CommonObject
public $remise_percent; public $remise_percent;
public $remise_supplier_percent; public $remise_supplier_percent;
public $mode_reglement_id;
public $cond_reglement_id;
public $deposit_percent;
public $mode_reglement_supplier_id; public $mode_reglement_supplier_id;
public $cond_reglement_supplier_id; public $cond_reglement_supplier_id;
public $transport_mode_supplier_id; public $transport_mode_supplier_id;
@ -526,19 +501,18 @@ class Societe extends CommonObject
/** /**
* Date of last update * Date of last update
* @var integer|string * @var string
*/ */
public $date_modification; public $date_modification;
/** /**
* User that made last update * User that made last update
* @var User * @var string
*/ */
public $user_modification; public $user_modification;
/** /**
* Date of creation * @var integer|string date_creation
* @var integer|string
*/ */
public $date_creation; public $date_creation;
@ -942,8 +916,8 @@ class Societe extends CommonObject
$sql .= ", accountancy_code_sell"; $sql .= ", accountancy_code_sell";
} }
$sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".((int) $this->entity).", '".$this->db->idate($now)."'"; $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".((int) $this->entity).", '".$this->db->idate($now)."'";
$sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null");
$sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null");
$sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null");
$sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null");
$sql .= ", ".((int) $this->status); $sql .= ", ".((int) $this->status);
$sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null");
@ -979,7 +953,7 @@ class Societe extends CommonObject
$sql .= ", accountancy_code_sell"; $sql .= ", accountancy_code_sell";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= $this->id; $sql .= $this->id;
$sql .= ", ".((int) $conf->entity); $sql .= ", ".$conf->entity;
$sql .= ", '".$this->db->escape($this->accountancy_code_customer)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_customer)."'";
$sql .= ", '".$this->db->escape($this->accountancy_code_supplier)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_supplier)."'";
$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";
@ -1105,7 +1079,7 @@ class Societe extends CommonObject
} }
} }
if (empty($error)) { if (!empty($error)) {
dol_syslog(get_class($this)."::create_individual success"); dol_syslog(get_class($this)."::create_individual success");
$this->db->commit(); $this->db->commit();
} else { } else {
@ -1477,19 +1451,16 @@ class Societe extends CommonObject
$sql .= ",prefix_comm = ".(!empty($this->prefix_comm) ? "'".$this->db->escape($this->prefix_comm)."'" : "null"); $sql .= ",prefix_comm = ".(!empty($this->prefix_comm) ? "'".$this->db->escape($this->prefix_comm)."'" : "null");
$sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); $sql .= ",fk_effectif = ".(!empty($this->effectif_id) ? "'".$this->db->escape($this->effectif_id)."'" : "null");
if (isset($this->stcomm_id)) { if (isset($this->stcomm_id)) {
$sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? ((int) $this->stcomm_id) : "0"); $sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0");
}
if (isset($this->typent_id)) {
$sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0");
} }
$sql .= ",fk_typent = ".(!empty($this->typent_id) ? "'".$this->db->escape($this->typent_id)."'" : "0");
$sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null"); $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null");
$sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null");
$sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null");
$sql .= ",deposit_percent = ".(!empty($this->deposit_percent) ? "'".$this->db->escape($this->deposit_percent)."'" : "null");
$sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null"); $sql .= ",transport_mode = ".(!empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null");
$sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null");
$sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null");
@ -1719,7 +1690,7 @@ class Societe extends CommonObject
$sql .= ', spe.accountancy_code_customer as code_compta, spe.accountancy_code_supplier as code_compta_fournisseur, spe.accountancy_code_buy, spe.accountancy_code_sell'; $sql .= ', spe.accountancy_code_customer as code_compta, spe.accountancy_code_supplier as code_compta_fournisseur, spe.accountancy_code_buy, spe.accountancy_code_sell';
} }
$sql .= ', s.code_client, s.code_fournisseur, s.parent, s.barcode'; $sql .= ', s.code_client, s.code_fournisseur, s.parent, s.barcode';
$sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.mode_reglement, s.cond_reglement, s.deposit_percent, s.transport_mode'; $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.mode_reglement, s.cond_reglement, s.transport_mode';
$sql .= ', s.fk_account, s.tva_assuj'; $sql .= ', s.fk_account, s.tva_assuj';
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mode_supplier'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mode_supplier';
$sql .= ', s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred'; $sql .= ', s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.logo_squarred';
@ -1897,7 +1868,6 @@ class Societe extends CommonObject
$this->mode_reglement_id = $obj->mode_reglement; $this->mode_reglement_id = $obj->mode_reglement;
$this->cond_reglement_id = $obj->cond_reglement; $this->cond_reglement_id = $obj->cond_reglement;
$this->deposit_percent = $obj->deposit_percent;
$this->transport_mode_id = $obj->transport_mode; $this->transport_mode_id = $obj->transport_mode;
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
$this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier;
@ -2561,10 +2531,9 @@ class Societe extends CommonObject
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param int $noaliasinname 1=Do not add alias into the link ref * @param int $noaliasinname 1=Do not add alias into the link ref
* @param string $target add attribute target
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip = 0, $save_lastsearch_value = -1, $noaliasinname = 0, $target = '') public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip = 0, $save_lastsearch_value = -1, $noaliasinname = 0)
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
@ -2737,10 +2706,13 @@ class Societe extends CommonObject
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip refurl"'; $linkclose .= ' class="classfortooltip refurl"';
$target_value = array('_self', '_blank', '_parent', '_top');
if (in_array($target, $target_value)) { /*
$linkclose .= ' target="'.dol_escape_htmltag($target).'"'; $hookmanager->initHooks(array('thirdpartydao'));
} $parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
} }
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
@ -2764,7 +2736,7 @@ class Societe extends CommonObject
$hookmanager->initHooks(array('thirdpartydao')); $hookmanager->initHooks(array('thirdpartydao'));
$parameters = array( $parameters = array(
'id'=>$this->id, 'id'=>$this->id,
'getnomurl' => &$result, 'getnomurl'=>$result,
'withpicto '=> $withpicto, 'withpicto '=> $withpicto,
'option'=> $option, 'option'=> $option,
'maxlen'=> $maxlen, 'maxlen'=> $maxlen,
@ -2784,30 +2756,29 @@ class Societe extends CommonObject
/** /**
* Return link(s) on type of thirdparty (with picto) * Return link(s) on type of thirdparty (with picto)
* *
* @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
* @param string $option ''=All * @param string $option ''=All
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param string $tag Tag 'a' or 'span' * @return string String with URL
* @return string String with URL
*/ */
public function getTypeUrl($withpicto = 0, $option = '', $notooltip = 0, $tag = 'a') public function getTypeUrl($withpicto = 0, $option = '', $notooltip = 0)
{ {
global $conf, $langs; global $conf, $langs;
$s = ''; $s = '';
if (empty($option) || preg_match('/prospect/', $option)) { if (empty($option) || preg_match('/prospect/', $option)) {
if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$s .= '<'.$tag.' class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</'.$tag.'>'; $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
} }
} }
if (empty($option) || preg_match('/customer/', $option)) { if (empty($option) || preg_match('/customer/', $option)) {
if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$s .= '<'.$tag.' class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</'.$tag.'>'; $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
} }
} }
if (empty($option) || preg_match('/supplier/', $option)) { if (empty($option) || preg_match('/supplier/', $option)) {
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) { if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) {
$s .= '<'.$tag.' class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</'.$tag.'>'; $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
} }
} }
return $s; return $s;
@ -3487,37 +3458,6 @@ class Societe extends CommonObject
} }
} }
/**
* Get parents for company
*
* @param int $company_id ID of company to search parent
* @param array $parents List of companies ID found
* @return array
*/
public function getParentsForCompany($company_id, $parents = [])
{
global $langs;
if ($company_id > 0) {
$sql = "SELECT parent FROM " . MAIN_DB_PREFIX . "societe WHERE rowid = $company_id";
$resql = $this->db->query($sql);
if ($resql) {
if ($obj = $this->db->fetch_object($resql)) {
$parent = $obj->parent;
if ($parent > 0 && !in_array($parent, $parents)) {
$parents[] = $parent;
return $this->getParentsForCompany($parent, $parents);
} else {
return $parents;
}
}
$this->db->free($resql);
} else {
setEventMessage($langs->trans('GetCompanyParentsError', $this->db->lasterror()), 'errors');
}
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Returns if a profid sould be verified to be unique * Returns if a profid sould be verified to be unique
@ -3790,6 +3730,20 @@ class Societe extends CommonObject
} }
} }
//Verify NIF if country is DZ
//Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad
if ($idprof == 1 && $soc->country_code == 'DZ') {
$string = trim($this->idprof1);
$string = preg_replace('/(\s)/', '', $string);
//Check NIF
if (preg_match('/(^[0-9]{15}$)/', $string)) {
return 1;
} else {
return -1;
}
}
return $ok; return $ok;
} }
@ -3832,6 +3786,9 @@ class Societe extends CommonObject
if ($idprof == 1 && $thirdparty->country_code == 'IN') { if ($idprof == 1 && $thirdparty->country_code == 'IN') {
$url = 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; $url = 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp';
} }
if ($idprof == 1 && $thirdparty->country_code == 'DZ') {
$url = 'http://nif.mfdgi.gov.dz/nif.asp?Nif='.$strippedIdProf1;
}
if ($idprof == 1 && $thirdparty->country_code == 'PT') { if ($idprof == 1 && $thirdparty->country_code == 'PT') {
$url = 'http://www.nif.pt/'.$strippedIdProf1; $url = 'http://www.nif.pt/'.$strippedIdProf1;
} }
@ -3877,7 +3834,7 @@ class Societe extends CommonObject
*/ */
public function info($id) public function info($id)
{ {
$sql = "SELECT s.rowid, s.nom as name, s.datec, tms as datem,"; $sql = "SELECT s.rowid, s.nom as name, s.datec as date_creation, tms as date_modification,";
$sql .= " fk_user_creat, fk_user_modif"; $sql .= " fk_user_creat, fk_user_modif";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.rowid = ".((int) $id); $sql .= " WHERE s.rowid = ".((int) $id);
@ -3889,12 +3846,21 @@ class Societe extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->user_creation_id = $obj->fk_user_creat; if ($obj->fk_user_creat) {
$this->user_modification_id = $obj->fk_user_modif; $cuser = new User($this->db);
$this->date_creation = $this->db->jdate($obj->datec); $cuser->fetch($obj->fk_user_creat);
$this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); $this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->ref = $obj->name; $this->ref = $obj->name;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification);
} }
$this->db->free($result); $this->db->free($result);