diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 6399add1af3..11cc7b55a4d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2020 Juanjo Menent - * Copyright (C) 2011-2013 Alexandre Spangaro + * Copyright (C) 2011-2021 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -446,19 +446,19 @@ if (empty($reshook)) { $object->name = dolGetFirstLastname(GETPOST('firstname', 'alphanohtml'), GETPOST('name', 'alphanohtml')); $object->civility_id = GETPOST('civility_id', 'alphanohtml'); // Note: civility id is a code, not an int // Add non official properties - $object->name_bis = GETPOST('name', 'alphanohtml'); - $object->firstname = GETPOST('firstname', 'alphanohtml'); + $object->name_bis = GETPOST('name', 'alphanohtml'); + $object->firstname = GETPOST('firstname', 'alphanohtml'); } else { - $object->name = GETPOST('name', 'alphanohtml'); + $object->name = GETPOST('name', 'alphanohtml'); } $object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity); - $object->name_alias = GETPOST('name_alias', 'alphanohtml'); + $object->name_alias = GETPOST('name_alias', 'alphanohtml'); $object->address = GETPOST('address', 'alphanohtml'); - $object->zip = GETPOST('zipcode', 'alphanohtml'); - $object->town = GETPOST('town', 'alphanohtml'); - $object->country_id = GETPOST('country_id', 'int'); - $object->state_id = GETPOST('state_id', 'int'); - //$object->skype = GETPOST('skype', 'alpha'); + $object->zip = GETPOST('zipcode', 'alphanohtml'); + $object->town = GETPOST('town', 'alphanohtml'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); + //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); @@ -470,9 +470,9 @@ if (empty($reshook)) { } } } - $object->phone = GETPOST('phone', 'alpha'); + $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); - $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); + $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $object->idprof1 = trim(GETPOST('idprof1', 'alphanohtml')); $object->idprof2 = trim(GETPOST('idprof2', 'alphanohtml')); @@ -482,7 +482,7 @@ if (empty($reshook)) { $object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml')); $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); $object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); - $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); + $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); $object->capital = GETPOST('capital', 'alphanohtml'); $object->barcode = GETPOST('barcode', 'alphanohtml'); @@ -497,24 +497,24 @@ if (empty($reshook)) { $object->localtax1_value = GETPOST('lt1', 'alpha'); $object->localtax2_value = GETPOST('lt2', 'alpha'); - $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); + $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->typent_id = GETPOST('typent_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type - $object->client = GETPOST('client', 'int'); + $object->client = GETPOST('client', 'int'); $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->commercial_id = GETPOST('commercial_id', 'int'); - $object->default_lang = GETPOST('default_lang'); + $object->commercial_id = GETPOST('commercial_id', 'int'); + $object->default_lang = GETPOST('default_lang'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); if (GETPOSTISSET('accountancy_code_sell')) { - $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; @@ -523,7 +523,7 @@ if (empty($reshook)) { } } if (GETPOSTISSET('accountancy_code_buy')) { - $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a7db5c1b4bb..a1c1dae1ffb 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -563,11 +563,23 @@ class Societe extends CommonObject public $code_compta_client; /** - * Accounting code for suppliers + * Accounting code for customer + * @var string + */ + public $accountancy_code_customer; + + /** + * Accounting code for supplier * @var string */ public $code_compta_fournisseur; + /** + * Accounting code for supplier + * @var string + */ + public $accountancy_code_supplier; + /** * @var string * @deprecated Note is split in public and private notes @@ -838,8 +850,8 @@ class Societe extends CommonObject } $this->import_key = trim($this->import_key); - $this->accountancy_code_customer = trim($this->accountancy_code_customer); - $this->accountancy_code_supplier = trim($this->accountancy_code_supplier); + $this->accountancy_code_customer = trim($this->code_compta); + $this->accountancy_code_supplier = trim($this->code_compta_fournisseur); $this->accountancy_code_buy = trim($this->accountancy_code_buy); $this->accountancy_code_sell= trim($this->accountancy_code_sell); @@ -2027,6 +2039,15 @@ class Societe extends CommonObject // Remove third party if (!$error) { + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_perentity"; + $sql .= " WHERE fk_soc = ".((int) $id); + if (!$this->db->query($sql)) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; $sql .= " WHERE rowid = ".((int) $id); if (!$this->db->query($sql)) {