2004-10-20 23:06:45 +02:00
< ? php
2015-08-26 19:30:40 +02:00
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Brian Fraval < brian @ fraval . org >
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 Eric Seigne < eric . seigne @ ryxeo . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ inodbox . com >
2015-08-26 19:30:40 +02:00
* Copyright ( C ) 2008 Patrick Raguin < patrick . raguin @ auguria . net >
2020-01-17 17:05:29 +01:00
* Copyright ( C ) 2010 - 2020 Juanjo Menent < jmenent @ 2 byte . es >
2023-04-06 08:47:28 +02:00
* Copyright ( C ) 2011 - 2023 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2015-08-26 19:30:40 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
* Copyright ( C ) 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2019-01-21 10:08:20 +01:00
* Copyright ( C ) 2018 Nicolas ZABOURI < info @ inovea - conseil . com >
2018-03-14 13:25:05 +01:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es . com >
2022-09-13 15:44:54 +02:00
* Copyright ( C ) 2018 - 2022 Frédéric France < frederic . france @ netlogic . fr >
2003-10-08 16:57:09 +02:00
*
2002-04-30 12:51:35 +02:00
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2002-04-30 12:51:35 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2002-04-30 12:51:35 +02:00
*/
2005-04-21 20:08:31 +02:00
/**
2017-03-20 20:58:43 +01:00
* \file htdocs / societe / card . php
2008-11-14 20:20:24 +01:00
* \ingroup societe
* \brief Third party card page
*/
2004-11-12 01:50:14 +01:00
2022-08-29 18:03:39 +02:00
// Load Dolibarr environment
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2014-07-03 18:47:06 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2015-09-17 20:20:03 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2022-08-31 21:55:55 +02:00
if ( isModEnabled ( 'adherent' )) {
2021-02-26 21:17:52 +01:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
}
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-02-26 21:17:52 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php' ;
}
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-02-26 21:17:52 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php' ;
}
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-02-26 21:17:52 +01:00
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php' ;
}
2022-08-31 22:38:53 +02:00
if ( isModEnabled ( 'eventorganization' )) {
2021-05-10 16:25:44 +02:00
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php' ;
}
2006-03-11 03:18:26 +01:00
2022-08-29 18:03:39 +02:00
// Load translation files required by the page
2019-09-08 20:16:05 +02:00
$langs -> loadLangs ( array ( " companies " , " commercial " , " bills " , " banks " , " users " ));
2022-08-29 18:03:39 +02:00
2022-08-31 21:55:55 +02:00
if ( isModEnabled ( 'adherent' )) {
2021-02-26 21:17:52 +01:00
$langs -> load ( " members " );
}
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'categorie' )) {
2021-02-26 21:17:52 +01:00
$langs -> load ( " categories " );
}
2022-09-25 22:53:21 +02:00
if ( isModEnabled ( 'incoterm' )) {
2021-02-26 21:17:52 +01:00
$langs -> load ( " incoterm " );
}
2022-09-25 06:32:24 +02:00
if ( isModEnabled ( 'notification' )) {
2021-02-26 21:17:52 +01:00
$langs -> load ( " mails " );
}
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-10-08 06:29:22 +02:00
$langs -> load ( " products " );
}
2007-02-10 14:43:49 +01:00
2021-09-03 13:19:37 +02:00
$error = 0 ; $errors = array ();
2011-07-01 00:38:06 +02:00
2022-08-29 18:03:39 +02:00
// Get parameters
2019-01-27 11:55:16 +01:00
$action = ( GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
2019-11-13 18:32:11 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2022-05-10 10:57:51 +02:00
$backtopageforcancel = GETPOST ( 'backtopageforcancel' , 'alpha' );
2022-05-19 21:32:17 +02:00
$backtopagejsfields = GETPOST ( 'backtopagejsfields' , 'alpha' );
2022-08-29 18:03:39 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-12-01 19:29:29 +01:00
2023-01-08 15:27:11 +01:00
$dol_openinpopup = '' ;
2022-12-26 15:14:55 +01:00
if ( ! empty ( $backtopagejsfields )) {
$tmpbacktopagejsfields = explode ( ':' , $backtopagejsfields );
$dol_openinpopup = $tmpbacktopagejsfields [ 0 ];
}
2019-11-13 18:32:11 +01:00
$socid = GETPOST ( 'socid' , 'int' ) ? GETPOST ( 'socid' , 'int' ) : GETPOST ( 'id' , 'int' );
2021-03-19 00:00:06 +01:00
if ( $user -> socid ) {
2021-03-11 16:37:27 +01:00
$socid = $user -> socid ;
2021-02-26 21:17:52 +01:00
}
if ( empty ( $socid ) && $action == 'view' ) {
2021-03-11 16:37:27 +01:00
$action = 'create' ;
2021-02-26 21:17:52 +01:00
}
2022-08-29 18:03:39 +02:00
2021-09-03 13:19:37 +02:00
$id = $socid ;
2011-04-06 16:26:43 +02:00
2011-07-01 00:47:04 +02:00
$object = new Societe ( $db );
2011-08-10 02:50:16 +02:00
$extrafields = new ExtraFields ( $db );
2011-07-01 00:38:06 +02:00
2013-03-29 14:09:47 +01:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-03-29 14:09:47 +01:00
2019-09-29 11:20:23 +02:00
$socialnetworks = getArrayOfSocialNetworks ();
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2019-11-13 18:32:11 +01:00
$hookmanager -> initHooks ( array ( 'thirdpartycard' , 'globalcard' ));
2015-03-14 13:05:28 +01:00
2021-02-26 21:17:52 +01:00
if ( $socid > 0 ) {
$object -> fetch ( $socid );
}
2018-03-13 18:04:18 +01:00
2021-02-26 21:17:52 +01:00
if ( ! ( $object -> id > 0 ) && $action == 'view' ) {
2016-12-10 11:49:16 +01:00
$langs -> load ( " errors " );
print ( $langs -> trans ( 'ErrorRecordNotFound' ));
exit ;
}
2015-03-14 13:05:28 +01:00
2010-09-02 23:34:43 +02:00
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
2019-11-13 18:32:11 +01:00
$canvas = $object -> canvas ? $object -> canvas : GETPOST ( " canvas " );
$objcanvas = null ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $canvas )) {
2020-10-07 15:01:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
$objcanvas = new Canvas ( $db , $action );
$objcanvas -> getCanvas ( 'thirdparty' , 'card' , $canvas );
2010-09-07 12:24:26 +02:00
}
2010-09-02 21:41:49 +02:00
2022-08-29 18:03:39 +02:00
// Permissions
2022-09-10 11:08:36 +02:00
$permissiontoread = $user -> hasRight ( 'societe' , 'lire' );
2022-12-09 14:27:43 +01:00
$permissiontoadd = $user -> hasRight ( 'societe' , 'creer' ); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
2022-09-10 11:18:31 +02:00
$permissiontodelete = $user -> hasRight ( 'societe' , 'supprimer' ) || ( $permissiontoadd && isset ( $object -> status ) && $object -> status == 0 );
2022-12-09 14:27:43 +01:00
$permissionnote = $user -> hasRight ( 'societe' , 'creer' ); // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user -> hasRight ( 'societe' , 'creer' ); // Used by the include of actions_dellink.inc.php
2022-08-29 18:03:39 +02:00
$upload_dir = $conf -> societe -> multidir_output [ isset ( $object -> entity ) ? $object -> entity : 1 ];
2021-04-01 11:01:07 +02:00
2011-09-13 14:00:37 +02:00
// Security check
2020-09-18 06:02:52 +02:00
$result = restrictedArea ( $user , 'societe' , $socid , '&societe' , '' , 'fk_soc' , 'rowid' , 0 );
2011-09-13 14:00:37 +02:00
2020-03-22 19:11:21 +01:00
2011-06-01 18:23:33 +02:00
2010-09-07 01:53:55 +02:00
/*
* Actions
*/
2010-09-02 23:34:43 +02:00
2019-11-13 18:32:11 +01:00
$parameters = array ( 'id' => $socid , 'objcanvas' => $objcanvas );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 21:17:52 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2011-07-01 00:38:06 +02:00
2021-02-26 21:17:52 +01:00
if ( empty ( $reshook )) {
2021-08-29 19:40:04 +02:00
$backurlforlist = DOL_URL_ROOT . '/societe/list.php' ;
if ( empty ( $backtopage ) || ( $cancel && empty ( $id ))) {
if ( empty ( $backtopage ) || ( $cancel && strpos ( $backtopage , '__ID__' ))) {
if ( empty ( $id ) && (( $action != 'add' && $action != 'create' ) || $cancel )) {
$backtopage = $backurlforlist ;
} else {
$backtopage = DOL_URL_ROOT . '/societe/card.php?id=' . (( ! empty ( $id ) && $id > 0 ) ? $id : '__ID__' );
}
}
}
2021-02-26 21:17:52 +01:00
if ( $cancel ) {
2021-08-29 19:40:04 +02:00
if ( ! empty ( $backtopageforcancel )) {
header ( " Location: " . $backtopageforcancel );
exit ;
} elseif ( ! empty ( $backtopage )) {
2020-10-07 15:01:28 +02:00
header ( " Location: " . $backtopage );
exit ;
}
2021-08-29 19:40:04 +02:00
$action = '' ;
2020-10-07 15:01:28 +02:00
}
2016-02-13 03:38:56 +01:00
2023-06-05 23:49:13 +02:00
if ( $action == 'confirm_merge' && $confirm == 'yes' && $user -> hasRight ( 'societe' , 'creer' )) {
2018-01-31 18:01:56 +01:00
$error = 0 ;
2015-04-18 18:11:01 +02:00
$soc_origin_id = GETPOST ( 'soc_origin' , 'int' );
$soc_origin = new Societe ( $db );
2021-02-26 21:17:52 +01:00
if ( $soc_origin_id <= 0 ) {
2015-04-18 18:11:01 +02:00
$langs -> load ( 'errors' );
2019-05-29 09:51:45 +02:00
setEventMessages ( $langs -> trans ( 'ErrorThirdPartyIdIsMandatory' , $langs -> transnoentitiesnoconv ( 'MergeOriginThirdparty' )), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 21:17:52 +01:00
if ( ! $error && $soc_origin -> fetch ( $soc_origin_id ) < 1 ) {
2015-12-20 10:36:20 +01:00
setEventMessages ( $langs -> trans ( 'ErrorRecordNotFound' ), null , 'errors' );
2018-01-31 18:01:56 +01:00
$error ++ ;
2015-04-18 18:11:01 +02:00
}
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2020-10-07 15:01:28 +02:00
// TODO Move the merge function into class of object.
2017-06-07 16:44:04 +02:00
2015-04-18 18:11:01 +02:00
$db -> begin ();
2017-03-15 13:30:30 +01:00
// Recopy some data
$object -> client = $object -> client | $soc_origin -> client ;
$object -> fournisseur = $object -> fournisseur | $soc_origin -> fournisseur ;
2019-11-13 18:32:11 +01:00
$listofproperties = array (
2021-10-27 16:39:34 +02:00
'address' , 'zip' , 'town' , 'state_id' , 'country_id' , 'phone' , 'phone_pro' , 'fax' , 'email' , 'socialnetworks' , 'url' , 'barcode' ,
2017-11-29 16:23:11 +01:00
'idprof1' , 'idprof2' , 'idprof3' , 'idprof4' , 'idprof5' , 'idprof6' ,
2018-02-27 16:30:39 +01:00
'tva_intra' , 'effectif_id' , 'forme_juridique' , 'remise_percent' , 'remise_supplier_percent' , 'mode_reglement_supplier_id' , 'cond_reglement_supplier_id' , 'name_bis' ,
2017-11-29 16:23:11 +01:00
'stcomm_id' , 'outstanding_limit' , 'price_level' , 'parent' , 'default_lang' , 'ref' , 'ref_ext' , 'import_key' , 'fk_incoterms' , 'fk_multicurrency' ,
'code_client' , 'code_fournisseur' , 'code_compta' , 'code_compta_fournisseur' ,
'model_pdf' , 'fk_projet'
2017-03-15 13:30:30 +01:00
);
2021-02-26 21:17:52 +01:00
foreach ( $listofproperties as $property ) {
if ( empty ( $object -> $property )) {
$object -> $property = $soc_origin -> $property ;
}
2017-03-15 13:30:30 +01:00
}
2017-06-07 16:44:04 +02:00
2017-03-15 13:30:30 +01:00
// Concat some data
2019-11-13 18:32:11 +01:00
$listofproperties = array (
2020-10-07 15:01:28 +02:00
'note_public' , 'note_private'
2017-03-15 13:30:30 +01:00
);
2021-02-26 21:17:52 +01:00
foreach ( $listofproperties as $property ) {
2020-10-07 15:01:28 +02:00
$object -> $property = dol_concatdesc ( $object -> $property , $soc_origin -> $property );
2017-03-15 13:30:30 +01:00
}
2017-06-07 16:44:04 +02:00
2017-03-15 13:30:30 +01:00
// Merge extrafields
2021-02-26 21:17:52 +01:00
if ( is_array ( $soc_origin -> array_options )) {
foreach ( $soc_origin -> array_options as $key => $val ) {
if ( empty ( $object -> array_options [ $key ])) {
$object -> array_options [ $key ] = $val ;
}
2017-08-23 16:57:07 +02:00
}
2017-03-15 13:30:30 +01:00
}
2017-11-03 15:23:18 +01:00
// Merge categories
$static_cat = new Categorie ( $db );
2017-08-23 17:14:29 +02:00
2018-03-14 13:25:05 +01:00
$custcats_ori = $static_cat -> containing ( $soc_origin -> id , 'customer' , 'id' );
$custcats = $static_cat -> containing ( $object -> id , 'customer' , 'id' );
2019-01-27 11:55:16 +01:00
$custcats = array_merge ( $custcats , $custcats_ori );
2017-11-03 15:23:18 +01:00
$object -> setCategories ( $custcats , 'customer' );
2017-08-23 17:14:29 +02:00
2018-03-14 13:25:05 +01:00
$suppcats_ori = $static_cat -> containing ( $soc_origin -> id , 'supplier' , 'id' );
$suppcats = $static_cat -> containing ( $object -> id , 'supplier' , 'id' );
2019-01-27 11:55:16 +01:00
$suppcats = array_merge ( $suppcats , $suppcats_ori );
2017-11-03 15:23:18 +01:00
$object -> setCategories ( $suppcats , 'supplier' );
2017-06-07 16:44:04 +02:00
2018-01-31 18:01:56 +01:00
// If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys.
if ( $soc_origin -> code_client == $object -> code_client
|| $soc_origin -> code_fournisseur == $object -> code_fournisseur
2021-02-26 21:17:52 +01:00
|| $soc_origin -> barcode == $object -> barcode ) {
2018-01-31 18:01:56 +01:00
dol_syslog ( " We clean customer and supplier code so we will be able to make the update of target " );
$soc_origin -> code_client = '' ;
$soc_origin -> code_fournisseur = '' ;
$soc_origin -> barcode = '' ;
$soc_origin -> update ( $soc_origin -> id , $user , 0 , 1 , 1 , 'merge' );
}
2015-04-18 18:11:01 +02:00
2017-11-03 15:23:18 +01:00
// Update
2019-09-02 16:13:11 +02:00
$result = $object -> update ( $object -> id , $user , 0 , 1 , 1 , 'merge' );
2022-08-29 14:46:26 +02:00
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2019-09-02 16:13:11 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2018-01-31 18:01:56 +01:00
$error ++ ;
}
2015-04-18 18:11:01 +02:00
2017-06-07 16:44:04 +02:00
// Move links
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2020-10-16 17:08:23 +02:00
// This list is also into the api_thirdparties.class.php
// TODO Mutualise the list into object societe.class.php
2018-01-31 18:01:56 +01:00
$objects = array (
'Adherent' => '/adherents/class/adherent.class.php' ,
2021-03-01 21:56:14 +01:00
'Don' => '/don/class/don.class.php' ,
2018-01-31 18:01:56 +01:00
'Societe' => '/societe/class/societe.class.php' ,
2018-03-14 13:25:05 +01:00
//'Categorie' => '/categories/class/categorie.class.php',
2018-01-31 18:01:56 +01:00
'ActionComm' => '/comm/action/class/actioncomm.class.php' ,
'Propal' => '/comm/propal/class/propal.class.php' ,
'Commande' => '/commande/class/commande.class.php' ,
'Facture' => '/compta/facture/class/facture.class.php' ,
'FactureRec' => '/compta/facture/class/facture-rec.class.php' ,
'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php' ,
2020-10-16 17:40:19 +02:00
'Mo' => '/mrp/class/mo.class.php' ,
2018-01-31 18:01:56 +01:00
'Contact' => '/contact/class/contact.class.php' ,
'Contrat' => '/contrat/class/contrat.class.php' ,
'Expedition' => '/expedition/class/expedition.class.php' ,
'Fichinter' => '/fichinter/class/fichinter.class.php' ,
'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php' ,
'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php' ,
'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php' ,
'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php' ,
2021-01-16 17:21:52 +01:00
'Delivery' => '/delivery/class/delivery.class.php' ,
2018-01-31 18:01:56 +01:00
'Product' => '/product/class/product.class.php' ,
'Project' => '/projet/class/project.class.php' ,
2020-10-16 17:08:23 +02:00
'Ticket' => '/ticket/class/ticket.class.php' ,
2021-05-04 17:28:20 +02:00
'User' => '/user/class/user.class.php' ,
'Account' => '/compta/bank/class/account.class.php' ,
2021-05-10 16:25:44 +02:00
'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php'
2018-01-31 18:01:56 +01:00
);
//First, all core objects must update their tables
2021-02-26 21:17:52 +01:00
foreach ( $objects as $object_name => $object_file ) {
2018-01-31 18:01:56 +01:00
require_once DOL_DOCUMENT_ROOT . $object_file ;
2021-02-26 21:17:52 +01:00
if ( ! $error && ! $object_name :: replaceThirdparty ( $db , $soc_origin -> id , $object -> id )) {
2018-01-31 18:01:56 +01:00
$error ++ ;
setEventMessages ( $db -> lasterror (), null , 'errors' );
2021-03-01 21:57:45 +01:00
break ;
2018-01-31 18:01:56 +01:00
}
2015-04-18 18:11:01 +02:00
}
}
2018-01-31 18:01:56 +01:00
// External modules should update their ones too
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2023-06-03 15:33:46 +02:00
$parameters = array ( 'soc_origin' => $soc_origin -> id , 'soc_dest' => $object -> id );
$reshook = $hookmanager -> executeHooks ( 'replaceThirdparty' , $parameters , $object , $action );
2015-04-18 18:11:01 +02:00
2021-02-26 21:17:52 +01:00
if ( $reshook < 0 ) {
2015-04-18 18:11:01 +02:00
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2018-01-31 18:01:56 +01:00
$error ++ ;
2015-04-18 18:11:01 +02:00
}
}
2017-11-29 16:23:11 +01:00
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2019-11-13 18:32:11 +01:00
$object -> context = array ( 'merge' => 1 , 'mergefromid' => $soc_origin -> id );
2017-11-29 16:23:11 +01:00
// Call trigger
2019-11-13 18:32:11 +01:00
$result = $object -> call_trigger ( 'COMPANY_MODIFY' , $user );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2017-11-29 16:26:19 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
2015-04-18 18:11:01 +02:00
}
2017-11-29 16:23:11 +01:00
// End call triggers
2015-04-18 18:11:01 +02:00
}
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2015-04-18 18:11:01 +02:00
//We finally remove the old thirdparty
2021-02-26 21:17:52 +01:00
if ( $soc_origin -> delete ( $soc_origin -> id , $user ) < 1 ) {
2022-09-13 15:44:54 +02:00
setEventMessages ( $soc_origin -> error , $soc_origin -> errors , 'errors' );
2018-01-31 18:01:56 +01:00
$error ++ ;
2015-04-18 18:11:01 +02:00
}
}
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2015-12-20 10:36:20 +01:00
setEventMessages ( $langs -> trans ( 'ThirdpartiesMergeSuccess' ), null , 'mesgs' );
2015-06-05 15:15:05 +02:00
$db -> commit ();
2020-05-21 15:05:19 +02:00
} else {
2020-10-07 15:01:28 +02:00
$langs -> load ( " errors " );
2015-12-20 10:36:20 +01:00
setEventMessages ( $langs -> trans ( 'ErrorsThirdpartyMerge' ), null , 'errors' );
2015-06-05 15:15:05 +02:00
$db -> rollback ();
}
2015-04-18 18:11:01 +02:00
}
}
}
2021-02-26 21:17:52 +01:00
if ( GETPOST ( 'getcustomercode' )) {
2020-10-07 15:01:28 +02:00
// We defined value code_client
$_POST [ " customer_code " ] = " Acompleter " ;
}
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( GETPOST ( 'getsuppliercode' )) {
2020-10-07 15:01:28 +02:00
// We defined value code_fournisseur
$_POST [ " supplier_code " ] = " Acompleter " ;
}
2014-07-04 14:25:08 +02:00
2021-02-26 21:17:52 +01:00
if ( $action == 'set_localtax1' ) {
2020-10-07 15:01:28 +02:00
//obtidre selected del combobox
$value = GETPOST ( 'lt1' );
$object -> fetch ( $socid );
$res = $object -> setValueFrom ( 'localtax1_value' , $value , '' , null , 'text' , '' , $user , 'COMPANY_MODIFY' );
}
2021-02-26 21:17:52 +01:00
if ( $action == 'set_localtax2' ) {
2020-10-07 15:01:28 +02:00
//obtidre selected del combobox
$value = GETPOST ( 'lt2' );
$object -> fetch ( $socid );
$res = $object -> setValueFrom ( 'localtax2_value' , $value , '' , null , 'text' , '' , $user , 'COMPANY_MODIFY' );
}
2011-06-30 15:25:32 +02:00
2020-10-07 15:01:28 +02:00
if ( $action == 'update_extras' ) {
$object -> fetch ( $socid );
2017-06-07 16:44:04 +02:00
2020-10-07 15:01:28 +02:00
$object -> oldcopy = dol_clone ( $object );
2018-02-23 16:11:00 +01:00
2020-10-07 15:01:28 +02:00
// Fill array 'array_options' with data from update form
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-10-06 14:41:52 +02:00
2020-10-07 15:01:28 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , GETPOST ( 'attribute' , 'restricthtml' ));
2021-02-26 21:17:52 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2017-10-24 19:04:40 +02:00
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
2020-10-07 15:01:28 +02:00
$result = $object -> insertExtraFields ( 'COMPANY_MODIFY' );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2020-10-07 15:01:28 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
}
2017-10-24 19:04:40 +02:00
2021-02-26 21:17:52 +01:00
if ( $error ) {
$action = 'edit_extras' ;
}
2020-10-07 15:01:28 +02:00
}
2017-06-07 16:44:04 +02:00
2020-10-07 15:01:28 +02:00
// Add new or update third party
if (( ! GETPOST ( 'getcustomercode' ) && ! GETPOST ( 'getsuppliercode' ))
2023-06-05 23:49:13 +02:00
&& ( $action == 'add' || $action == 'update' ) && $user -> hasRight ( 'societe' , 'creer' )) {
2020-10-07 15:01:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( ! GETPOST ( 'name' )) {
2020-10-07 15:01:28 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " ThirdPartyName " )), null , 'errors' );
$error ++ ;
}
2022-05-10 10:57:51 +02:00
if ( GETPOST ( 'client' , 'int' ) && GETPOST ( 'client' , 'int' ) < 0 ) {
2020-10-07 15:01:28 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " ProspectCustomer " )), null , 'errors' );
$error ++ ;
}
2022-05-10 10:57:51 +02:00
if ( GETPOSTISSET ( 'fournisseur' ) && GETPOST ( 'fournisseur' , 'int' ) < 0 ) {
2020-10-07 15:01:28 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Supplier " )), null , 'errors' );
$error ++ ;
}
2011-08-19 00:25:46 +02:00
2022-09-04 13:25:54 +02:00
if ( isModEnabled ( 'mailing' ) && ! empty ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS ) && $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST ( 'contact_no_email' , 'int' ) ==- 1 && ! empty ( GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL ))) {
2021-01-07 17:23:02 +01:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " No_Email " )), null , 'errors' );
}
2022-09-04 13:25:54 +02:00
if ( isModEnabled ( 'mailing' ) && GETPOST ( " private " , 'int' ) == 1 && ! empty ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS ) && $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST ( 'contact_no_email' , 'int' ) ==- 1 && ! empty ( GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL ))) {
2021-01-12 10:08:12 +01:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " No_Email " )), null , 'errors' );
}
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
if ( $action == 'update' ) {
2020-10-07 15:01:28 +02:00
$ret = $object -> fetch ( $socid );
2017-09-30 18:19:20 +02:00
$object -> oldcopy = clone $object ;
2021-02-26 21:17:52 +01:00
} else {
$object -> canvas = $canvas ;
}
2020-10-07 15:01:28 +02:00
2021-02-26 21:17:52 +01:00
if ( GETPOST ( " private " , 'int' ) == 1 ) { // Ask to create a contact
2020-10-07 15:01:28 +02:00
$object -> particulier = GETPOST ( " private " , 'int' );
$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
2021-10-08 06:50:22 +02:00
$object -> name_bis = GETPOST ( 'name' , 'alphanohtml' );
$object -> firstname = GETPOST ( 'firstname' , 'alphanohtml' );
2020-10-07 15:01:28 +02:00
} else {
2021-10-08 06:50:22 +02:00
$object -> name = GETPOST ( 'name' , 'alphanohtml' );
2020-10-07 15:01:28 +02:00
}
$object -> entity = ( GETPOSTISSET ( 'entity' ) ? GETPOST ( 'entity' , 'int' ) : $conf -> entity );
2021-10-08 06:50:22 +02:00
$object -> name_alias = GETPOST ( 'name_alias' , 'alphanohtml' );
2022-01-30 14:38:00 +01:00
$object -> parent = GETPOST ( 'parent_company_id' , 'int' );
2020-10-07 15:01:28 +02:00
$object -> address = GETPOST ( 'address' , 'alphanohtml' );
2021-10-08 06:50:22 +02:00
$object -> zip = GETPOST ( 'zipcode' , 'alphanohtml' );
$object -> town = GETPOST ( 'town' , 'alphanohtml' );
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2021-10-27 16:39:34 +02:00
2020-10-07 15:01:28 +02:00
$object -> socialnetworks = array ();
2022-08-31 21:49:10 +02:00
if ( isModEnabled ( 'socialnetworks' )) {
2020-10-07 15:01:28 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( GETPOSTISSET ( $key ) && GETPOST ( $key , 'alphanohtml' ) != '' ) {
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alphanohtml' );
}
}
}
2021-10-27 16:39:34 +02:00
2021-10-08 06:50:22 +02:00
$object -> phone = GETPOST ( 'phone' , 'alpha' );
2020-10-07 15:01:28 +02:00
$object -> fax = GETPOST ( 'fax' , 'alpha' );
2021-10-08 06:50:22 +02:00
$object -> email = trim ( GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL ));
2022-08-29 14:46:26 +02:00
$object -> no_email = GETPOST ( " no_email " , " int " );
2020-10-07 15:01:28 +02:00
$object -> url = trim ( GETPOST ( 'url' , 'custom' , 0 , FILTER_SANITIZE_URL ));
$object -> idprof1 = trim ( GETPOST ( 'idprof1' , 'alphanohtml' ));
$object -> idprof2 = trim ( GETPOST ( 'idprof2' , 'alphanohtml' ));
$object -> idprof3 = trim ( GETPOST ( 'idprof3' , 'alphanohtml' ));
$object -> idprof4 = trim ( GETPOST ( 'idprof4' , 'alphanohtml' ));
$object -> idprof5 = trim ( GETPOST ( 'idprof5' , 'alphanohtml' ));
$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' );
2021-10-08 06:50:22 +02:00
$object -> code_fournisseur = GETPOSTISSET ( 'supplier_code' ) ? GETPOST ( 'supplier_code' , 'alpha' ) : GETPOST ( 'code_fournisseur' , 'alpha' );
2020-10-07 15:01:28 +02:00
$object -> capital = GETPOST ( 'capital' , 'alphanohtml' );
$object -> barcode = GETPOST ( 'barcode' , 'alphanohtml' );
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alphanohtml' );
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'alpha' );
2023-04-06 08:47:28 +02:00
$object -> vat_reverse_charge = GETPOST ( 'vat_reverse_charge' ) == 'on' ? 1 : 0 ;
2020-10-07 15:01:28 +02:00
$object -> status = GETPOST ( 'status' , 'alpha' );
// Local Taxes
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' , 'alpha' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' , 'alpha' );
$object -> localtax1_value = GETPOST ( 'lt1' , 'alpha' );
$object -> localtax2_value = GETPOST ( 'lt2' , 'alpha' );
2021-10-08 06:50:22 +02:00
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' , 'int' );
2020-10-07 15:01:28 +02:00
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
2021-10-08 06:50:22 +02:00
$object -> typent_id = GETPOST ( 'typent_id' , 'int' );
2020-10-07 15:01:28 +02:00
$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
2021-10-08 06:50:22 +02:00
$object -> client = GETPOST ( 'client' , 'int' );
2020-10-07 15:01:28 +02:00
$object -> fournisseur = GETPOST ( 'fournisseur' , 'int' );
2021-10-08 06:50:22 +02:00
$object -> commercial_id = GETPOST ( 'commercial_id' , 'int' );
$object -> default_lang = GETPOST ( 'default_lang' );
2020-10-07 15:01:28 +02:00
// Webservices url/key
$object -> webservices_url = GETPOST ( 'webservices_url' , 'custom' , 0 , FILTER_SANITIZE_URL );
$object -> webservices_key = GETPOST ( 'webservices_key' , 'san_alpha' );
2016-06-30 15:49:57 +02:00
2021-02-26 21:17:52 +01:00
if ( GETPOSTISSET ( 'accountancy_code_sell' )) {
2021-10-08 06:50:22 +02:00
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
2021-07-08 21:35:25 +02:00
2021-07-08 21:53:24 +02:00
if ( empty ( $accountancy_code_sell ) || $accountancy_code_sell == '-1' ) {
2021-07-08 21:35:25 +02:00
$object -> accountancy_code_sell = '' ;
} else {
$object -> accountancy_code_sell = $accountancy_code_sell ;
}
2021-02-26 21:17:52 +01:00
}
if ( GETPOSTISSET ( 'accountancy_code_buy' )) {
2021-10-08 06:50:22 +02:00
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
2021-07-08 21:35:25 +02:00
2021-07-08 21:53:24 +02:00
if ( empty ( $accountancy_code_buy ) || $accountancy_code_buy == '-1' ) {
2021-07-08 21:35:25 +02:00
$object -> accountancy_code_buy = '' ;
} else {
$object -> accountancy_code_buy = $accountancy_code_buy ;
}
2021-02-26 21:17:52 +01:00
}
2020-12-04 04:13:42 +01:00
2017-09-30 18:19:20 +02:00
// Incoterms
2022-09-25 22:53:21 +02:00
if ( isModEnabled ( 'incoterm' )) {
2019-11-13 18:32:11 +01:00
$object -> fk_incoterms = GETPOST ( 'incoterm_id' , 'int' );
$object -> location_incoterms = GETPOST ( 'location_incoterms' , 'alpha' );
2017-09-30 18:19:20 +02:00
}
2013-10-15 20:51:44 +02:00
2017-09-30 18:19:20 +02:00
// Multicurrency
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2017-09-30 18:19:20 +02:00
$object -> multicurrency_code = GETPOST ( 'multicurrency_code' , 'alpha' );
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 21:17:52 +01:00
if ( $ret < 0 ) {
2017-09-30 18:19:20 +02:00
$error ++ ;
}
2013-01-26 10:35:30 +01:00
2020-03-29 04:28:23 +02:00
// Fill array 'array_languages' with data from add form
2020-04-01 16:21:03 +02:00
$ret = $object -> setValuesForExtraLanguages ();
2021-02-26 21:17:52 +01:00
if ( $ret < 0 ) {
2020-03-29 04:28:23 +02:00
$error ++ ;
}
//var_dump($object->array_languages);exit;
2022-07-24 14:49:57 +02:00
if ( ! empty ( $_FILES [ 'photo' ][ 'name' ])) {
2022-07-24 15:03:32 +02:00
$current_logo = $object -> logo ;
2021-02-26 21:17:52 +01:00
$object -> logo = dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
}
2013-01-26 10:35:30 +01:00
2020-10-07 15:01:28 +02:00
// Check parameters
2021-02-26 21:17:52 +01:00
if ( ! GETPOST ( 'cancel' , 'alpha' )) {
if ( ! empty ( $object -> email ) && ! isValidEMail ( $object -> email )) {
2020-10-07 15:01:28 +02:00
$langs -> load ( " errors " );
$error ++ ;
2022-12-30 02:00:31 +01:00
setEventMessages ( $langs -> trans ( " ErrorBadEMail " , $object -> email ), null , 'errors' );
2020-10-07 15:01:28 +02:00
}
2021-02-26 21:17:52 +01:00
if ( ! empty ( $object -> url ) && ! isValidUrl ( $object -> url )) {
2020-10-07 15:01:28 +02:00
$langs -> load ( " errors " );
2022-12-30 02:00:31 +01:00
setEventMessages ( $langs -> trans ( " ErrorBadUrl " , $object -> url ), null , 'errors' );
2020-10-07 15:01:28 +02:00
}
if ( ! empty ( $object -> webservices_url )) {
//Check if has transport, without any the soap client will give error
2021-02-26 21:17:52 +01:00
if ( strpos ( $object -> webservices_url , " http " ) === false ) {
2020-10-07 15:01:28 +02:00
$object -> webservices_url = " http:// " . $object -> webservices_url ;
}
if ( ! isValidUrl ( $object -> webservices_url )) {
$langs -> load ( " errors " );
$error ++ ; $errors [] = $langs -> trans ( " ErrorBadUrl " , $object -> webservices_url );
}
}
2018-02-23 11:23:04 +01:00
2020-10-07 15:01:28 +02:00
// We set country_id, country_code and country for the selected country
2021-07-05 18:46:27 +02:00
$object -> country_id = GETPOST ( 'country_id' , 'int' ) != '' ? GETPOST ( 'country_id' , 'int' ) : $mysoc -> country_id ;
2021-02-26 21:17:52 +01:00
if ( $object -> country_id ) {
2020-10-07 15:01:28 +02:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
}
}
}
2011-06-30 15:25:32 +02:00
2021-02-26 21:17:52 +01:00
if ( ! $error ) {
if ( $action == 'add' ) {
2020-10-07 15:01:28 +02:00
$error = 0 ;
2011-06-30 15:25:32 +02:00
2020-10-07 15:01:28 +02:00
$db -> begin ();
2021-02-26 21:17:52 +01:00
if ( empty ( $object -> client )) {
$object -> code_client = '' ;
}
if ( empty ( $object -> fournisseur )) {
$object -> code_fournisseur = '' ;
}
2020-10-07 15:01:28 +02:00
$result = $object -> create ( $user );
2017-06-07 16:44:04 +02:00
2023-02-21 13:19:57 +01:00
if ( empty ( $error ) && isModEnabled ( 'mailing' ) && ! empty ( $object -> email ) && $object -> no_email == 1 ) {
2022-08-29 14:46:26 +02:00
// Add mass emailing flag into table mailing_unsubscribe
$result = $object -> setNoEmail ( $object -> no_email );
if ( $result < 0 ) {
$error ++ ;
$errors = array_merge ( $errors , ( $object -> error ? array ( $object -> error ) : $object -> errors ));
$action = 'create' ;
}
}
2021-02-26 21:17:52 +01:00
if ( $result >= 0 ) {
if ( $object -> particulier ) {
2018-01-10 13:30:57 +01:00
dol_syslog ( " We ask to create a contact/address too " , LOG_DEBUG );
2021-01-06 09:11:04 +01:00
$contcats = GETPOST ( 'contcats' , 'array' );
2021-01-07 17:23:02 +01:00
$no_email = GETPOST ( 'contact_no_email' , 'int' );
$result = $object -> create_individual ( $user , $no_email , $contcats );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-01-10 13:30:57 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
}
2018-05-22 19:24:56 +02:00
2018-03-09 18:59:06 +01:00
// Links with users
$salesreps = GETPOST ( 'commercial' , 'array' );
2020-08-26 09:40:20 +02:00
$result = $object -> setSalesRep ( $salesreps , true );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-03-09 18:59:06 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-05-22 19:24:56 +02:00
2018-02-05 16:07:08 +01:00
// Customer categories association
2017-09-18 01:39:39 +02:00
$custcats = GETPOST ( 'custcats' , 'array' );
2018-02-23 11:23:04 +01:00
$result = $object -> setCategories ( $custcats , 'customer' );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-02-23 11:23:04 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-02-05 16:07:08 +01:00
// Supplier categories association
$suppcats = GETPOST ( 'suppcats' , 'array' );
2018-02-23 11:23:04 +01:00
$result = $object -> setCategories ( $suppcats , 'supplier' );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-02-23 11:23:04 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-05-22 19:24:56 +02:00
2020-10-07 15:01:28 +02:00
// Logo/Photo save
2021-05-18 20:13:26 +02:00
$dir = $conf -> societe -> multidir_output [ $conf -> entity ] . " / " . $object -> id . " /logos/ " ;
2020-10-07 15:01:28 +02:00
$file_OK = is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]);
2021-02-26 21:17:52 +01:00
if ( $file_OK ) {
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ])) {
2020-10-07 15:01:28 +02:00
dol_mkdir ( $dir );
2021-02-26 21:17:52 +01:00
if ( @ is_dir ( $dir )) {
2020-10-07 15:01:28 +02:00
$newfile = $dir . '/' . dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 );
2022-08-12 15:54:50 +02:00
if ( ! ( $result > 0 )) {
2020-10-07 15:01:28 +02:00
$errors [] = " ErrorFailedToSaveFile " ;
} else {
// Create thumbs
$object -> addThumbs ( $newfile );
}
}
}
} else {
2021-02-26 21:17:52 +01:00
switch ( $_FILES [ 'photo' ][ 'error' ]) {
2020-10-07 15:01:28 +02:00
case 1 : //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2 : //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors [] = " ErrorFileSizeTooLarge " ;
break ;
2021-02-26 21:17:52 +01:00
case 3 : //uploaded file was only partially uploaded
2020-10-07 15:01:28 +02:00
$errors [] = " ErrorFilePartiallyUploaded " ;
break ;
2013-11-23 15:22:27 +01:00
}
2021-02-26 21:17:52 +01:00
}
2020-10-07 15:01:28 +02:00
} else {
2021-02-26 21:17:52 +01:00
if ( $result == - 3 && in_array ( 'ErrorCustomerCodeAlreadyUsed' , $object -> errors )) {
2016-06-30 15:12:35 +02:00
$duplicate_code_error = true ;
$object -> code_client = null ;
}
2017-06-07 16:44:04 +02:00
2021-02-26 21:17:52 +01:00
if ( $result == - 3 && in_array ( 'ErrorSupplierCodeAlreadyUsed' , $object -> errors )) {
2020-12-15 22:01:33 +01:00
$duplicate_code_error = true ;
$object -> code_fournisseur = null ;
}
2020-12-16 00:32:18 +01:00
if ( $db -> lasterrno () == 'DB_ERROR_RECORD_ALREADY_EXISTS' ) { // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case
2020-12-15 22:03:15 +01:00
$duplicate_code_error = true ;
}
2020-10-07 15:01:28 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2021-02-26 21:17:52 +01:00
$error ++ ;
2020-10-07 15:01:28 +02:00
}
2011-06-30 15:25:32 +02:00
2020-12-16 00:32:18 +01:00
if ( $result >= 0 && ! $error ) {
2020-10-07 15:01:28 +02:00
$db -> commit ();
2011-06-30 15:25:32 +02:00
2022-05-19 21:32:17 +02:00
if ( $backtopagejsfields ) {
llxHeader ( '' , '' , '' );
$retstring = '<script>' ;
$retstring .= ' jQuery ( document ) . ready ( function () {
console . log ( \ 'We execute action to create. We save id and go back - ' . $dol_openinpopup . ' \ ' );
console . log ( \ 'id = ' . $object -> id . ' \ ' );
$ ( \ '#varforreturndialogid' . $dol_openinpopup . '\', window.parent.document).text(\'' . $object -> id . ' \ ' );
$ ( \ '#varforreturndialoglabel' . $dol_openinpopup . '\', window.parent.document).text(\'' . $object -> name . ' \ ' );
window . parent . jQuery ( \ '#idfordialog' . $dol_openinpopup . ' \ ' ) . dialog ( \ ' close\ ' );
}); ' ;
$retstring .= '</script>' ;
print $retstring ;
llxFooter ();
exit ;
}
2020-12-16 00:32:18 +01:00
if ( ! empty ( $backtopage )) {
2020-10-07 15:01:28 +02:00
$backtopage = preg_replace ( '/--IDFORBACKTOPAGE--/' , $object -> id , $backtopage ); // New method to autoselect project after a New on another form object creation
2021-02-26 21:17:52 +01:00
if ( preg_match ( '/\?/' , $backtopage )) {
$backtopage .= '&socid=' . $object -> id ; // Old method
}
header ( " Location: " . $backtopage );
2020-10-07 15:01:28 +02:00
exit ;
} else {
$url = $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id ; // Old method
2021-02-26 21:17:52 +01:00
if (( $object -> client == 1 || $object -> client == 3 ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) {
$url = DOL_URL_ROOT . " /comm/card.php?socid= " . $object -> id ;
} elseif ( $object -> fournisseur == 1 ) {
$url = DOL_URL_ROOT . " /fourn/card.php?socid= " . $object -> id ;
}
2020-10-07 15:01:28 +02:00
2022-05-19 21:32:17 +02:00
header ( " Location: " . $url );
exit ;
2020-10-07 15:01:28 +02:00
}
} else {
$db -> rollback ();
$action = 'create' ;
}
}
2018-02-23 11:23:04 +01:00
2021-02-26 21:17:52 +01:00
if ( $action == 'update' ) {
2020-10-07 15:01:28 +02:00
$error = 0 ;
2021-02-26 21:17:52 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
if ( ! empty ( $backtopage )) {
header ( " Location: " . $backtopage );
2020-10-07 15:01:28 +02:00
exit ;
} else {
2021-02-26 21:17:52 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?socid= " . $socid );
2020-10-07 15:01:28 +02:00
exit ;
}
}
2011-06-30 15:25:32 +02:00
2020-10-07 15:01:28 +02:00
// To not set code if third party is not concerned. But if it had values, we keep them.
2021-02-26 21:17:52 +01:00
if ( empty ( $object -> client ) && empty ( $object -> oldcopy -> code_client )) {
$object -> code_client = '' ;
}
if ( empty ( $object -> fournisseur ) && empty ( $object -> oldcopy -> code_fournisseur )) {
$object -> code_fournisseur = '' ;
}
2020-10-07 15:01:28 +02:00
//var_dump($object);exit;
2011-06-30 15:25:32 +02:00
2020-10-07 15:01:28 +02:00
$result = $object -> update ( $socid , $user , 1 , $object -> oldcopy -> codeclient_modifiable (), $object -> oldcopy -> codefournisseur_modifiable (), 'update' , 0 );
2019-09-02 16:13:11 +02:00
2022-08-29 14:46:26 +02:00
if ( $result > 0 ) {
// Update mass emailing flag into table mailing_unsubscribe
if ( GETPOSTISSET ( 'no_email' ) && $object -> email ) {
$no_email = GETPOST ( 'no_email' , 'int' );
$result = $object -> setNoEmail ( $no_email );
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = 'edit' ;
}
}
$action = 'view' ;
} else {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = 'edit' ;
}
2021-02-26 21:17:52 +01:00
if ( $result <= 0 ) {
2020-10-07 15:01:28 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
2018-05-22 19:24:56 +02:00
2018-03-09 18:59:06 +01:00
// Links with users
$salesreps = GETPOST ( 'commercial' , 'array' );
$result = $object -> setSalesRep ( $salesreps );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-03-09 18:59:06 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-02-23 11:23:04 +01:00
2018-02-08 13:09:21 +01:00
// Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined)
2021-02-26 21:17:52 +01:00
if ( ! $error && ! empty ( $user -> rights -> categorie -> lire )) {
2018-02-05 16:07:08 +01:00
// Customer categories association
2019-02-10 10:45:49 +01:00
$categories = GETPOST ( 'custcats' , 'array' );
2018-02-23 11:23:04 +01:00
$result = $object -> setCategories ( $categories , 'customer' );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-02-23 11:23:04 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-02-05 16:07:08 +01:00
// Supplier categories association
$categories = GETPOST ( 'suppcats' , 'array' );
2018-02-23 11:23:04 +01:00
$result = $object -> setCategories ( $categories , 'supplier' );
2021-02-26 21:17:52 +01:00
if ( $result < 0 ) {
2018-02-23 11:23:04 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-02-05 16:07:08 +01:00
}
2015-08-26 19:30:40 +02:00
2020-10-07 15:01:28 +02:00
// Logo/Photo save
$dir = $conf -> societe -> multidir_output [ $object -> entity ] . " / " . $object -> id . " /logos " ;
$file_OK = is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]);
2021-02-26 21:17:52 +01:00
if ( GETPOST ( 'deletephoto' ) && $object -> logo ) {
2020-10-07 15:01:28 +02:00
$fileimg = $dir . '/' . $object -> logo ;
$dirthumbs = $dir . '/thumbs' ;
dol_delete_file ( $fileimg );
dol_delete_dir_recursive ( $dirthumbs );
}
2021-02-26 21:17:52 +01:00
if ( $file_OK ) {
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ]) > 0 ) {
2022-07-24 15:15:39 +02:00
if ( $current_logo != $object -> logo ) {
2022-07-24 15:03:32 +02:00
$fileimg = $dir . '/' . $current_logo ;
$dirthumbs = $dir . '/thumbs' ;
dol_delete_file ( $fileimg );
2022-07-24 15:15:39 +02:00
dol_delete_dir_recursive ( $dirthumbs );
2022-07-24 15:03:32 +02:00
}
2020-10-07 15:01:28 +02:00
dol_mkdir ( $dir );
2021-02-26 21:17:52 +01:00
if ( @ is_dir ( $dir )) {
2020-10-07 15:01:28 +02:00
$newfile = $dir . '/' . dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 );
2022-08-12 15:54:50 +02:00
if ( ! ( $result > 0 )) {
2020-10-07 15:01:28 +02:00
$errors [] = " ErrorFailedToSaveFile " ;
} else {
// Create thumbs
$object -> addThumbs ( $newfile );
// Index file in database
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD )) {
2020-10-07 15:01:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
// the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir
deleteFilesIntoDatabaseIndex ( dirname ( $newfile ), '' , '' );
// now we index the uploaded logo file
addFileIntoDatabaseIndex ( dirname ( $newfile ), basename ( $newfile ), '' , 'uploaded' , 1 );
}
}
}
} else {
$errors [] = " ErrorBadImageFormat " ;
}
} else {
2021-02-26 21:17:52 +01:00
switch ( $_FILES [ 'photo' ][ 'error' ]) {
2020-10-07 15:01:28 +02:00
case 1 : //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2 : //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors [] = " ErrorFileSizeTooLarge " ;
break ;
2021-02-26 21:17:52 +01:00
case 3 : //uploaded file was only partially uploaded
2020-10-07 15:01:28 +02:00
$errors [] = " ErrorFilePartiallyUploaded " ;
break ;
2013-11-23 15:22:27 +01:00
}
2020-10-07 15:01:28 +02:00
}
// Gestion du logo de la société
2011-06-11 16:14:27 +02:00
2013-01-26 10:38:11 +01:00
2020-10-07 15:01:28 +02:00
// Update linked member
2021-02-26 21:17:52 +01:00
if ( ! $error && $object -> fk_soc > 0 ) {
2020-10-07 15:01:28 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " adherent " ;
2021-03-30 03:37:54 +02:00
$sql .= " SET fk_soc = NULL WHERE fk_soc = " . (( int ) $socid );
2021-02-26 21:17:52 +01:00
if ( ! $object -> db -> query ( $sql )) {
2020-10-07 15:01:28 +02:00
$error ++ ;
$object -> error .= $object -> db -> lasterror ();
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2013-01-26 10:35:30 +01:00
2021-02-26 21:17:52 +01:00
if ( ! $error && ! count ( $errors )) {
if ( ! empty ( $backtopage )) {
header ( " Location: " . $backtopage );
2020-10-07 15:01:28 +02:00
exit ;
} else {
2021-02-26 21:17:52 +01:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?socid= " . $socid );
2020-10-07 15:01:28 +02:00
exit ;
}
} else {
$object -> id = $socid ;
$action = " edit " ;
}
}
} else {
$action = ( $action == 'add' ? 'create' : 'edit' );
}
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Delete third party
2022-09-10 11:18:31 +02:00
if ( $action == 'confirm_delete' && $confirm == 'yes' && $user -> hasRight ( 'societe' , 'supprimer' )) {
2020-10-07 15:01:28 +02:00
$object -> fetch ( $socid );
$object -> oldcopy = clone $object ;
$result = $object -> delete ( $socid , $user );
2011-06-30 15:25:32 +02:00
2021-02-26 21:17:52 +01:00
if ( $result > 0 ) {
2020-10-07 15:01:28 +02:00
header ( " Location: " . DOL_URL_ROOT . " /societe/list.php?restore_lastsearch_values=1&delsoc= " . urlencode ( $object -> name ));
exit ;
} else {
$langs -> load ( " errors " );
2021-02-26 21:17:52 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
2020-10-07 15:01:28 +02:00
$action = '' ;
}
}
2011-06-11 16:14:27 +02:00
2020-12-13 19:50:35 +01:00
// Set third-party type
2023-06-05 23:49:13 +02:00
if ( $action == 'set_thirdpartytype' && $user -> hasRight ( 'societe' , 'creer' )) {
2020-10-07 15:01:28 +02:00
$object -> fetch ( $socid );
2020-12-13 19:50:35 +01:00
$result = $object -> setThirdpartyType ( GETPOST ( 'typent_id' , 'int' ));
2020-10-07 15:01:28 +02:00
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Set incoterm
2023-06-05 23:49:13 +02:00
if ( $action == 'set_incoterms' && $user -> hasRight ( 'societe' , 'creer' ) && isModEnabled ( 'incoterm' )) {
2020-10-07 15:01:28 +02:00
$object -> fetch ( $socid );
$result = $object -> setIncoterms ( GETPOST ( 'incoterm_id' , 'int' ), GETPOST ( 'location_incoterms' , 'alpha' ));
}
2013-09-25 21:36:40 +02:00
2020-12-13 19:50:35 +01:00
// Set parent company
2023-06-05 23:49:13 +02:00
if ( $action == 'set_thirdparty' && $user -> hasRight ( 'societe' , 'creer' )) {
2020-12-13 19:50:35 +01:00
$object -> fetch ( $socid );
2021-05-25 12:02:33 +02:00
$result = $object -> setParent ( GETPOST ( 'parent_id' , 'int' ));
2020-12-13 19:50:35 +01:00
}
2020-06-26 12:20:53 +02:00
// Set sales representatives
2023-06-05 23:49:13 +02:00
if ( $action == 'set_salesrepresentatives' && $user -> hasRight ( 'societe' , 'creer' )) {
2020-06-26 12:20:53 +02:00
$object -> fetch ( $socid );
$result = $object -> setSalesRep ( GETPOST ( 'commercial' , 'array' ));
}
2021-06-23 16:53:26 +02:00
// warehouse
2023-06-05 23:49:13 +02:00
if ( $action == 'setwarehouse' && $user -> hasRight ( 'societe' , 'creer' )) {
2021-06-23 16:53:26 +02:00
$result = $object -> setWarehouse ( GETPOST ( 'fk_warehouse' , 'int' ));
}
2020-10-07 15:01:28 +02:00
$id = $socid ;
$object -> fetch ( $socid );
2018-03-07 15:52:58 +01:00
2020-06-30 16:33:18 +02:00
// Selection of new fields
if ( ! empty ( $conf -> global -> MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD ) && ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS ) || ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ))) {
2020-10-31 14:32:18 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2020-06-30 16:33:18 +02:00
}
2020-10-07 15:01:28 +02:00
// Actions to send emails
$triggersendname = 'COMPANY_SENTBYMAIL' ;
$paramname = 'socid' ;
$mode = 'emailfromthirdparty' ;
$trackid = 'thi' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
// Actions to build doc
$id = $socid ;
2022-05-11 15:06:11 +02:00
$upload_dir = ! empty ( $conf -> societe -> multidir_output [ $object -> entity ]) ? $conf -> societe -> multidir_output [ $object -> entity ] : $conf -> societe -> dir_output ;
2022-12-09 14:27:43 +01:00
$permissiontoadd = $user -> hasRight ( 'societe' , 'creer' );
2020-10-07 15:01:28 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2010-09-07 01:53:55 +02:00
}
2010-09-02 21:41:49 +02:00
2010-09-07 01:53:55 +02:00
/*
* View
*/
$form = new Form ( $db );
$formfile = new FormFile ( $db );
$formadmin = new FormAdmin ( $db );
$formcompany = new FormCompany ( $db );
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-02-26 21:17:52 +01:00
$formaccounting = new FormAccounting ( $db );
}
2010-09-02 21:41:49 +02:00
2021-02-26 21:17:52 +01:00
if ( $socid > 0 && empty ( $object -> id )) {
2020-10-07 15:01:28 +02:00
$result = $object -> fetch ( $socid );
2021-02-26 21:17:52 +01:00
if ( $result <= 0 ) {
dol_print_error ( '' , $object -> error );
2022-06-20 13:40:54 +02:00
exit ( - 1 );
2021-02-26 21:17:52 +01:00
}
2015-01-17 14:34:16 +01:00
}
2019-11-13 18:32:11 +01:00
$title = $langs -> trans ( " ThirdParty " );
2022-06-27 12:46:39 +02:00
if ( $action == 'create' ) {
$title = $langs -> trans ( " NewThirdParty " );
}
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/thirdpartynameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) {
$title = $object -> name . " - " . $langs -> trans ( 'Card' );
}
2021-03-16 13:16:03 +01:00
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner' ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $title , $help_url );
2015-01-17 14:34:16 +01:00
2019-11-13 18:32:11 +01:00
$countrynotdefined = $langs -> trans ( " ErrorSetACountryFirst " ) . ' (' . $langs -> trans ( " SeeAbove " ) . ')' ;
2010-09-07 01:53:55 +02:00
2021-02-26 21:17:52 +01:00
if ( is_object ( $objcanvas ) && $objcanvas -> displayCanvasExists ( $action )) {
2020-10-07 15:01:28 +02:00
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
2021-02-26 21:17:52 +01:00
$objcanvas -> assign_values ( $action , $object -> id , $object -> ref ); // Set value for templates
2020-10-07 15:01:28 +02:00
$objcanvas -> display_canvas ( $action ); // Show template
2020-05-21 15:05:19 +02:00
} else {
2020-10-07 15:01:28 +02:00
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
2021-02-26 21:17:52 +01:00
if ( $action == 'create' ) {
2020-10-07 15:01:28 +02:00
/*
2021-02-26 21:17:52 +01:00
* Creation
*/
2019-11-13 18:32:11 +01:00
$private = GETPOST ( " private " , " int " );
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> THIRDPARTY_DEFAULT_CREATE_CONTACT ) && ! GETPOSTISSET ( 'private' )) {
$private = 1 ;
}
if ( empty ( $private )) {
$private = 0 ;
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Load object modCodeTiers
$module = ( ! empty ( $conf -> global -> SOCIETE_CODECLIENT_ADDON ) ? $conf -> global -> SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard' );
2021-02-26 21:17:52 +01:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' ) {
2020-10-07 15:01:28 +02:00
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2021-02-26 21:17:52 +01:00
foreach ( $dirsociete as $dirroot ) {
2020-10-07 15:01:28 +02:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2021-02-26 21:17:52 +01:00
if ( $res ) {
break ;
}
2020-10-07 15:01:28 +02:00
}
$modCodeClient = new $module ;
// Load object modCodeFournisseur
$module = ( ! empty ( $conf -> global -> SOCIETE_CODECLIENT_ADDON ) ? $conf -> global -> SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard' );
2021-02-26 21:17:52 +01:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' ) {
2020-10-07 15:01:28 +02:00
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2021-02-26 21:17:52 +01:00
foreach ( $dirsociete as $dirroot ) {
2020-10-07 15:01:28 +02:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2021-02-26 21:17:52 +01:00
if ( $res ) {
break ;
}
2020-10-07 15:01:28 +02:00
}
$modCodeFournisseur = new $module ;
2010-09-07 12:24:26 +02:00
2020-10-07 15:01:28 +02:00
// Define if customer/prospect or supplier status is set or not
2022-02-13 17:53:22 +01:00
if ( GETPOST ( " type " , 'aZ' ) != 'f' ) {
2020-10-07 15:01:28 +02:00
$object -> client = - 1 ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT )) {
$object -> client = 3 ;
}
2020-10-07 15:01:28 +02:00
}
// Prospect / Customer
2022-02-13 17:53:22 +01:00
if ( GETPOST ( " type " , 'aZ' ) == 'c' ) {
2020-10-07 15:01:28 +02:00
if ( ! empty ( $conf -> global -> THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT )) {
$object -> client = $conf -> global -> THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT ;
} else {
$object -> client = 3 ;
}
}
2022-02-13 17:53:22 +01:00
if ( GETPOST ( " type " , 'aZ' ) == 'p' ) {
2021-02-26 21:17:52 +01:00
$object -> client = 2 ;
}
2022-04-01 14:39:10 +02:00
if ( ! empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTSCUSTOMERS ) && $object -> client == 3 ) {
$object -> client = 1 ;
}
2023-04-18 16:15:13 +02:00
if (( isModEnabled ( " supplier_order " ) || isModEnabled ( " supplier_invoice " )) && ( GETPOST ( " type " ) == 'f' || ( GETPOST ( " type " ) == '' && ! empty ( $conf -> global -> THIRDPARTY_SUPPLIER_BY_DEFAULT )))) {
2021-02-26 21:17:52 +01:00
$object -> fournisseur = 1 ;
}
2020-10-07 15:01:28 +02:00
$object -> name = GETPOST ( 'name' , 'alphanohtml' );
2020-10-31 14:32:18 +01:00
$object -> name_alias = GETPOST ( 'name_alias' , 'alphanohtml' );
2020-10-07 15:01:28 +02:00
$object -> firstname = GETPOST ( 'firstname' , 'alphanohtml' );
$object -> particulier = $private ;
$object -> prefix_comm = GETPOST ( 'prefix_comm' , 'alphanohtml' );
$object -> client = GETPOST ( 'client' , 'int' ) ? GETPOST ( 'client' , 'int' ) : $object -> client ;
if ( empty ( $duplicate_code_error )) {
$object -> code_client = GETPOST ( 'customer_code' , 'alpha' );
$object -> fournisseur = GETPOST ( 'fournisseur' ) ? GETPOST ( 'fournisseur' , 'int' ) : $object -> fournisseur ;
$object -> code_fournisseur = GETPOST ( 'supplier_code' , 'alpha' );
} else {
2022-12-28 11:41:59 +01:00
setEventMessages ( $langs -> trans ( 'NewCustomerSupplierCodeProposed' ), null , 'warnings' );
2016-06-30 15:12:35 +02:00
}
2017-06-07 16:44:04 +02:00
2020-10-07 15:01:28 +02:00
$object -> address = GETPOST ( 'address' , 'alphanohtml' );
$object -> zip = GETPOST ( 'zipcode' , 'alphanohtml' );
$object -> town = GETPOST ( 'town' , 'alphanohtml' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2021-10-27 16:39:34 +02:00
2020-10-07 15:01:28 +02:00
$object -> socialnetworks = array ();
2022-08-31 21:49:10 +02:00
if ( isModEnabled ( 'socialnetworks' )) {
2020-10-07 15:01:28 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( GETPOSTISSET ( $key ) && GETPOST ( $key , 'alphanohtml' ) != '' ) {
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alphanohtml' );
}
}
}
2021-10-27 16:39:34 +02:00
2020-10-07 15:01:28 +02:00
$object -> phone = GETPOST ( 'phone' , 'alpha' );
$object -> fax = GETPOST ( 'fax' , 'alpha' );
$object -> email = GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL );
$object -> url = GETPOST ( 'url' , 'custom' , 0 , FILTER_SANITIZE_URL );
$object -> capital = GETPOST ( 'capital' , 'alphanohtml' );
$object -> barcode = GETPOST ( 'barcode' , 'alphanohtml' );
$object -> idprof1 = GETPOST ( 'idprof1' , 'alphanohtml' );
$object -> idprof2 = GETPOST ( 'idprof2' , 'alphanohtml' );
$object -> idprof3 = GETPOST ( 'idprof3' , 'alphanohtml' );
$object -> idprof4 = GETPOST ( 'idprof4' , 'alphanohtml' );
$object -> idprof5 = GETPOST ( 'idprof5' , 'alphanohtml' );
$object -> idprof6 = GETPOST ( 'idprof6' , 'alphanohtml' );
$object -> typent_id = GETPOST ( 'typent_id' , 'int' );
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
$object -> civility_id = GETPOST ( 'civility_id' , 'alpha' );
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'int' );
2023-04-06 08:47:28 +02:00
$object -> vat_reverse_charge = GETPOST ( 'vat_reverse_charge' ) == 'on' ? 1 : 0 ;
2020-10-07 15:01:28 +02:00
$object -> status = GETPOST ( 'status' , 'int' );
//Local Taxes
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' , 'int' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' , 'int' );
$object -> localtax1_value = GETPOST ( 'lt1' , 'int' );
$object -> localtax2_value = GETPOST ( 'lt2' , 'int' );
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alphanohtml' );
$object -> commercial_id = GETPOST ( 'commercial_id' , 'int' );
$object -> default_lang = GETPOST ( 'default_lang' );
2021-02-26 21:17:52 +01:00
if ( GETPOSTISSET ( 'accountancy_code_sell' )) {
2021-07-08 21:35:25 +02:00
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
2021-07-08 21:53:24 +02:00
if ( empty ( $accountancy_code_sell ) || $accountancy_code_sell == '-1' ) {
2021-07-08 21:35:25 +02:00
$object -> accountancy_code_sell = '' ;
} else {
$object -> accountancy_code_sell = $accountancy_code_sell ;
}
2021-02-26 21:17:52 +01:00
}
if ( GETPOSTISSET ( 'accountancy_code_buy' )) {
2021-07-08 21:35:25 +02:00
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
2021-07-08 21:53:24 +02:00
if ( empty ( $accountancy_code_buy ) || $accountancy_code_buy == '-1' ) {
2021-07-08 21:35:25 +02:00
$object -> accountancy_code_buy = '' ;
} else {
$object -> accountancy_code_buy = $accountancy_code_buy ;
}
2021-02-26 21:17:52 +01:00
}
2020-12-04 04:13:42 +01:00
2020-10-07 15:01:28 +02:00
$object -> logo = ( isset ( $_FILES [ 'photo' ]) ? dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]) : '' );
// Gestion du logo de la société
$dir = $conf -> societe -> multidir_output [ $conf -> entity ] . " / " . $object -> id . " /logos " ;
$file_OK = ( isset ( $_FILES [ 'photo' ]) ? is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]) : false );
2021-02-26 21:17:52 +01:00
if ( $file_OK ) {
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ])) {
2020-10-07 15:01:28 +02:00
dol_mkdir ( $dir );
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( @ is_dir ( $dir )) {
2020-10-07 15:01:28 +02:00
$newfile = $dir . '/' . dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 );
2011-06-11 16:14:27 +02:00
2022-08-12 15:54:50 +02:00
if ( ! ( $result > 0 )) {
2020-10-07 15:01:28 +02:00
$errors [] = " ErrorFailedToSaveFile " ;
} else {
// Create thumbs
$object -> addThumbs ( $newfile );
}
}
}
}
// We set country_id, country_code and country for the selected country
$object -> country_id = GETPOST ( 'country_id' ) ? GETPOST ( 'country_id' ) : $mysoc -> country_id ;
2021-02-26 21:17:52 +01:00
if ( $object -> country_id ) {
2020-10-07 15:01:28 +02:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
}
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' );
2022-06-05 14:32:21 +02:00
// We set multicurrency_code if enabled
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2022-06-05 14:32:21 +02:00
$object -> multicurrency_code = GETPOST ( 'multicurrency_code' ) ? GETPOST ( 'multicurrency_code' ) : $conf -> currency ;
}
2020-10-07 15:01:28 +02:00
/* Show create form */
2010-09-07 12:24:26 +02:00
2020-10-07 15:01:28 +02:00
$linkback = " " ;
print load_fiche_titre ( $langs -> trans ( " NewThirdParty " ), $linkback , 'building' );
2010-09-07 12:24:26 +02:00
2020-10-07 15:01:28 +02:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-01-17 17:05:29 +01:00
if ( ! empty ( $conf -> global -> THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION )) {
2020-01-30 01:48:28 +01:00
print " \n " . '<script type="text/javascript">' ;
2020-01-17 17:05:29 +01:00
print ' $ ( document ) . ready ( function () {
2011-01-18 10:05:28 +01:00
id_te_private = 8 ;
id_ef15 = 1 ;
2020-01-30 01:48:28 +01:00
is_private = ' . $private.' ;
2011-01-18 10:05:28 +01:00
if ( is_private ) {
2011-12-15 12:28:31 +01:00
$ ( " .individualline " ) . show ();
2011-01-18 10:05:28 +01:00
} else {
2011-12-15 12:28:31 +01:00
$ ( " .individualline " ) . hide ();
2011-01-18 10:05:28 +01:00
}
2011-12-15 12:28:31 +01:00
$ ( " #radiocompany " ) . click ( function () {
$ ( " .individualline " ) . hide ();
$ ( " #typent_id " ) . val ( 0 );
2021-02-16 18:57:25 +01:00
$ ( " #typent_id " ) . change ();
2011-12-15 12:28:31 +01:00
$ ( " #effectif_id " ) . val ( 0 );
2021-02-16 18:57:25 +01:00
$ ( " #effectif_id " ) . change ();
2011-12-15 12:28:31 +01:00
$ ( " #TypeName " ) . html ( document . formsoc . ThirdPartyName . value );
document . formsoc . private . value = 0 ;
});
$ ( " #radioprivate " ) . click ( function () {
$ ( " .individualline " ) . show ();
$ ( " #typent_id " ) . val ( id_te_private );
2021-02-16 18:57:25 +01:00
$ ( " #typent_id " ) . change ();
2011-12-15 12:28:31 +01:00
$ ( " #effectif_id " ) . val ( id_ef15 );
2021-02-16 18:57:25 +01:00
$ ( " #effectif_id " ) . change ();
2021-10-20 11:30:38 +02:00
/* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
2021-10-20 11:15:02 +02:00
if ( $ ( " #civility_id " ) . data ( " select2 " )) {
$ ( " #civility_id " ) . select2 ({ width : " resolve " });
}
2011-12-15 12:28:31 +01:00
$ ( " #TypeName " ) . html ( document . formsoc . LastName . value );
document . formsoc . private . value = 1 ;
});
2018-10-12 12:04:04 +02:00
2022-04-07 15:01:20 +02:00
var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ? ' 0 ' : ' 1 ') . ' ;
2018-10-12 12:04:04 +02:00
init_customer_categ ();
$ ( " #customerprospect " ) . change ( function () {
init_customer_categ ();
});
function init_customer_categ () {
console . log ( " is customer or prospect = " + jQuery ( " #customerprospect " ) . val ());
2022-04-07 15:01:20 +02:00
if ( jQuery ( " #customerprospect " ) . val () == 0 && ! canHaveCategoryIfNotCustomerProspectSupplier )
2018-10-12 12:04:04 +02:00
{
jQuery ( " .visibleifcustomer " ) . hide ();
}
else
{
jQuery ( " .visibleifcustomer " ) . show ();
}
}
init_supplier_categ ();
$ ( " #fournisseur " ) . change ( function () {
init_supplier_categ ();
});
function init_supplier_categ () {
console . log ( " is supplier = " + jQuery ( " #fournisseur " ) . val ());
if ( jQuery ( " #fournisseur " ) . val () == 0 )
{
jQuery ( " .visibleifsupplier " ) . hide ();
}
else
{
jQuery ( " .visibleifsupplier " ) . show ();
}
}
2011-12-15 12:28:31 +01:00
$ ( " #selectcountry_id " ) . change ( function () {
document . formsoc . action . value = " create " ;
document . formsoc . submit ();
2021-01-07 17:23:02 +01:00
}); ' ;
2021-09-01 22:37:15 +02:00
if ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 ) {
2021-01-07 17:23:02 +01:00
print '
function init_check_no_email ( input ) {
if ( input . val () != " " ) {
$ ( " .noemail " ) . addClass ( " fieldrequired " );
} else {
$ ( " .noemail " ) . removeClass ( " fieldrequired " );
}
}
$ ( " #email " ) . keyup ( function () {
init_check_no_email ( $ ( this ));
});
2021-01-12 09:51:39 +01:00
init_check_no_email ( $ ( " #email " )); ' ;
2021-01-07 17:23:02 +01:00
}
print '});' ;
2020-01-30 01:48:28 +01:00
print '</script>' . " \n " ;
2020-01-17 17:05:29 +01:00
print '<div id="selectthirdpartytype">' ;
print '<div class="hideonsmartphone float">' ;
2020-01-30 01:48:28 +01:00
print $langs -> trans ( " ThirdPartyType " ) . ': ' ;
2020-01-17 17:05:29 +01:00
print '</div>' ;
print '<label for="radiocompany" class="radiocompany">' ;
2020-01-30 01:48:28 +01:00
print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"' . ( $private ? '' : ' checked' ) . '>' ;
2020-01-17 17:05:29 +01:00
print ' ' ;
print $langs -> trans ( " CreateThirdPartyOnly " );
print '</label>' ;
print ' ' ;
print '<label for="radioprivate" class="radioprivate">' ;
2020-01-30 01:48:28 +01:00
$text = '<input type="radio" id="radioprivate" class="flat" name="private" value="1"' . ( $private ? ' checked' : '' ) . '>' ;
2020-01-17 17:05:29 +01:00
$text .= ' ' ;
$text .= $langs -> trans ( " CreateThirdPartyAndContact " );
$htmltext = $langs -> trans ( " ToCreateContactWithSameName " );
print $form -> textwithpicto ( $text , $htmltext , 1 , 'help' , '' , 0 , 3 );
print '</label>' ;
print '</div>' ;
print " <br> \n " ;
} else {
print '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
$ ( " #selectcountry_id " ) . change ( function () {
document . formsoc . action . value = " create " ;
document . formsoc . submit ();
});
}); ' ;
2020-01-30 01:48:28 +01:00
print '</script>' . " \n " ;
2020-01-17 17:05:29 +01:00
}
}
2010-09-07 12:24:26 +02:00
2020-10-31 18:51:30 +01:00
dol_htmloutput_mesg ( is_numeric ( $error ) ? '' : $error , $errors , 'error' );
2010-09-07 12:24:26 +02:00
2020-10-31 18:51:30 +01:00
print '<form enctype="multipart/form-data" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post" name="formsoc" autocomplete="off">' ; // Chrome ignor autocomplete
2010-09-07 12:24:26 +02:00
2020-10-31 18:51:30 +01:00
print '<input type="hidden" name="action" value="add">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2022-05-12 20:18:58 +02:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
print '<input type="hidden" name="backtopagejsfields" value="' . $backtopagejsfields . '">' ;
2022-12-26 15:14:55 +01:00
print '<input type="hidden" name="dol_openinpopup" value="' . $dol_openinpopup . '">' ;
2020-10-31 18:51:30 +01:00
print '<input type="hidden" name="private" value=' . $object -> particulier . '>' ;
print '<input type="hidden" name="type" value=' . GETPOST ( " type " , 'alpha' ) . '>' ;
print '<input type="hidden" name="LastName" value="' . $langs -> trans ( 'ThirdPartyName' ) . ' / ' . $langs -> trans ( 'LastName' ) . '">' ;
print '<input type="hidden" name="ThirdPartyName" value="' . $langs -> trans ( 'ThirdPartyName' ) . '">' ;
2021-02-26 21:17:52 +01:00
if ( $modCodeClient -> code_auto || $modCodeFournisseur -> code_auto ) {
print '<input type="hidden" name="code_auto" value="1">' ;
}
2010-09-07 12:24:26 +02:00
2020-10-31 18:51:30 +01:00
print dol_get_fiche_head ( null , 'card' , '' , 0 , '' );
2014-12-08 17:51:36 +01:00
2020-10-31 18:51:30 +01:00
print '<table class="border centpercent">' ;
2010-09-07 12:24:26 +02:00
2020-10-31 18:51:30 +01:00
// Name, firstname
2021-01-28 15:47:32 +01:00
print '<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">' ;
if ( $object -> particulier || $private ) {
2020-10-31 18:51:30 +01:00
print '<span id="TypeName" class="fieldrequired">' . $langs -> trans ( 'ThirdPartyName' ) . ' / ' . $langs -> trans ( 'LastName' , 'name' ) . '</span>' ;
} else {
2018-10-27 13:48:30 +02:00
print '<span id="TypeName" class="fieldrequired">' . $form -> editfieldkey ( 'ThirdPartyName' , 'name' , '' , $object , 0 ) . '</span>' ;
2020-10-31 18:51:30 +01:00
}
print '</td><td' . ( empty ( $conf -> global -> SOCIETE_USEPREFIX ) ? ' colspan="3"' : '' ) . '>' ;
2022-05-20 23:00:25 +02:00
print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="' . dol_escape_htmltag ( $object -> name ) . '" autofocus="autofocus">' ;
2023-04-27 19:30:34 +02:00
print $form -> widgetForTranslation ( " name " , $object , $permissiontoadd , 'string' , 'alpahnohtml' , 'minwidth300' ); // For some countries that need the company name in 2 languages
// This implementation of the feature to search already existing company has been disabled. It must be implemented by keeping the "input text" and we must call the search ajax societe/ajax/ajaxcompanies.php
// on a keydown of the input. We should show data about a duplicate found if we found less than 5 answers into a div under the input.
2022-05-20 23:00:25 +02:00
/*
2022-04-14 17:19:55 +02:00
print '<select class="name" name="name" id="name" style="min-width:500px"></select>' ;
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
$ ( " #name " ) . select2 ({
ajax : {
url : " ' . DOL_URL_ROOT . '/core/ajax/ajaxcompanies.php " ,
dataType : " json " ,
delay : 250 ,
data : function ( params ) {
return {
newcompany : params . term // search term
2022-12-30 18:43:43 +01:00
}
2022-04-14 17:19:55 +02:00
},
processResults : function ( data , params ) {
return {
results : data
2022-12-30 18:43:43 +01:00
}
2022-04-14 17:19:55 +02:00
},
cache : true
},
placeholder : " ' . $langs->trans ('Name of the new third party. In the meantime we check if it already exists...') . ' " ,
allowClear : true ,
minimumInputLength : 3 ,
language : select2arrayoflanguage ,
2022-05-20 23:00:25 +02:00
containerCssClass : " :all: " ,
2022-04-14 17:19:55 +02:00
selectionCssClass : " :all: " ,
tags : true ,
templateResult : formatCustomer ,
templateSelection : formatCustomerSelection
});
function formatCustomer ( Customer ) {
if ( Customer . label === undefined ) {
return Customer . text ;
}
2022-04-13 02:09:44 +02:00
2022-04-14 17:19:55 +02:00
if ( Customer . logo !== null ) {
logo = \ ' < img src = " \ ';
logo += \ '' . DOL_URL_ROOT . ' / viewimage . php ? modulepart = societe & amp ; entity = 1 & amp ; file = \ ' + Customer . key + " %2Flogos%2Fthumbs%2F " + Customer . logo . replace ( " . " , " _mini. " ) + " &cache=0 " ;
logo += \ ' " /></div> \ ';
} else {
logo = \ ' < div class = " floatleft inline-block valigntop photowithmargin " style = " padding:0 10px " >< div class = " photosociete photoref " alt = " No photo " >< span class = " fas fa-building " style = " color: #6c6aa8; " ></ span ></ div ></ div > \ ' ;
}
2022-05-20 23:00:25 +02:00
2022-04-14 17:19:55 +02:00
var $container = $ ( " <div class= \ 'select2-result-repository clearfix \ '> " +
" <div class= \ 'select2-result-repository__avatar floatleft inline-block valigntop \ '> " + logo +
" <div class= \ 'select2-result-repository__meta floatleft inline-block valigntop \ '> " +
" <div class= \ 'select2-result-repository__title \ '></div> " +
" <div class= \ 'select2-result-repository__name_alias \ '></div> " +
" <div class= \ 'select2-result-repository__code_client \ '></div> " +
" <div class= \ 'select2-result-repository__code_fournisseur \ '></div> " +
" <div class= \ 'select2-result-repository__companies_info \ '> " +
" <div class= \ 'select2-result-repository__email \ '><i class= \ 'fa fa-at \ '></i> </div> " +
" <div class= \ 'select2-result-repository__address \ '><i class= \ 'fa fa-flag \ '></i> </div> " +
" <div class= \ 'select2-result-repository__zip \ '><i class= \ 'fa fa-circle-o \ '></i> </div> " +
" <div class= \ 'select2-result-repository__country \ '><i class= \ 'fa fa-globe-americas \ '></i> </div> " +
" <div class= \ 'select2-result-repository__departement \ '><i class= \ 'fa fa-circle-o \ '></i> </div> " +
" <div class= \ 'select2-result-repository__town \ '><i class= \ 'fa fa-circle-o \ '></i> </div> " +
" <div class= \ 'select2-result-repository__siren \ '><i class= \ 'fa fa-circle-o \ '></i> </div> " +
" <div class= \ 'select2-result-repository__datec \ '><i class= \ 'fa fa-calendar \ '></i> </div> " +
" </div> " +
" </div> " +
" </div> "
);
2022-04-13 02:09:44 +02:00
2022-04-14 17:19:55 +02:00
$container . find ( " .select2-result-repository__title " ) . text ( Customer . label );
$container . find ( " .select2-result-repository__name_alias " ) . text ( Customer . name_alias ? Customer . name_alias : " " );
$container . find ( " .select2-result-repository__code_client " ) . text ( Customer . code_client ? Customer . code_client : " " );
$container . find ( " .select2-result-repository__code_fournisseur " ) . text (( Customer . code_fournisseur !== null ) ? Customer . code_fournisseur : " " );
$container . find ( " .select2-result-repository__email " ) . append ( " ' . $langs->trans ('EMail') . ': " + ( Customer . email !== null ? Customer . email : " " ));
$container . find ( " .select2-result-repository__address " ) . append ( " ' . $langs->trans ('Address') . ': " + ( Customer . address !== null ? Customer . address : " " ));
$container . find ( " .select2-result-repository__country " ) . append ( " ' . $langs->trans ('Country') . ': " + ( Customer . country !== null ? Customer . country : " " ));
$container . find ( " .select2-result-repository__departement " ) . append ( " ' . $langs->trans ('Region-State') . ': " + ( Customer . departement !== null ? Customer . departement : " " ));
$container . find ( " .select2-result-repository__zip " ) . append ( " ' . $langs->trans ('Zip') . ': " + ( Customer . zip !== null ? Customer . zip : " " ));
$container . find ( " .select2-result-repository__town " ) . append ( " ' . $langs->trans ('Town') . ': " + ( Customer . town !== null ? Customer . town : " " ));
$container . find ( " .select2-result-repository__siren " ) . append ( " ' . $langs->trans ('Siren') . ': " + ( Customer . siren !== null ? Customer . siren : " " ));
$container . find ( " .select2-result-repository__datec " ) . append ( " ' . $langs->trans ('Created') . ': " + ( Customer . datec !== null ? Customer . datec : " " ));
return $container ;
2022-04-13 18:11:51 +02:00
}
2022-04-14 17:19:55 +02:00
function formatCustomerSelection ( selection ) {
return selection . label || selection . text ;
}
});
</ script >
' ;
2022-05-20 23:00:25 +02:00
*/
2020-10-31 18:51:30 +01:00
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) { // Old not used prefix field
2020-10-31 18:51:30 +01:00
print '<td>' . $langs -> trans ( 'Prefix' ) . '</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="' . dol_escape_htmltag ( $object -> prefix_comm ) . '"></td>' ;
}
print '</tr>' ;
// If javascript on, we show option individual
2021-02-26 21:17:52 +01:00
if ( $conf -> use_javascript_ajax ) {
if ( ! empty ( $conf -> global -> THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION )) {
2020-10-31 18:51:30 +01:00
// Firstname
print '<tr class="individualline"><td>' . $form -> editfieldkey ( 'FirstName' , 'firstname' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="' . dol_escape_htmltag ( $object -> firstname ) . '"></td>' ;
print '</tr>' ;
// Title
print '<tr class="individualline"><td>' . $form -> editfieldkey ( 'UserTitle' , 'civility_id' , '' , $object , 0 ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
print $formcompany -> select_civility ( $object -> civility_id , 'civility_id' , 'maxwidth100' ) . '</td>' ;
print '</tr>' ;
}
}
// Alias names (commercial, trademark or alias names)
print '<tr id="name_alias"><td><label for="name_alias_input">' . $langs -> trans ( 'AliasNames' ) . '</label></td>' ;
print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="' . dol_escape_htmltag ( $object -> name_alias ) . '"></td></tr>' ;
// Prospect/Customer
print '<tr><td class="titlefieldcreate">' . $form -> editfieldkey ( 'ProspectCustomer' , 'customerprospect' , '' , $object , 0 , 'string' , '' , 1 ) . '</td>' ;
print '<td class="maxwidthonsmartphone">' ;
$selected = ( GETPOSTISSET ( 'client' ) ? GETPOST ( 'client' , 'int' ) : $object -> client );
print $formcompany -> selectProspectCustomerType ( $selected );
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 18:51:30 +01:00
print '<td>' . $form -> editfieldkey ( 'CustomerCode' , 'customer_code' , '' , $object , 0 ) . '</td><td>' ;
print '<table class="nobordernopadding"><tr><td>' ;
2019-11-13 18:32:11 +01:00
$tmpcode = $object -> code_client ;
2021-02-26 21:17:52 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modCodeClient -> code_auto )) {
$tmpcode = $modCodeClient -> getNextValue ( $object , 0 );
}
2021-02-28 23:43:07 +01:00
print '<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="24">' ;
2020-10-31 18:51:30 +01:00
print '</td><td>' ;
$s = $modCodeClient -> getToolTip ( $langs , $object , 0 );
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
print '</td></tr>' ;
2022-08-23 20:05:09 +02:00
if (( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))
2022-08-31 22:02:31 +02:00
|| ( isModEnabled ( 'supplier_proposal' ) && ! empty ( $user -> rights -> supplier_proposal -> lire ))) {
2020-10-31 18:51:30 +01:00
// Supplier
print '<tr>' ;
print '<td>' . $form -> editfieldkey ( 'Vendor' , 'fournisseur' , '' , $object , 0 , 'string' , '' , 1 ) . '</td><td>' ;
$default = - 1 ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> THIRDPARTY_SUPPLIER_BY_DEFAULT )) {
$default = 1 ;
}
2020-12-11 00:55:21 +01:00
print $form -> selectyesno ( " fournisseur " , ( GETPOST ( 'fournisseur' , 'int' ) != '' ? GETPOST ( 'fournisseur' , 'int' ) : ( GETPOST ( " type " , 'alpha' ) == '' ? $default : $object -> fournisseur )), 1 , 0 , ( GETPOST ( " type " , 'alpha' ) == '' ? 1 : 0 ), 1 );
2020-10-31 18:51:30 +01:00
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 18:51:30 +01:00
print '<td>' ;
2022-08-23 20:05:09 +02:00
if (( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))) {
2020-10-31 18:51:30 +01:00
print $form -> editfieldkey ( 'SupplierCode' , 'supplier_code' , '' , $object , 0 );
}
print '</td><td>' ;
2022-08-23 20:05:09 +02:00
if (( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))) {
2020-10-31 18:51:30 +01:00
print '<table class="nobordernopadding"><tr><td>' ;
$tmpcode = $object -> code_fournisseur ;
2021-02-26 21:17:52 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modCodeFournisseur -> code_auto )) {
$tmpcode = $modCodeFournisseur -> getNextValue ( $object , 1 );
}
2021-02-28 23:43:07 +01:00
print '<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="24">' ;
2020-10-31 18:51:30 +01:00
print '</td><td>' ;
$s = $modCodeFournisseur -> getToolTip ( $langs , $object , 1 );
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
}
print '</td></tr>' ;
}
// Status
print '<tr><td>' . $form -> editfieldkey ( 'Status' , 'status' , '' , $object , 0 ) . '</td><td colspan="3">' ;
2020-12-11 00:55:21 +01:00
print $form -> selectarray ( 'status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), 1 , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth100' , 1 );
2020-10-31 18:51:30 +01:00
print '</td></tr>' ;
// Barcode
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Gencod' , 'barcode' , '' , $object , 0 ) . '</td>' ;
2021-02-27 02:49:24 +01:00
print '<td colspan="3">' ;
2021-12-12 02:13:09 +01:00
print img_picto ( '' , 'barcode' , 'class="pictofixedwidth"' );
2021-02-27 02:49:24 +01:00
print '<input type="text" name="barcode" id="barcode" value="' . dol_escape_htmltag ( $object -> barcode ) . '">' ;
2020-10-31 18:51:30 +01:00
print '</td></tr>' ;
}
// Address
print '<tr><td class="tdtop">' ;
print $form -> editfieldkey ( 'Address' , 'address' , '' , $object , 0 );
print '</td>' ;
print '<td colspan="3">' ;
print '<textarea name="address" id="address" class="quatrevingtpercent" rows="' . ROWS_2 . '" wrap="soft">' ;
2020-11-04 18:54:56 +01:00
print dol_escape_htmltag ( $object -> address , 0 , 1 );
2020-10-31 18:51:30 +01:00
print '</textarea>' ;
print $form -> widgetForTranslation ( " address " , $object , $permissiontoadd , 'textarea' , 'alphanohtml' , 'quatrevingtpercent' );
print '</td></tr>' ;
// Zip / Town
print '<tr><td>' . $form -> editfieldkey ( 'Zip' , 'zipcode' , '' , $object , 0 ) . '</td><td>' ;
2021-01-13 12:45:23 +01:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 0 , 0 , '' , 'maxwidth100' );
2020-10-31 18:51:30 +01:00
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 18:51:30 +01:00
print '<td class="tdtop">' . $form -> editfieldkey ( 'Town' , 'town' , '' , $object , 0 ) . '</td><td>' ;
2021-10-18 16:22:19 +02:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ), 0 , 0 , '' , 'maxwidth150 quatrevingtpercent' );
2020-10-31 18:51:30 +01:00
print $form -> widgetForTranslation ( " town " , $object , $permissiontoadd , 'string' , 'alphanohtml' , 'maxwidth100 quatrevingtpercent' );
print '</td></tr>' ;
// Country
print '<tr><td>' . $form -> editfieldkey ( 'Country' , 'selectcountry_id' , '' , $object , 0 ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
2021-12-12 02:13:09 +01:00
print img_picto ( '' , 'country' , 'class="pictofixedwidth"' );
2020-11-23 12:29:38 +01:00
print $form -> select_country (( GETPOSTISSET ( 'country_id' ) ? GETPOST ( 'country_id' ) : $object -> country_id ), 'country_id' , '' , 0 , 'minwidth300 maxwidth500 widthcentpercentminusx' );
2021-02-26 21:17:52 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2020-10-31 18:51:30 +01:00
print '</td></tr>' ;
// State
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE )) {
if ( ! empty ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT ) && ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 2 )) {
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Region-State' , 'state_id' , '' , $object , 0 ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
} else {
print '<tr><td>' . $form -> editfieldkey ( 'State' , 'state_id' , '' , $object , 0 ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
}
2021-02-26 21:17:52 +01:00
if ( $object -> country_id ) {
2021-07-04 19:23:04 +02:00
print img_picto ( '' , 'state' , 'class="pictofixedwidth"' );
2021-02-26 21:17:52 +01:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code );
} else {
print $countrynotdefined ;
}
2020-10-31 18:51:30 +01:00
print '</td></tr>' ;
}
// Phone / Fax
print '<tr><td>' . $form -> editfieldkey ( 'Phone' , 'phone' , '' , $object , 0 ) . '</td>' ;
2021-12-12 02:13:09 +01:00
print '<td' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' . img_picto ( '' , 'object_phoning' , 'class="pictofixedwidth"' ) . ' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="' . ( GETPOSTISSET ( 'phone' ) ? GETPOST ( 'phone' , 'alpha' ) : $object -> phone ) . '"></td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 18:51:30 +01:00
print '<td>' . $form -> editfieldkey ( 'Fax' , 'fax' , '' , $object , 0 ) . '</td>' ;
2021-12-12 02:13:09 +01:00
print '<td' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' . img_picto ( '' , 'object_phoning_fax' , 'class="pictofixedwidth"' ) . ' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="' . ( GETPOSTISSET ( 'fax' ) ? GETPOST ( 'fax' , 'alpha' ) : $object -> fax ) . '"></td></tr>' ;
2020-10-31 18:51:30 +01:00
// Email / Web
2020-12-29 04:27:16 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'EMail' , 'email' , '' , $object , 0 , 'string' , '' , empty ( $conf -> global -> SOCIETE_EMAIL_MANDATORY ) ? '' : $conf -> global -> SOCIETE_EMAIL_MANDATORY ) . '</td>' ;
2022-09-04 13:26:49 +02:00
print '<td' . (( $conf -> browser -> layout == 'phone' ) || ! isModEnabled ( 'mailing' ) ? ' colspan="3"' : '' ) . '>' . img_picto ( '' , 'object_email' , 'class="pictofixedwidth"' ) . ' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="' . $object -> email . '"></td>' ;
2022-09-04 13:25:54 +02:00
if ( isModEnabled ( 'mailing' ) && ! empty ( $conf -> global -> THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION )) {
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2021-01-07 17:23:02 +01:00
print '<td class="individualline noemail">' . $form -> editfieldkey ( $langs -> trans ( 'No_Email' ) . ' (' . $langs -> trans ( 'Contact' ) . ')' , 'contact_no_email' , '' , $object , 0 ) . '</td>' ;
2022-09-04 13:26:49 +02:00
print '<td class="individualline" ' . (( $conf -> browser -> layout == 'phone' ) || ! isModEnabled ( 'mailing' ) ? ' colspan="3"' : '' ) . '>' . $form -> selectyesno ( 'contact_no_email' , ( GETPOSTISSET ( " contact_no_email " ) ? GETPOST ( " contact_no_email " , 'alpha' ) : ( empty ( $object -> no_email ) ? 0 : 1 )), 1 , false , 1 ) . '</td>' ;
2021-01-07 17:23:02 +01:00
}
print '</tr>' ;
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Web' , 'url' , '' , $object , 0 ) . '</td>' ;
2021-12-12 02:13:09 +01:00
print '<td colspan="3">' . img_picto ( '' , 'globe' , 'class="pictofixedwidth"' ) . ' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="' . $object -> url . '"></td></tr>' ;
2020-10-31 18:51:30 +01:00
2023-03-27 13:02:42 +02:00
// Unsubscribe
2023-02-21 13:19:57 +01:00
if ( isModEnabled ( 'mailing' )) {
2022-08-29 14:47:01 +02:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 ) {
print " \n " . '<script type="text/javascript">' . " \n " ;
print ' $ ( document ) . ready ( function () {
2022-08-29 14:46:26 +02:00
$ ( " #email " ) . keyup ( function () {
if ( $ ( this ) . val () != " " ) {
$ ( " .noemail " ) . addClass ( " fieldrequired " );
} else {
$ ( " .noemail " ) . removeClass ( " fieldrequired " );
}
});
}) ' . " \n " ;
2022-08-29 14:47:01 +02:00
print '</script>' . " \n " ;
}
if ( ! GETPOSTISSET ( " no_email " ) && ! empty ( $object -> email )) {
$result = $object -> getNoEmail ();
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2022-08-29 14:46:26 +02:00
}
}
2022-08-29 14:47:01 +02:00
print '<tr>' ;
print '<td class="noemail"><label for="no_email">' . $langs -> trans ( " No_Email " ) . '</label></td>' ;
print '<td>' ;
print $form -> selectyesno ( 'no_email' , ( GETPOSTISSET ( " no_email " ) ? GETPOST ( " no_email " , 'int' ) : $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS ), 1 , false , ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 ));
print '</td>' ;
print '</tr>' ;
}
2022-08-29 14:46:26 +02:00
2021-12-12 02:13:09 +01:00
// Social networks
2022-08-31 21:49:10 +02:00
if ( isModEnabled ( 'socialnetworks' )) {
2023-01-20 13:36:23 +01:00
$object -> showSocialNetwork ( $socialnetworks , ( $conf -> browser -> layout == 'phone' ? 2 : 4 ));
2020-10-31 18:51:30 +01:00
}
// Prof ids
$i = 1 ; $j = 0 ; $NBCOLS = ( $conf -> browser -> layout == 'phone' ? 1 : 2 );
2020-12-11 00:55:21 +01:00
while ( $i <= 6 ) {
2020-10-31 18:51:30 +01:00
$idprof = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code );
2020-12-11 00:55:21 +01:00
if ( $idprof != '-' ) {
2020-10-31 18:51:30 +01:00
$key = 'idprof' . $i ;
2021-02-26 21:17:52 +01:00
if (( $j % $NBCOLS ) == 0 ) {
print '<tr>' ;
}
2020-10-31 18:51:30 +01:00
$idprof_mandatory = 'SOCIETE_IDPROF' . ( $i ) . '_MANDATORY' ;
print '<td>' . $form -> editfieldkey ( $idprof , $key , '' , $object , 0 , 'string' , '' , ( empty ( $conf -> global -> $idprof_mandatory ) ? 0 : 1 )) . '</td><td>' ;
print $formcompany -> get_input_id_prof ( $i , $key , $object -> $key , $object -> country_code );
print '</td>' ;
2021-02-26 21:17:52 +01:00
if (( $j % $NBCOLS ) == ( $NBCOLS - 1 )) {
print '</tr>' ;
}
2020-10-31 18:51:30 +01:00
$j ++ ;
}
$i ++ ;
}
2021-02-26 21:17:52 +01:00
if ( $NBCOLS > 1 && ( $j % 2 == 1 )) {
print '<td colspan="2"></td></tr>' ;
}
2020-10-31 18:51:30 +01:00
// Vat is used
print '<tr><td>' . $form -> editfieldkey ( 'VATIsUsed' , 'assujtva_value' , '' , $object , 0 ) . '</td>' ;
print '<td>' ;
print $form -> selectyesno ( 'assujtva_value' , GETPOSTISSET ( 'assujtva_value' ) ? GETPOST ( 'assujtva_value' , 'int' ) : 1 , 1 ); // Assujeti par defaut en creation
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 18:51:30 +01:00
print '<td class="nowrap">' . $form -> editfieldkey ( 'VATIntra' , 'intra_vat' , '' , $object , 0 ) . '</td>' ;
print '<td class="nowrap">' ;
$s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="' . $object -> tva_intra . '">' ;
2020-12-11 00:55:21 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ) && isInEEC ( $object )) {
2020-10-31 18:51:30 +01:00
$s .= ' ' ;
2020-12-11 00:55:21 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-10-31 18:51:30 +01:00
$widthpopup = 600 ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> dol_use_jmobile )) {
$widthpopup = 350 ;
}
2020-10-31 18:51:30 +01:00
$heightpopup = 400 ;
print " \n " ;
2021-11-29 15:09:18 +01:00
print '<script type="text/javascript">' ;
2020-10-31 18:51:30 +01:00
print " function CheckVAT(a) { \n " ;
print " newpopup(' " . DOL_URL_ROOT . " /societe/checkvat/checkVatPopup.php?vatNumber='+a, ' " . dol_escape_js ( $langs -> trans ( " VATIntraCheckableOnEUSite " )) . " ', " . $widthpopup . " , " . $heightpopup . " ); \n " ;
print " } \n " ;
print '</script>' ;
print " \n " ;
2023-05-01 14:33:08 +02:00
$s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
2020-10-31 18:51:30 +01:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> transnoentitiesnoconv ( " VATIntraCheck " )), 1 );
} else {
2021-11-22 02:35:55 +01:00
$s .= '<a href="' . $langs -> transcountry ( " VATIntraCheckURL " , $object -> country_id ) . '" target="_blank" rel="noopener noreferrer">' . img_picto ( $langs -> trans ( " VATIntraCheckableOnEUSite " ), 'help' ) . '</a>' ;
2020-10-31 18:51:30 +01:00
}
}
print $s ;
print '</td>' ;
print '</tr>' ;
2023-04-06 08:47:28 +02:00
// VAT reverse charge by default
if ( ! empty ( $conf -> global -> ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE )) {
print '<tr><td>' . $form -> editfieldkey ( 'VATReverseChargeByDefault' , 'vat_reverse_charge' , '' , $object , 0 ) . '</td><td colspan="3">' ;
print '<input type="checkbox" name="vat_reverse_charge" ' . ( $object -> vat_reverse_charge == '1' ? ' checked' : '' ) . '>' ;
print '</td></tr>' ;
}
2020-10-31 18:51:30 +01:00
// Local Taxes
//TODO: Place into a function to control showing by country or study better option
2021-02-26 21:17:52 +01:00
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " ) {
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print $form -> selectyesno ( 'localtax1assuj_value' , ( isset ( $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX1 ) ? $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX1 : 0 ), 1 );
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 18:51:30 +01:00
print '<td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print $form -> selectyesno ( 'localtax2assuj_value' , ( isset ( $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX2 ) ? $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX2 : 0 ), 1 );
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
} elseif ( $mysoc -> localtax1_assuj == " 1 " ) {
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
print $form -> selectyesno ( 'localtax1assuj_value' , ( isset ( $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX1 ) ? $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX1 : 0 ), 1 );
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
} elseif ( $mysoc -> localtax2_assuj == " 1 " ) {
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
print $form -> selectyesno ( 'localtax2assuj_value' , ( isset ( $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX2 ) ? $conf -> global -> THIRDPARTY_DEFAULT_USELOCALTAX2 : 0 ), 1 );
print '</td></tr>' ;
}
// Type - Workforce/Staff
2021-04-16 15:26:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'ThirdPartyType' , 'typent_id' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone"' . ( ( $conf -> browser -> layout == 'phone' || ! empty ( $conf -> global -> SOCIETE_DISABLE_WORKFORCE )) ? ' colspan="3"' : '' ) . '>' . " \n " ;
2020-10-31 18:51:30 +01:00
$sortparam = ( empty ( $conf -> global -> SOCIETE_SORT_ON_TYPEENT ) ? 'ASC' : $conf -> global -> SOCIETE_SORT_ON_TYPEENT ); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
2021-02-04 08:35:17 +01:00
print $form -> selectarray ( " typent_id " , $formcompany -> typent_array ( 0 ), $object -> typent_id , 1 , 0 , 0 , '' , 0 , 0 , 0 , $sortparam , '' , 1 );
2021-02-26 21:17:52 +01:00
if ( $user -> admin ) {
print ' ' . info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2021-04-21 17:04:44 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_WORKFORCE )) {
2021-04-16 15:26:29 +02:00
print '</td>' ;
2021-04-21 17:02:37 +02:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2021-04-16 15:26:29 +02:00
print '<td>' . $form -> editfieldkey ( 'Workforce' , 'effectif_id' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone"' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' ;
print $form -> selectarray ( " effectif_id " , $formcompany -> effectif_array ( 0 ), $object -> effectif_id , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , '' , 1 );
2021-04-21 17:02:37 +02:00
if ( $user -> admin ) {
print ' ' . info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2021-04-21 17:04:44 +02:00
} else {
2021-04-16 15:26:29 +02:00
print '<input type="hidden" name="effectif_id" id="effectif_id" value="' . $object -> effectif_id . '">' ;
}
2020-10-31 18:51:30 +01:00
print '</td></tr>' ;
// Legal Form
print '<tr><td>' . $form -> editfieldkey ( 'JuridicalStatus' , 'forme_juridique_code' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2021-02-26 21:17:52 +01:00
if ( $object -> country_id ) {
2020-10-31 18:51:30 +01:00
print $formcompany -> select_juridicalstatus ( $object -> forme_juridique_code , $object -> country_code , '' , 'forme_juridique_code' );
} else {
print $countrynotdefined ;
}
print '</td></tr>' ;
// Capital
print '<tr><td>' . $form -> editfieldkey ( 'Capital' , 'capital' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="' . $object -> capital . '"> ' ;
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2022-06-05 14:32:21 +02:00
print '<span class="hideonsmartphone">' . $langs -> trans ( " Currency " . $object -> multicurrency_code ) . '</span></td></tr>' ;
} else {
print '<span class="hideonsmartphone">' . $langs -> trans ( " Currency " . $conf -> currency ) . '</span></td></tr>' ;
}
2022-09-24 14:55:10 +02:00
if ( getDolGlobalInt ( 'MAIN_MULTILANGS' )) {
2020-10-31 18:51:30 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'DefaultLang' , 'default_lang' , '' , $object , 0 ) . '</td><td colspan="3" class="maxwidthonsmartphone">' . " \n " ;
2021-12-12 02:13:09 +01:00
print img_picto ( '' , 'language' , 'class="pictofixedwidth"' ) . $formadmin -> select_language ( GETPOST ( 'default_lang' , 'alpha' ) ? GETPOST ( 'default_lang' , 'alpha' ) : ( $object -> default_lang ? $object -> default_lang : '' ), 'default_lang' , 0 , 0 , 1 , 0 , 0 , 'maxwidth200onsmartphone' );
2020-10-31 18:51:30 +01:00
print '</td>' ;
print '</tr>' ;
}
2011-06-11 22:58:08 +02:00
2015-02-09 17:55:43 +01:00
// Incoterms
2022-09-25 22:53:21 +02:00
if ( isModEnabled ( 'incoterm' )) {
2015-02-09 17:55:43 +01:00
print '<tr>' ;
2018-10-27 13:48:30 +02:00
print '<td>' . $form -> editfieldkey ( 'IncotermLabel' , 'incoterm_id' , '' , $object , 0 ) . '</td>' ;
2020-10-31 18:51:30 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
print $form -> select_incoterms (( ! empty ( $object -> fk_incoterms ) ? $object -> fk_incoterms : '' ), ( ! empty ( $object -> location_incoterms ) ? $object -> location_incoterms : '' ));
2015-02-09 17:55:43 +01:00
print '</td></tr>' ;
}
2015-03-14 13:05:28 +01:00
2015-05-29 18:49:10 +02:00
// Categories
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'categorie' ) && ! empty ( $user -> rights -> categorie -> lire )) {
2015-09-16 21:35:20 +02:00
$langs -> load ( 'categories' );
2015-08-26 19:30:40 +02:00
// Customer
2019-11-13 18:32:11 +01:00
print '<tr class="visibleifcustomer"><td class="toptd">' . $form -> editfieldkey ( 'CustomersProspectsCategoriesShort' , 'custcats' , '' , $object , 0 ) . '</td><td colspan="3">' ;
2018-10-12 12:04:04 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_CUSTOMER , null , 'parent' , null , null , 1 );
2021-12-12 02:13:09 +01:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'custcats' , $cate_arbo , GETPOST ( 'custcats' , 'array' ), null , null , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2018-10-12 12:04:04 +02:00
print " </td></tr> " ;
2015-08-26 19:30:40 +02:00
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION )) {
2021-01-06 09:11:04 +01:00
print '<tr class="individualline"><td class="toptd">' . $form -> editfieldkey ( 'ContactCategoriesShort' , 'contcats' , '' , $object , 0 ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_CONTACT , null , 'parent' , null , null , 1 );
2021-12-12 02:13:09 +01:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'contcats' , $cate_arbo , GETPOST ( 'contcats' , 'array' ), null , null , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2021-01-12 10:08:12 +01:00
print " </td></tr> " ;
}
2015-08-26 19:30:40 +02:00
// Supplier
2023-04-18 16:15:13 +02:00
if ( isModEnabled ( " supplier_proposal " ) || isModEnabled ( " supplier_order " ) || isModEnabled ( " supplier_invoice " )) {
2021-01-06 20:51:44 +01:00
print '<tr class="visibleifsupplier"><td class="toptd">' . $form -> editfieldkey ( 'SuppliersCategoriesShort' , 'suppcats' , '' , $object , 0 ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_SUPPLIER , null , 'parent' , null , null , 1 );
2021-12-12 02:13:09 +01:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'suppcats' , $cate_arbo , GETPOST ( 'suppcats' , 'array' ), null , null , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2021-01-06 20:51:44 +01:00
print " </td></tr> " ;
}
2015-08-26 19:30:40 +02:00
}
2015-06-05 14:02:50 +02:00
2016-01-18 19:45:27 +01:00
// Multicurrency
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2016-01-18 19:45:27 +01:00
print '<tr>' ;
2018-10-27 13:48:30 +02:00
print '<td>' . $form -> editfieldkey ( 'Currency' , 'multicurrency_code' , '' , $object , 0 ) . '</td>' ;
2020-10-31 14:32:18 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'currency' , 'class="pictofixedwidth"' );
print $form -> selectMultiCurrency (( GETPOSTISSET ( 'multicurrency_code' ) ? GETPOST ( 'multicurrency_code' ) : ( $object -> multicurrency_code ? $object -> multicurrency_code : $conf -> currency )), 'multicurrency_code' , 1 , '' , false , 'maxwidth150 widthcentpercentminusx' );
2016-01-18 19:45:27 +01:00
print '</td></tr>' ;
}
2020-03-10 21:54:50 +01:00
// Other attributes
$parameters = array ( 'socid' => $socid , 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' );
2020-03-13 17:22:54 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php' ;
2011-06-22 12:58:22 +02:00
2022-04-07 15:59:50 +02:00
// Parent company
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PARENTCOMPANY )) {
print '<tr>' ;
print '<td>' . $langs -> trans ( 'ParentCompany' ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
print img_picto ( '' , 'company' , 'class="paddingrightonly"' );
2022-04-07 16:05:55 +02:00
print $form -> select_company ( GETPOST ( 'parent_company_id' ), 'parent_company_id' , '' , 'SelectThirdParty' , 0 , 0 , null , 0 , 'minwidth300 maxwidth500 widthcentpercentminusxx' );
2022-04-07 15:59:50 +02:00
print '</td></tr>' ;
}
2018-12-14 15:42:01 +01:00
// Assign a sale representative
print '<tr>' ;
print '<td>' . $form -> editfieldkey ( 'AllocateCommercial' , 'commercial_id' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2023-03-27 13:02:42 +02:00
$userlist = $form -> select_dolusers ( '' , '' , 0 , null , 0 , '' , '' , '0' , 0 , 0 , 'AND u.statut = 1' , 0 , '' , '' , 0 , 2 );
2019-09-30 13:04:01 +02:00
// Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record.
2019-11-13 18:32:11 +01:00
$selected = ( count ( GETPOST ( 'commercial' , 'array' )) > 0 ? GETPOST ( 'commercial' , 'array' ) : ( GETPOST ( 'commercial' , 'int' ) > 0 ? array ( GETPOST ( 'commercial' , 'int' )) : ( empty ( $user -> rights -> societe -> client -> voir ) ? array ( $user -> id ) : array ())));
2020-12-11 00:55:21 +01:00
print img_picto ( '' , 'user' ) . $form -> multiselectarray ( 'commercial' , $userlist , $selected , null , null , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2018-12-14 15:42:01 +01:00
print '</td></tr>' ;
2018-11-27 09:22:59 +01:00
2021-02-27 02:44:52 +01:00
// Add logo
2020-10-31 14:32:18 +01:00
print '<tr class="hideonsmartphone">' ;
print '<td>' . $form -> editfieldkey ( 'Logo' , 'photoinput' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3">' ;
print '<input class="flat" type="file" name="photo" id="photoinput" />' ;
print '</td>' ;
print '</tr>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
print '</table>' . " \n " ;
2011-08-13 02:47:59 +02:00
2020-12-04 04:13:42 +01:00
// Accountancy codes
2021-01-15 17:35:16 +01:00
if ( ! empty ( $conf -> global -> ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY )) {
2022-12-28 01:54:54 +01:00
print '<table class="border centpercent">' ;
2020-12-04 04:13:42 +01:00
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-01-15 17:35:16 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td>' ;
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
print $formaccounting -> select_account ( $accountancy_code_sell , 'accountancy_code_sell' , 1 , null , 1 , 1 , '' );
print '</td></tr>' ;
2020-12-04 04:13:42 +01:00
2021-01-15 17:35:16 +01:00
// Accountancy_code_buy
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td>' ;
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
print $formaccounting -> select_account ( $accountancy_code_buy , 'accountancy_code_buy' , 1 , null , 1 , 1 , '' );
print '</td></tr>' ;
2021-06-29 19:24:46 +02:00
} else { // For external software
2021-01-15 17:35:16 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="' . $object -> accountancy_code_sell . '">' ;
print '</td></tr>' ;
2020-12-04 04:13:42 +01:00
2021-01-15 17:35:16 +01:00
// Accountancy_code_buy
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="' . $object -> accountancy_code_buy . '">' ;
print '</td></tr>' ;
}
print '</table>' ;
2020-12-04 04:13:42 +01:00
}
2020-10-31 14:32:18 +01:00
print dol_get_fiche_end ();
2014-12-08 17:51:36 +01:00
2022-05-12 20:18:58 +02:00
print $form -> buttonsSaveCancel ( " AddThirdParty " , 'Cancel' , null , 0 , '' , $dol_openinpopup );
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
print '</form>' . " \n " ;
2020-12-11 00:55:21 +01:00
} elseif ( $action == 'edit' ) {
2020-10-31 14:32:18 +01:00
//print load_fiche_titre($langs->trans("EditCompany"));
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( $socid ) {
2020-10-31 14:32:18 +01:00
$res = $object -> fetch_optionals ();
//if ($res < 0) { dol_print_error($db); exit; }
2011-06-22 12:58:22 +02:00
2020-10-31 14:32:18 +01:00
$head = societe_prepare_head ( $object );
2012-04-05 20:33:40 +02:00
2020-10-31 14:32:18 +01:00
// Load object modCodeTiers
$module = ( ! empty ( $conf -> global -> SOCIETE_CODECLIENT_ADDON ) ? $conf -> global -> SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard' );
2021-02-26 21:17:52 +01:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' ) {
2020-10-31 14:32:18 +01:00
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2021-02-26 21:17:52 +01:00
foreach ( $dirsociete as $dirroot ) {
2020-10-31 14:32:18 +01:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2021-02-26 21:17:52 +01:00
if ( $res ) {
break ;
}
2020-10-31 14:32:18 +01:00
}
$modCodeClient = new $module ( $db );
// We verified if the tag prefix is used
2021-02-26 21:17:52 +01:00
if ( $modCodeClient -> code_auto ) {
2020-10-31 14:32:18 +01:00
$prefixCustomerIsUsed = $modCodeClient -> verif_prefixIsUsed ();
}
$module = $conf -> global -> SOCIETE_CODECLIENT_ADDON ;
2021-02-26 21:17:52 +01:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' ) {
2020-10-31 14:32:18 +01:00
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2021-02-26 21:17:52 +01:00
foreach ( $dirsociete as $dirroot ) {
2020-10-31 14:32:18 +01:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2021-02-26 21:17:52 +01:00
if ( $res ) {
break ;
}
2020-10-31 14:32:18 +01:00
}
$modCodeFournisseur = new $module ( $db );
// On verifie si la balise prefix est utilisee
2021-02-26 21:17:52 +01:00
if ( $modCodeFournisseur -> code_auto ) {
2020-10-31 14:32:18 +01:00
$prefixSupplierIsUsed = $modCodeFournisseur -> verif_prefixIsUsed ();
}
2014-09-15 22:58:39 +02:00
2015-09-24 16:32:48 +02:00
$object -> oldcopy = clone $object ;
2014-09-15 22:58:39 +02:00
2021-02-26 21:17:52 +01:00
if ( GETPOSTISSET ( 'name' )) {
2020-10-31 14:32:18 +01:00
// We overwrite with values if posted
$object -> name = GETPOST ( 'name' , 'alphanohtml' );
2022-01-09 14:19:55 +01:00
$object -> name_alias = GETPOST ( 'name_alias' , 'alphanohtml' );
$object -> prefix_comm = GETPOST ( 'prefix_comm' , 'alphanohtml' );
2020-10-31 14:32:18 +01:00
$object -> client = GETPOST ( 'client' , 'int' );
2022-01-09 14:19:55 +01:00
$object -> code_client = GETPOST ( 'customer_code' , 'alpha' );
$object -> fournisseur = GETPOST ( 'fournisseur' , 'int' );
2020-10-31 14:32:18 +01:00
$object -> code_fournisseur = GETPOST ( 'supplier_code' , 'alpha' );
$object -> address = GETPOST ( 'address' , 'alphanohtml' );
$object -> zip = GETPOST ( 'zipcode' , 'alphanohtml' );
$object -> town = GETPOST ( 'town' , 'alphanohtml' );
$object -> country_id = GETPOST ( 'country_id' ) ? GETPOST ( 'country_id' , 'int' ) : $mysoc -> country_id ;
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2022-12-13 10:57:34 +01:00
$object -> parent = GETPOST ( 'parent_company_id' , 'int' );
2021-10-27 16:39:34 +02:00
2020-10-31 14:32:18 +01:00
$object -> socialnetworks = array ();
2022-08-31 21:49:10 +02:00
if ( isModEnabled ( 'socialnetworks' )) {
2020-10-31 14:32:18 +01:00
foreach ( $socialnetworks as $key => $value ) {
if ( GETPOSTISSET ( $key ) && GETPOST ( $key , 'alphanohtml' ) != '' ) {
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alphanohtml' );
}
}
}
2021-10-27 16:39:34 +02:00
2020-10-31 14:32:18 +01:00
$object -> phone = GETPOST ( 'phone' , 'alpha' );
$object -> fax = GETPOST ( 'fax' , 'alpha' );
$object -> email = GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL );
2022-08-29 14:46:26 +02:00
$object -> no_email = GETPOST ( " no_email " , " int " );
2020-10-31 14:32:18 +01:00
$object -> url = GETPOST ( 'url' , 'custom' , 0 , FILTER_SANITIZE_URL );
$object -> capital = GETPOST ( 'capital' , 'alphanohtml' );
$object -> idprof1 = GETPOST ( 'idprof1' , 'alphanohtml' );
$object -> idprof2 = GETPOST ( 'idprof2' , 'alphanohtml' );
$object -> idprof3 = GETPOST ( 'idprof3' , 'alphanohtml' );
$object -> idprof4 = GETPOST ( 'idprof4' , 'alphanohtml' );
$object -> idprof5 = GETPOST ( 'idprof5' , 'alphanohtml' );
$object -> idprof6 = GETPOST ( 'idprof6' , 'alphanohtml' );
$object -> typent_id = GETPOST ( 'typent_id' , 'int' );
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
$object -> barcode = GETPOST ( 'barcode' , 'alphanohtml' );
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' , 'int' );
$object -> default_lang = GETPOST ( 'default_lang' , 'alpha' );
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'int' );
2023-04-06 08:47:28 +02:00
$object -> vat_reverse_charge = GETPOST ( 'vat_reverse_charge' ) == 'on' ? 1 : 0 ;
2020-10-31 14:32:18 +01:00
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alphanohtml' );
2023-04-06 08:47:28 +02:00
$object -> status = GETPOST ( 'status' , 'int' );
2020-10-31 14:32:18 +01:00
// Webservices url/key
$object -> webservices_url = GETPOST ( 'webservices_url' , 'custom' , 0 , FILTER_SANITIZE_URL );
$object -> webservices_key = GETPOST ( 'webservices_key' , 'san_alpha' );
2014-10-31 17:46:11 +01:00
2021-02-26 21:17:52 +01:00
if ( GETPOSTISSET ( 'accountancy_code_sell' )) {
2021-07-08 21:35:25 +02:00
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
2021-07-08 21:55:35 +02:00
if ( empty ( $accountancy_code_sell ) || $accountancy_code_sell == '-1' ) {
2021-07-08 21:35:25 +02:00
$object -> accountancy_code_sell = '' ;
} else {
$object -> accountancy_code_sell = $accountancy_code_sell ;
}
2021-02-26 21:17:52 +01:00
}
if ( GETPOSTISSET ( 'accountancy_code_buy' )) {
2021-07-08 21:35:25 +02:00
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
2021-07-08 21:55:35 +02:00
if ( empty ( $accountancy_code_buy ) || $accountancy_code_buy == '-1' ) {
2021-07-08 21:35:25 +02:00
$object -> accountancy_code_buy = '' ;
} else {
$object -> accountancy_code_buy = $accountancy_code_buy ;
}
2021-02-26 21:17:52 +01:00
}
2020-12-04 04:13:42 +01:00
2015-02-09 17:55:43 +01:00
//Incoterms
2022-09-25 22:53:21 +02:00
if ( isModEnabled ( 'incoterm' )) {
2019-11-13 18:32:11 +01:00
$object -> fk_incoterms = GETPOST ( 'incoterm_id' , 'int' );
$object -> location_incoterms = GETPOST ( 'lcoation_incoterms' , 'alpha' );
2015-02-09 17:55:43 +01:00
}
2015-03-14 13:05:28 +01:00
2020-10-07 15:01:28 +02:00
//Local Taxes
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' );
2014-07-04 14:25:08 +02:00
2020-10-07 15:01:28 +02:00
$object -> localtax1_value = GETPOST ( 'lt1' );
$object -> localtax2_value = GETPOST ( 'lt2' );
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// We set country_id, and country_code label of the chosen country
2021-02-26 21:17:52 +01:00
if ( $object -> country_id > 0 ) {
2020-10-07 15:01:28 +02:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
}
2022-06-05 14:56:26 +02:00
2022-06-05 14:32:21 +02:00
// We set multicurrency_code if enabled
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2022-06-05 14:32:21 +02:00
$object -> multicurrency_code = GETPOST ( 'multicurrency_code' ) ? GETPOST ( 'multicurrency_code' ) : $object -> multicurrency_code ;
}
2020-10-07 15:01:28 +02:00
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
if ( $object -> localtax1_assuj == 0 ) {
$sub = 0 ;
2021-02-26 21:17:52 +01:00
} else {
$sub = 1 ;
}
2020-10-07 15:01:28 +02:00
if ( $object -> localtax2_assuj == 0 ) {
$sub2 = 0 ;
2021-02-26 21:17:52 +01:00
} else {
$sub2 = 1 ;
}
2014-07-04 14:25:08 +02:00
2021-07-11 01:12:52 +02:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-10-07 15:01:28 +02:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
2014-07-03 18:47:06 +02:00
var val = '.$sub.' ;
var val2 = '.$sub2.' ;
if ( " #localtax1assuj_value " . value == undefined ){
if ( val == 1 ){
$ ( " .cblt1 " ) . show ();
} else {
$ ( " .cblt1 " ) . hide ();
}
}
if ( " #localtax2assuj_value " . value == undefined ){
if ( val2 == 1 ){
$ ( " .cblt2 " ) . show ();
} else {
$ ( " .cblt2 " ) . hide ();
}
}
$ ( " #localtax1assuj_value " ) . change ( function () {
var value = document . getElementById ( " localtax1assuj_value " ) . value ;
if ( value == 1 ){
$ ( " .cblt1 " ) . show ();
} else {
$ ( " .cblt1 " ) . hide ();
}
});
$ ( " #localtax2assuj_value " ) . change ( function () {
var value = document . getElementById ( " localtax2assuj_value " ) . value ;
if ( value == 1 ){
$ ( " .cblt2 " ) . show ();
} else {
$ ( " .cblt2 " ) . hide ();
}
});
2014-07-04 14:25:08 +02:00
2022-04-07 15:01:20 +02:00
var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ? ' 0 ' : ' 1 ') . ' ;
2018-10-12 12:04:04 +02:00
init_customer_categ ();
$ ( " #customerprospect " ) . change ( function () {
init_customer_categ ();
});
function init_customer_categ () {
console . log ( " is customer or prospect = " + jQuery ( " #customerprospect " ) . val ());
2022-04-07 15:01:20 +02:00
if ( jQuery ( " #customerprospect " ) . val () == 0 && ! canHaveCategoryIfNotCustomerProspectSupplier )
2018-10-12 12:04:04 +02:00
{
jQuery ( " .visibleifcustomer " ) . hide ();
}
else
{
jQuery ( " .visibleifcustomer " ) . show ();
}
}
2014-07-04 14:25:08 +02:00
2018-10-12 12:04:04 +02:00
init_supplier_categ ();
$ ( " #fournisseur " ) . change ( function () {
init_supplier_categ ();
});
function init_supplier_categ () {
console . log ( " is supplier = " + jQuery ( " #fournisseur " ) . val ());
if ( jQuery ( " #fournisseur " ) . val () == 0 )
{
jQuery ( " .visibleifsupplier " ) . hide ();
}
else
{
jQuery ( " .visibleifsupplier " ) . show ();
}
2022-12-30 18:43:43 +01:00
}
2014-07-04 14:25:08 +02:00
2018-10-12 12:04:04 +02:00
$ ( " #selectcountry_id " ) . change ( function () {
document . formsoc . action . value = " edit " ;
document . formsoc . submit ();
});
}) ' ;
2020-10-31 14:32:18 +01:00
print '</script>' . " \n " ;
}
2010-09-07 12:24:26 +02:00
2020-10-31 14:32:18 +01:00
print '<form enctype="multipart/form-data" action="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '" method="post" name="formsoc">' ;
print '<input type="hidden" name="action" value="update">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="socid" value="' . $object -> id . '">' ;
print '<input type="hidden" name="entity" value="' . $object -> entity . '">' ;
2021-02-26 21:17:52 +01:00
if ( $modCodeClient -> code_auto || $modCodeFournisseur -> code_auto ) {
print '<input type="hidden" name="code_auto" value="1">' ;
}
2014-09-15 22:58:39 +02:00
2015-06-18 19:33:29 +02:00
2020-10-31 14:32:18 +01:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " ThirdParty " ), 0 , 'company' );
2015-06-18 19:33:29 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="fichecenter2">' ;
print '<table class="border centpercent">' ;
2010-09-07 12:24:26 +02:00
2020-10-31 14:32:18 +01:00
// Ref/ID
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID )) {
2020-10-31 14:32:18 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ID " ) . '</td><td colspan="3">' ;
print $object -> ref ;
print '</td></tr>' ;
2015-10-11 12:27:04 +02:00
}
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
// Name
print '<tr><td class="titlefieldcreate">' . $form -> editfieldkey ( 'ThirdPartyName' , 'name' , '' , $object , 0 , 'string' , '' , 1 ) . '</td>' ;
print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="' . dol_escape_htmltag ( $object -> name ) . '" autofocus="autofocus">' ;
print $form -> widgetForTranslation ( " name " , $object , $permissiontoadd , 'string' , 'alpahnohtml' , 'minwidth300' );
print '</td></tr>' ;
2010-09-07 12:24:26 +02:00
2020-10-31 14:32:18 +01:00
// Alias names (commercial, trademark or alias names)
print '<tr id="name_alias"><td><label for="name_alias_input">' . $langs -> trans ( 'AliasNames' ) . '</label></td>' ;
print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="' . dol_escape_htmltag ( $object -> name_alias ) . '"></td></tr>' ;
2015-02-27 15:08:08 +01:00
2020-10-31 14:32:18 +01:00
// Prefix
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) { // Old not used prefix field
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Prefix' , 'prefix' , '' , $object , 0 ) . '</td><td colspan="3">' ;
// It does not change the prefix mode using the auto numbering prefix
2021-02-26 21:17:52 +01:00
if (( $prefixCustomerIsUsed || $prefixSupplierIsUsed ) && $object -> prefix_comm ) {
2020-10-31 14:32:18 +01:00
print '<input type="hidden" name="prefix_comm" value="' . dol_escape_htmltag ( $object -> prefix_comm ) . '">' ;
print $object -> prefix_comm ;
} else {
print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="' . dol_escape_htmltag ( $object -> prefix_comm ) . '">' ;
}
print '</td>' ;
}
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Prospect/Customer
print '<tr><td>' . $form -> editfieldkey ( 'ProspectCustomer' , 'customerprospect' , '' , $object , 0 , 'string' , '' , 1 ) . '</td>' ;
print '<td class="maxwidthonsmartphone">' ;
print $formcompany -> selectProspectCustomerType ( $object -> client );
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 14:32:18 +01:00
print '<td>' . $form -> editfieldkey ( 'CustomerCode' , 'customer_code' , '' , $object , 0 ) . '</td><td>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
print '<table class="nobordernopadding"><tr><td>' ;
2021-02-26 21:17:52 +01:00
if (( ! $object -> code_client || $object -> code_client == - 1 ) && $modCodeClient -> code_auto ) {
2020-10-31 14:32:18 +01:00
$tmpcode = $object -> code_client ;
2021-02-26 21:17:52 +01:00
if ( empty ( $tmpcode ) && ! empty ( $object -> oldcopy -> code_client )) {
$tmpcode = $object -> oldcopy -> code_client ; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
}
if ( empty ( $tmpcode ) && ! empty ( $modCodeClient -> code_auto )) {
$tmpcode = $modCodeClient -> getNextValue ( $object , 0 );
}
2021-02-28 23:43:07 +01:00
print '<input type="text" name="customer_code" id="customer_code" size="16" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="24">' ;
2021-02-26 21:17:52 +01:00
} elseif ( $object -> codeclient_modifiable ()) {
2021-02-28 23:43:07 +01:00
print '<input type="text" name="customer_code" id="customer_code" size="16" value="' . dol_escape_htmltag ( $object -> code_client ) . '" maxlength="24">' ;
2020-10-31 14:32:18 +01:00
} else {
print $object -> code_client ;
print '<input type="hidden" name="customer_code" value="' . dol_escape_htmltag ( $object -> code_client ) . '">' ;
}
print '</td><td>' ;
$s = $modCodeClient -> getToolTip ( $langs , $object , 0 );
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Supplier
2022-08-23 20:05:09 +02:00
if ((( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire )))
2022-08-31 22:02:31 +02:00
|| ( isModEnabled ( 'supplier_proposal' ) && ! empty ( $user -> rights -> supplier_proposal -> lire ))) {
2020-10-31 14:32:18 +01:00
print '<tr>' ;
print '<td>' . $form -> editfieldkey ( 'Supplier' , 'fournisseur' , '' , $object , 0 , 'string' , '' , 1 ) . '</td>' ;
print '<td class="maxwidthonsmartphone">' ;
2020-12-11 00:55:21 +01:00
print $form -> selectyesno ( " fournisseur " , $object -> fournisseur , 1 , false , 0 , 1 );
2020-10-31 14:32:18 +01:00
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 14:32:18 +01:00
print '<td>' ;
2022-08-23 20:05:09 +02:00
if (( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))) {
2020-10-31 14:32:18 +01:00
print $form -> editfieldkey ( 'SupplierCode' , 'supplier_code' , '' , $object , 0 );
}
print '</td>' ;
print '<td>' ;
print '<table class="nobordernopadding"><tr><td>' ;
2021-02-26 21:17:52 +01:00
if (( ! $object -> code_fournisseur || $object -> code_fournisseur == - 1 ) && $modCodeFournisseur -> code_auto ) {
2020-10-31 14:32:18 +01:00
$tmpcode = $object -> code_fournisseur ;
2021-02-26 21:17:52 +01:00
if ( empty ( $tmpcode ) && ! empty ( $object -> oldcopy -> code_fournisseur )) {
$tmpcode = $object -> oldcopy -> code_fournisseur ; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
}
if ( empty ( $tmpcode ) && ! empty ( $modCodeFournisseur -> code_auto )) {
$tmpcode = $modCodeFournisseur -> getNextValue ( $object , 1 );
}
2021-02-28 23:43:07 +01:00
print '<input type="text" name="supplier_code" id="supplier_code" size="16" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="24">' ;
2021-02-26 21:17:52 +01:00
} elseif ( $object -> codefournisseur_modifiable ()) {
2021-02-28 23:43:07 +01:00
print '<input type="text" name="supplier_code" id="supplier_code" size="16" value="' . dol_escape_htmltag ( $object -> code_fournisseur ) . '" maxlength="24">' ;
2020-10-31 14:32:18 +01:00
} else {
print $object -> code_fournisseur ;
print '<input type="hidden" name="supplier_code" value="' . $object -> code_fournisseur . '">' ;
}
print '</td><td>' ;
$s = $modCodeFournisseur -> getToolTip ( $langs , $object , 1 );
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
print '</td></tr>' ;
}
2010-09-07 12:24:26 +02:00
2020-10-31 14:32:18 +01:00
// Barcode
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2020-10-31 14:32:18 +01:00
print '<tr><td class="tdtop">' . $form -> editfieldkey ( 'Gencod' , 'barcode' , '' , $object , 0 ) . '</td>' ;
2021-02-27 02:49:24 +01:00
print '<td colspan="3">' ;
print img_picto ( '' , 'barcode' );
print '<input type="text" name="barcode" id="barcode" value="' . dol_escape_htmltag ( $object -> barcode ) . '">' ;
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
}
2010-09-07 12:24:26 +02:00
2020-10-31 14:32:18 +01:00
// Status
print '<tr><td>' . $form -> editfieldkey ( 'Status' , 'status' , '' , $object , 0 ) . '</td><td colspan="3">' ;
2020-12-11 00:55:21 +01:00
print $form -> selectarray ( 'status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), $object -> status , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth100' , 1 );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2011-12-07 15:06:29 +01:00
2020-10-31 14:32:18 +01:00
// Address
print '<tr><td class="tdtop">' . $form -> editfieldkey ( 'Address' , 'address' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
2020-11-04 18:54:56 +01:00
print dol_escape_htmltag ( $object -> address , 0 , 1 );
2020-10-31 14:32:18 +01:00
print '</textarea>' ;
print $form -> widgetForTranslation ( " address " , $object , $permissiontoadd , 'textarea' , 'alphanohtml' , 'quatrevingtpercent' );
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Zip / Town
2022-12-28 01:54:54 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Zip' , 'zipcode' , '' , $object , 0 ) . '</td><td' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' ;
2021-01-13 12:45:23 +01:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 0 , 0 , '' , 'maxwidth100' );
2020-10-31 14:32:18 +01:00
print '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2022-12-28 01:54:54 +01:00
print '<td>' . $form -> editfieldkey ( 'Town' , 'town' , '' , $object , 0 ) . '</td><td' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' ;
2020-10-31 14:32:18 +01:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
print $form -> widgetForTranslation ( " town " , $object , $permissiontoadd , 'string' , 'alphanohtml' , 'maxwidth100 quatrevingtpercent' );
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Country
print '<tr><td>' . $form -> editfieldkey ( 'Country' , 'selectcounty_id' , '' , $object , 0 ) . '</td><td colspan="3">' ;
print img_picto ( '' , 'globe-americas' , 'class="paddingrightonly"' );
2021-02-10 01:10:31 +01:00
print $form -> select_country (( GETPOSTISSET ( 'country_id' ) ? GETPOST ( 'country_id' ) : $object -> country_id ), 'country_id' , '' , 0 , 'minwidth300 maxwidth500 widthcentpercentminusx' );
2021-02-26 21:17:52 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// State
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE )) {
if ( ! empty ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT ) && ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 2 )) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Region-State' , 'state_id' , '' , $object , 0 ) . '</td><td colspan="3">' ;
} else {
print '<tr><td>' . $form -> editfieldkey ( 'State' , 'state_id' , '' , $object , 0 ) . '</td><td colspan="3">' ;
}
2018-01-25 19:30:20 +01:00
2021-07-04 19:23:04 +02:00
print img_picto ( '' , 'state' , 'class="pictofixedwidth"' );
2020-10-31 14:32:18 +01:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code );
print '</td></tr>' ;
}
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Phone / Fax
print '<tr><td>' . $form -> editfieldkey ( 'Phone' , 'phone' , GETPOST ( 'phone' , 'alpha' ), $object , 0 ) . '</td>' ;
2022-12-28 01:54:54 +01:00
print '<td' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' . img_picto ( '' , 'object_phoning' , 'class="pictofixedwidth"' ) . ' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="' . ( GETPOSTISSET ( 'phone' ) ? GETPOST ( 'phone' , 'alpha' ) : $object -> phone ) . '"></td>' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2020-10-31 14:32:18 +01:00
print '<td>' . $form -> editfieldkey ( 'Fax' , 'fax' , GETPOST ( 'fax' , 'alpha' ), $object , 0 ) . '</td>' ;
2022-12-28 01:54:54 +01:00
print '<td' . ( $conf -> browser -> layout == 'phone' ? ' colspan="3"' : '' ) . '>' . img_picto ( '' , 'object_phoning_fax' , 'class="pictofixedwidth"' ) . ' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="' . ( GETPOSTISSET ( 'fax' ) ? GETPOST ( 'fax' , 'alpha' ) : $object -> fax ) . '"></td>' ;
print '</tr>' ;
2013-11-23 15:22:27 +01:00
2022-12-28 01:54:54 +01:00
// Web
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Web' , 'url' , GETPOST ( 'url' , 'alpha' ), $object , 0 ) . '</td>' ;
2022-12-28 01:54:54 +01:00
print '<td colspan="3">' . img_picto ( '' , 'globe' , 'class="pictofixedwidth"' ) . ' <input type="text" name="url" id="url" class="maxwidth200onsmartphone maxwidth300 widthcentpercentminusx " value="' . ( GETPOSTISSET ( 'url' ) ? GETPOST ( 'url' , 'alpha' ) : $object -> url ) . '"></td></tr>' ;
2022-08-29 14:46:26 +02:00
// EMail
print '<tr><td>' . $form -> editfieldkey ( 'EMail' , 'email' , GETPOST ( 'email' , 'alpha' ), $object , 0 , 'string' , '' , ( ! empty ( $conf -> global -> SOCIETE_EMAIL_MANDATORY ))) . '</td>' ;
2022-12-28 01:54:54 +01:00
print '<td colspan="3">' ;
print img_picto ( '' , 'object_email' , 'class="pictofixedwidth"' );
print '<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="' . ( GETPOSTISSET ( 'email' ) ? GETPOST ( 'email' , 'alpha' ) : $object -> email ) . '">' ;
print '</td></tr>' ;
2022-08-29 14:46:26 +02:00
// Unsubscribe
2023-02-21 13:19:57 +01:00
if ( isModEnabled ( 'mailing' )) {
2022-08-29 14:46:26 +02:00
if ( $conf -> use_javascript_ajax && isset ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS ) && $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 ) {
print " \n " . '<script type="text/javascript">' . " \n " ;
print '
jQuery ( document ) . ready ( function () {
function init_check_no_email ( input ) {
if ( input . val () != " " ) {
$ ( " .noemail " ) . addClass ( " fieldrequired " );
} else {
$ ( " .noemail " ) . removeClass ( " fieldrequired " );
}
}
$ ( " #email " ) . keyup ( function () {
init_check_no_email ( $ ( this ));
});
init_check_no_email ( $ ( " #email " ));
}) ' . " \n " ;
print '</script>' . " \n " ;
}
if ( ! GETPOSTISSET ( " no_email " ) && ! empty ( $object -> email )) {
$result = $object -> getNoEmail ();
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
print '<tr>' ;
print '<td class="noemail"><label for="no_email">' . $langs -> trans ( " No_Email " ) . '</label></td>' ;
print '<td>' ;
$useempty = ( isset ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS ) && ( $conf -> global -> MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 ));
print $form -> selectyesno ( 'no_email' , ( GETPOSTISSET ( " no_email " ) ? GETPOST ( " no_email " , 'int' ) : $object -> no_email ), 1 , false , $useempty );
print '</td>' ;
print '</tr>' ;
}
2014-07-12 12:04:39 +02:00
2022-06-15 14:19:26 +02:00
// Social network
2022-08-31 21:49:10 +02:00
if ( isModEnabled ( 'socialnetworks' )) {
2023-01-20 13:36:23 +01:00
$object -> showSocialNetwork ( $socialnetworks , ( $conf -> browser -> layout == 'phone' ? 2 : 4 ));
2020-10-31 14:32:18 +01:00
}
2013-01-26 10:35:30 +01:00
2020-10-31 14:32:18 +01:00
// Prof ids
2021-03-18 22:26:14 +01:00
$i = 1 ;
$j = 0 ;
$NBCOLS = ( $conf -> browser -> layout == 'phone' ? 1 : 2 );
2021-02-26 21:17:52 +01:00
while ( $i <= 6 ) {
2020-10-31 14:32:18 +01:00
$idprof = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code );
2021-02-26 21:17:52 +01:00
if ( $idprof != '-' ) {
2020-10-31 14:32:18 +01:00
$key = 'idprof' . $i ;
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if (( $j % $NBCOLS ) == 0 ) {
print '<tr>' ;
}
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
$idprof_mandatory = 'SOCIETE_IDPROF' . ( $i ) . '_MANDATORY' ;
print '<td>' . $form -> editfieldkey ( $idprof , $key , '' , $object , 0 , 'string' , '' , ! ( empty ( $conf -> global -> $idprof_mandatory ) || ! $object -> isACompany ())) . '</td><td>' ;
print $formcompany -> get_input_id_prof ( $i , $key , $object -> $key , $object -> country_code );
print '</td>' ;
2021-02-26 21:17:52 +01:00
if (( $j % $NBCOLS ) == ( $NBCOLS - 1 )) {
print '</tr>' ;
}
2020-10-31 14:32:18 +01:00
$j ++ ;
}
$i ++ ;
}
2021-02-26 21:17:52 +01:00
if ( $NBCOLS > 0 && $j % 2 == 1 ) {
print '<td colspan="2"></td></tr>' ;
}
2017-06-07 16:44:04 +02:00
2020-10-31 14:32:18 +01:00
// VAT is used
print '<tr><td>' . $form -> editfieldkey ( 'VATIsUsed' , 'assujtva_value' , '' , $object , 0 ) . '</td><td colspan="3">' ;
print $form -> selectyesno ( 'assujtva_value' , $object -> tva_assuj , 1 );
print '</td></tr>' ;
2016-10-24 12:42:37 +02:00
2020-10-31 14:32:18 +01:00
// Local Taxes
//TODO: Place into a function to control showing by country or study better option
2021-02-26 21:17:52 +01:00
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ), 'localtax1assuj_value' , '' , $object , 0 ) . '</td><td>' ;
print $form -> selectyesno ( 'localtax1assuj_value' , $object -> localtax1_assuj , 1 );
2021-02-26 21:17:52 +01:00
if ( ! isOnlyOneLocalTax ( 1 )) {
2020-10-31 14:32:18 +01:00
print '<span class="cblt1"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '</span>' ;
}
print '</td>' ;
print '</tr><tr>' ;
print '<td>' . $form -> editfieldkey ( $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ), 'localtax2assuj_value' , '' , $object , 0 ) . '</td><td>' ;
print $form -> selectyesno ( 'localtax2assuj_value' , $object -> localtax2_assuj , 1 );
2021-02-26 21:17:52 +01:00
if ( ! isOnlyOneLocalTax ( 2 )) {
2020-10-31 14:32:18 +01:00
print '<span class="cblt2"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '</span>' ;
}
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
} elseif ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj != " 1 " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ), 'localtax1assuj_value' , '' , $object , 0 ) . '</td><td colspan="3">' ;
print $form -> selectyesno ( 'localtax1assuj_value' , $object -> localtax1_assuj , 1 );
2021-02-26 21:17:52 +01:00
if ( ! isOnlyOneLocalTax ( 1 )) {
2020-10-31 14:32:18 +01:00
print '<span class="cblt1"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '</span>' ;
}
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
} elseif ( $mysoc -> localtax2_assuj == " 1 " && $mysoc -> localtax1_assuj != " 1 " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ), 'localtax2assuj_value' , '' , $object , 0 ) . '</td><td colspan="3">' ;
print $form -> selectyesno ( 'localtax2assuj_value' , $object -> localtax2_assuj , 1 );
2021-02-26 21:17:52 +01:00
if ( ! isOnlyOneLocalTax ( 2 )) {
2020-10-31 14:32:18 +01:00
print '<span class="cblt2"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '</span>' ;
}
print '</td></tr>' ;
}
2013-01-26 10:35:30 +01:00
2023-04-06 08:47:28 +02:00
// VAT reverse charge by default
if ( ! empty ( $conf -> global -> ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE )) {
print '<tr><td>' . $form -> editfieldkey ( 'VATReverseChargeByDefault' , 'vat_reverse_charge' , '' , $object , 0 ) . '</td><td colspan="3">' ;
print '<input type="checkbox" name="vat_reverse_charge" ' . ( $object -> vat_reverse_charge == '1' ? ' checked' : '' ) . '>' ;
print '</td></tr>' ;
}
2020-10-31 14:32:18 +01:00
// VAT Code
print '<tr><td>' . $form -> editfieldkey ( 'VATIntra' , 'intra_vat' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3">' ;
$s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="' . $object -> tva_intra . '">' ;
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ) && isInEEC ( $object )) {
2020-10-31 14:32:18 +01:00
$s .= ' ' ;
2011-06-11 22:58:08 +02:00
2021-02-26 21:17:52 +01:00
if ( $conf -> use_javascript_ajax ) {
2020-10-31 14:32:18 +01:00
$widthpopup = 600 ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> dol_use_jmobile )) {
$widthpopup = 350 ;
}
2020-10-31 14:32:18 +01:00
$heightpopup = 400 ;
print " \n " ;
2021-11-29 15:09:18 +01:00
print '<script type="text/javascript">' ;
2020-10-31 14:32:18 +01:00
print " function CheckVAT(a) { \n " ;
print " newpopup(' " . DOL_URL_ROOT . " /societe/checkvat/checkVatPopup.php?vatNumber='+a,' " . dol_escape_js ( $langs -> trans ( " VATIntraCheckableOnEUSite " )) . " ', " . $widthpopup . " , " . $heightpopup . " ); \n " ;
print " } \n " ;
print '</script>' ;
print " \n " ;
2023-05-01 14:33:08 +02:00
$s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
2020-10-31 14:32:18 +01:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> transnoentitiesnoconv ( " VATIntraCheck " )), 1 );
} else {
2021-11-22 02:35:55 +01:00
$s .= '<a href="' . $langs -> transcountry ( " VATIntraCheckURL " , $object -> country_id ) . '" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">' . img_picto ( $langs -> trans ( " VATIntraCheckableOnEUSite " ), 'help' ) . '</a>' ;
2020-10-31 14:32:18 +01:00
}
}
print $s ;
print '</td>' ;
print '</tr>' ;
2018-03-22 16:05:50 +01:00
2020-10-31 14:32:18 +01:00
// Type - Workforce/Staff
2021-04-16 15:26:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'ThirdPartyType' , 'typent_id' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone"' . ( ( $conf -> browser -> layout == 'phone' || ! empty ( $conf -> global -> SOCIETE_DISABLE_WORKFORCE )) ? ' colspan="3"' : '' ) . '>' ;
2021-02-04 08:35:17 +01:00
print $form -> selectarray ( " typent_id " , $formcompany -> typent_array ( 0 ), $object -> typent_id , 1 , 0 , 0 , '' , 0 , 0 , 0 , ( empty ( $conf -> global -> SOCIETE_SORT_ON_TYPEENT ) ? 'ASC' : $conf -> global -> SOCIETE_SORT_ON_TYPEENT ), '' , 1 );
2021-02-26 21:17:52 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2021-04-21 17:04:44 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_WORKFORCE )) {
2021-04-16 15:26:29 +02:00
print '</td>' ;
2021-04-21 17:02:37 +02:00
if ( $conf -> browser -> layout == 'phone' ) {
print '</tr><tr>' ;
}
2021-04-16 15:26:29 +02:00
print '<td>' . $form -> editfieldkey ( 'Workforce' , 'effectif_id' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone">' ;
print $form -> selectarray ( " effectif_id " , $formcompany -> effectif_array ( 0 ), $object -> effectif_id , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , '' , 1 );
2021-04-21 17:02:37 +02:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2021-04-21 17:04:44 +02:00
} else {
2021-04-16 15:26:29 +02:00
print '<input type="hidden" name="effectif_id" id="effectif_id" value="' . $object -> effectif_id . '">' ;
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2013-04-03 15:20:56 +02:00
2020-10-31 14:32:18 +01:00
// Juridical type
print '<tr><td>' . $form -> editfieldkey ( 'JuridicalStatus' , 'forme_juridique_code' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone" colspan="3">' ;
print $formcompany -> select_juridicalstatus ( $object -> forme_juridique_code , $object -> country_code , '' , 'forme_juridique_code' );
print '</td></tr>' ;
// Capital
print '<tr><td>' . $form -> editfieldkey ( 'Capital' , 'capital' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="' ;
print $object -> capital != '' ? dol_escape_htmltag ( price ( $object -> capital )) : '' ;
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2022-06-05 14:32:21 +02:00
print '"> <span class="hideonsmartphone">' . $langs -> trans ( " Currency " . $object -> multicurrency_code ) . '</span></td></tr>' ;
} else {
print '"> <span class="hideonsmartphone">' . $langs -> trans ( " Currency " . $conf -> currency ) . '</span></td></tr>' ;
}
2020-10-31 14:32:18 +01:00
// Default language
2022-09-24 14:55:10 +02:00
if ( getDolGlobalInt ( 'MAIN_MULTILANGS' )) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'DefaultLang' , 'default_lang' , '' , $object , 0 ) . '</td><td colspan="3">' . " \n " ;
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'language' , 'class="pictofixedwidth"' ) . $formadmin -> select_language ( $object -> default_lang , 'default_lang' , 0 , null , '1' , 0 , 0 , 'maxwidth300 widthcentpercentminusx' );
2020-10-31 14:32:18 +01:00
print '</td>' ;
print '</tr>' ;
}
// Incoterms
2022-09-25 22:53:21 +02:00
if ( isModEnabled ( 'incoterm' )) {
2020-10-31 14:32:18 +01:00
print '<tr>' ;
2021-02-26 21:17:52 +01:00
print '<td>' . $form -> editfieldkey ( 'IncotermLabel' , 'incoterm_id' , '' , $object , 0 ) . '</td>' ;
2020-10-31 14:32:18 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
print $form -> select_incoterms (( ! empty ( $object -> fk_incoterms ) ? $object -> fk_incoterms : '' ), ( ! empty ( $object -> location_incoterms ) ? $object -> location_incoterms : '' ));
print '</td></tr>' ;
}
2018-11-27 09:22:59 +01:00
2015-05-29 18:49:10 +02:00
// Categories
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'categorie' ) && ! empty ( $user -> rights -> categorie -> lire )) {
2015-08-26 19:30:40 +02:00
// Customer
2019-11-13 18:32:11 +01:00
print '<tr class="visibleifcustomer"><td>' . $form -> editfieldkey ( 'CustomersCategoriesShort' , 'custcats' , '' , $object , 0 ) . '</td>' ;
2018-10-12 12:04:04 +02:00
print '<td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_CUSTOMER , null , null , null , null , 1 );
$c = new Categorie ( $db );
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_CUSTOMER );
2019-11-13 18:32:11 +01:00
$arrayselected = array ();
2018-10-12 12:04:04 +02:00
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
2015-06-05 09:57:41 +02:00
}
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'custcats' , $cate_arbo , $arrayselected , 0 , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2018-10-12 12:04:04 +02:00
print " </td></tr> " ;
2015-08-26 19:30:40 +02:00
// Supplier
2022-08-23 20:05:09 +02:00
if (( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))) {
2021-01-06 09:54:02 +01:00
print '<tr class="visibleifsupplier"><td>' . $form -> editfieldkey ( 'SuppliersCategoriesShort' , 'suppcats' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_SUPPLIER , null , null , null , null , 1 );
$c = new Categorie ( $db );
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_SUPPLIER );
$arrayselected = array ();
2021-01-07 10:20:41 +01:00
foreach ( $cats as $cat ) {
2021-01-06 09:54:02 +01:00
$arrayselected [] = $cat -> id ;
}
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'suppcats' , $cate_arbo , $arrayselected , 0 , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2021-01-06 09:54:02 +01:00
print " </td></tr> " ;
2015-08-26 19:30:40 +02:00
}
}
2015-06-05 14:02:50 +02:00
2016-01-18 19:45:27 +01:00
// Multicurrency
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2016-01-18 19:45:27 +01:00
print '<tr>' ;
2018-10-27 14:50:27 +02:00
print '<td>' . $form -> editfieldkey ( 'Currency' , 'multicurrency_code' , '' , $object , 0 ) . '</td>' ;
2020-10-07 15:01:28 +02:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'currency' , 'class="pictofixedwidth"' );
print $form -> selectMultiCurrency (( GETPOSTISSET ( 'multicurrency_code' ) ? GETPOST ( 'multicurrency_code' ) : ( $object -> multicurrency_code ? $object -> multicurrency_code : $conf -> currency )), 'multicurrency_code' , 1 , '' , false , 'maxwidth150 widthcentpercentminusx' );
2016-01-18 19:45:27 +01:00
print '</td></tr>' ;
}
2020-03-10 21:54:50 +01:00
// Other attributes
$parameters = array ( 'socid' => $socid , 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' );
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php' ;
2013-04-03 15:20:56 +02:00
2022-12-13 10:57:34 +01:00
// Parent company
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PARENTCOMPANY )) {
print '<tr>' ;
print '<td>' . $langs -> trans ( 'ParentCompany' ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'company' , 'class="pictofixedwidth"' );
2022-12-13 10:57:34 +01:00
print $form -> select_company ( GETPOST ( 'parent_company_id' ) ? GETPOST ( 'parent_company_id' ) : $object -> parent , 'parent_company_id' , '' , 'SelectThirdParty' , 0 , 0 , null , 0 , 'minwidth300 maxwidth500 widthcentpercentminusxx' );
print '</td></tr>' ;
}
2020-10-31 14:32:18 +01:00
// Webservices url/key
if ( ! empty ( $conf -> syncsupplierwebservices -> enabled )) {
print '<tr><td>' . $form -> editfieldkey ( 'WebServiceURL' , 'webservices_url' , '' , $object , 0 ) . '</td>' ;
print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="' . $object -> webservices_url . '"></td>' ;
print '<td>' . $form -> editfieldkey ( 'WebServiceKey' , 'webservices_key' , '' , $object , 0 ) . '</td>' ;
print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="' . $object -> webservices_key . '"></td></tr>' ;
}
2014-10-31 17:46:11 +01:00
2020-10-31 14:32:18 +01:00
// Logo
print '<tr class="hideonsmartphone">' ;
print '<td>' . $form -> editfieldkey ( 'Logo' , 'photoinput' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3">' ;
2021-02-26 21:17:52 +01:00
if ( $object -> logo ) {
print $form -> showphoto ( 'societe' , $object );
}
2020-10-31 14:32:18 +01:00
$caneditfield = 1 ;
2021-02-26 21:17:52 +01:00
if ( $caneditfield ) {
if ( $object -> logo ) {
print " <br> \n " ;
}
2020-10-31 14:32:18 +01:00
print '<table class="nobordernopadding">' ;
2021-02-26 21:17:52 +01:00
if ( $object -> logo ) {
2023-03-29 17:06:19 +02:00
print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">' . $langs -> trans ( " Delete " ) . '</photo><br><br></td></tr>' ;
2021-02-26 21:17:52 +01:00
}
2020-10-31 14:32:18 +01:00
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
2022-06-19 19:02:16 +02:00
print '<tr><td>' ;
$maxfilesizearray = getMaxFileSizeArray ();
$maxmin = $maxfilesizearray [ 'maxmin' ];
if ( $maxmin > 0 ) {
2022-07-25 18:37:55 +02:00
print '<input type="hidden" name="MAX_FILE_SIZE" value="' . ( $maxmin * 1024 ) . '">' ; // MAX_FILE_SIZE must precede the field type=file
2022-06-19 19:02:16 +02:00
}
print '<input type="file" class="flat" name="photo" id="photoinput">' ;
print '</td></tr>' ;
2020-10-31 14:32:18 +01:00
print '</table>' ;
}
print '</td>' ;
print '</tr>' ;
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Assign sale representative
print '<tr>' ;
print '<td>' . $form -> editfieldkey ( 'AllocateCommercial' , 'commercial_id' , '' , $object , 0 ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2020-11-10 11:10:35 +01:00
$userlist = $form -> select_dolusers ( '' , '' , 0 , null , 0 , '' , '' , 0 , 0 , 0 , 'AND u.statut = 1' , 0 , '' , '' , 0 , 1 );
2020-10-31 14:32:18 +01:00
$arrayselected = GETPOST ( 'commercial' , 'array' );
2021-02-26 21:17:52 +01:00
if ( empty ( $arrayselected )) {
$arrayselected = $object -> getSalesRepresentatives ( $user , 1 );
}
2022-12-28 01:54:54 +01:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'commercial' , $userlist , $arrayselected , 0 , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 , '' , '' , '' , 1 );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2018-11-27 09:22:59 +01:00
2020-10-31 14:32:18 +01:00
print '</table>' ;
2020-12-04 04:13:42 +01:00
2021-01-15 17:35:16 +01:00
if ( ! empty ( $conf -> global -> ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY )) {
print '<br>' ;
print '<table class="border centpercent">' ;
2020-12-04 04:13:42 +01:00
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2021-01-15 17:35:16 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td>' ;
print $formaccounting -> select_account ( $object -> accountancy_code_sell , 'accountancy_code_sell' , 1 , '' , 1 , 1 );
print '</td></tr>' ;
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td>' ;
print $formaccounting -> select_account ( $object -> accountancy_code_buy , 'accountancy_code_buy' , 1 , '' , 1 , 1 );
print '</td></tr>' ;
2021-06-29 19:24:46 +02:00
} else { // For external software
2021-01-15 17:35:16 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td><input name="accountancy_code_sell" class="maxwidth200" value="' . $object -> accountancy_code_sell . '">' ;
print '</td></tr>' ;
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td><input name="accountancy_code_buy" class="maxwidth200" value="' . $object -> accountancy_code_buy . '">' ;
print '</td></tr>' ;
}
print '</table>' ;
2020-12-04 04:13:42 +01:00
}
2020-10-31 14:32:18 +01:00
print '</div>' ;
2017-06-07 16:44:04 +02:00
2020-12-04 04:13:42 +01:00
print dol_get_fiche_end ();
2011-06-11 16:14:27 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
print '</form>' ;
}
} else {
/*
2021-02-26 21:17:52 +01:00
* View
*/
2017-06-07 16:44:04 +02:00
2021-02-26 21:17:52 +01:00
if ( ! empty ( $object -> id )) {
$res = $object -> fetch_optionals ();
}
2020-10-31 14:32:18 +01:00
//if ($res < 0) { dol_print_error($db); exit; }
2011-06-22 12:58:22 +02:00
2010-09-07 12:24:26 +02:00
2020-10-31 14:32:18 +01:00
$head = societe_prepare_head ( $object );
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " ThirdParty " ), - 1 , 'company' );
2011-06-11 16:14:27 +02:00
2020-12-22 16:07:07 +01:00
$formconfirm = '' ;
2020-10-31 14:32:18 +01:00
// Confirm delete third party
2021-02-26 21:17:52 +01:00
if ( $action == 'delete' || ( $conf -> use_javascript_ajax && empty ( $conf -> dol_use_jmobile ))) {
2020-12-22 16:07:07 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id , $langs -> trans ( " DeleteACompany " ), $langs -> trans ( " ConfirmDeleteCompany " ), " confirm_delete " , '' , 0 , " action-delete " );
2020-10-31 14:32:18 +01:00
}
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( $action == 'merge' ) {
2020-10-31 14:32:18 +01:00
$formquestion = array (
array (
'name' => 'soc_origin' ,
'label' => $langs -> trans ( 'MergeOriginThirdparty' ),
'type' => 'other' ,
2021-03-22 22:50:43 +01:00
'value' => $form -> select_company ( '' , 'soc_origin' , '' , 'SelectThirdParty' , 0 , 0 , array (), 0 , 'minwidth200' , '' , '' , 1 , null , false , array ( $object -> id ))
2020-10-31 14:32:18 +01:00
)
);
2020-12-22 16:07:07 +01:00
$formconfirm .= $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id , $langs -> trans ( " MergeThirdparties " ), $langs -> trans ( " ConfirmMergeThirdparties " ), " confirm_merge " , $formquestion , 'no' , 1 , 250 );
2020-10-31 14:32:18 +01:00
}
2015-05-10 12:43:21 +02:00
2020-12-22 16:07:07 +01:00
// Call Hook formConfirm
$parameters = array ( 'formConfirm' => $formconfirm );
$reshook = $hookmanager -> executeHooks ( 'formConfirm' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 21:17:52 +01:00
if ( empty ( $reshook )) {
$formconfirm .= $hookmanager -> resPrint ;
} elseif ( $reshook > 0 ) {
$formconfirm = $hookmanager -> resPrint ;
2020-10-31 14:32:18 +01:00
}
2015-05-10 12:43:21 +02:00
2020-12-22 16:07:07 +01:00
// Print form confirm
print $formconfirm ;
2020-10-31 14:32:18 +01:00
dol_htmloutput_mesg ( is_numeric ( $error ) ? '' : $error , $errors , 'error' );
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
dol_banner_tab ( $object , 'socid' , $linkback , ( $user -> socid ? 0 : 1 ), 'rowid' , 'nom' );
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="underbanner clearboth"></div>' ;
2021-10-29 11:35:09 +02:00
print '<table class="border tableforfield centpercent">' ;
2011-06-11 16:14:27 +02:00
2021-02-05 17:29:11 +01:00
// Type Prospect/Customer/Supplier
print '<tr><td class="titlefield">' . $langs -> trans ( 'NatureOfThirdParty' ) . '</td><td>' ;
print $object -> getTypeUrl ( 1 );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
// Prefix
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) { // Old not used prefix field
2021-01-28 12:44:45 +01:00
print '<tr><td>' . $langs -> trans ( 'Prefix' ) . '</td><td>' . dol_escape_htmltag ( $object -> prefix_comm ) . '</td>' ;
2020-10-31 14:32:18 +01:00
print '</tr>' ;
}
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Customer code
2021-02-26 21:17:52 +01:00
if ( $object -> client ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' ;
2021-01-21 17:15:32 +01:00
print $langs -> trans ( 'CustomerCode' );
print '</td>' ;
print '<td>' ;
2021-01-28 12:44:45 +01:00
print showValueWithClipboardCPButton ( dol_escape_htmltag ( $object -> code_client ));
2020-12-20 14:31:54 +01:00
$tmpcheck = $object -> check_codeclient ();
if ( $tmpcheck != 0 && $tmpcheck != - 5 ) {
2021-10-05 10:20:35 +02:00
print ' <span class="error">(' . $langs -> trans ( " WrongCustomerCode " ) . ')</span>' ;
2020-12-20 14:31:54 +01:00
}
2020-10-31 14:32:18 +01:00
print '</td>' ;
print '</tr>' ;
}
2011-06-11 16:14:27 +02:00
2020-10-31 14:32:18 +01:00
// Supplier code
2022-08-23 20:05:09 +02:00
if ((( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))) && $object -> fournisseur ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' ;
print $langs -> trans ( 'SupplierCode' ) . '</td><td>' ;
2021-01-28 12:44:45 +01:00
print showValueWithClipboardCPButton ( dol_escape_htmltag ( $object -> code_fournisseur ));
2020-12-20 14:31:54 +01:00
$tmpcheck = $object -> check_codefournisseur ();
if ( $tmpcheck != 0 && $tmpcheck != - 5 ) {
2021-10-05 10:20:35 +02:00
print ' <span class="error">(' . $langs -> trans ( " WrongSupplierCode " ) . ')</span>' ;
2018-03-15 14:25:09 +01:00
}
2020-10-31 14:32:18 +01:00
print '</td>' ;
print '</tr>' ;
}
2011-12-07 15:06:29 +01:00
2020-10-31 14:32:18 +01:00
// Barcode
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' ;
2021-01-28 12:44:45 +01:00
print $langs -> trans ( 'Gencod' ) . '</td><td>' . showValueWithClipboardCPButton ( dol_escape_htmltag ( $object -> barcode ));
2020-10-31 14:32:18 +01:00
print '</td>' ;
print '</tr>' ;
}
// Prof ids
$i = 1 ; $j = 0 ;
2021-02-26 21:17:52 +01:00
while ( $i <= 6 ) {
2020-10-31 14:32:18 +01:00
$idprof = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code );
2021-02-26 21:17:52 +01:00
if ( $idprof != '-' ) {
2020-10-31 14:32:18 +01:00
//if (($j % 2) == 0) print '<tr>';
print '<tr>' ;
print '<td>' . $idprof . '</td><td>' ;
$key = 'idprof' . $i ;
2022-01-28 11:22:12 +01:00
print dol_print_profids ( $object -> $key , 'ProfId' . $i , $object -> country_code , 1 );
2021-02-26 21:17:52 +01:00
if ( $object -> $key ) {
if ( $object -> id_prof_check ( $i , $object ) > 0 ) {
2022-06-09 12:04:35 +02:00
if ( ! empty ( $object -> id_prof_url ( $i , $object ))) {
print ' ' . $object -> id_prof_url ( $i , $object );
}
2021-02-26 21:17:52 +01:00
} else {
2021-10-05 10:20:35 +02:00
print ' <span class="error">(' . $langs -> trans ( " ErrorWrongValue " ) . ')</span>' ;
2021-02-26 21:17:52 +01:00
}
2020-10-31 14:32:18 +01:00
}
print '</td>' ;
//if (($j % 2) == 1) print '</tr>';
print '</tr>' ;
$j ++ ;
}
$i ++ ;
}
//if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
2011-06-11 16:14:27 +02:00
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
// This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
// We don't need them into customer profile.
// Except for spain and localtax where localtax depends on buyer and not seller
2017-06-07 16:44:04 +02:00
2021-02-26 21:17:52 +01:00
if ( $object -> fournisseur ) {
2020-10-31 14:32:18 +01:00
// VAT is used
print '<tr><td>' ;
print $form -> textwithpicto ( $langs -> trans ( 'VATIsUsed' ), $langs -> trans ( 'VATIsUsedWhenSelling' ));
print '</td><td>' ;
print yn ( $object -> tva_assuj );
print '</td>' ;
2018-03-15 14:25:09 +01:00
print '</tr>' ;
2023-04-06 08:47:28 +02:00
if ( ! empty ( $conf -> global -> ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE )) {
// VAT reverse charge by default
print '<tr><td>' ;
print $form -> textwithpicto ( $langs -> trans ( 'VATReverseChargeByDefault' ), $langs -> trans ( 'VATReverseChargeByDefaultDesc' ));
print '</td><td>' ;
print '<input type="checkbox" name="vat_reverse_charge" ' . ( $object -> vat_reverse_charge == '1' ? ' checked' : '' ) . ' disabled>' ;
print '</td>' ;
print '</tr>' ;
}
2020-10-31 14:32:18 +01:00
}
2017-06-07 16:44:04 +02:00
2016-10-24 12:42:37 +02:00
// Local Taxes
2021-02-26 21:17:52 +01:00
if ( $object -> fournisseur || $mysoc -> country_code == 'ES' ) {
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax1_assuj );
print '</td></tr><tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax2_assuj );
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
if ( $object -> localtax1_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 1 ))) {
2020-10-31 14:32:18 +01:00
print '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="set_localtax1">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2021-09-27 12:24:01 +02:00
print '<tr><td>' . $langs -> transcountry ( " Localtax1 " , $mysoc -> country_code ) . ' <a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editRE&token=' . newToken () . '&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
2021-02-26 21:17:52 +01:00
if ( $action == 'editRE' ) {
2020-10-31 14:32:18 +01:00
print '<td class="left">' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
2021-08-24 17:04:17 +02:00
print '<input type="submit" class="button button-edit" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
2020-10-31 14:32:18 +01:00
} else {
print '<td>' . $object -> localtax1_value . '</td>' ;
}
print '</tr></form>' ;
}
2021-02-26 21:17:52 +01:00
if ( $object -> localtax2_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 2 ))) {
2020-10-31 14:32:18 +01:00
print '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="set_localtax2">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2021-09-27 12:24:01 +02:00
print '<tr><td>' . $langs -> transcountry ( " Localtax2 " , $mysoc -> country_code ) . '<a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editIRPF&token=' . newToken () . '&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
2020-10-31 14:32:18 +01:00
if ( $action == 'editIRPF' ) {
print '<td class="left">' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
2021-08-24 17:04:17 +02:00
print '<input type="submit" class="button button-edit" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
2020-10-31 14:32:18 +01:00
} else {
print '<td>' . $object -> localtax2_value . '</td>' ;
}
print '</tr></form>' ;
}
2021-02-26 21:17:52 +01:00
} elseif ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj != " 1 " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax1_assuj );
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
if ( $object -> localtax1_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 1 ))) {
2020-10-31 14:32:18 +01:00
print '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="set_localtax1">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2021-09-27 12:24:01 +02:00
print '<tr><td> ' . $langs -> transcountry ( " Localtax1 " , $mysoc -> country_code ) . '<a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editRE&token=' . newToken () . '&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
2020-10-31 14:32:18 +01:00
if ( $action == 'editRE' ) {
print '<td class="left">' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
2021-08-24 17:04:17 +02:00
print '<input type="submit" class="button button-edit" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
2020-10-31 14:32:18 +01:00
} else {
print '<td>' . $object -> localtax1_value . '</td>' ;
}
print '</tr></form>' ;
}
2021-02-26 21:17:52 +01:00
} elseif ( $mysoc -> localtax2_assuj == " 1 " && $mysoc -> localtax1_assuj != " 1 " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax2_assuj );
print '</td></tr>' ;
2021-02-26 21:17:52 +01:00
if ( $object -> localtax2_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 2 ))) {
2020-10-31 14:32:18 +01:00
print '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="set_localtax2">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2021-09-27 12:24:01 +02:00
print '<tr><td> ' . $langs -> transcountry ( " Localtax2 " , $mysoc -> country_code ) . ' <a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editIRPF&token=' . newToken () . '&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
2020-10-31 14:32:18 +01:00
if ( $action == 'editIRPF' ) {
print '<td class="left">' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
2021-08-24 17:04:17 +02:00
print '<input type="submit" class="button button-edit" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
2020-10-31 14:32:18 +01:00
} else {
print '<td>' . $object -> localtax2_value . '</td>' ;
}
print '</tr></form>' ;
}
2018-03-15 14:25:09 +01:00
}
2020-10-31 14:32:18 +01:00
}
2017-06-07 16:44:04 +02:00
2020-10-31 14:32:18 +01:00
// Sale tax code (VAT code)
print '<tr>' ;
2015-10-10 01:51:12 +02:00
print '<td class="nowrap">' . $langs -> trans ( 'VATIntra' ) . '</td><td>' ;
2021-02-26 21:17:52 +01:00
if ( $object -> tva_intra ) {
2020-10-31 14:32:18 +01:00
$s = '' ;
2022-10-06 09:55:03 +02:00
$s .= dol_print_profids ( $object -> tva_intra , 'VAT' , $object -> country_code , 1 );
2020-10-31 14:32:18 +01:00
$s .= '<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="' . $object -> tva_intra . '">' ;
2011-06-11 16:14:27 +02:00
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ) && isInEEC ( $object )) {
2020-10-31 14:32:18 +01:00
$s .= ' ' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> use_javascript_ajax ) {
2020-10-31 14:32:18 +01:00
$widthpopup = 600 ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> dol_use_jmobile )) {
$widthpopup = 350 ;
}
2020-10-31 14:32:18 +01:00
$heightpopup = 400 ;
print " \n " ;
2021-11-29 15:09:18 +01:00
print '<script type="text/javascript">' ;
2020-10-31 14:32:18 +01:00
print " function CheckVAT(a) { \n " ;
print " newpopup(' " . DOL_URL_ROOT . " /societe/checkvat/checkVatPopup.php?vatNumber='+a, ' " . dol_escape_js ( $langs -> trans ( " VATIntraCheckableOnEUSite " )) . " ', " . $widthpopup . " , " . $heightpopup . " ); \n " ;
print " } \n " ;
print '</script>' ;
print " \n " ;
2023-05-01 14:33:08 +02:00
$s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT( $(\'#tva_intra\').val() );">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
2020-10-31 14:32:18 +01:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> transnoentitiesnoconv ( " VATIntraCheck " )), 1 );
} else {
2021-11-22 02:35:55 +01:00
$s .= '<a href="' . $langs -> transcountry ( " VATIntraCheckURL " , $object -> country_id ) . '" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">' . img_picto ( $langs -> trans ( " VATIntraCheckableOnEUSite " ), 'help' ) . '</a>' ;
2020-10-31 14:32:18 +01:00
}
}
print $s ;
} else {
print ' ' ;
}
2020-12-13 19:50:35 +01:00
print '</td></tr>' ;
2021-06-23 16:53:26 +02:00
// Warehouse
2022-09-25 06:06:06 +02:00
if ( isModEnabled ( 'stock' ) && ! empty ( $conf -> global -> SOCIETE_ASK_FOR_WAREHOUSE )) {
2021-06-23 16:53:26 +02:00
$langs -> load ( 'stocks' );
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
$formproduct = new FormProduct ( $db );
print '<tr class="nowrap">' ;
print '<td>' ;
print $form -> editfieldkey ( " Warehouse " , 'warehouse' , '' , $object , $user -> rights -> societe -> creer );
print '</td><td>' ;
if ( $action == 'editwarehouse' ) {
$formproduct -> formSelectWarehouses ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_warehouse , 'fk_warehouse' , 1 );
} else {
2021-06-23 19:02:14 +02:00
if ( $object -> fk_warehouse > 0 ) {
print img_picto ( '' , 'stock' , 'class="paddingrightonly"' );
}
2021-06-23 16:53:26 +02:00
$formproduct -> formSelectWarehouses ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_warehouse , 'none' );
}
print '</td>' ;
print '</tr>' ;
}
2020-10-31 14:32:18 +01:00
print '</table>' ;
print '</div>' ;
2020-12-13 19:50:35 +01:00
2021-10-23 17:18:35 +02:00
print '<div class="fichehalfright">' ;
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="underbanner clearboth"></div>' ;
2021-10-29 11:35:09 +02:00
print '<table class="border tableforfield centpercent">' ;
2016-06-30 15:49:57 +02:00
2020-10-31 14:32:18 +01:00
// Tags / categories
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'categorie' ) && ! empty ( $user -> rights -> categorie -> lire )) {
2016-10-24 12:42:37 +02:00
// Customer
2022-04-07 15:01:20 +02:00
if ( $object -> prospect || $object -> client || ! empty ( $conf -> global -> THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT )) {
2019-11-13 18:32:11 +01:00
print '<tr><td>' . $langs -> trans ( " CustomersCategoriesShort " ) . '</td>' ;
2016-10-24 12:42:37 +02:00
print '<td>' ;
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_CUSTOMER , 1 );
2016-10-24 12:42:37 +02:00
print " </td></tr> " ;
}
// Supplier
2022-08-23 20:05:09 +02:00
if ((( isModEnabled ( " fournisseur " ) && ! empty ( $user -> rights -> fournisseur -> lire ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ( isModEnabled ( " supplier_order " ) && ! empty ( $user -> rights -> supplier_order -> lire )) || ( isModEnabled ( " supplier_invoice " ) && ! empty ( $user -> rights -> supplier_invoice -> lire ))) && $object -> fournisseur ) {
2019-11-13 18:32:11 +01:00
print '<tr><td>' . $langs -> trans ( " SuppliersCategoriesShort " ) . '</td>' ;
2016-10-24 12:42:37 +02:00
print '<td>' ;
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_SUPPLIER , 1 );
2016-10-24 12:42:37 +02:00
print " </td></tr> " ;
}
}
2021-06-23 19:02:14 +02:00
// Third-Party Type
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' . $langs -> trans ( 'ThirdPartyType' ) . '</td>' ;
2022-12-09 14:27:43 +01:00
if ( $action != 'editthirdpartytype' && $user -> hasRight ( 'societe' , 'creer' )) {
2021-09-27 12:24:01 +02:00
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editthirdpartytype&token=' . newToken () . '&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</a></td>' ;
2021-06-23 19:02:14 +02:00
}
print '</tr></table>' ;
print '</td><td>' ;
$html_name = ( $action == 'editthirdpartytype' ) ? 'typent_id' : 'none' ;
$formcompany -> formThirdpartyType ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> typent_id , $html_name , '' );
print '</td></tr>' ;
// Workforce/Staff
if ( empty ( $conf -> global -> SOCIETE_DISABLE_WORKFORCE )) {
print '<tr><td>' . $langs -> trans ( " Workforce " ) . '</td><td>' . $object -> effectif . '</td></tr>' ;
}
2020-10-07 15:01:28 +02:00
// Legal
print '<tr><td class="titlefield">' . $langs -> trans ( 'JuridicalStatus' ) . '</td><td>' . $object -> forme_juridique . '</td></tr>' ;
2011-06-11 22:58:08 +02:00
2020-10-07 15:01:28 +02:00
// Capital
print '<tr><td>' . $langs -> trans ( 'Capital' ) . '</td><td>' ;
2021-02-26 21:17:52 +01:00
if ( $object -> capital ) {
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " ) && ! empty ( $object -> multicurrency_code )) {
2022-06-05 14:32:21 +02:00
print price ( $object -> capital , '' , $langs , 0 , - 1 , - 1 , $object -> multicurrency_code );
} else {
print price ( $object -> capital , '' , $langs , 0 , - 1 , - 1 , $conf -> currency );
}
2021-02-26 21:17:52 +01:00
} else {
print ' ' ;
}
2020-10-07 15:01:28 +02:00
print '</td></tr>' ;
2011-05-06 00:19:21 +02:00
2022-08-29 14:46:26 +02:00
// Unsubscribe opt-out
2023-02-21 13:19:57 +01:00
if ( isModEnabled ( 'mailing' )) {
2022-08-29 14:46:26 +02:00
$result = $object -> getNoEmail ();
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
print '<tr><td>' . $langs -> trans ( " No_Email " ) . '</td><td>' ;
if ( $object -> email ) {
print yn ( $object -> no_email );
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " EMailNotDefined " ) . '</span>' ;
}
2022-12-28 01:54:54 +01:00
$langs -> load ( " mails " );
print ' <span class="badge badge-secondary" title="' . dol_escape_htmltag ( $langs -> trans ( " NbOfEMailingsSend " )) . '">' . $object -> getNbOfEMailings () . '</span>' ;
2022-08-29 14:46:26 +02:00
print '</td></tr>' ;
}
2020-10-07 15:01:28 +02:00
// Default language
2022-09-24 14:55:10 +02:00
if ( getDolGlobalInt ( 'MAIN_MULTILANGS' )) {
2020-10-07 15:01:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
print '<tr><td>' . $langs -> trans ( " DefaultLang " ) . '</td><td>' ;
//$s=picto_from_langcode($object->default_lang);
//print ($s?$s.' ':'');
$langs -> load ( " languages " );
$labellang = ( $object -> default_lang ? $langs -> trans ( 'Language_' . $object -> default_lang ) : '' );
2021-02-27 17:15:40 +01:00
print picto_from_langcode ( $object -> default_lang , 'class="paddingrightonly saturatemedium opacitylow"' );
2020-10-07 15:01:28 +02:00
print $labellang ;
print '</td></tr>' ;
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Incoterms
2022-09-25 22:53:21 +02:00
if ( isModEnabled ( 'incoterm' )) {
2020-10-07 15:01:28 +02:00
print '<tr><td>' ;
2020-12-13 19:50:35 +01:00
print '<table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( 'IncotermLabel' ) . '</td>' ;
2022-12-09 14:27:43 +01:00
if ( $action != 'editincoterm' && $user -> hasRight ( 'societe' , 'creer' )) {
2021-09-27 12:24:01 +02:00
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&action=editincoterm&token=' . newToken () . '">' . img_edit ( '' , 1 ) . '</a></td>' ;
2021-02-26 21:17:52 +01:00
}
2020-12-13 19:50:35 +01:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2021-02-26 21:17:52 +01:00
if ( $action != 'editincoterm' ) {
2020-10-07 15:01:28 +02:00
print $form -> textwithpicto ( $object -> display_incoterms (), $object -> label_incoterms , 1 );
} else {
print $form -> select_incoterms (( ! empty ( $object -> fk_incoterms ) ? $object -> fk_incoterms : '' ), ( ! empty ( $object -> location_incoterms ) ? $object -> location_incoterms : '' ), $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id );
}
print '</td></tr>' ;
}
2015-02-09 17:55:43 +01:00
2016-01-18 19:45:27 +01:00
// Multicurrency
2022-09-03 11:32:24 +02:00
if ( isModEnabled ( " multicurrency " )) {
2016-01-18 19:45:27 +01:00
print '<tr>' ;
2018-10-27 14:50:27 +02:00
print '<td>' . $form -> editfieldkey ( 'Currency' , 'multicurrency_code' , '' , $object , 0 ) . '</td>' ;
2020-10-07 15:01:28 +02:00
print '<td>' ;
print ! empty ( $object -> multicurrency_code ) ? currency_name ( $object -> multicurrency_code , 1 ) : '' ;
2016-01-18 19:45:27 +01:00
print '</td></tr>' ;
}
2016-06-30 15:49:57 +02:00
2021-01-15 17:35:16 +01:00
if ( ! empty ( $conf -> global -> ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY )) {
// Accountancy sell code
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancySellCode " );
print '</td><td colspan="2">' ;
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2022-08-31 22:14:20 +02:00
if ( ! empty ( $object -> accountancy_code_sell )) {
2021-01-15 17:35:16 +01:00
$accountingaccount = new AccountingAccount ( $db );
$accountingaccount -> fetch ( '' , $object -> accountancy_code_sell , 1 );
2020-12-04 04:13:42 +01:00
2021-01-15 17:35:16 +01:00
print $accountingaccount -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
} else {
print $object -> accountancy_code_sell ;
2020-12-04 04:13:42 +01:00
}
2021-01-15 17:35:16 +01:00
print '</td></tr>' ;
2020-12-04 04:13:42 +01:00
2021-01-15 17:35:16 +01:00
// Accountancy buy code
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancyBuyCode " );
print '</td><td colspan="2">' ;
2022-09-04 13:33:11 +02:00
if ( isModEnabled ( 'accounting' )) {
2022-08-31 22:14:20 +02:00
if ( ! empty ( $object -> accountancy_code_buy )) {
2021-01-15 17:35:16 +01:00
$accountingaccount2 = new AccountingAccount ( $db );
$accountingaccount2 -> fetch ( '' , $object -> accountancy_code_buy , 1 );
2020-12-04 04:13:42 +01:00
2021-01-15 17:35:16 +01:00
print $accountingaccount2 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
} else {
print $object -> accountancy_code_buy ;
2020-12-04 04:13:42 +01:00
}
2021-01-15 17:35:16 +01:00
print '</td></tr>' ;
2020-12-04 04:13:42 +01:00
}
2017-06-07 16:44:04 +02:00
// Other attributes
2019-11-13 18:32:11 +01:00
$parameters = array ( 'socid' => $socid , 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' );
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2011-06-22 12:58:22 +02:00
2020-10-07 15:01:28 +02:00
// Parent company
2021-01-20 21:25:51 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PARENTCOMPANY )) {
2020-10-07 15:01:28 +02:00
print '<tr><td>' ;
2020-12-13 19:50:35 +01:00
print '<table class="nobordernopadding" width="100%"><tr><td>' . $langs -> trans ( 'ParentCompany' ) . '</td>' ;
2022-12-09 14:27:43 +01:00
if ( $action != 'editparentcompany' && $user -> hasRight ( 'societe' , 'creer' )) {
2021-09-27 12:24:01 +02:00
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editparentcompany&token=' . newToken () . '&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</a></td>' ;
2021-01-20 21:25:51 +01:00
}
2020-10-07 15:01:28 +02:00
print '</tr></table>' ;
print '</td><td>' ;
2020-12-13 19:50:35 +01:00
$html_name = ( $action == 'editparentcompany' ) ? 'parent_id' : 'none' ;
2021-03-22 22:50:43 +01:00
$form -> form_thirdparty ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> parent , $html_name , '' , 1 , 0 , 0 , null , 0 , array ( $object -> id ));
2020-12-13 19:50:35 +01:00
print '</td></tr>' ;
2020-10-07 15:01:28 +02:00
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Sales representative
include DOL_DOCUMENT_ROOT . '/societe/tpl/linesalesrepresentative.tpl.php' ;
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
// Module Adherent
2022-08-31 21:55:55 +02:00
if ( isModEnabled ( 'adherent' )) {
2020-10-07 15:01:28 +02:00
$langs -> load ( " members " );
print '<tr><td>' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
print '<td>' ;
$adh = new Adherent ( $db );
$result = $adh -> fetch ( '' , '' , $object -> id );
2021-01-20 21:25:51 +01:00
if ( $result > 0 ) {
2020-10-07 15:01:28 +02:00
$adh -> ref = $adh -> getFullName ( $langs );
2021-01-20 21:25:51 +01:00
print $adh -> getNomUrl ( - 1 );
2020-10-07 15:01:28 +02:00
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " ThirdpartyNotLinkedToMember " ) . '</span>' ;
}
2020-12-13 19:50:35 +01:00
print " </td></tr> \n " ;
2020-10-07 15:01:28 +02:00
}
2011-06-11 16:14:27 +02:00
2022-07-18 11:51:28 +02:00
// Link user (you must create a contact to get a user)
/*
print '<tr><td>' . $langs -> trans ( " DolibarrLogin " ) . '</td><td colspan="3">' ;
if ( $object -> user_id ) {
$dolibarr_user = new User ( $db );
$result = $dolibarr_user -> fetch ( $object -> user_id );
print $dolibarr_user -> getLoginUrl ( - 1 );
} else {
//print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
2023-06-05 23:49:13 +02:00
if ( ! $object -> user_id && $user -> hasRight ( 'user' , 'user' , 'creer' )) {
2022-07-18 11:51:28 +02:00
print '<a class="aaa" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=create_user&token=' . newToken () . '">' . img_picto ( $langs -> trans ( " CreateDolibarrLogin " ), 'add' ) . ' ' . $langs -> trans ( " CreateDolibarrLogin " ) . '</a>' ;
}
}
print '</td></tr>' ;
*/
2020-10-07 15:01:28 +02:00
// Webservices url/key
if ( ! empty ( $conf -> syncsupplierwebservices -> enabled )) {
print '<tr><td>' . $langs -> trans ( " WebServiceURL " ) . '</td><td>' . dol_print_url ( $object -> webservices_url ) . '</td>' ;
print '<td class="nowrap">' . $langs -> trans ( 'WebServiceKey' ) . '</td><td>' . $object -> webservices_key . '</td></tr>' ;
}
2014-10-31 17:46:11 +01:00
2020-10-07 15:01:28 +02:00
print '</table>' ;
2015-10-11 12:27:04 +02:00
print '</div>' ;
2016-06-30 15:49:57 +02:00
2021-10-23 17:18:35 +02:00
print '</div>' ;
2023-02-18 14:00:25 +01:00
print '<div class="clearboth"></div>' ;
2016-06-30 15:49:57 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
/*
2021-02-26 21:17:52 +01:00
* Actions
*/
if ( $action != 'presend' ) {
2020-10-07 15:01:28 +02:00
print '<div class="tabsAction">' . " \n " ;
2011-06-11 16:14:27 +02:00
2019-11-13 18:32:11 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 21:17:52 +01:00
if ( empty ( $reshook )) {
2017-09-27 19:56:03 +02:00
$at_least_one_email_contact = false ;
$TContact = $object -> contact_array_objects ();
2021-02-26 21:17:52 +01:00
foreach ( $TContact as & $contact ) {
if ( ! empty ( $contact -> email )) {
2017-09-27 19:56:03 +02:00
$at_least_one_email_contact = true ;
break ;
}
2016-03-04 12:21:14 +01:00
}
2016-06-30 15:49:57 +02:00
2020-04-10 01:37:04 +02:00
if ( empty ( $user -> socid )) {
2022-02-23 15:34:17 +01:00
$langs -> load ( " mails " );
$title = '' ;
if ( empty ( $object -> email ) && ! $at_least_one_email_contact ) { $title = $langs -> trans ( 'NoEMail' ); }
print dolGetButtonAction ( $title , $langs -> trans ( 'SendMail' ), 'default' , $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '&action=presend&mode=init#formmailbeforetitle' , 'btn-send-mail' , ! empty ( $object -> email ) || $at_least_one_email_contact );
2020-04-10 01:37:04 +02:00
}
2014-02-10 00:24:20 +01:00
2022-02-23 12:09:15 +01:00
print dolGetButtonAction ( '' , $langs -> trans ( 'Modify' ), 'default' , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&action=edit&token=' . newToken (), '' , $permissiontoadd );
2019-10-16 11:23:06 +02:00
2022-08-31 21:55:55 +02:00
if ( isModEnabled ( 'adherent' )) {
2019-10-07 20:36:48 +02:00
$adh = new Adherent ( $db );
2019-11-13 18:32:11 +01:00
$result = $adh -> fetch ( '' , '' , $object -> id );
2021-02-26 21:17:52 +01:00
if ( $result == 0 && ( $object -> client == 1 || $object -> client == 3 ) && ! empty ( $conf -> global -> MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS )) {
2021-05-18 17:24:17 +02:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/adherents/card.php?&action=create&socid=' . $object -> id . '" title="' . dol_escape_htmltag ( $langs -> trans ( " NewMember " )) . '">' . $langs -> trans ( " NewMember " ) . '</a>' . " \n " ;
2020-10-07 15:01:28 +02:00
}
}
2022-02-23 12:09:15 +01:00
print dolGetButtonAction ( $langs -> trans ( 'MergeThirdparties' ), $langs -> trans ( 'Merge' ), 'danger' , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&action=merge&token=' . newToken (), '' , $permissiontodelete );
2020-10-07 15:01:28 +02:00
2022-09-10 11:18:31 +02:00
if ( $user -> hasRight ( 'societe' , 'supprimer' )) {
2022-02-23 15:34:17 +01:00
$deleteUrl = $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&action=delete&token=' . newToken ();
$buttonId = 'action-delete-no-ajax' ;
2021-02-26 21:17:52 +01:00
if ( $conf -> use_javascript_ajax && empty ( $conf -> dol_use_jmobile )) { // We can't use preloaded confirm form with jmobile
2022-02-23 15:34:17 +01:00
$deleteUrl = '' ;
$buttonId = 'action-delete' ;
2020-10-07 15:01:28 +02:00
}
2022-02-23 15:34:17 +01:00
print dolGetButtonAction ( $langs -> trans ( 'Delete' ), '' , 'delete' , $deleteUrl , $buttonId , $permissiontodelete );
2020-10-07 15:01:28 +02:00
}
2017-09-27 19:56:03 +02:00
}
2014-02-10 00:24:20 +01:00
2020-10-07 15:01:28 +02:00
print '</div>' . " \n " ;
}
2011-06-11 16:14:27 +02:00
2020-10-07 15:01:28 +02:00
//Select mail models is same action as presend
2015-04-18 19:56:36 +02:00
if ( GETPOST ( 'modelselected' )) {
2015-04-18 11:06:53 +02:00
$action = 'presend' ;
}
2013-04-28 00:36:49 +02:00
2021-02-26 21:17:52 +01:00
if ( $action != 'presend' ) {
2017-09-27 19:56:03 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2013-09-25 21:36:40 +02:00
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_BUILDDOC )) {
2017-09-27 19:56:03 +02:00
print '<a name="builddoc"></a>' ; // ancre
2013-09-25 21:36:40 +02:00
2020-10-07 15:01:28 +02:00
/*
2021-03-16 04:04:18 +01:00
* Generated documents
2021-02-26 21:17:52 +01:00
*/
2020-10-07 15:01:28 +02:00
$filedir = $conf -> societe -> multidir_output [ $object -> entity ] . '/' . $object -> id ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id ;
2022-09-10 11:08:36 +02:00
$genallowed = $user -> hasRight ( 'societe' , 'lire' );
2022-12-09 14:27:43 +01:00
$delallowed = $user -> hasRight ( 'societe' , 'creer' );
2013-09-25 21:36:40 +02:00
2020-10-07 15:01:28 +02:00
print $formfile -> showdocuments ( 'company' , $object -> id , $filedir , $urlsource , $genallowed , $delallowed , $object -> model_pdf , 0 , 0 , 0 , 28 , 0 , 'entity=' . $object -> entity , 0 , '' , $object -> default_lang );
}
2013-09-25 21:36:40 +02:00
2018-01-10 12:38:27 +01:00
// Subsidiaries list
2022-09-28 19:45:14 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PARENTCOMPANY ) && empty ( $conf -> global -> SOCIETE_DISABLE_SHOW_SUBSIDIARIES )) {
2019-11-13 18:32:11 +01:00
$result = show_subsidiaries ( $conf , $langs , $db , $object );
2018-01-10 12:38:27 +01:00
}
2013-09-25 21:36:40 +02:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichehalfright">' ;
2013-09-25 21:36:40 +02:00
2017-11-26 20:21:01 +01:00
$MAXEVENT = 10 ;
2013-09-25 21:36:40 +02:00
2022-05-18 23:11:59 +02:00
$morehtmlcenter = dolGetButtonTitle ( $langs -> trans ( 'SeeAll' ), '' , 'fa fa-bars imgforviewmode' , DOL_URL_ROOT . '/societe/agenda.php?socid=' . $object -> id );
2013-09-25 21:36:40 +02:00
2017-09-27 19:56:03 +02:00
// List of actions on element
2019-11-13 18:32:11 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2017-09-27 19:56:03 +02:00
$formactions = new FormActions ( $db );
2021-10-18 15:25:56 +02:00
$somethingshown = $formactions -> showactions ( $object , '' , $socid , 1 , '' , $MAXEVENT , '' , $morehtmlcenter ); // Show all action for thirdparty
2013-09-25 21:36:40 +02:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2017-06-07 16:44:04 +02:00
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD )) {
2018-01-10 12:38:27 +01:00
// Contacts list
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS )) {
2019-11-13 18:32:11 +01:00
$result = show_contacts ( $conf , $langs , $db , $object , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id );
2018-01-10 12:38:27 +01:00
}
}
2013-09-23 13:17:31 +02:00
}
2017-09-27 19:56:03 +02:00
// Presend form
2019-11-13 18:32:11 +01:00
$modelmail = 'thirdparty' ;
$defaulttopic = 'Information' ;
2021-12-02 15:10:29 +01:00
$diroutput = $conf -> societe -> multidir_output [ $object -> entity ];
2017-09-27 19:56:03 +02:00
$trackid = 'thi' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/card_presend.tpl.php' ;
2020-10-07 15:01:28 +02:00
}
2002-04-30 12:51:35 +02:00
}
2023-01-16 18:06:23 +01:00
2012-03-14 15:08:40 +01:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-03-14 15:08:40 +01:00
$db -> close ();