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-01-10 13:30:57 +01:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ capnetworks . com >
2015-08-26 19:30:40 +02:00
* Copyright ( C ) 2008 Patrick Raguin < patrick . raguin @ auguria . net >
2016-03-18 13:16:33 +01:00
* Copyright ( C ) 2010 - 2016 Juanjo Menent < jmenent @ 2 byte . es >
2015-08-26 19:30:40 +02:00
* Copyright ( C ) 2011 - 2013 Alexandre Spangaro < aspangaro . dolibarr @ gmail . com >
* 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 >
2018-03-10 23:49:43 +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 >
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
2011-08-01 01:19:04 +02:00
* along with this program . If not , see < http :// 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
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' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> adherent -> enabled )) require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
2006-03-11 03:18:26 +01:00
2018-03-19 10:57:19 +01:00
$langs -> loadLangs ( array ( " companies " , " commercial " , " bills " , " banks " , " users " ));
2015-10-03 12:21:27 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) $langs -> load ( " categories " );
2015-09-16 21:34:01 +02:00
if ( ! empty ( $conf -> incoterm -> enabled )) $langs -> load ( " incoterm " );
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> notification -> enabled )) $langs -> load ( " mails " );
2007-02-10 14:43:49 +01:00
2011-08-23 00:04:21 +02:00
$mesg = '' ; $error = 0 ; $errors = array ();
2011-07-01 00:38:06 +02:00
2017-05-16 13:27:32 +02:00
$action = ( GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' );
2018-01-10 13:30:57 +01:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2018-04-30 11:01:33 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-12-01 19:29:29 +01:00
2017-09-27 19:56:03 +02:00
$socid = GETPOST ( 'socid' , 'int' ) ? GETPOST ( 'socid' , 'int' ) : GETPOST ( 'id' , 'int' );
2011-08-23 00:04:21 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2013-12-02 22:14:47 +01:00
if ( empty ( $socid ) && $action == 'view' ) $action = 'create' ;
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
2013-04-26 10:29:14 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-03-29 14:09:47 +01:00
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
2015-03-14 13:05:28 +01:00
$hookmanager -> initHooks ( array ( 'thirdpartycard' , 'globalcard' ));
2018-03-13 18:04:18 +01:00
if ( $socid > 0 ) $object -> fetch ( $socid );
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)
2011-09-13 14:00:37 +02:00
$object -> getCanvas ( $socid );
2011-08-23 00:04:21 +02:00
$canvas = $object -> canvas ? $object -> canvas : GETPOST ( " canvas " );
2014-11-15 16:20:03 +01:00
$objcanvas = null ;
2010-09-07 12:24:26 +02:00
if ( ! empty ( $canvas ))
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
2011-09-24 17:57:52 +02:00
$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
2011-09-13 14:00:37 +02:00
// Security check
2012-03-28 19:39:56 +02:00
$result = restrictedArea ( $user , 'societe' , $socid , '&societe' , '' , 'fk_soc' , 'rowid' , $objcanvas );
2011-09-13 14:00:37 +02: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
2011-09-24 17:57:52 +02:00
$parameters = array ( 'id' => $socid , 'objcanvas' => $objcanvas );
2011-08-11 00:47:33 +02:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2014-09-28 03:41:32 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2011-07-01 00:38:06 +02:00
2011-07-02 01:11:12 +02:00
if ( empty ( $reshook ))
{
2015-09-29 14:31:55 +02:00
if ( $cancel )
{
$action = '' ;
if ( ! empty ( $backtopage ))
{
header ( " Location: " . $backtopage );
exit ;
2016-06-30 15:49:57 +02:00
}
2015-09-29 14:31:55 +02:00
}
2016-02-13 03:38:56 +01:00
2016-11-20 15:47:05 +01:00
if ( $action == 'confirm_merge' && $confirm == 'yes' && $user -> rights -> societe -> creer )
2015-05-04 22:02:54 +02:00
{
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 );
2017-03-15 13:30:30 +01:00
if ( $soc_origin_id <= 0 )
2015-06-05 14:46:30 +02:00
{
2015-04-18 18:11:01 +02:00
$langs -> load ( 'errors' );
$langs -> load ( 'companies' );
2017-03-15 13:30:30 +01:00
setEventMessages ( $langs -> trans ( 'ErrorThirdPartyIdIsMandatory' , $langs -> trans ( 'MergeOriginThirdparty' )), null , 'errors' );
2015-06-05 14:46:30 +02:00
}
else
{
2018-01-31 18:01:56 +01:00
if ( ! $error && $soc_origin -> fetch ( $soc_origin_id ) < 1 )
2015-06-05 14:46:30 +02:00
{
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
}
2018-01-31 18:01:56 +01:00
if ( ! $error )
2015-06-05 14:46:30 +02:00
{
2017-03-15 13:30:30 +01: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 ;
$listofproperties = array (
2017-11-29 16:23:11 +01:00
'address' , 'zip' , 'town' , 'state_id' , 'country_id' , 'phone' , 'phone_pro' , 'fax' , 'email' , 'skype' , 'url' , 'barcode' ,
'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
);
foreach ( $listofproperties as $property )
{
2017-11-29 16:23:11 +01:00
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
$listofproperties = array (
2017-06-07 16:44:04 +02:00
'note_public' , 'note_private'
2017-03-15 13:30:30 +01:00
);
foreach ( $listofproperties as $property )
{
$object -> $property = dol_concatdesc ( $object -> $property , $soc_origin -> $property );
}
2017-06-07 16:44:04 +02:00
2017-03-15 13:30:30 +01:00
// Merge extrafields
2017-08-23 16:57:07 +02:00
if ( is_array ( $soc_origin -> array_options ))
2017-03-15 13:30:30 +01:00
{
2017-08-23 16:57:07 +02:00
foreach ( $soc_origin -> array_options as $key => $val )
{
if ( empty ( $object -> array_options [ $key ])) $object -> array_options [ $key ] = $val ;
}
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' );
$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' );
2018-03-15 00:36:56 +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
|| $soc_origin -> barcode == $object -> barcode )
{
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
2018-01-31 18:01:56 +01:00
$object -> update ( $object -> id , $user , 0 , 1 , 1 , 'merge' );
if ( $result < 0 )
2015-06-05 14:46:30 +02:00
{
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
2018-01-31 18:01:56 +01:00
if ( ! $error )
2015-06-05 14:46:30 +02:00
{
2018-01-31 18:01:56 +01:00
$objects = array (
'Adherent' => '/adherents/class/adherent.class.php' ,
'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' ,
'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' ,
'Livraison' => '/livraison/class/livraison.class.php' ,
'Product' => '/product/class/product.class.php' ,
'Project' => '/projet/class/project.class.php' ,
'User' => '/user/class/user.class.php' ,
);
//First, all core objects must update their tables
foreach ( $objects as $object_name => $object_file )
2015-06-05 15:15:05 +02:00
{
2018-01-31 18:01:56 +01:00
require_once DOL_DOCUMENT_ROOT . $object_file ;
if ( ! $error && ! $object_name :: replaceThirdparty ( $db , $soc_origin -> id , $object -> id ))
{
$error ++ ;
setEventMessages ( $db -> lasterror (), null , 'errors' );
}
2015-04-18 18:11:01 +02:00
}
}
2018-01-31 18:01:56 +01:00
// External modules should update their ones too
if ( ! $error )
2015-06-05 15:15:05 +02:00
{
2015-04-18 18:11:01 +02:00
$reshook = $hookmanager -> executeHooks ( 'replaceThirdparty' , array (
'soc_origin' => $soc_origin -> id ,
'soc_dest' => $object -> id
), $soc_dest , $action );
2015-06-05 15:15:05 +02: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
2017-11-29 16:34:44 +01:00
if ( ! $error )
2017-11-29 16:23:11 +01:00
{
$object -> context = array ( 'merge' => 1 , 'mergefromid' => $soc_origin -> id );
// Call trigger
$result = $object -> call_trigger ( 'COMPANY_MODIFY' , $user );
2017-11-29 16:26:19 +01:00
if ( $result < 0 )
{
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
}
2018-01-31 18:01:56 +01:00
if ( ! $error )
2015-06-05 15:15:05 +02:00
{
2015-04-18 18:11:01 +02:00
//We finally remove the old thirdparty
2015-06-05 15:15:05 +02:00
if ( $soc_origin -> delete ( $soc_origin -> id , $user ) < 1 )
{
2018-01-31 18:01:56 +01:00
$error ++ ;
2015-04-18 18:11:01 +02:00
}
}
2018-01-31 18:01:56 +01:00
if ( ! $error )
2015-06-05 15:15:05 +02:00
{
2015-12-20 10:36:20 +01:00
setEventMessages ( $langs -> trans ( 'ThirdpartiesMergeSuccess' ), null , 'mesgs' );
2015-06-05 15:15:05 +02:00
$db -> commit ();
2016-06-30 15:49:57 +02:00
}
else
2015-12-20 10:36:20 +01:00
{
2016-06-20 15:42:16 +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
}
}
}
2012-07-23 22:04:06 +02:00
if ( GETPOST ( 'getcustomercode' ))
2011-06-11 16:14:27 +02:00
{
2011-06-30 15:25:32 +02:00
// We defined value code_client
$_POST [ " code_client " ] = " Acompleter " ;
2011-06-11 16:14:27 +02:00
}
2012-07-23 22:04:06 +02:00
if ( GETPOST ( 'getsuppliercode' ))
2011-06-30 00:29:50 +02:00
{
2011-06-30 15:25:32 +02:00
// We defined value code_fournisseur
$_POST [ " code_fournisseur " ] = " Acompleter " ;
2011-06-30 00:29:50 +02:00
}
2014-07-04 14:25:08 +02:00
2014-07-03 18:47:06 +02:00
if ( $action == 'set_localtax1' )
{
//obtidre selected del combobox
$value = GETPOST ( 'lt1' );
2014-07-04 14:25:08 +02:00
$object -> fetch ( $socid );
2016-09-12 20:16:39 +02:00
$res = $object -> setValueFrom ( 'localtax1_value' , $value , '' , null , 'text' , '' , $user , 'COMPANY_MODIFY' );
2014-07-03 18:47:06 +02:00
}
if ( $action == 'set_localtax2' )
{
//obtidre selected del combobox
$value = GETPOST ( 'lt2' );
2014-07-04 14:25:08 +02:00
$object -> fetch ( $socid );
2016-09-12 20:16:39 +02:00
$res = $object -> setValueFrom ( 'localtax2_value' , $value , '' , null , 'text' , '' , $user , 'COMPANY_MODIFY' );
2014-07-03 18:47:06 +02:00
}
2011-06-30 15:25:32 +02:00
2017-06-07 16:44:04 +02:00
if ( $action == 'update_extras' ) {
$object -> fetch ( $socid );
2018-02-23 16:11:00 +01:00
$object -> oldcopy = dol_clone ( $object );
2017-06-07 16:44:04 +02:00
// Fill array 'array_options' with data from update form
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2018-02-23 14:38:41 +01:00
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object , GETPOST ( 'attribute' , 'none' ));
2017-06-07 16:44:04 +02:00
if ( $ret < 0 ) $error ++ ;
2017-10-24 19:04:40 +02:00
2017-06-07 16:44:04 +02:00
if ( ! $error )
{
2018-05-25 15:02:24 +02:00
$result = $object -> insertExtraFields ( 'COMPANY_MODIFY' );
if ( $result < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
2017-06-07 16:44:04 +02:00
}
2017-10-24 19:04:40 +02:00
2017-06-07 16:44:04 +02:00
if ( $error ) $action = 'edit_extras' ;
}
2014-10-31 17:46:11 +01:00
// Add new or update third party
2012-07-23 22:04:06 +02:00
if (( ! GETPOST ( 'getcustomercode' ) && ! GETPOST ( 'getsuppliercode' ))
2011-06-30 15:25:32 +02:00
&& ( $action == 'add' || $action == 'update' ) && $user -> rights -> societe -> creer )
2011-06-11 16:14:27 +02:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2011-06-11 16:14:27 +02:00
2015-10-16 15:05:05 +02:00
if ( ! GETPOST ( 'name' ))
{
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " ThirdPartyName " )), null , 'errors' );
2015-10-16 15:05:05 +02:00
$error ++ ;
}
if ( GETPOST ( 'client' ) < 0 )
{
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " ProspectCustomer " )), null , 'errors' );
2015-10-16 15:05:05 +02:00
$error ++ ;
}
if ( GETPOST ( 'fournisseur' ) < 0 )
{
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Supplier " )), null , 'errors' );
2015-10-16 15:05:05 +02:00
$error ++ ;
2016-06-30 15:49:57 +02:00
2012-05-29 09:53:39 +02:00
}
2011-08-19 00:25:46 +02:00
2017-09-30 19:12:12 +02:00
if ( ! $error )
2011-06-11 16:14:27 +02:00
{
2018-07-08 12:11:22 +02:00
if ( $action == 'update' )
2017-09-30 18:19:20 +02:00
{
2018-07-08 12:11:22 +02:00
$ret = $object -> fetch ( $socid );
2017-09-30 18:19:20 +02:00
$object -> oldcopy = clone $object ;
}
else $object -> canvas = $canvas ;
2014-10-31 17:46:11 +01:00
2017-09-30 18:19:20 +02:00
if ( GETPOST ( " private " ) == 1 ) // Ask to create a contact
{
2018-07-08 12:11:22 +02:00
$object -> particulier = GETPOST ( " private " );
2016-06-30 15:49:57 +02:00
2018-01-10 13:30:57 +01:00
$object -> name = dolGetFirstLastname ( GETPOST ( 'firstname' , 'alpha' ), GETPOST ( 'name' , 'alpha' ));
2018-07-08 12:11:22 +02:00
$object -> civility_id = GETPOST ( 'civility_id' ); // Note: civility id is a code, not an int
2017-09-30 18:19:20 +02:00
// Add non official properties
2018-01-10 13:30:57 +01:00
$object -> name_bis = GETPOST ( 'name' , 'alpha' );
$object -> firstname = GETPOST ( 'firstname' , 'alpha' );
2017-09-30 18:19:20 +02:00
}
else
{
2018-01-10 13:30:57 +01:00
$object -> name = GETPOST ( 'name' , 'alpha' );
2017-09-30 18:19:20 +02:00
}
2018-01-10 13:30:57 +01:00
$object -> entity = ( GETPOSTISSET ( 'entity' ) ? GETPOST ( 'entity' , 'int' ) : $conf -> entity );
$object -> name_alias = GETPOST ( 'name_alias' );
2018-07-08 12:11:22 +02:00
$object -> address = GETPOST ( 'address' );
$object -> zip = GETPOST ( 'zipcode' , 'alpha' );
2018-01-10 13:30:57 +01:00
$object -> town = GETPOST ( 'town' , 'alpha' );
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
$object -> skype = GETPOST ( 'skype' , 'alpha' );
$object -> phone = GETPOST ( 'phone' , 'alpha' );
2018-07-08 12:11:22 +02:00
$object -> fax = GETPOST ( 'fax' , 'alpha' );
2018-01-10 13:30:57 +01:00
$object -> email = trim ( GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL ));
2018-07-08 12:11:22 +02:00
$object -> url = trim ( GETPOST ( 'url' , 'custom' , 0 , FILTER_SANITIZE_URL ));
$object -> idprof1 = trim ( GETPOST ( 'idprof1' , 'alpha' ));
$object -> idprof2 = trim ( GETPOST ( 'idprof2' , 'alpha' ));
$object -> idprof3 = trim ( GETPOST ( 'idprof3' , 'alpha' ));
$object -> idprof4 = trim ( GETPOST ( 'idprof4' , 'alpha' ));
$object -> idprof5 = trim ( GETPOST ( 'idprof5' , 'alpha' ));
$object -> idprof6 = trim ( GETPOST ( 'idprof6' , 'alpha' ));
$object -> prefix_comm = GETPOST ( 'prefix_comm' , 'alpha' );
$object -> code_client = GETPOST ( 'code_client' , 'alpha' );
2018-01-10 13:30:57 +01:00
$object -> code_fournisseur = GETPOST ( 'code_fournisseur' , 'alpha' );
2018-07-08 12:11:22 +02:00
$object -> capital = GETPOST ( 'capital' , 'alpha' );
$object -> barcode = GETPOST ( 'barcode' , 'alpha' );
2018-01-10 13:30:57 +01:00
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alpha' );
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'alpha' );
$object -> status = GETPOST ( 'status' , 'alpha' );
2017-09-30 18:19:20 +02:00
// Local Taxes
2018-07-08 12:11:22 +02:00
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' , 'alpha' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' , 'alpha' );
2017-09-30 18:19:20 +02:00
2018-07-08 12:11:22 +02:00
$object -> localtax1_value = GETPOST ( 'lt1' , 'alpha' );
$object -> localtax2_value = GETPOST ( 'lt2' , 'alpha' );
2017-09-30 18:19:20 +02:00
2018-01-10 13:30:57 +01:00
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' , 'int' );
2018-07-08 12:11:22 +02:00
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
2018-01-10 13:30:57 +01:00
$object -> typent_id = GETPOST ( 'typent_id' , 'int' );
2017-09-30 18:19:20 +02:00
2018-07-08 12:11:22 +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
2017-09-30 18:19:20 +02:00
2018-01-10 13:30:57 +01:00
$object -> client = GETPOST ( 'client' , 'int' );
2018-07-08 12:11:22 +02:00
$object -> fournisseur = GETPOST ( 'fournisseur' , 'int' );
2017-09-30 18:19:20 +02:00
2018-01-10 13:30:57 +01:00
$object -> commercial_id = GETPOST ( 'commercial_id' , 'int' );
$object -> default_lang = GETPOST ( 'default_lang' );
2017-09-30 18:19:20 +02:00
// Webservices url/key
2018-07-08 12:11:22 +02:00
$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
2017-09-30 18:19:20 +02:00
// Incoterms
if ( ! empty ( $conf -> incoterm -> enabled ))
{
2018-01-10 13:30:57 +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
if ( ! empty ( $conf -> multicurrency -> enabled ))
{
$object -> multicurrency_code = GETPOST ( 'multicurrency_code' , 'alpha' );
}
2011-06-11 16:14:27 +02:00
2017-09-30 18:19:20 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
if ( $ret < 0 )
{
$error ++ ;
}
2013-01-26 10:35:30 +01:00
2017-09-30 18:19:20 +02:00
if ( GETPOST ( 'deletephoto' )) $object -> logo = '' ;
else if ( ! empty ( $_FILES [ 'photo' ][ 'name' ])) $object -> logo = dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
2011-08-19 00:25:46 +02:00
2017-09-30 18:19:20 +02:00
// Check parameters
if ( ! GETPOST ( 'cancel' , 'alpha' ))
{
if ( ! empty ( $object -> email ) && ! isValidEMail ( $object -> email ))
{
$langs -> load ( " errors " );
$error ++ ;
setEventMessages ( '' , $langs -> trans ( " ErrorBadEMail " , $object -> email ), 'errors' );
}
if ( ! empty ( $object -> url ) && ! isValidUrl ( $object -> url ))
{
$langs -> load ( " errors " );
setEventMessages ( '' , $langs -> trans ( " ErrorBadUrl " , $object -> url ), 'errors' );
}
if ( ! empty ( $object -> webservices_url )) {
//Check if has transport, without any the soap client will give error
if ( strpos ( $object -> webservices_url , " http " ) === false )
{
$object -> webservices_url = " http:// " . $object -> webservices_url ;
}
if ( ! isValidUrl ( $object -> webservices_url )) {
$langs -> load ( " errors " );
$error ++ ; $errors [] = $langs -> trans ( " ErrorBadUrl " , $object -> webservices_url );
}
}
2015-03-03 18:33:53 +01:00
2017-09-30 18:19:20 +02:00
// We set country_id, country_code and country for the selected country
$object -> country_id = GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $mysoc -> country_id ;
if ( $object -> country_id )
{
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
}
}
2011-08-19 00:25:46 +02:00
}
2013-01-26 10:35:30 +01:00
2011-06-30 15:25:32 +02:00
if ( ! $error )
{
if ( $action == 'add' )
2011-06-30 00:29:50 +02:00
{
2018-02-23 11:23:04 +01:00
$error = 0 ;
2011-06-30 15:25:32 +02:00
$db -> begin ();
2011-07-02 16:12:44 +02:00
if ( empty ( $object -> client )) $object -> code_client = '' ;
if ( empty ( $object -> fournisseur )) $object -> code_fournisseur = '' ;
2011-06-30 15:25:32 +02:00
2011-07-02 16:12:44 +02:00
$result = $object -> create ( $user );
2017-06-07 16:44:04 +02:00
2016-06-30 15:12:35 +02:00
if ( $result >= 0 )
2018-01-10 13:30:57 +01:00
{
if ( $object -> particulier )
{
dol_syslog ( " We ask to create a contact/address too " , LOG_DEBUG );
$result = $object -> create_individual ( $user );
if ( $result < 0 )
{
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
2018-09-21 10:14:23 +02:00
$salesreps = GETPOST ( 'commercial' , 'array' );
$result = $object -> setSalesRep ( $salesreps );
if ( $result < 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2018-03-09 18:59:06 +01:00
}
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' );
if ( $result < 0 )
{
$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' );
if ( $result < 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-05-22 19:24:56 +02:00
2013-11-23 15:22:27 +01:00
// Logo/Photo save
2012-04-07 09:14:33 +02:00
$dir = $conf -> societe -> multidir_output [ $conf -> entity ] . " / " . $object -> id . " /logos/ " ;
2011-06-30 15:25:32 +02:00
$file_OK = is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]);
if ( $file_OK )
2011-06-11 16:14:27 +02:00
{
2011-06-30 15:25:32 +02:00
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ]))
{
2012-02-19 18:34:22 +01:00
dol_mkdir ( $dir );
2011-06-30 15:25:32 +02:00
if ( @ is_dir ( $dir ))
{
$newfile = $dir . '/' . dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 );
if ( ! $result > 0 )
{
$errors [] = " ErrorFailedToSaveFile " ;
}
else
{
2016-04-09 14:12:21 +02:00
// Create thumbs
$object -> addThumbs ( $newfile );
2011-06-30 15:25:32 +02:00
}
}
}
2011-06-11 16:14:27 +02:00
}
2013-11-23 15:22:27 +01:00
else
2018-02-23 11:23:04 +01:00
{
2013-11-23 15:22:27 +01:00
switch ( $_FILES [ 'photo' ][ 'error' ])
{
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 ;
case 3 : //uploaded file was only partially uploaded
$errors [] = " ErrorFilePartiallyUploaded " ;
break ;
}
}
2011-09-20 12:30:56 +02:00
// Gestion du logo de la société
2011-06-30 15:25:32 +02:00
}
else
2012-11-30 21:23:12 +01:00
{
2017-01-28 15:12:14 +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
2017-01-28 12:36:53 +01:00
{
2016-06-30 15:12:35 +02:00
$duplicate_code_error = true ;
$object -> code_fournisseur = null ;
$object -> code_client = null ;
}
2017-06-07 16:44:04 +02:00
2017-09-03 20:49:36 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
2011-06-30 15:25:32 +02:00
}
2018-02-23 11:23:04 +01:00
if ( $result >= 0 && ! $error )
2011-06-30 15:25:32 +02:00
{
$db -> commit ();
2014-04-16 00:06:16 +02:00
if ( ! empty ( $backtopage ))
{
2017-06-08 11:51:22 +02:00
if ( preg_match ( '/\?/' , $backtopage )) $backtopage .= '&socid=' . $object -> id ;
2014-04-16 00:06:16 +02:00
header ( " Location: " . $backtopage );
exit ;
}
else
{
$url = $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id ;
2014-09-18 21:18:25 +02:00
if (( $object -> client == 1 || $object -> client == 3 ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) $url = DOL_URL_ROOT . " /comm/card.php?socid= " . $object -> id ;
else if ( $object -> fournisseur == 1 ) $url = DOL_URL_ROOT . " /fourn/card.php?socid= " . $object -> id ;
2014-04-16 00:06:16 +02:00
header ( " Location: " . $url );
exit ;
}
2011-06-30 15:25:32 +02:00
}
else
{
$db -> rollback ();
$action = 'create' ;
}
}
if ( $action == 'update' )
{
2018-02-23 11:23:04 +01:00
$error = 0 ;
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' ))
2011-06-30 15:25:32 +02:00
{
2014-04-16 00:06:16 +02:00
if ( ! empty ( $backtopage ))
{
header ( " Location: " . $backtopage );
exit ;
}
else
{
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?socid= " . $socid );
exit ;
}
2011-06-30 15:25:32 +02:00
}
// To not set code if third party is not concerned. But if it had values, we keep them.
2011-07-02 16:12:44 +02: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 = '' ;
2011-12-21 21:45:36 +01:00
//var_dump($object);exit;
2011-06-30 15:25:32 +02:00
2013-01-22 15:14:46 +01:00
$result = $object -> update ( $socid , $user , 1 , $object -> oldcopy -> codeclient_modifiable (), $object -> oldcopy -> codefournisseur_modifiable (), 'update' , 0 );
2011-06-30 15:25:32 +02:00
if ( $result <= 0 )
{
2018-05-22 19:24:56 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2018-05-25 13:14:58 +02:00
$error ++ ;
2011-06-11 16:14:27 +02:00
}
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 );
if ( $result < 0 )
{
$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)
2018-02-23 11:23:04 +01:00
if ( ! $error && ! empty ( $user -> rights -> categorie -> lire ))
2018-02-08 15:18:28 +01:00
{
2018-02-05 16:07:08 +01:00
// Customer categories association
$categories = GETPOST ( 'custcats' , 'array' );
2018-02-23 11:23:04 +01:00
$result = $object -> setCategories ( $categories , 'customer' );
if ( $result < 0 )
{
$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' );
if ( $result < 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2018-02-05 16:07:08 +01:00
}
2015-08-26 19:30:40 +02:00
2013-11-23 15:22:27 +01:00
// Logo/Photo save
2012-04-07 09:14:33 +02:00
$dir = $conf -> societe -> multidir_output [ $object -> entity ] . " / " . $object -> id . " /logos " ;
2011-06-11 22:58:08 +02:00
$file_OK = is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]);
2018-05-30 12:29:02 +02:00
if ( GETPOST ( 'deletephoto' ) && $object -> logo )
2015-12-21 17:32:20 +01:00
{
$fileimg = $dir . '/' . $object -> logo ;
$dirthumbs = $dir . '/thumbs' ;
dol_delete_file ( $fileimg );
dol_delete_dir_recursive ( $dirthumbs );
}
2011-06-11 16:14:27 +02:00
if ( $file_OK )
{
2011-06-30 15:25:32 +02:00
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ]) > 0 )
{
dol_mkdir ( $dir );
2011-06-11 16:14:27 +02:00
if ( @ is_dir ( $dir ))
{
2011-06-11 22:58:08 +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
if ( ! $result > 0 )
{
$errors [] = " ErrorFailedToSaveFile " ;
}
else
{
2018-02-23 19:55:15 +01:00
// Create thumbs
$object -> addThumbs ( $newfile );
2011-06-11 16:14:27 +02:00
2018-02-23 19:55:15 +01:00
// Index file in database
if ( ! empty ( $conf -> global -> THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD ))
{
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 ), '' , '' , 'uploaded' , 1 );
// now we index the uploaded logo file
addFileIntoDatabaseIndex ( dirname ( $newfile ), basename ( $newfile ), '' , 'uploaded' , 1 );
}
2011-06-11 16:14:27 +02:00
}
}
}
2011-06-30 15:25:32 +02:00
else
2013-11-23 15:22:27 +01:00
{
2011-06-30 15:25:32 +02:00
$errors [] = " ErrorBadImageFormat " ;
}
2011-06-11 16:14:27 +02:00
}
2013-11-23 15:22:27 +01:00
else
2017-09-03 17:47:45 +02:00
{
2013-11-23 15:22:27 +01:00
switch ( $_FILES [ 'photo' ][ 'error' ])
{
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 ;
case 3 : //uploaded file was only partially uploaded
$errors [] = " ErrorFilePartiallyUploaded " ;
break ;
}
}
2011-09-20 12:30:56 +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
// Update linked member
if ( ! $error && $object -> fk_soc > 0 )
2013-01-22 15:14:46 +01:00
{
2013-01-26 10:38:11 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " adherent " ;
$sql .= " SET fk_soc = NULL WHERE fk_soc = " . $id ;
2014-06-14 12:02:07 +02:00
if ( ! $object -> db -> query ( $sql ))
2013-01-26 10:38:11 +01:00
{
$error ++ ;
2014-06-14 12:02:07 +02:00
$object -> error .= $object -> db -> lasterror ();
2018-05-22 19:24:56 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2013-01-26 10:38:11 +01:00
}
}
2013-01-26 10:35:30 +01:00
2011-09-17 21:49:50 +02:00
if ( ! $error && ! count ( $errors ))
2011-06-11 16:14:27 +02:00
{
2017-09-03 17:47:45 +02:00
if ( ! empty ( $backtopage ))
2014-04-16 00:06:16 +02:00
{
header ( " Location: " . $backtopage );
exit ;
}
else
{
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?socid= " . $socid );
exit ;
}
2011-06-11 16:14:27 +02:00
}
else
{
2011-07-02 16:12:44 +02:00
$object -> id = $socid ;
2011-06-30 15:25:32 +02:00
$action = " edit " ;
2011-06-11 16:14:27 +02:00
}
}
}
2017-09-02 15:23:53 +02:00
else
{
2017-09-03 17:47:45 +02:00
$action = ( $action == 'add' ? 'create' : 'edit' );
2017-09-02 15:23:53 +02:00
}
2011-06-11 16:14:27 +02:00
}
2011-06-30 15:25:32 +02:00
// Delete third party
if ( $action == 'confirm_delete' && $confirm == 'yes' && $user -> rights -> societe -> supprimer )
2011-06-30 00:29:50 +02:00
{
2011-07-02 16:12:44 +02:00
$object -> fetch ( $socid );
2015-05-03 18:44:42 +02:00
$result = $object -> delete ( $socid , $user );
2011-06-30 15:25:32 +02:00
2011-08-28 14:57:23 +02:00
if ( $result > 0 )
2011-06-30 15:25:32 +02:00
{
2018-02-26 21:16:40 +01:00
header ( " Location: " . DOL_URL_ROOT . " /societe/list.php?restore_lastsearch_values=1&delsoc= " . urlencode ( $object -> name ));
2011-06-30 15:25:32 +02:00
exit ;
}
else
{
$langs -> load ( " errors " );
2017-09-03 20:49:36 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
2011-06-30 15:25:32 +02:00
$action = '' ;
}
2011-06-11 16:14:27 +02:00
}
2013-04-08 19:26:45 +02:00
// Set parent company
2013-06-05 16:24:32 +02:00
if ( $action == 'set_thirdparty' && $user -> rights -> societe -> creer )
2013-04-08 19:26:45 +02:00
{
2015-10-15 16:48:52 +02:00
$object -> fetch ( $socid );
2013-06-05 16:24:32 +02:00
$result = $object -> set_parent ( GETPOST ( 'editparentcompany' , 'int' ));
}
2011-06-11 16:14:27 +02:00
2015-02-10 10:22:38 +01:00
// Set incoterm
2015-02-10 12:21:29 +01:00
if ( $action == 'set_incoterms' && ! empty ( $conf -> incoterm -> enabled ))
2015-02-10 10:22:38 +01:00
{
$object -> fetch ( $socid );
$result = $object -> setIncoterms ( GETPOST ( 'incoterm_id' , 'int' ), GETPOST ( 'location_incoterms' , 'alpha' ));
}
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
$id = $socid ;
2018-03-07 15:52:58 +01:00
$object -> fetch ( $socid );
// Actions to send emails
2014-11-04 13:54:18 +01:00
$trigger_name = 'COMPANY_SENTBYMAIL' ;
2013-09-25 21:36:40 +02:00
$paramname = 'socid' ;
2014-08-05 09:26:40 +02:00
$mode = 'emailfromthirdparty' ;
2016-10-03 00:38:28 +02:00
$trackid = 'thi' . $object -> id ;
2013-09-23 13:17:31 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
2013-09-25 21:36:40 +02:00
2015-09-06 12:30:41 +02:00
// Actions to build doc
$id = $socid ;
$upload_dir = $conf -> societe -> dir_output ;
$permissioncreate = $user -> rights -> societe -> creer ;
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 );
2010-09-02 21:41:49 +02:00
2015-01-17 14:34:16 +01:00
if ( $socid > 0 && empty ( $object -> id ))
{
2015-08-03 11:39:24 +02:00
$result = $object -> fetch ( $socid );
2015-01-17 14:34:16 +01:00
if ( $result <= 0 ) dol_print_error ( '' , $object -> error );
}
$title = $langs -> trans ( " ThirdParty " );
2016-08-09 10:19:42 +02:00
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/thirdpartynameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) $title = $object -> name . " - " . $langs -> trans ( 'Card' );
2015-01-17 14:34:16 +01:00
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas' ;
llxHeader ( '' , $title , $help_url );
2010-09-07 01:53:55 +02:00
$countrynotdefined = $langs -> trans ( " ErrorSetACountryFirst " ) . ' (' . $langs -> trans ( " SeeAbove " ) . ')' ;
2012-02-28 16:48:18 +01:00
if ( is_object ( $objcanvas ) && $objcanvas -> displayCanvasExists ( $action ))
2010-09-07 01:53:55 +02:00
{
2011-06-11 16:14:27 +02:00
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
2013-04-09 23:56:52 +02:00
$objcanvas -> assign_values ( $action , $object -> id , $object -> ref ); // Set value for templates
$objcanvas -> display_canvas ( $action ); // Show template
2010-09-07 12:24:26 +02:00
}
else
{
2011-06-11 16:14:27 +02:00
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
if ( $action == 'create' )
{
/*
* Creation
*/
2012-11-15 16:26:05 +01:00
$private = GETPOST ( " private " , " int " );
2016-10-29 21:47:10 +02:00
if ( ! empty ( $conf -> global -> THIRDPARTY_DEFAULT_CREATE_CONTACT ) && ! isset ( $_GET [ 'private' ]) && ! isset ( $_POST [ 'private' ])) $private = 1 ;
2012-11-15 16:26:05 +01:00
if ( empty ( $private )) $private = 0 ;
2011-06-11 16:14:27 +02:00
// Load object modCodeTiers
2012-08-15 09:06:36 +02:00
$module = ( ! empty ( $conf -> global -> SOCIETE_CODECLIENT_ADDON ) ? $conf -> global -> SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard' );
2011-06-11 16:14:27 +02:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' )
{
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
2013-01-07 13:28:14 +01:00
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2012-03-01 00:03:16 +01:00
foreach ( $dirsociete as $dirroot )
{
2012-08-23 02:04:35 +02:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2012-03-01 00:03:16 +01:00
if ( $res ) break ;
}
2011-06-11 16:14:27 +02:00
$modCodeClient = new $module ;
2014-02-10 00:24:20 +01:00
// Load object modCodeFournisseur
$module = ( ! empty ( $conf -> global -> SOCIETE_CODECLIENT_ADDON ) ? $conf -> global -> SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard' );
2011-06-11 16:14:27 +02:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' )
{
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
2013-01-07 13:28:14 +01:00
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2012-03-01 00:03:16 +01:00
foreach ( $dirsociete as $dirroot )
{
2012-08-23 02:04:35 +02:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2012-03-01 00:03:16 +01:00
if ( $res ) break ;
}
2011-06-11 16:14:27 +02:00
$modCodeFournisseur = new $module ;
2010-09-07 12:24:26 +02:00
2015-05-18 10:58:04 +02:00
// Define if customer/prospect or supplier status is set or not
2016-04-30 14:59:40 +02:00
if ( GETPOST ( " type " ) != 'f' )
{
$object -> client =- 1 ;
if ( ! empty ( $conf -> global -> THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT )) { $object -> client = 3 ; }
}
if ( GETPOST ( " type " ) == 'c' ) { $object -> client = 3 ; } // Prospect / Customer
2011-07-02 16:12:44 +02:00
if ( GETPOST ( " type " ) == 'p' ) { $object -> client = 2 ; }
2016-04-30 14:59:40 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && ( GETPOST ( " type " ) == 'f' || ( GETPOST ( " type " ) == '' && ! empty ( $conf -> global -> THIRDPARTY_SUPPLIER_BY_DEFAULT )))) { $object -> fournisseur = 1 ; }
2011-07-02 16:12:44 +02:00
2015-06-05 14:02:50 +02:00
$object -> name = GETPOST ( 'name' , 'alpha' );
2014-10-18 00:41:21 +02:00
$object -> firstname = GETPOST ( 'firstname' , 'alpha' );
2012-11-15 16:26:05 +01:00
$object -> particulier = $private ;
2012-07-28 12:35:11 +02:00
$object -> prefix_comm = GETPOST ( 'prefix_comm' );
$object -> client = GETPOST ( 'client' ) ? GETPOST ( 'client' ) : $object -> client ;
2017-06-07 16:44:04 +02:00
2016-06-30 15:12:35 +02:00
if ( empty ( $duplicate_code_error )) {
$object -> code_client = GETPOST ( 'code_client' , 'alpha' );
$object -> fournisseur = GETPOST ( 'fournisseur' ) ? GETPOST ( 'fournisseur' ) : $object -> fournisseur ;
2016-10-13 16:44:17 +02:00
}
else {
2016-06-30 15:12:35 +02:00
setEventMessages ( $langs -> trans ( 'NewCustomerSupplierCodeProposed' ), '' , 'warnings' );
}
2017-06-07 16:44:04 +02:00
2014-10-18 00:41:21 +02:00
$object -> code_fournisseur = GETPOST ( 'code_fournisseur' , 'alpha' );
$object -> address = GETPOST ( 'address' , 'alpha' );
$object -> zip = GETPOST ( 'zipcode' , 'alpha' );
$object -> town = GETPOST ( 'town' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> skype = GETPOST ( 'skype' , 'alpha' );
$object -> phone = GETPOST ( 'phone' , 'alpha' );
$object -> fax = GETPOST ( 'fax' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> email = GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL );
$object -> url = GETPOST ( 'url' , 'custom' , 0 , FILTER_SANITIZE_URL );
2015-10-14 23:50:36 +02:00
$object -> capital = GETPOST ( 'capital' , 'alpha' );
2014-10-18 00:41:21 +02:00
$object -> barcode = GETPOST ( 'barcode' , 'alpha' );
$object -> idprof1 = GETPOST ( 'idprof1' , 'alpha' );
$object -> idprof2 = GETPOST ( 'idprof2' , 'alpha' );
$object -> idprof3 = GETPOST ( 'idprof3' , 'alpha' );
$object -> idprof4 = GETPOST ( 'idprof4' , 'alpha' );
$object -> idprof5 = GETPOST ( 'idprof5' , 'alpha' );
$object -> idprof6 = GETPOST ( 'idprof6' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> typent_id = GETPOST ( 'typent_id' , 'int' );
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
$object -> civility_id = GETPOST ( 'civility_id' , 'int' );
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'int' );
$object -> status = GETPOST ( 'status' , 'int' );
2010-09-07 12:24:26 +02:00
2011-06-11 16:14:27 +02:00
//Local Taxes
2014-08-06 15:59:36 +02:00
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' , 'int' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' , 'int' );
2014-07-04 14:25:08 +02:00
2014-08-06 15:59:36 +02:00
$object -> localtax1_value = GETPOST ( 'lt1' , 'int' );
$object -> localtax2_value = GETPOST ( 'lt2' , 'int' );
2011-06-11 16:14:27 +02:00
2014-10-18 00:41:21 +02:00
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alpha' );
2011-06-11 16:14:27 +02:00
2014-08-06 15:59:36 +02:00
$object -> commercial_id = GETPOST ( 'commercial_id' , 'int' );
2012-07-28 12:35:11 +02:00
$object -> default_lang = GETPOST ( 'default_lang' );
2011-06-11 16:14:27 +02:00
2012-07-28 12:35:11 +02:00
$object -> logo = ( isset ( $_FILES [ 'photo' ]) ? dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]) : '' );
2011-06-11 16:14:27 +02:00
2011-09-20 12:30:56 +02:00
// Gestion du logo de la société
2012-07-28 12:35:11 +02:00
$dir = $conf -> societe -> multidir_output [ $conf -> entity ] . " / " . $object -> id . " /logos " ;
$file_OK = ( isset ( $_FILES [ 'photo' ]) ? is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]) : false );
2011-06-11 16:14:27 +02:00
if ( $file_OK )
{
2011-06-11 22:58:08 +02:00
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ]))
2011-06-11 16:14:27 +02:00
{
2012-02-19 18:34:22 +01:00
dol_mkdir ( $dir );
2011-06-11 16:14:27 +02:00
if ( @ is_dir ( $dir ))
{
2011-06-11 22:58:08 +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
if ( ! $result > 0 )
{
$errors [] = " ErrorFailedToSaveFile " ;
}
else
{
2016-04-09 14:12:21 +02:00
// Create thumbs
$object -> addThumbs ( $newfile );
2011-06-11 16:14:27 +02:00
}
}
}
}
2011-08-24 20:05:58 +02:00
// We set country_id, country_code and country for the selected country
2012-07-28 12:35:11 +02:00
$object -> country_id = GETPOST ( 'country_id' ) ? GETPOST ( 'country_id' ) : $mysoc -> country_id ;
2011-12-15 12:28:31 +01:00
if ( $object -> country_id )
2011-06-11 16:14:27 +02:00
{
2011-12-29 18:07:41 +01:00
$tmparray = getCountry ( $object -> country_id , 'all' );
2011-08-24 20:05:58 +02:00
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
2011-06-11 16:14:27 +02:00
}
2012-07-28 12:35:11 +02:00
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' );
2011-06-11 16:14:27 +02:00
/* Show create form */
2010-09-07 12:24:26 +02:00
2015-04-18 20:33:18 +02:00
$linkback = " " ;
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " NewThirdParty " ), $linkback , 'title_companies.png' );
2010-09-07 12:24:26 +02:00
2012-07-28 12:35:11 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ))
2011-06-11 16:14:27 +02:00
{
2012-03-15 16:52:18 +01:00
print " \n " . '<script type="text/javascript">' ;
2011-12-15 12:28:31 +01:00
print ' $ ( document ) . ready ( function () {
2011-01-18 10:05:28 +01:00
id_te_private = 8 ;
id_ef15 = 1 ;
2012-11-15 16:26:05 +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 );
$ ( " #effectif_id " ) . val ( 0 );
$ ( " #TypeName " ) . html ( document . formsoc . ThirdPartyName . value );
document . formsoc . private . value = 0 ;
});
$ ( " #radioprivate " ) . click ( function () {
$ ( " .individualline " ) . show ();
$ ( " #typent_id " ) . val ( id_te_private );
$ ( " #effectif_id " ) . val ( id_ef15 );
$ ( " #TypeName " ) . html ( document . formsoc . LastName . value );
document . formsoc . private . value = 1 ;
});
$ ( " #selectcountry_id " ) . change ( function () {
document . formsoc . action . value = " create " ;
document . formsoc . submit ();
});
2010-09-07 12:24:26 +02:00
}); ' ;
2011-06-11 16:14:27 +02:00
print '</script>' . " \n " ;
2013-04-28 20:29:21 +02:00
print '<div id="selectthirdpartytype">' ;
2013-11-30 02:31:17 +01:00
print '<div class="hideonsmartphone float">' ;
print $langs -> trans ( " ThirdPartyType " ) . ': ' ;
print '</div>' ;
2018-02-15 12:57:04 +01:00
print '<label for="radiocompany" class="radiocompany">' ;
2015-05-07 11:39:26 +02:00
print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"' . ( $private ? '' : ' checked' ) . '>' ;
2014-07-11 19:57:51 +02:00
print ' ' ;
2016-09-09 18:41:42 +02:00
print $langs -> trans ( " CreateThirdPartyOnly " );
2014-07-11 19:57:51 +02:00
print '</label>' ;
2011-06-11 16:14:27 +02:00
print ' ' ;
2018-02-15 12:57:04 +01:00
print '<label for="radioprivate" class="radioprivate">' ;
2015-05-07 11:39:26 +02:00
$text = '<input type="radio" id="radioprivate" class="flat" name="private" value="1"' . ( $private ? ' checked' : '' ) . '>' ;
2014-12-08 00:29:33 +01:00
$text .= ' ' ;
2016-09-09 18:41:42 +02:00
$text .= $langs -> trans ( " CreateThirdPartyAndContact " );
2014-12-08 00:29:33 +01:00
$htmltext = $langs -> trans ( " ToCreateContactWithSameName " );
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $text , $htmltext , 1 , 'help' , '' , 0 , 3 );
2014-11-28 02:05:40 +01:00
print '</label>' ;
2013-04-28 20:29:21 +02:00
print '</div>' ;
2011-06-11 16:14:27 +02:00
print " <br> \n " ;
}
2010-09-07 12:24:26 +02:00
2013-02-18 12:57:14 +01:00
dol_htmloutput_mesg ( is_numeric ( $error ) ? '' : $error , $errors , 'error' );
2010-09-07 12:24:26 +02:00
2017-09-30 20:31:20 +02: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
2011-06-11 16:14:27 +02:00
print '<input type="hidden" name="action" value="add">' ;
2014-04-16 00:06:16 +02:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2011-06-11 16:14:27 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2011-07-02 16:12:44 +02:00
print '<input type="hidden" name="private" value=' . $object -> particulier . '>' ;
2017-10-09 10:43:19 +02:00
print '<input type="hidden" name="type" value=' . GETPOST ( " type " , 'alpha' ) . '>' ;
2017-01-08 12:10:07 +01:00
print '<input type="hidden" name="LastName" value="' . $langs -> trans ( 'ThirdPartyName' ) . ' / ' . $langs -> trans ( 'LastName' ) . '">' ;
2011-07-18 18:37:14 +02:00
print '<input type="hidden" name="ThirdPartyName" value="' . $langs -> trans ( 'ThirdPartyName' ) . '">' ;
2011-06-11 16:14:27 +02: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
2014-12-08 17:51:36 +01:00
dol_fiche_head ( null , 'card' , '' , 0 , '' );
2011-06-11 16:14:27 +02:00
print '<table class="border" width="100%">' ;
2010-09-07 12:24:26 +02:00
2011-06-11 16:14:27 +02:00
// Name, firstname
2016-04-01 16:15:07 +02:00
print '<tr><td class="titlefieldcreate">' ;
2012-11-15 16:26:05 +01:00
if ( $object -> particulier || $private )
2011-06-11 16:14:27 +02:00
{
2017-01-08 12:10:07 +01:00
print '<span id="TypeName" class="fieldrequired">' . $langs -> trans ( 'ThirdPartyName' ) . ' / ' . $langs -> trans ( 'LastName' , 'name' ) . '</span>' ;
2011-06-11 16:14:27 +02:00
}
else
2013-11-30 02:31:17 +01:00
{
2017-01-08 12:10:07 +01:00
print '<span id="TypeName" class="fieldrequired">' . fieldLabel ( 'ThirdPartyName' , 'name' ) . '</span>' ;
2011-06-11 16:14:27 +02:00
}
2014-07-11 20:04:18 +02:00
print '</td><td' . ( empty ( $conf -> global -> SOCIETE_USEPREFIX ) ? ' colspan="3"' : '' ) . '>' ;
2016-09-21 00:29:19 +02:00
print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="' . $object -> name . '" autofocus="autofocus"></td>' ;
2014-07-11 20:04:18 +02:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) // Old not used prefix field
{
print '<td>' . $langs -> trans ( 'Prefix' ) . '</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="' . $object -> prefix_comm . '"></td>' ;
}
print '</tr>' ;
2011-06-11 16:14:27 +02:00
// If javascript on, we show option individual
if ( $conf -> use_javascript_ajax )
{
2015-06-05 14:02:50 +02:00
print '<tr class="individualline"><td>' . fieldLabel ( 'FirstName' , 'firstname' ) . '</td>' ;
2016-11-05 03:27:56 +01:00
print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="' . $object -> firstname . '"></td>' ;
2016-05-24 20:24:51 +02:00
print '</tr>' ;
2016-11-05 03:27:56 +01:00
// Title
print '<tr class="individualline"><td>' . fieldLabel ( 'UserTitle' , 'civility_id' ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
print $formcompany -> select_civility ( $object -> civility_id , 'civility_id' , 'maxwidth100' ) . '</td>' ;
2016-05-24 20:24:51 +02:00
print '</tr>' ;
2011-06-11 16:14:27 +02:00
}
2016-02-29 10:35: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>' ;
2016-09-21 00:29:19 +02:00
print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="' . $object -> name_alias . '"></td></tr>' ;
2016-02-29 10:35:18 +01:00
2011-06-11 16:14:27 +02:00
// Prospect/Customer
2016-05-17 02:16:28 +02:00
print '<tr><td class="titlefieldcreate">' . fieldLabel ( 'ProspectCustomer' , 'customerprospect' , 1 ) . '</td>' ;
print '<td class="maxwidthonsmartphone">' ;
2017-09-12 16:51:10 +02:00
$selected = GETPOST ( 'client' , 'int' ) != '' ? GETPOST ( 'client' , 'int' ) : $object -> client ;
2016-04-30 14:59:40 +02:00
print '<select class="flat" name="client" id="customerprospect">' ;
2017-06-08 11:51:22 +02:00
if ( GETPOST ( " type " ) == '' ) print '<option value="-1"> </option>' ;
2015-05-07 12:20:20 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS )) print '<option value="2"' . ( $selected == 2 ? ' selected' : '' ) . '>' . $langs -> trans ( 'Prospect' ) . '</option>' ;
2016-11-22 20:24:42 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS ) && empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTSCUSTOMERS )) print '<option value="3"' . ( $selected == 3 ? ' selected' : '' ) . '>' . $langs -> trans ( 'ProspectCustomer' ) . '</option>' ;
2015-05-07 12:20:20 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="1"' . ( $selected == 1 ? ' selected' : '' ) . '>' . $langs -> trans ( 'Customer' ) . '</option>' ;
2015-10-16 15:05:05 +02:00
print '<option value="0"' . (( string ) $selected == '0' ? ' selected' : '' ) . '>' . $langs -> trans ( 'NorProspectNorCustomer' ) . '</option>' ;
2011-06-11 16:14:27 +02:00
print '</select></td>' ;
2016-09-21 00:29:19 +02:00
print '<td>' . fieldLabel ( 'CustomerCode' , 'customer_code' ) . '</td><td>' ;
2011-06-11 16:14:27 +02:00
print '<table class="nobordernopadding"><tr><td>' ;
2016-06-30 15:12:35 +02:00
$tmpcode = $object -> code_client ;
2014-02-19 01:51:19 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modCodeClient -> code_auto )) $tmpcode = $modCodeClient -> getNextValue ( $object , 0 );
2016-09-21 03:54:54 +02:00
print '<input type="text" name="code_client" id="customer_code" class="maxwidthonsmartphone" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="15">' ;
2011-06-11 16:14:27 +02:00
print '</td><td>' ;
2011-07-02 16:12:44 +02:00
$s = $modCodeClient -> getToolTip ( $langs , $object , 0 );
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( '' , $s , 1 );
2011-06-11 16:14:27 +02:00
print '</td></tr></table>' ;
print '</td></tr>' ;
2018-07-03 17:37:23 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
|| ( ! empty ( $conf -> supplier_proposal -> enabled ) && ! empty ( $user -> rights -> supplier_proposal -> lire )))
2011-06-11 16:14:27 +02:00
{
// Supplier
print '<tr>' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'Supplier' , 'fournisseur' , 1 ) . '</td><td>' ;
2016-04-30 14:59:40 +02:00
$default = - 1 ;
if ( ! empty ( $conf -> global -> THIRDPARTY_SUPPLIER_BY_DEFAULT )) $default = 1 ;
2017-09-12 16:51:10 +02:00
print $form -> selectyesno ( " fournisseur " , ( GETPOST ( 'fournisseur' , 'int' ) != '' ? GETPOST ( 'fournisseur' , 'int' ) : ( GETPOST ( " type " , 'alpha' ) == '' ? $default : $object -> fournisseur )), 1 , 0 , ( GETPOST ( " type " , 'alpha' ) == '' ? 1 : 0 ));
2011-06-11 16:14:27 +02:00
print '</td>' ;
2018-07-03 17:37:23 +02:00
print '<td>' ;
if ( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
{
print fieldLabel ( 'SupplierCode' , 'supplier_code' );
}
2011-06-11 16:14:27 +02:00
print '</td><td>' ;
2018-07-03 17:37:23 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
{
print '<table class="nobordernopadding"><tr><td>' ;
$tmpcode = $object -> code_fournisseur ;
if ( empty ( $tmpcode ) && ! empty ( $modCodeFournisseur -> code_auto )) $tmpcode = $modCodeFournisseur -> getNextValue ( $object , 1 );
print '<input type="text" name="code_fournisseur" id="supplier_code" class="maxwidthonsmartphone" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="15">' ;
print '</td><td>' ;
$s = $modCodeFournisseur -> getToolTip ( $langs , $object , 1 );
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
}
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
}
2010-09-07 12:24:26 +02:00
2011-05-06 00:19:21 +02:00
// Status
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Status' , 'status' ) . '</td><td colspan="3">' ;
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), 1 );
2011-05-06 00:19:21 +02:00
print '</td></tr>' ;
// Barcode
2012-09-09 16:31:00 +02:00
if ( ! empty ( $conf -> barcode -> enabled ))
2011-06-11 16:14:27 +02:00
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Gencod' , 'barcode' ) . '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="' . $object -> barcode . '">' ;
2011-08-19 00:25:46 +02:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
}
// Address
2015-06-05 14:02:50 +02:00
print '<tr><td class="tdtop">' . fieldLabel ( 'Address' , 'address' ) . '</td>' ;
2018-02-24 13:49:30 +01:00
print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="' . ROWS_2 . '" wrap="soft">' ;
2011-07-02 16:12:44 +02:00
print $object -> address ;
2011-06-11 16:14:27 +02:00
print '</textarea></td></tr>' ;
// Zip / Town
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Zip' , 'zipcode' ) . '</td><td>' ;
2016-11-05 03:27:56 +01:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 0 , 0 , '' , 'maxwidth100 quatrevingtpercent' );
2015-06-05 14:02:50 +02:00
print '</td><td>' . fieldLabel ( 'Town' , 'town' ) . '</td><td>' ;
2016-11-05 03:27:56 +01:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ), 0 , 0 , '' , 'maxwidth100 quatrevingtpercent' );
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
// Country
2016-09-21 00:29:19 +02:00
print '<tr><td>' . fieldLabel ( 'Country' , 'selectcountry_id' ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
2014-07-11 19:57:51 +02:00
print $form -> select_country (( GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $object -> country_id ));
2014-02-05 17:53:30 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
// State
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE ))
{
2018-01-25 19:30:20 +01:00
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 ))
{
print '<tr><td>' . fieldLabel ( 'Region-State' , 'state_id' ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
}
else
{
print '<tr><td>' . fieldLabel ( 'State' , 'state_id' ) . '</td><td colspan="3" class="maxwidthonsmartphone">' ;
}
2014-07-11 19:57:51 +02:00
if ( $object -> country_id ) print $formcompany -> select_state ( $object -> state_id , $object -> country_code );
2011-06-22 12:58:22 +02:00
else print $countrynotdefined ;
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
}
2013-04-28 01:12:40 +02:00
// Email web
2017-09-02 12:36:22 +02:00
print '<tr><td>' . fieldLabel ( 'EMail' , 'email' , $conf -> global -> SOCIETE_EMAIL_MANDATORY ) . '</td>' ;
2016-11-05 03:27:56 +01:00
print '<td colspan="3"><input type="text" name="email" id="email" value="' . $object -> email . '"></td></tr>' ;
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Web' , 'url' ) . '</td>' ;
2016-11-05 03:27:56 +01:00
print '<td colspan="3"><input type="text" name="url" id="url" value="' . $object -> url . '"></td></tr>' ;
2017-06-07 16:44:04 +02:00
2013-11-04 21:41:36 +01:00
// Skype
if ( ! empty ( $conf -> skype -> enabled ))
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Skype' , 'skype' ) . '</td>' ;
2016-11-05 03:27:56 +01:00
print '<td colspan="3"><input type="text" name="skype" id="skype" value="' . $object -> skype . '"></td></tr>' ;
2013-11-04 21:41:36 +01:00
}
2013-11-23 15:22:27 +01:00
2011-06-11 16:14:27 +02:00
// Phone / Fax
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Phone' , 'phone' ) . '</td>' ;
2016-09-21 00:29:19 +02:00
print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="' . $object -> phone . '"></td>' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'Fax' , 'fax' ) . '</td>' ;
2016-09-21 00:29:19 +02:00
print '<td><input type="text" name="fax" id="fax" class="maxwidth100onsmartphone quatrevingtpercent" value="' . $object -> fax . '"></td></tr>' ;
2011-06-11 16:14:27 +02:00
2012-04-05 20:33:40 +02:00
// Prof ids
$i = 1 ; $j = 0 ;
while ( $i <= 6 )
2011-06-11 16:14:27 +02:00
{
2012-04-05 20:33:40 +02:00
$idprof = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code );
if ( $idprof != '-' )
{
2014-07-12 12:04:39 +02:00
$key = 'idprof' . $i ;
2012-04-05 20:33:40 +02:00
if (( $j % 2 ) == 0 ) print '<tr>' ;
2013-01-26 10:35:30 +01:00
2012-11-30 21:23:12 +01:00
$idprof_mandatory = 'SOCIETE_IDPROF' . ( $i ) . '_MANDATORY' ;
2016-06-19 16:07:34 +02:00
print '<td>' . fieldLabel ( $idprof , $key , ( empty ( $conf -> global -> $idprof_mandatory ) ? 0 : 1 )) . '</td><td>' ;
2013-01-26 10:35:30 +01:00
2016-06-19 16:07:34 +02:00
print $formcompany -> get_input_id_prof ( $i , $key , $object -> $key , $object -> country_code );
2012-04-05 20:33:40 +02:00
print '</td>' ;
if (( $j % 2 ) == 1 ) print '</tr>' ;
$j ++ ;
}
$i ++ ;
2011-06-11 16:14:27 +02:00
}
2012-04-05 20:33:40 +02:00
if ( $j % 2 == 1 ) print '<td colspan="2"></td></tr>' ;
2011-06-11 16:14:27 +02:00
2016-10-24 12:42:37 +02:00
// Vat is used
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'VATIsUsed' , 'assujtva_value' ) . '</td>' ;
2011-06-11 16:14:27 +02:00
print '<td>' ;
2018-04-06 20:55:02 +02:00
print $form -> selectyesno ( 'assujtva_value' , GETPOSTISSET ( 'assujtva_value' ) ? GETPOST ( 'assujtva_value' , 'int' ) : 1 , 1 ); // Assujeti par defaut en creation
2011-06-11 16:14:27 +02:00
print '</td>' ;
2015-06-14 20:24:25 +02:00
print '<td class="nowrap">' . fieldLabel ( 'VATIntra' , 'intra_vat' ) . '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2016-09-21 03:54:54 +02:00
$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
2018-02-12 15:54:24 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ) && isInEEC ( $object ))
2011-06-11 16:14:27 +02:00
{
$s .= ' ' ;
2012-07-28 12:35:11 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ))
2011-06-11 16:14:27 +02:00
{
print " \n " ;
print '<script language="JavaScript" type="text/javascript">' ;
print " function CheckVAT(a) { \n " ;
2012-06-23 20:39:20 +02:00
print " newpopup(' " . DOL_URL_ROOT . " /societe/checkvat/checkVatPopup.php?vatNumber='+a,' " . dol_escape_js ( $langs -> trans ( " VATIntraCheckableOnEUSite " )) . " ',500,300); \n " ;
2011-06-11 16:14:27 +02:00
print " } \n " ;
print '</script>' ;
print " \n " ;
2013-04-24 03:56:13 +02:00
$s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
2016-03-25 15:24:57 +01:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> trans ( " VATIntraCheck " )), 1 );
2011-06-11 16:14:27 +02:00
}
else
{
2013-02-25 18:21:12 +01:00
$s .= '<a href="' . $langs -> transcountry ( " VATIntraCheckURL " , $object -> country_id ) . '" target="_blank">' . img_picto ( $langs -> trans ( " VATIntraCheckableOnEUSite " ), 'help' ) . '</a>' ;
2011-06-11 16:14:27 +02:00
}
}
print $s ;
print '</td>' ;
print '</tr>' ;
2016-10-29 21:47:10 +02:00
// Local Taxes
//TODO: Place into a function to control showing by country or study better option
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " )
{
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><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>' ;
2017-06-07 16:44:04 +02:00
2016-10-29 21:47:10 +02:00
}
elseif ( $mysoc -> localtax1_assuj == " 1 " )
{
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>' ;
}
elseif ( $mysoc -> localtax2_assuj == " 1 " )
{
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>' ;
}
2017-06-07 16:44:04 +02:00
2011-06-11 22:58:08 +02:00
// Type - Size
2016-06-19 16:07:34 +02:00
print '<tr><td>' . fieldLabel ( 'ThirdPartyType' , 'typent_id' ) . '</td><td class="maxwidthonsmartphone">' . " \n " ;
2016-02-19 21:09:36 +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.
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( " typent_id " , $formcompany -> typent_array ( 0 ), $object -> typent_id , 0 , 0 , 0 , '' , 0 , 0 , 0 , $sortparam );
2015-06-04 11:42:24 +02:00
if ( $user -> admin ) print ' ' . info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-06-11 22:58:08 +02:00
print '</td>' ;
2016-06-19 16:07:34 +02:00
print '<td>' . fieldLabel ( 'Staff' , 'effectif_id' ) . '</td><td class="maxwidthonsmartphone">' ;
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( " effectif_id " , $formcompany -> effectif_array ( 0 ), $object -> effectif_id );
2015-06-04 11:42:24 +02:00
if ( $user -> admin ) print ' ' . info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-06-11 22:58:08 +02:00
print '</td></tr>' ;
// Legal Form
2015-09-25 08:50:00 +02:00
print '<tr><td>' . fieldLabel ( 'JuridicalStatus' , 'forme_juridique_code' ) . '</td>' ;
2013-11-30 02:31:17 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2011-12-15 12:28:31 +01:00
if ( $object -> country_id )
2011-06-11 22:58:08 +02:00
{
2015-09-25 08:50:00 +02:00
print $formcompany -> select_juridicalstatus ( $object -> forme_juridique_code , $object -> country_code , '' , 'forme_juridique_code' );
2011-06-11 22:58:08 +02:00
}
else
{
print $countrynotdefined ;
}
print '</td></tr>' ;
// Capital
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Capital' , 'capital' ) . '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="' . $object -> capital . '"> ' ;
2013-04-24 03:56:13 +02:00
print '<span class="hideonsmartphone">' . $langs -> trans ( " Currency " . $conf -> currency ) . '</span></td></tr>' ;
2011-06-11 22:58:08 +02:00
2012-07-28 12:35:11 +02:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2011-06-11 22:58:08 +02:00
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'DefaultLang' , 'default_lang' ) . '</td><td colspan="3" class="maxwidthonsmartphone">' . " \n " ;
2016-09-21 03:54:54 +02:00
print $formadmin -> select_language (( $object -> default_lang ? $object -> default_lang : $conf -> global -> MAIN_LANG_DEFAULT ), 'default_lang' , 0 , 0 , 1 , 0 , 0 , 'maxwidth200onsmartphone' );
2011-06-11 22:58:08 +02:00
print '</td>' ;
print '</tr>' ;
}
2018-09-21 10:14:23 +02:00
// Assign a Name
print '<tr>' ;
print '<td>' . fieldLabel ( 'AllocateCommercial' , 'commercial_id' ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
$userlist = $form -> select_dolusers ( '' , '' , 0 , null , 0 , '' , '' , 0 , 0 , 0 , '' , 0 , '' , '' , 0 , 1 );
2018-09-21 10:18:54 +02:00
print $form -> multiselectarray ( 'commercial' , $userlist , ( count ( GETPOST ( 'commercial' , 'array' )) > 0 ? GETPOST ( 'commercial' , 'array' ) : ( empty ( $user -> rights -> societe -> client -> voir ) ? array ( $user -> id ) : array ())), null , null , null , null , " 90% " );
2018-09-21 10:14:23 +02:00
print '</td></tr>' ;
2015-03-14 13:05:28 +01:00
2015-02-09 17:55:43 +01:00
// Incoterms
2015-02-10 12:21:29 +01:00
if ( ! empty ( $conf -> incoterm -> enabled ))
2015-02-09 17:55:43 +01:00
{
print '<tr>' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'IncotermLabel' , 'incoterm_id' ) . '</td>' ;
2015-02-09 17:55:43 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2015-02-10 10:22:38 +01:00
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
2015-08-26 19:30:40 +02:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! 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
2018-05-03 09:26:48 +02:00
if ( $object -> prospect || $object -> client || ( ! $object -> fournisseur && ! empty ( $conf -> global -> THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER ))) {
2015-08-26 19:30:40 +02:00
print '<tr><td class="toptd">' . fieldLabel ( 'CustomersCategoriesShort' , 'custcats' ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_CUSTOMER , null , 'parent' , null , null , 1 );
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'custcats' , $cate_arbo , GETPOST ( 'custcats' , 'array' ), null , null , null ,
2015-08-26 19:30:40 +02:00
null , " 90% " );
print " </td></tr> " ;
}
// Supplier
if ( $object -> fournisseur ) {
print '<tr><td class="toptd">' . fieldLabel ( 'SuppliersCategoriesShort' , 'suppcats' ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_SUPPLIER , null , 'parent' , null , null , 1 );
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'suppcats' , $cate_arbo , GETPOST ( 'suppcats' , 'array' ), null , null , null ,
2015-08-26 19:30:40 +02:00
null , " 90% " );
print " </td></tr> " ;
}
}
2015-06-05 14:02:50 +02:00
2016-01-18 19:45:27 +01:00
// Multicurrency
if ( ! empty ( $conf -> multicurrency -> enabled ))
{
print '<tr>' ;
print '<td>' . fieldLabel ( 'Currency' , 'multicurrency_code' ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
print $form -> selectMultiCurrency (( $object -> multicurrency_code ? $object -> multicurrency_code : $conf -> currency ), 'multicurrency_code' , 1 );
print '</td></tr>' ;
}
2011-06-22 13:41:37 +02:00
// Other attributes
2012-11-03 16:58:50 +01:00
$parameters = array ( 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' );
2012-02-06 17:18:19 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2015-07-18 17:35:36 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2011-06-22 12:58:22 +02:00
{
2013-04-01 19:43:26 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
2011-06-22 12:58:22 +02:00
}
2011-06-11 16:14:27 +02:00
// Ajout du logo
2013-04-24 03:56:13 +02:00
print '<tr class="hideonsmartphone">' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'Logo' , 'photoinput' ) . '</td>' ;
2011-06-11 16:14:27 +02:00
print '<td colspan="3">' ;
2011-06-11 22:58:08 +02:00
print '<input class="flat" type="file" name="photo" id="photoinput" />' ;
2011-06-11 16:14:27 +02:00
print '</td>' ;
print '</tr>' ;
2011-08-13 02:47:59 +02:00
print '</table>' . " \n " ;
2014-12-08 17:51:36 +01:00
dol_fiche_end ();
print '<div class="center">' ;
2016-02-22 14:33:14 +01:00
print '<input type="submit" class="button" name="create" value="' . $langs -> trans ( 'AddThirdParty' ) . '">' ;
2017-02-01 13:25:16 +01:00
if ( ! empty ( $backtopage ))
2015-09-29 14:31:55 +02:00
{
2017-02-01 13:25:16 +01:00
print ' ' ;
2015-09-29 14:31:55 +02:00
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( 'Cancel' ) . '">' ;
}
2017-02-01 13:25:16 +01:00
else
{
print ' ' ;
print '<input type="button" class="button" value="' . $langs -> trans ( " Cancel " ) . '" onClick="javascript:history.go(-1)">' ;
}
2014-11-24 06:43:15 +01:00
print '</div>' . " \n " ;
2011-06-11 16:14:27 +02:00
print '</form>' . " \n " ;
}
elseif ( $action == 'edit' )
{
/*
* Edition
*/
2012-04-05 20:33:40 +02:00
2017-09-03 17:47:45 +02:00
2015-09-24 18:33:48 +02:00
//print load_fiche_titre($langs->trans("EditCompany"));
2011-06-11 16:14:27 +02:00
if ( $socid )
{
2018-02-21 14:48:25 +01:00
$res = $object -> fetch_optionals ();
2011-08-09 11:13:08 +02:00
//if ($res < 0) { dol_print_error($db); exit; }
2011-06-22 12:58:22 +02:00
2012-03-26 18:23:08 +02:00
$head = societe_prepare_head ( $object );
2012-04-05 20:33:40 +02:00
2011-06-11 16:14:27 +02:00
// Load object modCodeTiers
2012-08-15 09:06:36 +02:00
$module = ( ! empty ( $conf -> global -> SOCIETE_CODECLIENT_ADDON ) ? $conf -> global -> SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard' );
2011-06-11 16:14:27 +02:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' )
{
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
2013-01-07 13:28:14 +01:00
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2012-03-01 00:03:16 +01:00
foreach ( $dirsociete as $dirroot )
{
2012-08-23 02:04:35 +02:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2012-03-01 00:03:16 +01:00
if ( $res ) break ;
}
2012-09-02 22:31:25 +02:00
$modCodeClient = new $module ( $db );
2011-06-11 16:14:27 +02:00
// We verified if the tag prefix is used
if ( $modCodeClient -> code_auto )
{
$prefixCustomerIsUsed = $modCodeClient -> verif_prefixIsUsed ();
}
2013-04-11 20:32:09 +02:00
$module = $conf -> global -> SOCIETE_CODECLIENT_ADDON ;
2011-06-11 16:14:27 +02:00
if ( substr ( $module , 0 , 15 ) == 'mod_codeclient_' && substr ( $module , - 3 ) == 'php' )
{
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
2013-01-07 13:28:14 +01:00
$dirsociete = array_merge ( array ( '/core/modules/societe/' ), $conf -> modules_parts [ 'societe' ]);
2012-03-01 00:03:16 +01:00
foreach ( $dirsociete as $dirroot )
{
2012-08-23 02:04:35 +02:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2012-03-01 00:03:16 +01:00
if ( $res ) break ;
}
2012-09-02 22:31:25 +02:00
$modCodeFournisseur = new $module ( $db );
2011-06-11 16:14:27 +02:00
// On verifie si la balise prefix est utilisee
if ( $modCodeFournisseur -> code_auto )
{
$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
2017-10-09 10:43:19 +02:00
if ( GETPOSTISSET ( 'name' ))
2011-06-25 21:55:36 +02:00
{
// We overwrite with values if posted
2015-06-05 14:02:50 +02:00
$object -> name = GETPOST ( 'name' , 'alpha' );
2014-10-18 00:41:21 +02:00
$object -> prefix_comm = GETPOST ( 'prefix_comm' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> client = GETPOST ( 'client' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> code_client = GETPOST ( 'code_client' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> fournisseur = GETPOST ( 'fournisseur' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> code_fournisseur = GETPOST ( 'code_fournisseur' , 'alpha' );
$object -> address = GETPOST ( 'address' , 'alpha' );
$object -> zip = GETPOST ( 'zipcode' , 'alpha' );
$object -> town = GETPOST ( 'town' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> country_id = GETPOST ( 'country_id' ) ? GETPOST ( 'country_id' , 'int' ) : $mysoc -> country_id ;
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> skype = GETPOST ( 'skype' , 'alpha' );
$object -> phone = GETPOST ( 'phone' , 'alpha' );
$object -> fax = GETPOST ( 'fax' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> email = GETPOST ( 'email' , 'custom' , 0 , FILTER_SANITIZE_EMAIL );
$object -> url = GETPOST ( 'url' , 'custom' , 0 , FILTER_SANITIZE_URL );
2015-10-14 23:50:36 +02:00
$object -> capital = GETPOST ( 'capital' , 'alpha' );
2014-10-18 00:41:21 +02:00
$object -> idprof1 = GETPOST ( 'idprof1' , 'alpha' );
$object -> idprof2 = GETPOST ( 'idprof2' , 'alpha' );
$object -> idprof3 = GETPOST ( 'idprof3' , 'alpha' );
$object -> idprof4 = GETPOST ( 'idprof4' , 'alpha' );
2015-01-23 00:55:24 +01:00
$object -> idprof5 = GETPOST ( 'idprof5' , 'alpha' );
$object -> idprof6 = GETPOST ( 'idprof6' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> typent_id = GETPOST ( 'typent_id' , 'int' );
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> barcode = GETPOST ( 'barcode' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> default_lang = GETPOST ( 'default_lang' , 'alpha' );
2014-09-15 22:58:39 +02:00
2014-08-06 15:59:36 +02:00
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'int' );
2014-10-18 00:41:21 +02:00
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alpha' );
2014-08-06 15:59:36 +02:00
$object -> status = GETPOST ( 'status' , 'int' );
2010-09-07 12:24:26 +02:00
2014-10-31 17:46:11 +01:00
// Webservices url/key
$object -> webservices_url = GETPOST ( 'webservices_url' , 'custom' , 0 , FILTER_SANITIZE_URL );
$object -> webservices_key = GETPOST ( 'webservices_key' , 'san_alpha' );
2015-02-09 17:55:43 +01:00
//Incoterms
2015-02-10 12:21:29 +01:00
if ( ! empty ( $conf -> incoterm -> enabled ))
2015-03-14 13:05:28 +01:00
{
2015-02-09 17:55:43 +01:00
$object -> fk_incoterms = GETPOST ( 'incoterm_id' , 'int' );
$object -> location_incoterms = GETPOST ( 'lcoation_incoterms' , 'alpha' );
}
2015-03-14 13:05:28 +01:00
2011-06-11 16:14:27 +02:00
//Local Taxes
2012-07-28 12:35:11 +02:00
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' );
2014-07-04 14:25:08 +02:00
2014-07-03 18:47:06 +02:00
$object -> localtax1_value = GETPOST ( 'lt1' );
$object -> localtax2_value = GETPOST ( 'lt2' );
2011-06-11 16:14:27 +02:00
2013-02-25 09:52:24 +01:00
// We set country_id, and country_code label of the chosen country
2013-05-02 17:41:10 +02:00
if ( $object -> country_id > 0 )
2011-06-11 16:14:27 +02:00
{
2013-05-02 17:41:10 +02:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
2011-06-11 16:14:27 +02:00
}
2011-06-25 21:55:36 +02:00
}
2011-06-11 16:14:27 +02:00
2014-07-03 18:47:06 +02:00
if ( $object -> localtax1_assuj == 0 ){
$sub = 0 ;
} else { $sub = 1 ;}
if ( $object -> localtax2_assuj == 0 ){
$sub2 = 0 ;
} else { $sub2 = 1 ;}
2014-07-04 14:25:08 +02:00
2014-07-03 18:47:06 +02:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
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
2014-07-03 18:47:06 +02:00
}); ' ;
print '</script>' . " \n " ;
2014-07-04 14:25:08 +02:00
2011-06-11 16:14:27 +02:00
if ( $conf -> use_javascript_ajax )
{
print " \n " . '<script type="text/javascript" language="javascript">' ;
2011-12-15 12:28:31 +01:00
print ' $ ( document ) . ready ( function () {
$ ( " #selectcountry_id " ) . change ( function () {
document . formsoc . action . value = " edit " ;
document . formsoc . submit ();
});
2010-09-02 21:41:49 +02:00
}) ' ;
2011-06-11 16:14:27 +02:00
print '</script>' . " \n " ;
}
2010-09-07 12:24:26 +02:00
2011-07-02 16:12:44 +02:00
print '<form enctype="multipart/form-data" action="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '" method="post" name="formsoc">' ;
2011-06-11 16:14:27 +02:00
print '<input type="hidden" name="action" value="update">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2011-07-02 16:12:44 +02:00
print '<input type="hidden" name="socid" value="' . $object -> id . '">' ;
2018-04-01 13:45:39 +02:00
print '<input type="hidden" name="entity" value="' . $object -> entity . '">' ;
2011-06-11 16:14:27 +02: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
2017-03-15 11:13:30 +01:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " ThirdParty " ), 0 , 'company' );
2015-06-18 19:33:29 +02:00
2017-06-07 16:44:04 +02:00
print '<div class="fichecenter2">' ;
2011-06-11 16:14:27 +02:00
print '<table class="border" width="100%">' ;
2010-09-07 12:24:26 +02:00
2015-10-11 12:27:04 +02:00
// Ref/ID
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID ))
{
2017-03-11 12:04:28 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ID " ) . '</td><td colspan="3">' ;
2015-10-11 12:27:04 +02:00
print $object -> ref ;
print '</td></tr>' ;
}
2016-06-30 15:49:57 +02:00
2011-06-11 16:14:27 +02:00
// Name
2017-03-11 12:04:28 +01:00
print '<tr><td class="titlefieldcreate">' . fieldLabel ( 'ThirdPartyName' , 'name' , 1 ) . '</td>' ;
2016-09-21 03:54:54 +02:00
print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="' . dol_escape_htmltag ( $object -> name ) . '" autofocus="autofocus"></td></tr>' ;
2010-09-07 12:24:26 +02:00
2015-06-16 12:04:11 +02:00
// Alias names (commercial, trademark or alias names)
print '<tr id="name_alias"><td><label for="name_alias_input">' . $langs -> trans ( 'AliasNames' ) . '</label></td>' ;
2016-09-21 03:54:54 +02:00
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
2011-06-11 16:14:27 +02:00
// Prefix
2011-01-29 17:25:01 +01:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) // Old not used prefix field
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Prefix' , 'prefix' ) . '</td><td colspan="3">' ;
2011-06-11 16:14:27 +02:00
// It does not change the prefix mode using the auto numbering prefix
2011-07-02 16:12:44 +02:00
if (( $prefixCustomerIsUsed || $prefixSupplierIsUsed ) && $object -> prefix_comm )
2011-06-11 16:14:27 +02:00
{
2012-11-26 16:06:50 +01:00
print '<input type="hidden" name="prefix_comm" value="' . dol_escape_htmltag ( $object -> prefix_comm ) . '">' ;
2011-07-02 16:12:44 +02:00
print $object -> prefix_comm ;
2011-06-11 16:14:27 +02:00
}
else
{
2014-07-11 19:57:51 +02:00
print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="' . dol_escape_htmltag ( $object -> prefix_comm ) . '">' ;
2011-06-11 16:14:27 +02:00
}
print '</td>' ;
}
// Prospect/Customer
2016-05-17 02:16:28 +02:00
print '<tr><td>' . fieldLabel ( 'ProspectCustomer' , 'customerprospect' , 1 ) . '</td>' ;
2016-08-31 16:14:31 +02:00
print '<td class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">' ;
2015-05-07 12:20:20 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS )) print '<option value="2"' . ( $object -> client == 2 ? ' selected' : '' ) . '>' . $langs -> trans ( 'Prospect' ) . '</option>' ;
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="3"' . ( $object -> client == 3 ? ' selected' : '' ) . '>' . $langs -> trans ( 'ProspectCustomer' ) . '</option>' ;
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="1"' . ( $object -> client == 1 ? ' selected' : '' ) . '>' . $langs -> trans ( 'Customer' ) . '</option>' ;
print '<option value="0"' . ( $object -> client == 0 ? ' selected' : '' ) . '>' . $langs -> trans ( 'NorProspectNorCustomer' ) . '</option>' ;
2011-06-11 16:14:27 +02:00
print '</select></td>' ;
2016-09-21 00:29:19 +02:00
print '<td>' . fieldLabel ( 'CustomerCode' , 'customer_code' ) . '</td><td>' ;
2011-06-11 16:14:27 +02:00
print '<table class="nobordernopadding"><tr><td>' ;
2011-07-02 16:12:44 +02:00
if (( ! $object -> code_client || $object -> code_client == - 1 ) && $modCodeClient -> code_auto )
2011-06-11 16:14:27 +02:00
{
2011-07-02 16:12:44 +02:00
$tmpcode = $object -> code_client ;
2014-08-05 18:28:06 +02: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.
2014-02-19 01:51:19 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modCodeClient -> code_auto )) $tmpcode = $modCodeClient -> getNextValue ( $object , 0 );
2014-07-11 19:57:51 +02:00
print '<input type="text" name="code_client" id="customer_code" size="16" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="15">' ;
2011-06-11 16:14:27 +02:00
}
2011-07-02 16:12:44 +02:00
else if ( $object -> codeclient_modifiable ())
2011-06-11 16:14:27 +02:00
{
2018-03-15 01:21:44 +01:00
print '<input type="text" name="code_client" id="customer_code" size="16" value="' . dol_escape_htmltag ( $object -> code_client ) . '" maxlength="15">' ;
2011-06-11 16:14:27 +02:00
}
else
{
2011-07-02 16:12:44 +02:00
print $object -> code_client ;
2018-03-15 01:21:44 +01:00
print '<input type="hidden" name="code_client" value="' . dol_escape_htmltag ( $object -> code_client ) . '">' ;
2011-06-11 16:14:27 +02:00
}
print '</td><td>' ;
2011-07-02 16:12:44 +02:00
$s = $modCodeClient -> getToolTip ( $langs , $object , 0 );
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( '' , $s , 1 );
2011-06-11 16:14:27 +02:00
print '</td></tr></table>' ;
print '</td></tr>' ;
// Supplier
2018-07-03 17:37:23 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
|| ( ! empty ( $conf -> supplier_proposal -> enabled ) && ! empty ( $user -> rights -> supplier_proposal -> lire )))
2011-06-11 16:14:27 +02:00
{
print '<tr>' ;
2016-08-31 16:14:31 +02:00
print '<td>' . fieldLabel ( 'Supplier' , 'fournisseur' , 1 ) . '</td><td class="maxwidthonsmartphone">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( " fournisseur " , $object -> fournisseur , 1 );
2011-06-11 16:14:27 +02:00
print '</td>' ;
2018-07-03 17:37:23 +02:00
print '<td>' ;
if ( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
2011-06-11 16:14:27 +02:00
{
2018-07-03 17:37:23 +02:00
print fieldLabel ( 'SupplierCode' , 'supplier_code' );
2011-06-11 16:14:27 +02:00
}
2018-07-03 17:37:23 +02:00
print '</td><td>' ;
if ( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
2011-06-11 16:14:27 +02:00
{
2018-07-03 17:37:23 +02:00
print '<table class="nobordernopadding"><tr><td>' ;
if (( ! $object -> code_fournisseur || $object -> code_fournisseur == - 1 ) && $modCodeFournisseur -> code_auto )
{
$tmpcode = $object -> code_fournisseur ;
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 );
print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="' . dol_escape_htmltag ( $tmpcode ) . '" maxlength="15">' ;
}
else if ( $object -> codefournisseur_modifiable ())
{
print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="' . $object -> code_fournisseur . '" maxlength="15">' ;
}
else
{
print $object -> code_fournisseur ;
print '<input type="hidden" name="code_fournisseur" value="' . $object -> code_fournisseur . '">' ;
}
print '</td><td>' ;
$s = $modCodeFournisseur -> getToolTip ( $langs , $object , 1 );
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
2011-06-11 16:14:27 +02:00
}
print '</td></tr>' ;
2011-01-29 17:25:01 +01:00
}
2010-09-07 12:24:26 +02:00
2011-05-06 00:19:21 +02:00
// Barcode
2012-09-09 16:31:00 +02:00
if ( ! empty ( $conf -> barcode -> enabled ))
2011-06-11 16:14:27 +02:00
{
2015-06-05 14:02:50 +02:00
print '<tr><td class="tdtop">' . fieldLabel ( 'Gencod' , 'barcode' ) . '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="' . $object -> barcode . '">' ;
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
}
2010-09-07 12:24:26 +02:00
2011-12-07 15:06:29 +01:00
// Status
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Status' , 'status' ) . '</td><td colspan="3">' ;
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), $object -> status );
2011-12-07 15:06:29 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
// Address
2015-06-05 14:02:50 +02:00
print '<tr><td class="tdtop">' . fieldLabel ( 'Address' , 'address' ) . '</td>' ;
2016-06-19 16:07:34 +02:00
print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
2011-07-02 16:12:44 +02:00
print $object -> address ;
2011-06-11 16:14:27 +02:00
print '</textarea></td></tr>' ;
// Zip / Town
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Zip' , 'zipcode' ) . '</td><td>' ;
2017-03-31 14:21:51 +02:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 0 , 0 , '' , 'maxwidth50onsmartphone' );
2015-06-05 14:02:50 +02:00
print '</td><td>' . fieldLabel ( 'Town' , 'town' ) . '</td><td>' ;
2015-06-20 17:24:34 +02:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
// Country
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Country' , 'selectcounty_id' ) . '</td><td colspan="3">' ;
2013-10-15 20:51:44 +02:00
print $form -> select_country (( GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $object -> country_id ), 'country_id' );
2014-02-05 17:53:30 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
// State
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE ))
{
2018-01-25 19:30:20 +01:00
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 ))
{
print '<tr><td>' . fieldLabel ( 'Region-State' , 'state_id' ) . '</td><td colspan="3">' ;
}
else
{
print '<tr><td>' . fieldLabel ( 'State' , 'state_id' ) . '</td><td colspan="3">' ;
}
2012-03-15 22:37:42 +01:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code );
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
}
2013-04-28 01:12:40 +02:00
// EMail / Web
2017-09-02 12:36:22 +02:00
print '<tr><td>' . fieldLabel ( 'EMail' , 'email' ,( ! empty ( $conf -> global -> SOCIETE_EMAIL_MANDATORY ))) . '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td colspan="3"><input type="text" name="email" id="email" size="32" value="' . $object -> email . '"></td></tr>' ;
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Web' , 'url' ) . '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="' . $object -> url . '"></td></tr>' ;
2013-11-23 15:22:27 +01:00
2013-11-04 21:41:36 +01:00
// Skype
if ( ! empty ( $conf -> skype -> enabled ))
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Skype' , 'skype' ) . '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td colspan="3"><input type="text" name="skype" id="skype" size="32" value="' . $object -> skype . '"></td></tr>' ;
2013-11-04 21:41:36 +01:00
}
2013-11-23 15:22:27 +01:00
2011-06-11 16:14:27 +02:00
// Phone / Fax
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Phone' , 'phone' ) . '</td>' ;
2016-09-21 00:29:19 +02:00
print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="' . $object -> phone . '"></td>' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'Fax' , 'fax' ) . '</td>' ;
2016-09-21 00:29:19 +02:00
print '<td><input type="text" name="fax" id="fax" class="maxwidth100onsmartphone quatrevingtpercent" value="' . $object -> fax . '"></td></tr>' ;
2011-06-11 16:14:27 +02:00
2012-04-05 20:33:40 +02:00
// Prof ids
$i = 1 ; $j = 0 ;
while ( $i <= 6 )
2011-06-11 16:14:27 +02:00
{
2012-04-05 20:33:40 +02:00
$idprof = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code );
if ( $idprof != '-' )
{
2014-07-12 12:04:39 +02:00
$key = 'idprof' . $i ;
if (( $j % 2 ) == 0 ) print '<tr>' ;
2013-01-26 10:35:30 +01:00
2014-07-12 12:04:39 +02:00
$idprof_mandatory = 'SOCIETE_IDPROF' . ( $i ) . '_MANDATORY' ;
2017-09-02 12:36:22 +02:00
if ( empty ( $conf -> global -> $idprof_mandatory ) || ! $object -> isACompany ())
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( $idprof , $key ) . '</td><td>' ;
2014-07-12 12:04:39 +02:00
else
2015-06-05 14:02:50 +02:00
print '<td><span class="fieldrequired">' . fieldLabel ( $idprof , $key ) . '</td><td>' ;
2013-01-26 10:35:30 +01:00
2014-07-12 12:04:39 +02:00
print $formcompany -> get_input_id_prof ( $i , $key , $object -> $key , $object -> country_code );
2012-04-05 20:33:40 +02:00
print '</td>' ;
if (( $j % 2 ) == 1 ) print '</tr>' ;
$j ++ ;
}
$i ++ ;
2011-06-11 16:14:27 +02:00
}
2012-04-05 20:33:40 +02:00
if ( $j % 2 == 1 ) print '<td colspan="2"></td></tr>' ;
2011-06-11 16:14:27 +02:00
2016-10-24 12:42:37 +02:00
// VAT is used
print '<tr><td>' . fieldLabel ( 'VATIsUsed' , 'assujtva_value' ) . '</td><td colspan="3">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( 'assujtva_value' , $object -> tva_assuj , 1 );
2016-12-10 22:58:55 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
// Local Taxes
2013-01-05 16:03:00 +01:00
//TODO: Place into a function to control showing by country or study better option
2016-10-24 12:42:37 +02:00
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " )
2011-06-11 16:14:27 +02:00
{
2017-05-02 21:27:56 +02:00
print '<tr><td>' . fieldLabel ( $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ), 'localtax1assuj_value' ) . '</td><td>' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( 'localtax1assuj_value' , $object -> localtax1_assuj , 1 );
2014-07-03 18:47:06 +02:00
if ( ! isOnlyOneLocalTax ( 1 ))
{
2016-10-24 12:42:37 +02:00
print '<span class="cblt1"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '</span>' ;
2014-07-03 18:47:06 +02:00
}
2017-06-16 01:02:53 +02:00
print '</td>' ;
2017-06-07 16:44:04 +02:00
2017-06-16 01:02:53 +02:00
print '<td>' . fieldLabel ( $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ), 'localtax2assuj_value' ) . '</td><td>' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( 'localtax2assuj_value' , $object -> localtax2_assuj , 1 );
2016-10-24 12:42:37 +02:00
if ( ! isOnlyOneLocalTax ( 2 ))
{
print '<span class="cblt2"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '</span>' ;
2014-07-03 18:47:06 +02:00
}
2012-11-27 13:05:21 +01:00
print '</td></tr>' ;
2017-06-07 16:44:04 +02:00
2012-11-27 13:05:21 +01:00
}
2014-07-03 18:47:06 +02:00
elseif ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj != " 1 " )
2012-11-27 13:05:21 +01:00
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ), 'localtax1assuj_value' ) . '</td><td colspan="3">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( 'localtax1assuj_value' , $object -> localtax1_assuj , 1 );
2014-07-03 18:47:06 +02:00
if ( ! isOnlyOneLocalTax ( 1 ))
{
2016-10-24 12:42:37 +02:00
print '<span class="cblt1"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '</span>' ;
2014-07-03 18:47:06 +02:00
}
2012-11-27 13:05:21 +01:00
print '</td></tr>' ;
2017-06-07 16:44:04 +02:00
2012-11-27 13:05:21 +01:00
}
2014-07-03 18:47:06 +02:00
elseif ( $mysoc -> localtax2_assuj == " 1 " && $mysoc -> localtax1_assuj != " 1 " )
2012-11-27 13:05:21 +01:00
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ), 'localtax2assuj_value' ) . '</td><td colspan="3">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( 'localtax2assuj_value' , $object -> localtax2_assuj , 1 );
2014-07-03 18:47:06 +02:00
if ( ! isOnlyOneLocalTax ( 2 ))
{
2016-10-24 12:42:37 +02:00
print '<span class="cblt2"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '</span>' ;
2014-07-03 18:47:06 +02:00
}
2012-11-27 13:05:21 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
}
2017-06-07 16:44:04 +02:00
2016-10-24 12:42:37 +02:00
// VAT Code
2016-12-10 22:58:55 +01:00
print '<tr><td>' . fieldLabel ( 'VATIntra' , 'intra_vat' ) . '</td>' ;
2016-10-24 12:42:37 +02:00
print '<td colspan="3">' ;
$s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="' . $object -> tva_intra . '">' ;
2018-02-12 15:54:24 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ) && isInEEC ( $object ))
2016-10-24 12:42:37 +02:00
{
$s .= ' ' ;
if ( $conf -> use_javascript_ajax )
{
print " \n " ;
print '<script language="JavaScript" type="text/javascript">' ;
print " function CheckVAT(a) { \n " ;
print " newpopup(' " . DOL_URL_ROOT . " /societe/checkvat/checkVatPopup.php?vatNumber='+a,' " . dol_escape_js ( $langs -> trans ( " VATIntraCheckableOnEUSite " )) . " ',500,285); \n " ;
print " } \n " ;
print '</script>' ;
print " \n " ;
$s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> trans ( " VATIntraCheck " )), 1 );
}
else
{
$s .= '<a href="' . $langs -> transcountry ( " VATIntraCheckURL " , $object -> country_id ) . '" class="hideonsmartphone" target="_blank">' . img_picto ( $langs -> trans ( " VATIntraCheckableOnEUSite " ), 'help' ) . '</a>' ;
}
}
print $s ;
print '</td>' ;
print '</tr>' ;
2013-01-26 10:35:30 +01:00
2011-06-11 22:58:08 +02:00
// Type - Size
2016-06-19 16:07:34 +02:00
print '<tr><td>' . fieldLabel ( 'ThirdPartyType' , 'typent_id' ) . '</td><td class="maxwidthonsmartphone">' ;
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( " typent_id " , $formcompany -> typent_array ( 0 ), $object -> typent_id , 0 , 0 , 0 , '' , 0 , 0 , 0 , ( empty ( $conf -> global -> SOCIETE_SORT_ON_TYPEENT ) ? 'ASC' : $conf -> global -> SOCIETE_SORT_ON_TYPEENT ));
2014-02-05 17:53:30 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-06-11 16:14:27 +02:00
print '</td>' ;
2016-06-19 16:07:34 +02:00
print '<td>' . fieldLabel ( 'Staff' , 'effectif_id' ) . '</td><td class="maxwidthonsmartphone">' ;
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( " effectif_id " , $formcompany -> effectif_array ( 0 ), $object -> effectif_id );
2014-02-05 17:53:30 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
2015-04-01 21:00:51 +02:00
// Juridical type
2016-08-31 16:09:56 +02:00
print '<tr><td>' . fieldLabel ( 'JuridicalStatus' , 'forme_juridique_code' ) . '</td><td class="maxwidthonsmartphone" colspan="3">' ;
2015-09-25 08:50:00 +02:00
print $formcompany -> select_juridicalstatus ( $object -> forme_juridique_code , $object -> country_code , '' , 'forme_juridique_code' );
2011-06-11 22:58:08 +02:00
print '</td></tr>' ;
// Capital
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'Capital' , 'capital' ) . '</td>' ;
2018-04-30 11:01:33 +02:00
print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="' ;
2018-09-12 15:21:11 +02:00
print $object -> capital != '' ? dol_escape_htmltag ( price ( $object -> capital )) : '' ;
2018-04-30 11:01:33 +02:00
print '"> <font class="hideonsmartphone">' . $langs -> trans ( " Currency " . $conf -> currency ) . '</font></td></tr>' ;
2018-03-22 16:05:50 +01:00
2018-03-09 18:59:06 +01:00
// Assign a Name
print '<tr>' ;
print '<td>' . fieldLabel ( 'AllocateCommercial' , 'commercial_id' ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
$userlist = $form -> select_dolusers ( '' , '' , 0 , null , 0 , '' , '' , 0 , 0 , 0 , '' , 0 , '' , '' , 0 , 1 );
$arrayselected = GETPOST ( 'commercial' , 'array' );
2018-03-22 16:05:50 +01:00
if ( empty ( $arrayselected )) $arrayselected = $object -> getSalesRepresentatives ( $user , 1 );
2018-03-09 18:59:06 +01:00
print $form -> multiselectarray ( 'commercial' , $userlist , $arrayselected , null , null , null , null , " 90% " );
print '</td></tr>' ;
2011-06-11 22:58:08 +02:00
2011-06-11 16:14:27 +02:00
// Default language
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2011-06-11 16:14:27 +02:00
{
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'DefaultLang' , 'default_lang' ) . '</td><td colspan="3">' . " \n " ;
2011-07-02 16:12:44 +02:00
print $formadmin -> select_language ( $object -> default_lang , 'default_lang' , 0 , 0 , 1 );
2011-06-11 16:14:27 +02:00
print '</td>' ;
print '</tr>' ;
}
2013-04-03 15:20:56 +02:00
2015-05-29 18:49:10 +02:00
// Categories
2015-08-26 19:30:40 +02:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
{
// Customer
2018-05-03 09:26:48 +02:00
if ( $object -> prospect || $object -> client || ( ! $object -> fournisseur && ! empty ( $conf -> global -> THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER ))) {
2015-08-26 19:30:40 +02:00
print '<tr><td>' . fieldLabel ( 'CustomersCategoriesShort' , 'custcats' ) . '</td>' ;
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 );
2018-02-04 14:34:31 +01:00
$arrayselected = array ();
2015-08-26 19:30:40 +02:00
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'custcats' , $cate_arbo , $arrayselected , '' , 0 , '' , 0 , '90%' );
2015-08-26 19:30:40 +02:00
print " </td></tr> " ;
2015-06-05 09:57:41 +02:00
}
2015-08-26 19:30:40 +02:00
// Supplier
if ( $object -> fournisseur ) {
print '<tr><td>' . fieldLabel ( 'SuppliersCategoriesShort' , 'suppcats' ) . '</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 );
2018-02-04 14:34:31 +01:00
$arrayselected = array ();
2015-08-26 19:30:40 +02:00
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'suppcats' , $cate_arbo , $arrayselected , '' , 0 , '' , 0 , '90%' );
2015-08-26 19:30:40 +02:00
print " </td></tr> " ;
}
}
2015-06-05 14:02:50 +02:00
2016-01-18 19:45:27 +01:00
// Multicurrency
if ( ! empty ( $conf -> multicurrency -> enabled ))
{
print '<tr>' ;
print '<td>' . fieldLabel ( 'Currency' , 'multicurrency_code' ) . '</td>' ;
print '<td colspan="3" class="maxwidthonsmartphone">' ;
print $form -> selectMultiCurrency (( $object -> multicurrency_code ? $object -> multicurrency_code : $conf -> currency ), 'multicurrency_code' , 1 );
print '</td></tr>' ;
}
2011-06-22 12:58:22 +02:00
// Other attributes
2012-11-03 16:58:50 +01:00
$parameters = array ( 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' );
2012-02-06 17:18:19 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2015-07-18 17:35:36 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2011-06-22 12:58:22 +02:00
{
2013-04-01 19:43:26 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
2011-06-22 12:58:22 +02:00
}
2013-04-03 15:20:56 +02:00
2014-10-31 17:46:11 +01:00
// Webservices url/key
if ( ! empty ( $conf -> syncsupplierwebservices -> enabled )) {
2015-06-05 14:02:50 +02:00
print '<tr><td>' . fieldLabel ( 'WebServiceURL' , 'webservices_url' ) . '</td>' ;
2014-10-31 17:46:11 +01:00
print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="' . $object -> webservices_url . '"></td>' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'WebServiceKey' , 'webservices_key' ) . '</td>' ;
2014-10-31 17:46:11 +01:00
print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="' . $object -> webservices_key . '"></td></tr>' ;
}
2015-02-09 17:55:43 +01:00
// Incoterms
2015-02-10 12:21:29 +01:00
if ( ! empty ( $conf -> incoterm -> enabled ))
2015-02-09 17:55:43 +01:00
{
print '<tr>' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'IncotermLabel' , 'incoterm_id' ) . '</td>' ;
2015-02-09 17:55:43 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2015-02-10 10:22:38 +01:00
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
2011-06-11 16:14:27 +02:00
// Logo
2013-04-03 15:20:56 +02:00
print '<tr class="hideonsmartphone">' ;
2015-06-05 14:02:50 +02:00
print '<td>' . fieldLabel ( 'Logo' , 'photoinput' ) . '</td>' ;
2011-06-11 22:58:08 +02:00
print '<td colspan="3">' ;
2016-03-25 15:24:57 +01:00
if ( $object -> logo ) print $form -> showphoto ( 'societe' , $object );
2011-06-11 22:58:08 +02:00
$caneditfield = 1 ;
if ( $caneditfield )
{
2011-07-02 16:12:44 +02:00
if ( $object -> logo ) print " <br> \n " ;
2011-06-11 22:58:08 +02:00
print '<table class="nobordernopadding">' ;
2015-12-21 17:32:20 +01:00
if ( $object -> logo ) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> ' . $langs -> trans ( " Delete " ) . '<br><br></td></tr>' ;
2011-06-11 22:58:08 +02:00
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>' ;
print '</table>' ;
}
print '</td>' ;
2011-06-11 16:14:27 +02:00
print '</tr>' ;
print '</table>' ;
2017-05-23 01:32:19 +02:00
print '</div>' ;
2017-06-07 16:44:04 +02:00
2015-06-18 19:33:29 +02:00
dol_fiche_end ();
2011-06-11 16:14:27 +02:00
2014-11-24 06:43:15 +01:00
print '<div align="center">' ;
2011-06-11 16:14:27 +02:00
print '<input type="submit" class="button" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
2017-02-01 13:25:16 +01:00
print ' ' ;
2011-06-11 16:14:27 +02:00
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2014-11-24 06:43:15 +01:00
print '</div>' ;
2011-06-11 16:14:27 +02:00
print '</form>' ;
}
}
else
{
2017-09-03 17:47:45 +02:00
/*
2011-06-11 16:14:27 +02:00
* View
*/
2017-06-07 16:44:04 +02:00
2018-02-21 14:48:25 +01:00
if ( ! empty ( $object -> id )) $res = $object -> fetch_optionals ();
2011-08-09 11:13:08 +02: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
2011-07-02 16:12:44 +02:00
$head = societe_prepare_head ( $object );
2011-06-11 16:14:27 +02:00
2017-05-23 01:32:19 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " ThirdParty " ), - 1 , 'company' );
2011-06-11 16:14:27 +02:00
// Confirm delete third party
2013-08-01 04:20:08 +02:00
if ( $action == 'delete' || ( $conf -> use_javascript_ajax && empty ( $conf -> dol_use_jmobile )))
2011-06-11 16:14:27 +02:00
{
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id , $langs -> trans ( " DeleteACompany " ), $langs -> trans ( " ConfirmDeleteCompany " ), " confirm_delete " , '' , 0 , " action-delete " );
2011-06-11 16:14:27 +02:00
}
2015-06-05 15:15:05 +02:00
if ( $action == 'merge' )
{
$formquestion = array (
2015-05-10 12:43:21 +02:00
array (
2015-06-05 15:15:05 +02:00
'name' => 'soc_origin' ,
'label' => $langs -> trans ( 'MergeOriginThirdparty' ),
2015-05-10 12:43:21 +02:00
'type' => 'other' ,
2016-04-08 19:31:18 +02:00
'value' => $form -> select_company ( '' , 'soc_origin' , 's.rowid != ' . $object -> id , 'SelectThirdParty' , 0 , 0 , array (), 0 , 'minwidth200' )
2015-05-10 12:43:21 +02:00
)
);
2017-11-29 16:34:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id , $langs -> trans ( " MergeThirdparties " ), $langs -> trans ( " ConfirmMergeThirdparties " ), " confirm_merge " , $formquestion , 'no' , 1 , 250 );
2015-05-10 12:43:21 +02:00
}
2017-09-10 19:28:20 +02:00
dol_htmloutput_mesg ( is_numeric ( $error ) ? '' : $error , $errors , 'error' );
2011-06-11 16:14:27 +02:00
2017-07-01 14:18:09 +02: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
2016-02-13 03:38:56 +01:00
dol_banner_tab ( $object , 'socid' , $linkback , ( $user -> societe_id ? 0 : 1 ), 'rowid' , 'nom' );
2016-06-30 15:49:57 +02:00
2015-10-10 13:12:14 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2016-06-30 15:49:57 +02:00
2015-10-10 13:12:14 +02:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2011-06-11 16:14:27 +02:00
2015-10-25 23:32:49 +01:00
// Prospect/Customer
2016-04-01 16:15:07 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( 'ProspectCustomer' ) . '</td><td>' ;
2015-10-25 23:32:49 +01:00
print $object -> getLibCustProspStatut ();
print '</td></tr>' ;
2016-06-30 15:49:57 +02:00
2017-10-27 01:46:54 +02:00
// Supplier
2018-07-03 17:37:23 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) || ! empty ( $conf -> supplier_proposal -> enabled ))
2017-10-27 01:46:54 +02:00
{
print '<tr><td>' . $langs -> trans ( 'Supplier' ) . '</td><td>' ;
print yn ( $object -> fournisseur );
print '</td></tr>' ;
}
2016-06-30 15:49:57 +02:00
2015-10-25 23:32:49 +01:00
// Prefix
2011-06-11 16:14:27 +02:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) // Old not used prefix field
{
2015-10-10 01:51:12 +02:00
print '<tr><td>' . $langs -> trans ( 'Prefix' ) . '</td><td>' . $object -> prefix_comm . '</td>' ;
2011-12-07 15:06:29 +01:00
print $htmllogobar ; $htmllogobar = '' ;
2011-06-11 16:14:27 +02:00
print '</tr>' ;
}
2011-12-07 15:06:29 +01:00
// Customer code
2011-07-02 16:12:44 +02:00
if ( $object -> client )
2011-06-11 16:14:27 +02:00
{
print '<tr><td>' ;
2015-10-10 01:51:12 +02:00
print $langs -> trans ( 'CustomerCode' ) . '</td><td>' ;
2011-07-02 16:12:44 +02:00
print $object -> code_client ;
if ( $object -> check_codeclient () <> 0 ) print ' <font class="error">(' . $langs -> trans ( " WrongCustomerCode " ) . ')</font>' ;
2011-06-11 16:14:27 +02:00
print '</td>' ;
2011-12-07 15:06:29 +01:00
print $htmllogobar ; $htmllogobar = '' ;
2011-06-11 16:14:27 +02:00
print '</tr>' ;
}
2011-12-07 15:06:29 +01:00
// Supplier code
2012-07-23 22:04:06 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $object -> fournisseur && ! empty ( $user -> rights -> fournisseur -> lire ))
2011-06-11 16:14:27 +02:00
{
print '<tr><td>' ;
2015-10-10 01:51:12 +02:00
print $langs -> trans ( 'SupplierCode' ) . '</td><td>' ;
2011-07-02 16:12:44 +02:00
print $object -> code_fournisseur ;
if ( $object -> check_codefournisseur () <> 0 ) print ' <font class="error">(' . $langs -> trans ( " WrongSupplierCode " ) . ')</font>' ;
2011-06-11 16:14:27 +02:00
print '</td>' ;
2011-12-07 15:06:29 +01:00
print $htmllogobar ; $htmllogobar = '' ;
2011-06-11 16:14:27 +02:00
print '</tr>' ;
}
2011-12-07 15:06:29 +01:00
// Barcode
2012-09-09 16:31:00 +02:00
if ( ! empty ( $conf -> barcode -> enabled ))
2011-12-07 15:06:29 +01:00
{
2012-04-08 12:14:27 +02:00
print '<tr><td>' ;
2015-10-10 01:51:12 +02:00
print $langs -> trans ( 'Gencod' ) . '</td><td>' . $object -> barcode ;
2012-04-08 12:14:27 +02:00
print '</td>' ;
2016-03-25 15:53:44 +01:00
if ( $htmllogobar ) $htmllogobar .= $form -> showbarcode ( $object );
2015-10-10 01:51:12 +02:00
print $htmllogobar ;
$htmllogobar = '' ;
2012-04-08 12:14:27 +02:00
print '</tr>' ;
2011-12-07 15:06:29 +01:00
}
2012-04-05 20:33:40 +02:00
// Prof ids
$i = 1 ; $j = 0 ;
while ( $i <= 6 )
2011-06-11 16:14:27 +02:00
{
2012-04-05 20:33:40 +02:00
$idprof = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code );
if ( $idprof != '-' )
2011-06-11 16:14:27 +02:00
{
2015-10-10 01:51:12 +02:00
//if (($j % 2) == 0) print '<tr>';
print '<tr>' ;
print '<td>' . $idprof . '</td><td>' ;
2012-04-05 20:33:40 +02:00
$key = 'idprof' . $i ;
print $object -> $key ;
if ( $object -> $key )
{
if ( $object -> id_prof_check ( $i , $object ) > 0 ) print ' ' . $object -> id_prof_url ( $i , $object );
else print ' <font class="error">(' . $langs -> trans ( " ErrorWrongValue " ) . ')</font>' ;
}
print '</td>' ;
2015-10-10 01:51:12 +02:00
//if (($j % 2) == 1) print '</tr>';
print '</tr>' ;
2012-04-05 20:33:40 +02:00
$j ++ ;
2011-06-11 16:14:27 +02:00
}
2012-04-05 20:33:40 +02:00
$i ++ ;
2011-06-11 16:14:27 +02:00
}
2015-10-10 01:51:12 +02:00
//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
2018-03-15 14:25:09 +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
2018-03-15 14:25:09 +01:00
if ( $object -> fournisseur )
{
// 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>' ;
print '</tr>' ;
}
2017-06-07 16:44:04 +02:00
2016-10-24 12:42:37 +02:00
// Local Taxes
2018-03-15 14:25:09 +01:00
if ( $object -> fournisseur || $mysoc -> country_code == 'ES' )
{
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " )
{
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>' ;
if ( $object -> localtax1_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 1 )))
{
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="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<tr><td>' . $langs -> transcountry ( " TypeLocaltax1 " , $mysoc -> country_code ) . ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editRE&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
if ( $action == 'editRE' )
{
print '<td align="left">' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
}
else
{
print '<td>' . $object -> localtax1_value . '</td>' ;
}
print '</tr></form>' ;
}
if ( $object -> localtax2_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 2 )))
{
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="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<tr><td>' . $langs -> transcountry ( " TypeLocaltax2 " , $mysoc -> country_code ) . '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editIRPF&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
if ( $action == 'editIRPF' ){
print '<td align="left">' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
} else {
print '<td>' . $object -> localtax2_value . '</td>' ;
}
print '</tr></form>' ;
}
}
elseif ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj != " 1 " )
{
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax1_assuj );
print '</td></tr>' ;
if ( $object -> localtax1_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 1 )))
{
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="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<tr><td> ' . $langs -> transcountry ( " TypeLocaltax1 " , $mysoc -> country_code ) . '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editRE&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
if ( $action == 'editRE' ){
print '<td align="left">' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
} else {
print '<td>' . $object -> localtax1_value . '</td>' ;
}
print '</tr></form>' ;
}
}
elseif ( $mysoc -> localtax2_assuj == " 1 " && $mysoc -> localtax1_assuj != " 1 " )
{
print '<tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax2_assuj );
print '</td></tr>' ;
if ( $object -> localtax2_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 2 )))
{
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="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<tr><td> ' . $langs -> transcountry ( " TypeLocaltax2 " , $mysoc -> country_code ) . ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editIRPF&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</td>' ;
if ( $action == 'editIRPF' ){
print '<td align="left">' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '"></td>' ;
} else {
print '<td>' . $object -> localtax2_value . '</td>' ;
}
print '</tr></form>' ;
}
}
}
2017-06-07 16:44:04 +02:00
2011-06-11 16:14:27 +02:00
// VAT Code
2015-10-10 01:51:12 +02:00
print '<tr>' ;
print '<td class="nowrap">' . $langs -> trans ( 'VATIntra' ) . '</td><td>' ;
2011-07-02 16:12:44 +02:00
if ( $object -> tva_intra )
2011-06-11 16:14:27 +02:00
{
$s = '' ;
2011-07-02 16:12:44 +02:00
$s .= $object -> tva_intra ;
2016-09-21 03:54:54 +02: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
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ))
{
$s .= ' ' ;
if ( $conf -> use_javascript_ajax )
{
print " \n " ;
print '<script language="JavaScript" type="text/javascript">' ;
print " function CheckVAT(a) { \n " ;
print " newpopup(' " . DOL_URL_ROOT . " /societe/checkvat/checkVatPopup.php?vatNumber='+a,' " . dol_escape_js ( $langs -> trans ( " VATIntraCheckableOnEUSite " )) . " ',500,285); \n " ;
print " } \n " ;
print '</script>' ;
print " \n " ;
2013-04-03 15:20:56 +02:00
$s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
2016-03-25 15:24:57 +01:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> trans ( " VATIntraCheck " )), 1 );
2011-06-11 16:14:27 +02:00
}
else
{
2013-04-03 15:20:56 +02:00
$s .= '<a href="' . $langs -> transcountry ( " VATIntraCheckURL " , $object -> country_id ) . '" class="hideonsmartphone" target="_blank">' . img_picto ( $langs -> trans ( " VATIntraCheckableOnEUSite " ), 'help' ) . '</a>' ;
2011-06-11 16:14:27 +02:00
}
}
print $s ;
}
else
{
print ' ' ;
}
print '</td>' ;
print '</tr>' ;
2011-06-11 22:58:08 +02:00
// Type + Staff
$arr = $formcompany -> typent_array ( 1 );
2011-07-02 16:12:44 +02:00
$object -> typent = $arr [ $object -> typent_code ];
2015-10-10 01:51:12 +02:00
print '<tr><td>' . $langs -> trans ( " ThirdPartyType " ) . '</td><td>' . $object -> typent . '</td>' ;
print '<tr><td>' . $langs -> trans ( " Staff " ) . '</td><td>' . $object -> effectif . '</td></tr>' ;
2011-06-11 22:58:08 +02:00
2015-11-13 00:30:10 +01:00
print '</table>' ;
2016-06-30 15:49:57 +02:00
2015-11-13 00:30:10 +01:00
print '</div>' ;
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2016-06-30 15:49:57 +02:00
2015-11-13 00:30:10 +01:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2016-06-30 15:49:57 +02:00
2016-10-24 12:42:37 +02:00
// Tags / categories
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
{
// Customer
2018-05-03 09:26:48 +02:00
if ( $object -> prospect || $object -> client || ( ! $object -> fournisseur && ! empty ( $conf -> global -> THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER ))) {
2016-10-24 12:42:37 +02:00
print '<tr><td>' . $langs -> trans ( " CustomersCategoriesShort " ) . '</td>' ;
print '<td>' ;
print $form -> showCategories ( $object -> id , 'customer' , 1 );
print " </td></tr> " ;
}
// Supplier
if ( $object -> fournisseur ) {
print '<tr><td>' . $langs -> trans ( " SuppliersCategoriesShort " ) . '</td>' ;
print '<td>' ;
print $form -> showCategories ( $object -> id , 'supplier' , 1 );
print " </td></tr> " ;
}
}
2011-06-11 22:58:08 +02:00
// Legal
2016-07-21 06:25:25 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( 'JuridicalStatus' ) . '</td><td>' . $object -> forme_juridique . '</td></tr>' ;
2011-06-11 22:58:08 +02:00
2011-06-11 16:14:27 +02:00
// Capital
2015-10-10 01:51:12 +02:00
print '<tr><td>' . $langs -> trans ( 'Capital' ) . '</td><td>' ;
2013-12-14 17:40:23 +01:00
if ( $object -> capital ) print price ( $object -> capital , '' , $langs , 0 , - 1 , - 1 , $conf -> currency );
2011-06-11 16:14:27 +02:00
else print ' ' ;
2011-05-06 00:19:21 +02:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
// Default language
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2011-06-11 16:14:27 +02:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2015-10-10 01:51:12 +02:00
print '<tr><td>' . $langs -> trans ( " DefaultLang " ) . '</td><td>' ;
2011-07-02 16:12:44 +02:00
//$s=picto_from_langcode($object->default_lang);
2011-06-11 16:14:27 +02:00
//print ($s?$s.' ':'');
$langs -> load ( " languages " );
2011-07-02 16:12:44 +02:00
$labellang = ( $object -> default_lang ? $langs -> trans ( 'Language_' . $object -> default_lang ) : '' );
2011-06-11 16:14:27 +02:00
print $labellang ;
print '</td></tr>' ;
}
2015-02-09 17:55:43 +01:00
// Incoterms
2015-02-10 12:21:29 +01:00
if ( ! empty ( $conf -> incoterm -> enabled ))
2015-03-14 13:05:28 +01:00
{
2015-02-09 17:55:43 +01:00
print '<tr><td>' ;
print '<table width="100%" class="nobordernopadding"><tr><td>' ;
print $langs -> trans ( 'IncotermLabel' );
print '<td><td align="right">' ;
2017-03-20 20:58:43 +01:00
if ( $user -> rights -> societe -> creer ) print '<a href="' . DOL_URL_ROOT . '/societe/card.php?socid=' . $object -> id . '&action=editincoterm">' . img_edit ( '' , 1 ) . '</a>' ;
2015-02-09 17:55:43 +01:00
else print ' ' ;
print '</td></tr></table>' ;
print '</td>' ;
print '<td colspan="3">' ;
2015-02-10 10:22:38 +01:00
if ( $action != 'editincoterm' )
{
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( $object -> display_incoterms (), $object -> libelle_incoterms , 1 );
2015-02-10 10:22:38 +01:00
}
2015-03-14 13:05:28 +01:00
else
2015-02-10 10:22:38 +01:00
{
print $form -> select_incoterms (( ! empty ( $object -> fk_incoterms ) ? $object -> fk_incoterms : '' ), ( ! empty ( $object -> location_incoterms ) ? $object -> location_incoterms : '' ), $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id );
}
2015-02-09 17:55:43 +01:00
print '</td></tr>' ;
}
2016-01-18 19:45:27 +01:00
// Multicurrency
if ( ! empty ( $conf -> multicurrency -> enabled ))
{
print '<tr>' ;
print '<td>' . fieldLabel ( 'Currency' , 'multicurrency_code' ) . '</td>' ;
print '<td>' ;
print ! empty ( $object -> multicurrency_code ) ? currency_name ( $object -> multicurrency_code , 1 ) : '' ;
print '</td></tr>' ;
}
2016-06-30 15:49:57 +02:00
2017-06-07 16:44:04 +02:00
// Other attributes
$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
2011-06-11 16:14:27 +02:00
// Parent company
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PARENTCOMPANY ))
{
2013-06-05 16:24:32 +02:00
// Payment term
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'ParentCompany' );
print '</td>' ;
if ( $action != 'editparentcompany' ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editparentcompany&socid=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $action == 'editparentcompany' )
{
$form -> form_thirdparty ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> parent , 'editparentcompany' , 's.rowid <> ' . $object -> id , 1 );
}
else
{
$form -> form_thirdparty ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> parent , 'none' , 's.rowid <> ' . $object -> id , 1 );
}
print '</td>' ;
print '</tr>' ;
2011-06-11 16:14:27 +02:00
}
2012-06-23 20:39:20 +02:00
// Sales representative
2012-08-23 02:04:35 +02:00
include DOL_DOCUMENT_ROOT . '/societe/tpl/linesalesrepresentative.tpl.php' ;
2011-06-11 16:14:27 +02:00
// Module Adherent
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> adherent -> enabled ))
2011-06-11 16:14:27 +02:00
{
$langs -> load ( " members " );
2017-03-31 14:21:51 +02:00
print '<tr><td>' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
2011-06-11 16:14:27 +02:00
print '<td colspan="3">' ;
$adh = new Adherent ( $db );
2011-07-02 16:12:44 +02:00
$result = $adh -> fetch ( '' , '' , $object -> id );
2011-06-11 16:14:27 +02:00
if ( $result > 0 )
{
$adh -> ref = $adh -> getFullName ( $langs );
print $adh -> getNomUrl ( 1 );
}
else
{
2017-03-31 14:21:51 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " ThirdpartyNotLinkedToMember " ) . '</span>' ;
2011-06-11 16:14:27 +02:00
}
print '</td>' ;
print " </tr> \n " ;
}
2014-10-31 17:46:11 +01: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>' ;
}
2011-06-11 16:14:27 +02:00
print '</table>' ;
2015-10-11 12:27:04 +02:00
print '</div>' ;
2016-06-30 15:49:57 +02:00
2015-10-11 12:27:04 +02:00
print '</div></div>' ;
2015-10-10 13:12:14 +02:00
print '<div style="clear:both"></div>' ;
2016-06-30 15:49:57 +02:00
2011-06-11 16:14:27 +02:00
dol_fiche_end ();
/*
* Actions
*/
2017-09-27 19:56:03 +02:00
if ( $action != 'presend' )
{
print '<div class="tabsAction">' . " \n " ;
2011-06-11 16:14:27 +02:00
2017-09-27 19:56:03 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook ))
2016-03-04 12:21:14 +01:00
{
2017-09-27 19:56:03 +02:00
$at_least_one_email_contact = false ;
$TContact = $object -> contact_array_objects ();
foreach ( $TContact as & $contact )
2016-03-04 12:21:14 +01:00
{
2017-09-27 19:56:03 +02:00
if ( ! empty ( $contact -> email ))
{
$at_least_one_email_contact = true ;
break ;
}
2016-03-04 12:21:14 +01:00
}
2016-06-30 15:49:57 +02:00
2017-09-27 19:56:03 +02:00
if ( ! empty ( $object -> email ) || $at_least_one_email_contact )
{
$langs -> load ( " mails " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '&action=presend&mode=init#formmailbeforetitle">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
}
else
{
$langs -> load ( " mails " );
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " NoEMail " )) . '">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
}
2014-02-10 00:24:20 +01:00
2017-09-27 19:56:03 +02:00
if ( $user -> rights -> societe -> creer )
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&action=edit">' . $langs -> trans ( " Modify " ) . '</a></div>' . " \n " ;
}
2014-02-10 00:24:20 +01:00
2017-09-27 19:56:03 +02:00
if ( $user -> rights -> societe -> supprimer )
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=merge&socid=' . $object -> id . '" title="' . dol_escape_htmltag ( $langs -> trans ( " MergeThirdparties " )) . '">' . $langs -> trans ( 'Merge' ) . '</a></div>' ;
}
2015-05-22 12:21:36 +02:00
2017-09-27 19:56:03 +02:00
if ( $user -> rights -> societe -> supprimer )
{
if ( $conf -> use_javascript_ajax && empty ( $conf -> dol_use_jmobile )) // We can't use preloaded confirm form with jmobile
{
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">' . $langs -> trans ( 'Delete' ) . '</span></div>' . " \n " ;
}
else
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&action=delete">' . $langs -> trans ( 'Delete' ) . '</a></div>' . " \n " ;
}
}
}
2014-02-10 00:24:20 +01:00
2017-09-27 19:56:03 +02:00
print '</div>' . " \n " ;
}
2011-06-11 16:14:27 +02:00
2015-04-18 11:06:53 +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
2017-09-27 19:56:03 +02:00
if ( $action != 'presend' )
2013-09-23 13:17:31 +02:00
{
2017-09-27 19:56:03 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02: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
2013-09-23 13:17:31 +02:00
/*
* Documents generes
*/
$filedir = $conf -> societe -> multidir_output [ $object -> entity ] . '/' . $object -> id ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?socid= " . $object -> id ;
2017-10-18 17:21:30 +02:00
$genallowed = $user -> rights -> societe -> lire ;
$delallowed = $user -> rights -> societe -> creer ;
2013-09-25 21:36:40 +02:00
2017-01-25 09:26:26 +01:00
print $formfile -> showdocuments ( 'company' , $object -> id , $filedir , $urlsource , $genallowed , $delallowed , $object -> modelpdf , 0 , 0 , 0 , 28 , 0 , 'entity=' . $object -> entity , 0 , '' , $object -> default_lang );
2013-09-23 13:17:31 +02:00
}
2013-09-25 21:36:40 +02:00
2018-01-10 12:38:27 +01:00
// Subsidiaries list
if ( empty ( $conf -> global -> SOCIETE_DISABLE_SUBSIDIARIES ))
{
$result = show_subsidiaries ( $conf , $langs , $db , $object );
}
2013-09-25 21:36:40 +02:00
2017-09-27 19:56:03 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
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
2017-10-04 12:58:13 +02:00
$morehtmlright = '<a href="' . DOL_URL_ROOT . '/societe/agenda.php?socid=' . $object -> id . '">' ;
$morehtmlright .= $langs -> trans ( " SeeAll " );
$morehtmlright .= '</a>' ;
2013-09-25 21:36:40 +02:00
2017-09-27 19:56:03 +02:00
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
2017-11-26 20:21:01 +01:00
$somethingshown = $formactions -> showactions ( $object , '' , $socid , 1 , '' , $MAXEVENT , '' , $morehtmlright ); // Show all action for thirdparty
2013-09-25 21:36:40 +02:00
2017-09-27 19:56:03 +02:00
print '</div></div></div>' ;
2017-06-07 16:44:04 +02:00
2018-01-11 01:06:50 +01:00
if ( ! empty ( $conf -> global -> MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD ))
2018-01-10 12:38:27 +01:00
{
// Contacts list
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS ))
{
$result = show_contacts ( $conf , $langs , $db , $object , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id );
}
2013-09-25 21:36:40 +02:00
2018-01-10 12:38:27 +01:00
// Addresses list
if ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ))
{
$result = show_addresses ( $conf , $langs , $db , $object , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id );
}
}
2013-09-23 13:17:31 +02:00
}
2017-09-27 19:56:03 +02:00
// Presend form
$modelmail = 'thirdparty' ;
$defaulttopic = 'Information' ;
$diroutput = $conf -> societe -> dir_output ;
$trackid = 'thi' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/card_presend.tpl.php' ;
2011-06-11 16:14:27 +02:00
}
2002-04-30 12:51:35 +02:00
}
2010-09-02 21:41:49 +02: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 ();